@bizzywork/routing 0.4.5 → 0.4.6
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-IY47BGRH.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.6" : "dev",
|
|
39
39
|
platform: process.platform,
|
|
40
40
|
uid: process.getuid?.(),
|
|
41
41
|
interactive,
|
|
@@ -402,6 +402,8 @@ export const register: Register = (on) => {
|
|
|
402
402
|
usage.cache_read_input_tokens +
|
|
403
403
|
usage.cache_creation_input_tokens,
|
|
404
404
|
outputTokens: usage.output_tokens,
|
|
405
|
+
cacheReadTokens: usage.cache_read_input_tokens,
|
|
406
|
+
cacheWriteTokens: usage.cache_creation_input_tokens,
|
|
405
407
|
},
|
|
406
408
|
}
|
|
407
409
|
: {}),
|
|
@@ -423,6 +423,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
423
423
|
usage: {
|
|
424
424
|
inputTokens: message.usage.input + message.usage.cacheRead + message.usage.cacheWrite,
|
|
425
425
|
outputTokens: message.usage.output,
|
|
426
|
+
cacheReadTokens: message.usage.cacheRead,
|
|
427
|
+
cacheWriteTokens: message.usage.cacheWrite,
|
|
426
428
|
},
|
|
427
429
|
}).catch(() => {});
|
|
428
430
|
}
|
|
@@ -1173,7 +1173,7 @@ var require_foldFlowLines = __commonJS({
|
|
|
1173
1173
|
else
|
|
1174
1174
|
end = lineWidth - indentAtStart;
|
|
1175
1175
|
}
|
|
1176
|
-
let
|
|
1176
|
+
let split2 = void 0;
|
|
1177
1177
|
let prev = void 0;
|
|
1178
1178
|
let overflow = false;
|
|
1179
1179
|
let i = -1;
|
|
@@ -1206,18 +1206,18 @@ var require_foldFlowLines = __commonJS({
|
|
|
1206
1206
|
if (mode === FOLD_BLOCK)
|
|
1207
1207
|
i = consumeMoreIndentedLines(text, i, indent.length);
|
|
1208
1208
|
end = i + indent.length + endStep;
|
|
1209
|
-
|
|
1209
|
+
split2 = void 0;
|
|
1210
1210
|
} else {
|
|
1211
1211
|
if (ch === " " && prev && prev !== " " && prev !== "\n" && prev !== " ") {
|
|
1212
1212
|
const next = text[i + 1];
|
|
1213
1213
|
if (next && next !== " " && next !== "\n" && next !== " ")
|
|
1214
|
-
|
|
1214
|
+
split2 = i;
|
|
1215
1215
|
}
|
|
1216
1216
|
if (i >= end) {
|
|
1217
|
-
if (
|
|
1218
|
-
folds.push(
|
|
1219
|
-
end =
|
|
1220
|
-
|
|
1217
|
+
if (split2) {
|
|
1218
|
+
folds.push(split2);
|
|
1219
|
+
end = split2 + endStep;
|
|
1220
|
+
split2 = void 0;
|
|
1221
1221
|
} else if (mode === FOLD_QUOTED) {
|
|
1222
1222
|
while (prev === " " || prev === " ") {
|
|
1223
1223
|
prev = ch;
|
|
@@ -1230,7 +1230,7 @@ var require_foldFlowLines = __commonJS({
|
|
|
1230
1230
|
folds.push(j);
|
|
1231
1231
|
escapedFolds[j] = true;
|
|
1232
1232
|
end = j + endStep;
|
|
1233
|
-
|
|
1233
|
+
split2 = void 0;
|
|
1234
1234
|
} else {
|
|
1235
1235
|
overflow = true;
|
|
1236
1236
|
}
|
|
@@ -4764,13 +4764,13 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
4764
4764
|
return { mode, indent, chomp, comment, length };
|
|
4765
4765
|
}
|
|
4766
4766
|
function splitLines(source) {
|
|
4767
|
-
const
|
|
4768
|
-
const first =
|
|
4767
|
+
const split2 = source.split(/\n( *)/);
|
|
4768
|
+
const first = split2[0];
|
|
4769
4769
|
const m = first.match(/^( *)/);
|
|
4770
4770
|
const line0 = m?.[1] ? [m[1], first.slice(m[1].length)] : ["", first];
|
|
4771
4771
|
const lines2 = [line0];
|
|
4772
|
-
for (let i = 1; i <
|
|
4773
|
-
lines2.push([
|
|
4772
|
+
for (let i = 1; i < split2.length; i += 2)
|
|
4773
|
+
lines2.push([split2[i], split2[i + 1]]);
|
|
4774
4774
|
return lines2;
|
|
4775
4775
|
}
|
|
4776
4776
|
exports.resolveBlockScalar = resolveBlockScalar;
|
|
@@ -9172,8 +9172,8 @@ var require_common = __commonJS({
|
|
|
9172
9172
|
createDebug.namespaces = namespaces;
|
|
9173
9173
|
createDebug.names = [];
|
|
9174
9174
|
createDebug.skips = [];
|
|
9175
|
-
const
|
|
9176
|
-
for (const ns of
|
|
9175
|
+
const split2 = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
|
|
9176
|
+
for (const ns of split2) {
|
|
9177
9177
|
if (ns[0] === "-") {
|
|
9178
9178
|
createDebug.skips.push(ns.slice(1));
|
|
9179
9179
|
} else {
|
|
@@ -54052,16 +54052,16 @@ var require_set_cookie = __commonJS({
|
|
|
54052
54052
|
input2 = sch;
|
|
54053
54053
|
}
|
|
54054
54054
|
}
|
|
54055
|
-
var
|
|
54055
|
+
var split2 = options.split;
|
|
54056
54056
|
var isArray = Array.isArray(input2);
|
|
54057
|
-
if (
|
|
54058
|
-
|
|
54057
|
+
if (split2 === "auto") {
|
|
54058
|
+
split2 = !isArray;
|
|
54059
54059
|
}
|
|
54060
54060
|
if (!isArray) {
|
|
54061
54061
|
input2 = [input2];
|
|
54062
54062
|
}
|
|
54063
54063
|
input2 = input2.filter(isNonEmptyString);
|
|
54064
|
-
if (
|
|
54064
|
+
if (split2) {
|
|
54065
54065
|
input2 = input2.map(splitCookiesString).flat();
|
|
54066
54066
|
}
|
|
54067
54067
|
if (!options.map) {
|
|
@@ -76528,9 +76528,14 @@ var RoutingStateSchema = external_exports.record(
|
|
|
76528
76528
|
var IsoDateSchema = external_exports.string().regex(/^\d{4}-\d{2}-\d{2}T/).refine((value) => Number.isFinite(Date.parse(value)));
|
|
76529
76529
|
var CountSchema2 = external_exports.number().int().min(0);
|
|
76530
76530
|
var UsageSchema = external_exports.object({
|
|
76531
|
+
/** All input tokens, cached ones included: the total the provider bills against. */
|
|
76531
76532
|
inputTokens: CountSchema2,
|
|
76532
76533
|
outputTokens: CountSchema2,
|
|
76533
|
-
costUsd: external_exports.number().min(0)
|
|
76534
|
+
costUsd: external_exports.number().min(0),
|
|
76535
|
+
/** The part of `inputTokens` served from the provider's prompt cache, and the part written to it. Unset on
|
|
76536
|
+
* runs recorded before they were split out, which price as fresh input. */
|
|
76537
|
+
cacheReadTokens: CountSchema2.exactOptional(),
|
|
76538
|
+
cacheWriteTokens: CountSchema2.exactOptional()
|
|
76534
76539
|
});
|
|
76535
76540
|
var RunRecordSchema = external_exports.object({
|
|
76536
76541
|
version: external_exports.literal("2"),
|
|
@@ -81004,11 +81009,15 @@ function parseModels(body) {
|
|
|
81004
81009
|
const input2 = Number(pricing?.prompt) * 1e3, output2 = Number(pricing?.completion) * 1e3;
|
|
81005
81010
|
if (!(input2 >= 0 && output2 >= 0)) continue;
|
|
81006
81011
|
const parameters = Array.isArray(row.supported_parameters) ? row.supported_parameters : [];
|
|
81012
|
+
const cache = pricing;
|
|
81013
|
+
const cacheRead = Number(cache?.input_cache_read) * 1e3, cacheWrite = Number(cache?.input_cache_write) * 1e3;
|
|
81007
81014
|
models.push({
|
|
81008
81015
|
id: id2,
|
|
81009
81016
|
contextLength: score(row.context_length) ?? 0,
|
|
81010
81017
|
inputPer1k: input2,
|
|
81011
81018
|
outputPer1k: output2,
|
|
81019
|
+
...cacheRead >= 0 ? { cacheReadPer1k: cacheRead } : {},
|
|
81020
|
+
...cacheWrite >= 0 ? { cacheWritePer1k: cacheWrite } : {},
|
|
81012
81021
|
toolUse: parameters.includes("tools"),
|
|
81013
81022
|
codingIndex: null,
|
|
81014
81023
|
agenticIndex: null,
|
|
@@ -81715,7 +81724,9 @@ function parseHarnessComplete(raw) {
|
|
|
81715
81724
|
...usage ? {
|
|
81716
81725
|
usage: {
|
|
81717
81726
|
inputTokens: count(usage.inputTokens, "usage.inputTokens"),
|
|
81718
|
-
outputTokens: count(usage.outputTokens, "usage.outputTokens")
|
|
81727
|
+
outputTokens: count(usage.outputTokens, "usage.outputTokens"),
|
|
81728
|
+
...usage.cacheReadTokens === void 0 ? {} : { cacheReadTokens: count(usage.cacheReadTokens, "usage.cacheReadTokens") },
|
|
81729
|
+
...usage.cacheWriteTokens === void 0 ? {} : { cacheWriteTokens: count(usage.cacheWriteTokens, "usage.cacheWriteTokens") }
|
|
81719
81730
|
}
|
|
81720
81731
|
} : {}
|
|
81721
81732
|
};
|
|
@@ -81962,7 +81973,9 @@ function createHarnessRouter(options, server) {
|
|
|
81962
81973
|
usage: {
|
|
81963
81974
|
inputTokens: body.usage?.inputTokens ?? 0,
|
|
81964
81975
|
outputTokens: body.usage?.outputTokens ?? 0,
|
|
81965
|
-
costUsd: 0
|
|
81976
|
+
costUsd: 0,
|
|
81977
|
+
...body.usage?.cacheReadTokens === void 0 ? {} : { cacheReadTokens: body.usage.cacheReadTokens },
|
|
81978
|
+
...body.usage?.cacheWriteTokens === void 0 ? {} : { cacheWriteTokens: body.usage.cacheWriteTokens }
|
|
81966
81979
|
},
|
|
81967
81980
|
signals: turn.signals,
|
|
81968
81981
|
quality: 0,
|
|
@@ -82204,7 +82217,12 @@ function terminalWatcher(onEnd) {
|
|
|
82204
82217
|
const askedForTools = output2.some((item) => /call$/.test(String(record4(item)?.type)));
|
|
82205
82218
|
onEnd(
|
|
82206
82219
|
event.type === "response.completed" ? "answer" : "error",
|
|
82207
|
-
usage && typeof usage.input_tokens === "number" && typeof usage.output_tokens === "number" ? {
|
|
82220
|
+
usage && typeof usage.input_tokens === "number" && typeof usage.output_tokens === "number" ? {
|
|
82221
|
+
inputTokens: usage.input_tokens,
|
|
82222
|
+
outputTokens: usage.output_tokens,
|
|
82223
|
+
// OpenAI bills cached input at a discount and charges nothing extra to write it.
|
|
82224
|
+
...typeof record4(usage.input_tokens_details)?.cached_tokens === "number" ? { cacheReadTokens: record4(usage.input_tokens_details).cached_tokens } : {}
|
|
82225
|
+
} : void 0,
|
|
82208
82226
|
askedForTools
|
|
82209
82227
|
);
|
|
82210
82228
|
}
|
|
@@ -82358,6 +82376,8 @@ function createCodexRelay(options, server) {
|
|
|
82358
82376
|
if (usage) {
|
|
82359
82377
|
sum.inputTokens += usage.inputTokens;
|
|
82360
82378
|
sum.outputTokens += usage.outputTokens;
|
|
82379
|
+
if (usage.cacheReadTokens !== void 0)
|
|
82380
|
+
sum.cacheReadTokens = (sum.cacheReadTokens ?? 0) + usage.cacheReadTokens;
|
|
82361
82381
|
}
|
|
82362
82382
|
turns.set(key, sum);
|
|
82363
82383
|
if (askedForTools && reason === "answer") return;
|
|
@@ -82624,7 +82644,13 @@ function catalogPrice(catalog, aliases = {}) {
|
|
|
82624
82644
|
};
|
|
82625
82645
|
}
|
|
82626
82646
|
var completed = (run3) => run3.processSuccess && (run3.signals === void 0 || run3.signals.maxSeverity < 0.7 && !run3.signals.repeatedFailure);
|
|
82627
|
-
var
|
|
82647
|
+
var split = (run3) => run3.usage.cacheReadTokens !== void 0 || run3.usage.cacheWriteTokens !== void 0;
|
|
82648
|
+
var tokensCost = (run3, price) => {
|
|
82649
|
+
const read = run3.usage.cacheReadTokens ?? 0;
|
|
82650
|
+
const write = run3.usage.cacheWriteTokens ?? 0;
|
|
82651
|
+
const fresh = Math.max(0, run3.usage.inputTokens - read - write);
|
|
82652
|
+
return fresh / 1e3 * price.inputPer1k + read / 1e3 * (price.cacheReadPer1k ?? price.inputPer1k) + write / 1e3 * (price.cacheWritePer1k ?? price.inputPer1k) + run3.usage.outputTokens / 1e3 * price.outputPer1k;
|
|
82653
|
+
};
|
|
82628
82654
|
var mean = (values) => values.reduce((sum, value) => sum + value, 0) / values.length;
|
|
82629
82655
|
function judgeCostAverage(runs) {
|
|
82630
82656
|
const priced = runs.flatMap(
|
|
@@ -82645,7 +82671,7 @@ function summarizeRouting(records2, price) {
|
|
|
82645
82671
|
return [...groups.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([key, runs]) => {
|
|
82646
82672
|
const [date5, taskKind] = key.split("\0");
|
|
82647
82673
|
const succeeded = runs.filter((run3) => run3.taskSuccess);
|
|
82648
|
-
const priced = price ? runs.flatMap((run3) => {
|
|
82674
|
+
const priced = price ? runs.filter(split).flatMap((run3) => {
|
|
82649
82675
|
const served = price(run3.route.modelId, run3.route.provider);
|
|
82650
82676
|
const baseline = run3.route.baselineModelId && price(run3.route.baselineModelId, run3.route.provider) || price(standardBaseline, run3.route.provider);
|
|
82651
82677
|
return served && baseline ? [{ served: tokensCost(run3, served), baseline: tokensCost(run3, baseline) }] : [];
|
|
@@ -82664,6 +82690,7 @@ function summarizeRouting(records2, price) {
|
|
|
82664
82690
|
listPriceSavingsUsd: priced.length ? sum(priced.map((run3) => run3.baseline - run3.served)) : null,
|
|
82665
82691
|
pricedRuns: priced.length,
|
|
82666
82692
|
missingBaselineRuns: runs.filter((run3) => run3.route.baselineModelId === void 0).length,
|
|
82693
|
+
unsplitRuns: runs.filter((run3) => !split(run3)).length,
|
|
82667
82694
|
avgQuality: mean(runs.map((run3) => run3.quality)),
|
|
82668
82695
|
avgLatencyMs: mean(runs.map((run3) => run3.latencyMs)),
|
|
82669
82696
|
avgInputTokens: mean(runs.map((run3) => run3.usage.inputTokens)),
|
|
@@ -82701,7 +82728,7 @@ function summarizeModels(records2, price) {
|
|
|
82701
82728
|
completedRuns: runs.filter(completed).length,
|
|
82702
82729
|
inputTokens: sum(runs.map((run3) => run3.usage.inputTokens)),
|
|
82703
82730
|
outputTokens: sum(runs.map((run3) => run3.usage.outputTokens)),
|
|
82704
|
-
listPriceCostUsd: rate ? sum(runs.map((run3) => tokensCost(run3, rate))) : null
|
|
82731
|
+
listPriceCostUsd: rate && runs.some(split) ? sum(runs.filter(split).map((run3) => tokensCost(run3, rate))) : null
|
|
82705
82732
|
};
|
|
82706
82733
|
});
|
|
82707
82734
|
}
|
package/package.json
CHANGED