import { type SessionEvent } from "../events.ts"; import type { DraftEvent, HarnessNormalizer } from "./types.ts"; export interface LinkOptions { /** * Id generator for drafts that do not carry a native id. Default is * `crypto.randomUUID`, which is unique-safe across repeated * `normalizeSession()` calls for one session (e.g. per chunk / per resume * leg); inject a deterministic generator in tests when stable ids are needed. * It is only consulted when a draft omits `id`. */ newId?: () => string; /** * The `parentId` the first linked event points at — the causal predecessor * this transcript continues from. `null` (default) starts a fresh chain; on a * resume the caller passes the last restored event's id so the new events * continue the same chain across the resume boundary. */ parentId?: string | null; } /** * Thread a flat list of {@link DraftEvent}s into a causal chain of canonical * {@link SessionEvent}s: each event's `id` is its native id when it supplied one * else a freshly generated id, and its `parentId` is the id of the event before * it (or {@link LinkOptions.parentId} for the first). Offsets are *not* assigned * here — the authoritative log owns those on `emit` (slice 1); this only records * causality (`parentId`), which survives compaction. */ export declare function linkDrafts(drafts: readonly DraftEvent[], options?: LinkOptions): SessionEvent[]; /** * Normalize a whole native transcript through a harness normalizer: map every * record to drafts, then {@link linkDrafts} the concatenation into one canonical * causal chain. This is the fallback backend's public ingestion call — the * mirror of the ACP backend's `session/update` stream, producing the same * {@link SessionEvent}s a caller feeds to a slice-1 `SessionAdapter.emit`. */ export declare function normalizeSession(normalizer: HarnessNormalizer, records: Iterable, options?: LinkOptions): SessionEvent[];