import type { Interaction, SessionResolvedAction, SessionToolResultBlock, SessionToolUseBlock, SessionTranscriptFrame, SessionTranscriptMessage, SessionTranscriptSnapshot, SessionTranscriptTurn, TurnAck } from "./api/index.js"; export interface NormalizedToolUse { wireName: string; wireInput: Record; resolvedAction?: SessionResolvedAction; toolkitName?: string; command?: string; raw: SessionToolUseBlock; } /** * Normalize a tool-use block without discarding the model-facing wire shape. * Persisted `resolved_action` is authoritative; the legacy `{command,args}` * shape is recognized only as a compatibility fallback. */ export declare function normalizeToolUse(block: SessionToolUseBlock): NormalizedToolUse; /** Concatenate the text blocks in one transcript message. */ export declare function textOf(message: SessionTranscriptMessage): string; /** Return readable text from a tool-result block's string-or-block content. */ export declare function toolResultText(block: SessionToolResultBlock): string; /** * Terminal {@link SessionTranscriptTurn} statuses. A turn in one of these * states will not transition again. The set is closed (turn status is an open * string in the contract, but only these three are terminal). */ export declare function isTerminalTurnStatus(status: string): boolean; /** * A single decoded frame from a session transcript stream, paired with the * opaque {@link SessionTranscript.cursor | resume cursor} in effect through * this frame. The server sends an SSE `id:` line only on state frames that * advance the delivered watermark; per the SSE spec the last-event-id * persists, so `id` here is that watermark and is `undefined` only before the * first `id:` line of the connection. */ export interface TranscriptStreamEvent { frame: SessionTranscriptFrame; id?: string; } /** * The live view of a session: message rows keyed by their immutable id, the * turns that produced them, the opaque resume cursor, and a `ready` flag. It * is built by folding session-transcript v2 stream frames (or snapshot pages) * into place — the session-scope analogue of Dive's `llm.ResponseAccumulator`. * * The whole merge is set-by-id: state frames carry absolute state, so last * write wins and nothing is an increment except {@link apply | message.delta} * text. Ignoring deltas entirely still converges. * * The streaming client methods drive one for you: {@link Client.invokeAgent} * returns a `TurnTranscript` and {@link Client.watchSessionTranscript} yields * this view after every change. Construct one directly only for the escape * hatches: polling {@link Client.getSessionTranscript} into * {@link applySnapshot}, or feeding {@link Client.streamSessionTranscript} * frames into {@link apply}. */ export declare class SessionTranscript { #private; /** * Opaque resume cursor in effect through everything folded in so far; never * parse it. Set it only to resume a fresh view from a persisted position — * applied frames and snapshots overwrite it. */ get cursor(): string | null; set cursor(value: string | null); /** True once `stream.ready` has been seen on the current connection — safe to render. */ get ready(): boolean; /** @internal Ready is per-connection; the watch loop re-arms it on reconnect. */ _resetReady(): void; /** The message row with the given id, if present. */ message(id: string): SessionTranscriptMessage | undefined; /** The turn with the given id, if present. */ turn(id: string): SessionTranscriptTurn | undefined; /** Interaction with the given id, if observed on this session stream. */ interaction(id: string): Interaction | undefined; /** Interactions ordered by `(created_at, id)`. Terminal records remain available for reconciliation. */ interactions(): Interaction[]; /** Pending human-input requests currently blocking this session. */ pendingInteractions(): Interaction[]; /** Turns ordered by `(created_at, id)`. */ turns(): SessionTranscriptTurn[]; /** * Rows in render order: final rows by `sequence`, then streaming rows ordered * by `(turn.created_at, turn.id, turn_index)` — `turn_index` alone is unique * only within one turn, and turns can run concurrently. */ messages(): SessionTranscriptMessage[]; /** Rows belonging to one turn, in render order. */ messagesForTurn(turnId: string): SessionTranscriptMessage[]; /** * Policy-light rendering projection: one row per logical response segment, * final over streaming, empty-preview suppression, and tool-call-id dedup. * The lossless {@link messages} view remains unchanged. */ renderableMessages(): SessionTranscriptMessage[]; /** Renderable rows belonging to one turn. */ renderableMessagesForTurn(turnId: string): SessionTranscriptMessage[]; /** * Fold one stream frame into the view. Unknown `event_type`s are ignored so * the protocol can grow without breaking this client. This is the escape * hatch for frames obtained from {@link Client.streamSessionTranscript} or a * custom transport; the streaming client methods call it for you. */ apply(ev: TranscriptStreamEvent): void; /** * Fold a transcript snapshot page (from {@link Client.getSessionTranscript}). * Each message folds in as a `message.upsert`, each turn as a `turn.upsert`. * On the final page (`has_more` false) the snapshot's streaming rows are the * complete live set, so any local streaming row absent from it is pruned. */ applySnapshot(snap: SessionTranscriptSnapshot): void; /** * Fold a turn-start response into the view: the caller's message row, the * acked turn, and the resume cursor. {@link Client.invokeAgent} calls it for * you; it is public for callers wiring their own transport around a raw * invoke. */ seed(ack: TurnAck): void; } //# sourceMappingURL=transcript.d.ts.map