@standardagents/cli 0.45.4 → 0.45.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # @standardagents/cli
2
2
 
3
- CLI tool for Standard Agents setup and model discovery.
3
+ Command-line tool for Standard Agents Builder: project setup, sign-in,
4
+ deployment, and diagnostics. The command is `agents`.
4
5
 
5
6
  ## Installation
6
7
 
@@ -14,6 +15,30 @@ The CLI supports Node.js 22 (22.12 or newer) and Node.js 24. It checks the
14
15
  version at startup: an older Node.js stops with the version to install, and a
15
16
  newer untested release line prints a warning and continues.
16
17
 
18
+ ## Command Names
19
+
20
+ `agents` is the canonical command. This README, the CLI's help, and its
21
+ messages use that name, and it is the name to type after an install:
22
+
23
+ ```bash
24
+ npm install -g @standardagents/cli
25
+ agents --help
26
+ ```
27
+
28
+ Inside a project that depends on the package, run it through the package
29
+ manager, for example `pnpm exec agents <command>`.
30
+
31
+ The package installs two more names for the same program. Both behave exactly
32
+ like `agents`, and both identify themselves as `agents` in help and errors.
33
+
34
+ | Name | Policy |
35
+ |------|--------|
36
+ | `agents` | Canonical. Use it everywhere. |
37
+ | `cli` | Kept only so `npx @standardagents/cli` and `pnpm dlx @standardagents/cli` can find the program: both look for a binary named after the package. Deprecated as a command to type. A global install also puts this generic name on your `PATH`, where another tool's `cli` may take precedence; type `agents`. |
38
+ | `agentup` | Compatibility alias from earlier releases. It is kept so existing scripts keep working and is not used in documentation. Use `agents` in new scripts. |
39
+
40
+ A name is not removed without notice in the release notes.
41
+
17
42
  ## Usage
18
43
 
19
44
  ### Create And Connect A Project
@@ -39,6 +64,9 @@ This command will:
39
64
  The init command stays attached to the dev server. Press Ctrl-C in that terminal to stop it.
40
65
  The dev server listens on `127.0.0.1` only, both on this first start and on a later `npm run dev`.
41
66
  The success output includes the commands that start it again later.
67
+ If the dev server does not start, or exits with an error, `init` exits with
68
+ code 1. Your project stays cloned and configured, and the output ends with the
69
+ commands that start the server again.
42
70
 
43
71
  `init` needs an interactive terminal. Without one it exits with a message
44
72
  before it contacts the platform. To sign in from another device, or to run it
@@ -66,7 +94,7 @@ are running a packed or globally installed local CLI, also set
66
94
 
67
95
  ```bash
68
96
  STANDARDAGENTS_WORKSPACE=1 STANDARD_AGENTS_API_URL=https://platform.agentbuilder-platform.orb.local pnpm exec agents init
69
- STANDARDAGENTS_WORKSPACE=1 STANDARDAGENTS_WORKSPACE_ROOT=/path/to/agentbuilder STANDARD_AGENTS_API_URL=https://platform.agentbuilder-platform.orb.local cli init
97
+ STANDARDAGENTS_WORKSPACE=1 STANDARDAGENTS_WORKSPACE_ROOT=/path/to/agentbuilder STANDARD_AGENTS_API_URL=https://platform.agentbuilder-platform.orb.local agents init
70
98
  ```
71
99
 
72
100
  From the monorepo root, `pnpm onboarding:verify:local` runs both no-publish
@@ -92,9 +120,9 @@ Do not run manual npm publishes to test this flow.
92
120
  - `--no-open` - Print the sign-in URL without opening a browser
93
121
  - `--no-dev` - Clone and configure the project without starting the dev server
94
122
  - `--package-manager <manager>` - Override package manager detection (`npm`, `pnpm`, `yarn`, or `bun`)
95
- - `--api-url <url>` - Platform API URL. Also available through `STANDARD_AGENTS_API_URL` or `PLATFORM_ENDPOINT`
123
+ - `--api-url <url>` - Platform API URL. See [Platform API URL](#platform-api-url) for the environment variables
96
124
 
97
- Set `STANDARD_AGENTS_BROWSER="Google Chrome"` or another macOS browser app name when you need the browser handoff to use a specific browser during local development. Set `STANDARD_AGENTS_BROWSER=none` for headless verification.
125
+ Set `STANDARD_AGENTS_BROWSER` to open the sign-in in a specific browser: an application name on macOS and Windows (`"Google Chrome"`), or a command on Linux (`firefox`). `init` and `login` read it. Set `STANDARD_AGENTS_BROWSER=none` for headless verification. When the browser cannot be opened, the command prints a warning in place of `Opening your browser`; open the printed sign-in URL yourself.
98
126
 
99
127
  ### Scaffold Project Structure
100
128
 
@@ -108,9 +136,94 @@ Adds Standard Agents to an existing Vite project. The command updates
108
136
  documentation files. The Standard Agents Builder plugin generates the Cloudflare Worker entry
109
137
  and binding config at build time.
110
138
 
111
- ### Deploy From Artifacts Git
139
+ The command keeps your application files, and it keeps an existing
140
+ `AGENTS.md`.
141
+
142
+ **Options:**
143
+ - `--force` - Reset the `builder()` entry in `vite.config` to the default `builder()`, and replace existing `AGENTS.md` guides with the current versions. The command prints each replacement before it writes. It changes nothing else.
144
+ - `--json` - Print one JSON result on stdout. Progress lines go to stderr.
145
+
146
+ The command runs five stages: `vite-config`, `package-json`, `registry-pin`,
147
+ `guides`, and `tsconfig`. When a stage fails, the other stages still run and
148
+ their changes stay. The command names the failed stage, prints the command
149
+ that resumes it, and exits with code 1.
150
+
151
+ ```json
152
+ {
153
+ "command": "scaffold",
154
+ "ok": false,
155
+ "stages": [
156
+ { "stage": "vite-config", "status": "failed", "message": "No vite.config found. ..." },
157
+ { "stage": "package-json", "status": "ok", "message": "Updated package.json with current Standard Agents dependencies" },
158
+ { "stage": "registry-pin", "status": "ok", "message": "The @standardagents scope installs from public npm" },
159
+ { "stage": "guides", "status": "ok", "message": "Agent directories and AGENTS.md guides are in place" },
160
+ { "stage": "tsconfig", "status": "skipped", "message": "No tsconfig.json found, so there is no TypeScript configuration to update" }
161
+ ],
162
+ "resume": "npx @standardagents/cli@latest scaffold",
163
+ "replaced": []
164
+ }
165
+ ```
166
+
167
+ A stage `status` is `ok`, `skipped`, or `failed`. `resume` is `null` when no
168
+ stage failed. `replaced` lists the guides that `--force` replaced.
169
+ `agents support-files` accepts `--json` with the same shape and the stages
170
+ `support-files` and `registry-pin`.
171
+
172
+ ### Scaffold A Chat Front End
173
+
174
+ ```bash
175
+ npx @standardagents/cli@latest init-chat my-chat
176
+ ```
177
+
178
+ Creates a standalone React chat application (Vite or Next.js) for a running
179
+ Standard Agents instance. In a terminal the command asks for the framework,
180
+ the instance URL, and the package manager, installs dependencies, starts the
181
+ dev server, and opens the browser.
182
+
183
+ Without a terminal the command never prompts, so a script or coding agent can
184
+ run it. Pass the project name, and either `--yes` or a flag for each value:
185
+
186
+ ```bash
187
+ npx @standardagents/cli@latest init-chat my-chat --yes
188
+ npx @standardagents/cli@latest init-chat my-chat \
189
+ --framework nextjs --instance-url http://localhost:5173 --package-manager pnpm
190
+ ```
191
+
192
+ A missing value exits 1 before anything is created, and the message names the
193
+ missing flag. Without a terminal the command installs dependencies, prints the
194
+ command that starts the dev server, and exits. It does not start the server
195
+ unless you pass `--dev`.
196
+
197
+ #### Options
198
+
199
+ - `-y, --yes` - Skip prompts and use the defaults: Vite, `http://localhost:5173`, and the detected package manager
200
+ - `--framework <framework>` - `vite` or `nextjs`. Any other value exits 1 and lists these two
201
+ - `--instance-url <url>` - URL of the Standard Agents instance the chat connects to
202
+ - `--package-manager <manager>` - `npm`, `pnpm`, `yarn`, or `bun`
203
+ - `--no-install` - Write the project without installing dependencies or starting the dev server
204
+ - `--dev` - Start the dev server in the foreground. This is the default in a terminal
205
+ - `--no-dev` - Do not start the dev server. This is the default without a terminal
206
+ - `--no-open` - Do not open the browser when the dev server starts
207
+
208
+ When the dev server exits with an error, the command exits with the same code.
209
+ Ctrl-C or SIGTERM stops the dev server and the processes it started.
210
+
211
+ ### Credential Files
112
212
 
113
- Deployments are triggered by pushes to the platform-owned Artifacts repository:
213
+ The CLI writes one credential into a project: the project API key, in
214
+ `.dev.vars`. Before each write, it adds `.dev.vars` and `.agents` to your
215
+ `.gitignore` when Git does not ignore them. When Git tracks `.dev.vars`, the
216
+ CLI writes no credential into it and prints the `git rm --cached` command that
217
+ stops the tracking. `agents logout` still removes credentials from a tracked
218
+ `.dev.vars`.
219
+
220
+ Your account sign-in is saved once for the machine, in the CLI configuration
221
+ directory. No project file holds an account session.
222
+
223
+ ### Deploy From Git
224
+
225
+ The platform builds and deploys a project from pushes to its Standard Agents
226
+ git repository:
114
227
 
115
228
  ```bash
116
229
  git push origin main
@@ -118,9 +231,154 @@ git push origin main
118
231
  agents deploy
119
232
  ```
120
233
 
121
- `agents deploy` is a convenience wrapper around `git push origin HEAD:<branch>`.
122
- It does not run a local build or upload bundles; the platform build runner
123
- deploys from the Artifacts push event.
234
+ `agents deploy` runs `git push origin HEAD:refs/heads/<branch>`, then follows
235
+ the platform build of that commit and reports the result. It does not run a
236
+ local build or upload bundles.
237
+
238
+ - `Push accepted` means git stored the commit. It is not a deployment.
239
+ - When the remote branch already has the commit, nothing is pushed. The
240
+ command says that no build was started and reports the existing build.
241
+ - When the platform answers the push with a `remote: Standard Agents:` notice,
242
+ it stored the push and started no build. The command exits 4 when the notice
243
+ asks for the terms, else 1.
244
+ - Following a build uses your sign-in from `agents login`, or the project API
245
+ key in `.dev.vars`. With neither, `deploy` says `Only the push was verified`,
246
+ prints how to check the result, and exits 0.
247
+ - A failed build prints the platform's error, the last 20 log lines, and the
248
+ `builds logs` and `builds retry` commands.
249
+
250
+ | Option | Effect |
251
+ | --- | --- |
252
+ | `--no-wait` | Push and return |
253
+ | `--timeout <seconds>` | How long to follow the build (default 900); then exit 5 |
254
+ | `--remote <name>` | Git remote to push to (default `origin`) |
255
+ | `--branch <name>` | Remote branch to push to (default: the checked-out branch) |
256
+ | `--json` | Print one JSON document on standard output; every other line goes to standard error |
257
+ | `--project <id>` | Project ID, instead of matching the remote |
258
+ | `--endpoint <url>` | Platform API endpoint |
259
+
260
+ The remote must be `https://git.standardagents.ai` (or the earlier
261
+ `https://git.standardagentbuilder.com`), the hosts that the git credential
262
+ helper authenticates. Printed remote URLs never include credentials.
263
+
264
+ ### Read, Retry, And Roll Back Builds
265
+
266
+ ```bash
267
+ agents builds # recent builds, newest first
268
+ agents builds status # the build of the checked-out commit
269
+ agents builds status --commit <sha>
270
+ agents builds status <build> --wait
271
+ agents builds logs <build> # the build transcript
272
+ agents builds logs <build> --follow
273
+ agents builds retry [build] # re-run a failed build without a new commit
274
+ agents rollback --yes # make the earlier production build live again
275
+ agents redeploy # deploy the live production build again
276
+ ```
277
+
278
+ `<build>` is a build ID, or a unique prefix of an ID or commit. Without it the
279
+ command uses the newest build of the checked-out commit, else the newest
280
+ build. Every command accepts `--json`, `--project <id>` (when the project
281
+ cannot be found from the `origin` remote), and `--endpoint <url>`. These
282
+ commands use the same sign-in or project API key as `deploy`, and read builds
283
+ only for projects of that account. `rollback` and `redeploy` change what
284
+ production serves, so they need an owner or admin sign-in (`agents login`);
285
+ the project API key is refused there with exit code 3.
286
+
287
+ - `builds status`, `builds retry`, and `rollback` accept `--wait` and
288
+ `--timeout <seconds>` (default 900). A wait follows the platform's project
289
+ events socket; nothing is re-read on a timer.
290
+ - `agents builds retry` without a build retries the newest build of the
291
+ checked-out branch when it failed. When that build did not fail, the command
292
+ says that no build waits for a retry, starts nothing, and exits 0. After you
293
+ accept the terms, this command starts the deploy that waited.
294
+ - `agents rollback [build]` applies to production only. Without a build it
295
+ targets the production build that was live before the current one. It asks
296
+ for confirmation on a terminal and needs `--yes` when none is attached.
297
+ - `agents redeploy` deploys the live production build's stored bundle again,
298
+ so changed environment values take effect. It runs no build.
299
+ - `builds logs --follow --json` shows the log on standard error as it arrives,
300
+ then prints one JSON document with the whole log and the final build.
301
+ - None of the commands prompts, except `rollback` on a terminal without `--yes`.
302
+
303
+ When a deploy fails: read `agents builds logs <build>`, fix the cause, and push
304
+ a new commit. For a failure that needs no code change, run
305
+ `agents builds retry <build>`.
306
+
307
+ Exit codes are the same for `deploy`, `builds`, `rollback`, and `redeploy`:
308
+
309
+ | Code | Meaning |
310
+ | --- | --- |
311
+ | 0 | Done. For a wait: the commit was deployed (the build is `live`, or was live and is `superseded`). A plain `builds status` or `builds logs` read also exits 0 |
312
+ | 1 | The build failed or was cancelled, no build started, or the platform refused the request |
313
+ | 2 | The command line, the checkout, or the named build is not usable |
314
+ | 3 | Not signed in, or the sign-in expired. Run `npx @standardagents/cli@latest login` |
315
+ | 4 | The platform refused a build until the terms are accepted (`error_code` `legal_acceptance_required`). A refused build that a retry later started is listed as `retried` and needs no action. The platform's message is printed, then `Run: npx @standardagents/cli@latest terms accept` and the `builds retry` command that starts the waiting deploy |
316
+ | 5 | The time limit passed while the build was still in progress |
317
+
318
+ With `--json`, a failure before any result prints
319
+ `{ "error": { "message", "fix", "exit_code" } }`.
320
+
321
+ ### Read And Accept The Terms
322
+
323
+ ```bash
324
+ npx @standardagents/cli@latest terms
325
+ npx @standardagents/cli@latest terms accept
326
+ ```
327
+
328
+ `terms` shows the Terms of Service and the Privacy Policy that are in force:
329
+ each title, version, and URL, and whether you accepted that version.
330
+
331
+ `terms accept` shows the same documents and the acknowledgement sentence from
332
+ the platform, then asks `Do you accept? [y/N]`.
333
+
334
+ An acceptance starts no build. After you accept, the command lists each deploy
335
+ that the platform refused for the terms and that is still the newest build of
336
+ its branch. It asks `Start this deploy now? [y/N]` and, after a yes, starts
337
+ each one through the retry route. With `--agree` it starts them with no second
338
+ question, because you approved each deploy when you pushed it. It reports each
339
+ result and follows none of them; read one with `agents builds status <build>`.
340
+ When a retry is refused, the command prints the platform's reason (for
341
+ example, "Push again to deploy"), states that your acceptance is recorded, and
342
+ exits with code 1. To start a waiting deploy later, run `agents builds retry`
343
+ in its project.
344
+
345
+ Both commands use your sign-in for this machine, so they work in any
346
+ directory. Run `npx @standardagents/cli@latest login` once before you use
347
+ them. An API key cannot accept terms, because acceptance belongs to a person.
348
+
349
+ Without a terminal, `terms accept` records nothing and exits with code 2. It
350
+ prints the two links, the acknowledgement sentence, and the command that
351
+ accepts those versions:
352
+
353
+ ```bash
354
+ npx @standardagents/cli@latest terms accept --agree --terms-version <version> --privacy-version <version>
355
+ ```
356
+
357
+ `--agree` needs both version options. The command accepts only when the two
358
+ versions match the current documents. When a document changed after you
359
+ reviewed it, the command records nothing, exits with code 2, and prints the
360
+ current documents with a new command.
361
+
362
+ If your coding agent runs the command, it must show you the two links and the
363
+ acknowledgement sentence. It runs the printed command only after you say yes
364
+ to those versions.
365
+
366
+ #### Options
367
+
368
+ - `--json` - Print one JSON object and never prompt. `terms accept --json` still needs `--agree`. A code 2 result holds the command in `accept_command`. An accepted result holds `refused_builds` (the deploys that waited) and `retried` (`{ build_id, ok, status, started_build_id }`, or `{ build_id, ok: false, error }`)
369
+ - `--agree` - Accept without a prompt (`terms accept` only). It needs `--terms-version` and `--privacy-version`
370
+ - `--terms-version <version>` - With `--agree`: the Terms of Service version you reviewed
371
+ - `--privacy-version <version>` - With `--agree`: the Privacy Policy version you reviewed
372
+ - `--endpoint <url>` - Platform API endpoint. The default is the endpoint of your saved sign-in
373
+
374
+ #### Exit codes
375
+
376
+ | Code | Meaning |
377
+ |------|---------|
378
+ | 0 | Success, including "already accepted" and "no terms to accept" |
379
+ | 1 | Failure. This includes a waiting deploy that did not start after a recorded acceptance |
380
+ | 2 | Confirmation needed; nothing was recorded |
381
+ | 3 | Not signed in |
124
382
 
125
383
  ### Install The Standard Agents Builder Skill
126
384
 
@@ -153,6 +411,148 @@ npx @standardagents/cli skill --agent agents
153
411
  npx @standardagents/cli skill --agent claude
154
412
  ```
155
413
 
414
+ ### Sign In And Out
415
+
416
+ ```bash
417
+ npx @standardagents/cli@latest login
418
+ npx @standardagents/cli@latest login --bootstrap-stdin # setup code on standard input
419
+ npx @standardagents/cli@latest whoami
420
+ npx @standardagents/cli@latest logout
421
+ ```
422
+
423
+ `login` is the one sign-in command. It works in any directory and never
424
+ creates a project. It does three things:
425
+
426
+ 1. It saves one sign-in for this machine: an account session and a long-lived
427
+ account API key. `terms`, `builds`, `deploy`, `rollback`, `redeploy`, and
428
+ Git use it in every directory.
429
+ 2. It registers the Git credential helper for `git.standardagents.ai` and
430
+ `git.standardagentbuilder.com` in your global Git configuration.
431
+ `--no-config` skips this step.
432
+ 3. Inside a project that has no project API key, it saves that key in
433
+ `.dev.vars`. Account sign-in to the local instance needs it. `login` finds
434
+ the project from the Git remote of your checkout, or from the setup code on
435
+ the project's Overview page. An existing key is kept.
436
+
437
+ `login` takes the setup code three ways: `--bootstrap-stdin` reads it from
438
+ standard input, `--bootstrap-file <path>` reads it from a file, and
439
+ `--bootstrap <code>` takes it as an argument. Other users of the machine can
440
+ read an argument in the process list, so prefer the first two.
441
+
442
+ When `login` replaces a published default admin password, it saves the new
443
+ one as `SUPER_ADMIN_PASSWORD` in `.dev.vars` and does not print it.
444
+
445
+ On macOS `login` keeps the account session and the account API key in the
446
+ Keychain. On other platforms, when the Keychain is locked (for example over
447
+ SSH), or when you set `STANDARD_AGENTS_CREDENTIAL_STORE=file`, it keeps them
448
+ in `auth-state.json` in the CLI configuration directory, readable only by your
449
+ user. A sign-in that an earlier release saved in that file keeps working and
450
+ moves to the Keychain the next time you run `login`. Running `login` again
451
+ keeps the existing API key, or revokes the key of a different user or account
452
+ before it creates a new one, so one machine holds one active key.
453
+
454
+ `login` prints the sign-in URL, opens your browser, and waits until you
455
+ approve the sign-in. Press Ctrl-C to cancel; the pending sign-in is cancelled
456
+ on the platform too. The command never asks for typed input.
457
+ `--no-open` prints the sign-in URL and waits without opening a browser on this
458
+ machine, for sign-in from another device, a container, or a script.
459
+ `STANDARD_AGENTS_BROWSER=none` has the same effect.
460
+ Without a terminal, `login` exits with code 1 before it contacts the platform
461
+ unless you pass `--no-open` or a setup code, which needs no browser.
462
+
463
+ `agents git-login` is an earlier name of `login`. It accepts the same flags
464
+ and does the same work.
465
+
466
+ Releases through 0.45.5 had a separate project sign-in that saved a session in
467
+ `.agents/bootstrap-session.json`. No command reads that file any more. If you
468
+ signed in only that way, run `login` once. `logout` deletes the old file.
469
+
470
+ `whoami` prints the user, the account, and the platform address of the saved
471
+ sign-in. It sends no request and never prints the session or the key.
472
+ `whoami --json` prints
473
+ `{ "ok": true, "endpoint", "account": { "id", "slug" }, "user": { "id", "email" }, "credential", "signed_in_at" }`.
474
+ `credential` is `api_key`, `session`, or `unreadable` when the Keychain does
475
+ not return the saved sign-in (for example in an SSH session).
476
+ When no sign-in is saved it exits with code 3 and prints
477
+ `{ "ok": false, "error": { "code": "NOT_SIGNED_IN", "message", "fix" } }`.
478
+
479
+ `logout` removes every stored credential: your sign-in for this machine,
480
+ `STANDARD_AGENTS_API_KEY` in `.dev.vars`, and a project session from an
481
+ earlier release. It revokes the project API key, the account API key of this
482
+ machine, and the account session on the platform, which also signs you out of
483
+ the dashboard. It then lists what still works. A platform with no route for a
484
+ key to revoke itself reports the project API key as still valid; revoke it
485
+ under API keys in the dashboard. Credentials set in your shell environment
486
+ stay until you unset them. `logout` exits 1 when a credential on this machine
487
+ still works or a revocation failed.
488
+
489
+ `logout --json` prints only the result on stdout:
490
+ `{ "ok", "removed": [...], "revoked": [...], "remaining": [{ "message", "blocking" }] }`.
491
+ `ok` is `false` exactly when the exit code is 1.
492
+
493
+ ### Git Credential Helper Version
494
+
495
+ `login` and `init` register the credential helper as
496
+ `npx -y @standardagents/cli@<version> git-credential`, where `<version>` is the
497
+ CLI release that ran the command. Git runs the helper with your credentials on
498
+ every fetch and push, so it never starts a release that you did not run
499
+ yourself.
500
+
501
+ - To move the helper to a newer release, run that release's `login`
502
+ again. For a repository that `init` cloned, the helper is in the
503
+ repository's own Git configuration (`git config --local credential.helper`).
504
+ - `--helper-command <command>` and `STANDARD_AGENTS_GIT_HELPER` register a
505
+ command of your choice.
506
+ - A helper that a release through 0.45.5 registered as `@latest` keeps
507
+ working. It runs the newest published release on each Git operation until
508
+ you run `login` again.
509
+ - A build without a version, such as a source checkout, registers `@latest`.
510
+
511
+ The helper requests a read-only token for `git clone`, `git fetch`, `git pull`,
512
+ and `git ls-remote`, and a write token for every other command. It reads the
513
+ command from the `git` process that started it and falls back to a write
514
+ token. `STANDARD_AGENTS_GIT_TOKEN_SCOPE=write` forces the earlier behavior.
515
+
516
+ `login` sets `useHttpPath` for the two Standard Agents Git hosts only. It
517
+ removes the global `credential.useHttpPath` that earlier releases set when
518
+ your global Git configuration holds no other credential setting, and otherwise
519
+ prints the command that removes it.
520
+
521
+ ### Platform API URL
522
+
523
+ `init`, `login`, `logout`, `builds`, `terms`, and the Git credential helper
524
+ resolve the platform API URL in one order:
525
+
526
+ 1. The command's flag: `--endpoint <url>` or `--api-url <url>`
527
+ 2. `STANDARD_AGENTS_API_URL`
528
+ 3. `PLATFORM_ENDPOINT`
529
+ 4. `STANDARD_AGENTS_PLATFORM_URL`
530
+ 5. `https://api.standardagents.ai`
531
+
532
+ The Git credential helper and `builds` read the same three variables from your
533
+ project's `.dev.vars` after the environment. `logout` revokes each credential
534
+ at the platform that issued it.
535
+
536
+ `--endpoint` and `--api-url` are two names for one option. Every command that
537
+ takes a platform URL accepts both; `init --help` lists `--api-url` and the
538
+ other commands list `--endpoint`. With both on one command line, `--api-url`
539
+ is used.
540
+
541
+ The CLI sends your session or API key to this URL, so it must use HTTPS. Plain
542
+ HTTP is accepted only for this machine (`localhost`, `127.0.0.1`, `[::1]`).
543
+ For any other URL the command exits 1 before it sends a request and prints the
544
+ `https://` URL to use. A URL that contains a user name or password is refused
545
+ the same way. `diag --token` and the account key of `available-models` follow
546
+ the same rule.
547
+
548
+ A request that carries your session, API key, or setup code is never
549
+ redirected. When the platform answers with a redirect, the command stops and
550
+ names the host; check the platform URL.
551
+
552
+ Each request to the platform, an instance, or the model guide ends after 30
553
+ seconds without an answer (15 seconds per model guide address). The message
554
+ names the host and the command to run next.
555
+
156
556
  ### Read The Curated Current Models Guide
157
557
 
158
558
  ```bash
@@ -160,21 +560,265 @@ pnpm exec agents current-models
160
560
  ```
161
561
 
162
562
  This fetches the live markdown guide from the Standard Agents spec site and
163
- prints it to stdout.
563
+ prints it to stdout. It requests `https://standardagentspec.org/models.md`
564
+ first, and `https://standardagentspec.com/models.md` when that request fails.
565
+ `--url <url>` requests another address instead.
164
566
 
165
- ### List Available Models From A Configured Provider
567
+ ### List Available Models From A Provider
166
568
 
167
569
  ```bash
168
570
  pnpm exec agents available-models --provider=cerebras
169
571
  ```
170
572
 
171
- The CLI reads your current project's installed provider packages plus the env
172
- keys in `.env`, `.env.local`, `.dev.vars`, `.dev.vars.local`, and `process.env`.
173
- If multiple providers are configured, specify one with `--provider`.
573
+ The CLI reads your current project's installed provider packages, the
574
+ providers defined in `agents/providers/`, and the env keys in `.env`,
575
+ `.env.local`, `.dev.vars`, `.dev.vars.local`, and `process.env`.
576
+ If more than one provider is usable, specify one with `--provider`.
577
+
578
+ A project linked to a Standard Agents account needs no provider key. When a
579
+ provider's own key is not set, the command lists its models with the
580
+ project's account key (`STANDARD_AGENTS_API_KEY`), through the same platform
581
+ route the running project uses. A provider's own key takes precedence and goes
582
+ to the provider directly. A provider from `agents/providers/` always uses the
583
+ key and base URL its definition declares; the account key does not cover it.
584
+
585
+ The command exits 1 with the cause when a key is missing, the request fails,
586
+ or the provider returns no models.
174
587
 
175
588
  The command walks every provider page until it has the full model list, then
176
589
  prints a markdown table containing the exact `model` strings to use in
177
- `defineModel({ model: ... })`.
590
+ `defineModel({ model: ... })`. `--json` prints the same list as one JSON
591
+ document.
592
+
593
+ ### Pack And Unpack Agents
594
+
595
+ ```bash
596
+ npx @standardagents/cli pack my_agent
597
+ npx @standardagents/cli list-packed
598
+ npx @standardagents/cli unpack standardagent-my-agent
599
+ ```
600
+
601
+ Run these from the project root. They use the Standard Agents Builder installed in the project, so install the project's dependencies first. A project without it gets the install command and exit code 1.
602
+
603
+ `pack` writes the package to `agents/packed/` and then removes the original files that only the packed agent uses. Files that another agent shares are kept. It lists the files before it removes them. Pass `--no-remove` to keep every original; `unpack` restores them from the package.
604
+
605
+ `list-packed --json` prints the packages as one JSON document.
606
+
607
+ Without a terminal, or with `--no-interactive`, `pack` never prompts. When the project has several agents, name the one to pack; otherwise the command lists the agents and exits with code 1.
608
+
609
+ ### Diagnose A Running Instance
610
+
611
+ ```bash
612
+ agents diag instance # deployed version, watchdog budgets, config warnings
613
+ agents diag threads --stuck # recent threads with an unrecovered open request
614
+ agents diag thread <id> # one thread in detail
615
+ agents diag logs <thread> [logId] # request logs
616
+ agents diag tail <thread> # live log stream
617
+ agents diag revive <thread> # run a watchdog check now
618
+ ```
619
+
620
+ These commands read an instance, not the platform. Set
621
+ `STANDARD_AGENTS_INSTANCE_URL` and `STANDARD_AGENTS_INSTANCE_TOKEN`. The
622
+ `--endpoint <url>` and `--token <key>` flags take the same values, but other
623
+ users of the machine can read a token that is passed as an argument.
624
+
625
+ - A failed request prints the instance's error code, message and request ID.
626
+ - `diag threads` reports how many threads it could not read. Those threads are
627
+ listed as `UNKNOWN`. With `--stuck`, an unread thread could be the stuck one,
628
+ so the command lists each unread thread with its error and exits 1. Exit 0
629
+ means every thread was read; the stuck threads, if any, are the ones listed.
630
+ - `diag tail` exits 0 when the stream closes normally (close code 1000 or
631
+ 1005) and 1 when the socket fails or closes with any other code.
632
+
633
+ ### Every Command
634
+
635
+ The [CLI reference](https://docs.standardagents.ai/user-interfaces/cli) lists
636
+ every command and flag, the exit codes, the commands to run without a
637
+ terminal, where credentials are stored, and what to do when a build fails.
638
+
639
+ | Command | Purpose |
640
+ |---------|---------|
641
+ | `init` | Create a project on the platform, clone it, and start it locally |
642
+ | `login` | Sign in to your account on this machine. Inside a project, also save the project API key |
643
+ | `whoami` | Print the account this machine is signed in to. Exits 3 when not signed in |
644
+ | `logout` | Remove and revoke stored credentials |
645
+ | `git-credential` | The Git credential helper that `init` and `login` register. Git runs it; you do not need to |
646
+ | `scaffold` | Add Standard Agents to an existing Vite project |
647
+ | `support-files` | Write the local support files (`package.json` when missing, `.gitignore` entries, the registry setting) of a project repository that you cloned yourself. `init` runs this step for you |
648
+ | `init-chat` | Create a React chat front end (Vite or Next.js) for a running instance |
649
+ | `deploy` | Push the current branch and follow the platform build |
650
+ | `builds` | Read builds and build logs, and retry a failed build |
651
+ | `rollback` | Make an earlier production build live again |
652
+ | `redeploy` | Deploy the live production build again |
653
+ | `skill` | Install the coding skill for your coding agent |
654
+ | `current-models` | Print the current model guide |
655
+ | `available-models` | List the model IDs of one provider |
656
+ | `pack` | Pack an agent and its dependencies into a package |
657
+ | `unpack` | Copy a packed agent into editable files. Without a package name it lists the packages |
658
+ | `list-packed` | List the packed agents in the project |
659
+ | `diag` | Diagnose a running instance |
660
+ | `terms` | Read and accept the Standard Agents terms |
661
+
662
+ ## Machine-Readable Output
663
+
664
+ Errors and warnings from every command go to stderr. Status lines and results
665
+ go to stdout.
666
+
667
+ With `--json`, stdout holds exactly one JSON document and nothing else, and
668
+ status lines, warnings and errors go to stderr. `diag tail` is the one
669
+ exception: it prints one JSON frame per line.
670
+
671
+ This section describes `--json` for `available-models`, `list-packed`, and
672
+ every `diag` subcommand:
673
+
674
+ - A command that exits 0 prints its result document.
675
+ - A command that exits nonzero prints a document with an `error` member. The
676
+ document may also carry the result fields that were known when it failed.
677
+
678
+ Four groups of commands print their own documents, described with the
679
+ commands:
680
+
681
+ - `deploy`, `builds` and its subcommands, `rollback`, and `redeploy`: see
682
+ [Read, Retry, And Roll Back Builds](#read-retry-and-roll-back-builds). Their
683
+ documents carry `exit_code`, and a failure before any result prints
684
+ `{ "error": { "message", "fix", "exit_code" } }`.
685
+ - `scaffold` and `support-files`: see
686
+ [Scaffold Project Structure](#scaffold-project-structure). A failure is
687
+ `"ok": false`, with the cause in the failed stage's `message` and the next
688
+ command in `resume`.
689
+ - `logout` and `whoami`: see [Sign In And Out](#sign-in-and-out). A `logout` failure is
690
+ `"ok": false`, with the credentials that still work in `remaining`.
691
+ - `terms` and `terms accept`: see
692
+ [Read And Accept The Terms](#read-and-accept-the-terms).
693
+
694
+ ### Error object
695
+
696
+ ```json
697
+ {
698
+ "error": {
699
+ "code": "request_failed",
700
+ "message": "The same text the command prints on stderr.",
701
+ "hint": "The next command or step, when the command knows one.",
702
+ "status": 403,
703
+ "request_id": "0b9f6c1e-..."
704
+ }
705
+ }
706
+ ```
707
+
708
+ `code` and `message` are always present. `hint` is present when the command
709
+ knows the next step. `status` and `request_id` are present for a failed HTTP
710
+ request to an instance (`diag`).
711
+
712
+ Two codes come from the CLI itself, for any command: `usage_error` (an unknown
713
+ command or option, or a missing argument) and `command_failed` (a failure with
714
+ no more specific code). They are printed whenever `--json` is in the
715
+ arguments, including for a command that has no `--json` option.
716
+
717
+ ### Exit codes
718
+
719
+ | Code | Meaning |
720
+ | --- | --- |
721
+ | 0 | The command did what it reports. With `--json`, the document has no `error` member |
722
+ | 1 | The command failed, or could not verify its result. The cause is on stderr and, with `--json`, in `error` (`scaffold` and `support-files`: in the failed stage) |
723
+ | 2 to 5 | Used by `deploy`, `builds`, `rollback`, and `redeploy` (see [Read, Retry, And Roll Back Builds](#read-retry-and-roll-back-builds)), and codes 2 and 3 by `terms` (see [Read And Accept The Terms](#read-and-accept-the-terms)) |
724
+ | 130, 143 | `init` was interrupted by Ctrl-C (130) or SIGTERM (143) and cleaned up |
725
+
726
+ Command-specific cases of exit code 1: `logout` when a credential still works
727
+ or a revocation failed; `diag threads --stuck` when a thread could not be
728
+ read; `diag tail` when the stream closed abnormally.
729
+
730
+ ### `available-models --json`
731
+
732
+ ```json
733
+ {
734
+ "provider": {
735
+ "name": "openai",
736
+ "label": "OpenAI",
737
+ "source": "package",
738
+ "credential": "platform",
739
+ "platform_origin": "https://api.standardagents.ai"
740
+ },
741
+ "models": [
742
+ { "id": "gpt-5.4", "label": "GPT-5.4", "description": "", "context_length": 400000 }
743
+ ]
744
+ }
745
+ ```
746
+
747
+ - `models[].id` is the value for `defineModel({ model })`. `context_length` is
748
+ `null` when the provider does not report it.
749
+ - `provider.source` is `package` for an installed provider package and
750
+ `project` for a provider defined in `agents/providers/`.
751
+ - `provider.credential` is `own-key` (the provider's own key), `platform` (the
752
+ project's Standard Agents account key; `platform_origin` is then set), or
753
+ `definition` (a provider from `agents/providers/`; `file` is then set, and
754
+ `base_url` when the definition configures one).
755
+ - The document never contains a key.
756
+ - Error codes: `no_providers`, `unknown_provider`, `provider_not_installed`,
757
+ `provider_load_failed`, `missing_credentials`, `no_configured_provider`,
758
+ `ambiguous_provider`, `request_failed`, `no_models`, `insecure_endpoint` (the
759
+ account key would go to a platform URL that is neither HTTPS nor on this
760
+ machine).
761
+
762
+ ### `list-packed --json`
763
+
764
+ ```json
765
+ {
766
+ "packages": [
767
+ {
768
+ "package_id": "standardagent-my-agent",
769
+ "version": "1.0.0",
770
+ "source": "local",
771
+ "entry_agents": ["my_agent"],
772
+ "path": "agents/packed/standardagent-my-agent"
773
+ }
774
+ ]
775
+ }
776
+ ```
777
+
778
+ `packages` is empty when none are found. Error codes: `not_a_project` (no
779
+ `agents/` directory) and `packing_unavailable` (the Standard Agents Builder is
780
+ not installed in the project, or has no packing entry point).
781
+
782
+ ### `diag --json`
783
+
784
+ - `diag instance`, `diag thread`, `diag logs <thread> <logId>` and
785
+ `diag revive` print the instance's API response unchanged. `diag logs
786
+ <thread>` prints the array of logs.
787
+ - `diag threads` prints the scan:
788
+
789
+ ```json
790
+ {
791
+ "scanned": 25,
792
+ "unreadable": 1,
793
+ "threads": [
794
+ { "id": "050d96f1-...", "agent": "support", "health": "idle", "detail": "idle" }
795
+ ],
796
+ "unreadable_threads": [
797
+ {
798
+ "id": "7c1e22aa-...",
799
+ "agent": "support",
800
+ "error": { "code": "internal_error", "message": "GET /api/threads/7c1e22aa-.../diagnostics → HTTP 500: ...", "status": 500, "request_id": "..." }
801
+ }
802
+ ]
803
+ }
804
+ ```
805
+
806
+ `scanned` counts the threads that were checked and `unreadable` the ones
807
+ whose diagnostics could not be read. `health` is `stuck`, `running`,
808
+ `stopped`, `idle`, `terminated` or `unknown`. With `--stuck`, `threads`
809
+ holds only stuck threads, and an incomplete scan exits 1 with the error code
810
+ `incomplete_scan`. Earlier releases printed the `threads` array alone.
811
+ - `diag tail --json` prints each frame from the instance on its own line, as
812
+ the instance sent it (JSON Lines), and nothing else on stdout. A frame that
813
+ is not JSON is skipped with a note on stderr. A failure is reported on
814
+ stderr only, because stdout carries frames.
815
+ - Error codes: the instance's own code for a refused request (for example
816
+ `forbidden`), `request_failed` when the instance sent none, `unreachable`
817
+ when no connection was made, `timeout` when the instance did not answer
818
+ within 30 seconds, `insecure_endpoint` when a token would go to an instance
819
+ URL that is neither HTTPS nor on this machine, `redirect_refused` when the
820
+ instance answered a request that carried a token with a redirect, and
821
+ `diag_failed` otherwise.
178
822
 
179
823
  ## Manual Configuration
180
824
 
@@ -185,18 +829,16 @@ compatibility flags, and migrations automatically.
185
829
 
186
830
  ## TypeScript Types
187
831
 
188
- Standard Agents Builder generates project types when the dev server starts. For a focused
189
- type-generation pass, run:
832
+ The dev server generates the project's type files. It writes
833
+ `.agents/types.d.ts` and `.agents/virtual-module.d.ts` when it starts, and
834
+ again after each change under `agents/`:
190
835
 
191
836
  ```bash
192
- pnpm exec vite build
837
+ npm run dev
193
838
  ```
194
839
 
195
- This will update your `worker-configuration.d.ts` file with:
196
-
197
- ```typescript
198
- interface Env {
199
- AGENT_BUILDER_THREAD: DurableObjectNamespace<DurableThread>;
200
- AGENT_BUILDER: DurableObjectNamespace<DurableAgentBuilder>;
201
- }
202
- ```
840
+ Start the dev server once before you run the type checker in a new project;
841
+ the type checker reports missing type files until then. There is no separate
842
+ type-generation command. Do not run `vite build` for types: the `build` script
843
+ of a generated project stops with a message, because builds run on the
844
+ Standard Agents platform.