Workflows
Linear sugar over graph(). Kept for simple step chains. Prefer graphs for new code (branching, cycles, interrupts, checkpoints). See the Public API contract.
Builder
refund-workflow.ts
typescript
import { workflow, memorySaver } from "@monorch/ai";
const refund = workflow("refund", { maxSteps: 16 })
.step("lookup", async ({ input }) => `order:${input.orderId}`)
.human("approve", { prompt: "Approve refund?" })
.step("pay", async ({ outputs }) => `refunded:${outputs.lookup}`)
.build({ checkpointer: memorySaver() });
let run = await refund.start({ orderId: "ord_9" }, { threadId: "t1" });
if (run.status === "waitingInterrupt") {
run = await run.resume("approved");
}Mapping to graph
step → node. agentStep → agentNode. human → interrupt. The run handle is a GraphRunHandle. Status waitingInterrupt replaces older waitingHuman naming.
workflow(name, { maxRetries }) accepts maxRetries for API compatibility but it is a no-op today — the builder compiles to graph() and uses fail-fast + maxSteps. Pass maxSteps on workflow() or build() for step budgets.