Introduction
Cairnflow runs your handlers durably. Every step — a model call, a tool call, a payment — is recorded in a journal before the run moves on. When a process crashes, a deploy restarts your service or a connection drops, the run resumes from the last recorded step instead of starting over or running side effects twice.
You write ordinary TypeScript with the @cairnflow/sdk package, Python with the
cairnflow package, or Go with the cairn package.
Cairnflow calls your service over HTTP, keeps the
journal, the state and the timers, and decides when each run continues.
What you can build
Section titled “What you can build”| Use case | What cairnflow gives you | Start with |
|---|---|---|
| AI agents | Model and tool calls as durable steps, tool approvals that wait on a durable promise, streams that reconnect after a reload, one turn at a time per chat | Vercel AI SDK |
| Durable workflows | Multi-step processes with one run per ID, waits of minutes or weeks, signals from outside | Workflows |
| Stateful objects | State per user, account or device behind a key, with one writer per key at a time | Virtual objects and state |
| Sagas and payments | Recorded side effects, idempotency keys, compensation with TerminalError |
Errors and retries |
| Schedules and background jobs | Server-side cron with time zones, delayed sends, fan-out to child invocations | Schedules |
| Webhooks and events | Acknowledge once durable, deduplicate with Idempotency-Key, concurrency and rate limits per scope |
Flow control |
Where your code runs
Section titled “Where your code runs”On a long-running server — a container, a VM or Kubernetes — with serve() on Node.js 22.6 or
newer. This is the best fit for agents: a replay cache keeps resumes cheap, and where HTTP/2 reaches
your service, one streaming connection per run carries tokens and cancellation as they happen. On
Cairnflow Cloud, streaming is opt-in; see Deployments.
On a serverless function — Vercel, Cloudflare Workers or AWS Lambda — with fetchHandler, the
Fetch adapter, which Deno and Bun can serve too. This fits short workflows: a few steps with
retries and timers, on the platform you already deploy to. See
Serverless.
How it is built
Section titled “How it is built”All of cairnflow’s state lives on object storage — an S3-compatible bucket. The runtime nodes keep nothing on disk: a node takes ownership of a range of keys with a lease, and when it dies another node takes the range over from the bucket. A run is acknowledged only after its step is durable in the bucket.
- Quickstart — a first durable run on your own machine.
- Concepts — services, virtual objects, workflows and the journal.