workflow-studio
Public API reference for config helpers, adapters, and CLI integration points
Overview
workflow-studio is the user-facing package for remote compute configuration and tooling.
It provides:
- config helpers (
defineWorkflowStudioConfig,defineWorkflowConfig), - framework adapter helpers,
- proxy-trigger helper functions,
- ownership diagnostics handler,
- worker and compute deployment CLI commands.
Config API
defineWorkflowStudioConfig(config)
Defines typed configuration loaded from workflow.config.*.
import { defineWorkflowStudioConfig } from 'workflow-studio';
export default defineWorkflowStudioConfig({
execution: {
mode: 'remote',
remoteWorkerUrl: process.env.WORKFLOW_COMPUTE_BASE_URL,
apiKeyEnv: 'WORKFLOW_COMPUTE_API_KEY',
failPolicy: 'error',
},
worker: {
world: ({ env }) => createWorld({ connectionString: env.WORKFLOW_POSTGRES_URL! }),
server: { host: '0.0.0.0', port: 3001 },
security: { requireHttps: true },
auth: { seedApiKeys: [/* ... */] },
storage: { sqlitePath: './data/worker.db' },
},
});execution config fields
Controls how workflow-studio routes execution traffic.
| Field | Type | Default | Description |
|---|---|---|---|
mode | 'local' | 'remote' | 'local' | Execution mode. remote routes to the worker via ComputeClient. |
remoteWorkerUrl | string | — | Base URL of the remote compute worker (required when mode='remote'). |
apiKeyEnv | string | — | Name of the env var holding the worker API key (e.g. 'WORKFLOW_COMPUTE_API_KEY'). |
timeoutMs | number | — | Request timeout for remote calls in milliseconds. |
retries | number | — | Maximum retry attempts for retriable errors. |
failPolicy | 'error' | 'fallback-local' | 'error' | error rejects on remote failure. fallback-local degrades to local execution. |
worker config fields
Configures the remote compute worker process.
worker.server
| Field | Type | Default | Description |
|---|---|---|---|
host | string | — | Bind address (e.g. '0.0.0.0'). |
port | number | — | Listen port. Falls back to PORT env var. |
requestOrigin | string | — | Override origin used in request URL parsing. |
worker.security
| Field | Type | Default | Description |
|---|---|---|---|
requireHttps | boolean | true | Enforce HTTPS for non-local requests. |
rateLimitPerMinute | number | — | Per-key rate limit. |
worker.auth
| Field | Type | Default | Description |
|---|---|---|---|
seedApiKeys | SeedApiKey[] | — | API keys seeded into the worker database on boot. Each key has keyId, secret, projectId, environment, and scopes. |
worker.storage
| Field | Type | Default | Description |
|---|---|---|---|
sqlitePath | string | — | Path to the SQLite database for worker state (API keys, audit logs, deployments). |
artifactDir | string | — | Directory for storing deployment artifacts. |
Worker world forms
worker.world accepts:
- a function returning a complete
World, or - a composed object with
baseand optionalqueue/streamsfactories.
See World Composition for details.
Framework adapters
Next.js
withWorkflowStudioNext(nextConfig, options)— see Next.js guideproxyTriggerFromNext(request, options)proxyWebhookFromNext(request, options)
Nitro
withWorkflowStudioNitro(nitroConfig, options)— see Nitro guideproxyTriggerFromNitro(request, options)proxyWebhookFromNitro(request, options)
SvelteKit
withWorkflowStudioSvelteKit(config, options)— see SvelteKit guideproxyTriggerFromSvelteKit(request, options)proxyWebhookFromSvelteKit(request, options)
Execution and routing behavior
world-remote reroute
When WORKFLOW_TARGET_WORLD=workflow-studio/world-remote is set on the application service, existing start(...) calls are intercepted and routed to the remote compute worker. No application code changes are required.
The remote adapter creates a ComputeClient using execution.remoteWorkerUrl and the API key from the env var named by execution.apiKeyEnv. All world operations (queue publish, event creation, stream writes) are proxied through the worker's /v1/world/* routes.
Mode behavior
execution.mode='local'— local/default execution. Workflow runs execute in-process.execution.mode='remote'— remote execution when worker settings and deployment env are configured.
Ownership diagnostics
Handler
createRemoteOwnershipDiagnosticsHandler() returns a route handler for:
GET /api/workflow-studio/diagnostics/remote-ownership
Authentication
| Environment | Auth requirement |
|---|---|
Production (NODE_ENV=production) | WORKFLOW_STUDIO_DIAGNOSTICS_TOKEN env var must be set. Token read from Authorization: Bearer <token> or x-workflow-studio-diagnostics-token header. Returns 500 if env var is missing, 401 if token is invalid. |
| Non-production | Localhost only (localhost, 127.0.0.1, ::1). Returns 403 for non-local requests. |
Method restriction: GET only. Returns 405 for other methods.
Response shape
{
"remoteModeEnabled": true,
"strictMode": true,
"targetWorld": "workflow-studio/world-remote",
"expectedTargetWorld": "workflow-studio/world-remote",
"status": "pass",
"lifetimeUnexpectedHits": 0,
"unexpectedHitsLast15m": 0,
"lastUnexpectedHitAt": null,
"lastEvent": null,
"hardChecks": {},
"softChecks": {},
"generatedAt": "2025-01-15T12:00:00.000Z",
"correlationId": "abc-123-def"
}Response fields
| Field | Type | Description |
|---|---|---|
remoteModeEnabled | boolean | true when WORKFLOW_TARGET_WORLD matches expected target. |
strictMode | boolean | true when NODE_ENV=production. |
targetWorld | string | undefined | Current value of WORKFLOW_TARGET_WORLD. |
expectedTargetWorld | string | Always workflow-studio/world-remote. |
status | 'pass' | 'warn' | 'fail' | Overall ownership status. fail if strict mode + any rolling hits, or any hard check fails. warn if any soft check is not true. |
lifetimeUnexpectedHits | number | Total unexpected queue callback hits since process start. |
unexpectedHitsLast15m | number | Unexpected hits in the rolling 15-minute window. |
lastUnexpectedHitAt | string | null | ISO timestamp of last unexpected hit. |
lastEvent | object | null | Details of the most recent unexpected event (timestamp, correlationId, runId, route, method, markerHeaders, bodyShapeMatched). |
hardChecks | Record<string, boolean> | Hard check results passed by the caller. Any false value forces fail. |
softChecks | Record<string, boolean | 'unsupported'> | Soft check results. Non-true values produce warn. |
generatedAt | string | ISO timestamp when the snapshot was generated. |
correlationId | string | From inbound x-workflow-correlation-id header, or a generated UUID. |
See Security Model — Ownership detection for how unexpected hits are classified.
CLI command groups
workflow-studio worker ...check-configstart
workflow-studio compute ...builddeployactivaterollbackvalidate-ownership
See CLI Commands for full reference.