import { AgentMessage, InputMessage } from "./AgentMessage.js"; import { AgentRunConfig, RunStatus } from "./AgentStore.js"; //#region src/agent-runtime/AgentRuntime.d.ts export declare const AgentErrorCode: { readonly ExecError: "EXEC_ERROR"; }; export type AgentErrorCode = (typeof AgentErrorCode)[keyof typeof AgentErrorCode]; export interface ThreadObject { id: string; object: "thread"; createdAt: number; metadata: Record; } export interface ThreadObjectWithMessages extends ThreadObject { messages: AgentMessage[]; } export interface RunObject { id: string; object: "thread.run"; createdAt: number; threadId: string; status: RunStatus; lastError?: { code: string; message: string; } | null; startedAt?: number | null; completedAt?: number | null; cancelledAt?: number | null; failedAt?: number | null; usage?: { promptTokens: number; completionTokens: number; totalTokens: number; } | null; metadata?: Record; config?: AgentRunConfig; } export interface CreateRunInput { threadId?: string; /** * Populated by AgentRuntime before calling execRun. * - true: threadId was provided (resume existing conversation) * - false: no threadId provided, new thread created */ isResume?: boolean; input: { messages: InputMessage[]; }; config?: AgentRunConfig; /** * Metadata for the run. Stored verbatim on the run record, and additionally * shallow-merged into the thread metadata (`meta.json`): * - For an auto-created thread, it initializes the thread metadata. * - For an existing thread, the keys are shallow-merged: new values overwrite * matching keys, while keys not present are preserved. * - An omitted or empty object leaves the thread metadata unchanged. */ metadata?: Record; } /** * Options for {@link AgentRuntime.createThread}. * * `metadata` is forwarded verbatim to {@link AgentStore.createThread} so callers * can persist additional business semantics on the thread record (e.g. the * resolved agent name, owning sandbox id, trace id). */ export interface CreateThreadOptions { metadata?: Record; } export interface StreamEvent { seq: number; type: string; data: unknown; ts: number; } export interface GetThreadOptions { /** When true, return all message types (system, result, stream_event, etc.). * Defaults to false — only user and assistant messages are returned. */ includeAllMessages?: boolean; } //#endregion