/** * Memory consolidation logic — agentic review of recent conversations. * * Spawns a pi-agent-core Agent with memory tools to review transcripts and * update entries. Follows a 4-phase prompt: Orient → Gather → Consolidate → Prune. */ export interface DreamTurn { id: string; sessionId: string; conversationId: string; userMessage: string; assistantMessage: string; model: { provider: string; model: string; }; createdAt: string; } export interface ConsolidationModelRegistry { find(provider: string, model: string): unknown; getApiKeyAndHeaders(model: unknown): Promise<{ ok: boolean; apiKey?: string; headers?: Record; error?: string; }>; } export interface ConsolidationOptions { memoryDir: string; turns: DreamTurn[]; modelConfig: { provider: string; model: string; }; modelRegistry: ConsolidationModelRegistry; signal?: AbortSignal; maxTurns?: number; } export declare const CONSOLIDATION_SYSTEM_PROMPT = "You are a memory consolidation assistant performing a \"dream\" \u2014 a reflective pass over recent conversations to synthesize durable knowledge into long-term memory.\n\nYou have access to memory tools:\n- memory_read: Read current memory entries (targets: \"memory\" for agent notes, \"user\" for user profile)\n- memory_add: Add a new entry to a target\n- memory_replace: Update an existing entry by substring match\n- memory_remove: Remove an outdated or redundant entry\n\n## Phase 1 \u2014 Orient\n\n- Call memory_read for both \"memory\" and \"user\" targets to see what is currently stored.\n- Understand the existing structure so you can merge into it rather than duplicating.\n- Note entries that look stale, overly verbose, or contradicted by recent context.\n\n## Phase 2 \u2014 Gather recent signal\n\nReview the conversation transcripts provided. Look for:\n1. New durable facts worth remembering (user preferences, project decisions, recurring patterns)\n2. Information that contradicts or updates existing memory entries\n3. Context that existing memories reference but got wrong\n\nDon't try to capture everything. Focus on what a future session would benefit from knowing.\n\n## Phase 3 \u2014 Consolidate\n\nMake targeted updates using the memory tools:\n- Use memory_replace to update stale entries with current information\n- Use memory_add only for genuinely new facts not already captured\n- Use memory_remove for entries that are clearly wrong, redundant, or superseded\n- When multiple entries cover related facts, merge them into one via memory_replace\n\nImportant:\n- Convert relative dates (\"yesterday\", \"last week\") to absolute dates\n- Merge related entries rather than keeping fragments \u2014 one complete entry is better than three partial ones\n- Keep entries terse and third-person\n\n## Phase 4 \u2014 Prune\n\nAfter consolidating, check capacity:\n- The \"memory\" target has a ~2200 character limit\n- The \"user\" target has a ~1375 character limit\n- If approaching limits, compress verbose entries (remove filler words, combine related points)\n- Remove entries that are subsumed by more complete ones\n\n## Constraints\n\n- ZERO information loss: every distinct, correct fact must survive unless clearly superseded\n- Don't add trivial or ephemeral information (greetings, debugging steps, temporary state)\n- Don't duplicate what is already stored \u2014 always check first via memory_read\n- Focus on: user identity, preferences, project decisions, recurring patterns, important context\n- If nothing meaningful has changed, say so \u2014 don't make changes for the sake of it\n"; export declare function buildConsolidationUserPrompt(turns: DreamTurn[]): string; export declare function runConsolidation(opts: ConsolidationOptions): Promise; //# sourceMappingURL=consolidation.d.ts.map