/** * Message delivery logic extracted from wait-tool.ts (Phase 4). * * Handles: * - Simple message processing (photo, document, text, sticker) * - Auto-ingesting episodes for messages not saved by media handlers * - Smart context injection (embedding search + GPT-4o-mini filter) * - Intent classification and final operator response assembly */ import type { StoredMessage } from "../../services/dispatcher/index.js"; import { type MessageIntent } from "../../services/intent.js"; import { type initMemoryDb } from "../../data/memory/index.js"; import type { TelegramClient } from "../../services/telegram.js"; import type { ContentBlock, ToolResult } from "../../lib/types.js"; interface MessageDeliveryContext { telegram: TelegramClient; getMemoryDb: () => ReturnType; effectiveThreadId: number; sessionStartedAt: number; autonomousMode: boolean; } /** * Render the operator's quoted excerpt as a compact single-line prefix so the * agent knows WHICH part of its own message is being replied to. * * The excerpt is a pointer, not content to reason over: internal whitespace is * collapsed and anything past MAX_QUOTE_CHARS is truncated so a quoted wall of * text can't crowd out the operator's actual message. Returns undefined when * the excerpt is blank, so the caller emits no block at all. */ export declare function formatQuotePrefix(quote: string): string | undefined; /** * Process non-media message types for a single StoredMessage. * Handles: photo, document, text, sticker. * Returns content blocks for the processed parts. */ export declare function processSimpleMessage(msg: StoredMessage, telegram: TelegramClient): Promise; /** * If contentBlocks is empty after processing all messages, push an * unsupported-type placeholder and log the message fields for debugging. */ export declare function handleEmptyContent(contentBlocks: ContentBlock[], stored: StoredMessage[]): void; /** * Auto-ingest episodes for messages that were not already saved by * voice/video handlers (identified by savedEpisodeUpdateIds). */ export declare function autoIngestEpisodes(stored: StoredMessage[], savedEpisodeUpdateIds: Set, ctx: Pick): void; /** * Smart context injection: retrieves candidate memory notes via embedding * search, then uses GPT-4o-mini to select ONLY the notes truly relevant * to the operator's message. Falls back to keyword search if embedding * fails, and to raw top-3 if the LLM filter fails. */ export declare function buildSmartContext(operatorText: string, ctx: Pick): Promise; /** * Build the final operator message response: intent classification, * reminder selection, and the `<<< OPERATOR MESSAGE >>>` envelope. */ export declare function assembleOperatorResponse(contentBlocks: ContentBlock[], operatorText: string, hasVoiceMessages: boolean, autoMemoryContext: string, ctx: Pick, intent?: MessageIntent): ToolResult; export {}; //# sourceMappingURL=message-delivery.d.ts.map