trantor 0.18.30 → 0.18.31
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/bin/cli.mjs +1 -1
- package/bin/crew-runner.mjs +17 -4
- package/bin/crew.sh +23 -8
- package/bin/new.mjs +21 -9
- package/bin/patrol.mjs +23 -1
- package/hooks/lib/resources.mjs +19 -2
- package/lib/classify-failure.mjs +50 -9
- package/package.json +2 -2
package/bin/cli.mjs
CHANGED
|
@@ -209,7 +209,7 @@ switch (cmd) {
|
|
|
209
209
|
trantor gates verification gates: "must verify before shipping" claims that survive handoffs — [--all] [--json]
|
|
210
210
|
trantor backfill card past GIT work onto the board (solo commits that were never carded) — [--since "14 days ago"] [--dry-run]
|
|
211
211
|
trantor init-hooks install a git post-commit hook so EVERY commit auto-cards on the board (reliable solo-work backstop) — [--uninstall]
|
|
212
|
-
trantor new project genesis: new <name> [--from <git-url>] [--brief <file>] [--dir <
|
|
212
|
+
trantor new project genesis: new <name> [--from <git-url>] [--brief <file>] [--dir <parent>] [--adopt] [--json] — creates <parent>/<name>, git main, CLAUDE.md from the brief, hooks, hub brief + first card (never spawns a session)
|
|
213
213
|
trantor balances how much credit is left on each CONFIGURED provider (from your profile) — refill before you stall — [--json]
|
|
214
214
|
trantor recost recompute sub-agent notional cost from on-disk transcripts + reseed the board (repair after upgrade) — [--dry-run]
|
|
215
215
|
trantor handoff finish this session NOW: write a handoff, open a fresh session that takes over, and close this one (manual baton)
|
package/bin/crew-runner.mjs
CHANGED
|
@@ -19,6 +19,7 @@ import { ensureEnrolled } from "../lib/enroll.mjs";
|
|
|
19
19
|
import { redactKeys } from "../lib/redact.mjs";
|
|
20
20
|
import {
|
|
21
21
|
AUTH_MARKER_RE, classifyFailure, looksLikeAuthDeath,
|
|
22
|
+
verdictFor,
|
|
22
23
|
readPromptText, stripPromptEcho,
|
|
23
24
|
} from "../lib/classify-failure.mjs";
|
|
24
25
|
import { capWake, capBcast, pickLessons, composePrompt } from "./crew-payload.mjs";
|
|
@@ -461,6 +462,10 @@ async function runTurn(prompt, isFirst, trigger = "kickoff") {
|
|
|
461
462
|
const pf = join(homedir(), ".agent-bus", `turn-${AGENT}-${PROJ}.txt`);
|
|
462
463
|
appendFileSync(pf, "", { flag: "w" }); // truncate
|
|
463
464
|
appendFileSync(pf, prompt);
|
|
465
|
+
// #5868: where HEAD stood when the turn began. A turn that moved it shipped real work, and an
|
|
466
|
+
// exit-0 turn with real output must never be re-labelled "auth" by the #5405 escalation — the
|
|
467
|
+
// qwen specimen committed aa3c340 while its captured stream still tripped the auth regex.
|
|
468
|
+
const headBefore = gitOut(["rev-parse", "HEAD"], TURN_DIR);
|
|
464
469
|
let cmd = (isFirst || (cli.sid && !sid)) ? cli.first : cli.next;
|
|
465
470
|
const mfrag = MODEL && cli.mflag ? `${cli.mflag}${MODEL}` : "";
|
|
466
471
|
cmd = cmd.replaceAll("{M}", mfrag).replaceAll("{P}", pf).replaceAll("{SID}", sid);
|
|
@@ -543,10 +548,15 @@ async function runTurn(prompt, isFirst, trigger = "kickoff") {
|
|
|
543
548
|
// fail the turn. Telemetry keeps the REAL exit; the returned code is the effective one every
|
|
544
549
|
// call site branches on (kickoff, pulse, deliverWake).
|
|
545
550
|
let effExit = realExit;
|
|
546
|
-
|
|
551
|
+
let authHit = "";
|
|
552
|
+
// #5868: a NEW commit since turn start is real work, and an exit-0 turn with real output is
|
|
553
|
+
// never re-labelled auth — the qwen specimen exited 0 with a shipped commit (aa3c340) while a
|
|
554
|
+
// short capture of echoed contract text tripped the regex.
|
|
555
|
+
const newCommit = !!headBefore && gitOut(["rev-parse", "HEAD"], TURN_DIR) !== headBefore;
|
|
556
|
+
if (realExit === 0 && looksLikeAuthDeath(ownOut, newCommit)) {
|
|
547
557
|
effExit = 1;
|
|
548
|
-
|
|
549
|
-
log(`\x1b[31mexit 0 but the turn output IS an auth failure — treating as FAILED (auth, "${
|
|
558
|
+
authHit = AUTH_MARKER_RE.exec(ownOut)[0];
|
|
559
|
+
log(`\x1b[31mexit 0 but the turn output IS an auth failure — treating as FAILED (auth, "${authHit}")\x1b[0m`);
|
|
550
560
|
}
|
|
551
561
|
// #5481: the Inception/Mercury trap — exit 0 with a NULL completion. ERRF is the TOTAL output
|
|
552
562
|
// capture, not just stderr: every seat's stdout is tee'd into it (`| tee -a ERRF` for the
|
|
@@ -562,7 +572,10 @@ async function runTurn(prompt, isFirst, trigger = "kickoff") {
|
|
|
562
572
|
lastEmptyOutput = true;
|
|
563
573
|
log("\x1b[31mexit 0 but the turn produced NO output — treating as FAILED (empty-output)\x1b[0m");
|
|
564
574
|
}
|
|
565
|
-
|
|
575
|
+
// #5868: the verdict rides the telemetry row so a classification survives the pane scrolling
|
|
576
|
+
// away — the same "classified X because Y" shape the runner logs, in the seat's jsonl forever.
|
|
577
|
+
const verdict = verdictFor(realExit, effExit, lastEmptyOutput, ownOut);
|
|
578
|
+
telemetry({ ts: Date.now(), agent: AGENT, project: PROJ, turn: TURN, trigger, model: MODEL || "cli-default", duration_ms: Date.now() - t0, exit: realExit, effExit, authFailed: effExit !== realExit, emptyOutput: lastEmptyOutput, verdict });
|
|
566
579
|
log(`turn ended (exit ${realExit}${effExit !== realExit ? ` → effective ${effExit} (${lastEmptyOutput ? "empty-output" : "auth"})` : ""}, ${((Date.now() - t0) / 1000).toFixed(0)}s)`);
|
|
567
580
|
if (realExit === 0 && effExit === 0) { cmuxStatus("idle", "#8a94a6", "robot"); herdrAgent("idle"); } // finished this turn, waiting for the next
|
|
568
581
|
// #5965 — TURN END. A clean exit means the seat is idle again; say so right away so the app stops
|
package/bin/crew.sh
CHANGED
|
@@ -733,7 +733,8 @@ echo "[crew] hub for $PROJ: $HUB_URL (baked into every seat; CREW_HUB=<url> over
|
|
|
733
733
|
SCROOGE="$BUS_DIR/engine/bin/scrooge"
|
|
734
734
|
[ -f "$SCROOGE" ] || SCROOGE="$(command -v scrooge 2>/dev/null || echo scrooge)"
|
|
735
735
|
|
|
736
|
-
# resolve_model <agent> <provider> <task> <diff> -> echoes a
|
|
736
|
+
# resolve_model <agent> <provider> <task> <diff> -> echoes a provider-qualified model id.
|
|
737
|
+
# A provider seat must never fall through to opencode's unrelated global default.
|
|
737
738
|
resolve_model() {
|
|
738
739
|
local agent="$1" provider="$2" task="$3" diff="$4" cands="" out=""
|
|
739
740
|
cands="$(opencode models "$provider" 2>/dev/null | tr '\n' ' ')"
|
|
@@ -742,10 +743,16 @@ resolve_model() {
|
|
|
742
743
|
else
|
|
743
744
|
out="$(python3 "$SCROOGE" route --provider "$provider" -t "$task" -d "$diff" --json 2>/dev/null)"
|
|
744
745
|
fi
|
|
745
|
-
[ -n "$out" ] || { echo "[crew] live model selection failed for $agent:$provider —
|
|
746
|
-
printf '%s' "$out" | python3 -c 'import json,sys
|
|
746
|
+
[ -n "$out" ] || { echo "[crew] live model selection failed for $agent:$provider — refusing opencode global default" >&2; return 1; }
|
|
747
|
+
out="$(printf '%s' "$out" | python3 -c 'import json,sys
|
|
747
748
|
try: print(json.load(sys.stdin).get("qualified") or "")
|
|
748
|
-
except Exception: pass' 2>/dev/null
|
|
749
|
+
except Exception: pass' 2>/dev/null)"
|
|
750
|
+
[ -n "$out" ] || { echo "[crew] router returned no model for $agent:$provider — refusing opencode global default" >&2; return 1; }
|
|
751
|
+
[ "${out%%/*}" = "$provider" ] || {
|
|
752
|
+
echo "[crew] router selected $out outside $provider — refusing cross-provider fallback" >&2
|
|
753
|
+
return 1
|
|
754
|
+
}
|
|
755
|
+
printf '%s' "$out"
|
|
749
756
|
}
|
|
750
757
|
|
|
751
758
|
epoch_ms() { python3 -c 'import time;print(int(time.time()*1000))'; }
|
|
@@ -760,13 +767,21 @@ resolve_spec() {
|
|
|
760
767
|
# into the launcher string. AGENT is set above and DIR is fixed, so this is the earliest safe point.
|
|
761
768
|
reap_seat
|
|
762
769
|
FIELD=""; [ "$SPEC" != "$AGENT" ] && FIELD="${SPEC#*:}"
|
|
763
|
-
|
|
770
|
+
# Bare native seats use their own CLI defaults. Bare opencode-hosted seats MUST name their
|
|
771
|
+
# provider implicitly: glm is the one non-obvious alias; every discovered/BYOM seat's label is
|
|
772
|
+
# its provider id. Leaving FIELD empty is what handed qwen/glm to opencode's global DeepSeek.
|
|
773
|
+
if [ -z "$FIELD" ]; then
|
|
774
|
+
case "$AGENT" in
|
|
775
|
+
codex|kimi|claude|gemini|dsh|opencode) ;;
|
|
776
|
+
glm) FIELD="zai-coding-plan" ;;
|
|
777
|
+
*) FIELD="$AGENT" ;;
|
|
778
|
+
esac
|
|
779
|
+
fi
|
|
764
780
|
if [ -n "$FIELD" ]; then
|
|
765
781
|
case "$FIELD" in
|
|
766
782
|
*/*) MODEL="$FIELD" ;;
|
|
767
|
-
*) MODEL="$(resolve_model "$AGENT" "$FIELD" "$TASK" "$DIFF")"
|
|
768
|
-
|
|
769
|
-
else echo " → $AGENT: '$FIELD' live selection unavailable — CLI default"; fi ;;
|
|
783
|
+
*) MODEL="$(resolve_model "$AGENT" "$FIELD" "$TASK" "$DIFF")" || exit 1
|
|
784
|
+
echo " → $AGENT: live model $MODEL ($FIELD · $TASK/$DIFF)" ;;
|
|
770
785
|
esac
|
|
771
786
|
fi
|
|
772
787
|
}
|
package/bin/new.mjs
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// trantor new — project genesis, the CLI half (#5862). One command stands a project up:
|
|
3
3
|
//
|
|
4
|
-
// trantor new <name> [--from <git-url>] [--brief <file>] [--dir <
|
|
4
|
+
// trantor new <name> [--from <git-url>] [--brief <file>] [--dir <parent>] [--adopt] [--json]
|
|
5
5
|
//
|
|
6
|
-
// It makes the directory
|
|
7
|
-
//
|
|
6
|
+
// It makes the project directory at <parent>/<name> — --dir names the PARENT, never the project
|
|
7
|
+
// directory itself (default parent: TRANTOR_DEV_ROOT or ~/development). The name is always
|
|
8
|
+
// appended under it, so `--dir P` with name N creates P/N. Starts git on main (or clones --from,
|
|
9
|
+
// or adopts an existing folder with --adopt), seeds CLAUDE.md from the
|
|
8
10
|
// brief (verbatim brief + the trantor conventions block), installs the same auto-card hook as
|
|
9
11
|
// `trantor init-hooks`, posts the brief as the hub project brief (POST /project — the same call
|
|
10
12
|
// relay_project_brief makes), and opens the first card "genesis: <name>" on the new board.
|
|
@@ -17,7 +19,8 @@ import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync, append
|
|
|
17
19
|
import { homedir } from "node:os";
|
|
18
20
|
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
19
21
|
import { fileURLToPath } from "node:url";
|
|
20
|
-
import { ensureEnrolled, loadIdentity, signedPost } from "../hooks/lib/api.mjs";
|
|
22
|
+
import { ensureEnrolled as enrollTofu, loadIdentity, signedPost } from "../hooks/lib/api.mjs";
|
|
23
|
+
import { ensureEnrolled as enrollViaOwnerInvite } from "../lib/enroll.mjs";
|
|
21
24
|
import { setAutonomy } from "../lib/autonomy.mjs";
|
|
22
25
|
import { resolveHub, setProjectHub } from "../lib/project.mjs";
|
|
23
26
|
|
|
@@ -52,7 +55,7 @@ const flag = (n) => { const i = args.indexOf("--" + n); return i >= 0 ? args[i +
|
|
|
52
55
|
const has = (n) => args.includes("--" + n);
|
|
53
56
|
const json = has("json");
|
|
54
57
|
const name = args.find(a => !a.startsWith("--"));
|
|
55
|
-
if (!name) die("usage: trantor new <name> [--from <git-url>] [--brief <file>] [--dir <
|
|
58
|
+
if (!name) die("usage: trantor new <name> [--from <git-url>] [--brief <file>] [--dir <parent>] [--adopt] [--json] — project lands at <parent>/<name>");
|
|
56
59
|
if (!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(name)) die(`invalid project name "${name}" — letters, digits, dot, dash, underscore`);
|
|
57
60
|
const from = flag("from");
|
|
58
61
|
const briefFile = flag("brief");
|
|
@@ -120,10 +123,17 @@ const identity = loadIdentity(session);
|
|
|
120
123
|
let card = null;
|
|
121
124
|
let hubError = null;
|
|
122
125
|
try {
|
|
123
|
-
|
|
126
|
+
// The genesis identity is BRAND NEW — it cannot write to a project on an enforce hub until the
|
|
127
|
+
// hub knows it. TOFU /enroll only works on a local loopback hub; a remote enforce hub refuses it
|
|
128
|
+
// (403 "tofu enrollment refused") and the genesis silently records nothing (#6049). So enroll the
|
|
129
|
+
// way crew seats do: the operator's owner key mints a project-scoped write invite and the genesis
|
|
130
|
+
// identity spends it. Only when NO owner key is configured (a loopback hub with no owner identity)
|
|
131
|
+
// do we fall back to the plain TOFU enroll.
|
|
132
|
+
const viaOwner = await enrollViaOwnerInvite(hub, identity, name, { timeoutMs: 8000 });
|
|
133
|
+
if (!viaOwner.ok && viaOwner.reason === "no-owner-key") await enrollTofu(session, identity, name);
|
|
124
134
|
const briefForHub = (brief || `Genesis of ${name} — created by trantor new.`).slice(0, 600);
|
|
125
135
|
const r1 = await signedPost("/project", { project: name, brief: briefForHub, by: session }, { session, project: name, timeoutMs: 8000 });
|
|
126
|
-
if (!r1.ok) throw new Error(`hub ${r1.status} on /project`);
|
|
136
|
+
if (!r1.ok) throw new Error(`hub ${r1.status} on /project${r1.json?.error ? `: ${r1.json.error}` : ""}`);
|
|
127
137
|
const r2 = await signedPost("/task", {
|
|
128
138
|
project: name,
|
|
129
139
|
title: `genesis: ${name}`,
|
|
@@ -131,7 +141,7 @@ try {
|
|
|
131
141
|
by: session,
|
|
132
142
|
note: "project genesis — created by trantor new",
|
|
133
143
|
}, { session, project: name, timeoutMs: 8000 });
|
|
134
|
-
if (!r2.ok) throw new Error(`hub ${r2.status} on /task`);
|
|
144
|
+
if (!r2.ok) throw new Error(`hub ${r2.status} on /task${r2.json?.error ? `: ${r2.json.error}` : ""}`);
|
|
135
145
|
card = r2.json?.task?.id ?? null;
|
|
136
146
|
} catch (e) {
|
|
137
147
|
hubError = e instanceof Error ? e.message : String(e);
|
|
@@ -139,8 +149,10 @@ try {
|
|
|
139
149
|
}
|
|
140
150
|
|
|
141
151
|
// ── report ──────────────────────────────────────────────────────────────────────────────────────
|
|
152
|
+
// dir is the created project directory <parent>/<name>; parent is the --dir (or default) root the
|
|
153
|
+
// name was appended under — the two together state the parent contract explicitly.
|
|
142
154
|
if (json) {
|
|
143
|
-
console.log(JSON.stringify({ name, dir, branch, hub, card }));
|
|
155
|
+
console.log(JSON.stringify({ name, parent: devRoot, dir, branch, hub, card }));
|
|
144
156
|
} else {
|
|
145
157
|
console.log(`✓ ${dir} (${branch}${from ? ", cloned" : adopt ? ", adopted" : ""})`);
|
|
146
158
|
console.log(`✓ CLAUDE.md seeded${brief ? " from the brief" : " (no brief — add the project's what/why/goal)"}`);
|
package/bin/patrol.mjs
CHANGED
|
@@ -43,6 +43,11 @@ function rowMatchesRunner(row, runner) {
|
|
|
43
43
|
return !rp || rp === runnerProject(runner);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
function seatProvider(agent) {
|
|
47
|
+
if (["codex", "kimi", "claude", "gemini", "dsh", "opencode"].includes(agent)) return null;
|
|
48
|
+
return agent === "glm" ? "zai-coding-plan" : agent;
|
|
49
|
+
}
|
|
50
|
+
|
|
46
51
|
function sortedProjects(projects) {
|
|
47
52
|
return [...projects].sort((a, b) => displayProject(a).localeCompare(displayProject(b)));
|
|
48
53
|
}
|
|
@@ -76,6 +81,7 @@ export function buildPatrolReport(rawInventory = {}, reaped = [], { bus = busDir
|
|
|
76
81
|
const workspaceIds = new Set(workspaces.map(w => String(w?.id || "")).filter(Boolean));
|
|
77
82
|
const orphans = [];
|
|
78
83
|
const ambiguous = [];
|
|
84
|
+
const warnings = [];
|
|
79
85
|
|
|
80
86
|
for (const runner of runners) {
|
|
81
87
|
if (isBusInternalRunner(runner, bus)) continue;
|
|
@@ -85,6 +91,18 @@ export function buildPatrolReport(rawInventory = {}, reaped = [], { bus = busDir
|
|
|
85
91
|
} else if (!rows.some(row => rowMatchesRunner(row, runner))) {
|
|
86
92
|
orphans.push({ type: "live-runner-without-row", project: p, agent: runner.agent, pid: runner.pid, dir: runner.dir });
|
|
87
93
|
}
|
|
94
|
+
const expectedProvider = seatProvider(String(runner?.agent || ""));
|
|
95
|
+
const actualProvider = String(runner?.model || "").split("/")[0];
|
|
96
|
+
if (expectedProvider && actualProvider && actualProvider !== expectedProvider) {
|
|
97
|
+
warnings.push({
|
|
98
|
+
type: "seat-model-provider-mismatch",
|
|
99
|
+
project: p,
|
|
100
|
+
agent: runner.agent,
|
|
101
|
+
model: runner.model,
|
|
102
|
+
expectedProvider,
|
|
103
|
+
pid: runner.pid,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
88
106
|
}
|
|
89
107
|
|
|
90
108
|
for (const ws of workspaces) {
|
|
@@ -124,7 +142,7 @@ export function buildPatrolReport(rawInventory = {}, reaped = [], { bus = busDir
|
|
|
124
142
|
};
|
|
125
143
|
}
|
|
126
144
|
|
|
127
|
-
return { projects: out, orphans, ambiguous, reaped };
|
|
145
|
+
return { projects: out, orphans, ambiguous, warnings, reaped };
|
|
128
146
|
}
|
|
129
147
|
|
|
130
148
|
function oldEnough(path, now, maxAgeMs) {
|
|
@@ -196,6 +214,10 @@ export function formatHuman(report) {
|
|
|
196
214
|
for (const item of report.orphans) lines.push(` - ${item.type}: ${displayProject(item.project)} ${item.agent || item.title || item.handle || item.id || ""}`.trimEnd());
|
|
197
215
|
lines.push(`ambiguous: ${report.ambiguous.length}`);
|
|
198
216
|
for (const item of report.ambiguous) lines.push(` - ${item.type}: ${item.agent || item.title || item.dir || item.id || ""}`.trimEnd());
|
|
217
|
+
lines.push(`warnings: ${report.warnings?.length || 0}`);
|
|
218
|
+
for (const item of report.warnings || []) {
|
|
219
|
+
lines.push(` - ${item.type}: ${displayProject(item.project)} ${item.agent} runs ${item.model}; expected ${item.expectedProvider}/*`);
|
|
220
|
+
}
|
|
199
221
|
lines.push(`reaped: ${report.reaped.length}`);
|
|
200
222
|
for (const item of report.reaped) lines.push(` - ${item.type}: ${item.path || item.output || ""}`.trimEnd());
|
|
201
223
|
return `${lines.join("\n")}\n`;
|
package/hooks/lib/resources.mjs
CHANGED
|
@@ -22,6 +22,16 @@ const TIMEOUT = 2000; // contract: ev
|
|
|
22
22
|
|
|
23
23
|
const busDir = () => process.env.RELAY_DATA_DIR || join(homedir(), ".agent-bus");
|
|
24
24
|
|
|
25
|
+
function opencodeDefaultModel() {
|
|
26
|
+
try {
|
|
27
|
+
const home = process.env.HOME || homedir();
|
|
28
|
+
const configDir = process.env.XDG_CONFIG_HOME || join(home, ".config");
|
|
29
|
+
const config = JSON.parse(readFileSync(join(configDir, "opencode", "opencode.json"), "utf8"));
|
|
30
|
+
const model = config?.model;
|
|
31
|
+
return /^[^\s/]+\/[^\s/]+$/.test(model) ? String(model) : "";
|
|
32
|
+
} catch { return ""; }
|
|
33
|
+
}
|
|
34
|
+
|
|
25
35
|
// Run a subprocess, return stdout; "" on ANY failure (missing binary, nonzero exit, timeout).
|
|
26
36
|
function run(cmd, args, env = {}) {
|
|
27
37
|
try {
|
|
@@ -75,7 +85,7 @@ function psTable() {
|
|
|
75
85
|
return rows;
|
|
76
86
|
}
|
|
77
87
|
|
|
78
|
-
// Live crew-runner processes → [{pid,agent,dir}]. Runner argv (crew.sh RUN_CMD) is
|
|
88
|
+
// Live crew-runner processes → [{pid,agent,dir,model}]. Runner argv (crew.sh RUN_CMD) is
|
|
79
89
|
// `node …/crew-runner.mjs <agent> <dir>` — dir is the LAST argument, so the regex is anchored
|
|
80
90
|
// on end-of-string. project=null → all runners; project given → only runners whose dir resolves
|
|
81
91
|
// to that project. Resolution is the lib/project.mjs walk (git-root basename, else dir basename)
|
|
@@ -84,6 +94,7 @@ function psTable() {
|
|
|
84
94
|
export function liveRunners(project = null) {
|
|
85
95
|
try {
|
|
86
96
|
const out = [];
|
|
97
|
+
const globalModel = opencodeDefaultModel();
|
|
87
98
|
for (const { pid, cmd } of psTable()) {
|
|
88
99
|
const m = cmd.match(/crew-runner\.mjs\s+(\S+)\s+(\S+)\s*$/);
|
|
89
100
|
if (!m) continue;
|
|
@@ -92,7 +103,13 @@ export function liveRunners(project = null) {
|
|
|
92
103
|
const name = basename(gitRoot(dir) || dir);
|
|
93
104
|
if (name !== project) continue;
|
|
94
105
|
}
|
|
95
|
-
|
|
106
|
+
// CREW_MODEL is fixed for the runner lifetime. Read only that named environment field —
|
|
107
|
+
// never return the rest of `ps eww`, which can contain provider credentials.
|
|
108
|
+
const envLine = run("ps", ["eww", "-p", String(pid), "-o", "command="]);
|
|
109
|
+
const pinnedModel = (envLine.match(/(?:^|\s)CREW_MODEL=([^\s]*)/) || [])[1] || "";
|
|
110
|
+
const model = pinnedModel || globalModel;
|
|
111
|
+
const modelSource = pinnedModel ? "crew" : (globalModel ? "opencode-global" : "");
|
|
112
|
+
out.push({ pid, agent, dir, model, modelSource });
|
|
96
113
|
}
|
|
97
114
|
return out;
|
|
98
115
|
} catch { return []; }
|
package/lib/classify-failure.mjs
CHANGED
|
@@ -8,10 +8,18 @@
|
|
|
8
8
|
// matched AUTH_MARKER_RE's bare "forbidden", and the codex lesson "retries burn quota" matched
|
|
9
9
|
// the exhausted rule. Three fixes, one per failure mode:
|
|
10
10
|
// · stripPromptEcho — a prompt line reappearing in the err stream is the CLI REPLAYING what it
|
|
11
|
-
// was told, not the CLI speaking; classification sees only the CLI's own output.
|
|
11
|
+
// was told, not the CLI speaking; classification sees only the CLI's own output. The exact-
|
|
12
|
+
// match version (9b28036) caught nothing in the wild: the qwen specimen (turn 9, 2026-09-02,
|
|
13
|
+
// card #5868) echoed its CONTRACT — the #6049 wake text is ABOUT a hub 401, dense with "401",
|
|
14
|
+
// "unknown identity", "credentials" — wrapped in CLI framing no prompt line equals verbatim.
|
|
15
|
+
// The strip now normalizes (ANSI off, whitespace collapsed) and drops a line that CONTAINS a
|
|
16
|
+
// prompt line or is a wrapped FRAGMENT of one, so replay is caught however the CLI frames it.
|
|
12
17
|
// · looksLikeAuthDeath — the #5405 exit-0 escalation fires only on a SHORT error-only output
|
|
13
18
|
// (the opencode "401 Unauthorized" specimen is a couple of lines); a long output is a real
|
|
14
|
-
// answer, and a warning inside it must not fail the turn.
|
|
19
|
+
// answer, and a warning inside it must not fail the turn. AND never when the turn produced
|
|
20
|
+
// REAL WORK (a new commit): the qwen specimen exited 0, committed aa3c340, and its captured
|
|
21
|
+
// stream still held under 400 bytes of contract echo carrying "401" — a short capture is not
|
|
22
|
+
// proof of a dead turn, but a shipped commit is proof of a live one.
|
|
15
23
|
// · classifyFailure — "exhausted" demands an explicit quota/rate-limit message; the broad bare
|
|
16
24
|
// words ("credit", "balance", bare "insufficient") labelled ordinary prose on a dead turn and
|
|
17
25
|
// sent the operator to wait out a window that did not exist.
|
|
@@ -19,25 +27,58 @@ import { readFileSync } from "node:fs";
|
|
|
19
27
|
|
|
20
28
|
export const AUTH_MARKER_RE = /unauthor|401|403|forbidden|invalid[ _-]?api[ _-]?key|authentication? failed|token expired/i;
|
|
21
29
|
|
|
22
|
-
/** Prompt lines (≥40 chars — a short line carries no signature) echoed back
|
|
23
|
-
*
|
|
30
|
+
/** Prompt lines (≥40 chars — a short line carries no signature) echoed back by the CLI are
|
|
31
|
+
* replay, not speech. Echoes are rarely byte-identical (CLI framing, terminal wrapping, ANSI
|
|
32
|
+
* colors — the exact-match strip caught nothing in the qwen #6049 specimen), so both sides are
|
|
33
|
+
* normalized (ANSI stripped, whitespace collapsed) and a long line is dropped when it CONTAINS
|
|
34
|
+
* a prompt line, IS a fragment of one, or contains a ≥40-char RUN of one — terminal wrapping
|
|
35
|
+
* breaks the line but preserves long runs inside each wrapped piece. */
|
|
36
|
+
const ECHO_RUN = 40;
|
|
24
37
|
export function stripPromptEcho(errText, promptText) {
|
|
25
38
|
const text = String(errText || "");
|
|
26
39
|
if (!promptText) return text;
|
|
27
|
-
const
|
|
28
|
-
|
|
40
|
+
const norm = (l) => String(l).replace(/\x1b\[[0-9;]*[A-Za-z]/g, "").replace(/\s+/g, " ").trim();
|
|
41
|
+
const prompts = String(promptText).split("\n").map(norm).filter(l => l.length >= 40);
|
|
42
|
+
if (!prompts.length) return text;
|
|
43
|
+
const hasRun = (p, n) => {
|
|
44
|
+
for (let i = 0; i + ECHO_RUN <= p.length; i++) if (n.includes(p.slice(i, i + ECHO_RUN))) return true;
|
|
45
|
+
return false;
|
|
46
|
+
};
|
|
47
|
+
return text.split("\n").filter(line => {
|
|
48
|
+
const n = norm(line);
|
|
49
|
+
// Short lines survive — no signature, nothing to match against.
|
|
50
|
+
if (n.length < 40) return true;
|
|
51
|
+
return !prompts.some(p => n.includes(p) || p.includes(n) || hasRun(p, n));
|
|
52
|
+
}).join("\n");
|
|
29
53
|
}
|
|
30
54
|
|
|
31
55
|
/** A real answer is long; an auth death is a couple of lines. The opencode specimen (#5405)
|
|
32
56
|
* printed its whole failure in under a hundred characters and produced nothing else. */
|
|
33
57
|
export const OWN_OUTPUT_ANSWER_MIN = 400;
|
|
34
58
|
|
|
35
|
-
/** The #5405 rule, refined by #5868: exit 0 + an auth-shaped marker means FAILED only when
|
|
36
|
-
* CLI's own output is short enough to be JUST the error
|
|
37
|
-
|
|
59
|
+
/** The #5405 rule, refined twice by #5868: exit 0 + an auth-shaped marker means FAILED only when
|
|
60
|
+
* the CLI's own output is short enough to be JUST the error — and NEVER when the turn did real
|
|
61
|
+
* work (newCommit, checked by the runner via git): a shipped commit is a live turn, whatever the
|
|
62
|
+
* captured stream happens to hold. */
|
|
63
|
+
export function looksLikeAuthDeath(ownText, realWork = false) {
|
|
64
|
+
if (realWork) return false;
|
|
38
65
|
return String(ownText || "").length < OWN_OUTPUT_ANSWER_MIN && AUTH_MARKER_RE.test(ownText);
|
|
39
66
|
}
|
|
40
67
|
|
|
68
|
+
/** The one-line verdict the seat's jsonl carries (#5868): why the runner judged the turn the way
|
|
69
|
+
* it did, phrased exactly like the runner's own "classified X because Y" log — so a pane that
|
|
70
|
+
* scrolls away loses nothing that the telemetry row needs to say. */
|
|
71
|
+
export function verdictFor(realExit, effExit, emptyOutput, ownText) {
|
|
72
|
+
if (realExit === 0 && effExit === 0) return "classified success because exit 0 with CLI output";
|
|
73
|
+
if (realExit === 0 && effExit === 1) {
|
|
74
|
+
if (emptyOutput) return "classified empty-output because exit 0 with no output on either stream";
|
|
75
|
+
const m = AUTH_MARKER_RE.exec(String(ownText || ""));
|
|
76
|
+
return `classified auth because ${m ? m[0] : "auth marker"} in the CLI's own short output`;
|
|
77
|
+
}
|
|
78
|
+
const { reason, matched } = classifyFailure(realExit, String(ownText || ""), emptyOutput);
|
|
79
|
+
return `classified ${reason} because ${matched}`;
|
|
80
|
+
}
|
|
81
|
+
|
|
41
82
|
/** Classify one failed turn. Returns { reason, matched } — matched is the evidence excerpt the
|
|
42
83
|
* runner logs, so the next misclassification is diagnosable from the seat log alone. */
|
|
43
84
|
export function classifyFailure(exit, errText, emptyOutput = false) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trantor",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.31",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"trantor": "bin/cli.mjs"
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"zod": "^4.4.3"
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
|
-
"test": "node bin/slop-gate.mjs --surface desktop/src && node test.mjs && node test-scenarios.mjs && node test-failure.mjs && node test-redelivery.mjs && node test-crew-completion.mjs && node test-contracts.mjs && node test-autonomy.mjs && node test-integrate.mjs && node test-handoff.mjs && node test-handoff-summarizer.mjs && node test-baton-turn-boundary.mjs && node test-agents.mjs && node test-update.mjs && node test-handoff-guard.mjs && node test-baton-latest.mjs && node test-balances.mjs && node test-usage-live.mjs && node test-subagent-cost.mjs && node test-inbox.mjs && node test-inflight.mjs && node test-notify.mjs && node test-focus.mjs && node test-cardlog.mjs && node test-checklist.mjs && node test-relay-note.mjs && node test-reaper.mjs && node test-events.mjs && node test-proposals.mjs && node test-scrub.mjs && node test-store-delta.mjs && node test-message-re.mjs && node test-claims.mjs && node test-adopt.mjs && node test-summarize.mjs && node test-identity-core.mjs && node test-identity.mjs && node test-identity-instances.mjs && node test-duty.mjs && node test-duty-dark.mjs && node test-duty-seat.mjs && node test-discovery.mjs && node test-doctor.mjs && node test-crew-env.mjs && node test-desktop-transport.mjs && node test-crew-worktree.mjs && node test-crew-redact.mjs && node test-crew-classify.mjs && bash test-crew-herdr.sh && npm --prefix desktop run test --silent && node test-splitbrain.mjs && node test-overseer.mjs && node test-overseer-lib.mjs && node test-overseer-warn.mjs && node test-provider-keys.mjs && node test-provider-cli.mjs && node test-inbox-delivery.mjs && node test-identity-drift.mjs && node test-inbox-staleness.mjs && node test-seats.mjs && node test-seat-identity.mjs && node test-hub-routing.mjs && node test-hook-routing.mjs && node test-relay-wait.mjs && node test-dsh-seat.mjs && node test-kimi-bridge.mjs && node test-kimi-events.mjs && python3 engine/test-routing.py && node test-new.mjs && node test-reconcile.mjs && node test-resources.mjs && node test-patrol.mjs && node test-bridge.mjs && bash test-crew.sh"
|
|
14
|
+
"test": "node bin/slop-gate.mjs --surface desktop/src && node test.mjs && node test-scenarios.mjs && node test-failure.mjs && node test-redelivery.mjs && node test-crew-completion.mjs && node test-contracts.mjs && node test-autonomy.mjs && node test-integrate.mjs && node test-handoff.mjs && node test-handoff-summarizer.mjs && node test-baton-turn-boundary.mjs && node test-agents.mjs && node test-update.mjs && node test-handoff-guard.mjs && node test-baton-latest.mjs && node test-balances.mjs && node test-usage-live.mjs && node test-subagent-cost.mjs && node test-inbox.mjs && node test-inflight.mjs && node test-notify.mjs && node test-focus.mjs && node test-cardlog.mjs && node test-checklist.mjs && node test-relay-note.mjs && node test-reaper.mjs && node test-events.mjs && node test-proposals.mjs && node test-scrub.mjs && node test-store-delta.mjs && node test-message-re.mjs && node test-claims.mjs && node test-adopt.mjs && node test-summarize.mjs && node test-identity-core.mjs && node test-identity.mjs && node test-identity-instances.mjs && node test-duty.mjs && node test-duty-dark.mjs && node test-duty-seat.mjs && node test-discovery.mjs && node test-doctor.mjs && node test-crew-env.mjs && node test-desktop-transport.mjs && node test-crew-worktree.mjs && node test-crew-redact.mjs && node test-crew-classify.mjs && bash test-crew-herdr.sh && npm --prefix desktop run test --silent && node test-splitbrain.mjs && node test-overseer.mjs && node test-overseer-lib.mjs && node test-overseer-warn.mjs && node test-provider-keys.mjs && node test-provider-cli.mjs && node test-crew-model-defaults.mjs && node test-inbox-delivery.mjs && node test-identity-drift.mjs && node test-inbox-staleness.mjs && node test-seats.mjs && node test-seat-identity.mjs && node test-hub-routing.mjs && node test-hook-routing.mjs && node test-relay-wait.mjs && node test-dsh-seat.mjs && node test-kimi-bridge.mjs && node test-kimi-events.mjs && python3 engine/test-routing.py && node test-new.mjs && node test-reconcile.mjs && node test-resources.mjs && node test-patrol.mjs && node test-bridge.mjs && bash test-crew.sh"
|
|
15
15
|
},
|
|
16
16
|
"description": "The hub-world for AI agent crews — orchestrate Claude Code, Codex, GLM, Kimi, DeepSeek & any OpenRouter model as live crews with a plan-aware Advisor, a Kanban/flow command center, a testing gate, and an economics brain (Scrooge).",
|
|
17
17
|
"files": [
|