Express API to define playbooks with dependent steps and execute them with parallelism and failure handling.
Prereqs: Node.js v22+
-
Install dependencies:
npm install
-
Build and start the server (TypeScript):
npm run build && npm start
-
For development with live TypeScript execution:
npm run dev
-
src/server.ts: Bootstrap and HTTP serversrc/web/app.ts: Express app factory, middleware wiringsrc/web/config/env.ts: Environment parsing/validation (zod)src/web/middleware/*: Not-found and error handlerssrc/web/utils/asyncHandler.ts: Async route wrappersrc/web/routes/*: Route definitions (v1, health)src/web/controllers/*: Request validation and orchestrationsrc/services/*: Core services (executor, storage)src/types.ts: Shared domain types
-
Health check:
POST /api/v1/playbooks– Create a playbookGET /api/v1/playbooks– List playbooksGET /api/v1/playbooks/:id– Fetch a playbookPOST /api/v1/runs– Trigger a runGET /api/v1/runs/:id– Fetch run status/logsGET /health– Health check
Create a playbook:
curl -X POST http://localhost:3000/api/v1/playbooks
-H "Content-Type: application/json"
-d '{
"name": "Customer Health Check",
"steps": [
{"id": "fetch-metrics", "type": "transform", "config": {"metric": "login_frequency"}},
{"id": "fetch-support", "type": "transform", "config": {"source": "support_tickets"}},
{"id": "analyze-health", "type": "llm", "config": {"prompt": "Analyze customer health from metrics and support tickets"}, "dependencies": ["fetch-metrics", "fetch-support"]}
]
}'
Trigger a run:
curl -X POST http://localhost:3000/api/v1/runs
-H "Content-Type: application/json"
-d '{"playbookId": "", "context": {"customerId": "cust_789"}}'
Check status:
curl http://localhost:3000/api/v1/runs/
- Validates step IDs are unique and all dependencies reference existing steps.
- Runs steps in parallel "waves": any steps whose dependencies are completed start together.
- Detects deadlocks/cycles: if no runnable steps remain while steps are unfinished, the run fails.
transform: sleeps 1–3s, returns{ transformed: true, input }.llm(default mock): returns{ text: "mocked output", prompt, input }.- Failure simulation: each step has a 10% chance to fail; on first failure the run is marked failed and no further steps are scheduled (in-flight steps may still complete).
- Each step receives
{ config, context, deps }wheredepsis a map of dependency step outputs. - Run status includes per-step status and output; top-level
outputaggregates all step outputs.
- Storage is in-memory and resets on restart.
- The
llmstep type returns a mocked response by default.