/**
 * Folding emissions into an assistant turn.
 *
 * The reducer keeps the in-flight assistant {@link Turn} as an ordinary
 * immutable value and grows it one {@link Emission} at a time. These helpers do
 * that growth purely: each returns a brand-new block list (or turn, or usage)
 * rather than mutating its argument. Streaming a response means appending text
 * and reasoning deltas, opening tool-call blocks and concatenating their
 * argument fragments, and summing token accounting.
 *
 * While arguments stream in, a tool-call block's `input` holds the raw,
 * still-growing JSON string. {@link sealToolArgs} converts those strings into
 * parsed values once the stream ends, so partial JSON never escapes the turn.
 * A terminal `done` emission's fully-assembled blocks supersede the accumulated
 * ones entirely.
 */
import type { AssistantTurn, Block, Emission, ToolCallBlock, Usage } from "../../llmgateway/contract";
/** A neutral, all-zero usage accumulator. */
export declare const ZERO_USAGE: Usage;
/** Sum two usage records field by field, preserving present cache tiers only. */
export declare function addUsage(base: Usage, more: Usage): Usage;
/** Parse an accumulated argument buffer, tolerating empty/invalid JSON. */
export declare function parseToolArgs(raw: string): unknown;
/**
 * Fold a single emission into a block list, returning a new list.
 *
 * Text and thinking deltas extend the trailing block of their kind when one is
 * open, otherwise they start a fresh one. A `tool_call_start` opens a new
 * tool-call block whose `input` begins as an empty raw buffer; each
 * `tool_call_delta` concatenates onto that buffer in place. A terminal `done`
 * replaces the whole list with the reply's authoritative blocks. Emissions that
 * carry no content leave the list untouched (the same array reference is
 * returned, which callers may use to detect "no change").
 */
export declare function foldBlocks(blocks: readonly Block[], emission: Emission): readonly Block[];
/**
 * Finalize an assistant turn after its stream ends: every tool-call block whose
 * `input` is still a raw JSON string is parsed into a structured value. Returns
 * the same turn reference when nothing needed sealing.
 */
export declare function sealToolArgs(turn: AssistantTurn): AssistantTurn;
/**
 * Fold an emission into an assistant turn, returning a new turn. A thin wrapper
 * over {@link foldBlocks} that preserves the `assistant` role.
 */
export declare function foldTurn(turn: AssistantTurn, emission: Emission): AssistantTurn;
/** Collect the tool-call blocks present in an assistant turn, in order. */
export declare function toolCallsOf(turn: AssistantTurn): readonly ToolCallBlock[];
