import { type RunResumeSessionManager } from "../runtime/index.js"; import type { Agent, AgentResponse, Message } from "../types.js"; import { type AgUiRuntimeRequest } from "../runtime/ag-ui-contract.js"; import { type AgUiResumeValue } from "./tool-shared.js"; /** Context for AG-UI runtime lifecycle. */ export interface AgUiRuntimeLifecycleContext { request: AgUiRuntimeRequest; toolCallId?: string; error?: unknown; /** * The finalized messages this run produced (assistant + tool turns). Present * on the `onFinish` context after a successful run that produced a response; * omitted for `onError` / `onToolCallSeen` and bodyless runs. */ messages?: Message[]; /** The full finalized response, alongside `messages`, on `onFinish`. */ response?: AgentResponse; } /** Input payload for AG-UI runtime handler execute. */ export interface AgUiRuntimeHandlerExecuteInput { request: Request; agUiInput: AgUiRuntimeRequest; context: Record; createDefaultResponse?: () => Promise; } /** Public API contract for AG-UI runtime handler execute. */ export type AgUiRuntimeHandlerExecute = (input: AgUiRuntimeHandlerExecuteInput) => Promise | Response; export interface AgUiRuntimeRequestGateInput { /** Original request for trusted framework admission and authentication only. */ request: Request; /** Detached request safe to retain or pass into application callbacks. */ applicationRequest: Request; } export type AgUiRuntimeRequestGate = (input: AgUiRuntimeRequestGateInput) => Promise | Response | undefined | void; export interface AgUiRuntimeValidationErrorInput { request: Request; response: Response; } export type AgUiRuntimeValidationErrorResponse = (input: AgUiRuntimeValidationErrorInput) => Promise | Response; /** Options accepted by AG-UI runtime handler. */ export interface AgUiRuntimeHandlerOptions { context?: Record | ((request: Request) => Record | Promise>); beforeParse?: AgUiRuntimeRequestGate; validationErrorResponse?: AgUiRuntimeValidationErrorResponse; sessionManager?: RunResumeSessionManager; execute?: AgUiRuntimeHandlerExecute; onToolCallSeen?: (context: AgUiRuntimeLifecycleContext) => Promise | void; onFinish?: (context: AgUiRuntimeLifecycleContext) => Promise | void; onError?: (context: AgUiRuntimeLifecycleContext) => Promise | void; } /** Public API contract for AG-UI runtime handler config with agent. */ export interface AgUiRuntimeHandlerConfigWithAgent extends AgUiRuntimeHandlerOptions { agent: Agent; } /** Configuration used by AG-UI runtime handler. */ export type AgUiRuntimeHandlerConfig = AgUiRuntimeHandlerConfigWithAgent | (AgUiRuntimeHandlerOptions & { agent?: undefined; execute: AgUiRuntimeHandlerExecute; }); /** Handler for create AG-UI runtime. */ export declare function createAgUiRuntimeHandler(config: AgUiRuntimeHandlerConfig): (requestOrCtx: unknown) => Promise; //# sourceMappingURL=runtime-handler.d.ts.map