trantor 0.18.124 → 0.18.125

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trantor",
3
- "version": "0.18.124",
3
+ "version": "0.18.125",
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": {
@@ -6,6 +6,7 @@ import { readFileSync, writeFileSync, unlinkSync, existsSync, appendFileSync, mk
6
6
  import { join, basename } from "node:path";
7
7
  import { homedir } from "node:os";
8
8
  import { resolveProject, resolveHub, withEnvFiles, hostId } from "../lib/project.mjs";
9
+ import { machineLabel } from "../lib/machine-label.mjs";
9
10
  import { resolveSecrets, shadowEnv, withSecretExports } from "../lib/secrets.mjs";
10
11
  import { runnerPersona } from "../lib/persona.mjs";
11
12
  import { loadOrCreate } from "../lib/identity.mjs";
@@ -91,6 +92,9 @@ const DIR = process.argv[3] || process.cwd();
91
92
  // back to the git-repo-root basename — never a loose dir basename that could
92
93
  // fork the host's "builtbetter.ai" into a separate "builtbetter" lane.
93
94
  const PROJ = process.env.RELAY_PROJECT || resolveProject(DIR);
95
+ let machineConfig = {};
96
+ try { machineConfig = JSON.parse(readFileSync(join(process.env.AGENT_BUS_DIR || process.env.RELAY_DATA_DIR || join(homedir(), ".agent-bus"), "config.json"), "utf8")); } catch {}
97
+ const MACHINE_LABEL = machineLabel(machineConfig);
94
98
 
95
99
  function gitOut(args, cwd = DIR) {
96
100
  const r = spawnSync("git", args, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], timeout: 8000 });
@@ -183,8 +187,13 @@ const banner = (trigger) => {
183
187
  };
184
188
 
185
189
  async function api(path, body) {
190
+ let payload;
191
+ if (body) {
192
+ payload = { ...body };
193
+ if (path === "/register" && MACHINE_LABEL) payload.machine = MACHINE_LABEL;
194
+ }
186
195
  const opts = body
187
- ? { method: "POST", headers: { "content-type": "application/json", connection: "close" }, body: JSON.stringify(body) }
196
+ ? { method: "POST", headers: { "content-type": "application/json", connection: "close" }, body: JSON.stringify(payload) }
188
197
  : { headers: { connection: "close" } }; // fresh socket per call — long-polls on stale keep-alive sockets reset
189
198
  // Sign as THIS seat. Unsigned calls are 401 on an enforce hub, and because the runner fails open
190
199
  // that shows up as a seat that quietly records nothing rather than one that errors.
@@ -602,7 +611,9 @@ async function balanceRows() {
602
611
  // #7749: the live phase + its start ride the same call, so /peers answers what the seat does NOW.
603
612
  async function registerStatus(status, extra = {}) {
604
613
  const url = HUB + "/register";
605
- const body = JSON.stringify({ session: SESSION, project: PROJ, status, persona: PERSONA, agent: AGENT, llm: AGENT, model: MODEL, ...extra });
614
+ const payload = { session: SESSION, project: PROJ, status, persona: PERSONA, agent: AGENT, llm: AGENT, model: MODEL, ...extra };
615
+ if (MACHINE_LABEL) payload.machine = MACHINE_LABEL;
616
+ const body = JSON.stringify(payload);
606
617
  try {
607
618
  const opts = { method: "POST", headers: { "content-type": "application/json", connection: "close" }, body };
608
619
  await fetch(url, { ...opts, headers: { ...opts.headers, ...signedHeaders(identity, url, opts) }, signal: AbortSignal.timeout(5000) });
@@ -1888,6 +1899,7 @@ async function resolveWakeCard(messages, { session }) {
1888
1899
  // (and resets the counter with the fresh session below); the paused card itself never buys
1889
1900
  // another CLI session. The wake stays owed and retries on a long clock, so the orchestrator
1890
1901
  // sees the pause, not a silent seat.
1902
+
1891
1903
  // #13474: never run a metered provider under a subscription label (or any model off its label).
1892
1904
  // A `trantor swap` (CREW_SWAP_DRIVER) is the operator choosing another provider on purpose.
1893
1905
  const mismatch = process.env.CREW_SWAP_DRIVER ? null : providerMismatch(AGENT, MODEL);
@@ -1,10 +1,6 @@
1
1
  #!/usr/bin/env node
2
- // relay-watch — a live feed of the bus via SSE (true push, no polling). Run in a terminal
3
- // to watch sessions talk in real time, or to monitor a presence/status board.
4
- // node bin/relay-watch.mjs [session] (default: "all" — see every message)
5
- // Signed + per-project hub (2026-07-31, agent-UX audit): the hand-rolled relayUrl() here read
6
- // only the global config `url` (wrong hub for a migrated project) and fetched unsigned (dead
7
- // 401 under RELAY_AUTH=enforce). Now: canonical resolver + this session's keypair on every call.
2
+ // relay-watch streams the bus and lists live peer status.
3
+ // Run `node bin/relay-watch.mjs [session]`; the default watches every session.
8
4
  import { resolveProject, hostId, resolveHub } from "../lib/project.mjs";
9
5
  import { loadOrCreate } from "../lib/identity.mjs";
10
6
  import { sfetch, sfetchJson } from "../lib/signed-fetch.mjs";
@@ -22,7 +18,7 @@ async function showPeers() {
22
18
  const { peers } = await (await sfetchJson(`${URL_BASE}/peers`, { method: "GET", identity })).json();
23
19
  const live = peers.filter(p => p.online);
24
20
  console.log(`\n live sessions (${live.length}):`);
25
- for (const p of live) console.log(` 🟢 ${p.session}${p.status ? ` — ${p.status}` : ""}`);
21
+ for (const p of live) console.log(` 🟢 ${p.session}${p.machine ? ` [${p.machine}]` : ""}${p.status ? ` — ${p.status}` : ""}`);
26
22
  console.log("");
27
23
  } catch {}
28
24
  }
@@ -12,6 +12,7 @@ import { armBaton, readArm, clearArm, readConfig, contextUsage, warnFrac, alread
12
12
  import { resolveProject, hostId } from "../lib/project.mjs";
13
13
  import { installedVersion } from "./lib/update-check.mjs"; // report our hook version so the hub can flag stale sessions
14
14
  import { signedPost } from "./lib/api.mjs";
15
+ import { machineLabel } from "../lib/machine-label.mjs";
15
16
  import { gitCheckoutRoot } from "./lib/git-checkout.mjs";
16
17
 
17
18
  const HEARTBEAT_MS = Number(process.env.RELAY_HEARTBEAT_MS || 60 * 1000);
@@ -166,6 +167,8 @@ async function main(stdinRaw) {
166
167
  llm: process.env.RELAY_LLM || (process.env.RELAY_AGENT ? process.env.RELAY_AGENT.replace(/-orch$/, "") : "claude"),
167
168
  model: modelFromTranscript(stdinRaw),
168
169
  hookVersion: (() => { try { return installedVersion(); } catch { return ""; } })() };
170
+ const machine = machineLabel(readConfig());
171
+ if (machine) beatBody.machine = machine;
169
172
  if (beatKind) beatBody.kind = beatKind;
170
173
  await signedPost("/register", beatBody, { session, timeoutMs: Number(process.env.RELAY_HEARTBEAT_TIMEOUT_MS || 1500) });
171
174
 
@@ -19,6 +19,7 @@ import { ledgerPaths, ensureStart, anchorCursor, writeCursor } from "./lib/inbox
19
19
  import { ensureEnrolled } from "../lib/enroll.mjs";
20
20
  import { memoryStartLine } from "./lib/memory-start.mjs";
21
21
  import { staleResumeLine } from "./lib/cc-signals.mjs";
22
+ import { machineLabel } from "../lib/machine-label.mjs";
22
23
 
23
24
  // The build doctrine (docs/BUILD-DOCTRINE.md) in short form, one line per rule, injected for every
24
25
  // project's ORCHESTRATOR at boot (#6452): orchestrators that never opened the doc missed the ruling.
@@ -194,6 +195,8 @@ try {
194
195
  // (#6075): strict match badge === project, since a badge of "1" carries no name. Absent kind is preserved by /register.
195
196
  const orchBadge = process.env.TRANTOR_ORCH || "";
196
197
  const registerBody = { session, project, status: `active in ${project}` };
198
+ const machine = machineLabel(readConfig());
199
+ if (machine) registerBody.machine = machine;
197
200
  if (orchBadge === project) registerBody.kind = "orch";
198
201
  await jpost(`${url}/register`, registerBody, session).catch(() => {});
199
202
 
package/hub/events.mjs CHANGED
@@ -23,13 +23,15 @@ function applyPeerAuth(p, auth) {
23
23
  p.authWarning = auth.warning;
24
24
  }
25
25
  }
26
- function touch(session, status, project, hookVersion, auth) {
26
+ function touch(session, status, project, hookVersion, auth, machine) {
27
27
  if (!session || session === "all") return; // "all" is a wildcard, not a real peer
28
28
  const p = state.peers[session] || { lastSeen: 0, status: "", project: "" };
29
29
  // Peers carry no terminal address: /send is unauthenticated and `from` is self-asserted, so one
30
30
  // would turn any local process into arbitrary keystrokes. Messages reach agents only through
31
31
  // channels their own harness controls (hooks/inbox-deliver.mjs and hooks/stop-inbox.mjs).
32
32
  delete p.tty; delete p.windowId; delete p.host;
33
+ // Keep only an operator-chosen short label. Never retain the full host field.
34
+ if (typeof machine === "string" && /^[a-z0-9-]{1,24}$/.test(machine)) p.machine = machine;
33
35
  const wasOnline = p._on === true; // explicit flag, so the log gets ONE event per transition
34
36
  p.lastSeen = now();
35
37
  if (status !== undefined) p.status = String(status).slice(0, 280);
@@ -54,7 +54,7 @@ export async function routeAdmin({ req, res, q, P, auth, ctx }) {
54
54
  const b = await body(req);
55
55
  const cpg = crossProjectGuard(auth, P, b);
56
56
  if (!cpg.ok) return json(res, cpg.code, { error: cpg.error });
57
- touch(b.session, b.status, b.project, b.hookVersion, auth);
57
+ touch(b.session, b.status, b.project, b.hookVersion, auth, b.machine);
58
58
  // WHO is this, really: the LLM brand + the exact model currently loaded. In-memory like the
59
59
  // rest of presence — the next heartbeat re-supplies it after a restart.
60
60
  const pr = state.peers[b.session];
@@ -391,7 +391,7 @@ export async function routeAdmin({ req, res, q, P, auth, ctx }) {
391
391
  return json(res, 200, { hubVersion: HUB_VERSION, authMode: AUTH_MODE, peers: peerRows.map(([s, v]) => ({ session: s, lastSeen: v.lastSeen, online: v.lastSeen > cutoff, status: v.status || "", health: healthOf(v.status), project: v.project || "", phase: v.phase || "", phaseSince: v.phaseSince || 0,
392
392
  pubkey: v.pubkey || "", identity: v.identity || null, authWarning: v.authWarning || "",
393
393
  kind: peerKindOf(v), // #8723 bounce-3: same resolver declaredCrewFor reads — never a roster-only answer
394
- llm: v.llm || "", model: v.model || "", hookVersion: v.hookVersion || "", staleHooks: !!(v.lastSeen > cutoff && v.hookVersion && HUB_VERSION && cmpSemver(v.hookVersion, HUB_VERSION) < 0) })) });
394
+ llm: v.llm || "", model: v.model || "", machine: v.machine || undefined, hookVersion: v.hookVersion || "", staleHooks: !!(v.lastSeen > cutoff && v.hookVersion && HUB_VERSION && cmpSemver(v.hookVersion, HUB_VERSION) < 0) })) });
395
395
  }
396
396
  // --- Provider balances (prepaid credit) ---
397
397
  // The hub runs under launchd with no provider keys, so it can't fetch balances itself. Env-having
@@ -0,0 +1,6 @@
1
+ import { asString } from "./decode.mjs";
2
+
3
+ export function machineLabel(config = {}) {
4
+ const label = asString(config?.machineLabel);
5
+ return label && /^[a-z0-9-]{1,24}$/.test(label) ? label : "";
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trantor",
3
- "version": "0.18.124",
3
+ "version": "0.18.125",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "trantor": "bin/cli.mjs"