trantor 0.17.45 → 0.17.47
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 +66 -41
- package/bin/cli.mjs +4 -0
- package/bin/crew-runner.mjs +8 -2
- package/bin/crew.sh +10 -10
- package/bin/doctor.mjs +1 -1
- package/bin/models.mjs +67 -0
- package/bin/provider.mjs +115 -0
- package/engine/bin/scrooge +15 -4
- package/engine/bin/scrooge-capabilities +71 -5
- package/engine/test-routing.py +55 -0
- package/package.json +3 -3
- package/skills/crew/SKILL.md +9 -5
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
},
|
|
7
7
|
"metadata": {
|
|
8
8
|
"description": "Trantor — the hub-world for AI agent crews: live message bus, presence, project Kanban/flow board + context-handoff for independent AI coding agents (Claude, Codex, Gemini, …)",
|
|
9
|
-
"version": "0.17.
|
|
9
|
+
"version": "0.17.47"
|
|
10
10
|
},
|
|
11
11
|
"plugins": [
|
|
12
12
|
{
|
|
13
13
|
"name": "trantor",
|
|
14
14
|
"source": "./",
|
|
15
15
|
"description": "The hub-world for AI agent crews. Say \"fire up the crew\" and Claude becomes the architect: a plan-aware Advisor routes the work (solo / cheap inline calls / live crew of Codex, GLM, Kimi & DeepSeek in their own terminal windows), a Kanban/flow command center with a testing gate tracks it, and an economics brain (Scrooge) keeps the receipts. Includes the relay MCP, a SessionStart auto-discovery hook, and a PreCompact context-handoff so a fresh session can take over a full window instead of compacting.",
|
|
16
|
-
"version": "0.17.
|
|
16
|
+
"version": "0.17.47",
|
|
17
17
|
"author": {
|
|
18
18
|
"name": "Sasha Bogojevic"
|
|
19
19
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trantor",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.47",
|
|
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/advise.mjs
CHANGED
|
@@ -19,52 +19,73 @@ import { pathToFileURL } from "node:url";
|
|
|
19
19
|
const H = homedir();
|
|
20
20
|
const read = (p, fb) => { try { return JSON.parse(readFileSync(p, "utf8")); } catch { return fb; } };
|
|
21
21
|
|
|
22
|
-
// ----
|
|
23
|
-
// Each
|
|
24
|
-
//
|
|
25
|
-
//
|
|
22
|
+
// ---- crew roster: BUILT-IN seats + ANY opencode provider the user has brought (BYOM) ----
|
|
23
|
+
// Each seat: the CLI binary that must exist (`cli`) · the `trantor up` LAUNCH spec · the bus
|
|
24
|
+
// SESSION label (its identity on the board) · the profile PROVIDER key (tier/cost) · for
|
|
25
|
+
// opencode-driven seats, the opencode PROVIDER id (`providerOc`) used to enumerate models + auth.
|
|
26
26
|
//
|
|
27
|
-
// GEMINI is deliberately
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// live-selects the best OpenRouter model for the work's difficulty (or pin one:
|
|
42
|
-
// `openrouter:openrouter/<vendor>/<model>`). The model picked is what determines its strength,
|
|
43
|
-
// so it sits LAST in every CREW_PREF tier — a wildcard that fills once the proven native seats
|
|
44
|
-
// are taken, and the ONLY seat for a user who brought nothing but an OpenRouter key.
|
|
45
|
-
openrouter: { cli: "opencode", launch: "openrouter:openrouter", session: "openrouter", provider: "openrouter" },
|
|
27
|
+
// GEMINI is deliberately absent: Google retired the free CLI seat (2026-06-18) → `gemini --yolo`
|
|
28
|
+
// crashes exit 1. Its replacement is GLM via opencode.
|
|
29
|
+
//
|
|
30
|
+
// The opencode-driven seats are the BYOM substrate: opencode is a UNIVERSAL adapter, so any
|
|
31
|
+
// provider the user configures in opencode (or declares in their profile) becomes a crew seat
|
|
32
|
+
// with ZERO code change here — `buildRoster()` discovers them at runtime. The built-ins below are
|
|
33
|
+
// just the curated defaults + the two opencode seats with non-obvious mappings (glm: profile key
|
|
34
|
+
// `zai` ↔ opencode provider `zai-coding-plan`).
|
|
35
|
+
export const BUILTIN_ROSTER = {
|
|
36
|
+
codex: { cli: "codex", launch: "codex", session: "codex", provider: "codex" },
|
|
37
|
+
kimi: { cli: "kimi", launch: "kimi", session: "kimi", provider: "kimi" },
|
|
38
|
+
deepseek: { cli: "opencode", launch: "deepseek:deepseek", session: "deepseek", provider: "deepseek", providerOc: "deepseek" },
|
|
39
|
+
glm: { cli: "opencode", launch: "opencode:zai-coding-plan", session: "opencode", provider: "zai", providerOc: "zai-coding-plan" },
|
|
40
|
+
openrouter: { cli: "opencode", launch: "openrouter:openrouter", session: "openrouter", provider: "openrouter", providerOc: "openrouter" },
|
|
46
41
|
};
|
|
42
|
+
// opencode provider ids already claimed by a built-in (so discovery never duplicates them) + the
|
|
43
|
+
// names that are native CLIs / built-in profile aliases (never opencode-driven seats).
|
|
44
|
+
const BUILTIN_OC = new Set(Object.values(BUILTIN_ROSTER).filter(s => s.providerOc).map(s => s.providerOc));
|
|
45
|
+
const NEVER_DISCOVER = new Set(["claude", "codex", "kimi", "gemini", "zai", "opencode"]);
|
|
46
|
+
|
|
47
|
+
// Discover opencode providers the user has configured — from opencode.json `provider` keys AND
|
|
48
|
+
// from profile providers declared via `trantor provider add` — that aren't already built-in. Each
|
|
49
|
+
// becomes an opencode-driven seat under its OWN bus label (distinct session, no collisions). THIS
|
|
50
|
+
// is what lets a brought provider (Inception, a Japanese model, any opencode vendor) light up a
|
|
51
|
+
// seat with no code edit. T2's capability ingestion then makes it route well by difficulty.
|
|
52
|
+
export function discoverSeats(profile, ocConfig) {
|
|
53
|
+
const out = {};
|
|
54
|
+
const provKeys = new Set([...Object.keys(ocConfig?.provider || {}), ...Object.keys(profile?.providers || {})]);
|
|
55
|
+
for (const p of provKeys) {
|
|
56
|
+
if (BUILTIN_OC.has(p) || NEVER_DISCOVER.has(p)) continue;
|
|
57
|
+
const label = String(p).toLowerCase().replace(/[^a-z0-9-]/g, "-");
|
|
58
|
+
out[label] = { cli: "opencode", launch: `${label}:${p}`, session: label, provider: p, providerOc: p, discovered: true };
|
|
59
|
+
}
|
|
60
|
+
return out;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function buildRoster(profile, ocConfig) {
|
|
64
|
+
return { ...BUILTIN_ROSTER, ...discoverSeats(profile, ocConfig) };
|
|
65
|
+
}
|
|
47
66
|
|
|
48
67
|
export function loadWorld() {
|
|
49
68
|
const profile = read(join(H, ".agent-bus", "profile.json"), { providers: {} });
|
|
50
69
|
const registry = read(join(H, ".token-scrooge", "registry.json"), { models: {}, tasks: {} });
|
|
51
70
|
const caps = read(join(H, ".token-scrooge", "capabilities.json"), {});
|
|
71
|
+
const ocConfig = read(join(H, ".config", "opencode", "opencode.json"), {});
|
|
72
|
+
const roster = buildRoster(profile, ocConfig);
|
|
52
73
|
const has = (c) => { try { execSync(`command -v ${c}`, { stdio: "ignore", shell: "/bin/sh" }); return true; } catch { return false; } };
|
|
53
|
-
const opencodeKey = (prov) => !!
|
|
74
|
+
const opencodeKey = (prov) => !!ocConfig?.provider?.[prov]?.options?.apiKey;
|
|
54
75
|
// a key the user already has for Scrooge counts too — the opencode runner sources these .env
|
|
55
|
-
// files, so OPENROUTER_API_KEY in ~/.token-scrooge/.env lights up the
|
|
76
|
+
// files, so e.g. OPENROUTER_API_KEY in ~/.token-scrooge/.env lights up the seat with no extra setup.
|
|
56
77
|
const envHasKey = (k) => !!process.env[k] || [join(H, ".token-scrooge", ".env"), join(H, ".agent-bus", ".env")]
|
|
57
78
|
.some(f => { try { return readFileSync(f, "utf8").includes(k); } catch { return false; } });
|
|
58
|
-
// a seat is available only if its CLI exists AND
|
|
59
|
-
// binary with a dead/missing seat
|
|
79
|
+
// a seat is available only if its CLI exists AND (for opencode-driven seats) the provider is
|
|
80
|
+
// actually set up — a present binary with a dead/missing seat must NOT be recommended.
|
|
60
81
|
const hasSeat = (tok) => {
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
-
return
|
|
82
|
+
const s = roster[tok]; if (!s || !has(s.cli)) return false;
|
|
83
|
+
if (s.cli !== "opencode") return true; // native CLI present = ready
|
|
84
|
+
const envKey = `${String(s.providerOc).toUpperCase().replace(/[^A-Z0-9]/g, "_")}_API_KEY`;
|
|
85
|
+
return opencodeKey(s.providerOc) || envHasKey(envKey) || !!profile?.providers?.[s.provider];
|
|
65
86
|
};
|
|
66
|
-
const agents = Object.keys(
|
|
67
|
-
return { profile, registry, caps, agents, scrooge: has("scrooge") };
|
|
87
|
+
const agents = Object.keys(roster).filter(hasSeat);
|
|
88
|
+
return { profile, registry, caps, roster, agents, scrooge: has("scrooge") };
|
|
68
89
|
}
|
|
69
90
|
|
|
70
91
|
const tierOf = (profile, prov) => profile?.providers?.[prov]?.tier || "api";
|
|
@@ -86,7 +107,11 @@ const FORECAST = { easy: 0.3e6, medium: 1.5e6, hard: 6e6 }; // tokens
|
|
|
86
107
|
const CREW_PREF = { hard: ["codex", "glm", "kimi", "deepseek", "openrouter"], medium: ["kimi", "glm", "codex", "deepseek", "openrouter"], easy: ["deepseek", "kimi", "glm", "codex", "openrouter"] };
|
|
87
108
|
|
|
88
109
|
export function advise(input, world = loadWorld()) {
|
|
89
|
-
const { profile, registry, caps, agents, scrooge } = world;
|
|
110
|
+
const { profile, registry, caps, agents, scrooge, roster = BUILTIN_ROSTER } = world;
|
|
111
|
+
// brought (discovered) opencode providers extend the preference list — appended LAST in every
|
|
112
|
+
// tier (unknown strength a priori, like openrouter), so they fill once the curated seats are
|
|
113
|
+
// taken, and are the only option for a user who brought nothing but a custom provider.
|
|
114
|
+
const broughtPref = Object.keys(roster).filter(t => roster[t].discovered && !CREW_PREF.hard.includes(t));
|
|
90
115
|
const pkgs = (input.packages || []).map(p => ({ title: p.title || "work", difficulty: ["easy", "medium", "hard"].includes(p.difficulty) ? p.difficulty : "medium", kind: p.kind || "code", owner: p.owner === "self" ? "self" : (/(foundation|integration|scaffold)/i.test(p.title) ? "self" : "") }));
|
|
91
116
|
const horizon = input.horizon || (pkgs.length >= 4 ? "long" : pkgs.length >= 2 ? "medium" : "short");
|
|
92
117
|
const orchTier = tierOf(profile, "claude");
|
|
@@ -121,10 +146,10 @@ export function advise(input, world = loadWorld()) {
|
|
|
121
146
|
}
|
|
122
147
|
if (p.owner === "self") return { ...p, executor: "orchestrator", pool: tierOf(profile, "claude"), reason: "architect-owned (foundation/integration doctrine) — the orchestrator keeps the shared contract in its own hands" };
|
|
123
148
|
if (mode === "solo") return { ...p, executor: "orchestrator", pool: tierOf(profile, "claude"), reason: "small enough to do inline" };
|
|
124
|
-
const pref = CREW_PREF[p.difficulty].filter(a => agents.includes(a));
|
|
149
|
+
const pref = [...CREW_PREF[p.difficulty], ...broughtPref].filter(a => agents.includes(a));
|
|
125
150
|
const agent = pref.sort((a, b) => (used[a] || 0) - (used[b] || 0))[0] || agents[0] || "deepseek";
|
|
126
151
|
used[agent] = (used[agent] || 0) + 1;
|
|
127
|
-
const pool = tierOf(profile,
|
|
152
|
+
const pool = tierOf(profile, roster[agent]?.provider || agent);
|
|
128
153
|
let est = null;
|
|
129
154
|
if (pool === "api") { // deepseek API etc — estimate real $ via registry
|
|
130
155
|
const m = registry.models?.["deepseek-v4-flash"] || { cost_in: 0.14, cost_out: 0.28 };
|
|
@@ -135,10 +160,10 @@ export function advise(input, world = loadWorld()) {
|
|
|
135
160
|
: p.difficulty === "medium"
|
|
136
161
|
? `medium → solid mid-tier (${agent}) keeps frontier seats free for hard work; ${pool === "api" ? "metered" : "quota"} pool`
|
|
137
162
|
: `easy → cheapest seat (${agent})`;
|
|
138
|
-
// OpenRouter live-select ranks
|
|
139
|
-
//
|
|
140
|
-
//
|
|
141
|
-
if (agent === "openrouter" && p.difficulty === "hard") why_r += ` —
|
|
163
|
+
// OpenRouter live-select ranks capability×cost ACROSS the catalog once `scrooge-capabilities`
|
|
164
|
+
// has scored it (AA scores + price proxy + per-difficulty cost weighting → hard escalates to a
|
|
165
|
+
// strong model, easy stays cheap). If it hasn't been run, routing falls back to cost-only.
|
|
166
|
+
if (agent === "openrouter" && p.difficulty === "hard") why_r += ` — OpenRouter ranks capability×cost; run \`scrooge-capabilities\` to keep the catalog scored (or pin openrouter:openrouter/<vendor>/<model>)`;
|
|
142
167
|
return { ...p, executor: agent, pool, est_cost_usd: est, reason: why_r };
|
|
143
168
|
});
|
|
144
169
|
// crew-size rationale: seats are EMERGENT from the work, and we say so
|
|
@@ -165,7 +190,7 @@ export function advise(input, world = loadWorld()) {
|
|
|
165
190
|
const selfPkgs = routing.filter(r => r.executor === "orchestrator");
|
|
166
191
|
const foundationIdx = selfPkgs.length ? [1] : [];
|
|
167
192
|
const cards = routing.map((r, i) => {
|
|
168
|
-
const seat =
|
|
193
|
+
const seat = roster[r.executor];
|
|
169
194
|
return {
|
|
170
195
|
order: i + 1, title: r.title, difficulty: r.difficulty,
|
|
171
196
|
// bus identity = the runner's session name (spec's agent part) — glm rides the `opencode`
|
package/bin/cli.mjs
CHANGED
|
@@ -18,6 +18,8 @@ switch (cmd) {
|
|
|
18
18
|
case "doctor": run("bin/doctor.mjs"); break;
|
|
19
19
|
case "connect": run("bin/connect.mjs"); break;
|
|
20
20
|
case "profile": run("bin/profile.mjs"); break;
|
|
21
|
+
case "provider": case "providers": run("bin/provider.mjs"); break;
|
|
22
|
+
case "models": run("bin/models.mjs"); break;
|
|
21
23
|
case "advise": run("bin/advise.mjs"); break;
|
|
22
24
|
case "verify": run("bin/crew-verify.mjs"); break;
|
|
23
25
|
case "up": process.argv.splice(2, 1); spawn("/bin/bash", [join(ROOT, "bin/crew.sh"), "up", ...args], { stdio: "inherit", cwd: process.cwd() }).on("exit", c => process.exit(c ?? 0)); break;
|
|
@@ -49,6 +51,8 @@ switch (cmd) {
|
|
|
49
51
|
trantor doctor where do I stand? hub/plugin/CLIs/auth/keys/profile, with copy-paste fixes
|
|
50
52
|
trantor connect (re)wire every installed AI CLI to the bus
|
|
51
53
|
trantor profile declare your plans: trantor profile set claude=max codex=plus deepseek=api
|
|
54
|
+
trantor provider bring ANY model (BYOM): list seats · add <name> --key … · remove <name>
|
|
55
|
+
trantor models browse live models behind each seat + the router's pick per difficulty
|
|
52
56
|
trantor up … spawn a crew here: trantor up codex kimi deepseek:deepseek opencode:zai-coding-plan
|
|
53
57
|
trantor down tear the crew down (kills processes, closes windows, no dialogs)
|
|
54
58
|
trantor ui open the live dashboard (board + flow views)
|
package/bin/crew-runner.mjs
CHANGED
|
@@ -78,8 +78,14 @@ const CLI = {
|
|
|
78
78
|
claude: { first: `claude{M} -p "$(cat {P})" --dangerously-skip-permissions`,
|
|
79
79
|
next: `claude -c{M} -p "$(cat {P})" --dangerously-skip-permissions`, mflag: " --model " },
|
|
80
80
|
};
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
// BYOM: any agent label that isn't a known native CLI is treated as an opencode-driven provider
|
|
82
|
+
// seat (opencode is the universal adapter). This is what lets a BROUGHT provider — `trantor up
|
|
83
|
+
// <label>:<provider>` for any opencode vendor the user configured — run with no per-provider code
|
|
84
|
+
// here; its model id arrives pre-qualified (`<provider>/<model>`) as CREW_MODEL.
|
|
85
|
+
const NATIVE = new Set(["codex", "gemini", "kimi", "claude"]);
|
|
86
|
+
const cli = CLI[AGENT] || (NATIVE.has(AGENT) ? null : CLI.opencode);
|
|
87
|
+
if (!cli) { console.error(`unknown agent '${AGENT}' (native: ${[...NATIVE].join(", ")}; any other name = an opencode provider seat)`); process.exit(1); }
|
|
88
|
+
if (!CLI[AGENT]) log(`'${AGENT}' is not a built-in seat — running it as an opencode provider (BYOM)`);
|
|
83
89
|
|
|
84
90
|
const RULES = `Rules: you are ${SESSION} on the trantor crew. Work your assigned file(s), report on the bus (relay_send, <280 chars), move your Kanban card as you go (doing -> testing -> done; run the tests in 'testing', use 'failed' + a report if they break). When your work for THIS message is finished, END YOUR TURN — do NOT park, do NOT loop relay_wait; the runner waits for you and will wake you with the next message.`;
|
|
85
91
|
|
package/bin/crew.sh
CHANGED
|
@@ -70,18 +70,18 @@ SCROOGE="$BUS_DIR/engine/bin/scrooge"
|
|
|
70
70
|
[ -f "$SCROOGE" ] || SCROOGE="$(command -v scrooge 2>/dev/null || echo scrooge)"
|
|
71
71
|
|
|
72
72
|
# resolve_model <agent> <provider> <task> <diff> -> echoes a runner-ready model id, or empty
|
|
73
|
-
# (→ CLI default).
|
|
74
|
-
#
|
|
73
|
+
# (→ CLI default). PROVIDER-AGNOSTIC: if opencode knows the provider (ANY of its vendors — built-in
|
|
74
|
+
# or BROUGHT), enumerate via `opencode models <provider>`; else self-enumerate via the provider's
|
|
75
|
+
# OpenAI-compatible /models. No hardcoded provider list — a newly-brought opencode provider routes
|
|
76
|
+
# with zero change here. Never guesses an endpoint.
|
|
75
77
|
resolve_model() {
|
|
76
78
|
local agent="$1" provider="$2" task="$3" diff="$4" cands="" out=""
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
out="$(python3 "$SCROOGE" route --provider "$provider" -t "$task" -d "$diff" --json 2>/dev/null)" ;;
|
|
84
|
-
esac
|
|
79
|
+
cands="$(opencode models "$provider" 2>/dev/null | tr '\n' ' ')"
|
|
80
|
+
if [ -n "$cands" ]; then
|
|
81
|
+
out="$(python3 "$SCROOGE" route --candidates "$cands" -t "$task" -d "$diff" --json 2>/dev/null)"
|
|
82
|
+
else
|
|
83
|
+
out="$(python3 "$SCROOGE" route --provider "$provider" -t "$task" -d "$diff" --json 2>/dev/null)"
|
|
84
|
+
fi
|
|
85
85
|
[ -n "$out" ] || { echo "[crew] live model selection failed for $agent:$provider — CLI default" >&2; return 0; }
|
|
86
86
|
printf '%s' "$out" | python3 -c 'import json,sys
|
|
87
87
|
try: print(json.load(sys.stdin).get("qualified") or "")
|
package/bin/doctor.mjs
CHANGED
|
@@ -64,7 +64,7 @@ const CLIS = [
|
|
|
64
64
|
// OpenRouter — the BYOM on-ramp: ONE key fronts hundreds of models. Rides opencode; the same
|
|
65
65
|
// OPENROUTER_API_KEY Scrooge already uses authenticates the crew seat (the runner sources the
|
|
66
66
|
// .env files). Available the moment the key exists in env/opencode + declared `openrouter=api`.
|
|
67
|
-
{ name: "openrouter (via opencode · BYOM, hundreds of models)", bin: "opencode", wired: () => !!read(join(H, ".config", "opencode", "opencode.json"))?.mcp?.relay, auth: () => !!process.env.OPENROUTER_API_KEY || !!read(join(H, ".config", "opencode", "opencode.json"))?.provider?.openrouter?.options?.apiKey || [join(H, ".token-scrooge", ".env"), join(H, ".agent-bus", ".env")].some(f => { try { return readFileSync(f, "utf8").includes("OPENROUTER_API_KEY"); } catch { return false; } }), login: `get a key at openrouter.ai/keys, then: echo 'OPENROUTER_API_KEY=sk-or-…' >> ~/.agent-bus/.env && trantor profile set openrouter=api. Seat: trantor up openrouter (live-selects) or pin trantor up openrouter:openrouter/<vendor>/<model>` },
|
|
67
|
+
{ name: "openrouter (via opencode · BYOM, hundreds of models)", bin: "opencode", wired: () => !!read(join(H, ".config", "opencode", "opencode.json"))?.mcp?.relay, auth: () => !!process.env.OPENROUTER_API_KEY || !!read(join(H, ".config", "opencode", "opencode.json"))?.provider?.openrouter?.options?.apiKey || [join(H, ".token-scrooge", ".env"), join(H, ".agent-bus", ".env")].some(f => { try { return readFileSync(f, "utf8").includes("OPENROUTER_API_KEY"); } catch { return false; } }), login: `get a key at openrouter.ai/keys, then: echo 'OPENROUTER_API_KEY=sk-or-…' >> ~/.agent-bus/.env && trantor profile set openrouter=api && scrooge-capabilities (scores the catalog so the crew routes it by difficulty). Seat: trantor up openrouter (live-selects) or pin trantor up openrouter:openrouter/<vendor>/<model>` },
|
|
68
68
|
];
|
|
69
69
|
let installed = 0;
|
|
70
70
|
for (const c of CLIS) {
|
package/bin/models.mjs
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// trantor models — browse the live models behind your crew seats (opencode is the adapter).
|
|
3
|
+
//
|
|
4
|
+
// trantor models # every opencode-driven seat + how many live models it serves
|
|
5
|
+
// trantor models <provider> # list that provider's live models + what the router picks per
|
|
6
|
+
// # difficulty (so you can see hard→strong, easy→cheap at a glance)
|
|
7
|
+
import { execSync } from "node:child_process";
|
|
8
|
+
import { dirname, join } from "node:path";
|
|
9
|
+
import { homedir } from "node:os";
|
|
10
|
+
import { existsSync } from "node:fs";
|
|
11
|
+
import { pathToFileURL, fileURLToPath } from "node:url";
|
|
12
|
+
import { buildRoster, loadWorld } from "./advise.mjs";
|
|
13
|
+
|
|
14
|
+
const H = homedir();
|
|
15
|
+
const C = { dim: "\x1b[2m", grn: "\x1b[32m", gold: "\x1b[38;5;208m", off: "\x1b[0m" };
|
|
16
|
+
const has = (c) => { try { execSync(`command -v ${c}`, { stdio: "ignore", shell: "/bin/sh" }); return true; } catch { return false; } };
|
|
17
|
+
const SCROOGE = (() => {
|
|
18
|
+
const bundled = join(dirname(dirname(fileURLToPath(import.meta.url))), "engine", "bin", "scrooge");
|
|
19
|
+
if (existsSync(bundled)) return bundled;
|
|
20
|
+
try { return execSync("command -v scrooge", { encoding: "utf8" }).trim(); } catch { return "scrooge"; }
|
|
21
|
+
})();
|
|
22
|
+
|
|
23
|
+
const liveModels = (providerOc) => {
|
|
24
|
+
try { return execSync(`opencode models ${providerOc} 2>/dev/null`, { encoding: "utf8" }).split("\n").filter(Boolean); }
|
|
25
|
+
catch { return []; }
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
function routePick(candList, diff) {
|
|
29
|
+
try {
|
|
30
|
+
const out = execSync(`python3 ${SCROOGE} route --candidates ${JSON.stringify(candList.join(" "))} -t code -d ${diff} --json 2>/dev/null`, { encoding: "utf8" });
|
|
31
|
+
return JSON.parse(out).qualified || "?";
|
|
32
|
+
} catch { return "?"; }
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function listAll() {
|
|
36
|
+
const { roster, agents } = loadWorld();
|
|
37
|
+
if (!has("opencode")) { console.log("opencode not on PATH — it's the adapter that serves crew models. Install it, then re-run."); return; }
|
|
38
|
+
console.log("CREW MODELS — opencode-driven seats (● available now)\n");
|
|
39
|
+
for (const [label, s] of Object.entries(roster)) {
|
|
40
|
+
if (s.cli !== "opencode") continue;
|
|
41
|
+
const n = liveModels(s.providerOc).length;
|
|
42
|
+
const dot = agents.includes(label) ? `${C.grn}●${C.off}` : `${C.dim}○${C.off}`;
|
|
43
|
+
console.log(` ${dot} ${label.padEnd(14)} ${C.dim}${s.providerOc}${C.off} ${n} live models ${C.dim}trantor models ${label}${C.off}`);
|
|
44
|
+
}
|
|
45
|
+
console.log(`\n${C.dim}detail + routing preview:${C.off} trantor models <provider>`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function detail(name) {
|
|
49
|
+
const { roster } = loadWorld();
|
|
50
|
+
const seat = roster[name] || Object.values(roster).find(s => s.providerOc === name);
|
|
51
|
+
const providerOc = seat?.providerOc || name;
|
|
52
|
+
const models = liveModels(providerOc);
|
|
53
|
+
if (!models.length) { console.log(`No live models for '${providerOc}' (opencode offline / no key / unknown provider).`); return; }
|
|
54
|
+
console.log(`${C.gold}${providerOc}${C.off} — ${models.length} live models\n`);
|
|
55
|
+
for (const m of models.slice(0, 60)) console.log(` ${m}`);
|
|
56
|
+
if (models.length > 60) console.log(` ${C.dim}… +${models.length - 60} more${C.off}`);
|
|
57
|
+
if (existsSync(SCROOGE) || has("scrooge")) {
|
|
58
|
+
console.log(`\n${C.gold}router picks (code task):${C.off}`);
|
|
59
|
+
for (const d of ["easy", "medium", "hard"]) console.log(` ${d.padEnd(7)} → ${routePick(models, d)}`);
|
|
60
|
+
console.log(`${C.dim}(run scrooge-capabilities to (re)score the catalog for accurate difficulty routing)${C.off}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
65
|
+
const arg = process.argv[2];
|
|
66
|
+
if (!arg) listAll(); else detail(arg.toLowerCase());
|
|
67
|
+
}
|
package/bin/provider.mjs
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// trantor provider — bring ANY model to the crew (BYOM). opencode is a universal adapter, so a
|
|
3
|
+
// provider you configure there (or declare here) becomes a crew seat with no code change.
|
|
4
|
+
//
|
|
5
|
+
// trantor provider # list seats: built-in + discovered, with availability + tier
|
|
6
|
+
// trantor provider add <name> [--key sk-…] [--plan api|coding-plan|max] [--label <bus-name>]
|
|
7
|
+
// trantor provider remove <name> # drop it from your profile (leaves the key in place)
|
|
8
|
+
//
|
|
9
|
+
// `add` writes <NAME>_API_KEY to ~/.agent-bus/.env (if --key given), declares the plan in your
|
|
10
|
+
// quota profile, verifies opencode can see the provider's models, and prints the seat spec. The
|
|
11
|
+
// Advisor then routes to it automatically; run `scrooge-capabilities` so it routes well by difficulty.
|
|
12
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync, chmodSync, appendFileSync } from "node:fs";
|
|
13
|
+
import { join, dirname } from "node:path";
|
|
14
|
+
import { homedir } from "node:os";
|
|
15
|
+
import { execSync } from "node:child_process";
|
|
16
|
+
import { pathToFileURL } from "node:url";
|
|
17
|
+
import { buildRoster, loadWorld } from "./advise.mjs";
|
|
18
|
+
|
|
19
|
+
const H = homedir();
|
|
20
|
+
const ENV = join(H, ".agent-bus", ".env");
|
|
21
|
+
const read = (p, fb) => { try { return JSON.parse(readFileSync(p, "utf8")); } catch { return fb; } };
|
|
22
|
+
const has = (c) => { try { execSync(`command -v ${c}`, { stdio: "ignore", shell: "/bin/sh" }); return true; } catch { return false; } };
|
|
23
|
+
const C = { dim: "\x1b[2m", grn: "\x1b[32m", red: "\x1b[31m", yel: "\x1b[33m", gold: "\x1b[38;5;208m", off: "\x1b[0m" };
|
|
24
|
+
const envKeyName = (p) => `${String(p).toUpperCase().replace(/[^A-Z0-9]/g, "_")}_API_KEY`;
|
|
25
|
+
|
|
26
|
+
function opencodeModelCount(providerOc) {
|
|
27
|
+
if (!has("opencode")) return null;
|
|
28
|
+
try { return execSync(`opencode models ${providerOc} 2>/dev/null`, { encoding: "utf8" }).split("\n").filter(Boolean).length; }
|
|
29
|
+
catch { return 0; }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function listSeats() {
|
|
33
|
+
const world = loadWorld();
|
|
34
|
+
const { roster, agents, profile } = world;
|
|
35
|
+
console.log("CREW SEATS — built-in + brought (BYOM). ● = available now\n");
|
|
36
|
+
for (const [label, s] of Object.entries(roster)) {
|
|
37
|
+
const live = agents.includes(label);
|
|
38
|
+
const tier = profile?.providers?.[s.provider]?.tier || (s.cli === "opencode" ? "—" : "");
|
|
39
|
+
const kind = s.discovered ? "brought " : "built-in";
|
|
40
|
+
const models = s.cli === "opencode" ? opencodeModelCount(s.providerOc) : null;
|
|
41
|
+
const mtxt = models == null ? "" : `${models} models`;
|
|
42
|
+
const dot = live ? `${C.grn}●${C.off}` : `${C.dim}○${C.off}`;
|
|
43
|
+
console.log(` ${dot} ${label.padEnd(14)} ${C.dim}${kind}${C.off} launch: ${s.launch.padEnd(26)} ${tier ? `tier=${tier}` : ""} ${C.dim}${mtxt}${C.off}`);
|
|
44
|
+
}
|
|
45
|
+
console.log(`\n${C.dim}add one:${C.off} trantor provider add <name> --key sk-… --plan api`);
|
|
46
|
+
console.log(`${C.dim}browse models:${C.off} trantor models [<provider>]`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function addProvider(name, opts) {
|
|
50
|
+
if (!name) { console.error("usage: trantor provider add <name> [--key sk-…] [--plan api] [--label <bus-name>]"); process.exit(1); }
|
|
51
|
+
const provider = name.toLowerCase();
|
|
52
|
+
const label = (opts.label || provider).toLowerCase().replace(/[^a-z0-9-]/g, "-");
|
|
53
|
+
const plan = (opts.plan || "api").toLowerCase();
|
|
54
|
+
|
|
55
|
+
// 1) key → ~/.agent-bus/.env (the runner sources it; opencode reads <NAME>_API_KEY for known providers)
|
|
56
|
+
if (opts.key) {
|
|
57
|
+
mkdirSync(dirname(ENV), { recursive: true });
|
|
58
|
+
const k = envKeyName(provider);
|
|
59
|
+
let cur = existsSync(ENV) ? readFileSync(ENV, "utf8") : "";
|
|
60
|
+
if (new RegExp(`^${k}=`, "m").test(cur)) {
|
|
61
|
+
cur = cur.replace(new RegExp(`^${k}=.*$`, "m"), `${k}=${opts.key}`);
|
|
62
|
+
writeFileSync(ENV, cur);
|
|
63
|
+
} else {
|
|
64
|
+
appendFileSync(ENV, `${cur && !cur.endsWith("\n") ? "\n" : ""}# ${provider} — brought via 'trantor provider add'\n${k}=${opts.key}\n`);
|
|
65
|
+
}
|
|
66
|
+
try { chmodSync(ENV, 0o600); } catch {}
|
|
67
|
+
console.log(`${C.grn}✓${C.off} wrote ${envKeyName(provider)} → ~/.agent-bus/.env (chmod 600)`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// 2) declare the plan in the quota profile (drives the Advisor's tier/cost reasoning)
|
|
71
|
+
try {
|
|
72
|
+
execSync(`node ${join(dirname(new URL(import.meta.url).pathname), "profile.mjs")} set ${provider}=${plan}`, { stdio: "ignore" });
|
|
73
|
+
console.log(`${C.grn}✓${C.off} profile: ${provider}=${plan}`);
|
|
74
|
+
} catch (e) { console.log(`${C.yel}⚠${C.off} could not set profile (run: trantor profile set ${provider}=${plan})`); }
|
|
75
|
+
|
|
76
|
+
// 3) verify opencode can see the provider's models
|
|
77
|
+
const n = opencodeModelCount(provider);
|
|
78
|
+
if (n == null) console.log(`${C.yel}⚠${C.off} opencode not on PATH — install it to run this seat (it's the universal adapter)`);
|
|
79
|
+
else if (n === 0) console.log(`${C.yel}⚠${C.off} opencode lists 0 models for '${provider}'. If it's a known provider, the key above is enough; for a custom endpoint, add it to ~/.config/opencode/opencode.json (provider config). Then re-check: trantor models ${provider}`);
|
|
80
|
+
else console.log(`${C.grn}✓${C.off} opencode sees ${n} models for '${provider}'`);
|
|
81
|
+
|
|
82
|
+
// 4) score it for difficulty-aware routing + show the seat
|
|
83
|
+
console.log(`\n${C.gold}Seat ready.${C.off} Launch it:`);
|
|
84
|
+
console.log(` trantor up ${label === provider ? label : `${label}:${provider}`} ${C.dim}# live-selects the best model for the work${C.off}`);
|
|
85
|
+
console.log(` trantor up ${label}:${provider}/<model> ${C.dim}# pin a specific model${C.off}`);
|
|
86
|
+
console.log(`${C.dim}For difficulty-aware routing across its catalog, score it once (weekly):${C.off} scrooge-capabilities`);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function removeProvider(name) {
|
|
90
|
+
if (!name) { console.error("usage: trantor provider remove <name>"); process.exit(1); }
|
|
91
|
+
const FILE = join(H, ".agent-bus", "profile.json");
|
|
92
|
+
const prof = read(FILE, { providers: {} });
|
|
93
|
+
if (prof.providers && prof.providers[name.toLowerCase()]) {
|
|
94
|
+
delete prof.providers[name.toLowerCase()];
|
|
95
|
+
writeFileSync(FILE, JSON.stringify(prof, null, 2) + "\n");
|
|
96
|
+
console.log(`${C.grn}✓${C.off} removed '${name}' from your profile (the ${envKeyName(name)} key is left in place; delete it from ~/.agent-bus/.env if you want it gone)`);
|
|
97
|
+
} else {
|
|
98
|
+
console.log(`'${name}' is not in your profile.`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
103
|
+
const [, , sub, ...rest] = process.argv;
|
|
104
|
+
const opts = {}; const pos = [];
|
|
105
|
+
for (let i = 0; i < rest.length; i++) {
|
|
106
|
+
if (rest[i] === "--key") opts.key = rest[++i];
|
|
107
|
+
else if (rest[i] === "--plan") opts.plan = rest[++i];
|
|
108
|
+
else if (rest[i] === "--label") opts.label = rest[++i];
|
|
109
|
+
else pos.push(rest[i]);
|
|
110
|
+
}
|
|
111
|
+
if (!sub || sub === "list") listSeats();
|
|
112
|
+
else if (sub === "add") addProvider(pos[0], opts);
|
|
113
|
+
else if (sub === "remove" || sub === "rm") removeProvider(pos[0]);
|
|
114
|
+
else { console.error(`unknown subcommand '${sub}' — use: list | add | remove`); process.exit(1); }
|
|
115
|
+
}
|
package/engine/bin/scrooge
CHANGED
|
@@ -171,8 +171,11 @@ def model_quality(caps, mid, metric):
|
|
|
171
171
|
v = c.get("intelligence") # fall back to the general index
|
|
172
172
|
return float(v) if isinstance(v, (int, float)) else 0.0
|
|
173
173
|
|
|
174
|
-
def blended_cost(reg, mid):
|
|
175
|
-
|
|
174
|
+
def blended_cost(reg, caps, mid):
|
|
175
|
+
# The curated registry carries cost for its own models; for CATALOG models (OpenRouter's
|
|
176
|
+
# hundreds, brought via --candidates) the per-model price rides on the capability entry
|
|
177
|
+
# instead — so a brought model is ranked on its real price without bloating the registry.
|
|
178
|
+
m = reg["models"].get(mid) or (caps.get(mid) if isinstance(caps, dict) else None) or {}
|
|
176
179
|
return max(1e-6, 0.3 * m.get("cost_in", 0) + 0.7 * m.get("cost_out", 0))
|
|
177
180
|
|
|
178
181
|
def weigh_candidates(reg, caps, cand_ids, task, difficulty):
|
|
@@ -187,8 +190,16 @@ def weigh_candidates(reg, caps, cand_ids, task, difficulty):
|
|
|
187
190
|
floor = scored_q[min(len(scored_q) - 1, int(round(pct * (len(scored_q) - 1))))]
|
|
188
191
|
survivors = [(mid, q) for mid, q in quals if q >= floor] or quals
|
|
189
192
|
rw = reg.get("routing") or {}
|
|
190
|
-
qw
|
|
191
|
-
|
|
193
|
+
qw = rw.get("q_weight", 1.5)
|
|
194
|
+
# cost-weight scales DOWN as difficulty rises: EASY work optimizes price (cheap wins), HARD
|
|
195
|
+
# work prioritizes capability so it can escalate to a genuinely strong model instead of the
|
|
196
|
+
# cheapest-that-clears-the-floor (the "deepseek-flash wins everything" trap on a huge catalog).
|
|
197
|
+
# It still weighs cost (hard picks a strong *value* model, not a blind frontier overpay).
|
|
198
|
+
# Per-difficulty override via registry.routing.c_weight_<difficulty>; legacy c_weight still honored.
|
|
199
|
+
CW_BY_DIFF = {"easy": 0.65, "medium": 0.5, "hard": 0.1}
|
|
200
|
+
cw_key = "c_weight_" + str(difficulty)
|
|
201
|
+
cw = rw[cw_key] if cw_key in rw else (CW_BY_DIFF[difficulty] if difficulty in CW_BY_DIFF else rw.get("c_weight", 0.5))
|
|
202
|
+
out = [(mid, (max(q, 1e-6) ** qw) / (blended_cost(reg, caps, mid) ** cw)) for mid, q in survivors]
|
|
192
203
|
out.sort(key=lambda x: -x[1])
|
|
193
204
|
return out
|
|
194
205
|
|
|
@@ -22,7 +22,7 @@ Usage: scrooge-capabilities # refresh from AA (+OpenRouter), show a
|
|
|
22
22
|
scrooge-capabilities --dry-run # fetch + match, print, but don't write
|
|
23
23
|
Exit: 0 updated · 1 nothing fetched (no key / network) · 2 error.
|
|
24
24
|
"""
|
|
25
|
-
import sys, os, json, argparse, urllib.request, urllib.error
|
|
25
|
+
import sys, os, json, argparse, math, urllib.request, urllib.error
|
|
26
26
|
|
|
27
27
|
HOME = os.path.expanduser("~")
|
|
28
28
|
SCROOGE_DIR = os.environ.get("SCROOGE_HOME", os.path.join(HOME, ".token-scrooge"))
|
|
@@ -122,13 +122,35 @@ def fetch_openrouter():
|
|
|
122
122
|
if not mid:
|
|
123
123
|
continue
|
|
124
124
|
arch = m.get("architecture") or {}
|
|
125
|
-
|
|
125
|
+
pr = m.get("pricing") or {}
|
|
126
|
+
def _per_m(v): # OpenRouter prices are USD PER TOKEN → $/1M tokens
|
|
127
|
+
try:
|
|
128
|
+
return round(float(v) * 1e6, 4)
|
|
129
|
+
except Exception:
|
|
130
|
+
return None
|
|
131
|
+
# KEY BY THE RAW LAST SEGMENT (dots intact) — this is exactly what `scrooge route` uses to
|
|
132
|
+
# look a candidate up (by_bare = id.split("/")[-1], no normalisation), so the keys must match.
|
|
133
|
+
out[mid.split("/")[-1]] = {
|
|
134
|
+
"full": mid,
|
|
126
135
|
"context": m.get("context_length"),
|
|
127
136
|
"modalities": arch.get("input_modalities"),
|
|
137
|
+
"cost_in": _per_m(pr.get("prompt")),
|
|
138
|
+
"cost_out": _per_m(pr.get("completion")),
|
|
128
139
|
}
|
|
129
|
-
sys.stderr.write(DIM(" OpenRouter: %d models fetched (context/modality).\n" % len(out)))
|
|
140
|
+
sys.stderr.write(DIM(" OpenRouter: %d models fetched (pricing/context/modality).\n" % len(out)))
|
|
130
141
|
return out
|
|
131
142
|
|
|
143
|
+
def price_proxy_capability(cost_out):
|
|
144
|
+
"""A transparent fallback capability when AA has no score for a brought model: price is a
|
|
145
|
+
decent proxy for tier (frontier models cost more). Monotonic in cost_out ($/1M), with an
|
|
146
|
+
HONEST ceiling — never claim frontier capability from price alone. Gives every catalog model
|
|
147
|
+
a non-zero, rank-able score so the difficulty floor can separate hard from easy work; a later
|
|
148
|
+
AA refresh upgrades it to a real score."""
|
|
149
|
+
if not isinstance(cost_out, (int, float)) or cost_out <= 0:
|
|
150
|
+
return 8.0 # free / unknown price → low floor
|
|
151
|
+
cap = 30.0 + 20.0 * math.log10(cost_out + 0.1)
|
|
152
|
+
return round(max(5.0, min(72.0, cap)), 1)
|
|
153
|
+
|
|
132
154
|
def aa_scores(m):
|
|
133
155
|
ev = m.get("evaluations") or {}
|
|
134
156
|
g = ev.get("gpqa")
|
|
@@ -162,6 +184,7 @@ def main():
|
|
|
162
184
|
return 1
|
|
163
185
|
|
|
164
186
|
today = __import__("time").strftime("%Y-%m-%d")
|
|
187
|
+
by_or_norm = {norm(k): v for k, v in by_or.items()} # by_or is raw-keyed; registry ids are dash-form
|
|
165
188
|
matched, unmatched = [], []
|
|
166
189
|
for mid in reg["models"]:
|
|
167
190
|
existing = caps.get(mid) if isinstance(caps.get(mid), dict) else {}
|
|
@@ -175,7 +198,7 @@ def main():
|
|
|
175
198
|
matched.append(mid)
|
|
176
199
|
elif by_slug:
|
|
177
200
|
unmatched.append(mid)
|
|
178
|
-
orx =
|
|
201
|
+
orx = by_or_norm.get(norm(mid))
|
|
179
202
|
if orx:
|
|
180
203
|
if orx.get("context"):
|
|
181
204
|
rec["context"] = orx["context"]
|
|
@@ -184,10 +207,53 @@ def main():
|
|
|
184
207
|
if rec:
|
|
185
208
|
caps[mid] = rec
|
|
186
209
|
|
|
210
|
+
# ---- OpenRouter CATALOG ingestion: make every brought model routable by difficulty -------
|
|
211
|
+
# The crew passes OpenRouter's hundreds of models as candidates; the router ranks by
|
|
212
|
+
# capability (gated by a difficulty floor) ÷ price. Write each catalog model as a first-class
|
|
213
|
+
# entry keyed by its RAW bare name (matching `scrooge route`'s lookup): a REAL AA score when
|
|
214
|
+
# the model matches a slug, else a transparent price-tier PROXY — plus its real price so cost
|
|
215
|
+
# ranking works. Registry-curated models are never shadowed. Marked `_src` for honesty; a
|
|
216
|
+
# later AA refresh upgrades proxies in place.
|
|
217
|
+
or_real = or_proxy = 0
|
|
218
|
+
for bare, info in by_or.items():
|
|
219
|
+
if bare in reg["models"]: # curated registry model — leave it authoritative
|
|
220
|
+
continue
|
|
221
|
+
existing = caps.get(bare) if isinstance(caps.get(bare), dict) else {}
|
|
222
|
+
rec = dict(existing)
|
|
223
|
+
if info.get("cost_in") is not None:
|
|
224
|
+
rec["cost_in"] = info["cost_in"]
|
|
225
|
+
if info.get("cost_out") is not None:
|
|
226
|
+
rec["cost_out"] = info["cost_out"]
|
|
227
|
+
if info.get("context"):
|
|
228
|
+
rec.setdefault("context", info["context"])
|
|
229
|
+
has_real = isinstance(rec.get("coding"), (int, float)) or isinstance(rec.get("intelligence"), (int, float))
|
|
230
|
+
am = None
|
|
231
|
+
if by_slug:
|
|
232
|
+
full = info.get("full", "")
|
|
233
|
+
am = by_slug.get(norm(full)) or by_slug.get(norm(full.split("/")[-1])) or by_slug.get(bare)
|
|
234
|
+
if am:
|
|
235
|
+
rec.update({k: v for k, v in aa_scores(am).items() if v is not None})
|
|
236
|
+
rec["updated"] = today
|
|
237
|
+
rec["source"] = "artificialanalysis"
|
|
238
|
+
rec.pop("_src", None)
|
|
239
|
+
or_real += 1
|
|
240
|
+
elif not has_real or rec.get("_src") == "openrouter-price-proxy":
|
|
241
|
+
p = price_proxy_capability(rec.get("cost_out"))
|
|
242
|
+
if p is not None:
|
|
243
|
+
rec["coding"] = rec["intelligence"] = rec["reasoning"] = p
|
|
244
|
+
rec["_src"] = "openrouter-price-proxy"
|
|
245
|
+
rec["updated"] = today
|
|
246
|
+
or_proxy += 1
|
|
247
|
+
if rec:
|
|
248
|
+
caps[bare] = rec
|
|
249
|
+
|
|
187
250
|
caps["_meta"].update({"source": "artificialanalysis.ai + openrouter", "refreshed": today,
|
|
188
|
-
"attribution": "https://artificialanalysis.ai/"
|
|
251
|
+
"attribution": "https://artificialanalysis.ai/",
|
|
252
|
+
"openrouter_catalog": {"aa_scored": or_real, "price_proxy": or_proxy}})
|
|
189
253
|
|
|
190
254
|
sys.stderr.write(GOLD("🪙 scrooge-capabilities — %d matched, %d unmatched\n" % (len(matched), len(unmatched))))
|
|
255
|
+
if by_or:
|
|
256
|
+
sys.stderr.write(GOLD(" OpenRouter catalog — %d AA-scored, %d price-proxy (now routable by difficulty)\n" % (or_real, or_proxy)))
|
|
191
257
|
for mid in matched:
|
|
192
258
|
c = caps[mid]
|
|
193
259
|
sys.stderr.write(" %s %-24s intel=%-5s code=%-5s reason=%-5s %st/s\n" % (
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Regression test for capability×cost routing — difficulty-aware escalation + catalog cost.
|
|
3
|
+
|
|
4
|
+
Runs the real weigh_candidates/blended_cost out of bin/scrooge against SYNTHETIC capability
|
|
5
|
+
data (no network, no key), asserting:
|
|
6
|
+
1. catalog cost rides on the capability entry (blended_cost falls back to caps when the
|
|
7
|
+
registry doesn't have the model) — the OpenRouter-routing fix,
|
|
8
|
+
2. cost-weight is difficulty-aware: a cheap-but-decent model wins EASY, while HARD escalates
|
|
9
|
+
to a genuinely stronger model instead of the cheapest-that-clears-the-floor.
|
|
10
|
+
|
|
11
|
+
Exit 0 = all pass. Used to verify the T2 OpenRouter-routes-by-difficulty change.
|
|
12
|
+
"""
|
|
13
|
+
import os, sys
|
|
14
|
+
|
|
15
|
+
HERE = os.path.dirname(os.path.realpath(__file__))
|
|
16
|
+
SCROOGE = os.path.join(HERE, "bin", "scrooge")
|
|
17
|
+
g = {"__name__": "scr", "__file__": SCROOGE}
|
|
18
|
+
exec(compile(open(SCROOGE).read(), "scrooge", "exec"), g)
|
|
19
|
+
|
|
20
|
+
# Synthetic registry has NO catalog models — cost must come from caps (the OpenRouter case).
|
|
21
|
+
reg = {"models": {}, "routing": {}}
|
|
22
|
+
caps = {
|
|
23
|
+
"cheap-weak": {"coding": 20, "cost_in": 0.05, "cost_out": 0.10}, # junk-tier
|
|
24
|
+
"cheap-strong": {"coding": 56, "cost_in": 0.14, "cost_out": 0.28}, # deepseek-flash-like
|
|
25
|
+
"mid-strong": {"coding": 69, "cost_in": 0.60, "cost_out": 2.40}, # glm-5.2-like
|
|
26
|
+
"frontier": {"coding": 75, "cost_in": 5.00, "cost_out": 22.50}, # gpt-5.5-like
|
|
27
|
+
}
|
|
28
|
+
cands = list(caps.keys())
|
|
29
|
+
|
|
30
|
+
fails = []
|
|
31
|
+
def ok(name, cond):
|
|
32
|
+
print((" ✓ " if cond else " ✗ ") + name)
|
|
33
|
+
if not cond:
|
|
34
|
+
fails.append(name)
|
|
35
|
+
|
|
36
|
+
# 1. catalog cost via caps fallback (model absent from registry)
|
|
37
|
+
ok("blended_cost falls back to the capability entry for catalog models",
|
|
38
|
+
abs(g["blended_cost"](reg, caps, "frontier") - (0.3 * 5.0 + 0.7 * 22.5)) < 1e-6)
|
|
39
|
+
ok("blended_cost is 1e-6 for an entirely unknown model (no crash)",
|
|
40
|
+
g["blended_cost"](reg, caps, "does-not-exist") == 1e-6)
|
|
41
|
+
|
|
42
|
+
def winner(diff):
|
|
43
|
+
return g["weigh_candidates"](reg, caps, cands, "code", diff)[0][0]
|
|
44
|
+
|
|
45
|
+
easy, medium, hard = winner("easy"), winner("medium"), winner("hard")
|
|
46
|
+
print(" picks → easy=%s medium=%s hard=%s" % (easy, medium, hard))
|
|
47
|
+
|
|
48
|
+
# 2. difficulty-aware escalation
|
|
49
|
+
ok("easy prefers a cheap model (cost-optimized)", caps[easy]["coding"] <= caps["mid-strong"]["coding"])
|
|
50
|
+
ok("hard escalates to a stronger model than easy", caps[hard]["coding"] > caps[easy]["coding"])
|
|
51
|
+
ok("hard reaches genuine strength (>= mid-strong tier)", caps[hard]["coding"] >= caps["mid-strong"]["coding"])
|
|
52
|
+
ok("the junk-tier model never wins any difficulty", "cheap-weak" not in (easy, medium, hard))
|
|
53
|
+
|
|
54
|
+
print(("\nALL PASS" if not fails else "\nFAILED: %d" % len(fails)))
|
|
55
|
+
sys.exit(1 if fails else 0)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trantor",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.47",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"trantor": "bin/cli.mjs"
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
"zod": "^4.4.3"
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
|
-
"test": "node test.mjs && node test-scenarios.mjs && node test-failure.mjs && node test-handoff.mjs && node test-agents.mjs && node test-update.mjs && node test-handoff-guard.mjs && node test-balances.mjs && node test-subagent-cost.mjs && node test-inbox.mjs && node test-inflight.mjs && node test-focus.mjs"
|
|
13
|
+
"test": "node test.mjs && node test-scenarios.mjs && node test-failure.mjs && node test-handoff.mjs && node test-agents.mjs && node test-update.mjs && node test-handoff-guard.mjs && node test-balances.mjs && node test-subagent-cost.mjs && node test-inbox.mjs && node test-inflight.mjs && node test-focus.mjs && python3 engine/test-routing.py"
|
|
14
14
|
},
|
|
15
|
-
"description": "The hub-world for AI agent crews — orchestrate Claude Code, Codex,
|
|
15
|
+
"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).",
|
|
16
16
|
"files": [
|
|
17
17
|
"hub.mjs",
|
|
18
18
|
"mcp.mjs",
|
package/skills/crew/SKILL.md
CHANGED
|
@@ -54,11 +54,15 @@ EXACT launch spec per provider (do not improvise these):
|
|
|
54
54
|
|
|
55
55
|
`agent:provider` live-selects the best model now; `agent:provider/model` pins one. Example:
|
|
56
56
|
`trantor up codex kimi deepseek:deepseek opencode:zai-coding-plan --task code --difficulty hard`.
|
|
57
|
-
**Whatever the advisor's `launch` field says, run that verbatim** — the roster above is the
|
|
58
|
-
but the advisor
|
|
59
|
-
an OpenRouter key
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
**Whatever the advisor's `launch` field says, run that verbatim** — the roster above is just the
|
|
58
|
+
built-in menu, but the advisor picks the right seats/specs for THIS work (a user who's only brought
|
|
59
|
+
an OpenRouter key gets `openrouter` for everything; one who brought five providers gets a
|
|
60
|
+
load-balanced spread). **BYOM is fully general:** the roster is DERIVED, not hardcoded — ANY
|
|
61
|
+
opencode-supported provider the user configures becomes a seat with its own bus label, no code
|
|
62
|
+
change. A user adds one with `trantor provider add <name> --key … --plan api` (then
|
|
63
|
+
`scrooge-capabilities` to score it for difficulty routing); `trantor provider` lists all seats and
|
|
64
|
+
`trantor models [<provider>]` browses the live models + the router's pick per difficulty. If the
|
|
65
|
+
advisor routes to a brought provider you don't recognize, that's expected — run its `launch` spec.
|
|
62
66
|
|
|
63
67
|
⚠️ **Gemini CLI is RETIRED (Google killed the free seat 2026-06-18).** The advisor no longer
|
|
64
68
|
offers it and you must NOT fire up `gemini` — `gemini --yolo` exits 1 and crash-loops on the
|