import type { NormalizedMessage, NormalizedSession, PresetName, DetailLevel } from '../types.js'; /** * Options that tell `serializeMessage` how aggressively to dedup the * `content` / `blocks` channels and whether to suppress detail for `meta`. * * Why both? Two different agent contracts collide on the same payload: * * - `preset` (minimal/standard/verbose/full) is the user-facing volume * knob. `minimal`/`standard` callers want the cheap flat-text channel * (`content`); `verbose`/`full` callers want the structured `blocks` * channel (with tool args, full results, thinking blobs). Emitting * BOTH everywhere is the oc/12 + oc/13 regression — every tool_result * message paid ~2x the bytes it needed. * * - `detail` (full/condensed/skeleton/meta) is the read-command's * orthogonal "how much per-message" knob. `meta` in particular wants * EVERY block stripped — but for tool_use/tool_result messages, the * name + tool_use_id are load-bearing metadata an agent uses to * decide whether to fetch the full message later. We preserve those * two fields (and only those two) in meta mode. */ export interface SerializeMessageOpts { preset?: PresetName; detail?: DetailLevel; } /** * Serialize a NormalizedMessage for emission inside a v2 envelope. * * Channel policy (oc/12 + oc/13): * * preset \\ messages: text-only rich (tool_use/result, thinking, mixed) * ────────────────────────────────────────────────────────────────────────────────── * minimal/standard content only content only (blocks stripped) * verbose/full content only blocks only (content stripped) * undefined (default) content only blocks only (no dual-channel waste) * * The default is "blocks only" for rich messages so callers that don't yet * pass an explicit preset (send sync envelope, incidental message snippets * from stats/info) still benefit from the dedup. Pre-Phase-3 callers paid * 30–60% extra bytes on JSONL streams because every tool_result carried * both a truncated flat `content` AND the full structured `blocks` — the * default now matches what every modern JSON consumer would want. * * Detail policy (M3): * * detail=meta with role tool_use / tool_result: * - `content` becomes `"Tool: "` so an agent can see what was * invoked without paying for the full payload. * - `tool_use_id` surfaces as a top-level field (joins tool_use ↔ * tool_result across the wire). * - `blocks` is dropped entirely. */ export declare function serializeMessage(m: NormalizedMessage, opts?: SerializeMessageOpts | PresetName): Record; /** * Walk a value tree converting camelCase keys to snake_case (per the * CAMEL_TO_SNAKE_KEYS map) AND converting Date instances to ISO strings. * Use this on any object that surfaces in a v2 envelope's `result` — * most importantly NormalizedSession / SessionStats / SessionMetadata. * * Unknown keys are passed through unchanged (so `id`, `source`, `cwd`, * `model`, etc. retain their existing snake_case-or-single-word form). */ export declare function toExternal(value: unknown): unknown; /** * Convenience for the common case: serialize a NormalizedSession (minus its * raw messages) into the canonical external shape with snake_case keys + * ISO dates. Use this from `info`, `stats`, and anywhere else a session * descriptor surfaces in a v2 envelope. */ export declare function toExternalSession(session: NormalizedSession): Record; //# sourceMappingURL=serialize.d.ts.map