import type { OneShotOrchestrator } from '../execution/one-shot-llm.js'; import type { AfterRunHook, AgentExtension } from '../extension/extension-points.js'; import type { MemoryStore } from '../types/memory.js'; import type { Provider } from '../types/provider.js'; /** * Minimal interface for writing to SAGE without importing * @wrongstack/sage (core cannot depend on sage). * Tools like the consolidator use this to route adds through * rememberSage rather than the legacy MemoryStore.remember(), * making them visible to searchSage/turn-middleware. */ type ConsolidatorSageKind = 'fact' | 'decision' | 'convention' | 'preference' | 'anti_pattern' | 'warning' | 'workflow' | 'bug_root_cause' | 'file_note' | 'symbol_note' | 'command_note'; interface ConsolidatorMemoryAnchor { type: 'file' | 'directory' | 'symbol' | 'package' | 'command' | 'test' | 'git'; path?: string | undefined; symbol?: string | undefined; command?: string | undefined; } export interface ConsolidatorSage { rememberSage(input: { text: string; scope?: string | undefined; kind?: ConsolidatorSageKind | undefined; tags?: string[] | undefined; priority?: string | undefined; importance?: number | undefined; confidence?: number | undefined; persistence?: 'long_lived' | undefined; anchors?: ConsolidatorMemoryAnchor[] | undefined; sources?: Array<{ type: string; sessionId?: string | undefined; }> | undefined; }): Promise; listSage?(statuses?: Array<'active'>): Promise; searchSage?(query: string, opts?: { limit?: number; scope?: 'project'; includeStatuses?: Array<'active'>; }): Promise; } export interface ConsolidationOp { /** * Add-only by design. The consolidator runs unattended after every * successful session, so LLM-issued delete/edit ops used to give an * unsupervised model a substring-matched deletion path over the whole * memory store (see the 2026-07 mass-deletion postmortem). Removals and * corrections belong to explicit review flows (memory_delete / * memory_update / ReviewQueue), never to this hook. */ action: 'add'; /** The fact to remember. */ text?: string | undefined; /** Memory type for categorization. */ type?: string | undefined; /** Tags for grouping. */ tags?: string[] | undefined; /** Priority level. */ priority?: string | undefined; /** Confidence that the statement is durable and supported by the evidence. */ confidence?: number | undefined; /** Concrete retrieval anchors grounded in files, symbols, packages, tests, or commands touched. */ anchors?: ConsolidatorMemoryAnchor[] | undefined; } export interface MemoryConsolidatorOptions { memoryStore: MemoryStore; /** * Optional SAGE writer. When provided, the consolidator routes * adds through `rememberSage()` and reads existing entries for dedup * context via `searchSage()` instead of the legacy `MemoryStore`. * This makes consolidator-sourced memories visible to the turn-middleware * (searchSage, retrieveForPath) which only queries SAGE. */ Sage?: ConsolidatorSage | undefined; /** * Provider used for the consolidation LLM call. Uses the session's * provider by default. */ provider?: Provider | undefined; /** * Model override for the consolidation call. Uses the session's model * by default. A smaller/faster model is recommended (e.g. deepseek-chat, haiku, flash). */ model?: string | undefined; /** * Minimum session iterations before consolidation fires. * Sessions shorter than this are skipped (default 2). */ minIterations?: number | undefined; /** * Maximum memory entries to include in the prompt as context. */ maxExistingEntries?: number | undefined; /** * OneShotOrchestrator for the consolidation LLM call. When set, uses * it instead of the direct provider.complete() path, gaining fallback * chain support and cheap-model defaulting. */ oneShotOrchestrator?: OneShotOrchestrator | undefined; } export declare class SessionMemoryConsolidator implements AgentExtension { name: string; owner: string; private readonly memoryStore; private readonly Sage?; private readonly provider?; private readonly model?; private readonly minIterations; private readonly maxExistingEntries; private readonly oneShotOrchestrator?; constructor(opts: MemoryConsolidatorOptions); afterRun: AfterRunHook; } export {}; //# sourceMappingURL=memory-consolidator.d.ts.map