trantor 0.18.133 → 0.18.135

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 (46) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +10 -3
  4. package/bin/adopt.mjs +2 -2
  5. package/bin/cli.mjs +42 -0
  6. package/bin/connect.mjs +14 -1
  7. package/bin/crew/models.mjs +4 -1
  8. package/bin/crew/open.mjs +18 -8
  9. package/bin/crew/worktrees.mjs +3 -3
  10. package/bin/crew-runner.mjs +22 -7
  11. package/bin/crew.mjs +7 -2
  12. package/bin/doctor.mjs +14 -3
  13. package/bin/helper.mjs +119 -0
  14. package/bin/herdr-agent.mjs +67 -13
  15. package/bin/new.mjs +2 -2
  16. package/bin/seats.mjs +3 -2
  17. package/bin/slop-gate.mjs +1 -1
  18. package/bin/takeover.mjs +2 -2
  19. package/bin/turn-watchdog.mjs +2 -1
  20. package/deploy/node-path.sh +18 -0
  21. package/deploy/setup.sh +11 -3
  22. package/engine/bin/scrooge +9 -0
  23. package/hooks/lib/handoff.mjs +10 -3
  24. package/hooks/lib/start-gates.mjs +18 -0
  25. package/hooks/precompact.mjs +6 -2
  26. package/hooks/sessionstart.mjs +11 -6
  27. package/hub/routes/insights.mjs +77 -30
  28. package/hub/routes/messages.mjs +2 -1
  29. package/hub/store.mjs +140 -2
  30. package/kimi/bin/baton-close.mjs +108 -0
  31. package/kimi/bin/lib/handoff.mjs +119 -0
  32. package/kimi/bin/write-handoff.mjs +31 -0
  33. package/kimi/bridge.mjs +219 -0
  34. package/kimi/skills/crew/SKILL.md +119 -0
  35. package/kimi/skills/handoff/SKILL.md +44 -0
  36. package/kimi/skills/research/SKILL.md +49 -0
  37. package/kimi.plugin.json +66 -0
  38. package/lib/agent-preferences.mjs +15 -0
  39. package/lib/balances.mjs +6 -1
  40. package/lib/enroll.mjs +20 -2
  41. package/lib/jsonc.mjs +37 -0
  42. package/lib/project.mjs +21 -2
  43. package/lib/seat-compaction.mjs +26 -4
  44. package/lib/store-pg.mjs +64 -0
  45. package/lib/telemetry-ship.mjs +193 -0
  46. package/package.json +3 -1
@@ -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.17.67"
9
+ "version": "0.18.135"
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.17.67",
16
+ "version": "0.18.135",
17
17
  "author": {
18
18
  "name": "Sasha Bogojevic"
19
19
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trantor",
3
- "version": "0.18.133",
3
+ "version": "0.18.135",
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
@@ -372,8 +372,9 @@ board — no code change, no waiting for us to add it.
372
372
 
373
373
  A PreCompact hook writes a rich handoff before Claude Code compacts; a fresh session in the
374
374
  same project **takes over with a brand-new full context window**. Works manually from any
375
- agent via `relay_handoff`. Optional macOS auto-prompt (`autoHandoffPrompt` in
376
- `~/.agent-bus/config.json`) offers to open the fresh session for you, with a timeout.
375
+ agent via `relay_handoff`. Optional macOS auto-prompt (`"autoHandoffPrompt": true` in
376
+ `~/.agent-bus/config.json`, off by default since 0.18.135) opens the fresh session for you in
377
+ Terminal.app. Without it the handoff is still written, and the hook says how to continue.
377
378
 
378
379
  Since 0.18.18 the succession is a machine, not a ritual: at 90% context the running agent is
379
380
  told to finish or checkpoint and author the boundary handoff itself; the app's banner counts
@@ -440,7 +441,8 @@ trantor setup | doctor | connect | profile | provider | models
440
441
  the AXe pin.
441
442
 
442
443
  - **`trantor new <name>`** — project genesis in one command: makes the dir under your dev root
443
- (`TRANTOR_DEV_ROOT` or `~/development`), git on main (or `--from <git-url>`, or `--adopt` an
444
+ (`TRANTOR_DEV_ROOT`, else the Projects folder chosen in the app's Settings, stored as
445
+ `projectsRoot` in `~/.agent-bus/config.json`, else `~/development`), git on main (or `--from <git-url>`, or `--adopt` an
444
446
  existing folder), installs the auto-card hook, posts the brief to the hub, and opens the first
445
447
  card "genesis: <name>". `--json` for machines. It never spawns a session — firing the crew
446
448
  stays your call. Two paths in: **blank** (no brief) wakes the orchestrator plainly and you work
@@ -470,6 +472,11 @@ trantor setup | doctor | connect | profile | provider | models
470
472
  then logs, tracked panes, live pids): `live`, `dead-quota`, `dead-auth`, `dead-crash`,
471
473
  `no-runner`, or `no-pane`, each with the advice that actually fits. A quota-dead seat is
472
474
  indistinguishable from a broken bus until you read the err file — this reads it for you.
475
+ - **`trantor telemetry ship [--all]`** sends turn history to the hub: this seat's log, or every
476
+ log in `~/.agent-bus/logs` with `--all`. Runners report each turn on their own after it ends;
477
+ this command is for history written before a hub could receive it, and for a hub that was
478
+ unreachable for a while. Safe to run twice: the hub ignores rows it already has. See
479
+ `docs/CONTRACT-turn-telemetry.md`.
473
480
  - **`trantor down`** kills crew processes via their ttys and closes windows without macOS
474
481
  "Terminate?" dialogs.
475
482
 
package/bin/adopt.mjs CHANGED
@@ -15,7 +15,7 @@ import { readdirSync, statSync, existsSync, readFileSync, writeFileSync, mkdirSy
15
15
  import { execFileSync } from "node:child_process";
16
16
  import { join, dirname, basename } from "node:path";
17
17
  import { homedir } from "node:os";
18
- import { resolveProject, writeOrchSession, checkoutFor, devRootFor, readOrchSession } from "../lib/project.mjs";
18
+ import { resolveProject, writeOrchSession, checkoutFor, localCheckoutFor, devRootFor, readOrchSession } from "../lib/project.mjs";
19
19
 
20
20
  const D = "\x1b[2m", B = "\x1b[1m", Y = "\x1b[33m", G = "\x1b[32m", R = "\x1b[0m";
21
21
  const args = process.argv.slice(2);
@@ -24,7 +24,7 @@ const flag = (n) => { const i = args.indexOf(n); return i >= 0 ? args[i + 1] : n
24
24
  const project = args.find(a => !a.startsWith("--") && args[args.indexOf(a) - 1] !== "--session")
25
25
  || resolveProject(process.cwd());
26
26
  // The checkout is found by the project's ID (#6724): a renamed directory still answers.
27
- const dir = checkoutFor(project);
27
+ const dir = localCheckoutFor(project);
28
28
  if (!dir) {
29
29
  console.error(`no local checkout for ${project} (looked in ${devRootFor()})`);
30
30
  process.exit(1);
package/bin/cli.mjs CHANGED
@@ -137,9 +137,49 @@ switch (cmd) {
137
137
  break;
138
138
  }
139
139
  case "state": run("bin/state.mjs"); break;
140
+ case "helper": run("bin/helper.mjs"); break;
140
141
  case "seats": case "seat": run("bin/seats.mjs"); break;
141
142
  case "seat-why": case "why": run("bin/seat-why.mjs"); break;
142
143
  case "seat-record": run("bin/seat-record.mjs"); break;
144
+ case "telemetry": {
145
+ // #14067: `trantor telemetry ship` is how existing history reaches the hub — this seat's log,
146
+ // or every *.jsonl in the logs folder with --all. Always from the start of the file: a re-run
147
+ // must come back as duplicates, not as silence.
148
+ if (args[0] !== "ship") { console.error("usage: trantor telemetry ship [--all]"); process.exit(1); }
149
+ const { shipTurnRows, seatForTelemetryFile, telemetryDir, telemetryFiles, telemetryFileFor } = await import(join(ROOT, "lib/telemetry-ship.mjs"));
150
+ const { sessionContext } = await import(join(ROOT, "hooks/lib/api.mjs"));
151
+ // History rows carry no machine: stamp this machine's label, as the runner does for new rows.
152
+ const { machineLabel } = await import(join(ROOT, "lib/machine-label.mjs"));
153
+ const { homedir } = await import("node:os");
154
+ let machineConfig = {};
155
+ try { machineConfig = JSON.parse(readFileSync(join(process.env.AGENT_BUS_DIR || process.env.RELAY_DATA_DIR || join(homedir(), ".agent-bus"), "config.json"), "utf8")); } catch {}
156
+ const machine = machineLabel(machineConfig);
157
+ const report = (label, r) => {
158
+ if (r.ok) console.log(`${label}: stored ${r.stored} · duplicates ${r.duplicates} · dropped ${r.dropped}`);
159
+ else console.error(`${label}: FAILED — ${r.error}`);
160
+ return r.ok ? 0 : 1;
161
+ };
162
+ if (args.includes("--all")) {
163
+ const dir = telemetryDir();
164
+ const files = telemetryFiles();
165
+ if (!files.length) { console.log(`no telemetry logs in ${dir}`); break; }
166
+ let failed = 0;
167
+ for (const name of files) {
168
+ const seat = seatForTelemetryFile(join(dir, name));
169
+ if (!seat) { console.log(`${name}: no seat rows — skipped`); continue; }
170
+ failed += report(`${seat.persona}-${seat.project}`, await shipTurnRows({ ...seat, fromStart: true, machine }));
171
+ }
172
+ process.exitCode = failed ? 1 : 0;
173
+ break;
174
+ }
175
+ const { session, project } = sessionContext();
176
+ const persona = (session.split(":")[0] || session);
177
+ const file = telemetryFileFor(persona, project);
178
+ if (!existsSync(file)) { console.error(`no telemetry log for ${persona}-${project} at ${file}`); process.exit(1); }
179
+ const seat = seatForTelemetryFile(file) || { persona, project };
180
+ process.exitCode = report(`${seat.persona}-${seat.project}`, await shipTurnRows({ ...seat, fromStart: true, machine }));
181
+ break;
182
+ }
143
183
  case "orchestrate": run("bin/orchestrate.mjs"); break;
144
184
  case "app": run("bin/app.mjs"); break;
145
185
  case "patrol": run("bin/patrol.mjs"); break;
@@ -249,6 +289,7 @@ switch (cmd) {
249
289
  trantor secrets provider keys in the OS keychain: list · set <NAME> (stdin) · remove <NAME> · migrate [--dry-run]
250
290
  trantor keys identity keys in the OS keychain: status · migrate [--dry-run] · prune [--apply] [--idle-days N]
251
291
  trantor models browse live models behind each seat + the router's pick per difficulty
292
+ trantor helper run a visible helper pane | list --project <name> | stop <pane>
252
293
  trantor up … spawn a crew here: trantor up codex kimi deepseek:deepseek glm:zai-coding-plan
253
294
  trantor open host THIS session as the project's orchestrator pane (trantor down spares it)
254
295
  trantor herdr install|remove|status the login agent that keeps panes alive across a reboot
@@ -285,6 +326,7 @@ switch (cmd) {
285
326
  trantor state a seat's working memory: show <seat> <card> [--json] · validate · reset --force · gc [--apply]
286
327
  trantor seat-why WHY a seat is down (err file, logs, pids): seat-why <agent> [--json] — quota, auth, crash, or just no pane
287
328
  trantor seat-record the per-project seat record the advisor benches from (✓/∅/↩ per difficulty) — [--project p] [--reset <seat>] [--json]
329
+ trantor telemetry ship send turn history to the hub — this seat's log, or every log with --all; prints stored/duplicates/dropped per file
288
330
  trantor watch live bus feed in the terminal
289
331
  trantor inbox THIS session's unread bus messages, signed (works under enforce) — [--all] [--consume] [--json]
290
332
  trantor policy the autonomy ladder: show | set <project> <1-4> | link <a> <b> --reason "<why>"
package/bin/connect.mjs CHANGED
@@ -7,6 +7,7 @@ import { join, dirname } from "node:path";
7
7
  import { homedir } from "node:os";
8
8
  import { execSync } from "node:child_process";
9
9
  import { fileURLToPath } from "node:url";
10
+ import { parseJsonc } from "../lib/jsonc.mjs";
10
11
  import { resolveProjectInfo, resolveHubInfo, gitRoot, writeProjectId, PROJECT_MARKER } from "../lib/project.mjs";
11
12
 
12
13
  const DRY = process.argv.includes("--dry-run");
@@ -31,10 +32,22 @@ const report = (cli, status, detail = "") => out.push({ cli, status, detail });
31
32
 
32
33
  function patchJson(path, mutate) {
33
34
  const exists = existsSync(path);
34
- const d = exists ? JSON.parse(readFileSync(path, "utf8")) : {};
35
+ let d, raw = "";
36
+ try { raw = exists ? readFileSync(path, "utf8") : ""; d = exists ? parseJsonc(raw) : {}; }
37
+ catch { return "unparseable, skipped (left untouched)"; }
35
38
  const before = JSON.stringify(d);
36
39
  mutate(d);
37
40
  if (JSON.stringify(d) === before) return "already wired";
41
+ // A JSONC file (comments, trailing commas) would lose its comments if rewritten as JSON:
42
+ // leave it as the user wrote it and say what to add.
43
+ let strict = true;
44
+ try { if (exists) JSON.parse(raw); } catch { strict = false; }
45
+ if (!strict) {
46
+ // Name the keys only: the file can hold the user's own secrets, so no values are printed.
47
+ const was = parseJsonc(raw);
48
+ const keys = Object.keys(d).filter(k => JSON.stringify(d[k]) !== JSON.stringify(was[k]));
49
+ return `has comments, left untouched: add the Trantor entry under ${keys.join(", ") || "the top level"} by hand`;
50
+ }
38
51
  if (!DRY) {
39
52
  if (exists) backup(path); else mkdirSync(dirname(path), { recursive: true });
40
53
  writeFileSync(path, JSON.stringify(d, null, 2) + "\n");
@@ -1,6 +1,7 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { join } from "node:path";
3
- import { call } from "./core.mjs";
3
+ import { call, commandExists } from "./core.mjs";
4
+ import { seatCliProblem } from "../../lib/agent-preferences.mjs";
4
5
  import { resolveEffort } from "../../lib/model-catalog.mjs";
5
6
 
6
7
  function routeModel(ctx, provider, candidates, task, difficulty) {
@@ -22,6 +23,8 @@ function routeModel(ctx, provider, candidates, task, difficulty) {
22
23
 
23
24
  export function resolveModel(ctx, agent, provider, task, difficulty) {
24
25
  const result = call("opencode", ["models", provider], { env: ctx.env });
26
+ const missing = seatCliProblem(agent, cli => commandExists(cli, ctx.env));
27
+ if (!ctx.dry && !result.ok && missing && !commandExists("opencode", ctx.env)) throw new Error(missing);
25
28
  const candidates = result.ok ? result.stdout.split(/\s+/).filter(Boolean).join(" ") : "";
26
29
  let model = routeModel(ctx, provider, candidates, task, difficulty);
27
30
  // An unavailable router must not erase seats from a layout preview. Never launch an unresolved model.
package/bin/crew/open.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import { randomUUID } from "node:crypto";
2
- import { existsSync, openSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
2
+ import { existsSync, mkdirSync, openSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
3
3
  import { tmpdir } from "node:os";
4
- import { basename, join } from "node:path";
5
- import { spawn, execSync } from "node:child_process";
4
+ import { basename, dirname, isAbsolute, join } from "node:path";
5
+ import { spawn, execSync, execFileSync } from "node:child_process";
6
6
  import { call, parseJsonOutput } from "./core.mjs";
7
7
  import { createWorkspace, herdrCall, paneAlive, reportAgent, splitPane, workspaceList, workspacePane } from "./herdr.mjs";
8
8
  import { dropState, readRows, recordState } from "./state.mjs";
@@ -218,16 +218,26 @@ function hostPane(ctx, chosen, id) {
218
218
  // graph to serve. Non-blocking — the pane opens now, the ~7s build lands in the background; a no-op
219
219
  // if graft isn't installed or the index already exists (the graph self-refreshes per query after the
220
220
  // first build). Keeps the 20MB index out of the project's git.
221
+ // Hide graft/ through .git/info/exclude, never the user's tracked .gitignore (#14322). Returns the file written, "" when not a git checkout.
222
+ export function excludeGraftLocally(dir) {
223
+ try {
224
+ const out = execFileSync("git", ["-C", dir, "rev-parse", "--git-path", "info/exclude"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
225
+ if (!out) return "";
226
+ const file = isAbsolute(out) ? out : join(dir, out);
227
+ const cur = existsSync(file) ? readFileSync(file, "utf8") : "";
228
+ if (/^\/?graft\/?$/m.test(cur)) return file;
229
+ mkdirSync(dirname(file), { recursive: true });
230
+ writeFileSync(file, cur + (cur && !cur.endsWith("\n") ? "\n" : "") + "graft/\n");
231
+ return file;
232
+ } catch { return ""; }
233
+ }
234
+
221
235
  export function maybeBuildGraft(dir) {
222
236
  if (!dir) return;
223
237
  try { execSync("command -v graft", { stdio: "ignore", shell: "/bin/sh" }); } catch { return; }
224
238
  try {
225
239
  if (existsSync(join(dir, "graft", ".graph"))) return;
226
- const gi = join(dir, ".gitignore");
227
- try {
228
- const cur = existsSync(gi) ? readFileSync(gi, "utf8") : "";
229
- if (!/^graft\/?$/m.test(cur)) writeFileSync(gi, cur + (cur && !cur.endsWith("\n") ? "\n" : "") + "graft/\n");
230
- } catch {}
240
+ excludeGraftLocally(dir);
231
241
  // The build is backgrounded, so its exit code cannot gate the pane, but a failure has to land
232
242
  // SOMEWHERE: under stdio:"ignore" a graft without native parsers (see deploy/setup.sh) failed in
233
243
  // silence while the line below still claimed an index was being built.
@@ -1,7 +1,7 @@
1
1
  import { basename, join } from "node:path";
2
2
  import { existsSync } from "node:fs";
3
3
  import { call } from "./core.mjs";
4
- import { checkoutFor, readProjectId } from "../../lib/project.mjs";
4
+ import { checkoutFor, localCheckoutFor, devRootFor, readProjectId } from "../../lib/project.mjs";
5
5
 
6
6
  function gitRoot(dir) {
7
7
  const result = call("git", ["-C", dir, "rev-parse", "--show-toplevel"]);
@@ -22,12 +22,12 @@ export function resolveOrchestratorDir(ctx, projectArg) {
22
22
  }
23
23
  if (!projectArg || target === here) return { dir: ctx.dir, project: target };
24
24
  // By the project's id (#6724): a renamed checkout carries its marker and still answers.
25
- const targetDir = checkoutFor(target, { ...ctx.env, HOME: ctx.home });
25
+ const targetDir = localCheckoutFor(target, ctx.dir, { ...ctx.env, HOME: ctx.home });
26
26
  if (targetDir) {
27
27
  console.error(`— opening ${target} in its checkout: ${targetDir} —`);
28
28
  return { dir: targetDir, project: target };
29
29
  }
30
- throw new Error(`trantor open: '${target}' has no checkout under ${ctx.env.TRANTOR_DEV_ROOT || join(ctx.home, "development")} — cd into the project first`);
30
+ throw new Error(`trantor open: '${target}' has no checkout under ${devRootFor({ ...ctx.env, HOME: ctx.home })} — cd into the project first`);
31
31
  }
32
32
 
33
33
  function linkedByTest(env, badge, project) {
@@ -17,6 +17,7 @@ import { signedHeaders } from "../lib/signed-fetch.mjs";
17
17
  import { ensureEnrolled } from "../lib/enroll.mjs";
18
18
  import { redactKeys } from "../lib/redact.mjs";
19
19
  import { writeTurnState } from "../lib/turnstate.mjs";
20
+ import { completeTurnRow, isTurnRow, shipTurnRows } from "../lib/telemetry-ship.mjs";
20
21
  import { alignSeatWorktree, applyWorktreeDeclaration, ensureSeatWorktree, provisioningLines, readWorktreeDeclaration } from "../lib/seat-worktree.mjs";
21
22
  import {
22
23
  AUTH_MARKER_RE, classifyFailure, looksLikeAuthDeath,
@@ -36,7 +37,7 @@ import {
36
37
  import { snapshotBeforeCut } from "./cut-snapshot.mjs";
37
38
  import { ocTurnUsage, dshTurnUsage, usageTotal, processedInput, codexStepInput, kimiStepInput, claudeStepInput } from "../lib/turn-usage.mjs";
38
39
  import { capConfig, capDecision, capHandoffPrompt, capPointerLine, capExhaustedNote } from "../lib/context-cap.mjs";
39
- import { ocCompactionContent, ocCompactionLogLine, readOpencodeUserConfig, seatMcpOverlay, seatConfigContent } from "../lib/seat-compaction.mjs";
40
+ import { ocCompactionContent, ocCompactionLogLine, readOpencodeUserConfig, seatMcpOverlay, seatPermissionOverlay, seatConfigContent } from "../lib/seat-compaction.mjs";
40
41
  import { seatSignalPrefix } from "../lib/seat-signal-guard.mjs";
41
42
  import { providerMismatch } from "../lib/seat-provider.mjs";
42
43
  import { burnCeiling, afterTurn, burnVerdict } from "../lib/burn-guard.mjs";
@@ -193,9 +194,18 @@ let TURN = releaseState?.turn || 0;
193
194
  // fence assignments against this stamp — cards assigned before it are a predecessor's (#12138).
194
195
  // Carried across the in-place release restart; a swap or a fresh `trantor up` stamps anew.
195
196
  const BOOT_TS = releaseState?.bootTs || Date.now();
196
- const telemetry = (rec) => { try { appendFileSync(join(LOGDIR, `${PERSONA}-${PROJ}.jsonl`), JSON.stringify(rec) + "\n"); } catch {} };
197
+ // #14067: the jsonl stays the write-ahead log; a TURN row is completed (id, v, machine, verdict
198
+ // cut) before it lands on disk, and every turn row drains to the hub right after it is written —
199
+ // never awaited, never able to fail the turn. Boot and text rows are recorded and never shipped.
200
+ const telemetry = (rec) => {
201
+ const row = isTurnRow(rec) ? completeTurnRow(rec, MACHINE_LABEL) : rec;
202
+ try { appendFileSync(join(LOGDIR, `${PERSONA}-${PROJ}.jsonl`), JSON.stringify(row) + "\n"); } catch {}
203
+ if (isTurnRow(rec)) void shipTurnRows({ persona: PERSONA, project: PROJ, hub: HUB, log, machine: MACHINE_LABEL });
204
+ };
197
205
  // The boot line records the HUB this runner bound to, so a split-brain is diagnosable from disk.
198
206
  telemetry({ ts: Date.now(), persona: PERSONA, agent: AGENT, project: PROJ, boot: true, hub: HUB, pid: process.pid, version: bootVersion });
207
+ // #14067: ship at boot too, so rows written while the hub was down go out without waiting for a turn.
208
+ void shipTurnRows({ persona: PERSONA, project: PROJ, hub: HUB, log, machine: MACHINE_LABEL });
199
209
  // A seat can open a terminal window on a machine whose owner never asked for one and does not know
200
210
  // what they are looking at. "◤ CLAUDE ◢ trantor crew · fleet" tells that person nothing: not what
201
211
  // started, not what it will do, not how to stop it. RUNNER_TITLE names it in full and RUNNER_ABOUT
@@ -882,7 +892,10 @@ function capStepProcessed(sinceMs) {
882
892
  const OC_COMPACTION_WINDOW = contextWindow(MODEL);
883
893
  const OC_COMPACTION = ocCompactionContent(process.env, OC_COMPACTION_WINDOW);
884
894
  // #11854: plus every non-relay MCP server of the user's opencode config switched off for the seat.
885
- const OC_SEAT_CONFIG = seatConfigContent(OC_COMPACTION, seatMcpOverlay(readOpencodeUserConfig()));
895
+ // #14048: and the heavy-gate shim folder, which this runner puts on the seat's PATH, made readable.
896
+ const OC_USER_CONFIG = readOpencodeUserConfig();
897
+ const HEAVY_SHIM_DIR = join(import.meta.dirname, "heavy-gate-shim");
898
+ const OC_SEAT_CONFIG = seatConfigContent(OC_COMPACTION, seatMcpOverlay(OC_USER_CONFIG), seatPermissionOverlay(HEAVY_SHIM_DIR, OC_USER_CONFIG));
886
899
 
887
900
  let sid = releaseState?.sid || runnerOption("resume");
888
901
  // #6206: the watchdog is DETACHED, so a runner that dies without ending it leaves an orphan
@@ -1100,6 +1113,7 @@ exit $turn_exit`;
1100
1113
  // so a handoff spawn would only leak an unmanaged interactive window.
1101
1114
  TRANTOR_NO_HANDOFF_SPAWN: "1", TRANTOR_NO_BATON_SPAWN: "1",
1102
1115
  TRANTOR_HEAVY_GATE_WAIT_DIR: HEAVY_WAIT_DIR,
1116
+ // Spelled out here, not HEAVY_SHIM_DIR: the turn drills run this function alone, without the module's constants (#14048).
1103
1117
  PATH: `${join(import.meta.dirname, "heavy-gate-shim")}:${process.env.PATH || ""}`,
1104
1118
  // #6206: the seat's transcript dir — a real CLI ignores it, a drill's fake CLI writes
1105
1119
  // its transcript lines there so the watchdog sees the liveness a real claude shows.
@@ -1118,11 +1132,7 @@ exit $turn_exit`;
1118
1132
  const cut = !!TURN_MAX_MS && (boxed || stallCut);
1119
1133
  // #7761: how far the watchdog moved the box, one EXTF row per extension. boxMs is the box the
1120
1134
  // turn actually had, so a ceiling cut reads as the ceiling, never as the 20-minute default.
1121
- let extensions = 0;
1122
- try { extensions = readFileSync(EXTF, "utf8").split("\n").filter(Boolean).length; } catch {}
1123
- const boxMs = TURN_MAX_MS + extensions * TURN_EXTEND_MS;
1124
1135
  try { unlinkSync(DEADLINEF); } catch {}
1125
- try { unlinkSync(EXTF); } catch {}
1126
1136
  // DRAIN before classifying, never on a CUT turn (the sweep killed the scrubber, its marker never
1127
1137
  // comes). bash 3.2 `wait` skips process substitutions, so wait for DRAINF, bounded.
1128
1138
  if (!cut) {
@@ -1132,6 +1142,11 @@ exit $turn_exit`;
1132
1142
  try { unlinkSync(DRAINF); } catch {}
1133
1143
  killWatchdog(); // #6206: turn over — the watchdog dies NOW, it does not sleep on
1134
1144
  try { unlinkSync(STAMPF); } catch {} // disarm any survivor: the stamp is gone
1145
+ // #14235: count extensions only after the watchdog is dead and disarmed, or it appends one more after this read and the assigner hears a notice the ledger lacks.
1146
+ let extensions = 0;
1147
+ try { extensions = readFileSync(EXTF, "utf8").split("\n").filter(Boolean).length; } catch {}
1148
+ const boxMs = TURN_MAX_MS + extensions * TURN_EXTEND_MS;
1149
+ try { unlinkSync(EXTF); } catch {}
1135
1150
  if (cut) {
1136
1151
  const saved = snapshotBeforeCut(TURN_DIR, stallCut ? "stall" : "box");
1137
1152
  if (!saved.ok) log(`cut WIP snapshot failed: ${saved.error}`);
package/bin/crew.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  import { seatProcesses } from "./crew/processes.mjs";
3
3
  import { allocatePersona } from "../lib/persona.mjs";
4
4
  import { join } from "node:path";
5
- import { call, createContext } from "./crew/core.mjs";
5
+ import { call, createContext, commandExists } from "./crew/core.mjs";
6
6
  import { createCmuxAdapter, spawnCmux } from "./crew/cmux.mjs";
7
7
  import { createHerdrAdapter, spawnHerdr } from "./crew/herdr.mjs";
8
8
  import { resolveSpec, reportSkipped } from "./crew/models.mjs";
@@ -15,7 +15,7 @@ import { spawnTerminal, spawnTmux } from "./crew/tmux.mjs";
15
15
  import { epochMs, failedAgents, verifyCrew } from "./crew/verify.mjs";
16
16
  import { guardCrossProjectUp } from "./crew/worktrees.mjs";
17
17
  import { preflightFirstSeat } from "./crew/preflight.mjs";
18
- import { resolveAgentLaunchSpecs } from "../lib/agent-preferences.mjs";
18
+ import { resolveAgentLaunchSpecs, seatCliProblem } from "../lib/agent-preferences.mjs";
19
19
  import { readConfig } from "../lib/project.mjs";
20
20
 
21
21
  const [command = "up", ...inputArgs] = process.argv.slice(2);
@@ -85,6 +85,11 @@ async function runUp(args, verify = true) {
85
85
  console.error(`[crew] ✗ ${requested.disabled.join(", ")} ${requested.disabled.length === 1 ? "is" : "are"} disabled in ~/.agent-bus/config.json — enable the seat in Settings → Agents`);
86
86
  return 1;
87
87
  }
88
+ if (!ctx.dry) {
89
+ const missing = [...new Set(options.specs.map(spec => spec.split(":")[0]))]
90
+ .map(agent => seatCliProblem(agent, cli => commandExists(cli, ctx.env))).filter(Boolean);
91
+ if (missing.length) { for (const line of missing) console.error(line); return 1; }
92
+ }
88
93
  prune(ctx, adapters);
89
94
  connect();
90
95
  console.log(`[crew] hub for ${ctx.project}: ${ctx.hub} (baked into every seat; CREW_HUB=<url> overrides)`);
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, orchSessionsPath, PROJECT_MARKER } from "../lib/project.mjs";
11
+ import { resolveProject, resolveProjectInfo, resolveHub, DEFAULT_HUB_URL, gitRoot, readProjectId, checkoutFor, localCheckoutFor, orchSessionsPath, PROJECT_MARKER } 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";
@@ -89,11 +89,11 @@ section("project identity");
89
89
  : `if "${label}" is that project renamed: trantor project ${name} (the pin, board and orchestrator row then follow the id)`;
90
90
  let orphans = 0;
91
91
  for (const name of orchRows) {
92
- if (checkoutFor(name)) continue;
92
+ if (localCheckoutFor(name)) continue;
93
93
  orphans++;
94
94
  warn(`orphaned identity: ${name} has an orchestrator session row${pinned.includes(name) ? " and a hub pin" : ""} but no checkout on this machine carries it`, claim(name));
95
95
  }
96
- const pinnedOnly = pinned.filter(n => !orchRows.includes(n) && !checkoutFor(n));
96
+ const pinnedOnly = pinned.filter(n => !orchRows.includes(n) && !localCheckoutFor(n));
97
97
  if (pinnedOnly.length) note(`${pinnedOnly.length} pinned project(s) with no checkout here (${pinnedOnly.slice(0, 8).join(", ")}${pinnedOnly.length > 8 ? ", …" : ""}) — fine when they live on another machine`);
98
98
  if (!orphans) ok("every orchestrated project still has its checkout");
99
99
  }
@@ -178,6 +178,17 @@ section("duty seat (the fleet watcher)");
178
178
  section("claude (the orchestrator)");
179
179
  if (!has("claude")) warn("claude CLI not found", "install Claude Code: https://claude.com/claude-code");
180
180
  else {
181
+ // Claude Code's version against Trantor's compatibility states (#14030), mirroring the
182
+ // Rust-owned table in desktop/src-tauri/src/agent_cli.rs — keep the two in step.
183
+ const raw = (() => { try { return execSync("claude --version", { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim(); } catch { return ""; } })();
184
+ const parts = (raw.split(/\s+/)[0] || "").replace(/^v/, "").split(".").map(Number);
185
+ const cmp = (a, b) => a[0] - b[0] || a[1] - b[1] || a[2] - b[2];
186
+ if (parts.length === 3 && parts.every(Number.isFinite)) {
187
+ const MIN = [2, 1, 215], VERIFIED = [2, 1, 326];
188
+ if (cmp(parts, MIN) < 0) warn(`claude ${raw} is older than Trantor has audited (${MIN.join(".")}); the Mode menu needs ${VERIFIED.join(".")}`, "claude update (Claude Code's own updater)");
189
+ else if (cmp(parts, VERIFIED) > 0) note(`claude ${raw} is newer than the releases Trantor has verified (up to ${VERIFIED.join(".")})`);
190
+ else ok(`claude ${raw} within the verified range (${MIN.join(".")}–${VERIFIED.join(".")})`);
191
+ } else if (raw) note(`claude version unreadable: ${raw}`);
181
192
  const st = read(join(H, ".claude", "settings.json")) || {};
182
193
  Object.keys(st.enabledPlugins || {}).some(k => k.startsWith("agent-bus@") || k.startsWith("trantor@"))
183
194
  ? ok("plugin installed")
package/bin/helper.mjs ADDED
@@ -0,0 +1,119 @@
1
+ #!/usr/bin/env node
2
+ // #14264: helpers share the crew pane registry so the desktop can attach to their live output.
3
+ import { mkdirSync } from "node:fs";
4
+ import { homedir } from "node:os";
5
+ import { dirname, join, resolve } from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+ import { spawnSync } from "node:child_process";
8
+ import { commandExists, formatCommand } from "./crew/core.mjs";
9
+ import { closePane, createWorkspace, herdrCall, paneAlive, reportAgent, splitPane, workspaceList, workspacePane } from "./crew/herdr.mjs";
10
+ import { dropState, readRows, recordState } from "./crew/state.mjs";
11
+ import { herdrReportArgs } from "../lib/herdr-integration.mjs";
12
+
13
+ const USAGE = "usage: trantor helper run --project <name> --label <label> [--cwd <dir>] -- <command...> | list --project <name> | stop <pane>";
14
+
15
+ function parse(args) {
16
+ const [action, ...rest] = args;
17
+ const options = { action, project: "", label: "", cwd: process.cwd(), command: [], pane: "", json: false };
18
+ for (let i = 0; i < rest.length; i += 1) {
19
+ const arg = rest[i];
20
+ if (arg === "--" && action === "run") { options.command = rest.slice(i + 1); break; }
21
+ if (arg === "--json") { options.json = true; continue; }
22
+ if (["--project", "--label", "--cwd"].includes(arg) && rest[i + 1] && !rest[i + 1].startsWith("--")) {
23
+ options[arg.slice(2)] = rest[++i];
24
+ } else if (action === "stop" && !options.pane && !arg.startsWith("-")) options.pane = arg;
25
+ else throw new Error(USAGE);
26
+ }
27
+ if (!["run", "list", "stop"].includes(action)
28
+ || (action !== "stop" && !options.project.trim())
29
+ || (action === "run" && (!options.label.trim() || !options.command.length))
30
+ || (action === "stop" && !options.pane)) throw new Error(USAGE);
31
+ for (const value of [options.project, options.label, options.pane]) {
32
+ if (/[\x00-\x1f\x7f]/.test(value)) throw new Error("Project, label and pane must be single-line text");
33
+ }
34
+ return options;
35
+ }
36
+
37
+ export function helperCommand(pane, command, env) {
38
+ const done = formatCommand("herdr", herdrReportArgs({ pane, agent: "helper", state: "idle" }));
39
+ const script = `"$@"; helper_exit=$?; ${done} >/dev/null 2>&1; printf '\\nhelper finished, exit %s\\n' "$helper_exit"; while :; do sleep 86400; done`;
40
+ const vars = [`PATH=${env.PATH || ""}`];
41
+ if (env.HERDR_SOCKET_PATH) vars.push(`HERDR_SOCKET_PATH=${env.HERDR_SOCKET_PATH}`);
42
+ return formatCommand("env", [...vars, "/bin/sh", "-c", script, "helper", ...command]);
43
+ }
44
+
45
+ function projectPane(ctx) {
46
+ const tracked = readRows(ctx).filter(row => row.project === ctx.project);
47
+ const workspaces = [...new Set([
48
+ ...tracked.filter(row => row.kind === "herdrws").map(row => row.handle).reverse(),
49
+ ...workspaceList(ctx).items.filter(w => [w.label, w.name, w.custom_title].includes(`trantor:${ctx.project}`)).map(w => w.workspace_id || w.id),
50
+ ].filter(Boolean))];
51
+ for (const workspace of workspaces) {
52
+ const pane = workspacePane(ctx, workspace, ctx.dir);
53
+ if (!pane) continue;
54
+ recordState(ctx, ctx.project, "herdrws", "__ws__", workspace);
55
+ return pane;
56
+ }
57
+ // #14264: an orchestrator can be tracked before a workspace row is recorded.
58
+ for (const row of tracked.filter(r => ["orch", "herdr", "helper"].includes(r.kind)).reverse()) {
59
+ if (paneAlive(ctx, row.handle)) return row.handle;
60
+ }
61
+ const created = createWorkspace(ctx, ctx.dir, `trantor:${ctx.project}`);
62
+ recordState(ctx, ctx.project, "herdrws", "__ws__", created.workspace);
63
+ return created.pane;
64
+ }
65
+
66
+ function requireCall(ctx, args) {
67
+ const r = herdrCall(ctx, args);
68
+ if (!r.ok) throw new Error(`herdr ${args.slice(0, 2).join(" ")} failed: ${r.stderr || r.stdout || r.status}`);
69
+ }
70
+
71
+ export function main(args = process.argv.slice(2), env = process.env) {
72
+ const opts = parse(args);
73
+ const ctx = {
74
+ env, project: opts.project, dir: resolve(opts.cwd), dry: false,
75
+ statePath: join(env.AGENT_BUS_DIR || join(env.HOME || homedir(), ".agent-bus"), "crew-windows.txt"),
76
+ have: { herdr: commandExists("herdr", env) },
77
+ };
78
+ if (!ctx.have.herdr) {
79
+ console.error("Helpers need herdr to show in the app. Running commands in this terminal.");
80
+ if (opts.action !== "run") return opts.action === "list" ? 0 : 1;
81
+ const result = spawnSync(opts.command[0], opts.command.slice(1), { cwd: ctx.dir, env, stdio: "inherit" });
82
+ if (result.error) console.error(result.error.message);
83
+ return result.status ?? 1;
84
+ }
85
+ mkdirSync(dirname(ctx.statePath), { recursive: true });
86
+ if (opts.action === "list") {
87
+ for (const row of readRows(ctx).filter(r => r.project === opts.project && r.kind === "helper")) {
88
+ if (paneAlive(ctx, row.handle)) console.log(`${row.handle}\t${row.persona}`);
89
+ else dropState(ctx, row.project, "helper", "", row.handle);
90
+ }
91
+ return 0;
92
+ }
93
+ if (opts.action === "stop") {
94
+ const rows = readRows(ctx).filter(r => r.kind === "helper" && r.handle === opts.pane);
95
+ if (!rows.length) throw new Error(`No tracked helper at ${opts.pane}`);
96
+ if (!closePane(ctx, opts.pane) && paneAlive(ctx, opts.pane)) throw new Error(`Could not stop helper ${opts.pane}`);
97
+ for (const row of rows) dropState(ctx, row.project, "helper", "", row.handle);
98
+ if (opts.json) console.log(JSON.stringify({ ok: true }));
99
+ return 0;
100
+ }
101
+ const pane = splitPane(ctx, projectPane(ctx), "right", ctx.dir);
102
+ if (!pane) throw new Error("herdr returned no helper pane");
103
+ try {
104
+ requireCall(ctx, ["pane", "rename", pane, opts.label]);
105
+ reportAgent(ctx, pane, "helper");
106
+ recordState(ctx, ctx.project, "helper", opts.label, pane, { agent: "helper" });
107
+ requireCall(ctx, ["pane", "run", pane, helperCommand(pane, opts.command, env)]);
108
+ } catch (error) {
109
+ if (closePane(ctx, pane)) dropState(ctx, ctx.project, "helper", "", pane);
110
+ throw error;
111
+ }
112
+ console.log(pane);
113
+ return 0;
114
+ }
115
+
116
+ if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
117
+ try { process.exitCode = main(); }
118
+ catch (error) { console.error(`trantor helper: ${error.message}`); process.exitCode = 1; }
119
+ }