Smithers.workflow(...).build($) and use $ to create steps and control-flow nodes.
Smithers.workflow()
Creates a workflow definition:
| Option | Type | Description |
|---|---|---|
name | string | Unique workflow name |
input | Schema.Class | Input schema |
$.step()
Defines a single executable step:
Step Options
| Option | Type | Required | Description |
|---|---|---|---|
output | Model.Class | yes | The persisted output model |
run | (ctx) => Effect<Output> | yes | The step body |
needs | Record<string, StepHandle> | no | Upstream dependencies |
retry | any | no | Retry configuration — accepts an Effect Schedule or a plain number (retry count) |
retryPolicy | RetryPolicy | no | Declarative retry policy with backoff strategy ({ backoff?: "fixed" | "linear" | "exponential", initialDelayMs?: number }) |
timeout | DurationInput | no | Step timeout |
cache | CachePolicy | no | Cache configuration |
skipIf | (ctx) => boolean | no | Condition to skip |
Run Context
Therun function receives:
input— validated workflow input- Spread
needs— resolved dependency outputs as named fields executionId— durable execution idstepId— logical step idattempt— current attempt number (starts at 1)signal—AbortSignalfor timeout/cancellationiteration— loop iteration (0 for non-looped steps)
Step Handle
$.step() returns a step handle — a typed reference used in needs and control-flow nodes:
$.sequence()
Executes nodes sequentially:
$.parallel()
Executes nodes concurrently:
With Concurrency Limit
$.loop()
Repeats nodes until a condition is met:
Loop Options
| Option | Type | Required | Description |
|---|---|---|---|
id | string | no | Loop identifier |
children | node | yes | The nodes to repeat |
until | (outputs) => boolean | yes | Stop condition |
maxIterations | number | no | Safety limit (default: 5) |
onMaxReached | "fail" | "return-last" | no | Behavior at limit |
$.approval()
Creates a durable approval gate:
Approval Options
| Option | Type | Required | Description |
|---|---|---|---|
needs | Record<string, StepHandle> | no | Dependencies |
request | (needs) => { title, summary } | yes | Request payload |
onDeny | "fail" | "continue" | "skip" | no | Denial behavior |
ApprovalDecision:
$.match()
Branches based on a value:
$.component()
References a reusable workflow fragment:
Composition
All primitives compose freely:Smithers.loadToon()
Loads a .toon file and returns a workflow that can be executed like any builder workflow:
| Param | Type | Description |
|---|---|---|
path | string | File path to the .toon workflow definition |
BuiltSmithersWorkflow with an execute method that accepts the workflow input and optional execution options.
Executing a Workflow
run functions to be provided through the Layer stack.
Next Steps
- Context — Detailed step context reference.
- Services — Defining and providing Effect services.
- TOON Nodes — The declarative equivalent of builder primitives.