import type { ColineReference } from "../manifest/reference"; export interface ColineTask { id: string; taskboardId: string; title: string; description: string; statusId: string; priority: "none" | "low" | "medium" | "high" | "urgent"; dueDate: string | null; assigneeUserIds: string[]; } export interface ColineTaskInput { title: string; description?: string; statusId?: string; priority?: ColineTask["priority"]; dueDate?: string | null; assigneeUserIds?: string[]; } export interface ColineCalendarEvent { id: string; title: string; description: string | null; location: string | null; startsAt: string; endsAt: string; timeZone: string; isAllDay: boolean; } export interface ColineCalendarEventInput { title: string; description?: string; location?: string; calendarId?: string; startsAt: string; endsAt: string; timeZone: string; isAllDay?: boolean; attendeeUserIds?: string[]; } export interface ColineConversation { type: "channel" | "dm" | "event" | "task"; id: string; } export interface ColineMessage { id: string; text: string; createdAt: string; authorUserId: string | null; } /** These capabilities operate on existing Coline objects under the invoking user's ACLs. */ export interface ColineWorkspaceCapabilities { tasks: { list(input: { taskboardId: string; query?: string; limit?: number; cursor?: string; }): Promise<{ tasks: ColineTask[]; nextCursor: string | null }>; get(taskboardId: string, taskId: string): Promise; create(taskboardId: string, input: ColineTaskInput): Promise; update( taskboardId: string, taskId: string, input: Partial, ): Promise; delete(taskboardId: string, taskId: string): Promise; board( taskboardId: string, ): Promise<{ id: string; statuses: Array<{ id: string; name: string }> }>; }; calendar: { list(input: { start: string; end: string }): Promise<{ events: ColineCalendarEvent[] }>; get(eventId: string): Promise; create(input: ColineCalendarEventInput): Promise; update(eventId: string, input: Partial): Promise; delete(eventId: string): Promise; }; /** Task/event conversations are also the canonical shared comment threads. */ messages: { list(input: { conversation: ColineConversation; limit?: number; cursor?: string; }): Promise<{ messages: ColineMessage[]; nextCursor: string | null }>; send(input: { conversation: ColineConversation; text: string; replyToMessageId?: string; }): Promise; }; references: { resolve( reference: ColineReference, ): Promise<{ reference: ColineReference; title: string; href: string | null }>; }; } /** Shared transport mapping, used by both HTTP and the iframe bridge. */ export function createWorkspaceCapabilities( call: (operation: string, args: unknown[]) => Promise, ): ColineWorkspaceCapabilities { return { tasks: { list: (input) => call("tasks.list", [input]), board: (id) => call("tasks.board", [id]), get: (board, id) => call("tasks.get", [board, id]), create: (board, input) => call("tasks.create", [board, input]), update: (board, id, input) => call("tasks.update", [board, id, input]), delete: (board, id) => call("tasks.delete", [board, id]), }, calendar: { list: (input) => call("calendar.list", [input]), get: (id) => call("calendar.get", [id]), create: (input) => call("calendar.create", [input]), update: (id, input) => call("calendar.update", [id, input]), delete: (id) => call("calendar.delete", [id]), }, messages: { list: (input) => call("messages.list", [input]), send: (input) => call("messages.send", [input]), }, references: { resolve: (reference) => call("references.resolve", [reference]) }, }; }