Interface: FlowBuilder<TIn, THandle, TStepIds, TReceipt, TCustomMetrics, TStepOutputs>
Defined in: builders/flow-builder.ts:34
Fluent builder for a declarative multi-step workflow (P.flow(id)).
Threads THandle, TReceipt, TCustomMetrics, TStepIds, and TStepOutputs across sequential .step() and conditional .branch() declarations while enforcing scope capability tiers at .toAST() compilation time.
Extends
AstBuilder<FlowNode<TIn,THandle,TStepIds>>
Type Parameters
Methods
branch()
branch<TBranchId, TBranchOut>(id, configure): FlowBuilder<TIn, THandle, TStepIds | TBranchId, TReceipt, TCustomMetrics, TStepOutputs & { readonly [K in string]: TBranchOut }>;Defined in: builders/flow-builder.ts:132
Appends a conditional multi-way branch to the flow and records its unified output type under TStepOutputs[TBranchId].
Adds TBranchId to TStepIds and validates that the branch has an output schema, at least one when, and an otherwise.
Type Parameters
| Type Parameter | Description |
|---|---|
TBranchId extends string | Literal branch identifier string. |
TBranchOut | Unified branch output payload type. |
Parameters
| Parameter | Type | Description |
|---|---|---|
id | TBranchId | Unique branch identifier. |
configure | ($b) => FlowBranchBuilder<TIn, TBranchOut, THandle, TBranchId, TReceipt, TCustomMetrics, TStepOutputs> | Branch configurator callback. |
Returns
FlowBuilder<TIn, THandle, TStepIds | TBranchId, TReceipt, TCustomMetrics, TStepOutputs & { readonly [K in string]: TBranchOut }>
New immutable flow builder.
exit()
exit(exitState): FlowBuilder<TIn, THandle, TStepIds, TReceipt, TCustomMetrics, TStepOutputs>;Defined in: builders/flow-builder.ts:155
Sets the terminal exit state label recorded when the flow completes its final node.
Required before .toAST() can compile a valid FlowNode.
Parameters
| Parameter | Type | Description |
|---|---|---|
exitState | string | Terminal exit state label (e.g. 'done'). |
Returns
FlowBuilder<TIn, THandle, TStepIds, TReceipt, TCustomMetrics, TStepOutputs>
New immutable flow builder.
input()
input<TNewIn>(schema): FlowBuilder<TNewIn, THandle, TStepIds, TReceipt, TCustomMetrics, TStepOutputs>;Defined in: builders/flow-builder.ts:56
Binds the Zod validation schema for the work item input entering the flow.
Narrows TIn to TNewIn for all subsequent step input mappers and branch predicates.
Type Parameters
| Type Parameter | Description |
|---|---|
TNewIn | Validated flow input payload type. |
Parameters
| Parameter | Type | Description |
|---|---|---|
schema | ZodType<TNewIn> | Zod schema validating flow input. |
Returns
FlowBuilder<TNewIn, THandle, TStepIds, TReceipt, TCustomMetrics, TStepOutputs>
New immutable flow builder.
scope()
scope<TScope>(scope): FlowBuilder<TIn, ExtractScopeHandle<TScope>, TStepIds, ExtractScopeReceipt<TScope>, TCustomMetrics, TStepOutputs>;Defined in: builders/flow-builder.ts:71
Binds the capability-tiered IsolationScopeASTNode governing workspace lifecycle, checkpoints, and branching.
Infers both ExtractScopeHandle<TScope> and ExtractScopeReceipt<TScope> from scope.
Type Parameters
| Type Parameter | Description |
|---|---|
TScope extends IsolationScopeASTNode | Isolation scope AST node type. |
Parameters
| Parameter | Type | Description |
|---|---|---|
scope | MaybeBuilder<TScope> | Isolation scope AST node or builder. |
Returns
FlowBuilder<TIn, ExtractScopeHandle<TScope>, TStepIds, ExtractScopeReceipt<TScope>, TCustomMetrics, TStepOutputs>
New immutable flow builder.
step()
step<TStepId, TStep>(
id,
step,
configure?
): FlowBuilder<TIn, THandle, TStepIds | TStepId, TReceipt, TCustomMetrics, TStepOutputs & { readonly [K in string]: ExtractStepOutput<TStep> }>;Defined in: builders/flow-builder.ts:104
Appends a sequential step to the flow and records its output type under TStepOutputs[TStepId].
Adds TStepId to TStepIds so lane.onSignal(...).rewindTo(stepId) is type-checked against known step IDs.
Type Parameters
| Type Parameter | Description |
|---|---|
TStepId extends string | Literal step identifier string. |
TStep extends StepASTNode | Step AST node type. |
Parameters
| Parameter | Type | Description |
|---|---|---|
id | TStepId | Unique step identifier. |
step | MaybeBuilder<TStep> | Step AST node or builder. |
configure? | ($s) => FlowStepConfigBuilder<TIn, ExtractStepInput<TStep>, THandle, TReceipt, TCustomMetrics, TStepOutputs, TStepId> | Optional step input and interrupt configurator. |
Returns
FlowBuilder<TIn, THandle, TStepIds | TStepId, TReceipt, TCustomMetrics, TStepOutputs & { readonly [K in string]: ExtractStepOutput<TStep> }>
New immutable flow builder.
telemetry()
telemetry<TCollector>(collector): FlowBuilder<TIn, THandle, TStepIds, TReceipt, ExtractTelemetryMetrics<TCollector>, TStepOutputs>;Defined in: builders/flow-builder.ts:86
Binds an optional TelemetryCollectorASTNode folding observed ToolEffect lists into custom metrics.
Infers ExtractTelemetryMetrics<TCollector> for downstream .replaceWith(...) telemetry callbacks.
Type Parameters
| Type Parameter | Description |
|---|---|
TCollector extends FsTelemetryCollectorNode | Telemetry collector AST node type. |
Parameters
| Parameter | Type | Description |
|---|---|---|
collector | MaybeBuilder<TCollector> | Telemetry collector AST node or builder. |
Returns
FlowBuilder<TIn, THandle, TStepIds, TReceipt, ExtractTelemetryMetrics<TCollector>, TStepOutputs>
New immutable flow builder.
toAST()
toAST(): FlowNode;Defined in: ast/ast-builder.ts:20
Compiles the current builder configuration into a deeply frozen passive AST node.
Validates required builder invariants at compilation time and returns an immutable plain-object AST representation containing zero execution methods.
Returns
Deeply frozen passive AST node.
Inherited from
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
id | readonly | string | Unique identifier of the flow. | builders/flow-builder.ts:43 |