trantor 0.18.143 → 0.18.144

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +24 -0
  4. package/bin/app.mjs +54 -5
  5. package/bin/canary.mjs +108 -0
  6. package/bin/capacity.mjs +107 -0
  7. package/bin/cli.mjs +5 -0
  8. package/bin/crew-runner.mjs +25 -4
  9. package/bin/disk.mjs +1 -1
  10. package/bin/doctor.mjs +93 -1
  11. package/bin/duty.mjs +5 -2
  12. package/bin/fitness.mjs +15 -0
  13. package/bin/herdr-agent.mjs +8 -2
  14. package/bin/models.mjs +54 -23
  15. package/bin/wake-nudge.mjs +6 -3
  16. package/deploy/com.trantor.hub.plist +15 -3
  17. package/deploy/node-path.sh +11 -4
  18. package/deploy/setup.sh +6 -13
  19. package/docs/FEATURES.md +32 -0
  20. package/hub/auth.mjs +3 -1
  21. package/hub/review-store.mjs +48 -0
  22. package/hub/routes/capacity.mjs +77 -0
  23. package/hub/routes/insights.mjs +40 -6
  24. package/hub/routes/messages.mjs +16 -60
  25. package/hub/routes/reviews.mjs +86 -0
  26. package/hub/send-message.mjs +51 -0
  27. package/hub.mjs +5 -1
  28. package/kimi.plugin.json +1 -1
  29. package/lib/app-screenshot.mjs +155 -0
  30. package/lib/canary/canary.mjs +166 -0
  31. package/lib/canary/probes.mjs +197 -0
  32. package/lib/canary/registry.mjs +30 -0
  33. package/lib/capacity-machines.mjs +79 -0
  34. package/lib/capacity.mjs +172 -0
  35. package/lib/discovery/SOURCES.md +30 -0
  36. package/lib/discovery/claude.mjs +27 -0
  37. package/lib/discovery/codex.mjs +74 -0
  38. package/lib/discovery/common.mjs +56 -0
  39. package/lib/discovery/gemini.mjs +27 -0
  40. package/lib/discovery/index.mjs +104 -0
  41. package/lib/discovery/kimi.mjs +10 -0
  42. package/lib/discovery/opencode.mjs +19 -0
  43. package/lib/discovery/qwen.mjs +16 -0
  44. package/lib/disk.mjs +14 -4
  45. package/lib/fitness.mjs +97 -0
  46. package/lib/launch-node.mjs +96 -0
  47. package/lib/machine-health.mjs +80 -1
  48. package/lib/review-hunks.mjs +41 -0
  49. package/lib/turn-usage.mjs +66 -10
  50. package/mcp.mjs +14 -1
  51. package/package.json +3 -2
@@ -6,14 +6,14 @@
6
6
  },
7
7
  "metadata": {
8
8
  "description": "Trantor — the hub-world for AI agent crews: live message bus, presence, project Kanban/flow board + context-handoff for independent AI coding agents (Claude, Codex, Gemini, …)",
9
- "version": "0.18.143"
9
+ "version": "0.18.144"
10
10
  },
11
11
  "plugins": [
12
12
  {
13
13
  "name": "trantor",
14
14
  "source": "./",
15
15
  "description": "The hub-world for AI agent crews. Say \"fire up the crew\" and Claude becomes the architect: a plan-aware Advisor routes the work (solo / cheap inline calls / live crew of Codex, GLM, Kimi & DeepSeek in their own terminal windows), a Kanban/flow command center with a testing gate tracks it, and an economics brain (Scrooge) keeps the receipts. Includes the relay MCP, a SessionStart auto-discovery hook, and a PreCompact context-handoff so a fresh session can take over a full window instead of compacting.",
16
- "version": "0.18.143",
16
+ "version": "0.18.144",
17
17
  "author": {
18
18
  "name": "Sasha Bogojevic"
19
19
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trantor",
3
- "version": "0.18.143",
3
+ "version": "0.18.144",
4
4
  "description": "Trantor — the hub-world for AI agent crews: live message bus, presence, project Kanban/flow board + crew orchestration for independent AI coding agents (Claude, Codex, Gemini, Kimi, DeepSeek)",
5
5
  "mcpServers": {
6
6
  "relay": {
package/README.md CHANGED
@@ -446,6 +446,17 @@ trantor setup | doctor | connect | profile | provider | models
446
446
  built without macOS Screen Recording permission. Agents get the same as the `app_screenshot`
447
447
  tool. The pop-out window is picked by project (default: the caller's).
448
448
 
449
+ - **`trantor app click <name> [--selector css]`** — click the app's own UI by name, or
450
+ use `click --selector css` for an exact target. `app read [--selector css]` reads its text.
451
+ `app type <text> [--selector css]` replaces the focused input or textarea's value (including
452
+ empty text), firing input and change events so React state updates. A missing selector errors
453
+ without touching another element. `app key <chord>` dispatches keydown and keyup to the focused
454
+ element; for example `app key "Mod+N"`, `app type "src/hello.ts"`, then `app key Enter`.
455
+ `Esc` aliases Escape; Mod is Command on macOS and Control elsewhere. Ctrl, Meta, Alt and Shift
456
+ modifiers are also supported. These commands accept `--window main|popout` and `--project name`.
457
+ They use the app socket and DOM events; they do not synthesize OS keyboard events or browser
458
+ default actions such as Tab focus traversal.
459
+
449
460
  - **herdr signing** — herdr ships ad-hoc signed, so each herdr update used to orphan its Screen
450
461
  Recording toggle while it still showed on. `trantor herdr install` and `trantor open` re-sign an
451
462
  ad-hoc herdr with your Developer ID under the fixed identifier `com.trantor.herdr`, so the grant
@@ -469,6 +480,19 @@ trantor setup | doctor | connect | profile | provider | models
469
480
  endpoints are wired into OpenCode for you) · `remove <name>`.
470
481
  - **`trantor models [<provider>]`** — browse the live models behind each seat + the router's pick
471
482
  per difficulty. A model with no known price is listed as unpriced and never picked.
483
+ `--all [--json] [--refresh]` discovers models for every provider, including Codex, Kimi, Claude,
484
+ Gemini and Qwen, each marked `listed`, `entitled`, `callable` or `unknown` with its source and a
485
+ reason when unknown (sources: `lib/discovery/SOURCES.md`).
486
+ - **`trantor capacity [--json]`** — the live ledger across every project: each provider's usage
487
+ windows and resets, prepaid balances, burn rate per seat, each machine's load, memory, swap and
488
+ disk, and every seat's last turn and model. Unknown values print as unknown; with the hub down
489
+ it falls back to local balances.
490
+ - **`trantor fitness [--json]`** — read-only model fitness from attempt records, grouped by
491
+ provider, model, effort, harness, task kind, difficulty and machine, with sample counts.
492
+ Infrastructure failures are excluded from quality.
493
+ - **`trantor canary [--json]`** — runs the live probe for every long-standing feature in
494
+ `docs/FEATURES.md` and prints pass or fail per feature; `trantor canary install` adds the daily
495
+ job, which posts a failing probe once per episode.
472
496
  - **`trantor memory`** — pins a project's Claude memory notes to the code they describe
473
497
  (graft symbols and files) and flags a note **stale** when a pinned symbol's body changes, or
474
498
  **broken** when it disappears. `check [--strict]` reports; `pin <note> | --all [--dry-run]`
package/bin/app.mjs CHANGED
@@ -14,7 +14,10 @@ import { join } from "node:path";
14
14
  import { tmpdir } from "node:os";
15
15
  import { cleanLaunchEnv } from "../lib/launch-env.mjs";
16
16
  import { newestDmgRelease } from "../lib/app-release.mjs";
17
- import { appScreenshot, parseScreenshotArgs } from "../lib/app-screenshot.mjs";
17
+ import {
18
+ appType, appKey, appClick, appNavigate, appRead, appScreenshot, appWindow,
19
+ parseTypeArgs, parseKeyArgs, parseClickArgs, parseNavigateArgs, parseReadArgs, parseScreenshotArgs, parseWindowArgs,
20
+ } from "../lib/app-screenshot.mjs";
18
21
 
19
22
  const REPO = "sashabogi/trantor";
20
23
  const APP = "/Applications/Trantor.app";
@@ -27,14 +30,60 @@ if (cmd === "screenshot") {
27
30
  process.exit(0);
28
31
  }
29
32
 
33
+ // #14584: agents drive the app's own UI over the same socket as app_screenshot — no macOS
34
+ // permissions, and an explicit error when the app is not running.
35
+ if (["window", "navigate", "click", "read", "type", "key"].includes(cmd)) {
36
+ try { console.log(await appControl(cmd, process.argv.slice(3))); }
37
+ catch (error) { console.error(`trantor app: ${error.message}`); process.exit(1); }
38
+ process.exit(0);
39
+ }
40
+
41
+ async function appControl(verb, argv) {
42
+ if (verb === "window") {
43
+ const options = parseWindowArgs(argv);
44
+ const { action, window } = options;
45
+ const result = await appWindow(options);
46
+ if (action === "size") return `the ${result.window ?? window ?? "main"} window size is ${result.width}x${result.height}`;
47
+ if (action === "focus") return `focused the ${result.window ?? window ?? "main"} window`;
48
+ return `the ${result.window ?? window ?? "main"} window is ${result.fullscreen ? "" : "not "}fullscreen`;
49
+ }
50
+ if (verb === "navigate") {
51
+ const { screen, project } = parseNavigateArgs(argv);
52
+ await appNavigate({ screen, project });
53
+ return `navigated to ${screen}${project ? ` in ${project}` : ""}`;
54
+ }
55
+ if (verb === "click") {
56
+ const { name, selector, window, project } = parseClickArgs(argv);
57
+ const result = await appClick({ name, selector, window, project });
58
+ return `clicked ${JSON.stringify(result.name ?? name ?? selector)}`;
59
+ }
60
+ if (verb === "type") {
61
+ await appType(parseTypeArgs(argv));
62
+ return "typed into the app";
63
+ }
64
+ if (verb === "key") {
65
+ await appKey(parseKeyArgs(argv));
66
+ return "sent key to the app";
67
+ }
68
+ const options = parseReadArgs(argv);
69
+ const result = await appRead(options);
70
+ return (result.text ?? "").replace(/\n+$/, "");
71
+ }
72
+
30
73
  if (process.platform !== "darwin") { console.error("trantor app: the desktop app is macOS-only for now"); process.exit(1); }
31
74
  if (!["status", "install", "update"].includes(cmd)) {
32
75
  console.error([
33
- "usage: trantor app [status|install|update|screenshot]",
34
- " status installed version vs latest release (default)",
35
- " install download the latest release DMG and install to /Applications",
36
- " update same as install, then relaunch the app from a clean env",
76
+ "usage: trantor app [status|install|update|screenshot|window|navigate|click|read|type|key]",
77
+ " status installed version vs latest release (default)",
78
+ " install download the latest release DMG and install to /Applications",
79
+ " update same as install, then relaunch the app from a clean env",
37
80
  " screenshot [--window main|popout] [--project name] [--out file.png]",
81
+ " window <fullscreen|unfullscreen|focus|size WxH|size restore> [--window main|popout] [--project name]",
82
+ " navigate <screen> [--project name]",
83
+ " click <name> [--selector css] [--window main|popout] [--project name]",
84
+ " type <text> [--selector css] [--window main|popout] [--project name]",
85
+ " key <chord> [--window main|popout] [--project name]",
86
+ " read [--selector css] [--window main|popout] [--project name]",
38
87
  ].join("\n"));
39
88
  process.exit(1);
40
89
  }
package/bin/canary.mjs ADDED
@@ -0,0 +1,108 @@
1
+ #!/usr/bin/env node
2
+ // trantor canary — run every docs/FEATURES.md probe (#14655).
3
+ // trantor canary [--json] run the probes; read-only, writes nothing, posts nothing
4
+ // trantor canary --daily what launchd runs: also records the run and posts new failures once per episode
5
+ // trantor canary install | uninstall | plist
6
+ import { mkdirSync, writeFileSync, rmSync, existsSync } from "node:fs";
7
+ import { join } from "node:path";
8
+ import { homedir } from "node:os";
9
+ import { execFileSync } from "node:child_process";
10
+ import { fileURLToPath } from "node:url";
11
+ import { busDir, resolveHub, knownProjects, checkoutFor, readConfig } from "../lib/project.mjs";
12
+ import { loadRegistry } from "../lib/canary/registry.mjs";
13
+ import {
14
+ runCanary, tally, advanceEpisodes, episodeMessage, readEpisodes, recordRun,
15
+ defaultContext, canaryPlist, CANARY_LABEL,
16
+ } from "../lib/canary/canary.mjs";
17
+
18
+ const SELF = fileURLToPath(import.meta.url);
19
+ const PROJECT = "trantor";
20
+ const args = process.argv.slice(2);
21
+ const cmd = args.find((a) => !a.startsWith("--")) || "run";
22
+ const JSON_MODE = args.includes("--json");
23
+ const DAILY = args.includes("--daily");
24
+ const PLIST_PATH = join(homedir(), "Library", "LaunchAgents", `${CANARY_LABEL}.plist`);
25
+
26
+ const launchctl = (argv) => execFileSync("launchctl", argv, { stdio: ["ignore", "pipe", "pipe"], encoding: "utf8" });
27
+
28
+ if (cmd === "plist") {
29
+ process.stdout.write(canaryPlist({ script: SELF, busDir: busDir() }));
30
+ process.exit(0);
31
+ }
32
+
33
+ if (cmd === "install") {
34
+ if (process.platform !== "darwin") { console.error("trantor canary install: launchd is macOS-only; run `trantor canary --daily` from cron elsewhere"); process.exit(1); }
35
+ mkdirSync(join(busDir(), "logs"), { recursive: true });
36
+ mkdirSync(join(homedir(), "Library", "LaunchAgents"), { recursive: true });
37
+ writeFileSync(PLIST_PATH, canaryPlist({ script: SELF, busDir: busDir() }), { mode: 0o644 });
38
+ try { launchctl(["bootout", `gui/${process.getuid()}/${CANARY_LABEL}`]); } catch { /* first install has no prior job */ }
39
+ launchctl(["bootstrap", `gui/${process.getuid()}`, PLIST_PATH]);
40
+ console.log(`installed: ${PLIST_PATH}\nruns every day at 09:30; failures post to the ${PROJECT} lane and the app once per episode`);
41
+ process.exit(0);
42
+ }
43
+
44
+ if (cmd === "uninstall") {
45
+ try { launchctl(["bootout", `gui/${process.getuid()}/${CANARY_LABEL}`]); } catch { /* already stopped */ }
46
+ rmSync(PLIST_PATH, { force: true });
47
+ console.log(`${CANARY_LABEL} removed`);
48
+ process.exit(0);
49
+ }
50
+
51
+ if (cmd !== "run") {
52
+ console.error("usage: trantor canary [--json] [--daily] | install | uninstall | plist");
53
+ process.exit(2);
54
+ }
55
+
56
+ async function appRead() {
57
+ const { appRead: read } = await import("../lib/app-screenshot.mjs");
58
+ return read({ window: "main", project: "" });
59
+ }
60
+
61
+ // Owner identity, not a fresh agent key: the hub enforces enrollment, and a message to the owner is
62
+ // what raises the app's notification (shared/notify.ts), while the broadcast lands in the lane.
63
+ async function post(text) {
64
+ const cfg = readConfig();
65
+ const owner = String(cfg.ownerIdentity || "");
66
+ if (!owner) throw new Error("no ownerIdentity in ~/.agent-bus/config.json to sign with");
67
+ const { loadOrCreate } = await import("../lib/identity.mjs");
68
+ const { sfetchJson } = await import("../lib/signed-fetch.mjs");
69
+ const identity = loadOrCreate(owner, "human");
70
+ if (!identity) throw new Error(`owner identity ${owner} has no usable key on this machine`);
71
+ const hub = resolveHub(PROJECT);
72
+ for (const to of ["all", owner]) {
73
+ const r = await sfetchJson(`${hub}/send`, { payload: { from: owner, to, project: PROJECT, kind: "canary", text, wake: false }, identity, signal: AbortSignal.timeout(10000) });
74
+ if (!r?.ok) throw new Error(`hub refused the canary message to ${to} (HTTP ${r?.status ?? "?"})`);
75
+ }
76
+ }
77
+
78
+ const bus = busDir();
79
+ const rows = loadRegistry(process.env.TRANTOR_FEATURES_PATH || undefined);
80
+ const ctx = defaultContext({ busDir: bus, hub: resolveHub(PROJECT), knownProjects, checkoutFor, appRead });
81
+ const run = await runCanary({ rows, ctx });
82
+ const t = tally(run.results);
83
+
84
+ if (DAILY) {
85
+ const step = advanceEpisodes(readEpisodes(bus), run);
86
+ const text = episodeMessage(step, run);
87
+ const record = { ...run, posted: [] };
88
+ if (text) {
89
+ try { await post(text); record.posted = step.announce.map((r) => r.id); }
90
+ catch (error) {
91
+ // Unannounced episodes stay closed, so tomorrow's run tries again instead of going quiet.
92
+ for (const r of step.announce) delete step.episodes[r.id];
93
+ record.postError = error.message;
94
+ console.error(`canary: could not post: ${error.message}`);
95
+ }
96
+ }
97
+ recordRun(bus, record, step.episodes);
98
+ }
99
+
100
+ if (JSON_MODE) {
101
+ console.log(JSON.stringify({ ...run, ...t }, null, 2));
102
+ } else {
103
+ const mark = { pass: "✓", fail: "✗", skip: "–" };
104
+ console.log(`TRANTOR CANARY ${new Date(run.ts).toISOString().slice(0, 16).replace("T", " ")} UTC\n`);
105
+ for (const r of run.results) console.log(` ${mark[r.status]} ${r.status.padEnd(4)} ${r.id.padEnd(24)} ${r.detail}`);
106
+ console.log(`\n${t.pass} pass, ${t.fail} fail, ${t.skip} skip${existsSync(PLIST_PATH) ? "" : " (no daily job: trantor canary install)"}`);
107
+ }
108
+ process.exit(DAILY ? 0 : t.fail ? 1 : 0);
@@ -0,0 +1,107 @@
1
+ #!/usr/bin/env node
2
+ // #14653: trantor capacity — the live ledger on your terminal: provider budgets with every window
3
+ // and reset, prepaid balances, the burn rate, machine load/memory/swap/disk/seats, and each seat's
4
+ // last turn and real model. Read-only, straight from GET /capacity.
5
+
6
+ // Degraded by design: when the hub is unreachable the CLI falls back to the LOCAL provider
7
+ // balances (same sources `trantor balances` reads) and says it is local-only — machines, seats and
8
+ // burn rate print unknown, never a guess.
9
+ // Usage: trantor capacity [--json]
10
+ import { signedGet, sessionContext, relayUrl } from "../hooks/lib/api.mjs";
11
+ import { fetchBalances, fmtBalance } from "../lib/balances.mjs";
12
+ import { loadProfile } from "./profile.mjs";
13
+ import { resolveKeys } from "../lib/provider-keys.mjs";
14
+ import { detectedCliBalanceRows } from "../lib/providers.mjs";
15
+ import { fmtBytes, fmtAge, fmtCount, fmtReset } from "../lib/capacity.mjs";
16
+
17
+ const args = process.argv.slice(2);
18
+ const asJson = args.includes("--json");
19
+ const { project } = sessionContext();
20
+ const hub = relayUrl(project);
21
+
22
+ const response = await signedGet(`/capacity?project=${encodeURIComponent(project)}`, { timeoutMs: 5000, project });
23
+
24
+ if (!response.ok && response.status !== 0) {
25
+ console.error(`hub refused: ${response.json?.error || response.reason || `HTTP ${response.status}`}`);
26
+ process.exit(1);
27
+ }
28
+
29
+ if (!response.ok) {
30
+ // Hub down: local balances only (profile-scoped, exactly what `trantor balances` would fetch).
31
+ const profileProviders = loadProfile().providers || {};
32
+ const configured = Object.keys(profileProviders);
33
+ const env = resolveKeys(process.env);
34
+ const detected = await detectedCliBalanceRows({ env });
35
+ const profileScoped = await fetchBalances(env, { only: configured.filter((p) => p !== "claude" && p !== "codex") });
36
+ const balances = [...detected, ...profileScoped];
37
+ const reason = response.reason || "unreachable";
38
+ if (asJson) {
39
+ console.log(JSON.stringify({ degraded: "local-only", reason, hub, balances, budgets: null, burn: null, machines: null, seats: null }, null, 2));
40
+ } else {
41
+ console.log(`hub unreachable (${reason}) — LOCAL BALANCES ONLY; machines, seats and burn rate unknown.`);
42
+ console.log(`hub: ${hub}\n`);
43
+ if (!balances.length) console.log("no local balance rows (no keys in env / no quota profile on this machine)");
44
+ for (const b of balances) console.log(" " + fmtBalance(b));
45
+ }
46
+ process.exit(0);
47
+ }
48
+
49
+ const ledger = response.json || {};
50
+ if (asJson) { console.log(JSON.stringify(ledger, null, 2)); process.exit(0); }
51
+
52
+ const budgets = ledger.budgets || {};
53
+ console.log(`TRANTOR CAPACITY — hub ${hub}${budgets.snapshotAgeMs != null ? ` · budgets ${fmtAge(budgets.snapshotAgeMs)} old` : ""}\n`);
54
+
55
+ console.log("PROVIDER BUDGETS");
56
+ const providers = budgets.providers || [];
57
+ if (!providers.length) console.log(" unknown — no balance snapshot on the hub yet (run: trantor balances)");
58
+ for (const p of providers) {
59
+ const machine = p.machine ? ` · ${p.machine}` : "";
60
+ const age = p.ageMs != null ? ` · ${fmtAge(p.ageMs)} old` : "";
61
+ const low = p.low ? " 🔴 REFILL SOON" : "";
62
+ if (!p.ok) { console.log(` ${p.label}${machine}${age}: ⚠ ${p.error || "unread"}${low}`); continue; }
63
+ if (p.kind === "windows") {
64
+ const wins = (p.windows || []).map((w) => ` ${w.name} ${w.usedPct != null ? w.usedPct + "% used" : "unknown"}${w.resetsAt ? " · resets " + fmtReset(w.resetsAt) : ""}${w.locked ? " · LOCKED" : ""}`);
65
+ console.log(` ${p.label}${machine}${age}:${wins.join(" ·") || " windows unknown"}${low}`);
66
+ } else if (p.kind === "quota") {
67
+ const reset = p.resetTime ? ` · resets ${fmtReset(p.resetTime)}` : "";
68
+ console.log(` ${p.label}${p.plan ? " (" + p.plan + ")" : ""}${machine}${age}: ${p.remainingPct != null ? p.remainingPct + "% left" : p.detail || "quota unknown"}${reset}${low}`);
69
+ } else if (p.kind === "subscription") {
70
+ console.log(` ${p.label}${machine}${age}: ${p.plan || "subscription"}${low}`);
71
+ } else {
72
+ const sym = p.currency === "CNY" ? "¥" : p.currency === "EUR" ? "€" : "$";
73
+ const left = p.remaining != null ? `${sym}${p.remaining.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })} ${p.currency} left` : "no limit / unknown";
74
+ console.log(` ${p.label}${machine}${age}: ${left}${low}`);
75
+ }
76
+ }
77
+ const lows = providers.filter((p) => p.low);
78
+ if (lows.length) console.log(`\n⚠ ${lows.length} provider(s) low: ${lows.map((p) => p.label).join(", ")}`);
79
+
80
+ const burn = (ledger.burn?.windows) || {};
81
+ console.log("\nBURN RATE");
82
+ for (const [name, w] of Object.entries(burn)) {
83
+ console.log(` ${name}: ${w.turns} turns · ${fmtCount(w.tokens)} tokens (${w.turnsPerHour} turns/h · ${fmtCount(w.tokensPerHour)} tokens/h)`);
84
+ for (const s of w.bySeat || []) {
85
+ console.log(` ${s.persona}${s.project ? ":" + s.project : ""}: ${s.turns} turns · ${fmtCount(s.tokens)} tokens${s.failures ? ` · ${s.failures} failed` : ""}`);
86
+ }
87
+ }
88
+
89
+ console.log("\nMACHINES");
90
+ const machines = ledger.machines || [];
91
+ if (!machines.length) console.log(" unknown — no machine beats and no seat machines on the hub");
92
+ for (const m of machines) {
93
+ const beat = m.heartbeat ? `beat ${fmtAge(m.ageMs)}${m.stale ? " (STALE)" : ""}` : "no beat";
94
+ console.log(` ${m.machine} · ${beat}`);
95
+ console.log(` load ${m.cpuPct != null ? m.cpuPct + "%" : "unknown"}${m.cores ? ` on ${m.cores} cores` : ""} · mem ${m.memUsed != null ? `${fmtBytes(m.memUsed)}/${fmtBytes(m.memTotal)} (${Math.round((m.memUsed / m.memTotal) * 100)}%)` : "unknown"} · pressure ${m.memPressurePct != null ? m.memPressurePct + "%" : "unknown"}`);
96
+ console.log(` swap ${m.swapUsed != null ? `${fmtBytes(m.swapUsed)}/${fmtBytes(m.swapTotal)}` : "unknown"} · disk free ${m.diskFree != null ? `${fmtBytes(m.diskFree)}/${fmtBytes(m.diskTotal)}` : "unknown"} · seats ${m.seatsOnline != null ? `${m.seatsOnline}/${m.seats} online` : "unknown"}`);
97
+ }
98
+
99
+ console.log("\nSEATS");
100
+ const seats = ledger.seats || [];
101
+ if (!seats.length) console.log(" none visible");
102
+ for (const s of seats) {
103
+ const live = s.online ? "online" : `last seen ${fmtAge(s.ageMs)}`;
104
+ const last = s.lastTurn ? `last turn ${fmtAge(s.lastTurn.ageMs)} · ${s.lastTurn.outcome || "unknown"}` : "no turn in 7d";
105
+ const model = s.model || "cli-default";
106
+ console.log(` ${s.session} ${live} · ${model} · ${last}${s.machine ? ` · ${s.machine}` : ""}`);
107
+ }
package/bin/cli.mjs CHANGED
@@ -20,6 +20,7 @@ const runCrew = () => {
20
20
  switch (cmd) {
21
21
  case "setup": run("deploy/setup.sh", "/bin/bash"); break;
22
22
  case "doctor": run("bin/doctor.mjs"); break;
23
+ case "canary": run("bin/canary.mjs"); break;
23
24
  case "sim": run("bin/sim.mjs"); break;
24
25
  case "connect": run("bin/connect.mjs"); break;
25
26
  case "profile": run("bin/profile.mjs"); break;
@@ -139,6 +140,7 @@ switch (cmd) {
139
140
  case "new": run("bin/new.mjs"); break;
140
141
  case "genesis-kickoff": run("bin/genesis-kickoff.mjs"); break;
141
142
  case "balances": case "balance": case "credits": run("bin/balances.mjs"); break;
143
+ case "capacity": run("bin/capacity.mjs"); break;
142
144
  case "recost": run("bin/recost.mjs"); break;
143
145
  case "handoff": run("bin/baton.mjs"); break;
144
146
  case "takeover": run("bin/takeover.mjs"); break;
@@ -157,6 +159,7 @@ switch (cmd) {
157
159
  case "seats": case "seat": run("bin/seats.mjs"); break;
158
160
  case "seat-why": case "why": run("bin/seat-why.mjs"); break;
159
161
  case "seat-record": run("bin/seat-record.mjs"); break;
162
+ case "fitness": run("bin/fitness.mjs"); break;
160
163
  case "telemetry": {
161
164
  // #14067: `trantor telemetry ship` is how existing history reaches the hub — this seat's log,
162
165
  // or every *.jsonl in the logs folder with --all. Always from the start of the file: a re-run
@@ -311,6 +314,7 @@ switch (cmd) {
311
314
  trantor new project genesis: new <name> [--from <git-url>] [--brief <file>] [--dir <parent>] [--adopt] [--json] — creates <parent>/<name>, git main, docs/PRD.md + small CLAUDE.md, hooks, hub brief + first card (never spawns a session)
312
315
  trantor genesis-kickoff internal wake prompt selector from the checkout + signed project board
313
316
  trantor balances how much credit is left on each CONFIGURED provider (from your profile) — refill before you stall — [--json]
317
+ trantor capacity the live ledger: budgets and resets, burn rate, machines, seats — [--json]
314
318
  trantor recost recompute sub-agent notional cost from on-disk transcripts + reseed the board (repair after upgrade) — [--dry-run]
315
319
  trantor handoff finish this session NOW: write a handoff, open a fresh session that takes over, and close this one (manual baton)
316
320
  trantor advise ask the Advisor directly (JSON on stdin; --demo to see it)
@@ -324,6 +328,7 @@ switch (cmd) {
324
328
  trantor state a seat's working memory: show <seat> <card> [--json] · validate · reset --force · gc [--apply]
325
329
  trantor seat-why WHY a seat is down (err file, logs, pids): seat-why <agent> [--json] — quota, auth, crash, or just no pane
326
330
  trantor seat-record the per-project seat record the advisor benches from (✓/∅/↩ per difficulty) — [--project p] [--reset <seat>] [--json]
331
+ trantor fitness read-only model fitness by provider/model/effort/harness/task/difficulty/machine — [--project p] [--json]
327
332
  trantor telemetry ship send turn history to the hub — this seat's log, or every log with --all; prints stored/duplicates/dropped per file
328
333
  trantor inbox THIS session's unread bus messages, signed (works under enforce) — [--all] [--consume] [--json]
329
334
  trantor policy the autonomy ladder: show | set <project> <1-4> | link <a> <b> --reason "<why>"
@@ -35,7 +35,8 @@ import {
35
35
  CUT_CHAIN_PARK_MIN, cutChainEvidence, isBoundedPark, askDuringTurn, askedVerdict,
36
36
  } from "../lib/turn-policy.mjs";
37
37
  import { snapshotBeforeCut } from "./cut-snapshot.mjs";
38
- import { ocTurnUsage, dshTurnUsage, usageTotal, processedInput, codexStepInput, kimiStepInput, claudeStepInput } from "../lib/turn-usage.mjs";
38
+ import { ocTurnUsage, dshTurnUsage, usageTotal, processedInput, codexStepInput, kimiStepInput, claudeStepInput, codexTurnModel, kimiTurnModel, claudeTurnModel } from "../lib/turn-usage.mjs";
39
+ import { effortName, isInfraFailure, providerForModel } from "../lib/fitness.mjs";
39
40
  import { capConfig, capDecision, capHandoffPrompt, capPointerLine, capExhaustedNote } from "../lib/context-cap.mjs";
40
41
  import { ocCompactionContent, ocCompactionLogLine, readOpencodeUserConfig, seatMcpOverlay, seatPermissionOverlay, seatConfigContent } from "../lib/seat-compaction.mjs";
41
42
  import { seatSignalPrefix } from "../lib/seat-signal-guard.mjs";
@@ -941,13 +942,14 @@ async function runTurn(prompt, isFirst, trigger = "kickoff", opts = {}) {
941
942
  // #10197: the card status snapshot the turn is judged against at its end — a move to
942
943
  // testing/done under the turn is delivery even without a commit. null = the hub read failed:
943
944
  // the delivery check stands down rather than claim no-delivery on a transport error.
944
- let cardStatusBefore = null, cardLogBefore = [], cardDifficulty = "";
945
+ let cardStatusBefore = null, cardLogBefore = [], cardDifficulty = "", cardKind = "";
945
946
  if (!opts.state && sessionCard > 0) {
946
947
  try {
947
948
  const { task } = await api(`/card?project=${encodeURIComponent(PROJ)}&id=${sessionCard}`);
948
949
  cardStatusBefore = task ? String(task.status || "") : null;
949
950
  cardLogBefore = task?.log || [];
950
951
  cardDifficulty = task?.difficulty || "";
952
+ cardKind = task?.kind || task?.taskKind || task?.task_kind || "";
951
953
  } catch { cardStatusBefore = null; }
952
954
  }
953
955
  // #9778: the docker snapshot the turn is judged against — containers the CLI spawns are recorded
@@ -1203,7 +1205,8 @@ exit $turn_exit`;
1203
1205
  // #5868: a NEW commit since turn start is real work, and an exit-0 turn with real output is
1204
1206
  // never re-labelled auth — the qwen specimen exited 0 with a shipped commit (aa3c340) while a
1205
1207
  // short capture of echoed contract text tripped the regex.
1206
- const newCommit = !!headBefore && gitOut(["rev-parse", "HEAD"], TURN_DIR) !== headBefore;
1208
+ const headAfter = gitOut(["rev-parse", "HEAD"], TURN_DIR);
1209
+ const newCommit = !!headBefore && headAfter !== headBefore;
1207
1210
  if (realExit === 0 && looksLikeAuthDeath(ownOut, newCommit)) {
1208
1211
  effExit = 1;
1209
1212
  authHit = AUTH_MARKER_RE.exec(ownOut)[0];
@@ -1332,7 +1335,25 @@ exit $turn_exit`;
1332
1335
  // empty/stalled turns to the card that produced nothing. `cut` stays too: the drills read it.
1333
1336
  const outcome = cut ? (stallCut ? "stalled" : "cut") : (effExit !== 0 ? (lastPermissionReject ? "rejected" : "api-error") : noDelivery ? "no-delivery" : lastEmptyTurn ? "empty" : "completed");
1334
1337
  const finalOutcome = askVerdict ? "asked" : blockedVerdict ? "blocked" : outcome;
1335
- const telemetryRow = { ts: Date.now(), persona: PERSONA, agent: AGENT, project: PROJ, turn: TURN, trigger, card: sessionCard || 0, model: MODEL || "cli-default", duration_ms: Date.now() - t0, exit: realExit, effExit, authFailed: effExit !== realExit, emptyOutput: lastEmptyOutput, emptyTurn: lastEmptyTurn, verdict, outcome: finalOutcome, tokens };
1338
+ const endedAt = Date.now();
1339
+ const transcriptModel = DRIVER === "codex" ? codexTurnModel(join(homedir(), ".codex", "sessions"), t0, TURN_DIR)
1340
+ : DRIVER === "kimi" ? kimiTurnModel(join(homedir(), ".kimi-code", "sessions"), sid, t0)
1341
+ : DRIVER === "claude" ? claudeTurnModel(TRANSCRIPT_DIR, t0) : null;
1342
+ // #14654: structured transcript metadata, else the pinned model; free-text model: lines are never read.
1343
+ const actualModel = transcriptModel || MODEL || "unknown";
1344
+ const telemetryRow = { ts: endedAt, persona: PERSONA, agent: AGENT, project: PROJ, turn: TURN, trigger, card: sessionCard || 0, model: actualModel, duration_ms: endedAt - t0, exit: realExit, effExit, authFailed: effExit !== realExit, emptyOutput: lastEmptyOutput, emptyTurn: lastEmptyTurn, verdict, outcome: finalOutcome, tokens };
1345
+ if (sessionCard > 0) {
1346
+ const failure = classifyFailure(effExit, ownOut, lastEmptyOutput, lastEmptyTurn, cut).reason;
1347
+ telemetryRow.attempt = {
1348
+ id: `${SESSION}:${t0}:${TURN}`, card: sessionCard, seat: SESSION, project: PROJ,
1349
+ provider: providerForModel(DRIVER, actualModel), model: actualModel,
1350
+ effort: effortName(turnEffort.effort), harness: DRIVER,
1351
+ taskKind: cardKind || "unknown", difficulty: cardDifficulty || "unknown",
1352
+ machine: MACHINE_LABEL || "unknown", start: new Date(t0).toISOString(), end: new Date(endedAt).toISOString(),
1353
+ commit: newCommit ? headAfter : "", outcome: finalOutcome,
1354
+ infraFailure: isInfraFailure(finalOutcome, failure), tokens: Number.isFinite(tokens) ? tokens : null,
1355
+ };
1356
+ }
1336
1357
  if (usage) telemetryRow.usage = usage;
1337
1358
  if (dockerNew.length) telemetryRow.containers = dockerNew.map(c => c.name || c.id);
1338
1359
  if (cut) telemetryRow.cut = true;
package/bin/disk.mjs CHANGED
@@ -38,7 +38,7 @@ async function install() {
38
38
  const logPath = join(homedir(), ".agent-bus", "disk-launchd.log");
39
39
  mkdirSync(agentDir, { recursive: true });
40
40
  mkdirSync(dirname(logPath), { recursive: true });
41
- writeFileSync(plistPath, launchdPlist({ nodePath: process.execPath, scriptPath: join(ROOT, "bin", "disk.mjs"), logPath }));
41
+ writeFileSync(plistPath, launchdPlist({ scriptPath: join(ROOT, "bin", "disk.mjs"), logPath }));
42
42
  const uid = userInfo().uid;
43
43
  exec("launchctl", ["bootout", `gui/${uid}/com.trantor.disk`]);
44
44
  const r = exec("launchctl", ["bootstrap", `gui/${uid}`, plistPath]);
package/bin/doctor.mjs CHANGED
@@ -8,7 +8,7 @@ import { join, dirname, basename } from "node:path";
8
8
  import { homedir } from "node:os";
9
9
  import { execSync } from "node:child_process";
10
10
  import { fileURLToPath } from "node:url";
11
- import { resolveProject, resolveProjectInfo, resolveHub, DEFAULT_HUB_URL, gitRoot, readProjectId, checkoutFor, localCheckoutFor, orchSessionsPath, PROJECT_MARKER } from "../lib/project.mjs";
11
+ import { resolveProject, resolveProjectInfo, resolveHub, DEFAULT_HUB_URL, gitRoot, readProjectId, checkoutFor, localCheckoutFor, orchSessionsPath, PROJECT_MARKER, busDir as resolveBusDir } from "../lib/project.mjs";
12
12
  import { loadOrCreate } from "../lib/identity.mjs";
13
13
  import { sfetchJson } from "../lib/signed-fetch.mjs";
14
14
  import { scan } from "../lib/splitbrain.mjs";
@@ -18,6 +18,8 @@ import { probeClaudeIntegration, HERDR_CLAUDE_INSTALL } from "../lib/herdr-integ
18
18
  import { ensureHerdrSigned, HERDR_SIGN_IDENTIFIER, probeHerdrSigning } from "../lib/herdr-signing.mjs";
19
19
  import { herdrBin } from "./herdr-agent.mjs";
20
20
  import { axeDoctorStatus } from "../lib/sim/axe-status.mjs";
21
+ import { plistPinnedPaths, scriptPinnedPaths, launcherPathFindings } from "../lib/launch-node.mjs";
22
+ import { canaryDoctorRows, readLastRun, CANARY_LABEL } from "../lib/canary/canary.mjs";
21
23
 
22
24
  const H = homedir();
23
25
  const ROOT = dirname(dirname(fileURLToPath(import.meta.url)));
@@ -138,6 +140,39 @@ section("duty seat (the fleet watcher)");
138
140
  const FIX_UP = "trantor duty up (installs the launchd keepalive com.trantor.duty, which relaunches the seat after a crash or reboot)";
139
141
  let pid = 0;
140
142
  try { pid = Number(readFileSync(join(BUSD, "duty.pid"), "utf8")) || 0; if (pid) process.kill(pid, 0); else pid = 0; } catch { pid = 0; }
143
+ // #14646: ALIVE is not AWAKE. The duty process once sat up for three days on a node binary a
144
+ // Homebrew upgrade had deleted mid-flight — it lost the hub, parked, and took no turn while
145
+ // looking healthy. The runner's turn log is on disk and survives the process: the one witness
146
+ // that does not go down with the hub. A seat that is up must have turned within 24h.
147
+ if (pid) {
148
+ let lastTurn = 0, lastBoot = 0;
149
+ try {
150
+ for (const f of readdirSync(join(BUSD, "logs")).filter(n => n.endsWith("-trantor-duty.jsonl"))) {
151
+ for (const line of readFileSync(join(BUSD, "logs", f), "utf8").split("\n")) {
152
+ if (!line) continue;
153
+ try {
154
+ const row = JSON.parse(line);
155
+ if (!Number.isFinite(row.ts)) continue;
156
+ if (row.boot) lastBoot = Math.max(lastBoot, row.ts);
157
+ if (Number.isInteger(row.turn) && row.turn > 0) lastTurn = Math.max(lastTurn, row.ts);
158
+ } catch {}
159
+ }
160
+ }
161
+ } catch {}
162
+ const ago = (ms) => ms < 60e3 ? `${Math.max(1, Math.round(ms / 60e3))}m` : ms < 3600e3 ? `${Math.round(ms / 60e3)}m` : ms < 86400e3 ? `${Math.round(ms / 3600e3)}h` : `${Math.round(ms / 86400e3)}d`;
163
+ const when = (ts) => `${new Date(ts).toISOString().slice(0, 16).replace("T", " ")} UTC`;
164
+ if (lastTurn && Date.now() - lastTurn <= 24 * 3600e3) {
165
+ ok(`duty seat: turned ${ago(Date.now() - lastTurn)} ago (${when(lastTurn)})`);
166
+ } else if (!lastTurn && lastBoot && Date.now() - lastBoot < 10 * 60e3) {
167
+ note(`duty seat: restarted ${ago(Date.now() - lastBoot)} ago — no turn yet (the kickoff lands within minutes)`);
168
+ } else if (lastTurn) {
169
+ warn(`duty seat: ALIVE but turnless — the process is up (pid ${pid}) yet its last turn was ${ago(Date.now() - lastTurn)} ago (${when(lastTurn)}); nothing has triaged the fleet since`,
170
+ "trantor duty up (a seat that is up but not turning is parked or hub-lost; a restart revives it)");
171
+ } else {
172
+ warn(`duty seat: process up (pid ${pid}) but NO turn on record — it has never woken`,
173
+ "trantor duty up (restart it; the kickoff turn should land within minutes)");
174
+ }
175
+ }
141
176
  const keepalive = existsSync(DUTY_PLIST);
142
177
  // The seat watches the FLEET hub — the most common project hub in config, the exact pick
143
178
  // bin/duty.mjs makes — not necessarily THIS project's hub.
@@ -179,6 +214,63 @@ section("duty seat (the fleet watcher)");
179
214
  }
180
215
  }
181
216
 
217
+ // ── launch agents: every com.trantor.* job must still have a program to run ───────────────────
218
+ // #14646: a Homebrew node upgrade deletes the versioned Cellar path older launchers pinned, and
219
+ // launchd restarts the job into exit 126 — the seat dies silently while everything else looks
220
+ // installed. Pinned paths must exist now, and a /Cellar/ path is wrong even while it survives.
221
+ section("launch agents (com.trantor.*)");
222
+ {
223
+ const AGENTS_DIR = join(H, "Library", "LaunchAgents");
224
+ const AGENT_FIX = {
225
+ "com.trantor.duty": "trantor duty up (rewrites the duty launcher to resolve node at exec time)",
226
+ "com.trantor.wake-nudge": "trantor duty up (reinstalls the wake-nudge keepalive)",
227
+ "com.trantor.disk": "trantor disk install (rewrites the daily disk janitor job)",
228
+ "com.trantor.herdr": "trantor herdr install (rewrites herdr's login agent and restore script)",
229
+ "com.trantor.seats": "trantor seats login install (rewrites the seat-restore login job)",
230
+ "com.trantor.hub": "bash deploy/setup.sh (reinstalls the hub service, which resolves node at exec time)",
231
+ };
232
+ const REPORT_FAULT = (name, finding, fix) => {
233
+ const message = finding.kind === "cellar"
234
+ ? `pins a versioned Homebrew Cellar path — ${finding.path} (the next brew upgrade deletes it; launchd restarts the job into exit 126)`
235
+ : `program path does not exist — ${finding.path} (a Homebrew node upgrade deletes versioned paths)`;
236
+ warn(`${name}: ${message}`, fix);
237
+ };
238
+ let agents = 0, faults = 0;
239
+ if (!existsSync(AGENTS_DIR)) {
240
+ note("launch agents: no ~/Library/LaunchAgents on this machine (launchd is macOS-only) — nothing to check");
241
+ } else {
242
+ for (const f of readdirSync(AGENTS_DIR).filter(n => /^com\.trantor\..+\.plist$/.test(n)).sort()) {
243
+ const label = f.replace(/\.plist$/, "");
244
+ const fix = AGENT_FIX[label] || `re-run the command that installed ${label}`;
245
+ let text = "";
246
+ try { text = readFileSync(join(AGENTS_DIR, f), "utf8"); } catch { continue; }
247
+ agents++;
248
+ for (const finding of launcherPathFindings(plistPinnedPaths(text))) { REPORT_FAULT(label, finding, fix); faults++; }
249
+ }
250
+ if (!agents) note("launch agents: no com.trantor.* jobs installed in ~/Library/LaunchAgents (the duty keepalive, disk janitor and hub service each add one)");
251
+ }
252
+ // The two launcher scripts a plist execs carry their node INSIDE, not in ProgramArguments —
253
+ // the plist only proves the script exists; the script must prove its own programs do. They are
254
+ // checked even without LaunchAgents: a --window duty seat has a launcher but no plist.
255
+ const scripts = [
256
+ ["duty launcher (duty-launch.sh)", join(H, ".agent-bus", "duty-launch.sh"), AGENT_FIX["com.trantor.duty"]],
257
+ ["herdr restore script (trantor-herdr-restore.sh)", join(AGENTS_DIR, "trantor-herdr-restore.sh"), AGENT_FIX["com.trantor.herdr"]],
258
+ ];
259
+ for (const [name, path, fix] of scripts) {
260
+ if (!existsSync(path)) continue;
261
+ let text = "";
262
+ try { text = readFileSync(path, "utf8"); } catch { continue; }
263
+ for (const finding of launcherPathFindings(scriptPinnedPaths(text))) { REPORT_FAULT(name, finding, fix); faults++; }
264
+ }
265
+ if (agents && !faults) ok(`every com.trantor.* launch agent's program path exists (${agents} agent${agents === 1 ? "" : "s"})`);
266
+ }
267
+
268
+ // #14655: the feature canary's last run, so a feature that went dark shows up here too.
269
+ section("feature canary");
270
+ for (const row of canaryDoctorRows({ lastRun: readLastRun(resolveBusDir()), installed: existsSync(join(H, "Library", "LaunchAgents", `${CANARY_LABEL}.plist`)) })) {
271
+ row.level === "ok" ? ok(row.message) : row.level === "note" ? note(row.message) : warn(row.message, row.fix);
272
+ }
273
+
182
274
  // claude plugin
183
275
  section("claude (the orchestrator)");
184
276
  if (!has("claude")) warn("claude CLI not found", "install Claude Code: https://claude.com/claude-code");
package/bin/duty.mjs CHANGED
@@ -20,6 +20,7 @@ import { homedir } from "node:os";
20
20
  import { fileURLToPath } from "node:url";
21
21
  import { loadOrCreate } from "../lib/identity.mjs";
22
22
  import { sfetchJson } from "../lib/signed-fetch.mjs";
23
+ import { nodeResolverSnippet } from "../lib/launch-node.mjs";
23
24
 
24
25
  const ROOT = dirname(dirname(fileURLToPath(import.meta.url)));
25
26
  const BUS = process.env.AGENT_BUS_DIR || join(homedir(), ".agent-bus");
@@ -166,11 +167,13 @@ function keepalivePlistBody() {
166
167
  }
167
168
 
168
169
  // A launcher carries the rules because their quotes, backticks and dollar signs cannot safely ride
169
- // a command line. Single-quote every value so bash 3.2 treats them literally.
170
+ // a command line. Single-quote every value so bash 3.2 treats them literally. #14646: the node is
171
+ // resolved at EXEC time (command -v node against the PATH exported above) — a pinned execPath is
172
+ // a versioned Homebrew Cellar path that `brew upgrade node` deletes out from under launchd.
170
173
  function writeLauncher(env) {
171
174
  const shquote = (v) => `'${String(v).replace(/'/g, `'\\''`)}'`;
172
175
  const exports = Object.entries(env).map(([k, v]) => `export ${k}=${shquote(v)}`).join("\n");
173
- writeFileSync(LAUNCHER, `#!/bin/bash\n# written by \`trantor duty up\` — safe to delete when the seat is down\n${exports}\nexec ${JSON.stringify(process.execPath)} ${JSON.stringify(join(ROOT, "bin", "crew-runner.mjs"))} ${AGENT} ${JSON.stringify(DIR)}\n`, { mode: 0o700 });
176
+ writeFileSync(LAUNCHER, `#!/bin/bash\n# written by \`trantor duty up\` — safe to delete when the seat is down\n${exports}\n${nodeResolverSnippet()}\nexec "$NODE_BIN" ${shquote(join(ROOT, "bin", "crew-runner.mjs"))} ${shquote(AGENT)} ${shquote(DIR)}\n`, { mode: 0o700 });
174
177
  }
175
178
 
176
179
  // The old headless start: a detached child of whoever ran `up`. No keepalive — it dies with a
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+ import { signedGet } from "../hooks/lib/api.mjs";
3
+ import { aggregateFitness, formatFitness } from "../lib/fitness.mjs";
4
+
5
+ const args = process.argv.slice(2);
6
+ const at = args.indexOf("--project");
7
+ const project = at >= 0 ? String(args[at + 1] || "") : "";
8
+ const query = `?limit=1000${project ? `&project=${encodeURIComponent(project)}` : ""}`;
9
+ const response = await signedGet(`/telemetry/attempts${query}`, { project: project || undefined, timeoutMs: 5000 });
10
+ if (!response.ok || !Array.isArray(response.json?.attempts)) {
11
+ console.error(`fitness unavailable: ${response.json?.error || response.reason || `hub ${response.status}`}`);
12
+ process.exit(1);
13
+ }
14
+ const report = aggregateFitness(response.json.attempts);
15
+ console.log(args.includes("--json") ? JSON.stringify(report, null, 2) : formatFitness(report));