@standardagents/cli 0.45.5 → 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
@@ -69,7 +94,7 @@ are running a packed or globally installed local CLI, also set
69
94
 
70
95
  ```bash
71
96
  STANDARDAGENTS_WORKSPACE=1 STANDARD_AGENTS_API_URL=https://platform.agentbuilder-platform.orb.local pnpm exec agents init
72
- 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
73
98
  ```
74
99
 
75
100
  From the monorepo root, `pnpm onboarding:verify:local` runs both no-publish
@@ -97,7 +122,7 @@ Do not run manual npm publishes to test this flow.
97
122
  - `--package-manager <manager>` - Override package manager detection (`npm`, `pnpm`, `yarn`, or `bun`)
98
123
  - `--api-url <url>` - Platform API URL. See [Platform API URL](#platform-api-url) for the environment variables
99
124
 
100
- 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.
101
126
 
102
127
  ### Scaffold Project Structure
103
128
 
@@ -144,14 +169,56 @@ stage failed. `replaced` lists the guides that `--force` replaced.
144
169
  `agents support-files` accepts `--json` with the same shape and the stages
145
170
  `support-files` and `registry-pin`.
146
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
+
147
211
  ### Credential Files
148
212
 
149
- The CLI writes credentials into two project files: `.dev.vars` and
150
- `.agents/bootstrap-session.json`. Before each write, it adds `.dev.vars` and
151
- `.agents` to your `.gitignore` when Git does not ignore them. When Git tracks
152
- one of these files, the command stops and prints the `git rm --cached` command
153
- that stops the tracking. `agents logout` still removes credentials from a
154
- tracked `.dev.vars`.
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.
155
222
 
156
223
  ### Deploy From Git
157
224
 
@@ -174,9 +241,8 @@ local build or upload bundles.
174
241
  - When the platform answers the push with a `remote: Standard Agents:` notice,
175
242
  it stored the push and started no build. The command exits 4 when the notice
176
243
  asks for the terms, else 1.
177
- - Following a build uses your sign-in from `agents login` or
178
- `agents git-login`, or the project API key that `init` saved in
179
- `.dev.vars`. With neither, `deploy` says `Only the push was verified`,
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`,
180
246
  prints how to check the result, and exits 0.
181
247
  - A failed build prints the platform's error, the last 20 log lines, and the
182
248
  `builds logs` and `builds retry` commands.
@@ -245,8 +311,8 @@ Exit codes are the same for `deploy`, `builds`, `rollback`, and `redeploy`:
245
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 |
246
312
  | 1 | The build failed or was cancelled, no build started, or the platform refused the request |
247
313
  | 2 | The command line, the checkout, or the named build is not usable |
248
- | 3 | Not signed in, or the sign-in expired. Run `agents login` |
249
- | 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 terms accept` and the `builds retry` command that starts the waiting deploy |
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 |
250
316
  | 5 | The time limit passed while the build was still in progress |
251
317
 
252
318
  With `--json`, a failure before any result prints
@@ -276,9 +342,9 @@ example, "Push again to deploy"), states that your acceptance is recorded, and
276
342
  exits with code 1. To start a waiting deploy later, run `agents builds retry`
277
343
  in its project.
278
344
 
279
- Both commands use your saved sign-in. Run `agents login` in your project, or
280
- `agents git-login` once per machine, before you use them. An API key cannot
281
- accept terms, because acceptance belongs to a person.
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.
282
348
 
283
349
  Without a terminal, `terms accept` records nothing and exits with code 2. It
284
350
  prints the two links, the acknowledgement sentence, and the command that
@@ -349,46 +415,115 @@ npx @standardagents/cli skill --agent claude
349
415
 
350
416
  ```bash
351
417
  npx @standardagents/cli@latest login
352
- npx @standardagents/cli@latest login --bootstrap <code>
353
- npx @standardagents/cli@latest git-login
418
+ npx @standardagents/cli@latest login --bootstrap-stdin # setup code on standard input
419
+ npx @standardagents/cli@latest whoami
354
420
  npx @standardagents/cli@latest logout
355
421
  ```
356
422
 
357
- `login` signs the current project in to your Standard Agents account. It opens
358
- the browser sign-in page and never creates a project. The setup command on a
359
- project's Overview page (`login --bootstrap <code>`) also fetches the project
360
- API key that account sign-in to the local instance needs.
361
-
362
- `git-login` signs Git in on this machine for Standard Agents repositories.
363
-
364
- Both commands print the sign-in URL, open your browser, and wait until you
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
365
455
  approve the sign-in. Press Ctrl-C to cancel; the pending sign-in is cancelled
366
- on the platform too. Neither command asks for typed input.
456
+ on the platform too. The command never asks for typed input.
367
457
  `--no-open` prints the sign-in URL and waits without opening a browser on this
368
458
  machine, for sign-in from another device, a container, or a script.
369
459
  `STANDARD_AGENTS_BROWSER=none` has the same effect.
370
- Without a terminal, `login` and `git-login` exit with code 1 before they
371
- contact the platform unless you pass `--no-open` or `--bootstrap <code>`,
372
- which needs no browser.
373
-
374
- `logout` removes every stored credential: the Git login, the project session,
375
- and `STANDARD_AGENTS_API_KEY` in `.dev.vars`. It revokes the Git API key and
376
- the account session on the platform, which also signs you out of the
377
- dashboard. It then lists what still works. The project API key cannot be
378
- revoked from the CLI, and credentials set in your shell environment stay until
379
- you unset them. `logout` exits 1 when a credential on this machine still works
380
- or a revocation failed.
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.
381
488
 
382
489
  `logout --json` prints only the result on stdout:
383
490
  `{ "ok", "removed": [...], "revoked": [...], "remaining": [{ "message", "blocking" }] }`.
384
491
  `ok` is `false` exactly when the exit code is 1.
385
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
+
386
521
  ### Platform API URL
387
522
 
388
- `init`, `login`, `git-login`, `logout`, `builds`, and the Git credential helper
523
+ `init`, `login`, `logout`, `builds`, `terms`, and the Git credential helper
389
524
  resolve the platform API URL in one order:
390
525
 
391
- 1. The command's flag (`--api-url` for `init`, `--endpoint` for the others)
526
+ 1. The command's flag: `--endpoint <url>` or `--api-url <url>`
392
527
  2. `STANDARD_AGENTS_API_URL`
393
528
  3. `PLATFORM_ENDPOINT`
394
529
  4. `STANDARD_AGENTS_PLATFORM_URL`
@@ -398,6 +533,26 @@ The Git credential helper and `builds` read the same three variables from your
398
533
  project's `.dev.vars` after the environment. `logout` revokes each credential
399
534
  at the platform that issued it.
400
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
+
401
556
  ### Read The Curated Current Models Guide
402
557
 
403
558
  ```bash
@@ -405,7 +560,9 @@ pnpm exec agents current-models
405
560
  ```
406
561
 
407
562
  This fetches the live markdown guide from the Standard Agents spec site and
408
- 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.
409
566
 
410
567
  ### List Available Models From A Provider
411
568
 
@@ -430,7 +587,8 @@ or the provider returns no models.
430
587
 
431
588
  The command walks every provider page until it has the full model list, then
432
589
  prints a markdown table containing the exact `model` strings to use in
433
- `defineModel({ model: ... })`.
590
+ `defineModel({ model: ... })`. `--json` prints the same list as one JSON
591
+ document.
434
592
 
435
593
  ### Pack And Unpack Agents
436
594
 
@@ -444,8 +602,224 @@ Run these from the project root. They use the Standard Agents Builder installed
444
602
 
445
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.
446
604
 
605
+ `list-packed --json` prints the packages as one JSON document.
606
+
447
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.
448
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.
822
+
449
823
  ## Manual Configuration
450
824
 
451
825
  For new projects, manual Cloudflare configuration is not required. Add
@@ -455,18 +829,16 @@ compatibility flags, and migrations automatically.
455
829
 
456
830
  ## TypeScript Types
457
831
 
458
- Standard Agents Builder generates project types when the dev server starts. For a focused
459
- 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/`:
460
835
 
461
836
  ```bash
462
- pnpm exec vite build
837
+ npm run dev
463
838
  ```
464
839
 
465
- This will update your `worker-configuration.d.ts` file with:
466
-
467
- ```typescript
468
- interface Env {
469
- AGENT_BUILDER_THREAD: DurableObjectNamespace<DurableThread>;
470
- AGENT_BUILDER: DurableObjectNamespace<DurableAgentBuilder>;
471
- }
472
- ```
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.