Workflow class manages nodes and connections in a workflow.
Class: Workflow
Constructor
string
Optional unique identifier. Auto-generated if not provided.
string
Optional workflow name. Defaults to
'Untitled Workflow'.Properties
string
Unique workflow identifier.
string
Workflow name for display.
Map<NodeId, Node>
Map of node IDs to node instances.
Graph
Internal graph structure managing connections.
Methods
addNode()
Add a node to the workflow.typeof Node
Node class constructor (must be registered).
AddNodeOptions
Optional configuration:
id?: string- Custom node IDposition?: { x: number; y: number }- Visual positiondata?: Record<string, any>- Initial property values
removeNode()
Remove a node from the workflow.string
ID of the node to remove.
getNode()
Get a node by ID.string
ID of the node to retrieve.
undefined if not found.
Example:
connect()
Create a connection between two nodes.string
Source node ID.
string
Output port name on source node.
string
Target node ID.
string
Input port name on target node.
Connection object.
Example:
disconnect()
Remove a connection.string
ID of the connection to remove.
validate()
Validate the workflow structure.ValidationResult with validation status and errors.
Checks:
- No cycles in the graph
- All connections are valid
- All required inputs are connected or have default values
- All nodes are valid
execute()
Execute the workflow.ExecutionOptions
Optional execution configuration:
timeout?: number- Maximum execution time (ms)variables?: Record<string, any>- Workflow variablesabortSignal?: AbortSignal- Cancellation signal
ExecutionResult.
Example:
toJSON()
Serialize workflow to JSON.fromJSON()
Deserialize workflow from JSON.WorkflowJSON
JSON representation of the workflow.
Workflow instance.
Example:
Types
AddNodeOptions
ExecutionOptions
ExecutionResult
WorkflowJSON
Usage Examples
Basic Workflow
Save and Load
Validation Before Execute
Related
Workflows Guide
Learn workflow concepts
Node API
Node class reference
Executor API
Executor class reference
JSON Schema
Workflow JSON format