Skip to main content
This mirrors what tsc --emitDeclarationOnly would emit. Import these types from smthrs unless noted otherwise. createSmithers is a named export:
It returns a local API object for the workflow module. Destructure what you need (Workflow, Task, Branch, Sandbox, smithers, outputs) or use property access (api.Workflow, api.Task); both work for one factory, but property access reads clearer with multiple factories, e.g. parent/child workflows. There is no top-level default smithers export: the smithers wrapper is the property returned by createSmithers(...). smithers((ctx) => <Workflow ... />) returns the SmithersWorkflow value that workflow files usually export as their default. input is a reserved schema key on createSmithers(...) that controls the TypeScript type of ctx.input; every other key is an output schema and becomes a typed output ref under outputs.<key>. Fresh runs and graph previews parse input through this schema before rendering, so Zod defaults and transforms are available in ctx.input. The parsed fresh-run input is persisted; previews do not persist or mutate input. Treat required Zod fields as the authored TypeScript contract. For fields intentionally declared .optional() or .nullable(), coalesce inside the workflow (ctx.input.dryRun ?? false). Prefer output={outputs.someKey} on tasks, approvals, sandboxes, and subflows: the outputs object holds the exact Zod schema objects passed to createSmithers(...), so the task can infer outputSchema, validate and persist the returned row to the matching table, and feed the same schema to native structured-output agents. Major sections at a glance:
  • Workflow / Context: SmithersWorkflow, WorkflowFileRef, SmithersCtx, RunOptions, RunResult: entry points for defining and running workflows.
  • Task / Graph: TaskDescriptor, TaskProps, GraphSnapshot: node shape at runtime and in the JSX layer.
  • Component props: WorkflowProps, ApprovalProps, SignalProps, LoopProps, etc., all JSX component interfaces.
  • Errors: SmithersError, KnownSmithersErrorCode, typed error codes; see Errors.
  • Server / Gateway: ServerOptions, GatewayOptions, GatewayAuthConfig, self-hosting configuration.
  • Scorers / Memory / OpenAPI / Observability: sub-path imports (smthrs/scorers, /memory, /openapi, /observability).

Status contracts

RunStatus is the persisted run lifecycle and the type of RunResult.status. Its categories are: RunState is the derived outcome/health view. A persisted finished run maps to succeeded when clean and succeeded-with-failures when its durable RunFinished event records tolerated child failures. Both are terminal; RunStatus remains finished for compatibility. TaskState is the persisted, detailed lifecycle for an individual task. Import it from @smthrs/scheduler/TaskState. NodeStatus is a separate six-value display palette exported by @smthrs/gateway-react; useGatewayRunTree collapses detailed task and run states into that palette. In particular, every waiting-* value maps to waiting. Do not use the display palette as a persisted lifecycle contract. Status unions can gain values. Add a visible unknown fallback when consuming Gateway or event data, preserve the original value for diagnostics, and treat an unknown waiting-* value as suspended and nonterminal. See the compatibility and changelog policy.

Error reporting

RunOptions.onError receives a normalized SmithersError, the original error value, and the available run, node, iteration, and attempt context. It fires once per NodeFailed or RunFailed event: a retrying task produces one node report per failed attempt, and a terminal run failure adds a run report. Smithers catches reporter failures so they can’t change the run outcome.
For canonical, machine-checked types, install smthrs and use editor go-to-definition. For runtime errors, see Errors.