Skip to content
Français

defineWorkflowJob

import { defineWorkflowJob } from "@elie-laloum/outpost";

Return a queue handler that builds a workflow from each trigger job input and starts it under the job runId, with the job signal and checkpoint.version plus an input digest as checkpoint version. The job value summarizes the run (status, tasks, paused gates, input requests) with its token usage; a failed or cancelled workflow, or an incompatible checkpoint, completes the job with an error. Creation throws without a workflow factory, checkpoint store and version.

Complete example and detailed rules.

  • optionsRequired
    WorkflowJobOptions
    Workflow factory, checkpoint settings and start options.
  • options.workflowRequired
    (input: WorkflowJson, context: WorkflowJobContext) => Workflow | Promise<Workflow>
    Build the workflow for one job input; the same input must build the same workflow, and it may be asynchronous.
  • options.checkpointRequired
    WorkflowJobCheckpoint
    Checkpoint store and base version shared by every job; creation throws without both.
  • options.startOptional
    WorkflowJobStartOptions | undefined
    Other workflow start options, such as concurrency, budget, onQuota or timeoutMs; checkpoint, signal, decisions and answers are managed by the job.

QueueHandler

export declare function defineWorkflowJob(
  options: WorkflowJobOptions,
): QueueHandler;