trantor 0.18.149 → 0.18.153
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.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/bin/advise.mjs +11 -8
- package/bin/balances-agent.mjs +112 -0
- package/bin/balances.mjs +13 -11
- package/bin/cli.mjs +1 -1
- package/bin/connect.mjs +10 -1
- package/bin/crew-runner.mjs +27 -12
- package/bin/integrate.mjs +38 -9
- package/bin/turn-watchdog.mjs +15 -1
- package/bin/wake-nudge.mjs +5 -2
- package/deploy/restart-hub.sh +2 -0
- package/docs/FEATURES.md +4 -1
- package/hooks/sessionstart.mjs +6 -1
- package/hub/auth.mjs +5 -0
- package/hub/routes/admin.mjs +9 -1
- package/hub/routes/dispatcher-operations.mjs +12 -0
- package/hub/routes/git-policy.mjs +35 -0
- package/hub/startup-config.mjs +14 -0
- package/hub/store.mjs +32 -2
- package/hub.mjs +4 -2
- package/kimi.plugin.json +1 -1
- package/lib/balance-publish.mjs +22 -0
- package/lib/balances.mjs +28 -6
- package/lib/canary/canary.mjs +2 -0
- package/lib/canary/probes.mjs +62 -0
- package/lib/dispatcher/accounts.mjs +91 -1
- package/lib/dispatcher/admission.mjs +1 -0
- package/lib/dispatcher/board-bridge.mjs +82 -0
- package/lib/dispatcher/evidence-bridge.mjs +293 -0
- package/lib/dispatcher/operations.mjs +147 -20
- package/lib/dispatcher/planner.mjs +4 -2
- package/lib/dispatcher/preflight.mjs +42 -7
- package/lib/dispatcher/rollout.mjs +357 -0
- package/lib/dispatcher/schemas.mjs +2 -0
- package/lib/dispatcher/snapshot.mjs +18 -9
- package/lib/dispatcher/store.mjs +15 -0
- package/lib/git-guard.mjs +210 -0
- package/lib/integrate.mjs +10 -2
- package/lib/store-contract.mjs +7 -1
- package/mcp.mjs +4 -5
- package/package.json +3 -3
|
@@ -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.
|
|
9
|
+
"version": "0.18.153"
|
|
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.
|
|
16
|
+
"version": "0.18.153",
|
|
17
17
|
"author": {
|
|
18
18
|
"name": "Sasha Bogojevic"
|
|
19
19
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trantor",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.153",
|
|
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/bin/advise.mjs
CHANGED
|
@@ -241,16 +241,19 @@ export function advise(input, world = loadWorld()) {
|
|
|
241
241
|
return recommendation;
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
-
// #14678: stdin carrying {cards|drafts}, or --snapshot/--policy, asks the hub's planner (POST /advise);
|
|
245
|
-
// {task, packages} keeps the legacy advisor above, usable in shadow mode.
|
|
244
|
+
// #14678: stdin carrying {cards|drafts}, or --card/--snapshot/--policy, asks the hub's planner (POST /advise);
|
|
245
|
+
// {task, packages} keeps the legacy advisor above, usable in shadow mode. #14742: cards may be card
|
|
246
|
+
// numbers (--card N, repeatable, or {cards:[N]}); the hub's own WorkCard for each is fetched first.
|
|
247
|
+
export const cardFlags = (argv) => argv.flatMap((a, i) => (a === "--card" ? [Number(argv[i + 1])] : []));
|
|
246
248
|
async function hubAdvice(input, argv) {
|
|
247
|
-
const { signedPost, sessionContext } = await import("../hooks/lib/api.mjs");
|
|
248
|
-
const {
|
|
249
|
+
const { signedGet, signedPost, sessionContext } = await import("../hooks/lib/api.mjs");
|
|
250
|
+
const { adviseCards, renderAdvice } = await import("../lib/dispatcher/preflight.mjs");
|
|
249
251
|
const flag = (name) => { const i = argv.indexOf(name); return i > -1 ? argv[i + 1] : undefined; };
|
|
250
252
|
const project = input.project || sessionContext().project;
|
|
251
|
-
const
|
|
252
|
-
snapshotId: flag("--snapshot") || input.snapshotId, policyVersion: flag("--policy") || input.policyVersion
|
|
253
|
-
|
|
253
|
+
const result = await adviseCards({ project, cards: [...(input.cards || []), ...cardFlags(argv)], drafts: input.drafts || [],
|
|
254
|
+
snapshotId: flag("--snapshot") || input.snapshotId, policyVersion: flag("--policy") || input.policyVersion,
|
|
255
|
+
get: (path) => signedGet(path, { project, timeoutMs: 5000 }),
|
|
256
|
+
post: (path, body) => signedPost(path, body, { project, timeoutMs: 10000 }), busDir: busDir() });
|
|
254
257
|
console.log(argv.includes("--json") ? JSON.stringify(result, null, 2) : renderAdvice(result));
|
|
255
258
|
return result.source === "refused" ? 1 : 0;
|
|
256
259
|
}
|
|
@@ -263,7 +266,7 @@ if (import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
|
263
266
|
if (!argv.includes("--demo")) {
|
|
264
267
|
const stdin = process.stdin.isTTY ? "" : readFileSync(0, "utf8").trim();
|
|
265
268
|
input = stdin ? JSON.parse(stdin) : { packages: [] };
|
|
266
|
-
if (input.cards || input.drafts ||
|
|
269
|
+
if (input.cards || input.drafts || ["--card", "--snapshot", "--policy"].some((f) => argv.includes(f))) process.exit(await hubAdvice(input, argv));
|
|
267
270
|
}
|
|
268
271
|
if (argv.includes("--demo")) {
|
|
269
272
|
input = { task: "neon asteroids game", packages: [
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { execFileSync, spawnSync } from "node:child_process";
|
|
3
|
+
import { existsSync, mkdirSync, rmSync, writeFileSync } 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 { stableNodeExec } from "../lib/launch-node.mjs";
|
|
8
|
+
import { reloadLaunchAgent } from "../lib/launchd.mjs";
|
|
9
|
+
import { busDir } from "../lib/project.mjs";
|
|
10
|
+
import { sessionContext } from "../hooks/lib/api.mjs";
|
|
11
|
+
|
|
12
|
+
export const BALANCES_LABEL = "com.trantor.balances";
|
|
13
|
+
const SELF = fileURLToPath(import.meta.url);
|
|
14
|
+
const BALANCES_SCRIPT = join(dirname(SELF), "balances.mjs");
|
|
15
|
+
const xml = value => String(value).replace(/[&<>"']/g, c => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
16
|
+
|
|
17
|
+
export function balancesPlist({ bus, home = homedir(), script = SELF, path = process.env.PATH || "/usr/bin:/bin", context = sessionContext() }) {
|
|
18
|
+
const body = stableNodeExec(script, ["run"]);
|
|
19
|
+
const env = { AGENT_BUS_DIR: bus, HOME: home, PATH: path, RELAY_SESSION: context.session, RELAY_PROJECT: context.project };
|
|
20
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
21
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
22
|
+
<plist version="1.0"><dict>
|
|
23
|
+
<key>Label</key><string>${BALANCES_LABEL}</string>
|
|
24
|
+
<key>ProgramArguments</key><array><string>/bin/bash</string><string>-c</string><string>${xml(body)}</string></array>
|
|
25
|
+
<key>EnvironmentVariables</key><dict>${Object.entries(env).map(([key, value]) => `<key>${key}</key><string>${xml(value)}</string>`).join("")}</dict>
|
|
26
|
+
<key>RunAtLoad</key><true/>
|
|
27
|
+
<key>StartInterval</key><integer>240</integer>
|
|
28
|
+
<key>StandardOutPath</key><string>${xml(join(bus, "balances-launchd.log"))}</string>
|
|
29
|
+
<key>StandardErrorPath</key><string>${xml(join(bus, "balances-launchd.log"))}</string>
|
|
30
|
+
</dict></plist>
|
|
31
|
+
`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// #14753: an empty project signs as "<host>:" and the shared hub answers 401, so up refuses it.
|
|
35
|
+
export function installContext(argv = [], context = sessionContext(), env = process.env) {
|
|
36
|
+
const at = argv.indexOf("--project");
|
|
37
|
+
const project = at >= 0 ? String(argv[at + 1] || "") : context.project;
|
|
38
|
+
if (!project || project.startsWith("-")) throw new Error("balances collector needs a project identity: run `up` from a project checkout or pass --project <name>");
|
|
39
|
+
const session = at >= 0 && !env.RELAY_SESSION ? `${context.session.split(":")[0]}:${project}` : context.session;
|
|
40
|
+
return { session, project };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function errorDetail(result) {
|
|
44
|
+
const detail = String(result.error?.message || result.stderr || result.stdout || `balances exited with status ${result.status ?? "unknown"}`).trim();
|
|
45
|
+
return detail.slice(0, 1000);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function runBalancesOnce({
|
|
49
|
+
bus = busDir(),
|
|
50
|
+
script = BALANCES_SCRIPT,
|
|
51
|
+
runner = spawnSync,
|
|
52
|
+
log = message => console.error(message),
|
|
53
|
+
} = {}) {
|
|
54
|
+
mkdirSync(bus, { recursive: true });
|
|
55
|
+
const marker = join(bus, "balances-collector.failed");
|
|
56
|
+
const failedBefore = existsSync(marker);
|
|
57
|
+
const result = runner(process.execPath, [script, "--json", "--require-push"], {
|
|
58
|
+
encoding: "utf8",
|
|
59
|
+
env: process.env,
|
|
60
|
+
timeout: 120000,
|
|
61
|
+
maxBuffer: 4 * 1024 * 1024,
|
|
62
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
63
|
+
});
|
|
64
|
+
if (result.status === 0 && !result.error) {
|
|
65
|
+
if (failedBefore) {
|
|
66
|
+
rmSync(marker, { force: true });
|
|
67
|
+
log(`${BALANCES_LABEL}: collector recovered`);
|
|
68
|
+
}
|
|
69
|
+
return 0;
|
|
70
|
+
}
|
|
71
|
+
if (!failedBefore) {
|
|
72
|
+
writeFileSync(marker, `${errorDetail(result)}\n`, { mode: 0o600 });
|
|
73
|
+
log(`${BALANCES_LABEL}: ${errorDetail(result)}`);
|
|
74
|
+
}
|
|
75
|
+
return Number.isInteger(result.status) && result.status !== 0 ? result.status : 1;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function launchctl(args) {
|
|
79
|
+
return execFileSync("launchctl", args, { encoding: "utf8", timeout: 8000, stdio: ["ignore", "pipe", "ignore"] });
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function main() {
|
|
83
|
+
const cmd = process.argv[2] || "status";
|
|
84
|
+
const bus = busDir();
|
|
85
|
+
const plist = join(homedir(), "Library", "LaunchAgents", `${BALANCES_LABEL}.plist`);
|
|
86
|
+
const service = `gui/${process.getuid?.() ?? 0}/${BALANCES_LABEL}`;
|
|
87
|
+
if (cmd === "run") {
|
|
88
|
+
process.exitCode = runBalancesOnce({ bus });
|
|
89
|
+
} else if (cmd === "up") {
|
|
90
|
+
if (process.platform !== "darwin") throw new Error("balances collector requires launchd");
|
|
91
|
+
const context = installContext(process.argv.slice(3));
|
|
92
|
+
mkdirSync(bus, { recursive: true });
|
|
93
|
+
mkdirSync(dirname(plist), { recursive: true });
|
|
94
|
+
writeFileSync(plist, balancesPlist({ bus, context }), { mode: 0o600 });
|
|
95
|
+
const reloaded = reloadLaunchAgent({ label: BALANCES_LABEL, plist, domain: `gui/${process.getuid?.() ?? 0}` });
|
|
96
|
+
if (!reloaded.ok) throw new Error(reloaded.error);
|
|
97
|
+
console.log(`${BALANCES_LABEL} installed${reloaded.pid ? ` (pid ${reloaded.pid})` : ""}; collecting every 4 minutes`);
|
|
98
|
+
} else if (cmd === "down") {
|
|
99
|
+
try { launchctl(["bootout", service]); } catch {}
|
|
100
|
+
rmSync(plist, { force: true });
|
|
101
|
+
rmSync(join(bus, "balances-collector.failed"), { force: true });
|
|
102
|
+
console.log(`${BALANCES_LABEL} stopped`);
|
|
103
|
+
} else if (cmd === "status") {
|
|
104
|
+
console.log(existsSync(plist) ? launchctl(["print", service]) : `${BALANCES_LABEL} not installed`);
|
|
105
|
+
} else {
|
|
106
|
+
throw new Error("usage: node bin/balances-agent.mjs up [--project <name>]|down|status|run");
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (process.argv[1] && resolve(process.argv[1]) === SELF) {
|
|
111
|
+
main().catch(error => { console.error(error.message); process.exitCode = 1; });
|
|
112
|
+
}
|
package/bin/balances.mjs
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
/* oxlint-disable anti-slop/no-runtime-typeof -- SAFETY: config.json is user-editable external input; thresholds validates its optional number/object fields at that I/O boundary. */
|
|
3
3
|
// trantor balances: how much credit is left on each provider, so you can refill before a build
|
|
4
4
|
// stalls. Queries each provider with the env keys and pushes the snapshot to the hub.
|
|
5
|
-
// Usage: trantor balances [--json] [--no-push]
|
|
6
|
-
import { readFileSync
|
|
5
|
+
// Usage: trantor balances [--json] [--no-push] [--require-push]
|
|
6
|
+
import { readFileSync } from "node:fs";
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
import { homedir } from "node:os";
|
|
9
9
|
import { fetchBalances, isLow, fmtBalance, snapshotPayload, DEFAULT_LOW, DEFAULT_LOW_QUOTA_PCT } from "../lib/balances.mjs";
|
|
@@ -12,18 +12,18 @@ import { detectedCliBalanceRows } from "../lib/providers.mjs";
|
|
|
12
12
|
import { loadProfile } from "./profile.mjs";
|
|
13
13
|
import { resolveKeys } from "../lib/provider-keys.mjs";
|
|
14
14
|
import { publishUsageEnabled } from "../hooks/lib/balance-check.mjs";
|
|
15
|
+
import { publishBalanceSnapshot } from "../lib/balance-publish.mjs";
|
|
15
16
|
|
|
16
17
|
const args = process.argv.slice(2);
|
|
17
18
|
const asJson = args.includes("--json");
|
|
18
19
|
const noPush = args.includes("--no-push");
|
|
20
|
+
const requirePush = args.includes("--require-push");
|
|
19
21
|
|
|
20
22
|
// API-key providers stay profile-scoped so ambient keys are never scraped. Claude and Codex are
|
|
21
23
|
// machine CLI logins: the registry admits them from binary + credential + live-probe detection.
|
|
22
24
|
const profileProviders = loadProfile().providers || {};
|
|
23
25
|
const configured = Object.keys(profileProviders);
|
|
24
26
|
|
|
25
|
-
// Signed via the shared client: an unsigned POST is rejected under enforce.
|
|
26
|
-
import { signedPost } from "../hooks/lib/api.mjs";
|
|
27
27
|
let _qpct = DEFAULT_LOW_QUOTA_PCT;
|
|
28
28
|
function thresholds() {
|
|
29
29
|
try { const c = JSON.parse(readFileSync(join(homedir(), ".agent-bus", "config.json"), "utf8")); if (typeof c.lowQuotaPct === "number") _qpct = c.lowQuotaPct; if (c.lowBalance && typeof c.lowBalance === "object") return { ...DEFAULT_LOW, ...c.lowBalance }; } catch {}
|
|
@@ -36,16 +36,17 @@ const profileScoped = await fetchBalances(env, { only: configured.filter((provid
|
|
|
36
36
|
const balances = [...detected, ...profileScoped];
|
|
37
37
|
const low = thresholds();
|
|
38
38
|
|
|
39
|
-
// Push
|
|
40
|
-
//
|
|
41
|
-
//
|
|
39
|
+
// Push to the project and LOCAL hubs. Manual reports are best-effort;
|
|
40
|
+
// --require-push makes the scheduled collector fail unless the project hub accepts the snapshot.
|
|
41
|
+
// "publishUsage": false means a seats-only machine: skip both pushes but still print the report.
|
|
42
|
+
let publishFailed = false;
|
|
42
43
|
if (!noPush && publishUsageEnabled()) {
|
|
43
44
|
const snap = snapshotPayload(balances, { machine: hostId(), profile: profileProviders });
|
|
44
|
-
try { await
|
|
45
|
-
|
|
45
|
+
try { await publishBalanceSnapshot(snap, { required: requirePush }); }
|
|
46
|
+
catch (error) { publishFailed = true; console.error(`balances: ${error.message}`); }
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
if (asJson) { console.log(JSON.stringify({ balances, low: balances.filter((b) => isLow(b, low, _qpct)).map((b) => b.provider) }, null, 2)); process.exit(0); }
|
|
49
|
+
if (asJson) { console.log(JSON.stringify({ balances, low: balances.filter((b) => isLow(b, low, _qpct)).map((b) => b.provider) }, null, 2)); process.exit(publishFailed ? 1 : 0); }
|
|
49
50
|
|
|
50
51
|
if (!balances.length) {
|
|
51
52
|
if (!configured.length) {
|
|
@@ -55,7 +56,7 @@ if (!balances.length) {
|
|
|
55
56
|
console.log(`configured providers: ${configured.join(", ")} — but none expose a balance/quota API with a key present.`);
|
|
56
57
|
console.log("(subscriptions like claude/codex/gemini have nothing to refill; prepaid/coding-plan providers need their key in the env.)");
|
|
57
58
|
}
|
|
58
|
-
process.exit(0);
|
|
59
|
+
process.exit(publishFailed ? 1 : 0);
|
|
59
60
|
}
|
|
60
61
|
console.log("PROVIDER CREDITS\n");
|
|
61
62
|
for (const b of balances) {
|
|
@@ -65,3 +66,4 @@ for (const b of balances) {
|
|
|
65
66
|
}
|
|
66
67
|
const lows = balances.filter((b) => isLow(b, low, _qpct));
|
|
67
68
|
if (lows.length) console.log(`\n⚠ ${lows.length} provider(s) low — top up / pace: ${lows.map((b) => b.label).join(", ")}`);
|
|
69
|
+
if (publishFailed) process.exitCode = 1;
|
package/bin/cli.mjs
CHANGED
|
@@ -320,7 +320,7 @@ switch (cmd) {
|
|
|
320
320
|
trantor capacity the live ledger: budgets and resets, burn rate, machines, seats — [--json] [--version 1 [--snapshot <id>]]
|
|
321
321
|
trantor recost recompute sub-agent notional cost from on-disk transcripts + reseed the board (repair after upgrade) — [--dry-run]
|
|
322
322
|
trantor handoff finish this session NOW: write a handoff, open a fresh session that takes over, and close this one (manual baton)
|
|
323
|
-
trantor advise ask the Advisor directly (JSON on stdin; --demo to see it); {"cards":[
|
|
323
|
+
trantor advise ask the Advisor directly (JSON on stdin; --demo to see it); --card <n> (repeatable) or {"cards":[<n>]} asks the hub planner — [--json] [--snapshot <id>] [--policy <v>]
|
|
324
324
|
trantor dispatch admit planned cards through the hub: --decision <id> [--card <n>] · status <attemptId> · preflight — [--json]
|
|
325
325
|
trantor project this checkout's identity: project [<id>] — records .trantor/project.json so a directory rename cannot orphan the board, pin and sessions
|
|
326
326
|
project permissions <name> [ask|bypass] — whether <name>'s agents ask before acting or act without asking; no value prints it
|
package/bin/connect.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// trantor connect — wire every AI coding CLI on this machine to the bus, in one shot (idempotent;
|
|
3
3
|
// --dry-run touches nothing). Writes the one "relay" MCP entry into each CLI's own config format,
|
|
4
4
|
// with a timestamped .bak backup on first change. Claude Code rides the plugin: verified, not patched.
|
|
5
|
-
import { readFileSync, writeFileSync, existsSync, mkdirSync, copyFileSync } from "node:fs";
|
|
5
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync, copyFileSync, realpathSync, statSync } from "node:fs";
|
|
6
6
|
import { join, dirname } from "node:path";
|
|
7
7
|
import { homedir } from "node:os";
|
|
8
8
|
import { execSync } from "node:child_process";
|
|
@@ -296,6 +296,15 @@ const found = out.length;
|
|
|
296
296
|
if (!DRY) writeProjectId(root, PROJECT_AT_CONNECT, "trantor connect");
|
|
297
297
|
report("project", `id ${PROJECT_AT_CONNECT} recorded in ${PROJECT_MARKER} — commit it so worktrees and clones carry the identity`, root);
|
|
298
298
|
}
|
|
299
|
+
// Linked worktrees must not register themselves as the operator's checkout.
|
|
300
|
+
if (root && ["marker", "git"].includes(PROJECT_INFO.via) && statSync(join(root, ".git")).isDirectory()) {
|
|
301
|
+
if (!DRY) {
|
|
302
|
+
const path = join(root, PROJECT_MARKER);
|
|
303
|
+
const marker = JSON.parse(readFileSync(path, "utf8"));
|
|
304
|
+
writeFileSync(path, JSON.stringify({ ...marker, operatorCheckout: realpathSync(root) }, null, 2) + "\n");
|
|
305
|
+
}
|
|
306
|
+
report("project", `${DRY ? "would record" : "recorded"} operator checkout`, root);
|
|
307
|
+
}
|
|
299
308
|
}
|
|
300
309
|
console.log(`trantor connect${DRY ? " (dry run)" : ""} — project: ${PROJECT_AT_CONNECT}, hub: ${URL_}`);
|
|
301
310
|
for (const r of out) console.log(` ${r.cli.padEnd(9)} ${r.status}${r.detail ? ` (${r.detail})` : ""}`);
|
package/bin/crew-runner.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// trantor crew runner — keeps a crew agent alive without burning tokens: it long-polls the bus
|
|
3
3
|
// (zero tokens) and resumes the CLI with each message. Usage: node crew-runner.mjs <agent> [dir]
|
|
4
|
+
import { resolveKeys } from "../lib/provider-keys.mjs";
|
|
5
|
+
import { runnerAccountIdentity } from "../lib/dispatcher/accounts.mjs";
|
|
4
6
|
import { execSync, spawnSync, spawn } from "node:child_process";
|
|
5
7
|
import { randomUUID } from "node:crypto";
|
|
6
8
|
import { readFileSync, writeFileSync, unlinkSync, existsSync, appendFileSync, mkdirSync, realpathSync, statSync, rmSync } from "node:fs";
|
|
@@ -226,7 +228,7 @@ async function api(path, body) {
|
|
|
226
228
|
let payload;
|
|
227
229
|
if (body) {
|
|
228
230
|
payload = { ...body };
|
|
229
|
-
if (path === "/register"
|
|
231
|
+
if (path === "/register") payload.machine = MACHINE_LABEL || hostId().toLowerCase();
|
|
230
232
|
}
|
|
231
233
|
const opts = body
|
|
232
234
|
? { method: "POST", headers: { "content-type": "application/json", connection: "close" }, body: JSON.stringify(payload) }
|
|
@@ -547,7 +549,7 @@ async function reportFailure(exit, trigger, undelivered = 0, reasonOverride = ""
|
|
|
547
549
|
// queue kept, ladder stopped, room told once with the reset time. `trantor up` resumes.
|
|
548
550
|
let parkAnnounced = false;
|
|
549
551
|
// #7914: the park this seat is currently sitting in, or null. Read by the poll loop, which ends a
|
|
550
|
-
// bounded one the moment somebody sends a direct message, and cleared by any turn that lands.
|
|
552
|
+
// bounded one the moment somebody sends a waking direct message, and cleared by any turn that lands.
|
|
551
553
|
let parkState = null;
|
|
552
554
|
// #13949: unpark already told the room the episode ended, so the next reportHealthy must not echo
|
|
553
555
|
// a second "recovered" for the same landing. Consumed on every reportHealthy call, used or not.
|
|
@@ -561,7 +563,7 @@ const sameParkEpisode = (reason) => !!(parkState && parkState.reason === reason)
|
|
|
561
563
|
// names the resume clock (and the shortcut), a wall says it holds. Read after parkSeat sets it.
|
|
562
564
|
function parkLifts() {
|
|
563
565
|
return parkState?.bounded
|
|
564
|
-
? ` · resumes ${new Date(parkState.until).toLocaleTimeString()} (a direct message ends it now)`
|
|
566
|
+
? ` · resumes ${new Date(parkState.until).toLocaleTimeString()} (a waking direct message ends it now)`
|
|
565
567
|
: " — not retrying";
|
|
566
568
|
}
|
|
567
569
|
// #13474: uncommitted work in the seat worktree is saved on the seat branch when a turn is cut or
|
|
@@ -596,7 +598,7 @@ async function parkSeat(reason, undelivered, resetHint = 0, { evidence = "", ann
|
|
|
596
598
|
// #7914: the notice carries its own evidence. A reader who has to open three logs to learn
|
|
597
599
|
// which turns died and how is a reader who does not look, which is how 46 minutes passed.
|
|
598
600
|
const why = evidence ? ` · ${evidence}` : "";
|
|
599
|
-
const text = redactKeys(`⛔ ${SESSION} PARKED (${reason}${named}) — holding ${undelivered} message(s), redelivery stopped ${when ? `until ${when}` : `until \`trantor up ${AGENT}\``}${bounded ? " · a direct message ends the park now" : ""}${why}`);
|
|
601
|
+
const text = redactKeys(`⛔ ${SESSION} PARKED (${reason}${named}) — holding ${undelivered} message(s), redelivery stopped ${when ? `until ${when}` : `until \`trantor up ${AGENT}\``}${bounded ? " · a waking direct message ends the park now" : ""}${why}`);
|
|
600
602
|
await api("/send", { from: SESSION, to: "all", text, project: PROJ, kind: "status" }).catch(() => {});
|
|
601
603
|
const orch = `${hostId()}:${PROJ}`;
|
|
602
604
|
if (orch !== SESSION) await api("/send", { from: SESSION, to: orch, text, project: PROJ, kind: "alert" }).catch(() => {});
|
|
@@ -616,7 +618,7 @@ async function parkSeat(reason, undelivered, resetHint = 0, { evidence = "", ann
|
|
|
616
618
|
return until;
|
|
617
619
|
}
|
|
618
620
|
|
|
619
|
-
// #7914: the park is over — because a direct message asked for a turn now, or because one landed.
|
|
621
|
+
// #7914: the park is over — because a waking direct message asked for a turn now, or because one landed.
|
|
620
622
|
// The record goes with it, and the announce latch reopens so the NEXT park is heard too (a latch
|
|
621
623
|
// that never reopens turns a repeating park into one message and then silence).
|
|
622
624
|
// #13949: the END is an event too, once — one "recovered" each to the room and the orchestrator.
|
|
@@ -675,6 +677,16 @@ async function balanceRows() {
|
|
|
675
677
|
} catch { return []; }
|
|
676
678
|
}
|
|
677
679
|
|
|
680
|
+
// Identity refresh runs outside presence: keychain lookups must not scale with beat frequency.
|
|
681
|
+
const ACCOUNT_IDENTITY_REFRESH_MS = 5 * 60_000;
|
|
682
|
+
let cachedAccountIdentity;
|
|
683
|
+
function refreshAccountIdentity() {
|
|
684
|
+
cachedAccountIdentity = runnerAccountIdentity({ harness: AGENT, model: MODEL,
|
|
685
|
+
env: resolveKeys(process.env, [cli.env, join(homedir(), ".agent-bus", ".env")].filter(Boolean), resolveSecrets(process.env)) });
|
|
686
|
+
}
|
|
687
|
+
refreshAccountIdentity();
|
|
688
|
+
setInterval(refreshAccountIdentity, ACCOUNT_IDENTITY_REFRESH_MS).unref();
|
|
689
|
+
|
|
678
690
|
// ---- activity truth (#5965): the RUNNER is the source for this seat ----------------
|
|
679
691
|
// The runner reports `working · <trigger>` at start and `idle` on a clean landing, bounded to 5s.
|
|
680
692
|
// #7749: the live phase + its start ride the same call, so /peers answers what the seat does NOW.
|
|
@@ -687,7 +699,8 @@ async function registerStatus(status, extra = {}) {
|
|
|
687
699
|
}
|
|
688
700
|
const url = HUB + "/register";
|
|
689
701
|
const payload = { session: SESSION, project: PROJ, status, persona: PERSONA, agent: AGENT, llm: AGENT, model: MODEL, ...extra };
|
|
690
|
-
|
|
702
|
+
payload.machine = MACHINE_LABEL || hostId().toLowerCase();
|
|
703
|
+
payload.accountIdentity = cachedAccountIdentity;
|
|
691
704
|
const body = JSON.stringify(payload);
|
|
692
705
|
try {
|
|
693
706
|
const opts = { method: "POST", headers: { "content-type": "application/json", connection: "close" }, body };
|
|
@@ -1051,9 +1064,11 @@ async function runTurn(prompt, isFirst, trigger = "kickoff", opts = {}) {
|
|
|
1051
1064
|
} : undefined;
|
|
1052
1065
|
const presencePayload = { session: SESSION, project: PROJ, status: `working · ${trigger}`, persona: PERSONA,
|
|
1053
1066
|
agent: AGENT, llm: AGENT, model: MODEL, kind: "agent", phase: "working", phaseSince: t0, card: sessionCard || 0 };
|
|
1054
|
-
|
|
1067
|
+
presencePayload.machine = MACHINE_LABEL || hostId().toLowerCase();
|
|
1068
|
+
presencePayload.accountIdentity = cachedAccountIdentity;
|
|
1055
1069
|
writeFileSync(STAMPF, JSON.stringify({ turn: TURN, startedAt: Date.now(), runner: RUNNER_ID, box: boxPlan, activity,
|
|
1056
|
-
presence: { intervalMs: PRESENCE_MS, payload: presencePayload }
|
|
1070
|
+
presence: { intervalMs: PRESENCE_MS, payload: presencePayload },
|
|
1071
|
+
worktree: { cwd: TURN_DIR, seat: PERSONA, project: PROJ, machine: presencePayload.machine } }));
|
|
1057
1072
|
const wd = spawn(process.execPath, [join(import.meta.dirname, "turn-watchdog.mjs"), STAMPF, ERRF, String(WD_MS), SESSION, PROJ, HUB, TRANSCRIPT_DIR, TURN_DIR,
|
|
1058
1073
|
// #7752: the stall marker only exists when a box does — with no box there is no sweep to
|
|
1059
1074
|
// end the turn, so the watchdog stays report-only (reporting is the whole job, boxless).
|
|
@@ -1953,10 +1968,10 @@ async function resolveWakeCard(messages, { session }) {
|
|
|
1953
1968
|
savePending(pendingWake, pendingBcast);
|
|
1954
1969
|
}
|
|
1955
1970
|
if (awaitingAsk) { log(`holding for the answer to ask #${awaitingAsk.id} — ${wake.length} new message(s) queued behind it`); continue; }
|
|
1956
|
-
// #7914: a fresh DIRECT message to a parked seat is somebody asking for a turn now, so
|
|
1957
|
-
// a bounded park instead of queueing behind the window; a mention
|
|
1958
|
-
//
|
|
1959
|
-
const directWake = wake.filter(m => m.to === SESSION);
|
|
1971
|
+
// #7914: a fresh waking DIRECT message to a parked seat is somebody asking for a turn now, so
|
|
1972
|
+
// it ends a bounded park instead of queueing behind the window; a mention or wake:false note
|
|
1973
|
+
// does not. An exhausted or auth park is a wall and stands anyway (#6134).
|
|
1974
|
+
const directWake = wake.filter(m => m.to === SESSION && m.wake !== false);
|
|
1960
1975
|
// #10197: no-delivery owes the old contract, but its retry delay must not batch away
|
|
1961
1976
|
// fresh contracts. Only actual CLI failures impose backoff on a new wake.
|
|
1962
1977
|
if (noDeliveryRetry) {
|
package/bin/integrate.mjs
CHANGED
|
@@ -8,7 +8,8 @@ import { resolveAutonomy } from "../lib/autonomy.mjs";
|
|
|
8
8
|
import { seatWorktrees, commitSeatWork, seatAhead, mergeSeat, verify, git } from "../lib/integrate.mjs";
|
|
9
9
|
import { recordHarvest } from "../lib/harvest.mjs";
|
|
10
10
|
import { ownerIdentity } from "../lib/enroll.mjs";
|
|
11
|
-
import {
|
|
11
|
+
import { readGitPolicy, cacheGitPolicy, checkoutRole, installGitGuard, landingVerdict } from "../lib/git-guard.mjs";
|
|
12
|
+
import { checkSeatReview, publishSeatReview } from "../lib/review-gate.mjs";
|
|
12
13
|
|
|
13
14
|
const D = "\x1b[2m", B = "\x1b[1m", G = "\x1b[32m", Y = "\x1b[33m", RED = "\x1b[31m", R = "\x1b[0m";
|
|
14
15
|
const args = process.argv.slice(2);
|
|
@@ -16,6 +17,19 @@ const dry = args.includes("--dry-run");
|
|
|
16
17
|
const repo = process.cwd();
|
|
17
18
|
const project = resolveProject(repo);
|
|
18
19
|
const a = resolveAutonomy(project);
|
|
20
|
+
const hub = resolveHub(project);
|
|
21
|
+
const identity = ownerIdentity();
|
|
22
|
+
const role = checkoutRole(repo);
|
|
23
|
+
const requiresLandingPolicy = role !== "seat" && role !== "integration";
|
|
24
|
+
const policy = await readGitPolicy({ hub, identity, project });
|
|
25
|
+
if (requiresLandingPolicy) {
|
|
26
|
+
if (!dry) { installGitGuard(repo, project); cacheGitPolicy(repo, project, policy); }
|
|
27
|
+
for (const action of ["land", "integrate"]) {
|
|
28
|
+
if (policy.effective[action] !== "click") continue;
|
|
29
|
+
console.error(landingVerdict(policy, { action }).reason);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
19
33
|
|
|
20
34
|
console.log(`${B}integrate${R} · ${project} ${D}commit=${a.commit ? "on" : "off"} push=${a.push ? "on" : "off"} deploy=${a.deploy ? "on" : "off"}${R}`);
|
|
21
35
|
|
|
@@ -42,24 +56,34 @@ for (const w of seats) {
|
|
|
42
56
|
console.log(` ${G}${w.agent}: committed ${r.sha}${R}`);
|
|
43
57
|
}
|
|
44
58
|
|
|
45
|
-
//
|
|
46
|
-
// the collision the overseer exists to surface, not something to resolve silently. A seat under
|
|
47
|
-
// per-hunk review merges only when every hunk is approved at its current tip
|
|
48
|
-
// (docs/CONTRACT-review.md rule 5); otherwise it is skipped with its pending count.
|
|
59
|
+
// Review is tied to the seat tip; a changed tip must be reviewed again before landing.
|
|
49
60
|
const merged = [];
|
|
50
|
-
const hub = resolveHub(project);
|
|
51
|
-
const identity = ownerIdentity();
|
|
52
61
|
for (const w of seats) {
|
|
53
62
|
const { branch, ahead } = seatAhead(w, base);
|
|
54
63
|
if (!ahead) continue;
|
|
55
|
-
const
|
|
64
|
+
const tip = git(w.dir, ["rev-parse", branch]);
|
|
65
|
+
let review = { reviewed: false, merge: true };
|
|
66
|
+
if (requiresLandingPolicy) {
|
|
67
|
+
const required = policy.effective.land === "review" || policy.effective.integrate === "review";
|
|
68
|
+
if (required && !dry) await publishSeatReview({ hub, identity, project, seat: w.agent, dir: w.dir, base, tip });
|
|
69
|
+
review = await checkSeatReview({ hub, identity, project, seat: w.agent, dir: w.dir, base, tip, publish: !dry });
|
|
70
|
+
if (required && !review.reviewed) review = { merge: false, reason: "Mixed mode: review required at the current tip" };
|
|
71
|
+
review = { ...review, tip };
|
|
72
|
+
}
|
|
56
73
|
if (!review.merge) {
|
|
57
74
|
console.log(` ${Y}${w.agent}: skipped, ${review.reason}${R}`);
|
|
58
75
|
continue;
|
|
59
76
|
}
|
|
60
77
|
if (review.reviewed) console.log(` ${D}${w.agent}: ${review.reason}${R}`);
|
|
61
78
|
if (dry) { console.log(` ${D}[dry] would merge ${branch} (${ahead} commit(s))${R}`); merged.push(branch); continue; }
|
|
62
|
-
const
|
|
79
|
+
const current = await readGitPolicy({ hub, identity, project });
|
|
80
|
+
if (requiresLandingPolicy) cacheGitPolicy(repo, project, current);
|
|
81
|
+
const m = mergeSeat(repo, tip, { policy: current, review, action: "integrate" });
|
|
82
|
+
if (m.refused) {
|
|
83
|
+
console.log(` ${Y}${branch}: ${m.detail}${R}`);
|
|
84
|
+
blocked = true;
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
63
87
|
if (m.conflict) {
|
|
64
88
|
console.log(` ${RED}${branch}: CONFLICT — left untouched${R}\n${D}${m.detail}${R}`);
|
|
65
89
|
blocked = true;
|
|
@@ -100,6 +124,11 @@ if (!a.push) {
|
|
|
100
124
|
console.log(`${D}push is off — integrated and verified locally (trantor autonomy set push on)${R}`);
|
|
101
125
|
process.exit(0);
|
|
102
126
|
}
|
|
127
|
+
const shippingPolicy = await readGitPolicy({ hub, identity, project });
|
|
128
|
+
if (shippingPolicy.effective.push !== "autonomy") {
|
|
129
|
+
console.log(`${Y}${shippingPolicy.mode} mode: push from the sidebar${R}`);
|
|
130
|
+
process.exit(1);
|
|
131
|
+
}
|
|
103
132
|
git(repo, ["push"]);
|
|
104
133
|
console.log(`${G}pushed ${base}${R}`);
|
|
105
134
|
if (a.deploy) console.log(`${D}deploy is on, but this project has no deploy step wired here yet${R}`);
|
package/bin/turn-watchdog.mjs
CHANGED
|
@@ -10,6 +10,7 @@ import { hostId } from "../lib/project.mjs";
|
|
|
10
10
|
import { signedPost } from "../hooks/lib/api.mjs";
|
|
11
11
|
import { refreshTurnLiveness } from "../lib/turnstate.mjs";
|
|
12
12
|
import { readHeavyGateWait } from "../lib/heavy-gate-wait.mjs";
|
|
13
|
+
import { createWorktreeStatusReporter } from "../lib/worktree-status.mjs";
|
|
13
14
|
|
|
14
15
|
const [stampFile, errFile, windowMsRaw, session, project, hub, transcriptDir = "", workDir = "", stallFile = "", turnStateFile = "", heavyWaitDir = ""] = process.argv.slice(2);
|
|
15
16
|
// SAFETY: the 10-minute floor lives in crew-runner.mjs (the default when TRANTOR_TURN_WATCHDOG_MS
|
|
@@ -56,6 +57,15 @@ const runnerAlive = () => {
|
|
|
56
57
|
// The runner is blocked in spawnSync for the whole turn, so presence beats from this helper.
|
|
57
58
|
// The stamp check pins every beat to this runner and turn; killing the watchdog clears the timer.
|
|
58
59
|
const presence = armed.presence;
|
|
60
|
+
const worktree = armed.worktree;
|
|
61
|
+
const worktreeStatus = worktree ? createWorktreeStatusReporter({
|
|
62
|
+
...worktree,
|
|
63
|
+
post: async status => {
|
|
64
|
+
const result = await signedPost(`${hub}/worktree-status`, status, { session, timeoutMs: 5000 });
|
|
65
|
+
if (!result.ok || !result.json?.ok) throw new Error(result.json?.error || `hub ${result.status}`);
|
|
66
|
+
},
|
|
67
|
+
}) : null;
|
|
68
|
+
worktreeStatus?.start();
|
|
59
69
|
let presenceBusy = false;
|
|
60
70
|
async function beatPresence() {
|
|
61
71
|
if (!presence || presenceBusy) return;
|
|
@@ -64,10 +74,14 @@ async function beatPresence() {
|
|
|
64
74
|
presenceBusy = true;
|
|
65
75
|
try {
|
|
66
76
|
await signedPost(`${hub}/register`, presence.payload, { session, timeoutMs: 5000 });
|
|
77
|
+
await worktreeStatus?.heartbeat();
|
|
67
78
|
} catch {} finally { presenceBusy = false; }
|
|
68
79
|
}
|
|
69
80
|
const presenceTimer = presence ? setInterval(beatPresence, Math.max(100, Number(presence.intervalMs) || 60000)) : null;
|
|
70
|
-
process.on("exit", () => {
|
|
81
|
+
process.on("exit", () => {
|
|
82
|
+
if (presenceTimer) clearInterval(presenceTimer);
|
|
83
|
+
worktreeStatus?.stop();
|
|
84
|
+
});
|
|
71
85
|
|
|
72
86
|
// One observation of every liveness channel: stderr growth, transcript mtime, worktree mtime.
|
|
73
87
|
const ago = (t) => (t > 0 ? `${Math.max(1, Math.round((Date.now() - t) / 60000))}m ago` : "never");
|
package/bin/wake-nudge.mjs
CHANGED
|
@@ -249,11 +249,14 @@ export async function runDuty(args) {
|
|
|
249
249
|
const wakeArgs = [cmd, "--hub", fleetHub(args)];
|
|
250
250
|
const supported = ["up", "down", "status"].includes(cmd) && process.platform === "darwin";
|
|
251
251
|
const wakeCode = supported && cmd === "down" ? await execute("wake-nudge.mjs", wakeArgs) : 0;
|
|
252
|
+
const balancesStopCode = supported && cmd === "down" ? await execute("balances-agent.mjs", [cmd]) : 0;
|
|
252
253
|
const dutyCode = await execute("duty.mjs", args);
|
|
253
254
|
if (supported && (cmd === "status" || (cmd === "up" && dutyCode === 0))) {
|
|
254
|
-
|
|
255
|
+
const wakeServiceCode = await execute("wake-nudge.mjs", wakeArgs);
|
|
256
|
+
const balancesServiceCode = await execute("balances-agent.mjs", [cmd]);
|
|
257
|
+
return wakeServiceCode || balancesServiceCode || dutyCode;
|
|
255
258
|
}
|
|
256
|
-
return dutyCode || wakeCode;
|
|
259
|
+
return dutyCode || wakeCode || balancesStopCode;
|
|
257
260
|
}
|
|
258
261
|
|
|
259
262
|
const xml = value => String(value).replace(/[&<>"']/g, c => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
package/deploy/restart-hub.sh
CHANGED
package/docs/FEATURES.md
CHANGED
|
@@ -11,7 +11,8 @@ Rules for this file:
|
|
|
11
11
|
- One row per feature. The `id` column is the probe's name in `lib/canary/probes.mjs`; a row whose
|
|
12
12
|
id has no probe fails the canary, so the table and the code cannot drift apart.
|
|
13
13
|
- A probe only reads: files, `git log`, `herdr agent list` / `herdr pane read`, the hub's public
|
|
14
|
-
`/health`,
|
|
14
|
+
`/health`, `trantor capacity --version 1 --json` (one signed GET of the planning view), the npm
|
|
15
|
+
registry, GitHub releases and the app's read socket. It never writes, sends,
|
|
15
16
|
clicks, navigates, stages or commits.
|
|
16
17
|
- A probe says `skip` when the thing it reads is not on this machine (no app running, no idle
|
|
17
18
|
Claude pane, not macOS). A skip is never posted, and it neither opens nor closes an episode.
|
|
@@ -43,3 +44,5 @@ Rules for this file:
|
|
|
43
44
|
| `workspace-layouts` | The Workspace layouts render | the running app's read socket returns the main window's text, non-empty and without an error screen | #14618 | `desktop/src/v2/shell/`, `desktop/src/v2/screens/Workspace/` | `workspace-layouts` | mac | yes |
|
|
44
45
|
| `file-actions-no-commit` | File actions in the operator's own checkout don't commit | each known project's main checkout HEAD reflog for the last 7 days has no `create … in the app` / `delete … in the app` / `rename … in the app` commit | #14639 | `desktop/src-tauri/src/file_ops.rs` | `file-actions-no-commit` | mac | yes |
|
|
45
46
|
| `launchers` | Every com.trantor.* launcher's program path exists | each `~/Library/LaunchAgents/com.trantor.*.plist`'s pinned paths exist and none is a versioned Homebrew Cellar path | #14646 | `lib/launchd.mjs`, `lib/launch-node.mjs` | `launchers` | mac | yes |
|
|
47
|
+
| `dispatcher-runbook` | The dispatcher runbook names only commands and routes this tree serves (runbook: `docs/RUNBOOK-dispatcher.md`; drill: D15 in `test/dispatcher/test-rollout.mjs`) | every `trantor <cmd>` in `docs/RUNBOOK-dispatcher.md` is a subcommand in `bin/cli.mjs`, every `/dispatcher/…` route it names is in `hub/routes/dispatcher-operations.mjs` or `hub/routes/dispatcher.mjs`, and every `bin/*.mjs` it names exists; skips where the runbook is not shipped | #14682 | `docs/RUNBOOK-dispatcher.md`, `bin/cli.mjs`, `hub/routes/dispatcher-operations.mjs`, `hub/routes/dispatcher.mjs` | `dispatcher-runbook` | any | yes |
|
|
48
|
+
| `dispatcher-fail-closed` | The planner's capacity view fails closed (runbook: `docs/RUNBOOK-dispatcher.md` "What failing closed looks like"; drill: D16 in `test/dispatcher/test-feature-wiring.mjs`) | `trantor capacity --version 1 --json` answers a planning view with a snapshot id and policy version, or a hub refusal with its code, or local-only with a named cause and no dispatch token | #14678 | `bin/capacity.mjs`, `lib/dispatcher/preflight.mjs`, `lib/dispatcher/snapshot.mjs` | `dispatcher-fail-closed` | any | yes |
|
package/hooks/sessionstart.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// trantor SessionStart hook — every session registers with the hub and gets a roster of OTHER live
|
|
3
3
|
// sessions injected, so independent sessions discover each other. Config: env RELAY_URL →
|
|
4
4
|
// ~/.agent-bus/config.json → http://127.0.0.1:4477. Identity: RELAY_SESSION → "<hostname>:<basename(cwd)>".
|
|
5
|
-
import { readFileSync, existsSync } from "node:fs";
|
|
5
|
+
import { readFileSync, existsSync, appendFileSync } from "node:fs";
|
|
6
6
|
import { join, basename, dirname } from "node:path";
|
|
7
7
|
import { homedir, hostname } from "node:os";
|
|
8
8
|
import { execSync, spawn } from "node:child_process";
|
|
@@ -167,6 +167,11 @@ try {
|
|
|
167
167
|
sessionTitle = project; // baseline — enriched with the current work item after the catch-up fetch below
|
|
168
168
|
const session = process.env.RELAY_SESSION
|
|
169
169
|
|| (process.env.RELAY_AGENT ? `${process.env.RELAY_AGENT}:${project}` : `${hostId()}:${project}`);
|
|
170
|
+
// #14750: hook subprocess env cannot reach Bash; Claude sources this file for later tools.
|
|
171
|
+
if (project && process.env.TRANTOR_ORCH === project && process.env.CLAUDE_ENV_FILE) {
|
|
172
|
+
const quotedSession = "'" + session.replaceAll("'", "'\\''") + "'";
|
|
173
|
+
appendFileSync(process.env.CLAUDE_ENV_FILE, `\nexport TRANTOR_AGENT_IDENTITY=${quotedSession}\n`);
|
|
174
|
+
}
|
|
170
175
|
// relayUrl() with no project resolves from the hook process's cwd, which is not always the
|
|
171
176
|
// project the session is about. Pass it, or every call below can address the wrong hub.
|
|
172
177
|
// resolveHubInfo carries HOW the hub was chosen so an unpinned project can be flagged below
|
package/hub/auth.mjs
CHANGED
|
@@ -141,6 +141,11 @@ const canRead = (auth, project) => AUTH_MODE !== "enforce" && !auth?.identity
|
|
|
141
141
|
? true
|
|
142
142
|
: isDutyIdentity(auth) || scopeAllows(auth?.identity, project, "read");
|
|
143
143
|
function projectFromRequest(P, q, b, method) {
|
|
144
|
+
const gitPolicyPath = /^\/projects\/([^/]+)\/git-policy$/.exec(P);
|
|
145
|
+
if (gitPolicyPath) {
|
|
146
|
+
try { return canon(decodeURIComponent(gitPolicyPath[1])); }
|
|
147
|
+
catch { return ""; }
|
|
148
|
+
}
|
|
144
149
|
if (P === "/task/update" || P === "/card") {
|
|
145
150
|
const t = state.tasks.find(x => x.id === Number(b?.id ?? q?.id));
|
|
146
151
|
return t?.project || "";
|
package/hub/routes/admin.mjs
CHANGED
|
@@ -68,6 +68,13 @@ 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')) {
|
|
72
|
+
const identity = b.accountIdentity;
|
|
73
|
+
const provider = typeof identity?.provider === "string" && /^[a-z0-9-]{1,60}$/.test(identity.provider) ? identity.provider : 'unknown';
|
|
74
|
+
const subject = typeof identity?.subject === "string" && /^s-[a-f0-9]{32}$/.test(identity.subject) ? identity.subject : null;
|
|
75
|
+
pr.accountIdentity = { provider, subject, reason: subject ? null : `subject_unavailable:${provider}` };
|
|
76
|
+
markDirty();
|
|
77
|
+
}
|
|
71
78
|
// #7749: the runner's live turn phase (working/idle/cut/stalled/parked) + its start ride the
|
|
72
79
|
// presence row, so /peers answers "what is the seat doing now" without inferring it from durations.
|
|
73
80
|
if (pr && b.phase) { pr.phase = String(b.phase).slice(0, 20); pr.phaseSince = Number(b.phaseSince) || now(); }
|
|
@@ -445,7 +452,8 @@ export async function routeAdmin({ req, res, q, P, auth, ctx }) {
|
|
|
445
452
|
const entries = (snap?.entries || []).filter(e => detectedCli.has(e.provider) || profByCanon[canonP(e.provider)]).map(e => {
|
|
446
453
|
const pv = profByCanon[canonP(e.provider)];
|
|
447
454
|
if (!e.ok && isSub(pv?.tier)) return { provider: e.provider, label: e.label, kind: "subscription", plan: pv.plan, ok: true, remaining: null, low: false };
|
|
448
|
-
|
|
455
|
+
const { subject: _subject, billingSubject: _billingSubject, ...entry } = e;
|
|
456
|
+
return { ...entry, low: lowOf(e) };
|
|
449
457
|
});
|
|
450
458
|
// List configured non-CLI subscriptions not already fetched. Claude/Codex may only come from
|
|
451
459
|
// live registry detection above; a stale profile declaration cannot manufacture either row.
|