@nouter/platform-cli 0.4.0 → 0.6.0

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.
Files changed (4) hide show
  1. package/CHANGELOG.md +445 -0
  2. package/README.md +318 -6
  3. package/dist/index.js +6207 -879
  4. package/package.json +6 -3
package/README.md CHANGED
@@ -60,14 +60,40 @@ nouter-platform login --paste # paste code#state, for a remote session
60
60
  nouter-platform whoami --json
61
61
  nouter-platform agents list
62
62
  nouter-platform agents get <agent-id>
63
+ nouter-platform agents archive <agent-id> --yes
63
64
  nouter-platform environments list
64
65
  nouter-platform environments get <environment-id>
66
+ nouter-platform workspaces list
67
+ nouter-platform workspaces get <workspace-id>
68
+ nouter-platform workspaces archive <workspace-id> --yes
69
+ nouter-platform workspaces rate-limits <workspace-id>
70
+ nouter-platform workspaces rate-limits set <workspace-id> --model <model> --limiter <limiter> --value <n>
71
+ nouter-platform webhooks list
72
+ nouter-platform webhooks create --url <https-url> --event session.status_idled
73
+ nouter-platform webhooks get <webhook-id>
74
+ nouter-platform webhooks update <webhook-id> --status active
75
+ nouter-platform webhooks delete <webhook-id> --yes
76
+ nouter-platform webhooks deliveries <webhook-id>
77
+ nouter-platform webhooks regenerate-signing-secret <webhook-id> --yes
78
+ nouter-platform deployments list --agent <agent-id> --status active
79
+ nouter-platform deployments get <deployment-id>
80
+ nouter-platform deployments create -f deployment.yaml
81
+ nouter-platform deployments update <deployment-id> -f patch.yaml
82
+ nouter-platform deployments pause <deployment-id>
83
+ nouter-platform deployments unpause <deployment-id>
84
+ nouter-platform deployments archive <deployment-id> --yes
85
+ nouter-platform deployments run <deployment-id>
86
+ nouter-platform deployment-runs list --deployment <deployment-id>
87
+ nouter-platform deployment-runs get <run-id>
65
88
  nouter-platform apply -f ./resources --dry-run
66
89
  nouter-platform auth sessions list
67
90
  nouter-platform elevate
68
91
  nouter-platform logout
69
92
  ```
70
93
 
94
+ Every command has its own help: `nouter-platform usage --help` prints its
95
+ usage, its flags and its examples; `nouter-platform help usage` does the same.
96
+
71
97
  `login --api-key` is the non-interactive path for CI and for terminals without
72
98
  a browser. The key is read from stdin and never from `argv`.
73
99
 
@@ -123,14 +149,85 @@ The two commands report cost in different units, and neither one converts:
123
149
  `sessions` shows `usage.list_cost.amount` in cents (`"4"` is `$0.04`), and
124
150
  `usage` shows `cost_micros` in micro-USD (`"3402110"` is `$3.402110`).
125
151
 
152
+ ## Deployments
153
+
154
+ ```bash
155
+ nouter-platform deployments create -f deployment.yaml
156
+ nouter-platform deployments list --agent <agent-id> --status active
157
+ nouter-platform deployments get <deployment-id>
158
+ nouter-platform deployments pause <deployment-id>
159
+ nouter-platform deployments run <deployment-id>
160
+ nouter-platform deployment-runs list --errors
161
+ ```
162
+
163
+ A deployment pins an agent version to an environment and fires it on a
164
+ schedule, on demand or on an event; each firing is a **deployment run**.
165
+ `create` and `update` read one YAML or JSON file with `-f`, and the file is the
166
+ request body of the API, with no wrapper; the server validates the schema, so
167
+ an unknown field is a `400`. `update` takes a partial document and `null`
168
+ clears the optional fields. A `github_repository` resource needs its
169
+ `authorization_token` as `${VAR}`: the CLI reads the variable from the
170
+ environment before the request, rejects a literal without printing it and does
171
+ not call the API when the variable is missing.
172
+
173
+ `pause`/`unpause` are reversible and ask no confirmation; `archive` asks
174
+ `--yes`, cannot be undone and is an elevated route. `run` fires the deployment
175
+ now with an `Idempotency-Key`, and a run with an `error` does not start a
176
+ session: the CLI prints the reason and exits 1, also with `--json`.
177
+
178
+ The ten commands need a **workspace** credential (a CLI session or a workspace
179
+ key); an organization key gets a 403 `workspace_required`. Reads need
180
+ `deployments:read`, create/update/pause/unpause/run need `deployments:write`
181
+ and archive needs `deployments:admin`. `deployment-runs list` filters by
182
+ `--deployment`, `--agent`, `--trigger schedule|manual|event`, `--errors` and
183
+ `--since`/`--until`; both lists read every page and accept `--json`.
184
+
185
+ ## Workspaces
186
+
187
+ ```bash
188
+ nouter-platform workspaces list --include-archived --json
189
+ nouter-platform workspaces get default
190
+ nouter-platform workspaces archive wrkspc_123 --yes
191
+ nouter-platform workspaces rate-limits wrkspc_123 --include-inherited
192
+ nouter-platform workspaces rate-limits set wrkspc_123 --model claude-sonnet-5-5 --limiter requests_per_minute --value 500
193
+ nouter-platform workspaces rate-limits set wrkspc_123 --model claude-sonnet-5-5 --limiter requests_per_minute --clear
194
+ ```
195
+
196
+ `list` follows the cursor and prints every page; `--json` prints the whole array.
197
+ `get` takes the id or `default` for the default workspace of the organization.
198
+
199
+ The family needs an **Admin API key** of the organization: `org_workspaces:read`
200
+ to read and `org_workspaces:admin` to archive or set a limit. A CLI session, or
201
+ a workspace key, gets a 403 `organization_required`.
202
+
203
+ Archiving can't be undone, so it asks for `--yes`; there is no prompt, and the
204
+ default workspace can't be archived (409 `default_workspace_immutable`). The
205
+ rate limits are `min(organization, workspace)`: `--include-inherited` shows the
206
+ organization value and the source of each row, `--value` sets the workspace
207
+ override and `--clear` removes it so the organization value applies again.
208
+
209
+ ## Webhooks
210
+
211
+ `webhooks` manages the webhook endpoints of the organization. Every command needs an Admin API key with
212
+ `webhooks:admin`, the reads included; a CLI session (`nps_`) gets a `403 organization_required` before the handler.
213
+ `create` and `regenerate-signing-secret` print the signing secret once on stdout and the metadata on stderr, so it can
214
+ be redirected to a secret store. The previous secret stops working as soon as a rotation returns: there is no grace
215
+ period. `delete` is hard and stops the deliveries, and both it and the rotation ask for `--yes`.
216
+
217
+ `create` sends the event types it receives and does not validate them: the server answers `400
218
+ webhook_event_type_invalid` and the CLI reports the status and the stable code. `update` sends only the fields given;
219
+ `--event` replaces the set, and `--status` takes `active` or `disabled`. `deliveries` reads one page, 20 by default and
220
+ up to 100, prints the next command on stderr when there is a cursor, and the record lives seven days. `--json` prints
221
+ the raw response: the array for `list` and the envelope with `has_more` and `next_page` for `deliveries`.
222
+
126
223
  ## Apply
127
224
 
128
225
  `apply` reconciles agents and environments from YAML or JSON documents
129
- (`kind: agent` or `kind: environment`). A directory applies every `.yaml`,
130
- `.yml` and `.json` in name order, and repeating `-f` applies each file or
131
- directory in the order given. A directory with none of those extensions is an
132
- error, not a silent success. It matches by `name` inside the organization
133
- of the key and never deletes a resource the file does not name. Renaming a
226
+ (`kind: agent` or `kind: environment`), and publishes a skill from its
227
+ directory. A directory applies every `.yaml`, `.yml` and `.json` in name order,
228
+ and repeating `-f` applies each file or directory in the order given. A directory without `SKILL.md` and with none of
229
+ those extensions is an error, not a silent success. Agents and environments match by `name` inside the organization
230
+ of the key; a skill matches by `display_name`. It never deletes a resource the file does not name. Renaming a
134
231
  resource creates another one. Arrays such as `mcp_servers`, `tools` and
135
232
  `skills` are replaced whole, exactly like the API, and so are `model` and the
136
233
  `config` of an environment: what the file sends is the whole value, with the
@@ -151,6 +248,11 @@ Environments are applied before agents, and every document and variable is
151
248
  validated before the first write. A server failure stops there: the resources
152
249
  already applied keep their status, the rest are reported as `not applied`, and
153
250
  the command exits 1. Run it again to finish the job; it is idempotent by name.
251
+ Every failure that comes from the API starts with the HTTP status and the
252
+ stable `error_code`, never the response body, for agents, environments and
253
+ skills alike. A `validation_error` is caught before the request and carries no
254
+ status, and a skill 413 names the server's per-request limit with the request
255
+ id instead of leading with the number.
154
256
 
155
257
  Secrets do not belong in the files: `${NAME}` interpolation in
156
258
  `mcp_servers[].env` and `_oma.acp.agent.env` reads `NAME` from the process
@@ -162,7 +264,217 @@ change.
162
264
 
163
265
  `apply` needs the `agents:write` and `environments:write` scopes (the `ci` key
164
266
  preset). A document with `_oma.retention` also needs `agents:admin`, which only
165
- an `admin` or `owner` login has.
267
+ an `admin` or `owner` login has; a skill needs `skills:write`.
268
+
269
+ ### Skills
270
+
271
+ A directory with `SKILL.md` at its root is a skill, not a document: the
272
+ frontmatter carries its `name` (lowercase letters, digits and hyphens, up to 64
273
+ characters) and its `description`, and the supporting files go with their
274
+ relative paths, without a top-level folder.
275
+
276
+ ```bash
277
+ nouter-platform apply -f ./skills/summarize-reports --dry-run
278
+ nouter-platform apply -f ./skills/summarize-reports
279
+ ```
280
+
281
+ The CLI lists the `custom` skills of the organization, all pages, and matches
282
+ `display_name` against the frontmatter `name`. No match creates the skill and
283
+ prints `created skill "name"`; one match downloads its latest version and, if
284
+ the paths and bytes differ, creates a version and prints
285
+ `updated skill "name" (version <id>)`; equal files print `unchanged` with no
286
+ `POST`. More than one match is an error with the ids and no writes, because
287
+ `display_name` is not unique. A console skill whose `display_name` differs from
288
+ the frontmatter `name` is not recognized and gets a second skill.
289
+
290
+ A new version is a complete snapshot, not a delta. The exclusions are the
291
+ console's, with no opt-in: names and folders that usually hold secrets or tool
292
+ state, plus `.DS_Store` and symlinks, are skipped, and each skipped path and
293
+ its reason go to stderr. Exclusions run before the limits (500 files, 32 MB per
294
+ file and 100 MB in total), so a large `node_modules` does not fail the run. The
295
+ compiler's ceilings are not reachable over HTTP: each upload is one multipart
296
+ request and the edge accepts at most 25 MiB per request, so a bigger package
297
+ fails with a 413 `request_too_large`.
298
+ `--dry-run` prints the plan and sends only the reads. A failed skill prints the
299
+ HTTP status and the stable `error_code`, never the package body; a 413 says the
300
+ package exceeds the server's per-request limit, with the request id. `apply` has
301
+ no `--json`.
302
+
303
+ ## Evals
304
+
305
+ `eval` runs an eval suite against an agent and scores what the suite declares. Each case is a conversation with
306
+ one or more graders; a case passes when its mean reaches the threshold. A suite is a directory of files kept in
307
+ the repo:
308
+
309
+ ```text
310
+ evals/
311
+ ├── suite.yaml # optional: agent, environment, threshold, runs, timeout, budget
312
+ └── refund-policy/
313
+ ├── prompt.md # frontmatter + body: the user message
314
+ ├── case.yaml # optional: several turns, setup, canary or budget
315
+ └── graders/
316
+ └── mentions-30-days.md # frontmatter: type and options; body: the pattern or script
317
+ ```
318
+
319
+ A minimal case is two files: `prompt.md` with the message and a grader under `graders/`. `suite.yaml` can set
320
+ `agent` and `environment`; `--agent` and `--environment` override them.
321
+
322
+ ```yaml
323
+ # evals/suite.yaml
324
+ schema_version: "1"
325
+ name: support-agent
326
+ agent: agent_...
327
+ environment: env_...
328
+ threshold: 0.8
329
+ runs: 3
330
+ budget_per_case: "50"
331
+ vaults:
332
+ - vault_test
333
+ ```
334
+
335
+ ```markdown
336
+ <!-- evals/refund-policy/prompt.md -->
337
+ ---
338
+ tags: [smoke]
339
+ ---
340
+ Can I return an opened product?
341
+ ```
342
+
343
+ ```markdown
344
+ <!-- evals/refund-policy/graders/mentions-30-days.md -->
345
+ ---
346
+ type: regex
347
+ ---
348
+ 30 days
349
+ ```
350
+
351
+ ```bash
352
+ nouter-platform eval ./evals
353
+ nouter-platform eval ./evals --agent <agent-id> --environment <environment-id> --threshold 0.9 --runs 5
354
+ nouter-platform eval ./evals --case 'refund-*' --tag smoke --json > eval-results.json
355
+ nouter-platform eval ./evals --max-cost-usd 1.50
356
+ ```
357
+
358
+ | Flag | What it does |
359
+ | --- | --- |
360
+ | `--agent <agent-id>` | The agent to evaluate; required when `suite.yaml` does not set it. |
361
+ | `--environment <environment-id>` | The environment for the Sessions; required when `suite.yaml` does not set it. |
362
+ | `--threshold <0..1>` | The minimum for each case; defaults to 1. Overrides the manifest. |
363
+ | `--runs <1..20>` | The trials per case; defaults to 3. Overrides the manifest. |
364
+ | `--concurrency <1..32>` | The trials at a time; defaults to 4. Overrides the manifest. |
365
+ | `--case <glob>` | Filters by name, with `*` and `?`; may be repeated. |
366
+ | `--tag <tag>` | Filters by tag; may be repeated. |
367
+ | `--agent-version <n>` | Pins the expected version: if the agent is on another one, it fails before running anything. |
368
+ | `--wait-timeout <seconds>` | The cap for polling the run; defaults to 3600. |
369
+ | `--max-cost-usd <usd>` | The run's list-price ceiling, in dollars, at most six decimals; without it there is none. |
370
+ | `--vault <vault-id>` | Attaches that vault to every Session; repeatable. Overrides the suite `vaults:`. |
371
+ | `--keep` | Keeps the ephemeral benchmark and run and prints their ids, for debugging. |
372
+ | `--json` | Prints the versioned report on stdout, without the table. |
373
+
374
+ `[<dir>]` is the suite directory and defaults to `evals`. It must be relative and cannot contain `..`. The
375
+ `--case` and `--tag` filters apply before the run is created: a filter that leaves no cases is `NO_CASES`.
376
+
377
+ A vault is passed to each Session of a case, so a case can carry its own credential. `--vault <vault-id>` may be
378
+ repeated and replaces the `vaults:` of the suite and of the cases. Without the flag, `vaults:` in `suite.yaml` is
379
+ the default and a case can override it with `vaults:` in its `case.yaml`; `vaults: []` in a case means no vault for
380
+ that case. An empty list in `suite.yaml` is an error; each id is a non-empty string, and repeats are sent as given.
381
+ A vault id that does not exist or is archived fails the run with 404 `Vault <id> was not found` before any trial
382
+ starts. The runner only passes the ids: it never creates a vault, reads a credential or sees a secret. A suite with
383
+ `vaults:` also applies through `apply --require-eval`; the gate has no `--vault`.
384
+
385
+ If the agent policy has `requires_user_profile`, the platform gives each trial a synthetic profile
386
+ (`eval:<run>:<task>:<n>`) and archives it when the run closes; the suite does not set a user profile.
387
+
388
+ ### CI use
389
+
390
+ The command exits 0 only when every case reached the threshold and none ended with an error. In CI the exit code
391
+ is the gate, and the JSON is archived; a partial run from `--max-cost-usd` is a 2 that the job can treat as a
392
+ failure or archive:
393
+
394
+ ```bash
395
+ nouter-platform eval ./evals --json > eval-results.json
396
+ ```
397
+
398
+ ```yaml
399
+ # GitHub Actions: the step fails only on a non-zero exit code
400
+ - run: nouter-platform eval ./evals --json > eval-results.json
401
+ ```
402
+
403
+ | Code | When |
404
+ | --- | --- |
405
+ | 0 | Every case scored at or above the threshold, with no errors. |
406
+ | 1 | A case below the threshold or with an error, the suite did not load, the run failed, or the API failed. |
407
+ | 2 | Partial run: `--max-cost-usd` stopped trials before they started; the results are partial. |
408
+ | 64 | Invalid command usage: an unknown flag, an out-of-range value, or an absolute directory or one with `..`. |
409
+ | 130 | Interrupted with SIGINT (Ctrl-C) or SIGTERM. |
410
+
411
+ It also exits 1 when the agent version changed during the run: the report is not comparable. A run that does not
412
+ finish within `--wait-timeout` exits 1 too.
413
+
414
+ A code 2 wins over 0 and 1, but it does not mean the run passed: the trials that started are still scored and can
415
+ be below the threshold or in error. The report is written anyway and says why it is partial. `cost_ceiling` means
416
+ the ceiling stopped trials; `cost_unavailable` means the list cost could not be read and the run stopped starting
417
+ new trials to avoid spending blind. The JSON document carries `partial` and `partialReason`, and its `run` carries
418
+ `maxCostUsd` and `listCostCents`. The report (`--json` or the table) goes only to stdout; errors go only to stderr,
419
+ with the `{ "error": { "code": "..." } }` envelope. As soon as the run exists its id is printed
420
+ (`run <id> created; <n> cases`): on stdout without `--json`, and on stderr with `--json`, so stdout keeps a single
421
+ JSON document. With `--json`, stderr is therefore not pure JSON: the run id line comes before any error envelope.
422
+ If the process is interrupted it prints `interrupted; run <id> keeps running on the platform` on stderr and exits
423
+ 130 with no JSON: the run is not cancelled.
424
+
425
+ ### Cost
426
+
427
+ Each run pays for `cases × runs` managed Sessions plus sandbox. The CLI prints that number and the concurrency
428
+ before creating the run; when every selected case has a budget it also prints their sum (`Σ budget × runs`), the
429
+ hard cap that already existed per case. `--runs 1` is for iterating; use 3 to trust a change.
430
+
431
+ `--max-cost-usd <usd>` caps the run's list-price cost estimate, not the bill: the ceiling is checked before each
432
+ trial starts, and once the known cost reaches it no further trial starts; trials already in flight finish, so the
433
+ spend can pass the ceiling by what they use. The known cost is the sum of the Sessions' `usage.list_cost`, a floor
434
+ of the bill; session hours and the sandbox are outside it, and the organization spend caps remain the overall
435
+ ceiling. Without the flag there is no ceiling, like the reference CLI. The run closes `completed` with `partial:
436
+ true` and `partialReason`; the CLI exits 2 with the partial results and prints the closing line
437
+ `partial: the cost ceiling stopped <n> trials; list cost $<x>`. There is no confirmation prompt: the printed plan,
438
+ the budget cap and the ceiling are what you review, and CI passes the flag explicitly. The case `budget` (`budget`
439
+ in `case.yaml` or `budget_per_case` in `suite.yaml`), in cents, stays the per-conversation cap. If the server does
440
+ not confirm the ceiling it was sent, the CLI cancels the run, deletes the ephemeral resources and exits 1: it never
441
+ shows a ceiling that the server did not apply.
442
+
443
+ `apply --require-eval <suite>` pays for a full suite before applying and is opt-in: without the flag, `apply`
444
+ spends no model. The gate has no `--json`; it prints the human report and, if the run does not pass, writes
445
+ nothing and exits 1. Every `env` value of the document must come from `${VAR}`: a `"***"`, which `apply` accepts
446
+ to keep the stored secret, fails with this message and writes nothing:
447
+
448
+ ```text
449
+ --require-eval needs every env value via ${VAR}; nothing was written
450
+ ```
451
+
452
+ ### Security
453
+
454
+ Cases are repo files and get committed: they carry no secrets. The CLI does not interpolate `${VAR}` in the
455
+ suite, so a `${VAR}` in a case stays literal; there is no `.env` in messages, `setup_script` or `setup_files`. The
456
+ report carries ids, numbers, case and grader names and the server error, never the content of the cases or the
457
+ API key. Parse errors show path, line and column, not the text of the line.
458
+
459
+ The agent runs in a managed Session with the requested environment. `setup_script` and the `script` grader run in
460
+ the sandbox of that Session, not on the machine that launches the command; the network depends on what the
461
+ environment allows, and their stdout/stderr is not printed: only the verdict and the exit code. The Session does
462
+ not mount the repo.
463
+
464
+ A vault credential of type `environment_variable` is exposed to the agent as an environment variable. If the agent
465
+ prints it, the value stays in the Session trajectory and can appear in the eval report: prefer `static_bearer` or
466
+ `mcp_oauth` credentials for the vaults an eval uses.
467
+
468
+ The `apply --require-eval` candidate is a real agent of the organization and runs with the real environment and
469
+ MCP credentials of the document. A suite can have side effects (writing files, calling APIs): design the cases
470
+ with that in mind.
471
+
472
+ On SIGINT (Ctrl-C) or SIGTERM during a gate run, the CLI stops waiting for the run, archives the candidate agents that
473
+ run created (and waits for an archive already in progress), with a 10-second limit in total, and exits 130 without
474
+ applying anything, even if the run had just passed; a second signal exits at once. Whatever it could not archive is
475
+ listed on stderr (`warning: could not archive these eval agents: ...`). Find leftover agents named `*-eval-*` with
476
+ `nouter-platform agents list --json` and archive them with `nouter-platform agents archive <id> --yes`, which needs
477
+ `agents:admin` or an elevated session.
166
478
 
167
479
  ## Feedback
168
480