trantor 0.18.132 → 0.18.133
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/plugin.json +1 -1
- package/bin/baton-pane.mjs +22 -4
- package/bin/cli.mjs +2 -0
- package/bin/crew/herdr.mjs +27 -12
- package/bin/crew/open.mjs +4 -1
- package/bin/crew/restore.mjs +88 -0
- package/bin/crew.mjs +7 -3
- package/hub/routes/session.mjs +9 -2
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trantor",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.133",
|
|
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/baton-pane.mjs
CHANGED
|
@@ -112,6 +112,20 @@ function summary(value, limit = 240) {
|
|
|
112
112
|
return oneLine.length > limit ? `${oneLine.slice(0, limit - 1)}…` : oneLine;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
/** #13913: herdr's own answer is the delivery receipt — text plus Enter are sent before herdr
|
|
116
|
+
* reports anything, so this only names what became of the kickoff. `timeout` is the busy
|
|
117
|
+
* successor (words are in, not picked up yet), never a failure to resend. */
|
|
118
|
+
export function kickoffVerdict(raw) {
|
|
119
|
+
let response;
|
|
120
|
+
try { response = JSON.parse(String(raw)); } catch { return "unreadable_response"; }
|
|
121
|
+
if (response?.result?.type === "agent_prompted") return "agent_prompted";
|
|
122
|
+
if (response?.error) {
|
|
123
|
+
const code = String(response.error.code || "herdr error");
|
|
124
|
+
return code === "timeout" ? "sent, not yet picked up" : `${code} (${summary(response.error.message)})`;
|
|
125
|
+
}
|
|
126
|
+
return "unexpected_response";
|
|
127
|
+
}
|
|
128
|
+
|
|
115
129
|
async function main() {
|
|
116
130
|
if (!handoffFile || !existsSync(handoffFile)) { log(`no handoff file (${handoffFile}) — abort`); process.exit(1); }
|
|
117
131
|
const pane = arg("--pane") || orchPane((() => { try { return readFileSync(join(busDir, "crew-windows.txt"), "utf8"); } catch { return ""; } })(), projectName);
|
|
@@ -168,10 +182,14 @@ async function main() {
|
|
|
168
182
|
await sleep(3000);
|
|
169
183
|
}
|
|
170
184
|
try {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
185
|
+
// #13913: the same bounded pickup wait the app uses — herdr sends the text and Enter, then
|
|
186
|
+
// holds the answer until the successor shows working/blocked activity (10s budget, well
|
|
187
|
+
// inside this socket's own 30s read timeout).
|
|
188
|
+
const raw = await socketRequest({
|
|
189
|
+
id: "trantor:agent.prompt", method: "agent.prompt",
|
|
190
|
+
params: { target: pane, text: KICKOFF_PROMPT, wait: { until: ["working", "blocked"], timeout_ms: 10_000 } },
|
|
191
|
+
});
|
|
192
|
+
log(`kickoff result: ${kickoffVerdict(raw)}`);
|
|
175
193
|
} catch (e) {
|
|
176
194
|
log(`kickoff FAILED (${String(e?.message).slice(0, 120)}) — successor may sit idle until spoken to`);
|
|
177
195
|
}
|
package/bin/cli.mjs
CHANGED
|
@@ -43,6 +43,7 @@ switch (cmd) {
|
|
|
43
43
|
case "down": runCrew(); break;
|
|
44
44
|
case "swap": runCrew(); break;
|
|
45
45
|
case "prune": runCrew(); break;
|
|
46
|
+
case "restore": runCrew(); break;
|
|
46
47
|
case "hub": {
|
|
47
48
|
const sub = args[0];
|
|
48
49
|
if (sub === "timeouts") { args.splice(0, 1); run("bin/hub-timeouts.mjs", process.execPath); break; }
|
|
@@ -259,6 +260,7 @@ switch (cmd) {
|
|
|
259
260
|
trantor sync realign a seat branch with main from the receipts: sync [<seat>] [--dry-run] — refuses and names unharvested commits
|
|
260
261
|
trantor down tear the crew down (kills processes, closes windows, no dialogs)
|
|
261
262
|
trantor prune drop dead crew-window tracking rows (ghost workspaces/panes) without spawning anything
|
|
263
|
+
trantor restore after a reboot, reopen only the orchestrators you opted in: restore [--dry-run] · restore enable|disable <project>
|
|
262
264
|
trantor ui open the live dashboard (board + flow views)
|
|
263
265
|
trantor pair pair a phone: mint a trantor://enroll link for the companion app — [--role owner] [--sim] [--json]
|
|
264
266
|
trantor app the DESKTOP app: status | install | update — pulls the latest DMG from GitHub Releases
|
package/bin/crew/herdr.mjs
CHANGED
|
@@ -6,6 +6,15 @@ export function herdrCall(ctx, args) {
|
|
|
6
6
|
return call("herdr", args, { env: ctx.env });
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
function requireHerdr(ctx, args, execute = herdrCall) {
|
|
10
|
+
const result = execute(ctx, args);
|
|
11
|
+
if (result.ok === false) {
|
|
12
|
+
const detail = result.stderr || result.stdout || "no error output";
|
|
13
|
+
throw new Error(`${formatCommand("herdr", args)} exited ${result.status}: ${detail}`);
|
|
14
|
+
}
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
|
|
9
18
|
export function workspaceList(ctx) {
|
|
10
19
|
if (!ctx.have.herdr) return { proven: false, ids: new Set(), names: new Set(), items: [] };
|
|
11
20
|
const result = herdrCall(ctx, ["workspace", "list"]);
|
|
@@ -21,12 +30,12 @@ export function workspaceList(ctx) {
|
|
|
21
30
|
}
|
|
22
31
|
|
|
23
32
|
export function createWorkspace(ctx, cwd, label) {
|
|
24
|
-
const parsed = parseJsonOutput(
|
|
33
|
+
const parsed = parseJsonOutput(requireHerdr(ctx, ["workspace", "create", "--cwd", cwd, "--label", label, "--no-focus"]).stdout);
|
|
25
34
|
const result = parsed?.result || {};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
35
|
+
const workspace = result.workspace?.workspace_id || "";
|
|
36
|
+
const pane = result.root_pane?.pane_id || "";
|
|
37
|
+
if (!workspace || !pane) throw new Error("herdr workspace create returned no usable workspace and root pane");
|
|
38
|
+
return { workspace, pane };
|
|
30
39
|
}
|
|
31
40
|
|
|
32
41
|
export function splitPane(ctx, pane, direction, cwd = "", execute = herdrCall) {
|
|
@@ -34,7 +43,7 @@ export function splitPane(ctx, pane, direction, cwd = "", execute = herdrCall) {
|
|
|
34
43
|
if (pane) args.push(pane);
|
|
35
44
|
args.push("--direction", direction, "--no-focus");
|
|
36
45
|
if (cwd) args.push("--cwd", cwd);
|
|
37
|
-
const parsed = parseJsonOutput(
|
|
46
|
+
const parsed = parseJsonOutput(requireHerdr(ctx, args, execute).stdout);
|
|
38
47
|
return parsed?.result?.pane?.pane_id || "";
|
|
39
48
|
}
|
|
40
49
|
|
|
@@ -43,9 +52,14 @@ export function splitPane(ctx, pane, direction, cwd = "", execute = herdrCall) {
|
|
|
43
52
|
// is a layout question; process-info is the terminal question, and only a terminal hosts a session.
|
|
44
53
|
export function paneAlive(ctx, pane) {
|
|
45
54
|
if (!pane) return false;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
55
|
+
return paneReadAlive(ctx, pane);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Herdr can retain a layout row after its terminal has vanished. A readable pane is the
|
|
59
|
+
// authoritative liveness signal shared by CLI callers; process-info can report stale metadata.
|
|
60
|
+
export function paneReadAlive(ctx, pane) {
|
|
61
|
+
if (!pane) return false;
|
|
62
|
+
return herdrCall(ctx, ["pane", "read", pane, "--source", "recent-unwrapped"]).ok;
|
|
49
63
|
}
|
|
50
64
|
|
|
51
65
|
export function workspacePane(ctx, workspace, preferredCwd) {
|
|
@@ -103,9 +117,10 @@ export function reportAgent(ctx, pane, agent, { sessionId = "", resumeArgv = []
|
|
|
103
117
|
}
|
|
104
118
|
|
|
105
119
|
function runSeat(ctx, pane, agent, command) {
|
|
106
|
-
if (
|
|
107
|
-
|
|
108
|
-
|
|
120
|
+
if (ctx.dry) return;
|
|
121
|
+
if (!pane) throw new Error(`herdr created no pane for ${agent}; the seat runner was not started`);
|
|
122
|
+
requireHerdr(ctx, ["pane", "rename", pane, `${agent} · ${ctx.project}`]);
|
|
123
|
+
requireHerdr(ctx, ["pane", "run", pane, command]);
|
|
109
124
|
}
|
|
110
125
|
|
|
111
126
|
function trackedWorkspace(ctx) {
|
package/bin/crew/open.mjs
CHANGED
|
@@ -169,7 +169,10 @@ function reattach(ctx, workspace, pane, id) {
|
|
|
169
169
|
if (!started.ok) throw new Error(`trantor open: could not start the orchestrator in pane ${pane}`);
|
|
170
170
|
reportOrchestrator(ctx, pane, id);
|
|
171
171
|
console.error(`— orchestrator pane was empty: resumed session ${id} in herdr:${workspace || "?"}/${pane} —`);
|
|
172
|
-
} else
|
|
172
|
+
} else {
|
|
173
|
+
reportOrchestrator(ctx, pane, id);
|
|
174
|
+
console.error(`— orchestrator already hosted: reattached to herdr:${workspace || "?"}/${pane} —`);
|
|
175
|
+
}
|
|
173
176
|
console.log(`herdr:${workspace || "?"}/${pane}`);
|
|
174
177
|
return true;
|
|
175
178
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { readFileSync, existsSync, writeFileSync, renameSync, mkdirSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { call, parseJsonOutput } from "./core.mjs";
|
|
4
|
+
import { paneAlive, paneHasAgent, herdrCall } from "./herdr.mjs";
|
|
5
|
+
import { readRows } from "./state.mjs";
|
|
6
|
+
|
|
7
|
+
function config(ctx) {
|
|
8
|
+
try { return JSON.parse(readFileSync(join(ctx.home, ".agent-bus", "config.json"), "utf8")); }
|
|
9
|
+
catch { return {}; }
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function sessionIds(ctx, rows, agents) {
|
|
13
|
+
const result = new Map();
|
|
14
|
+
const file = join(ctx.home, ".agent-bus", "orch-sessions.txt");
|
|
15
|
+
if (!existsSync(file)) return result;
|
|
16
|
+
for (const line of readFileSync(file, "utf8").split("\n")) {
|
|
17
|
+
const [project, id] = line.split("\t");
|
|
18
|
+
if (project && id) result.set(project, id);
|
|
19
|
+
}
|
|
20
|
+
const paneProject = new Map(rows.filter(row => row.kind === "orch").map(row => [row.handle, row.project]));
|
|
21
|
+
for (const agent of agents) {
|
|
22
|
+
const project = paneProject.get(agent.pane_id);
|
|
23
|
+
const nativeId = agent.agent_session?.value;
|
|
24
|
+
if (project && nativeId) result.set(project, nativeId);
|
|
25
|
+
}
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function restoreCandidates({ rows, configured, frozen = [], dismissed = [], sessions = new Map(), live = new Set() }) {
|
|
30
|
+
const projects = [...new Set(rows.filter(row => row.kind === "orch").map(row => row.project))];
|
|
31
|
+
return projects.filter(project => configured.includes(project)
|
|
32
|
+
&& !frozen.includes(project)
|
|
33
|
+
&& !live.has(project)
|
|
34
|
+
&& !dismissed.some(item => item.project === project && item.sessionId === sessions.get(project)));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function dismissedSessions(ctx) {
|
|
38
|
+
try {
|
|
39
|
+
const value = JSON.parse(readFileSync(join(ctx.home, ".agent-bus", "config.json"), "utf8"));
|
|
40
|
+
return Array.isArray(value.dismissedSessions) ? value.dismissedSessions : [];
|
|
41
|
+
} catch { return []; }
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export async function restoreOrchestrators(ctx, args = []) {
|
|
45
|
+
if (args[0] === "enable" || args[0] === "disable") {
|
|
46
|
+
const [action, project, extra] = args;
|
|
47
|
+
if (!project || extra) throw new Error("usage: trantor restore enable|disable <project>");
|
|
48
|
+
const cfg = config(ctx);
|
|
49
|
+
const set = new Set(Array.isArray(cfg.resumeOnRestore) ? cfg.resumeOnRestore : []);
|
|
50
|
+
if (action === "enable") set.add(project); else set.delete(project);
|
|
51
|
+
cfg.resumeOnRestore = [...set].sort();
|
|
52
|
+
const file = join(ctx.home, ".agent-bus", "config.json");
|
|
53
|
+
mkdirSync(join(ctx.home, ".agent-bus"), { recursive: true });
|
|
54
|
+
const tmp = `${file}.tmp`;
|
|
55
|
+
writeFileSync(tmp, `${JSON.stringify(cfg, null, 2)}\n`);
|
|
56
|
+
renameSync(tmp, file);
|
|
57
|
+
console.log(`${project} ${action}d for Trantor restore`);
|
|
58
|
+
return 0;
|
|
59
|
+
}
|
|
60
|
+
const unknown = args.filter(arg => arg !== "--dry-run");
|
|
61
|
+
if (unknown.length) throw new Error("usage: trantor restore [--dry-run]");
|
|
62
|
+
if (args.includes("--dry-run")) ctx.dry = true;
|
|
63
|
+
if (!ctx.have.herdr) throw new Error("trantor restore needs herdr");
|
|
64
|
+
const cfg = config(ctx);
|
|
65
|
+
const configured = Array.isArray(cfg.resumeOnRestore) ? cfg.resumeOnRestore : [];
|
|
66
|
+
const frozen = Array.isArray(cfg.frozenProjects) ? cfg.frozenProjects : [];
|
|
67
|
+
const rows = readRows(ctx);
|
|
68
|
+
const parsed = parseJsonOutput(herdrCall(ctx, ["agent", "list"]).stdout);
|
|
69
|
+
const agents = parsed?.result?.agents || parsed?.agents || [];
|
|
70
|
+
const sessions = sessionIds(ctx, rows, agents);
|
|
71
|
+
const livePanes = new Set(agents.map(agent => agent.pane_id).filter(Boolean));
|
|
72
|
+
const live = new Set(rows.filter(row => row.kind === "orch" && livePanes.has(row.handle) && paneAlive(ctx, row.handle) && paneHasAgent(ctx, row.handle)).map(row => row.project));
|
|
73
|
+
const selected = restoreCandidates({ rows, configured, frozen, dismissed: dismissedSessions(ctx), sessions, live });
|
|
74
|
+
if (!selected.length) {
|
|
75
|
+
console.log("no configured interrupted orchestrators to restore (use trantor restore enable <project>)");
|
|
76
|
+
return 0;
|
|
77
|
+
}
|
|
78
|
+
for (const project of selected) {
|
|
79
|
+
if (ctx.dry) console.log(`would restore ${project}`);
|
|
80
|
+
else {
|
|
81
|
+
const result = call(process.execPath, [join(ctx.root, "bin/crew.mjs"), "open", project], { env: ctx.env });
|
|
82
|
+
if (!result.ok) throw new Error(`trantor restore: ${project} failed: ${result.stderr || result.stdout}`);
|
|
83
|
+
console.log(`restored ${project}`);
|
|
84
|
+
}
|
|
85
|
+
if (!ctx.dry) await new Promise(resolve => setTimeout(resolve, 1000));
|
|
86
|
+
}
|
|
87
|
+
return 0;
|
|
88
|
+
}
|
package/bin/crew.mjs
CHANGED
|
@@ -7,6 +7,7 @@ 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";
|
|
9
9
|
import { openOrchestrator } from "./crew/open.mjs";
|
|
10
|
+
import { restoreOrchestrators } from "./crew/restore.mjs";
|
|
10
11
|
import { performSwap, swapOptions, swapRuntime } from "./crew/swap.mjs";
|
|
11
12
|
import { redactKeys } from "../lib/redact.mjs";
|
|
12
13
|
import { reapSeat, down, prune, readRows } from "./crew/state.mjs";
|
|
@@ -39,7 +40,7 @@ const adapters = {
|
|
|
39
40
|
};
|
|
40
41
|
|
|
41
42
|
function usage() {
|
|
42
|
-
console.log("usage: crew.mjs up <agent...> | crew.mjs open [<project>] | crew.mjs swap <old> <new[:provider[/model]]> | crew.mjs down [<agent>...] [--all --yes] | crew.mjs prune");
|
|
43
|
+
console.log("usage: crew.mjs up <agent...> | crew.mjs open [<project>] | crew.mjs restore [--dry-run] | crew.mjs swap <old> <new[:provider[/model]]> | crew.mjs down [<agent>...] [--all --yes] | crew.mjs prune");
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
function parseUpArgs(args) {
|
|
@@ -150,6 +151,7 @@ try {
|
|
|
150
151
|
if (command === "down") code = await down(ctx, rawArgs, adapters);
|
|
151
152
|
else if (command === "prune") { prune(ctx, adapters); console.log(`— pruned dead crew rows (${ctx.statePath}) —`); }
|
|
152
153
|
else if (command === "open") code = openOrchestrator(ctx, rawArgs);
|
|
154
|
+
else if (command === "restore") code = await restoreOrchestrators(ctx, rawArgs);
|
|
153
155
|
else if (command === "swap") { result = await swap(rawArgs); code = result.ok ? 0 : 1; }
|
|
154
156
|
else if (command === "up") code = guardCrossProjectUp(ctx) ? await runUp(rawArgs) : 1;
|
|
155
157
|
else { usage(); code = 1; }
|
|
@@ -160,7 +162,9 @@ try {
|
|
|
160
162
|
if (!result) result = jsonResult(code);
|
|
161
163
|
if (!result.ok && !result.reason) result.reason = diagnostics.at(-1) || `${command} failed; see stderr`;
|
|
162
164
|
if (result.reason) result.reason = redactKeys(result.reason);
|
|
163
|
-
if (jsonMode)
|
|
164
|
-
|
|
165
|
+
if (jsonMode) {
|
|
166
|
+
if (!result.ok && result.reason) console.error(result.reason);
|
|
167
|
+
output(JSON.stringify(result));
|
|
168
|
+
} else if (result.reason) console.error(result.reason);
|
|
165
169
|
else if (command === "swap") console.log(`— swapped ${result.seat} → ${result.to}; moved contracts: ${result.moved.join(", ") || "none"} —`);
|
|
166
170
|
process.exit(code);
|
package/hub/routes/session.mjs
CHANGED
|
@@ -17,7 +17,7 @@ const CLAIM_TTL_MS = 300000;
|
|
|
17
17
|
const PROMPT_SWEEP_MS = Number(process.env.RELAY_PROMPT_SWEEP_MS || 30000);
|
|
18
18
|
const EXPIRED_REASON = "No Mac is relaying this project. Is the Trantor app open?";
|
|
19
19
|
const CLAIMED_EXPIRED_REASON = "The Mac claimed this prompt but never delivered it. Try sending it again.";
|
|
20
|
-
const ACK_OUTCOMES = new Set(["delivered", "blocked", "not_ready", "stalled", "no_agent", "stale"]);
|
|
20
|
+
const ACK_OUTCOMES = new Set(["delivered", "sent", "blocked", "not_ready", "stalled", "no_agent", "stale"]);
|
|
21
21
|
const ANSWER_PICKS_MAX = 10;
|
|
22
22
|
const ANSWER_OTHER_MAX = 2000;
|
|
23
23
|
const ANSWER_ENTRIES_MAX = 4; // CC's question limit per ask (#12912)
|
|
@@ -524,8 +524,15 @@ function pruneMachinesHealth() {
|
|
|
524
524
|
if (p.kind === "crew") {
|
|
525
525
|
p.output = stripAnsi(String(b.output || "")).slice(-CREW_OUTPUT_MAX);
|
|
526
526
|
p.status = outcome; // "done" or "failed"
|
|
527
|
+
} else if (outcome === "delivered") {
|
|
528
|
+
p.status = "delivered";
|
|
529
|
+
} else if (outcome === "sent") {
|
|
530
|
+
// #13913: herdr typed the text and Enter but the session has not picked it up. Terminal
|
|
531
|
+
// for claiming (never re-claimed, never re-typed); phones keep it queued until the
|
|
532
|
+
// transcript itself shows the turn.
|
|
533
|
+
p.status = "sent";
|
|
527
534
|
} else {
|
|
528
|
-
p.status =
|
|
535
|
+
p.status = "failed";
|
|
529
536
|
}
|
|
530
537
|
// A terminal row will never be claimed or downloaded again: its bytes go now.
|
|
531
538
|
unlinkAttachments(p);
|