import { type AgentRunOptions, type AgentSubmissionReference, type AgentQueuedSubmissionReceipt, type AgentSuggestion } from "@agent-native/agentkit/protocol"; import type { ActionChatUIConfig } from "../../action-ui.js"; import type { AgentMcpAppPayload } from "../../mcp-client/app-result.js"; import type { ReasoningEffort } from "../../shared/reasoning-effort.js"; import { type ServerRunState } from "./run-outcome.js"; import { type TurnSubmittedReport } from "./turn-submitted.js"; export type { ServerRunState } from "./run-outcome.js"; export type AgentChatRuntimeId = string; export type AgentChatRuntimeSessionId = string; export type AgentChatRuntimeTurnId = string; export type AgentChatRuntimeMessageId = string; export type AgentChatRuntimeToolCallId = string; export type AgentChatRuntimeMetadata = Record; export type AgentChatRuntimeAwaitable = T | Promise; export declare const AGENT_NATIVE_RUN_RESUME_STATE_METADATA_KEY = "agentNativeRunResumeState"; export type AgentChatRuntimeKind = "agent-native" | "external-agent" | "code-agent" | (string & {}); export type AgentChatRuntimeRole = "system" | "user" | "assistant" | "tool"; export interface AgentChatRuntimeContentPartBase { readonly type: TType; readonly id?: string; readonly metadata?: AgentChatRuntimeMetadata; } export interface AgentChatRuntimeTextPart extends AgentChatRuntimeContentPartBase<"text"> { readonly text: string; /** Explicit presentation authored by the runtime or host adapter. */ readonly format?: "plain" | "markdown"; } export interface AgentChatRuntimeReasoningPart extends AgentChatRuntimeContentPartBase<"reasoning"> { readonly text: string; readonly signature?: string; } export interface AgentChatRuntimeImagePart extends AgentChatRuntimeContentPartBase<"image"> { readonly data?: string; readonly url?: string; readonly mediaType?: string; readonly alt?: string; } export interface AgentChatRuntimeFilePart extends AgentChatRuntimeContentPartBase<"file"> { readonly data?: string; readonly url?: string; readonly mediaType?: string; readonly filename?: string; } export interface AgentChatRuntimeToolCallPart extends AgentChatRuntimeContentPartBase<"tool-call"> { readonly toolCallId: AgentChatRuntimeToolCallId; readonly toolName: string; readonly input?: unknown; readonly inputText?: string; readonly approval?: { readonly approvalKey: string; readonly askId?: string; }; /** Keeps the exact approved invocation available within the continuation budget. */ readonly approvedReplay?: true; } export interface AgentChatRuntimeToolResultPart extends AgentChatRuntimeContentPartBase<"tool-result"> { readonly toolCallId: AgentChatRuntimeToolCallId; readonly toolName?: string; readonly result?: unknown; readonly resultText?: string; readonly isError?: boolean; readonly approvalPause?: boolean; readonly approvalAskId?: string; readonly mcpApp?: AgentMcpAppPayload; readonly chatUI?: ActionChatUIConfig; } export interface AgentChatRuntimeDataPart extends AgentChatRuntimeContentPartBase<"data"> { readonly data: unknown; readonly mediaType?: string; readonly title?: string; } export interface AgentChatRuntimeCustomContentPart extends AgentChatRuntimeContentPartBase { readonly [key: string]: unknown; } export type AgentChatRuntimeKnownContentPart = AgentChatRuntimeTextPart | AgentChatRuntimeReasoningPart | AgentChatRuntimeImagePart | AgentChatRuntimeFilePart | AgentChatRuntimeToolCallPart | AgentChatRuntimeToolResultPart | AgentChatRuntimeDataPart; export type AgentChatRuntimeContentPart = AgentChatRuntimeKnownContentPart | TCustomPart; export interface AgentChatRuntimeMessage { readonly id: AgentChatRuntimeMessageId; readonly role: AgentChatRuntimeRole; readonly content: readonly TContentPart[]; readonly createdAt?: string; readonly status?: "streaming" | "complete" | "error"; readonly metadata?: AgentChatRuntimeMetadata; } export interface AgentChatRuntimeAttachment { readonly id?: string; readonly type?: string; readonly name: string; readonly mediaType?: string; readonly contentType?: string; readonly data?: string; readonly url?: string; readonly referenceUrl?: string; readonly text?: string; readonly metadata?: AgentChatRuntimeMetadata; } export interface AgentChatRuntimeToolDefinition { readonly name: string; readonly description?: string; readonly inputSchema?: Record; readonly readOnly?: boolean; readonly destructive?: boolean; readonly metadata?: AgentChatRuntimeMetadata; } export interface AgentChatRuntimeToolCall { readonly id: AgentChatRuntimeToolCallId; readonly name: string; readonly input?: unknown; readonly inputText?: string; readonly metadata?: AgentChatRuntimeMetadata; } export type AgentChatRuntimeToolStatus = "pending" | "running" | "completed" | "failed" | "cancelled"; export interface AgentChatRuntimeUsage { readonly inputTokens?: number; readonly outputTokens?: number; readonly totalTokens?: number; readonly reasoningTokens?: number; readonly cacheReadTokens?: number; readonly cacheWriteTokens?: number; readonly costCents?: number; readonly metadata?: AgentChatRuntimeMetadata; } export interface AgentChatRuntimeMessageCapabilities { readonly streaming: boolean; readonly history?: boolean; readonly structuredContent?: boolean; readonly multimodal?: boolean; readonly attachments?: boolean; } export interface AgentChatRuntimeToolCapabilities { readonly events: boolean; readonly hostTools?: boolean; readonly inputStreaming?: boolean; readonly resultStreaming?: boolean; readonly approvals?: boolean; readonly mcpApps?: boolean; } export interface AgentChatRuntimeSessionCapabilities { readonly create: boolean; readonly restore?: boolean; readonly list?: boolean; readonly fork?: boolean; readonly detach?: boolean; readonly persistent?: boolean; } export interface AgentChatRuntimeCancellationCapabilities { readonly abortSignal?: boolean; readonly explicitCancel?: boolean; readonly interrupt?: boolean; } export interface AgentChatRuntimeModelCapabilities { readonly selectable?: boolean; readonly reasoningEffort?: boolean; readonly temperature?: boolean; readonly providerOptions?: boolean; } export interface AgentChatRuntimeArtifactCapabilities { readonly files?: boolean; readonly links?: boolean; readonly patches?: boolean; readonly progress?: boolean; } export interface AgentChatRuntimeRichCapabilities { readonly annotations?: boolean; readonly citations?: boolean; readonly widgets?: boolean; readonly clientEffects?: boolean; readonly uploadProgress?: boolean; readonly participants?: boolean; readonly interactions?: boolean; readonly tasks?: boolean; readonly taskGroups?: boolean; readonly extensions?: boolean; readonly connectionRequests?: boolean; } export interface AgentChatRuntimeCapabilities { readonly messages: AgentChatRuntimeMessageCapabilities; /** The runtime can resume a durable run stream after its reader disconnects. */ readonly resumableRuns?: boolean; readonly tools?: AgentChatRuntimeToolCapabilities; readonly sessions?: AgentChatRuntimeSessionCapabilities; readonly cancellation?: AgentChatRuntimeCancellationCapabilities; readonly models?: AgentChatRuntimeModelCapabilities; readonly artifacts?: AgentChatRuntimeArtifactCapabilities; readonly rich?: AgentChatRuntimeRichCapabilities; readonly custom?: AgentChatRuntimeMetadata; } export interface AgentChatRuntimeCreateSessionInput { readonly id?: AgentChatRuntimeSessionId; readonly threadId?: string; readonly title?: string; readonly messages?: readonly AgentChatRuntimeMessage[]; readonly resumeState?: unknown; readonly metadata?: AgentChatRuntimeMetadata; readonly abortSignal?: AbortSignal; } export interface AgentChatRuntimeListSessionsInput { readonly threadId?: string; readonly limit?: number; readonly cursor?: string; readonly metadata?: AgentChatRuntimeMetadata; readonly abortSignal?: AbortSignal; } export type AgentChatRuntimeSessionStatus = "idle" | "running" | "waiting" | "cancelled" | "completed" | "error"; export interface AgentChatRuntimeSessionSummary { readonly id: AgentChatRuntimeSessionId; readonly runtimeId: AgentChatRuntimeId; readonly threadId?: string; readonly title?: string; readonly status?: AgentChatRuntimeSessionStatus; readonly createdAt?: string; readonly updatedAt?: string; readonly metadata?: AgentChatRuntimeMetadata; } export interface AgentChatRuntimeSessionSnapshot extends AgentChatRuntimeSessionSummary { readonly messages?: readonly AgentChatRuntimeMessage[]; readonly resumeState?: unknown; } export interface AgentChatRuntimeTurnInput { readonly prompt?: string; readonly messages?: readonly AgentChatRuntimeMessage[]; readonly submissionPayload?: unknown; readonly options?: AgentRunOptions; readonly references?: readonly AgentSubmissionReference[]; readonly queuePromotion?: { readonly messageId: string; readonly claimId: string; readonly turnId: string; }; readonly attachments?: readonly AgentChatRuntimeAttachment[]; readonly tools?: readonly AgentChatRuntimeToolDefinition[]; readonly model?: string; readonly reasoningEffort?: ReasoningEffort; readonly temperature?: number; readonly providerOptions?: Record; readonly metadata?: AgentChatRuntimeMetadata; readonly abortSignal?: AbortSignal; } export interface AgentChatRuntimeApprovalResponse { readonly id: string; readonly approved: boolean; readonly message?: string; readonly metadata?: AgentChatRuntimeMetadata; } export interface AgentChatRuntimeConnectionResponse { readonly id: string; readonly status: "connected" | "declined"; readonly connectionId?: string; readonly message?: string; readonly metadata?: AgentChatRuntimeMetadata; } export interface AgentChatRuntimeContinueInput { readonly turnId?: AgentChatRuntimeTurnId; readonly prompt?: string; readonly approval?: AgentChatRuntimeApprovalResponse; readonly connection?: AgentChatRuntimeConnectionResponse; /** Durable references to the continued turn's attachments; never bytes. */ readonly attachments?: readonly AgentChatRuntimeAttachment[]; readonly metadata?: AgentChatRuntimeMetadata; readonly abortSignal?: AbortSignal; } export interface AgentChatRuntimeCancelInput { readonly sessionId?: AgentChatRuntimeSessionId; readonly turnId?: AgentChatRuntimeTurnId; readonly runId?: string; readonly reason?: string; readonly metadata?: AgentChatRuntimeMetadata; readonly abortSignal?: AbortSignal; } export type AgentChatRuntimeCancelStatus = "cancelled" | "not-found" | "already-finished" | "unsupported"; export interface AgentChatRuntimeCancelResult { readonly status: AgentChatRuntimeCancelStatus; readonly message?: string; readonly metadata?: AgentChatRuntimeMetadata; } export interface AgentChatRuntimeEventBase { readonly type: TType; readonly id?: string; readonly sessionId?: AgentChatRuntimeSessionId; readonly turnId?: AgentChatRuntimeTurnId; readonly timestamp?: string; readonly metadata?: AgentChatRuntimeMetadata; } export interface AgentChatRuntimeMessageStartEvent extends AgentChatRuntimeEventBase<"message-start"> { readonly message: AgentChatRuntimeMessage; } export type AgentChatRuntimeMessageDelta = { readonly type: "text"; readonly text: string; readonly partId?: string; readonly format?: "plain" | "markdown"; } | { readonly type: "reasoning"; readonly text: string; readonly partId?: string; readonly signature?: string; } | { readonly type: "data"; readonly data: unknown; readonly partId?: string; readonly mediaType?: string; }; export interface AgentChatRuntimeMessageDeltaEvent extends AgentChatRuntimeEventBase<"message-delta"> { readonly messageId: AgentChatRuntimeMessageId; readonly delta: AgentChatRuntimeMessageDelta; } export interface AgentChatRuntimeMessageDoneEvent extends AgentChatRuntimeEventBase<"message-done"> { readonly message: AgentChatRuntimeMessage; } /** Replaces a streaming message's content without finishing it. */ export interface AgentChatRuntimeMessageReplaceEvent extends AgentChatRuntimeEventBase<"message-replace"> { readonly message: AgentChatRuntimeMessage; } export interface AgentChatRuntimeToolStartEvent extends AgentChatRuntimeEventBase<"tool-start"> { readonly toolCall: AgentChatRuntimeToolCall; } export interface AgentChatRuntimeToolDeltaEvent extends AgentChatRuntimeEventBase<"tool-delta"> { readonly toolCallId: AgentChatRuntimeToolCallId; readonly toolName?: string; readonly inputTextDelta?: string; readonly resultTextDelta?: string; } export interface AgentChatRuntimeToolDoneEvent extends AgentChatRuntimeEventBase<"tool-done"> { readonly toolCallId: AgentChatRuntimeToolCallId; readonly toolName: string; readonly status: AgentChatRuntimeToolStatus; readonly result?: unknown; readonly resultText?: string; readonly error?: string; readonly completedSideEffect?: boolean; readonly approvalPause?: boolean; readonly approvalAskId?: string; readonly mcpApp?: AgentMcpAppPayload; readonly chatUI?: ActionChatUIConfig; } export interface AgentChatRuntimeApprovalRequestEvent extends AgentChatRuntimeEventBase<"approval-request"> { readonly approvalId: string; readonly toolCallId?: AgentChatRuntimeToolCallId; readonly toolName?: string; readonly message: string; readonly input?: unknown; readonly allowPersistentApproval?: false; /** The server's approval row, when the agent-native store created one. */ readonly askId?: string; } export interface AgentChatRuntimeApprovalResolvedEvent extends AgentChatRuntimeEventBase<"approval-resolved"> { readonly approvalId: string; readonly approved: boolean; readonly message?: string; } export interface AgentChatRuntimeConnectionRequestEvent extends AgentChatRuntimeEventBase<"connection-request"> { readonly requestId: string; readonly provider: string; readonly reason: "connect" | "grant" | "reauthorize" | "admin_required"; readonly appId?: string; readonly detail?: string; readonly source?: AgentChatRuntimeObjectReference; } export interface AgentChatRuntimeStatusEvent extends AgentChatRuntimeEventBase<"status"> { readonly level?: "info" | "warning" | "error"; readonly message: string; readonly code?: string; } export interface AgentChatRuntimeSuggestionsEvent extends AgentChatRuntimeEventBase<"suggestions"> { readonly suggestions: AgentSuggestion[]; } export interface AgentChatRuntimeObjectReference { readonly id: string; readonly kind: string; readonly label?: string; readonly uri?: string; readonly metadata?: AgentChatRuntimeMetadata; } export interface AgentChatRuntimeAnnotation { readonly id: string; readonly kind: string; readonly label: string; readonly url?: string; readonly messageId?: AgentChatRuntimeMessageId; readonly start?: number; readonly end?: number; readonly object?: AgentChatRuntimeObjectReference; readonly metadata?: AgentChatRuntimeMetadata; } export interface AgentChatRuntimeAnnotationEvent extends AgentChatRuntimeEventBase<"annotation"> { readonly operation: "create" | "update" | "remove"; readonly annotation: AgentChatRuntimeAnnotation; } export interface AgentChatRuntimeWidget { readonly id: string; readonly kind: string; readonly title?: string; readonly data?: unknown; readonly state?: "loading" | "ready" | "error"; readonly object?: AgentChatRuntimeObjectReference; readonly metadata?: AgentChatRuntimeMetadata; } export interface AgentChatRuntimeWidgetEvent extends AgentChatRuntimeEventBase<"widget"> { readonly operation: "create" | "update" | "remove"; readonly widget: AgentChatRuntimeWidget; } export type AgentChatRuntimeParticipantStatus = "idle" | "working" | "waiting" | "paused" | "completed" | "failed" | "closed"; export interface AgentChatRuntimeParticipant { readonly id: string; readonly name: string; readonly kind?: string; readonly status?: AgentChatRuntimeParticipantStatus; readonly parentParticipantId?: string; readonly activeTaskId?: string; readonly description?: string; readonly origin?: AgentChatRuntimeObjectReference; readonly startedAt?: string; readonly updatedAt?: string; readonly completedAt?: string; readonly metadata?: AgentChatRuntimeMetadata; } export interface AgentChatRuntimeParticipantEvent extends AgentChatRuntimeEventBase<"participant"> { readonly operation: "register" | "update" | "unregister"; readonly participant: AgentChatRuntimeParticipant; } export type AgentChatRuntimeWorkScope = "thread" | "workspace" | "external"; export interface AgentChatRuntimeInteraction { readonly id: string; readonly kind: string; readonly participantId?: string; readonly targetParticipantId?: string; readonly label?: string; readonly detail?: string; readonly scope?: AgentChatRuntimeWorkScope; readonly object?: AgentChatRuntimeObjectReference; readonly source?: AgentChatRuntimeObjectReference; readonly occurredAt?: string; readonly metadata?: AgentChatRuntimeMetadata; } export interface AgentChatRuntimeInteractionEvent extends AgentChatRuntimeEventBase<"interaction"> { readonly interaction: AgentChatRuntimeInteraction; } export type AgentChatRuntimeWorkStatus = "pending" | "running" | "awaiting-input" | "completed" | "failed" | "cancelled"; export interface AgentChatRuntimeActivity { readonly id: string; readonly kind: string; readonly label: string; readonly detail?: string; readonly status: Exclude; readonly participantId?: string; readonly scope?: AgentChatRuntimeWorkScope; readonly object?: AgentChatRuntimeObjectReference; readonly source?: AgentChatRuntimeObjectReference; readonly data?: unknown; readonly metadata?: AgentChatRuntimeMetadata; } export interface AgentChatRuntimeActivityEvent extends AgentChatRuntimeEventBase<"activity"> { readonly operation: "start" | "update" | "complete"; readonly activity: AgentChatRuntimeActivity; } export interface AgentChatRuntimeTask { readonly id: string; readonly title: string; readonly status: AgentChatRuntimeWorkStatus; readonly kind?: string; readonly parentTaskId?: string; readonly assignedParticipantId?: string; readonly runId?: string; readonly threadId?: string; readonly detail?: string; readonly progress?: number; readonly summary?: string; readonly object?: AgentChatRuntimeObjectReference; readonly source?: AgentChatRuntimeObjectReference; readonly startedAt?: string; readonly updatedAt?: string; readonly completedAt?: string; readonly metadata?: AgentChatRuntimeMetadata; } export interface AgentChatRuntimeTaskEvent extends AgentChatRuntimeEventBase<"task"> { readonly operation: "create" | "update" | "complete"; readonly task: AgentChatRuntimeTask; } export interface AgentChatRuntimeTaskGroup { readonly id: string; readonly taskIds: readonly string[]; readonly title?: string; readonly status?: AgentChatRuntimeWorkStatus; readonly metadata?: AgentChatRuntimeMetadata; } export interface AgentChatRuntimeTaskGroupEvent extends AgentChatRuntimeEventBase<"task-group"> { readonly operation: "create" | "update" | "complete"; readonly taskGroup: AgentChatRuntimeTaskGroup; } export interface AgentChatRuntimeUploadProgressEvent extends AgentChatRuntimeEventBase<"upload-progress"> { readonly uploadId: string; readonly status: "pending" | "uploading" | "completed" | "failed" | "cancelled"; readonly bytesSent?: number; readonly bytesTotal?: number; readonly object?: AgentChatRuntimeObjectReference; readonly error?: string; } export interface AgentChatRuntimeClientEffectEvent extends AgentChatRuntimeEventBase<"client-effect"> { readonly effectId: string; readonly kind: "effect" | "deeplink" | (string & {}); readonly name: string; readonly data?: unknown; readonly object?: AgentChatRuntimeObjectReference; } export interface AgentChatRuntimeExtensionReference { readonly kind: string; readonly id: string; readonly label?: string; readonly uri?: string; } export interface AgentChatRuntimeExtensionEvent extends AgentChatRuntimeEventBase<"extension"> { readonly namespace: string; readonly name: string; readonly version?: number; readonly data?: unknown; readonly references?: readonly AgentChatRuntimeExtensionReference[]; } export interface AgentChatRuntimeArtifactEvent extends AgentChatRuntimeEventBase<"artifact"> { readonly artifact: { readonly id?: string; readonly kind: string; readonly title?: string; readonly url?: string; readonly path?: string; readonly data?: unknown; readonly metadata?: AgentChatRuntimeMetadata; }; } export interface AgentChatRuntimeFileEvent extends AgentChatRuntimeEventBase<"file"> { readonly path: string; readonly operation?: "create" | "update" | "delete" | "rename" | "unknown"; readonly summary?: string; } export interface AgentChatRuntimeUsageEvent extends AgentChatRuntimeEventBase<"usage"> { readonly usage: AgentChatRuntimeUsage; } export interface AgentChatRuntimeErrorEvent extends AgentChatRuntimeEventBase<"error"> { readonly error: string; readonly code?: string; readonly recoverable?: boolean; readonly retryable?: boolean; readonly details?: unknown; readonly cause?: unknown; } export type AgentChatRuntimeContinuationEvent = AgentChatRuntimeEventBase<"continuation">; export type AgentChatRuntimeDoneReason = "complete" | "cancelled" | "error" | "interrupted" | "length" | "tool-use" | (string & {}); export interface AgentChatRuntimeDoneEvent extends AgentChatRuntimeEventBase<"done"> { readonly reason?: AgentChatRuntimeDoneReason; } export interface AgentChatRuntimeCustomEvent extends AgentChatRuntimeEventBase { readonly [key: string]: unknown; } export type AgentChatRuntimeKnownEvent = AgentChatRuntimeMessageStartEvent | AgentChatRuntimeMessageDeltaEvent | AgentChatRuntimeMessageDoneEvent | AgentChatRuntimeMessageReplaceEvent | AgentChatRuntimeToolStartEvent | AgentChatRuntimeToolDeltaEvent | AgentChatRuntimeToolDoneEvent | AgentChatRuntimeApprovalRequestEvent | AgentChatRuntimeApprovalResolvedEvent | AgentChatRuntimeConnectionRequestEvent | AgentChatRuntimeStatusEvent | AgentChatRuntimeSuggestionsEvent | AgentChatRuntimeAnnotationEvent | AgentChatRuntimeWidgetEvent | AgentChatRuntimeParticipantEvent | AgentChatRuntimeInteractionEvent | AgentChatRuntimeActivityEvent | AgentChatRuntimeTaskEvent | AgentChatRuntimeTaskGroupEvent | AgentChatRuntimeUploadProgressEvent | AgentChatRuntimeClientEffectEvent | AgentChatRuntimeExtensionEvent | AgentChatRuntimeArtifactEvent | AgentChatRuntimeFileEvent | AgentChatRuntimeUsageEvent | AgentChatRuntimeErrorEvent | AgentChatRuntimeContinuationEvent | AgentChatRuntimeDoneEvent; export type AgentChatRuntimeEvent = AgentChatRuntimeKnownEvent | TCustomEvent; export interface AgentChatRuntimeTurn { readonly id?: AgentChatRuntimeTurnId; /** * The turn the server stored the run under (its `X-Turn-Id`), else the one * the request carried; absent for a replay the server did not name the turn * of. A continuation sends the turn it continues, and an approval resume * runs under its pending approval's turn, so this is not always `id`. */ readonly requestTurnId?: AgentChatRuntimeTurnId; readonly sessionId: AgentChatRuntimeSessionId; readonly runId?: string; readonly metadata?: AgentChatRuntimeMetadata; readonly queuedSubmission?: AgentQueuedSubmissionReceipt; readonly events: AsyncIterable; /** Close the local event stream without cancelling the underlying run. */ closeEvents?(): Promise | void; cancel?(input?: AgentChatRuntimeCancelInput): Promise; } export interface AgentChatRuntimeSendMessageInput extends AgentChatRuntimeTurnInput { readonly sessionId?: AgentChatRuntimeSessionId; } export interface AgentChatRuntimeSubscribeInput { readonly sessionId?: AgentChatRuntimeSessionId; readonly turnId?: AgentChatRuntimeTurnId; readonly runId?: string; readonly after?: number; readonly metadata?: AgentChatRuntimeMetadata; readonly abortSignal?: AbortSignal; } export interface AgentChatRuntimeReadRunStateInput extends AgentChatRuntimeSubscribeInput { /** Include the durable request id when checking whether a restored request is pending. */ readonly includePendingConnectionRequest?: boolean; } export interface AgentChatRuntimeResumeInput extends AgentChatRuntimeSubscribeInput { readonly prompt?: string; } export interface AgentChatRuntimeSession { readonly id: AgentChatRuntimeSessionId; readonly runtimeId: AgentChatRuntimeId; readonly threadId?: string; readonly capabilities?: Partial; sendMessage?(input: AgentChatRuntimeTurnInput): AgentChatRuntimeAwaitable>; startTurn(input: AgentChatRuntimeTurnInput): AgentChatRuntimeAwaitable>; continueTurn?(input?: AgentChatRuntimeContinueInput): AgentChatRuntimeAwaitable>; cancelTurn?(input?: AgentChatRuntimeCancelInput): Promise; snapshot?(): AgentChatRuntimeAwaitable; dispose?(): AgentChatRuntimeAwaitable; } export interface AgentChatRuntime { readonly id: AgentChatRuntimeId; readonly kind: AgentChatRuntimeKind; readonly label: string; readonly description?: string; readonly capabilities: AgentChatRuntimeCapabilities; createSession(input?: AgentChatRuntimeCreateSessionInput): AgentChatRuntimeAwaitable>; restoreSession?(snapshot: AgentChatRuntimeSessionSnapshot): AgentChatRuntimeAwaitable>; getSession?(input: { readonly sessionId: AgentChatRuntimeSessionId; readonly abortSignal?: AbortSignal; }): AgentChatRuntimeAwaitable | null>; listSessions?(input?: AgentChatRuntimeListSessionsInput): AgentChatRuntimeAwaitable; sendMessage?(input: AgentChatRuntimeSendMessageInput): AgentChatRuntimeAwaitable>; subscribe?(input: AgentChatRuntimeSubscribeInput): AgentChatRuntimeAwaitable>; resume?(input: AgentChatRuntimeResumeInput): AgentChatRuntimeAwaitable>; /** * The server's record of the newest run carrying this run's turn. A runtime * that provides it owns run outcome: a closed `subscribe` stream is then only * a connection fact. Rejects when the record cannot be read. */ readRunState?(input: AgentChatRuntimeReadRunStateInput): Promise; cancel?(input: AgentChatRuntimeCancelInput): Promise; } type FetchLike = typeof fetch; type HeadersFactory = HeadersInit | ((input: { sessionId?: AgentChatRuntimeSessionId; turnId?: AgentChatRuntimeTurnId; runId?: string; }) => HeadersInit | Promise); export interface CreateHttpAgentChatRuntimeOptions { readonly id?: AgentChatRuntimeId; readonly kind?: AgentChatRuntimeKind; readonly label?: string; readonly description?: string; readonly endpoint: string | ((input: { session: AgentChatRuntimeSessionSummary; turn: AgentChatRuntimeTurnInput; }) => string | URL); readonly method?: "POST" | "PUT"; readonly headers?: HeadersFactory; readonly credentials?: RequestCredentials; readonly fetch?: FetchLike; readonly capabilities?: Partial; readonly mapRequest?: (input: { session: AgentChatRuntimeSessionSummary; turn: AgentChatRuntimeTurnInput; turnId: AgentChatRuntimeTurnId; requestTurnId: AgentChatRuntimeTurnId; }) => unknown; /** The turn id a turn's request carries; the runtime's own id by default. */ readonly requestTurnId?: (input: { turn: AgentChatRuntimeTurnInput; turnId: AgentChatRuntimeTurnId; }) => AgentChatRuntimeTurnId; /** * Told once the endpoint accepts a turn, before its events are read. It is * not awaited and anything it throws is ignored. */ readonly onTurnAccepted?: (input: { session: AgentChatRuntimeSessionSummary; turn: AgentChatRuntimeTurnInput; turnId: AgentChatRuntimeTurnId; /** The turn the server stored the run under, as on the returned turn. */ requestTurnId: AgentChatRuntimeTurnId; runId: string; }) => void; /** Called at the final client boundary before a new turn reaches the endpoint. */ readonly beforeStartTurn?: (input: { session: AgentChatRuntimeSessionSummary; turn: AgentChatRuntimeTurnInput; turnId: AgentChatRuntimeTurnId; }) => AgentChatRuntimeAwaitable; readonly mapEvent?: (event: unknown, context: { sessionId: AgentChatRuntimeSessionId; turnId?: AgentChatRuntimeTurnId; runId?: string; }) => TEvent | readonly TEvent[] | null; /** Continues a paused turn using that turn's original request context. */ readonly continueTurn?: (input: { session: AgentChatRuntimeSessionSummary; continuation: AgentChatRuntimeContinueInput; previousTurn?: AgentChatRuntimeTurnInput; startTurn: (turn: AgentChatRuntimeTurnInput) => Promise>; }) => AgentChatRuntimeAwaitable>; readonly cancelEndpoint?: string | ((input: AgentChatRuntimeCancelInput) => string | URL | null); readonly resumeEndpoint?: string | ((input: AgentChatRuntimeSubscribeInput) => string | URL | null); readonly listSessionsEndpoint?: string | URL; readonly getSessionEndpoint?: string | ((input: { sessionId: AgentChatRuntimeSessionId; }) => string | URL); } export interface CreateAgentNativeChatRuntimeOptions { readonly id?: AgentChatRuntimeId; readonly label?: string; readonly description?: string; readonly apiUrl?: string; readonly streamingUrl?: string; readonly headers?: HeadersFactory; readonly fetch?: FetchLike; readonly threadId?: string; readonly browserTabId?: string; readonly surface?: "app" | "dev-frame" | "desktop"; readonly mode?: "act" | "plan"; readonly model?: string; readonly engine?: string; readonly effort?: ReasoningEffort; readonly scope?: unknown; } export declare function createHttpAgentChatRuntime(options: CreateHttpAgentChatRuntimeOptions): AgentChatRuntime; export declare function loadedSkillSlugsFromMessages(messages: readonly AgentChatRuntimeMessage[] | undefined): string[]; export declare const AGENT_CALL_FAILURE_REASON_KEYS: readonly string[]; /** * Where the runtime reports telemetry. It is injected rather than imported so * the runtime stays loadable without the browser analytics module. */ export interface AgentNativeChatRuntimeTelemetry { readonly onTurnSubmitted?: (report: TurnSubmittedReport) => void; } export declare function createAgentNativeChatRuntime(options?: CreateAgentNativeChatRuntimeOptions, telemetry?: AgentNativeChatRuntimeTelemetry): AgentChatRuntime; export declare function isAgentNativeChatRuntime(runtime: AgentChatRuntime | undefined): boolean;