benignswarm 0.12.97 → 0.12.99

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/dist/help.js CHANGED
@@ -21,24 +21,27 @@ GET /account/usage reports used and allowed micro-dollars, uncertain calls and t
21
21
  Session/admin clients can use GET /assistant/conversations, GET /assistant/conversations/:id/messages (paged history with saved tool notices), POST /assistant/conversations/:id/messages (SSE), and DELETE /assistant/conversations/:id. Old assistant messages report notices_available=false. The assistant can draft changes; POST /assistant/proposals/:id/apply or /discard is the operator's explicit action. See the agent/operator skill API reference for events and tools.
22
22
  Free and paid accounts without a live Stripe subscription use the UTC calendar month; subscribed paid accounts reset at current_period_end.
23
23
 
24
- Mac capacity/signing API records (profiles, lease requests, capability snapshots, signer-only references and TestFlight requests) are documented in docs/MACOS-MACHINES-API.md. This API contract does not provision a host or sign/upload; operator controls are the named Mac fleet and signing console unit.
24
+ Mac capacity/signing API (profiles, leases, signer-only references, TestFlight approvals, and the isolated signer job contract) is documented in docs/MACOS-MACHINES-API.md. There is no CLI command to issue signer-host credentials or trigger release; operator controls are WU #286, real host/provider integration is WU #288.
25
25
 
26
- GitHub connection and repository status are available in the console and through b9s-admin github status and b9s-admin project github <project> status|unlink. A repository link enables agent credentials without requiring a ruleset. Verify an exact target ruleset in Account -> GitHub connection before enabling hosted merge; the CLI cannot perform this owner OAuth step. Disconnect an installation with b9s-admin github disconnect <installation-id>. Hosted merge execution and status use b9s wu merge <n> and b9s wu merge status <n>; they call POST/GET /projects/:p/work-units/:n/merge and never inspect local Git state. API role checks use merge.merged_by and operator override; operator_hold is checked, merges serialize in MergeTargetDO, and retries reconcile idempotently. Manual wu done remains disabled for enabled linked targets. Enable with b9s-admin project hosted-merge <project> enable --confirm-bypass-signal only after ruleset verification and the live GitHub bypass-change check; disable with b9s-admin project hosted-merge <project> disable. The console control is WU #196. App setup steps are in packages/skill-admin/references/setup.md.
26
+ GitHub connection and repository status are available in the console and through b9s-admin github status and b9s-admin project github <project> status|unlink. A repository link enables agent credentials without requiring a ruleset. An agent can inspect its effective repository permission with GET /projects/:p/git-credentials; a project admin can inspect a named agent with GET /projects/:p/git-credentials?agent=<name-or-id>. Each issuance records its permission reason without storing the token. Verify an exact target ruleset in Account -> GitHub connection before enabling hosted merge; the CLI cannot perform this owner OAuth step. Disconnect an installation with b9s-admin github disconnect <installation-id>. Hosted merge execution and status use b9s wu merge <n> and b9s wu merge status <n>; they call POST/GET /projects/:p/work-units/:n/merge and never inspect local Git state. API role checks use merge.merged_by and operator override; operator_hold is checked, merges serialize in MergeTargetDO, and retries reconcile idempotently. Manual wu done remains disabled for enabled linked targets. Enable with b9s-admin project hosted-merge <project> enable --confirm-bypass-signal only after ruleset verification and the live GitHub bypass-change check; disable with b9s-admin project hosted-merge <project> disable. The console control is WU #196. App setup steps are in packages/skill-admin/references/setup.md.
27
27
 
28
28
  Environment problems: agents report bounded, redacted observations with b9s environment report; reports use scoped project or machine access, account-scoped evidence, and only the agent's own blocked units. Agents can append observations but cannot claim, diagnose, or resolve issues. Operators and agents whose role has own_environment_problems can manage visible issues. Operators use Account → Environment in the console to filter and inspect issues, claim/assign/reassign, record diagnoses, and resolve with a note and verification. Manual diagnoses use source agent; doctor/daemon provenance is for actual check results. Banner links open the same issue detail with impact context. Issue detail links active notices in the same scope and current machine-session faults related to its machine or explicitly linked unit owner. The read-only steward summary lists active linked issues and currently waiting linked units, without publishing notices or creating work. Machine issue views respect linked-project access. Spending impact is unknown and creates no banner until unit-attributed telemetry lands in WU #236; see packages/skill/references/api.md.
29
29
 
30
30
  Work-unit open, start, submit and close endpoints accept context fill and compaction metadata on lifecycle events. Report explicit unknown reasons when unavailable; never send prompt or response text as context. Context aggregation is grouped by the event owner and its stamped model/effort. Context policies (keep | compact | clear | agent-decides) resolve unit > role > project > system default keep, freeze on assignment/open, audit settings and action-metadata decisions via GET/PUT /projects/:p/context-policy, POST /projects/:p/work-units/:n/context-policy, and POST /projects/:p/work-units/:n/context-policy/decision, and fail closed until an assigner or operator updates a blocked unit. See packages/skill/references/api.md for field validation and response shapes.
31
+ GET /projects/:p/context-policy/comparison reports descriptive project-scoped policy aggregates by build/review mode, tag, and exact event-stamped class. Reviewer event counts are separate from replay-cluster uncertainty; turn token usage stays unknown. Clear-cohort units need their own server-verified clear event and a later start by the same actor. Results are not causal or paired; the console view is WU #299.
32
+ Build dispatch checks role qualifications, capabilities, holds, reservations and operator-only required_class first, then ranks eligible workers by routing_policy weights, build quality guardrail, weakest-tag tie-break and build exploration budget, falling back when the preferred class is busy and recording route_decision / dispatch_reasons on units and events. Operators set/clear hard required_class with an audited reason via POST /projects/:p/work-units/:n/required-class (or tag definitions) and inspect cleared legacy min_tier rows via GET /projects/:p/routing/tier-migration (never guessing class mappings). Console routing controls are WU #244; CLI routing view/controls are WU #242.
33
+ Review routing ranks only independent qualified reviewers (excluding owner, prior builders, same-worktree occupants, and forbidden_dependent_roles), preserves trial/expert/mandatory_reviewer blockers, supports paired comparisons and head-to-head verdicts (POST /projects/:p/work-units/:n/compare, closing non-selected units as compared), and exposes GET /projects/:p/review-routing. Console routing controls are WU #244; CLI routing view/controls are WU #242. See packages/skill/references/api.md for field validation and response shapes.
31
34
 
32
35
  Agent commands
33
36
  b9s login --as <name> --key <bs_agent_...> [--url <api>] [--label <machine-label>]
34
37
  b9s logout --as <name>
35
38
  b9s identities list saved identities on this machine
36
- b9s me who am I, role, permissions, channels
39
+ b9s me who am I, role, permissions, channels; --json includes your machine sessions
37
40
  b9s git-credential get|store|erase Git credential helper for the project's linked GitHub repository
38
41
  b9s resume compact recovery brief: units, reviews, asks, slices, decisions, outcomes, process and notices
39
42
  b9s notice add --project <p> "<text>" [--until <time>] [--command-pattern <regex>]
40
43
  assigner only: add a project notice; matching commands warn but continue
41
- b9s who [--account] what every agent is doing (--account: all projects); benched agents get their own line, usage-limited agents show the harness reset time
44
+ b9s who [--account] agent status (--account: all projects); shows pressure for active machine sessions
42
45
  b9s status set [--state s] [--goal g] [--task t] [--blocked-on b] [--tags a,b] [--custom '{json}']
43
46
  [--checks-every <min>|none] not always on but checking on a schedule: say how often
44
47
  b9s status history <agent> [--limit n]
@@ -80,11 +83,18 @@ Agent commands
80
83
  target as of the original); a worktree left half-written by an interrupted
81
84
  checkout is removed and made again; wu open does the same for your own units;
82
85
  --branch continues existing work (never a SHA); always fetches and branches from origin/<target>; --here uses this checkout
86
+ context policy is resolved before worktree creation: keep is recorded automatically;
87
+ compact requires a completed interactive /compact confirmation; clear requires a saved checkpoint,
88
+ a different thread, and a matching locally recorded current-thread id; /me.machine_sessions identifies placement:
89
+ managed sessions update their remembered thread atomically on start; an empty list confirms unmanaged; unknown is refused;
90
+ Codex clear also remains unsupported until an affirmative foreground-mode marker is verified;
91
+ clear also needs --context-checkpoint-ref, --context-old-thread, and --context-new-thread; unsupported work never starts
83
92
  lifecycle events include context-fill metadata and compaction deltas: Claude Code reads assistant usage
84
93
  and compact markers, Codex reads token_count and compaction events; Antigravity needs a confirmed window;
85
94
  unsupported or unavailable measurements include a reason; compaction intervals include the start and exclude the end
86
95
  b9s record per agent/tag; --json also includes project cause/evidence aggregates, cohorts, and role-scoped attribution
87
96
  b9s record --by model same counters keyed by model and effort; JSON includes attempt/review outcomes, recorded wait timing, cause aggregates by stamped model/effort, and usage availability
97
+ b9s record --by matrix [--mode build|review] [--tag <tag>] class x tag confidence matrix, policy weights and exploration budget state
88
98
  b9s milestones the plan's slices: ready or waiting on which, units done/total; wu open|assign --milestone <key>
89
99
  b9s milestones set --file plan.json define or replace the plan (assigner roles or the operator): a JSON list of
90
100
  {key, title, exit, depends_on, default_tags}; existing keys keep their status; cycles are refused
@@ -104,6 +114,7 @@ Agent commands
104
114
  b9s unlock <name> [--machine <label>|--shared] [--remove-empty] | b9s locks
105
115
  release it (also released when your unit closes); assigners/operators can remove an empty scoped lock with --remove-empty
106
116
  lock names acquire/list/release/show/status are reserved: use lock <name>, locks, or unlock <name> as suggested
117
+ project locks are separate from account-wide weighted machine-job permits; a lock never grants permit capacity
107
118
  b9s measures latest measure values, freshness and merges since each value
108
119
  b9s measure show <name> definition history, values and runner requests
109
120
  b9s measure run <name> --sha <commit> [--target branch] [--rerun] request a bounded runner unit
@@ -152,11 +163,11 @@ Agent commands
152
163
  b9s wu done <n> --merged <sha> | --no-source --evidence id[,id...] [--keep-worktree] after approval; no-source closes an evidence-only unit without a merge SHA and checks its branch has no commits beyond the target
153
164
  b9s wu merge <n> [--note "..."] role-checked hosted merge through the API; never inspects local Git credentials or state
154
165
  b9s wu merge status <n> operation status and non-secret audit trail for a hosted merge
155
- b9s wu show <n> [--scope-only] show the full unit or only its scope for scripts
166
+ b9s wu show <n> [--scope-only] show the full unit (including route/review explanation when recorded) or only its scope for scripts
156
167
  b9s wu recovery save <n> --reason "..." save a WIP branch commit and encrypted cutoff bundle; keep the source volume until safe_to_delete
157
168
  b9s wu recovery restore <n> next owner: verify and restore the restricted recovery bundle into the unit worktree
158
169
  b9s wu abandon <n> [--note ..] wu list [--all] for state and timeline
159
- b9s worktrees prune [--yes] [--archive] remove clean worktrees whose work landed or whose unit is closed (dry run without --yes);
170
+ b9s worktrees prune [--yes] [--archive] remove clean, fully pushed worktrees whose work landed or whose unit is closed (dry run without --yes);
160
171
  --archive also saves a closed unit's uncommitted files to archive/wu<n>-leftovers and removes it
161
172
  b9s worktrees [scan] the project's worktree registry (machine, path, branch, dirty, merged, who);
162
173
  scan reports every linked worktree of the repo you are in (watchers do this hourly)
@@ -171,9 +182,13 @@ Agent commands
171
182
  followed-channel chatter waits --follow-delay 300 s and collapses; digest never wakes.
172
183
  --env A,B copies those variables from this shell into the LaunchAgent (Antigravity needs
173
184
  ANTIGRAVITY_LS_ADDRESS,ANTIGRAVITY_CSRF_TOKEN). --full queues the text itself. --once /
185
+ Set BSCHAT_WATCH_DEBUG=1 for per-poll item counts, tier and wake decisions.
174
186
  --service (launchd on macOS, systemd on Linux; --launchd is the same). --turn runs each turn
175
- itself (--harness codex|claude-code|dsh|antigravity --session <id>); 3 consecutive turns without an
176
- agent-key call faults it; six unproductive turns in a rolling hour also fault. The 60-turn
187
+ itself (--harness codex|claude-code|dsh|antigravity --session <id> [--machine-session-id uuid]); without activated judgment capture,
188
+ 3 consecutive turns without an agent-key call fault it and six unproductive turns in a rolling hour also fault.
189
+ With judgment capture activated, these become triggers and the watcher pauses before the next turn;
190
+ hard-budget caps still reserve each launch independently. Capture defaults off; hard caps alone do not activate it.
191
+ The 60-turn
177
192
  hourly cap pauses a busy agent until a turn rolls out, then resumes automatically. Set
178
193
  --turns-per-hour 1..60, --unproductive-per-hour 1..60, and --turn-coalesce-seconds 0..3600;
179
194
  direct wake-ups coalesce for 180s by default; 0 disables it. Operators and urgent-marked items
@@ -190,18 +205,24 @@ Agent commands
190
205
  b9s environment report --project <p> | --machine <m> --title <text> --category <name> --component <name> --description <what failed> [--normalized-key <key>] [--evidence <id,...>] [--units <id,...>]
191
206
  submit a bounded observation; evidence is account-scoped, and agents may link only their own units
192
207
  b9s codex hooks | bind <thread-id> | sync install b9s's Codex hooks (~/.codex/hooks.json) and say which thread is you
193
- b9s start --harness codex|claude-code|dsh|antigravity --as <project>/<name> --sandbox <mode> [--provider anthropic|deepseek] [--token t] [--thread id] [--model m] [--effort e] [--writable-root path]... [--max-budget-usd n] [--turns-per-hour 1..60] [--unproductive-per-hour 1..60] [--turn-coalesce-seconds 0..3600] [--dsh path] [--agy path]
208
+ b9s start --harness codex|claude-code|dsh|antigravity --as <project>/<name> --sandbox <mode> [--provider anthropic|deepseek] [--token t] [--thread id] [--model m] [--effort e] [--writable-root path]... [--max-budget-usd n] [--turns-per-hour 1..60] [--unproductive-per-hour 1..60] [--turn-coalesce-seconds 0..3600] [--machine-session-id uuid] [--dsh path] [--agy path]
194
209
  run an agent headless: enroll, start or adopt its session, turn-mode watcher
210
+ --machine-session-id is normally supplied by b9s-admin for a managed machine session
195
211
  Claude Code workspace-write defaults to a $1 per-turn cap; configure it with --max-budget-usd
196
212
  Account turn-spend caps are set by the account operator separately; token caps support subscriptions,
197
- missing usage remains reserved, and judged turn mode stays off until session-hour and account-day caps are set.
213
+ missing usage remains reserved. Judgment capture has a separate default-off activation in console WU #238.
198
214
  Admin-only account reads: GET /account/turn-spend/reservations and
199
215
  GET /account/turn-spend/sessions/:session/reservations list unresolved reservations;
200
216
  GET /account/turn-budget/audit lists policy changes. All three are paged and account-scoped.
201
217
  (b9s codex start is the same with --harness codex)
202
218
  b9s unpause [--as <a>] lift a usage-limit pause now (the harness was switched to an account with quota)
219
+ b9s turn note "<short progress summary>" [--as <a>] save a 300-character turn-end excerpt for an enabled managed session; it is labelled unverified
203
220
  b9s machine bootstrap --url <api> [--retrieve-ec2 | --token-file <path> | --token <bs_boot_...>] [--name <m>] retrieve (over TLS+IMDSv2/STS) and exchange a single-use cloud bootstrap token once, scrub it, and write mode-0600 credentials
204
- b9s machine run [--interval seconds] | once | build-images | status | prepare | service default 30s, 1..3600; prepare checks dsh availability/version (Linux has no DSH build)
221
+ b9s machine run [--interval seconds] | once | build-images | status | prepare | service
222
+ default interval 30s, 1..3600; prepare checks dsh availability/version (Linux has no DSH build)
223
+ b9s machine processes --worktree <path> [--as <project>/<agent>] [--json] read-only host process sample for a project-owned worktree
224
+ includes pid/parent, start/elapsed, command (120 chars), cwd, TCP listeners and sample time
225
+ project agents only; stale samples are labelled; command credentials are redacted; no environment values or signaling
205
226
  b9s checkpoint "<title>" --body "..." a resume note without retiring: what you are doing, open threads, next steps;
206
227
  your next session (after a move to another machine) reads it first
207
228
  b9s antigravity bind <conversation-id> | sync which Antigravity conversation is you, for its hook (watchers bind theirs)
@@ -261,6 +282,8 @@ b9s-admin login (approve it in your signed-in browser); the session lasts 30 day
261
282
  b9s-admin project github <project> status | unlink
262
283
  b9s-admin project hosted-merge <project> enable|disable [--confirm-bypass-signal]
263
284
  enable only after exact ruleset verification in console and live bypass-change signal check; controls are also in console WU #196
285
+ b9s-admin project secrets <project> list | show <name> | create <name> --purpose <text> --storage-mode hosted|aws_secrets_manager --units 1,2 --tags api --hosts host[,host] [--arn <exact ARN> --version-id <id>] | update <name> [--purpose <text>] [--units 1,2] [--tags api] [--hosts host[,host]] | rotate <name> --arn <exact ARN> --version-id <id> | revoke <name> | delete <name> | set <name> [--stdin]
286
+ purpose is trimmed before send (1–200 characters); values remain unavailable until encrypted storage lands in WU #231; set checks before reading input; console control is WU #230
264
287
  b9s-admin project environment show <project> | setup <project> [--catalog family@version] [--assessment-only] [--context text] | set <project> --file declaration.json --source-commit <merged-sha>
265
288
  setup queues one reviewed work unit; set records its merged declaration; catalog versions are x.y.z
266
289
  b9s-admin environment settings show | settings set [--stage disabled|report_only|staged|enabled] [--projects a,b] [--machines m1,m2] [--resolved-retention-days n] [--wont-fix-retention-days n] [--alerts on|off] [--alert-cooldown-minutes n]
@@ -293,6 +316,14 @@ b9s-admin login (approve it in your signed-in browser); the session lasts 30 day
293
316
  b9s-admin role edit <name> [--project p] [--projects a,b|*] [--post c1,c2] [--broadcast] [--create-channels] [--read-account-status] [--assign-outside-qualifications yes|no] [--description d] [--cardinality one|many]
294
317
  b9s-admin role list [--project p]
295
318
  b9s-admin wu assign <project> <n> --to <agent> [--reason "why"] operator: reassign a unit in place
319
+ b9s-admin wu required-class <project> <n> (--class <p/h/m/e> | --clear) --reason "why" set or clear an operator hard routing-class lock
320
+ b9s-admin routing show <project> [--mode build|review] [--tag <tag>] inspect confidence matrix, exploration spend, and recent decisions
321
+ b9s-admin routing policy <project> [--weights q,t,c] [--quality-target <0..100|none>] [--half-life <days>] [--min-samples <n>] [--build-explore <0..20>] [--review-explore <0..20>] [--pause-build yes|no] [--pause-review yes|no] [--reason "why"]
322
+ b9s-admin routing explain <project> <n> explain a unit's required_class, build route_decision, review_route, and dispatch candidates
323
+ b9s-admin routing required-class <project> <n> (--class <p/h/m/e> | --clear) --reason "why"
324
+ b9s-admin routing tag-required-class <project> <tag> (--class <p/h/m/e> | --clear) --reason "why"
325
+ b9s-admin routing tier-migration <project> inspect cleared legacy min_tier units requiring operator required_class review
326
+ b9s-admin routing pool-suggestions <project> [--status pending|accepted|rejected|superseded|all]
296
327
  b9s-admin role delete <name> [--project p]
297
328
  b9s-admin channel create|delete <project> <name>
298
329
  b9s-admin keys [create | revoke <id>] list admin and agent keys; create shows a new admin key once
@@ -326,6 +357,7 @@ b9s-admin login (approve it in your signed-in browser); the session lasts 30 day
326
357
  b9s-admin worktree forget <project> <id> delete a stale worktree record (never the directory)
327
358
 
328
359
  Machines (provisioned over your own ssh; a daemon on each runs the agent sessions you declare)
360
+ Account Mac leases and trusted TestFlight signing approvals are managed in Console → Machines → Mac fleet and signing; there is no CLI signing or App Store release command.
329
361
  b9s-admin machine add <name> --ssh <host> [--rotate] [--codex-userns] [--bwrap-userns] install Node and b9s (no sudo), linger, harness login checks,
330
362
  on macOS also check selected Xcode/license/SDKs, actual simulator runtimes, and disk;
331
363
  b9s's Codex hooks in /etc/codex (passwordless sudo only), register, start the daemon;
@@ -340,6 +372,8 @@ Machines (provisioned over your own ssh; a daemon on each runs the agent session
340
372
  15 min before, its agents away until the machine reports back after booting
341
373
  b9s-admin machine resize <name> --type <t> [--instance-id <id>] [--drain-timeout 5m] [--yes] [--on-running-turn wait|proceed|abort] [--extend 5m] [--ssh <host>]
342
374
  preflight (AZ offering, arch, ENA/NVMe + root UUID/PARTUUID, quota, hourly/daily cap delta), drain with deadline, stop/modify/start via AWS role, verify cores/RAM + resumed session threads, update BYO SSH config without opening SSH, and audit every step
375
+ b9s-admin machine quarantine <name> --reason <text> [--evidence <json>] | unquarantine <name> [--reason <text>]
376
+ exclude a host from scheduler/pool placement and preserve containment across scale-down; only unquarantine clears it
343
377
  b9s-admin machine session add <machine> <project>/<agent> --dir <checkout> --sandbox <read-only|workspace-write|danger-full-access> [--harness codex|claude-code|dsh|antigravity] [--provider anthropic|deepseek]
344
378
  [--create --role <role>] [--model m] [--effort e] [--thread <id>] [--turn-timeout min] [--turns-per-hour 1..60] [--unproductive-per-hour 1..60] [--turn-coalesce-seconds 0..3600]
345
379
  b9s-admin machine session thread <machine> <project>/<agent> <thread-id|none> set or clear the thread a pool session adopts
@@ -356,8 +390,8 @@ Machines (provisioned over your own ssh; a daemon on each runs the agent session
356
390
  b9s-admin machine workdir <name> <path | default> where its daemon clones projects for pool sessions (default ~/bschat)
357
391
  b9s-admin machine cache-budget <name> [<GB> | default] [--floor <pct | default>] per-cache budget (default 40 GB) and volume free-space floor (default 15%)
358
392
  b9s-admin machine caches <name> <path...> | none [--tool auto|cargo|generic] [--processes cmd,...] declared build-cache directories managed by the daemon
359
- b9s-admin machine readiness <name> [--project <p>] git identity, nested sandbox, IMDS block, harness logins/secrets, and image probe readiness (console in WU #200)
360
- b9s-admin machine login <name> --harness codex|claude-code|antigravity [--provider default|openai|anthropic|deepseek] | status <name> | cancel <name> <id> one-time device-code login handled via /account/needs (console in WU #200)
393
+ b9s-admin machine readiness <name> [--project <p>] git identity, nested sandbox, IMDS block, harness logins/secrets, and image probe readiness (console in WU #379; image build/pins in WU #377)
394
+ b9s-admin machine login <name> --harness codex|claude-code|antigravity [--provider default|openai|anthropic|deepseek] | status <name> | cancel <name> <id> one-time device-code login handled via /account/needs (console in WU #379)
361
395
 
362
396
  BYO AWS cloud machines (the connection is account-scoped; AWS bills the account directly; console controls in WU #200)
363
397
  b9s-admin cloud connect --file connection.json connect an IAM role, show its external ID once, and print the reviewed trust/permissions policies
@@ -366,9 +400,11 @@ BYO AWS cloud machines (the connection is account-scoped; AWS bills the account
366
400
  b9s-admin cloud secret set --harness <h> --arn <arn> [--provider p] [--project p] [--region r] [--name n] | list [--project p] | remove <id> store AWS Secrets Manager ARN refs for JIT host delivery (never secrets)
367
401
  b9s-admin cloud launch --machine <id> --idempotency-key <key> [--project <p>] [--recipe-version v] [--node-version v] [--node-sha256 hex] [--b9s-version v] [--base-image ref] request one capped instance and mint one single-use bootstrap token once
368
402
  b9s-admin cloud operations | inspect <operation-id> | terminate <operation-id> --reason <why> terminate refuses unless signed ownership proof and immutable tags verify
369
- Cloud audit history and recovery-hold resolution are available in the signed-in operator console; the account provisioning switch blocks launches while allowing safe drain and termination.
403
+ b9s-admin cloud capacity | regions set <r[,r...]> --reason <why> | regions clear [--reason <why>] | hosted-provisioning enable|disable --reason <why> | spend-signal <0..200|clear> [--source aws_budget|cost_explorer|billing_alarm|operator] [--detail <text>]
404
+ inspect effective BYO limits/spend/active builds, manage approved regions, toggle hosted kill switch, and record budget/cost signals
405
+ Cloud audit history and recovery-hold resolution are available in the signed-in operator console (WU #200, WU #309); the account provisioning switch blocks launches while allowing safe drain and termination.
370
406
 
371
- Project devcontainer images & immutable registry builds (console controls in WU #200)
407
+ Project devcontainer images & immutable registry builds (console controls in WU #377)
372
408
  b9s-admin project image validate --file <.devcontainer/devcontainer.json> [--dockerfile Dockerfile] [--arch linux/amd64|linux/arm64] validate @sha256 pins and reject secrets/host mounts/--privileged
373
409
  b9s-admin project image config <project> [--path <path>] [--arch linux/amd64|linux/arm64] [--cache name,...] configure immutable per-account image registry & build cache allowlist
374
410
  b9s-admin project image show <project> active digest, rollback target, latest build, and image capability probes
@@ -382,5 +418,8 @@ Pools (a role, variants and a count; the server names the agents and places them
382
418
  --count <n> --sandbox <mode> [--needs label,label] [--min-ram GB] [--turn-timeout min] [--turns-per-hour 1..60] [--unproductive-per-hour 1..60]
383
419
  slots are agents named <name>-<tag>-<n>; fewer retires the extra ones
384
420
  b9s-admin pool list [project] | show <project>/<name> | remove <project>/<name>
421
+ b9s-admin pool suggestions <project> [--status pending|accepted|rejected|superseded|all] inspect explicit non-mutating pool-weight suggestions
422
+ b9s-admin pool suggestion accept <project> <id> [--note "..."] apply a pending pool-weight suggestion and audit it
423
+ b9s-admin pool suggestion reject <project> <id> [--reason "..."] reject a pool-weight suggestion with an audit note
385
424
  b9s-admin delete-account --confirm "delete everything"
386
425
  `;
package/dist/index.js CHANGED
@@ -10,6 +10,7 @@ import { watch } from "./commands/watch.js";
10
10
  import { feedback } from "./commands/feedback.js";
11
11
  import { goal } from "./commands/goal.js";
12
12
  import { wake } from "./commands/wake.js";
13
+ import { turn } from "./commands/turn.js";
13
14
  import { antigravity } from "./commands/antigravity.js";
14
15
  import { codex, unpause } from "./commands/codex.js";
15
16
  import { harnessStart } from "./commands/codex-start.js";
@@ -72,6 +73,7 @@ const COMMANDS = {
72
73
  feedback,
73
74
  goal,
74
75
  wake,
76
+ turn,
75
77
  antigravity,
76
78
  codex,
77
79
  start: async (p, out) => {
package/dist/install.js CHANGED
@@ -274,13 +274,32 @@ export const systemdUserDir = () => join(process.env.XDG_CONFIG_HOME ?? join(hom
274
274
  /** Every watcher service on this machine. */
275
275
  export function watcherServices() {
276
276
  if (process.platform === "darwin")
277
- return watcherPlists().map((w) => ({ kind: "launchd", ...w, args: plistArgs(w.path) }));
277
+ return watcherPlists().map((w) => ({ kind: "launchd", ...w, args: plistArgs(w.path), cwd: plistWorkingDirectory(w.path) }));
278
278
  const dir = systemdUserDir();
279
279
  if (process.platform !== "linux" || !existsSync(dir))
280
280
  return [];
281
281
  return readdirSync(dir)
282
282
  .filter((f) => f.endsWith(".service") && isOurService(f.slice(0, -".service".length)))
283
- .map((f) => ({ kind: "systemd", label: f.slice(0, -".service".length), path: join(dir, f), args: unitArgs(readFileSync(join(dir, f), "utf8")) }));
283
+ .map((f) => {
284
+ const path = join(dir, f);
285
+ const text = readFileSync(path, "utf8");
286
+ return { kind: "systemd", label: f.slice(0, -".service".length), path, args: unitArgs(text), cwd: unitWorkingDirectory(text) };
287
+ });
288
+ }
289
+ function plistWorkingDirectory(path) {
290
+ const r = spawnSync("plutil", ["-convert", "json", "-o", "-", path], { encoding: "utf8" });
291
+ if (r.status !== 0)
292
+ return null;
293
+ try {
294
+ const cwd = JSON.parse(r.stdout).WorkingDirectory;
295
+ return typeof cwd === "string" ? cwd : null;
296
+ }
297
+ catch {
298
+ return null;
299
+ }
300
+ }
301
+ export function unitWorkingDirectory(text) {
302
+ return /^WorkingDirectory=(.+)$/m.exec(text)?.[1] ?? null;
284
303
  }
285
304
  /** Read the recorded working directory for a watcher; pruning must fail closed on an unreadable service. */
286
305
  export function watcherWorkingDirectory(service) {
@@ -0,0 +1,312 @@
1
+ import { readdirSync, readlinkSync, realpathSync, readFileSync } from "node:fs";
2
+ import { spawnSync } from "node:child_process";
3
+ import { isAbsolute, relative, sep } from "node:path";
4
+ const run = (command, args) => {
5
+ const result = spawnSync(command, args, { encoding: "utf8", timeout: 10_000, maxBuffer: 16 * 1024 * 1024 });
6
+ return { status: result.status, stdout: result.stdout ?? "", stderr: result.stderr ?? "" };
7
+ };
8
+ const START = /^\s*(\d+)\s+(\d+)\s+((?:\w{3}\s+){2}\d{1,2}\s+\d{2}:\d{2}:\d{2}\s+\d{4})\s+(.*)$/;
9
+ export function redactProcessCommand(command) {
10
+ return command
11
+ .replace(/(^|[\s"'`;|&(){}<>])([A-Za-z_][A-Za-z0-9_]*=)(?:"[^"]*"|'[^']*'|[^\s"'`;|&(){}<>]*)/g, "$1$2[redacted]")
12
+ .replace(/(--?(?:password|passwd|token|secret|api[-_]?key|access[-_]?key|client[-_]?secret|authorization)(?:=|\s+))(?:"[^"]*"|'[^']*'|[^\s"']+)/gi, "$1[redacted]")
13
+ .replace(/(authorization\s*:\s*bearer\s+)[^\s"']+/gi, "$1[redacted]")
14
+ .replace(/(https?:\/\/[^\s/:@]+:)[^\s/@]+@/gi, "$1[redacted]@")
15
+ .replace(/\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,}|xox[baprs]-[A-Za-z0-9-]{10,}|sk-[A-Za-z0-9_-]{8,}|AKIA[0-9A-Z]{16})\b/g, "[redacted]");
16
+ }
17
+ export function parsePsProcessRows(text) {
18
+ const rows = [];
19
+ for (const line of text.split(/\r?\n/)) {
20
+ if (!line.trim())
21
+ continue;
22
+ const match = START.exec(line);
23
+ if (!match)
24
+ throw new Error("could not parse the host process table; no process sample was returned");
25
+ const started = Date.parse(match[3]);
26
+ const pid = Number(match[1]);
27
+ const parentPid = Number(match[2]);
28
+ if (!Number.isFinite(started) || !Number.isSafeInteger(pid) || !Number.isSafeInteger(parentPid))
29
+ throw new Error("host process table contains invalid identity fields");
30
+ rows.push({ pid, parent_pid: parentPid, started_at: new Date(started).toISOString(), command: match[4] });
31
+ }
32
+ return rows;
33
+ }
34
+ export function assembleWorktreeProcesses(rows, cwdByPid, listenersByPid, worktree, sampledAt = new Date().toISOString(), foreignRoots = []) {
35
+ const root = realpathSync(worktree);
36
+ const excludedRoots = foreignRoots.flatMap((foreign) => {
37
+ try {
38
+ return [realpathSync(foreign)];
39
+ }
40
+ catch (error) {
41
+ if (error.code === "ENOENT")
42
+ return [];
43
+ throw new Error(`cannot resolve another project worktree root: ${error.message}`);
44
+ }
45
+ });
46
+ const sampledMs = Date.parse(sampledAt);
47
+ if (!Number.isFinite(sampledMs))
48
+ throw new Error("process sample time is invalid");
49
+ return rows.flatMap((row) => {
50
+ const cwd = cwdByPid.get(row.pid);
51
+ if (!cwd)
52
+ return [];
53
+ let canonicalCwd;
54
+ try {
55
+ canonicalCwd = realpathSync(cwd);
56
+ }
57
+ catch {
58
+ // The process can exit between ps and cwd inspection; it is no longer part of this sample.
59
+ return [];
60
+ }
61
+ const rel = relative(root, canonicalCwd);
62
+ if (rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute(rel))
63
+ return [];
64
+ if (excludedRoots.some((foreign) => {
65
+ const foreignRel = relative(foreign, canonicalCwd);
66
+ return foreignRel === "" || (foreignRel !== ".." && !foreignRel.startsWith(`..${sep}`) && !isAbsolute(foreignRel));
67
+ }))
68
+ return [];
69
+ return [{
70
+ pid: row.pid,
71
+ parent_pid: row.parent_pid,
72
+ started_at: row.started_at,
73
+ elapsed_seconds: Math.max(0, Math.floor((sampledMs - Date.parse(row.started_at)) / 1_000)),
74
+ command: redactProcessCommand(row.command).slice(0, 120),
75
+ cwd: canonicalCwd,
76
+ listeners: (listenersByPid.get(row.pid) ?? []).slice(0, 100),
77
+ }];
78
+ });
79
+ }
80
+ export function authorizeWorktreeScope(worktree, projectRoots, foreignRoots) {
81
+ if (!Array.isArray(projectRoots) || projectRoots.length === 0 || !Array.isArray(foreignRoots))
82
+ throw new Error("authoritative project worktree scope is unavailable");
83
+ let requested;
84
+ try {
85
+ requested = realpathSync(worktree);
86
+ }
87
+ catch (error) {
88
+ throw new Error(`cannot resolve requested worktree: ${error.message}`);
89
+ }
90
+ const own = [...new Set(projectRoots.map((path) => realpathSync(path)))];
91
+ const foreign = [...new Set(foreignRoots.map((path) => {
92
+ try {
93
+ return realpathSync(path);
94
+ }
95
+ catch (error) {
96
+ if (error.code === "ENOENT")
97
+ return null;
98
+ throw new Error(`cannot resolve another project worktree root: ${error.message}`);
99
+ }
100
+ }).filter((path) => path !== null))];
101
+ const within = (root, path) => {
102
+ const rel = relative(root, path);
103
+ return rel === "" || (rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute(rel));
104
+ };
105
+ if (own.some((root) => foreign.includes(root)))
106
+ throw new Error("project worktree roots overlap; ownership is ambiguous");
107
+ if (!own.some((root) => within(root, requested)))
108
+ throw new Error("requested worktree is outside this project's registered worktree roots");
109
+ if (foreign.some((root) => within(root, requested)))
110
+ throw new Error("requested worktree is inside a foreign project's worktree root");
111
+ if (foreign.some((root) => own.some((candidate) => within(root, candidate))))
112
+ throw new Error("project worktree roots overlap; ownership is ambiguous");
113
+ return { worktree: requested, project_roots: own, foreign_roots: foreign };
114
+ }
115
+ function parseLsofFileRecords(text) {
116
+ const records = [];
117
+ let pid = null;
118
+ let current = null;
119
+ const flush = () => {
120
+ if (pid !== null && current)
121
+ records.push({ pid, ...current });
122
+ current = null;
123
+ };
124
+ for (const line of text.split(/\r?\n/)) {
125
+ if (line.startsWith("p")) {
126
+ flush();
127
+ const parsed = Number(line.slice(1));
128
+ pid = Number.isSafeInteger(parsed) ? parsed : null;
129
+ }
130
+ else if (line.startsWith("f")) {
131
+ flush();
132
+ current = { descriptor: line.slice(1), type: null, name: null, state: null };
133
+ }
134
+ else if (line.startsWith("t") && current) {
135
+ current.type = line.slice(1);
136
+ }
137
+ else if (line.startsWith("TST=") && current) {
138
+ current.state = line.slice(4);
139
+ }
140
+ else if (line.startsWith("n") && current) {
141
+ current.name = line.slice(1);
142
+ }
143
+ }
144
+ flush();
145
+ return records;
146
+ }
147
+ function isDisappearedProcess(error) {
148
+ const code = error?.code;
149
+ return code === "ENOENT" || code === "ESRCH" || code === "EBADF";
150
+ }
151
+ function processIsInWorktree(cwd, root) {
152
+ let canonicalCwd;
153
+ try {
154
+ canonicalCwd = realpathSync(cwd);
155
+ }
156
+ catch (error) {
157
+ if (isDisappearedProcess(error))
158
+ return false;
159
+ throw new Error(`cannot resolve process working directory ${cwd}: ${error.message}`);
160
+ }
161
+ const rel = relative(root, canonicalCwd);
162
+ return rel === "" || (rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute(rel));
163
+ }
164
+ export function readMacProcessPaths(runner, uid) {
165
+ const cwdResult = runner("lsof", ["-nP", "-a", "-u", String(uid), "-d", "cwd", "-FpcftnT"]);
166
+ if (cwdResult.status !== 0)
167
+ throw new Error(`could not inspect host process working directories: ${cwdResult.stderr.trim() || `lsof exited ${cwdResult.status}`}`);
168
+ const cwd = new Map(parseLsofFileRecords(cwdResult.stdout)
169
+ .filter((entry) => entry.descriptor === "cwd" && entry.name !== null)
170
+ .map((entry) => [entry.pid, entry.name]));
171
+ const listenerResult = runner("lsof", ["-nP", "-a", "-u", String(uid), "-iTCP", "-sTCP:LISTEN", "-FpcftnT"]);
172
+ if (listenerResult.status !== 0 && !(listenerResult.status === 1 && !listenerResult.stdout.trim())) {
173
+ throw new Error(`could not inspect host TCP listeners: ${listenerResult.stderr.trim() || `lsof exited ${listenerResult.status}`}`);
174
+ }
175
+ const listeners = new Map();
176
+ for (const { pid, type, name, state } of parseLsofFileRecords(listenerResult.stdout)) {
177
+ if (!type || !/^IPv[46]$/.test(type) || !name || state !== "LISTEN")
178
+ continue;
179
+ const current = listeners.get(pid) ?? [];
180
+ if (!current.includes(name))
181
+ current.push(name);
182
+ listeners.set(pid, current);
183
+ }
184
+ return { cwd, listeners };
185
+ }
186
+ function compressIPv6(groups) {
187
+ let bestStart = -1;
188
+ let bestLength = 1;
189
+ for (let i = 0; i < groups.length;) {
190
+ if (groups[i] !== 0) {
191
+ i++;
192
+ continue;
193
+ }
194
+ let end = i + 1;
195
+ while (end < groups.length && groups[end] === 0)
196
+ end++;
197
+ if (end - i > bestLength) {
198
+ bestStart = i;
199
+ bestLength = end - i;
200
+ }
201
+ i = end;
202
+ }
203
+ const rendered = groups.map((group) => group.toString(16));
204
+ if (bestStart < 0)
205
+ return rendered.join(":");
206
+ const before = rendered.slice(0, bestStart).join(":");
207
+ const after = rendered.slice(bestStart + bestLength).join(":");
208
+ return `${before}::${after}`;
209
+ }
210
+ function decodeProcAddress(hex, ipv6) {
211
+ const match = /^([0-9a-fA-F]+):([0-9a-fA-F]{1,4})$/.exec(hex);
212
+ const expectedLength = ipv6 ? 32 : 8;
213
+ if (!match || match[1].length !== expectedLength)
214
+ throw new Error(`invalid IPv${ipv6 ? "6" : "4"} listener address from /proc`);
215
+ const port = Number.parseInt(match[2], 16);
216
+ const addressHex = match[1];
217
+ if (!ipv6) {
218
+ const bytes = addressHex.match(/../g);
219
+ return `${bytes.reverse().map((byte) => Number.parseInt(byte, 16)).join(".")}:${port}`;
220
+ }
221
+ // Linux prints each 32-bit /proc/net/tcp6 word in host byte order.
222
+ const networkOrder = (addressHex.match(/.{8}/g) ?? []).map((word) => word.match(/../g).reverse().join("")).join("");
223
+ const groups = (networkOrder.match(/.{4}/g) ?? []).map((group) => Number.parseInt(group, 16));
224
+ return `[${compressIPv6(groups)}]:${port}`;
225
+ }
226
+ export function parseLinuxListenerTable(text, inodes, ipv6) {
227
+ const listeners = [];
228
+ for (const line of text.split(/\r?\n/).slice(1)) {
229
+ const fields = line.trim().split(/\s+/);
230
+ if (fields.length < 10 || fields[3] !== "0A" || !inodes.has(fields[9]))
231
+ continue;
232
+ listeners.push(decodeProcAddress(fields[1], ipv6));
233
+ }
234
+ return [...new Set(listeners)];
235
+ }
236
+ function linuxListenersForPid(pid) {
237
+ const inodes = new Set();
238
+ let fds;
239
+ try {
240
+ fds = readdirSync(`/proc/${pid}/fd`);
241
+ }
242
+ catch (error) {
243
+ if (isDisappearedProcess(error))
244
+ return [];
245
+ throw new Error(`cannot inspect file descriptors for process ${pid}: ${error.message}`);
246
+ }
247
+ for (const fd of fds) {
248
+ try {
249
+ const target = readlinkSync(`/proc/${pid}/fd/${fd}`);
250
+ const match = /^socket:\[(\d+)\]$/.exec(target);
251
+ if (match)
252
+ inodes.add(match[1]);
253
+ }
254
+ catch (error) {
255
+ if (!isDisappearedProcess(error))
256
+ throw new Error(`cannot inspect file descriptor for process ${pid}: ${error.message}`);
257
+ }
258
+ }
259
+ const out = [];
260
+ for (const [table, ipv6] of [["/proc/net/tcp", false], ["/proc/net/tcp6", true]]) {
261
+ let contents;
262
+ try {
263
+ contents = readFileSync(table, "utf8");
264
+ }
265
+ catch {
266
+ throw new Error(`cannot read ${table}; no listener sample was returned`);
267
+ }
268
+ out.push(...parseLinuxListenerTable(contents, inodes, ipv6));
269
+ }
270
+ return [...new Set(out)];
271
+ }
272
+ function readLinuxProcessPaths(rows, worktree) {
273
+ const cwd = new Map();
274
+ const listeners = new Map();
275
+ const root = realpathSync(worktree);
276
+ for (const row of rows) {
277
+ try {
278
+ cwd.set(row.pid, readlinkSync(`/proc/${row.pid}/cwd`));
279
+ }
280
+ catch (error) {
281
+ if (!isDisappearedProcess(error))
282
+ throw new Error(`cannot inspect working directory for process ${row.pid}: ${error.message}`);
283
+ }
284
+ }
285
+ for (const row of rows) {
286
+ const processCwd = cwd.get(row.pid);
287
+ if (!processCwd || !processIsInWorktree(processCwd, root))
288
+ continue;
289
+ const found = linuxListenersForPid(row.pid);
290
+ if (found.length)
291
+ listeners.set(row.pid, found);
292
+ }
293
+ return { cwd, listeners };
294
+ }
295
+ export function scanWorktreeProcesses(worktree, scope, runner = run, sampledAt = new Date().toISOString()) {
296
+ const authorized = authorizeWorktreeScope(worktree, scope.project_roots, scope.foreign_roots);
297
+ const root = authorized.worktree;
298
+ const uid = process.getuid?.();
299
+ if (uid === undefined)
300
+ throw new Error(`host process inspection is unsupported on ${process.platform}`);
301
+ const ps = runner("ps", ["-U", String(uid), "-ww", "-axo", "pid=,ppid=,lstart=,command="]);
302
+ if (ps.status !== 0)
303
+ throw new Error(`could not inspect the host process table: ${ps.stderr.trim() || `ps exited ${ps.status}`}`);
304
+ const rows = parsePsProcessRows(ps.stdout);
305
+ const paths = process.platform === "darwin"
306
+ ? readMacProcessPaths(runner, uid)
307
+ : process.platform === "linux"
308
+ ? readLinuxProcessPaths(rows, root)
309
+ : (() => { throw new Error(`host process inspection is unsupported on ${process.platform}`); })();
310
+ // Keep the sample anchored to the exact worktree path accepted by the API.
311
+ return assembleWorktreeProcesses(rows, paths.cwd, paths.listeners, root, sampledAt, authorized.foreign_roots);
312
+ }