API Reference

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.

FieldTypeDefaultDescription
mode'local' | 'remote''local'Execution mode. remote routes to the worker via ComputeClient.
remoteWorkerUrlstringBase URL of the remote compute worker (required when mode='remote').
apiKeyEnvstringName of the env var holding the worker API key (e.g. 'WORKFLOW_COMPUTE_API_KEY').
timeoutMsnumberRequest timeout for remote calls in milliseconds.
retriesnumberMaximum 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

FieldTypeDefaultDescription
hoststringBind address (e.g. '0.0.0.0').
portnumberListen port. Falls back to PORT env var.
requestOriginstringOverride origin used in request URL parsing.

worker.security

FieldTypeDefaultDescription
requireHttpsbooleantrueEnforce HTTPS for non-local requests.
rateLimitPerMinutenumberPer-key rate limit.

worker.auth

FieldTypeDefaultDescription
seedApiKeysSeedApiKey[]API keys seeded into the worker database on boot. Each key has keyId, secret, projectId, environment, and scopes.

worker.storage

FieldTypeDefaultDescription
sqlitePathstringPath to the SQLite database for worker state (API keys, audit logs, deployments).
artifactDirstringDirectory for storing deployment artifacts.

Worker world forms

worker.world accepts:

  • a function returning a complete World, or
  • a composed object with base and optional queue/streams factories.

See World Composition for details.

Framework adapters

Next.js

  • withWorkflowStudioNext(nextConfig, options) — see Next.js guide
  • proxyTriggerFromNext(request, options)
  • proxyWebhookFromNext(request, options)

Nitro

  • withWorkflowStudioNitro(nitroConfig, options) — see Nitro guide
  • proxyTriggerFromNitro(request, options)
  • proxyWebhookFromNitro(request, options)

SvelteKit

  • withWorkflowStudioSvelteKit(config, options) — see SvelteKit guide
  • proxyTriggerFromSvelteKit(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

EnvironmentAuth 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-productionLocalhost 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

FieldTypeDescription
remoteModeEnabledbooleantrue when WORKFLOW_TARGET_WORLD matches expected target.
strictModebooleantrue when NODE_ENV=production.
targetWorldstring | undefinedCurrent value of WORKFLOW_TARGET_WORLD.
expectedTargetWorldstringAlways 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.
lifetimeUnexpectedHitsnumberTotal unexpected queue callback hits since process start.
unexpectedHitsLast15mnumberUnexpected hits in the rolling 15-minute window.
lastUnexpectedHitAtstring | nullISO timestamp of last unexpected hit.
lastEventobject | nullDetails of the most recent unexpected event (timestamp, correlationId, runId, route, method, markerHeaders, bodyShapeMatched).
hardChecksRecord<string, boolean>Hard check results passed by the caller. Any false value forces fail.
softChecksRecord<string, boolean | 'unsupported'>Soft check results. Non-true values produce warn.
generatedAtstringISO timestamp when the snapshot was generated.
correlationIdstringFrom 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-config
    • start
  • workflow-studio compute ...
    • build
    • deploy
    • activate
    • rollback
    • validate-ownership

See CLI Commands for full reference.