/** * Tapal Mail Adapter contract. * * Every mail-client adapter (Apple Mail today; Outlook + Thunderbird later) * implements this interface. The MCP server consumes adapters through this * contract so a single tool surface can target multiple mail clients. * * v0.1 scope: this interface establishes the shape. The MCP server in v0.1 * still imports the flat function API directly from the Apple Mail adapter * (for minimal churn during the rename / restructure). A subsequent sprint * will refactor the server to consume adapters through this interface and * pick the right adapter at runtime via env var or auto-detection. * * @module adapter */ import type { MailAccount, MailMessage, MailMessageSummary, PaginatedResult } from "./types.js"; /** What an adapter can and cannot do. The server uses this to decide whether * to expose a given MCP tool for the active adapter. */ export interface AdapterCapabilities { /** Adapter exposes multiple configured accounts (true for Apple Mail; may be false for single-account IMAP adapters). */ multiAccount: boolean; /** Compose supports rich HTML body. */ htmlCompose: boolean; /** Compose supports file attachments. */ attachments: boolean; /** Adapter can detect and parse calendar invites (.ics). */ calendarInvites: boolean; /** Adapter exposes message threads / conversations. */ threading: boolean; /** Adapter pushes search to the mail client (vs client-side scan). */ serverSideSearch: boolean; /** Adapter can flag / star messages. */ flags: boolean; /** Adapter can move messages between mailboxes. */ move: boolean; /** Adapter can permanently delete messages (vs only move-to-trash). */ permanentDelete: boolean; } export interface ListMessagesOptions { account: string; mailbox?: string; limit?: number; offset?: number; unreadOnly?: boolean; flaggedOnly?: boolean; fromFilter?: string; subjectFilter?: string; } export interface ReadMessageOptions { account: string; mailbox?: string; messageId?: string; index?: number; maxBody?: number; } export interface SearchOptions { query: string; accounts?: string; field?: "subject" | "sender" | "recipient" | "all"; mailbox?: string; limit?: number; offset?: number; from?: string; subject?: string; before?: string; after?: string; excludeSender?: string; excludeSubject?: string; unreadOnly?: boolean; } export interface CountOptions { account: string; mailbox?: string; } export interface CountResult { total: number; unread: number; flagged: number; } export interface MoveMessageOptions { account: string; mailbox?: string; messageId: string; destMailbox: string; destAccount?: string; } export interface MarkReadOptions { messageId?: string; all?: boolean; unread?: boolean; mailbox?: string; } export type BatchAction = "move" | "delete" | "archive" | "flag" | "unflag" | "mark-read" | "mark-unread"; export interface BatchOptions { account: string; mailbox?: string; messageIds: string[]; action: BatchAction; destMailbox?: string; destAccount?: string; } export interface BatchResult { action: string; processed: number; failed: number; total: number; } export type TrashAction = "empty" | "delete" | "restore"; export interface TrashOptions { account: string; action: TrashAction; messageIds?: string[]; olderThanDays?: number; } export interface TrashResult { action: string; processed: number; } export type ComposeMode = "open" | "send" | "draft"; export interface ComposeOptions { from: string; to: string | string[]; subject: string; body: string; cc?: string | string[]; bcc?: string | string[]; html?: string; attachments?: string[]; mode?: ComposeMode; } export interface ReplyOptions { account: string; mailbox?: string; messageId: string; body: string; replyAll?: boolean; mode?: ComposeMode; } export interface ForwardOptions { account: string; mailbox?: string; messageId: string; to: string | string[]; body?: string; mode?: ComposeMode; } export interface ComposeResult { created: boolean; subject: string; mode: ComposeMode; recipients?: { to: number; cc: number; bcc: number; }; note: string; } /** * Provider-agnostic mail operations. Implemented by each adapter. * * v0.1: only the Apple Mail adapter exists. The interface is forward-looking * and intentionally keeps a flat method shape so adapters that wrap remote * APIs (Outlook Graph, JMAP) can map cleanly. */ export interface MailAdapter { /** Stable identifier — `"apple-mail"`, `"outlook"`, `"thunderbird"`, etc. */ readonly id: string; /** What this adapter supports. The server may hide tools whose capability is `false`. */ readonly capabilities: AdapterCapabilities; discoverAccounts(): Promise; listMessages(options: ListMessagesOptions): Promise>; readMessage(options: ReadMessageOptions): Promise; searchMessages(options: SearchOptions): Promise>; countMessages(options: CountOptions): Promise; composeMail(options: ComposeOptions): Promise; replyToMail(options: ReplyOptions): Promise; forwardMail(options: ForwardOptions): Promise; moveMessage(options: MoveMessageOptions): Promise<{ subject: string; moved: boolean; }>; flagMessage(account: string, messageId: string, mailbox?: string, unflag?: boolean): Promise<{ subject: string; flagged: boolean; }>; markRead(account: string, options: MarkReadOptions): Promise<{ count: number; read: boolean; }>; batchOperate(options: BatchOptions): Promise; manageTrash(options: TrashOptions): Promise; } //# sourceMappingURL=adapter.d.ts.map