workflow-studio
Public API reference for the CLI-facing Workflow Studio package
Overview
workflow-studio is the user-facing package for remote worker configuration and tooling.
It provides:
- config helpers (
defineWorkflowStudioConfig,defineWorkflowConfig), - framework adapter helpers,
- proxy-trigger helper functions,
- ownership diagnostics handler,
- worker and deployment CLI commands.
Shared protocol, client, and config types live in @workflow-studio/core. The deployable runtime lives in @workflow-studio/worker.
Config API
defineWorkflowStudioConfig(config)
Defines typed configuration loaded from workflow.config.*.
import { defineWorkflowStudioConfig } from 'workflow-studio';
import { createWorld } from '@workflow/world-postgres';
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 worker (required when mode='remote'). |
apiKeyEnv | string | - | Name of the env var holding the worker API key (for example '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 worker process.
worker.server
| Field | Type | Default | Description |
|---|---|---|---|
host | string | - | Bind address (for example '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 optionalqueueandstreamsfactories.
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 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. World operations are proxied through the worker's restricted /v1/world/* routes.
Mode behavior
execution.mode='local'- local or 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.
CLI command groups
workflow-studio worker ...check-configstart
workflow-studio ...deployrollback
workflow-studio compute ...builddeployactivaterollbackvalidate-ownership
See Operator Guide for full reference.