import type { CompletionError, CompletionEvent, CompletionFinal, CompletionStats, StopReason, ToolCall, ToolCallError } from '../schemas/index.js'; import { type ToolHandlerMap } from './tool-helpers.js'; export type AggregatedEvents = { contentText: string; thinkingText: string; stats: CompletionStats | undefined; toolCalls: ToolCall[]; /** Tool-call regions that failed to parse or validate; see `CompletionFinal.toolErrors`. */ toolErrors: ToolCallError[]; rawFullText: string | undefined; error: CompletionError | undefined; stopReason: StopReason | undefined; /** * True when the terminal `completionDone` carried * `stopReason: "cancelled"`. The client wrapper rejects the * promise-aggregates (`final` / `text` / `toolCalls` / `stats`) with * `InferenceCancelledError` carrying the partial state when this is * set; the `events` stream itself still ends normally. */ cancelled: boolean; }; export declare function aggregateEvents(events: CompletionEvent[]): AggregatedEvents; export declare function buildFinalFromEvents(events: CompletionEvent[], handlers: ToolHandlerMap): { final: CompletionFinal; error: CompletionError | undefined; cancelled: boolean; };