Skip to content

Admin script commands

server/admin.ts runs on the server host. It adds teams, people, machines and agents, puts a repo under the coding framework, and connects GitHub. It talks to Postgres directly, so it needs DATABASE_URL in its environment.

On gomoe.dev the host has no SSH. An operator runs the script from a laptop through ops/aws-deploy/admin.ts, with the gomoe AWS profile and TF_DATA_DIR=~/.agents-app/terraform/gomoe, since it reads the stack from Terraform’s outputs. It sends the command over SSM Run Command, runs it in /srv/agents as the API’s user with the API’s .env, and prints what the command printed.

Terminal window
node ops/aws-deploy/admin.ts <command> <arguments>

With billing first, ops/aws-deploy/admin.ts runs server/billing/main.ts the same way. On a host you are signed in to, such as a developer’s Mac, run the script directly.

Terminal window
node --env-file=.env server/admin.ts <command> <arguments>

A command with the wrong number of arguments, or an unknown name, prints usage: with every command and exits with code 2. A team’s first login is its admin. The admin invites everyone else from the app.

A login is a person’s sign-in name. On gomoe.dev, with native sign-in, it is the email of an account. Adding a login that no account has makes an account with that email and no password, and its owner sets one with Forgot your password? on the sign-in page. On a server in Tailscale mode, a login is the Tailscale login that tailscale serve passes on.

Command Arguments What it does
add-team <team> <login> Creates a team and its first person, as an admin.
add-person <team> <login> Adds a person to a team as a member.
set-role <team> <login> <admin|member> Changes a person’s role.
add-instance <team> <name> <mac|box|check> <owner login> Registers a machine and prints its token.
add-agent <team> <name> <home instance> [model] [instructions] Creates a team-visible agent on an instance.
move-agents <team> Moves agents from their Macs to their person’s computer.
forge-login <login> <forge user> Records a person’s user name on the forge.
set-policy <team> <repo clone url> <policy.json> <owner login> Records a policy version for a repo and protects its default branch.
add-lesson <team> <rule> <incident> Adds a written lesson to a team.
github-token <team> <organization or account> Saves a team’s GitHub token, read from standard input.
grant-enterprise <email> [days] Gives the account the enterprise entitlement, which lets it make an organization, for [days] or with no end. Prints <email> has the enterprise entitlement, with for <days> days after it when days are given.
revoke-enterprise <email> Takes the entitlement back. Prints <email> no longer has the enterprise entitlement, or <email> had no enterprise entitlement.

The load-make, load-status, load-clean and stand-in-attempt commands serve the load harness in ops/load/ and bin/agentsctl. This page does not describe them.

Inserts the team and adds <login> to it with the role admin. Prints team <team> with <login> as its admin. On gomoe.dev people also make teams themselves, with Make a team on the page an account on no team sees.

Adds <login> to the team with the role member. Prints <login> joined <team>. Fails with no team <team> when the team does not exist.

Sets the role of <login> in <team> to admin or member. Prints <login> is now an admin of <team> or <login> is now a member of <team>. Fails with no person <login> in <team> when the login is not on the team.

Registers a machine of the kind mac, box or check, owned by the person <owner login> on the team. It prints one line of JSON with the machine’s name and its token.

{"instance":"<name>","token":"machine_<random>"}

The token is 24 random bytes in base64url after the prefix machine_. Postgres keeps only its SHA-256 hash, so the printed token is the only copy. Fails with no team <team> with person <owner login> when either is missing.

Creates an agent with the visibility team and <home instance> as its home. The optional [model] and [instructions] set its model and its instructions. An empty model leaves the model unset, and missing instructions are an empty string. Prints one line of JSON.

{"agent":"<name>","agentId":"<uuid>"}

Fails with no team <team> with instance <home instance> when either is missing.

Moves the team’s agents whose home is a Mac to the computer of their owner, or of their Mac’s owner when they have none. An agent moves only when its person’s computer can run it. That takes the box image built on this server and either the team’s Claude token saved on the server or the computer’s person signed in to Claude.

Prints moved <count>, followed by : <names> when any moved, then one line stayed on its Mac, <agent>: <reason> for each agent that did not. A reason is one of these.

  • it and its Mac have no owner with a computer
  • the box image is not built
  • the team's Claude token is not saved and its person has not signed in

Running the command again moves only the agents that could not move before.

Sets the forge user name for every person with <login>. Prints <login> is <forge user> on the forge. Fails with no person <login> when no person has that login. set-policy needs the repo owner’s forge user name when the repo lives on the server’s own forge.

Reads <policy.json> and checks it against the policy schema in shared/policy.ts. The policy’s name is the file name without .json.

  1. Inserts a new version of that policy for the team. The version is one more than the highest the team has for that name.
  2. Points the repo at the new version and sets <owner login> as the repo’s owner.
  3. When the clone URL starts with the server’s forge URL, makes the owner an admin of the repo on the forge and protects the repo’s default branch. The protection turns off pushes and force pushes, lets only the factory user and the owner merge, and requires one approval from the owner that a new push makes stale. It requires the four status contexts agents/gates, agents/review, agents/verdict and agents/suite, and protects the file patterns in the policy’s protectedPaths.

The repo must already be on the team under that clone URL, and the owner must be a person on the team. The command reads the forge’s settings file even when the repo is not on the forge. Steps 1 and 2 stay in place when step 3 fails. Step 3 fails with a request to run forge-login first when the owner has no forge user. Prints one line of JSON.

{"policy":"<name>","version":1,"repo":"<repo clone url>","owner":"<owner login>"}

Adds a lesson with the given rule and incident to the team. The lesson starts written, and it becomes enforced once it names the gate, lint rule or check that holds it. Prints added a written lesson to <team>. It becomes enforced once it names what holds it.

Reads a fine-grained personal access token from standard input, so the token never shows in the process list or the shell history. The token must match github_pat_ followed by 20 to 255 letters, digits or _ characters. A classic token is refused.

The command asks GitHub whose token it is. When <organization or account> is an organization, it also asks GitHub whether the token can see it. It then saves the token for the team in AGENTS_GITHUB_DIR, under stopgaps/<team id>.json, and prints {"login":"<account>","owner":"<owner>"}. It never prints the token. The owner is letters, digits and dashes, up to 39 characters.

The command needs AGENTS_GITHUB_DIR, AGENTS_GITHUB_API and AGENTS_GITHUB_GIT set together, or it stops with the names that are missing. ops/aws-deploy/admin.ts sends only the arguments, not standard input, so this command does not run through it on gomoe.dev. There an admin saves the team token on Repos with Set a team token. The line below runs against the server whose .env is in the checkout, such as a server on the developer’s Mac.

Terminal window
pbpaste | node --env-file=.env server/admin.ts github-token <team> <organization or account>
Variable Used by What it does
DATABASE_URL Every command The Postgres connection.
AGENTS_FORGE_FILE set-policy The forge’s settings file. The default is ~/.agents-app/forge.json. On gomoe.dev the API’s .env names /data/agents-app/forge.json.
AGENTS_GITHUB_DIR, AGENTS_GITHUB_API, AGENTS_GITHUB_GIT github-token Where GitHub’s tokens are kept and where its API and git are.