trantor 0.18.144 → 0.18.148
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/canary.mjs +55 -15
- package/bin/capacity.mjs +21 -3
- package/bin/cli.mjs +6 -2
- package/bin/connect.mjs +10 -3
- package/bin/crew-runner.mjs +101 -18
- package/bin/disk.mjs +8 -5
- package/bin/dispatch.mjs +78 -0
- package/bin/integrate.mjs +14 -2
- package/bin/review.mjs +35 -0
- package/bin/wake-nudge.mjs +27 -3
- package/configs/dispatcher-policy.json +84 -0
- package/docs/FEATURES.md +25 -12
- package/hooks/sessionstart.mjs +4 -1
- package/hub/routes/capacity.mjs +31 -24
- package/hub/routes/cards.mjs +7 -2
- package/hub/routes/dispatcher.mjs +97 -0
- package/hub/routes/insights.mjs +69 -4
- package/hub/routes/worktree-status.mjs +56 -0
- package/hub.mjs +2 -1
- package/kimi.plugin.json +1 -1
- package/lib/canary/canary.mjs +66 -7
- package/lib/canary/registry.mjs +153 -4
- package/lib/capacity.mjs +113 -18
- package/lib/classify-failure.mjs +14 -8
- package/lib/dispatcher/acceptance.mjs +314 -0
- package/lib/dispatcher/accounts.mjs +442 -0
- package/lib/dispatcher/admission.mjs +719 -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/planner.mjs +516 -0
- package/lib/dispatcher/policy.mjs +50 -0
- package/lib/dispatcher/preflight.mjs +247 -0
- package/lib/dispatcher/resources.mjs +44 -0
- package/lib/dispatcher/schemas.mjs +220 -0
- package/lib/dispatcher/snapshot.mjs +70 -0
- package/lib/dispatcher/spend.mjs +319 -0
- package/lib/dispatcher/store.mjs +316 -0
- package/lib/fitness.mjs +227 -41
- package/lib/launchd.mjs +61 -0
- package/lib/review-gate.mjs +63 -0
- package/lib/seat-liveness.mjs +41 -0
- package/lib/session-liveness.mjs +23 -0
- package/lib/telemetry-ship.mjs +8 -7
- package/lib/turn-usage.mjs +88 -17
- package/lib/worktree-status.mjs +216 -0
- package/mcp.mjs +53 -7
- package/package.json +1 -1
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);
|
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) {
|
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/bin/wake-nudge.mjs
CHANGED
|
@@ -27,6 +27,7 @@ import { ledgerPaths } from "../hooks/lib/inbox-ledger.mjs";
|
|
|
27
27
|
import { dutyEscalations, claimDutyNudges, auditDutyNudges, releaseDutyNudgeClaims } from "../lib/duty-nudges.mjs";
|
|
28
28
|
import { reserveNudgeIds, releaseNudgeIds } from "../lib/nudge-ledger.mjs";
|
|
29
29
|
import { recipientPanes } from "../lib/duty-recipient.mjs";
|
|
30
|
+
import { reloadLaunchAgent } from "../lib/launchd.mjs";
|
|
30
31
|
|
|
31
32
|
const SELF = fileURLToPath(import.meta.url);
|
|
32
33
|
const LABEL = "com.trantor.wake-nudge";
|
|
@@ -272,6 +273,25 @@ export function keepalivePlist({ bus, hub, home = homedir(), script = SELF, path
|
|
|
272
273
|
</dict></plist>\n`;
|
|
273
274
|
}
|
|
274
275
|
|
|
276
|
+
// #14661: a reload whose bootout let a process escape leaves a poller outside launchd — the canary
|
|
277
|
+
// probe reads that orphan as healthy while nothing would ever restart it. Reap wake-nudge run
|
|
278
|
+
// processes the freshly-loaded job does not own; the pattern is THIS script's path (another
|
|
279
|
+
// checkout's daemon is that install's business), and no owned pid yet means the sweep is skipped.
|
|
280
|
+
const SELF_RUN_RE = new RegExp(`${SELF.replaceAll(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\s+run\\b`);
|
|
281
|
+
export function reapStrayWakeNudges(ownedPid, { command = run, kill = (pid) => process.kill(pid, "SIGTERM") } = {}) {
|
|
282
|
+
if (!ownedPid) return [];
|
|
283
|
+
let rows;
|
|
284
|
+
try { rows = processRows(command("ps", ["-axo", "pid=,ppid=,command="])); } catch { return []; }
|
|
285
|
+
const owned = new Set(descendants(ownedPid, rows));
|
|
286
|
+
const reaped = [];
|
|
287
|
+
for (const row of rows) {
|
|
288
|
+
if (row.pid === process.pid || owned.has(row.pid)) continue;
|
|
289
|
+
if (!SELF_RUN_RE.test(row.command)) continue;
|
|
290
|
+
try { kill(row.pid); reaped.push(row.pid); } catch { /* already gone */ }
|
|
291
|
+
}
|
|
292
|
+
return reaped;
|
|
293
|
+
}
|
|
294
|
+
|
|
275
295
|
async function main() {
|
|
276
296
|
const [cmd = "status", ...args] = process.argv.slice(2);
|
|
277
297
|
const hub = fleetHub(args);
|
|
@@ -284,9 +304,13 @@ async function main() {
|
|
|
284
304
|
mkdirSync(bus, { recursive: true });
|
|
285
305
|
mkdirSync(dirname(plist), { recursive: true });
|
|
286
306
|
writeFileSync(plist, keepalivePlist({ bus, hub }), { mode: 0o600 });
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
307
|
+
// #14661: reload the already-registered job instead of betting one bootstrap against the
|
|
308
|
+
// teardown race; a bootstrap that still fails is an error, never a quiet unloaded agent.
|
|
309
|
+
const reloaded = reloadLaunchAgent({ label: LABEL, plist, domain: `gui/${process.getuid()}` });
|
|
310
|
+
if (!reloaded.ok) throw new Error(reloaded.error);
|
|
311
|
+
const reaped = reapStrayWakeNudges(reloaded.pid);
|
|
312
|
+
for (const pid of reaped) console.error(`${LABEL}: reaped stray pid ${pid} that was polling outside launchd`);
|
|
313
|
+
console.log(`${LABEL} installed${reloaded.pid ? ` (pid ${reloaded.pid})` : ""}; polling ${hub}`);
|
|
290
314
|
} else if (cmd === "down") {
|
|
291
315
|
try { run("launchctl", ["bootout", service]); } catch { /* #7429: stop is idempotent. */ }
|
|
292
316
|
rmSync(plist, { force: true });
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"version": "dispatcher-v1-defaults",
|
|
4
|
+
"parentVersion": null,
|
|
5
|
+
"createdAtMs": 0,
|
|
6
|
+
"createdBy": "builtin-defaults",
|
|
7
|
+
"plannerVersion": "dispatcher-v1",
|
|
8
|
+
"modeByProject": {},
|
|
9
|
+
"roster": [],
|
|
10
|
+
"placementByKind": {},
|
|
11
|
+
"discoveryTtlMs": 172800000,
|
|
12
|
+
"invocationTtlMs": 86400000,
|
|
13
|
+
"balanceTtlMs": 300000,
|
|
14
|
+
"machineTtlMs": 90000,
|
|
15
|
+
"heartbeatMs": 30000,
|
|
16
|
+
"leaseSilenceMs": 600000,
|
|
17
|
+
"reserveFractionPpm": 150000,
|
|
18
|
+
"prepaidReserveFloorMicros": 250000,
|
|
19
|
+
"dailyLimits": {
|
|
20
|
+
"deepseek": {
|
|
21
|
+
"usdMicros": 2000000,
|
|
22
|
+
"timeZone": "UTC"
|
|
23
|
+
},
|
|
24
|
+
"openrouter": {
|
|
25
|
+
"usdMicros": 3000000,
|
|
26
|
+
"timeZone": "UTC"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"accountOverrides": [],
|
|
30
|
+
"qualityPriors": [],
|
|
31
|
+
"capabilityFloors": [
|
|
32
|
+
{
|
|
33
|
+
"difficulty": "easy",
|
|
34
|
+
"kind": "code",
|
|
35
|
+
"minimumScorePpm": 0
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"difficulty": "medium",
|
|
39
|
+
"kind": "code",
|
|
40
|
+
"minimumScorePpm": 350000
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"difficulty": "hard",
|
|
44
|
+
"kind": "code",
|
|
45
|
+
"minimumScorePpm": 550000
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
"exploration": {
|
|
49
|
+
"fractionPpm": 100000,
|
|
50
|
+
"minimumBatch": 10
|
|
51
|
+
},
|
|
52
|
+
"ranking": {
|
|
53
|
+
"tieRatioPpm": 1100000,
|
|
54
|
+
"priorityBasesPpm": [
|
|
55
|
+
1000000,
|
|
56
|
+
700000,
|
|
57
|
+
500000,
|
|
58
|
+
350000,
|
|
59
|
+
250000
|
|
60
|
+
],
|
|
61
|
+
"deadlineHorizonMs": 172800000,
|
|
62
|
+
"agingPerHourPpm": 50000,
|
|
63
|
+
"agingCapPpm": 2000000
|
|
64
|
+
},
|
|
65
|
+
"retry": {
|
|
66
|
+
"maxSwaps": 2,
|
|
67
|
+
"backoffMs": [
|
|
68
|
+
30000,
|
|
69
|
+
120000
|
|
70
|
+
]
|
|
71
|
+
},
|
|
72
|
+
"machineLimits": {
|
|
73
|
+
"cpuPct": 85,
|
|
74
|
+
"memPressurePct": 90,
|
|
75
|
+
"minDiskFreeBytes": 2147483648,
|
|
76
|
+
"minFreeMemoryBytes": 1073741824
|
|
77
|
+
},
|
|
78
|
+
"kill": {
|
|
79
|
+
"fleet": false,
|
|
80
|
+
"projects": []
|
|
81
|
+
},
|
|
82
|
+
"exclusions": [],
|
|
83
|
+
"hash": "sha256:8520e6f7e1f530b54ce0f80b58233d6901bc6f5b51f676dcd23dec622029d4ef"
|
|
84
|
+
}
|
package/docs/FEATURES.md
CHANGED
|
@@ -15,18 +15,31 @@ Rules for this file:
|
|
|
15
15
|
clicks, navigates, stages or commits.
|
|
16
16
|
- A probe says `skip` when the thing it reads is not on this machine (no app running, no idle
|
|
17
17
|
Claude pane, not macOS). A skip is never posted, and it neither opens nor closes an episode.
|
|
18
|
-
- When a card's files touch a feature below, that feature's probe joins the card's drill.
|
|
18
|
+
- When a card's files touch a feature below, that feature's probe joins the card's drill (#14670).
|
|
19
|
+
`files` lists exact repo paths; a path ending in `/` covers that whole directory. A card whose
|
|
20
|
+
claimed files overlap a row carries the row's probe, pinned to this table's registry hash, and a
|
|
21
|
+
probe marked required must pass on the card's artifact SHA before acceptance. A skip or a missing
|
|
22
|
+
run keeps acceptance pending; a host other than `any` means the probe only runs on that machine.
|
|
23
|
+
A claimed path no row covers needs an owner-approved no-feature-impact reason on the card.
|
|
24
|
+
`trantor canary attach <path…>` prints the probes a set of paths attaches.
|
|
25
|
+
- Changing a row's files, probe, host or required column changes the registry hash, so every open
|
|
26
|
+
card planned against the old hash replans and reverifies. `trantor canary check` validates the
|
|
27
|
+
mappings: a path with globs, `..` or a leading `/`, a probe missing from `lib/canary/probes.mjs`,
|
|
28
|
+
or a required value other than yes or no fails the check and the daily canary.
|
|
29
|
+
- `trantor canary brief` prints open regressions first, oldest first, then a missing daily run or one
|
|
30
|
+
older than 36h. A failure whose alert could not be posted stays open, says so, and is posted again
|
|
31
|
+
on the next run.
|
|
19
32
|
|
|
20
33
|
## Registry
|
|
21
34
|
|
|
22
|
-
| id | feature | what the probe reads | origin |
|
|
23
|
-
|
|
24
|
-
| `duty-turns` | The duty seat is alive and takes a turn at least once a day | `~/.agent-bus/duty.pid` names a live process, the runner's `*-trantor-duty.jsonl` turn log has a turn in the last 24h, and the hub's `/health` reports duty online | #14646 |
|
|
25
|
-
| `wake-nudge` | The wake-nudge daemon is installed and polling | `com.trantor.wake-nudge.plist` exists and `wake-nudge-cursor.json` was rewritten in the last 10 minutes (the daemon rewrites it every poll) | #7429 |
|
|
26
|
-
| `bus-delivery` | The bus delivers messages | the hub's `/health`: answers ok, persistence healthy, duty consuming with nothing stuck and no escalations queued | #5686 |
|
|
27
|
-
| `chat-working-state` | The chat working state follows herdr and the transcript | `herdr agent list` answers with a status on every agent, and the Claude agents' session ids resolve to transcripts under `~/.claude/projects` | #14644 |
|
|
28
|
-
| `cc-suggestion-pills` | The predicted-prompt pills can read Claude Code's suggestion | `herdr pane read --source visible --format ansi` on idle Claude panes still shows the `❯` + NBSP prompt line the pill parser anchors on | #11649 |
|
|
29
|
-
| `release-install` | The release install path works | the npm registry's `trantor@latest` has a version and a tarball, and the newest GitHub app release carries a `Trantor_*.dmg` | #14571 |
|
|
30
|
-
| `workspace-layouts` | The Workspace layouts render | the running app's read socket returns the main window's text, non-empty and without an error screen | #14618 |
|
|
31
|
-
| `file-actions-no-commit` | File actions in the operator's own checkout don't commit | each known project's main checkout HEAD reflog for the last 7 days has no `create … in the app` / `delete … in the app` / `rename … in the app` commit | #14639 |
|
|
32
|
-
| `launchers` | Every com.trantor.* launcher's program path exists | each `~/Library/LaunchAgents/com.trantor.*.plist`'s pinned paths exist and none is a versioned Homebrew Cellar path | #14646 |
|
|
35
|
+
| id | feature | what the probe reads | origin | files | probe | host | required for acceptance |
|
|
36
|
+
|---|---|---|---|---|---|---|---|
|
|
37
|
+
| `duty-turns` | The duty seat is alive and takes a turn at least once a day | `~/.agent-bus/duty.pid` names a live process, the runner's `*-trantor-duty.jsonl` turn log has a turn in the last 24h, and the hub's `/health` reports duty online | #14646 | `bin/duty.mjs`, `lib/duty-nudges.mjs`, `lib/duty-recipient.mjs` | `duty-turns` | mac | yes |
|
|
38
|
+
| `wake-nudge` | The wake-nudge daemon is installed and polling | `com.trantor.wake-nudge.plist` exists and `wake-nudge-cursor.json` was rewritten in the last 10 minutes (the daemon rewrites it every poll) | #7429 | `bin/wake-nudge.mjs` | `wake-nudge` | mac | yes |
|
|
39
|
+
| `bus-delivery` | The bus delivers messages | the hub's `/health`: answers ok, persistence healthy, duty consuming with nothing stuck and no escalations queued | #5686 | `hub/routes/messages.mjs` | `bus-delivery` | any | yes |
|
|
40
|
+
| `chat-working-state` | The chat working state follows herdr and the transcript | `herdr agent list` answers with a status on every agent, and the Claude agents' session ids resolve to transcripts under `~/.claude/projects` | #14644 | `desktop/src-tauri/src/chat.rs`, `desktop/src-tauri/src/transcript_facts.rs`, `desktop/src-tauri/src/herdr.rs` | `chat-working-state` | mac | yes |
|
|
41
|
+
| `cc-suggestion-pills` | The predicted-prompt pills can read Claude Code's suggestion | `herdr pane read --source visible --format ansi` on idle Claude panes still shows the `❯` + NBSP prompt line the pill parser anchors on | #11649 | `desktop/src-tauri/src/cc_suggestion.rs` | `cc-suggestion-pills` | mac | yes |
|
|
42
|
+
| `release-install` | The release install path works | the npm registry's `trantor@latest` has a version and a tarball, and the newest GitHub app release carries a `Trantor_*.dmg` | #14571 | `.github/workflows/release.yml` | `release-install` | any | yes |
|
|
43
|
+
| `workspace-layouts` | The Workspace layouts render | the running app's read socket returns the main window's text, non-empty and without an error screen | #14618 | `desktop/src/v2/shell/`, `desktop/src/v2/screens/Workspace/` | `workspace-layouts` | mac | yes |
|
|
44
|
+
| `file-actions-no-commit` | File actions in the operator's own checkout don't commit | each known project's main checkout HEAD reflog for the last 7 days has no `create … in the app` / `delete … in the app` / `rename … in the app` commit | #14639 | `desktop/src-tauri/src/file_ops.rs` | `file-actions-no-commit` | mac | yes |
|
|
45
|
+
| `launchers` | Every com.trantor.* launcher's program path exists | each `~/Library/LaunchAgents/com.trantor.*.plist`'s pinned paths exist and none is a versioned Homebrew Cellar path | #14646 | `lib/launchd.mjs`, `lib/launch-node.mjs` | `launchers` | mac | yes |
|
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/routes/capacity.mjs
CHANGED
|
@@ -12,7 +12,8 @@ import { homedir } from "node:os";
|
|
|
12
12
|
import { join } from "node:path";
|
|
13
13
|
import { DEFAULT_LOW, DEFAULT_LOW_QUOTA_PCT } from "../../lib/balances.mjs";
|
|
14
14
|
import { recordMachineBeat, machineHealthRows, CAPACITY_STALE_MS } from "../../lib/capacity-machines.mjs";
|
|
15
|
-
import { budgetsView, burnView, seatsView,
|
|
15
|
+
import { budgetsView, burnView, seatsView, machinesView } from "../../lib/capacity.mjs";
|
|
16
|
+
import { readScroogeLedger, scroogeReceipts } from "../../lib/dispatcher/spend.mjs";
|
|
16
17
|
|
|
17
18
|
/* oxlint-disable anti-slop/no-runtime-typeof -- SAFETY: config.json is user-editable external input; lowThresholds validates its optional number/object fields at that I/O boundary, the same guard GET /balances uses. */
|
|
18
19
|
// The same low-balance thresholds GET /balances reads, so both views flag the same provider.
|
|
@@ -25,6 +26,19 @@ function lowThresholds() {
|
|
|
25
26
|
} catch { return { low: DEFAULT_LOW, pct: DEFAULT_LOW_QUOTA_PCT }; }
|
|
26
27
|
}
|
|
27
28
|
|
|
29
|
+
// Crew USD receipts for the burn view (#14671): the scrooge one-shot ledger, mtime-cached the
|
|
30
|
+
// same way /economics reads it. Dispatcher usage events join the same projection when B5/B6 wire
|
|
31
|
+
// their store; no token-derived dollar estimates are ever fabricated here.
|
|
32
|
+
let spendLedgerCache = { mtimeMs: -1, receipts: [] };
|
|
33
|
+
function crewSpendReceipts() {
|
|
34
|
+
const ledger = readScroogeLedger();
|
|
35
|
+
if (ledger.mtimeMs == null) return [];
|
|
36
|
+
if (ledger.mtimeMs !== spendLedgerCache.mtimeMs) {
|
|
37
|
+
spendLedgerCache = { mtimeMs: ledger.mtimeMs, receipts: scroogeReceipts({ lines: ledger.rows.map((row) => row.line) }) };
|
|
38
|
+
}
|
|
39
|
+
return spendLedgerCache.receipts;
|
|
40
|
+
}
|
|
41
|
+
|
|
28
42
|
export async function routeCapacity({ req, res, P, auth, ctx }) {
|
|
29
43
|
const { state, body, json, now, turnTelemetry, ONLINE_MS, PEER_TTL_MS, filterReadable } = ctx;
|
|
30
44
|
|
|
@@ -39,37 +53,30 @@ export async function routeCapacity({ req, res, P, auth, ctx }) {
|
|
|
39
53
|
const burnRows = turnTelemetry.readRows({ since: nowMs - 86400e3 });
|
|
40
54
|
const lastRows = turnTelemetry.readRows({ since: nowMs - 7 * 86400e3 });
|
|
41
55
|
const { low, pct } = lowThresholds();
|
|
42
|
-
const seats = seatsView({ peers: state.peers, lastRows, nowMs, onlineMs: ONLINE_MS });
|
|
56
|
+
const seats = seatsView({ peers: state.peers, lastRows, messages: state.messages, nowMs, onlineMs: ONLINE_MS });
|
|
43
57
|
const visibleSeats = filterReadable(auth, seats, (s) => s.project);
|
|
44
58
|
const seatKey = (s) => `${s.persona}\u0000${s.project}`;
|
|
45
59
|
const visibleKeys = new Set(visibleSeats.map(seatKey));
|
|
46
|
-
|
|
60
|
+
// One-shot receipts have no presence seat: their visibility is project-readability of the
|
|
61
|
+
// receipt itself, so a project-scoped reader still sees their dollars without seeing seats.
|
|
62
|
+
const receipts = crewSpendReceipts();
|
|
63
|
+
const visibleReceiptKeys = new Set(filterReadable(auth, receipts, (r) => r.project)
|
|
64
|
+
.map((r) => `${r.persona || ""}\u0000${r.project || ""}`));
|
|
65
|
+
const canSee = (s) => visibleKeys.has(seatKey(s)) || visibleReceiptKeys.has(seatKey(s));
|
|
47
66
|
|
|
48
|
-
// Machine rows: the beat registry joined with seat counts
|
|
49
|
-
//
|
|
50
|
-
|
|
51
|
-
const machines =
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
machines.push({ ...h, seats: counts?.seats || 0, seatsOnline: counts?.seatsOnline || 0, heartbeat: true });
|
|
57
|
-
}
|
|
58
|
-
for (const [machine, counts] of seatCounts) {
|
|
59
|
-
if (seen.has(machine)) continue;
|
|
60
|
-
machines.push({
|
|
61
|
-
machine, cpuPct: null, memUsed: null, memTotal: null, cores: null, memPressurePct: null,
|
|
62
|
-
swapUsed: null, swapTotal: null, diskFree: null, diskTotal: null,
|
|
63
|
-
ts: null, ageMs: null, stale: true, heartbeat: false,
|
|
64
|
-
seats: counts.seats, seatsOnline: counts.seatsOnline,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
machines.sort((a, b) => a.machine.localeCompare(b.machine));
|
|
67
|
+
// Machine rows (#14702): the beat registry joined with seat counts over every machine name the
|
|
68
|
+
// hub knows — beat labels, presence labels, balances host names — case-insensitively, with an
|
|
69
|
+
// unlabeled "host:project" session attributed to a known host (the operator's Mac).
|
|
70
|
+
const machines = machinesView({
|
|
71
|
+
beats: machineHealthRows(nowMs), peers: state.peers, nowMs,
|
|
72
|
+
ttlMs: PEER_TTL_MS, onlineMs: ONLINE_MS,
|
|
73
|
+
balanceMachines: Object.keys(state.balancesByMachine || {}),
|
|
74
|
+
});
|
|
68
75
|
|
|
69
76
|
return json(res, 200, {
|
|
70
77
|
ts: nowMs,
|
|
71
78
|
budgets: budgetsView({ state, nowMs, thresholds: low, quotaPct: pct }),
|
|
72
|
-
burn: burnView({ rows: burnRows, nowMs, canSee }),
|
|
79
|
+
burn: burnView({ rows: burnRows, nowMs, canSee, spendReceipts: receipts }),
|
|
73
80
|
machines,
|
|
74
81
|
staleAfterMs: CAPACITY_STALE_MS,
|
|
75
82
|
seats: visibleSeats,
|
package/hub/routes/cards.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/* oxlint-disable anti-slop/no-runtime-typeof, anti-slop/no-conditional-empty-object-spread -- SAFETY: Card wire envelopes and omission semantics are a compatibility contract; this module is a mechanical extraction with unchanged suites. */
|
|
2
|
+
import { seatWorkFlags } from "../../lib/capacity.mjs";
|
|
3
|
+
|
|
2
4
|
// The three fields that make a card heavy (#6983): its note log, its status history, and its
|
|
3
5
|
// checklist. All three are per-card detail nobody reads off a board — a board shows how many notes
|
|
4
6
|
// a card carries, never their text. Dropping them is what turns a 1.55MB read into 0.26MB.
|
|
@@ -569,8 +571,11 @@ export async function routeCards({ req, res, q, P, auth, ctx }) {
|
|
|
569
571
|
const ttlCut = now() - PEER_TTL_MS; // #8723: a memory row (quiet past PEER_TTL_MS) never lists as a board agent…
|
|
570
572
|
for (const [s, v] of filterReadable(auth, Object.entries(state.peers), ([, v]) => v.project || "")) {
|
|
571
573
|
if ((v.lastSeen || 0) < ttlCut) continue; // …declaredCrewFor and the duty watermark still read it from state.
|
|
572
|
-
const k = proj(v.project); const e = mk(k);
|
|
573
|
-
|
|
574
|
+
const k = proj(v.project); const e = mk(k);
|
|
575
|
+
const online = v.lastSeen > cutoff;
|
|
576
|
+
const work = seatWorkFlags({ messages: state.messages, session: s, deliveredUpTo: v.deliveredUpTo, nowMs: now(), online });
|
|
577
|
+
e.agents.push({ session: s, online, status: v.status || "", health: work.fault ? "stuck" : healthOf(v.status), ...work,
|
|
578
|
+
llm: v.llm || "", model: v.model || "", hookVersion: v.hookVersion || "", staleHooks: !!(online && v.hookVersion && HUB_VERSION && cmpSemver(v.hookVersion, HUB_VERSION) < 0) });
|
|
574
579
|
if ((v.lastSeen || 0) > e.lastActivity) e.lastActivity = v.lastSeen;
|
|
575
580
|
}
|
|
576
581
|
for (const t of filterReadable(auth, state.tasks, t => t.project || "")) { const e = mk(proj(t.project)); e.tasks[t.status] = (e.tasks[t.status]||0)+1; if (t.status === "doing") e.doingTitles.push(t.title); if ((t.updated || 0) > e.lastActivity) e.lastActivity = t.updated; }
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { WorkCardSchema, UsageEventSchema, ArtifactSchema, SnapshotSchema, PolicySchema } from '../../lib/dispatcher/schemas.mjs';
|
|
3
|
+
import { DispatchRequestSchema, reject } from '../../lib/dispatcher/admission.mjs';
|
|
4
|
+
import { canonicalJson, verifySnapshot } from '../../lib/dispatcher/snapshot.mjs';
|
|
5
|
+
import { verifyPolicy } from '../../lib/dispatcher/policy.mjs';
|
|
6
|
+
import { plan } from '../../lib/dispatcher/planner.mjs';
|
|
7
|
+
|
|
8
|
+
const text = z.string().min(1).max(8192);
|
|
9
|
+
const positive = z.number().int().positive().max(Number.MAX_SAFE_INTEGER);
|
|
10
|
+
export const AdviceRequestSchema = z.strictObject({ schemaVersion: z.literal(1), project: text,
|
|
11
|
+
snapshotId: text.optional(), policyVersion: text.optional(), cards: z.array(WorkCardSchema),
|
|
12
|
+
drafts: z.array(WorkCardSchema).optional() });
|
|
13
|
+
export const AdviceAuthoritySchema = z.strictObject({ snapshot: SnapshotSchema, policy: PolicySchema });
|
|
14
|
+
export const AttemptEventSchema = z.discriminatedUnion('kind', [
|
|
15
|
+
z.strictObject({ kind: z.literal('usage'), event: UsageEventSchema }),
|
|
16
|
+
z.strictObject({ kind: z.literal('artifact'), artifact: ArtifactSchema,
|
|
17
|
+
capability: z.strictObject({ generation: positive, launchToken: text }) }),
|
|
18
|
+
]);
|
|
19
|
+
|
|
20
|
+
async function readable(client, orgId, actor, project) {
|
|
21
|
+
const row = (await client.query('SELECT scopes,revoked_at FROM identities WHERE org_id=$1 AND pubkey=$2', [orgId, actor.pubkey])).rows[0];
|
|
22
|
+
if (!row || row.revoked_at != null || !['read','write','approver','owner'].includes(row.scopes[project])
|
|
23
|
+
&& !['read','write','approver','owner'].includes(row.scopes['*'])) reject('permission_denied', 403);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async function advise(service, orgId, input, actor, auth) {
|
|
27
|
+
const request = AdviceRequestSchema.parse(input);
|
|
28
|
+
if ([...request.cards, ...request.drafts || []].some(c => c.project !== request.project)) reject('permission_denied', 403);
|
|
29
|
+
return service.store.locked(orgId, async client => {
|
|
30
|
+
await readable(client, orgId, actor, request.project);
|
|
31
|
+
const authority = AdviceAuthoritySchema.parse(await service.readAdvice(client, { orgId, request, actor }));
|
|
32
|
+
let snapshot;
|
|
33
|
+
try { snapshot = verifySnapshot(authority.snapshot); verifyPolicy(authority.policy); } catch { reject('snapshot_invalid'); }
|
|
34
|
+
if (request.snapshotId && request.snapshotId !== snapshot.id) reject('snapshot_gone', 410);
|
|
35
|
+
if (request.policyVersion && request.policyVersion !== authority.policy.version) reject('policy_stale');
|
|
36
|
+
for (const card of request.cards) {
|
|
37
|
+
const stored = snapshot.readyQueue.find(c => c.project === card.project && c.card === card.card);
|
|
38
|
+
if (!stored || canonicalJson(stored) !== canonicalJson(card)) reject('card_stale');
|
|
39
|
+
}
|
|
40
|
+
const decision = plan({ ...authority, cards: [...request.cards, ...request.drafts || []] });
|
|
41
|
+
const dispatchable = !request.drafts?.length;
|
|
42
|
+
if (dispatchable) await client.query(`INSERT INTO dispatcher_decisions VALUES($1,$2,$3,$4,$5,$6,$7)
|
|
43
|
+
ON CONFLICT(org_id,id) DO NOTHING`, [orgId, decision.id, request.project, decision.snapshotId,
|
|
44
|
+
decision.policyVersion, decision.createdAtMs, decision]);
|
|
45
|
+
return { schemaVersion: 1, dispatchable, decision: service.projectDecision(decision, auth) };
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export async function routeDispatcher({ req, res, q: _q, P, auth, ctx }) {
|
|
50
|
+
const match = /^\/dispatch\/([^/]+)(?:\/(heartbeat|events|stop))?$/.exec(P);
|
|
51
|
+
const advice = req.method === 'POST' && P === '/advise';
|
|
52
|
+
const dispatch = req.method === 'POST' && P === '/dispatch';
|
|
53
|
+
if (!advice && !dispatch && !(match && (req.method === 'POST' && match[2] || req.method === 'GET' && !match[2]))) return false;
|
|
54
|
+
try {
|
|
55
|
+
if (ctx.AUTH_MODE === 'off' || !auth?.ok || !auth.identity || !auth.pubkey) reject('permission_denied', 403);
|
|
56
|
+
const service = ctx.dispatcher;
|
|
57
|
+
if (!service) reject('dispatch_unavailable', 503);
|
|
58
|
+
const orgId = service.orgId(auth);
|
|
59
|
+
if (!orgId) reject('permission_denied', 403);
|
|
60
|
+
const actor = { pubkey: auth.pubkey };
|
|
61
|
+
if (advice) return ctx.json(res, 200, await advise(service, orgId, await ctx.body(req), actor, auth));
|
|
62
|
+
if (dispatch) {
|
|
63
|
+
const input = DispatchRequestSchema.parse(await ctx.body(req));
|
|
64
|
+
const result = await service.admission.dispatch(orgId, input, actor);
|
|
65
|
+
return ctx.json(res, result.replayed ? 200 : 202, result);
|
|
66
|
+
}
|
|
67
|
+
const attemptId = decodeURIComponent(match[1]);
|
|
68
|
+
const attempt = await service.store.attempt(orgId, attemptId);
|
|
69
|
+
if (!attempt || !ctx.canRead(auth, attempt.project)) reject('attempt_missing', 404);
|
|
70
|
+
if (req.method === 'GET') {
|
|
71
|
+
await service.store.locked(orgId, client => readable(client, orgId, actor, attempt.project));
|
|
72
|
+
return ctx.json(res, 200, { schemaVersion: 1, attemptId, project: attempt.project, card: attempt.card,
|
|
73
|
+
leaseId: attempt.leaseId, state: attempt.state, generation: attempt.generation, artifact: attempt.artifact,
|
|
74
|
+
acceptance: attempt.acceptance, failure: attempt.failure, endedAtMs: attempt.endedAtMs });
|
|
75
|
+
}
|
|
76
|
+
const input = await ctx.body(req);
|
|
77
|
+
let result;
|
|
78
|
+
if (match[2] === 'heartbeat') result = await service.executor.heartbeat(orgId, attemptId, input, actor);
|
|
79
|
+
if (match[2] === 'stop') {
|
|
80
|
+
const stop = z.strictObject({ reason: text }).parse(input);
|
|
81
|
+
result = await service.executor.stop(orgId, attemptId, stop.reason, actor);
|
|
82
|
+
}
|
|
83
|
+
if (match[2] === 'events') {
|
|
84
|
+
const event = AttemptEventSchema.parse(input);
|
|
85
|
+
result = event.kind === 'usage' ? await service.executor.usage(orgId, attemptId, event.event, actor)
|
|
86
|
+
: await service.executor.artifact(orgId, attemptId, event.artifact, event.capability, actor);
|
|
87
|
+
if (event.kind === 'artifact') result = { state: result.state, generation: result.generation };
|
|
88
|
+
}
|
|
89
|
+
return ctx.json(res, 200, { schemaVersion: 1, ...result });
|
|
90
|
+
} catch (error) {
|
|
91
|
+
const status = error instanceof z.ZodError || error instanceof URIError ? 422 : error.status || 503;
|
|
92
|
+
const code = status === 422 ? 'schema_invalid' : error.code || 'dispatch_unavailable';
|
|
93
|
+
if (code === 'admission_busy') res.setHeader('Retry-After', '1');
|
|
94
|
+
return ctx.json(res, status, { schemaVersion: 1, code, reasons: [{ code, resource: null, retryAtMs: null }],
|
|
95
|
+
retryable: status === 429 || status === 503 });
|
|
96
|
+
}
|
|
97
|
+
}
|