export interface EmailAccountConfig { name?: string; enabled?: boolean; email?: string; password?: string; imapHost?: string; imapPort?: number; smtpHost?: string; smtpPort?: number; allowFrom?: string[]; dmPolicy?: string; replyMode?: string; replyTo?: ReplyTo; transport?: "imap" | "ws" | "im"; mailCliProfile?: string; token?: string; apiKey?: string; } /** * Email channel configuration * * Mirrors TelegramConfig / SlackConfig pattern exactly. * `enabled` and `name` are inherited from EmailAccountConfig but have different * semantics at this level: `enabled` is the channel-level switch (not per-account), * `name` is not meaningful at the top level. Both are stripped before account merge. */ export interface EmailConfig extends EmailAccountConfig { enabled?: boolean; accounts?: Record; /** Agent-to-agent collaboration configuration */ a2a?: A2AConfig; } /** * Default reply recipient mode when no tag is present * - all: Reply to original sender + all To recipients (excluding self) — default * - sender: Reply to original sender only */ export type ReplyTo = 'sender' | 'all'; /** * Email reply delivery strategy * - immediate: Send email for each streaming block (multiple emails) * - accumulated: Buffer all blocks, send as one email when complete * - complete: Only send final payload, ignore streaming blocks (default) */ export type ReplyMode = "immediate" | "accumulated" | "complete"; /** * Resolved email account with defaults applied */ export interface ResolvedEmailAccount { /** Account identifier */ accountId: string; /** Account name (optional) */ name?: string; /** Is enabled */ enabled: boolean; /** Is configured */ configured: boolean; /** Email address */ email: string; /** Email password */ password: string; /** IMAP host */ imapHost: string; /** IMAP port */ imapPort: number; /** SMTP host */ smtpHost: string; /** SMTP port */ smtpPort: number; /** Allowed senders */ allowFrom: string[]; /** Reply delivery mode */ replyMode: ReplyMode; /** Default reply recipient mode */ replyTo: ReplyTo; /** Raw config object */ config: EmailAccountConfig; } /** * Resolved WS transport account (via @clawemail/node-sdk WebSocket) */ export interface ResolvedWsAccount { transport: "ws"; accountId: string; email: string; apiKey: string; token?: string; allowFrom: string[]; replyMode: ReplyMode; replyTo: ReplyTo; name?: string; enabled: boolean; configured: boolean; config: EmailAccountConfig; } /** * Parsed email message */ export interface ParsedEmail { /** Sender email address */ from: string; /** Recipient email addresses */ to: string[]; /** CC recipients */ cc: string[]; /** BCC recipients (only visible to sender) */ bcc: string[]; /** Email subject */ subject: string; /** Message-ID header */ messageId: string; /** References header for thread tracking */ references: string[]; /** In-Reply-To header */ inReplyTo: string | null; /** Thread root ID */ threadId: string; /** Plain text content */ textPlain?: string; /** HTML content converted to Markdown */ textMarkdown?: string; /** Raw HTML content (before markdown conversion) */ html?: string; /** Parsed attachments */ attachments: ParsedAttachment[]; /** Attachment local paths (after saving to disk) */ attachmentPaths: string[]; /** Email timestamp */ timestamp: number; /** IMAP UID */ uid: number; /** Original mailId string (CLI transport: mailId from IM notification); undefined for IMAP */ mailId?: string; /** Raw email headers (lowercase keys) */ headers?: Record; } /** * Parsed email attachment */ export interface ParsedAttachment { /** Attachment filename */ filename: string; /** Content type */ contentType: string; /** Size in bytes */ size: number; /** Local path after download */ path?: string; /** Content buffer (for small files) */ buffer?: Buffer; } /** * Agent-to-agent collaboration configuration */ export interface A2AConfig { /** Enable agent-to-agent communication (default: true) */ enabled?: boolean; /** Domains that host agents (e.g., ["agents.example.com"]) */ agentDomains?: string[]; /** Maximum ping-pong turns (default: 20, max: 20) */ maxPingPongTurns?: number; } /** * Agent-to-agent message context */ export interface A2AContext { /** Remote agent ID */ remoteAgentId: string; /** Current turn number */ currentTurn: number; /** Maximum allowed turns */ maxTurns: number; } /** * UID store for tracking processed emails */ export interface UidStore { /** Last processed UID */ lastUid: number | null; /** Last update timestamp */ lastUpdateAt: number; } /** * Email send result */ export interface EmailSendResult { /** Channel identifier */ channel: "email"; /** Message-ID from SMTP server */ messageId?: string; /** Success status */ ok: boolean; /** Error message if failed */ error?: string; } /** * IMAP client options */ export interface ImapClientOptions { /** IMAP server host */ host: string; /** IMAP port */ port: number; /** Username (email address) */ user: string; /** Password */ password: string; /** Use TLS */ tls: boolean; } /** * SMTP client options */ export interface SmtpClientOptions { /** SMTP server host */ host: string; /** SMTP port */ port: number; /** Use SSL */ ssl?: boolean; /** Username */ user: string; /** Password */ password: string; } /** * Monitoring options */ export interface MonitorOptions { /** Account ID */ accountId: string; /** OpenClaw config */ config: unknown; /** Runtime environment */ runtime: RuntimeEnv; /** Abort signal */ abortSignal: AbortSignal; } /** * Runtime environment */ export interface RuntimeEnv { /** Log function */ log?: (...args: unknown[]) => void; /** Error log function */ error?: (...args: unknown[]) => void; /** Info log function */ info?: (...args: unknown[]) => void; /** Warn log function */ warn?: (...args: unknown[]) => void; }