trantor 0.18.153 → 0.18.154

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.153"
9
+ "version": "0.18.154"
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.153",
16
+ "version": "0.18.154",
17
17
  "author": {
18
18
  "name": "Sasha Bogojevic"
19
19
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trantor",
3
- "version": "0.18.153",
3
+ "version": "0.18.154",
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/hub/events.mjs CHANGED
@@ -31,7 +31,7 @@ function touch(session, status, project, hookVersion, auth, machine) {
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
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;
34
+ if (typeof machine === "string" && /^[a-z0-9-]{1,24}$/i.test(machine)) p.machine = machine;
35
35
  const wasOnline = p._on === true; // explicit flag, so the log gets ONE event per transition
36
36
  p.lastSeen = now();
37
37
  if (status !== undefined) p.status = String(status).slice(0, 280);
@@ -55,8 +55,8 @@ export async function routeAdmin({ req, res, q, P, auth, ctx }) {
55
55
  const cpg = crossProjectGuard(auth, P, b);
56
56
  if (!cpg.ok) return json(res, cpg.code, { error: cpg.error });
57
57
  touch(b.session, b.status, b.project, b.hookVersion, auth, b.machine);
58
- // WHO is this, really: the LLM brand + the exact model currently loaded. In-memory like the
59
- // rest of presence — the next heartbeat re-supplies it after a restart.
58
+ // WHO is this, really: the LLM brand + the exact model currently loaded. These runner-owned
59
+ // fields persist with the peer so an idle seat survives a hub restart without another turn.
60
60
  const pr = state.peers[b.session];
61
61
  if (pr && b.gitRoot) {
62
62
  pr.gitRoot = String(b.gitRoot).slice(0, 2000);
@@ -68,7 +68,9 @@ export async function routeAdmin({ req, res, q, P, auth, ctx }) {
68
68
  // #6148: WHAT a session is rides its peer row (kind "genesis" = the CLI's brief-poster,
69
69
  // "agent" = a crew seat) — /peers hands it to the app so the seat strip can tell them apart.
70
70
  if (pr) { if (b.model) pr.model = String(b.model).slice(0, 80); if (b.llm) pr.llm = String(b.llm).slice(0, 40); if (b.kind) pr.kind = String(b.kind).slice(0, 40); }
71
- if (pr && Object.hasOwn(b, 'accountIdentity')) {
71
+ // Hooks and MCP beats share the runner's session name; only the runner may rotate or clear its account binding.
72
+ const fromRunner = typeof b.persona === "string" && b.persona.length > 0 && typeof b.agent === "string" && b.agent.length > 0;
73
+ if (pr && fromRunner && Object.hasOwn(b, 'accountIdentity')) {
72
74
  const identity = b.accountIdentity;
73
75
  const provider = typeof identity?.provider === "string" && /^[a-z0-9-]{1,60}$/.test(identity.provider) ? identity.provider : 'unknown';
74
76
  const subject = typeof identity?.subject === "string" && /^s-[a-f0-9]{32}$/.test(identity.subject) ? identity.subject : null;
package/hub/store.mjs CHANGED
@@ -153,10 +153,8 @@ function normalizeState(loaded = {}) {
153
153
  // migrate old numeric form
154
154
  s.peers[session] = typeof v === "number"
155
155
  ? { lastSeen: v, status: "", project: "" }
156
- // #6170: `kind` rides the load. This normalizer rebuilds every peer from an explicit field
157
- // list, so a field missing here is dropped however faithfully the store returned it (the kinds
158
- // came back empty on the first live restart). llm/model stay out: they are in-memory presence.
159
- : { lastSeen: v.lastSeen || 0, status: v.status || "", project: v.project || "", pubkey: v.pubkey || "", identity: v.identity || null, authWarning: v.authWarning || "", hookVersion: v.hookVersion || "", kind: v.kind || "", gitRoot: v.gitRoot || loaded.overseerState?.roots?.[session] || "", deliveredUpTo: v.deliveredUpTo || v.delivered_up_to || 0, _on: v._on === true || v.online === true };
156
+ // #6170/#14760: this explicit projection must retain every durable peer field.
157
+ : { lastSeen: v.lastSeen || 0, status: v.status || "", project: v.project || "", pubkey: v.pubkey || "", identity: v.identity || null, authWarning: v.authWarning || "", hookVersion: v.hookVersion || "", kind: v.kind || "", machine: v.machine || "", llm: v.llm || "", model: v.model || "", accountIdentity: v.accountIdentity || null, gitRoot: v.gitRoot || loaded.overseerState?.roots?.[session] || "", deliveredUpTo: v.deliveredUpTo || v.delivered_up_to || 0, _on: v._on === true || v.online === true };
160
158
  }
161
159
  return s;
162
160
  }
package/kimi.plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trantor",
3
- "version": "0.18.153",
3
+ "version": "0.18.154",
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",
@@ -1,4 +1,5 @@
1
1
  import { bindAccounts, resolveSeatAccount } from './accounts.mjs';
2
+ import { canonicalHash } from './snapshot.mjs';
2
3
  import { heldLiability } from './spend.mjs';
3
4
  import { DEFAULT_POLICY } from './policy.mjs';
4
5
  import { loadCatalog, lookup } from '../model-catalog.mjs';
@@ -270,11 +271,31 @@ export function buildEvidence({ balances = [], machines = [], seats = [], discov
270
271
  ];
271
272
  }
272
273
 
274
+ const bridgeStates = new WeakMap();
275
+
276
+ function bridgeState(service, orgId, grantId) {
277
+ if (!bridgeStates.has(service)) bridgeStates.set(service, new Map());
278
+ const states = bridgeStates.get(service);
279
+ const key = JSON.stringify([orgId, grantId]);
280
+ if (!states.has(key)) states.set(key, { accepted: new Map(), failures: new Set() });
281
+ return states.get(key);
282
+ }
283
+
284
+ function contentHash(envelope) {
285
+ const record = structuredClone(envelope.record);
286
+ const observations = envelope.kind === 'account' ? record.windows.map(window => window.remaining)
287
+ : envelope.kind === 'machine' ? [record.health]
288
+ : envelope.kind === 'model' ? [record.catalog, record.entitlement, record.invocation] : [];
289
+ for (const item of observations) delete item.receivedAtMs;
290
+ return canonicalHash({ source: envelope.source, sourceRef: envelope.sourceRef, record });
291
+ }
292
+
273
293
  export function createEvidenceBridge({ service, orgId, grant: grantId, sources,
274
- clock = Date.now, policy = DEFAULT_POLICY, catalog = loadCatalog() }) {
294
+ clock = Date.now, policy = DEFAULT_POLICY, catalog = loadCatalog(), log = console.warn }) {
275
295
  if (!service || !orgId || !grantId || !sources) {
276
296
  throw new TypeError('evidence bridge requires service, orgId, grant and sources');
277
297
  }
298
+ const state = bridgeState(service, orgId, grantId);
278
299
  async function tick() {
279
300
  const nowMs = clock();
280
301
  const [balances, machines, seats, discovery] = await Promise.all([
@@ -283,11 +304,41 @@ export function createEvidenceBridge({ service, orgId, grant: grantId, sources,
283
304
  const pending = buildEvidence({ balances, machines, seats, discovery, orgId, nowMs, policy, catalog })
284
305
  .filter(envelope => envelope.expiresAtMs > clock());
285
306
  let written = 0;
307
+ let rejected = 0;
308
+ const keys = new Set(pending.map(envelope => JSON.stringify([envelope.kind, envelope.id])));
309
+ for (const key of state.accepted.keys()) if (!keys.has(key)) state.accepted.delete(key);
310
+ for (const key of state.failures) if (!keys.has(key)) state.failures.delete(key);
286
311
  for (const envelope of pending) {
287
- const result = await service.registerEvidence(orgId, envelope, { grant: grantId });
288
- if (!result.replayed) written++;
312
+ const key = JSON.stringify([envelope.kind, envelope.id]);
313
+ const sourceTime = envelope.observedAtMs;
314
+ const hash = contentHash(envelope);
315
+ const previous = state.accepted.get(key);
316
+ if (previous && sourceTime >= previous.sourceTime && sourceTime <= previous.observedAtMs) {
317
+ envelope.observedAtMs = hash === previous.hash ? previous.observedAtMs : nowMs;
318
+ }
319
+ try {
320
+ let result;
321
+ try {
322
+ result = await service.registerEvidence(orgId, envelope, { grant: grantId });
323
+ } catch (error) {
324
+ // A restarted bridge can encounter a derived observation already persisted by its predecessor.
325
+ if (previous || !['evidence_conflict', 'evidence_stale'].includes(error.code)
326
+ || envelope.observedAtMs >= nowMs) throw error;
327
+ envelope.observedAtMs = nowMs;
328
+ result = await service.registerEvidence(orgId, envelope, { grant: grantId });
329
+ }
330
+ state.accepted.set(key, { sourceTime, hash, observedAtMs: envelope.observedAtMs });
331
+ state.failures.delete(key);
332
+ if (!result.replayed) written++;
333
+ } catch (error) {
334
+ rejected++;
335
+ if (!state.failures.has(key)) {
336
+ state.failures.add(key);
337
+ log(`[trantor] evidence bridge rejected ${envelope.kind}:${envelope.id}: ${error.code || error.message}`);
338
+ }
339
+ }
289
340
  }
290
- return { observed: pending.length, written, skipped: pending.length - written };
341
+ return { observed: pending.length, written, skipped: pending.length - written - rejected, rejected };
291
342
  }
292
343
  return { tick, build: input => buildEvidence({ ...input, orgId, nowMs: clock(), policy, catalog }) };
293
344
  }
@@ -141,17 +141,25 @@ CREATE TABLE IF NOT EXISTS peers (
141
141
  -- 'orch', 'genesis', 'tool'. The overseer's crew
142
142
  -- exemption reads it (#6075/#6148), so when a restart
143
143
  -- forgot it the hub warned about its own crew.
144
+ machine TEXT,
145
+ llm TEXT,
146
+ model TEXT,
147
+ account_identity JSONB,
144
148
  PRIMARY KEY (org_id, session)
145
149
  );
146
- -- additive migration for hubs whose peers table predates the kind column (#6170)
150
+ -- additive migrations for hubs whose peers table predates these columns
147
151
  ALTER TABLE peers ADD COLUMN IF NOT EXISTS kind TEXT;
152
+ ALTER TABLE peers ADD COLUMN IF NOT EXISTS machine TEXT;
153
+ ALTER TABLE peers ADD COLUMN IF NOT EXISTS llm TEXT;
154
+ ALTER TABLE peers ADD COLUMN IF NOT EXISTS model TEXT;
155
+ ALTER TABLE peers ADD COLUMN IF NOT EXISTS account_identity JSONB;
148
156
  -- DELIBERATELY no CHECK on peers.kind, unlike identities.kind above. The hub accepts whatever a
149
157
  -- client stamps (hub.mjs /register takes any string up to 40 chars) and the vocabulary grows with
150
158
  -- the product — 'genesis' arrived in #6068, 'orch' in #6075. #6169 is the cost of getting this
151
159
  -- wrong in the other direction: a CHECK narrower than the values in flight poisoned every persist
152
160
  -- delta for 13 minutes. A column that stores what it is given cannot fail that way.
153
161
 
154
- -- The fields that currently ride in-memory and are LOST on restart. This is the debt being paid.
162
+ -- State projections without dedicated columns ride in kv so they survive restart.
155
163
  CREATE TABLE IF NOT EXISTS kv (
156
164
  org_id TEXT NOT NULL,
157
165
  key TEXT NOT NULL, -- 'verifyGates'|'balances'|'handoffLog'|'aliases'|'phaseMeta'|'focus'|'projectMeta'|'lessons'|'orgPolicy'|'meta'|'contractReap'
package/lib/store-pg.mjs CHANGED
@@ -162,6 +162,10 @@ function peerFromRow(row) {
162
162
  online: !!row.online,
163
163
  deliveredUpTo: row.delivered_up_to == null ? 0 : Number(row.delivered_up_to),
164
164
  kind: row.kind || "", // #6170: survives the restart that used to forget who was crew
165
+ machine: row.machine || "",
166
+ llm: row.llm || "",
167
+ model: row.model || "",
168
+ accountIdentity: row.account_identity || null,
165
169
  };
166
170
  }
167
171
 
@@ -469,8 +473,8 @@ export class PgStore {
469
473
  async touchPeer(orgId, session, patch = {}) {
470
474
  if (!session || session === "all") return;
471
475
  await this.pool.query(
472
- `INSERT INTO peers(session, org_id, pubkey, project, status, hook_version, last_seen, online, delivered_up_to, kind)
473
- VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10)
476
+ `INSERT INTO peers(session, org_id, pubkey, project, status, hook_version, last_seen, online, delivered_up_to, kind, machine, llm, model, account_identity)
477
+ VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14::jsonb)
474
478
  ON CONFLICT(org_id, session) DO UPDATE SET
475
479
  pubkey=COALESCE(EXCLUDED.pubkey, peers.pubkey),
476
480
  project=COALESCE(NULLIF(EXCLUDED.project,''), peers.project),
@@ -483,12 +487,17 @@ export class PgStore {
483
487
  -- (the MCP one only learns it under TRANTOR_ORCH), and plain last_seen refreshes are the
484
488
  -- majority of writes here — overwriting on every one is how the orchestrator kept
485
489
  -- reverting to a nameless agent between registrations.
486
- kind=COALESCE(NULLIF(EXCLUDED.kind,''), peers.kind)`,
490
+ kind=COALESCE(NULLIF(EXCLUDED.kind,''), peers.kind),
491
+ machine=COALESCE(NULLIF(EXCLUDED.machine,''), peers.machine),
492
+ llm=COALESCE(NULLIF(EXCLUDED.llm,''), peers.llm),
493
+ model=COALESCE(NULLIF(EXCLUDED.model,''), peers.model),
494
+ account_identity=COALESCE(EXCLUDED.account_identity, peers.account_identity)`,
487
495
  [
488
496
  session, orgId, patch.pubkey || null, patch.project || "", patch.status ?? null,
489
497
  patch.hookVersion || patch.hook_version || "", ms(patch.lastSeen || patch.last_seen),
490
498
  patch.online ?? true, Number(patch.deliveredUpTo || patch.delivered_up_to || 0),
491
- patch.kind || "",
499
+ patch.kind || "", patch.machine || "", patch.llm || "", patch.model || "",
500
+ patch.accountIdentity ? JSON.stringify(patch.accountIdentity) : null,
492
501
  ],
493
502
  );
494
503
  }
@@ -618,15 +627,19 @@ export class PgStore {
618
627
  );
619
628
  for (const [session, p] of Object.entries(state.peers || {})) {
620
629
  await c.query(
621
- `INSERT INTO peers(session, org_id, pubkey, project, status, hook_version, last_seen, online, delivered_up_to, kind)
622
- VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10)
630
+ `INSERT INTO peers(session, org_id, pubkey, project, status, hook_version, last_seen, online, delivered_up_to, kind, machine, llm, model, account_identity)
631
+ VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14::jsonb)
623
632
  ON CONFLICT(org_id, session) DO UPDATE SET pubkey=EXCLUDED.pubkey, project=EXCLUDED.project, status=EXCLUDED.status,
624
633
  hook_version=EXCLUDED.hook_version, last_seen=EXCLUDED.last_seen, online=EXCLUDED.online, delivered_up_to=GREATEST(peers.delivered_up_to, EXCLUDED.delivered_up_to),
625
634
  -- #6170: same non-demoting rule as touchPeer. A snapshot is written from MEMORY, and
626
635
  -- memory is exactly where the kind was being lost, so a blank in the snapshot means
627
636
  -- "not known right now", never "this peer is nothing".
628
- kind=COALESCE(NULLIF(EXCLUDED.kind,''), peers.kind)`,
629
- [session, orgId, p.pubkey || "", p.project || "", p.status || "", p.hookVersion || "", Number(p.lastSeen || 0), p._on === true || p.online === true, Number(p.deliveredUpTo || 0), p.kind || ""],
637
+ kind=COALESCE(NULLIF(EXCLUDED.kind,''), peers.kind),
638
+ machine=COALESCE(NULLIF(EXCLUDED.machine,''), peers.machine),
639
+ llm=COALESCE(NULLIF(EXCLUDED.llm,''), peers.llm),
640
+ model=COALESCE(NULLIF(EXCLUDED.model,''), peers.model),
641
+ account_identity=COALESCE(EXCLUDED.account_identity, peers.account_identity)`,
642
+ [session, orgId, p.pubkey || "", p.project || "", p.status || "", p.hookVersion || "", Number(p.lastSeen || 0), p._on === true || p.online === true, Number(p.deliveredUpTo || 0), p.kind || "", p.machine || "", p.llm || "", p.model || "", p.accountIdentity ? JSON.stringify(p.accountIdentity) : null],
630
643
  );
631
644
  }
632
645
  await c.query(
@@ -759,15 +772,19 @@ export class PgStore {
759
772
  for (const raw of peers.upserts) {
760
773
  const p = stripNulDeep(raw);
761
774
  await c.query(
762
- `INSERT INTO peers(session, org_id, pubkey, project, status, hook_version, last_seen, online, delivered_up_to, kind)
763
- VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10)
775
+ `INSERT INTO peers(session, org_id, pubkey, project, status, hook_version, last_seen, online, delivered_up_to, kind, machine, llm, model, account_identity)
776
+ VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14::jsonb)
764
777
  ON CONFLICT(org_id, session) DO UPDATE SET pubkey=EXCLUDED.pubkey, project=EXCLUDED.project, status=EXCLUDED.status,
765
778
  hook_version=EXCLUDED.hook_version, last_seen=EXCLUDED.last_seen, online=EXCLUDED.online, delivered_up_to=GREATEST(peers.delivered_up_to, EXCLUDED.delivered_up_to),
766
779
  -- #6170: THIS is the path a running hub actually persists through — saveDelta on the
767
780
  -- persist tick, not touchPeer or saveSnapshot. Adding the column to the other two and
768
781
  -- not this one is why the first live restart still came back with empty kinds.
769
- kind=COALESCE(NULLIF(EXCLUDED.kind,''), peers.kind)`,
770
- [p.session, orgId, p.pubkey || "", p.project || "", p.status || "", p.hookVersion || "", Number(p.lastSeen || 0), p._on === true || p.online === true, Number(p.deliveredUpTo || 0), p.kind || ""],
782
+ kind=COALESCE(NULLIF(EXCLUDED.kind,''), peers.kind),
783
+ machine=COALESCE(NULLIF(EXCLUDED.machine,''), peers.machine),
784
+ llm=COALESCE(NULLIF(EXCLUDED.llm,''), peers.llm),
785
+ model=COALESCE(NULLIF(EXCLUDED.model,''), peers.model),
786
+ account_identity=COALESCE(EXCLUDED.account_identity, peers.account_identity)`,
787
+ [p.session, orgId, p.pubkey || "", p.project || "", p.status || "", p.hookVersion || "", Number(p.lastSeen || 0), p._on === true || p.online === true, Number(p.deliveredUpTo || 0), p.kind || "", p.machine || "", p.llm || "", p.model || "", p.accountIdentity ? JSON.stringify(p.accountIdentity) : null],
771
788
  );
772
789
  }
773
790
  if (peers.deletes.length) await c.query("DELETE FROM peers WHERE org_id=$1 AND session = ANY($2::text[])", [orgId, peers.deletes]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trantor",
3
- "version": "0.18.153",
3
+ "version": "0.18.154",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "trantor": "bin/cli.mjs"