跳转到内容

createWorkflow

createWorkflow(): Workflow

定义于:core/src/core/workflow.ts:115

创建一个新的工作流实例。

这是用于创建工作流的主要工厂函数。每个工作流 维护其自身的事件处理器注册表,并能创建多个 独立的执行上下文。

Workflow

一个新的工作流实例

// 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);