Workflows
Multi-step workflow engine with graph execution, checkpoints, human-in-the-loop pauses, and cron scheduling.
Overview
@consensus-tools/workflows defines multi-step workflows with node-graph execution, checkpoint persistence, human-in-the-loop pauses, and cron scheduling.
Installation
Quick start
API reference
WorkflowRunner
The primary interface for creating, running, and resuming workflows.
Built-in templates
Three pre-built workflow templates are included:
| Template | ID | Description |
|---|---|---|
| PR Merge Guard | template-github-pr | GitHub PR → parallel agent review → guard → human approval → merge |
| Linear Task Decomposition | template-linear-tasks | Linear task → agent decomposition → guard → human approval → create subtasks |
| Cron Auto-Assign | template-linear-assign | Cron → fetch unassigned subtasks → parallel review → guard → assign |
Node types
Node types: trigger, agent, group (parallel), guard, hitl, action.
CronScheduler
ℹ
HITL pause/resume
HITL nodes pause execution at waiting status. Call runner.resume(workflowId, runId, decision, userId) to continue. No automatic retry on failed nodes — explicit resume required.
Exports reference
| Export | Kind | Description |
|---|---|---|
WorkflowRunner | Class | Create, run, resume workflows with checkpoint persistence |
NodeExecutor | Class | Execute individual nodes in a workflow graph |
validateWorkflowDefinition | Function | Validate a workflow definition before execution |
CronScheduler | Class | IStorage-backed cron scheduling with dedup |
shouldRunNow(expr) | Function | Check if a 5-field cron expression matches now |
prMergeGuardTemplate | Const | Template: GitHub PR merge guard |
linearTaskDecompTemplate | Const | Template: Linear task decomposition |
cronAutoAssignTemplate | Const | Template: Cron auto-assign subtasks |
listTemplates() / getTemplateById(id) | Function | Discover built-in templates |
WorkflowTemplate | Type | Template definition with id, name, steps, and handler |
WorkflowStepHandler | Type | Handler function for template-based workflow steps |
WorkflowContext | Type | Context passed to step handlers |
WorkflowStepResult | Type | Step result with status (completed / failed / waiting) |
NodeExecutorDeps | Type | Dependencies for NodeExecutor constructor |
WorkflowNode | Type | Single node in a workflow graph definition |
WorkflowDefinition | Type | Full workflow definition with nodes array |
NodeOutput | Type | Output from a single node execution |
TemplateDefinition | Type | Metadata for a built-in template |
Related
- core -- JobEngine and storage that workflows depends on
- notifications -- HITL dispatch via Slack, Teams, Discord
- integrations -- GitHub and Linear adapters used by templates