import type { WorkflowContext } from "./types.js"; /** * @internal How deep the walk descends before handing the value back to JSON. * * This walk recurses and `JSON.stringify` does not, so a value nested a few * thousand levels deep exhausts the stack here while JSON encodes it without * complaint. Failing such a run with `Maximum call stack size exceeded` raised * from inside the backend is the outcome this module exists to remove, so past * this depth the diagnostic is dropped rather than the run: the value is * encoded the way the backend encoded it before this check existed. */ export declare const MAX_TRAVERSAL_DEPTH = 1000; /** * Serialize one field of a workflow run for durable storage. * * `WorkflowContext` is JSON-representable by contract, but nothing enforced it: * a step writes whatever it returns, and the in-memory backend keeps the value * intact, so a run that never suspends never notices. Persisting the same run * puts it through `JSON.stringify`, which quietly rewrites some values and * refuses others. * * Checking here makes the mismatch legible at the moment it matters: * * - Values JSON cannot encode at all fail the run with the field and path that * produced them, instead of `Do not know how to serialize a BigInt` raised * from inside the backend with nothing pointing back at the step. * - Values it encodes lossily are logged with the same detail, because the * alternative is a step reading a `string` where its predecessor wrote a * `Date`, decided by whether the run happened to pause. * * Durable backends serialize context before its duplicate run projections, so * this check decides the diagnostic rather than the anonymous error a later * field would raise on the same value. * * Scope, stated plainly because the ordering above is easy to read as more: * only `context` is checked. A run's `input`, `output`, `nodeStates`, * `currentNodes`, and `error` are encoded directly, so nothing here inspects * them. That is deliberate for now: `nodeStates` carries a `Date` on every * node, so checking it would report the framework's own timestamps on every * run. Anything the framework writes into `context` has to obey the same rule * it asks of a step, which is why the loop encodes its child node states * rather than being exempted from the check. */ /** @internal Prepare the exact JSON value and encoded string for durable storage. */ export declare function prepareWorkflowJson(value: unknown, label: string, runId?: string): { normalized: unknown; serialized: string; }; export declare function serializeWorkflowJson(value: unknown, label: string, runId?: string): string; /** Serialize a workflow context for durable storage. */ export declare function serializeWorkflowContext(context: WorkflowContext, runId?: string): string; //# sourceMappingURL=context-serialization.d.ts.map