/** * Context Window Module * * Shared logic for building context windows around messages. * Used by both the classifier (for AI context) and deduplication * (to check if agreements fall within a suggestion's context). * * Rules: * - Minimum 280 chars before and 280 chars after * - Minimum 2 messages on each side * - Messages are already chunked at parse time (≤280 chars each), no truncation needed * - Snaps to message boundaries * - Messages include timestamps in WhatsApp format so AI understands time gaps */ import type { CandidateMessage, ContextMessage, ParsedMessage } from '../types'; export declare const MIN_CONTEXT_MESSAGES = 2; export interface MessageContext { /** Context messages before target */ readonly before: readonly ContextMessage[]; /** Context messages after target */ readonly after: readonly ContextMessage[]; /** First message ID in context window (before target) */ readonly firstMessageId: number; /** Last message ID in context window (after target) */ readonly lastMessageId: number; /** The target message ID */ readonly targetMessageId: number; } /** * Get context around a message. * * Rules: * - Minimum 280 chars before and 280 chars after * - Minimum 2 messages on each side * - Each message truncated to max 280 chars with "[truncated to 280 chars]" suffix * - For prior context: snap to message boundaries, then truncate * * Returns both the formatted context strings AND the message counts/IDs * for use in deduplication. */ export declare function getMessageContext(messages: readonly ParsedMessage[], index: number): MessageContext; /** * Check if a message ID falls within a context window. */ export declare function isInContextWindow(messageId: number, ctx: MessageContext): boolean; /** * Deduplicate agreement candidates that fall within a suggestion's context window. * * When an agreement (like "That looks amazing!") appears in the context window * of a suggestion (like "Let's do a whale safari!"), the agreement is redundant * because the classifier will see both in the same context. Keep only the suggestion. * * Uses the same context window logic as the classifier (280 chars / 2 messages minimum). */ export declare function deduplicateAgreements(candidates: readonly CandidateMessage[], messages: readonly ParsedMessage[]): { candidates: CandidateMessage[]; removedCount: number; }; //# sourceMappingURL=context-window.d.ts.map