cortex workflow

A DSL-based workflow engine for defining and executing multi-step agent tasks. Supports sequential steps, conditional branching, parallel execution, goto jumps, and human-in-the-loop approval waits.

Usage

cortex workflow <subcommand> [options]

Subcommands

SubcommandDescription
runExecute a workflow
approveApprove a paused workflow step

Workflow Nodes

Node TypeDescription
stepSequential execution step
branchConditional branching (if/then/else)
parallelParallel execution of multiple steps
gotoJump to a specific step (loops)
waitPause execution awaiting human approval

Fluent API

Workflows are built using a fluent builder pattern:

Workflow.create("deploy")
  .step("build", async (ctx) => { ... })
  .step("test", async (ctx) => { ... })
  .branch("check", (ctx) => ctx.testsPassed)
    .then("deploy", async (ctx) => { ... })
    .else("rollback", async (ctx) => { ... })
  .waitForApproval("confirm", "Deploy to production?")
  .execute(context)

Lifecycle Callbacks

Each step supports lifecycle hooks:

  • onStepStart — Called before step execution
  • onStepEnd — Called after step execution completes

Built-in Workflows

Cortex ships with a health-check workflow that runs system diagnostics:

  • Disk space check (df)
  • Memory check (free)
  • Returns system health report

Examples

# Run a workflow
cortex workflow run

# Approve a waiting workflow step
cortex workflow approve <workflow-id>