//#region src/errors/index.d.ts /** * Typed error surface for `@graphorin/workflow`. Every workflow-level * failure lands as a subclass of {@link WorkflowError} carrying the * stable string `code` discriminator so consumers can pattern-match * without inspecting messages. * * @packageDocumentation */ /** * Stable `code` discriminator on every {@link WorkflowError} subclass. * Treat as a string literal union for `switch (err.code)` style code. * * @stable */ type WorkflowErrorCode = 'invalid-config' | 'invalid-channel-write' | 'multi-write-into-latest-value' | 'unknown-node' | 'thread-not-found' | 'checkpoint-not-found' | 'checkpoint-version-conflict' | 'resume-without-suspension' | 'concurrent-resume-rejected' | 'workflow-aborted' | 'workflow-cancel-timeout' | 'max-steps-exceeded' | 'node-execution-failed' | 'reducer-failed' | 'state-validation-failed' | 'dead-end' | 'state-not-serializable' | 'node-timeout' | 'workflow-version-mismatch' | 'workflow-divergence' | 'pause-not-found' | 'pause-replay-divergence' | 'awakeable-payload-invalid' | 'timer-driver-store-unsupported'; /** * Base error class for all `@graphorin/workflow` failures. * * @stable */ declare class WorkflowError extends Error { readonly code: WorkflowErrorCode; readonly cause?: unknown; readonly hint?: string; constructor(code: WorkflowErrorCode, message: string, opts?: { readonly cause?: unknown; readonly hint?: string; }); } /** Thrown by `createWorkflow` on configuration validation failure. */ declare class InvalidWorkflowConfigError extends WorkflowError { constructor(message: string, hint?: string); } /** Thrown when a node writes a key not declared in `stateSchema`. */ declare class InvalidChannelWriteError extends WorkflowError { readonly nodeName: string; readonly channel: string; constructor(nodeName: string, channel: string); } /** Thrown when more than one writer in a single execution step writes a `LatestValue`. */ declare class MultiWriteError extends WorkflowError { readonly channel: string; readonly writers: ReadonlyArray; constructor(channel: string, writers: ReadonlyArray); } /** Thrown by `createWorkflow` when an edge references a node that is not registered. */ declare class UnknownNodeError extends WorkflowError { readonly nodeName: string; constructor(nodeName: string, context: string); } /** Thrown when `Workflow.resume` cannot find the named thread. */ declare class ThreadNotFoundError extends WorkflowError { readonly threadId: string; constructor(threadId: string); } /** Thrown when `Workflow.fork` cannot find the named checkpoint. */ declare class CheckpointNotFoundError extends WorkflowError { readonly threadId: string; readonly checkpointId: string; constructor(threadId: string, checkpointId: string); } /** Thrown when a second concurrent resume is attempted for the same thread. */ declare class ConcurrentResumeError extends WorkflowError { readonly threadId: string; constructor(threadId: string); } /** Thrown by `Workflow.resume` when the named thread is not in a suspended state. */ declare class ResumeWithoutSuspensionError extends WorkflowError { readonly threadId: string; readonly status: string; constructor(threadId: string, status: string); } /** Thrown when a workflow run is cancelled via `AbortSignal`. */ declare class WorkflowAbortedError extends WorkflowError { readonly threadId: string; constructor(threadId: string, reason?: string); } /** Thrown when a node throws and the failure is propagated through the engine. */ declare class NodeExecutionError extends WorkflowError { readonly nodeName: string; constructor(nodeName: string, cause: unknown); } /** * Thrown when a node body exceeds its wall-clock budget. The task's * `ctx.signal` is aborted first so a well-behaved body can stop; * bodies that ignore the signal keep running in the background (same * contract as cancellation). */ declare class NodeTimeoutError extends WorkflowError { readonly nodeName: string; readonly timeoutMs: number; constructor(nodeName: string, timeoutMs: number); } /** * Thrown on resume when the stored frontier was written by a different * `WorkflowConfig.version` - replaying persisted state through * changed code must fail loudly, not silently diverge. Opt out per * call via `allowVersionMismatch`. */ declare class WorkflowVersionMismatchError extends WorkflowError { readonly threadId: string; readonly storedVersion: string; readonly currentVersion: string; constructor(threadId: string, storedVersion: string, currentVersion: string); } /** * Thrown on resume when the persisted frontier references nodes that no * longer exist in the workflow definition - the definition changed * mid-flight and a silent re-plan would diverge from the journal. */ declare class WorkflowDivergenceError extends WorkflowError { readonly threadId: string; readonly missingNodes: ReadonlyArray; constructor(threadId: string, missingNodes: ReadonlyArray); } /** * Thrown by `resolveAwakeable` / `approve` when no pending pause * carries the requested name. */ declare class PauseNotFoundError extends WorkflowError { readonly threadId: string; readonly pauseName: string; constructor(threadId: string, pauseName: string); } /** * Thrown when a checkpoint write detects that another writer advanced * the thread concurrently - the loser must not fork the * timeline. */ declare class CheckpointVersionConflictError extends WorkflowError { readonly threadId: string; readonly expectedParentId: string; readonly actualLatestId: string; constructor(threadId: string, expectedParentId: string, actualLatestId: string); } /** * Thrown when planning stalls with no runnable tasks and no satisfied * END edge - an all-false conditional fan is an error, not a * silent completion. */ declare class DeadEndError extends WorkflowError { readonly workflowName: string; readonly stalledNodes: ReadonlyArray; constructor(workflowName: string, stalledNodes: ReadonlyArray); } /** * Thrown when a value that rides the checkpoint would not survive a * JSON round-trip - Map/Set/Date/class instances silently * degrade with the SQLite store, so every store rejects them eagerly. * Covers EVERYTHING that round-trips through the checkpoint: * channel state, pause values and approval payloads, dispatchArgs, * satisfied resume values, and operator directives (validated at * resume entry, before the node body runs). The pseudo-channels * `` / `` / `` / `` * name the offending surface. */ declare class StateNotSerializableError extends WorkflowError { readonly channel: string; readonly path: string; constructor(channel: string, path: string, kind: string); } /** Thrown when a `Reducer` channel's `reduce(...)` callback throws. */ declare class ReducerError extends WorkflowError { readonly channel: string; constructor(channel: string, cause: unknown); } //#endregion export { CheckpointNotFoundError, CheckpointVersionConflictError, ConcurrentResumeError, DeadEndError, InvalidChannelWriteError, InvalidWorkflowConfigError, MultiWriteError, NodeExecutionError, NodeTimeoutError, PauseNotFoundError, ReducerError, ResumeWithoutSuspensionError, StateNotSerializableError, ThreadNotFoundError, UnknownNodeError, WorkflowAbortedError, WorkflowDivergenceError, WorkflowError, WorkflowErrorCode, WorkflowVersionMismatchError }; //# sourceMappingURL=index.d.ts.map