trantor 0.18.137 → 0.18.139

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.
@@ -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.137"
9
+ "version": "0.18.139"
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.137",
16
+ "version": "0.18.139",
17
17
  "author": {
18
18
  "name": "Sasha Bogojevic"
19
19
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trantor",
3
- "version": "0.18.137",
3
+ "version": "0.18.139",
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
@@ -269,7 +269,7 @@ No cmux or tmux? Crews still work — one titled Terminal window per seat, still
269
269
 
270
270
  ## The dashboard — `trantor ui`
271
271
 
272
- A live command center at `http://127.0.0.1:4477`, grouped by **project** — and a *durable,
272
+ A live command center in the Trantor desktop app, grouped by **project** — and a *durable,
273
273
  self-maintaining record*, not just a snapshot. Dead sessions self-prune (no more graveyard of
274
274
  stale boards), and the project order is **stable**: a working board updates in place instead of
275
275
  jumping to the top while you're reading it.
@@ -506,7 +506,7 @@ GLM via OpenCode is its replacement. Gemini still works as a Scrooge cheap-model
506
506
  hub.mjs ←— plain HTTP + SSE · presence/messages/board/history/lessons/learning/economics
507
507
  (Node built-ins only · state in ~/.agent-bus/bus.json · loopback by default)
508
508
  ▲
509
- dashboard (ui.html) · BOARD/FLOW/TIMELINE · 🧠 Learning · 🪙 savings · conversation lanes
509
+ dashboard (Trantor.app) · BOARD/FLOW/TIMELINE · 🧠 Learning · 🪙 savings · conversation lanes
510
510
  ```
511
511
 
512
512
  Config: `RELAY_URL` env → `~/.agent-bus/config.json` → `http://127.0.0.1:4477`.
@@ -526,7 +526,7 @@ The `relay_*` tool names and the `~/.agent-bus` state dir remain until a later r
526
526
  - You can't interrupt an agent **mid-turn**; messages land when its current turn ends (idle
527
527
  agents wake instantly via their runner).
528
528
  - Window spawning is macOS (Terminal.app); on Linux the launcher prints per-agent commands
529
- to run in your own terminals. Hub/MCP/dashboard are cross-platform.
529
+ to run in your own terminals. Hub/MCP are cross-platform.
530
530
  - The hub is deliberately tiny (in-memory + JSON file) — a coordination bus, not a message queue.
531
531
  - Each CLI's sign-in is its own (ChatGPT, Google, Kimi accounts) — the doctor detects state
532
532
  and names the fix, but can't log in for you.
package/bin/cli.mjs CHANGED
@@ -110,7 +110,6 @@ switch (cmd) {
110
110
  console.log(`${id} recorded in ${p}${current === id ? " (unchanged)" : ""} — commit it so worktrees and clones carry the identity`);
111
111
  break;
112
112
  }
113
- case "watch": run("bin/relay-watch.mjs"); break;
114
113
  case "catchup": run("bin/catchup.mjs"); break;
115
114
  case "agents": run("bin/agents.mjs"); break;
116
115
  case "gate": run("bin/gate.mjs"); break;
@@ -124,7 +123,6 @@ switch (cmd) {
124
123
  case "balances": case "balance": case "credits": run("bin/balances.mjs"); break;
125
124
  case "recost": run("bin/recost.mjs"); break;
126
125
  case "handoff": run("bin/baton.mjs"); break;
127
- case "adopt": run("bin/adopt.mjs"); break;
128
126
  case "takeover": run("bin/takeover.mjs"); break;
129
127
  case "drill": run("bin/drill-surface.mjs"); break;
130
128
  case "summarize": run("bin/summarize.mjs"); break;
@@ -247,32 +245,13 @@ switch (cmd) {
247
245
  else console.error(`Enrollment failed: ${j.error || r.statusText}`);
248
246
  break;
249
247
  }
250
- // Prefer the desktop app: it signs hub requests in Rust; the browser has no signing key.
251
- // Explain the browser's read limitation when the desktop app is unavailable.
252
248
  case "ui": {
253
- const { resolveHubInfo } = await import(join(ROOT, "lib/project.mjs"));
254
- const { resolveProject } = await import(join(ROOT, "lib/project.mjs"));
255
- const url = resolveHubInfo(resolveProject(process.cwd())).url;
256
-
257
- let authMode = "";
258
- try {
259
- const r = await fetch(`${url}/health`, { signal: AbortSignal.timeout(5000) });
260
- authMode = String((await r.json()).authMode || "");
261
- } catch { /* hub unreachable — fall through and let the browser show that */ }
262
-
263
- const hasApp = process.platform === "darwin" && existsSync("/Applications/Trantor.app");
264
- if (authMode === "enforce" && hasApp) {
249
+ if (process.platform === "darwin" && existsSync("/Applications/Trantor.app")) {
265
250
  spawn("open", ["-a", "Trantor"], { stdio: "ignore", detached: true }).unref();
266
- console.log(`dashboard → Trantor.app (${url} is auth:enforce — a browser cannot sign, so it would show an empty board)`);
267
- break;
268
- }
269
- if (authMode === "enforce") {
270
- console.log(`⚠ ${url} is auth:enforce. A browser cannot sign its requests, so the board will be EMPTY —`);
271
- console.log(` every data endpoint returns 401. Install the desktop app instead: trantor app install`);
272
- console.log(` Opening it anyway so you can see for yourself…`);
251
+ console.log("dashboard → Trantor.app");
252
+ } else {
253
+ console.log("The dashboard is the Trantor desktop app. Install it with: trantor app install");
273
254
  }
274
- spawn(process.platform === "darwin" ? "open" : "xdg-open", [url], { stdio: "ignore", detached: true }).unref();
275
- console.log(`dashboard → ${url}`);
276
255
  break;
277
256
  }
278
257
  case "version": case "-v": case "--version":
@@ -327,7 +306,6 @@ switch (cmd) {
327
306
  trantor seat-why WHY a seat is down (err file, logs, pids): seat-why <agent> [--json] — quota, auth, crash, or just no pane
328
307
  trantor seat-record the per-project seat record the advisor benches from (✓/∅/↩ per difficulty) — [--project p] [--reset <seat>] [--json]
329
308
  trantor telemetry ship send turn history to the hub — this seat's log, or every log with --all; prints stored/duplicates/dropped per file
330
- trantor watch live bus feed in the terminal
331
309
  trantor inbox THIS session's unread bus messages, signed (works under enforce) — [--all] [--consume] [--json]
332
310
  trantor policy the autonomy ladder: show | set <project> <1-4> | link <a> <b> --reason "<why>"
333
311
  trantor proposals agent-proposed permissions awaiting YOUR decision: [--all] | approve <id> [--note "…"] | deny <id> --note "…"
package/bin/connect.mjs CHANGED
@@ -19,11 +19,17 @@ const MCP = join(dirname(dirname(fileURLToPath(import.meta.url))), "mcp.mjs");
19
19
  const PROJECT_INFO = resolveProjectInfo(process.cwd());
20
20
  const PROJECT_AT_CONNECT = PROJECT_INFO.project;
21
21
  const URL_ = resolveHubInfo(PROJECT_AT_CONNECT).url;
22
- // Graft (github.com/NanoNets/context-graph-engine): local Tree-sitter dependency graph over MCP,
23
- // wired next to `relay` so a seat locates code in one call; the graph refreshes itself per query
24
- // and a project with no graft/ index simply returns empty tools. `graft build` seeds an index.
25
- const GRAFT = (() => { try { return execSync("command -v graft", { encoding: "utf8", shell: "/bin/sh" }).trim(); } catch { return "graft"; } })();
26
- const HAS_GRAFT = GRAFT !== "graft" || (() => { try { execSync("command -v graft", { stdio: "ignore", shell: "/bin/sh" }); return true; } catch { return false; } })();
22
+ // #14536: graft is no longer an agent MCP server (0 calls from Claude sessions in 30 days, a handful
23
+ // from seats, ~900 tokens of tool list per turn). The desktop app still runs the graft CLI itself.
24
+ // Connect removes the entries older versions wrote.
25
+ // The [mcp_servers.graft] table up to the next table, and the comment line connect wrote for it,
26
+ // which a later relay env refresh can leave separated from the table.
27
+ function removeCodexGraft(toml) {
28
+ return toml
29
+ .replace(/^# trantor — Graft[^\n]*\n/m, "")
30
+ .replace(/^\[mcp_servers\.graft\]\n(?:(?!\[)[^\n]*\n?)*/m, "")
31
+ .replace(/\n{3,}/g, "\n\n");
32
+ }
27
33
  const has = (cmd) => { try { execSync(`command -v ${cmd}`, { stdio: "ignore", shell: "/bin/sh" }); return true; } catch { return false; } };
28
34
  const stamp = new Date().toISOString().slice(0, 10);
29
35
  const backup = (p) => { const b = `${p}.bak-${stamp}`; if (!existsSync(b)) copyFileSync(p, b); return b; };
@@ -101,15 +107,11 @@ if (has("codex")) {
101
107
  }
102
108
  report("codex", note, p);
103
109
  }
104
- // graft alongside relay
105
- if (HAS_GRAFT) {
106
- const g = existsSync(p) ? readFileSync(p, "utf8") : "";
107
- if (g.includes("[mcp_servers.graft]")) report("codex", "graft already wired");
108
- else {
109
- const gblock = `\n# trantor — Graft code-graph tools (graft_find_code/_find_all/_trace_calls/_file_api/_repo_map)\n[mcp_servers.graft]\ncommand = "${GRAFT}"\nargs = ["mcp"]\n`;
110
- if (!DRY) { if (existsSync(p)) backup(p); writeFileSync(p, g + gblock); }
111
- report("codex", "graft wired", p);
112
- }
110
+ const g = existsSync(p) ? readFileSync(p, "utf8") : "";
111
+ const ungrafted = removeCodexGraft(g);
112
+ if (ungrafted !== g) {
113
+ if (!DRY) { backup(p); writeFileSync(p, ungrafted); }
114
+ report("codex", "graft MCP removed", p);
113
115
  }
114
116
  }
115
117
 
@@ -120,7 +122,7 @@ if (has("gemini")) {
120
122
  d.mcpServers ||= {};
121
123
  d.mcpServers.relay ||= { command: "node", args: [MCP], env: {} };
122
124
  d.mcpServers.relay.env = { ...d.mcpServers.relay.env, ...relayEnv("gemini") };
123
- if (HAS_GRAFT) d.mcpServers.graft ||= { command: GRAFT, args: ["mcp"] };
125
+ delete d.mcpServers.graft;
124
126
  }), p);
125
127
  }
126
128
 
@@ -132,7 +134,7 @@ const kimiRelay = (cli, p) => report(cli, patchJson(p, d => {
132
134
  d.mcpServers ||= {};
133
135
  d.mcpServers.relay ||= { command: "node", args: [MCP], env: {} };
134
136
  d.mcpServers.relay.env = { ...d.mcpServers.relay.env, ...relayEnv("kimi") };
135
- if (HAS_GRAFT) d.mcpServers.graft ||= { command: GRAFT, args: ["mcp"] };
137
+ delete d.mcpServers.graft;
136
138
  }), p);
137
139
  const kimiCodeHome = join(homedir(), ".kimi-code");
138
140
  const kimiPaths = [join(homedir(), ".kimi", "mcp.json"), join(kimiCodeHome, "mcp.json")];
@@ -168,7 +170,7 @@ if (has("opencode")) {
168
170
  d.$schema ||= "https://opencode.ai/config.json";
169
171
  d.mcp ||= {};
170
172
  d.mcp.relay ||= { type: "local", command: ["node", MCP], enabled: true };
171
- if (HAS_GRAFT) d.mcp.graft ||= { type: "local", command: [GRAFT, "mcp"], enabled: true };
173
+ delete d.mcp.graft;
172
174
  d.mcp.relay.environment ||= {};
173
175
  // Migrate the old generated pin too: `||=` alone left RELAY_AGENT=opencode in every existing
174
176
  // config forever, where OpenCode overlaid it on the qwen/glm/deepseek runner environment.
@@ -225,14 +227,7 @@ if (has("dsh")) {
225
227
  RELAY_AGENT: !!js process.env.RELAY_AGENT ?? 'dsh'
226
228
  RELAY_PROJECT: !!js process.env.RELAY_PROJECT ?? ''
227
229
  RELAY_SESSION: !!js process.env.RELAY_SESSION ?? ''
228
- ${HAS_GRAFT ? ` - id: trantor-graft
229
- name: '@deepseek-ai/dsh-mcp-client'
230
- config:
231
- serverName: graft
232
- transport: stdio
233
- command: ${GRAFT}
234
- args: ['mcp']
235
- ` : ""}`;
230
+ `;
236
231
  // "a profile exists" is not "a profile is current": connect grows rows over time, and an existence
237
232
  // check short-circuits on a profile written by an older connect forever. The gate is CONTENT-based:
238
233
  // every row id this connect writes must already be in the patch, else regenerate (backed up).
@@ -31,7 +31,7 @@ import {
31
31
  cardRefs, servedContractCard, carriesWork, parseTurnTokens, parseResetAt, reasonWithBalances, quotaResetAt, queuedWording, turnDelivered, budgetPause, PARKING_REASONS,
32
32
  senderProjectOf, isLinkedProject, stateSkipReason, isMessageCardTitle, OPEN_CARD_STATUSES,
33
33
  ownCardForInstance, contractedCardIds,
34
- shouldAlignForContract, hasContractText,
34
+ shouldAlignForContract, hasContractText, completedCardIds, owesReadContract,
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";
@@ -417,10 +417,8 @@ async function janitorStop(why, card) {
417
417
  log(text);
418
418
  await api("/send", { from: SESSION, to: "all", text, project: PROJ, kind: "status" }).catch(() => {});
419
419
  }
420
- // #7778: message ids this seat already consumed through its OWN inbox path (relay_inbox, the
421
- // PostToolUse hook) — reconciled from the hub's deliveredUpTo ledger at each clean turn boundary
422
- // and persisted in the pending file, so a message the session read mid-turn is never re-woken by
423
- // the poll, across turn AND process boundaries.
420
+ // Inbox reads dedupe context across turn boundaries; #14520 contracts still need a matching outcome.
421
+ // Persist that turn's completed cards with its read ids so later outcomes cannot consume old work.
424
422
  let seenLedger = [];
425
423
  // A cap, so a long outage cannot grow the queue without bound. Overflow drops the OLDEST and says
426
424
  // so on the bus — a silent drop is the exact failure this whole mechanism exists to end.
@@ -474,7 +472,7 @@ function loadPending() {
474
472
  wake: Array.isArray(j.wake) ? j.wake : [],
475
473
  bcast: Array.isArray(j.bcast) ? j.bcast : [],
476
474
  seen: Array.isArray(j.seen)
477
- ? j.seen.filter(e => e && Number.isFinite(Number(e.id))).map(e => ({ id: Number(e.id), ts: Number(e.ts) || 0 }))
475
+ ? j.seen.filter(e => e && Number.isFinite(Number(e.id))).map(e => ({ id: Number(e.id), ts: Number(e.ts) || 0, completedCards: e.completedCards || [] }))
478
476
  : [],
479
477
  ask: Number(j.ask) || 0, askTo: String(j.askTo || ""),
480
478
  };
@@ -1780,7 +1778,10 @@ async function resolveWakeCard(messages, { session }) {
1780
1778
  // not the shared ledger, so the second reader stands down here and the cursor adopts the consumed
1781
1779
  // ids. Filtering BEFORE the wake/bcast split keeps a dupe out of #7766's demoted-sender notice.
1782
1780
  if (seenLedger.length) {
1783
- const seenIds = new Set(seenLedger.map(e => e.id));
1781
+ const seenIds = new Set(msgs.filter(m => {
1782
+ const entry = seenLedger.find(e => e.id === m.id);
1783
+ return entry && !owesReadContract(m, SESSION, entry.completedCards);
1784
+ }).map(m => m.id));
1784
1785
  const dupes = msgs.filter(m => seenIds.has(m.id));
1785
1786
  if (dupes.length) {
1786
1787
  log(`duplicate delivery suppressed — ${dupes.map(m => `#${m.id}`).join(", ")} already consumed by the session's own inbox read`);
@@ -1886,12 +1887,13 @@ async function resolveWakeCard(messages, { session }) {
1886
1887
  // A delta wider than one turn could plausibly carry is a corrupt or rewound ledger: mark
1887
1888
  // nothing. Non-marking only risks the duplicate this fixes, never a lost message.
1888
1889
  if (!(readUpTo > upToCursor) || readUpTo - upToCursor > 10000) return 0;
1889
- for (let id = upToCursor + 1; id <= readUpTo; id++) seenLedger.push({ id, ts: Date.now() });
1890
+ const turnCompletedCards = completedCardIds(lastErrText);
1891
+ for (let id = upToCursor + 1; id <= readUpTo; id++) seenLedger.push({ id, ts: Date.now(), completedCards: turnCompletedCards });
1890
1892
  seenLedger = seenLedger.filter(e => e.id > upToCursor).slice(-500);
1891
1893
  // persist HERE, at every caller: a runner killed seconds after the boundary is exactly the
1892
1894
  // restart the restored seen-set exists for.
1893
1895
  savePending(pendingWake, pendingBcast);
1894
- log(`dedupe: message id(s) ${upToCursor + 1}..${readUpTo} were consumed by the session's own inbox read — the poll will not wake on them again`);
1896
+ log(`dedupe: message id(s) ${upToCursor + 1}..${readUpTo} were read by the session — context dedupes; contracts require a matching done/testing outcome`);
1895
1897
  return readUpTo - upToCursor;
1896
1898
  } catch { return 0; }
1897
1899
  }
@@ -1,10 +1,21 @@
1
1
  #!/bin/bash
2
2
  # open-session.sh <dir> <command...> — open a NEW macOS Terminal window in <dir> running <command>.
3
3
  # Lets a Claude session spawn sibling terminal sessions (e.g. to test multi-session relay flows).
4
+ #
5
+ # #14531: the new window must not carry the caller's session identity. A Terminal session that
6
+ # kept HERDR_PANE_ID registered itself as the agent of a herdr pane it was not in (the app then
7
+ # attached to an empty pane), and one that kept CLAUDE_CODE_CHILD_SESSION ran with transcript
8
+ # saving off, so its conversation could never be resumed. Same list as lib/seats.mjs
9
+ # SESSION_IDENTITY_ENV, plus the rest of herdr's pane env.
4
10
  DIR="${1:-$HOME}"; shift; CMD="$*"
5
- osascript >/dev/null <<OSA
6
- tell application "Terminal"
7
- do script "cd " & quoted form of "$DIR" & " && $CMD"
8
- activate
9
- end tell
11
+ SCRUB="unset HERDR_ENV HERDR_PANE_ID HERDR_TAB_ID HERDR_WORKSPACE_ID HERDR_SOCKET_PATH TRANTOR_ORCH CLAUDECODE CLAUDE_CODE_CHILD_SESSION CLAUDE_CODE_ENTRYPOINT CLAUDE_CODE_SESSION_ID"
12
+ LINE="$SCRUB; cd $(printf '%q' "$DIR") && $CMD"
13
+ if [ "${TRANTOR_OPEN_SESSION_PRINT:-}" = "1" ]; then printf '%s\n' "$LINE"; exit 0; fi
14
+ osascript - "$LINE" >/dev/null <<'OSA'
15
+ on run argv
16
+ tell application "Terminal"
17
+ do script (item 1 of argv)
18
+ activate
19
+ end tell
20
+ end run
10
21
  OSA
package/hub/auth.mjs CHANGED
@@ -13,11 +13,8 @@ const BODY_CAP_DEFAULT = 4 * 1024 * 1024;
13
13
  const BODY_CAP_PROMPT = 16 * 1024 * 1024;
14
14
  // More than 100x the measured 115,194-byte desktop snapshot.
15
15
  const BODY_CAP_OWNER_CHAT = 16 * 1024 * 1024;
16
- // About 6x the measured 10,659,828-byte real state.
17
- const BODY_CAP_OWNER_IMPORT = 64 * 1024 * 1024;
18
16
  const OWNER_BODY_CAPS = new Map([
19
17
  ["/session/chat", BODY_CAP_OWNER_CHAT],
20
- ["/import", BODY_CAP_OWNER_IMPORT],
21
18
  ["/handoff", BODY_CAP_DEFAULT], ["/task", BODY_CAP_DEFAULT], ["/task/update", BODY_CAP_DEFAULT],
22
19
  ]);
23
20
  function bodyCap(P) { return P === "/session/prompt" ? BODY_CAP_PROMPT : BODY_CAP_DEFAULT; }
@@ -96,7 +93,7 @@ function cmpSemver(a, b) {
96
93
  }
97
94
  const AUTH_HEADERS = ["x-trantor-pubkey", "x-trantor-sig", "x-trantor-ts", "x-trantor-nonce"];
98
95
  const PUBLIC_ENDPOINTS = new Set(["/", "/ui", "/health", "/enroll"]);
99
- const OWNER_ENDPOINTS = new Set(["/project/delete", "/sweep", "/reconcile", "/invite", "/import", "/policy", "/session/prompts", "/session/prompt/claim", "/session/prompt/ack", "/session/attachment"]);
96
+ const OWNER_ENDPOINTS = new Set(["/project/delete", "/sweep", "/reconcile", "/invite", "/policy", "/session/prompts", "/session/prompt/claim", "/session/prompt/ack", "/session/attachment"]);
100
97
  const DEVICE_ENDPOINTS = new Set(["/device/register", "/device/unregister", "/devices"]);
101
98
  const READ_ENDPOINTS = new Set(["/peers", "/tasks", "/events", "/inbox", "/peer", "/card", "/stream", "/history", "/projects", "/catchup", "/phases", "/recent", "/handoffs", "/verify-gates", "/claims", "/proposals", "/grants", "/overseer/context", "/overseer/status", "/session/chat", "/session/prompt", "/crew/roster", "/machines/health"]);
102
99
  const roleRank = { read: 1, write: 2, approver: 3, owner: 4 };
@@ -25,7 +25,7 @@ function remoteEvidence(value, file) {
25
25
  export async function routeAdmin({ req, res, q, P, auth, ctx }) {
26
26
  const {
27
27
  state, body, json, crossProjectGuard, touch, canon, filterReadable,
28
- appendEvent, EVENT_CAP, overseer, ONLINE_MS, PEER_TTL_MS, pruneClaims, fileClaims,
28
+ appendEvent, overseer, ONLINE_MS, PEER_TTL_MS, pruneClaims, fileClaims,
29
29
  scopeAllows, duty, markDirty, HUB_VERSION, cmpSemver, prunePeers,
30
30
  filterDiscoverable, healthOf, now, canRead, AUTH_MODE, CLAIM_TTL_MS, subFp,
31
31
  } = ctx;
@@ -118,47 +118,6 @@ export async function routeAdmin({ req, res, q, P, auth, ctx }) {
118
118
  // BEFORE every file edit and the response carries any live claims by OTHER sessions, so an
119
119
  // orchestrator learns of a collision before the edit lands. Ephemeral like presence BY DESIGN.
120
120
 
121
- // --- project adoption: merge one project's rows brought from ANOTHER hub -------------------
122
- // The other half of `trantor adopt`: the CLI reads the project's rows off the machine-local hub
123
- // and POSTs them here (owner-signed). Colliding card ids get FRESH ids; idempotence is the
124
- // CALLER's contract: adopt refuses when the project already has cards here, unless forced.
125
- if (req.method === "POST" && P === "/import") {
126
- const b = await body(req);
127
- const proj = canon(String(b.project || "").slice(0, 80));
128
- if (!proj) return json(res, 400, { error: "project required" });
129
- const existing = state.tasks.filter(t => t.project === proj).length;
130
- if (existing && !b.force) return json(res, 409, { error: "project already has cards here", existing });
131
- const remap = new Map();
132
- const added = { tasks: 0, events: 0, messages: 0, remapped: 0 };
133
- const have = new Set(state.tasks.map(t => t.id));
134
- for (const t of (Array.isArray(b.tasks) ? b.tasks : [])) {
135
- let id = Number(t.id);
136
- if (!Number.isFinite(id)) continue;
137
- if (have.has(id)) { const nid = ++state.taskSeq; remap.set(id, nid); id = nid; added.remapped++; }
138
- else state.taskSeq = Math.max(state.taskSeq, id);
139
- state.tasks.push({ ...t, id, project: proj });
140
- have.add(id); added.tasks++;
141
- }
142
- for (const e of (Array.isArray(b.events) ? b.events : [])) {
143
- const last = state.events[state.events.length - 1];
144
- // Spread the incoming event FIRST, then stamp OUR id and project over it. The incoming `id`
145
- // belongs to the other hub's log and must not survive in any form: carried into the payload
146
- // it comes back on load and overwrites the real row id.
147
- state.eventSeq = Math.max(Number(state.eventSeq || 0), Number(last?.id) || 0) + 1;
148
- const ev = { ...e, id: state.eventSeq, project: proj };
149
- const taskId = ev.taskId != null ? remap.get(Number(ev.taskId)) : undefined;
150
- const importedEvent = taskId === undefined ? ev : { ...ev, taskId };
151
- state.events.push(importedEvent); added.events++;
152
- }
153
- if (state.events.length > EVENT_CAP) state.events.splice(0, state.events.length - EVENT_CAP);
154
- for (const m of (Array.isArray(b.messages) ? b.messages : [])) {
155
- state.messages.push({ ...m, id: ++state.seq, project: proj }); added.messages++;
156
- }
157
- if (state.messages.length > 5000) state.messages.splice(0, 1000);
158
- markDirty();
159
- appendEvent("project.adopted", proj, String(b.by || ""), { counts: added });
160
- return json(res, 200, { ok: true, ...added });
161
- }
162
121
  if (req.method === "GET" && P === "/policy") {
163
122
  return json(res, 200, overseerPolicy());
164
123
  }
@@ -7,7 +7,7 @@ export async function routeMessages({ req, res, q, P, auth, ctx }) {
7
7
  const {
8
8
  state, body, json, stripNulText, copyTask, crossProjectGuard, touch, pushToStreams,
9
9
  appendEvent, appendCardEvent, appendTaskLog, markDelivered, contractsFor, canUseInboxSession, inboxWindow,
10
- deliverable, inboxReadable, inboxResponse, filterReadable, canRead, streams, UI,
10
+ deliverable, inboxReadable, inboxResponse, filterReadable, canRead, streams,
11
11
  AUTH_MODE, persistHealth, duty, now, markDirty, assertNoSecrets, PEER_TTL_MS,
12
12
  CONTRACT_WINDOW_MS, PUBLIC_URL, turnTelemetry,
13
13
  } = ctx;
@@ -170,7 +170,7 @@ export async function routeMessages({ req, res, q, P, auth, ctx }) {
170
170
  return json(res, 200, { messages: filterReadable(auth, state.messages, m => m.project || "").slice(-n) });
171
171
  }
172
172
  if (req.method === "GET" && (P === "/" || P === "/ui")) {
173
- res.writeHead(200, { "content-type": "text/html; charset=utf-8" }); return res.end(UI || "<h1>trantor</h1><p>dashboard unavailable</p>");
173
+ res.writeHead(200, { "content-type": "text/html; charset=utf-8" }); return res.end("<h1>Trantor</h1><p>The dashboard is the Trantor desktop app.</p>");
174
174
  }
175
175
  // #8723: the count is a listing in aggregate — memory rows (past PEER_TTL_MS) never count.
176
176
  if (P === "/health") return json(res, 200, { ok: true, authMode: AUTH_MODE, peers: Object.values(state.peers).filter(v => (v.lastSeen || 0) >= now() - PEER_TTL_MS).length, messages: state.messages.length, streams: streams.length,
package/hub.mjs CHANGED
@@ -126,11 +126,9 @@ function recordOpOutcome(res, op) {
126
126
  };
127
127
  }
128
128
 
129
- let UI = "";
130
- try { UI = readFileSync(new URL("./ui.html", import.meta.url), "utf8"); } catch {}
131
129
  const context = {
132
130
  ...store, ...authRuntime, ...events, ...reaper, duty, overseer, derivePhases,
133
- hubSend: duty.hubSend, assertNoSecrets, UI, AUTH_MODE, ONLINE_MS, PEER_TTL_MS,
131
+ hubSend: duty.hubSend, assertNoSecrets, AUTH_MODE, ONLINE_MS, PEER_TTL_MS,
134
132
  REAP_GRACE_MS, CONTRACT_WINDOW_MS, PUBLIC_URL,
135
133
  };
136
134
  const sessionChat = createSessionRuntime({
@@ -37,7 +37,7 @@ explicit EVENT/INTERFACE CONTRACT — cross-agent bugs come from contract drift.
37
37
  2. One card per package: `relay_task_add(title, assignee, difficulty, model)` — set `model`
38
38
  to the advisor-routed model (or the CLI's default name); difficulty + model show as badges
39
39
  on the card. Assignees: `codex:<project>` etc. Keep one for yourself.
40
- 3. Open the dashboard: `trantor ui` (or `open -na "Google Chrome" --args --new-window <hub-url>`)
40
+ 3. Open the dashboard: `trantor ui` (opens the Trantor desktop app)
41
41
 
42
42
  ## Phase 2 — fire up the crew (with the Advisor's models)
43
43
  **Each crew card from `relay_advise` carries a `launch` spec — run it VERBATIM; never invent a
package/kimi.plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trantor",
3
- "version": "0.18.137",
3
+ "version": "0.18.139",
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). This manifest makes Kimi Code CLI a first-class ORCHESTRATOR, mirroring .claude-plugin/plugin.json. Hooks are the CANONICAL hooks/** executed through the kimi dialect bridge (kimi/bridge.mjs) — docs/KIMI-BRIDGE-CONTRACT.md.",
5
5
  "interface": {
6
6
  "displayName": "Trantor",
@@ -388,3 +388,18 @@ export function askedVerdict(ask) {
388
388
  export function hasContractText(text) {
389
389
  return /\bcontract(?:\s*:|\s+(?:for\s+)?#\d+\b)/i.test(String(text || ""));
390
390
  }
391
+
392
+ // #14520: reading a contract during another turn is not delivery of that contract.
393
+ export function owesReadContract(message, session, completedCards = []) {
394
+ if (message.to !== session || message.wake === false) return false;
395
+ if (message.kind !== "contract" && !hasContractText(message.text)) return false;
396
+ const cards = cardRefs(message.text);
397
+ if (Number(message.card) > 0) cards.push(Number(message.card));
398
+ return !cards.length || cards.some(id => !completedCards.includes(id));
399
+ }
400
+
401
+ // Accept explicit card outcomes, not a bare mention or a promise to finish later.
402
+ export function completedCardIds(text) {
403
+ return [...String(text || "").matchAll(/^[ \t]*(?:[-*][ \t]+)?(?:card[ \t]+)?#(\d{1,7})\b[ \t]*(?::|—|-)?[ \t]*(?:(?:is|was|moved to|moved|in|→)[ \t]+)?(done|testing)\b/gim)]
404
+ .map(match => Number(match[1]));
405
+ }
package/mcp.mjs CHANGED
@@ -257,14 +257,6 @@ server.tool("relay_task_check", "Tick (or untick) one checklist item on a card.
257
257
  return { content: [{ type: "text", text: `card #${id} checklist: [${done !== false ? "x" : " "}] "${task.checklist[index].text}" — ${n}/${task.checklist.length} done` }] };
258
258
  });
259
259
 
260
- server.tool("relay_phase_goal", "Set a phase's goal, shown as its header in the Flow view. Set it when you plan a phase. Phase keys match relay_task_add's `phase`.",
261
- { phase: z.string().describe("the phase key (e.g. 'P5', 'Auth', 'Launch')"), goal: z.string().describe("1-2 sentences: what this phase delivers + done-criteria"), project: z.string().optional().describe("board (default: this session's project)") },
262
- async ({ phase, goal, project }) => {
263
- const proj = project || PROJECT;
264
- await api("POST", "/phase", { project: proj, phase, goal, by: SESSION });
265
- return { content: [{ type: "text", text: `phase "${phase}" goal set for ${proj}` }] };
266
- });
267
-
268
260
  server.tool("relay_task_move", "Move a card: todo -> doing -> testing -> done. Never go straight to done: move to 'testing' when finished, run the tests/typecheck, then 'done' only if green, else 'failed' (relay_send what broke). blocked = waiting on something external. A move to testing or done MUST carry a `note`: what changed plus the evidence (command, pass counts).",
269
261
  { id: z.number(), status: z.enum(["todo","doing","testing","failed","done","blocked"]), note: z.string().max(2000).optional().describe("card-log entry; REQUIRED on testing/done"), drill: z.string().max(300).optional().describe("set the drill line in this call; done is refused without one") },
270
262
  async ({ id, status, note, drill }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trantor",
3
- "version": "0.18.137",
3
+ "version": "0.18.139",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "trantor": "bin/cli.mjs"
@@ -19,10 +19,8 @@
19
19
  "hub.mjs",
20
20
  "hub/",
21
21
  "mcp.mjs",
22
- "ui.html",
23
22
  "bin/",
24
23
  "hooks/",
25
- "mods/",
26
24
  "lib/",
27
25
  "skills/",
28
26
  "deploy/",
@@ -1,52 +0,0 @@
1
- #!/usr/bin/env node
2
- // relay-watch streams the bus and lists live peer status.
3
- // Run `node bin/relay-watch.mjs [session]`; the default watches every session.
4
- import { resolveProject, hostId, resolveHub } from "../lib/project.mjs";
5
- import { loadOrCreate } from "../lib/identity.mjs";
6
- import { sfetch, sfetchJson } from "../lib/signed-fetch.mjs";
7
-
8
- const PROJECT = resolveProject(process.cwd());
9
- const ME = process.env.RELAY_SESSION
10
- || (process.env.RELAY_AGENT ? `${process.env.RELAY_AGENT}:${PROJECT}` : `${hostId()}:${PROJECT}`);
11
- const identity = loadOrCreate(ME, "agent");
12
- const URL_BASE = resolveHub(PROJECT);
13
- const SESSION = process.argv[2] || "all";
14
- const t = () => new Date().toLocaleTimeString();
15
-
16
- async function showPeers() {
17
- try {
18
- const { peers } = await (await sfetchJson(`${URL_BASE}/peers`, { method: "GET", identity })).json();
19
- const live = peers.filter(p => p.online);
20
- console.log(`\n live sessions (${live.length}):`);
21
- for (const p of live) console.log(` 🟢 ${p.session}${p.machine ? ` [${p.machine}]` : ""}${p.status ? ` — ${p.status}` : ""}`);
22
- console.log("");
23
- } catch {}
24
- }
25
-
26
- async function watch() {
27
- console.log(`relay-watch → ${URL_BASE} (watching "${SESSION}") — Ctrl-C to stop`);
28
- await showPeers();
29
- for (;;) {
30
- try {
31
- const r = await sfetch(`${URL_BASE}/stream?session=${encodeURIComponent(SESSION)}`, { headers: { accept: "text/event-stream" } }, identity);
32
- if (!r.ok || !r.body) throw new Error(`stream ${r.status}`);
33
- let buf = "";
34
- const dec = new TextDecoder();
35
- for await (const chunk of r.body) {
36
- buf += dec.decode(chunk, { stream: true });
37
- let i;
38
- while ((i = buf.indexOf("\n\n")) >= 0) {
39
- const frame = buf.slice(0, i); buf = buf.slice(i + 2);
40
- for (const line of frame.split("\n")) {
41
- if (!line.startsWith("data:")) continue;
42
- try { const m = JSON.parse(line.slice(5).trim()); console.log(` [${t()}] ${m.from} → ${m.to}: ${m.text}`); } catch {}
43
- }
44
- }
45
- }
46
- } catch (e) {
47
- console.error(` (stream dropped: ${e?.message || e} — reconnecting in 2s)`);
48
- await new Promise(r => setTimeout(r, 2000));
49
- }
50
- }
51
- }
52
- watch();
@@ -1,6 +0,0 @@
1
- # agent-bus for Codex CLI — add to ~/.codex/config.toml
2
- # Loading this MCP auto-registers the Codex session on the bus + gives the relay_* tools.
3
- [mcp_servers.relay]
4
- command = "node"
5
- args = ["REPLACE/WITH/ABSOLUTE/PATH/agent-bus/mcp.mjs"]
6
- env = { RELAY_URL = "http://127.0.0.1:4477", RELAY_SESSION = "codex:myproject" }
@@ -1,10 +0,0 @@
1
- {
2
- "//": "trantor for Gemini CLI — merge into ~/.gemini/settings.json (or a project .gemini/settings.json).",
3
- "mcpServers": {
4
- "relay": {
5
- "command": "node",
6
- "args": ["REPLACE/WITH/ABSOLUTE/PATH/trantor/mcp.mjs"],
7
- "env": { "RELAY_URL": "http://127.0.0.1:4477", "RELAY_SESSION": "gemini:myproject" }
8
- }
9
- }
10
- }
@@ -1,5 +0,0 @@
1
- {
2
- "name": "trantor-band",
3
- "version": "0.1.0",
4
- "description": "Pilot: a line above the Claude Code prompt with live context fill and the project's handoff state, read from Trantor's files. Off unless TRANTOR_MOD=1."
5
- }