/** * Wire-side compaction/projection for replayed session history. * * Stored `events_jsonl` blobs can grow to several megabytes because they * contain data the browser never renders: * * - `tool_result.result.details.results` — the subagent's full internal * transcript (`messages`, `systemPrompt`, `task`, `stderr`, …). * - Hundreds of repeated `subagent_tool_progress` snapshots for the same * `stepId`, each re-carrying full tool args and partial results. * - Inline base64 screenshots (`{ type: "image", data }`) captured by the * desktop-control tools. A single full-screen PNG is worth several MB of * base64, and legacy rows carry them verbatim. * * This module performs a **projection at replay build time**. It never * mutates SQLite or the live agent stream; it only shapes the history that is * about to be serialized into `history_chunk` frames. * * The projection is intentionally best-effort: * - Malformed JSONL lines are skipped. * - Unknown events and every field the frontend renders are left untouched. */ import type { WireMessage } from "../server/wire.js"; /** Byte ceiling for individual preserved strings inside a projected event. */ export declare const MAX_PROJECTED_FIELD_BYTES: number; /** * Strip threshold for an inline image `data`, measured in base64 CHARACTERS * (what travels as JSON), not decoded bytes — hence the `_CHARS` name. * * It mirrors `MAX_INLINE_IMAGE_BASE64_CHARS`, the real ingress/wire cap: * anything at or below that cap is renderable, so stripping it would only * lose images the user can still see. Anything above it could never have been * accepted by the relay in the first place. */ export declare const MAX_PROJECTED_INLINE_IMAGE_CHARS: number; /** Marker appended when an oversized string is truncated. */ export declare const TRUNCATION_MARKER = "\n...[spectral truncated for history replay]"; /** * Parse and project a newline-delimited `events_jsonl` string. * * - Skips blank/malformed lines. * - Dedupes `subagent_tool_progress` by `stepId` (last occurrence wins). * - Re-joins the projected events into a JSONL string. */ export declare function projectEventsJsonl(eventsJsonl: string): string; /** * Project an entire persisted history tail before it is chunked and emitted. * * Only assistant messages carry `events_jsonl`. Messages whose projection is * byte-identical to the input are returned by reference, so this is a no-op * for already-compact histories. */ export declare function projectHistoryForReplay(history: readonly WireMessage[]): WireMessage[]; //# sourceMappingURL=history-projection.d.ts.map