Architecture
World Composition
Configure worker world implementations for remote execution
Overview
worker.world is the runtime world input for worker boot.
You can configure it as:
- a world factory that returns a complete
World, or - a composed object with
baseand optionalqueue/streamsprimitives.
World factory
Use this when you already have a complete world implementation.
import { defineWorkflowStudioConfig } from 'workflow-studio';
import { createWorld } from '@workflow/world-postgres';
export default defineWorkflowStudioConfig({
worker: {
world: ({ env }) =>
createWorld({
connectionString: env.WORKFLOW_POSTGRES_URL!,
}),
},
});Composed world primitives
Use this when you are composing storage, queue, and stream primitives.
import { defineWorkflowStudioConfig } from 'workflow-studio';
export default defineWorkflowStudioConfig({
worker: {
world: {
base: ({ env }) => createStorageBase({ url: env.DB_URL! }),
queue: ({ env }) => createQueuePrimitive({ token: env.QUEUE_TOKEN! }),
streams: ({ env }) => createStreamPrimitive({ key: env.STREAM_KEY! }),
},
},
});Required methods in composed mode
base must provide:
runsstepseventshooks
Queue methods must resolve from queue(...) or fallback from base:
getDeploymentIdqueuecreateQueueHandler
Stream methods must resolve from streams(...) or fallback from base:
writeToStreamcloseStreamreadFromStreamlistStreamsByRunId
Optional pass-through methods:
writeToStreamMultistartclosegetEncryptionKeyForRun
Factory context
World and primitive factories receive:
type WorkerFactoryContext = {
env: NodeJS.ProcessEnv;
cwd: string;
};This supports provider-specific credentials and community world setup.
Failure behavior
Worker startup fails fast when:
worker.worldis missing,- composed mode is missing
base, - required storage/queue/stream methods are missing.
Use workflow-studio worker check-config before deployment.