import type { ChatCompletionResponse } from '../types/provider/chat.js'; import type { StreamChunk } from '../types/provider/stream.js'; /** * Drains a {@link StreamChunk} async iterable into the equivalent * non-streaming {@link ChatCompletionResponse}. * * Phase 2 of ses_001-tool-stream-events removes `LLMProvider.chat()`; the * four internal callers that genuinely need the aggregated view (advisory * executor, RouterAgent's deterministic routing decision, compaction's * verifier, the instrumentation wrapper) replace `provider.chat(p)` with * `collectChatCompletion(provider.chatStream(p))`. * * Behaviour matches the pre-removal `chat()` contract: * - ordinary text is concatenated in delta order; identified public text * items are preserved and explicit final-answer items select the settled text; * - tool calls are bucketed by `index` into the existing * `Array<{ id, function: { name, arguments } }>` shape; * - reasoning blocks are bucketed by `index` the same way, because the * assembled message is the thing a caller replays and * {@link ReasoningBlock} is documented as replayed verbatim. This was * missing: `delta.reasoning` was dropped on the floor, so a response collected * through this helper came back with no reasoning even when the driver had * streamed it — and a vendor that requires the blocks back on the next turn * would then be sent a message that had lost them; * - usage and finishReason fall back to safe defaults when the provider * omits them (defensive — a known vendor-SDK failure mode * where `message_stop` is occasionally dropped on connection close). * * The orchestrator does NOT call this helper — it consumes the stream * directly so it can emit per-delta `SessionEvent`s. */ export declare function collectChatCompletion(stream: AsyncIterable): Promise; //# sourceMappingURL=collect-chat-completion.d.ts.map