import { AgentMessage, InputMessage } from "./AgentMessage.js"; import { GetThreadOptions } from "./AgentRuntime.js"; //#region src/agent-runtime/AgentStore.d.ts export declare const AgentObjectType: { readonly Thread: "thread"; readonly ThreadRun: "thread.run"; }; export type AgentObjectType = (typeof AgentObjectType)[keyof typeof AgentObjectType]; export declare const RunStatus: { readonly Queued: "queued"; readonly InProgress: "in_progress"; readonly Completed: "completed"; readonly Failed: "failed"; readonly Cancelled: "cancelled"; readonly Cancelling: "cancelling"; readonly Expired: "expired"; }; export type RunStatus = (typeof RunStatus)[keyof typeof RunStatus]; export interface AgentRunConfig { maxIterations?: number; timeoutMs?: number; } export interface ThreadRecord { id: string; object: typeof AgentObjectType.Thread; /** * All messages in the thread, stored as SDK-format AgentMessage objects. * In OSSAgentStore the messages are stored separately as a JSONL file * and assembled on read — callers should treat this as a unified view * regardless of the underlying storage layout. */ messages: AgentMessage[]; metadata: Record; createdAt: number; /** * Id of the most recently created run on this thread, maintained by * `createRun` as a best-effort pointer so callers can resolve a thread's * latest run without an external index. Absent on threads that have no * runs yet, and on threads created before this field existed — a missing * value must be treated as "no recent run". */ latestRunId?: string; } export interface RunRecord { id: string; object: typeof AgentObjectType.ThreadRun; threadId?: string; status: RunStatus; input: InputMessage[]; lastError?: { code: string; message: string; } | null; usage?: { promptTokens: number; completionTokens: number; totalTokens: number; } | null; config?: AgentRunConfig; metadata?: Record; createdAt: number; startedAt?: number | null; completedAt?: number | null; cancelledAt?: number | null; failedAt?: number | null; } export interface AgentStore { init?(): Promise; destroy?(): Promise; createThread(metadata?: Record): Promise; getThread(threadId: string, options?: GetThreadOptions): Promise; /** * Shallow-merge metadata into an existing thread. * New values overwrite matching keys; omitted keys are preserved. */ updateThreadMetadata?(threadId: string, metadata: Record): Promise; appendMessages(threadId: string, messages: AgentMessage[]): Promise; createRun(input: InputMessage[], threadId?: string, config?: AgentRunConfig, metadata?: Record): Promise; getRun(runId: string): Promise; /** * Id of the most recent run created on the thread, or `null` when the * thread exists but has no recorded run (including threads created before * run tracking existed). Throws AgentNotFoundError when the thread itself * does not exist. */ getLatestRunId(threadId: string): Promise; updateRun(runId: string, updates: Partial): Promise; } //#endregion