import type { TLlmTokenUsage } from "../../lib/llm/types.js"; import type { TOpenAiOutputItem, TOpenAiResponsesEnvelope } from "./types.js"; /** * Read an SSE `text/event-stream` body and return the envelope carried * by the terminal event. A stream that ends with no terminal event * (connection drop) throws `TransientLlmError` so the framework retries. * `AbortError` from the underlying reader propagates verbatim so * `llmStage` marks the stage `skipped`. * * `onResponseId`, when supplied, fires the moment the `response.created` * lifecycle event is parsed — i.e. while the call is still streaming, * before the terminal event arrives. This is the load-bearing seam for * background-stream mode: it lets a caller persist the response id * mid-flight so an in-flight call interrupted before completion can be * recovered from the upstream's stored copy. Invoked at most once. * * Note: the event-separator scan assumes LF (`\n\n`) framing, which the * OpenAI Responses API emits. Reuse against a strict CRLF-only SSE * server would need the separator scan adjusted to `\r\n\r\n`. */ export declare function readSseEnvelope(response: Response, onResponseId?: (responseId: string) => void): Promise; type TParsedFunctionCall = { callId: string; name: string; arguments: string; }; export declare function pickFunctionCalls(output: TOpenAiOutputItem[] | undefined): TParsedFunctionCall[]; export declare function extractAssistantText(output: TOpenAiOutputItem[] | undefined): string | undefined; export declare function safeParseJson(raw: string): unknown; export declare function extractUsage(envelope: TOpenAiResponsesEnvelope): TLlmTokenUsage; export declare function mergeUsage(accumulated: TLlmTokenUsage, next: TLlmTokenUsage): TLlmTokenUsage; export declare function isAbortError(err: unknown): boolean; export {}; //# sourceMappingURL=openai-parsing.d.ts.map