Orkestia
Blog
Staff & Agents

Staff as code

Declare your units and actors in TypeScript, review them in pull requests, check them on your machine, then plan and apply them to your organization with the orkestia command

Your Staff (business units, units, actors, their schedules, triggers, limits and the skills each one may use) can live in TypeScript files in a Git repository. You change a file, review it in a pull request, and apply it. The orkestia command checks the files on your machine, shows exactly what would change in your organization, and applies only what you approved.

Everything you can declare here you can also do by hand in the Staff console. Staff as code is the way to keep it reviewable and repeatable.

Staff as code is in beta (version 0.1). The command and the file format may still change between minor versions; orkestia upgrade moves a project to the newest one.

Install

You need Node.js 20 or newer (node --version).

macOS and Linux:

curl -fsSL https://download.orkestia.dev/framework/install.sh | sh

Windows (PowerShell, no admin rights needed):

irm https://download.orkestia.dev/framework/install.ps1 | iex

The script downloads the newest version, checks it against the release's SHA256SUMS and installs the orkestia command with your local npm. Nothing is downloaded from the npm registry for Orkestia's own packages.

orkestia --version

Run the script again to update the command. To pin a version, set ORKESTIA_FRAMEWORK_VERSION (for example ORKESTIA_FRAMEWORK_VERSION=0.1.4). downloads.json lists every version with each file's size and SHA256.

Start a project

In a new folder, or in an existing repository:

orkestia init
npm install

orkestia init keeps what is already in your package.json and adds:

FileWhat it is
package.json@orkestia/cli and @orkestia/staff as dev dependencies, plus staff:compile and staff:plan scripts
tsconfig.jsonEditor settings for the staff files (only when you have none)
app/staff/my-team.staff.tsA starter staff file

The dependencies point at the same download host, pinned to one version, so everyone on the project and your CI use exactly the same framework.

Write your Staff

Each app/staff/*.staff.ts file default-exports one staff(...) definition:

import { staff, usd } from "@orkestia/staff";

export default staff("my-team", ({ org }) => {
  const support = org.bu("my-company").vertical("operations").unit("support", {
    title: "Support",
    charter: "Answer customer questions.",
  });

  support.actor("support-agent", { kind: "loop" })
    .limits({ maxSteps: 12, budget: usd(5) })
    .every(3600, "Read new support questions and draft the answers.");
});
  • org.bu(...).vertical(...).unit(...) is the same tree you see in the Staff console.
  • .actor(name, { kind }) hires an actor in that unit: loop (runs on a schedule), trigger (wakes on an event) or hybrid.
  • .limits(...), .every(...), .listensTo(...), .canUse(skill(...)) and .promptedBy(...) set what it does and what it may use.

Your editor completes and checks every option. The full reference ships with the package: node_modules/@orkestia/staff/README.md.

Check it on your machine

npx orkestia staff compile

This compiles every staff file to .orkestia/staff.blueprint.json without contacting Orkestia. Errors point at the file and line. In CI, use the sandboxed compile, which cannot read secrets, use the network or start processes:

npx orkestia staff compile --pure --out staff.blueprint.json

Connect to your organization

The live commands need an API token:

  1. In the Orkestia app, switch to the organization you want to manage, then Organization → API Tokens → + Issue new token. Copy the value once.
  2. Set it in your shell (or as a CI secret):
export ORKESTIA_MEMBER_TOKEN=...

A token belongs to one organization, and the commands use that one. Every live command acts with the token's permissions, as you. Never commit a token.

Plan and apply

npx orkestia staff validate   # the server checks the blueprint: permissions, budgets, missing runners or models
npx orkestia staff plan       # what would change: creates, updates, grants, archives
npx orkestia staff apply --yes --watch
  • plan writes .orkestia/staff.plan.json. Review it, or post it on the pull request.
  • apply changes only what the plan showed, and you approve it as yourself: the command records the token's user as the approver.
  • Removing a unit or actor from a file never archives it. To archive one, say so in the file (below).
  • --watch follows the apply until it finishes; orkestia staff watch <apply_run_uuid> picks it up again later.

Archive an actor or a unit

Archiving is explicit. Add it to the staff file:

export default staff("my-team", ({ org }) => {
  // ...the rest of your Staff
  org.archiveActor("old-agent", { reason: "Replaced by support-agent" });
  org.archiveUnit("bu/my-company/vertical/operations/unit/old-team");
});
  • staff plan lists each archive.
  • Archives are destructive, so staff apply --yes skips them and tells you so. Apply them with:
npx orkestia staff apply --yes --allow-destructive --watch

An archived actor stops running, and its tokens and seat are released. Archive a unit's actors and child units along with it; they are archived first. Once something is archived, applying the same line again does nothing, so you can delete it from the file.

Upgrade

orkestia upgrade   # moves the project's framework packages to the newest version
npm install

Then run the install script again to update the orkestia command itself.