Skip to main content

Exports

flow(config)

Creates a new FlowBuilder instance. This is the recommended entry point for creating workflows.
Parameters:
  • config.id — Unique workflow identifier
  • config.name — Display name (defaults to id)
  • config.inputSchema — Zod schema for input validation
  • config.outputSchema — Zod schema for output validation
Returns: FlowBuilder

FlowBuilder Methods

.step(id, handler | opts)

Add a function step.

.agent(id, agent, opts?)

Add an agent step. Output is always AgentStepResult.

.branch(id, opts)

Binary routing (if/else).
onTrue and onFalse accept either a handler function or a WorkflowStep[] array.

.switch(id, opts)

Multi-way routing.

.parallel(id, steps, opts?)

Concurrent execution.

.foreach(id, opts)

Array iteration.

.map(transform)

Data transformation between steps.

.connector(id, connector, resource, action, parameters)

Connector call.

.output(transform)

Final output builder.

.build()

Create the Workflow instance.

Workflow Instance

.execute(input)

Execute the workflow with validated input.

.toGraph()

Get the workflow structure as a serializable DAG.

.on(event, handler)

Listen to execution events. See Events.

.id, .name, .steps

Read-only getters.

Step Helpers

Next Steps

Workflow Types

TypeScript type definitions

Workflows Guide

Learn workflow concepts