import type { ChatModelAdapter } from "@assistant-ui/react"; import type { ActionChatUIConfig } from "../../action-ui.js"; import type { AgentMcpAppPayload } from "../../mcp-client/app-result.js"; import type { ReasoningEffort } from "../../shared/reasoning-effort.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 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; } 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; } export interface AgentChatRuntimeToolResultPart extends AgentChatRuntimeContentPartBase<"tool-result"> { readonly toolCallId: AgentChatRuntimeToolCallId; readonly toolName?: string; readonly result?: unknown; readonly resultText?: string; readonly isError?: boolean; 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 metadata?: AgentChatRuntimeMetadata; } export interface AgentChatRuntimeAttachment { readonly id?: string; readonly name: string; readonly mediaType?: string; readonly data?: string; readonly url?: 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 AgentChatRuntimeCapabilities { readonly messages: AgentChatRuntimeMessageCapabilities; readonly tools?: AgentChatRuntimeToolCapabilities; readonly sessions?: AgentChatRuntimeSessionCapabilities; readonly cancellation?: AgentChatRuntimeCancellationCapabilities; readonly models?: AgentChatRuntimeModelCapabilities; readonly artifacts?: AgentChatRuntimeArtifactCapabilities; 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 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 AgentChatRuntimeContinueInput { readonly turnId?: AgentChatRuntimeTurnId; readonly prompt?: string; readonly approval?: AgentChatRuntimeApprovalResponse; 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 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; } 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 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; } export interface AgentChatRuntimeApprovalResolvedEvent extends AgentChatRuntimeEventBase<"approval-resolved"> { readonly approvalId: string; readonly approved: boolean; readonly message?: string; } export interface AgentChatRuntimeStatusEvent extends AgentChatRuntimeEventBase<"status"> { readonly level?: "info" | "warning" | "error"; readonly message: string; readonly code?: string; } 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 cause?: unknown; } 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 | AgentChatRuntimeToolStartEvent | AgentChatRuntimeToolDeltaEvent | AgentChatRuntimeToolDoneEvent | AgentChatRuntimeApprovalRequestEvent | AgentChatRuntimeApprovalResolvedEvent | AgentChatRuntimeStatusEvent | AgentChatRuntimeArtifactEvent | AgentChatRuntimeFileEvent | AgentChatRuntimeUsageEvent | AgentChatRuntimeErrorEvent | AgentChatRuntimeDoneEvent; export type AgentChatRuntimeEvent = AgentChatRuntimeKnownEvent | TCustomEvent; export interface AgentChatRuntimeTurn { readonly id?: AgentChatRuntimeTurnId; readonly sessionId: AgentChatRuntimeSessionId; readonly runId?: string; readonly metadata?: AgentChatRuntimeMetadata; readonly events: AsyncIterable; 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 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>; 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; }) => unknown; readonly mapEvent?: (event: unknown, context: { sessionId: AgentChatRuntimeSessionId; turnId?: AgentChatRuntimeTurnId; runId?: string; }) => TEvent | readonly TEvent[] | null; 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 headers?: HeadersFactory; readonly fetch?: FetchLike; readonly threadId?: string; readonly browserTabId?: string; readonly surface?: "app" | "dev-frame"; readonly mode?: "act" | "plan"; readonly model?: string; readonly engine?: string; readonly effort?: ReasoningEffort; readonly scope?: unknown; } export interface CreateAgentChatRuntimeAdapterOptions { readonly sessionId?: AgentChatRuntimeSessionId; readonly threadId?: string; readonly modelRef?: { current: string | undefined; }; readonly effortRef?: { current: ReasoningEffort | undefined; }; readonly metadata?: AgentChatRuntimeMetadata; } export declare function createHttpAgentChatRuntime(options: CreateHttpAgentChatRuntimeOptions): AgentChatRuntime; export declare function createAgentNativeChatRuntime(options?: CreateAgentNativeChatRuntimeOptions): AgentChatRuntime; export declare function createAgentChatRuntimeAdapter(runtime: AgentChatRuntime, options?: CreateAgentChatRuntimeAdapterOptions): ChatModelAdapter; export {}; //# sourceMappingURL=runtime.d.ts.map