@flowlinejs/engine
v0.3.0
Published
Durable workflow engine for Flowline: interprets workflow documents over a pluggable StorageAdapter, with retries, suspension, schedules and an audit trail.
Downloads
567
Maintainers
Readme
@flowlinejs/engine
The durable Flowline workflow engine: createEngine interprets a published WorkflowDoc over a
pluggable StorageAdapter, exposes an HTTP handler for the editor and run viewer, runs a worker
that claims and executes steps, and records every step to a journal and audit trail. Retries,
suspension (delay, waitForCallback, sub-flows), webhooks and cron schedules are all built in.
Install
pnpm add @flowlinejs/engine @flowlinejs/core zod@^4
pnpm add @flowlinejs/storage-memory # or @flowlinejs/storage-postgreszod 4 is a required peer dependency. Bring your own StorageAdapter: @flowlinejs/storage-memory
(for tests and prototypes) is an optional peer, used by runWorkflowInMemory;
@flowlinejs/storage-postgres (for production) is a regular dependency, not a peer, and you just
install it directly. vitest is an optional peer used only by @flowlinejs/engine/conformance;
@flowlinejs/engine/testing never imports vitest, and loads @flowlinejs/storage-memory lazily so
testNode alone works without it installed either.
Usage
import { createEngine } from "@flowlinejs/engine";
import { createMemoryStorage } from "@flowlinejs/storage-memory";
import { createRegistry } from "@flowlinejs/core";
const registry = createRegistry([]); // your plugins; core.* builtins are added automatically
export const engine = createEngine({
registry,
storage: createMemoryStorage(),
authorize: async () => ({ tenantId: "acme", userId: "u1" }),
});
// Mount engine.handler (a `(Request) => Promise<Response>`) with any fetch-style server,
// and start a worker to execute claimed runs:
export const worker = engine.startWorker({ concurrency: 4 });See the root README for the full quick start (nodes, plugin, Postgres storage,
HTTP mount, worker, publish, editor) and docs/ for the design spec. @flowlinejs/engine/testing
exports runWorkflowInMemory and testNode. @flowlinejs/engine/conformance exports
runStorageConformance, a storage conformance suite for testing your own StorageAdapter — its
own entry point because it requires vitest.
