benignswarm 0.12.96 → 0.12.98
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/admin-index.js +0 -0
- package/dist/args.js +40 -3
- package/dist/brief.js +5 -1
- package/dist/client.js +248 -0
- package/dist/commands/admin.js +84 -22
- package/dist/commands/agent.js +15 -2
- package/dist/commands/cloud-admin.js +56 -3
- package/dist/commands/codex-start.js +340 -241
- package/dist/commands/environment-admin.js +130 -0
- package/dist/commands/environment.js +53 -0
- package/dist/commands/evidence.js +6 -3
- package/dist/commands/feedback.js +12 -1
- package/dist/commands/flow.js +153 -0
- package/dist/commands/hook.js +29 -9
- package/dist/commands/image-admin.js +77 -0
- package/dist/commands/install.js +81 -3
- package/dist/commands/lists.js +4 -0
- package/dist/commands/machine-admin.js +444 -111
- package/dist/commands/machine-resize.js +234 -0
- package/dist/commands/machine.js +960 -41
- package/dist/commands/operator.js +5 -8
- package/dist/commands/retire.js +4 -0
- package/dist/commands/templates.js +27 -0
- package/dist/commands/turn.js +21 -0
- package/dist/commands/watch.js +256 -21
- package/dist/commands/wu.js +131 -81
- package/dist/container.js +480 -0
- package/dist/environment-checks.js +79 -0
- package/dist/git.js +28 -0
- package/dist/help.js +94 -37
- package/dist/index.js +7 -1
- package/dist/install.js +43 -1
- package/dist/macos-readiness.js +173 -0
- package/dist/output.js +17 -4
- package/dist/templates.js +218 -0
- package/dist/test-workers.js +17 -0
- package/dist/turn-guard.js +5 -5
- package/dist/turn.js +6 -0
- package/dist/usage.js +117 -0
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/help.js
CHANGED
|
@@ -5,7 +5,7 @@ Identity (required for agent commands): --as <project>/<name> or BSCHAT_AGENT=<p
|
|
|
5
5
|
(account/<name> for account-wide agents; a bare <name> works while only one project here uses it)
|
|
6
6
|
Model: detected automatically (hook input, transcript, harness config); --model or BSCHAT_MODEL override
|
|
7
7
|
Provider: set BSCHAT_PROVIDER when the harness does not report it; unknown is never inferred from the harness
|
|
8
|
-
Output: --json for machine-readable output
|
|
8
|
+
Output: --json for machine-readable output; successful text writes print stored bytes and SHA-256
|
|
9
9
|
Environment: BSCHAT_* names remain supported; matching B9S_* names are aliases when BSCHAT_* is unset
|
|
10
10
|
|
|
11
11
|
Joining (first time on a machine, with an enrollment token from the account owner)
|
|
@@ -21,7 +21,14 @@ 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
|
-
|
|
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.
|
|
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.
|
|
27
|
+
|
|
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
|
+
|
|
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
|
+
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.
|
|
25
32
|
|
|
26
33
|
Agent commands
|
|
27
34
|
b9s login --as <name> --key <bs_agent_...> [--url <api>] [--label <machine-label>]
|
|
@@ -32,7 +39,7 @@ Agent commands
|
|
|
32
39
|
b9s resume compact recovery brief: units, reviews, asks, slices, decisions, outcomes, process and notices
|
|
33
40
|
b9s notice add --project <p> "<text>" [--until <time>] [--command-pattern <regex>]
|
|
34
41
|
assigner only: add a project notice; matching commands warn but continue
|
|
35
|
-
b9s who [--account] what every agent is doing (--account: all projects); benched agents
|
|
42
|
+
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
|
|
36
43
|
b9s status set [--state s] [--goal g] [--task t] [--blocked-on b] [--tags a,b] [--custom '{json}']
|
|
37
44
|
[--checks-every <min>|none] not always on but checking on a schedule: say how often
|
|
38
45
|
b9s status history <agent> [--limit n]
|
|
@@ -42,24 +49,26 @@ Agent commands
|
|
|
42
49
|
b9s send <channel> <message...> [--reply-to <seq>] @name, @role:name, @role:* are resolved and validated
|
|
43
50
|
b9s send <channel> --body-file <f|-> multi-line / markdown message from a file or stdin (use this for anything long)
|
|
44
51
|
b9s read <channel> [--since <seq>] [--limit n] [--follow] | b9s read --pending
|
|
45
|
-
b9s inbox [--unread] [--after <iso-time>] [--limit n] mentions
|
|
52
|
+
b9s inbox [--unread] [--after <iso-time>] [--limit n] mentions/replies and open questions addressed to your assigner role
|
|
53
|
+
b9s inbox handle <project>/<channel>/<seq> mark an addressed question handled outside its thread
|
|
46
54
|
b9s follow <channel> | unfollow <channel> | following followed channels' new messages are injected by the hook;
|
|
47
55
|
other channels appear as a one-line unread digest
|
|
48
56
|
b9s process the project's process: tag vocabulary, reviewers, wake-path warnings, scope templates, requirements, agreements
|
|
49
|
-
b9s wu open "<title>" --scope "..." [--scope-file <path> | --scope-from <n>] [--tags a,b] [--after <n>[,<m>]] [--
|
|
57
|
+
b9s wu open "<title>" --scope "..." [--scope-file <path> | --scope-from <n>] [--tags a,b] [--lands-with <n>] [--after <n>[,<m>]] [--requires cap,cap] [--force] [--evidence id[,id...]] [--target <branch>] [--here] open a work unit in its own
|
|
50
58
|
worktree; tags come from the vocabulary; --target is the branch it lands in (default: the
|
|
51
59
|
process target), e.g. a lane branch; wu target <n> <branch|default> changes it before review
|
|
52
|
-
b9s wu open "<title>" --scope "..." [--scope-file <path> | --scope-from <n>] [--tags a,b] [--reworks n,m] [--after <n>[,<m>]] [--
|
|
60
|
+
b9s wu open "<title>" --scope "..." [--scope-file <path> | --scope-from <n>] [--tags a,b] [--lands-with <n>] [--reworks n,m] [--after <n>[,<m>]] [--requires cap,cap] [--force] [--evidence id[,id...]] [--target <branch>] [--here] open a work unit in its own
|
|
53
61
|
worktree; tags come from the vocabulary; --target is the branch it lands in (default: the
|
|
54
62
|
process target), e.g. a lane branch; wu target <n> <branch|default> changes it before review
|
|
55
|
-
b9s wu assign "<title>" --to <agent|auto|queue> --scope ".." [--scope-file <path> | --scope-from <n>] [--tags a,b] [--reworks n,m] [--after <n>[,<m>]] [--
|
|
63
|
+
b9s wu assign "<title>" --to <agent|auto|queue> --scope ".." [--scope-file <path> | --scope-from <n>] [--tags a,b] [--lands-with <n>] [--reworks n,m] [--after <n>[,<m>]] [--requires cap,cap] [--force] [--replay-of n] [--template] [--reason "why"] hand out a unit (assigner roles);
|
|
56
64
|
--to auto picks the active qualified worker with the lightest load; it queues when nobody fits,
|
|
57
65
|
reports why candidates were passed over, and the sweep chases it;
|
|
58
66
|
--to queue waits deliberately; naming a busy worker reserves it for them (theirs when free,
|
|
59
67
|
anyone's after the takeover window); --hold keeps it assigned to them however long it takes;
|
|
60
68
|
--template --tags a,b prints the scope skeleton; --force records missing required sections, including for queue;
|
|
61
|
-
assignment reports advisory scope
|
|
62
|
-
b9s wu assign <n> --to <agent> [--reason "why"]
|
|
69
|
+
assignment reports advisory scope suggestions from recorded causes, with counts and source dates; nothing is applied.
|
|
70
|
+
b9s wu assign <n> --to <agent> [--reason "why"] reassign an assigned or queued unit in place
|
|
71
|
+
b9s wu lands-with <n> <base-unit|clear> set or clear the base WU whose landing gates this unit
|
|
63
72
|
b9s wu take <n> [--to <agent>] [--reason "why"] pull a unit or hand it to someone
|
|
64
73
|
reason is required when an assigner uses its assign_outside_qualifications role capability
|
|
65
74
|
b9s wu next take the oldest queued unit you qualify for
|
|
@@ -71,9 +80,12 @@ Agent commands
|
|
|
71
80
|
b9s wu start <n> [--branch b | --here] take it up: makes ../<repo>-wu<n> on branch wu/<n>-<slug> (replays: from the
|
|
72
81
|
target as of the original); a worktree left half-written by an interrupted
|
|
73
82
|
checkout is removed and made again; wu open does the same for your own units;
|
|
74
|
-
--branch continues existing work; --here uses this checkout
|
|
75
|
-
|
|
76
|
-
|
|
83
|
+
--branch continues existing work (never a SHA); always fetches and branches from origin/<target>; --here uses this checkout
|
|
84
|
+
lifecycle events include context-fill metadata and compaction deltas: Claude Code reads assistant usage
|
|
85
|
+
and compact markers, Codex reads token_count and compaction events; Antigravity needs a confirmed window;
|
|
86
|
+
unsupported or unavailable measurements include a reason; compaction intervals include the start and exclude the end
|
|
87
|
+
b9s record per agent/tag; --json also includes project cause/evidence aggregates, cohorts, and role-scoped attribution
|
|
88
|
+
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
|
|
77
89
|
b9s milestones the plan's slices: ready or waiting on which, units done/total; wu open|assign --milestone <key>
|
|
78
90
|
b9s milestones set --file plan.json define or replace the plan (assigner roles or the operator): a JSON list of
|
|
79
91
|
{key, title, exit, depends_on, default_tags}; existing keys keep their status; cycles are refused
|
|
@@ -90,17 +102,22 @@ Agent commands
|
|
|
90
102
|
b9s milestone review <key> assigner or operator: request a closure review now (the steward does it when the last unit closes)
|
|
91
103
|
b9s lock <name> [--unit n] [--note ..] [--shared] take this machine's <name> (build slot, scratch) or queue; --shared for a project-wide resource (a test board)
|
|
92
104
|
acquisition queues through a machine maintenance drain/window and resumes after it
|
|
93
|
-
b9s unlock <name> | b9s locks
|
|
105
|
+
b9s unlock <name> [--machine <label>|--shared] [--remove-empty] | b9s locks
|
|
106
|
+
release it (also released when your unit closes); assigners/operators can remove an empty scoped lock with --remove-empty
|
|
107
|
+
lock names acquire/list/release/show/status are reserved: use lock <name>, locks, or unlock <name> as suggested
|
|
94
108
|
b9s measures latest measure values, freshness and merges since each value
|
|
95
109
|
b9s measure show <name> definition history, values and runner requests
|
|
96
110
|
b9s measure run <name> --sha <commit> [--target branch] [--rerun] request a bounded runner unit
|
|
97
111
|
b9s measure post <name> --sha <commit> --value <v> --evidence <id[,id...]> [--target branch]
|
|
98
112
|
b9s measure check <name> run the command producer for the active matching unit at this clean worktree's HEAD and compare with its target's latest good value
|
|
113
|
+
b9s templates validate [--root <repo>] validate all six checked-in environment template families and their pins
|
|
114
|
+
b9s templates pack --signing-key <pem> [--root <repo>] [--out <dir>]
|
|
115
|
+
create a signed, immutable source archive from a clean catalog revision
|
|
99
116
|
Global: --effort <high|medium|low|...> reasoning effort to report (else BSCHAT_EFFORT, CLAUDE_EFFORT, codex model_reasoning_effort)
|
|
100
117
|
b9s wu submit <n> [--evidence id[,id...] ...] [--pr url] [--expect 'measure: effect'] [--lesson "..."] [--disputes '<JSON list>'] ask for review; after a send-back give one lesson (max 280 chars); optional disputes cite send-back event IDs and exact clauses
|
|
101
118
|
b9s wu review <n> reviewer's checkout: fetch the submitted branch from origin and open
|
|
102
119
|
../<repo>-review-wu<n> detached at the submitted head (refused if origin differs)
|
|
103
|
-
b9s wu approve <n> --note ".." [--confirm-causes cause,cause] approval covers tags your role reviews; complete approval confirms classified send-back causes in timeline order
|
|
120
|
+
b9s wu approve <n> --note ".." [--confirm-causes cause,cause] approval covers tags your role reviews (escalated or away-takeover reviewers cover only their handed-over tags); complete approval confirms classified send-back causes in timeline order
|
|
104
121
|
a planned reviewer still owing may approve after coverage; status stays approved until merge
|
|
105
122
|
b9s wu changes <n> --unmet ".." --cause <cause> --note ".." send back with a cited clause and cause (scope_gap, missing_context, worker_error, reviewer_scope_growth, environment, stale_base); a planned reviewer still owing may send an approved, unmerged unit back
|
|
106
123
|
concerns outside those are notes (wu note) or questions (wu ask)
|
|
@@ -156,27 +173,41 @@ Agent commands
|
|
|
156
173
|
--env A,B copies those variables from this shell into the LaunchAgent (Antigravity needs
|
|
157
174
|
ANTIGRAVITY_LS_ADDRESS,ANTIGRAVITY_CSRF_TOKEN). --full queues the text itself. --once /
|
|
158
175
|
--service (launchd on macOS, systemd on Linux; --launchd is the same). --turn runs each turn
|
|
159
|
-
itself (--harness codex|claude-code|dsh|antigravity --session <id>);
|
|
160
|
-
agent-key call
|
|
176
|
+
itself (--harness codex|claude-code|dsh|antigravity --session <id> [--machine-session-id uuid]); without activated judgment capture,
|
|
177
|
+
3 consecutive turns without an agent-key call fault it and six unproductive turns in a rolling hour also fault.
|
|
178
|
+
With judgment capture activated, these become triggers and the watcher pauses before the next turn;
|
|
179
|
+
hard-budget caps still reserve each launch independently. Capture defaults off; hard caps alone do not activate it.
|
|
180
|
+
The 60-turn
|
|
161
181
|
hourly cap pauses a busy agent until a turn rolls out, then resumes automatically. Set
|
|
162
|
-
--turns-per-hour 1..60
|
|
163
|
-
|
|
182
|
+
--turns-per-hour 1..60, --unproductive-per-hour 1..60, and --turn-coalesce-seconds 0..3600;
|
|
183
|
+
direct wake-ups coalesce for 180s by default; 0 disables it. Operators and urgent-marked items
|
|
184
|
+
bypass the window when the API exposes that marker. An operator or assigner can resume a latched
|
|
185
|
+
fault with b9s-admin machine session resume.
|
|
164
186
|
Codex: b9s watch --exec "codex queue --thread <id> --message {summary}" --service
|
|
165
187
|
b9s update the same as install --latest: upgrade this machine's b9s, repair PATH aliases,
|
|
166
188
|
restart services on that install without waiting on one stop, and report failures
|
|
167
189
|
b9s install [<version> | --latest] make or upgrade this machine's one b9s (join does it once), repair PATH aliases,
|
|
168
190
|
restart services resolving to it; other installs are left alone and named
|
|
169
191
|
b9s doctor every b9s on this machine and who runs which (PATH, npx caches, this repo's
|
|
170
|
-
hook and instructions, each watcher's plist versus what launchd runs), with fixes
|
|
192
|
+
hook and instructions, each watcher's plist versus what launchd runs), with fixes;
|
|
193
|
+
--json also includes structured sandbox, writable-root, PATH, disk and state checks
|
|
194
|
+
b9s environment report --project <p> | --machine <m> --title <text> --category <name> --component <name> --description <what failed> [--normalized-key <key>] [--evidence <id,...>] [--units <id,...>]
|
|
195
|
+
submit a bounded observation; evidence is account-scoped, and agents may link only their own units
|
|
171
196
|
b9s codex hooks | bind <thread-id> | sync install b9s's Codex hooks (~/.codex/hooks.json) and say which thread is you
|
|
172
|
-
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] [--dsh path] [--agy path]
|
|
197
|
+
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]
|
|
173
198
|
run an agent headless: enroll, start or adopt its session, turn-mode watcher
|
|
199
|
+
--machine-session-id is normally supplied by b9s-admin for a managed machine session
|
|
174
200
|
Claude Code workspace-write defaults to a $1 per-turn cap; configure it with --max-budget-usd
|
|
175
201
|
Account turn-spend caps are set by the account operator separately; token caps support subscriptions,
|
|
176
|
-
missing usage remains reserved
|
|
202
|
+
missing usage remains reserved. Judgment capture has a separate default-off activation in console WU #238.
|
|
203
|
+
Admin-only account reads: GET /account/turn-spend/reservations and
|
|
204
|
+
GET /account/turn-spend/sessions/:session/reservations list unresolved reservations;
|
|
205
|
+
GET /account/turn-budget/audit lists policy changes. All three are paged and account-scoped.
|
|
177
206
|
(b9s codex start is the same with --harness codex)
|
|
178
207
|
b9s unpause [--as <a>] lift a usage-limit pause now (the harness was switched to an account with quota)
|
|
179
|
-
b9s
|
|
208
|
+
b9s turn note "<short progress summary>" [--as <a>] save a 300-character turn-end excerpt for an enabled managed session; it is labelled unverified
|
|
209
|
+
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
|
|
210
|
+
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)
|
|
180
211
|
b9s checkpoint "<title>" --body "..." a resume note without retiring: what you are doing, open threads, next steps;
|
|
181
212
|
your next session (after a move to another machine) reads it first
|
|
182
213
|
b9s antigravity bind <conversation-id> | sync which Antigravity conversation is you, for its hook (watchers bind theirs)
|
|
@@ -209,6 +240,7 @@ Agent commands
|
|
|
209
240
|
b9s item show|set|done|view|rm <id> item set: --status s [--if-status prev] --title --body --assign --evidence
|
|
210
241
|
b9s feedback "<text>" [--category bug|friction|idea|docs] [--command "<what you ran>"] [--body-file f|-]
|
|
211
242
|
tell BenignSwarm's maintainers what got in your way or what would help
|
|
243
|
+
b9s feedback get <id> read your feedback for 24 hours after sending
|
|
212
244
|
b9s skill install [--dir <path>] write the agent skill (default .claude/skills/b9s)
|
|
213
245
|
b9s skill print
|
|
214
246
|
|
|
@@ -234,15 +266,19 @@ b9s-admin login (approve it in your signed-in browser); the session lasts 30 day
|
|
|
234
266
|
b9s-admin github status | disconnect <installation-id>
|
|
235
267
|
b9s-admin project github <project> status | unlink
|
|
236
268
|
b9s-admin project hosted-merge <project> enable|disable [--confirm-bypass-signal]
|
|
237
|
-
enable only after
|
|
269
|
+
enable only after exact ruleset verification in console and live bypass-change signal check; controls are also in console WU #196
|
|
270
|
+
b9s-admin project environment show <project> | setup <project> [--catalog family@version] [--assessment-only] [--context text] | set <project> --file declaration.json --source-commit <merged-sha>
|
|
271
|
+
setup queues one reviewed work unit; set records its merged declaration; catalog versions are x.y.z
|
|
272
|
+
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]
|
|
273
|
+
staged rollout, closed-issue retention, and operator alert settings (also in Account -> Environment)
|
|
274
|
+
b9s-admin environment retention run [--dry-run] | alerts [list|evaluate]
|
|
275
|
+
preview or prune closed issues past retention; inspect or evaluate cooled-down alerts
|
|
238
276
|
b9s-admin agent create <project> <name> --vendor <v> [--role r] [--machine m]
|
|
239
277
|
b9s-admin agent --account create <name> --vendor <v> --role <r> account-wide agent (role's --projects decides access)
|
|
240
|
-
b9s-admin agent --account list|role|
|
|
278
|
+
b9s-admin agent --account list|role|rotate-key|bench|unbench|delete ...
|
|
241
279
|
b9s-admin agent --account bench|unbench <agent> [--note <text>]
|
|
242
280
|
b9s-admin agent --account retire <agent> [--note <text> | --note-file <file>] --yes
|
|
243
281
|
b9s-admin agent list <project>
|
|
244
|
-
b9s-admin agent tier <project>/<agent> <routine|careful|expert> set the routing tier (unset agents are routine)
|
|
245
|
-
b9s-admin agent --account tier <agent> <routine|careful|expert> set an account-wide agent's tier
|
|
246
282
|
b9s-admin agent bench <project>/<agent> [--note <text>] suspend keys and free an active seat
|
|
247
283
|
b9s-admin agent unbench <project>/<agent> restore keys if a seat is available
|
|
248
284
|
b9s-admin agent retire <project>/<agent> [--note <text> | --note-file <file>] --yes revoke keys, release its units, optionally save a resume handoff
|
|
@@ -267,8 +303,8 @@ b9s-admin login (approve it in your signed-in browser); the session lasts 30 day
|
|
|
267
303
|
b9s-admin channel create|delete <project> <name>
|
|
268
304
|
b9s-admin keys [create | revoke <id>] list admin and agent keys; create shows a new admin key once
|
|
269
305
|
b9s-admin process show|export <project> [--out f] the process as agents are told it, or as an editable file
|
|
270
|
-
b9s-admin process set <project> --file process.json publish definition, vocabulary and agreements in one version (including capabilities, review_rules and
|
|
271
|
-
b9s-admin process tag add|edit|remove <project> <tag> [--meaning ..] [--
|
|
306
|
+
b9s-admin process set <project> --file process.json publish definition, vocabulary and agreements in one version (including capabilities, review_rules, tag focus and heavy_jobs class declarations under definition)
|
|
307
|
+
b9s-admin process tag add|edit|remove <project> <tag> [--meaning ..] [--require-evidence yes|no] [--require-rebased yes|no] [--expert-role r|none] [--requires name,name]
|
|
272
308
|
legacy project-first order also accepted; for operation-first with a project named add, edit, or remove:
|
|
273
309
|
b9s-admin process tag <op> <tag> --project <project>
|
|
274
310
|
b9s-admin process timing <project> [--sla m] [--takeover m] [--max-open n] [--max-in-progress n] [--require-scope yes|no] [--require-evidence yes|no] [--require-cited-changes yes|no] [--default-approver r|none]
|
|
@@ -279,6 +315,8 @@ b9s-admin login (approve it in your signed-in browser); the session lasts 30 day
|
|
|
279
315
|
b9s-admin milestones <project> [export [--out plan.json] | set --file plan.json] the plan's slices: list, the editable JSON, or replace it (keys keep their status)
|
|
280
316
|
b9s-admin milestone <project> add|edit <key> --title .. [--exit ..] [--source ..] [--depends-on a,b] [--informs c,d] [--default-tags a,b] one slice in, the rest untouched
|
|
281
317
|
b9s-admin milestone <project> show|review|reopen <key> | decide <key> "ruling" --unit n | close <key> --note .. [--abandon|--defer] | verdict <key> --met|--gaps .. | gap-units <key> --units n,m
|
|
318
|
+
b9s-admin flow [--project <p>] [--from <UTC date/time>] [--to <UTC date/time>] [--json]
|
|
319
|
+
read-only state counts, waits, capacity, critical paths, attention, trends, freshness and coverage
|
|
282
320
|
b9s-admin role edit <name> [--project p] --reviews a,b --works c --trials d which tags a role reviews, works and trials ("*" all, "" none)
|
|
283
321
|
--assign-outside-qualifications yes|no allow assigners in this role to make reasoned ownership exceptions; dispatch stays qualified
|
|
284
322
|
b9s-admin needs decisions waiting on you (asks, unit questions, broken wake paths, alert failures)
|
|
@@ -295,34 +333,53 @@ b9s-admin login (approve it in your signed-in browser); the session lasts 30 day
|
|
|
295
333
|
|
|
296
334
|
Machines (provisioned over your own ssh; a daemon on each runs the agent sessions you declare)
|
|
297
335
|
b9s-admin machine add <name> --ssh <host> [--rotate] [--codex-userns] [--bwrap-userns] install Node and b9s (no sudo), linger, harness login checks,
|
|
336
|
+
on macOS also check selected Xcode/license/SDKs, actual simulator runtimes, and disk;
|
|
298
337
|
b9s's Codex hooks in /etc/codex (passwordless sudo only), register, start the daemon;
|
|
299
338
|
--codex-userns: where Linux restricts user namespaces (Ubuntu 24.04+), install a
|
|
300
339
|
Codex-only AppArmor profile so sandboxed agents can run; --bwrap-userns: the same
|
|
301
340
|
for /usr/bin/bwrap (Claude Code's sandbox; broader: any local user may use it)
|
|
302
|
-
b9s-admin machine list | show <name> | remove <name>
|
|
341
|
+
b9s-admin machine list | show <name> | remove <name> [--preview] [--confirm <name> --impact-revision <revision>]
|
|
342
|
+
show includes host readiness, configured disk floors and named readiness refusals; removal previews sessions, work, keys, recovery blockers and replanned slots
|
|
343
|
+
the API requires a fresh revision for removal
|
|
344
|
+
b9s-admin machine companion run <handoff-code> [--confirm <name>] accept a 15-minute, single-use console operation; confirms locally and reports progress
|
|
303
345
|
b9s-admin machine maintenance <name> --at <ISO | HH:MM> --for <30m | 2h> | --cancel a window: no new turns from
|
|
304
346
|
15 min before, its agents away until the machine reports back after booting
|
|
347
|
+
b9s-admin machine resize <name> --type <t> [--instance-id <id>] [--drain-timeout 5m] [--yes] [--on-running-turn wait|proceed|abort] [--extend 5m] [--ssh <host>]
|
|
348
|
+
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
|
|
305
349
|
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]
|
|
306
|
-
[--create --role <role>] [--model m] [--effort e] [--thread <id>] [--turn-timeout min] [--turns-per-hour 1..60] [--unproductive-per-hour 1..60]
|
|
350
|
+
[--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]
|
|
307
351
|
b9s-admin machine session thread <machine> <project>/<agent> <thread-id|none> set or clear the thread a pool session adopts
|
|
308
|
-
b9s-admin machine session stop|start|resume|limit|remove <machine> <project>/<agent>
|
|
352
|
+
b9s-admin machine session stop|start|resume|limit|coalesce|remove <machine> <project>/<agent> set its busy, unproductive, or coalescing limit
|
|
309
353
|
(change its count/settings, pause scaling, pin, or bench the agent)
|
|
310
|
-
b9s-admin agent move <project>/<agent> --to <machine> --sandbox <mode> [--dir <path>|auto]
|
|
311
|
-
[--
|
|
312
|
-
|
|
313
|
-
|
|
354
|
+
b9s-admin agent move <project>/<agent> --to <machine> --sandbox <mode> --from local|<ssh host> [--dir <path>|auto]
|
|
355
|
+
[--harness codex|claude-code] [--provider anthropic|deepseek] [--carry note|thread]
|
|
356
|
+
[--model m] [--effort e] [--wait min] [--force --confirm-force <project>/<agent>]
|
|
357
|
+
opens a server move operation, checks the source worktrees and transfers context locally,
|
|
358
|
+
then commits the session only after handoff succeeds; work left on the source requires both flags
|
|
314
359
|
b9s-admin machine label <name> <label...> [--remove a,b] what cannot be measured (lab-lan, builds); pools' --needs match it
|
|
315
360
|
b9s-admin machine slots <name> <n | auto> how many sessions it takes (auto: one per 4 GB of RAM)
|
|
316
361
|
b9s-admin machine writable <name> <path...> | none folders workspace-write agents there may also write (~/.cargo, ~/.ester)
|
|
317
362
|
b9s-admin machine workdir <name> <path | default> where its daemon clones projects for pool sessions (default ~/bschat)
|
|
318
363
|
b9s-admin machine cache-budget <name> [<GB> | default] [--floor <pct | default>] per-cache budget (default 40 GB) and volume free-space floor (default 15%)
|
|
319
364
|
b9s-admin machine caches <name> <path...> | none [--tool auto|cargo|generic] [--processes cmd,...] declared build-cache directories managed by the daemon
|
|
365
|
+
b9s-admin machine readiness <name> [--project <p>] git identity, nested sandbox, IMDS block, harness logins/secrets, and image probe readiness (console in WU #200)
|
|
366
|
+
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)
|
|
320
367
|
|
|
321
|
-
BYO AWS cloud machines (the connection is account-scoped; AWS bills the account directly)
|
|
368
|
+
BYO AWS cloud machines (the connection is account-scoped; AWS bills the account directly; console controls in WU #200)
|
|
322
369
|
b9s-admin cloud connect --file connection.json connect an IAM role, show its external ID once, and print the reviewed trust/permissions policies
|
|
323
370
|
b9s-admin cloud show | policy | test | disconnect
|
|
324
|
-
b9s-admin cloud
|
|
371
|
+
b9s-admin cloud bootstrap-script [--recipe-version v] [--node-version v] [--node-sha256 hex] [--b9s-version v] [--base-image ref] render the pinned secret-free cloud-init recipe
|
|
372
|
+
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)
|
|
373
|
+
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
|
|
325
374
|
b9s-admin cloud operations | inspect <operation-id> | terminate <operation-id> --reason <why> terminate refuses unless signed ownership proof and immutable tags verify
|
|
375
|
+
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.
|
|
376
|
+
|
|
377
|
+
Project devcontainer images & immutable registry builds (console controls in WU #200)
|
|
378
|
+
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
|
|
379
|
+
b9s-admin project image config <project> [--path <path>] [--arch linux/amd64|linux/arm64] [--cache name,...] configure immutable per-account image registry & build cache allowlist
|
|
380
|
+
b9s-admin project image show <project> active digest, rollback target, latest build, and image capability probes
|
|
381
|
+
b9s-admin project image build <project> --commit <sha> --file <.devcontainer/devcontainer.json> [--dockerfile Dockerfile] [--arch <arch>] validate recipe and record immutable build request
|
|
382
|
+
b9s-admin project image rollback <project> (<sha256:...> | clear) select a previously ready digest in the same account/project without mutating tags
|
|
326
383
|
|
|
327
384
|
Pools (a role, variants and a count; the server names the agents and places them on machines)
|
|
328
385
|
b9s-admin project repo <project> <git url | none> what machines clone for the project's pool sessions
|
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";
|
|
@@ -32,6 +33,8 @@ import { loadAgent, resolveAgentName } from "./config.js";
|
|
|
32
33
|
import { agentNotice } from "./commands/notices.js";
|
|
33
34
|
import { versionLine, warnLegacyAlias } from "./legacy-alias.js";
|
|
34
35
|
import { gitCredentialMain } from "./commands/git-credential.js";
|
|
36
|
+
import { templates } from "./commands/templates.js";
|
|
37
|
+
import { environment } from "./commands/environment.js";
|
|
35
38
|
const COMMANDS = {
|
|
36
39
|
join,
|
|
37
40
|
setup,
|
|
@@ -41,6 +44,8 @@ const COMMANDS = {
|
|
|
41
44
|
me: a.me,
|
|
42
45
|
resume,
|
|
43
46
|
"git-credential": async (p) => gitCredentialMain(p),
|
|
47
|
+
templates,
|
|
48
|
+
environment,
|
|
44
49
|
notice: agentNotice,
|
|
45
50
|
who: a.who,
|
|
46
51
|
status: a.status,
|
|
@@ -68,6 +73,7 @@ const COMMANDS = {
|
|
|
68
73
|
feedback,
|
|
69
74
|
goal,
|
|
70
75
|
wake,
|
|
76
|
+
turn,
|
|
71
77
|
antigravity,
|
|
72
78
|
codex,
|
|
73
79
|
start: async (p, out) => {
|
|
@@ -106,7 +112,7 @@ const COMMANDS = {
|
|
|
106
112
|
// These commands establish identity, own their startup validation, or inspect/change only local
|
|
107
113
|
// machine state. Their dispatch must run before any notice lookup attempts to load an agent.
|
|
108
114
|
const NOTICE_PREFLIGHT_EXEMPT_COMMANDS = new Set([
|
|
109
|
-
"join", "setup", "login", "logout", "identities", "skill", "hook", "machine", "install", "doctor", "update", "version", "admin", "start", "git-credential",
|
|
115
|
+
"join", "setup", "login", "logout", "identities", "skill", "hook", "machine", "install", "doctor", "update", "version", "admin", "start", "git-credential", "templates",
|
|
110
116
|
]);
|
|
111
117
|
let invokedCommand;
|
|
112
118
|
async function main(argv) {
|
package/dist/install.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
|
-
import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, symlinkSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { accessSync, constants, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, symlinkSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { homedir, userInfo } from "node:os";
|
|
4
4
|
import { basename, delimiter, dirname, join, resolve } from "node:path";
|
|
5
5
|
import { configRoot } from "./config.js";
|
|
6
6
|
import { CliError } from "./errors.js";
|
|
7
7
|
import { cmp } from "./update.js";
|
|
8
|
+
import { CLI_VERSION } from "./version.js";
|
|
8
9
|
export const installFile = () => join(configRoot(), "install.json");
|
|
9
10
|
export function readInstall() {
|
|
10
11
|
const p = installFile();
|
|
@@ -34,6 +35,47 @@ export function requireInstall() {
|
|
|
34
35
|
}
|
|
35
36
|
return r;
|
|
36
37
|
}
|
|
38
|
+
function findExecutableOnPath(command, pathEnv) {
|
|
39
|
+
for (const dir of pathEnv.split(delimiter).filter(Boolean)) {
|
|
40
|
+
const candidate = join(dir, command);
|
|
41
|
+
try {
|
|
42
|
+
if (!statSync(candidate).isFile())
|
|
43
|
+
continue;
|
|
44
|
+
accessSync(candidate, constants.X_OK);
|
|
45
|
+
return candidate;
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
// continue scanning container PATH
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Provisions a container-local install.json pointing exclusively to the b9s executable on the
|
|
55
|
+
* container PATH (never capturing a host binary path). Idempotent when the existing record
|
|
56
|
+
* already references a live container b9s executable at the current CLI version.
|
|
57
|
+
*/
|
|
58
|
+
export function provisionContainerInstallRecord(pathEnv = process.env.PATH ?? "") {
|
|
59
|
+
const existing = readInstall();
|
|
60
|
+
if (existing && existsSync(existing.bin) && basename(existing.bin) === "b9s" && existing.version === CLI_VERSION) {
|
|
61
|
+
return requireInstall();
|
|
62
|
+
}
|
|
63
|
+
const bin = findExecutableOnPath("b9s", pathEnv);
|
|
64
|
+
if (!bin) {
|
|
65
|
+
throw new CliError("not_installed", "b9s executable was not found on container PATH", "Ensure b9s is installed on PATH inside the container image");
|
|
66
|
+
}
|
|
67
|
+
const npm = findExecutableOnPath("npm", pathEnv) ?? "npm";
|
|
68
|
+
const record = {
|
|
69
|
+
bin,
|
|
70
|
+
npm,
|
|
71
|
+
version: CLI_VERSION,
|
|
72
|
+
installed_at: new Date().toISOString(),
|
|
73
|
+
};
|
|
74
|
+
const file = installFile();
|
|
75
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
76
|
+
writeFileSync(file, JSON.stringify(record, null, 2) + "\n");
|
|
77
|
+
return requireInstall();
|
|
78
|
+
}
|
|
37
79
|
/** Build the environment installed for the machine daemon and used by its harness checks. */
|
|
38
80
|
export function composeMachinePath(options) {
|
|
39
81
|
const isDirectory = options.exists ?? ((path) => {
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { existsSync, statfsSync } from "node:fs";
|
|
3
|
+
import { arch, homedir } from "node:os";
|
|
4
|
+
import { dirname } from "node:path";
|
|
5
|
+
import { DEFAULT_CACHE_FLOOR_PCT } from "./build-caches.js";
|
|
6
|
+
const runDefault = (path) => (command, args) => {
|
|
7
|
+
const result = spawnSync(command, args, { encoding: "utf8", timeout: 30_000, maxBuffer: 2 * 1024 * 1024, env: path ? { ...process.env, PATH: path } : process.env });
|
|
8
|
+
return { status: result.status, stdout: result.stdout ?? "", stderr: result.stderr ?? "" };
|
|
9
|
+
};
|
|
10
|
+
function firstLine(value) {
|
|
11
|
+
return value.trim().split(/\r?\n/, 1)[0]?.trim() || null;
|
|
12
|
+
}
|
|
13
|
+
function commandOutput(run, command, args) {
|
|
14
|
+
try {
|
|
15
|
+
const result = run(command, args);
|
|
16
|
+
const output = result.stdout.trim();
|
|
17
|
+
const detail = firstLine(result.stderr) ?? firstLine(result.stdout) ?? `exit ${result.status ?? "unknown"}`;
|
|
18
|
+
return { ok: result.status === 0, output, error: result.status === 0 ? null : `${command} ${args.join(" ")}: ${detail}`.slice(0, 300) };
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
return { ok: false, output: "", error: `${command} ${args.join(" ")}: ${error.message}`.slice(0, 300) };
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function diskFact(path, stat, floorPct) {
|
|
25
|
+
try {
|
|
26
|
+
const fs = stat(existsSync(path) ? path : dirname(path));
|
|
27
|
+
const free = fs.bavail * fs.bsize;
|
|
28
|
+
const total = fs.blocks * fs.bsize;
|
|
29
|
+
const valid = Number.isFinite(free) && Number.isFinite(total) && total > 0;
|
|
30
|
+
const freePct = valid ? (free / total) * 100 : null;
|
|
31
|
+
return {
|
|
32
|
+
path, free_bytes: valid ? free : null, total_bytes: valid ? total : null,
|
|
33
|
+
free_pct: freePct === null ? null : Math.round(freePct * 100) / 100,
|
|
34
|
+
floor_pct: floorPct, threshold_source: "machine cache floor",
|
|
35
|
+
status: freePct === null ? "unknown" : freePct < floorPct ? "below_floor" : "ready",
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function platformFromIdentifier(identifier, fallback) {
|
|
43
|
+
const match = /^com\.apple\.CoreSimulator\.SimRuntime\.([A-Za-z]+)-/.exec(identifier);
|
|
44
|
+
return match?.[1]?.toLowerCase() ?? fallback?.replace(/\s+Simulator$/i, "").toLowerCase() ?? "unknown";
|
|
45
|
+
}
|
|
46
|
+
function runtimesFromJson(raw, devicesRaw, stat, floorPct) {
|
|
47
|
+
let json;
|
|
48
|
+
let devices;
|
|
49
|
+
try {
|
|
50
|
+
json = JSON.parse(raw);
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return { runtimes: [], error: "simctl runtimes returned invalid JSON" };
|
|
54
|
+
}
|
|
55
|
+
let devicesValid = true;
|
|
56
|
+
try {
|
|
57
|
+
devices = JSON.parse(devicesRaw);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
devices = null;
|
|
61
|
+
devicesValid = false;
|
|
62
|
+
}
|
|
63
|
+
if (!Array.isArray(json?.runtimes))
|
|
64
|
+
return { runtimes: [], error: "simctl runtimes JSON has no runtimes list" };
|
|
65
|
+
const groups = devices?.devices && typeof devices.devices === "object" ? devices.devices : {};
|
|
66
|
+
const runtimes = json.runtimes.flatMap((value) => {
|
|
67
|
+
const identifier = typeof value?.identifier === "string" ? value.identifier : typeof value?.runtimeIdentifier === "string" ? value.runtimeIdentifier : null;
|
|
68
|
+
if (!identifier)
|
|
69
|
+
return [];
|
|
70
|
+
const runtimeDevices = Array.isArray(groups[identifier]) ? groups[identifier] : [];
|
|
71
|
+
const bundlePath = typeof value.bundlePath === "string" ? value.bundlePath : null;
|
|
72
|
+
const available = value.isAvailable === true;
|
|
73
|
+
return [{
|
|
74
|
+
platform: platformFromIdentifier(identifier, value.platform),
|
|
75
|
+
identifier,
|
|
76
|
+
version: typeof value.version === "string" ? value.version : null,
|
|
77
|
+
build: typeof value.buildversion === "string" ? value.buildversion : null,
|
|
78
|
+
available,
|
|
79
|
+
available_devices: devicesValid ? runtimeDevices.filter((device) => device?.isAvailable === true).length : null,
|
|
80
|
+
bundle_path: bundlePath,
|
|
81
|
+
disk: bundlePath ? diskFact(bundlePath, stat, floorPct) : null,
|
|
82
|
+
error: available ? null : "runtime is installed but simctl marks it unavailable",
|
|
83
|
+
}];
|
|
84
|
+
});
|
|
85
|
+
return { runtimes, error: devicesValid ? null : "simctl devices returned invalid JSON" };
|
|
86
|
+
}
|
|
87
|
+
/** Read-only macOS/Xcode facts; probes never select Xcode, install runtimes, or accept licenses. */
|
|
88
|
+
export function macReadiness(options = {}) {
|
|
89
|
+
const run = options.run ?? runDefault(options.path);
|
|
90
|
+
const stat = options.stat ?? ((path) => {
|
|
91
|
+
const fs = statfsSync(path);
|
|
92
|
+
return { bavail: fs.bavail, bsize: fs.bsize, blocks: fs.blocks };
|
|
93
|
+
});
|
|
94
|
+
const home = options.home ?? homedir();
|
|
95
|
+
const checkout = options.checkout ?? `${home}/bschat`;
|
|
96
|
+
const floorPct = Number.isInteger(options.diskFloorPct) && options.diskFloorPct >= 1 && options.diskFloorPct <= 90
|
|
97
|
+
? options.diskFloorPct
|
|
98
|
+
: DEFAULT_CACHE_FLOOR_PCT;
|
|
99
|
+
const product = commandOutput(run, "sw_vers", ["-productVersion"]);
|
|
100
|
+
const build = commandOutput(run, "sw_vers", ["-buildVersion"]);
|
|
101
|
+
const model = commandOutput(run, "sysctl", ["-n", "hw.model"]);
|
|
102
|
+
const hardwareArch = commandOutput(run, "sysctl", ["-n", "hw.machine"]);
|
|
103
|
+
const selected = commandOutput(run, "xcode-select", ["-p"]);
|
|
104
|
+
const xcodeVersion = commandOutput(run, "xcodebuild", ["-version"]);
|
|
105
|
+
const sdkList = commandOutput(run, "xcodebuild", ["-showsdks"]);
|
|
106
|
+
const license = selected.ok && xcodeVersion.ok
|
|
107
|
+
? commandOutput(run, "xcodebuild", ["-license", "check"])
|
|
108
|
+
: { ok: false, output: "", error: "cannot check Xcode license without a selected Xcode" };
|
|
109
|
+
const runtimeList = commandOutput(run, "xcrun", ["simctl", "list", "runtimes", "--json"]);
|
|
110
|
+
const deviceList = commandOutput(run, "xcrun", ["simctl", "list", "devices", "--json"]);
|
|
111
|
+
const version = /^Xcode\s+(.+)$/mi.exec(xcodeVersion.output)?.[1]?.trim() ?? null;
|
|
112
|
+
const xcodeBuild = /^Build version\s+(.+)$/mi.exec(xcodeVersion.output)?.[1]?.trim() ?? null;
|
|
113
|
+
const sdks = sdkList.ok ? sdkList.output.split(/\r?\n/).map((line) => line.trim()).filter((line) => /^.+\s+-sdk\s+\S+/i.test(line)).map((line) => line.slice(0, 200)) : [];
|
|
114
|
+
const simulatorJson = runtimeList.ok
|
|
115
|
+
? runtimesFromJson(runtimeList.output, deviceList.ok ? deviceList.output : "", stat, floorPct)
|
|
116
|
+
: { runtimes: [], error: runtimeList.error ?? "simctl runtimes probe failed" };
|
|
117
|
+
const simulatorError = !runtimeList.ok ? runtimeList.error : !deviceList.ok ? deviceList.error : simulatorJson.error;
|
|
118
|
+
const licenseAccepted = license.ok ? true : /not\s+agreed|license.{0,50}(not accepted|unaccepted)|must accept/i.test(license.error ?? "") ? false : null;
|
|
119
|
+
const xcodeReady = selected.ok && !!selected.output && xcodeVersion.ok && !!version && !!xcodeBuild && sdkList.ok && sdks.length > 0 && licenseAccepted === true;
|
|
120
|
+
const macVersion = product.ok ? firstLine(product.output) : null;
|
|
121
|
+
const machineArch = options.architecture ?? (hardwareArch.ok ? firstLine(hardwareArch.output) : null) ?? arch();
|
|
122
|
+
const homeDisk = diskFact(home, stat, floorPct);
|
|
123
|
+
const checkoutDisk = diskFact(checkout, stat, floorPct);
|
|
124
|
+
const buildRefusals = [volumeRefusal("home", homeDisk), volumeRefusal("checkout/build", checkoutDisk)].filter((value) => value !== null);
|
|
125
|
+
const simulatorRefusals = [...buildRefusals, ...simulatorJson.runtimes.flatMap((runtime) => {
|
|
126
|
+
if (!runtime.available || runtime.disk?.status === "ready")
|
|
127
|
+
return [];
|
|
128
|
+
return [volumeRefusal(`${runtime.platform} ${runtime.version ?? runtime.identifier} simulator runtime`, runtime.disk)];
|
|
129
|
+
})];
|
|
130
|
+
return {
|
|
131
|
+
product_version: macVersion,
|
|
132
|
+
product_build: build.ok ? firstLine(build.output) : null,
|
|
133
|
+
model: model.ok ? firstLine(model.output) : null,
|
|
134
|
+
architecture: machineArch,
|
|
135
|
+
developer_directory: selected.ok ? firstLine(selected.output) : null,
|
|
136
|
+
developer_directory_ok: selected.ok && !!selected.output,
|
|
137
|
+
xcode: { version, build: xcodeBuild, sdks, license_accepted: licenseAccepted, ready: xcodeReady, error: !xcodeReady ? [selected.error, xcodeVersion.error, sdkList.error, license.error, licenseAccepted === false ? "Xcode license is not accepted (accept it interactively as the machine owner)" : null].filter(Boolean).join("; ").slice(0, 500) || "selected Xcode is incomplete" : null },
|
|
138
|
+
simulators: { probe_ok: runtimeList.ok && deviceList.ok && !simulatorJson.error, runtimes: simulatorJson.runtimes, error: simulatorError },
|
|
139
|
+
disk: { home: homeDisk, checkout_build: checkoutDisk },
|
|
140
|
+
disk_policy: { floor_pct: floorPct, source: "machine cache floor" },
|
|
141
|
+
readiness_refusals: { build: buildRefusals, simulators: simulatorRefusals },
|
|
142
|
+
capabilities: {
|
|
143
|
+
mac: { ok: !!macVersion, version: macVersion },
|
|
144
|
+
architecture: { ok: !!machineArch, version: machineArch },
|
|
145
|
+
xcode: { ok: xcodeReady && buildRefusals.length === 0, version },
|
|
146
|
+
simulators: simulatorJson.runtimes.map((runtime) => ({ platform: runtime.platform, runtime: runtime.identifier, ok: xcodeReady && simulatorJson.error === null && runtime.available && runtime.disk?.status === "ready" && buildRefusals.length === 0, version: runtime.version, build: runtime.build })),
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function volumeRefusal(name, disk) {
|
|
151
|
+
if (disk?.status === "ready")
|
|
152
|
+
return null;
|
|
153
|
+
const reason = disk?.status === "below_floor"
|
|
154
|
+
? `${disk.free_pct}% free is below the machine cache floor`
|
|
155
|
+
: "free space is unknown against the machine cache floor";
|
|
156
|
+
return `refuse new ${name.includes("simulator runtime") ? "simulator" : "build/simulator"} work: ${name} ${reason} ${disk?.floor_pct ?? DEFAULT_CACHE_FLOOR_PCT}% (source: ${disk?.threshold_source ?? "machine cache floor"})`;
|
|
157
|
+
}
|
|
158
|
+
function diskReadinessDetail(name, disk) {
|
|
159
|
+
const refusal = volumeRefusal(name, disk);
|
|
160
|
+
if (refusal)
|
|
161
|
+
return refusal;
|
|
162
|
+
return `${disk.free_pct}% free (${Math.round(disk.free_bytes / 1e9)} GB of ${Math.round(disk.total_bytes / 1e9)} GB), above machine cache floor ${disk.floor_pct}% (source: ${disk.threshold_source})`;
|
|
163
|
+
}
|
|
164
|
+
export function macReadinessSteps(facts) {
|
|
165
|
+
const steps = [
|
|
166
|
+
{ step: "macOS", result: facts.capabilities.mac.ok ? "ok" : "failed", detail: facts.product_version ? `${facts.product_version} (${facts.product_build ?? "build unknown"}), ${facts.model ?? "model unknown"}, ${facts.architecture}` : "macOS version probe failed" },
|
|
167
|
+
{ step: "Xcode selection", result: facts.developer_directory_ok ? "ok" : "failed", detail: facts.developer_directory ?? "xcode-select has no valid developer directory; select one as the machine owner" },
|
|
168
|
+
{ step: "Xcode readiness", result: facts.xcode.ready ? "ok" : "failed", detail: facts.xcode.ready ? `Xcode ${facts.xcode.version} (${facts.xcode.build}); SDKs ${facts.xcode.sdks.join(", ")}; license accepted` : facts.xcode.error ?? "Xcode is not ready" },
|
|
169
|
+
{ step: "simulator runtimes", result: facts.xcode.ready && facts.simulators.probe_ok && facts.simulators.runtimes.some((runtime) => runtime.available && runtime.disk?.status === "ready" && facts.readiness_refusals.build.length === 0) ? "ok" : "failed", detail: `${facts.xcode.ready ? "" : `blocked: Xcode is not ready (${facts.xcode.error ?? "readiness probe failed"}); `}${facts.simulators.runtimes.length ? facts.simulators.runtimes.map((runtime) => `${runtime.platform} ${runtime.version ?? "version unknown"} (${runtime.build ?? "build unknown"}) ${runtime.available ? runtime.disk?.status === "ready" && facts.readiness_refusals.build.length === 0 ? `available; runtime volume ${runtime.disk.free_pct}% free vs ${runtime.disk.floor_pct}% machine cache floor` : volumeRefusal(`${runtime.platform} ${runtime.version ?? runtime.identifier} simulator runtime`, runtime.disk) ?? "build volumes below machine cache floor" : "unavailable"}`).join("; ") : "no simulator runtimes are installed"}${facts.simulators.error ? `; ${facts.simulators.error}` : ""}` },
|
|
170
|
+
{ step: "Mac disk", result: facts.readiness_refusals.build.length === 0 ? "ok" : "failed", detail: `home: ${diskReadinessDetail("home", facts.disk.home)}; checkout/build: ${diskReadinessDetail("checkout/build", facts.disk.checkout_build)}` },
|
|
171
|
+
];
|
|
172
|
+
return steps;
|
|
173
|
+
}
|