import type { Normalized } from "../../shared/schema-utils/index.js"; import type { WorkflowBlockConfigFriendlyStruct, WorkflowBlockConfigFriendlyValueOf } from "../../shared/workflow/config-schema/index.js"; import type { WorkflowOutcomeDataNode, WorkflowOutcomeDataRuntimeValueOf } from "../../shared/workflow/outcome-data-schema/index.js"; import type { WorkflowOutcomeIdentifier } from "../../shared/workflow/outcome-identifier.js"; export type WorkflowBlockExecutorConfig = WorkflowBlockConfigFriendlyValueOf>; /** * Runtime metadata passed into a step block's `execute` handler. */ export type WorkflowBlockExecutorMetadata = { workflowId: string; workflowVersionId: string; workflowBlockId: string; workflowRunId: string; uniqueExecutionId: string; workflowTitle: string; workflowUrl: string; runUrl: string; /** Used to finish a deferred workflow block execution. */ finishCallbackUrl: string; }; /** * Why a block execution is deferring. Shown as a unique badge on the block in the workflow's run * view, instead of the usual "Running" badge. * * - `"action-needed"`: waiting for a person to do something, such as click a button in a message. * - `"waiting"`: a generic waiting status, such as waiting for a fixed amount of time. */ export type WorkflowBlockExecutorDeferReason = "action-needed" | "waiting"; export type WorkflowBlockExecutorReturn = ({ /** Finish the block execution with an outcome. */ type: "outcome"; data: WorkflowOutcomeDataRuntimeValueOf | null; } & WorkflowOutcomeIdentifier) | { /** Finish the block execution without an outcome. */ type: "exit"; } | { /** * Raise an unclassified error. * * With no `id`, the run retries when `retryable` is set, then fails, or follows the * catch-all error path when the workflow author has turned on continue-on-error. */ type: "error"; errorMessage: string; retryable?: boolean; } | ({ /** * Raise a classified error. * * `id` must match an `` in the configurator. The workflow author decides * whether this outcome is handled. `data` is that outcome's payload. Pass `null` when * the outcome has no payload. */ type: "error"; errorMessage: string; retryable?: boolean; data: WorkflowOutcomeDataRuntimeValueOf | null; } & WorkflowOutcomeIdentifier) | { /** Keep this block execution running until it is finished later via `finishCallbackUrl`. */ type: "defer"; /** Optional reason to show the user why the block is deferring. */ reason?: WorkflowBlockExecutorDeferReason; }; /** Context passed into a step block's `execute` handler. */ export type WorkflowBlockExecutorContext = { config: WorkflowBlockExecutorConfig; metadata: WorkflowBlockExecutorMetadata; }; export type WorkflowBlockExecutor = (ctx: WorkflowBlockExecutorContext) => Promise | WorkflowBlockExecutorReturn; //# sourceMappingURL=execute.d.ts.map