@bizzywork/routing 0.4.1 → 0.4.3
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.
|
@@ -24,7 +24,7 @@ async function readStdin() {
|
|
|
24
24
|
for await (const chunk of process.stdin) text += String(chunk);
|
|
25
25
|
return text;
|
|
26
26
|
}
|
|
27
|
-
var { run } = await import("./main-
|
|
27
|
+
var { run } = await import("./main-TRXFLPTZ.js");
|
|
28
28
|
var { plainUi } = await import("./ui-PEKFVWX7.js");
|
|
29
29
|
var { clackUi, showError } = await import("./clack-ui-KG2I32T5.js");
|
|
30
30
|
var interactive = Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
@@ -35,7 +35,7 @@ try {
|
|
|
35
35
|
home: homedir(),
|
|
36
36
|
execPath: process.execPath,
|
|
37
37
|
bundleDir: dirname(fileURLToPath(import.meta.url)),
|
|
38
|
-
version: true ? "0.4.
|
|
38
|
+
version: true ? "0.4.3" : "dev",
|
|
39
39
|
platform: process.platform,
|
|
40
40
|
uid: process.getuid?.(),
|
|
41
41
|
interactive,
|
|
@@ -76747,6 +76747,8 @@ __export(src_exports, {
|
|
|
76747
76747
|
getBest: () => getBest,
|
|
76748
76748
|
getPromoted: () => getPromoted,
|
|
76749
76749
|
has: () => has,
|
|
76750
|
+
isApproved: () => isApproved,
|
|
76751
|
+
isSubscription: () => isSubscription,
|
|
76750
76752
|
isTrialDue: () => isTrialDue,
|
|
76751
76753
|
jevGradeProfile: () => jevGradeProfile,
|
|
76752
76754
|
jevProfile: () => jevProfile,
|
|
@@ -76786,6 +76788,40 @@ __export(src_exports, {
|
|
|
76786
76788
|
wilsonLowerBound: () => wilsonLowerBound
|
|
76787
76789
|
});
|
|
76788
76790
|
|
|
76791
|
+
// bizzy-routing/decision/src/approved.ts
|
|
76792
|
+
var subscriptionProviders = /* @__PURE__ */ new Set(["anthropic", "openai", "openai-codex"]);
|
|
76793
|
+
var anthropicModels = [
|
|
76794
|
+
"anthropic/claude-fable-5.2",
|
|
76795
|
+
"anthropic/claude-haiku-5.5",
|
|
76796
|
+
"anthropic/claude-opus-5.5",
|
|
76797
|
+
"anthropic/claude-sonnet-5.5"
|
|
76798
|
+
];
|
|
76799
|
+
var openAiModels = [
|
|
76800
|
+
"openai/gpt-6-astra",
|
|
76801
|
+
"openai/gpt-6-luna",
|
|
76802
|
+
"openai/gpt-6.1-sol",
|
|
76803
|
+
"openai/gpt-6.1-terra",
|
|
76804
|
+
"openai/gpt-6.2-astra",
|
|
76805
|
+
"openai/gpt-6.2-sol"
|
|
76806
|
+
];
|
|
76807
|
+
var openRouterModels = [
|
|
76808
|
+
"deepseek/deepseek-v4.1-flash-1017",
|
|
76809
|
+
"deepseek/deepseek-v4.1-flash",
|
|
76810
|
+
"deepseek/deepseek-v4-flash-0731",
|
|
76811
|
+
"z-ai/glm-5.3-flash",
|
|
76812
|
+
"z-ai/glm-5.3",
|
|
76813
|
+
"minimax/minimax-m3.1-flash",
|
|
76814
|
+
"tencent/hy4-flash",
|
|
76815
|
+
"moonshotai/kimi-k3.1-pro",
|
|
76816
|
+
"nvidia/nemotron-3-ultra-550b-a55b",
|
|
76817
|
+
"nvidia/nemotron-3.5-super-vl",
|
|
76818
|
+
"meta/muse-spark-1.3-contributor",
|
|
76819
|
+
"xiaomi/mimo-v2.6-flash"
|
|
76820
|
+
];
|
|
76821
|
+
var approved = /* @__PURE__ */ new Set([...anthropicModels, ...openAiModels, ...openRouterModels]);
|
|
76822
|
+
var isSubscription = (provider) => subscriptionProviders.has(provider);
|
|
76823
|
+
var isApproved = (catalogId) => catalogId !== null && approved.has(catalogId);
|
|
76824
|
+
|
|
76789
76825
|
// bizzy-routing/decision/src/profiles.ts
|
|
76790
76826
|
var jevProfile = {
|
|
76791
76827
|
name: "jev",
|
|
@@ -77341,7 +77377,10 @@ var judgeGradeStrategy = function* (input2) {
|
|
|
77341
77377
|
const state = validateRoutingState(input2.state);
|
|
77342
77378
|
const base = cascade(input2, [pin, trial, registry2, history, coldStart]);
|
|
77343
77379
|
if (input2.pin) return { kind: "done", decision: base, state };
|
|
77344
|
-
const
|
|
77380
|
+
const priors = input2.priors ?? {};
|
|
77381
|
+
const ranked = [...permittedCandidates(input2)].sort(
|
|
77382
|
+
(a, b) => Number(!(a.id in priors)) - Number(!(b.id in priors)) || a.costPer1k - b.costPer1k
|
|
77383
|
+
);
|
|
77345
77384
|
if (!ranked.length) return { kind: "done", decision: base, state };
|
|
77346
77385
|
const questions2 = ranked.map((_, i) => ({
|
|
77347
77386
|
id: gradeQuestionId(i + 1),
|
|
@@ -81341,13 +81380,16 @@ async function routeInput(envelope, options) {
|
|
|
81341
81380
|
const id2 = catalog && catalogIdOf(candidate.id, catalog, { provider: candidate.provider, aliases });
|
|
81342
81381
|
return id2 ? listed.get(id2) : void 0;
|
|
81343
81382
|
};
|
|
81344
|
-
const
|
|
81383
|
+
const approved2 = envelope.candidates.filter(
|
|
81384
|
+
(candidate) => options.approved?.(rowOf(candidate)?.id ?? null) ?? true
|
|
81385
|
+
);
|
|
81386
|
+
const candidates = approved2.map((candidate) => {
|
|
81345
81387
|
const model = rowOf(candidate);
|
|
81346
81388
|
return model ? { ...candidate, costPer1k: (model.inputPer1k + model.outputPer1k) / 2 } : candidate;
|
|
81347
81389
|
});
|
|
81348
81390
|
const { priors: benchmarks, priorIndex } = poolPriors(
|
|
81349
81391
|
Object.fromEntries(
|
|
81350
|
-
|
|
81392
|
+
approved2.flatMap((candidate) => {
|
|
81351
81393
|
const model = rowOf(candidate);
|
|
81352
81394
|
return model ? [[candidate.id, model]] : [];
|
|
81353
81395
|
})
|
|
@@ -81373,8 +81415,8 @@ async function routeInput(envelope, options) {
|
|
|
81373
81415
|
function profileFor({ envelope, material }) {
|
|
81374
81416
|
if (material.policy === "none") return cascadeProfile;
|
|
81375
81417
|
if (envelope.profile === "cascade") return cascadeProfile;
|
|
81376
|
-
if (envelope.profile === "jev
|
|
81377
|
-
return
|
|
81418
|
+
if (envelope.profile === "jev") return jevProfile;
|
|
81419
|
+
return jevGradeProfile;
|
|
81378
81420
|
}
|
|
81379
81421
|
var routeNotices = {
|
|
81380
81422
|
absent: "no OpenRouter key: routing with Bizzy's own rules",
|
|
@@ -81463,6 +81505,7 @@ function createHostedRoute(options) {
|
|
|
81463
81505
|
state: envelope.state,
|
|
81464
81506
|
...envelope.profile ? { profile: envelope.profile } : {},
|
|
81465
81507
|
...envelope.newUserTurn ? { newUserTurn: true } : {},
|
|
81508
|
+
...envelope.allowOpenRouter ? { allowOpenRouter: true } : {},
|
|
81466
81509
|
...shared ? { context: "summary", summary: shared } : {}
|
|
81467
81510
|
};
|
|
81468
81511
|
const text = await post(
|
|
@@ -81569,12 +81612,24 @@ async function matchModels(available, server, provider) {
|
|
|
81569
81612
|
const rows2 = new Map(catalog?.models.map((model) => [model.id, model]));
|
|
81570
81613
|
const matched = {};
|
|
81571
81614
|
const unmatched = [];
|
|
81572
|
-
const
|
|
81573
|
-
|
|
81574
|
-
|
|
81575
|
-
|
|
81576
|
-
|
|
81577
|
-
|
|
81615
|
+
const reached = /* @__PURE__ */ new Set();
|
|
81616
|
+
const byPreference = [...new Set(available)].sort(
|
|
81617
|
+
(a, b) => Number(!isSubscription(providerOf(a, provider))) - Number(!isSubscription(providerOf(b, provider)))
|
|
81618
|
+
);
|
|
81619
|
+
for (const model of byPreference) {
|
|
81620
|
+
const catalogId = catalog ? catalogIdOf(model.replace(/^openai-codex\//, "openai/"), catalog, {
|
|
81621
|
+
...provider ? { provider } : {},
|
|
81622
|
+
aliases
|
|
81623
|
+
}) : null;
|
|
81624
|
+
if (server.approved && !server.approved(catalogId)) continue;
|
|
81625
|
+
const row = catalogId ? rows2.get(catalogId) : void 0;
|
|
81626
|
+
if (!row?.toolUse) {
|
|
81627
|
+
unmatched.push(model);
|
|
81628
|
+
continue;
|
|
81629
|
+
}
|
|
81630
|
+
if (reached.has(row.id)) continue;
|
|
81631
|
+
reached.add(row.id);
|
|
81632
|
+
matched[model] = row;
|
|
81578
81633
|
}
|
|
81579
81634
|
const candidate = (model, costPer1k) => ({
|
|
81580
81635
|
id: model,
|
|
@@ -81599,8 +81654,8 @@ async function matchModels(available, server, provider) {
|
|
|
81599
81654
|
candidates: Object.keys(matched),
|
|
81600
81655
|
unmatched,
|
|
81601
81656
|
picks: efficient && capable ? { efficient: efficient.model.id, capable: capable.model.id } : null,
|
|
81602
|
-
//
|
|
81603
|
-
pool:
|
|
81657
|
+
// Only models with a catalog row that takes tools: a model with no price or score can't be compared, so it's never routed.
|
|
81658
|
+
pool: candidates
|
|
81604
81659
|
};
|
|
81605
81660
|
}
|
|
81606
81661
|
function parseHarnessComplete(raw) {
|
|
@@ -81728,6 +81783,8 @@ function createHarnessRouter(options, server) {
|
|
|
81728
81783
|
mode: "auto",
|
|
81729
81784
|
state: current.state,
|
|
81730
81785
|
newUserTurn: true,
|
|
81786
|
+
// The harness's OpenRouter models are ones its user signed in to; the approved list has already narrowed them.
|
|
81787
|
+
allowOpenRouter: true,
|
|
81731
81788
|
...options.profile ? { profile: options.profile } : {}
|
|
81732
81789
|
};
|
|
81733
81790
|
const material = body.prompt ? { policy: "summary", summary: body.prompt } : { policy: "none" };
|
|
@@ -83088,7 +83145,8 @@ async function openServerState(dataDir, env, log) {
|
|
|
83088
83145
|
trialWindow: new SqliteTrialWindowStore(database),
|
|
83089
83146
|
// The same key fetches the daily catalog that prices callers' candidates and scores them.
|
|
83090
83147
|
catalog: bundled ? async () => bundled : () => loadCatalog({ cwd: dataDir, apiKey: env.OPENROUTER_API_KEY }),
|
|
83091
|
-
aliases: () => loadAliases(dataDir)
|
|
83148
|
+
aliases: () => loadAliases(dataDir),
|
|
83149
|
+
approved: isApproved
|
|
83092
83150
|
}
|
|
83093
83151
|
};
|
|
83094
83152
|
}
|
|
@@ -83726,6 +83784,8 @@ Options:
|
|
|
83726
83784
|
--key-stdin install: read the routing key from stdin instead of asking.
|
|
83727
83785
|
--no-share-prompts install: keep prompts on this machine; the hosted API then routes on its rules.
|
|
83728
83786
|
--share-prompts install: send prompts to the hosted judge again (the default).
|
|
83787
|
+
--jev-grade install claude-code: grade every available model directly instead of
|
|
83788
|
+
comparing a fixed efficient/capable pair. Off by default.
|
|
83729
83789
|
--stdin key: read the key from stdin instead of asking.
|
|
83730
83790
|
--purge uninstall: also remove ~/.bizzy/routing, with its data and key.
|
|
83731
83791
|
-h, --help Show this help.
|
|
@@ -83773,6 +83833,8 @@ async function installFlow(harness, target, flags) {
|
|
|
83773
83833
|
else if (io.interactive && !hasKey) ui.warn("No routing key: turns route with Bizzy's own rules");
|
|
83774
83834
|
if (flags.sharePrompts === false) writeEnvValues(target.dataDir, { BIZZY_SHARE_PROMPTS: "0" });
|
|
83775
83835
|
else if (flags.sharePrompts) writeEnvValues(target.dataDir, { BIZZY_SHARE_PROMPTS: void 0 });
|
|
83836
|
+
if (flags.jevGrade && harness === "claude-code")
|
|
83837
|
+
writeEnvValues(target.dataDir, { BIZZY_API_CLAUDE_CODE_PROFILE: "jev-grade" });
|
|
83776
83838
|
if (wired.run) ui.command(wired.run.command, wired.run.title);
|
|
83777
83839
|
ui.note(wired.next, "Next");
|
|
83778
83840
|
}
|
|
@@ -83795,6 +83857,7 @@ async function run2(io) {
|
|
|
83795
83857
|
"key-stdin": { type: "boolean" },
|
|
83796
83858
|
"share-prompts": { type: "boolean" },
|
|
83797
83859
|
"no-share-prompts": { type: "boolean" },
|
|
83860
|
+
"jev-grade": { type: "boolean" },
|
|
83798
83861
|
help: { type: "boolean", short: "h" },
|
|
83799
83862
|
version: { type: "boolean", short: "v" }
|
|
83800
83863
|
}
|
|
@@ -83827,7 +83890,8 @@ async function run2(io) {
|
|
|
83827
83890
|
};
|
|
83828
83891
|
const flags = {
|
|
83829
83892
|
keyStdin: values["key-stdin"] === true,
|
|
83830
|
-
sharePrompts: values["no-share-prompts"] ? false : values["share-prompts"] ? true : void 0
|
|
83893
|
+
sharePrompts: values["no-share-prompts"] ? false : values["share-prompts"] ? true : void 0,
|
|
83894
|
+
jevGrade: values["jev-grade"] === true
|
|
83831
83895
|
};
|
|
83832
83896
|
if (command && !["install", "uninstall", "key", "status", "doctor"].includes(command))
|
|
83833
83897
|
throw new Error(`unknown command: ${command}; run \`${npx} help\` for usage`);
|
package/package.json
CHANGED