@bizzywork/routing 0.4.4 → 0.4.5
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-HTRHF32Q.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.5" : "dev",
|
|
39
39
|
platform: process.platform,
|
|
40
40
|
uid: process.getuid?.(),
|
|
41
41
|
interactive,
|
|
@@ -392,6 +392,8 @@ export const register: Register = (on) => {
|
|
|
392
392
|
reason: e.reason,
|
|
393
393
|
// The id that served the turn, which an alias tier doesn't name.
|
|
394
394
|
...(usage?.model ? { model: usage.model } : {}),
|
|
395
|
+
// The session's own model: what this turn would have used without routing.
|
|
396
|
+
...(nativeModel ? { baseline: safeId(nativeModel) } : {}),
|
|
395
397
|
...(usage
|
|
396
398
|
? {
|
|
397
399
|
usage: {
|
|
@@ -419,6 +419,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
419
419
|
? "aborted"
|
|
420
420
|
: "error",
|
|
421
421
|
model: safeId(modelId(real)),
|
|
422
|
+
baseline: safeId(modelId(fallbackModel)),
|
|
422
423
|
usage: {
|
|
423
424
|
inputTokens: message.usage.input + message.usage.cacheRead + message.usage.cacheWrite,
|
|
424
425
|
outputTokens: message.usage.output,
|
|
@@ -19041,11 +19041,11 @@ var require_plugin = __commonJS({
|
|
|
19041
19041
|
this.server = server;
|
|
19042
19042
|
const func = this.func;
|
|
19043
19043
|
const name = this.name;
|
|
19044
|
-
let
|
|
19044
|
+
let completed2 = false;
|
|
19045
19045
|
this.options = typeof this.options === "function" ? this.options(this.server) : this.options;
|
|
19046
19046
|
let timer = null;
|
|
19047
19047
|
const done = (execErr) => {
|
|
19048
|
-
if (
|
|
19048
|
+
if (completed2) {
|
|
19049
19049
|
debug("loading complete", name);
|
|
19050
19050
|
return;
|
|
19051
19051
|
}
|
|
@@ -19055,7 +19055,7 @@ var require_plugin = __commonJS({
|
|
|
19055
19055
|
} else {
|
|
19056
19056
|
debug("exec completed", name);
|
|
19057
19057
|
}
|
|
19058
|
-
|
|
19058
|
+
completed2 = true;
|
|
19059
19059
|
if (timer) {
|
|
19060
19060
|
clearTimeout(timer);
|
|
19061
19061
|
}
|
|
@@ -19631,12 +19631,12 @@ var require_avvio = __commonJS({
|
|
|
19631
19631
|
executeWithThenable(func, [err], cb);
|
|
19632
19632
|
} else {
|
|
19633
19633
|
if (this._opts.timeout === 0) {
|
|
19634
|
-
let
|
|
19634
|
+
let completed2 = false;
|
|
19635
19635
|
const wrapCb = (err2) => {
|
|
19636
|
-
if (
|
|
19636
|
+
if (completed2) {
|
|
19637
19637
|
return;
|
|
19638
19638
|
}
|
|
19639
|
-
|
|
19639
|
+
completed2 = true;
|
|
19640
19640
|
this._error = err2;
|
|
19641
19641
|
process.nextTick(cb, this._error);
|
|
19642
19642
|
};
|
|
@@ -76498,18 +76498,51 @@ var ModelCandidateSchema = external_exports.object({
|
|
|
76498
76498
|
taskType: SafeIdSchema.exactOptional()
|
|
76499
76499
|
});
|
|
76500
76500
|
|
|
76501
|
+
// bizzy-routing/contracts/src/schemas/signals.ts
|
|
76502
|
+
var maximumLength = 64;
|
|
76503
|
+
var CountSchema = external_exports.number().int().min(0);
|
|
76504
|
+
var TurnSignalsSchema = external_exports.object({
|
|
76505
|
+
/** Worst severity in the recent window: 0 clean, 0.3 soft, 0.7 hard, 1 critical. */
|
|
76506
|
+
maxSeverity: UnitSchema,
|
|
76507
|
+
/** The same hard or explicit failure appeared twice in the recent window. */
|
|
76508
|
+
repeatedFailure: external_exports.boolean(),
|
|
76509
|
+
/** Read, edit, write and planning calls in the recent window. */
|
|
76510
|
+
reads: CountSchema,
|
|
76511
|
+
edits: CountSchema,
|
|
76512
|
+
writes: CountSchema,
|
|
76513
|
+
plans: CountSchema,
|
|
76514
|
+
/** Turns into the mission. */
|
|
76515
|
+
depth: CountSchema,
|
|
76516
|
+
/** Clean tool results back from the most recent. */
|
|
76517
|
+
cleanStreak: CountSchema,
|
|
76518
|
+
/** A test pass after the latest failure in the recent window. */
|
|
76519
|
+
testsPassed: external_exports.boolean(),
|
|
76520
|
+
compacted: external_exports.boolean()
|
|
76521
|
+
});
|
|
76522
|
+
var RoutingStateSchema = external_exports.record(
|
|
76523
|
+
external_exports.string().max(maximumLength),
|
|
76524
|
+
external_exports.union([external_exports.string().max(maximumLength), external_exports.number(), external_exports.boolean()])
|
|
76525
|
+
);
|
|
76526
|
+
|
|
76501
76527
|
// bizzy-routing/contracts/src/schemas/run-record.ts
|
|
76502
76528
|
var IsoDateSchema = external_exports.string().regex(/^\d{4}-\d{2}-\d{2}T/).refine((value) => Number.isFinite(Date.parse(value)));
|
|
76503
|
-
var
|
|
76529
|
+
var CountSchema2 = external_exports.number().int().min(0);
|
|
76504
76530
|
var UsageSchema = external_exports.object({
|
|
76505
|
-
inputTokens:
|
|
76506
|
-
outputTokens:
|
|
76531
|
+
inputTokens: CountSchema2,
|
|
76532
|
+
outputTokens: CountSchema2,
|
|
76507
76533
|
costUsd: external_exports.number().min(0)
|
|
76508
76534
|
});
|
|
76509
76535
|
var RunRecordSchema = external_exports.object({
|
|
76510
76536
|
version: external_exports.literal("2"),
|
|
76511
76537
|
runId: SafeIdSchema,
|
|
76512
|
-
task: external_exports.object({
|
|
76538
|
+
task: external_exports.object({
|
|
76539
|
+
kind: SafeIdSchema,
|
|
76540
|
+
risk: RiskSchema,
|
|
76541
|
+
inputRef: HashRefSchema,
|
|
76542
|
+
/** What the judge called the task (`coding`, `legal`, ...), for reports. `kind` stays the routing scope that
|
|
76543
|
+
* history and earned scores are kept under. */
|
|
76544
|
+
type: SafeIdSchema.exactOptional()
|
|
76545
|
+
}),
|
|
76513
76546
|
route: external_exports.object({
|
|
76514
76547
|
modelId: SafeIdSchema,
|
|
76515
76548
|
provider: SafeIdSchema,
|
|
@@ -76525,8 +76558,8 @@ var RunRecordSchema = external_exports.object({
|
|
|
76525
76558
|
/** The judge's own token usage for this run's route call, regardless of which strategy asked it.
|
|
76526
76559
|
* `costUsd` is null when no judge price was configured, not a guessed number. */
|
|
76527
76560
|
judgeUsage: external_exports.object({
|
|
76528
|
-
inputTokens:
|
|
76529
|
-
outputTokens:
|
|
76561
|
+
inputTokens: CountSchema2,
|
|
76562
|
+
outputTokens: CountSchema2,
|
|
76530
76563
|
costUsd: external_exports.number().min(0).nullable()
|
|
76531
76564
|
}).exactOptional(),
|
|
76532
76565
|
/** Set by the caller when a live routing-vs-control comparison chose this run's arm;
|
|
@@ -76534,12 +76567,17 @@ var RunRecordSchema = external_exports.object({
|
|
|
76534
76567
|
* bizzy-v2 never sees or sets it. */
|
|
76535
76568
|
arm: external_exports.enum(["treatment", "control"]).exactOptional(),
|
|
76536
76569
|
/** The comparison window this run belongs to, when `arm` is set. */
|
|
76537
|
-
windowId: SafeIdSchema.exactOptional()
|
|
76570
|
+
windowId: SafeIdSchema.exactOptional(),
|
|
76571
|
+
/** The model this person's own harness would have used without routing (their default). Unset from a client that
|
|
76572
|
+
* doesn't send it; a report then prices the run against a standard baseline. */
|
|
76573
|
+
baselineModelId: SafeIdSchema.exactOptional()
|
|
76538
76574
|
}),
|
|
76539
76575
|
startedAt: IsoDateSchema,
|
|
76540
76576
|
settledAt: IsoDateSchema,
|
|
76541
76577
|
latencyMs: external_exports.number().min(0),
|
|
76542
76578
|
usage: UsageSchema,
|
|
76579
|
+
/** The turn's tool activity when it ended, as numbers and flags: the proxy for whether it went well. */
|
|
76580
|
+
signals: TurnSignalsSchema.exactOptional(),
|
|
76543
76581
|
quality: UnitSchema,
|
|
76544
76582
|
taskSuccess: external_exports.boolean(),
|
|
76545
76583
|
processSuccess: external_exports.boolean(),
|
|
@@ -76561,32 +76599,6 @@ function sanitizeRunRecord(input2) {
|
|
|
76561
76599
|
return parseOrThrow(RunRecordSchema, input2, (issue2) => issueField("RunRecord", issue2));
|
|
76562
76600
|
}
|
|
76563
76601
|
|
|
76564
|
-
// bizzy-routing/contracts/src/schemas/signals.ts
|
|
76565
|
-
var maximumLength = 64;
|
|
76566
|
-
var CountSchema2 = external_exports.number().int().min(0);
|
|
76567
|
-
var TurnSignalsSchema = external_exports.object({
|
|
76568
|
-
/** Worst severity in the recent window: 0 clean, 0.3 soft, 0.7 hard, 1 critical. */
|
|
76569
|
-
maxSeverity: UnitSchema,
|
|
76570
|
-
/** The same hard or explicit failure appeared twice in the recent window. */
|
|
76571
|
-
repeatedFailure: external_exports.boolean(),
|
|
76572
|
-
/** Read, edit, write and planning calls in the recent window. */
|
|
76573
|
-
reads: CountSchema2,
|
|
76574
|
-
edits: CountSchema2,
|
|
76575
|
-
writes: CountSchema2,
|
|
76576
|
-
plans: CountSchema2,
|
|
76577
|
-
/** Turns into the mission. */
|
|
76578
|
-
depth: CountSchema2,
|
|
76579
|
-
/** Clean tool results back from the most recent. */
|
|
76580
|
-
cleanStreak: CountSchema2,
|
|
76581
|
-
/** A test pass after the latest failure in the recent window. */
|
|
76582
|
-
testsPassed: external_exports.boolean(),
|
|
76583
|
-
compacted: external_exports.boolean()
|
|
76584
|
-
});
|
|
76585
|
-
var RoutingStateSchema = external_exports.record(
|
|
76586
|
-
external_exports.string().max(maximumLength),
|
|
76587
|
-
external_exports.union([external_exports.string().max(maximumLength), external_exports.number(), external_exports.boolean()])
|
|
76588
|
-
);
|
|
76589
|
-
|
|
76590
76602
|
// bizzy-routing/contracts/src/state.ts
|
|
76591
76603
|
function validateRoutingState(value) {
|
|
76592
76604
|
return parseOrThrow(
|
|
@@ -76655,7 +76667,9 @@ var DoneStepSchema = external_exports.object({
|
|
|
76655
76667
|
/** Set by the host when a question went unanswered, so the decision is the rules' alone; for the user to see. */
|
|
76656
76668
|
notice: external_exports.string().exactOptional(),
|
|
76657
76669
|
/** Set when a live routing-vs-control comparison is open; unset otherwise. */
|
|
76658
|
-
window: OpenWindowSchema.exactOptional()
|
|
76670
|
+
window: OpenWindowSchema.exactOptional(),
|
|
76671
|
+
/** What the judge called the task, when it was asked; unset when no judge answered. */
|
|
76672
|
+
taskType: SafeIdSchema.exactOptional()
|
|
76659
76673
|
});
|
|
76660
76674
|
var StepSchema = external_exports.discriminatedUnion("kind", [AskJudgeStepSchema, DoneStepSchema]);
|
|
76661
76675
|
|
|
@@ -76683,6 +76697,7 @@ var RouteBodySchema = external_exports.strictObject({
|
|
|
76683
76697
|
mode: ModeSchema,
|
|
76684
76698
|
pin: SafeIdSchema.exactOptional(),
|
|
76685
76699
|
allowOpenRouter: external_exports.boolean().exactOptional(),
|
|
76700
|
+
subscriptionFirst: external_exports.boolean().exactOptional(),
|
|
76686
76701
|
strategy: external_exports.enum(strategies).exactOptional(),
|
|
76687
76702
|
profile: external_exports.enum(profiles).exactOptional(),
|
|
76688
76703
|
newUserTurn: external_exports.boolean().exactOptional(),
|
|
@@ -76782,6 +76797,7 @@ __export(src_exports, {
|
|
|
76782
76797
|
stageConstants: () => stageConstants,
|
|
76783
76798
|
stageStrategy: () => stageStrategy,
|
|
76784
76799
|
summarize: () => summarize,
|
|
76800
|
+
taskTypes: () => taskTypes,
|
|
76785
76801
|
updateRuleScore: () => updateRuleScore,
|
|
76786
76802
|
updateScore: () => updateScore,
|
|
76787
76803
|
useRegistryStore: () => useRegistryStore,
|
|
@@ -76822,6 +76838,18 @@ var approved = /* @__PURE__ */ new Set([...anthropicModels, ...openAiModels, ...
|
|
|
76822
76838
|
var isSubscription = (provider) => subscriptionProviders.has(provider);
|
|
76823
76839
|
var isApproved = (catalogId) => catalogId !== null && approved.has(catalogId);
|
|
76824
76840
|
|
|
76841
|
+
// bizzy-routing/decision/src/task-types.ts
|
|
76842
|
+
var taskTypes = [
|
|
76843
|
+
"engineering",
|
|
76844
|
+
"finance",
|
|
76845
|
+
"legal",
|
|
76846
|
+
"healthcare",
|
|
76847
|
+
"strategy",
|
|
76848
|
+
"cyber",
|
|
76849
|
+
"multilingual",
|
|
76850
|
+
"general"
|
|
76851
|
+
];
|
|
76852
|
+
|
|
76825
76853
|
// bizzy-routing/decision/src/profiles.ts
|
|
76826
76854
|
var jevProfile = {
|
|
76827
76855
|
name: "jev",
|
|
@@ -77378,23 +77406,31 @@ var judgeGradeStrategy = function* (input2) {
|
|
|
77378
77406
|
const base = cascade(input2, [pin, trial, registry2, history, coldStart]);
|
|
77379
77407
|
if (input2.pin) return { kind: "done", decision: base, state };
|
|
77380
77408
|
const priors = input2.priors ?? {};
|
|
77409
|
+
const subscriptionRank = (provider) => input2.subscriptionFirst ? Number(!isSubscription(provider)) : 0;
|
|
77381
77410
|
const ranked = [...permittedCandidates(input2)].sort(
|
|
77382
|
-
(a, b) => Number(!(a.id in priors)) - Number(!(b.id in priors)) || a.costPer1k - b.costPer1k
|
|
77411
|
+
(a, b) => subscriptionRank(a.provider) - subscriptionRank(b.provider) || Number(!(a.id in priors)) - Number(!(b.id in priors)) || a.costPer1k - b.costPer1k
|
|
77383
77412
|
);
|
|
77384
77413
|
if (!ranked.length) return { kind: "done", decision: base, state };
|
|
77385
|
-
const questions2 =
|
|
77386
|
-
|
|
77387
|
-
|
|
77388
|
-
|
|
77389
|
-
|
|
77390
|
-
|
|
77414
|
+
const questions2 = [
|
|
77415
|
+
...ranked.map((_, i) => ({
|
|
77416
|
+
id: gradeQuestionId(i + 1),
|
|
77417
|
+
kind: "score",
|
|
77418
|
+
min: 0,
|
|
77419
|
+
max: 1
|
|
77420
|
+
})),
|
|
77421
|
+
// The same call names the task's type, for reports; it doesn't change the pick.
|
|
77422
|
+
{ id: "taskType", kind: "choice", options: taskTypes }
|
|
77423
|
+
];
|
|
77391
77424
|
const result = yield { kind: "ask-judge", questions: questions2, context: "summary" };
|
|
77392
77425
|
if (result.kind !== "answers") return { kind: "done", decision: base, state };
|
|
77426
|
+
const taskType = result.answers.taskType;
|
|
77427
|
+
const typed2 = typeof taskType === "string" ? { taskType } : {};
|
|
77393
77428
|
const winner = ranked.find((_, i) => {
|
|
77394
77429
|
const answer = result.answers[gradeQuestionId(i + 1)];
|
|
77395
77430
|
return typeof answer === "number" && answer > 0.5;
|
|
77396
77431
|
});
|
|
77397
|
-
if (!winner || winner === base.model)
|
|
77432
|
+
if (!winner || winner === base.model)
|
|
77433
|
+
return { kind: "done", decision: base, state, ...typed2 };
|
|
77398
77434
|
return {
|
|
77399
77435
|
kind: "done",
|
|
77400
77436
|
decision: decisionForModel(
|
|
@@ -77403,7 +77439,8 @@ var judgeGradeStrategy = function* (input2) {
|
|
|
77403
77439
|
"judge-grade",
|
|
77404
77440
|
"judge-grade: cheapest candidate Jev rated capable of the task"
|
|
77405
77441
|
),
|
|
77406
|
-
state
|
|
77442
|
+
state,
|
|
77443
|
+
...typed2
|
|
77407
77444
|
};
|
|
77408
77445
|
};
|
|
77409
77446
|
|
|
@@ -81467,6 +81504,15 @@ function trialWindowOpenBody(raw) {
|
|
|
81467
81504
|
// bizzy-routing/api/src/harness.ts
|
|
81468
81505
|
import { createHash, randomUUID as randomUUID2 } from "node:crypto";
|
|
81469
81506
|
|
|
81507
|
+
// bizzy-routing/api/src/catalog-match.ts
|
|
81508
|
+
var vendor = (value) => value.replace(/^openai-codex(?=\/|$)/, "openai");
|
|
81509
|
+
function harnessCatalogId(model, catalog, { provider, aliases }) {
|
|
81510
|
+
return catalogIdOf(vendor(model), catalog, {
|
|
81511
|
+
...provider ? { provider: vendor(provider) } : {},
|
|
81512
|
+
...aliases ? { aliases } : {}
|
|
81513
|
+
});
|
|
81514
|
+
}
|
|
81515
|
+
|
|
81470
81516
|
// bizzy-routing/api/src/hosted.ts
|
|
81471
81517
|
var HostedError = class extends Error {
|
|
81472
81518
|
};
|
|
@@ -81506,6 +81552,7 @@ function createHostedRoute(options) {
|
|
|
81506
81552
|
...envelope.profile ? { profile: envelope.profile } : {},
|
|
81507
81553
|
...envelope.newUserTurn ? { newUserTurn: true } : {},
|
|
81508
81554
|
...envelope.allowOpenRouter ? { allowOpenRouter: true } : {},
|
|
81555
|
+
...envelope.subscriptionFirst ? { subscriptionFirst: true } : {},
|
|
81509
81556
|
...shared ? { context: "summary", summary: shared } : {}
|
|
81510
81557
|
};
|
|
81511
81558
|
const text = await post(
|
|
@@ -81617,10 +81664,7 @@ async function matchModels(available, server, provider) {
|
|
|
81617
81664
|
(a, b) => Number(!isSubscription(providerOf(a, provider))) - Number(!isSubscription(providerOf(b, provider)))
|
|
81618
81665
|
);
|
|
81619
81666
|
for (const model of byPreference) {
|
|
81620
|
-
const catalogId = catalog ?
|
|
81621
|
-
...provider ? { provider } : {},
|
|
81622
|
-
aliases
|
|
81623
|
-
}) : null;
|
|
81667
|
+
const catalogId = catalog ? harnessCatalogId(model, catalog, { ...provider ? { provider } : {}, aliases }) : null;
|
|
81624
81668
|
if (server.approved && !server.approved(catalogId)) continue;
|
|
81625
81669
|
const row = catalogId ? rows2.get(catalogId) : void 0;
|
|
81626
81670
|
if (!row?.toolUse) {
|
|
@@ -81667,6 +81711,7 @@ function parseHarnessComplete(raw) {
|
|
|
81667
81711
|
turnId: id(body.turnId, "turnId"),
|
|
81668
81712
|
reason: body.reason,
|
|
81669
81713
|
...body.model === void 0 ? {} : { model: id(body.model, "model") },
|
|
81714
|
+
...body.baseline === void 0 ? {} : { baseline: id(body.baseline, "baseline") },
|
|
81670
81715
|
...usage ? {
|
|
81671
81716
|
usage: {
|
|
81672
81717
|
inputTokens: count(usage.inputTokens, "usage.inputTokens"),
|
|
@@ -81785,6 +81830,7 @@ function createHarnessRouter(options, server) {
|
|
|
81785
81830
|
newUserTurn: true,
|
|
81786
81831
|
// The harness's OpenRouter models are ones its user signed in to; the approved list has already narrowed them.
|
|
81787
81832
|
allowOpenRouter: true,
|
|
81833
|
+
...options.subscriptionFirst ? { subscriptionFirst: true } : {},
|
|
81788
81834
|
...options.profile ? { profile: options.profile } : {}
|
|
81789
81835
|
};
|
|
81790
81836
|
const material = body.prompt ? { policy: "summary", summary: body.prompt } : { policy: "none" };
|
|
@@ -81813,6 +81859,7 @@ function createHarnessRouter(options, server) {
|
|
|
81813
81859
|
...judged && typeof done.state.judgeAdvantage === "number" ? { judgeAdvantage: done.state.judgeAdvantage } : {},
|
|
81814
81860
|
...judged && done.state.judgeTrial ? { judgeTrial: true } : {},
|
|
81815
81861
|
...done.window ? { windowId: done.window.id } : {},
|
|
81862
|
+
...done.taskType ? { taskType: done.taskType } : {},
|
|
81816
81863
|
...judgeUsage.inputTokens || judgeUsage.outputTokens ? { judgeUsage } : {},
|
|
81817
81864
|
startedAt: now(),
|
|
81818
81865
|
signals
|
|
@@ -81884,7 +81931,12 @@ function createHarnessRouter(options, server) {
|
|
|
81884
81931
|
const run3 = {
|
|
81885
81932
|
version: "2",
|
|
81886
81933
|
runId: randomUUID2(),
|
|
81887
|
-
task: {
|
|
81934
|
+
task: {
|
|
81935
|
+
kind: "code",
|
|
81936
|
+
risk: "low",
|
|
81937
|
+
inputRef: hashRef(`${body.session}:${body.turnId}`),
|
|
81938
|
+
...turn.taskType ? { type: turn.taskType } : {}
|
|
81939
|
+
},
|
|
81888
81940
|
route: {
|
|
81889
81941
|
modelId: served,
|
|
81890
81942
|
provider: providerOf(served, options.provider),
|
|
@@ -81900,7 +81952,8 @@ function createHarnessRouter(options, server) {
|
|
|
81900
81952
|
costUsd: server.judgePricePer1k ? turn.judgeUsage.inputTokens / 1e3 * server.judgePricePer1k.input + turn.judgeUsage.outputTokens / 1e3 * server.judgePricePer1k.output : null
|
|
81901
81953
|
}
|
|
81902
81954
|
} : {},
|
|
81903
|
-
...turn.served.arm ? { arm: turn.served.arm, windowId: turn.windowId } : {}
|
|
81955
|
+
...turn.served.arm ? { arm: turn.served.arm, windowId: turn.windowId } : {},
|
|
81956
|
+
...body.baseline === void 0 ? {} : { baselineModelId: body.baseline }
|
|
81904
81957
|
},
|
|
81905
81958
|
startedAt: new Date(turn.startedAt).toISOString(),
|
|
81906
81959
|
settledAt: new Date(settledAt).toISOString(),
|
|
@@ -81911,6 +81964,7 @@ function createHarnessRouter(options, server) {
|
|
|
81911
81964
|
outputTokens: body.usage?.outputTokens ?? 0,
|
|
81912
81965
|
costUsd: 0
|
|
81913
81966
|
},
|
|
81967
|
+
signals: turn.signals,
|
|
81914
81968
|
quality: 0,
|
|
81915
81969
|
taskSuccess: false,
|
|
81916
81970
|
processSuccess: body.reason === "answer",
|
|
@@ -82308,7 +82362,14 @@ function createCodexRelay(options, server) {
|
|
|
82308
82362
|
turns.set(key, sum);
|
|
82309
82363
|
if (askedForTools && reason === "answer") return;
|
|
82310
82364
|
turns.delete(key);
|
|
82311
|
-
settling = router.complete({
|
|
82365
|
+
settling = router.complete({
|
|
82366
|
+
session: position.session,
|
|
82367
|
+
turnId: position.turnId,
|
|
82368
|
+
reason,
|
|
82369
|
+
usage: sum,
|
|
82370
|
+
// Codex's own first model: what this account would have used without the relay.
|
|
82371
|
+
...visibleModels(list2)[0] ? { baseline: visibleModels(list2)[0].slug } : {}
|
|
82372
|
+
}).catch(() => {
|
|
82312
82373
|
});
|
|
82313
82374
|
}) : void 0;
|
|
82314
82375
|
const decoder = new TextDecoder();
|
|
@@ -82502,10 +82563,10 @@ function openApiDocument({ auth }) {
|
|
|
82502
82563
|
"/v1/routing-report": {
|
|
82503
82564
|
get: {
|
|
82504
82565
|
summary: "Report Bizzy's own standing routing performance",
|
|
82505
|
-
description: "Per day and task kind, over every run Bizzy actually routed (a trial's control arm is excluded; it isn't Bizzy's routing): runs, cost per completed run, success rate, average quality, latency and token usage, how often routing escalated to the capable model, and Jev's own call rate and cost. Aggregates only. Independent of any trial window. Takes a key from BIZZY_API_KEYS or a read-only one from BIZZY_REPORT_KEYS.",
|
|
82566
|
+
description: "Per day and task kind, over every run Bizzy actually routed (a trial's control arm is excluded; it isn't Bizzy's routing): runs, cost per completed run, success rate, completion rate (finished, with no hard tool failure), estimated savings at catalog list prices against each person's default model (subscription turns included; not cash), average quality, latency and token usage, how often routing escalated to the capable model, and Jev's own call rate and cost. Aggregates only. Independent of any trial window. Takes a key from BIZZY_API_KEYS or a read-only one from BIZZY_REPORT_KEYS.",
|
|
82506
82567
|
...guard({
|
|
82507
82568
|
"200": {
|
|
82508
|
-
description: "`{ rows }`: one `{ date, taskKind, runs, costPerCompleted, successRate, avgQuality, avgLatencyMs, avgInputTokens, avgOutputTokens, capableRate, judgeCallRate, avgJudgeCostUsd }` per day and task kind, oldest first (`costPerCompleted` and `avgJudgeCostUsd` null when nothing succeeded, or nothing priced the judge).",
|
|
82569
|
+
description: "`{ rows, models }`: `models` has one `{ date, taskKind, modelId, provider, billing, runs, completedRuns, inputTokens, outputTokens, listPriceCostUsd }` per day, task kind and served model, for a table of which models were selected. `rows` is one `{ date, taskKind, runs, costPerCompleted, successRate, completionRate, listPriceCostUsd, baselineListPriceCostUsd, listPriceSavingsUsd, pricedRuns, missingBaselineRuns, avgQuality, avgLatencyMs, avgInputTokens, avgOutputTokens, capableRate, judgeCallRate, avgJudgeCostUsd }` per day and task kind, oldest first (`costPerCompleted` and `avgJudgeCostUsd` null when nothing succeeded, or nothing priced the judge; the list-price fields null when the catalog priced no run).",
|
|
82509
82570
|
content: { "application/json": { schema: { type: "object" } } }
|
|
82510
82571
|
}
|
|
82511
82572
|
})
|
|
@@ -82554,6 +82615,16 @@ function openApiDocument({ auth }) {
|
|
|
82554
82615
|
}
|
|
82555
82616
|
|
|
82556
82617
|
// bizzy-routing/api/src/routing-report.ts
|
|
82618
|
+
var standardBaseline = "anthropic/claude-sonnet-5.5";
|
|
82619
|
+
function catalogPrice(catalog, aliases = {}) {
|
|
82620
|
+
const rows2 = new Map(catalog.models.map((model) => [model.id, model]));
|
|
82621
|
+
return (modelId, provider) => {
|
|
82622
|
+
const id2 = harnessCatalogId(modelId, catalog, { provider, aliases });
|
|
82623
|
+
return id2 ? rows2.get(id2) : void 0;
|
|
82624
|
+
};
|
|
82625
|
+
}
|
|
82626
|
+
var completed = (run3) => run3.processSuccess && (run3.signals === void 0 || run3.signals.maxSeverity < 0.7 && !run3.signals.repeatedFailure);
|
|
82627
|
+
var tokensCost = (run3, price) => run3.usage.inputTokens / 1e3 * price.inputPer1k + run3.usage.outputTokens / 1e3 * price.outputPer1k;
|
|
82557
82628
|
var mean = (values) => values.reduce((sum, value) => sum + value, 0) / values.length;
|
|
82558
82629
|
function judgeCostAverage(runs) {
|
|
82559
82630
|
const priced = runs.flatMap(
|
|
@@ -82561,26 +82632,38 @@ function judgeCostAverage(runs) {
|
|
|
82561
82632
|
);
|
|
82562
82633
|
return priced.length ? mean(priced) : null;
|
|
82563
82634
|
}
|
|
82564
|
-
function summarizeRouting(records2) {
|
|
82635
|
+
function summarizeRouting(records2, price) {
|
|
82565
82636
|
const groups = /* @__PURE__ */ new Map();
|
|
82566
82637
|
for (const record5 of records2) {
|
|
82567
82638
|
if (record5.route.arm === "control") continue;
|
|
82568
82639
|
const date5 = record5.settledAt.slice(0, 10);
|
|
82569
|
-
const key = `${date5}\0${record5.task.kind}`;
|
|
82640
|
+
const key = `${date5}\0${record5.task.type ?? record5.task.kind}`;
|
|
82570
82641
|
const group = groups.get(key) ?? [];
|
|
82571
82642
|
group.push(record5);
|
|
82572
82643
|
groups.set(key, group);
|
|
82573
82644
|
}
|
|
82574
82645
|
return [...groups.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([key, runs]) => {
|
|
82575
82646
|
const [date5, taskKind] = key.split("\0");
|
|
82576
|
-
const
|
|
82577
|
-
const
|
|
82647
|
+
const succeeded = runs.filter((run3) => run3.taskSuccess);
|
|
82648
|
+
const priced = price ? runs.flatMap((run3) => {
|
|
82649
|
+
const served = price(run3.route.modelId, run3.route.provider);
|
|
82650
|
+
const baseline = run3.route.baselineModelId && price(run3.route.baselineModelId, run3.route.provider) || price(standardBaseline, run3.route.provider);
|
|
82651
|
+
return served && baseline ? [{ served: tokensCost(run3, served), baseline: tokensCost(run3, baseline) }] : [];
|
|
82652
|
+
}) : [];
|
|
82653
|
+
const sum = (values) => values.reduce((total, value) => total + value, 0);
|
|
82654
|
+
const totalCost = runs.reduce((total, run3) => total + run3.usage.costUsd, 0);
|
|
82578
82655
|
return {
|
|
82579
82656
|
date: date5,
|
|
82580
82657
|
taskKind,
|
|
82581
82658
|
runs: runs.length,
|
|
82582
|
-
costPerCompleted:
|
|
82583
|
-
successRate:
|
|
82659
|
+
costPerCompleted: succeeded.length ? totalCost / succeeded.length : null,
|
|
82660
|
+
successRate: succeeded.length / runs.length,
|
|
82661
|
+
completionRate: runs.filter(completed).length / runs.length,
|
|
82662
|
+
listPriceCostUsd: priced.length ? sum(priced.map((run3) => run3.served)) : null,
|
|
82663
|
+
baselineListPriceCostUsd: priced.length ? sum(priced.map((run3) => run3.baseline)) : null,
|
|
82664
|
+
listPriceSavingsUsd: priced.length ? sum(priced.map((run3) => run3.baseline - run3.served)) : null,
|
|
82665
|
+
pricedRuns: priced.length,
|
|
82666
|
+
missingBaselineRuns: runs.filter((run3) => run3.route.baselineModelId === void 0).length,
|
|
82584
82667
|
avgQuality: mean(runs.map((run3) => run3.quality)),
|
|
82585
82668
|
avgLatencyMs: mean(runs.map((run3) => run3.latencyMs)),
|
|
82586
82669
|
avgInputTokens: mean(runs.map((run3) => run3.usage.inputTokens)),
|
|
@@ -82591,6 +82674,37 @@ function summarizeRouting(records2) {
|
|
|
82591
82674
|
};
|
|
82592
82675
|
});
|
|
82593
82676
|
}
|
|
82677
|
+
function summarizeModels(records2, price) {
|
|
82678
|
+
const groups = /* @__PURE__ */ new Map();
|
|
82679
|
+
for (const record5 of records2) {
|
|
82680
|
+
if (record5.route.arm === "control") continue;
|
|
82681
|
+
const kind = record5.task.type ?? record5.task.kind;
|
|
82682
|
+
const key = [
|
|
82683
|
+
record5.settledAt.slice(0, 10),
|
|
82684
|
+
kind,
|
|
82685
|
+
record5.route.modelId,
|
|
82686
|
+
record5.route.provider
|
|
82687
|
+
].join("\0");
|
|
82688
|
+
groups.set(key, [...groups.get(key) ?? [], record5]);
|
|
82689
|
+
}
|
|
82690
|
+
const sum = (values) => values.reduce((total, value) => total + value, 0);
|
|
82691
|
+
return [...groups.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([key, runs]) => {
|
|
82692
|
+
const [date5, taskKind, modelId, provider] = key.split("\0");
|
|
82693
|
+
const rate = price?.(modelId, provider);
|
|
82694
|
+
return {
|
|
82695
|
+
date: date5,
|
|
82696
|
+
taskKind,
|
|
82697
|
+
modelId,
|
|
82698
|
+
provider,
|
|
82699
|
+
billing: isSubscription(provider) ? "subscription" : "per-token",
|
|
82700
|
+
runs: runs.length,
|
|
82701
|
+
completedRuns: runs.filter(completed).length,
|
|
82702
|
+
inputTokens: sum(runs.map((run3) => run3.usage.inputTokens)),
|
|
82703
|
+
outputTokens: sum(runs.map((run3) => run3.usage.outputTokens)),
|
|
82704
|
+
listPriceCostUsd: rate ? sum(runs.map((run3) => tokensCost(run3, rate))) : null
|
|
82705
|
+
};
|
|
82706
|
+
});
|
|
82707
|
+
}
|
|
82594
82708
|
|
|
82595
82709
|
// bizzy-routing/api/src/trial-report.ts
|
|
82596
82710
|
var mean2 = (values) => values.reduce((sum, value) => sum + value, 0) / values.length;
|
|
@@ -82598,21 +82712,21 @@ function summarizeWindow(records2) {
|
|
|
82598
82712
|
const groups = /* @__PURE__ */ new Map();
|
|
82599
82713
|
for (const record5 of records2) {
|
|
82600
82714
|
if (!record5.route.arm) continue;
|
|
82601
|
-
const key = `${record5.route.arm}\0${record5.task.kind}`;
|
|
82715
|
+
const key = `${record5.route.arm}\0${record5.task.type ?? record5.task.kind}`;
|
|
82602
82716
|
const group = groups.get(key) ?? [];
|
|
82603
82717
|
group.push(record5);
|
|
82604
82718
|
groups.set(key, group);
|
|
82605
82719
|
}
|
|
82606
82720
|
return [...groups.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([key, runs]) => {
|
|
82607
82721
|
const [arm, taskKind] = key.split("\0");
|
|
82608
|
-
const
|
|
82722
|
+
const completed2 = runs.filter((run3) => run3.taskSuccess);
|
|
82609
82723
|
const totalCost = runs.reduce((sum, run3) => sum + run3.usage.costUsd, 0);
|
|
82610
82724
|
return {
|
|
82611
82725
|
arm,
|
|
82612
82726
|
taskKind,
|
|
82613
82727
|
runs: runs.length,
|
|
82614
|
-
costPerCompleted:
|
|
82615
|
-
successRate:
|
|
82728
|
+
costPerCompleted: completed2.length ? totalCost / completed2.length : null,
|
|
82729
|
+
successRate: completed2.length / runs.length,
|
|
82616
82730
|
avgQuality: mean2(runs.map((run3) => run3.quality)),
|
|
82617
82731
|
avgLatencyMs: mean2(runs.map((run3) => run3.latencyMs))
|
|
82618
82732
|
};
|
|
@@ -82728,9 +82842,13 @@ function createRoutingServer(options) {
|
|
|
82728
82842
|
const window2 = options.trialWindow?.load();
|
|
82729
82843
|
return trialReport(options.trialRuns?.() ?? [], window2 ? openWindowOf(window2) : null);
|
|
82730
82844
|
});
|
|
82731
|
-
app.get("/v1/routing-report", reportGuard, async () =>
|
|
82732
|
-
|
|
82733
|
-
|
|
82845
|
+
app.get("/v1/routing-report", reportGuard, async () => {
|
|
82846
|
+
const catalog = await options.catalog?.().catch(() => null);
|
|
82847
|
+
const aliases = await options.aliases?.().catch(() => void 0) ?? {};
|
|
82848
|
+
const runs = options.allRuns?.() ?? [];
|
|
82849
|
+
const price = catalog ? catalogPrice(catalog, aliases) : void 0;
|
|
82850
|
+
return { rows: summarizeRouting(runs, price), models: summarizeModels(runs, price) };
|
|
82851
|
+
});
|
|
82734
82852
|
app.post("/v1/route", guarded, async (request, reply) => {
|
|
82735
82853
|
let parsed2;
|
|
82736
82854
|
try {
|
|
@@ -83113,7 +83231,7 @@ function claudeHarness(profile) {
|
|
|
83113
83231
|
return { harnessId: "claude-code", provider: "anthropic", ...profile ? { profile } : {} };
|
|
83114
83232
|
}
|
|
83115
83233
|
function ompHarness() {
|
|
83116
|
-
return { harnessId: "omp" };
|
|
83234
|
+
return { harnessId: "omp", subscriptionFirst: true };
|
|
83117
83235
|
}
|
|
83118
83236
|
function codexRelay(env) {
|
|
83119
83237
|
return {
|
package/package.json
CHANGED