Skip to content
trestle

Run a business process everyone can actually see.

Your coding agent builds the steps and Trestle draws every path and run.

Describe what needs to happen in plain English, or write it yourself as one ordinary TypeScript function. Trestle runs it through crashes, deploys, and months-long waits, keeping the diagram generated straight from the code. It ships as a library over your own database, with no vendor server to run or rent.

To your coding agent

Build a process for handling insurance claims. First get an appraisal, and if the claim is higher than that, wait up to three days for an adjuster to approve it and refuse it if they don’t. Pay the claim if it’s approved or within the appraisal, and make sure it never gets paid twice.

The code, 27 lines
const value = await act({
  name: 'Appraise the claim',
  body: () => surveyor.appraise(policy),
});
const isOver = await choice({
  name: 'Over the appraisal?',
  condition: amount > value,
});
if (isOver) {
  const review = await wait({
    name: 'Adjuster approves',
    party: adjuster,
    window: '3 days',
  });
  const isApproved = await choice({
    name: 'Approved?',
    condition: review.isAnswered && review.answer === true,
  });
  if (!isApproved) {
    return 'refused';
  }
}
await act({
  name: 'Pay the claim',
  body: ({ actKey }) => bank.pay(amount, actKey),
});
return 'paid';

  1. You start by explaining what should happen in your own words. Any project started with npm create @trestlerun already includes the instructions, lint rules, and tests your coding agent needs.
  2. The agent writes one async TypeScript function using Trestle’s act, wait, and choice steps alongside plain if statements. Because it is ordinary code, your team can read it and change it safely with tests.
  3. Nobody drew this diagram by hand. Trestle builds it straight from the function, mapping every branch, the three-day timeout, and all three endings to the lines of code sitting beside it.
  4. Claim 1042 arrives above its appraisal. Trestle records each step before it starts.
  5. Three days went by with no reply, so the claim took the timeout path from the code and closed as refused.
  6. The first engine died mid-payment, so nobody knew whether the bank had taken it. A second engine resumed from the last saved step and retried with the same actKey; the bank matched the key, leaving one payment on the ledger.
  7. That one function ran the claim, generated the diagram, and recorded every step along the way.

Everything Trestle includes.

Writing processes

  • Write a process as ordinary async TypeScript with standard control flow.
  • Use async/await, Effect, RxJS, or state machines—all run and draw alike.
  • Validate inputs, answers, and outcomes with Zod, Valibot, or Standard Schema.
  • Generate live diagrams linked to source lines, with Mermaid export and diffs.
  • Start coding agents with built-in instructions, lint rules, and diagram checks.
  • Call processes from any language via OpenAPI HTTP or a fetch client.

Building blocks

  • Three core steps: act for work, wait for responses, choice for decisions.
  • Run branches in parallel, race them, or take the first success.
  • Undo cancelled or losing branches, with cleanup steps run to completion.
  • Call another process directly, or start a separate one once.
  • Loop over collections while capping how many items run at once.
  • Poll external systems, schedule timers, and put deadlines on any part.

Messages and timing

  • Send messages to active runs, taking duplicate IDs only once.
  • Start or advance runs from signed Stripe, Slack, GitHub, or Shopify webhooks.
  • Feed runs from queues with recipes for SQS, Kafka, and NATS.
  • Start runs on a schedule where duplicate ticks create one run.
  • Wait for minutes or months with nothing kept in memory.
  • Cap concurrency or rate limits for a step across all runs.

People

  • Turn human waits into inbox tasks with forms built from schemas.
  • Notify through your provider, with one reminder when a task is late.
  • Reassign tasks anytime, or from your late-task notifier, alerting both people.
  • Open a single task directly for one person via a signed link.
  • Take an explicit fallback path on timeout, taking duplicate answers once.
  • Scope tasks by relationship so managers only answer for their own team.

AI agents

  • Coding agents write plain TypeScript processes and verify them against tests.
  • Operate runs over MCP, starting read-only; agent changes log under whoever asked.
  • Put process decisions to an agent that picks drawn options with reasons.
  • Block forbidden options with rules the deciding agent sees and cannot change.
  • Bound multi-turn agent tool loops so they stay readable on the diagram.
  • Track step metrics like tokens and cost using your own models.

Operations

  • List every run in the console with a plain summary of status.
  • Retry steps, restart from earlier points, supply results by hand, or cancel.
  • Preview and apply operator fixes across many runs at once.
  • Run the same actions from the console, CLI, HTTP API, or MCP.
  • Measure step counts, timing, retries, and spend, and compare across releases.
  • Export OpenTelemetry traces and metrics, JSON logs, and signed event webhooks.

Safe deploys

  • Choose per process whether unfinished runs adopt new code, finish, or pause.
  • Run a pre-deploy check predicting every unfinished run’s outcome without executing work.
  • Move active runs onto new code without repeating finished steps unasked.
  • Declare renamed steps so existing run history follows the new name.
  • Spot paths on the diagram that no real run has ever taken.

Testing

  • Test processes with stand-in systems and jump the clock weeks ahead.
  • Fail tests automatically when Trestle detects side effects outside a step.
  • Generate tests covering every branch and report any unreachable diagram edge.
  • Record a production run and replay it against new process code.
  • Simulate crashes at every save, failing stores, and concurrent engines.
  • Drive real web pages inside a process through Playwright.

Rules and access

  • Declare rules for step order, bans, per-run limits, and separation of duties.
  • Check rules before deploy and enforce them live, with one-time owner overrides.
  • Pass system credentials to a step only where that work is declared.
  • Pause steps or processes with a lock without deploying or burning deadlines.
  • Require authentication by default with seven scopes and hashed, rotating keys.
  • Uneditable audit log of requested changes, who asked, how, and the answer.

Where it runs

  • Just a library and your database, with no vendor server to run.
  • Store state in SQLite, Postgres (including behind PgBouncer), memory, or browsers.
  • Run on Node, edge runtimes, browsers, and Web Workers.
  • Host on one server, containers, Cloudflare, AWS Lambda, or Cloud Run.
  • Hand individual steps off to external workers or specialised services.
  • Retry interrupted steps with actKey, bound retries by time, or pause them.

How Trestle is tested.

A deterministic simulator runs several engines over one store, crashes them and fails the store, and checks more than seventy named invariants after every turn. Dedicated crash tests kill active runs immediately before and after every save to verify that saved progress survives and each finishes with the same record as one left alone. Every failure the simulator finds is kept as a replayable test that every future commit has to pass.

What Trestle promises

  • Saved progress survives a crash, and completed steps are answered from the record instead of running again.
  • Every attempt of an act receives the exact same actKey, even if you later rename the step.
  • Messages sent under the same ID, duplicate task answers, and child process starts are each accepted once.
  • Business rules declared on a process are checked against the diagram before deploy and enforced during each run.

What Trestle does not promise

  • Side effects written outside a step will run again on replay, though Trestle’s tests fail on any they detect.
  • An external system that ignores the actKey you pass it can still perform the work twice.
  • Decisions hidden outside a choice will not appear on the diagram and are only caught if a live run leaves the map.
  • Rules only govern the steps and choices your process declares, not code outside them.

Read the full proof

Start a project.

npm create @trestlerun
Copy the code
Creates a TypeScript project with a starter process, tests, lint and diagram checks, and ready-to-use instructions for your coding agent.

Trestle is open source under the MIT licence.

Your visit is running on Trestle.

This is the real Trestle engine running a live process in your browser tab, not a simulation. Each of the eight topic pages you open answers its question once, showing the path you have taken and the pages you have not opened yet—until you copy npm create @trestlerun to finish it.