Durable SDK

A TypeScript framework with a ledger, an undo, a doctor and docs an agent can read. Hosted at durablesdk.com.

Open in CursorView as Markdown

This page says what Durable is and which of two paths to take next. The commands it names are npx durable-sdk init, durable-sdk deploy and durable-sdk doctor --host.

What it is#

Durable is a TypeScript framework for apps that already have a Postgres database and a cron. A workflow is a keyed saga: one run per intent, every side effect a step that reads before it writes, undoes itself or says why it cannot, and leaves a before/after image in an append-only, hash-chained ledger. It runs inside an ordinary serverless function, needs no worker, broker or control plane, holds a failed run for a person instead of retrying it in the dark, and refuses to store a secret.

import { defineWorkflow } from "@durable-sdk/core";

// stock, payments and orders are the app's clients, one seam: the app
// binds them at boot, a test binds doubles.
export const checkoutComplete = defineWorkflow({
  name: "checkout.complete",
  version: 1,
  describe: "Reserves, charges and creates the order once per checkout.",
  key: ["checkoutId", "requestId"],
  example: { checkoutId: "chk_4f21", requestId: "q7c1" },
  async run(ctx) {
    const { checkoutId: id, requestId } = ctx.input;
    await ctx.step("stock.reserve", () => stock.reserve(id), {
      undo: (_, out) => stock.release(out.reservationId),
      effect: "provider",
    });
    const paid = await ctx.step("payment.capture", () => payments.capture(id), {
      undo: (_, out) => payments.refund(out.paymentId),
      effect: "provider",
    });
    const order = await ctx.step("order.create", () => orders.create(paid), {
      undo: (_, out) => orders.cancel(out.orderId),
      effect: "ledgered",
    });
    await ctx.emit("order.placed", { ...order, checkoutId: id, requestId });
    return { orderId: order.orderId };
  },
});

The key never reads the clock: the moment rides in the input as requestId. The same checkout through ten callers is one run; the eleventh caller gets the first run's result. Each step names its effect and carries an undo over the same seam, so the order's failure refunds the capture and releases the stock, in that order, and the card is charged once; a step that cannot undo says irreversible: "<why>" instead. The template's src/workflows/hello.ts is the same shape with one step. Concepts has the model in one page.

The four things you can check#

Each of these is in your database or in your tree, not in a dashboard you have to trust.

What Where to look
The ledger: every write's before and after image the ledger table, hash-chained per scope; verify walks it from genesis
The undo: what a compensation found and restored <step>.undo rows beside the step; a step that cannot undo says irreversible: "why"
The doctor: the rules your tree keeps durable-sdk doctor --host, one line per failed rule with its fix
The legibility: every refusal a sentence with a remedy durable-sdk explain <code>, offline; the same table the API and the dashboard print

The doctor says what the rules are; Errors lists every code the platform can answer.

The path#

Sign up at durablesdk.com, run four commands, and your app answers at <app>.durablesdk.com with its own database, its console and a read string. Start with the Quickstart; Hosting says what runs for you.

The packages are the ones your app imports; Compatibility says what the product promises to keep across their versions. Before you start, see it drawn: How it works has the model in seven pictures.

Where to go next#