trantor 0.18.146 → 0.18.149
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 +23 -7
- package/bin/capacity.mjs +18 -2
- package/bin/cli.mjs +6 -2
- package/bin/connect.mjs +10 -3
- package/bin/crew/state.mjs +1 -1
- package/bin/crew-runner.mjs +29 -4
- package/bin/dispatch.mjs +78 -0
- package/bin/docker-seat.mjs +33 -0
- package/bin/heavy-gate-shim/docker +2 -0
- package/bin/integrate.mjs +14 -2
- package/bin/migrate-dispatcher.mjs +50 -0
- package/bin/review.mjs +35 -0
- package/hooks/sessionstart.mjs +4 -1
- package/hub/auth.mjs +3 -3
- package/hub/routes/capacity.mjs +30 -23
- package/hub/routes/cards.mjs +13 -1
- package/hub/routes/dispatcher-operations.mjs +122 -0
- package/hub/routes/dispatcher.mjs +106 -0
- package/hub/routes/insights.mjs +68 -4
- package/hub/routes/worktree-status.mjs +56 -0
- package/hub/store.mjs +20 -0
- package/hub.mjs +17 -1
- package/kimi.plugin.json +1 -1
- package/lib/capacity.mjs +94 -16
- package/lib/dispatcher/acceptance.mjs +314 -0
- package/lib/dispatcher/accounts.mjs +442 -0
- package/lib/dispatcher/admission.mjs +731 -0
- package/lib/dispatcher/breakers.mjs +70 -0
- package/lib/dispatcher/executor.mjs +486 -0
- package/lib/dispatcher/forecast.mjs +391 -0
- package/lib/dispatcher/harness/boundary-linux.mjs +246 -0
- package/lib/dispatcher/harness/boundary-macos.mjs +237 -0
- package/lib/dispatcher/harness/contract.mjs +198 -0
- package/lib/dispatcher/harness/crew.mjs +463 -0
- package/lib/dispatcher/harness/publication.mjs +188 -0
- package/lib/dispatcher/migrate-attempts.mjs +51 -0
- package/lib/dispatcher/operations.mjs +401 -0
- package/lib/dispatcher/planner.mjs +516 -0
- package/lib/dispatcher/policy.mjs +9 -0
- package/lib/dispatcher/preflight.mjs +249 -0
- package/lib/dispatcher/resources.mjs +44 -0
- package/lib/dispatcher/schemas.mjs +3 -1
- package/lib/dispatcher/snapshot.mjs +72 -1
- package/lib/dispatcher/spend.mjs +319 -0
- package/lib/dispatcher/store.mjs +207 -2
- package/lib/dispatcher/verifier.mjs +246 -0
- package/lib/docker-janitor.mjs +24 -14
- package/lib/fitness.mjs +227 -41
- package/lib/review-gate.mjs +63 -0
- package/lib/store-contract.mjs +57 -0
- package/lib/store-pg.mjs +38 -3
- package/lib/telemetry-ship.mjs +8 -7
- package/lib/worktree-status.mjs +216 -0
- package/mcp.mjs +53 -7
- package/package.json +1 -1
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
},
|
|
7
7
|
"metadata": {
|
|
8
8
|
"description": "Trantor — the hub-world for AI agent crews: live message bus, presence, project Kanban/flow board + context-handoff for independent AI coding agents (Claude, Codex, Gemini, …)",
|
|
9
|
-
"version": "0.18.
|
|
9
|
+
"version": "0.18.149"
|
|
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.149",
|
|
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.149",
|
|
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,19 +241,35 @@ export function advise(input, world = loadWorld()) {
|
|
|
241
241
|
return recommendation;
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
-
//
|
|
245
|
-
//
|
|
246
|
-
|
|
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.
|
|
246
|
+
async function hubAdvice(input, argv) {
|
|
247
|
+
const { signedPost, sessionContext } = await import("../hooks/lib/api.mjs");
|
|
248
|
+
const { buildAdviceRequest, requestAdvice, renderAdvice } = await import("../lib/dispatcher/preflight.mjs");
|
|
249
|
+
const flag = (name) => { const i = argv.indexOf(name); return i > -1 ? argv[i + 1] : undefined; };
|
|
250
|
+
const project = input.project || sessionContext().project;
|
|
251
|
+
const request = await buildAdviceRequest({ project, cards: input.cards || [], drafts: input.drafts || [],
|
|
252
|
+
snapshotId: flag("--snapshot") || input.snapshotId, policyVersion: flag("--policy") || input.policyVersion });
|
|
253
|
+
const result = await requestAdvice({ post: (path, body) => signedPost(path, body, { project, timeoutMs: 10000 }), busDir: busDir(), request });
|
|
254
|
+
console.log(argv.includes("--json") ? JSON.stringify(result, null, 2) : renderAdvice(result));
|
|
255
|
+
return result.source === "refused" ? 1 : 0;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// ---- CLI ---- is-main guard via an ENCODED file URL: a hand-built `file://${argv[1]}` no-ops when the
|
|
259
|
+
// install path holds a URL-reserved char (a SPACE in ".../Application Support/..."). See profile.mjs.
|
|
247
260
|
if (import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
248
261
|
let input;
|
|
249
|
-
|
|
262
|
+
const argv = process.argv.slice(2);
|
|
263
|
+
if (!argv.includes("--demo")) {
|
|
264
|
+
const stdin = process.stdin.isTTY ? "" : readFileSync(0, "utf8").trim();
|
|
265
|
+
input = stdin ? JSON.parse(stdin) : { packages: [] };
|
|
266
|
+
if (input.cards || input.drafts || argv.includes("--snapshot") || argv.includes("--policy")) process.exit(await hubAdvice(input, argv));
|
|
267
|
+
}
|
|
268
|
+
if (argv.includes("--demo")) {
|
|
250
269
|
input = { task: "neon asteroids game", packages: [
|
|
251
270
|
{ title: "engine+integration", difficulty: "hard" }, { title: "render/bloom", difficulty: "hard" },
|
|
252
271
|
{ title: "combat+ui", difficulty: "medium" }, { title: "audio", difficulty: "medium" },
|
|
253
272
|
{ title: "readme+badges", difficulty: "easy" } ] };
|
|
254
|
-
} else {
|
|
255
|
-
const stdin = readFileSync(0, "utf8").trim();
|
|
256
|
-
input = stdin ? JSON.parse(stdin) : { packages: [] };
|
|
257
273
|
}
|
|
258
274
|
const world = loadWorld();
|
|
259
275
|
// #7762: fold this project's seat record into the routing (fail-open — no hub, no record,
|
package/bin/capacity.mjs
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// Degraded by design: when the hub is unreachable the CLI falls back to the LOCAL provider
|
|
7
7
|
// balances (same sources `trantor balances` reads) and says it is local-only — machines, seats and
|
|
8
8
|
// burn rate print unknown, never a guess.
|
|
9
|
-
// Usage: trantor capacity [--json]
|
|
9
|
+
// Usage: trantor capacity [--json] [--version 1 [--snapshot <id>]]
|
|
10
10
|
import { signedGet, sessionContext, relayUrl } from "../hooks/lib/api.mjs";
|
|
11
11
|
import { fetchBalances, fmtBalance } from "../lib/balances.mjs";
|
|
12
12
|
import { loadProfile } from "./profile.mjs";
|
|
@@ -19,6 +19,22 @@ const asJson = args.includes("--json");
|
|
|
19
19
|
const { project } = sessionContext();
|
|
20
20
|
const hub = relayUrl(project);
|
|
21
21
|
|
|
22
|
+
// #14678: --version 1 is the planner's envelope; an unreachable hub gives the cached one, localOnly, no token.
|
|
23
|
+
const versionAt = args.indexOf("--version");
|
|
24
|
+
if (versionAt > -1 && args[versionAt + 1] === "1") {
|
|
25
|
+
const { readCapacity } = await import("../lib/dispatcher/preflight.mjs");
|
|
26
|
+
const { busDir } = await import("../lib/project.mjs");
|
|
27
|
+
const snapshotAt = args.indexOf("--snapshot");
|
|
28
|
+
const envelope = await readCapacity({ get: (path) => signedGet(path, { timeoutMs: 5000, project }), busDir: busDir(), project,
|
|
29
|
+
snapshotId: snapshotAt > -1 ? args[snapshotAt + 1] : null });
|
|
30
|
+
if (asJson) console.log(JSON.stringify(envelope, null, 2));
|
|
31
|
+
else if (envelope.refused) console.log(`hub refused the planning view: ${envelope.code}`);
|
|
32
|
+
else if (envelope.localOnly) console.log(`hub unreachable (${envelope.reason}) — LOCAL ONLY: ${envelope.envelope ? `cached planning view ${Math.round(envelope.sourceAgeMs / 1000)}s old` : "no cached planning view"}; no dispatch token.`);
|
|
33
|
+
else if (!envelope.versioned) console.log("this hub has no planning view yet (it answered with the display ledger); run trantor capacity for that view");
|
|
34
|
+
else console.log(`planning snapshot ${envelope.snapshotId} · policy ${envelope.policyVersion ?? "unknown"}${envelope.degraded?.length ? ` · degraded: ${envelope.degraded.join(", ")}` : ""}`);
|
|
35
|
+
process.exit(envelope.refused ? 1 : 0);
|
|
36
|
+
}
|
|
37
|
+
|
|
22
38
|
const response = await signedGet(`/capacity?project=${encodeURIComponent(project)}`, { timeoutMs: 5000, project });
|
|
23
39
|
|
|
24
40
|
if (!response.ok && response.status !== 0) {
|
|
@@ -36,7 +52,7 @@ if (!response.ok) {
|
|
|
36
52
|
const balances = [...detected, ...profileScoped];
|
|
37
53
|
const reason = response.reason || "unreachable";
|
|
38
54
|
if (asJson) {
|
|
39
|
-
console.log(JSON.stringify({ degraded: "local-only", reason, hub, balances, budgets: null, burn: null, machines: null, seats: null }, null, 2));
|
|
55
|
+
console.log(JSON.stringify({ degraded: "local-only", localOnly: true, reason, hub, balances, budgets: null, burn: null, machines: null, seats: null }, null, 2));
|
|
40
56
|
} else {
|
|
41
57
|
console.log(`hub unreachable (${reason}) — LOCAL BALANCES ONLY; machines, seats and burn rate unknown.`);
|
|
42
58
|
console.log(`hub: ${hub}\n`);
|
package/bin/cli.mjs
CHANGED
|
@@ -30,6 +30,7 @@ switch (cmd) {
|
|
|
30
30
|
case "models": run("bin/models.mjs"); break;
|
|
31
31
|
case "memory": run("bin/memory.mjs"); break;
|
|
32
32
|
case "advise": run("bin/advise.mjs"); break;
|
|
33
|
+
case "dispatch": run("bin/dispatch.mjs"); break;
|
|
33
34
|
case "verify": run("bin/crew-verify.mjs"); break;
|
|
34
35
|
case "up": runCrew(); break;
|
|
35
36
|
case "open": runCrew(); break;
|
|
@@ -38,6 +39,7 @@ switch (cmd) {
|
|
|
38
39
|
case "agent-settings": run("bin/agent-settings.mjs"); break;
|
|
39
40
|
case "adopt": spawn(process.execPath, [join(ROOT, "bin/adopt.mjs"), ...args], { stdio: "inherit", cwd: process.cwd() }).on("exit", c => process.exit(c ?? 0)); break;
|
|
40
41
|
case "integrate": spawn(process.execPath, [join(ROOT, "bin/integrate.mjs"), ...args], { stdio: "inherit", cwd: process.cwd() }).on("exit", c => process.exit(c ?? 0)); break;
|
|
42
|
+
case "review": spawn(process.execPath, [join(ROOT, "bin/review.mjs"), ...args], { stdio: "inherit", cwd: process.cwd() }).on("exit", c => process.exit(c ?? 0)); break;
|
|
41
43
|
case "attribution": run("bin/attribution.mjs"); break;
|
|
42
44
|
case "harvest": run("bin/harvest.mjs"); break;
|
|
43
45
|
case "sync": run("bin/sync.mjs"); break;
|
|
@@ -297,6 +299,7 @@ switch (cmd) {
|
|
|
297
299
|
trantor adopt take over a session already running in a Terminal, then open it here
|
|
298
300
|
trantor takeover the whole move in one command: idle-gate the Terminal session, end it gracefully, adopt, open in the pane — [--force] [--session <id>] [--dry-run]
|
|
299
301
|
trantor integrate collect the crew's work, merge it, verify it, push it (--dry-run to rehearse)
|
|
302
|
+
trantor review publish publish each seat's diff to the hub for per-hunk review (Mixed mode)
|
|
300
303
|
trantor harvest receipt for a seat commit you landed on main by hand: harvest <seat-sha> <main-sha> [--card N]
|
|
301
304
|
trantor sync realign a seat branch with main from the receipts: sync [<seat>] [--dry-run] — refuses and names unharvested commits
|
|
302
305
|
trantor down tear the crew down (kills processes, closes windows, no dialogs)
|
|
@@ -314,10 +317,11 @@ switch (cmd) {
|
|
|
314
317
|
trantor new project genesis: new <name> [--from <git-url>] [--brief <file>] [--dir <parent>] [--adopt] [--json] — creates <parent>/<name>, git main, docs/PRD.md + small CLAUDE.md, hooks, hub brief + first card (never spawns a session)
|
|
315
318
|
trantor genesis-kickoff internal wake prompt selector from the checkout + signed project board
|
|
316
319
|
trantor balances how much credit is left on each CONFIGURED provider (from your profile) — refill before you stall — [--json]
|
|
317
|
-
trantor capacity the live ledger: budgets and resets, burn rate, machines, seats — [--json]
|
|
320
|
+
trantor capacity the live ledger: budgets and resets, burn rate, machines, seats — [--json] [--version 1 [--snapshot <id>]]
|
|
318
321
|
trantor recost recompute sub-agent notional cost from on-disk transcripts + reseed the board (repair after upgrade) — [--dry-run]
|
|
319
322
|
trantor handoff finish this session NOW: write a handoff, open a fresh session that takes over, and close this one (manual baton)
|
|
320
|
-
trantor advise ask the Advisor directly (JSON on stdin; --demo to see it)
|
|
323
|
+
trantor advise ask the Advisor directly (JSON on stdin; --demo to see it); {"cards":[...]} asks the hub planner — [--json] [--snapshot <id>] [--policy <v>]
|
|
324
|
+
trantor dispatch admit planned cards through the hub: --decision <id> [--card <n>] · status <attemptId> · preflight — [--json]
|
|
321
325
|
trantor project this checkout's identity: project [<id>] — records .trantor/project.json so a directory rename cannot orphan the board, pin and sessions
|
|
322
326
|
project permissions <name> [ask|bypass] — whether <name>'s agents ask before acting or act without asking; no value prints it
|
|
323
327
|
trantor hub run the hub in the foreground (setup installs it as a service instead)
|
package/bin/connect.mjs
CHANGED
|
@@ -9,6 +9,7 @@ import { execSync } from "node:child_process";
|
|
|
9
9
|
import { fileURLToPath } from "node:url";
|
|
10
10
|
import { parseJsonc } from "../lib/jsonc.mjs";
|
|
11
11
|
import { resolveProjectInfo, resolveHubInfo, gitRoot, writeProjectId, PROJECT_MARKER } from "../lib/project.mjs";
|
|
12
|
+
import { BRIEF_MARKER, upsertBriefBlock } from "../lib/dispatcher/preflight.mjs";
|
|
12
13
|
|
|
13
14
|
const DRY = process.argv.includes("--dry-run");
|
|
14
15
|
const MCP = join(dirname(dirname(fileURLToPath(import.meta.url))), "mcp.mjs");
|
|
@@ -19,9 +20,7 @@ const MCP = join(dirname(dirname(fileURLToPath(import.meta.url))), "mcp.mjs");
|
|
|
19
20
|
const PROJECT_INFO = resolveProjectInfo(process.cwd());
|
|
20
21
|
const PROJECT_AT_CONNECT = PROJECT_INFO.project;
|
|
21
22
|
const URL_ = resolveHubInfo(PROJECT_AT_CONNECT).url;
|
|
22
|
-
// #14536: graft is no longer an agent MCP server
|
|
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.
|
|
23
|
+
// #14536: graft is no longer an agent MCP server; connect removes the entries older versions wrote.
|
|
25
24
|
// The [mcp_servers.graft] table up to the next table, and the comment line connect wrote for it,
|
|
26
25
|
// which a later relay env refresh can leave separated from the table.
|
|
27
26
|
function removeCodexGraft(toml) {
|
|
@@ -107,6 +106,14 @@ if (has("codex")) {
|
|
|
107
106
|
}
|
|
108
107
|
report("codex", note, p);
|
|
109
108
|
}
|
|
109
|
+
// #14678: Codex has no session hook, so the shared orchestrator brief goes in its global instructions file.
|
|
110
|
+
const agentsMd = join(homedir(), ".codex", "AGENTS.md");
|
|
111
|
+
const curMd = existsSync(agentsMd) ? readFileSync(agentsMd, "utf8") : "";
|
|
112
|
+
const nextMd = upsertBriefBlock(curMd);
|
|
113
|
+
if (nextMd !== curMd) {
|
|
114
|
+
if (!DRY) { if (existsSync(agentsMd)) backup(agentsMd); else mkdirSync(dirname(agentsMd), { recursive: true }); writeFileSync(agentsMd, nextMd); }
|
|
115
|
+
report("codex", curMd.includes(BRIEF_MARKER) ? "orchestrator brief refreshed" : "orchestrator brief written", agentsMd);
|
|
116
|
+
}
|
|
110
117
|
const g = existsSync(p) ? readFileSync(p, "utf8") : "";
|
|
111
118
|
const ungrafted = removeCodexGraft(g);
|
|
112
119
|
if (ungrafted !== g) {
|
package/bin/crew/state.mjs
CHANGED
|
@@ -53,7 +53,7 @@ export function dropState(ctx, project, kind, agent = "", handle = "") {
|
|
|
53
53
|
// never rm, never volumes; docker absent skips silently. Same kill-switch as the process kill.
|
|
54
54
|
async function stopSeatContainers(ctx, project, agent) {
|
|
55
55
|
if (ctx.dry || ctx.env?.CREW_NO_PROC_KILL === "1" || !project || !agent) return;
|
|
56
|
-
const r = dockerSweep({ path: dockerStatePathFor(agent, project) });
|
|
56
|
+
const r = dockerSweep({ path: dockerStatePathFor(agent, project), owner: `${agent}:${project}` });
|
|
57
57
|
if (r.skipped || !r.stopped.length) return;
|
|
58
58
|
console.log(` 🧹 ${agent}:${project} — stopped ${r.stopped.length} container(s): ${r.stopped.join(", ")}`);
|
|
59
59
|
try {
|
package/bin/crew-runner.mjs
CHANGED
|
@@ -59,6 +59,7 @@ import {
|
|
|
59
59
|
} from "../lib/state/driver.mjs";
|
|
60
60
|
import { costLine } from "../lib/state/cost.mjs";
|
|
61
61
|
import { resolveStateFlags, stateFeatureOn } from "../lib/state/flags.mjs";
|
|
62
|
+
import { createWorktreeStatusReporter } from "../lib/worktree-status.mjs";
|
|
62
63
|
|
|
63
64
|
import { awaitSwapRelease } from "./crew/stage.mjs";
|
|
64
65
|
import { codexRelayFlags } from "./crew/codex-relay.mjs";
|
|
@@ -132,6 +133,8 @@ function seatWorktree(sourceDir) {
|
|
|
132
133
|
}
|
|
133
134
|
|
|
134
135
|
const TURN_DIR = seatWorktree(DIR);
|
|
136
|
+
const TEST_SANDBOX = /(?:^|\/)test-home-[^/]+(?:\/|$)/.test(DIR);
|
|
137
|
+
const TEST_HUB_DEAD_AFTER_MS = Math.max(100, Number(process.env.TRANTOR_TEST_HUB_DEAD_AFTER_MS) || 120000);
|
|
135
138
|
|
|
136
139
|
// #13921: an explicit contract base wins; without one, fetch the current origin/main instead of
|
|
137
140
|
// trusting a cached local ref from when this seat worktree was created.
|
|
@@ -411,9 +414,10 @@ const PARKF = join(homedir(), ".agent-bus", `park-${PERSONA}-${PROJ}.json`);
|
|
|
411
414
|
// #9778: the seat's recorded containers, persisted per seat so a card close, a park or
|
|
412
415
|
// `trantor down <seat>` can stop what the seat started even after this runner is gone.
|
|
413
416
|
const DOCKERF = dockerStatePathFor(PERSONA, PROJ);
|
|
417
|
+
const DOCKER_SEAT = `${PERSONA}:${PROJ}`;
|
|
414
418
|
// One bus line per sweep, naming what was stopped; docker absent sweeps stay silent by contract.
|
|
415
419
|
async function janitorStop(why, card) {
|
|
416
|
-
const r = dockerSweep({ path: DOCKERF, card });
|
|
420
|
+
const r = dockerSweep({ path: DOCKERF, card, owner: DOCKER_SEAT });
|
|
417
421
|
if (r.skipped || !r.stopped.length) return;
|
|
418
422
|
const text = `🧹 ${SESSION} stopped ${r.stopped.length} container(s) (${why}): ${r.stopped.join(", ")}${r.failed.length ? ` · could not stop: ${r.failed.join(", ")}` : ""}`;
|
|
419
423
|
log(text);
|
|
@@ -674,8 +678,8 @@ async function balanceRows() {
|
|
|
674
678
|
// ---- activity truth (#5965): the RUNNER is the source for this seat ----------------
|
|
675
679
|
// The runner reports `working · <trigger>` at start and `idle` on a clean landing, bounded to 5s.
|
|
676
680
|
// #7749: the live phase + its start ride the same call, so /peers answers what the seat does NOW.
|
|
677
|
-
// The detached watchdog repeats the working payload
|
|
678
|
-
const PRESENCE_MS = Math.max(100, Number(process.env.RUNNER_PRESENCE_MS) ||
|
|
681
|
+
// The detached watchdog repeats the working payload every 30s: runTurn blocks this event loop.
|
|
682
|
+
const PRESENCE_MS = Math.max(100, Number(process.env.RUNNER_PRESENCE_MS) || 30_000);
|
|
679
683
|
async function registerStatus(status, extra = {}) {
|
|
680
684
|
if (extra.phase === "working") {
|
|
681
685
|
lastTurnStartedAt = Number(extra.phaseSince) || Date.now();
|
|
@@ -1118,6 +1122,7 @@ exit $turn_exit`;
|
|
|
1118
1122
|
// so a handoff spawn would only leak an unmanaged interactive window.
|
|
1119
1123
|
TRANTOR_NO_HANDOFF_SPAWN: "1", TRANTOR_NO_BATON_SPAWN: "1",
|
|
1120
1124
|
TRANTOR_HEAVY_GATE_WAIT_DIR: HEAVY_WAIT_DIR,
|
|
1125
|
+
TRANTOR_DOCKER_SEAT: `${PERSONA}:${PROJ}`,
|
|
1121
1126
|
// Spelled out here, not HEAVY_SHIM_DIR: the turn drills run this function alone, without the module's constants (#14048).
|
|
1122
1127
|
PATH: `${join(import.meta.dirname, "heavy-gate-shim")}:${process.env.PATH || ""}`,
|
|
1123
1128
|
// #6206: the seat's transcript dir — a real CLI ignores it, a drill's fake CLI writes
|
|
@@ -1247,7 +1252,7 @@ exit $turn_exit`;
|
|
|
1247
1252
|
const busActive = await busActivitySince(busSeqBefore);
|
|
1248
1253
|
// #9778: containers this turn created are recorded against its card — and land on the telemetry
|
|
1249
1254
|
// row, which is the ledger the seat record (#7762) is derived from.
|
|
1250
|
-
const dockerNew = newContainers(dockerBefore, listContainers());
|
|
1255
|
+
const dockerNew = newContainers(dockerBefore, listContainers(), `${PERSONA}:${PROJ}`);
|
|
1251
1256
|
if (dockerNew.length) {
|
|
1252
1257
|
recordContainers({ path: DOCKERF, card: sessionCard || 0, containers: dockerNew });
|
|
1253
1258
|
log(`turn started ${dockerNew.length} container(s) — recorded against #${sessionCard || 0}: ${dockerNew.map(c => c.name || c.id).join(", ")}`);
|
|
@@ -1696,6 +1701,16 @@ async function resolveWakeCard(messages, { session }) {
|
|
|
1696
1701
|
askReleased = releaseState?.askReleased || false;
|
|
1697
1702
|
if (pendingWake.length) log(`\x1b[33m${pendingWake.length} message(s) survived from a previous run — redelivering\x1b[0m`);
|
|
1698
1703
|
|
|
1704
|
+
const worktreeStatus = createWorktreeStatusReporter({
|
|
1705
|
+
cwd: TURN_DIR, seat: PERSONA, project: PROJ, machine: MACHINE_LABEL || hostId(),
|
|
1706
|
+
post: async status => {
|
|
1707
|
+
const result = await api("/worktree-status", status);
|
|
1708
|
+
if (!result?.ok) throw new Error(result?.error || "hub rejected snapshot");
|
|
1709
|
+
},
|
|
1710
|
+
log,
|
|
1711
|
+
});
|
|
1712
|
+
worktreeStatus.start();
|
|
1713
|
+
|
|
1699
1714
|
// #7060: the turn the boot line was read as a promise about. It is a transcript turn by
|
|
1700
1715
|
// construction and now says so, in the same breath as the line that armed the mode.
|
|
1701
1716
|
if (!releaseState) {
|
|
@@ -1797,6 +1812,7 @@ async function resolveWakeCard(messages, { session }) {
|
|
|
1797
1812
|
log(`machine health heartbeat armed as ${MACHINE_LABEL} every ${Math.round(HEALTH_BEAT_MS / 1000)}s`);
|
|
1798
1813
|
}
|
|
1799
1814
|
|
|
1815
|
+
let hubUnreachableSince = 0;
|
|
1800
1816
|
while (true) {
|
|
1801
1817
|
restartForRelease();
|
|
1802
1818
|
// pulse first: a due mission beat runs even on a silent bus. Measured from the END of the
|
|
@@ -1838,9 +1854,18 @@ async function resolveWakeCard(messages, { session }) {
|
|
|
1838
1854
|
// response (stalled event loop, napped machine, dead socket). Reconnect immediately and say
|
|
1839
1855
|
// so calmly; reserve the scary "hub unreachable" + 5s backoff for real connection failures.
|
|
1840
1856
|
const expired = e && (e.name === "TimeoutError" || /abort/i.test(String(e.message)));
|
|
1857
|
+
if (TEST_SANDBOX) {
|
|
1858
|
+
hubUnreachableSince ||= Date.now();
|
|
1859
|
+
if (Date.now() - hubUnreachableSince >= TEST_HUB_DEAD_AFTER_MS) {
|
|
1860
|
+
log(`test hub unreachable for ${Math.round((Date.now() - hubUnreachableSince) / 1000)}s — exiting`);
|
|
1861
|
+
process.exit(0);
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1841
1864
|
log(expired ? `long-poll hold expired with no hub response — reconnecting` : `hub unreachable (${e.message}) — retrying in 5s`);
|
|
1842
1865
|
await new Promise(s => setTimeout(s, expired ? 250 : 5000)); continue;
|
|
1843
1866
|
}
|
|
1867
|
+
hubUnreachableSince = 0;
|
|
1868
|
+
await worktreeStatus.heartbeat();
|
|
1844
1869
|
if (!msgs.length) continue; // heartbeat tick, nothing for us
|
|
1845
1870
|
// never wake on your own broadcasts: a claude seat's report contains "claude:" and matched the
|
|
1846
1871
|
// @mention filter, buying one echo turn per report (seen live on the first pulsed orchestrator)
|
package/bin/dispatch.mjs
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// #14678: trantor dispatch admits planned cards through the hub (POST /dispatch); the hub admits or refuses.
|
|
3
|
+
// --decision <id> [--card <n>]... [--json] · --json < {decisionId,card,cardRevision,expectedPolicyVersion}
|
|
4
|
+
// status <attemptId> [--json] · preflight [--json] [--snapshot <id>] with optional {"cards":[...]} on stdin
|
|
5
|
+
import { readFileSync } from "node:fs";
|
|
6
|
+
import { signedGet, signedPost, sessionContext } from "../hooks/lib/api.mjs";
|
|
7
|
+
import { busDir } from "../lib/project.mjs";
|
|
8
|
+
import { loadRegistry } from "../lib/canary/registry.mjs";
|
|
9
|
+
import {
|
|
10
|
+
dispatchDecision, idempotencyKey, parseCards, preflight, readCachedAdvice, renderDispatch, requestDispatch,
|
|
11
|
+
} from "../lib/dispatcher/preflight.mjs";
|
|
12
|
+
|
|
13
|
+
const args = process.argv.slice(2);
|
|
14
|
+
const asJson = args.includes("--json");
|
|
15
|
+
const flag = (name) => { const i = args.indexOf(name); return i > -1 ? args[i + 1] : null; };
|
|
16
|
+
const flags = (name) => args.flatMap((a, i) => (a === name ? [args[i + 1]] : []));
|
|
17
|
+
const { project } = sessionContext();
|
|
18
|
+
const BUS = busDir();
|
|
19
|
+
const get = (path) => signedGet(path, { project, timeoutMs: 5000 });
|
|
20
|
+
const post = (path, body) => signedPost(path, body, { project, timeoutMs: 10000 });
|
|
21
|
+
const print = (value, text) => console.log(asJson ? JSON.stringify(value, null, 2) : text);
|
|
22
|
+
const stdinJson = () => {
|
|
23
|
+
if (process.stdin.isTTY) return null;
|
|
24
|
+
const raw = readFileSync(0, "utf8").trim();
|
|
25
|
+
return raw ? JSON.parse(raw) : null;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
async function status(attemptId) {
|
|
29
|
+
const r = await get(`/dispatch/${encodeURIComponent(attemptId)}`);
|
|
30
|
+
if (!r.ok) {
|
|
31
|
+
print({ ok: false, status: r.status, code: r.json?.code || (r.status === 0 ? "hub_unreachable" : `http_${r.status}`) },
|
|
32
|
+
`attempt ${attemptId}: ${r.status === 0 ? `hub unreachable (${r.reason})` : r.json?.code || `HTTP ${r.status}`}`);
|
|
33
|
+
return r.status === 0 ? 3 : 1;
|
|
34
|
+
}
|
|
35
|
+
const a = r.json;
|
|
36
|
+
print(a, `attempt ${a.attemptId}: #${a.card} ${a.state} · generation ${a.generation} · lease ${a.leaseId}${a.failure ? ` · failed ${a.failure.code}` : ""}`);
|
|
37
|
+
return 0;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function runPreflight() {
|
|
41
|
+
const input = stdinJson();
|
|
42
|
+
const cards = await parseCards(input?.cards || []);
|
|
43
|
+
const out = await preflight({ get, busDir: BUS, project, cards, rows: loadRegistry(), snapshotId: flag("--snapshot") });
|
|
44
|
+
print(out, out.lines.join("\n") || "preflight: nothing open");
|
|
45
|
+
return out.ok ? 0 : 1;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function admit() {
|
|
49
|
+
const decisionId = flag("--decision");
|
|
50
|
+
if (decisionId) {
|
|
51
|
+
const cached = readCachedAdvice(BUS, project);
|
|
52
|
+
if (cached?.decision?.id !== decisionId) {
|
|
53
|
+
print({ ok: false, code: "decision_unknown", decisionId },
|
|
54
|
+
`decision ${decisionId} is not the last hub decision for ${project}; run trantor advise --json first`);
|
|
55
|
+
return 1;
|
|
56
|
+
}
|
|
57
|
+
const only = flags("--card").map(Number);
|
|
58
|
+
const outcome = await dispatchDecision({ post, decision: cached.decision, project, only: only.length ? only : null });
|
|
59
|
+
print(outcome, renderDispatch(outcome));
|
|
60
|
+
return outcome.admitted === outcome.results.length && outcome.results.length ? 0 : 3;
|
|
61
|
+
}
|
|
62
|
+
const input = stdinJson();
|
|
63
|
+
if (!input?.decisionId) {
|
|
64
|
+
console.error("usage: trantor dispatch --decision <id> [--card <n>]... [--json] | --json < request | status <attemptId> | preflight");
|
|
65
|
+
return 2;
|
|
66
|
+
}
|
|
67
|
+
const request = { schemaVersion: 1, project, decisionId: input.decisionId, card: input.card, cardRevision: input.cardRevision,
|
|
68
|
+
expectedPolicyVersion: input.expectedPolicyVersion,
|
|
69
|
+
idempotencyKey: input.idempotencyKey || idempotencyKey({ project, decisionId: input.decisionId, card: input.card, cardRevision: input.cardRevision }) };
|
|
70
|
+
const result = await requestDispatch({ post, request });
|
|
71
|
+
const outcome = { decisionId: request.decisionId, admitted: result.admitted ? 1 : 0, results: [result] };
|
|
72
|
+
print(outcome, renderDispatch(outcome));
|
|
73
|
+
return result.admitted ? 0 : 3;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const sub = args[0];
|
|
77
|
+
const code = sub === "status" ? await status(args[1]) : sub === "preflight" ? await runPreflight() : await admit();
|
|
78
|
+
process.exit(code);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawnSync } from "node:child_process";
|
|
3
|
+
import { accessSync, constants } from "node:fs";
|
|
4
|
+
import { delimiter, join, resolve } from "node:path";
|
|
5
|
+
import { SEAT_LABEL } from "../lib/docker-janitor.mjs";
|
|
6
|
+
|
|
7
|
+
const shim = resolve(import.meta.dirname, "heavy-gate-shim", "docker");
|
|
8
|
+
let binary = "";
|
|
9
|
+
for (const dir of String(process.env.PATH || "").split(delimiter)) {
|
|
10
|
+
if (!dir) continue;
|
|
11
|
+
const candidate = resolve(dir, "docker");
|
|
12
|
+
if (candidate === shim) continue;
|
|
13
|
+
try {
|
|
14
|
+
accessSync(candidate, constants.X_OK);
|
|
15
|
+
binary = candidate;
|
|
16
|
+
break;
|
|
17
|
+
} catch {}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (!binary) {
|
|
21
|
+
console.error("docker: executable not found");
|
|
22
|
+
process.exit(127);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const args = process.argv.slice(2);
|
|
26
|
+
const owner = process.env.TRANTOR_DOCKER_SEAT || "";
|
|
27
|
+
const command = args[0] === "container" ? 1 : 0;
|
|
28
|
+
if (owner && ["run", "create"].includes(args[command])) {
|
|
29
|
+
args.splice(command + 1, 0, "--label", `${SEAT_LABEL}=${owner}`);
|
|
30
|
+
}
|
|
31
|
+
const result = spawnSync(binary, args, { stdio: "inherit" });
|
|
32
|
+
if (result.error) console.error(`docker: ${result.error.message}`);
|
|
33
|
+
process.exit(result.status ?? 1);
|
package/bin/integrate.mjs
CHANGED
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
// The steps are the ones the orchestrator already performs by hand. The dials decide how far it is
|
|
4
4
|
// allowed to go on its own, and every stop says which dial stopped it, so "why didn't it push"
|
|
5
5
|
// always has an answer.
|
|
6
|
-
import { resolveProject } from "../lib/project.mjs";
|
|
6
|
+
import { resolveProject, resolveHub } from "../lib/project.mjs";
|
|
7
7
|
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
|
+
import { ownerIdentity } from "../lib/enroll.mjs";
|
|
11
|
+
import { checkSeatReview } from "../lib/review-gate.mjs";
|
|
10
12
|
|
|
11
13
|
const D = "\x1b[2m", B = "\x1b[1m", G = "\x1b[32m", Y = "\x1b[33m", RED = "\x1b[31m", R = "\x1b[0m";
|
|
12
14
|
const args = process.argv.slice(2);
|
|
@@ -41,11 +43,21 @@ for (const w of seats) {
|
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
// 2. Merge what each seat is ahead by. A conflict stops the pass: two seats on the same lines is
|
|
44
|
-
// the collision the overseer exists to surface, not something to resolve silently.
|
|
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.
|
|
45
49
|
const merged = [];
|
|
50
|
+
const hub = resolveHub(project);
|
|
51
|
+
const identity = ownerIdentity();
|
|
46
52
|
for (const w of seats) {
|
|
47
53
|
const { branch, ahead } = seatAhead(w, base);
|
|
48
54
|
if (!ahead) continue;
|
|
55
|
+
const review = await checkSeatReview({ hub, identity, project, seat: w.agent, dir: w.dir, base, tip: branch, publish: !dry });
|
|
56
|
+
if (!review.merge) {
|
|
57
|
+
console.log(` ${Y}${w.agent}: skipped, ${review.reason}${R}`);
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (review.reviewed) console.log(` ${D}${w.agent}: ${review.reason}${R}`);
|
|
49
61
|
if (dry) { console.log(` ${D}[dry] would merge ${branch} (${ahead} commit(s))${R}`); merged.push(branch); continue; }
|
|
50
62
|
const m = mergeSeat(repo, branch);
|
|
51
63
|
if (m.conflict) {
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { parseArgs } from 'node:util';
|
|
3
|
+
import { pathToFileURL } from 'node:url';
|
|
4
|
+
import { PgStore } from '../lib/store-pg.mjs';
|
|
5
|
+
import { DISPATCHER_MIGRATION_ID, DISPATCHER_MIGRATION_LOCK_SQL,
|
|
6
|
+
DISPATCHER_SCHEMA_SQL, DISPATCHER_SCHEMA_VERSION } from '../lib/dispatcher/store.mjs';
|
|
7
|
+
import { backfillAttempts } from '../lib/dispatcher/migrate-attempts.mjs';
|
|
8
|
+
import { DISPATCHER_INTEGRATION_SQL } from '../lib/store-contract.mjs';
|
|
9
|
+
|
|
10
|
+
export async function migrateDispatcher({ store, batchSize = 1000, onCheckpoint = () => {} }) {
|
|
11
|
+
if (!Number.isSafeInteger(batchSize) || batchSize < 1 || batchSize > 1000) {
|
|
12
|
+
throw new RangeError('batch size must be between 1 and 1000');
|
|
13
|
+
}
|
|
14
|
+
const transaction = store.transaction.bind(store);
|
|
15
|
+
await transaction(async client => {
|
|
16
|
+
await client.query(DISPATCHER_MIGRATION_LOCK_SQL);
|
|
17
|
+
await client.query(DISPATCHER_SCHEMA_SQL);
|
|
18
|
+
await client.query(DISPATCHER_INTEGRATION_SQL);
|
|
19
|
+
await client.query(`INSERT INTO dispatcher_migrations(id,schema_version,checkpoint,completed_at_ms)
|
|
20
|
+
VALUES($1,$2,$3,NULL) ON CONFLICT(id) DO NOTHING`,
|
|
21
|
+
[DISPATCHER_MIGRATION_ID, DISPATCHER_SCHEMA_VERSION, { lastKey: null, scanned: 0 }]);
|
|
22
|
+
});
|
|
23
|
+
let checkpoint;
|
|
24
|
+
do {
|
|
25
|
+
checkpoint = await backfillAttempts({ transaction, batchSize });
|
|
26
|
+
await onCheckpoint(checkpoint);
|
|
27
|
+
} while (!checkpoint.complete);
|
|
28
|
+
return checkpoint;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function main() {
|
|
32
|
+
const { values } = parseArgs({ options: { 'batch-size': { type: 'string', default: '1000' },
|
|
33
|
+
help: { type: 'boolean', default: false } } });
|
|
34
|
+
if (values.help) {
|
|
35
|
+
process.stdout.write('Usage: node bin/migrate-dispatcher.mjs [--batch-size 1..1000]\nUses RELAY_DATABASE_URL or DATABASE_URL for an initialized PostgreSQL hub.\n');
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const url = process.env.RELAY_DATABASE_URL || process.env.DATABASE_URL;
|
|
39
|
+
if (!url) throw new Error('RELAY_DATABASE_URL or DATABASE_URL is required');
|
|
40
|
+
const { default: pg } = await import('pg');
|
|
41
|
+
const pool = new pg.Pool({ connectionString: url });
|
|
42
|
+
try {
|
|
43
|
+
await migrateDispatcher({ store: new PgStore({ pool }), batchSize: Number(values['batch-size']),
|
|
44
|
+
onCheckpoint: checkpoint => process.stdout.write(`${JSON.stringify(checkpoint)}\n`) });
|
|
45
|
+
} finally { await pool.end(); }
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
49
|
+
main().catch(error => { process.stderr.write(`Dispatcher migration failed: ${error.message}\n`); process.exitCode = 1; });
|
|
50
|
+
}
|
package/bin/review.mjs
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// `trantor review publish [--json]`: run from the project checkout, it publishes every seat's
|
|
3
|
+
// committed diff against the checkout's branch (the branch `trantor integrate` merges into) to the
|
|
4
|
+
// hub, so Mixed mode can decide its hunks (docs/CONTRACT-review.md). It never merges or edits.
|
|
5
|
+
import { resolveProject, resolveHub } from "../lib/project.mjs";
|
|
6
|
+
import { seatWorktrees, seatAhead, git } from "../lib/integrate.mjs";
|
|
7
|
+
import { ownerIdentity } from "../lib/enroll.mjs";
|
|
8
|
+
import { publishSeatReview } from "../lib/review-gate.mjs";
|
|
9
|
+
|
|
10
|
+
const args = process.argv.slice(2);
|
|
11
|
+
const json = args.includes("--json");
|
|
12
|
+
if (args[0] !== "publish") {
|
|
13
|
+
console.error("usage: trantor review publish [--json]");
|
|
14
|
+
process.exit(2);
|
|
15
|
+
}
|
|
16
|
+
const repo = process.cwd();
|
|
17
|
+
const project = resolveProject(repo);
|
|
18
|
+
const base = git(repo, ["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
19
|
+
const hub = resolveHub(project);
|
|
20
|
+
const identity = ownerIdentity();
|
|
21
|
+
const seats = [];
|
|
22
|
+
for (const w of seatWorktrees(project)) {
|
|
23
|
+
const { branch, ahead } = seatAhead(w, base);
|
|
24
|
+
if (!ahead) continue;
|
|
25
|
+
try {
|
|
26
|
+
const review = await publishSeatReview({ hub, identity, project, seat: w.agent, dir: w.dir, base, tip: branch });
|
|
27
|
+
seats.push({ seat: w.agent, tip: review.tip, hunks: review.hunks.length, pending: review.pendingCount });
|
|
28
|
+
} catch (e) {
|
|
29
|
+
seats.push({ seat: w.agent, error: e.message });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (json) console.log(JSON.stringify({ project, base, seats }));
|
|
33
|
+
else for (const s of seats) console.log(s.error ? `${s.seat}: ${s.error}` : `${s.seat}: ${s.pending} of ${s.hunks} hunks pending`);
|
|
34
|
+
// --json reports per-seat errors in the payload, so the desktop can show each one beside its seat.
|
|
35
|
+
process.exit(!json && seats.some(s => s.error) ? 1 : 0);
|
package/hooks/sessionstart.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { join, basename, dirname } from "node:path";
|
|
|
7
7
|
import { homedir, hostname } from "node:os";
|
|
8
8
|
import { execSync, spawn } from "node:child_process";
|
|
9
9
|
import { fileURLToPath } from "node:url";
|
|
10
|
-
import { resolveProject, hostId, resolveHubInfo, knownProjects, nonSeatReason, nestedProjects, readConfig as readBusConfig, handoffDir, readOrchSession, writeOrchSession } from "../lib/project.mjs";
|
|
10
|
+
import { resolveProject, hostId, resolveHubInfo, knownProjects, nonSeatReason, nestedProjects, readConfig as readBusConfig, handoffDir, readOrchSession, writeOrchSession, busDirFor } from "../lib/project.mjs";
|
|
11
11
|
import { formatSubagentManifest } from "../lib/subagent-manifest.mjs";
|
|
12
12
|
import { updateAvailable, maybeNotifyDesktop, readConfig } from "./lib/update-check.mjs";
|
|
13
13
|
import { renderStateBlock, capSummary } from "./lib/handoff.mjs";
|
|
@@ -372,6 +372,9 @@ try {
|
|
|
372
372
|
`- Dispatch rule: the target project is confirmed from the session's badge and cwd before any relay_send, relay_task_add or \`trantor up\` — an ambiguous instruction is not a project name; and a session asking the operator a question never triggers a wake (its messages batch until the answer).\n` +
|
|
373
373
|
`</trantor-orchestrator-role>\n`;
|
|
374
374
|
if (wantsBuildDoctrine(readBusConfig())) additionalContext += buildDoctrineShortForm();
|
|
375
|
+
// #14678: the shared dispatch brief, open regressions first; Codex gets the same text via connect.
|
|
376
|
+
const { sessionBrief } = await import("../lib/dispatcher/preflight.mjs");
|
|
377
|
+
additionalContext += `<trantor-dispatch-brief project="${sanitize(project)}">\n${sanitize(sessionBrief({ busDir: busDirFor() }))}\n</trantor-dispatch-brief>\n`;
|
|
375
378
|
process.stderr.write(`[trantor] injected orchestrator-role doctrine for ${project}\n`);
|
|
376
379
|
}
|
|
377
380
|
} catch {}
|
package/hub/auth.mjs
CHANGED
|
@@ -17,7 +17,7 @@ const OWNER_BODY_CAPS = new Map([
|
|
|
17
17
|
["/session/chat", BODY_CAP_OWNER_CHAT],
|
|
18
18
|
["/handoff", BODY_CAP_DEFAULT], ["/task", BODY_CAP_DEFAULT], ["/task/update", BODY_CAP_DEFAULT],
|
|
19
19
|
]);
|
|
20
|
-
function bodyCap(P) { return P === "/session/prompt" ? BODY_CAP_PROMPT : BODY_CAP_DEFAULT; }
|
|
20
|
+
function bodyCap(P) { return P === "/advise" ? 1024 * 1024 : P === "/session/prompt" ? BODY_CAP_PROMPT : BODY_CAP_DEFAULT; }
|
|
21
21
|
function ownerBodyCap(req, P) {
|
|
22
22
|
const cap = OWNER_BODY_CAPS.get(P) || bodyCap(P);
|
|
23
23
|
if (cap <= bodyCap(P) || !Object.values(HDR).every(h => req.headers[h])) return bodyCap(P);
|
|
@@ -170,7 +170,7 @@ function projectFromRequest(P, q, b, method) {
|
|
|
170
170
|
return canon(String(b?.project || q?.project || "").slice(0, 80));
|
|
171
171
|
}
|
|
172
172
|
// Cross-project actions require a declared link or the operator identity, even with wildcard scopes (#6228).
|
|
173
|
-
const CROSS_PROJECT_ENDPOINTS = new Set(["/send", "/task", "/task/update", "/register", "/invite"]);
|
|
173
|
+
const CROSS_PROJECT_ENDPOINTS = new Set(["/send", "/task", "/task/update", "/register", "/invite", "/dispatch"]);
|
|
174
174
|
function projectsLinked(a, b) {
|
|
175
175
|
if (!a || !b || a === b) return true;
|
|
176
176
|
return overseerPolicy().links.some(l => {
|
|
@@ -204,7 +204,7 @@ function crossProjectTarget(P, b) {
|
|
|
204
204
|
const to = String(b.to);
|
|
205
205
|
return canon(state.peers[to]?.project || (to.includes(":") ? to.slice(to.lastIndexOf(":") + 1) : ""));
|
|
206
206
|
}
|
|
207
|
-
if (P === "/task" || P === "/register") return canon(String(b?.project || "").slice(0, 80));
|
|
207
|
+
if (P === "/task" || P === "/register" || P === "/dispatch") return canon(String(b?.project || "").slice(0, 80));
|
|
208
208
|
if (P === "/task/update") {
|
|
209
209
|
const t = state.tasks.find(x => x.id === Number(b?.id));
|
|
210
210
|
return t?.project || "";
|