benignswarm 0.12.166 → 0.12.168
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/antigravity.js +10 -6
- package/dist/args.js +5 -3
- package/dist/client.js +10 -7
- package/dist/command-flags.js +1 -1
- package/dist/commands/admin.js +10 -1
- package/dist/commands/gh.js +18 -1
- package/dist/commands/health.js +44 -0
- package/dist/commands/machine-admin.js +9 -0
- package/dist/commands/machine.js +71 -0
- package/dist/commands/mock.js +115 -2
- package/dist/commands/operator.js +1 -1
- package/dist/commands/ux.js +13 -4
- package/dist/commands/watch.js +44 -10
- package/dist/commands/worktrees.js +9 -3
- package/dist/commands/wu.js +101 -16
- package/dist/gate-quarantines.js +76 -0
- package/dist/gate-test-reports.js +50 -0
- package/dist/git.js +47 -1
- package/dist/harnesses.js +22 -2
- package/dist/heartbeat.js +11 -1
- package/dist/help.js +16 -7
- package/dist/index.js +2 -0
- package/dist/jsonl.js +113 -0
- package/dist/macos-readiness.js +128 -0
- package/dist/merge-train.js +50 -61
- package/dist/scoped-gate.js +393 -0
- package/dist/state.js +9 -0
- package/dist/usage.js +88 -56
- package/dist/ux-jobs.js +47 -20
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/antigravity.js
CHANGED
|
@@ -6,6 +6,7 @@ import { basename, delimiter, dirname, isAbsolute, join, resolve, sep } from "no
|
|
|
6
6
|
import { configRoot } from "./config.js";
|
|
7
7
|
import { repoDirectory } from "./directories.js";
|
|
8
8
|
import { CliError } from "./errors.js";
|
|
9
|
+
import { readJsonlRecords } from "./jsonl.js";
|
|
9
10
|
import { gitSandboxDeniedPaths, gitSandboxReadablePaths, gitSandboxWorktreeMetadataPath, gitSandboxWritablePaths, sandboxProbeWorktreeAdminPath } from "./git-sandbox-paths.js";
|
|
10
11
|
export const ANTIGRAVITY_SETTINGS_PLACEHOLDER = "__B9S_ANTIGRAVITY_TURN_SETTINGS__";
|
|
11
12
|
export function isAntigravityWorkspaceWrite(env = process.env) {
|
|
@@ -294,12 +295,15 @@ export function antigravityProbe(session, ref, logPath = antigravityLog(ref), co
|
|
|
294
295
|
}
|
|
295
296
|
export function antigravityUsage(path, since, until) {
|
|
296
297
|
const from = Date.parse(since), to = Date.parse(until);
|
|
297
|
-
const rows = agyRecords(path).filter((record) => Date.parse(record.started_at) >= from && Date.parse(record.started_at) <= to && record.result?.usage);
|
|
298
|
-
if (!rows.length)
|
|
299
|
-
return null;
|
|
300
298
|
const totals = { input: 0, cached_input: 0, output: 0, reasoning: 0, total: 0 };
|
|
301
|
-
|
|
302
|
-
|
|
299
|
+
let found = false;
|
|
300
|
+
for (const row of readJsonlRecords(path)) {
|
|
301
|
+
const record = row;
|
|
302
|
+
const at = Date.parse(record.started_at);
|
|
303
|
+
const usage = record.result?.usage;
|
|
304
|
+
if (!Number.isFinite(at) || at < from || at > to || !usage)
|
|
305
|
+
continue;
|
|
306
|
+
found = true;
|
|
303
307
|
const cached = usage.cache_read_tokens ?? 0;
|
|
304
308
|
totals.input += (usage.input_tokens ?? 0) + cached;
|
|
305
309
|
totals.cached_input += cached;
|
|
@@ -307,7 +311,7 @@ export function antigravityUsage(path, since, until) {
|
|
|
307
311
|
totals.reasoning += usage.thinking_tokens ?? 0;
|
|
308
312
|
totals.total += antigravityTotalTokens(usage) ?? 0;
|
|
309
313
|
}
|
|
310
|
-
return totals;
|
|
314
|
+
return found ? totals : null;
|
|
311
315
|
}
|
|
312
316
|
export function appendAntigravityRawResult(path, output, exitCode, expectedConversation) {
|
|
313
317
|
const result = parseAntigravityJson(output);
|
package/dist/args.js
CHANGED
|
@@ -16,7 +16,7 @@ export const STRING_FLAGS = [
|
|
|
16
16
|
"parent", "parent-item", "channel", "statuses", "assign", "if-status", "status", "exec", "interval",
|
|
17
17
|
"requeue-after", "unacked-after", "category", "command", "command-pattern", "follow-delay", "startup-jitter-seconds", "env", "scope",
|
|
18
18
|
"session-harness", "session-sandbox", "session-machine", "session-machine-label", "scope-file", "scope-from", "append", "pr", "note", "note-file", "add", "remove", "merged", "tag",
|
|
19
|
-
"activity", "max-unanswered", "to", "replay-of", "branch", "base", "effort", "max-budget-usd", "by", "target", "lands-with",
|
|
19
|
+
"activity", "max-unanswered", "to", "replay-of", "branch", "base", "effort", "max-budget-usd", "by", "target", "lands-with", "group", "study",
|
|
20
20
|
"milestone", "file", "exit", "depends-on", "default-tags", "source", "on", "partial", "question", "ruling",
|
|
21
21
|
"gaps", "unit", "units", "blocks", "sla", "takeover", "stall", "max-open", "max-in-progress", "require-scope",
|
|
22
22
|
"require-evidence", "default-approver", "merged-by", "integrator-role", "require-rebased", "require-merge-commit",
|
|
@@ -32,6 +32,7 @@ export const STRING_FLAGS = [
|
|
|
32
32
|
"instance-id", "machine-id", "machine-name", "node-sha256", "node-version", "path", "recipe-version", "region",
|
|
33
33
|
"root", "signing-key", "catalog", "context", "context-action", "context-checkpoint-ref", "context-old-thread", "context-new-thread", "source-commit", "component", "normalized-key",
|
|
34
34
|
"drain-timeout", "on-running-turn", "extend", "ssh-config", "poll-ms",
|
|
35
|
+
"override-reason",
|
|
35
36
|
"stage", "machines", "resolved-retention-days", "wont-fix-retention-days", "alert-cooldown-minutes", "alerts", "confirm-force",
|
|
36
37
|
"machine-session-id", "harness-binary", "pool-sessions", "registry", "detail", "worktree", "turn-claude-runtime", "turn-antigravity-runtime",
|
|
37
38
|
"purpose", "storage-mode", "hosts", "arn", "version-id", "kms-key",
|
|
@@ -43,8 +44,9 @@ export const BOOL_FLAGS = [
|
|
|
43
44
|
"latest", "no-restart", "json", "follow", "account", "help", "version", "broadcast", "create-channels",
|
|
44
45
|
"read-account-status", "replace-key", "mentions-me", "no-skill", "replace", "template", "scope-only", "unread",
|
|
45
46
|
"clear-session", "pending", "force", "no-hooks", "yes", "open", "bind-here", "peek", "once", "launchd", "full", "no-bind", "log",
|
|
46
|
-
"all", "here", "keep-worktree", "prune", "abandon", "defer", "hold", "clear", "met", "shared", "archive",
|
|
47
|
+
"all", "here", "keep-worktree", "prune", "abandon", "defer", "hold", "review-hold", "clear", "met", "shared", "archive",
|
|
47
48
|
"approve", "turn", "service", "print-hooks", "create", "rotate", "drain", "codex-userns", "bwrap-userns", "agy-userns", "print-apparmor", "overdue",
|
|
49
|
+
"override-unwakeable",
|
|
48
50
|
"cancel", "rerun", "confirmed", "refuted", "no-source", "confirm-bypass-signal", "assessment-only", "continue",
|
|
49
51
|
"no-wait-verify", "preview", "remove-empty", "dry-run", "quota-substitution", "auto-merge",
|
|
50
52
|
"in-container", "retrieve-ec2", "stdin", "context-confirmed", "confirm-compatible", "move-provisioned", "provisioned", "no-commits-beyond-target", "train",
|
|
@@ -63,7 +65,7 @@ export function parse(argv) {
|
|
|
63
65
|
// replacement command needs its value. Resolve that spelling by command.
|
|
64
66
|
if (argv[0] === "wu" && argv[1] === "reviewer")
|
|
65
67
|
options.replace = { type: "string" };
|
|
66
|
-
if ((argv[0] === "mock" || argv[0] === "design-study") && argv[1] === "gaps")
|
|
68
|
+
if ((argv[0] === "mock" || argv[0] === "design-study") && (argv[1] === "gaps" || argv[1] === "review" && (argv[2] === "gaps" || argv[2] === "propose")))
|
|
67
69
|
options.json = { type: "string" };
|
|
68
70
|
try {
|
|
69
71
|
const seen = new Set();
|
package/dist/client.js
CHANGED
|
@@ -537,14 +537,17 @@ export class Client {
|
|
|
537
537
|
throw new CliError(err.error ?? `http_${res.status}`, err.message ?? text, hint, res.status);
|
|
538
538
|
}
|
|
539
539
|
const allowsRedactedExcerpt = upperMethod === "POST" && /^\/agents\/me\/sessions\/[^/]+\/turns\/[^/]+\/complete(?:\?|$)/.test(path);
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
540
|
+
const isScopedGateReceipt = upperMethod === "POST" && /^\/projects\/[^/]+\/work-units\/\d+\/scoped-gate-receipts(?:\?|$)/.test(path);
|
|
541
|
+
if (!isScopedGateReceipt) {
|
|
542
|
+
try {
|
|
543
|
+
verifyTextReceipts(json, body, expectedTextReceiptFields(method, path, body, json), allowsRedactedExcerpt ? ["excerpt"] : [], allowsRedactedExcerpt ? ["excerpt"] : [], expectedStoredText(method, path, body, json));
|
|
544
|
+
}
|
|
545
|
+
catch (error) {
|
|
546
|
+
if (res.status >= 200 && res.status < 300 && error instanceof CliError && !isRead) {
|
|
547
|
+
throw new WrittenReceiptMismatchError(json, error);
|
|
548
|
+
}
|
|
549
|
+
throw error;
|
|
546
550
|
}
|
|
547
|
-
throw error;
|
|
548
551
|
}
|
|
549
552
|
return json;
|
|
550
553
|
}
|
package/dist/command-flags.js
CHANGED
|
@@ -6,7 +6,7 @@ const INHERITED_OPTION_CONTRACTS = new Map([["codex start", ["start"]]]);
|
|
|
6
6
|
const PROJECT_COMMANDS = new Set([
|
|
7
7
|
"mock", "design-study", "flow-agent", "notice", "who", "send", "read", "channel", "agents", "activity", "feed", "evidence", "retire", "handoffs", "lists", "list", "item",
|
|
8
8
|
"wu", "process", "record", "milestones", "milestone", "lock", "unlock", "locks", "ask", "ask-operator",
|
|
9
|
-
"explain", "worktrees", "measures", "measure", "environment", "test-results", "ux", "gate",
|
|
9
|
+
"explain", "worktrees", "measures", "measure", "environment", "test-results", "ux", "gate", "health",
|
|
10
10
|
]);
|
|
11
11
|
function supportsProject(command) {
|
|
12
12
|
return PROJECT_COMMANDS.has(command[0] ?? "") || (command[0] === "status" && command[1] === "history");
|
package/dist/commands/admin.js
CHANGED
|
@@ -18,6 +18,7 @@ import { cloudAdmin } from "./cloud-admin.js";
|
|
|
18
18
|
import { projectImageAdmin } from "./image-admin.js";
|
|
19
19
|
import { environmentAdmin } from "./environment-admin.js";
|
|
20
20
|
import { flowAdmin } from "./flow.js";
|
|
21
|
+
import { healthAdmin } from "./health.js";
|
|
21
22
|
import { projectSecrets } from "./project-secrets.js";
|
|
22
23
|
import { standingRuleAdmin } from "./standing-rules.js";
|
|
23
24
|
import { diagAdmin } from "./diag-admin.js";
|
|
@@ -137,6 +138,8 @@ export async function admin(p, out) {
|
|
|
137
138
|
return needsAdmin(p, out, action);
|
|
138
139
|
case "flow":
|
|
139
140
|
return flowAdmin(action, rest, p, out);
|
|
141
|
+
case "health":
|
|
142
|
+
return healthAdmin(action, rest, p, out);
|
|
140
143
|
case "diag":
|
|
141
144
|
return diagAdmin(action, rest, p, out);
|
|
142
145
|
case "notice":
|
|
@@ -699,7 +702,13 @@ async function workUnitAdmin(action, rest, p, out) {
|
|
|
699
702
|
if (!to)
|
|
700
703
|
throw new CliError("usage", 'b9s-admin wu assign <project> <n> --to <agent> [--reason "why"]');
|
|
701
704
|
const reason = str(p.flags, "reason");
|
|
702
|
-
const
|
|
705
|
+
const overrideWakeability = bool(p.flags, "override-unwakeable");
|
|
706
|
+
const overrideReason = str(p.flags, "override-reason");
|
|
707
|
+
if (overrideWakeability && !overrideReason?.trim())
|
|
708
|
+
throw new CliError("usage", '--override-unwakeable requires --override-reason "why this unavailable target must receive work"');
|
|
709
|
+
if (overrideReason !== undefined && !overrideWakeability)
|
|
710
|
+
throw new CliError("usage", "--override-reason requires --override-unwakeable");
|
|
711
|
+
const r = await adminClient(p).call("POST", `/projects/${rest[0]}/work-units/${Number(rest[1])}/assign`, { to, ...(reason === undefined ? {} : { reason }), ...(overrideWakeability ? { override_unwakeable: true, override_reason: overrideReason } : {}) });
|
|
703
712
|
out.print(`WU #${r.unit.number} reassigned to ${r.unit.owner_name || r.unit.preferred_name}${r.unit.status === "queued" ? "; queued until they are free" : ""}.`, r);
|
|
704
713
|
}
|
|
705
714
|
async function channel(action, rest, p, out) {
|
package/dist/commands/gh.js
CHANGED
|
@@ -77,6 +77,10 @@ const GH_COMMAND_OPTIONS = {
|
|
|
77
77
|
values: new Set(["--json", "--jq", "--template"]),
|
|
78
78
|
booleans: new Set(),
|
|
79
79
|
},
|
|
80
|
+
"pr edit": {
|
|
81
|
+
values: new Set(["--add-label"]),
|
|
82
|
+
booleans: new Set(),
|
|
83
|
+
},
|
|
80
84
|
"run view": { values: new Set(["--job", "--json"]), booleans: new Set(["--log-failed"]) },
|
|
81
85
|
"run download": { values: new Set(["-n", "-p", "-D"]), booleans: new Set() },
|
|
82
86
|
"run list": { values: new Set(["--branch", "--commit", "--limit", "--json"]), booleans: new Set() },
|
|
@@ -145,6 +149,17 @@ function validateGhOperation(args, linkedRepository, env) {
|
|
|
145
149
|
if ((operation === "pr view" || operation === "pr checks") && positional.some((value) => !pullRequestTarget(value, linkedRepository))) {
|
|
146
150
|
throw new CliError("github_repository_mismatch", "b9s gh accepts only a pull request number or a github.com URL in the linked repository.");
|
|
147
151
|
}
|
|
152
|
+
if (operation === "pr edit") {
|
|
153
|
+
if (positional.length !== 1) {
|
|
154
|
+
throw new CliError("github_target_unsupported", "b9s gh pr edit requires one pull request number or URL in the linked repository.");
|
|
155
|
+
}
|
|
156
|
+
if (!pullRequestTarget(positional[0], linkedRepository))
|
|
157
|
+
throw new CliError("github_repository_mismatch", "b9s gh accepts only a pull request number or a github.com URL in the linked repository.");
|
|
158
|
+
const label = seen.get("--add-label");
|
|
159
|
+
if (label !== "ci" && label !== "workflow") {
|
|
160
|
+
throw new CliError("github_label_unsupported", "b9s gh pr edit can add only the allowlisted labels: ci, workflow.");
|
|
161
|
+
}
|
|
162
|
+
}
|
|
148
163
|
if (positional.length > 1 || (operation === "pr status" && positional.length !== 0)) {
|
|
149
164
|
throw new CliError("github_target_unsupported", `b9s gh ${operation} accepts at most one pull request target.`);
|
|
150
165
|
}
|
|
@@ -199,7 +214,9 @@ export async function runGhWithProjectCredential(args, cwd, api, runner = run, p
|
|
|
199
214
|
}
|
|
200
215
|
validateGhOperation(args, repository.path, parentEnv);
|
|
201
216
|
const needsActionsRead = args[0] === "run";
|
|
202
|
-
const
|
|
217
|
+
const needsPullRequestWrite = args[0] === "pr" && args[1] === "edit";
|
|
218
|
+
const requiredPermission = needsActionsRead ? "actions:read" : needsPullRequestWrite ? "pull_requests:write" : undefined;
|
|
219
|
+
const credential = await githubCredentialForRepository(repository.path, api, true, requiredPermission);
|
|
203
220
|
if (!credential?.password)
|
|
204
221
|
throw new CliError("github_credential_missing", "The linked repository did not return a GitHub credential.");
|
|
205
222
|
// The scoped installation token exists only in the gh child's environment. It is never
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { str } from "../args.js";
|
|
2
|
+
import { Client } from "../client.js";
|
|
3
|
+
import { loadAdmin, loadAgent, resolveAdminName, resolveAgentName } from "../config.js";
|
|
4
|
+
import { CliError } from "../errors.js";
|
|
5
|
+
import { projectOf } from "./agent.js";
|
|
6
|
+
export function formatHealthText(data) {
|
|
7
|
+
const scopeLabel = data.project ? `project ${data.project.name}` : "account";
|
|
8
|
+
const lines = [
|
|
9
|
+
`Machinery health · ${scopeLabel} · overall: ${data.overall} (checked ${data.generated_at})`,
|
|
10
|
+
];
|
|
11
|
+
for (const component of data.components) {
|
|
12
|
+
const status = component.status;
|
|
13
|
+
const since = component.since ? ` · since ${component.since}` : "";
|
|
14
|
+
const cause = component.cause ? ` · ${component.cause}` : "";
|
|
15
|
+
lines.push(` [${status}] ${component.label}${since}${cause}`);
|
|
16
|
+
}
|
|
17
|
+
return lines.join("\n");
|
|
18
|
+
}
|
|
19
|
+
export async function health(p, out) {
|
|
20
|
+
if (p.positionals.length > 1) {
|
|
21
|
+
throw new CliError("usage", "b9s health [--project <p>] [--json]");
|
|
22
|
+
}
|
|
23
|
+
const agentName = resolveAgentName(str(p.flags, "as"));
|
|
24
|
+
const creds = loadAgent(agentName);
|
|
25
|
+
const client = Client.forAgent(creds, undefined);
|
|
26
|
+
const explicitProject = str(p.flags, "project");
|
|
27
|
+
const project = explicitProject !== undefined ? projectOf(p, creds) : creds.project ?? undefined;
|
|
28
|
+
const path = project ? `/projects/${encodeURIComponent(project)}/health` : "/account/machinery-health";
|
|
29
|
+
const data = await client.call("GET", path);
|
|
30
|
+
out.print(formatHealthText(data), data);
|
|
31
|
+
}
|
|
32
|
+
export async function healthAdmin(action, rest, p, out) {
|
|
33
|
+
if (action || rest.length) {
|
|
34
|
+
throw new CliError("usage", "b9s-admin health [--project <p>] [--json]");
|
|
35
|
+
}
|
|
36
|
+
const project = str(p.flags, "project");
|
|
37
|
+
if (project !== undefined && !project.trim()) {
|
|
38
|
+
throw new CliError("usage", "--project must be a non-empty project name");
|
|
39
|
+
}
|
|
40
|
+
const client = Client.forAdmin(loadAdmin(resolveAdminName(str(p.flags, "admin"))));
|
|
41
|
+
const path = project ? `/projects/${encodeURIComponent(project)}/health` : "/account/machinery-health";
|
|
42
|
+
const data = await client.call("GET", path);
|
|
43
|
+
out.print(formatHealthText(data), data);
|
|
44
|
+
}
|
|
@@ -97,6 +97,15 @@ export function machineMacLines(macos) {
|
|
|
97
97
|
lines.push(` Xcode readiness: ${macos.xcode?.error ?? "not ready"}`);
|
|
98
98
|
if (!macos.simulators?.probe_ok)
|
|
99
99
|
lines.push(` simulator probe: ${macos.simulators?.error ?? "not ready"}`);
|
|
100
|
+
if (macos.signing_identity && typeof macos.signing_identity === "object") {
|
|
101
|
+
const s = macos.signing_identity;
|
|
102
|
+
if (s.status === "available") {
|
|
103
|
+
lines.push(` signing identity: ${s.name}${s.team_id ? ` (team ${s.team_id})` : ""}, certificate ${s.expires_at ? `expires ${s.expires_at}` : `expiry unavailable (${s.expiry_reason ?? "unknown"})`}`);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
lines.push(` signing identity: unavailable (${s.reason ?? "not reported"})`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
100
109
|
return lines;
|
|
101
110
|
}
|
|
102
111
|
export function machineGitLines(gitFacts) {
|
package/dist/commands/machine.js
CHANGED
|
@@ -145,6 +145,7 @@ export function startArgs(s, thread, writable = [], startupJitterSeconds) {
|
|
|
145
145
|
const KEY_CHECK_MS = 10 * 60_000;
|
|
146
146
|
const CAPABILITY_PROBE_MS = 60 * 60_000;
|
|
147
147
|
const lastCapabilityProbe = new Map();
|
|
148
|
+
const lastMacCapabilityReportHash = new Map();
|
|
148
149
|
const WORKTREE_PRUNE_INTERVAL_MS = 60 * 60_000;
|
|
149
150
|
const WORKTREE_PRUNE_PRESSURE_INTERVAL_MS = 15 * 60_000;
|
|
150
151
|
const WORKTREE_PRUNE_TIMEOUT_MS = 2 * 60_000;
|
|
@@ -2244,6 +2245,10 @@ export async function reconcile(m, log, reportIntervalSeconds = 30, deps) {
|
|
|
2244
2245
|
for (const item of probedProjects) {
|
|
2245
2246
|
lastCapabilityProbe.set(item.id, { at: Date.now(), signature: item.signature });
|
|
2246
2247
|
}
|
|
2248
|
+
const macosFacts = facts.macos;
|
|
2249
|
+
if (macosFacts) {
|
|
2250
|
+
await maybeReportMacCapabilities(client, m.name, macosFacts, log);
|
|
2251
|
+
}
|
|
2247
2252
|
const warning = diskSpaceNotice(homeSpace, workSpace);
|
|
2248
2253
|
if (warning !== undefined)
|
|
2249
2254
|
await client.call("PUT", "/machines/me/notices/disk", { text: warning });
|
|
@@ -2290,6 +2295,72 @@ export async function reconcile(m, log, reportIntervalSeconds = 30, deps) {
|
|
|
2290
2295
|
await resumePromise;
|
|
2291
2296
|
return { sessions: out, report };
|
|
2292
2297
|
}
|
|
2298
|
+
/** Build the strict allowlisted PUT /machines/me/mac-capabilities payload from a MacReadiness probe. */
|
|
2299
|
+
export function buildMacCapabilityReportPayload(macos, probeVersion = CLI_VERSION) {
|
|
2300
|
+
if (!macos.product_version ||
|
|
2301
|
+
!macos.product_build ||
|
|
2302
|
+
(macos.architecture !== "arm64" && macos.architecture !== "x86_64") ||
|
|
2303
|
+
!macos.model ||
|
|
2304
|
+
!macos.xcode?.version ||
|
|
2305
|
+
!macos.xcode?.build) {
|
|
2306
|
+
return null;
|
|
2307
|
+
}
|
|
2308
|
+
const disk = {};
|
|
2309
|
+
if (typeof macos.disk?.home?.free_bytes === "number")
|
|
2310
|
+
disk.home_free_bytes = Math.floor(macos.disk.home.free_bytes);
|
|
2311
|
+
if (typeof macos.disk?.checkout_build?.free_bytes === "number")
|
|
2312
|
+
disk.worktree_free_bytes = Math.floor(macos.disk.checkout_build.free_bytes);
|
|
2313
|
+
if (typeof macos.disk?.checkout_build?.total_bytes === "number")
|
|
2314
|
+
disk.total_bytes = Math.floor(macos.disk.checkout_build.total_bytes);
|
|
2315
|
+
const simulatorFree = macos.simulators?.runtimes.find((r) => typeof r.disk?.free_bytes === "number")?.disk?.free_bytes;
|
|
2316
|
+
if (typeof simulatorFree === "number")
|
|
2317
|
+
disk.simulator_free_bytes = Math.floor(simulatorFree);
|
|
2318
|
+
const capabilities = {
|
|
2319
|
+
macos_product_version: macos.product_version,
|
|
2320
|
+
macos_build: macos.product_build,
|
|
2321
|
+
architecture: macos.architecture,
|
|
2322
|
+
model: macos.model,
|
|
2323
|
+
...(macos.developer_directory ? { developer_directory: macos.developer_directory } : {}),
|
|
2324
|
+
xcode_version: macos.xcode.version,
|
|
2325
|
+
xcode_build: macos.xcode.build,
|
|
2326
|
+
license_accepted: macos.xcode.license_accepted === true,
|
|
2327
|
+
sdks: macos.xcode.sdks.slice(0, 100),
|
|
2328
|
+
simulator_runtimes: macos.simulators.runtimes
|
|
2329
|
+
.map((runtime) => `${runtime.platform} ${runtime.version ?? "unknown"}${runtime.build ? ` (${runtime.build})` : ""}`.slice(0, 200))
|
|
2330
|
+
.slice(0, 100),
|
|
2331
|
+
...(Object.keys(disk).length ? { disk } : {}),
|
|
2332
|
+
checks: {
|
|
2333
|
+
developer_directory_selected: macos.developer_directory_ok,
|
|
2334
|
+
xcode_license_accepted: macos.xcode.license_accepted === true,
|
|
2335
|
+
disk_ready: macos.readiness_refusals.build.length === 0,
|
|
2336
|
+
},
|
|
2337
|
+
signing_identity: macos.signing_identity,
|
|
2338
|
+
};
|
|
2339
|
+
return { probe_version: `cli-${probeVersion}`.slice(0, 100), capabilities };
|
|
2340
|
+
}
|
|
2341
|
+
/** Submit PUT /machines/me/mac-capabilities from a Mac daemon whenever its probe output changes. */
|
|
2342
|
+
export async function maybeReportMacCapabilities(client, machineKey, macos, log, probeVersion = CLI_VERSION) {
|
|
2343
|
+
const payload = buildMacCapabilityReportPayload(macos, probeVersion);
|
|
2344
|
+
if (!payload)
|
|
2345
|
+
return false;
|
|
2346
|
+
const serialized = JSON.stringify(payload);
|
|
2347
|
+
const digest = createHash("sha256").update(serialized).digest("hex");
|
|
2348
|
+
if (lastMacCapabilityReportHash.get(machineKey) === digest)
|
|
2349
|
+
return false;
|
|
2350
|
+
try {
|
|
2351
|
+
await client.call("PUT", "/machines/me/mac-capabilities", payload, { retryForMs: MACHINE_NETWORK_RETRY_MS });
|
|
2352
|
+
lastMacCapabilityReportHash.set(machineKey, digest);
|
|
2353
|
+
const idSummary = macos.signing_identity.status === "available"
|
|
2354
|
+
? `${macos.signing_identity.name}${macos.signing_identity.expires_at ? ` (expires ${macos.signing_identity.expires_at})` : ""}`
|
|
2355
|
+
: `unavailable (${macos.signing_identity.reason ?? "unknown"})`;
|
|
2356
|
+
log(`reported Mac capabilities (${macos.xcode.version}; signing identity ${idSummary})`);
|
|
2357
|
+
return true;
|
|
2358
|
+
}
|
|
2359
|
+
catch (error) {
|
|
2360
|
+
log(`Mac capability report upload failed safely: ${error.message}`);
|
|
2361
|
+
return false;
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2293
2364
|
export async function answerWorktreeProcessQueries(client, desired, queries, log, scan = scanWorktreeProcesses) {
|
|
2294
2365
|
for (const query of queries) {
|
|
2295
2366
|
try {
|
package/dist/commands/mock.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { str } from "../args.js";
|
|
2
2
|
import { Client } from "../client.js";
|
|
3
3
|
import { loadAgent, resolveAgentName, resolveModel } from "../config.js";
|
|
4
|
+
import { consoleLink } from "../console-links.js";
|
|
4
5
|
import { CliError, WrittenReceiptMismatchError } from "../errors.js";
|
|
5
6
|
import { projectOf } from "./agent.js";
|
|
6
7
|
import { evidence } from "./evidence.js";
|
|
7
8
|
export async function mock(p, out) {
|
|
8
|
-
const [, sub,
|
|
9
|
+
const [, sub, ...args] = p.positionals;
|
|
10
|
+
if (sub === "review")
|
|
11
|
+
return platformReview(args, p, out);
|
|
12
|
+
const [study, variant, file] = args;
|
|
9
13
|
if (sub !== "upload" && sub !== "gaps")
|
|
10
|
-
throw new CliError("usage", "mock upload <studyId> <variantId> <file.html> [--summary text] | mock gaps <studyId> --json <gapsJson> | --clear");
|
|
14
|
+
throw new CliError("usage", "mock upload <studyId> <variantId> <file.html> [--summary text] | mock gaps <studyId> --json <gapsJson> | --clear | mock review show --group <id> | --study <id> | mock review gaps|propose <reviewId> --json <array> | mock review revise <reviewId>");
|
|
11
15
|
if (!study)
|
|
12
16
|
throw new CliError("usage", "studyId is required");
|
|
13
17
|
if (sub === "upload" && (!variant || !file || p.positionals.length !== 5))
|
|
@@ -62,3 +66,112 @@ export async function mock(p, out) {
|
|
|
62
66
|
throw new CliError("attach_failed", `Mock evidence:${id} was uploaded, but attachment failed: ${error.message}`);
|
|
63
67
|
}
|
|
64
68
|
}
|
|
69
|
+
function jsonArray(raw, flag) {
|
|
70
|
+
if (!raw)
|
|
71
|
+
throw new CliError("usage", `--json must be a JSON array of ${flag}`);
|
|
72
|
+
let value;
|
|
73
|
+
try {
|
|
74
|
+
value = JSON.parse(raw);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
throw new CliError("usage", `--json must be a JSON array of ${flag}`);
|
|
78
|
+
}
|
|
79
|
+
if (!Array.isArray(value))
|
|
80
|
+
throw new CliError("usage", `--json must be a JSON array of ${flag}`);
|
|
81
|
+
return value;
|
|
82
|
+
}
|
|
83
|
+
function assertUniqueGapTitles(gaps) {
|
|
84
|
+
const titles = new Set();
|
|
85
|
+
for (const gap of gaps) {
|
|
86
|
+
if (!gap || typeof gap !== "object" || typeof gap.title !== "string")
|
|
87
|
+
throw new CliError("usage", "each gap needs a title and description");
|
|
88
|
+
const title = gap.title.trim().toLocaleLowerCase().replace(/\s+/g, " ");
|
|
89
|
+
if (!title)
|
|
90
|
+
throw new CliError("usage", "each gap needs a title and description");
|
|
91
|
+
if (titles.has(title))
|
|
92
|
+
throw new CliError("usage", `duplicate platform gap title: ${gap.title}`);
|
|
93
|
+
titles.add(title);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
async function platformReview(args, p, out) {
|
|
97
|
+
const [action, reviewId] = args;
|
|
98
|
+
const usage = "mock review show --group <groupId> | --study <studyId> | mock review gaps <reviewId> --json <gapsArray> | mock review propose <reviewId> --json <proposalsArray> | mock review revise <reviewId>";
|
|
99
|
+
if (!action)
|
|
100
|
+
throw new CliError("usage", usage);
|
|
101
|
+
const name = resolveAgentName(str(p.flags, "as"));
|
|
102
|
+
const creds = loadAgent(name);
|
|
103
|
+
const client = Client.forAgent(creds, resolveModel(str(p.flags, "model"), process.env, process.cwd(), name));
|
|
104
|
+
const project = projectOf(p, creds);
|
|
105
|
+
const reviews = `/projects/${encodeURIComponent(project)}/design-platform-reviews`;
|
|
106
|
+
if (action === "show") {
|
|
107
|
+
if (args.length !== 1)
|
|
108
|
+
throw new CliError("usage", usage);
|
|
109
|
+
const groupId = str(p.flags, "group"), studyId = str(p.flags, "study");
|
|
110
|
+
if ((groupId === undefined) === (studyId === undefined))
|
|
111
|
+
throw new CliError("usage", "choose exactly one of --group <groupId> or --study <studyId>");
|
|
112
|
+
const query = groupId !== undefined ? `group_id=${encodeURIComponent(groupId)}` : `study_id=${encodeURIComponent(studyId)}`;
|
|
113
|
+
const result = await client.call("GET", `${reviews}?${query}`);
|
|
114
|
+
const review = result.review;
|
|
115
|
+
if (!review) {
|
|
116
|
+
out.print("No platform review exists for this scope.", result);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const studiesResult = await client.call("GET", `/projects/${encodeURIComponent(project)}/design-studies`);
|
|
120
|
+
if (!Array.isArray(studiesResult.studies))
|
|
121
|
+
throw new CliError("bad_response", "design study list response omitted studies");
|
|
122
|
+
const variants = studiesResult.studies.flatMap(study => (study.rounds ?? []).flatMap(round => (round.variants ?? []).map(variant => ({ ...variant, study_id: study.id, study_title: study.title }))));
|
|
123
|
+
const selected = review.shortlist.map(id => {
|
|
124
|
+
const variant = variants.find(item => item.id === id);
|
|
125
|
+
return variant ? { variant_id: id, study_id: variant.study_id, study_title: variant.study_title, label: variant.label, status: variant.status, summary: variant.summary } : { variant_id: id, unavailable: true };
|
|
126
|
+
});
|
|
127
|
+
const lines = [`Platform review ${review.id} [${review.status}]`, ...selected.map(item => "unavailable" in item ? `Shortlisted ${item.variant_id}: mock details unavailable` : `${item.study_title} · ${item.label} [${item.status}]${item.summary ? `\n ${item.summary}` : ""}\n ${consoleLink("mock", project, item.study_id)}`), ...review.gaps.map(gap => `Gap: ${gap.title} — ${gap.description}${gap.direction ? `\n Direction: ${gap.direction}` : ""}`), ...review.proposals.map(proposal => `Proposed WU${proposal.work_unit_number ? ` #${proposal.work_unit_number}` : " (draft)"}: ${proposal.title} [${proposal.tags.join(", ")}]`), ...(review.direction ? [`Operator direction: ${review.direction}`] : [])];
|
|
128
|
+
out.print(lines.join("\n") || `Platform review ${review.id} [${review.status}]`, { ...result, shortlisted_mocks: selected });
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (action === "gaps" || action === "propose") {
|
|
132
|
+
if (args.length !== 2 || !reviewId)
|
|
133
|
+
throw new CliError("usage", usage);
|
|
134
|
+
const values = jsonArray(str(p.flags, "json"), action === "gaps" ? "gaps" : "proposals");
|
|
135
|
+
if (action === "gaps")
|
|
136
|
+
assertUniqueGapTitles(values);
|
|
137
|
+
const body = action === "gaps" ? { gaps: values } : { proposals: values };
|
|
138
|
+
const result = await client.call("POST", `${reviews}/${encodeURIComponent(reviewId)}/${action === "propose" ? "proposals" : "gaps"}`, body);
|
|
139
|
+
out.print(action === "gaps" ? "Platform review gaps submitted." : "Platform unit proposals submitted as drafts.", result);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (action === "revise") {
|
|
143
|
+
if (args.length !== 2 || !reviewId)
|
|
144
|
+
throw new CliError("usage", usage);
|
|
145
|
+
const result = await client.call("GET", `${reviews}/${encodeURIComponent(reviewId)}`);
|
|
146
|
+
const review = result.review;
|
|
147
|
+
if (review.status !== "revision")
|
|
148
|
+
throw new CliError("conflict", `mock revisions can start only after operator confirmation and direction (review status is ${review.status})`);
|
|
149
|
+
const studiesResult = await client.call("GET", `/projects/${encodeURIComponent(project)}/design-studies`);
|
|
150
|
+
if (!Array.isArray(studiesResult.studies))
|
|
151
|
+
throw new CliError("bad_response", "design study list response omitted studies");
|
|
152
|
+
const byVariant = new Map();
|
|
153
|
+
for (const study of studiesResult.studies) {
|
|
154
|
+
const sourceVariantIds = new Set((study.rounds ?? []).flatMap(round => (round.variants ?? []).flatMap(variant => variant.source_variant_id ? [variant.source_variant_id] : [])));
|
|
155
|
+
for (const round of study.rounds ?? [])
|
|
156
|
+
for (const variant of round.variants ?? [])
|
|
157
|
+
byVariant.set(variant.id, { studyId: study.id, title: study.title, sourceVariantIds });
|
|
158
|
+
}
|
|
159
|
+
if (!review.shortlist.length)
|
|
160
|
+
throw new CliError("bad_response", "confirmed platform review has no shortlisted mocks");
|
|
161
|
+
const started = [];
|
|
162
|
+
for (const variantId of review.shortlist) {
|
|
163
|
+
const source = byVariant.get(variantId);
|
|
164
|
+
if (!source)
|
|
165
|
+
throw new CliError("bad_response", `shortlisted variant ${variantId} is missing from project studies`);
|
|
166
|
+
if (source.sourceVariantIds.has(variantId)) {
|
|
167
|
+
started.push({ study_id: source.studyId, study_title: source.title, source_variant_id: variantId, already_started: true });
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
const iteration = await client.call("POST", `/projects/${encodeURIComponent(project)}/design-studies/${encodeURIComponent(source.studyId)}/iterate`, { variant_id: variantId });
|
|
171
|
+
started.push({ study_id: source.studyId, study_title: source.title, source_variant_id: variantId, study: iteration.study });
|
|
172
|
+
}
|
|
173
|
+
out.print(started.map(item => `${"already_started" in item ? "Revision already started" : "Revision started"}: ${item.study_title}\n ${consoleLink("mock", project, item.study_id)}`).join("\n"), { review_id: reviewId, revisions: started });
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
throw new CliError("usage", usage);
|
|
177
|
+
}
|
|
@@ -327,7 +327,7 @@ export async function needsAdmin(p, out, project) {
|
|
|
327
327
|
return out.print(project ? `Nothing waiting in ${r.project?.name ?? project}.` : "Nothing is waiting on you.", r);
|
|
328
328
|
const ind = (t) => t.replace(/\n/g, "\n ");
|
|
329
329
|
out.print(r.needs.map((n, i) => [
|
|
330
|
-
`${i + 1}. [${n.project || "Account"}] ${n.display_id ?? (n.kind === "unit_question" ? `WU #${n.unit} question` : n.kind === "sendback_reviewer_gap" ? "send-back reviewer gap" : "decision id unavailable")} · ${n.kind === "unit_question" ? "unit question" : n.kind === "wake_broken" || n.kind === "wake_unresponsive" ? "wake path" : n.kind === "sendback_reviewer_gap" ? "send-back reviewer gap" : n.kind === "notifier" ? "your alerts" : n.kind === "machine_report_refused" ? "machine report refused" : n.kind === "machine_session" ? "machine" : n.kind === "lock_silent" ? "silent lock job" : n.kind === "platform_fault" ? (n.key.startsWith("remote-job-health:") ? "remote job health" : "platform fault") : "decision"} · ${n.asked_by} · since ${n.since.slice(0, 16).replace("T", " ")} UTC`,
|
|
330
|
+
`${i + 1}. [${n.project || "Account"}] ${n.display_id ?? (n.kind === "unit_question" ? `WU #${n.unit} question` : n.kind === "sendback_reviewer_gap" ? "send-back reviewer gap" : "decision id unavailable")} · ${n.kind === "unit_question" ? "unit question" : n.kind === "wake_broken" || n.kind === "wake_unresponsive" ? "wake path" : n.kind === "sendback_reviewer_gap" ? "send-back reviewer gap" : n.kind === "flow_agent_budget" ? "Flow Agent budget" : n.kind === "notifier" ? "your alerts" : n.kind === "machine_report_refused" ? "machine report refused" : n.kind === "machine_session" ? "machine" : n.kind === "lock_silent" ? "silent lock job" : n.kind === "platform_fault" ? (n.key.startsWith("remote-job-health:") ? "remote job health" : "platform fault") : "decision"} · ${n.asked_by} · since ${n.since.slice(0, 16).replace("T", " ")} UTC`,
|
|
331
331
|
` Console: ${consoleLink("decision", n.project, n.key)}`,
|
|
332
332
|
n.plain ? ` In plain words: ${ind(n.plain)}` : n.unexplained ? ` In plain words: (${n.asked_by} did not explain this; b9s-admin explain ${n.key})` : null,
|
|
333
333
|
n.blocks ? ` What's stuck: ${ind(n.blocks)}` : null,
|
package/dist/commands/ux.js
CHANGED
|
@@ -35,10 +35,19 @@ async function printJob(job, res, p, out, creds, client, project) {
|
|
|
35
35
|
throw new CliError("checksum_mismatch", `full-log bytes hash to ${actual} but server says ${expected || "no checksum"}`);
|
|
36
36
|
process.stdout.write(bytes);
|
|
37
37
|
}
|
|
38
|
+
function jobUnitTarget(job) {
|
|
39
|
+
return job.work_unit_number !== null && job.work_unit_number !== undefined
|
|
40
|
+
? `WU #${job.work_unit_number}`
|
|
41
|
+
: `branch ${job.target_branch ?? job.branch}`;
|
|
42
|
+
}
|
|
38
43
|
function formatJob(job) {
|
|
39
44
|
const isGate = job.job_kind === "gate";
|
|
40
45
|
const what = isGate
|
|
41
|
-
? (job.train_run_id
|
|
46
|
+
? (job.train_run_id
|
|
47
|
+
? "merge train gate"
|
|
48
|
+
: job.trigger_source === "direct_push" || job.target_branch
|
|
49
|
+
? `direct push gate (${job.target_branch ?? job.branch})`
|
|
50
|
+
: "complete-suite gate (scripts/gate.sh)")
|
|
42
51
|
: [job.task ? `ux:task ${job.task}` : null, job.compare_screen ? `ux:compare ${job.compare_screen}` : null].filter(Boolean).join(" + ");
|
|
43
52
|
const headText = job.resolved_head ? job.resolved_head.slice(0, 9) : job.head ? job.head.slice(0, 9) : "branch tip";
|
|
44
53
|
const evidenceLine = Array.isArray(job.evidence_ids) && job.evidence_ids.length
|
|
@@ -71,7 +80,7 @@ function formatJob(job) {
|
|
|
71
80
|
}
|
|
72
81
|
else if (job.checkout_retention_note)
|
|
73
82
|
checkoutLine = `\nCheckout: ${job.checkout_retention_note}`;
|
|
74
|
-
return `${kindLabel} job ${job.id} [${job.status}] on ${job.machine} for
|
|
83
|
+
return `${kindLabel} job ${job.id} [${job.status}] on ${job.machine} for ${jobUnitTarget(job)}\nTask: ${what}\nBranch: ${job.branch} @ ${headText}${steps}${failedTail}${fingerprint}${checkoutLine}${evidenceLine}${fullLogLine}${errorLine}`;
|
|
75
84
|
}
|
|
76
85
|
export async function ux(p, out) {
|
|
77
86
|
const sub = p.positionals[1];
|
|
@@ -147,7 +156,7 @@ export async function ux(p, out) {
|
|
|
147
156
|
id: job.id,
|
|
148
157
|
kind: job.job_kind ?? "ux",
|
|
149
158
|
status: job.status,
|
|
150
|
-
unit: `#${job.work_unit_number}
|
|
159
|
+
unit: job.work_unit_number !== null && job.work_unit_number !== undefined ? `#${job.work_unit_number}` : (job.target_branch ?? job.branch),
|
|
151
160
|
machine: job.machine,
|
|
152
161
|
task: job.job_kind === "gate" ? "gate.sh" : (job.task ?? job.compare_screen ?? "-"),
|
|
153
162
|
head: (job.resolved_head ?? job.head ?? "-").slice(0, 9),
|
|
@@ -219,7 +228,7 @@ export async function gate(p, out) {
|
|
|
219
228
|
const rows = res.jobs.map((job) => ({
|
|
220
229
|
id: job.id,
|
|
221
230
|
status: job.status,
|
|
222
|
-
unit: `#${job.work_unit_number}
|
|
231
|
+
unit: job.work_unit_number !== null && job.work_unit_number !== undefined ? `#${job.work_unit_number}` : (job.target_branch ?? job.branch),
|
|
223
232
|
machine: job.machine,
|
|
224
233
|
head: (job.resolved_head ?? job.head ?? "-").slice(0, 9),
|
|
225
234
|
evidence: Array.isArray(job.evidence_ids) ? job.evidence_ids.length : 0,
|