---
name: terminus
description: "Build, run and publish apps, agents, skills and services on Terminus with the terminus CLI. Use in a folder with a terminus.json, or when asked to build on Terminus."
---

These docs are for Terminus 0.0.1. If the folder's terminus.json pins another version, read https://www.terminus.build/docs/<that version>.md instead.

- You can't sign in, approve or publish for the person: ask them.
- Never write a secret into a file or a command: `terminus secrets set` asks for it at a hidden prompt.
- Branch on exit codes and error codes, never on messages.
- Before you say you're done, run `terminus push --dry-run`, `terminus status` and `terminus dev`, then `terminus push`.
- For a call these docs don't show, read the SDK's types in `node_modules/@terminus-ai/sdk`.

# Build on Terminus

## Get Started {#get-started}

The design philosophy of Terminus is Lego-style: you can design and build any component, and connect them together. Terminus supports four kinds:

- **[Apps](#apps):** Apps for you and your agent. You can create apps for yourself, games you can share with your friends, or websites that help you understand things better. Your data belongs to you, and you can download it from the app at any time.
- **[Agents](#agents):** Long-running agents that help you get things done, 24/7. Write a prompt that tells one what to do, and it handles things for you.
- **[Skills](#skills):** Know-how any agent can load when it needs it, on Terminus or in Claude Code and Codex. Write it once, and every agent can use it.
- **[Services](#services):** Operations that apps, agents and other services can call. Write your own code and host it on Terminus, or register and connect a service you already run.

### Set up {#set-up}

We provide a `terminus` CLI for you and your coding agent to interact with our environment natively. You need to install [Node.js](https://nodejs.org/en/download) 24 or newer on your machine. Install the CLI and sign in:

```bash
npm install -g @terminus-ai/terminus
terminus login     # a browser tab opens to approve this computer
```

Node.js (https://nodejs.org/en/download):

macOS and Linux:

```bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.8/install.sh | NODE_VERSION=--lts bash
```

- The SDK comes with each folder: the CLI keeps the package of the folder's version of Terminus in `.terminus/sdk/`, which its `package.json` links.
- The CLI builds apps and services on the machine, and Terminus receives only what was built: TypeScript's bundle, which Terminus runs on V8, or another language's WebAssembly component. TypeScript builds with the SDK's build tools. The CLI fetches the toolchains a build needs into `~/.terminus/tools/<tool>/<version>` the first time: TypeScript's, unless the folder installs its own, and Python's, Go's and C or C++'s; `WASI_SDK_PATH` picks a wasi-sdk of your own.
- A service in Rust needs Rust, from https://rustup.rs; its `rust-toolchain.toml` adds the `wasm32-wasip2` target on the first build.

### Workflows {#workflows}

Every creation moves the same way: from an address, to a folder on your machine, to a draft on Terminus, to a release people use.

```bash
terminus create <name>     # create it, with a folder to build in, its packages installed
cd <name>
terminus dev               # run it on your machine
terminus push              # upload it to its draft
terminus settings          # see and adjust its settings
terminus publish           # publish a release
terminus --help            # list the commands
```

**Create and register a creation on Terminus.** `terminus create <name>` registers `@you/<name>` on Terminus and makes a folder on your machine to build it in, started from a template of its kind.

- It asks what you are making: an app, an agent, a skill or a service. Without a terminal to ask in, as in a script or for your coding agent, `--kind` answers: `--kind app`, `agent`, `skill` or `service`. The kind is chosen once, and never changes.
- For code you already have, `terminus create <name> .` registers it and makes the current folder its folder instead.
- `terminus clone <name>` brings a creation that already has files into a new folder, such as on another machine, and `terminus link <name>` connects a folder to a creation that already exists.

**Testing and Debugging.** `terminus dev` gives you a simulator of Terminus to test in before you push: the folder runs as it will on Terminus, and what it opens depends on the kind. Its data is stored in the folder's `.terminus/dev/`.

- **An app** runs on test data that never leaves your machine, with its dev tools beside it at each member's address. [Apps](#apps) has the details.
  - It sends your folder to its Test world, which builds and runs it there. It never writes the draft: only `terminus push` does.
  - Each folder has a Test world of its own, so two worktrees of one app run side by side without meeting. The desk's Test window runs the draft in another.
  - `--members <n>` runs it as several people side by side, each on a port of their own: `--members 2`, or by name, `--members alice,bob`.
  - Your copy of your data is made once, when its Test world starts, and each run says since when. `--fresh` starts it again on a new copy of your data. A Test world 120 minutes past its last run is deleted, and the next run starts a new one.
  - `--empty` starts it again with nothing in it.
  - Its schedules and watches run only when you run one: press `t` in `terminus dev`, or Run now in its Test window.
  - `--build` builds it as `terminus push` does and serves the build, again each time `terminus dev` starts. An app built with Vite updates as you save without it; one built any other way runs this way.
  - `--service <folder>` runs a service's folder beside it, for its calls. An external service runs on your own server, so `--endpoint <url>` says where it's running, such as `http://127.0.0.1:8080`, and `--endpoint @you/<name>=<url>` names each one's when several are external.
  - `--port <n>` serves it from that port instead of 8868.
- **An agent** runs on Terminus, and you talk to it on the web: `terminus dev` opens its chat, in the agent's Test on the desk, which picks the conversation up where it stopped, unless `--fresh` starts a new one. Each save pushes its draft, and its settings are its `terminus.json`'s.
  - `--call "<message>"` sends it one message in that conversation and prints the reply, and `--file <path>` attaches a file or an image to it.
  - `--trigger <name>` fires one of its triggers, and `--file <path>` gives a webhook trigger its body.
  - `--port <n>` takes its webhooks on that port instead of 4720.
- **A service** written in code is built first, as Terminus runs it, then runs behind a test page of its operations. [Services](#services) has the details.
  - `--call <operation> name=value` calls one of its operations and prints the answer. A field that is an object or a list is written as JSON, and `--file <path>` gives a body of bytes.
  - `--remote` runs its draft on Terminus instead, with the secrets stored there.
  - `--service <folder>` runs another service's folder beside it, for its calls. An external service, this one or one beside it, runs on your own server, so `--endpoint <url>` says where it's running, such as `http://127.0.0.1:8080`, and `--endpoint @you/<name>=<url>` names each one's when the run has several.
  - `--fresh` starts with an empty store.
  - `--port <n>` serves its test page from that port instead of 4750.

**Adjust Settings.** `terminus settings` shows a creation's settings, and `terminus settings set <field>=<value>` changes them, as its page does, without a new release. `listing`, `open_source`, `open_to_guests` and `price` wait until you confirm them on the page.

- `name` and `description`.
- `icon`: a square JPEG, PNG or WebP file of 1024 to 4096 px a side and at most 5 MB. `icon=` takes it off.
- `listing`: `public` (in the Store and search), `unlisted` (anyone with its address) or `restricted` (you and the people you let in).
- `open_source`: `true` lets anyone read its source and fork it for free.
- `open_to_guests`: `true` lets people who aren't signed in try it at its address, and asks them to sign in when something needs an account. It needs a free price and a listing other than `restricted`.
- `price`: a plan and its credits, as JSON in quotes, such as `price='{"plan":"subscription","credits":"4.99","days":30}'`.
  - An app or an agent: `free`, `one_time`, or `subscription` with `days` of 1, 7 or 30.
  - A service or a skill: `free` or `per_use`.

**Push and Publish.** Pushing and publishing are different acts. A push updates the draft, which only you and your collaborators see. Publishing makes a release people use, and only you do it: `terminus publish` opens the creation's page on the web, where you confirm it.

Before you push, `terminus push --dry-run` checks everything the push would, offline, and sends nothing; `--verbose` shows the build's own output. It's how a skill is checked, as a skill has nothing to run.

- `terminus create <name> .` writes only `terminus.json` into a folder that already has files, and refuses a folder whose `terminus.json` names another creation.
- With no terminal to ask in, `terminus create` needs `--kind`. `--template` picks an app's starter (`vanilla`, `react`, `vue` or `svelte`) or a service's language (`typescript`, the default, `rust`, `python`, `go`, `c`, `cpp`, or `external`). `create` runs `npm install` in a new folder unless given `--no-install`.
- A kind never changes. A wrong one, before the first release, is fixed by deleting the empty creation and creating it again; a published address stays reserved.
- A skill has nothing to install or run: it skips `npm install` and `terminus dev`, and runs inside the agents that load it.
- An app's `terminus dev` serves http://localhost:8868, signed in as Alan; `--members 2` adds Bob on the next port. The services and models the app declares are the real ones, called as the signed-in account.
- `--json` prints each event of the turn as a line of JSON: its text, each tool call and its result, the plan, and how it ended. The files a turn or an answer hands over are saved under `.terminus/calls/`.
- `terminus push` replaces the draft. If the draft changed since the last pull, it asks for `terminus pull` first.
- `terminus push --dry-run` also warns where an app's own code does what the SDK provides, such as records in its own IndexedDB or localStorage, naming the file and line and the SDK's way.
- `terminus publish --notes "…"` writes the release notes and opens the page, where the person publishes.
- An icon is a square PNG, JPEG or WebP of 1024 to 4096 px a side and at most 5 MB, and Terminus makes its smaller sizes. Its artwork fills about four fifths of the square, centred, and the margin around it is transparent, as Terminus's own icons are drawn: the Dock and the desktop show every icon at one size.
- An app's page reaches its icon at `iconUrl`, which `ready()` answers: `/_terminus/icon`, the icon whole. `/_terminus/icon?size=<pixels>` answers the smallest size Terminus makes at least that big (64, 128, 256, 512 or 1024 px, a WebP), so a page asks for twice the CSS pixels it draws: `?size=64` for an icon drawn 32 px wide.

```bash
terminus settings set icon=icon.png listing=unlisted
terminus settings set price='{"plan":"subscription","credits":"4.99","days":30}'
```

## Apps {#apps}

An app runs on Terminus, in a window of its own on the Terminus desktop or in a browser tab. You build it with the web tools you already know, and Terminus gives it the rest: records that work offline and sync across each person's devices, spaces where people share them, a server for what the browser can't be trusted with, work that runs while no window is open, and tools for people's agents. The records belong to the people who made them.

- **The convention.** The app, and beside it the files that tell Terminus what it is built on:
  - `index.html` and `src/`: the app's source code. We recommend Vite, which the starters use.
  - `terminus.json`: the convention file, with the app's address and the version of Terminus it is written against.
  - `schema.ts`: its collections, its server's operations, and the services and models it calls. Terminus refuses anything it doesn't declare, and agents learn from it what the app can do.
  - `src/server/`: background operations, compiled and hosted on Terminus.
  - `migrations/`: a file for each change to how data is stored, named by when it was written, updating the records people already have.
- **Data.** Records live in the app's collections: each person's own, a space's shared by its members, or one set for everyone.
  - They work offline, and a change reaches the person's other devices and a space's members as soon as it lands.
  - A space is a group the app brings together, such as a team's board, a family's list or a game's table. People join by an invitation to their handle.
  - People can download their records as SQLite files.
- **The server.** It runs on Terminus, and knows for certain who called.
  - Its operations do what the browser can't be trusted with: checking a score, using a secret, writing what everyone shares.
  - Its background work runs while no window is open: a job, a schedule, a webhook, or a public page the app watches. It runs as the person it was made for, and can notify them.
- **Tools for agents.** People's agents may read and write the app's records and run the operations it opens to them, as far as each person allows.
  - `terminus mcp --dev` gives your coding agent the running app's tools, as the first member unless `--member <handle>` names another, and the dev tools' own. What it may use of the app's is set on that member's App access page, and starts off.
- **Test and publish.**
  - Under `terminus dev`, each member's address opens the app with its dev tools beside it, opened by the button in its corner or ⇧⌥D: its records, sync, clock, agents and log. They take the network offline or make it slow or flaky, move the clock forward, and open another device.
  - After a push, Test on the app's page runs the draft on Terminus on a copy of your own data. People move to a new release when they press Update.
  - Use Draft, under Test's arrow on the app's page or in its right-click menu on the desk, runs your own installation on the draft as it is now, on your real data, wherever the app opens; each push reaches it on its own. It is for the app's owner and collaborators. Before the first release it installs the app, which runs the draft until it is published; after, Use Release goes back.
  - On the draft, change a data format in two steps where you can: add the new field or collection beside the old one (it needs no migration file), have the app convert what it meets, and remove the old shape in a later migration. A migration with SQL waits: your installation runs the release until it is published, so prove it with Test first.

**The convention.**

| | |
|---|---|
| `terminus.json` | Its address, and the version of Terminus it is written against. |
| `index.html`, `src/` | The app's source code. Anything that builds to static files works; the starters use Vite. |
| `schema.ts` | What the app is built on, declared once. |
| `src/server/` | Background operations, compiled and hosted on Terminus. |
| `migrations/` | How a release reshapes data that earlier releases wrote. |
| `.env.local` | The secrets `terminus dev` uses. Never uploaded. |
| `.terminus/types.d.ts` | The types of the services `schema.ts` declares, which `terminus dev` and `terminus push` write from their contracts. |

```json terminus.json
{ "kind": "app", "id": "@you/<name>", "terminus_version": "0.0.1" }
```

`schema`, `server`, `migrations` and `build` in `terminus.json` name other places in the folder for the schema, the server, the migrations and the build's output, `dist/` unless said.

```ts schema.ts
import { schema, t } from "@terminus-ai/sdk";

export default schema({
  collections: {
    tasks: { fields: { title: t.text(200), status: t.choice("open", "done") }, indexes: ["status"] },
    cards: { scopes: ["space"], fields: { title: t.text(200) } },
    scores: { scopes: ["app"], fields: { best: t.int(0) } },
  },
  operations: {
    submit: { runs: "server", effect: "write", input: { score: t.int(0) }, output: { saved: t.bool() } },
  },
  services: { web: "@terminus/web-access@0.0.1" },
});
```

- Import it as `app`, in the window and on the server. Each name is a handle: `app.tasks`, `app.submit`, `app.web`.
- A service is named at a version, as `@terminus/web-access@0.0.1`: its calls run that release until `terminus update` moves it to the newest. An external service runs on its maker's own server, so its version holds what its calls send and answer.
- `scopes` says where a collection's records live: each person's own (the default), a space's, or one set for the whole app, which only the server writes.
- A name is a lowercase letter, then lowercase letters, digits and `_`; an operation's or a route's may take capitals too (`submitScore`). No two handles share a name. An app declares at most 32 collections, 32 services, 32 models and 8 channels.
- A collection without `fields` runs in `terminus dev`, its records typed `unknown`, and `terminus push` refuses it.
- `routes` are requests on the app's own origin that its server answers, such as a feed. `app.server` implements each under its name, from the Request to a Response, and `from: ["guests"]` lets signed-out visitors ask it. A route never says `HEAD`, which its path's GET route answers, and never lies under `/_terminus`.

```ts
routes: { feed: { at: "GET /feed.xml", effect: "read", from: ["guests"] } },   // in schema()
async feed(request) { return new Response(xml, { headers: { "content-type": "application/rss+xml" } }); },   // in app.server()
```

**Data.**

```ts
await app.tasks.put("t1", { title: "Ship", status: "open" });   // create, or replace whole
const task = await app.tasks.get("t1");
await app.tasks.patch("t1", { status: "done" });                 // only the fields named
await app.tasks.delete("t1");

const page = await app.tasks.find({ status: "open" }, { limit: 20 });
const next = await app.tasks.find({ status: "open" }, { limit: 20, after: page.nextCursor });

const live = await app.tasks.live({ where: { status: "open" } });
live.subscribe((records) => render(records));                    // again on every change
```

- A long list reads a page at a time: `live({ sort: "-createdAt", limit: 100 })` keeps its first 100 records live, `live.more(100)` reads the next 100 past them and keeps them live too, and `live.hasMore` (a store's `hasMore`) says whether more lie past. Its `sort` is on a field the collection `indexes`, or a shuffle: `sort: "~seed"` (1 to 32 letters and digits) gives every record one place, the same for that seed on every page and every device, and another seed shuffles them all again.
- The types have the rest: `search` by words, `putMany`, several writes in one `db.transact` with `putWrite`, `patchWrite` and `deleteWrite`, `move` into a space, and logs that are only appended to.
- A refusal is a `TerminusError`: branch on its `code`, listed at https://www.terminus.build/docs/errors.
- In a framework, read through `stores` from `@terminus-ai/sdk`, each made once per query: React keeps `stores.live(app.tasks, options)` in `useMemo` and reads it with `useSyncExternalStore(store.subscribe, store.get)`. A store made on every render opens its query again.
- A device keeps each collection whole, so every query answers offline. `keep: { recent: 500, by: "sentAt" }` keeps the newest 500 records of each scope by an indexed field, and answers offline only a query in that order within them. `keep: "cloud"` keeps none, for a set too large to copy. What the device cannot answer is `offline` without a connection.

```ts
import { people, spaces } from "@terminus-ai/sdk";

const [bob] = await people.search("bo");   // an exact handle first
const { space } = await spaces.create({ name: "#launch", memberHandles: [bob.handle] });
await app.cards.in(space.id).put("c1", { title: "Launch" });
```

- A signal is heard live and never kept: cursors, typing. `const room = await spaces.enter(space.id)`, then `room.signal("cursor", { x, y })` and `room.subscribe("cursor", ({ payload }) => …)`.
- What must not be missed is a record.
- Two people typing in one `t.richText()` field need no code: a page's `live()` collection in a space says each `patch` of such a field straight to the host that holds the space, which merges it character by character, hands the result to every page there at once and saves it in batches, each save an ordinary write. Other fields keep their ordinary writes. So does a page that is offline, whose edits merge when it comes back, and a guest's.
- A field whose edit passes 36 KiB, its runs and the runs they started from together, gets no live typing: it reaches the others as any write does, about a second late. A paragraph is far below that; one large rich-text body is not, so keep long documents in records of a paragraph each.
- A game loop is a match the server runs: `matches` in the schema, its code `defineMatch` from `@terminus-ai/sdk/service` in `app.server`, joined with `app.<match>.in(space.id).join(id)`.
- A turn-based match answers `sleep: true` between moves, with `wakeIn: ms` to wake by itself at a time (a chess clock), and `keep: true` to be saved before what it sends goes out. `join(id, { watch: true })` watches it: the page hears what it sends to everyone and says no input, and the match's code is handed `{ type: "watch" }` to send it what the match shows.
- A fast match ticks up to 60 times a second. `match.input(payload)` takes a `Uint8Array` or an `ArrayBuffer` as well as JSON, its code is handed a `Uint8Array`, a send's `payload` may be one, and the page hears a `Uint8Array`, at most `LIMITS.eventPayloadBytes` either way; the state stays JSON. `ctx.rtt` names each player's round trip in milliseconds, by member, once measured: a shot taken now was aimed at what its shooter's page showed about that long ago. A page can hold its answers back, so hold how far you rewind to a bound.
- What the newest replaces may be lossy: `match.input(bytes, { lossy: true })` and a send's `{ payload: bytes, lossy: true }` go as UDP datagrams (WebTransport) where the browser and the network allow, and on the live socket otherwise, never held up behind a lost packet. A lossy message may be lost, or come after a later one: stamp it with the tick, and keep what must arrive (a kill, a round's end) on the reliable path. A lossy payload is bytes, at most `LIMITS.matchLossyBytes`.
- A world of hundreds relays: `matches: { city: { tickRate: 30, players: 256, relay: true } }`, up to `LIMITS.matchRelayedPlayers`. Each page publishes the states of the entities it owns, `match.publish([{ id, x, y, z, priority, bytes }])`, and hears the others' near it with `match.subscribeStates(({ at, states }) => …)`: within 150 m 30 times a second, at most 96, the highest priority first, then the nearest; to 500 m 10 times; to 2 km twice. Terminus relays them on the match's host, never through a tick. A page's interest is where its own entities of the highest priority it publishes are, so give the one it plays the most.
- The relayed match's code referees: it takes inputs as any match does, and reads the states for its checks, `ctx.states.get(id)`, `ctx.states.history(id)` (the last second) and each entity's latest, with who published it (`member`) and how long ago (`ago`).
- A call is its people's microphones, and their cameras and screens when it says so, through Terminus's servers: `calls: { meeting: { video: true, screen: true } }` in the schema, joined with `const call = await app.meeting.in(space.id).join(id)`. The first time, the person is asked for the microphone (and the camera, with `{ camera: true }`). Show someone's camera or screen with `call.attach(userId, "camera", videoElement)`, turn yours on and off with `setMicrophone`, `setCamera` and `setScreen`, hear who is in it with `call.subscribe(listener)`, and `call.leave()`. `app.meeting.in(space.id).live()` lists the space's calls and who is in each, without joining. Under `terminus dev`, calls need a local LiveKit: `docker run --rm -p 7880:7880 -p 7881:7881 -p 7882:7882/udp livekit/livekit-server --dev --bind 0.0.0.0 --node-ip 127.0.0.1`.

- Almost every change to stored data comes with a migration, `migrations/<YYYYMMDDHHMMSS>_<name>.sql`, which `terminus migration new <name>` writes with its tests. Write SQL in it only when a field becomes required, changes type or loses a choice, or when something is removed or renamed.
- A migration is one file per change, named by the UTC time it was written. Every file runs migrations in the order of those 14 digits, whatever release ships them.
- A new migration is newer than every migration a release has shipped, and a released one never changes. One no release has shipped grows by statements added at its end.
- A migration runs on the whole file and may work across rows: move records, change their ids, make and delete them. It must be deterministic: no `random()` or `'now'`.
- A write an older release queued offline is replayed through the migration on the file as it was before, for 30 days; after that it is refused, and the app asks for an update.
- `terminus push --dry-run` rehearses the migrations and says what a release destroys. Publishing measures that on the data on Terminus and asks you to confirm it.
- A migration runs once on every file that holds a collection it names: each person's, each space's and the app's own.
- `terminus dev` and `terminus push` print each storage change since the last release and what it needs: nothing, or SQL in the newest migration no release has shipped, or a new one, which they never write. Push keeps the last release's collections in `.terminus/released.json`.
- `terminus dev` runs pending migrations at every start.
- Cases in `tests/migrations/<the migration's name>.json` give a migration records and the records it must leave, and `terminus push` runs them.
- Cases in `tests/operations/<operation>.json` give a server operation a person's records and its input, and the answer and records it must leave; `terminus push` runs them on the server's bundle, and refuses one that fails.
- A migration of a collection only appended to changes what an entry holds, never its number.

```sql migrations/20261105093000_status_defaults_to_open.sql
UPDATE tasks SET data = json_set(data, '$.status', 'open') WHERE data->>'status' IS NULL;
```

```json tests/migrations/20261105093000_status_defaults_to_open.json
{ "status defaults to open": { "given": { "tasks": { "t1": { "title": "Ship" } } }, "expect": { "tasks": { "t1": { "status": "open" } } } } }
```

**The server.**

```ts src/server/index.ts
import app from "../../schema";

export default app.server({
  async submit({ score }, ctx) {
    const player = ctx.caller.userId;   // who called: key on it, never on the input
    await app.scores.update(player, (current) => (current && current.best >= score ? undefined : { best: score }));
    return { saved: true };
  },
});
```

- The window calls it by its handle: `const { saved } = await app.submit({ score: 42 });`
- A call from the window waits at most 10 seconds. An operation that needs longer declares `timeoutSeconds`, up to 120, and runs as a job: `app.<name>.run(input)`.
- An operation reaches only the hosts and secrets its `reaches` names. Secrets are set on the app's page; `terminus dev` reads them from `.env.local`.
- To refuse in your own words, throw `OperationError` from `@terminus-ai/sdk/service`: `throw new OperationError("not_your_turn", "Wait for your turn.")`. The caller gets `refused`, with your code in `details.code`, and pays nothing.

```ts
import { notifications } from "@terminus-ai/sdk";

await app.remind.run({ title: "Stand-up" }, { idempotencyKey: "standup" });
await app.remind.schedule({ every: "day", at: "09:00", timezone: "user" });
await notifications.create({ title: "Export ready", route: "/?view=exports" });
```

`remind` is a server operation the schema declares. The app's code makes jobs, schedules, webhooks (`app.<name>.webhook()`) and watches (`app.<name>.watch(url)`) at runtime.

Background work may run any server operation the schema declares, whatever its `from`. A release cannot remove an operation, or narrow its input, while people's schedules, webhooks, watches or unfinished jobs name it: publishing refuses it, and `terminus push` warns. A new shape takes a new name, and the old one goes once nothing names it.

**Tools for agents.**

```ts schema.ts
collections: {
  notes: { fields: { title: t.text(200) }, search: { fields: ["title"] }, agents: "write" },
},
operations: {
  digest: { runs: "server", effect: "read", from: ["agents"], description: "Summarise this week's notes." },
},
```

`agents: "read"` gives agents `list_notes`, `get_note` and `search_notes`; `"write"` adds create, update and delete. A server operation whose `from` lists `"agents"` becomes a command.

- `from` names who else may call a server operation, beyond the app's own window and background work: `"agents"`, and `"guests"`, signed-out visitors.
- Each person chooses per app, in Settings → App Access, for Norbert and for coding agents apart: Off, Read Only, or Read and Write, with Send to People its own yes where a tool reaches people. An agent works in the app as the person does: its level reaches every tool of that effect and below, data tools, server commands and window commands alike, in their own data and every space they are in, and it holds across the app's updates. An agent asks for more where it needs it: Norbert with a card in his conversation, and a coding agent refused in the terminal with a notice on the person's desk, which waits two minutes for Not Now or Allow; Allow raises coding agents' level to what the call needs, and the call runs. `terminus mcp` lists an app's data tools and server commands whatever the level, each past it saying that a call asks first, and its window commands only as far as the level reaches.
- A window operation (`runs: "window"`) runs in the app's window on the Terminus desktop, where the agent's level holds too: Off is off, even there. The desktop asks the person once whether agents may use their tabs at all (its Settings › Internet).
- `terminus mcp --dev` serves the app `terminus dev` runs in this folder, with no sign-in: the dev tools' own tools (`dev__…`) always, and the app's only as far as the member's App access page lets coding agents use them, none until the person sets it at `http://127.0.0.1:<their port>/__terminus_dev/app-access`. An app's window commands run only in the Terminus desktop: with it open, the first one called, or the first browser tool, opens the app there in a developer window.

**Test and publish.**

- `/__terminus_dev/index.md` lists every view of the dev tools as text, `/__terminus_dev/<view>.md`, and every request that acts on them, each with its `terminus mcp --dev` tool.
- A test can script the run. `/__terminus_dev/requests` lists the members' invitations, and a POST to `/__terminus_dev/requests/<id>/accept` or `/decline` answers one. With `--service`, `/__terminus_dev/services/calls` lists the calls the app made, and a POST to `/__terminus_dev/services/faults`, such as `{"code": "rate_limited", "times": 2}`, refuses the next matching calls.

## Agents {#agents}

An agent is a prompt that works for you on Terminus, around the clock. You write what it should do in `AGENT.md` and give it a model and tools. It answers when you talk to it, wakes on its own on a schedule, a webhook or a page it watches, and tells you when it has something to say. Once published, it works the same way for whoever installs it, with their own accounts.

- **The convention.** One folder.
  - `terminus.json`: what it is.
  - `AGENT.md`: its model, its tools and what wakes it in the frontmatter, its instructions below. Other files in the folder ship with it.
  - `skills/<name>/SKILL.md`: its own skills, which ship with it. Their descriptions say when it uses them.
- **Tools and models.** It can use services, the web and running code among them, load skills, and ask other agents. A skill's description says when to use it; `when` on a tool says it for this agent. People can switch it to another model.
- **Triggers.** A schedule, a webhook or a change on a public page wakes it on its own. A run with something to say notifies its person; an empty reply sends nothing.

**The convention.**

```json terminus.json
{
  "kind": "agent",
  "id": "@you/release-notes",
  "terminus_version": "0.0.1"
}
```

```md AGENT.md
---
models:
  default: "@terminus/claude-sonnet-4-6"
tools:
  - service:@terminus/web-access
  - service:@terminus/github
  - skill:@acme/brand-voice
triggers:
  weekly:
    schedule: { every: friday, at: "16:00", timezone: user }
    prompt: Draft this week's release notes.
---

# Release notes

You draft the week's release notes from the merged pull requests.
```

**Tools and models.**

| | |
|---|---|
| `service:@publisher/slug` | A service's operations; `#operation` grants one. The web and running code are services: `service:@terminus/web-access` and `service:@terminus/code` (`#bash`, `#python`, `#javascript`). |
| `skill:@publisher/slug` | A skill it can load. |
| `agent:@publisher/slug` | Another agent it can ask. |
| `schedules.manage` | Its own schedules, for each person it works for. |
| `watches.manage` | Its own page watches, for each person it works for. |

`mode: default` in `models` keeps it to its default model.

**Triggers.**

| | |
|---|---|
| `schedule` | `every` `"day"`, a weekday such as `"friday"`, or `"month"`, with `at`; an interval such as `"30m"`; or a five-field `cron`. UTC unless `timezone` says; `"user"` is each installer's own. |
| `webhook` | A URL each installation gets. |
| `watch` | A public page, checked on an interval for a change. |

- A trigger holds exactly one of them, with an optional `prompt` of up to 4,000 characters: without one, the wake says only why it woke. `enabled: false` starts it off.
- An agent has at most 64 schedules, 16 webhooks and 8 watches. A watch's page is a public https page, checked every 15 to 10,080 minutes (`interval_minutes`, 60 unless said).
- A trigger that fails 10 times in a row pauses itself and notifies its person; turning it on again resumes it.

## Skills {#skills}

A skill is know-how an agent loads when it needs it: instructions, and the files that go with them. Write it once, and it works in Terminus's own agents and in Claude Code and Codex.

- **The convention.** `SKILL.md` holds the instructions, and the files beside it go with them. Its description says when to use the skill, and agents choose skills by it.
- **Use skills.** `terminus skills install @acme/pdf` adds one to Claude Code or Codex, and `--agent claude`, `codex` or `both` picks which.

**The convention.**

```md SKILL.md
---
name: "release-notes"
description: "Use when writing release notes from merged pull requests."
---

# Release notes
…
```

- `name` and `description` are required. Its `terminus.json` holds only `kind`, `id` and `terminus_version`.
- `terminus create` writes a new skill's starter SKILL.md; push and publish it as in [Workflows](#workflows).

**Use skills.**

```bash
terminus search "pdf" --kind skill
terminus skills install @acme/pdf --agent claude   # or codex; --global for every project
terminus skills use "make a slide deck"            # find one and print its instructions now
```

- An installed skill loads its live release at each use; `@1.2.0` after its address pins one. A paid skill runs only on Terminus and is never installed.
- An agent on Terminus loads one with `skill:@publisher/slug` in its tools.

## Services {#services}

A service is a set of operations that apps, agents and other services call by its address. Write your own code and host it on Terminus, or connect an API you already run.

- **Hosted or external.**
  - Hosted: your own code in TypeScript, Rust, Python, Go, C or C++, which Terminus runs for each call.
  - External: an API you already run, joined through its OpenAPI document. Terminus can sign each call for your server to check, and a connector works in each person's own account, through their sign-in or their key.
- **The schema and the code.**
  - The schema declares each operation: what it takes, what it answers, and the hosts and secrets it may reach. Terminus checks every call and every answer against it.
  - The code answers each operation, with the input already checked, and gets the service's secrets, its settings, a cache and a store of its own.
- **Secrets and variables.** A secret, such as an API key, is typed once at a hidden prompt and never read back. A variable is a setting the service reads, changed without a release.

**Hosted or external.**

```json terminus.json
{ "kind": "service", "type": "hosted", "id": "@you/search", "terminus_version": "0.0.1" }
```

An external service's terminus.json says `"type": "external"`, and its `openapi.json` describes it.

A service can be files alone, its terminus.json saying no `type`. Its `assets/` holds files for pages: an app that declares it adds `assets/index.css` with `app.<name>.style()`, and takes a file's URL from `app.<name>.url(path)`. `terminus push` refuses scripts and WebAssembly there.

- On the security scheme in `openapi.json`, `"x-terminus-secret": "VENDOR_KEY"` sends a secret you set. `"x-terminus-signed": true` signs each call, once your server serves its token at `/.well-known/terminus-service-verification`.
- A connector's scheme is an OAuth sign-in, or `"x-terminus-person": true` for a key each person pastes, and it names an `x-terminus-health` path that reads who the person is.
- `terminus dev --endpoint <url>` runs it against your server.
- Calls go to `servers[0].url`, a public HTTPS address. Terminus checks its health at `/health/ready` unless `x-terminus-health` names another path.
- An `oauth2` scheme names its app with `x-terminus-client-id` and the app's client secret with `x-terminus-secret`, and takes one flow: `clientCredentials` for the service's own token, or `authorizationCode` for each person's sign-in.
- A signed call carries a bearer `service+jwt`: check it with the keys at Terminus's `/.well-known/jwks.json` (its `iss`), and that its `aud` is `urn:terminus:service:<id>`. `terminus push` prints what your server must be told: that audience, the token to serve, and a sign-in's redirect URI.

**The schema and the code.**

```ts schema.ts
import { service, t } from "@terminus-ai/sdk";

export default service({
  variables: { REGION: t.string(8).default("us") },
  operations: {
    search: {
      description: "Search the public web. Answers up to count results.",
      effect: "read",
      input: { query: t.text(400), count: t.int(1, 10).default(5) },
      output: { results: t.list(t.object({ title: t.text(), url: t.string(4096) }), 10) },
      reaches: { network: ["api.acme.com"], secrets: ["ACME_KEY"] },
    },
  },
});
```

- An operation reaches only the hosts and secrets it names, and has 10 seconds unless `timeoutSeconds` says otherwise.
- `job: true` answers the call at once with a job, which the caller waits on, and lets `timeoutSeconds` reach 300. A service that declares no services and no models runs no job.
- Grow, never break: add optional inputs and new answer fields. A breaking change is a new operation.
- A TypeScript service can declare the services and models it calls, as an app does.

```ts src/service.ts
import schema from "../schema";

export default schema.server({
  async search({ query, count }, ctx) {
    const url = `https://api.acme.com/v1/search?q=${encodeURIComponent(query)}&n=${count}`;
    const answer = await fetch(url, { headers: { authorization: `Bearer ${ctx.secrets.get("ACME_KEY")}` } });
    const { hits } = await answer.json();
    return { results: hits.map((hit) => ({ title: hit.title, url: hit.url })) };
  },
});
```

`ctx` holds `secrets`, `variables`, `cache`, `store` and `caller`. To refuse in your own words, throw `OperationError` from `@terminus-ai/sdk/service`. In another language, the code answers `POST /operations/<name>`.

Each call runs fresh, so nothing in memory outlasts it: what must last goes in `ctx.store`. A chain of service calls is at most four services deep, and never reaches a service already on it.

**Call it.**

```bash
terminus dev --call search query=rust            # one call, its answer printed
terminus dev --call search query=rust --remote   # the draft on Terminus, with its stored secrets
```

A page loads no picture from another origin: `@terminus/web-access`'s `image` operation fetches one and answers its bytes, a PNG, JPEG, GIF, WebP or AVIF of at most 5 MiB. `app.web.request("image", { url })` answers them as `bodyBase64`, for a `data:` URL.

**Secrets and variables.**

```bash
terminus secrets set ACME_KEY       # typed at a hidden prompt, never in a file
terminus variables set REGION=eu
```

A variable is declared in `schema.ts` with its default. For `terminus dev`, both come from `.env.local`.

## Terminus Conventions {#conventions}

Every creation is made with the same tools: the `terminus` CLI, which you and your coding agent run on your machine, and the SDK, which apps and TypeScript services are written with.

- **The CLI.** `terminus` is how you and your coding agent work on creations from your machine.
  - `terminus --help --all` lists its 19 commands, and `terminus <command> --help` prints each one's options.
  - `npm install -g @terminus-ai/terminus@latest` updates it.
- **The SDK.** `@terminus-ai/sdk`: an app's pages reach records, spaces, files and notifications through it, and a schema is written with it. Server code imports `@terminus-ai/sdk/service`.
  - The CLI keeps the package of the version a folder pins in its `.terminus/sdk/`, as Terminus serves it now, and its `package.json` links it as `"@terminus-ai/sdk": "file:.terminus/sdk"`, which `terminus create` writes. `terminus create`, `clone`, `dev` and `push` keep it; in a folder you got with `git clone`, `terminus sdk` keeps it.
- **Versions.** Every creation pins the version of Terminus it is written against, `terminus_version` in its `terminus.json`, and keeps working as Terminus moves on. `terminus update` moves a folder, and its SDK, to the newest version.

**The CLI.**

| | |
|---|---|
| Account | `login`, `logout` |
| Find | `search` |
| Start | `create`, `clone`, `link` |
| Sync | `status`, `diff`, `pull`, `push`, `update` |
| Work | `dev` |
| Configure | `settings`, `secrets`, `variables` |
| Release | `publish` |
| Coding agents | `mcp`, `skills` |

Most commands take `--json`; a failure is then one object on stderr: `{ "error": { "code": "…", "message": "…" } }`.

Exit codes: 0 done, 1 an error, 2 bad usage, 3 not signed in, 69 Terminus unreachable, 75 rate limited, 77 not allowed.

**Versions.**

An app's or a hosted service's `terminus_version` is the version its SDK speaks: `terminus dev` and `terminus push` write it from the folder's SDK. Another kind's moves only with `terminus update`.
