import type { StepResult, WorkflowRunState } from '../../../workflows/index.js'; import type { WorkflowRun, WorkflowRuns, StorageListWorkflowRunsInput, UpdateWorkflowStateOptions } from '../../types.js'; import type { InMemoryDB } from '../inmemory-db.js'; import { WorkflowsStorage } from './base.js'; /** * Deep-clone in-memory workflow state. * * We previously used `JSON.parse(JSON.stringify(x))` here, but the agent loop * and workflow engine legitimately place values in step results that don't * survive JSON round-tripping: * - `Date` instances (e.g. `response.timestamp`) — JSON turns them into ISO * strings, downstream consumers that do `.getTime()` then break. * - Explicitly-`undefined` properties (e.g. `headers`, `providerMetadata`, * `usage.{cacheRead, cacheWrite, reasoning}`) — JSON drops keys with * `undefined` values, breaking snapshot assertions that include them. * - `Error` instances (e.g. tool execution failures, AssertionErrors from * inside `tool.execute`) — JSON strips `message`/`name`/`stack` (non- * enumerable). `structuredClone` isn't enough either — it preserves the * Error type but drops subclass-specific enumerable props (`actual`, * `expected`, `operator`). * * The custom walk below preserves all of that. It also handles builtins with * internal slots explicitly — `Map`, `Set`, `RegExp`, `URL`, `ArrayBuffer`, * typed arrays, and `DataView` — because cloning them via `Object.create(proto)` * would produce a value that passes `instanceof` but whose methods throw (the * internal slots were never initialized). Null-prototype dictionaries keep * their null prototype. */ /** @internal Exported for testing only. */ export declare function cloneRunData(value: T): T; export declare class WorkflowsInMemory extends WorkflowsStorage { private db; constructor({ db }: { db: InMemoryDB; }); supportsConcurrentUpdates(): boolean; dangerouslyClearAll(): Promise; private getWorkflowKey; updateWorkflowResults({ workflowName, runId, stepId, result, requestContext, }: { workflowName: string; runId: string; stepId: string; result: StepResult; requestContext: Record; }): Promise>>; updateWorkflowState({ workflowName, runId, opts, }: { workflowName: string; runId: string; opts: UpdateWorkflowStateOptions; }): Promise; persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot, createdAt, updatedAt, }: { workflowName: string; runId: string; resourceId?: string; snapshot: WorkflowRunState; createdAt?: Date; updatedAt?: Date; }): Promise; loadWorkflowSnapshot({ workflowName, runId, }: { workflowName: string; runId: string; }): Promise; listWorkflowRuns({ workflowName, fromDate, toDate, perPage, page, resourceId, status, }?: StorageListWorkflowRunsInput): Promise; getWorkflowRunById({ runId, workflowName, }: { runId: string; workflowName?: string; }): Promise; deleteWorkflowRunById({ runId, workflowName }: { runId: string; workflowName: string; }): Promise; } //# sourceMappingURL=inmemory.d.ts.map