import type { ReplyMode } from "../types.js"; import type { EmailLogger } from "../utils/logger.js"; export interface EmailGroup { to: string[]; cc: string[]; subject?: string; textBlocks: string[]; attachments: string[]; } interface ParsedEmailReply { to: string[]; cc: string[]; subject?: string; attachments: string[]; cleanText: string; } /** * Parse email reply tags from text (AI response or user email body) * Supports: , , , * Tolerant parsing: allows whitespace variations */ export declare function parseEmailReplyTags(text: string): ParsedEmailReply; /** * Compute a stable group key from to + cc addresses. */ export declare function buildGroupKey(to: string[], cc: string[], email: { from: string; to: string[]; cc: string[]; }, myEmail: string): string; export interface ReplyModeDispatcherOptions { replyMode: ReplyMode; email: { from: string; to: string[]; cc: string[]; subject: string; }; myEmail: string; log: EmailLogger; /** immediate / complete mode: send single text */ sendOnce: (text: string) => Promise; /** accumulated mode: send a collected group */ sendGroup: (group: EmailGroup) => Promise; /** * Optional: return true if the text is a stop token (e.g. REPLY_SKIP). * When true, sending is suppressed and the reply chain is terminated. */ isStopToken?: (text: string) => boolean; } export interface ReplyModeDispatcher { /** Pass as dispatcherOptions.deliver */ deliver: (payload: any, context?: { kind?: string; }) => Promise; /** Call after dispatch completes: sends accumulated groups or complete fallback */ flush: () => Promise; } /** * Create a reply-mode dispatcher that encapsulates the state machine for * immediate / accumulated / complete delivery modes. */ export declare function createReplyModeDispatcher(opts: ReplyModeDispatcherOptions): ReplyModeDispatcher; export {};