/** * CompactionSnapshotService — builds a reference-based compaction snapshot. * * Ported fresh (NOT copied) from context-mode's snapshot.ts approach. * * This preserves SESSION continuity (what happened in the conversation), NOT * index/task state. It is the complement of `CheckpointManager` * (packages/core/src/services/checkpoint/checkpoint-manager.ts), which versions * TASK execution state (progress, decisions, files) in PostgreSQL memories table. See * `packages/core/src/services/SESSION-STATE.md` for the full reconciliation. * * Design contract: * - The snapshot is a TABLE OF CONTENTS, not inlined data. Each section * contains a brief summary + a runnable search/recall/read_file call that * re-fetches the full raw events from the observation store on demand. * - Zero truncation, zero information loss: raw events stay in the store; the * snapshot just points to them by id + provides the exact retrieval call. * - Bounded size (<~2KB): structural limits per section (last-N items, dedup, * short summaries), not a byte budget that drops data. * - XML format (portable, LLM-friendly, matches context-mode convention). * * The snapshot is emitted on /compact (or PreCompact hook) so the resuming * agent can reconstruct session continuity without re-reading truncated inline * payloads — it follows the references to fetch full detail on demand. */ import { type ObservationStore, type ObservationCategory } from "../../data/memory/observation-repository.js"; export interface SnapshotSection { category: ObservationCategory; label: string; count: number; /** Brief summary line(s) — NOT the raw data. */ summary: string; /** Runnable retrieval call to re-fetch the full raw events. */ retrievalCall: string; /** Observation ids referenced by this section (for round-trip verification). */ observationIds: string[]; } export interface CompactionSnapshot { sessionId: string; projectId: string; eventCount: number; compactCount: number; generatedAt: string; sections: SnapshotSection[]; /** The serialized XML payload (bounded <~2KB). */ xml: string; /** Byte size of the XML payload (for the bounded-size contract). */ bytes: number; } export interface SnapshotBuildOptions { sessionId: string; projectId: string; compactCount?: number; /** Max observations to scan per session (default 200 — plenty for a session). */ maxEvents?: number; /** Max items to summarize per section (default 5 — keeps the TOC bounded). */ maxItemsPerSection?: number; /** Max summary line length in chars (default 120). */ maxSummaryLineLength?: number; } export declare class CompactionSnapshotService { private store; constructor(store: ObservationStore); /** * Build a bounded, reference-based compaction snapshot for a session. * * The snapshot is a table-of-contents: each section summarizes a category * of observations and provides a runnable retrieval call to re-fetch the * full raw events. Zero inlined data, zero information loss. */ build(options: SnapshotBuildOptions): CompactionSnapshot; /** * Serialize sections to a bounded XML string. * Format matches context-mode's session_resume XML convention. */ private serializeXml; } export declare function getCompactionSnapshotService(store?: ObservationStore): CompactionSnapshotService; /** Test hook: reset the cached service. */ export declare function resetCompactionSnapshotService(): void; //# sourceMappingURL=compaction-snapshot-service.d.ts.map