/** * Options for streaming requests */ export interface StreamOptions { signal?: AbortSignal; onError?: (error: Error) => void; timeout?: number; maxChunks?: number; maxBufferSize?: number; } /** * Events emitted by thread message streaming. * * For threads backed by an agent, the stream emits the full execution event * lifecycle including tool calls and results. For RAG threads (no agent), * only `content`/`token`, `done`, and `error` events are emitted. */ export type StreamMessageChunk = StreamTokenEvent | StreamToolCallEvent | StreamToolResultEvent | StreamIterationCompleteEvent | StreamApprovalRequiredEvent | StreamDoneEvent | StreamErrorEvent; /** * Incremental token from LLM streaming output. * `type: "content"` is a backward-compatible alias — new consumers should match on `"token"`. */ export interface StreamTokenEvent { type: "token" | "content"; content?: string; } /** Tool invocation started (agent-backed threads only). */ export interface StreamToolCallEvent { type: "tool_call"; data: { name: string; arguments: Record; }; } /** Tool invocation completed (agent-backed threads only). */ export interface StreamToolResultEvent { type: "tool_result"; data: { name: string; summary: string; }; } /** LLM loop iteration completed (agent-backed threads only). */ export interface StreamIterationCompleteEvent { type: "iteration_complete"; data: { iteration: number; tokens: number; }; } /** Human-in-the-loop approval required (agent-backed threads only). */ export interface StreamApprovalRequiredEvent { type: "approval_required"; data: { tool_name: string; arguments: Record; classification: string; }; } /** Metadata included with stream completion events. */ export interface StreamDoneMetadata { thread_id?: string; execution_id?: string; total_tokens?: number; [key: string]: unknown; } /** Stream completed successfully. */ export interface StreamDoneEvent { type: "done"; content?: string; error?: string; metadata?: StreamDoneMetadata; } /** Stream error. */ export interface StreamErrorEvent { type: "error"; content?: string; error?: string; } /** * Parse Server-Sent Events (SSE) stream into typed chunks. * Security: Enforces timeout, chunk count, and buffer size limits. */ export declare function streamSSE(response: Response, options?: StreamOptions): AsyncIterableIterator; /** * Parse streaming message response — stops on terminal events. */ export declare function streamMessage(response: Response, options?: StreamOptions): AsyncIterableIterator; //# sourceMappingURL=streaming.d.ts.map