nexus-agents 2.174.0 → 2.174.2
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-EQ2NKTK2.js → child-mcp-config-GWB7JLIS.js} +2 -2
- package/dist/{chunk-26WHBGN6.js → chunk-2CB6QMRX.js} +35 -35
- package/dist/{chunk-TZS5IKWW.js → chunk-3P7SMHBU.js} +3 -3
- package/dist/{chunk-YXLJNG7E.js → chunk-4PTAG65V.js} +2 -2
- package/dist/{chunk-MM6UYUIC.js → chunk-5QVJCBM4.js} +3 -3
- package/dist/{chunk-LSMFXWRN.js → chunk-6RRAQFSX.js} +2 -2
- package/dist/{chunk-YVVUKVZV.js → chunk-ASJTVA7W.js} +5 -5
- package/dist/{chunk-OPZQQWVW.js → chunk-DGR27REV.js} +4 -170
- package/dist/chunk-DGR27REV.js.map +1 -0
- package/dist/{chunk-KOK66W2C.js → chunk-DJZGCMNU.js} +2 -2
- package/dist/{chunk-TFU5J53T.js → chunk-E35RUETV.js} +2 -2
- package/dist/{chunk-NDNJ3TBM.js → chunk-EDWON3X5.js} +4 -4
- package/dist/{chunk-KNOIZAYR.js → chunk-H5KLPUAL.js} +2 -2
- package/dist/{chunk-KKFTLDNO.js → chunk-HUYP2XXH.js} +2 -2
- package/dist/{chunk-P7BKE3OH.js → chunk-IVINLVGP.js} +2 -2
- package/dist/{chunk-AJHA7DSS.js → chunk-JSIX5L3C.js} +2 -2
- package/dist/{chunk-TOH2HSHH.js → chunk-JVBI4WKP.js} +35 -5
- package/dist/{chunk-TOH2HSHH.js.map → chunk-JVBI4WKP.js.map} +1 -1
- package/dist/{chunk-ZLQLBSSQ.js → chunk-K6NXLBHG.js} +22 -9
- package/dist/{chunk-ZLQLBSSQ.js.map → chunk-K6NXLBHG.js.map} +1 -1
- package/dist/{chunk-NCGPKRRY.js → chunk-KAL22DYO.js} +2 -2
- package/dist/{chunk-IJMNDXPZ.js → chunk-KU2HPCJG.js} +4 -4
- package/dist/{chunk-22NGPM4P.js → chunk-KWKGX7LC.js} +5 -5
- package/dist/{chunk-AOOZ6IZB.js → chunk-KYF4YAZO.js} +3 -3
- package/dist/{chunk-4NYZ2VTW.js → chunk-MRRKFMYJ.js} +4 -4
- package/dist/{chunk-VAD2FMNC.js → chunk-OCTNNEXT.js} +36 -11
- package/dist/chunk-OCTNNEXT.js.map +1 -0
- package/dist/{chunk-HZB3LIBF.js → chunk-OGR5Q6QO.js} +5 -5
- package/dist/chunk-OM2VVQKB.js +172 -0
- package/dist/chunk-OM2VVQKB.js.map +1 -0
- package/dist/{chunk-ZMM3HJ2E.js → chunk-PN43VH6Z.js} +7 -7
- package/dist/{chunk-CERGIC66.js → chunk-RAIFOYRM.js} +2 -2
- package/dist/{chunk-3DI4CEC7.js → chunk-SGIWJYLJ.js} +2 -2
- package/dist/{chunk-MLJAC2UH.js → chunk-UB6APBIY.js} +2 -2
- package/dist/{chunk-JUUHARON.js → chunk-VSETLO4Q.js} +2 -2
- package/dist/{chunk-25ZJ5TCC.js → chunk-Y5JA7XEO.js} +404 -378
- package/dist/chunk-Y5JA7XEO.js.map +1 -0
- package/dist/{chunk-SDFC2IOJ.js → chunk-YE2XMU3T.js} +3 -3
- package/dist/{chunk-V4XEPUCM.js → chunk-YUCJ7VSJ.js} +8 -8
- package/dist/{chunk-QPKG7LS7.js → chunk-Z77MIV3C.js} +2 -2
- package/dist/{cli-circuit-breaker-OKP72JMQ.js → cli-circuit-breaker-EINPV2CX.js} +3 -3
- package/dist/cli.js +41 -40
- package/dist/cli.js.map +1 -1
- package/dist/{composite-router-BYXWBPQU.js → composite-router-CUJAG7O4.js} +2 -2
- package/dist/{consensus-vote-UJRG6CJS.js → consensus-vote-BLCQCWPV.js} +16 -15
- package/dist/{context-retriever-TAUTDY3F.js → context-retriever-MTJR3AQM.js} +8 -8
- package/dist/{dist-KUG63MRZ.js → dist-GR7PQU7T.js} +563 -482
- package/dist/dist-GR7PQU7T.js.map +1 -0
- package/dist/{doctor-deep-XKGC3T76.js → doctor-deep-X2KP2G4M.js} +3 -3
- package/dist/{expert-bridge-WOKMAGXB.js → expert-bridge-2W2JMFQW.js} +4 -4
- package/dist/{factory-ETFUFSGU.js → factory-7UFJ6LXW.js} +9 -8
- package/dist/{factory-M4OE3GLA.js → factory-SC5D5P3C.js} +5 -5
- package/dist/{improvement-review-CBVDAPCL.js → improvement-review-ZMUJQSX3.js} +5 -5
- package/dist/index.d.ts +17 -0
- package/dist/index.js +30 -29
- package/dist/index.js.map +1 -1
- package/dist/{init-opencode-442YJUON.js → init-opencode-I5XSFY34.js} +6 -5
- package/dist/{init-opencode-442YJUON.js.map → init-opencode-I5XSFY34.js.map} +1 -1
- package/dist/{issue-triage-S7RSXHCS.js → issue-triage-KOIPTNDH.js} +6 -6
- package/dist/{pr-reviewer-helpers-UVDDO3T4.js → pr-reviewer-helpers-CZDMP5UJ.js} +4 -4
- package/dist/{registry-command-DWOQ2IV4.js → registry-command-5J6RJZMS.js} +2 -2
- package/dist/{repo-security-plan-5P23NS3N.js → repo-security-plan-MKSCD567.js} +3 -3
- package/dist/{research-helpers-synthesize-5AIKCDA2.js → research-helpers-synthesize-TIT43XF4.js} +4 -4
- package/dist/{routing-memory-BOTPCHXJ.js → routing-memory-HAWL7RKO.js} +2 -2
- package/dist/{session-memory-KOUNAH5O.js → session-memory-RPSM7Y4Q.js} +3 -3
- package/dist/{setup-command-DW3DQJMG.js → setup-command-SORJLYU3.js} +14 -13
- package/dist/{setup-config-BBUFGXW2.js → setup-config-YDA4MY4N.js} +3 -3
- package/dist/{setup-custom-api-PSVW6DIY.js → setup-custom-api-BZSHB2M5.js} +6 -4
- package/dist/{setup-custom-api-PSVW6DIY.js.map → setup-custom-api-BZSHB2M5.js.map} +1 -1
- package/dist/{tool-memory-RBACIEGW.js → tool-memory-FCEJMKEH.js} +5 -5
- package/dist/{unified-registry-35EIUQ2M.js → unified-registry-JWPD2ES2.js} +10 -9
- package/dist/{weather-report-YXGRGPCX.js → weather-report-VNABZRH7.js} +2 -2
- package/package.json +8 -8
- package/dist/chunk-25ZJ5TCC.js.map +0 -1
- package/dist/chunk-OPZQQWVW.js.map +0 -1
- package/dist/chunk-VAD2FMNC.js.map +0 -1
- package/dist/dist-KUG63MRZ.js.map +0 -1
- /package/dist/{child-mcp-config-EQ2NKTK2.js.map → child-mcp-config-GWB7JLIS.js.map} +0 -0
- /package/dist/{chunk-26WHBGN6.js.map → chunk-2CB6QMRX.js.map} +0 -0
- /package/dist/{chunk-TZS5IKWW.js.map → chunk-3P7SMHBU.js.map} +0 -0
- /package/dist/{chunk-YXLJNG7E.js.map → chunk-4PTAG65V.js.map} +0 -0
- /package/dist/{chunk-MM6UYUIC.js.map → chunk-5QVJCBM4.js.map} +0 -0
- /package/dist/{chunk-LSMFXWRN.js.map → chunk-6RRAQFSX.js.map} +0 -0
- /package/dist/{chunk-YVVUKVZV.js.map → chunk-ASJTVA7W.js.map} +0 -0
- /package/dist/{chunk-KOK66W2C.js.map → chunk-DJZGCMNU.js.map} +0 -0
- /package/dist/{chunk-TFU5J53T.js.map → chunk-E35RUETV.js.map} +0 -0
- /package/dist/{chunk-NDNJ3TBM.js.map → chunk-EDWON3X5.js.map} +0 -0
- /package/dist/{chunk-KNOIZAYR.js.map → chunk-H5KLPUAL.js.map} +0 -0
- /package/dist/{chunk-KKFTLDNO.js.map → chunk-HUYP2XXH.js.map} +0 -0
- /package/dist/{chunk-P7BKE3OH.js.map → chunk-IVINLVGP.js.map} +0 -0
- /package/dist/{chunk-AJHA7DSS.js.map → chunk-JSIX5L3C.js.map} +0 -0
- /package/dist/{chunk-NCGPKRRY.js.map → chunk-KAL22DYO.js.map} +0 -0
- /package/dist/{chunk-IJMNDXPZ.js.map → chunk-KU2HPCJG.js.map} +0 -0
- /package/dist/{chunk-22NGPM4P.js.map → chunk-KWKGX7LC.js.map} +0 -0
- /package/dist/{chunk-AOOZ6IZB.js.map → chunk-KYF4YAZO.js.map} +0 -0
- /package/dist/{chunk-4NYZ2VTW.js.map → chunk-MRRKFMYJ.js.map} +0 -0
- /package/dist/{chunk-HZB3LIBF.js.map → chunk-OGR5Q6QO.js.map} +0 -0
- /package/dist/{chunk-ZMM3HJ2E.js.map → chunk-PN43VH6Z.js.map} +0 -0
- /package/dist/{chunk-CERGIC66.js.map → chunk-RAIFOYRM.js.map} +0 -0
- /package/dist/{chunk-3DI4CEC7.js.map → chunk-SGIWJYLJ.js.map} +0 -0
- /package/dist/{chunk-MLJAC2UH.js.map → chunk-UB6APBIY.js.map} +0 -0
- /package/dist/{chunk-JUUHARON.js.map → chunk-VSETLO4Q.js.map} +0 -0
- /package/dist/{chunk-SDFC2IOJ.js.map → chunk-YE2XMU3T.js.map} +0 -0
- /package/dist/{chunk-V4XEPUCM.js.map → chunk-YUCJ7VSJ.js.map} +0 -0
- /package/dist/{chunk-QPKG7LS7.js.map → chunk-Z77MIV3C.js.map} +0 -0
- /package/dist/{cli-circuit-breaker-OKP72JMQ.js.map → cli-circuit-breaker-EINPV2CX.js.map} +0 -0
- /package/dist/{composite-router-BYXWBPQU.js.map → composite-router-CUJAG7O4.js.map} +0 -0
- /package/dist/{consensus-vote-UJRG6CJS.js.map → consensus-vote-BLCQCWPV.js.map} +0 -0
- /package/dist/{context-retriever-TAUTDY3F.js.map → context-retriever-MTJR3AQM.js.map} +0 -0
- /package/dist/{doctor-deep-XKGC3T76.js.map → doctor-deep-X2KP2G4M.js.map} +0 -0
- /package/dist/{expert-bridge-WOKMAGXB.js.map → expert-bridge-2W2JMFQW.js.map} +0 -0
- /package/dist/{factory-ETFUFSGU.js.map → factory-7UFJ6LXW.js.map} +0 -0
- /package/dist/{factory-M4OE3GLA.js.map → factory-SC5D5P3C.js.map} +0 -0
- /package/dist/{improvement-review-CBVDAPCL.js.map → improvement-review-ZMUJQSX3.js.map} +0 -0
- /package/dist/{issue-triage-S7RSXHCS.js.map → issue-triage-KOIPTNDH.js.map} +0 -0
- /package/dist/{pr-reviewer-helpers-UVDDO3T4.js.map → pr-reviewer-helpers-CZDMP5UJ.js.map} +0 -0
- /package/dist/{registry-command-DWOQ2IV4.js.map → registry-command-5J6RJZMS.js.map} +0 -0
- /package/dist/{repo-security-plan-5P23NS3N.js.map → repo-security-plan-MKSCD567.js.map} +0 -0
- /package/dist/{research-helpers-synthesize-5AIKCDA2.js.map → research-helpers-synthesize-TIT43XF4.js.map} +0 -0
- /package/dist/{routing-memory-BOTPCHXJ.js.map → routing-memory-HAWL7RKO.js.map} +0 -0
- /package/dist/{session-memory-KOUNAH5O.js.map → session-memory-RPSM7Y4Q.js.map} +0 -0
- /package/dist/{setup-command-DW3DQJMG.js.map → setup-command-SORJLYU3.js.map} +0 -0
- /package/dist/{setup-config-BBUFGXW2.js.map → setup-config-YDA4MY4N.js.map} +0 -0
- /package/dist/{tool-memory-RBACIEGW.js.map → tool-memory-FCEJMKEH.js.map} +0 -0
- /package/dist/{unified-registry-35EIUQ2M.js.map → unified-registry-JWPD2ES2.js.map} +0 -0
- /package/dist/{weather-report-YXGRGPCX.js.map → weather-report-VNABZRH7.js.map} +0 -0
|
@@ -2170,14 +2170,14 @@ var ManifestSchema = z2.object({
|
|
|
2170
2170
|
models: z2.array(z2.unknown())
|
|
2171
2171
|
});
|
|
2172
2172
|
function loadManifestOverlay(options) {
|
|
2173
|
-
const
|
|
2173
|
+
const logger15 = options?.logger ?? createLogger({ component: "manifest-overlay" });
|
|
2174
2174
|
if (options?.path !== void 0) {
|
|
2175
|
-
return loadManifestFile(options.path,
|
|
2175
|
+
return loadManifestFile(options.path, logger15);
|
|
2176
2176
|
}
|
|
2177
2177
|
const userPath = resolveUserManifestPath(options?.env);
|
|
2178
2178
|
const operatorPath = resolveManifestPath(options?.env);
|
|
2179
|
-
const user = loadManifestFile(userPath,
|
|
2180
|
-
const operator = loadManifestFile(operatorPath,
|
|
2179
|
+
const user = loadManifestFile(userPath, logger15);
|
|
2180
|
+
const operator = loadManifestFile(operatorPath, logger15);
|
|
2181
2181
|
return mergeOverlays(user, operator);
|
|
2182
2182
|
}
|
|
2183
2183
|
function mergeOverlays(lower, higher) {
|
|
@@ -2194,11 +2194,11 @@ function mergeOverlays(lower, higher) {
|
|
|
2194
2194
|
return merged;
|
|
2195
2195
|
}
|
|
2196
2196
|
function loadUserManifestOverlay(options) {
|
|
2197
|
-
const
|
|
2197
|
+
const logger15 = options?.logger ?? createLogger({ component: "manifest-overlay" });
|
|
2198
2198
|
const path2 = options?.path ?? resolveUserManifestPath(options?.env);
|
|
2199
|
-
return loadManifestFile(path2,
|
|
2199
|
+
return loadManifestFile(path2, logger15);
|
|
2200
2200
|
}
|
|
2201
|
-
function loadManifestFile(path2,
|
|
2201
|
+
function loadManifestFile(path2, logger15) {
|
|
2202
2202
|
let exists = false;
|
|
2203
2203
|
try {
|
|
2204
2204
|
exists = existsSync(path2);
|
|
@@ -2213,7 +2213,7 @@ function loadManifestFile(path2, logger14) {
|
|
|
2213
2213
|
return { entries: [], rejections: [], path: path2, status: "empty" };
|
|
2214
2214
|
}
|
|
2215
2215
|
if (stat.size > MANIFEST_MAX_BYTES) {
|
|
2216
|
-
|
|
2216
|
+
logger15.warn("Manifest overlay too large; skipping", {
|
|
2217
2217
|
path: path2,
|
|
2218
2218
|
size: stat.size,
|
|
2219
2219
|
max: MANIFEST_MAX_BYTES
|
|
@@ -2221,9 +2221,9 @@ function loadManifestFile(path2, logger14) {
|
|
|
2221
2221
|
return { entries: [], rejections: [], path: path2, status: "too-large" };
|
|
2222
2222
|
}
|
|
2223
2223
|
const raw = readFileSync(path2, "utf-8");
|
|
2224
|
-
return parseManifest(raw, path2,
|
|
2224
|
+
return parseManifest(raw, path2, logger15);
|
|
2225
2225
|
}
|
|
2226
|
-
function parseManifest(raw, path2,
|
|
2226
|
+
function parseManifest(raw, path2, logger15) {
|
|
2227
2227
|
let parsed;
|
|
2228
2228
|
try {
|
|
2229
2229
|
if (path2.endsWith(".json")) {
|
|
@@ -2232,7 +2232,7 @@ function parseManifest(raw, path2, logger14) {
|
|
|
2232
2232
|
parsed = parseYaml(raw);
|
|
2233
2233
|
}
|
|
2234
2234
|
} catch (e) {
|
|
2235
|
-
|
|
2235
|
+
logger15.warn("Manifest overlay parse failure; skipping", {
|
|
2236
2236
|
path: path2,
|
|
2237
2237
|
error: e instanceof Error ? e.message : String(e)
|
|
2238
2238
|
});
|
|
@@ -2240,7 +2240,7 @@ function parseManifest(raw, path2, logger14) {
|
|
|
2240
2240
|
}
|
|
2241
2241
|
const shape = ManifestSchema.safeParse(parsed);
|
|
2242
2242
|
if (!shape.success) {
|
|
2243
|
-
|
|
2243
|
+
logger15.warn("Manifest overlay schema mismatch at root; skipping", {
|
|
2244
2244
|
path: path2,
|
|
2245
2245
|
issues: shape.error.issues.slice(0, 5).map((i) => i.message)
|
|
2246
2246
|
});
|
|
@@ -2315,7 +2315,7 @@ function defaultSnapshotPath() {
|
|
|
2315
2315
|
return join(here, "models-dev-snapshot.json");
|
|
2316
2316
|
}
|
|
2317
2317
|
function loadModelsDevSnapshot(options) {
|
|
2318
|
-
const
|
|
2318
|
+
const logger15 = createLogger({ component: "models-dev-snapshot" });
|
|
2319
2319
|
const path2 = options?.path ?? defaultSnapshotPath();
|
|
2320
2320
|
let exists = false;
|
|
2321
2321
|
try {
|
|
@@ -2330,21 +2330,21 @@ function loadModelsDevSnapshot(options) {
|
|
|
2330
2330
|
try {
|
|
2331
2331
|
parsed = JSON.parse(readFileSync2(path2, "utf-8"));
|
|
2332
2332
|
} catch (e) {
|
|
2333
|
-
|
|
2333
|
+
logger15.warn("models.dev snapshot parse failure; skipping", {
|
|
2334
2334
|
path: path2,
|
|
2335
2335
|
error: e instanceof Error ? e.message : String(e)
|
|
2336
2336
|
});
|
|
2337
2337
|
return { entries: [], path: path2, status: "malformed" };
|
|
2338
2338
|
}
|
|
2339
2339
|
if (parsed.version !== 1) {
|
|
2340
|
-
|
|
2340
|
+
logger15.warn("models.dev snapshot version unsupported; skipping", {
|
|
2341
2341
|
path: path2,
|
|
2342
2342
|
version: parsed.version
|
|
2343
2343
|
});
|
|
2344
2344
|
return { entries: [], path: path2, status: "malformed" };
|
|
2345
2345
|
}
|
|
2346
2346
|
if (!Array.isArray(parsed.entries)) {
|
|
2347
|
-
|
|
2347
|
+
logger15.warn("models.dev snapshot missing entries array; skipping", { path: path2 });
|
|
2348
2348
|
return { entries: [], path: path2, status: "malformed" };
|
|
2349
2349
|
}
|
|
2350
2350
|
const entries = parsed.entries;
|
|
@@ -2391,7 +2391,7 @@ function toModelEntry(rec) {
|
|
|
2391
2391
|
};
|
|
2392
2392
|
}
|
|
2393
2393
|
function loadGeneratedRegistryEntries(options) {
|
|
2394
|
-
const
|
|
2394
|
+
const logger15 = createLogger({ component: "models-generated" });
|
|
2395
2395
|
const path2 = options?.path ?? defaultGeneratedPath();
|
|
2396
2396
|
let exists = false;
|
|
2397
2397
|
try {
|
|
@@ -2404,14 +2404,14 @@ function loadGeneratedRegistryEntries(options) {
|
|
|
2404
2404
|
try {
|
|
2405
2405
|
parsed = JSON.parse(readFileSync3(path2, "utf-8"));
|
|
2406
2406
|
} catch (e) {
|
|
2407
|
-
|
|
2407
|
+
logger15.warn("generated registry parse failure; skipping", {
|
|
2408
2408
|
path: path2,
|
|
2409
2409
|
error: e instanceof Error ? e.message : String(e)
|
|
2410
2410
|
});
|
|
2411
2411
|
return { entries: [], path: path2, status: "malformed" };
|
|
2412
2412
|
}
|
|
2413
2413
|
if (!Array.isArray(parsed.entries)) {
|
|
2414
|
-
|
|
2414
|
+
logger15.warn("generated registry missing entries array; skipping", { path: path2 });
|
|
2415
2415
|
return { entries: [], path: path2, status: "malformed" };
|
|
2416
2416
|
}
|
|
2417
2417
|
const entries = [];
|
|
@@ -2619,7 +2619,7 @@ function setDefaultRegistry(registry) {
|
|
|
2619
2619
|
}
|
|
2620
2620
|
async function reloadDefaultRegistry() {
|
|
2621
2621
|
globalRegistry = buildDefaultRegistry();
|
|
2622
|
-
const { resetGlobalRegistry } = await import("./unified-registry-
|
|
2622
|
+
const { resetGlobalRegistry } = await import("./unified-registry-JWPD2ES2.js");
|
|
2623
2623
|
resetGlobalRegistry();
|
|
2624
2624
|
return globalRegistry;
|
|
2625
2625
|
}
|
|
@@ -2845,7 +2845,7 @@ function lookupCanonicalPricing(model) {
|
|
|
2845
2845
|
for (const m of models) {
|
|
2846
2846
|
if (m.pricing !== void 0 && isPrefixMatch(m, model)) return toPricing(m.pricing);
|
|
2847
2847
|
}
|
|
2848
|
-
return
|
|
2848
|
+
return toPricing(getDefaultRegistry().getEntry(model).pricing);
|
|
2849
2849
|
}
|
|
2850
2850
|
function calculateCost(model, inputTokens, outputTokens) {
|
|
2851
2851
|
const pricing = lookupCanonicalPricing(model);
|
|
@@ -5336,6 +5336,13 @@ function estimateTokens(text) {
|
|
|
5336
5336
|
}
|
|
5337
5337
|
|
|
5338
5338
|
// src/cli-adapters/types-core.ts
|
|
5339
|
+
import { z as z4 } from "zod";
|
|
5340
|
+
var ApiArmIdSchema = z4.enum([
|
|
5341
|
+
"api:anthropic",
|
|
5342
|
+
"api:openai",
|
|
5343
|
+
"api:google",
|
|
5344
|
+
"api:custom-openai"
|
|
5345
|
+
]);
|
|
5339
5346
|
function apiArmId(vendor) {
|
|
5340
5347
|
return `api:${vendor}`;
|
|
5341
5348
|
}
|
|
@@ -5519,7 +5526,7 @@ function createBudgetExceededError(budget, result, currentBudget) {
|
|
|
5519
5526
|
}
|
|
5520
5527
|
|
|
5521
5528
|
// src/config/task-specialization-types.ts
|
|
5522
|
-
import { z as
|
|
5529
|
+
import { z as z5 } from "zod";
|
|
5523
5530
|
var TASK_CATEGORIES = [
|
|
5524
5531
|
"architecture",
|
|
5525
5532
|
"code_generation",
|
|
@@ -5532,8 +5539,8 @@ var TASK_CATEGORIES = [
|
|
|
5532
5539
|
"devops",
|
|
5533
5540
|
"exploration"
|
|
5534
5541
|
];
|
|
5535
|
-
var TaskCategorySchema =
|
|
5536
|
-
var TaskSpecializationSchema =
|
|
5542
|
+
var TaskCategorySchema = z5.enum(TASK_CATEGORIES);
|
|
5543
|
+
var TaskSpecializationSchema = z5.object({
|
|
5537
5544
|
/** Task category identifier */
|
|
5538
5545
|
category: TaskCategorySchema,
|
|
5539
5546
|
/** Primary CLI recommendation */
|
|
@@ -5541,11 +5548,11 @@ var TaskSpecializationSchema = z4.object({
|
|
|
5541
5548
|
/** Secondary CLI fallback */
|
|
5542
5549
|
secondaryCli: CliNameSchema,
|
|
5543
5550
|
/** Why this CLI is preferred for this task type */
|
|
5544
|
-
reasoning:
|
|
5551
|
+
reasoning: z5.string(),
|
|
5545
5552
|
/** Keywords that trigger this category detection */
|
|
5546
|
-
keywords:
|
|
5553
|
+
keywords: z5.array(z5.string()).min(1),
|
|
5547
5554
|
/** Bonus score applied when this category matches (0-20) */
|
|
5548
|
-
bonus:
|
|
5555
|
+
bonus: z5.number().min(0).max(20)
|
|
5549
5556
|
});
|
|
5550
5557
|
|
|
5551
5558
|
// src/config/task-specialization.ts
|
|
@@ -6198,9 +6205,9 @@ var DEFAULT_OUTPUT_TOKENS = 500;
|
|
|
6198
6205
|
var TopsisRouter = class {
|
|
6199
6206
|
config;
|
|
6200
6207
|
logger;
|
|
6201
|
-
constructor(config = {},
|
|
6208
|
+
constructor(config = {}, logger15) {
|
|
6202
6209
|
this.config = { ...DEFAULT_TOPSIS_CONFIG, ...config };
|
|
6203
|
-
this.logger =
|
|
6210
|
+
this.logger = logger15 ?? createLogger({ component: "TopsisRouter" });
|
|
6204
6211
|
this.validateWeights();
|
|
6205
6212
|
}
|
|
6206
6213
|
/**
|
|
@@ -6381,19 +6388,19 @@ var TopsisRouter = class {
|
|
|
6381
6388
|
};
|
|
6382
6389
|
|
|
6383
6390
|
// src/cli-adapters/budget-router-types.ts
|
|
6384
|
-
import { z as
|
|
6385
|
-
var BudgetConstraintSchema =
|
|
6386
|
-
maxTokens:
|
|
6387
|
-
maxCostUSD:
|
|
6388
|
-
maxLatencyMs:
|
|
6391
|
+
import { z as z6 } from "zod";
|
|
6392
|
+
var BudgetConstraintSchema = z6.object({
|
|
6393
|
+
maxTokens: z6.number().int().positive().optional(),
|
|
6394
|
+
maxCostUSD: z6.number().positive().optional(),
|
|
6395
|
+
maxLatencyMs: z6.number().positive().optional()
|
|
6389
6396
|
});
|
|
6390
|
-
var SessionBudgetSchema =
|
|
6391
|
-
totalTokens:
|
|
6392
|
-
totalCostUSD:
|
|
6393
|
-
usedTokens:
|
|
6394
|
-
usedCostUSD:
|
|
6395
|
-
startTime:
|
|
6396
|
-
sessionId:
|
|
6397
|
+
var SessionBudgetSchema = z6.object({
|
|
6398
|
+
totalTokens: z6.number().int().positive(),
|
|
6399
|
+
totalCostUSD: z6.number().positive(),
|
|
6400
|
+
usedTokens: z6.number().int().min(0).default(0),
|
|
6401
|
+
usedCostUSD: z6.number().min(0).default(0),
|
|
6402
|
+
startTime: z6.number().int().positive(),
|
|
6403
|
+
sessionId: z6.string().min(1)
|
|
6397
6404
|
});
|
|
6398
6405
|
var DEFAULT_LINUCB_CONFIG = {
|
|
6399
6406
|
numArms: 4,
|
|
@@ -6401,11 +6408,11 @@ var DEFAULT_LINUCB_CONFIG = {
|
|
|
6401
6408
|
alpha: 1,
|
|
6402
6409
|
lambda: 1
|
|
6403
6410
|
};
|
|
6404
|
-
var LinUCBConfigSchema =
|
|
6405
|
-
numArms:
|
|
6406
|
-
featureDim:
|
|
6407
|
-
alpha:
|
|
6408
|
-
lambda:
|
|
6411
|
+
var LinUCBConfigSchema = z6.object({
|
|
6412
|
+
numArms: z6.number().int().positive().default(4),
|
|
6413
|
+
featureDim: z6.number().int().positive().default(6),
|
|
6414
|
+
alpha: z6.number().positive().default(1),
|
|
6415
|
+
lambda: z6.number().positive().default(1)
|
|
6409
6416
|
});
|
|
6410
6417
|
|
|
6411
6418
|
// src/cli-adapters/linucb-math.ts
|
|
@@ -6542,6 +6549,7 @@ function createIdentityMatrixInverse(dim, lambda) {
|
|
|
6542
6549
|
}
|
|
6543
6550
|
|
|
6544
6551
|
// src/cli-adapters/linucb-bandit.ts
|
|
6552
|
+
var logger5 = createLogger({ component: "linucb-bandit" });
|
|
6545
6553
|
var SUCCESS_REWARD = 0.7;
|
|
6546
6554
|
var FAILURE_REWARD = 0.1;
|
|
6547
6555
|
var LinUCBBandit = class {
|
|
@@ -6722,6 +6730,13 @@ var LinUCBBandit = class {
|
|
|
6722
6730
|
* from persisted data. Uses a neutral context (same as seedPriors) since
|
|
6723
6731
|
* the original task context is not stored in TaskOutcome.
|
|
6724
6732
|
*
|
|
6733
|
+
* Outcomes whose arm is not among this bandit's arms are skipped. That skip
|
|
6734
|
+
* used to be entirely silent, which hid a real defect: `api:*` arms could not
|
|
6735
|
+
* be represented in `TaskOutcome.cli` at all (#4400), so every API arm
|
|
6736
|
+
* discarded its whole history and began cold each process with nothing
|
|
6737
|
+
* reported. The skip is now counted and logged — a warm-start that silently
|
|
6738
|
+
* drops most of its input looks identical to one that worked.
|
|
6739
|
+
*
|
|
6725
6740
|
* @param outcomes - Persisted task outcomes to replay
|
|
6726
6741
|
* @returns Number of outcomes successfully replayed
|
|
6727
6742
|
*/
|
|
@@ -6735,14 +6750,25 @@ var LinUCBBandit = class {
|
|
|
6735
6750
|
timePressure: 0.5
|
|
6736
6751
|
};
|
|
6737
6752
|
let replayed = 0;
|
|
6753
|
+
const skippedArms = /* @__PURE__ */ new Map();
|
|
6738
6754
|
for (const outcome of outcomes) {
|
|
6739
6755
|
const armIndex = this.armNames.indexOf(outcome.cli);
|
|
6740
|
-
if (armIndex < 0)
|
|
6756
|
+
if (armIndex < 0) {
|
|
6757
|
+
skippedArms.set(outcome.cli, (skippedArms.get(outcome.cli) ?? 0) + 1);
|
|
6758
|
+
continue;
|
|
6759
|
+
}
|
|
6741
6760
|
const reward = outcome.success ? SUCCESS_REWARD : FAILURE_REWARD;
|
|
6742
6761
|
this.update(armIndex, neutralContext, reward);
|
|
6743
6762
|
this.recordWarmStartModelStat(outcome.cli, outcome.model, outcome.success);
|
|
6744
6763
|
replayed++;
|
|
6745
6764
|
}
|
|
6765
|
+
if (skippedArms.size > 0) {
|
|
6766
|
+
logger5.warn("Warm-start skipped outcomes for arms this bandit does not have", {
|
|
6767
|
+
skippedByArm: Object.fromEntries(skippedArms),
|
|
6768
|
+
replayed,
|
|
6769
|
+
knownArms: this.armNames
|
|
6770
|
+
});
|
|
6771
|
+
}
|
|
6746
6772
|
return replayed;
|
|
6747
6773
|
}
|
|
6748
6774
|
/** Accumulate the per-arm × per-model warm-start ledger (#4194). */
|
|
@@ -6786,7 +6812,7 @@ var LinUCBBandit = class {
|
|
|
6786
6812
|
import { randomUUID as randomUUID4 } from "crypto";
|
|
6787
6813
|
|
|
6788
6814
|
// src/cli-adapters/preference-router-types.ts
|
|
6789
|
-
import { z as
|
|
6815
|
+
import { z as z7 } from "zod";
|
|
6790
6816
|
var DEFAULT_PREFERENCE_ROUTER_CONFIG = {
|
|
6791
6817
|
strongModel: {
|
|
6792
6818
|
tier: "strong",
|
|
@@ -6807,24 +6833,24 @@ var DEFAULT_PREFERENCE_ROUTER_CONFIG = {
|
|
|
6807
6833
|
maxDataPoints: 1e4,
|
|
6808
6834
|
enableOnlineLearning: true
|
|
6809
6835
|
};
|
|
6810
|
-
var PreferenceRouterConfigSchema =
|
|
6811
|
-
strongModel:
|
|
6812
|
-
tier:
|
|
6813
|
-
cli:
|
|
6814
|
-
costPerMillionTokens:
|
|
6815
|
-
qualityBaseline:
|
|
6836
|
+
var PreferenceRouterConfigSchema = z7.object({
|
|
6837
|
+
strongModel: z7.object({
|
|
6838
|
+
tier: z7.literal("strong"),
|
|
6839
|
+
cli: z7.enum(["claude", "gemini", "codex", "opencode"]),
|
|
6840
|
+
costPerMillionTokens: z7.number().positive(),
|
|
6841
|
+
qualityBaseline: z7.number().min(0).max(1)
|
|
6816
6842
|
}),
|
|
6817
|
-
weakModel:
|
|
6818
|
-
tier:
|
|
6819
|
-
cli:
|
|
6820
|
-
costPerMillionTokens:
|
|
6821
|
-
qualityBaseline:
|
|
6843
|
+
weakModel: z7.object({
|
|
6844
|
+
tier: z7.literal("weak"),
|
|
6845
|
+
cli: z7.enum(["claude", "gemini", "codex", "opencode"]),
|
|
6846
|
+
costPerMillionTokens: z7.number().positive(),
|
|
6847
|
+
qualityBaseline: z7.number().min(0).max(1)
|
|
6822
6848
|
}),
|
|
6823
|
-
routingThreshold:
|
|
6824
|
-
minDataPoints:
|
|
6825
|
-
maxDataPoints:
|
|
6826
|
-
enableOnlineLearning:
|
|
6827
|
-
domainThresholds:
|
|
6849
|
+
routingThreshold: z7.number().min(0).max(1).default(0.5),
|
|
6850
|
+
minDataPoints: z7.number().int().positive().default(10),
|
|
6851
|
+
maxDataPoints: z7.number().int().positive().default(1e4),
|
|
6852
|
+
enableOnlineLearning: z7.boolean().default(true),
|
|
6853
|
+
domainThresholds: z7.record(z7.string(), z7.number().min(0).max(1)).optional()
|
|
6828
6854
|
});
|
|
6829
6855
|
|
|
6830
6856
|
// src/cli-adapters/preference-router-store.ts
|
|
@@ -7019,7 +7045,7 @@ var QueryFeatureExtractor = class {
|
|
|
7019
7045
|
};
|
|
7020
7046
|
|
|
7021
7047
|
// src/cli-adapters/preference-router.ts
|
|
7022
|
-
var
|
|
7048
|
+
var logger6 = createLogger({ component: "PreferenceRouter" });
|
|
7023
7049
|
var PreferenceRouter = class {
|
|
7024
7050
|
config;
|
|
7025
7051
|
dataStore;
|
|
@@ -7032,7 +7058,7 @@ var PreferenceRouter = class {
|
|
|
7032
7058
|
this.config = validated;
|
|
7033
7059
|
this.dataStore = dataStore ?? new InMemoryPreferenceStore(validated.maxDataPoints);
|
|
7034
7060
|
this.featureExtractor = new QueryFeatureExtractor();
|
|
7035
|
-
|
|
7061
|
+
logger6.info("PreferenceRouter initialized", {
|
|
7036
7062
|
strongModel: this.config.strongModel.cli,
|
|
7037
7063
|
weakModel: this.config.weakModel.cli,
|
|
7038
7064
|
threshold: this.config.routingThreshold
|
|
@@ -7058,7 +7084,7 @@ var PreferenceRouter = class {
|
|
|
7058
7084
|
routingLatencyMs: getTimeProvider().now() - startTime,
|
|
7059
7085
|
estimatedCostSavings: costSavings
|
|
7060
7086
|
};
|
|
7061
|
-
|
|
7087
|
+
logger6.debug("Routing decision made", {
|
|
7062
7088
|
tier: selectedTier,
|
|
7063
7089
|
cli: selectedConfig.cli,
|
|
7064
7090
|
probability: prediction.strongModelProbability,
|
|
@@ -7083,7 +7109,7 @@ var PreferenceRouter = class {
|
|
|
7083
7109
|
};
|
|
7084
7110
|
if (this.config.enableOnlineLearning) {
|
|
7085
7111
|
this.dataStore.store(dataPoint);
|
|
7086
|
-
|
|
7112
|
+
logger6.debug("Preference recorded", {
|
|
7087
7113
|
strongPreferred: strongModelPreferred,
|
|
7088
7114
|
domain: features.domain
|
|
7089
7115
|
});
|
|
@@ -7166,7 +7192,7 @@ function createPreferenceRouter(config, dataStore) {
|
|
|
7166
7192
|
}
|
|
7167
7193
|
|
|
7168
7194
|
// src/cli-adapters/zero-router-types.ts
|
|
7169
|
-
import { z as
|
|
7195
|
+
import { z as z8 } from "zod";
|
|
7170
7196
|
|
|
7171
7197
|
// src/cli-adapters/derive-tier-tables.ts
|
|
7172
7198
|
var CLI_ORDER = CLI_NAMES;
|
|
@@ -7294,7 +7320,7 @@ function deriveWeakClis() {
|
|
|
7294
7320
|
}
|
|
7295
7321
|
|
|
7296
7322
|
// src/cli-adapters/zero-router-types.ts
|
|
7297
|
-
var DifficultyDimensionSchema =
|
|
7323
|
+
var DifficultyDimensionSchema = z8.enum([
|
|
7298
7324
|
"reasoning",
|
|
7299
7325
|
"knowledge",
|
|
7300
7326
|
"creativity",
|
|
@@ -7308,17 +7334,17 @@ var DIFFICULTY_DIMENSIONS = [
|
|
|
7308
7334
|
"precision",
|
|
7309
7335
|
"context_length"
|
|
7310
7336
|
];
|
|
7311
|
-
var DifficultySpaceSchema =
|
|
7337
|
+
var DifficultySpaceSchema = z8.object({
|
|
7312
7338
|
/** Reasoning difficulty: logical complexity, multi-step inference (0-1) */
|
|
7313
|
-
reasoning:
|
|
7339
|
+
reasoning: z8.number().min(0).max(1),
|
|
7314
7340
|
/** Knowledge difficulty: domain expertise required (0-1) */
|
|
7315
|
-
knowledge:
|
|
7341
|
+
knowledge: z8.number().min(0).max(1),
|
|
7316
7342
|
/** Creativity difficulty: novel generation, open-endedness (0-1) */
|
|
7317
|
-
creativity:
|
|
7343
|
+
creativity: z8.number().min(0).max(1),
|
|
7318
7344
|
/** Precision difficulty: accuracy requirements, error tolerance (0-1) */
|
|
7319
|
-
precision:
|
|
7345
|
+
precision: z8.number().min(0).max(1),
|
|
7320
7346
|
/** Context length difficulty: amount of context to process (0-1) */
|
|
7321
|
-
context_length:
|
|
7347
|
+
context_length: z8.number().min(0).max(1)
|
|
7322
7348
|
});
|
|
7323
7349
|
var DEFAULT_DIFFICULTY_THRESHOLDS = {
|
|
7324
7350
|
easyUpperBound: 0.3,
|
|
@@ -7330,12 +7356,12 @@ var DEFAULT_DIFFICULTY_TO_TIER = {
|
|
|
7330
7356
|
hard: "powerful"
|
|
7331
7357
|
};
|
|
7332
7358
|
var DEFAULT_TIER_TO_CLIS = deriveTierToClis();
|
|
7333
|
-
var DifficultyWeightsSchema =
|
|
7334
|
-
reasoning:
|
|
7335
|
-
knowledge:
|
|
7336
|
-
creativity:
|
|
7337
|
-
precision:
|
|
7338
|
-
context_length:
|
|
7359
|
+
var DifficultyWeightsSchema = z8.object({
|
|
7360
|
+
reasoning: z8.number().min(0).max(1),
|
|
7361
|
+
knowledge: z8.number().min(0).max(1),
|
|
7362
|
+
creativity: z8.number().min(0).max(1),
|
|
7363
|
+
precision: z8.number().min(0).max(1),
|
|
7364
|
+
context_length: z8.number().min(0).max(1)
|
|
7339
7365
|
});
|
|
7340
7366
|
var DEFAULT_DIFFICULTY_WEIGHTS = {
|
|
7341
7367
|
reasoning: 0.3,
|
|
@@ -7344,29 +7370,29 @@ var DEFAULT_DIFFICULTY_WEIGHTS = {
|
|
|
7344
7370
|
precision: 0.25,
|
|
7345
7371
|
context_length: 0.15
|
|
7346
7372
|
};
|
|
7347
|
-
var ZeroRouterConfigSchema =
|
|
7373
|
+
var ZeroRouterConfigSchema = z8.object({
|
|
7348
7374
|
/** Difficulty thresholds for level classification */
|
|
7349
|
-
thresholds:
|
|
7350
|
-
easyUpperBound:
|
|
7351
|
-
hardLowerBound:
|
|
7375
|
+
thresholds: z8.object({
|
|
7376
|
+
easyUpperBound: z8.number().min(0).max(1),
|
|
7377
|
+
hardLowerBound: z8.number().min(0).max(1)
|
|
7352
7378
|
}).default(DEFAULT_DIFFICULTY_THRESHOLDS),
|
|
7353
7379
|
/** Weights for difficulty aggregation */
|
|
7354
7380
|
weights: DifficultyWeightsSchema.default(DEFAULT_DIFFICULTY_WEIGHTS),
|
|
7355
7381
|
/** Mapping from difficulty level to model tier */
|
|
7356
|
-
difficultyToTier:
|
|
7382
|
+
difficultyToTier: z8.record(z8.enum(["easy", "medium", "hard"]), z8.enum(["fast", "balanced", "powerful"])).default(DEFAULT_DIFFICULTY_TO_TIER),
|
|
7357
7383
|
/** Mapping from model tier to CLI preference order */
|
|
7358
|
-
tierToClis:
|
|
7359
|
-
|
|
7360
|
-
|
|
7384
|
+
tierToClis: z8.record(
|
|
7385
|
+
z8.enum(["fast", "balanced", "powerful"]),
|
|
7386
|
+
z8.array(z8.enum(["claude", "gemini", "codex", "opencode"]))
|
|
7361
7387
|
).default(DEFAULT_TIER_TO_CLIS),
|
|
7362
7388
|
/** Enable adaptive calibration from outcomes */
|
|
7363
|
-
enableCalibration:
|
|
7389
|
+
enableCalibration: z8.boolean().default(true),
|
|
7364
7390
|
/** Maximum outcomes to store for calibration */
|
|
7365
|
-
maxCalibrationOutcomes:
|
|
7391
|
+
maxCalibrationOutcomes: z8.number().int().positive().default(1e3),
|
|
7366
7392
|
/** Minimum outcomes before applying calibration adjustments */
|
|
7367
|
-
minCalibrationOutcomes:
|
|
7393
|
+
minCalibrationOutcomes: z8.number().int().positive().default(50),
|
|
7368
7394
|
/** Verbose logging */
|
|
7369
|
-
verbose:
|
|
7395
|
+
verbose: z8.boolean().default(false)
|
|
7370
7396
|
});
|
|
7371
7397
|
var DEFAULT_ZERO_ROUTER_CONFIG = {
|
|
7372
7398
|
thresholds: DEFAULT_DIFFICULTY_THRESHOLDS,
|
|
@@ -7706,9 +7732,9 @@ var ZeroRouter = class {
|
|
|
7706
7732
|
logger;
|
|
7707
7733
|
outcomes = [];
|
|
7708
7734
|
calibrationBias = 0;
|
|
7709
|
-
constructor(config,
|
|
7735
|
+
constructor(config, logger15) {
|
|
7710
7736
|
this.config = ZeroRouterConfigSchema.parse(config ?? {});
|
|
7711
|
-
this.logger =
|
|
7737
|
+
this.logger = logger15 ?? createLogger({ component: "ZeroRouter" });
|
|
7712
7738
|
this.logger.debug("ZeroRouter initialized", {
|
|
7713
7739
|
thresholds: this.config.thresholds,
|
|
7714
7740
|
enableCalibration: this.config.enableCalibration
|
|
@@ -7890,16 +7916,16 @@ var ZeroRouter = class {
|
|
|
7890
7916
|
};
|
|
7891
7917
|
|
|
7892
7918
|
// src/cli-adapters/latency-tracker-types.ts
|
|
7893
|
-
import { z as
|
|
7894
|
-
var LatencyTrackerConfigSchema =
|
|
7919
|
+
import { z as z9 } from "zod";
|
|
7920
|
+
var LatencyTrackerConfigSchema = z9.object({
|
|
7895
7921
|
/** Maximum number of samples to keep per CLI (default: 100) */
|
|
7896
|
-
windowSize:
|
|
7922
|
+
windowSize: z9.number().int().positive().default(100),
|
|
7897
7923
|
/** Time-weighted decay factor (0-1, higher = more weight to recent) (default: 0.95) */
|
|
7898
|
-
decayFactor:
|
|
7924
|
+
decayFactor: z9.number().min(0).max(1).default(0.95),
|
|
7899
7925
|
/** Maximum age of samples in milliseconds before forced eviction (default: 3600000 = 1 hour) */
|
|
7900
|
-
maxSampleAgeMs:
|
|
7926
|
+
maxSampleAgeMs: z9.number().int().positive().default(36e5),
|
|
7901
7927
|
/** Percentiles to calculate (default: [50, 95, 99]) */
|
|
7902
|
-
percentiles:
|
|
7928
|
+
percentiles: z9.array(z9.number().min(0).max(100)).default([50, 95, 99])
|
|
7903
7929
|
});
|
|
7904
7930
|
var EMPTY_LATENCY_STATS = {
|
|
7905
7931
|
count: 0,
|
|
@@ -8134,19 +8160,19 @@ var LatencyTracker = class {
|
|
|
8134
8160
|
};
|
|
8135
8161
|
|
|
8136
8162
|
// src/cli-adapters/routing/router-stage.ts
|
|
8137
|
-
import { z as
|
|
8138
|
-
var StageConfigSchema =
|
|
8139
|
-
enabled:
|
|
8140
|
-
priority:
|
|
8141
|
-
options:
|
|
8163
|
+
import { z as z10 } from "zod";
|
|
8164
|
+
var StageConfigSchema = z10.object({
|
|
8165
|
+
enabled: z10.boolean().default(true),
|
|
8166
|
+
priority: z10.number().int().min(0).max(100).default(50),
|
|
8167
|
+
options: z10.record(z10.string(), z10.unknown()).optional()
|
|
8142
8168
|
});
|
|
8143
|
-
var RoutingOutcomeSchema =
|
|
8169
|
+
var RoutingOutcomeSchema = z10.object({
|
|
8144
8170
|
selectedCli: CliNameSchema,
|
|
8145
|
-
task:
|
|
8146
|
-
success:
|
|
8147
|
-
qualityScore:
|
|
8148
|
-
latencyMs:
|
|
8149
|
-
tokensUsed:
|
|
8171
|
+
task: z10.string(),
|
|
8172
|
+
success: z10.boolean(),
|
|
8173
|
+
qualityScore: z10.number().min(0).max(1).optional(),
|
|
8174
|
+
latencyMs: z10.number().int().positive().optional(),
|
|
8175
|
+
tokensUsed: z10.number().int().positive().optional()
|
|
8150
8176
|
});
|
|
8151
8177
|
function createRoutingContext(task, availableClis = ["claude", "gemini", "codex", "opencode"], metadata) {
|
|
8152
8178
|
return {
|
|
@@ -8219,9 +8245,9 @@ var ConfidenceCascadeStage = class {
|
|
|
8219
8245
|
routingsCount = 0;
|
|
8220
8246
|
escalationCount = 0;
|
|
8221
8247
|
complexityDistribution = { simple: 0, moderate: 0, complex: 0 };
|
|
8222
|
-
constructor(config = {},
|
|
8248
|
+
constructor(config = {}, logger15) {
|
|
8223
8249
|
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
8224
|
-
this.logger =
|
|
8250
|
+
this.logger = logger15 ?? createLogger({ component: "ConfidenceCascadeStage" });
|
|
8225
8251
|
}
|
|
8226
8252
|
canHandle(ctx) {
|
|
8227
8253
|
return getRemainingCandidates(ctx).length > 0;
|
|
@@ -8370,9 +8396,9 @@ var CapabilityMatchStage = class {
|
|
|
8370
8396
|
creative: 0,
|
|
8371
8397
|
general: 0
|
|
8372
8398
|
};
|
|
8373
|
-
constructor(config = {},
|
|
8399
|
+
constructor(config = {}, logger15) {
|
|
8374
8400
|
this.config = { ...DEFAULT_CONFIG2, ...config };
|
|
8375
|
-
this.logger =
|
|
8401
|
+
this.logger = logger15 ?? createLogger({ component: "CapabilityMatchStage" });
|
|
8376
8402
|
}
|
|
8377
8403
|
canHandle(ctx) {
|
|
8378
8404
|
return getRemainingCandidates(ctx).length > 0;
|
|
@@ -8528,9 +8554,9 @@ var QualityConstraintStage = class {
|
|
|
8528
8554
|
filteredCount = 0;
|
|
8529
8555
|
fallbackCount = 0;
|
|
8530
8556
|
constraintViolations = { quality: 0, cost: 0, latency: 0 };
|
|
8531
|
-
constructor(config = {},
|
|
8557
|
+
constructor(config = {}, logger15) {
|
|
8532
8558
|
this.config = { ...DEFAULT_CONFIG3, ...config };
|
|
8533
|
-
this.logger =
|
|
8559
|
+
this.logger = logger15 ?? createLogger({ component: "QualityConstraintStage" });
|
|
8534
8560
|
}
|
|
8535
8561
|
canHandle(ctx) {
|
|
8536
8562
|
return getRemainingCandidates(ctx).length > 0;
|
|
@@ -8728,9 +8754,9 @@ var ResourceStrategyStage = class {
|
|
|
8728
8754
|
logger;
|
|
8729
8755
|
routingsCount = 0;
|
|
8730
8756
|
tierHistory = [];
|
|
8731
|
-
constructor(config = {},
|
|
8757
|
+
constructor(config = {}, logger15) {
|
|
8732
8758
|
this.config = { ...DEFAULT_CONFIG4, ...config };
|
|
8733
|
-
this.logger =
|
|
8759
|
+
this.logger = logger15 ?? createLogger({ component: "ResourceStrategyStage" });
|
|
8734
8760
|
}
|
|
8735
8761
|
canHandle(ctx) {
|
|
8736
8762
|
return getRemainingCandidates(ctx).length > 1;
|
|
@@ -8839,10 +8865,10 @@ var DistilledRuleStage = class {
|
|
|
8839
8865
|
config;
|
|
8840
8866
|
logger;
|
|
8841
8867
|
rulesAppliedCount = 0;
|
|
8842
|
-
constructor(distiller, config,
|
|
8868
|
+
constructor(distiller, config, logger15) {
|
|
8843
8869
|
this.distiller = distiller;
|
|
8844
8870
|
this.config = { ...DEFAULT_CONFIG5, ...config };
|
|
8845
|
-
this.logger =
|
|
8871
|
+
this.logger = logger15 ?? createLogger({ component: "DistilledRuleStage" });
|
|
8846
8872
|
}
|
|
8847
8873
|
canHandle(ctx) {
|
|
8848
8874
|
const candidates = getRemainingCandidates(ctx);
|
|
@@ -8981,10 +9007,10 @@ var KnnRoutingStage = class {
|
|
|
8981
9007
|
memory;
|
|
8982
9008
|
routingsCount = 0;
|
|
8983
9009
|
matchCount = 0;
|
|
8984
|
-
constructor(memory, config = {},
|
|
9010
|
+
constructor(memory, config = {}, logger15) {
|
|
8985
9011
|
this.config = { ...DEFAULT_CONFIG6, ...config };
|
|
8986
9012
|
this.memory = memory;
|
|
8987
|
-
this.logger =
|
|
9013
|
+
this.logger = logger15 ?? createLogger({ component: "KnnRoutingStage" });
|
|
8988
9014
|
}
|
|
8989
9015
|
canHandle(ctx) {
|
|
8990
9016
|
return getRemainingCandidates(ctx).length > 0;
|
|
@@ -9199,10 +9225,10 @@ var StrategyDistiller = class {
|
|
|
9199
9225
|
rules = /* @__PURE__ */ new Map();
|
|
9200
9226
|
outcomeCounter = 0;
|
|
9201
9227
|
lastDistillAt;
|
|
9202
|
-
constructor(outcomeStore,
|
|
9228
|
+
constructor(outcomeStore, logger15, config) {
|
|
9203
9229
|
this.outcomeStore = outcomeStore;
|
|
9204
9230
|
this.config = { ...DEFAULT_DISTILLER_CONFIG, ...config };
|
|
9205
|
-
this.logger =
|
|
9231
|
+
this.logger = logger15 ?? createLogger({ component: "StrategyDistiller" });
|
|
9206
9232
|
}
|
|
9207
9233
|
/** Called for each processed outcome. Triggers distillation at threshold. */
|
|
9208
9234
|
onOutcome() {
|
|
@@ -9366,25 +9392,25 @@ var StrategyDistiller = class {
|
|
|
9366
9392
|
};
|
|
9367
9393
|
}
|
|
9368
9394
|
};
|
|
9369
|
-
function createStrategyDistiller(outcomeStore,
|
|
9370
|
-
return new StrategyDistiller(outcomeStore,
|
|
9395
|
+
function createStrategyDistiller(outcomeStore, logger15, config) {
|
|
9396
|
+
return new StrategyDistiller(outcomeStore, logger15, config);
|
|
9371
9397
|
}
|
|
9372
9398
|
var persistentDistillerFactory;
|
|
9373
9399
|
function registerPersistentDistillerFactory(factory) {
|
|
9374
9400
|
persistentDistillerFactory = factory;
|
|
9375
9401
|
}
|
|
9376
|
-
function createPersistentDistillerOrFallback(outcomeStore,
|
|
9402
|
+
function createPersistentDistillerOrFallback(outcomeStore, logger15) {
|
|
9377
9403
|
if (persistentDistillerFactory !== void 0) {
|
|
9378
|
-
return persistentDistillerFactory(outcomeStore,
|
|
9404
|
+
return persistentDistillerFactory(outcomeStore, logger15);
|
|
9379
9405
|
}
|
|
9380
|
-
return new StrategyDistiller(outcomeStore,
|
|
9406
|
+
return new StrategyDistiller(outcomeStore, logger15);
|
|
9381
9407
|
}
|
|
9382
9408
|
|
|
9383
9409
|
// src/orchestration/outcomes/outcome-types.ts
|
|
9384
|
-
import { z as
|
|
9385
|
-
var
|
|
9386
|
-
var OutcomeSourceSchema =
|
|
9387
|
-
var OutcomeFailureCategorySchema =
|
|
9410
|
+
import { z as z11 } from "zod";
|
|
9411
|
+
var logger7 = createLogger({ component: "outcome-error-taxonomy" });
|
|
9412
|
+
var OutcomeSourceSchema = z11.enum(["delegate", "consensus", "manual"]);
|
|
9413
|
+
var OutcomeFailureCategorySchema = z11.enum([
|
|
9388
9414
|
"timeout",
|
|
9389
9415
|
"authentication",
|
|
9390
9416
|
"rate_limit",
|
|
@@ -9397,37 +9423,37 @@ var OutcomeFailureCategorySchema = z10.enum([
|
|
|
9397
9423
|
"generic",
|
|
9398
9424
|
"unknown"
|
|
9399
9425
|
]);
|
|
9400
|
-
var OutcomeCliSchema =
|
|
9401
|
-
var TaskOutcomeSchema =
|
|
9402
|
-
id:
|
|
9426
|
+
var OutcomeCliSchema = z11.union([CliNameSchema, ApiArmIdSchema, z11.literal("unknown")]);
|
|
9427
|
+
var TaskOutcomeSchema = z11.object({
|
|
9428
|
+
id: z11.string().min(1),
|
|
9403
9429
|
cli: OutcomeCliSchema,
|
|
9404
9430
|
category: TaskCategorySchema,
|
|
9405
|
-
model:
|
|
9406
|
-
success:
|
|
9407
|
-
durationMs:
|
|
9408
|
-
timestamp:
|
|
9409
|
-
qualitySignals:
|
|
9431
|
+
model: z11.string().min(1),
|
|
9432
|
+
success: z11.boolean(),
|
|
9433
|
+
durationMs: z11.number().nonnegative(),
|
|
9434
|
+
timestamp: z11.string().min(1),
|
|
9435
|
+
qualitySignals: z11.array(z11.string()).optional(),
|
|
9410
9436
|
failureCategory: OutcomeFailureCategorySchema.optional(),
|
|
9411
|
-
errorMessage:
|
|
9437
|
+
errorMessage: z11.string().max(500).optional(),
|
|
9412
9438
|
source: OutcomeSourceSchema,
|
|
9413
9439
|
/** Whether this outcome came from a triage-initiated retry (#1506). */
|
|
9414
|
-
wasRetried:
|
|
9440
|
+
wasRetried: z11.boolean().optional(),
|
|
9415
9441
|
/** Triage action taken on the failure (#1506). */
|
|
9416
|
-
triageAction:
|
|
9442
|
+
triageAction: z11.string().max(30).optional(),
|
|
9417
9443
|
/** Routing stage that selected this CLI (#1785). */
|
|
9418
|
-
routingStage:
|
|
9444
|
+
routingStage: z11.string().max(50).optional(),
|
|
9419
9445
|
/** Number of retry attempts before this outcome (#1785). */
|
|
9420
|
-
retryCount:
|
|
9446
|
+
retryCount: z11.number().int().nonnegative().optional(),
|
|
9421
9447
|
/** Vendor resolved from `model` via ModelRegistry at write time (#2548). */
|
|
9422
|
-
vendor:
|
|
9448
|
+
vendor: z11.string().min(1).max(40).optional(),
|
|
9423
9449
|
/** Family resolved from `model` via ModelRegistry at write time (#2548). */
|
|
9424
|
-
family:
|
|
9450
|
+
family: z11.string().min(1).max(80).optional(),
|
|
9425
9451
|
/**
|
|
9426
9452
|
* Voter role for `source: 'consensus'` outcomes (#2662) — `architect`,
|
|
9427
9453
|
* `security`, etc. Absent on non-consensus outcomes. Lets the
|
|
9428
9454
|
* stratified outcome report break results down by voter role.
|
|
9429
9455
|
*/
|
|
9430
|
-
voterRole:
|
|
9456
|
+
voterRole: z11.string().min(1).max(40).optional(),
|
|
9431
9457
|
/**
|
|
9432
9458
|
* Baseline this outcome forked from (#2697 / Epic F follow-up to #2665).
|
|
9433
9459
|
* Set on outcomes recorded inside a fork-then-merge graph branch so
|
|
@@ -9436,27 +9462,27 @@ var TaskOutcomeSchema = z10.object({
|
|
|
9436
9462
|
* cohort. Free-form string (caller-assigned); typically the parent
|
|
9437
9463
|
* node's `executionId` or `taskId`.
|
|
9438
9464
|
*/
|
|
9439
|
-
baselineId:
|
|
9465
|
+
baselineId: z11.string().min(1).max(64).optional(),
|
|
9440
9466
|
/**
|
|
9441
9467
|
* Distributed trace id correlating this outcome across the pipeline (#3146).
|
|
9442
9468
|
* Optional + backward-compatible: older JSONL records without it hydrate fine.
|
|
9443
9469
|
*/
|
|
9444
|
-
traceId:
|
|
9470
|
+
traceId: z11.string().min(1).max(128).optional(),
|
|
9445
9471
|
/** Request id correlating this outcome to its originating invocation (#3146). */
|
|
9446
|
-
requestId:
|
|
9472
|
+
requestId: z11.string().min(1).max(128).optional()
|
|
9447
9473
|
});
|
|
9448
|
-
var OutcomeQuerySchema =
|
|
9474
|
+
var OutcomeQuerySchema = z11.object({
|
|
9449
9475
|
cli: OutcomeCliSchema.optional(),
|
|
9450
9476
|
category: TaskCategorySchema.optional(),
|
|
9451
9477
|
source: OutcomeSourceSchema.optional(),
|
|
9452
|
-
success:
|
|
9478
|
+
success: z11.boolean().optional(),
|
|
9453
9479
|
failureCategory: OutcomeFailureCategorySchema.optional(),
|
|
9454
|
-
since:
|
|
9455
|
-
limit:
|
|
9480
|
+
since: z11.string().optional(),
|
|
9481
|
+
limit: z11.number().int().positive().optional(),
|
|
9456
9482
|
/** Exclude outcomes with any of these quality signals (#1680). */
|
|
9457
|
-
excludeQualitySignals:
|
|
9483
|
+
excludeQualitySignals: z11.array(z11.string()).optional(),
|
|
9458
9484
|
/** Restrict to outcomes recorded against a specific baseline (#2697). */
|
|
9459
|
-
baselineId:
|
|
9485
|
+
baselineId: z11.string().min(1).max(64).optional()
|
|
9460
9486
|
});
|
|
9461
9487
|
var TIMEOUT_PATTERNS = ["timeout", "timed out", "deadline exceeded", "socket hang up", "aborted"];
|
|
9462
9488
|
var AUTH_PATTERNS = [
|
|
@@ -9601,7 +9627,7 @@ function matchesAny(text, patterns) {
|
|
|
9601
9627
|
function classifyExecutionOrGeneric(text) {
|
|
9602
9628
|
if (matchesAny(text, EXECUTION_PATTERNS)) return "execution";
|
|
9603
9629
|
if (matchesAny(text, GENERIC_PATTERNS)) return "generic";
|
|
9604
|
-
|
|
9630
|
+
logger7.debug("Unclassified error string", { sample: text.slice(0, 200) });
|
|
9605
9631
|
return "unknown";
|
|
9606
9632
|
}
|
|
9607
9633
|
function classifyText(text) {
|
|
@@ -9943,7 +9969,7 @@ function groupBy(outcomes, keyFn) {
|
|
|
9943
9969
|
}
|
|
9944
9970
|
|
|
9945
9971
|
// src/pipeline/event-bus.ts
|
|
9946
|
-
var
|
|
9972
|
+
var logger8 = createLogger({ component: "EventBus" });
|
|
9947
9973
|
var DEFAULT_MAX_BUFFER = 1e4;
|
|
9948
9974
|
var EventBus = class {
|
|
9949
9975
|
buffer;
|
|
@@ -9997,7 +10023,7 @@ var EventBus = class {
|
|
|
9997
10023
|
sub.handler(event);
|
|
9998
10024
|
} catch (error) {
|
|
9999
10025
|
const msg = getErrorMessage(error);
|
|
10000
|
-
|
|
10026
|
+
logger8.warn("Event handler error", { eventType: event.type, error: msg });
|
|
10001
10027
|
}
|
|
10002
10028
|
}
|
|
10003
10029
|
}
|
|
@@ -10061,8 +10087,8 @@ function generateSyntheticPriors() {
|
|
|
10061
10087
|
}
|
|
10062
10088
|
return priors;
|
|
10063
10089
|
}
|
|
10064
|
-
function runWarmUp(
|
|
10065
|
-
const log =
|
|
10090
|
+
function runWarmUp(logger15) {
|
|
10091
|
+
const log = logger15 ?? createLogger({ component: "warm-up" });
|
|
10066
10092
|
const store = getOutcomeStore();
|
|
10067
10093
|
const existing = store.query();
|
|
10068
10094
|
const hasSynthetic = existing.some((o) => o.qualitySignals?.includes(SYNTHETIC_MARKER) === true);
|
|
@@ -10106,58 +10132,58 @@ function runWarmUp(logger14) {
|
|
|
10106
10132
|
}
|
|
10107
10133
|
|
|
10108
10134
|
// src/cli-adapters/composite-router-types.ts
|
|
10109
|
-
import { z as
|
|
10110
|
-
var CompositeRouterConfigSchema =
|
|
10135
|
+
import { z as z12 } from "zod";
|
|
10136
|
+
var CompositeRouterConfigSchema = z12.object({
|
|
10111
10137
|
/** Enable confidence cascade stage (default: false) (Issue #755, ADR-0005) */
|
|
10112
|
-
enableConfidenceCascade:
|
|
10138
|
+
enableConfidenceCascade: z12.boolean().default(false),
|
|
10113
10139
|
/** Enable budget filtering stage (default: true) */
|
|
10114
|
-
enableBudgetFilter:
|
|
10140
|
+
enableBudgetFilter: z12.boolean().default(true),
|
|
10115
10141
|
/** Enable capability match stage (default: false) (Issue #755, ADR-0005) */
|
|
10116
|
-
enableCapabilityMatch:
|
|
10142
|
+
enableCapabilityMatch: z12.boolean().default(false),
|
|
10117
10143
|
/** Enable ZeroRouter difficulty-based routing stage (default: true) (Issue #473) */
|
|
10118
|
-
enableZeroRouter:
|
|
10144
|
+
enableZeroRouter: z12.boolean().default(true),
|
|
10119
10145
|
/** Enable preference-trained routing stage (default: false) */
|
|
10120
|
-
enablePreferenceRouting:
|
|
10146
|
+
enablePreferenceRouting: z12.boolean().default(false),
|
|
10121
10147
|
/** Enable TOPSIS ranking stage (default: true) */
|
|
10122
|
-
enableTopsisRanking:
|
|
10148
|
+
enableTopsisRanking: z12.boolean().default(true),
|
|
10123
10149
|
/** Enable LinUCB selection stage (default: true) */
|
|
10124
|
-
enableLinUCBSelection:
|
|
10150
|
+
enableLinUCBSelection: z12.boolean().default(true),
|
|
10125
10151
|
/** Enable quality constraint stage (default: false) (Issue #755, ADR-0005) */
|
|
10126
|
-
enableQualityConstraint:
|
|
10152
|
+
enableQualityConstraint: z12.boolean().default(false),
|
|
10127
10153
|
/** Enable resource strategy stage for budget-aware oscillation (default: true) (Issue #998) */
|
|
10128
|
-
enableResourceStrategy:
|
|
10154
|
+
enableResourceStrategy: z12.boolean().default(true),
|
|
10129
10155
|
/** Enable strategy distillation for learned routing rules (default: false) (Issue #999) */
|
|
10130
|
-
enableStrategyDistillation:
|
|
10156
|
+
enableStrategyDistillation: z12.boolean().default(false),
|
|
10131
10157
|
/** Enable latency tracking for routing decisions (default: true) (Issue #361) */
|
|
10132
|
-
enableLatencyTracking:
|
|
10158
|
+
enableLatencyTracking: z12.boolean().default(true),
|
|
10133
10159
|
/** Enable routing memory for learned routing (default: false) (Issue #463, #461) */
|
|
10134
|
-
enableRoutingMemory:
|
|
10160
|
+
enableRoutingMemory: z12.boolean().default(false),
|
|
10135
10161
|
/** Enable KNN experience-based routing (default: false) (arXiv:2505.12601) */
|
|
10136
|
-
enableKnnRouting:
|
|
10162
|
+
enableKnnRouting: z12.boolean().default(false),
|
|
10137
10163
|
/** Weight for latency score in final routing (0-1, default: 0.2) */
|
|
10138
|
-
latencyScoreWeight:
|
|
10164
|
+
latencyScoreWeight: z12.number().min(0).max(1).default(0.2),
|
|
10139
10165
|
/** Budget constraints (optional) */
|
|
10140
|
-
budgetConstraints:
|
|
10141
|
-
maxTokens:
|
|
10142
|
-
maxCostUsd:
|
|
10143
|
-
maxLatencyMs:
|
|
10166
|
+
budgetConstraints: z12.object({
|
|
10167
|
+
maxTokens: z12.number().positive(),
|
|
10168
|
+
maxCostUsd: z12.number().positive(),
|
|
10169
|
+
maxLatencyMs: z12.number().positive(),
|
|
10144
10170
|
/** Per-task-class cost ceilings in USD, keyed by TaskCategory (#4196).
|
|
10145
10171
|
* Keys are validated against the TaskCategory enum (#4214) so a typo'd
|
|
10146
10172
|
* class fails config parsing instead of silently configuring nothing.
|
|
10147
10173
|
* Default: absent → no ceiling (OFF/unlimited). Enforced only under
|
|
10148
10174
|
* billingMode 'api'; missing candidate pricing fails CLOSED. */
|
|
10149
|
-
taskClassMaxCostUsd:
|
|
10175
|
+
taskClassMaxCostUsd: z12.partialRecord(TaskCategorySchema, z12.number().positive())
|
|
10150
10176
|
}).partial().optional(),
|
|
10151
10177
|
/** LinUCB exploration parameter (default: 1.0) */
|
|
10152
|
-
linucbAlpha:
|
|
10178
|
+
linucbAlpha: z12.number().positive().default(1),
|
|
10153
10179
|
/** Billing mode: 'plan' zeroes cost weight, 'api' preserves current behavior (default: 'plan') */
|
|
10154
|
-
billingMode:
|
|
10180
|
+
billingMode: z12.enum(["plan", "api"]).default("plan"),
|
|
10155
10181
|
/** Enable capacity-aware load balancing (deprioritize exhausted CLIs) (default: true) (Issue #807) */
|
|
10156
|
-
enableCapacityBalancing:
|
|
10182
|
+
enableCapacityBalancing: z12.boolean().default(true),
|
|
10157
10183
|
/** Maximum routing decision time in ms (default: 50) */
|
|
10158
|
-
maxDecisionTimeMs:
|
|
10184
|
+
maxDecisionTimeMs: z12.number().positive().default(50),
|
|
10159
10185
|
/** Minimum preference data points before using learned routing (default: 10) */
|
|
10160
|
-
preferenceMinDataPoints:
|
|
10186
|
+
preferenceMinDataPoints: z12.number().int().positive().default(10)
|
|
10161
10187
|
});
|
|
10162
10188
|
var DEFAULT_COMPOSITE_CONFIG = {
|
|
10163
10189
|
enableConfidenceCascade: false,
|
|
@@ -10566,12 +10592,12 @@ All defaults can be overridden via environment variables using the NEXUS_ prefix
|
|
|
10566
10592
|
}
|
|
10567
10593
|
|
|
10568
10594
|
// src/mcp/tools/weather-report-types.ts
|
|
10569
|
-
import { z as
|
|
10570
|
-
var WeatherReportInputSchema =
|
|
10595
|
+
import { z as z13 } from "zod";
|
|
10596
|
+
var WeatherReportInputSchema = z13.object({
|
|
10571
10597
|
/** Filter by CLI name. */
|
|
10572
|
-
cli:
|
|
10598
|
+
cli: z13.enum(CLI_NAMES).optional().describe("Filter by CLI"),
|
|
10573
10599
|
/** Filter by task category. */
|
|
10574
|
-
category:
|
|
10600
|
+
category: z13.enum([
|
|
10575
10601
|
"architecture",
|
|
10576
10602
|
"code_generation",
|
|
10577
10603
|
"code_review",
|
|
@@ -10584,22 +10610,22 @@ var WeatherReportInputSchema = z12.object({
|
|
|
10584
10610
|
"exploration"
|
|
10585
10611
|
]).optional().describe("Filter by task category"),
|
|
10586
10612
|
/** Include adaptive routing bonus data. */
|
|
10587
|
-
includeAdaptive:
|
|
10613
|
+
includeAdaptive: z13.boolean().optional().default(true).describe("Include adaptive routing bonuses (default: true)")
|
|
10588
10614
|
});
|
|
10589
10615
|
var DEFAULT_OUTCOME_LOOKBACK_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
10590
|
-
var WeatherReportConfigSchema =
|
|
10616
|
+
var WeatherReportConfigSchema = z13.object({
|
|
10591
10617
|
/** Minimum observations before adjusting bonuses (lowered for faster activation). */
|
|
10592
|
-
coldStartThreshold:
|
|
10618
|
+
coldStartThreshold: z13.number().int().min(1).max(1e3).default(3),
|
|
10593
10619
|
/** Exploration rate: fraction of random routing (0.0-1.0). */
|
|
10594
|
-
explorationRate:
|
|
10620
|
+
explorationRate: z13.number().min(0).max(1).default(0.1),
|
|
10595
10621
|
/** Max adaptive bonus adjustment (+/-). */
|
|
10596
|
-
maxBonusAdjustment:
|
|
10622
|
+
maxBonusAdjustment: z13.number().min(0).max(20).default(10),
|
|
10597
10623
|
/**
|
|
10598
10624
|
* Lookback window for outcome queries (ms). Only outcomes within this
|
|
10599
10625
|
* window are used for adaptive bonuses. Falls back to all history if
|
|
10600
10626
|
* the window has fewer samples than coldStartThreshold. Default: 7 days.
|
|
10601
10627
|
*/
|
|
10602
|
-
outcomeLookbackMs:
|
|
10628
|
+
outcomeLookbackMs: z13.number().int().min(0).default(DEFAULT_OUTCOME_LOOKBACK_MS)
|
|
10603
10629
|
});
|
|
10604
10630
|
function createDefaultWeatherConfig() {
|
|
10605
10631
|
return WeatherReportConfigSchema.parse({});
|
|
@@ -10985,47 +11011,47 @@ function createMetricsMiddleware() {
|
|
|
10985
11011
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
10986
11012
|
|
|
10987
11013
|
// src/config/defaults-types.ts
|
|
10988
|
-
import { z as
|
|
11014
|
+
import { z as z14 } from "zod";
|
|
10989
11015
|
function isKnownCliName(cli) {
|
|
10990
11016
|
return cli === "claude" || cli === "gemini" || cli === "codex" || cli === "opencode" || cli === "default";
|
|
10991
11017
|
}
|
|
10992
|
-
var positiveInt =
|
|
10993
|
-
var nonNegativeInt =
|
|
10994
|
-
var durationMs =
|
|
10995
|
-
var TimeoutProfileSchema =
|
|
11018
|
+
var positiveInt = z14.number().int().positive();
|
|
11019
|
+
var nonNegativeInt = z14.number().int().nonnegative();
|
|
11020
|
+
var durationMs = z14.number().int().positive().describe("Duration in milliseconds");
|
|
11021
|
+
var TimeoutProfileSchema = z14.object({
|
|
10996
11022
|
simple: durationMs.describe("Timeout for simple tasks"),
|
|
10997
11023
|
standard: durationMs.describe("Timeout for standard tasks"),
|
|
10998
11024
|
complex: durationMs.describe("Timeout for complex tasks")
|
|
10999
11025
|
});
|
|
11000
|
-
var RetryDefaultsSchema =
|
|
11026
|
+
var RetryDefaultsSchema = z14.object({
|
|
11001
11027
|
maxRetries: nonNegativeInt.max(10).describe("Maximum retry attempts"),
|
|
11002
11028
|
baseDelayMs: durationMs.describe("Base delay between retries"),
|
|
11003
11029
|
maxDelayMs: durationMs.describe("Maximum delay between retries"),
|
|
11004
|
-
jitterFactor:
|
|
11030
|
+
jitterFactor: z14.number().min(0).max(1).describe("Jitter factor (0-1)")
|
|
11005
11031
|
});
|
|
11006
|
-
var RateLimitDefaultsSchema =
|
|
11032
|
+
var RateLimitDefaultsSchema = z14.object({
|
|
11007
11033
|
requestsPerMinute: positiveInt.max(1e3).describe("Max requests per minute"),
|
|
11008
|
-
enabled:
|
|
11034
|
+
enabled: z14.boolean().describe("Whether rate limiting is enabled"),
|
|
11009
11035
|
maxConcurrent: positiveInt.max(100).describe("Max concurrent requests"),
|
|
11010
11036
|
capacity: positiveInt.describe("Token bucket capacity"),
|
|
11011
11037
|
refillRate: positiveInt.describe("Token refill rate"),
|
|
11012
11038
|
refillIntervalMs: durationMs.describe("Token refill interval")
|
|
11013
11039
|
});
|
|
11014
|
-
var CircuitBreakerDefaultsSchema =
|
|
11015
|
-
failureThreshold:
|
|
11040
|
+
var CircuitBreakerDefaultsSchema = z14.object({
|
|
11041
|
+
failureThreshold: z14.number().int().min(1).max(100).describe("Failures before opening"),
|
|
11016
11042
|
resetTimeoutMs: durationMs.describe("Time before attempting reset"),
|
|
11017
|
-
halfOpenSuccessThreshold:
|
|
11018
|
-
countTimeoutsAsFailures:
|
|
11019
|
-
countAuthFailuresAsFailures:
|
|
11020
|
-
countRateLimitsAsFailures:
|
|
11043
|
+
halfOpenSuccessThreshold: z14.number().int().min(1).max(10).describe("Successes to close"),
|
|
11044
|
+
countTimeoutsAsFailures: z14.boolean().describe("Count timeouts as failures"),
|
|
11045
|
+
countAuthFailuresAsFailures: z14.boolean().describe("Count auth failures as failures"),
|
|
11046
|
+
countRateLimitsAsFailures: z14.boolean().describe("Count rate limit errors as failures"),
|
|
11021
11047
|
halfOpenMaxRequests: positiveInt.describe("Max requests in half-open state")
|
|
11022
11048
|
});
|
|
11023
|
-
var ToolRateLimitConfigSchema =
|
|
11049
|
+
var ToolRateLimitConfigSchema = z14.object({
|
|
11024
11050
|
capacity: positiveInt.describe("Token bucket capacity"),
|
|
11025
11051
|
refillRate: positiveInt.describe("Token refill rate"),
|
|
11026
11052
|
refillIntervalMs: durationMs.describe("Token refill interval")
|
|
11027
11053
|
});
|
|
11028
|
-
var TimeoutDefaultsSchema =
|
|
11054
|
+
var TimeoutDefaultsSchema = z14.object({
|
|
11029
11055
|
cliMs: durationMs.describe("Default CLI timeout"),
|
|
11030
11056
|
// cliSimpleMs / cliComplexMs removed in #4180 — see config/defaults.ts.
|
|
11031
11057
|
apiMs: durationMs.describe("Default API timeout"),
|
|
@@ -11638,7 +11664,7 @@ function aggregateDecisionCosts(records, windowMs) {
|
|
|
11638
11664
|
}
|
|
11639
11665
|
|
|
11640
11666
|
// src/observability/decision-cost-store.ts
|
|
11641
|
-
import { z as
|
|
11667
|
+
import { z as z16 } from "zod";
|
|
11642
11668
|
|
|
11643
11669
|
// src/config/jsonl-store.ts
|
|
11644
11670
|
import { appendFileSync, existsSync as existsSync5, mkdirSync as mkdirSync2, readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "fs";
|
|
@@ -11773,36 +11799,36 @@ var JsonlStore = class {
|
|
|
11773
11799
|
};
|
|
11774
11800
|
|
|
11775
11801
|
// src/observability/decision-cost.ts
|
|
11776
|
-
import { z as
|
|
11802
|
+
import { z as z15 } from "zod";
|
|
11777
11803
|
var UNKNOWN_MODEL = "unknown";
|
|
11778
|
-
var DecisionCostSummarySchema =
|
|
11779
|
-
billingMode:
|
|
11780
|
-
voterCount:
|
|
11781
|
-
measuredVoters:
|
|
11782
|
-
unmeasuredVoters:
|
|
11783
|
-
totalInputTokens:
|
|
11784
|
-
totalOutputTokens:
|
|
11785
|
-
totalTokens:
|
|
11786
|
-
totalCostUsd:
|
|
11787
|
-
perVoter:
|
|
11788
|
-
|
|
11789
|
-
role:
|
|
11790
|
-
model:
|
|
11791
|
-
inputTokens:
|
|
11792
|
-
outputTokens:
|
|
11793
|
-
totalTokens:
|
|
11794
|
-
costUsd:
|
|
11795
|
-
unmeasured:
|
|
11804
|
+
var DecisionCostSummarySchema = z15.object({
|
|
11805
|
+
billingMode: z15.enum(["plan", "api"]),
|
|
11806
|
+
voterCount: z15.number(),
|
|
11807
|
+
measuredVoters: z15.number(),
|
|
11808
|
+
unmeasuredVoters: z15.number(),
|
|
11809
|
+
totalInputTokens: z15.number(),
|
|
11810
|
+
totalOutputTokens: z15.number(),
|
|
11811
|
+
totalTokens: z15.number(),
|
|
11812
|
+
totalCostUsd: z15.number(),
|
|
11813
|
+
perVoter: z15.array(
|
|
11814
|
+
z15.object({
|
|
11815
|
+
role: z15.string(),
|
|
11816
|
+
model: z15.string(),
|
|
11817
|
+
inputTokens: z15.number(),
|
|
11818
|
+
outputTokens: z15.number(),
|
|
11819
|
+
totalTokens: z15.number(),
|
|
11820
|
+
costUsd: z15.number(),
|
|
11821
|
+
unmeasured: z15.boolean()
|
|
11796
11822
|
})
|
|
11797
11823
|
),
|
|
11798
|
-
perModel:
|
|
11799
|
-
|
|
11800
|
-
model:
|
|
11801
|
-
voterCount:
|
|
11802
|
-
inputTokens:
|
|
11803
|
-
outputTokens:
|
|
11804
|
-
totalTokens:
|
|
11805
|
-
costUsd:
|
|
11824
|
+
perModel: z15.array(
|
|
11825
|
+
z15.object({
|
|
11826
|
+
model: z15.string(),
|
|
11827
|
+
voterCount: z15.number(),
|
|
11828
|
+
inputTokens: z15.number(),
|
|
11829
|
+
outputTokens: z15.number(),
|
|
11830
|
+
totalTokens: z15.number(),
|
|
11831
|
+
costUsd: z15.number()
|
|
11806
11832
|
})
|
|
11807
11833
|
)
|
|
11808
11834
|
});
|
|
@@ -11877,43 +11903,43 @@ function buildPerModelBreakdowns(modelAcc) {
|
|
|
11877
11903
|
}
|
|
11878
11904
|
|
|
11879
11905
|
// src/observability/decision-cost-store.ts
|
|
11880
|
-
var DecisionGateSchema =
|
|
11881
|
-
var VoterCostBreakdownSchema =
|
|
11882
|
-
role:
|
|
11883
|
-
model:
|
|
11884
|
-
inputTokens:
|
|
11885
|
-
outputTokens:
|
|
11886
|
-
totalTokens:
|
|
11887
|
-
costUsd:
|
|
11888
|
-
unmeasured:
|
|
11906
|
+
var DecisionGateSchema = z16.enum(["consensus_vote", "pr_review"]);
|
|
11907
|
+
var VoterCostBreakdownSchema = z16.object({
|
|
11908
|
+
role: z16.string().min(1).max(64),
|
|
11909
|
+
model: z16.string().min(1).max(120),
|
|
11910
|
+
inputTokens: z16.number().int().nonnegative(),
|
|
11911
|
+
outputTokens: z16.number().int().nonnegative(),
|
|
11912
|
+
totalTokens: z16.number().int().nonnegative(),
|
|
11913
|
+
costUsd: z16.number().nonnegative(),
|
|
11914
|
+
unmeasured: z16.boolean()
|
|
11889
11915
|
});
|
|
11890
|
-
var ModelCostBreakdownSchema =
|
|
11891
|
-
model:
|
|
11892
|
-
voterCount:
|
|
11893
|
-
inputTokens:
|
|
11894
|
-
outputTokens:
|
|
11895
|
-
totalTokens:
|
|
11896
|
-
costUsd:
|
|
11916
|
+
var ModelCostBreakdownSchema = z16.object({
|
|
11917
|
+
model: z16.string().min(1).max(120),
|
|
11918
|
+
voterCount: z16.number().int().nonnegative(),
|
|
11919
|
+
inputTokens: z16.number().int().nonnegative(),
|
|
11920
|
+
outputTokens: z16.number().int().nonnegative(),
|
|
11921
|
+
totalTokens: z16.number().int().nonnegative(),
|
|
11922
|
+
costUsd: z16.number().nonnegative()
|
|
11897
11923
|
});
|
|
11898
|
-
var DecisionCostSummarySchema2 =
|
|
11899
|
-
billingMode:
|
|
11900
|
-
voterCount:
|
|
11901
|
-
measuredVoters:
|
|
11902
|
-
unmeasuredVoters:
|
|
11903
|
-
totalInputTokens:
|
|
11904
|
-
totalOutputTokens:
|
|
11905
|
-
totalTokens:
|
|
11906
|
-
totalCostUsd:
|
|
11907
|
-
perVoter:
|
|
11908
|
-
perModel:
|
|
11924
|
+
var DecisionCostSummarySchema2 = z16.object({
|
|
11925
|
+
billingMode: z16.enum(["plan", "api"]),
|
|
11926
|
+
voterCount: z16.number().int().nonnegative(),
|
|
11927
|
+
measuredVoters: z16.number().int().nonnegative(),
|
|
11928
|
+
unmeasuredVoters: z16.number().int().nonnegative(),
|
|
11929
|
+
totalInputTokens: z16.number().int().nonnegative(),
|
|
11930
|
+
totalOutputTokens: z16.number().int().nonnegative(),
|
|
11931
|
+
totalTokens: z16.number().int().nonnegative(),
|
|
11932
|
+
totalCostUsd: z16.number().nonnegative(),
|
|
11933
|
+
perVoter: z16.array(VoterCostBreakdownSchema).readonly(),
|
|
11934
|
+
perModel: z16.array(ModelCostBreakdownSchema).readonly()
|
|
11909
11935
|
});
|
|
11910
|
-
var DecisionCostRecordSchema =
|
|
11936
|
+
var DecisionCostRecordSchema = z16.object({
|
|
11911
11937
|
/** Stable id for the decision (correlation id / jobId / minted decision id). */
|
|
11912
|
-
decisionId:
|
|
11938
|
+
decisionId: z16.string().min(1).max(160),
|
|
11913
11939
|
/** Which gate type incurred the cost. */
|
|
11914
11940
|
gate: DecisionGateSchema,
|
|
11915
11941
|
/** ISO 8601 timestamp the rollup was recorded. */
|
|
11916
|
-
timestamp:
|
|
11942
|
+
timestamp: z16.string().min(1).max(40),
|
|
11917
11943
|
/** The rolled-up cost summary. */
|
|
11918
11944
|
summary: DecisionCostSummarySchema2
|
|
11919
11945
|
});
|
|
@@ -11973,7 +11999,7 @@ var DecisionCostStore = class {
|
|
|
11973
11999
|
// src/orchestration/strategy-manifest.ts
|
|
11974
12000
|
import { existsSync as existsSync6, readFileSync as readFileSync5 } from "fs";
|
|
11975
12001
|
import { parse as parseYaml2 } from "yaml";
|
|
11976
|
-
import { z as
|
|
12002
|
+
import { z as z17 } from "zod";
|
|
11977
12003
|
var STRATEGY_MANIFEST_SCHEMA_VERSION = 1;
|
|
11978
12004
|
var EXECUTION_STRATEGY_NAMES = [
|
|
11979
12005
|
"single-shot",
|
|
@@ -11985,41 +12011,41 @@ var EXECUTION_STRATEGY_NAMES = [
|
|
|
11985
12011
|
"spec",
|
|
11986
12012
|
"research"
|
|
11987
12013
|
];
|
|
11988
|
-
var StrategyNameSchema =
|
|
11989
|
-
var AuthorityTierSchema =
|
|
11990
|
-
var PromotionEvidenceSchema =
|
|
12014
|
+
var StrategyNameSchema = z17.enum(EXECUTION_STRATEGY_NAMES);
|
|
12015
|
+
var AuthorityTierSchema = z17.enum(["observe", "suggest", "advisory", "enforce"]);
|
|
12016
|
+
var PromotionEvidenceSchema = z17.object({
|
|
11991
12017
|
/** The loop/strategy being promoted (manifest `id`). */
|
|
11992
|
-
loopId:
|
|
12018
|
+
loopId: z17.string().min(1),
|
|
11993
12019
|
/** Current tier before promotion. */
|
|
11994
12020
|
fromTier: AuthorityTierSchema,
|
|
11995
12021
|
/** Target tier; must be exactly one step up (checked by the gate). */
|
|
11996
12022
|
toTier: AuthorityTierSchema,
|
|
11997
12023
|
/** Number of independent, judged evaluations behind the metric. */
|
|
11998
|
-
evalN:
|
|
12024
|
+
evalN: z17.number().int().nonnegative(),
|
|
11999
12025
|
/** Precision on judged output (0–1); required for advisory+ promotions. */
|
|
12000
|
-
precision:
|
|
12026
|
+
precision: z17.number().min(0).max(1).optional(),
|
|
12001
12027
|
/** Recall (0–1); required for enforce promotions (missed-action cost). */
|
|
12002
|
-
recall:
|
|
12028
|
+
recall: z17.number().min(0).max(1).optional(),
|
|
12003
12029
|
/** The loop-specific promotion metric: name, value, and CI bounds. */
|
|
12004
|
-
primaryMetric:
|
|
12005
|
-
name:
|
|
12006
|
-
value:
|
|
12007
|
-
ci:
|
|
12030
|
+
primaryMetric: z17.object({
|
|
12031
|
+
name: z17.string().min(1),
|
|
12032
|
+
value: z17.number(),
|
|
12033
|
+
ci: z17.tuple([z17.number(), z17.number()])
|
|
12008
12034
|
}).strict(),
|
|
12009
12035
|
/** ISO-8601 duration of soak at the lower tier with no intervention. */
|
|
12010
|
-
soakDuration:
|
|
12036
|
+
soakDuration: z17.string().regex(/^P/, "soakDuration must be an ISO-8601 duration (e.g. P30D)"),
|
|
12011
12037
|
/** Confounders the primaryMetric controls for. */
|
|
12012
|
-
controlledFor:
|
|
12038
|
+
controlledFor: z17.array(z17.string()).optional(),
|
|
12013
12039
|
/** The recorded consensus_vote ref that ratifies the promotion. */
|
|
12014
|
-
ratificationVote:
|
|
12040
|
+
ratificationVote: z17.string().min(1),
|
|
12015
12041
|
/** Link to the measurement surface / report that produced the numbers. */
|
|
12016
|
-
evidenceUri:
|
|
12042
|
+
evidenceUri: z17.string().min(1)
|
|
12017
12043
|
}).strict();
|
|
12018
|
-
var PromotionEvidenceLedgerSchema =
|
|
12019
|
-
version:
|
|
12020
|
-
evidence:
|
|
12044
|
+
var PromotionEvidenceLedgerSchema = z17.object({
|
|
12045
|
+
version: z17.number().int().positive(),
|
|
12046
|
+
evidence: z17.array(PromotionEvidenceSchema)
|
|
12021
12047
|
}).strict();
|
|
12022
|
-
var LatencyClassSchema =
|
|
12048
|
+
var LatencyClassSchema = z17.enum([
|
|
12023
12049
|
"interactive",
|
|
12024
12050
|
"single-llm",
|
|
12025
12051
|
"multi-llm-panel",
|
|
@@ -12027,9 +12053,9 @@ var LatencyClassSchema = z16.enum([
|
|
|
12027
12053
|
"network-fetch",
|
|
12028
12054
|
"async-job-body"
|
|
12029
12055
|
]);
|
|
12030
|
-
var MaturityTierSchema =
|
|
12031
|
-
var CostProfileSchema =
|
|
12032
|
-
var WorkflowPatternSchema =
|
|
12056
|
+
var MaturityTierSchema = z17.enum(["experimental", "beta", "stable"]);
|
|
12057
|
+
var CostProfileSchema = z17.enum(["low", "medium", "high", "variable"]);
|
|
12058
|
+
var WorkflowPatternSchema = z17.enum([
|
|
12033
12059
|
"sequential",
|
|
12034
12060
|
"wave",
|
|
12035
12061
|
"graph",
|
|
@@ -12037,34 +12063,34 @@ var WorkflowPatternSchema = z16.enum([
|
|
|
12037
12063
|
"aflow",
|
|
12038
12064
|
"puppeteer"
|
|
12039
12065
|
]);
|
|
12040
|
-
var PipelineTypeSchema =
|
|
12041
|
-
var ComplexityTierSchema =
|
|
12042
|
-
var SelectionRuleSchema =
|
|
12066
|
+
var PipelineTypeSchema = z17.enum(["dev", "research", "audit", "greenfield", "general"]);
|
|
12067
|
+
var ComplexityTierSchema = z17.enum(["simple", "moderate", "complex", "expert"]);
|
|
12068
|
+
var SelectionRuleSchema = z17.object({
|
|
12043
12069
|
/** Higher wins. Distinctive templates outrank the structural-pattern fallback. */
|
|
12044
|
-
priority:
|
|
12070
|
+
priority: z17.number().int(),
|
|
12045
12071
|
/** Matches only when the routed workflow pattern is one of these. */
|
|
12046
|
-
patterns:
|
|
12072
|
+
patterns: z17.array(WorkflowPatternSchema).min(1).optional(),
|
|
12047
12073
|
/** Matches only when the classified pipeline template is one of these. */
|
|
12048
|
-
pipelineTypes:
|
|
12074
|
+
pipelineTypes: z17.array(PipelineTypeSchema).min(1).optional(),
|
|
12049
12075
|
/** Matches only when the analyzed complexity is one of these. */
|
|
12050
|
-
complexities:
|
|
12076
|
+
complexities: z17.array(ComplexityTierSchema).min(1).optional()
|
|
12051
12077
|
}).strict().refine((r) => r.patterns !== void 0 || r.pipelineTypes !== void 0, {
|
|
12052
12078
|
message: "a selection rule must constrain at least patterns or pipelineTypes"
|
|
12053
12079
|
});
|
|
12054
|
-
var StrategyManifestSchema =
|
|
12080
|
+
var StrategyManifestSchema = z17.object({
|
|
12055
12081
|
/**
|
|
12056
12082
|
* Stable kebab-case identifier; never reused. For the initial 8 this equals
|
|
12057
12083
|
* the strategy name, but `id` is a distinct field so future strategies can
|
|
12058
12084
|
* carry a more specific id without colliding with the {@link StrategyName}
|
|
12059
12085
|
* enum.
|
|
12060
12086
|
*/
|
|
12061
|
-
id:
|
|
12087
|
+
id: z17.string().regex(/^[a-z0-9]+(-[a-z0-9]+)*$/, "id must be kebab-case"),
|
|
12062
12088
|
/**
|
|
12063
12089
|
* The manifest-shape version this entry was authored against. Must equal
|
|
12064
12090
|
* {@link STRATEGY_MANIFEST_SCHEMA_VERSION}; a mismatch fails closed so a
|
|
12065
12091
|
* manifest written for a future shape is never misread.
|
|
12066
12092
|
*/
|
|
12067
|
-
schemaVersion:
|
|
12093
|
+
schemaVersion: z17.literal(STRATEGY_MANIFEST_SCHEMA_VERSION),
|
|
12068
12094
|
/** The execution strategy this manifest describes (router enum). */
|
|
12069
12095
|
strategy: StrategyNameSchema,
|
|
12070
12096
|
/**
|
|
@@ -12072,7 +12098,7 @@ var StrategyManifestSchema = z16.object({
|
|
|
12072
12098
|
* force-strategy entry point (generalizes `STRATEGY_ENTRYPOINT_TOOL`,
|
|
12073
12099
|
* run-tool.ts). Non-empty.
|
|
12074
12100
|
*/
|
|
12075
|
-
entrypointTool:
|
|
12101
|
+
entrypointTool: z17.string().min(1),
|
|
12076
12102
|
/**
|
|
12077
12103
|
* Whether a wired executor exists for this strategy (run-tool.ts
|
|
12078
12104
|
* `buildDefaultExecutors`). FAIL-CLOSED routing key: only 4/8 are `true`
|
|
@@ -12086,15 +12112,15 @@ var StrategyManifestSchema = z16.object({
|
|
|
12086
12112
|
* (#3881), so declaring `true` for a strategy with no wired executor (silent
|
|
12087
12113
|
* fail-OPEN) fails the build rather than mis-advertising routability.
|
|
12088
12114
|
*/
|
|
12089
|
-
executorAvailable:
|
|
12115
|
+
executorAvailable: z17.boolean(),
|
|
12090
12116
|
/** One-line human description of what this strategy is for (#3838 docs). */
|
|
12091
|
-
description:
|
|
12117
|
+
description: z17.string().min(1),
|
|
12092
12118
|
/**
|
|
12093
12119
|
* Guidance on when to FORCE this strategy via `run({ forceStrategy })` —
|
|
12094
12120
|
* the escape-hatch docs surfaced in #3838. Optional: the router selects by
|
|
12095
12121
|
* capability; this is operator guidance, not a routing input.
|
|
12096
12122
|
*/
|
|
12097
|
-
whenToForce:
|
|
12123
|
+
whenToForce: z17.string().min(1).optional(),
|
|
12098
12124
|
/** Maturity tier; defaults are not assumed — author states it explicitly. */
|
|
12099
12125
|
maturityTier: MaturityTierSchema,
|
|
12100
12126
|
/** Expected latency class (#3734 taxonomy). */
|
|
@@ -12118,11 +12144,11 @@ var StrategyManifestSchema = z16.object({
|
|
|
12118
12144
|
* no claim on any signal). Each rule is a {@link SelectionRule}; the router
|
|
12119
12145
|
* applies the highest-priority matching rule across the whole registry.
|
|
12120
12146
|
*/
|
|
12121
|
-
selectionRules:
|
|
12147
|
+
selectionRules: z17.array(SelectionRuleSchema).min(1).optional()
|
|
12122
12148
|
}).strict();
|
|
12123
|
-
var StrategyManifestRegistrySchema =
|
|
12124
|
-
version:
|
|
12125
|
-
manifests:
|
|
12149
|
+
var StrategyManifestRegistrySchema = z17.object({
|
|
12150
|
+
version: z17.number().int().positive(),
|
|
12151
|
+
manifests: z17.array(StrategyManifestSchema).min(1).superRefine((manifests, ctx) => {
|
|
12126
12152
|
const seenIds = /* @__PURE__ */ new Set();
|
|
12127
12153
|
const seenStrategies = /* @__PURE__ */ new Set();
|
|
12128
12154
|
for (const [i, m] of manifests.entries()) {
|
|
@@ -12911,14 +12937,14 @@ function buildTierRecommendations(summary) {
|
|
|
12911
12937
|
}
|
|
12912
12938
|
|
|
12913
12939
|
// src/cli-adapters/weather-bonus-stage.ts
|
|
12914
|
-
var
|
|
12940
|
+
var logger9 = createLogger({ component: "weather-bonus-stage" });
|
|
12915
12941
|
var MIN_SAMPLE_COUNT = 5;
|
|
12916
12942
|
function getWeatherBonusScores(taskCategory) {
|
|
12917
12943
|
try {
|
|
12918
12944
|
const report = generateWeatherReport({ includeAdaptive: true });
|
|
12919
12945
|
return convertBonusesToScoreMap(report.adaptiveBonuses, taskCategory);
|
|
12920
12946
|
} catch {
|
|
12921
|
-
|
|
12947
|
+
logger9.debug("Weather bonus stage skipped (best-effort)");
|
|
12922
12948
|
return /* @__PURE__ */ new Map();
|
|
12923
12949
|
}
|
|
12924
12950
|
}
|
|
@@ -12931,7 +12957,7 @@ function convertBonusesToScoreMap(bonuses, taskCategory) {
|
|
|
12931
12957
|
scores.set(bonus.cli, bonus.adaptiveBonus);
|
|
12932
12958
|
}
|
|
12933
12959
|
if (scores.size > 0) {
|
|
12934
|
-
|
|
12960
|
+
logger9.debug("Weather bonus scores applied", {
|
|
12935
12961
|
category: taskCategory,
|
|
12936
12962
|
clis: [...scores.keys()]
|
|
12937
12963
|
});
|
|
@@ -12940,9 +12966,9 @@ function convertBonusesToScoreMap(bonuses, taskCategory) {
|
|
|
12940
12966
|
}
|
|
12941
12967
|
|
|
12942
12968
|
// src/cli-adapters/fallback-chains.ts
|
|
12943
|
-
import { z as
|
|
12944
|
-
var FallbackChainSchema =
|
|
12945
|
-
var FallbackChainRegistrySchema =
|
|
12969
|
+
import { z as z18 } from "zod";
|
|
12970
|
+
var FallbackChainSchema = z18.array(z18.enum(["claude", "gemini", "codex", "opencode"])).min(1).readonly();
|
|
12971
|
+
var FallbackChainRegistrySchema = z18.object({
|
|
12946
12972
|
code: FallbackChainSchema,
|
|
12947
12973
|
research: FallbackChainSchema,
|
|
12948
12974
|
documentation: FallbackChainSchema,
|
|
@@ -12984,7 +13010,7 @@ function getFallbackChainForCategory(category, bucketType, registry = DEFAULT_FA
|
|
|
12984
13010
|
}
|
|
12985
13011
|
|
|
12986
13012
|
// src/cli-adapters/composite-router-stages.ts
|
|
12987
|
-
var
|
|
13013
|
+
var logger10 = createLogger({ component: "composite-router-stages" });
|
|
12988
13014
|
var sharedAnalyzer2 = createSharedTaskAnalyzer();
|
|
12989
13015
|
function armsToSlots(candidates) {
|
|
12990
13016
|
return [...new Set(candidates.map(routingArmDisplaySlot))];
|
|
@@ -13199,7 +13225,7 @@ function getPerformanceDataForCategory(taskContent) {
|
|
|
13199
13225
|
}
|
|
13200
13226
|
return result;
|
|
13201
13227
|
} catch (error) {
|
|
13202
|
-
|
|
13228
|
+
logger10.debug("Performance-floor outcome-store read failed; skipping penalty", {
|
|
13203
13229
|
error: error instanceof Error ? error.message : String(error)
|
|
13204
13230
|
});
|
|
13205
13231
|
return /* @__PURE__ */ new Map();
|
|
@@ -13377,7 +13403,7 @@ function getWeatherBonusForTask(taskContent) {
|
|
|
13377
13403
|
if (match === null) return /* @__PURE__ */ new Map();
|
|
13378
13404
|
return getWeatherBonusScores(match.category);
|
|
13379
13405
|
} catch (error) {
|
|
13380
|
-
|
|
13406
|
+
logger10.debug("Weather bonus outcome-store read failed; skipping bonus", {
|
|
13381
13407
|
error: error instanceof Error ? error.message : String(error)
|
|
13382
13408
|
});
|
|
13383
13409
|
return /* @__PURE__ */ new Map();
|
|
@@ -13403,7 +13429,7 @@ function applyCategoryOverride(task, candidates, stagesExecuted) {
|
|
|
13403
13429
|
if (filtered.length === 0) {
|
|
13404
13430
|
if (isCategoryFailClosed(match.category)) {
|
|
13405
13431
|
stagesExecuted.push("category-override:fail-closed");
|
|
13406
|
-
|
|
13432
|
+
logger10.warn("Category override fail-closed \u2014 every override CLI unavailable", {
|
|
13407
13433
|
category: match.category,
|
|
13408
13434
|
override,
|
|
13409
13435
|
availableCandidates: candidates
|
|
@@ -13528,7 +13554,7 @@ function selectWithMemoryInfluence(linucbSelection, memoryResult, deps) {
|
|
|
13528
13554
|
}
|
|
13529
13555
|
|
|
13530
13556
|
// src/config/available-models-cache.ts
|
|
13531
|
-
var
|
|
13557
|
+
var logger11 = createLogger({ component: "available-models-cache" });
|
|
13532
13558
|
var DEFAULT_TTL_MS = 5 * 60 * 1e3;
|
|
13533
13559
|
var DEFAULT_STALE_TTL_MS = 25 * 60 * 1e3;
|
|
13534
13560
|
var AvailableModelsCache = class {
|
|
@@ -13636,7 +13662,7 @@ var AvailableModelsCache = class {
|
|
|
13636
13662
|
state.fetchedAt = this.now();
|
|
13637
13663
|
return value;
|
|
13638
13664
|
} catch (e) {
|
|
13639
|
-
|
|
13665
|
+
logger11.warn("AvailableModelsCache source probe failed", {
|
|
13640
13666
|
source: source.name,
|
|
13641
13667
|
error: e instanceof Error ? e.message : String(e)
|
|
13642
13668
|
});
|
|
@@ -13671,29 +13697,29 @@ function setDefaultAvailableModelsCache(cache) {
|
|
|
13671
13697
|
}
|
|
13672
13698
|
|
|
13673
13699
|
// src/config/openrouter-models-source.ts
|
|
13674
|
-
import { z as
|
|
13700
|
+
import { z as z19 } from "zod";
|
|
13675
13701
|
var OPENROUTER_MODELS_URL = "https://openrouter.ai/api/v1/models";
|
|
13676
13702
|
var DEFAULT_TIMEOUT_MS = 8e3;
|
|
13677
13703
|
var MAX_MODELS = 5e3;
|
|
13678
13704
|
var MAX_BYTES = 8e6;
|
|
13679
13705
|
var MAX_SUPPORTED_PARAMETERS = 256;
|
|
13680
|
-
var OpenRouterModelSchema =
|
|
13681
|
-
id:
|
|
13706
|
+
var OpenRouterModelSchema = z19.object({
|
|
13707
|
+
id: z19.string().min(1).max(256),
|
|
13682
13708
|
// #4121: the provider's machine-readable capability list. Optional & additive —
|
|
13683
13709
|
// older catalogs (and our older fixtures) omit it; consumers reading only `.id`
|
|
13684
13710
|
// are unaffected. Bounded so a hostile payload can't blow memory.
|
|
13685
|
-
supported_parameters:
|
|
13711
|
+
supported_parameters: z19.array(z19.string().max(256)).max(MAX_SUPPORTED_PARAMETERS).optional()
|
|
13686
13712
|
});
|
|
13687
|
-
var OpenRouterModelsResponseSchema =
|
|
13688
|
-
var
|
|
13713
|
+
var OpenRouterModelsResponseSchema = z19.object({ data: z19.array(OpenRouterModelSchema) });
|
|
13714
|
+
var logger12 = createLogger({ component: "openrouter-models-source" });
|
|
13689
13715
|
function parseCatalog(text) {
|
|
13690
13716
|
if (text.length > MAX_BYTES) {
|
|
13691
|
-
|
|
13717
|
+
logger12.warn("OpenRouter catalog exceeds byte cap; ignoring", { bytes: text.length });
|
|
13692
13718
|
return [];
|
|
13693
13719
|
}
|
|
13694
13720
|
const parsed = OpenRouterModelsResponseSchema.safeParse(JSON.parse(text));
|
|
13695
13721
|
if (!parsed.success) {
|
|
13696
|
-
|
|
13722
|
+
logger12.warn("OpenRouter catalog failed schema validation; treating as empty", {
|
|
13697
13723
|
error: parsed.error.message
|
|
13698
13724
|
});
|
|
13699
13725
|
return [];
|
|
@@ -13713,23 +13739,23 @@ async function fetchCatalog(url, timeoutMs, doFetch) {
|
|
|
13713
13739
|
headers: { accept: "application/json" }
|
|
13714
13740
|
});
|
|
13715
13741
|
if (!res.ok) {
|
|
13716
|
-
|
|
13742
|
+
logger12.warn("OpenRouter catalog fetch returned non-OK; treating as empty", {
|
|
13717
13743
|
status: res.status
|
|
13718
13744
|
});
|
|
13719
13745
|
return [];
|
|
13720
13746
|
}
|
|
13721
13747
|
const declaredLen = res.headers.get("content-length");
|
|
13722
13748
|
if (declaredLen !== null && Number(declaredLen) > MAX_BYTES) {
|
|
13723
|
-
|
|
13749
|
+
logger12.warn("OpenRouter catalog Content-Length exceeds byte cap; ignoring", {
|
|
13724
13750
|
bytes: declaredLen
|
|
13725
13751
|
});
|
|
13726
13752
|
return [];
|
|
13727
13753
|
}
|
|
13728
13754
|
const ids = parseCatalog(await res.text());
|
|
13729
|
-
|
|
13755
|
+
logger12.debug("OpenRouter catalog loaded", { count: ids.length });
|
|
13730
13756
|
return ids;
|
|
13731
13757
|
} catch (error) {
|
|
13732
|
-
|
|
13758
|
+
logger12.warn("OpenRouter catalog fetch failed; treating as empty", {
|
|
13733
13759
|
error: error instanceof Error ? error.message : String(error)
|
|
13734
13760
|
});
|
|
13735
13761
|
return [];
|
|
@@ -13749,7 +13775,7 @@ function createOpenRouterModelsSource(opts = {}) {
|
|
|
13749
13775
|
}
|
|
13750
13776
|
|
|
13751
13777
|
// src/config/register-model-sources.ts
|
|
13752
|
-
var
|
|
13778
|
+
var logger13 = createLogger({ component: "register-model-sources" });
|
|
13753
13779
|
function isDynamicModelsEnabled() {
|
|
13754
13780
|
return process.env["NEXUS_DYNAMIC_MODELS"] === "true";
|
|
13755
13781
|
}
|
|
@@ -13760,7 +13786,7 @@ function adapterSource(cliName, adapter) {
|
|
|
13760
13786
|
return {
|
|
13761
13787
|
name: cliName,
|
|
13762
13788
|
listModels: () => adapter.listModels().then((models) => models.map((m) => ({ id: m.id }))).catch((error) => {
|
|
13763
|
-
|
|
13789
|
+
logger13.debug("adapter listModels failed; treating as empty", {
|
|
13764
13790
|
cli: cliName,
|
|
13765
13791
|
error: error instanceof Error ? error.message : String(error)
|
|
13766
13792
|
});
|
|
@@ -13823,32 +13849,32 @@ function resolveModelForTier(cliName, tier, opts = {}) {
|
|
|
13823
13849
|
|
|
13824
13850
|
// src/cli-adapters/model-selection-shadow.ts
|
|
13825
13851
|
import { appendFileSync as appendFileSync2, existsSync as existsSync7, readFileSync as readFileSync6 } from "fs";
|
|
13826
|
-
import { z as
|
|
13852
|
+
import { z as z20 } from "zod";
|
|
13827
13853
|
function isRouteModelShadowEnabled() {
|
|
13828
13854
|
return process.env["NEXUS_ROUTE_MODEL_SHADOW"] === "1" && isPersistenceEnabled();
|
|
13829
13855
|
}
|
|
13830
13856
|
var MODEL_SELECTION_SHADOW_SCHEMA_VERSION = 1;
|
|
13831
13857
|
var READ_LOOKBACK_DAYS = 30;
|
|
13832
13858
|
var READ_LOOKBACK_MS = READ_LOOKBACK_DAYS * 24 * 60 * 60 * 1e3;
|
|
13833
|
-
var ModelTierSchema =
|
|
13834
|
-
var ModelSelectionShadowRecordSchema =
|
|
13835
|
-
schema:
|
|
13859
|
+
var ModelTierSchema = z20.enum(["fast", "balanced", "powerful"]);
|
|
13860
|
+
var ModelSelectionShadowRecordSchema = z20.object({
|
|
13861
|
+
schema: z20.literal(MODEL_SELECTION_SHADOW_SCHEMA_VERSION),
|
|
13836
13862
|
/** ISO timestamp of the outcome join. */
|
|
13837
|
-
timestamp:
|
|
13863
|
+
timestamp: z20.string().min(1),
|
|
13838
13864
|
/** Display slot of the routed CLI (api:* arms collapse to their slot). */
|
|
13839
|
-
cli:
|
|
13865
|
+
cli: z20.string().min(1).max(40),
|
|
13840
13866
|
/** Difficulty tier the ZeroRouter computed for the task. */
|
|
13841
13867
|
tier: ModelTierSchema,
|
|
13842
13868
|
/** Model the live decision actually used (or the CLI default when route-time selection is off). */
|
|
13843
|
-
actualModel:
|
|
13869
|
+
actualModel: z20.string().min(1).max(120),
|
|
13844
13870
|
/** Model `resolveModelForTier` WOULD have picked (never executed). */
|
|
13845
|
-
shadowModel:
|
|
13871
|
+
shadowModel: z20.string().min(1).max(120),
|
|
13846
13872
|
/** Whether shadow and actual agree. */
|
|
13847
|
-
agree:
|
|
13873
|
+
agree: z20.boolean(),
|
|
13848
13874
|
/** Whether the actually-executed decision succeeded. */
|
|
13849
|
-
success:
|
|
13875
|
+
success: z20.boolean(),
|
|
13850
13876
|
/** Measured cost of the actual execution, when available (unmeasured today on the routing path). */
|
|
13851
|
-
costUsd:
|
|
13877
|
+
costUsd: z20.number().nonnegative().optional()
|
|
13852
13878
|
});
|
|
13853
13879
|
function computeModelSelectionShadow(cli, tier, actualModel) {
|
|
13854
13880
|
const shadowModel = resolveModelForTier(cli, tier);
|
|
@@ -13959,14 +13985,14 @@ function evaluateModelSelectionReadiness(records, config = DEFAULT_MODEL_SELECTI
|
|
|
13959
13985
|
return { ready: blockers.length === 0, criteria, blockers };
|
|
13960
13986
|
}
|
|
13961
13987
|
var readinessLogged = false;
|
|
13962
|
-
function logModelSelectionReadinessOnce(
|
|
13988
|
+
function logModelSelectionReadinessOnce(logger15) {
|
|
13963
13989
|
if (readinessLogged) return;
|
|
13964
13990
|
readinessLogged = true;
|
|
13965
13991
|
try {
|
|
13966
13992
|
const records = readModelSelectionShadowRecords();
|
|
13967
13993
|
const summary = summarizeModelSelectionShadow(records);
|
|
13968
13994
|
const verdict = evaluateModelSelectionReadiness(records);
|
|
13969
|
-
|
|
13995
|
+
logger15.info("route-model-selection shadow readiness", {
|
|
13970
13996
|
ready: verdict.ready,
|
|
13971
13997
|
blockers: verdict.blockers,
|
|
13972
13998
|
total: summary.total,
|
|
@@ -13978,7 +14004,7 @@ function logModelSelectionReadinessOnce(logger14) {
|
|
|
13978
14004
|
meanCostUsd: summary.meanCostUsd
|
|
13979
14005
|
});
|
|
13980
14006
|
} catch (err2) {
|
|
13981
|
-
|
|
14007
|
+
logger15.warn("route-model-selection readiness signal failed (non-fatal)", {
|
|
13982
14008
|
error: getErrorMessage(err2)
|
|
13983
14009
|
});
|
|
13984
14010
|
}
|
|
@@ -14199,7 +14225,7 @@ var CompositeRouter = class _CompositeRouter {
|
|
|
14199
14225
|
* The task content itself is never persisted.
|
|
14200
14226
|
*/
|
|
14201
14227
|
pendingModelShadow;
|
|
14202
|
-
constructor(adapters, config,
|
|
14228
|
+
constructor(adapters, config, logger15) {
|
|
14203
14229
|
const {
|
|
14204
14230
|
preferenceRouterConfig,
|
|
14205
14231
|
zeroRouterConfig,
|
|
@@ -14216,7 +14242,7 @@ var CompositeRouter = class _CompositeRouter {
|
|
|
14216
14242
|
...baseConfig
|
|
14217
14243
|
} = config ?? {};
|
|
14218
14244
|
this.config = CompositeRouterConfigSchema.parse(baseConfig);
|
|
14219
|
-
this.logger =
|
|
14245
|
+
this.logger = logger15 ?? createLogger({ component: "CompositeRouter" });
|
|
14220
14246
|
this.adapters = adapters;
|
|
14221
14247
|
this.cliNames = Array.from(adapters.keys());
|
|
14222
14248
|
if (metricsCollector !== void 0) {
|
|
@@ -14383,7 +14409,7 @@ var CompositeRouter = class _CompositeRouter {
|
|
|
14383
14409
|
*/
|
|
14384
14410
|
async consultUnifiedContext(task) {
|
|
14385
14411
|
try {
|
|
14386
|
-
const { getContextForTask, inferTaskCategory } = await import("./context-retriever-
|
|
14412
|
+
const { getContextForTask, inferTaskCategory } = await import("./context-retriever-MTJR3AQM.js");
|
|
14387
14413
|
const ctx = await getContextForTask({
|
|
14388
14414
|
task: task.content,
|
|
14389
14415
|
category: inferTaskCategory(task.content),
|
|
@@ -14825,14 +14851,14 @@ var CompositeRouter = class _CompositeRouter {
|
|
|
14825
14851
|
return this.routingMemory;
|
|
14826
14852
|
}
|
|
14827
14853
|
};
|
|
14828
|
-
function createCompositeRouter(adapters, config,
|
|
14854
|
+
function createCompositeRouter(adapters, config, logger15) {
|
|
14829
14855
|
let resolved = config;
|
|
14830
14856
|
if (isDynamicModelsEnabled() && config?.availableModelsCache === void 0) {
|
|
14831
14857
|
const cache = getDefaultAvailableModelsCache();
|
|
14832
14858
|
registerDefaultModelSources(cache, adapters);
|
|
14833
14859
|
resolved = { ...config, availableModelsCache: cache };
|
|
14834
14860
|
}
|
|
14835
|
-
return new CompositeRouter(adapters, resolved,
|
|
14861
|
+
return new CompositeRouter(adapters, resolved, logger15);
|
|
14836
14862
|
}
|
|
14837
14863
|
|
|
14838
14864
|
// src/core/types/model.ts
|
|
@@ -14887,7 +14913,7 @@ import { dirname as dirname5 } from "path";
|
|
|
14887
14913
|
import { mkdirSync as mkdirSync3 } from "fs";
|
|
14888
14914
|
|
|
14889
14915
|
// src/context/mobimem-types.ts
|
|
14890
|
-
import { z as
|
|
14916
|
+
import { z as z21 } from "zod";
|
|
14891
14917
|
var DEFAULT_MOBIMEM_CONFIG = {
|
|
14892
14918
|
dbPath: ":memory:",
|
|
14893
14919
|
maxProfileEntries: 100,
|
|
@@ -14899,15 +14925,15 @@ var DEFAULT_MOBIMEM_CONFIG = {
|
|
|
14899
14925
|
minExperienceSuccessRate: 0.7,
|
|
14900
14926
|
autoEviction: true
|
|
14901
14927
|
};
|
|
14902
|
-
var MobiMemConfigSchema =
|
|
14903
|
-
dbPath:
|
|
14904
|
-
maxProfileEntries:
|
|
14905
|
-
maxExperiencePatterns:
|
|
14906
|
-
maxActionCacheEntries:
|
|
14907
|
-
actionCacheTtlMs:
|
|
14908
|
-
minProfileConfidence:
|
|
14909
|
-
minExperienceSuccessRate:
|
|
14910
|
-
autoEviction:
|
|
14928
|
+
var MobiMemConfigSchema = z21.object({
|
|
14929
|
+
dbPath: z21.string(),
|
|
14930
|
+
maxProfileEntries: z21.number().int().positive().default(100),
|
|
14931
|
+
maxExperiencePatterns: z21.number().int().positive().default(500),
|
|
14932
|
+
maxActionCacheEntries: z21.number().int().positive().default(1e3),
|
|
14933
|
+
actionCacheTtlMs: z21.number().int().positive().default(36e5),
|
|
14934
|
+
minProfileConfidence: z21.number().min(0).max(1).default(0.6),
|
|
14935
|
+
minExperienceSuccessRate: z21.number().min(0).max(1).default(0.7),
|
|
14936
|
+
autoEviction: z21.boolean().default(true)
|
|
14911
14937
|
});
|
|
14912
14938
|
|
|
14913
14939
|
// src/context/mobimem-impl.ts
|
|
@@ -15362,7 +15388,7 @@ var ActionCacheImpl = class {
|
|
|
15362
15388
|
};
|
|
15363
15389
|
|
|
15364
15390
|
// src/context/mobimem.ts
|
|
15365
|
-
var
|
|
15391
|
+
var logger14 = createLogger({ component: "MobiMem" });
|
|
15366
15392
|
var MobiMem = class {
|
|
15367
15393
|
profile;
|
|
15368
15394
|
experience;
|
|
@@ -15383,7 +15409,7 @@ var MobiMem = class {
|
|
|
15383
15409
|
this.profile = new ProfileMemoryImpl(this.config, this.db);
|
|
15384
15410
|
this.experience = new ExperienceMemoryImpl(this.config, this.db);
|
|
15385
15411
|
this.action = new ActionCacheImpl(this.config, this.db);
|
|
15386
|
-
|
|
15412
|
+
logger14.info("MobiMem initialized", {
|
|
15387
15413
|
dbPath: validated.dbPath,
|
|
15388
15414
|
persisted: this.db !== null,
|
|
15389
15415
|
maxProfileEntries: this.config.maxProfileEntries,
|
|
@@ -15416,13 +15442,13 @@ var MobiMem = class {
|
|
|
15416
15442
|
if (this.config.autoEviction) {
|
|
15417
15443
|
const evicted = this.action.evictExpired();
|
|
15418
15444
|
if (evicted > 0) {
|
|
15419
|
-
|
|
15445
|
+
logger14.debug("Evicted expired action cache entries", { count: evicted });
|
|
15420
15446
|
}
|
|
15421
15447
|
}
|
|
15422
15448
|
}
|
|
15423
15449
|
close() {
|
|
15424
15450
|
if (this.db !== null) this.db.close();
|
|
15425
|
-
|
|
15451
|
+
logger14.info("MobiMem closed");
|
|
15426
15452
|
}
|
|
15427
15453
|
};
|
|
15428
15454
|
var sharedInstance = null;
|
|
@@ -15973,4 +15999,4 @@ export {
|
|
|
15973
15999
|
AgentCapability,
|
|
15974
16000
|
OrchestratorError
|
|
15975
16001
|
};
|
|
15976
|
-
//# sourceMappingURL=chunk-
|
|
16002
|
+
//# sourceMappingURL=chunk-Y5JA7XEO.js.map
|