/** * @license * Copyright 2026 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import { CodeExecutionResult, ExecutableCode, FunctionCall, FunctionResponse } from '@google/genai'; import { Event } from './event.js'; /** * The types of events that can be parsed from a raw Event. * * Each value corresponds to one category of structured output that * {@link toStructuredEvents} may produce from a raw {@link Event}. */ export declare enum EventType { /** A reasoning trace (thought) emitted by the model. */ THOUGHT = "thought", /** A text delta intended for the end user. */ CONTENT = "content", /** A request from the model to execute a tool (function call). */ TOOL_CALL = "tool_call", /** The result returned by a tool execution (function response). */ TOOL_RESULT = "tool_result", /** A request from the model to execute code. */ CALL_CODE = "call_code", /** The result of a code execution. */ CODE_RESULT = "code_result", /** A runtime error signalled via `event.errorCode`. */ ERROR = "error", /** A generic activity or status update. */ ACTIVITY = "activity", /** A request for the user to confirm one or more tool calls. */ TOOL_CONFIRMATION = "tool_confirmation", /** The agent has produced its final response for this turn. */ FINISHED = "finished" } /** * Represents a reasoning trace (thought) from the agent. */ export interface ThoughtEvent { type: EventType.THOUGHT; content: string; } /** * Represents partial content (text delta) intended for the user. */ export interface ContentEvent { type: EventType.CONTENT; content: string; } /** * Represents a request to execute a tool. */ export interface ToolCallEvent { type: EventType.TOOL_CALL; call: FunctionCall; } /** * Represents the result of a tool execution. */ export interface ToolResultEvent { type: EventType.TOOL_RESULT; result: FunctionResponse; } /** * Represents a request to execute code. */ export interface CallCodeEvent { type: EventType.CALL_CODE; code: ExecutableCode; } /** * Represents the result of code execution. */ export interface CodeResultEvent { type: EventType.CODE_RESULT; result: CodeExecutionResult; } /** * Represents a runtime error. */ export interface ErrorEvent { type: EventType.ERROR; error: Error; } /** * Represents a generic activity or status update. */ export interface ActivityEvent { type: EventType.ACTIVITY; kind: string; detail: Record; } /** * Represents a request for tool confirmation. */ export interface ToolConfirmationEvent { type: EventType.TOOL_CONFIRMATION; confirmations: Record; } /** * Represents the final completion of the agent's task. */ export interface FinishedEvent { type: EventType.FINISHED; output?: unknown; } /** * A standard structured event parsed from the raw Event stream. */ export type StructuredEvent = ThoughtEvent | ContentEvent | ToolCallEvent | ToolResultEvent | CallCodeEvent | CodeResultEvent | ErrorEvent | ActivityEvent | ToolConfirmationEvent | FinishedEvent; /** * Converts an internal Event to a list of structured events. * This is an optional utility for callers who want to easily identify * the type of event they are handling. * * @param event - The raw event to convert. * @returns The structured events. */ export declare function toStructuredEvents(event: Event): StructuredEvent[];