/** * Typed events emitted by the agent execution SSE stream. * * Each event corresponds to a lifecycle stage of an agent execution. * Use the `type` discriminant to narrow the union in switch statements. * * Field names match the backend SSE controller exactly: * - token_delta → { content, index } * - tool_call → { name, arguments } * - tool_result → { name, summary } * - iteration_complete → { iteration, tokens } * - approval_required → { tool_name, arguments, classification } * - done → { status, total_tokens, total_credits } * - error → { error_type, message } */ /** Token fragment from LLM streaming output. */ export interface TokenDeltaEvent { type: "token_delta"; data: { content: string; index: number; }; } /** Tool invocation started. */ export interface ToolCallEvent { type: "tool_call"; data: { name: string; arguments: Record; }; } /** Tool invocation completed. */ export interface ToolResultEvent { type: "tool_result"; data: { name: string; summary: string; }; } /** LLM loop iteration completed. */ export interface IterationCompleteEvent { type: "iteration_complete"; data: { iteration: number; tokens: number; }; } /** Human-in-the-loop approval required for a tool call. */ export interface ApprovalRequiredEvent { type: "approval_required"; data: { tool_name: string; arguments: Record; classification: string; }; } /** Execution completed successfully. */ export interface DoneEvent { type: "done"; data: { status: string; total_tokens: number; total_credits: string; }; } /** Execution failed with an error. */ export interface ErrorEvent { type: "error"; data: { error_type: string; message: string; }; } /** * Union of all execution SSE event types. * * @example * ```typescript * for await (const event of stream) { * switch (event.type) { * case "token_delta": * process.stdout.write(event.data.content); * break; * case "tool_call": * console.log(`Calling tool: ${event.data.name}`); * break; * case "done": * console.log(`Complete: ${event.data.status}, tokens: ${event.data.total_tokens}`); * break; * } * } * ``` */ export type ExecutionEvent = TokenDeltaEvent | ToolCallEvent | ToolResultEvent | IterationCompleteEvent | ApprovalRequiredEvent | DoneEvent | ErrorEvent; //# sourceMappingURL=execution-events.d.ts.map