GNL
Examples

Five examples. None of them need an API key.

Every example in the repository runs against a deterministic mock model, so you can clone it and watch the guarantee hold before you spend a token on a provider. Each one is a real program with real assertions behind it — not a snippet that only reads well on a page.

Build the packages first: pnpm -r build from the repository root — the workspace links point at dist.

examples/oncall-triage

On-call incident triage

The tutorial example — every package, one real job: triage an incident without restarting production twice.

Send an alert and the agent reads the runbook, pulls the metric, reads the log, and stops for approval before restarting anything. The database password in that log never reaches the model. Approve, and the restart happens exactly once; a post-restart watch is scheduled that survives a redeploy. Fire the same alert again as a brand-new run and the on-call engineer is still paged only once.

View the source
Run it
examples/oncall-triage
pnpm start
http://localhost:3200 · /studio
Packages
durableworkflowmemoryragcacheprocessorstool-schemaqueueeventsschedulera2amcpserverchat-adapterstudioauthevalsotel
examples/app

Durable AI support desk

The full reference app — one port, with Studio mounted at /studio.

Open a ticket and ask for a refund: the agent searches the policy over RAG and calls the refund tool, and the guard stops it for approval because the amount is over the limit. Approve, and the refund is processed exactly once — firing a background email job and a refund event. Then replay the whole run with time-travel in the ops Studio.

View the source
Run it
examples/app
pnpm start
http://localhost:3100 · /studio
Packages
durablememoryragqueueeventsworkflowstudioevalsotelcacheprocessors
examples/incident-proofs

Incident proofs

Three documented double-side-effect failures, reproduced and then blocked.

The same tool called with the same arguments five times in one turn, under five different toolCallIds. A tool call over 180 seconds silently resent after a crash from a checkpoint. An approval event processed twice. Each case runs twice — unprotected, then with GNL — and prints both counts side by side.

View the source
Run it
examples/incident-proofs
pnpm proofs
Packages
durable
examples/stripe-idempotency

Provider-side exactly-once

The guarantee reaching past the framework, into the payment provider itself.

durableTool injects a stable idempotencyKey — runId:toolCallId — into every tool call, and this example threads it to a mock Stripe client. Unprotected, the naive retry generates a new key and Stripe cannot tell it is a retry: two charges. With GNL the retry carries the same key: one charge. With the recover() hook, execute never runs a second time at all.

View the source
Run it
examples/stripe-idempotency
pnpm demo
Packages
durable
examples/react-client

React chat client

useChat, token streaming, and approving an interrupt from the browser.

A Vite front end against an auto-generated REST + SSE backend. Tokens stream in as they arrive, and when a tool call suspends for approval the interrupt appears in the UI with Approve and Deny — the same suspend/resume the support desk uses, seen from the client side.

View the source
Run it
examples/react-client
pnpm server
pnpm dev
http://localhost:5173
Packages
clientdurableserver
examples/showcase

Self-verifying showcase

Every feature, asserted, printed with a pass or a fail.

Imports the packages the way a real consumer does and runs each feature with an assertion behind it: exactly-once across a crash, PII redaction, RAG with a reranker, MCP client and server, multi-agent handoff, durable queue, exactly-once event bus, cross-network A2A, cross-run cache, evals, an OTel cost waterfall, time-travel and fork. It ends by printing N/N.

View the source
Run it
examples/showcase
pnpm demo
pnpm studio
http://localhost:4321
Packages
durableragmcpa2amemoryqueueeventsworkflowserverstudioevalsotelcacheprocessors

Read how each guarantee works, then run it.

Every example above maps to a feature page in the docs — the API it calls, the guarantee it rests on, and what happens on resume.