trantor 0.18.143 → 0.18.146

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 (61) 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 +148 -0
  6. package/bin/capacity.mjs +109 -0
  7. package/bin/cli.mjs +5 -0
  8. package/bin/crew-runner.mjs +98 -17
  9. package/bin/disk.mjs +9 -6
  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 +33 -6
  16. package/configs/dispatcher-policy.json +84 -0
  17. package/deploy/com.trantor.hub.plist +15 -3
  18. package/deploy/node-path.sh +11 -4
  19. package/deploy/setup.sh +6 -13
  20. package/docs/FEATURES.md +45 -0
  21. package/hub/auth.mjs +3 -1
  22. package/hub/review-store.mjs +48 -0
  23. package/hub/routes/capacity.mjs +77 -0
  24. package/hub/routes/cards.mjs +7 -2
  25. package/hub/routes/insights.mjs +41 -6
  26. package/hub/routes/messages.mjs +16 -60
  27. package/hub/routes/reviews.mjs +86 -0
  28. package/hub/send-message.mjs +51 -0
  29. package/hub.mjs +5 -1
  30. package/kimi.plugin.json +1 -1
  31. package/lib/app-screenshot.mjs +155 -0
  32. package/lib/canary/canary.mjs +225 -0
  33. package/lib/canary/probes.mjs +197 -0
  34. package/lib/canary/registry.mjs +179 -0
  35. package/lib/capacity-machines.mjs +79 -0
  36. package/lib/capacity.mjs +189 -0
  37. package/lib/classify-failure.mjs +14 -8
  38. package/lib/discovery/SOURCES.md +30 -0
  39. package/lib/discovery/claude.mjs +27 -0
  40. package/lib/discovery/codex.mjs +74 -0
  41. package/lib/discovery/common.mjs +56 -0
  42. package/lib/discovery/gemini.mjs +27 -0
  43. package/lib/discovery/index.mjs +104 -0
  44. package/lib/discovery/kimi.mjs +10 -0
  45. package/lib/discovery/opencode.mjs +19 -0
  46. package/lib/discovery/qwen.mjs +16 -0
  47. package/lib/disk.mjs +14 -4
  48. package/lib/dispatcher/policy.mjs +41 -0
  49. package/lib/dispatcher/schemas.mjs +218 -0
  50. package/lib/dispatcher/snapshot.mjs +70 -0
  51. package/lib/dispatcher/store.mjs +111 -0
  52. package/lib/fitness.mjs +97 -0
  53. package/lib/launch-node.mjs +96 -0
  54. package/lib/launchd.mjs +61 -0
  55. package/lib/machine-health.mjs +80 -1
  56. package/lib/review-hunks.mjs +41 -0
  57. package/lib/seat-liveness.mjs +41 -0
  58. package/lib/session-liveness.mjs +23 -0
  59. package/lib/turn-usage.mjs +154 -27
  60. package/mcp.mjs +14 -1
  61. 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.146"
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.146",
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.146",
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,148 @@
1
+ #!/usr/bin/env node
2
+ // trantor canary — run every docs/FEATURES.md probe (#14655).
3
+ // trantor canary [--json] [--daily] probes only; --daily also records the run and posts new failures
4
+ // trantor canary install | uninstall | plist | check | attach <path…> | brief (#14670: docs/FEATURES.md)
5
+ import { mkdirSync, writeFileSync, rmSync, existsSync } from "node:fs";
6
+ import { join } from "node:path";
7
+ import { homedir } from "node:os";
8
+ import { execFileSync } from "node:child_process";
9
+ import { fileURLToPath } from "node:url";
10
+ import { busDir, resolveHub, knownProjects, checkoutFor, readConfig } from "../lib/project.mjs";
11
+ import { loadRegistry, validateRegistry, registryHash, attachProbes } from "../lib/canary/registry.mjs";
12
+ import { PROBES } from "../lib/canary/probes.mjs";
13
+ import {
14
+ runCanary, tally, advanceEpisodes, markDelivered, episodeMessage, readEpisodes, readLastRun, recordRun,
15
+ regressionBrief, defaultContext, canaryPlist, CANARY_LABEL,
16
+ } from "../lib/canary/canary.mjs";
17
+ import { reloadLaunchAgent } from "../lib/launchd.mjs";
18
+
19
+ const SELF = fileURLToPath(import.meta.url);
20
+ const PROJECT = "trantor";
21
+ const args = process.argv.slice(2);
22
+ const cmd = args.find((a) => !a.startsWith("--")) || "run";
23
+ const JSON_MODE = args.includes("--json");
24
+ const DAILY = args.includes("--daily");
25
+ const PLIST_PATH = join(homedir(), "Library", "LaunchAgents", `${CANARY_LABEL}.plist`);
26
+
27
+ const launchctl = (argv) => execFileSync("launchctl", argv, { stdio: ["ignore", "pipe", "pipe"], encoding: "utf8" });
28
+
29
+ if (cmd === "plist") {
30
+ process.stdout.write(canaryPlist({ script: SELF, busDir: busDir() }));
31
+ process.exit(0);
32
+ }
33
+
34
+ if (cmd === "install") {
35
+ if (process.platform !== "darwin") { console.error("trantor canary install: launchd is macOS-only; run `trantor canary --daily` from cron elsewhere"); process.exit(1); }
36
+ mkdirSync(join(busDir(), "logs"), { recursive: true });
37
+ mkdirSync(join(homedir(), "Library", "LaunchAgents"), { recursive: true });
38
+ writeFileSync(PLIST_PATH, canaryPlist({ script: SELF, busDir: busDir() }), { mode: 0o644 });
39
+ // #14661: reload through bootout-wait-bootstrap; a failed bootstrap is an error, not a stack.
40
+ const reloaded = reloadLaunchAgent({ label: CANARY_LABEL, plist: PLIST_PATH, domain: `gui/${process.getuid()}` });
41
+ if (!reloaded.ok) { console.error(reloaded.error); process.exit(1); }
42
+ console.log(`installed: ${PLIST_PATH}\nruns every day at 09:30; failures post to the ${PROJECT} lane and the app once per episode`);
43
+ process.exit(0);
44
+ }
45
+
46
+ if (cmd === "uninstall") {
47
+ try { launchctl(["bootout", `gui/${process.getuid()}/${CANARY_LABEL}`]); } catch { /* already stopped */ }
48
+ rmSync(PLIST_PATH, { force: true });
49
+ console.log(`${CANARY_LABEL} removed`);
50
+ process.exit(0);
51
+ }
52
+
53
+ const rows = loadRegistry(process.env.TRANTOR_FEATURES_PATH || undefined);
54
+ const valid = validateRegistry(rows, PROBES);
55
+
56
+ if (cmd === "check") {
57
+ const hash = registryHash(rows);
58
+ if (JSON_MODE) console.log(JSON.stringify({ ...valid, registryHash: hash, rows: rows.length, mapped: rows.filter((r) => r.mapped).length }, null, 2));
59
+ else {
60
+ for (const e of valid.errors) console.log(` ✗ ${e}`);
61
+ console.log(`${rows.length} features, ${rows.filter((r) => r.mapped).length} mapped, registry ${hash.slice(0, 12)}${valid.ok ? ", mappings valid" : `, ${valid.errors.length} malformed`}`);
62
+ }
63
+ process.exit(valid.ok ? 0 : 1);
64
+ }
65
+
66
+ if (cmd === "attach") {
67
+ const at = args.indexOf("--features");
68
+ const featureArg = at >= 0 ? args[at + 1] || "" : "";
69
+ const claims = args.slice(1).filter((a, i, all) => !a.startsWith("--") && all[i - 1] !== "--features");
70
+ const out = attachProbes({ rows, claims, declaredFeatures: featureArg.split(",").map((s) => s.trim()).filter(Boolean) });
71
+ if (JSON_MODE) console.log(JSON.stringify(out, null, 2));
72
+ else {
73
+ console.log(out.probeIds.length ? `required probes: ${out.probeIds.map((p) => `${p} (${out.hosts[p]})`).join(", ")}` : "required probes: none");
74
+ console.log(`features: ${out.features.join(", ") || "none"} registry ${out.registryHash.slice(0, 12)}`);
75
+ for (const p of out.problems) console.log(` ✗ ${p}`);
76
+ }
77
+ process.exit(out.ok && valid.ok ? 0 : 1);
78
+ }
79
+
80
+ if (cmd === "brief") {
81
+ const lines = regressionBrief({ episodes: readEpisodes(busDir()), lastRun: readLastRun(busDir()) });
82
+ console.log(lines.length ? lines.join("\n") : "no open regressions");
83
+ process.exit(0);
84
+ }
85
+
86
+ if (cmd !== "run") {
87
+ console.error("usage: trantor canary [--json] [--daily] | check | attach <path…> | brief | install | uninstall | plist");
88
+ process.exit(2);
89
+ }
90
+
91
+ async function appRead() {
92
+ const { appRead: read } = await import("../lib/app-screenshot.mjs");
93
+ return read({ window: "main", project: "" });
94
+ }
95
+
96
+ // Owner identity, not a fresh agent key: the hub enforces enrollment, and a message to the owner is
97
+ // what raises the app's notification (shared/notify.ts), while the broadcast lands in the lane.
98
+ async function post(text) {
99
+ const cfg = readConfig();
100
+ const owner = String(cfg.ownerIdentity || "");
101
+ if (!owner) throw new Error("no ownerIdentity in ~/.agent-bus/config.json to sign with");
102
+ const { loadOrCreate } = await import("../lib/identity.mjs");
103
+ const { sfetchJson } = await import("../lib/signed-fetch.mjs");
104
+ const identity = loadOrCreate(owner, "human");
105
+ if (!identity) throw new Error(`owner identity ${owner} has no usable key on this machine`);
106
+ const hub = resolveHub(PROJECT);
107
+ for (const to of ["all", owner]) {
108
+ const r = await sfetchJson(`${hub}/send`, { payload: { from: owner, to, project: PROJECT, kind: "canary", text, wake: false }, identity, signal: AbortSignal.timeout(10000) });
109
+ if (!r?.ok) throw new Error(`hub refused the canary message to ${to} (HTTP ${r?.status ?? "?"})`);
110
+ }
111
+ }
112
+
113
+ const bus = busDir();
114
+ const ctx = defaultContext({ busDir: bus, hub: resolveHub(PROJECT), knownProjects, checkoutFor, appRead });
115
+ const run = await runCanary({ rows, ctx });
116
+ if (!valid.ok) {
117
+ run.results.push({ id: "registry", probeId: "registry", host: "any", feature: "docs/FEATURES.md mappings", status: "fail", detail: valid.errors.join("; ") });
118
+ }
119
+ const t = tally(run.results);
120
+
121
+ if (DAILY) {
122
+ const step = advanceEpisodes(readEpisodes(bus), run);
123
+ const text = episodeMessage(step, run);
124
+ const record = { ...run, posted: [], registryHash: registryHash(rows) };
125
+ const ids = step.announce.map((r) => r.id);
126
+ let episodes = step.episodes;
127
+ if (text) {
128
+ try { await post(text); record.posted = ids; episodes = markDelivered(episodes, ids, true); }
129
+ catch (error) {
130
+ // #14670: the episode stays open marked undelivered, so the next run announces it again and the
131
+ // brief shows the alert never landed, instead of the failure going quiet.
132
+ episodes = markDelivered(episodes, ids, false, error.message);
133
+ record.postError = error.message;
134
+ console.error(`canary: could not post: ${error.message}`);
135
+ }
136
+ }
137
+ recordRun(bus, record, episodes);
138
+ }
139
+
140
+ if (JSON_MODE) {
141
+ console.log(JSON.stringify({ ...run, ...t }, null, 2));
142
+ } else {
143
+ const mark = { pass: "✓", fail: "✗", skip: "–" };
144
+ console.log(`TRANTOR CANARY ${new Date(run.ts).toISOString().slice(0, 16).replace("T", " ")} UTC\n`);
145
+ for (const r of run.results) console.log(` ${mark[r.status]} ${r.status.padEnd(4)} ${r.id.padEnd(24)} ${r.detail}`);
146
+ console.log(`\n${t.pass} pass, ${t.fail} fail, ${t.skip} skip${existsSync(PLIST_PATH) ? "" : " (no daily job: trantor canary install)"}`);
147
+ }
148
+ process.exit(DAILY ? 0 : t.fail ? 1 : 0);
@@ -0,0 +1,109 @@
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
+ const fault = s.fault ? ` · FAULT ${s.fault}: ${s.unconsumedWork?.count || 0} direct message(s) unconsumed for ${fmtAge(s.unconsumedWork?.ageMs)}` : "";
107
+ console.log(` ${s.session} ${live} · ${model} · ${last}${s.machine ? ` · ${s.machine}` : ""}${fault}`);
108
+ if (s.lastTurn?.stderrTail) console.log(` redacted stderr tail:\n${s.lastTurn.stderrTail.split("\n").map(line => ` ${line}`).join("\n")}`);
109
+ }
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>"