import type { StructuredError } from '@workflow/world'; import type { StringValue } from 'ms'; /** * @internal * All the slugs of the errors used for documentation links. */ export declare const ERROR_SLUGS: { readonly NODE_JS_MODULE_IN_WORKFLOW: "node-js-module-in-workflow"; readonly START_INVALID_WORKFLOW_FUNCTION: "start-invalid-workflow-function"; readonly SERIALIZATION_FAILED: "serialization-failed"; readonly WEBHOOK_INVALID_RESPOND_WITH_VALUE: "webhook-invalid-respond-with-value"; readonly WEBHOOK_RESPONSE_NOT_SENT: "webhook-response-not-sent"; readonly FETCH_IN_WORKFLOW_FUNCTION: "fetch-in-workflow"; readonly TIMEOUT_FUNCTIONS_IN_WORKFLOW: "timeout-in-workflow"; readonly HOOK_CONFLICT: "hook-conflict"; }; type ErrorSlug = (typeof ERROR_SLUGS)[keyof typeof ERROR_SLUGS]; interface WorkflowErrorOptions extends ErrorOptions { /** * The slug of the error. This will be used to generate a link to the error documentation. */ slug?: ErrorSlug; } /** * The base class for all Workflow-related errors. * * This error is thrown by the Workflow DevKit when internal operations fail. * You can use this class with `instanceof` to catch any Workflow DevKit error. * * @example * ```ts * try { * await getRun(runId); * } catch (error) { * if (error instanceof WorkflowError) { * console.error('Workflow DevKit error:', error.message); * } * } * ``` */ export declare class WorkflowError extends Error { readonly cause?: unknown; constructor(message: string, options?: WorkflowErrorOptions); static is(value: unknown): value is WorkflowError; } /** * Thrown when a Workflow API request fails. * * This error is thrown when HTTP requests to the Workflow backend fail, * typically due to network issues, invalid requests, or server errors. * * @example * ```ts * try { * await startWorkflow('myWorkflow', input); * } catch (error) { * if (error instanceof WorkflowAPIError) { * console.error(`API error (${error.status}):`, error.message); * } * } * ``` */ export declare class WorkflowAPIError extends WorkflowError { status?: number; code?: string; url?: string; constructor(message: string, options?: { status?: number; url?: string; code?: string; cause?: unknown; }); static is(value: unknown): value is WorkflowAPIError; } /** * Thrown when a workflow run fails during execution. * * This error indicates that the workflow encountered a fatal error * and cannot continue. The `cause` property contains the underlying * error with its message, stack trace, and optional error code. * * @example * ``` * const run = await getRun(runId); * if (run.status === 'failed') { * // WorkflowRunFailedError will be thrown * } * ``` */ export declare class WorkflowRunFailedError extends WorkflowError { runId: string; cause: Error & { code?: string; }; constructor(runId: string, error: StructuredError); static is(value: unknown): value is WorkflowRunFailedError; } /** * Thrown when attempting to get results from an incomplete workflow run. * * This error occurs when you try to access the result of a workflow * that is still running or hasn't completed yet. */ export declare class WorkflowRunNotCompletedError extends WorkflowError { runId: string; status: string; constructor(runId: string, status: string); static is(value: unknown): value is WorkflowRunNotCompletedError; } /** * Thrown when the Workflow runtime encounters an internal error. * * This error indicates an issue with workflow execution, such as * serialization failures, starting an invalid workflow function, or * other runtime problems. */ export declare class WorkflowRuntimeError extends WorkflowError { constructor(message: string, options?: WorkflowErrorOptions); static is(value: unknown): value is WorkflowRuntimeError; } export declare class WorkflowRunNotFoundError extends WorkflowError { runId: string; constructor(runId: string); static is(value: unknown): value is WorkflowRunNotFoundError; } export declare class WorkflowRunCancelledError extends WorkflowError { runId: string; constructor(runId: string); static is(value: unknown): value is WorkflowRunCancelledError; } /** * Thrown when attempting to operate on a workflow run that requires a newer World version. * * This error occurs when a run was created with a newer spec version than the * current World implementation supports. Users should upgrade their @workflow packages. */ export declare class RunNotSupportedError extends WorkflowError { readonly runSpecVersion: number; readonly worldSpecVersion: number; constructor(runSpecVersion: number, worldSpecVersion: number); static is(value: unknown): value is RunNotSupportedError; } /** * A fatal error is an error that cannot be retried. * It will cause the step to fail and the error will * be bubbled up to the workflow logic. */ export declare class FatalError extends Error { fatal: boolean; constructor(message: string); static is(value: unknown): value is FatalError; } export interface RetryableErrorOptions { /** * The number of milliseconds to wait before retrying the step. * Can also be a duration string (e.g., "5s", "2m") or a Date object. * If not provided, the step will be retried after 1 second (1000 milliseconds). */ retryAfter?: number | StringValue | Date; } /** * An error that can happen during a step execution, allowing * for configuration of the retry behavior. */ export declare class RetryableError extends Error { /** * The Date when the step should be retried. */ retryAfter: Date; constructor(message: string, options?: RetryableErrorOptions); static is(value: unknown): value is RetryableError; } export declare const VERCEL_403_ERROR_MESSAGE = "Your current vercel account does not have access to this resource. Use `vercel login` or `vercel switch` to ensure you are linked to the right account. You might need to run `vercel env pull` to use the latest environment variables."; export {}; //# sourceMappingURL=index.d.ts.map