Skip to content

createWorkflow

createWorkflow(): Workflow

Defined in: core/src/core/workflow.ts:115

Creates a new workflow instance.

This is the primary factory function for creating workflows. Each workflow maintains its own registry of event handlers and can create multiple independent execution contexts.

Workflow

A new workflow instance

// Create a simple workflow
const workflow = createWorkflow();
// Register handlers
workflow.handle([InputEvent], async (context, event) => \{
const processed = await processInput(event.data);
return OutputEvent.with(processed);
\});
// Use the workflow
const context = workflow.createContext();
const input = InputEvent.with(\{ text: 'Hello World' \});
await context.send(input);