import { Agent } from './agent'; import { AgentOutputSchema } from './agent-outputs'; import { InputGuardrailResult, OutputGuardrailResult } from './guardrails'; import { ModelResponse, RunItem, TResponseInputItem } from './items'; import { StreamEvent } from './stream-events'; import { Trace } from './tracing/traces'; import { QueueCompleteSentinel } from './_run-impl'; import { SingleStepResult } from './_run-impl'; import { ZodType } from 'zod'; /** * Base class for run results */ export declare abstract class RunResultBase { /** * The original input items i.e. the items before run() was called. This may be a mutated * version of the input, if there are handoff input filters that mutate the input. */ input: string | TResponseInputItem[]; /** * The new items generated during the agent run. These include things like new messages, tool * calls and their outputs, etc. */ newItems: RunItem[]; /** * The raw LLM responses generated by the model during the agent run. */ rawResponses: ModelResponse[]; /** * The output of the last agent. */ finalOutput: any; /** * Guardrail results for the input messages. */ inputGuardrailResults: InputGuardrailResult[]; /** * Guardrail results for the final output of the agent. */ outputGuardrailResults: OutputGuardrailResult[]; constructor(input: string | TResponseInputItem[], newItems: RunItem[], rawResponses: ModelResponse[], finalOutput: any, inputGuardrailResults: InputGuardrailResult[], outputGuardrailResults: OutputGuardrailResult[]); /** * The last agent that was run. */ abstract get lastAgent(): Agent; /** * A convenience method to cast the final output to a specific type. By default, the cast * is only for the typechecker. If you set `raiseIfIncorrectType` to true, we'll raise a * TypeError if the final output does not match the Zod schema. * * @param type The Zod schema to validate and parse the final output with. * @param raiseIfIncorrectType If true, we'll raise a TypeError if the final output does not match the schema. * @returns The final output parsed according to the schema. */ finalOutputAs(type: ZodType, raiseIfIncorrectType?: boolean): T; /** * Creates a new input list, merging the original input with all the new items generated. */ toInputList(): TResponseInputItem[]; get lastResponseId(): string | null; } /** * The result of a completed agent run */ export declare class RunResult extends RunResultBase { private _lastAgent; constructor(input: string | TResponseInputItem[], newItems: RunItem[], rawResponses: ModelResponse[], finalOutput: any, inputGuardrailResults: InputGuardrailResult[], outputGuardrailResults: OutputGuardrailResult[], lastAgent: Agent); /** * The last agent that was run. */ get lastAgent(): Agent; toString(): string; } /** * The result of an agent run in streaming mode. You can use the `streamEvents` method to * receive semantic events as they are generated. * * The streaming method will raise: * - A MaxTurnsExceeded exception if the agent exceeds the max_turns limit. * - A GuardrailTripwireTriggered exception if a guardrail is tripped. */ export declare class RunResultStreaming extends RunResultBase { /** * The current agent that is running. */ currentAgent: Agent; /** * The current turn number. */ currentTurn: number; /** * The maximum number of turns the agent can run for. */ maxTurns: number; /** * Whether the agent has finished running. */ isComplete: boolean; _current_agent_output_schema?: AgentOutputSchema | null; _trace: Trace | null; _event_queue: AsyncQueue; _input_guardrail_queue: AsyncQueue; _run_impl_task: Promise | null; _input_guardrails_task?: Promise | null; _output_guardrails_task?: Promise | null; _stored_exception: Error | null; constructor(input: string | TResponseInputItem[], newItems: RunItem[], rawResponses: ModelResponse[], finalOutput: any, inputGuardrailResults: InputGuardrailResult[], outputGuardrailResults: OutputGuardrailResult[], currentAgent: Agent, currentTurn: number, maxTurns: number, currentAgentOutputSchema: AgentOutputSchema | null, trace: Trace | null); /** * The last agent that was run. Updates as the agent run progresses, so the true last agent * is only available after the agent run is complete. */ get lastAgent(): Agent; /** * Stream deltas for new items as they are generated. We're using the types from the * OpenAI Responses API, so these are semantic events: each event has a `type` field that * describes the type of the event, along with the data for that event. * * This will raise: * - A MaxTurnsExceeded exception if the agent exceeds the max_turns limit. * - A GuardrailTripwireTriggered exception if a guardrail is tripped. */ streamEvents(): AsyncGenerator; private _checkErrors; private _cleanupTasks; toString(): string; /** * Add an input guardrail result to the queue */ addInputGuardrailResult(result: InputGuardrailResult): Promise; /** * Add a step result to the event queue */ addStepResult(stepResult: SingleStepResult): Promise; /** * Complete the streaming by adding a sentinel to the queue */ complete(): Promise; /** * Update the current agent and emit an event */ updateAgent(agent: Agent): Promise; /** * Set an error and complete the streaming */ setError(error: Error): Promise; } /** * Simple async queue implementation to mimic Python's asyncio.Queue */ export declare class AsyncQueue { private _queue; private _waiters; private _tasksInProgress; get(): Promise; getNonBlocking(): T | null; put(item: T): void; put_nowait(item: T): void; taskDone(): void; isEmpty(): boolean; }