startServer boots a multi-workflow HTTP server with REST endpoints for run lifecycle, SSE event streams, and human-in-the-loop approvals. For a single-workflow variant alongside bunx smithers-orchestrator up, see Serve Mode.
API reference: Server & Gateway lists every server and gateway export, its options, and links to source and tests.
Quick start
ServerOptions
startServer returns a listening http.Server. headersTimeout and requestTimeout are applied to that server to bound slow header/body uploads.
API Routes (TOON)
Content-Type: application/json, Cache-Control: no-store, and X-Content-Type-Options: nosniff. SSE events are named smithers and carry SmithersEvent JSON; the stream sends a keep-alive comment every 10 s and closes on terminal state.
Errors use the envelope { "error": { "code", "message", "details" } }. Common codes: INVALID_REQUEST, INVALID_JSON, PAYLOAD_TOO_LARGE, RUN_ID_REQUIRED, RUN_NOT_FOUND, RUN_ALREADY_EXISTS, RUN_NOT_ACTIVE, NOT_FOUND, UNAUTHORIZED, WORKFLOW_PATH_OUTSIDE_ROOT, DB_NOT_CONFIGURED, SERVER_ERROR.
Tool surface
Tools resolve relative torootDir. The example below exposes a workflow that uses the built-in bash tool through the server; clients call it via POST /v1/runs.
allowNetwork: false (the default) keeps bash offline. Set rootDir to constrain the filesystem the workflow can touch.
Authentication
WhenauthToken is configured (directly or via SMITHERS_API_KEY), every request must include either:
Authorization: Bearer <token>, orx-smithers-key: <token>.
401. No scopes; for finer access control use the Gateway.
Notes
- Each
POST /v1/runsand/resumereloads the workflow source via a content-addressed shadow file with the same extension as the source, so edits take effect on the next call without a restart. - Active runs heartbeat to
_smithers_runs.heartbeat_at_msevery 1 s; stale rows (no heartbeat in 30 s) are treated as crashed and may be resumed. - When a server-level
dbdiffers from a workflow’s database, runs and events are mirrored asynchronously to the server db so they show up inGET /v1/runs. - Metrics are exported via
/metrics; setSMITHERS_OTEL_ENABLED=1plusOTEL_EXPORTER_OTLP_ENDPOINTfor OTLP. See Observability.