Skip to main content
Serve mode starts a Hono-based HTTP server alongside a running workflow. Every route operates on the single active run: no workflow path or run ID in requests.
API reference: Server & Gateway lists every server and gateway export, its options, and links to source and tests.

CLI

A non-loopback --host (like 0.0.0.0) requires --auth-token (or --insecure, dangerous). The default 127.0.0.1 needs neither. The process stays alive after the workflow completes, so final state stays queryable. Ctrl+C stops both server and workflow. Detached mode:

Programmatic

createServeApp returns a standard Hono app. Mount it with Bun.serve, pass it to another Hono app via app.route(), or use app.fetch in tests.

ServeOptions


Authentication

When authToken is configured, every route except /health requires:
  • Authorization: Bearer <token>, or
  • x-smithers-key: <token>
Missing or invalid tokens receive 401.

Routes

GET /health

Returns 200 regardless of auth.

GET /

Run status and node summary.

GET /events

SSE stream of lifecycle events, same format as the multi-workflow server.
  • Polls every 500ms.
  • Auto-closes when the run reaches a terminal state.
  • Reconnect with ?afterSeq=N to resume.

GET /frames

Rendered workflow frames.

POST /approve/:nodeId

Approve a pending approval gate. All fields optional. Returns { "runId": "run-1234" }.
For select and rank approvals, decision must contain a valid selection or ranking. A stable decision envelope with value is also accepted.

POST /deny/:nodeId

Deny a pending approval gate. Same body as /approve/:nodeId.

POST /cancel

Cancel the running workflow.
Note: Runs in waiting-approval or waiting-timer state are cancelled immediately and return 200.

GET /metrics

Prometheus text exposition, same metrics as the multi-workflow server.

Error Format

Unknown routes return 404 with code NOT_FOUND.

Serve Mode vs Multi-Workflow Server


Example