trantor 0.18.134 → 0.18.137
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/README.md +6 -3
- package/bin/adopt.mjs +2 -2
- package/bin/app.mjs +5 -10
- package/bin/cli.mjs +2 -0
- package/bin/connect.mjs +14 -1
- package/bin/crew/models.mjs +4 -1
- package/bin/crew/open.mjs +18 -8
- package/bin/crew/worktrees.mjs +3 -3
- package/bin/crew-runner.mjs +7 -6
- package/bin/crew.mjs +7 -2
- package/bin/doctor.mjs +3 -3
- package/bin/helper.mjs +119 -0
- package/bin/new.mjs +2 -2
- package/bin/seats.mjs +3 -2
- package/bin/slop-gate.mjs +1 -1
- package/bin/takeover.mjs +2 -2
- package/bin/turn-watchdog.mjs +2 -1
- package/deploy/node-path.sh +18 -0
- package/deploy/setup.sh +11 -3
- package/engine/bin/scrooge +9 -0
- package/hooks/lib/handoff.mjs +10 -3
- package/hooks/lib/start-gates.mjs +18 -0
- package/hooks/precompact.mjs +6 -2
- package/hooks/sessionstart.mjs +11 -6
- package/hub/routes/insights.mjs +29 -31
- package/hub/store.mjs +8 -1
- package/kimi/bin/baton-close.mjs +108 -0
- package/kimi/bin/lib/handoff.mjs +119 -0
- package/kimi/bin/write-handoff.mjs +31 -0
- package/kimi/bridge.mjs +219 -0
- package/kimi/skills/crew/SKILL.md +119 -0
- package/kimi/skills/handoff/SKILL.md +44 -0
- package/kimi/skills/research/SKILL.md +49 -0
- package/kimi.plugin.json +66 -0
- package/lib/agent-preferences.mjs +15 -0
- package/lib/app-release.mjs +30 -0
- package/lib/browser-client.mjs +117 -0
- package/lib/enroll.mjs +20 -2
- package/lib/jsonc.mjs +37 -0
- package/lib/project.mjs +21 -2
- package/lib/turn-policy.mjs +5 -0
- package/mcp.mjs +84 -3
- package/package.json +3 -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.
|
|
9
|
+
"version": "0.18.137"
|
|
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.
|
|
16
|
+
"version": "0.18.137",
|
|
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.137",
|
|
4
4
|
"description": "Trantor — the hub-world for AI agent crews: live message bus, presence, project Kanban/flow board + crew orchestration for independent AI coding agents (Claude, Codex, Gemini, Kimi, DeepSeek)",
|
|
5
5
|
"mcpServers": {
|
|
6
6
|
"relay": {
|
package/README.md
CHANGED
|
@@ -372,8 +372,9 @@ board — no code change, no waiting for us to add it.
|
|
|
372
372
|
|
|
373
373
|
A PreCompact hook writes a rich handoff before Claude Code compacts; a fresh session in the
|
|
374
374
|
same project **takes over with a brand-new full context window**. Works manually from any
|
|
375
|
-
agent via `relay_handoff`. Optional macOS auto-prompt (`autoHandoffPrompt` in
|
|
376
|
-
`~/.agent-bus/config.json
|
|
375
|
+
agent via `relay_handoff`. Optional macOS auto-prompt (`"autoHandoffPrompt": true` in
|
|
376
|
+
`~/.agent-bus/config.json`, off by default since 0.18.135) opens the fresh session for you in
|
|
377
|
+
Terminal.app. Without it the handoff is still written, and the hook says how to continue.
|
|
377
378
|
|
|
378
379
|
Since 0.18.18 the succession is a machine, not a ritual: at 90% context the running agent is
|
|
379
380
|
told to finish or checkpoint and author the boundary handoff itself; the app's banner counts
|
|
@@ -414,6 +415,7 @@ rate, not work rate.
|
|
|
414
415
|
| `relay_scrooge(prompt, task?, difficulty?)` | Fractal cheap-model delegation, with the ledger receipt |
|
|
415
416
|
| `relay_lesson(text, scope?)` | Record a failure lesson — auto-injected into all future crews |
|
|
416
417
|
| `relay_handoff(summary)` | Full-window session succession |
|
|
418
|
+
| `browser_open` / `browser_read` / `browser_click` / `browser_type` / `browser_scroll` / `browser_screenshot` / `browser_resize` / `browser_pages` / `browser_back` / `browser_forward` | Drive the project's browser tab in the Trantor desktop app on the same Mac: open a page, read its text and element refs, act on refs, screenshot, emulate a device. Waits while the operator holds the browser or approves a new site; says so when the desktop app is not open |
|
|
417
419
|
|
|
418
420
|
## The CLI
|
|
419
421
|
|
|
@@ -440,7 +442,8 @@ trantor setup | doctor | connect | profile | provider | models
|
|
|
440
442
|
the AXe pin.
|
|
441
443
|
|
|
442
444
|
- **`trantor new <name>`** — project genesis in one command: makes the dir under your dev root
|
|
443
|
-
(`TRANTOR_DEV_ROOT
|
|
445
|
+
(`TRANTOR_DEV_ROOT`, else the Projects folder chosen in the app's Settings, stored as
|
|
446
|
+
`projectsRoot` in `~/.agent-bus/config.json`, else `~/development`), git on main (or `--from <git-url>`, or `--adopt` an
|
|
444
447
|
existing folder), installs the auto-card hook, posts the brief to the hub, and opens the first
|
|
445
448
|
card "genesis: <name>". `--json` for machines. It never spawns a session — firing the crew
|
|
446
449
|
stays your call. Two paths in: **blank** (no brief) wakes the orchestrator plainly and you work
|
package/bin/adopt.mjs
CHANGED
|
@@ -15,7 +15,7 @@ import { readdirSync, statSync, existsSync, readFileSync, writeFileSync, mkdirSy
|
|
|
15
15
|
import { execFileSync } from "node:child_process";
|
|
16
16
|
import { join, dirname, basename } from "node:path";
|
|
17
17
|
import { homedir } from "node:os";
|
|
18
|
-
import { resolveProject, writeOrchSession, checkoutFor, devRootFor, readOrchSession } from "../lib/project.mjs";
|
|
18
|
+
import { resolveProject, writeOrchSession, checkoutFor, localCheckoutFor, devRootFor, readOrchSession } from "../lib/project.mjs";
|
|
19
19
|
|
|
20
20
|
const D = "\x1b[2m", B = "\x1b[1m", Y = "\x1b[33m", G = "\x1b[32m", R = "\x1b[0m";
|
|
21
21
|
const args = process.argv.slice(2);
|
|
@@ -24,7 +24,7 @@ const flag = (n) => { const i = args.indexOf(n); return i >= 0 ? args[i + 1] : n
|
|
|
24
24
|
const project = args.find(a => !a.startsWith("--") && args[args.indexOf(a) - 1] !== "--session")
|
|
25
25
|
|| resolveProject(process.cwd());
|
|
26
26
|
// The checkout is found by the project's ID (#6724): a renamed directory still answers.
|
|
27
|
-
const dir =
|
|
27
|
+
const dir = localCheckoutFor(project);
|
|
28
28
|
if (!dir) {
|
|
29
29
|
console.error(`no local checkout for ${project} (looked in ${devRootFor()})`);
|
|
30
30
|
process.exit(1);
|
package/bin/app.mjs
CHANGED
|
@@ -13,6 +13,7 @@ import { pipeline } from "node:stream/promises";
|
|
|
13
13
|
import { join } from "node:path";
|
|
14
14
|
import { tmpdir } from "node:os";
|
|
15
15
|
import { cleanLaunchEnv } from "../lib/launch-env.mjs";
|
|
16
|
+
import { newestDmgRelease } from "../lib/app-release.mjs";
|
|
16
17
|
|
|
17
18
|
const REPO = "sashabogi/trantor";
|
|
18
19
|
const APP = "/Applications/Trantor.app";
|
|
@@ -69,16 +70,10 @@ async function latestAppRelease() {
|
|
|
69
70
|
if (process.env.GITHUB_TOKEN) headers.authorization = `Bearer ${process.env.GITHUB_TOKEN}`;
|
|
70
71
|
const r = await fetch(`https://api.github.com/repos/${REPO}/releases?per_page=30`, { headers, signal: AbortSignal.timeout(15000) });
|
|
71
72
|
if (!r.ok) throw new Error(`GitHub API ${r.status} — ${(await r.text()).slice(0, 200)}`);
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const asset = assets.find(a => a.name.includes(`_${ARCH_TAG}`)) || assets[0];
|
|
77
|
-
if (!asset.name.includes(`_${ARCH_TAG}`)) console.error(`⚠ no ${ARCH_TAG} build in ${rel.tag_name} — using ${asset.name} (may not run on this Mac)`);
|
|
78
|
-
const version = (asset.name.match(/[_-]([0-9]+(?:\.[0-9]+)*)[_-]/) || [])[1] || rel.tag_name.replace(/^app-v?|^v/, "");
|
|
79
|
-
return { tag: rel.tag_name, version, asset };
|
|
80
|
-
}
|
|
81
|
-
throw new Error("no release with a Trantor DMG asset found");
|
|
73
|
+
const best = newestDmgRelease(await r.json(), ARCH_TAG);
|
|
74
|
+
if (!best) throw new Error("no release with a Trantor DMG asset found");
|
|
75
|
+
if (!best.asset.name.includes(`_${ARCH_TAG}`)) console.error(`⚠ no ${ARCH_TAG} build in ${best.tag} — using ${best.asset.name} (may not run on this Mac)`);
|
|
76
|
+
return best;
|
|
82
77
|
}
|
|
83
78
|
|
|
84
79
|
const rel = await latestAppRelease().catch(e => { console.error(`trantor app: ${e.message}`); process.exit(1); });
|
package/bin/cli.mjs
CHANGED
|
@@ -137,6 +137,7 @@ switch (cmd) {
|
|
|
137
137
|
break;
|
|
138
138
|
}
|
|
139
139
|
case "state": run("bin/state.mjs"); break;
|
|
140
|
+
case "helper": run("bin/helper.mjs"); break;
|
|
140
141
|
case "seats": case "seat": run("bin/seats.mjs"); break;
|
|
141
142
|
case "seat-why": case "why": run("bin/seat-why.mjs"); break;
|
|
142
143
|
case "seat-record": run("bin/seat-record.mjs"); break;
|
|
@@ -288,6 +289,7 @@ switch (cmd) {
|
|
|
288
289
|
trantor secrets provider keys in the OS keychain: list · set <NAME> (stdin) · remove <NAME> · migrate [--dry-run]
|
|
289
290
|
trantor keys identity keys in the OS keychain: status · migrate [--dry-run] · prune [--apply] [--idle-days N]
|
|
290
291
|
trantor models browse live models behind each seat + the router's pick per difficulty
|
|
292
|
+
trantor helper run a visible helper pane | list --project <name> | stop <pane>
|
|
291
293
|
trantor up … spawn a crew here: trantor up codex kimi deepseek:deepseek glm:zai-coding-plan
|
|
292
294
|
trantor open host THIS session as the project's orchestrator pane (trantor down spares it)
|
|
293
295
|
trantor herdr install|remove|status the login agent that keeps panes alive across a reboot
|
package/bin/connect.mjs
CHANGED
|
@@ -7,6 +7,7 @@ import { join, dirname } from "node:path";
|
|
|
7
7
|
import { homedir } from "node:os";
|
|
8
8
|
import { execSync } from "node:child_process";
|
|
9
9
|
import { fileURLToPath } from "node:url";
|
|
10
|
+
import { parseJsonc } from "../lib/jsonc.mjs";
|
|
10
11
|
import { resolveProjectInfo, resolveHubInfo, gitRoot, writeProjectId, PROJECT_MARKER } from "../lib/project.mjs";
|
|
11
12
|
|
|
12
13
|
const DRY = process.argv.includes("--dry-run");
|
|
@@ -31,10 +32,22 @@ const report = (cli, status, detail = "") => out.push({ cli, status, detail });
|
|
|
31
32
|
|
|
32
33
|
function patchJson(path, mutate) {
|
|
33
34
|
const exists = existsSync(path);
|
|
34
|
-
|
|
35
|
+
let d, raw = "";
|
|
36
|
+
try { raw = exists ? readFileSync(path, "utf8") : ""; d = exists ? parseJsonc(raw) : {}; }
|
|
37
|
+
catch { return "unparseable, skipped (left untouched)"; }
|
|
35
38
|
const before = JSON.stringify(d);
|
|
36
39
|
mutate(d);
|
|
37
40
|
if (JSON.stringify(d) === before) return "already wired";
|
|
41
|
+
// A JSONC file (comments, trailing commas) would lose its comments if rewritten as JSON:
|
|
42
|
+
// leave it as the user wrote it and say what to add.
|
|
43
|
+
let strict = true;
|
|
44
|
+
try { if (exists) JSON.parse(raw); } catch { strict = false; }
|
|
45
|
+
if (!strict) {
|
|
46
|
+
// Name the keys only: the file can hold the user's own secrets, so no values are printed.
|
|
47
|
+
const was = parseJsonc(raw);
|
|
48
|
+
const keys = Object.keys(d).filter(k => JSON.stringify(d[k]) !== JSON.stringify(was[k]));
|
|
49
|
+
return `has comments, left untouched: add the Trantor entry under ${keys.join(", ") || "the top level"} by hand`;
|
|
50
|
+
}
|
|
38
51
|
if (!DRY) {
|
|
39
52
|
if (exists) backup(path); else mkdirSync(dirname(path), { recursive: true });
|
|
40
53
|
writeFileSync(path, JSON.stringify(d, null, 2) + "\n");
|
package/bin/crew/models.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import { call } from "./core.mjs";
|
|
3
|
+
import { call, commandExists } from "./core.mjs";
|
|
4
|
+
import { seatCliProblem } from "../../lib/agent-preferences.mjs";
|
|
4
5
|
import { resolveEffort } from "../../lib/model-catalog.mjs";
|
|
5
6
|
|
|
6
7
|
function routeModel(ctx, provider, candidates, task, difficulty) {
|
|
@@ -22,6 +23,8 @@ function routeModel(ctx, provider, candidates, task, difficulty) {
|
|
|
22
23
|
|
|
23
24
|
export function resolveModel(ctx, agent, provider, task, difficulty) {
|
|
24
25
|
const result = call("opencode", ["models", provider], { env: ctx.env });
|
|
26
|
+
const missing = seatCliProblem(agent, cli => commandExists(cli, ctx.env));
|
|
27
|
+
if (!ctx.dry && !result.ok && missing && !commandExists("opencode", ctx.env)) throw new Error(missing);
|
|
25
28
|
const candidates = result.ok ? result.stdout.split(/\s+/).filter(Boolean).join(" ") : "";
|
|
26
29
|
let model = routeModel(ctx, provider, candidates, task, difficulty);
|
|
27
30
|
// An unavailable router must not erase seats from a layout preview. Never launch an unresolved model.
|
package/bin/crew/open.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { existsSync, openSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { existsSync, mkdirSync, openSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
|
-
import { basename, join } from "node:path";
|
|
5
|
-
import { spawn, execSync } from "node:child_process";
|
|
4
|
+
import { basename, dirname, isAbsolute, join } from "node:path";
|
|
5
|
+
import { spawn, execSync, execFileSync } from "node:child_process";
|
|
6
6
|
import { call, parseJsonOutput } from "./core.mjs";
|
|
7
7
|
import { createWorkspace, herdrCall, paneAlive, reportAgent, splitPane, workspaceList, workspacePane } from "./herdr.mjs";
|
|
8
8
|
import { dropState, readRows, recordState } from "./state.mjs";
|
|
@@ -218,16 +218,26 @@ function hostPane(ctx, chosen, id) {
|
|
|
218
218
|
// graph to serve. Non-blocking — the pane opens now, the ~7s build lands in the background; a no-op
|
|
219
219
|
// if graft isn't installed or the index already exists (the graph self-refreshes per query after the
|
|
220
220
|
// first build). Keeps the 20MB index out of the project's git.
|
|
221
|
+
// Hide graft/ through .git/info/exclude, never the user's tracked .gitignore (#14322). Returns the file written, "" when not a git checkout.
|
|
222
|
+
export function excludeGraftLocally(dir) {
|
|
223
|
+
try {
|
|
224
|
+
const out = execFileSync("git", ["-C", dir, "rev-parse", "--git-path", "info/exclude"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
225
|
+
if (!out) return "";
|
|
226
|
+
const file = isAbsolute(out) ? out : join(dir, out);
|
|
227
|
+
const cur = existsSync(file) ? readFileSync(file, "utf8") : "";
|
|
228
|
+
if (/^\/?graft\/?$/m.test(cur)) return file;
|
|
229
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
230
|
+
writeFileSync(file, cur + (cur && !cur.endsWith("\n") ? "\n" : "") + "graft/\n");
|
|
231
|
+
return file;
|
|
232
|
+
} catch { return ""; }
|
|
233
|
+
}
|
|
234
|
+
|
|
221
235
|
export function maybeBuildGraft(dir) {
|
|
222
236
|
if (!dir) return;
|
|
223
237
|
try { execSync("command -v graft", { stdio: "ignore", shell: "/bin/sh" }); } catch { return; }
|
|
224
238
|
try {
|
|
225
239
|
if (existsSync(join(dir, "graft", ".graph"))) return;
|
|
226
|
-
|
|
227
|
-
try {
|
|
228
|
-
const cur = existsSync(gi) ? readFileSync(gi, "utf8") : "";
|
|
229
|
-
if (!/^graft\/?$/m.test(cur)) writeFileSync(gi, cur + (cur && !cur.endsWith("\n") ? "\n" : "") + "graft/\n");
|
|
230
|
-
} catch {}
|
|
240
|
+
excludeGraftLocally(dir);
|
|
231
241
|
// The build is backgrounded, so its exit code cannot gate the pane, but a failure has to land
|
|
232
242
|
// SOMEWHERE: under stdio:"ignore" a graft without native parsers (see deploy/setup.sh) failed in
|
|
233
243
|
// silence while the line below still claimed an index was being built.
|
package/bin/crew/worktrees.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { basename, join } from "node:path";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import { call } from "./core.mjs";
|
|
4
|
-
import { checkoutFor, readProjectId } from "../../lib/project.mjs";
|
|
4
|
+
import { checkoutFor, localCheckoutFor, devRootFor, readProjectId } from "../../lib/project.mjs";
|
|
5
5
|
|
|
6
6
|
function gitRoot(dir) {
|
|
7
7
|
const result = call("git", ["-C", dir, "rev-parse", "--show-toplevel"]);
|
|
@@ -22,12 +22,12 @@ export function resolveOrchestratorDir(ctx, projectArg) {
|
|
|
22
22
|
}
|
|
23
23
|
if (!projectArg || target === here) return { dir: ctx.dir, project: target };
|
|
24
24
|
// By the project's id (#6724): a renamed checkout carries its marker and still answers.
|
|
25
|
-
const targetDir =
|
|
25
|
+
const targetDir = localCheckoutFor(target, ctx.dir, { ...ctx.env, HOME: ctx.home });
|
|
26
26
|
if (targetDir) {
|
|
27
27
|
console.error(`— opening ${target} in its checkout: ${targetDir} —`);
|
|
28
28
|
return { dir: targetDir, project: target };
|
|
29
29
|
}
|
|
30
|
-
throw new Error(`trantor open: '${target}' has no checkout under ${ctx.env
|
|
30
|
+
throw new Error(`trantor open: '${target}' has no checkout under ${devRootFor({ ...ctx.env, HOME: ctx.home })} — cd into the project first`);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
function linkedByTest(env, badge, project) {
|
package/bin/crew-runner.mjs
CHANGED
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
cardRefs, servedContractCard, carriesWork, parseTurnTokens, parseResetAt, reasonWithBalances, quotaResetAt, queuedWording, turnDelivered, budgetPause, PARKING_REASONS,
|
|
32
32
|
senderProjectOf, isLinkedProject, stateSkipReason, isMessageCardTitle, OPEN_CARD_STATUSES,
|
|
33
33
|
ownCardForInstance, contractedCardIds,
|
|
34
|
-
shouldAlignForContract,
|
|
34
|
+
shouldAlignForContract, hasContractText,
|
|
35
35
|
CUT_CHAIN_PARK_MIN, cutChainEvidence, isBoundedPark, askDuringTurn, askedVerdict,
|
|
36
36
|
} from "../lib/turn-policy.mjs";
|
|
37
37
|
import { snapshotBeforeCut } from "./cut-snapshot.mjs";
|
|
@@ -1132,11 +1132,7 @@ exit $turn_exit`;
|
|
|
1132
1132
|
const cut = !!TURN_MAX_MS && (boxed || stallCut);
|
|
1133
1133
|
// #7761: how far the watchdog moved the box, one EXTF row per extension. boxMs is the box the
|
|
1134
1134
|
// turn actually had, so a ceiling cut reads as the ceiling, never as the 20-minute default.
|
|
1135
|
-
let extensions = 0;
|
|
1136
|
-
try { extensions = readFileSync(EXTF, "utf8").split("\n").filter(Boolean).length; } catch {}
|
|
1137
|
-
const boxMs = TURN_MAX_MS + extensions * TURN_EXTEND_MS;
|
|
1138
1135
|
try { unlinkSync(DEADLINEF); } catch {}
|
|
1139
|
-
try { unlinkSync(EXTF); } catch {}
|
|
1140
1136
|
// DRAIN before classifying, never on a CUT turn (the sweep killed the scrubber, its marker never
|
|
1141
1137
|
// comes). bash 3.2 `wait` skips process substitutions, so wait for DRAINF, bounded.
|
|
1142
1138
|
if (!cut) {
|
|
@@ -1146,6 +1142,11 @@ exit $turn_exit`;
|
|
|
1146
1142
|
try { unlinkSync(DRAINF); } catch {}
|
|
1147
1143
|
killWatchdog(); // #6206: turn over — the watchdog dies NOW, it does not sleep on
|
|
1148
1144
|
try { unlinkSync(STAMPF); } catch {} // disarm any survivor: the stamp is gone
|
|
1145
|
+
// #14235: count extensions only after the watchdog is dead and disarmed, or it appends one more after this read and the assigner hears a notice the ledger lacks.
|
|
1146
|
+
let extensions = 0;
|
|
1147
|
+
try { extensions = readFileSync(EXTF, "utf8").split("\n").filter(Boolean).length; } catch {}
|
|
1148
|
+
const boxMs = TURN_MAX_MS + extensions * TURN_EXTEND_MS;
|
|
1149
|
+
try { unlinkSync(EXTF); } catch {}
|
|
1149
1150
|
if (cut) {
|
|
1150
1151
|
const saved = snapshotBeforeCut(TURN_DIR, stallCut ? "stall" : "box");
|
|
1151
1152
|
if (!saved.ok) log(`cut WIP snapshot failed: ${saved.error}`);
|
|
@@ -1497,7 +1498,7 @@ function isReceipt(message) {
|
|
|
1497
1498
|
// contract riding `re` must wake. A reply is a receipt only when it threads an outcome THIS seat
|
|
1498
1499
|
// sent and its own text carries no work (an ack/closure, #7079).
|
|
1499
1500
|
if (!(Number(message?.re) > 0)) return false;
|
|
1500
|
-
return sentOutcomes.has(Number(message.re)) && !carriesWork(text) && !isContract(message);
|
|
1501
|
+
return sentOutcomes.has(Number(message.re)) && !carriesWork(text) && !isContract(message) && !hasContractText(text);
|
|
1501
1502
|
}
|
|
1502
1503
|
|
|
1503
1504
|
function isStatusBroadcast(message) {
|
package/bin/crew.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { seatProcesses } from "./crew/processes.mjs";
|
|
3
3
|
import { allocatePersona } from "../lib/persona.mjs";
|
|
4
4
|
import { join } from "node:path";
|
|
5
|
-
import { call, createContext } from "./crew/core.mjs";
|
|
5
|
+
import { call, createContext, commandExists } from "./crew/core.mjs";
|
|
6
6
|
import { createCmuxAdapter, spawnCmux } from "./crew/cmux.mjs";
|
|
7
7
|
import { createHerdrAdapter, spawnHerdr } from "./crew/herdr.mjs";
|
|
8
8
|
import { resolveSpec, reportSkipped } from "./crew/models.mjs";
|
|
@@ -15,7 +15,7 @@ import { spawnTerminal, spawnTmux } from "./crew/tmux.mjs";
|
|
|
15
15
|
import { epochMs, failedAgents, verifyCrew } from "./crew/verify.mjs";
|
|
16
16
|
import { guardCrossProjectUp } from "./crew/worktrees.mjs";
|
|
17
17
|
import { preflightFirstSeat } from "./crew/preflight.mjs";
|
|
18
|
-
import { resolveAgentLaunchSpecs } from "../lib/agent-preferences.mjs";
|
|
18
|
+
import { resolveAgentLaunchSpecs, seatCliProblem } from "../lib/agent-preferences.mjs";
|
|
19
19
|
import { readConfig } from "../lib/project.mjs";
|
|
20
20
|
|
|
21
21
|
const [command = "up", ...inputArgs] = process.argv.slice(2);
|
|
@@ -85,6 +85,11 @@ async function runUp(args, verify = true) {
|
|
|
85
85
|
console.error(`[crew] ✗ ${requested.disabled.join(", ")} ${requested.disabled.length === 1 ? "is" : "are"} disabled in ~/.agent-bus/config.json — enable the seat in Settings → Agents`);
|
|
86
86
|
return 1;
|
|
87
87
|
}
|
|
88
|
+
if (!ctx.dry) {
|
|
89
|
+
const missing = [...new Set(options.specs.map(spec => spec.split(":")[0]))]
|
|
90
|
+
.map(agent => seatCliProblem(agent, cli => commandExists(cli, ctx.env))).filter(Boolean);
|
|
91
|
+
if (missing.length) { for (const line of missing) console.error(line); return 1; }
|
|
92
|
+
}
|
|
88
93
|
prune(ctx, adapters);
|
|
89
94
|
connect();
|
|
90
95
|
console.log(`[crew] hub for ${ctx.project}: ${ctx.hub} (baked into every seat; CREW_HUB=<url> overrides)`);
|
package/bin/doctor.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { join, dirname, basename } from "node:path";
|
|
|
8
8
|
import { homedir } from "node:os";
|
|
9
9
|
import { execSync } from "node:child_process";
|
|
10
10
|
import { fileURLToPath } from "node:url";
|
|
11
|
-
import { resolveProject, resolveProjectInfo, resolveHub, DEFAULT_HUB_URL, gitRoot, readProjectId, checkoutFor, orchSessionsPath, PROJECT_MARKER } from "../lib/project.mjs";
|
|
11
|
+
import { resolveProject, resolveProjectInfo, resolveHub, DEFAULT_HUB_URL, gitRoot, readProjectId, checkoutFor, localCheckoutFor, orchSessionsPath, PROJECT_MARKER } from "../lib/project.mjs";
|
|
12
12
|
import { loadOrCreate } from "../lib/identity.mjs";
|
|
13
13
|
import { sfetchJson } from "../lib/signed-fetch.mjs";
|
|
14
14
|
import { scan } from "../lib/splitbrain.mjs";
|
|
@@ -89,11 +89,11 @@ section("project identity");
|
|
|
89
89
|
: `if "${label}" is that project renamed: trantor project ${name} (the pin, board and orchestrator row then follow the id)`;
|
|
90
90
|
let orphans = 0;
|
|
91
91
|
for (const name of orchRows) {
|
|
92
|
-
if (
|
|
92
|
+
if (localCheckoutFor(name)) continue;
|
|
93
93
|
orphans++;
|
|
94
94
|
warn(`orphaned identity: ${name} has an orchestrator session row${pinned.includes(name) ? " and a hub pin" : ""} but no checkout on this machine carries it`, claim(name));
|
|
95
95
|
}
|
|
96
|
-
const pinnedOnly = pinned.filter(n => !orchRows.includes(n) && !
|
|
96
|
+
const pinnedOnly = pinned.filter(n => !orchRows.includes(n) && !localCheckoutFor(n));
|
|
97
97
|
if (pinnedOnly.length) note(`${pinnedOnly.length} pinned project(s) with no checkout here (${pinnedOnly.slice(0, 8).join(", ")}${pinnedOnly.length > 8 ? ", …" : ""}) — fine when they live on another machine`);
|
|
98
98
|
if (!orphans) ok("every orchestrated project still has its checkout");
|
|
99
99
|
}
|
package/bin/helper.mjs
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// #14264: helpers share the crew pane registry so the desktop can attach to their live output.
|
|
3
|
+
import { mkdirSync } 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 { spawnSync } from "node:child_process";
|
|
8
|
+
import { commandExists, formatCommand } from "./crew/core.mjs";
|
|
9
|
+
import { closePane, createWorkspace, herdrCall, paneAlive, reportAgent, splitPane, workspaceList, workspacePane } from "./crew/herdr.mjs";
|
|
10
|
+
import { dropState, readRows, recordState } from "./crew/state.mjs";
|
|
11
|
+
import { herdrReportArgs } from "../lib/herdr-integration.mjs";
|
|
12
|
+
|
|
13
|
+
const USAGE = "usage: trantor helper run --project <name> --label <label> [--cwd <dir>] -- <command...> | list --project <name> | stop <pane>";
|
|
14
|
+
|
|
15
|
+
function parse(args) {
|
|
16
|
+
const [action, ...rest] = args;
|
|
17
|
+
const options = { action, project: "", label: "", cwd: process.cwd(), command: [], pane: "", json: false };
|
|
18
|
+
for (let i = 0; i < rest.length; i += 1) {
|
|
19
|
+
const arg = rest[i];
|
|
20
|
+
if (arg === "--" && action === "run") { options.command = rest.slice(i + 1); break; }
|
|
21
|
+
if (arg === "--json") { options.json = true; continue; }
|
|
22
|
+
if (["--project", "--label", "--cwd"].includes(arg) && rest[i + 1] && !rest[i + 1].startsWith("--")) {
|
|
23
|
+
options[arg.slice(2)] = rest[++i];
|
|
24
|
+
} else if (action === "stop" && !options.pane && !arg.startsWith("-")) options.pane = arg;
|
|
25
|
+
else throw new Error(USAGE);
|
|
26
|
+
}
|
|
27
|
+
if (!["run", "list", "stop"].includes(action)
|
|
28
|
+
|| (action !== "stop" && !options.project.trim())
|
|
29
|
+
|| (action === "run" && (!options.label.trim() || !options.command.length))
|
|
30
|
+
|| (action === "stop" && !options.pane)) throw new Error(USAGE);
|
|
31
|
+
for (const value of [options.project, options.label, options.pane]) {
|
|
32
|
+
if (/[\x00-\x1f\x7f]/.test(value)) throw new Error("Project, label and pane must be single-line text");
|
|
33
|
+
}
|
|
34
|
+
return options;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function helperCommand(pane, command, env) {
|
|
38
|
+
const done = formatCommand("herdr", herdrReportArgs({ pane, agent: "helper", state: "idle" }));
|
|
39
|
+
const script = `"$@"; helper_exit=$?; ${done} >/dev/null 2>&1; printf '\\nhelper finished, exit %s\\n' "$helper_exit"; while :; do sleep 86400; done`;
|
|
40
|
+
const vars = [`PATH=${env.PATH || ""}`];
|
|
41
|
+
if (env.HERDR_SOCKET_PATH) vars.push(`HERDR_SOCKET_PATH=${env.HERDR_SOCKET_PATH}`);
|
|
42
|
+
return formatCommand("env", [...vars, "/bin/sh", "-c", script, "helper", ...command]);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function projectPane(ctx) {
|
|
46
|
+
const tracked = readRows(ctx).filter(row => row.project === ctx.project);
|
|
47
|
+
const workspaces = [...new Set([
|
|
48
|
+
...tracked.filter(row => row.kind === "herdrws").map(row => row.handle).reverse(),
|
|
49
|
+
...workspaceList(ctx).items.filter(w => [w.label, w.name, w.custom_title].includes(`trantor:${ctx.project}`)).map(w => w.workspace_id || w.id),
|
|
50
|
+
].filter(Boolean))];
|
|
51
|
+
for (const workspace of workspaces) {
|
|
52
|
+
const pane = workspacePane(ctx, workspace, ctx.dir);
|
|
53
|
+
if (!pane) continue;
|
|
54
|
+
recordState(ctx, ctx.project, "herdrws", "__ws__", workspace);
|
|
55
|
+
return pane;
|
|
56
|
+
}
|
|
57
|
+
// #14264: an orchestrator can be tracked before a workspace row is recorded.
|
|
58
|
+
for (const row of tracked.filter(r => ["orch", "herdr", "helper"].includes(r.kind)).reverse()) {
|
|
59
|
+
if (paneAlive(ctx, row.handle)) return row.handle;
|
|
60
|
+
}
|
|
61
|
+
const created = createWorkspace(ctx, ctx.dir, `trantor:${ctx.project}`);
|
|
62
|
+
recordState(ctx, ctx.project, "herdrws", "__ws__", created.workspace);
|
|
63
|
+
return created.pane;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function requireCall(ctx, args) {
|
|
67
|
+
const r = herdrCall(ctx, args);
|
|
68
|
+
if (!r.ok) throw new Error(`herdr ${args.slice(0, 2).join(" ")} failed: ${r.stderr || r.stdout || r.status}`);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function main(args = process.argv.slice(2), env = process.env) {
|
|
72
|
+
const opts = parse(args);
|
|
73
|
+
const ctx = {
|
|
74
|
+
env, project: opts.project, dir: resolve(opts.cwd), dry: false,
|
|
75
|
+
statePath: join(env.AGENT_BUS_DIR || join(env.HOME || homedir(), ".agent-bus"), "crew-windows.txt"),
|
|
76
|
+
have: { herdr: commandExists("herdr", env) },
|
|
77
|
+
};
|
|
78
|
+
if (!ctx.have.herdr) {
|
|
79
|
+
console.error("Helpers need herdr to show in the app. Running commands in this terminal.");
|
|
80
|
+
if (opts.action !== "run") return opts.action === "list" ? 0 : 1;
|
|
81
|
+
const result = spawnSync(opts.command[0], opts.command.slice(1), { cwd: ctx.dir, env, stdio: "inherit" });
|
|
82
|
+
if (result.error) console.error(result.error.message);
|
|
83
|
+
return result.status ?? 1;
|
|
84
|
+
}
|
|
85
|
+
mkdirSync(dirname(ctx.statePath), { recursive: true });
|
|
86
|
+
if (opts.action === "list") {
|
|
87
|
+
for (const row of readRows(ctx).filter(r => r.project === opts.project && r.kind === "helper")) {
|
|
88
|
+
if (paneAlive(ctx, row.handle)) console.log(`${row.handle}\t${row.persona}`);
|
|
89
|
+
else dropState(ctx, row.project, "helper", "", row.handle);
|
|
90
|
+
}
|
|
91
|
+
return 0;
|
|
92
|
+
}
|
|
93
|
+
if (opts.action === "stop") {
|
|
94
|
+
const rows = readRows(ctx).filter(r => r.kind === "helper" && r.handle === opts.pane);
|
|
95
|
+
if (!rows.length) throw new Error(`No tracked helper at ${opts.pane}`);
|
|
96
|
+
if (!closePane(ctx, opts.pane) && paneAlive(ctx, opts.pane)) throw new Error(`Could not stop helper ${opts.pane}`);
|
|
97
|
+
for (const row of rows) dropState(ctx, row.project, "helper", "", row.handle);
|
|
98
|
+
if (opts.json) console.log(JSON.stringify({ ok: true }));
|
|
99
|
+
return 0;
|
|
100
|
+
}
|
|
101
|
+
const pane = splitPane(ctx, projectPane(ctx), "right", ctx.dir);
|
|
102
|
+
if (!pane) throw new Error("herdr returned no helper pane");
|
|
103
|
+
try {
|
|
104
|
+
requireCall(ctx, ["pane", "rename", pane, opts.label]);
|
|
105
|
+
reportAgent(ctx, pane, "helper");
|
|
106
|
+
recordState(ctx, ctx.project, "helper", opts.label, pane, { agent: "helper" });
|
|
107
|
+
requireCall(ctx, ["pane", "run", pane, helperCommand(pane, opts.command, env)]);
|
|
108
|
+
} catch (error) {
|
|
109
|
+
if (closePane(ctx, pane)) dropState(ctx, ctx.project, "helper", "", pane);
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
console.log(pane);
|
|
113
|
+
return 0;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
117
|
+
try { process.exitCode = main(); }
|
|
118
|
+
catch (error) { console.error(`trantor helper: ${error.message}`); process.exitCode = 1; }
|
|
119
|
+
}
|
package/bin/new.mjs
CHANGED
|
@@ -22,7 +22,7 @@ import { fileURLToPath } from "node:url";
|
|
|
22
22
|
import { ensureEnrolled as enrollTofu, loadIdentity, signedPost } from "../hooks/lib/api.mjs";
|
|
23
23
|
import { ensureEnrolled as enrollViaOwnerInvite } from "../lib/enroll.mjs";
|
|
24
24
|
import { setAutonomy } from "../lib/autonomy.mjs";
|
|
25
|
-
import { resolveHub, setProjectHub, writeProjectId, isProjectId } from "../lib/project.mjs";
|
|
25
|
+
import { resolveHub, setProjectHub, writeProjectId, isProjectId, devRootFor } from "../lib/project.mjs";
|
|
26
26
|
|
|
27
27
|
const ROOT = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
28
28
|
|
|
@@ -71,7 +71,7 @@ if (briefFile) {
|
|
|
71
71
|
const dirArg = flag("dir");
|
|
72
72
|
const devRoot = dirArg
|
|
73
73
|
? resolve(dirArg)
|
|
74
|
-
:
|
|
74
|
+
: resolve(devRootFor());
|
|
75
75
|
if (dirArg && !isAbsolute(dirArg)) { /* relative --dir is allowed; resolved above */ }
|
|
76
76
|
const dir = isAbsolute(name) ? name : join(devRoot, name);
|
|
77
77
|
|
package/bin/seats.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import { existsSync, writeFileSync, unlinkSync } from "node:fs";
|
|
|
6
6
|
import { join, resolve } from "node:path";
|
|
7
7
|
import { homedir } from "node:os";
|
|
8
8
|
import { execFileSync } from "node:child_process";
|
|
9
|
+
import { devRootFor } from "../lib/project.mjs";
|
|
9
10
|
import {
|
|
10
11
|
readSeats, declareSeat, undeclareSeat, seatStatus,
|
|
11
12
|
launchSeat, suggestSeats, projectForDir, waitForHerdr,
|
|
@@ -25,7 +26,7 @@ function printStatus() {
|
|
|
25
26
|
if (!rows.length) {
|
|
26
27
|
console.log("No seats declared yet.");
|
|
27
28
|
console.log(`Declare the one you are standing in: ${O}trantor seats add ${projectForDir(process.cwd())}${R}`);
|
|
28
|
-
console.log(`…or adopt every pinned project under a workspace: ${O}trantor seats adopt
|
|
29
|
+
console.log(`…or adopt every pinned project under a workspace: ${O}trantor seats adopt ${devRootFor()}${R}`);
|
|
29
30
|
return 0;
|
|
30
31
|
}
|
|
31
32
|
const w = Math.max(...rows.map(r => r.project.length), 7);
|
|
@@ -114,7 +115,7 @@ switch (sub) {
|
|
|
114
115
|
}
|
|
115
116
|
|
|
116
117
|
case "adopt": {
|
|
117
|
-
const workspace = resolve(rest[0] ||
|
|
118
|
+
const workspace = resolve(rest[0] || devRootFor());
|
|
118
119
|
const found = suggestSeats(workspace);
|
|
119
120
|
if (!found.length) { console.log(`nothing to adopt under ${workspace} (every pinned project is already declared, or has no directory there)`); break; }
|
|
120
121
|
console.log(`Found ${found.length} pinned project(s) with a directory under ${workspace}:`);
|
package/bin/slop-gate.mjs
CHANGED
|
@@ -60,7 +60,7 @@ if (SURFACE) {
|
|
|
60
60
|
} else if (ALL) {
|
|
61
61
|
files = walk(".", []);
|
|
62
62
|
} else {
|
|
63
|
-
const changed = sh("git diff --name-only HEAD");
|
|
63
|
+
const changed = sh("git diff --name-only --diff-filter=d HEAD"); // a deleted file has nothing left to read
|
|
64
64
|
const untracked = sh("git ls-files --others --exclude-standard");
|
|
65
65
|
files = [...new Set([...changed.split("\n"), ...untracked.split("\n")])].filter(f => f && COMMENTABLE.test(f));
|
|
66
66
|
if (!files.length) { console.log("slop-gate: no lintable changes — pass."); process.exit(0); }
|
package/bin/takeover.mjs
CHANGED
|
@@ -16,7 +16,7 @@ import { join, dirname } from "node:path";
|
|
|
16
16
|
import { homedir } from "node:os";
|
|
17
17
|
import { fileURLToPath } from "node:url";
|
|
18
18
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
19
|
-
import { resolveProject, checkoutFor, devRootFor } from "../lib/project.mjs";
|
|
19
|
+
import { resolveProject, checkoutFor, localCheckoutFor, devRootFor } from "../lib/project.mjs";
|
|
20
20
|
|
|
21
21
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
22
22
|
const args = process.argv.slice(2);
|
|
@@ -103,7 +103,7 @@ if (process.argv[1] && _bn(process.argv[1]) === "takeover.mjs") {
|
|
|
103
103
|
const project = args.find(a => !a.startsWith("--") && args[args.indexOf(a) - 1] !== "--session")
|
|
104
104
|
|| resolveProject(process.cwd());
|
|
105
105
|
// By the project's id, so a renamed directory still answers (#6724).
|
|
106
|
-
const dir =
|
|
106
|
+
const dir = localCheckoutFor(project);
|
|
107
107
|
if (!dir) { say(`no local checkout for ${project} (looked in ${devRootFor()})`); out(false, { reason: "no-checkout" }); }
|
|
108
108
|
const d = decide({ terminalPids: terminalClaudePids(dir, project), candidates: recentCandidates(dir), sessionFlag: opt("--session"), force: flag("--force") });
|
|
109
109
|
if (flag("--dry-run")) { say(`dry-run: ${d.action}${d.reason ? ` — ${d.reason}` : ""}${d.sid ? ` (sid ${d.sid}, pid ${d.pid})` : ""}`); out(true, { decision: d }); }
|
package/bin/turn-watchdog.mjs
CHANGED
|
@@ -141,7 +141,8 @@ if (stallFile) {
|
|
|
141
141
|
reportLiveness(now, Math.max(tr, cli));
|
|
142
142
|
if (heavyWait.waiting) { lastErrAt = now; continue; }
|
|
143
143
|
if (tr > freshCut || cli > freshCut || wk > freshCut || now - lastErrAt < windowMs) { // producing work: alive
|
|
144
|
-
|
|
144
|
+
// #14235: re-read the stamp just before extending, so a turn that ended during this pass is not extended and announced after the runner counted.
|
|
145
|
+
if (box && extensions < Number(box.extensionsMax) && now + poll + SLACK >= deadline && (() => { const t = readStamp(); return t && t.turn === armed.turn; })()) {
|
|
145
146
|
extensions++;
|
|
146
147
|
deadline += Number(box.extendMs);
|
|
147
148
|
try { writeFileSync(box.deadlineFile, String(Math.floor(deadline / 1000))); } catch {}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Sourced by setup.sh. Prints the node binary to bake into the launchd plist.
|
|
3
|
+
# A Node manager path (nvm, fnm, volta) changes when the user switches versions and would leave the hub
|
|
4
|
+
# service pointing at a missing binary, so a system install wins when one exists.
|
|
5
|
+
# TRANTOR_NODE_CANDIDATES (space separated) overrides the system locations, for tests.
|
|
6
|
+
pick_node() {
|
|
7
|
+
local cur c
|
|
8
|
+
cur="$(command -v node)"
|
|
9
|
+
for c in ${TRANTOR_NODE_CANDIDATES:-/opt/homebrew/bin/node /usr/local/bin/node}; do
|
|
10
|
+
if [ -x "$c" ]; then echo "$c"; return 0; fi
|
|
11
|
+
done
|
|
12
|
+
[ -n "$cur" ] && echo "$cur"
|
|
13
|
+
case "$cur" in
|
|
14
|
+
*"/.nvm/"*|*"/.fnm/"*|*"/fnm_multishells/"*|*"/.volta/"*|*"/.asdf/"*|*"/.local/share/mise/"*)
|
|
15
|
+
echo "warning: node is at $cur, a Node manager path that changes when you switch versions; install Node system-wide (brew install node) and re-run trantor setup if the hub stops starting" >&2;;
|
|
16
|
+
esac
|
|
17
|
+
return 0
|
|
18
|
+
}
|
package/deploy/setup.sh
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
# trantor one-shot setup: hub service + config + CLI wiring + doctor.
|
|
3
3
|
set -e
|
|
4
4
|
REPO="$(cd "$(dirname "$0")/.." && pwd)"
|
|
5
|
-
|
|
5
|
+
. "$REPO/deploy/node-path.sh"
|
|
6
|
+
NODE="$(pick_node)"
|
|
6
7
|
[ -z "$NODE" ] && { echo "node >= 18 required"; exit 1; }
|
|
7
8
|
mkdir -p "$HOME/.agent-bus"
|
|
8
9
|
[ -f "$HOME/.agent-bus/config.json" ] || echo '{"url":"http://127.0.0.1:4477"}' > "$HOME/.agent-bus/config.json"
|
|
@@ -11,8 +12,15 @@ if [ "$(uname)" = "Darwin" ]; then
|
|
|
11
12
|
PL="$HOME/Library/LaunchAgents/com.trantor.hub.plist"
|
|
12
13
|
sed -e "s|__NODE__|$NODE|" -e "s|__REPO__|$REPO|" "$REPO/deploy/com.trantor.hub.plist" > "$PL"
|
|
13
14
|
launchctl bootout "gui/$(id -u)/com.trantor.hub" 2>/dev/null || true
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
# bootstrap can fail when the label is still loading or already loaded; retry once, then carry on
|
|
16
|
+
# (the rest of setup must not abort under set -e).
|
|
17
|
+
if ! launchctl bootstrap "gui/$(id -u)" "$PL" 2>/dev/null; then
|
|
18
|
+
sleep 1
|
|
19
|
+
launchctl bootout "gui/$(id -u)/com.trantor.hub" 2>/dev/null || true
|
|
20
|
+
launchctl bootstrap "gui/$(id -u)" "$PL" 2>/dev/null \
|
|
21
|
+
|| echo " (launchd did not load the hub service; start it with: trantor hub — setup continues)"
|
|
22
|
+
fi
|
|
23
|
+
echo "✓ hub service installed (starts at login, restarts on crash)"
|
|
16
24
|
else
|
|
17
25
|
echo "Linux: run the hub under systemd/tmux: RELAY_PORT=4477 node $REPO/hub.mjs"
|
|
18
26
|
fi
|
package/engine/bin/scrooge
CHANGED
|
@@ -86,6 +86,15 @@ def load_env_fallback():
|
|
|
86
86
|
_load_env_file(ENV_FALLBACK)
|
|
87
87
|
|
|
88
88
|
def load_registry():
|
|
89
|
+
# A fresh machine has no ~/.token-scrooge/registry.json until `trantor setup`/install.sh runs: seed it
|
|
90
|
+
# from the template shipped next to this script instead of dying with a traceback (#14322).
|
|
91
|
+
if not os.path.exists(REGISTRY):
|
|
92
|
+
tpl = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "registry.template.json")
|
|
93
|
+
if os.path.exists(tpl):
|
|
94
|
+
os.makedirs(SCROOGE_DIR, exist_ok=True)
|
|
95
|
+
shutil.copyfile(tpl, REGISTRY)
|
|
96
|
+
shutil.copyfile(tpl, os.path.join(SCROOGE_DIR, "registry.template.json"))
|
|
97
|
+
sys.stderr.write("[scrooge] seeded %s from the bundled template\n" % REGISTRY)
|
|
89
98
|
with open(REGISTRY) as fh:
|
|
90
99
|
return json.load(fh)
|
|
91
100
|
|