trantor 0.18.155 → 0.18.159
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/crew/open.mjs +6 -2
- package/bin/dispatch.mjs +4 -0
- package/bin/duty.mjs +12 -6
- package/bin/herdr-agent.mjs +18 -9
- package/bin/patrol.mjs +1 -1
- package/bin/policy-draft.mjs +40 -0
- package/hooks/lib/resources.mjs +5 -2
- package/hooks/sessionstart.mjs +21 -1
- package/hub/routes/dispatcher-operations.mjs +7 -0
- package/hub.mjs +3 -10
- package/kimi.plugin.json +1 -1
- package/lib/dispatcher/accounts.mjs +17 -9
- package/lib/dispatcher/evidence-bridge.mjs +20 -20
- package/lib/dispatcher/operations.mjs +76 -41
- package/lib/dispatcher/planner.mjs +15 -9
- package/lib/dispatcher/policy-draft.mjs +158 -0
- package/lib/dispatcher/rollout.mjs +130 -16
- package/lib/dispatcher/schemas.mjs +10 -3
- package/lib/dispatcher/store.mjs +32 -0
- package/lib/herdr-integration.mjs +62 -0
- package/lib/seat-provider.mjs +2 -1
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ import { spawnSync } from "node:child_process";
|
|
|
4
4
|
import { readFileSync, readdirSync, realpathSync, statSync } from "node:fs";
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { createHash } from "node:crypto";
|
|
7
|
+
import { createConnection } from "node:net";
|
|
7
8
|
import { codexRolloutCwd } from "./turn-usage.mjs";
|
|
8
9
|
|
|
9
10
|
export const HERDR_CLAUDE_INSTALL = "herdr integration install claude";
|
|
@@ -37,6 +38,67 @@ const validArgv = (args) => args.length > 0 && args.length <= 64
|
|
|
37
38
|
&& args.every(validArg)
|
|
38
39
|
&& Buffer.byteLength(args.join("\0")) <= 8192;
|
|
39
40
|
|
|
41
|
+
function herdrSocketAttempt(wire, socketPath, timeoutMs) {
|
|
42
|
+
return new Promise(resolve => {
|
|
43
|
+
let done = false, timeout;
|
|
44
|
+
const socket = createConnection(socketPath);
|
|
45
|
+
const finish = delivered => {
|
|
46
|
+
if (done) return;
|
|
47
|
+
done = true;
|
|
48
|
+
clearTimeout(timeout);
|
|
49
|
+
socket.destroy();
|
|
50
|
+
resolve(delivered);
|
|
51
|
+
};
|
|
52
|
+
socket.on("error", () => finish(false));
|
|
53
|
+
socket.on("connect", () => socket.write(wire));
|
|
54
|
+
socket.on("data", () => finish(true));
|
|
55
|
+
socket.on("end", () => finish(false));
|
|
56
|
+
timeout = setTimeout(() => finish(false), timeoutMs);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function herdrRequestWire(request) {
|
|
61
|
+
const seq = request.params.seq;
|
|
62
|
+
const json = JSON.stringify({ ...request, params: { ...request.params, seq: seq.toString() } });
|
|
63
|
+
return `${json.replace(`"seq":"${seq}"`, `"seq":${seq}`)}\n`;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function herdrSocketRequest(request, wire = herdrRequestWire(request)) {
|
|
67
|
+
const socketPath = process.env.HERDR_SOCKET_PATH || "";
|
|
68
|
+
if (!socketPath) return false;
|
|
69
|
+
if (await herdrSocketAttempt(wire, socketPath, 500)) return true;
|
|
70
|
+
return herdrSocketAttempt(wire, socketPath, 1500);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function reportedHerdrSession(pane) {
|
|
74
|
+
try {
|
|
75
|
+
const result = spawnSync("herdr", ["agent", "get", pane], { encoding: "utf8", timeout: 1500 });
|
|
76
|
+
if (result.status !== 0) return "";
|
|
77
|
+
return JSON.parse(result.stdout || "{}")?.result?.agent?.agent_session?.value || "";
|
|
78
|
+
} catch { return ""; }
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const herdrClockWall = BigInt(Date.now()) * 1_000_000n;
|
|
82
|
+
const herdrClockMono = process.hrtime.bigint();
|
|
83
|
+
let herdrReportSeq = 0n;
|
|
84
|
+
function nextHerdrReportSeq() {
|
|
85
|
+
const wall = herdrClockWall + process.hrtime.bigint() - herdrClockMono;
|
|
86
|
+
herdrReportSeq = wall > herdrReportSeq ? wall : herdrReportSeq + 1n;
|
|
87
|
+
return herdrReportSeq;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export async function reportHerdrSessionResume({ pane, sessionId, transcriptPath = "", resumeArgv = [] }, transport = herdrSocketRequest, readSession = reportedHerdrSession) {
|
|
91
|
+
if (!pane || !sessionId || !validArgv(resumeArgv)) return false;
|
|
92
|
+
// #14774: herdr orders reports by time_ns; BigInt keeps the ns integer exact.
|
|
93
|
+
const params = { pane_id: pane, source: "herdr:claude", agent: "claude", seq: nextHerdrReportSeq(),
|
|
94
|
+
agent_session_id: sessionId, session_start_source: "resume", resume_argv: resumeArgv };
|
|
95
|
+
if (transcriptPath) params.agent_session_path = transcriptPath;
|
|
96
|
+
const request = { id: `herdr:claude:${Date.now()}:${Math.random().toString(36).slice(2)}`,
|
|
97
|
+
method: "pane.report_agent_session", params };
|
|
98
|
+
if (!await transport(request, herdrRequestWire(request))) return false;
|
|
99
|
+
return await readSession(pane) === sessionId;
|
|
100
|
+
}
|
|
101
|
+
|
|
40
102
|
export function runnerResumeArgv({ agent, driver = agent, persona = agent, dir, runnerPath, model = "", effort = null, project, hub, sessionId }) {
|
|
41
103
|
if (!sessionId || !RESUMABLE.has(driver)) return [];
|
|
42
104
|
const args = ["node", runnerPath, persona, dir, "--agent", agent, "--persona", persona,
|
package/lib/seat-provider.mjs
CHANGED
|
@@ -19,7 +19,8 @@ export function seatProvider(agent) {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
/** null when label and live model agree; else { label, model, expected, actual } for the refusal. */
|
|
22
|
-
export function providerMismatch(label, model) {
|
|
22
|
+
export function providerMismatch(label, model, modelSource = "") {
|
|
23
|
+
if (modelSource === "cli-default") return null;
|
|
23
24
|
const m = String(model || "");
|
|
24
25
|
const actual = m.split("/")[0];
|
|
25
26
|
if (!actual) return null;
|