import type { AgentMessage } from "@caupulican/pi-agent-core"; export interface SemanticMemoryGcSettings { enabled?: boolean; /** Number of newest Automata/Mind injected pages to preserve verbatim. */ preserveRecentPages?: number; /** Minimum provider-visible text chars before a stale semantic memory page is packed. */ minChars?: number; /** Markers that identify deterministic Automata/Mind context pages. */ markers?: string[]; } export interface ContextGcSettings { enabled?: boolean; /** Number of most recent AgentMessage rows to preserve verbatim. */ preserveRecentMessages?: number; /** Minimum provider-visible text chars before a stale tool result is packed. */ minToolResultChars?: number; /** Tool names eligible for stale result packing. */ tools?: string[]; /** Provider-context control for deterministic Automata/Mind semantic memory pages. */ semanticMemory?: SemanticMemoryGcSettings; } export interface NormalizedContextGcSettings extends Omit, "semanticMemory"> { semanticMemory: Required; } /** * Brain-curation hooks (both optional; absent hooks are byte-for-byte today's behavior). * `resolveDigest` is a pure lookup keyed by the record's content hash — it must return the digest * already fenced in the untrusted-content boundary (e.g. BrainCurator.getDigest), with the fence's * nonce fixed once at store time, since GC re-renders the stub from raw messages on every request * and renders the returned string VERBATIM. `onPacked` lets the caller enqueue digest work with the * exact original text at the moment it is packed. */ export interface ContextGcCurationHooks { resolveDigest?: (digestKey: string) => string | undefined; onPacked?: (record: ContextGcPackedRecord, originalText: string) => void; } export interface ContextGcOptions extends NormalizedContextGcSettings { cwd: string; storageDir?: string; /** Acquire the leased store only when an eligible payload is actually written. */ acquireStorageDir?: () => string; writePayloads?: boolean; curation?: ContextGcCurationHooks; } export interface ContextGcPackedRecord { toolName: string; toolCallId: string; messageIndex: number; reason: "superseded-read" | "stale-tool-result" | "stale-semantic-memory"; originalChars: number; originalTokens: number; packedTokens: number; storagePath?: string; path?: string; command?: string; key?: string; /** Brain-curator semantic digest of the packed content (model-generated; advisory only). Arrives * already fenced in the untrusted-content boundary (see ContextGcCurationHooks.resolveDigest) — * render verbatim, never re-wrap. */ digest?: string; } export interface ContextGcReport { enabled: boolean; packedCount: number; originalTokens: number; packedTokens: number; savedTokens: number; records: ContextGcPackedRecord[]; } export interface ContextGcResult { messages: AgentMessage[]; report: ContextGcReport; } export declare const DEFAULT_CONTEXT_GC_SETTINGS: NormalizedContextGcSettings; export declare function getContextGcSettings(settings?: ContextGcSettings): NormalizedContextGcSettings; export declare function applyContextGc(messages: AgentMessage[], rawSettings: ContextGcSettings & { cwd?: string; storageDir?: string; acquireStorageDir?: () => string; writePayloads?: boolean; curation?: ContextGcCurationHooks; }): ContextGcResult; //# sourceMappingURL=context-gc.d.ts.map