aiki
durable workflow engine / typescript / apache-2.0

Durable workflows in TypeScript

A workflow is a plain async function that survives crashes, restarts, and deploys. It can pause for months without holding a process, then resume exactly where it left off.
Run it on demand or on a schedule.

Aiki lives inside your app — no separate service to run, unless you want one.

Read the docs GitHub
no DSL · no YAML
import { event, workflow } from "@aikirun/workflow";
import { activateTrial, downgradeToFree } from "./tasks";

export const trialV1 = workflow({ name: "trial" }).v("1", {
  async handler(run, input: { userId: string }) {
    // start a task
    await activateTrial.start(run, input.userId);

    // wait for an external event with a durable timeout
    const result = await run.events.paymentReceived
      .wait({ timeout: { days: 14 } });

    if (result.timeout) {
      await downgradeToFree.start(run, input.userId);
    }
  },
  events: { paymentReceived: event() },
});
import { task } from "@aikirun/workflow";

export const activateTrial = task({
  name: "activate-trial",
  async handler(userId: string) {
    /** your code **/
  },
});

export const downgradeToFree = task({
  name: "downgrade-to-free",
  async handler(userId: string) {
    /** your code **/
  },
});
import { client } from "@aikirun/client";
import { database, server } from "@aikirun/server";
import { worker } from "@aikirun/worker";
import { trialV1 } from "./workflow";

const db = database({ provider: "pg", url: process.env.DATABASE_URL });

// the server is a library — it runs inside this process
const aikiServer = server({ db });
aikiServer.runtime.start();

// talk to it in-process — no network hop, no URL
const aikiClient = client({ handler: aikiServer.handler });

// workers execute the workflows they're given
worker({ workflows: [trialV1] }).start(aikiClient);

// start a workflow — on demand
await trialV1.start(aikiClient, { userId: "u_1f9c" });
01 — ORCHESTRATION

One engine for all your background work.

Scheduled & recurring work

Cron expressions and intervals, timezones, overlap policies — allow, skip, or cancel-previous — and independent per-tenant schedule instances.

Retries

Per-task and per-workflow retry policies: fixed, exponential, or jittered backoff, with attempt limits.

Queues & distribution

Start a workflow and it runs on whichever worker is free. Add workers and load spreads across them automatically.

Deduplication

Reference IDs deduplicate workflow starts and event deliveries — the same request twice runs once.

Pools

Route workflows to dedicated groups of workers.

Priorities

When multiple runs are due at once, priority decides who goes first.

The same primitive scales from a five-second job to a six-month, human-in-the-loop workflow.

02 — DURABILITY

Work that survives crashes, restarts, and deploys.

Never lose progress

Workflows run for minutes, days, or months. Crashes and restarts resume from the last completed step.

Durable timers

A workflow can pause for minutes or months without holding a process — and wake exactly on time, even if everything restarted in between.

Fault tolerance

If a worker dies mid-run, another picks up the run automatically and the workflow continues from its last completed step.

Versioning

Ship new workflow versions without breaking in-flight runs; old versions keep running on old code.

03 — TOPOLOGY

Topology is your choice.

The Aiki server — the orchestrator — is a library. Run it inside your app or as a separate service; workflow code is identical either way. Where things run is configuration, not architecture. In every shape, execution happens in your infrastructure.

Embedded
Separate service
Pull — workers Push — endpoints · coming soon
your infrastructure
one process
your app + server + worker

In your app + in-process workers

Everything in one process — your app, the server, and as many workers as you like. One deploy, nothing else to operate.

your infrastructure
one process your app + server endpoint your Cloudflare / AWS / Vercel account
Coming soon

In your app + serverless endpoints

Your app hosts the server; execution runs on serverless functions.

your infrastructure
your app server worker

Separate service + worker fleet

The server runs as its own service; long-lived workers pull work in your infrastructure.

your infrastructure
your app server endpoint your Cloudflare / AWS / Vercel account
Coming soon

Separate service + serverless endpoints

The server runs as its own service; execution runs entirely on serverless endpoints.

04 — INFRASTRUCTURE

Infrastructure is optional.

What you run depends on what you need — nothing more.

Coming soon

Zero infrastructure

One process, a SQLite file. Durable workflows with no external services.

Shared state

Postgres, when you want multiple server instances or a shared database.

Accelerated distribution

Plug in Redis — or any transport — to speed up work distribution across your workers.

These combine in any way you like — a standalone server on a SQLite file driving dozens of workers is a perfectly ordinary production setup.

05 — EVENTS

Events from the outside world.

External systems signal running workflows with typed, schema-validated events. Events sent early are held and delivered the moment the workflow asks for them. No race between the event arriving and your code being ready for it.

// send an event to the running workflow
await trialV1.events.paymentReceived.send(client, "runId_8f2d");
06 — DASHBOARD

See every run.

Status, task history, timings, and failures.

Aiki Cloud · coming soon

Managed orchestration.

Same developer experience.