CLI
The sendwend command that @sendwend/studio installs, the dev server, generate for the engine's drizzle schema and plan for the deploy-time check against running journeys.
@sendwend/studio installs one binary, sendwend, with three commands. dev starts the studio's dev server. generate writes the engine's Postgres tables as a drizzle schema file. plan checks the bundle you are about to deploy against the journeys still running in the database. The last two are meant for scripts and CI, and neither starts a server.
All three load the project the same way: --config <path>, else workflow.config.ts (or .tsx, .js, .mjs) in the current directory, whose default export must be defineConfig({...}) from sendwend. -h or --help prints the usage.
The dev server
| Option | Default | What it does |
|---|---|---|
-p, --port <port> | 4321 | The port to listen on |
-c, --config <path> | ./workflow.config.ts | The project file to load |
-s, --stats <path> | ./workflow.stats.ts, if present | The stats source; an explicit path must exist |
--open | off | Open the browser on start |
A command is required: sendwend alone prints the help, and an unknown command prints it and exits 1. The server is a Vite dev server, so edits to workflows, templates and the config are picked up over HMR. Overview covers what it serves and what it refuses to serve; Configuration covers the two files it reads.
generate
The engine keeps its state in one Postgres schema (workflow unless the config sets database: { schema }), and your app owns the migrations. Nothing creates or alters the engine's tables at runtime. generate writes those tables as one drizzle file, so drizzle-kit can migrate them alongside your own:
| Option | What it does |
|---|---|
-o, --out <file> | Where the drizzle schema file goes (required); missing directories are created |
--check | Write nothing; exit 1 when the file on disk is out of date |
-c, --config <path> | The project file, for its database.schema |
It prints <file> written or <file> is up to date. Re-export the file from your drizzle schema and let drizzle-kit write the migration, so the migration history stays yours.
The comparison ignores formatting: quotes, whitespace, spaces around punctuation and trailing commas do not count, so running your formatter over the file does not make it "out of date". The file is also laid out the way a prettier-compatible formatter at 100 columns would lay it out, so a regeneration diff shows only real changes.
In CI, run --check. An SDK upgrade that changes the engine's tables then fails the build until someone regenerates the file and writes the migration. With --check an out-of-date file prints:
This matters because POST /bundle/deploy checks the live database against the tables the SDK expects (columns, unique indexes and constraints) and answers 503, listing what is missing, until they match. Catching it in CI is cheaper than catching it at deploy.
The site you are reading wires both into package.json and runs the check in its deploy workflow:
Without drizzle, renderPostgresDdl() from sendwend returns the same tables as plain DDL.
plan
A running journey is pinned to the workflow IR it entered on, and that IR names its templates, segments and actions by id, resolved against whatever code is deployed. A release that drops one of them, moves a template to another channel or adds a required prop strands those journeys: they reach the node and fail. The runtime refuses such a deploy itself (POST /bundle/deploy answers 409 with the details), but on Cloudflare a published version's code serves the moment it is published, so that refusal comes too late to protect a running journey from a template change. plan runs the same check before you publish.
| Option | Default | What it does |
|---|---|---|
-d, --database-url <url> | $DATABASE_URL | The engine's database |
-c, --config <path> | ./workflow.config.ts | The project file |
It needs the optional postgres peer dependency. It compiles the project, reads from the database which workflow versions journeys are still running on, and holds the bundle, with the templates this code would serve, against them (checkInFlight from sendwend). It then prints three things:
- Pinned versions. Each workflow version with running journeys, its content hash and how many are running. A version this bundle no longer contains is marked: those journeys finish on their own version, and new entries take the new one.
- What the database lacks. Tables, columns or indexes the SDK expects that are missing: migrations to run before the deploy.
- What would break. Every pinned journey the bundle would strand, and why.
A safe run prints lines of this shape (the workflows, hashes and counts here are illustrative):
When there is a problem it ends with this bundle would break running journeys:, the list, and the ways out: keep the segment or action, give the changed template a new id, make the new prop optional, or deploy with POST /bundle/deploy?force=1 to fail those journeys deliberately. It exits 1 when there is a problem, so CI stops the release. On a database where the migrations have not created the engine's tables yet, nothing is pinned: the run prints no journey is running: nothing is pinned and lists the missing tables under what the database lacks.
Compatible changes pass: a reworded template, a new optional prop, a segment whose condition changed. Versioning explains the rules and why they are what they are.
In CI, run it after the build and before wrangler deploy (or your equivalent), against the production database. It only reads, so a read-only role is enough if your setup allows it (see Configuration). On AWS Lambda each durable execution is pinned to the published function version, so a template change cannot reach a running journey there; the segment and action checks still matter, since those are resolved from the database.
planthe command is notplan()the function.sendwendalso exportsplan(local, deployed), which diffs two compiled bundles and reports which workflows changed. The CLI command checks a bundle against the journeys in a database.
Exit codes
| Command | Exit 1 when |
|---|---|
| dev server | No config file is found, or an explicit --config / --stats path does not exist (a config that fails to compile is shown in the studio instead) |
generate | --out is missing, the config fails to load, or --check finds the file out of date |
plan | No database URL, the config or database fails, or the bundle would break running journeys |