nexus-agents 6.3.2 → 6.3.4
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/dist/{child-mcp-config-6UXFBHW5.js → child-mcp-config-HGD32ADZ.js} +2 -2
- package/dist/{chunk-DZQWHHGI.js → chunk-3FPHHCY5.js} +4 -4
- package/dist/{chunk-UONHQ3Q3.js → chunk-5FHJAPIR.js} +2 -2
- package/dist/chunk-AQBOZVBW.js +7 -0
- package/dist/{chunk-2TP7YLBC.js → chunk-BE6FQ7XI.js} +2 -2
- package/dist/{chunk-XJ76EMQV.js → chunk-CLIZCXWB.js} +5 -5
- package/dist/{chunk-XHKHC44U.js → chunk-DJN4XAQO.js} +47 -43
- package/dist/{chunk-XHKHC44U.js.map → chunk-DJN4XAQO.js.map} +1 -1
- package/dist/{chunk-BT534KOS.js → chunk-DPFRPNAC.js} +7 -7
- package/dist/{chunk-MFORQ7FO.js → chunk-E6LGFJQE.js} +2 -2
- package/dist/{chunk-GVRDLRJM.js → chunk-ECHZGAZO.js} +49 -4
- package/dist/chunk-ECHZGAZO.js.map +1 -0
- package/dist/{chunk-47TTP5PC.js → chunk-FQQYGPMC.js} +2 -2
- package/dist/{chunk-5LREI4NO.js → chunk-GRLN6WL5.js} +3 -3
- package/dist/{chunk-5M3ZAK2V.js → chunk-HJUL6YRG.js} +4 -4
- package/dist/{chunk-LX4DUS4M.js → chunk-ITB2NBB7.js} +6 -6
- package/dist/{chunk-E2TILOO3.js → chunk-JLA2YAGY.js} +5 -5
- package/dist/{chunk-T7NTJNCG.js → chunk-JLE24ZSP.js} +2 -2
- package/dist/{chunk-XWKL7QDH.js → chunk-KNBIEADY.js} +2 -2
- package/dist/{chunk-QOF5S5Z5.js → chunk-KYHZYRMR.js} +2 -2
- package/dist/{chunk-5F36KKHM.js → chunk-LB4UH4FF.js} +25 -4
- package/dist/chunk-LB4UH4FF.js.map +1 -0
- package/dist/{chunk-ZT6RBA7L.js → chunk-LMIR62SG.js} +2 -2
- package/dist/{chunk-QEZ5CS5H.js → chunk-LPBGCX6H.js} +2 -2
- package/dist/{chunk-JYTDEFY6.js → chunk-NQ2CC67G.js} +2 -2
- package/dist/{chunk-ZCNB6YJ3.js → chunk-NXHPOKIO.js} +4 -4
- package/dist/{chunk-M2TFLYPC.js → chunk-Q3DEXAOB.js} +7 -7
- package/dist/{chunk-LM5ZSWYB.js → chunk-QZJR42BR.js} +4 -4
- package/dist/{chunk-5YZF5DUW.js → chunk-R6YU33TY.js} +8 -8
- package/dist/{chunk-ZTH7YD3J.js → chunk-RIMEO4AY.js} +3 -3
- package/dist/{chunk-VE6ZMLCT.js → chunk-SPRQFHVR.js} +2 -2
- package/dist/{chunk-W3VI2AAJ.js → chunk-TOQVL64J.js} +3 -3
- package/dist/{chunk-KFKI2M4X.js → chunk-UCW7IIX6.js} +2 -2
- package/dist/{chunk-YZDCUGPS.js → chunk-Y5ATK7BS.js} +2 -2
- package/dist/{chunk-6THNSXDV.js → chunk-YBG6Y2UN.js} +8 -8
- package/dist/{chunk-EPIRYAU3.js → chunk-Z2EUE6E6.js} +2 -2
- package/dist/{chunk-64LODBD3.js → chunk-ZNPUVXMB.js} +2 -2
- package/dist/{cli-circuit-breaker-U2CTVGQ7.js → cli-circuit-breaker-NPISC6Q4.js} +3 -3
- package/dist/cli.js +41 -41
- package/dist/{composite-router-GQOZMVH7.js → composite-router-ULU3C7ZA.js} +2 -2
- package/dist/{consensus-vote-YUVGQZL7.js → consensus-vote-5XRP2OY4.js} +17 -17
- package/dist/{context-retriever-FHHESJMM.js → context-retriever-UDMXESPP.js} +8 -8
- package/dist/{doctor-deep-Y65MN57O.js → doctor-deep-E2UHOIOS.js} +3 -3
- package/dist/{doctor-live-SWFNSL5Y.js → doctor-live-52MCZLBK.js} +9 -9
- package/dist/{expert-bridge-Y75TQIEO.js → expert-bridge-KMJQGVUM.js} +4 -4
- package/dist/{factory-7BW4S6PR.js → factory-LCKPBDL2.js} +5 -5
- package/dist/{factory-EBM7Z7MP.js → factory-RPWJNOET.js} +9 -9
- package/dist/{improvement-review-QKDI3QDL.js → improvement-review-2R6UZ4PF.js} +6 -6
- package/dist/index.js +31 -31
- package/dist/{init-opencode-SSEA3UCA.js → init-opencode-AFES5ZQD.js} +6 -6
- package/dist/issue-triage-VVEGWHXP.js +17 -0
- package/dist/{pr-reviewer-helpers-245UWBYB.js → pr-reviewer-helpers-EJIWNM3Z.js} +4 -4
- package/dist/{registry-command-TPLFFKVI.js → registry-command-45SBK736.js} +2 -2
- package/dist/{repo-security-plan-C4JE7ZKQ.js → repo-security-plan-Z25BUZGY.js} +3 -3
- package/dist/{research-helpers-synthesize-ZZRDEX7R.js → research-helpers-synthesize-ILCLFNSL.js} +4 -4
- package/dist/{routing-memory-MLMNEIZD.js → routing-memory-SE3MTQSU.js} +2 -2
- package/dist/{session-memory-43TLUGSP.js → session-memory-JOJ5SHVX.js} +3 -3
- package/dist/{setup-config-LZWSAEL7.js → setup-config-IVLUCSF2.js} +3 -3
- package/dist/{setup-custom-api-UIIB2OYQ.js → setup-custom-api-G24JS2HB.js} +4 -4
- package/dist/setup-data-dir-VN2PMSVM.js +29 -0
- package/dist/{tool-memory-6HM6HC2C.js → tool-memory-O4XK27UO.js} +5 -5
- package/dist/{unified-registry-YYHYITVO.js → unified-registry-DPOXBGFQ.js} +10 -10
- package/dist/{weather-report-WCWQRH3K.js → weather-report-5SMT3RHJ.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-5F36KKHM.js.map +0 -1
- package/dist/chunk-5STSWEDG.js +0 -7
- package/dist/chunk-GVRDLRJM.js.map +0 -1
- package/dist/issue-triage-HQQ2TR4C.js +0 -17
- package/dist/setup-data-dir-NNBWZ2BK.js +0 -29
- /package/dist/{child-mcp-config-6UXFBHW5.js.map → child-mcp-config-HGD32ADZ.js.map} +0 -0
- /package/dist/{chunk-DZQWHHGI.js.map → chunk-3FPHHCY5.js.map} +0 -0
- /package/dist/{chunk-UONHQ3Q3.js.map → chunk-5FHJAPIR.js.map} +0 -0
- /package/dist/{chunk-5STSWEDG.js.map → chunk-AQBOZVBW.js.map} +0 -0
- /package/dist/{chunk-2TP7YLBC.js.map → chunk-BE6FQ7XI.js.map} +0 -0
- /package/dist/{chunk-XJ76EMQV.js.map → chunk-CLIZCXWB.js.map} +0 -0
- /package/dist/{chunk-BT534KOS.js.map → chunk-DPFRPNAC.js.map} +0 -0
- /package/dist/{chunk-MFORQ7FO.js.map → chunk-E6LGFJQE.js.map} +0 -0
- /package/dist/{chunk-47TTP5PC.js.map → chunk-FQQYGPMC.js.map} +0 -0
- /package/dist/{chunk-5LREI4NO.js.map → chunk-GRLN6WL5.js.map} +0 -0
- /package/dist/{chunk-5M3ZAK2V.js.map → chunk-HJUL6YRG.js.map} +0 -0
- /package/dist/{chunk-LX4DUS4M.js.map → chunk-ITB2NBB7.js.map} +0 -0
- /package/dist/{chunk-E2TILOO3.js.map → chunk-JLA2YAGY.js.map} +0 -0
- /package/dist/{chunk-T7NTJNCG.js.map → chunk-JLE24ZSP.js.map} +0 -0
- /package/dist/{chunk-XWKL7QDH.js.map → chunk-KNBIEADY.js.map} +0 -0
- /package/dist/{chunk-QOF5S5Z5.js.map → chunk-KYHZYRMR.js.map} +0 -0
- /package/dist/{chunk-ZT6RBA7L.js.map → chunk-LMIR62SG.js.map} +0 -0
- /package/dist/{chunk-QEZ5CS5H.js.map → chunk-LPBGCX6H.js.map} +0 -0
- /package/dist/{chunk-JYTDEFY6.js.map → chunk-NQ2CC67G.js.map} +0 -0
- /package/dist/{chunk-ZCNB6YJ3.js.map → chunk-NXHPOKIO.js.map} +0 -0
- /package/dist/{chunk-M2TFLYPC.js.map → chunk-Q3DEXAOB.js.map} +0 -0
- /package/dist/{chunk-LM5ZSWYB.js.map → chunk-QZJR42BR.js.map} +0 -0
- /package/dist/{chunk-5YZF5DUW.js.map → chunk-R6YU33TY.js.map} +0 -0
- /package/dist/{chunk-ZTH7YD3J.js.map → chunk-RIMEO4AY.js.map} +0 -0
- /package/dist/{chunk-VE6ZMLCT.js.map → chunk-SPRQFHVR.js.map} +0 -0
- /package/dist/{chunk-W3VI2AAJ.js.map → chunk-TOQVL64J.js.map} +0 -0
- /package/dist/{chunk-KFKI2M4X.js.map → chunk-UCW7IIX6.js.map} +0 -0
- /package/dist/{chunk-YZDCUGPS.js.map → chunk-Y5ATK7BS.js.map} +0 -0
- /package/dist/{chunk-6THNSXDV.js.map → chunk-YBG6Y2UN.js.map} +0 -0
- /package/dist/{chunk-EPIRYAU3.js.map → chunk-Z2EUE6E6.js.map} +0 -0
- /package/dist/{chunk-64LODBD3.js.map → chunk-ZNPUVXMB.js.map} +0 -0
- /package/dist/{cli-circuit-breaker-U2CTVGQ7.js.map → cli-circuit-breaker-NPISC6Q4.js.map} +0 -0
- /package/dist/{composite-router-GQOZMVH7.js.map → composite-router-ULU3C7ZA.js.map} +0 -0
- /package/dist/{consensus-vote-YUVGQZL7.js.map → consensus-vote-5XRP2OY4.js.map} +0 -0
- /package/dist/{context-retriever-FHHESJMM.js.map → context-retriever-UDMXESPP.js.map} +0 -0
- /package/dist/{doctor-deep-Y65MN57O.js.map → doctor-deep-E2UHOIOS.js.map} +0 -0
- /package/dist/{doctor-live-SWFNSL5Y.js.map → doctor-live-52MCZLBK.js.map} +0 -0
- /package/dist/{expert-bridge-Y75TQIEO.js.map → expert-bridge-KMJQGVUM.js.map} +0 -0
- /package/dist/{factory-7BW4S6PR.js.map → factory-LCKPBDL2.js.map} +0 -0
- /package/dist/{factory-EBM7Z7MP.js.map → factory-RPWJNOET.js.map} +0 -0
- /package/dist/{improvement-review-QKDI3QDL.js.map → improvement-review-2R6UZ4PF.js.map} +0 -0
- /package/dist/{init-opencode-SSEA3UCA.js.map → init-opencode-AFES5ZQD.js.map} +0 -0
- /package/dist/{issue-triage-HQQ2TR4C.js.map → issue-triage-VVEGWHXP.js.map} +0 -0
- /package/dist/{pr-reviewer-helpers-245UWBYB.js.map → pr-reviewer-helpers-EJIWNM3Z.js.map} +0 -0
- /package/dist/{registry-command-TPLFFKVI.js.map → registry-command-45SBK736.js.map} +0 -0
- /package/dist/{repo-security-plan-C4JE7ZKQ.js.map → repo-security-plan-Z25BUZGY.js.map} +0 -0
- /package/dist/{research-helpers-synthesize-ZZRDEX7R.js.map → research-helpers-synthesize-ILCLFNSL.js.map} +0 -0
- /package/dist/{routing-memory-MLMNEIZD.js.map → routing-memory-SE3MTQSU.js.map} +0 -0
- /package/dist/{session-memory-43TLUGSP.js.map → session-memory-JOJ5SHVX.js.map} +0 -0
- /package/dist/{setup-config-LZWSAEL7.js.map → setup-config-IVLUCSF2.js.map} +0 -0
- /package/dist/{setup-custom-api-UIIB2OYQ.js.map → setup-custom-api-G24JS2HB.js.map} +0 -0
- /package/dist/{setup-data-dir-NNBWZ2BK.js.map → setup-data-dir-VN2PMSVM.js.map} +0 -0
- /package/dist/{tool-memory-6HM6HC2C.js.map → tool-memory-O4XK27UO.js.map} +0 -0
- /package/dist/{unified-registry-YYHYITVO.js.map → unified-registry-DPOXBGFQ.js.map} +0 -0
- /package/dist/{weather-report-WCWQRH3K.js.map → weather-report-5SMT3RHJ.js.map} +0 -0
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
readOpenAICompatEnv
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JLA2YAGY.js";
|
|
4
4
|
import {
|
|
5
5
|
allOf
|
|
6
6
|
} from "./chunk-OQB3XC5O.js";
|
|
7
7
|
import {
|
|
8
8
|
VERSION
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-AQBOZVBW.js";
|
|
10
10
|
import {
|
|
11
11
|
capitalize
|
|
12
12
|
} from "./chunk-6T3EPABN.js";
|
|
13
13
|
import {
|
|
14
14
|
createAllAdapters,
|
|
15
15
|
probeCli
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-R6YU33TY.js";
|
|
17
17
|
import {
|
|
18
18
|
getNexusTmpDir
|
|
19
19
|
} from "./chunk-4OW67KT2.js";
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
ok,
|
|
29
29
|
symbols,
|
|
30
30
|
writeLine
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-LB4UH4FF.js";
|
|
32
32
|
import {
|
|
33
33
|
getLearningDir,
|
|
34
34
|
getOutcomesFile,
|
|
@@ -1201,13 +1201,13 @@ async function runDoctorFix(result) {
|
|
|
1201
1201
|
writeLine2("\u2500".repeat(40));
|
|
1202
1202
|
let fixCount = 0;
|
|
1203
1203
|
if (!result.dataDirectory.rootExists || result.dataDirectory.subdirectories.some((d) => !d.exists || !d.writable)) {
|
|
1204
|
-
const { initDataDirectories: initDataDirectories2, describeDataDirFix: describeDataDirFix2 } = await import("./setup-data-dir-
|
|
1204
|
+
const { initDataDirectories: initDataDirectories2, describeDataDirFix: describeDataDirFix2 } = await import("./setup-data-dir-VN2PMSVM.js");
|
|
1205
1205
|
const outcome = describeDataDirFix2(initDataDirectories2());
|
|
1206
1206
|
writeLine2(outcome.line);
|
|
1207
1207
|
if (outcome.counted) fixCount++;
|
|
1208
1208
|
}
|
|
1209
1209
|
if (!result.configFile.found) {
|
|
1210
|
-
const { runConfigInitSync } = await import("./setup-config-
|
|
1210
|
+
const { runConfigInitSync } = await import("./setup-config-IVLUCSF2.js");
|
|
1211
1211
|
const configResult = runConfigInitSync(process.cwd(), false, false);
|
|
1212
1212
|
if (configResult.success && configResult.created) {
|
|
1213
1213
|
writeLine2(`\u2713 Generated config: ${configResult.path}`);
|
|
@@ -1303,4 +1303,4 @@ export {
|
|
|
1303
1303
|
startStdioServer,
|
|
1304
1304
|
closeServer
|
|
1305
1305
|
};
|
|
1306
|
-
//# sourceMappingURL=chunk-
|
|
1306
|
+
//# sourceMappingURL=chunk-DPFRPNAC.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
getErrorMessage,
|
|
5
5
|
getTimeProvider,
|
|
6
6
|
ok
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-LB4UH4FF.js";
|
|
8
8
|
|
|
9
9
|
// src/context/session-memory.ts
|
|
10
10
|
import * as fs from "fs";
|
|
@@ -366,4 +366,4 @@ export {
|
|
|
366
366
|
SessionMemory,
|
|
367
367
|
createSessionMemory
|
|
368
368
|
};
|
|
369
|
-
//# sourceMappingURL=chunk-
|
|
369
|
+
//# sourceMappingURL=chunk-E6LGFJQE.js.map
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
computeTokenCost,
|
|
3
|
+
createLogger,
|
|
3
4
|
getDefaultRegistry,
|
|
4
5
|
roundToMicroUsd
|
|
5
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-LB4UH4FF.js";
|
|
6
7
|
import {
|
|
7
8
|
getNexusDataDir
|
|
8
9
|
} from "./chunk-OGHEKPLD.js";
|
|
9
10
|
|
|
10
11
|
// src/learning/usage-log.ts
|
|
12
|
+
import { z } from "zod";
|
|
11
13
|
import { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync } from "fs";
|
|
12
14
|
import { dirname, join } from "path";
|
|
13
15
|
function computeCostDetail(modelId, inputTokens, outputTokens) {
|
|
@@ -48,6 +50,37 @@ function listUsageFiles(dir) {
|
|
|
48
50
|
return [];
|
|
49
51
|
}
|
|
50
52
|
}
|
|
53
|
+
var logger = createLogger({ component: "usage-log" });
|
|
54
|
+
var UsageEventSchema = z.object({
|
|
55
|
+
timestamp: z.string(),
|
|
56
|
+
modelId: z.string(),
|
|
57
|
+
providerId: z.string(),
|
|
58
|
+
inputTokens: z.number(),
|
|
59
|
+
outputTokens: z.number(),
|
|
60
|
+
usdCost: z.number(),
|
|
61
|
+
latencyMs: z.number(),
|
|
62
|
+
success: z.boolean(),
|
|
63
|
+
category: z.string().optional(),
|
|
64
|
+
errorCode: z.string().optional(),
|
|
65
|
+
priced: z.boolean().optional(),
|
|
66
|
+
priceSource: z.string().optional()
|
|
67
|
+
});
|
|
68
|
+
function toUsageEvent(v) {
|
|
69
|
+
return {
|
|
70
|
+
timestamp: v.timestamp,
|
|
71
|
+
modelId: v.modelId,
|
|
72
|
+
providerId: v.providerId,
|
|
73
|
+
inputTokens: v.inputTokens,
|
|
74
|
+
outputTokens: v.outputTokens,
|
|
75
|
+
usdCost: v.usdCost,
|
|
76
|
+
latencyMs: v.latencyMs,
|
|
77
|
+
success: v.success,
|
|
78
|
+
...v.category !== void 0 && { category: v.category },
|
|
79
|
+
...v.errorCode !== void 0 && { errorCode: v.errorCode },
|
|
80
|
+
...v.priced !== void 0 && { priced: v.priced },
|
|
81
|
+
...v.priceSource !== void 0 && { priceSource: v.priceSource }
|
|
82
|
+
};
|
|
83
|
+
}
|
|
51
84
|
function eventMatches(parsed, f) {
|
|
52
85
|
const ts = Date.parse(parsed.timestamp);
|
|
53
86
|
if (ts < f.sinceMs || ts >= f.untilMs) return false;
|
|
@@ -63,14 +96,26 @@ function parseFileLines(filePath, filter) {
|
|
|
63
96
|
return [];
|
|
64
97
|
}
|
|
65
98
|
const out = [];
|
|
99
|
+
let rejected = 0;
|
|
66
100
|
for (const line of content.split("\n")) {
|
|
67
101
|
if (line.trim() === "") continue;
|
|
102
|
+
let raw;
|
|
68
103
|
try {
|
|
69
|
-
|
|
70
|
-
if (eventMatches(parsed, filter)) out.push(parsed);
|
|
104
|
+
raw = JSON.parse(line);
|
|
71
105
|
} catch {
|
|
106
|
+
rejected++;
|
|
72
107
|
continue;
|
|
73
108
|
}
|
|
109
|
+
const parsed = UsageEventSchema.safeParse(raw);
|
|
110
|
+
if (!parsed.success) {
|
|
111
|
+
rejected++;
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
const event = toUsageEvent(parsed.data);
|
|
115
|
+
if (eventMatches(event, filter)) out.push(event);
|
|
116
|
+
}
|
|
117
|
+
if (rejected > 0) {
|
|
118
|
+
logger.warn("Usage ledger lines rejected as unreadable", { filePath, rejected });
|
|
74
119
|
}
|
|
75
120
|
return out;
|
|
76
121
|
}
|
|
@@ -131,4 +176,4 @@ export {
|
|
|
131
176
|
loadUsageEvents,
|
|
132
177
|
rollupByModel
|
|
133
178
|
};
|
|
134
|
-
//# sourceMappingURL=chunk-
|
|
179
|
+
//# sourceMappingURL=chunk-ECHZGAZO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/learning/usage-log.ts"],"sourcesContent":["/**\n * usage-log — append-only per-call usage events with cost.\n *\n * Source: Issue #2469 (epic #2467 child).\n *\n * For operators running against metered API gateways, per-call cost +\n * tokens + latency is the data they need to manage spend. This module\n * provides three things:\n *\n * 1. `recordUsageEvent(event)` — append a per-call record to a JSONL\n * log under <NEXUS_DATA_DIR>/usage/usage-YYYY-MM.jsonl.\n * 2. `loadUsageEvents({...})` — read events for a window, filtered\n * by model / category.\n * 3. `computeCostDetail(modelId, inputTokens, outputTokens)` (and its\n * thin wrapper `computeCostUSD`) — compute cost from the FULL model\n * registry pricing chain (manifest > in-tree > models.dev > generated\n * LiteLLM catalog), including the #4164 normalized/identity resolution\n * tier for decorated gateway model ids. A model with no pricing\n * anywhere in the chain is reported as `priced: false` so consumers\n * can treat the missing cost as UNMEASURED (#3855), never a real $0.\n *\n * The `usage` CLI command (cli/usage-command.ts) consumes this for the\n * operator dashboard. Existing OutcomeStore is intentionally untouched\n * — its schema is for routing/learning signals, not billing.\n */\n\nimport { z } from 'zod';\nimport { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync } from 'node:fs';\nimport { computeTokenCost, roundToMicroUsd } from './token-cost-core.js';\nimport { dirname, join } from 'node:path';\n\nimport { getNexusDataDir } from '../config/nexus-data-dir.js';\nimport { createLogger } from '../core/logger.js';\n// NOTE: only the FUNCTION is imported here — `getDefaultRegistry()` must never\n// be CALLED at module scope (#3185 bootstrap hazard: first construction reads\n// the manifest overlay/snapshot from disk). All calls happen at invocation\n// time inside computeCostDetail.\nimport { getDefaultRegistry, type MatchedVia } from '../config/model-registry.js';\nimport type { PriceBasis } from '../core/price-basis.js';\n\nexport interface UsageEvent {\n /** ISO 8601 timestamp of the call. */\n readonly timestamp: string;\n /** Model identifier (e.g., 'claude-sonnet-4', 'gpt-4o'). */\n readonly modelId: string;\n /** Provider/adapter (e.g., 'anthropic', 'openai', 'openai-compat'). */\n readonly providerId: string;\n /** Token counts. */\n readonly inputTokens: number;\n readonly outputTokens: number;\n /**\n * Cost in USD. Computed at write time from the full model-registry pricing\n * chain (see `computeCostDetail`). 0 with `priced: false` means the model\n * was UNPRICED (cost unknown), not a real $0 — check `priced` before\n * treating this as a measured figure.\n */\n readonly usdCost: number;\n /** Wall-clock latency in milliseconds. */\n readonly latencyMs: number;\n /** Whether the call succeeded. */\n readonly success: boolean;\n /**\n * Optional task category — populated when the call was made on behalf of\n * a routed task (so aggregation can roll up by category).\n */\n readonly category?: string;\n /** Optional failure code when success === false. */\n readonly errorCode?: string;\n /**\n * Whether pricing data existed for the model at write time (#4165), so\n * audit can distinguish a real $0 from an unpriced model. Absent on lines\n * written before this field existed.\n */\n readonly priced?: boolean;\n /**\n * Pricing provenance: the canonical registry id whose pricing was applied\n * (the entry's `resolvedFrom` when the #4164 fuzzy tier matched a decorated\n * id, else the caller's model id). Present only when `priced` is true.\n */\n readonly priceSource?: string;\n}\n\n/** Result of a pricing-aware cost computation (#4165). */\nexport interface CostDetail {\n /** Cost in USD. Always 0 when `priced` is false — an unknown, not a $0. */\n readonly costUsd: number;\n /** Whether the resolved registry entry carried pricing data. */\n readonly priced: boolean;\n /**\n * Canonical id the pricing/metadata came from: the entry's `resolvedFrom`\n * when the #4164 fuzzy tier matched a decorated id, else the caller's id.\n */\n readonly resolvedId: string;\n /** Fuzzy-resolution provenance (#4164), passed through from the entry. */\n readonly matchedVia?: MatchedVia;\n}\n\n/**\n * Compute cost in USD given a model and token counts, with pricing\n * provenance. Reads the FULL registry chain via\n * `getDefaultRegistry().getEntry()` — manifest > in-tree > models.dev >\n * generated LiteLLM catalog, plus the #4164 normalized/identity tier that\n * resolves decorated model names from OpenAI-compatible gateways to their\n * canonical entry's pricing.\n *\n * `priced: false` (with `costUsd: 0`) means NO pricing existed anywhere in\n * the chain — consumers must treat the cost as UNMEASURED (#3855), never a\n * real $0. Operators can add pricing for gateway-only models via the\n * models-manifest overlay.\n */\nexport function computeCostDetail(\n modelId: string,\n inputTokens: number,\n outputTokens: number\n): CostDetail {\n // Registry read happens at INVOCATION time, never module load — first\n // construction touches the filesystem (#3185 bootstrap hazard).\n const entry = getDefaultRegistry().getEntry(modelId);\n const resolvedId = entry.resolvedFrom ?? modelId;\n const provenance = entry.matchedVia !== undefined ? { matchedVia: entry.matchedVia } : {};\n if (entry.pricing === undefined) {\n return { costUsd: 0, priced: false, resolvedId, ...provenance };\n }\n // The arithmetic lives in the shared core (#5122); this function is the\n // REGISTRY-BACKED, LEDGER-ROUNDED wrapper over it. Rounding to micro-USD\n // stays here rather than in the core: it exists so this log's JSONL does not\n // drift into floating-point noise across many small calls, which is a ledger\n // requirement, not a property of cost.\n const { costUsd } = computeTokenCost(\n { input: inputTokens, output: outputTokens },\n { inputPer1M: entry.pricing.inputPer1M, outputPer1M: entry.pricing.outputPer1M }\n );\n return { costUsd: roundToMicroUsd(costUsd), priced: true, resolvedId, ...provenance };\n}\n\n/**\n * The {@link PriceBasis} the cost in a {@link CostDetail} rests on (#4406).\n *\n * DELIBERATELY derived rather than stored, because `CostDetail.priced` already\n * carries the only distinction the current two-member union can express: the\n * chain resolved a rate, or it did not. A `priceBasis` property beside `priced`\n * would be a second spelling of the same boolean.\n *\n * WHAT THE `'list'` VALUE ASSERTS. Only that a rate was resolved, and that it\n * should be read as an assumed published rate. It is NOT a guarantee that the\n * number is a vendor's advertised public rate — at least two paths put\n * something else behind the label, and one puts a real published rate behind\n * `'unknown'`:\n *\n * - The operator manifest overlay is the highest-precedence tier and passes\n * `pricing` through; overriding pricing is its purpose. A negotiated rate\n * entered there reports `'list'`, and the caveat then warns the reader their\n * contract may differ over the contract rate.\n * - The normalized/fuzzy identity tier lets a decorated gateway id inherit a\n * DIFFERENT canonical entry's rate.\n * - `config/models-generated-loader.ts` discards a published $0/$0 rate unless\n * the id ends `:free`, so `'unknown'` does not mean no price exists.\n *\n * The derivation is therefore an assumption about the chain, not a fact about\n * it — conservative in the right direction (it invites a caveat rather than\n * suppressing one), and honest only if described this way. Narrowing it needs a\n * per-entry label the registry does not carry today; see {@link PriceBasis}.\n *\n * `priceSource`, the other provenance field, answers a different question: WHICH\n * registry entry supplied the number, not what KIND of rate it is. It does not\n * encode the basis, which is why the basis has to travel separately into records\n * (the decision-cost store) that persist neither field.\n */\nexport function priceBasisOf(detail: CostDetail): PriceBasis {\n return detail.priced ? 'list' : 'unknown';\n}\n\n/**\n * Thin wrapper over {@link computeCostDetail} returning only the USD figure.\n * Returns 0 both for a genuinely free model and for a model with no pricing\n * data — callers that must tell those apart (unpriced ⇒ UNMEASURED, #3855)\n * should use `computeCostDetail` and check `priced`.\n */\nexport function computeCostUSD(modelId: string, inputTokens: number, outputTokens: number): number {\n return computeCostDetail(modelId, inputTokens, outputTokens).costUsd;\n}\n\n/** Resolve the active usage log path for the current month. */\nexport function getUsageLogPath(date: Date = new Date()): string {\n const year = date.getUTCFullYear();\n const month = String(date.getUTCMonth() + 1).padStart(2, '0');\n return join(getNexusDataDir(), 'usage', `usage-${String(year)}-${month}.jsonl`);\n}\n\n/**\n * Append a usage event to the current month's log. Best-effort — failures\n * are silent (we don't want to fail a successful model call because we\n * couldn't write a log line).\n */\nexport function recordUsageEvent(event: UsageEvent): void {\n try {\n const path = getUsageLogPath(new Date(event.timestamp));\n mkdirSync(dirname(path), { recursive: true });\n appendFileSync(path, `${JSON.stringify(event)}\\n`, 'utf-8');\n } catch {\n // Intentionally silent — telemetry must not break user calls.\n }\n}\n\nexport interface LoadUsageOptions {\n /** Restrict to events at or after this ISO timestamp. */\n readonly sinceIso?: string;\n /** Restrict to events before this ISO timestamp. */\n readonly untilIso?: string;\n /** Only events for this model. */\n readonly modelId?: string;\n /** Only events for this category. */\n readonly category?: string;\n}\n\nfunction listUsageFiles(dir: string): readonly string[] {\n if (!existsSync(dir)) return [];\n try {\n return readdirSync(dir).filter((f) => f.startsWith('usage-') && f.endsWith('.jsonl'));\n } catch {\n return [];\n }\n}\n\ninterface LoadFilter {\n readonly sinceMs: number;\n readonly untilMs: number;\n readonly modelId: string | undefined;\n readonly category: string | undefined;\n}\n\nconst logger = createLogger({ component: 'usage-log' });\n\n/**\n * Validate a ledger line before it is trusted (#5328).\n *\n * The read path did `JSON.parse(line) as UsageEvent` — a cast. `eventMatches`\n * only inspects `timestamp` / `modelId` / `category`, so a corrupt `usdCost`\n * reached `rollupByModel`'s `reduce((s, e) => s + e.usdCost, 0)`: a string\n * concatenates, a missing value yields `NaN`, and neither throws. Every sibling\n * JSONL reader here validates; this one did not, and it is the cost ledger.\n *\n * Optional fields stay optional ON PURPOSE. `category`, `errorCode`, `priced`\n * and `priceSource` all postdate the original format — `priced` is documented\n * as \"Absent on lines written before this field existed\" — so requiring them\n * would silently discard real spend history, which is worse than the corruption\n * being fixed.\n *\n * Not `.strict()`, for the same forward-compatibility reason: a line carrying a\n * field a newer version writes must still load in an older one.\n *\n * `z.number()` already rejects `NaN` and infinities in zod v4, which is the\n * property that matters here: a cost that is not a real number cannot be summed,\n * and JSON renders `NaN` as `null`, which this also rejects.\n */\nconst UsageEventSchema = z.object({\n timestamp: z.string(),\n modelId: z.string(),\n providerId: z.string(),\n inputTokens: z.number(),\n outputTokens: z.number(),\n usdCost: z.number(),\n latencyMs: z.number(),\n success: z.boolean(),\n category: z.string().optional(),\n errorCode: z.string().optional(),\n priced: z.boolean().optional(),\n priceSource: z.string().optional(),\n});\n\n/**\n * Narrow a validated line to {@link UsageEvent}.\n *\n * Zod's `.optional()` yields `T | undefined`, which `exactOptionalPropertyTypes`\n * will not assign to a `?: T` property — an absent key and a present-but-\n * undefined key are different things under that flag, and the distinction is\n * the right one for a ledger: a line that omits `priced` is legacy, whereas one\n * that sets it to `undefined` is malformed.\n */\nfunction toUsageEvent(v: z.infer<typeof UsageEventSchema>): UsageEvent {\n return {\n timestamp: v.timestamp,\n modelId: v.modelId,\n providerId: v.providerId,\n inputTokens: v.inputTokens,\n outputTokens: v.outputTokens,\n usdCost: v.usdCost,\n latencyMs: v.latencyMs,\n success: v.success,\n ...(v.category !== undefined && { category: v.category }),\n ...(v.errorCode !== undefined && { errorCode: v.errorCode }),\n ...(v.priced !== undefined && { priced: v.priced }),\n ...(v.priceSource !== undefined && { priceSource: v.priceSource }),\n };\n}\n\nfunction eventMatches(parsed: UsageEvent, f: LoadFilter): boolean {\n const ts = Date.parse(parsed.timestamp);\n if (ts < f.sinceMs || ts >= f.untilMs) return false;\n if (f.modelId !== undefined && parsed.modelId !== f.modelId) return false;\n if (f.category !== undefined && parsed.category !== f.category) return false;\n return true;\n}\n\nfunction parseFileLines(filePath: string, filter: LoadFilter): readonly UsageEvent[] {\n let content: string;\n try {\n content = readFileSync(filePath, 'utf-8');\n } catch {\n return [];\n }\n const out: UsageEvent[] = [];\n let rejected = 0;\n for (const line of content.split('\\n')) {\n if (line.trim() === '') continue;\n let raw: unknown;\n try {\n raw = JSON.parse(line);\n } catch {\n // Skip malformed line; keep reading.\n rejected++;\n continue;\n }\n const parsed = UsageEventSchema.safeParse(raw);\n if (!parsed.success) {\n rejected++;\n continue;\n }\n const event = toUsageEvent(parsed.data);\n if (eventMatches(event, filter)) out.push(event);\n }\n // Say so rather than quietly returning a shorter list: a ledger that drops\n // lines silently under-reports spend, and the operator has no way to tell.\n if (rejected > 0) {\n logger.warn('Usage ledger lines rejected as unreadable', { filePath, rejected });\n }\n return out;\n}\n\n/**\n * Load all usage events from disk that match the filter. Reads every\n * monthly log file under the data dir; for sub-second filtering at scale\n * a future PR can index by month, but linear scan is fine at the\n * \"operator dashboard\" scale this command targets.\n */\nexport function loadUsageEvents(opts: LoadUsageOptions = {}): readonly UsageEvent[] {\n const dir = join(getNexusDataDir(), 'usage');\n const files = listUsageFiles(dir);\n if (files.length === 0) return [];\n const filter: LoadFilter = {\n sinceMs: opts.sinceIso !== undefined ? Date.parse(opts.sinceIso) : Number.NEGATIVE_INFINITY,\n untilMs: opts.untilIso !== undefined ? Date.parse(opts.untilIso) : Number.POSITIVE_INFINITY,\n modelId: opts.modelId,\n category: opts.category,\n };\n const events: UsageEvent[] = [];\n for (const f of files) {\n events.push(...parseFileLines(join(dir, f), filter));\n }\n return events;\n}\n\nexport interface ModelRollup {\n readonly modelId: string;\n readonly providerId: string;\n readonly callCount: number;\n readonly successCount: number;\n readonly successRate: number;\n readonly totalInputTokens: number;\n readonly totalOutputTokens: number;\n readonly totalUsdCost: number;\n readonly avgLatencyMs: number;\n readonly costPerSuccessUsd: number;\n}\n\n/**\n * Aggregate events into per-model rollups. Sorted by total cost descending\n * — the model burning the most money at top. Useful for \"where is my spend\n * going?\" investigations.\n */\nexport function rollupByModel(events: readonly UsageEvent[]): readonly ModelRollup[] {\n const groups = new Map<string, UsageEvent[]>();\n for (const e of events) {\n const arr = groups.get(e.modelId);\n if (arr === undefined) groups.set(e.modelId, [e]);\n else arr.push(e);\n }\n const rollups: ModelRollup[] = [];\n for (const [modelId, group] of groups) {\n const callCount = group.length;\n const successCount = group.filter((e) => e.success).length;\n const totalInputTokens = group.reduce((s, e) => s + e.inputTokens, 0);\n const totalOutputTokens = group.reduce((s, e) => s + e.outputTokens, 0);\n const totalUsdCost = group.reduce((s, e) => s + e.usdCost, 0);\n const totalLatency = group.reduce((s, e) => s + e.latencyMs, 0);\n const successRate = callCount === 0 ? 0 : successCount / callCount;\n const avgLatencyMs = callCount === 0 ? 0 : totalLatency / callCount;\n const costPerSuccessUsd = successCount === 0 ? totalUsdCost : totalUsdCost / successCount;\n rollups.push({\n modelId,\n providerId: group[0]?.providerId ?? 'unknown',\n callCount,\n successCount,\n successRate,\n totalInputTokens,\n totalOutputTokens,\n totalUsdCost,\n avgLatencyMs,\n costPerSuccessUsd,\n });\n }\n return rollups.sort((a, b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AAK,CAAC,GAAG,MAAM,EAAE,eAAe,EAAE,YAAY;AAC/D;","names":[]}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
createLogger,
|
|
6
6
|
getTimeProvider
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-LB4UH4FF.js";
|
|
8
8
|
|
|
9
9
|
// src/mcp/tools/scanner-registry-fetcher.ts
|
|
10
10
|
import { z } from "zod";
|
|
@@ -721,4 +721,4 @@ export {
|
|
|
721
721
|
generateSecurityPlan,
|
|
722
722
|
buildPlanFromAnalysis
|
|
723
723
|
};
|
|
724
|
-
//# sourceMappingURL=chunk-
|
|
724
|
+
//# sourceMappingURL=chunk-FQQYGPMC.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
loadPapersRegistry
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-BE6FQ7XI.js";
|
|
4
4
|
import {
|
|
5
5
|
getErrorMessage
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-LB4UH4FF.js";
|
|
7
7
|
|
|
8
8
|
// src/cli/research-helpers-synthesize.ts
|
|
9
9
|
import { z } from "zod";
|
|
@@ -886,4 +886,4 @@ export {
|
|
|
886
886
|
AttributedInsightSchema,
|
|
887
887
|
synthesizeResearch
|
|
888
888
|
};
|
|
889
|
-
//# sourceMappingURL=chunk-
|
|
889
|
+
//# sourceMappingURL=chunk-GRLN6WL5.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
VERSION
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-AQBOZVBW.js";
|
|
4
4
|
import {
|
|
5
5
|
emitClawGuardViolation
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-KYHZYRMR.js";
|
|
7
7
|
import {
|
|
8
8
|
CACHE_TIMEOUTS,
|
|
9
9
|
MCP_TIMEOUTS,
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
getTimeProvider,
|
|
20
20
|
ok,
|
|
21
21
|
resolveToolClassGuardMs
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-LB4UH4FF.js";
|
|
23
23
|
import {
|
|
24
24
|
getNexusDataDir
|
|
25
25
|
} from "./chunk-OGHEKPLD.js";
|
|
@@ -2135,4 +2135,4 @@ export {
|
|
|
2135
2135
|
VOTING_THRESHOLDS,
|
|
2136
2136
|
ConsensusMetricsSchema
|
|
2137
2137
|
};
|
|
2138
|
-
//# sourceMappingURL=chunk-
|
|
2138
|
+
//# sourceMappingURL=chunk-HJUL6YRG.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
GitHubProvider,
|
|
3
3
|
ScmError
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-UCW7IIX6.js";
|
|
5
5
|
import {
|
|
6
6
|
ROLE_DEFAULT_TRUST,
|
|
7
7
|
ReputationCache,
|
|
@@ -11,20 +11,20 @@ import {
|
|
|
11
11
|
gateWithReputation,
|
|
12
12
|
resolveReputationGatingMode,
|
|
13
13
|
sanitizeInput
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-NQ2CC67G.js";
|
|
15
15
|
import {
|
|
16
16
|
emitPolicyEvent
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-KYHZYRMR.js";
|
|
18
18
|
import {
|
|
19
19
|
hasToken
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-Y5ATK7BS.js";
|
|
21
21
|
import {
|
|
22
22
|
CLI_SUBPROCESS_TIMEOUTS,
|
|
23
23
|
createLogger,
|
|
24
24
|
err,
|
|
25
25
|
getTimeProvider,
|
|
26
26
|
ok
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-LB4UH4FF.js";
|
|
28
28
|
|
|
29
29
|
// src/security/trust-classifier.ts
|
|
30
30
|
function mapAuthorAssociation(association) {
|
|
@@ -1247,4 +1247,4 @@ export {
|
|
|
1247
1247
|
IssueTriage,
|
|
1248
1248
|
createIssueTriage
|
|
1249
1249
|
};
|
|
1250
|
-
//# sourceMappingURL=chunk-
|
|
1250
|
+
//# sourceMappingURL=chunk-ITB2NBB7.js.map
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
computeCostDetail,
|
|
3
3
|
recordUsageEvent
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ECHZGAZO.js";
|
|
5
5
|
import {
|
|
6
6
|
BaseAdapter,
|
|
7
7
|
createStream,
|
|
8
8
|
planOptionalParams,
|
|
9
9
|
requireApiKey,
|
|
10
10
|
validateApiKeyPresence
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-5FHJAPIR.js";
|
|
12
12
|
import {
|
|
13
13
|
assertCustomApiHostResolvesPublic
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-Z2EUE6E6.js";
|
|
15
15
|
import {
|
|
16
16
|
ConfigError,
|
|
17
17
|
ModelCapability,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
getTimeProvider,
|
|
23
23
|
getTokenEstimator,
|
|
24
24
|
ok
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-LB4UH4FF.js";
|
|
26
26
|
|
|
27
27
|
// src/adapters/openai-types.ts
|
|
28
28
|
var OPENAI_MODELS = {
|
|
@@ -833,4 +833,4 @@ export {
|
|
|
833
833
|
discoverModels,
|
|
834
834
|
buildOpenAICompatAdapters
|
|
835
835
|
};
|
|
836
|
-
//# sourceMappingURL=chunk-
|
|
836
|
+
//# sourceMappingURL=chunk-JLA2YAGY.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getRandomProvider,
|
|
3
3
|
getTimeProvider
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-LB4UH4FF.js";
|
|
5
5
|
|
|
6
6
|
// src/utils/id-utils.ts
|
|
7
7
|
import { randomUUID } from "crypto";
|
|
@@ -24,4 +24,4 @@ export {
|
|
|
24
24
|
generateHyphenId,
|
|
25
25
|
generateUUID
|
|
26
26
|
};
|
|
27
|
-
//# sourceMappingURL=chunk-
|
|
27
|
+
//# sourceMappingURL=chunk-JLE24ZSP.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
MODEL_IDS,
|
|
4
4
|
getTimeProvider,
|
|
5
5
|
resolveModelIdentitySync
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-LB4UH4FF.js";
|
|
7
7
|
|
|
8
8
|
// src/config/model-availability.ts
|
|
9
9
|
var DEFAULT_TTL_MS = 6e4;
|
|
@@ -150,4 +150,4 @@ export {
|
|
|
150
150
|
resetAvailabilityCache,
|
|
151
151
|
filterAvailableModels
|
|
152
152
|
};
|
|
153
|
-
//# sourceMappingURL=chunk-
|
|
153
|
+
//# sourceMappingURL=chunk-KNBIEADY.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getTimeProvider
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LB4UH4FF.js";
|
|
4
4
|
|
|
5
5
|
// src/security/audit-trail.ts
|
|
6
6
|
var MAX_EVENTS = 1e4;
|
|
@@ -205,4 +205,4 @@ export {
|
|
|
205
205
|
createGraphAuditBridge,
|
|
206
206
|
createAuditTrail
|
|
207
207
|
};
|
|
208
|
-
//# sourceMappingURL=chunk-
|
|
208
|
+
//# sourceMappingURL=chunk-KYHZYRMR.js.map
|
|
@@ -2319,6 +2319,27 @@ function defaultSnapshotPath() {
|
|
|
2319
2319
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
2320
2320
|
return join(here, "models-dev-snapshot.json");
|
|
2321
2321
|
}
|
|
2322
|
+
function stripMalformedPricing(entries, logger14, path2) {
|
|
2323
|
+
let strippedPricing = 0;
|
|
2324
|
+
const out = entries.map((entry) => {
|
|
2325
|
+
const pricing = entry.pricing;
|
|
2326
|
+
if (pricing === void 0) return entry;
|
|
2327
|
+
if (typeof pricing.inputPer1M === "number" && typeof pricing.outputPer1M === "number") {
|
|
2328
|
+
return entry;
|
|
2329
|
+
}
|
|
2330
|
+
strippedPricing++;
|
|
2331
|
+
const withoutPricing = { ...entry };
|
|
2332
|
+
delete withoutPricing.pricing;
|
|
2333
|
+
return withoutPricing;
|
|
2334
|
+
});
|
|
2335
|
+
if (strippedPricing > 0) {
|
|
2336
|
+
logger14.warn("models.dev snapshot entries had non-numeric pricing; treated as unpriced", {
|
|
2337
|
+
path: path2,
|
|
2338
|
+
strippedPricing
|
|
2339
|
+
});
|
|
2340
|
+
}
|
|
2341
|
+
return out;
|
|
2342
|
+
}
|
|
2322
2343
|
function loadModelsDevSnapshot(options) {
|
|
2323
2344
|
const logger14 = createLogger({ component: "models-dev-snapshot" });
|
|
2324
2345
|
const path2 = options?.path ?? defaultSnapshotPath();
|
|
@@ -2352,7 +2373,7 @@ function loadModelsDevSnapshot(options) {
|
|
|
2352
2373
|
logger14.warn("models.dev snapshot missing entries array; skipping", { path: path2 });
|
|
2353
2374
|
return { entries: [], path: path2, status: "malformed" };
|
|
2354
2375
|
}
|
|
2355
|
-
const entries = parsed.entries;
|
|
2376
|
+
const entries = stripMalformedPricing(parsed.entries, logger14, path2);
|
|
2356
2377
|
return {
|
|
2357
2378
|
entries,
|
|
2358
2379
|
path: path2,
|
|
@@ -2632,7 +2653,7 @@ function setDefaultRegistry(registry) {
|
|
|
2632
2653
|
}
|
|
2633
2654
|
async function reloadDefaultRegistry() {
|
|
2634
2655
|
globalRegistry = buildDefaultRegistry();
|
|
2635
|
-
const { resetGlobalRegistry } = await import("./unified-registry-
|
|
2656
|
+
const { resetGlobalRegistry } = await import("./unified-registry-DPOXBGFQ.js");
|
|
2636
2657
|
resetGlobalRegistry();
|
|
2637
2658
|
return globalRegistry;
|
|
2638
2659
|
}
|
|
@@ -15283,7 +15304,7 @@ var CompositeRouter = class _CompositeRouter {
|
|
|
15283
15304
|
*/
|
|
15284
15305
|
async consultUnifiedContext(task) {
|
|
15285
15306
|
try {
|
|
15286
|
-
const { getContextForTask, inferTaskCategory } = await import("./context-retriever-
|
|
15307
|
+
const { getContextForTask, inferTaskCategory } = await import("./context-retriever-UDMXESPP.js");
|
|
15287
15308
|
const ctx = await getContextForTask({
|
|
15288
15309
|
task: task.content,
|
|
15289
15310
|
category: inferTaskCategory(task.content),
|
|
@@ -16891,4 +16912,4 @@ export {
|
|
|
16891
16912
|
AgentCapability,
|
|
16892
16913
|
OrchestratorError
|
|
16893
16914
|
};
|
|
16894
|
-
//# sourceMappingURL=chunk-
|
|
16915
|
+
//# sourceMappingURL=chunk-LB4UH4FF.js.map
|