nexus-agents 6.1.5 → 6.2.1
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-4DDBRYPA.js → child-mcp-config-GM2RNTZL.js} +2 -2
- package/dist/{chunk-CL4TF6YT.js → chunk-2CZP5HI3.js} +2 -2
- package/dist/{chunk-XZHGPNSB.js → chunk-2QKZC2TZ.js} +4 -4
- package/dist/{chunk-YYCQ5G3K.js → chunk-56FMLTYA.js} +2 -2
- package/dist/{chunk-I7VQGYLE.js → chunk-5TQC5ZT3.js} +2 -2
- package/dist/{chunk-BIOAMDHR.js → chunk-62BXAKN4.js} +2 -2
- package/dist/{chunk-6U2OC56L.js → chunk-76E4SZ55.js} +3 -3
- package/dist/{chunk-R2QMJAUF.js → chunk-7EXGLORM.js} +4 -4
- package/dist/{chunk-R2QMJAUF.js.map → chunk-7EXGLORM.js.map} +1 -1
- package/dist/{chunk-QNXB6PVL.js → chunk-A337QC7T.js} +2 -2
- package/dist/{chunk-RGK3N3UN.js → chunk-B5BCAZ67.js} +3 -3
- package/dist/chunk-B5BCAZ67.js.map +1 -0
- package/dist/{chunk-K3P5KQXZ.js → chunk-B7OSEC65.js} +2 -2
- package/dist/{chunk-KQYXPAFQ.js → chunk-BBROWRNT.js} +2 -2
- package/dist/{chunk-QDRH7QJD.js → chunk-BEVDHBLV.js} +8 -8
- package/dist/{chunk-QDRH7QJD.js.map → chunk-BEVDHBLV.js.map} +1 -1
- package/dist/chunk-C364WBYN.js +7 -0
- package/dist/{chunk-ETEKZ4RK.js → chunk-CWEAD5L5.js} +2 -2
- package/dist/{chunk-62JZZXZA.js → chunk-F7YLKM2N.js} +2 -2
- package/dist/{chunk-BSUATLSL.js → chunk-FJPF6NUY.js} +2 -2
- package/dist/{chunk-MGXRJZUQ.js → chunk-J2WPQTXB.js} +2 -2
- package/dist/{chunk-2PEHRCZ2.js → chunk-L4TNK5EV.js} +3 -3
- package/dist/{chunk-LQOANCSX.js → chunk-LWDEI43X.js} +2 -2
- package/dist/{chunk-RGLSWWTT.js → chunk-LWDMTCTS.js} +5 -5
- package/dist/{chunk-5OISEA34.js → chunk-NGRUMP7Q.js} +5 -5
- package/dist/{chunk-JI4VNHV5.js → chunk-OIHHLQCQ.js} +35 -35
- package/dist/{chunk-JI4VNHV5.js.map → chunk-OIHHLQCQ.js.map} +1 -1
- package/dist/{chunk-OBCBF2AI.js → chunk-OTNFLBKH.js} +6 -6
- package/dist/{chunk-3NCBSBSA.js → chunk-P2KRXJI7.js} +2 -2
- package/dist/{chunk-3B5746AG.js → chunk-PYSJGQW3.js} +2 -2
- package/dist/{chunk-3N3HTDAK.js → chunk-Q7FAI4JO.js} +2 -2
- package/dist/{chunk-XKHFPXIP.js → chunk-SMYCLSH6.js} +4 -4
- package/dist/{chunk-GHD3CUV7.js → chunk-UDOFXNIG.js} +7 -7
- package/dist/chunk-UDOFXNIG.js.map +1 -0
- package/dist/{chunk-RPXCZLC7.js → chunk-UI5JIET2.js} +4 -4
- package/dist/{chunk-DDCKXILN.js → chunk-UYNAJJQR.js} +2 -2
- package/dist/{chunk-JPEXSNOX.js → chunk-VECTXFPX.js} +52 -9
- package/dist/chunk-VECTXFPX.js.map +1 -0
- package/dist/{chunk-F4K63ZYW.js → chunk-Z7OXB43V.js} +7 -7
- package/dist/{chunk-6D5BIVED.js → chunk-ZA5F5ESS.js} +3 -3
- package/dist/{cli-circuit-breaker-EZYSMS5J.js → cli-circuit-breaker-DW7LLHDL.js} +3 -3
- package/dist/cli.js +41 -41
- package/dist/{composite-router-4MX77KAO.js → composite-router-4MOMC7ON.js} +2 -2
- package/dist/{consensus-vote-4FIT5MTP.js → consensus-vote-B4V5F3LW.js} +17 -17
- package/dist/{context-retriever-XQXSR7X2.js → context-retriever-3HRRVJPX.js} +8 -8
- package/dist/{doctor-deep-LTNNWX2R.js → doctor-deep-ADQSW3RD.js} +3 -3
- package/dist/{doctor-live-S3EP4CDZ.js → doctor-live-LYCZPZ6R.js} +9 -9
- package/dist/{expert-bridge-3EHBG44P.js → expert-bridge-7H5ZRUQQ.js} +4 -4
- package/dist/{factory-5EQYMH5L.js → factory-7OHJ6VO6.js} +5 -5
- package/dist/{factory-I7V3JB6F.js → factory-ABM4AGFY.js} +9 -9
- package/dist/{improvement-review-7GAHAZYK.js → improvement-review-GCW3UXQP.js} +6 -6
- package/dist/index.d.ts +46 -4
- package/dist/index.js +31 -31
- package/dist/index.js.map +1 -1
- package/dist/{init-opencode-CX5YQG7X.js → init-opencode-ZF56EXKA.js} +6 -6
- package/dist/issue-triage-JCPJ27PG.js +17 -0
- package/dist/{pr-reviewer-helpers-BVQYKJQC.js → pr-reviewer-helpers-TZXSQZS7.js} +4 -4
- package/dist/{registry-command-AM4NCHY6.js → registry-command-QFGRDD2U.js} +2 -2
- package/dist/{repo-security-plan-4LB6D3NE.js → repo-security-plan-CMAAJI2S.js} +3 -3
- package/dist/{research-helpers-synthesize-R3NHYY7G.js → research-helpers-synthesize-M5BOALWE.js} +4 -4
- package/dist/{routing-memory-UFJLIHRW.js → routing-memory-A3YJZSFO.js} +2 -2
- package/dist/{session-memory-47LD45HS.js → session-memory-PHJHGRRQ.js} +3 -3
- package/dist/{setup-config-CZ4ATPBX.js → setup-config-QTUVOUZ4.js} +3 -3
- package/dist/{setup-custom-api-7W5AHZVX.js → setup-custom-api-FBTU6BYC.js} +4 -4
- package/dist/setup-data-dir-QH5D7IYY.js +29 -0
- package/dist/{tool-memory-FTLUCKZI.js → tool-memory-BL6YZ7WW.js} +5 -5
- package/dist/{unified-registry-GBD77P3U.js → unified-registry-HVXWIHRL.js} +10 -10
- package/dist/{weather-report-C6HWZL3B.js → weather-report-CVPWMDQF.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-GHD3CUV7.js.map +0 -1
- package/dist/chunk-JPEXSNOX.js.map +0 -1
- package/dist/chunk-KXHJA6WM.js +0 -7
- package/dist/chunk-RGK3N3UN.js.map +0 -1
- package/dist/issue-triage-FQXZ2UCS.js +0 -17
- package/dist/setup-data-dir-24U27GCS.js +0 -29
- /package/dist/{child-mcp-config-4DDBRYPA.js.map → child-mcp-config-GM2RNTZL.js.map} +0 -0
- /package/dist/{chunk-CL4TF6YT.js.map → chunk-2CZP5HI3.js.map} +0 -0
- /package/dist/{chunk-XZHGPNSB.js.map → chunk-2QKZC2TZ.js.map} +0 -0
- /package/dist/{chunk-YYCQ5G3K.js.map → chunk-56FMLTYA.js.map} +0 -0
- /package/dist/{chunk-I7VQGYLE.js.map → chunk-5TQC5ZT3.js.map} +0 -0
- /package/dist/{chunk-BIOAMDHR.js.map → chunk-62BXAKN4.js.map} +0 -0
- /package/dist/{chunk-6U2OC56L.js.map → chunk-76E4SZ55.js.map} +0 -0
- /package/dist/{chunk-QNXB6PVL.js.map → chunk-A337QC7T.js.map} +0 -0
- /package/dist/{chunk-K3P5KQXZ.js.map → chunk-B7OSEC65.js.map} +0 -0
- /package/dist/{chunk-KQYXPAFQ.js.map → chunk-BBROWRNT.js.map} +0 -0
- /package/dist/{chunk-KXHJA6WM.js.map → chunk-C364WBYN.js.map} +0 -0
- /package/dist/{chunk-ETEKZ4RK.js.map → chunk-CWEAD5L5.js.map} +0 -0
- /package/dist/{chunk-62JZZXZA.js.map → chunk-F7YLKM2N.js.map} +0 -0
- /package/dist/{chunk-BSUATLSL.js.map → chunk-FJPF6NUY.js.map} +0 -0
- /package/dist/{chunk-MGXRJZUQ.js.map → chunk-J2WPQTXB.js.map} +0 -0
- /package/dist/{chunk-2PEHRCZ2.js.map → chunk-L4TNK5EV.js.map} +0 -0
- /package/dist/{chunk-LQOANCSX.js.map → chunk-LWDEI43X.js.map} +0 -0
- /package/dist/{chunk-RGLSWWTT.js.map → chunk-LWDMTCTS.js.map} +0 -0
- /package/dist/{chunk-5OISEA34.js.map → chunk-NGRUMP7Q.js.map} +0 -0
- /package/dist/{chunk-OBCBF2AI.js.map → chunk-OTNFLBKH.js.map} +0 -0
- /package/dist/{chunk-3NCBSBSA.js.map → chunk-P2KRXJI7.js.map} +0 -0
- /package/dist/{chunk-3B5746AG.js.map → chunk-PYSJGQW3.js.map} +0 -0
- /package/dist/{chunk-3N3HTDAK.js.map → chunk-Q7FAI4JO.js.map} +0 -0
- /package/dist/{chunk-XKHFPXIP.js.map → chunk-SMYCLSH6.js.map} +0 -0
- /package/dist/{chunk-RPXCZLC7.js.map → chunk-UI5JIET2.js.map} +0 -0
- /package/dist/{chunk-DDCKXILN.js.map → chunk-UYNAJJQR.js.map} +0 -0
- /package/dist/{chunk-F4K63ZYW.js.map → chunk-Z7OXB43V.js.map} +0 -0
- /package/dist/{chunk-6D5BIVED.js.map → chunk-ZA5F5ESS.js.map} +0 -0
- /package/dist/{cli-circuit-breaker-EZYSMS5J.js.map → cli-circuit-breaker-DW7LLHDL.js.map} +0 -0
- /package/dist/{composite-router-4MX77KAO.js.map → composite-router-4MOMC7ON.js.map} +0 -0
- /package/dist/{consensus-vote-4FIT5MTP.js.map → consensus-vote-B4V5F3LW.js.map} +0 -0
- /package/dist/{context-retriever-XQXSR7X2.js.map → context-retriever-3HRRVJPX.js.map} +0 -0
- /package/dist/{doctor-deep-LTNNWX2R.js.map → doctor-deep-ADQSW3RD.js.map} +0 -0
- /package/dist/{doctor-live-S3EP4CDZ.js.map → doctor-live-LYCZPZ6R.js.map} +0 -0
- /package/dist/{expert-bridge-3EHBG44P.js.map → expert-bridge-7H5ZRUQQ.js.map} +0 -0
- /package/dist/{factory-5EQYMH5L.js.map → factory-7OHJ6VO6.js.map} +0 -0
- /package/dist/{factory-I7V3JB6F.js.map → factory-ABM4AGFY.js.map} +0 -0
- /package/dist/{improvement-review-7GAHAZYK.js.map → improvement-review-GCW3UXQP.js.map} +0 -0
- /package/dist/{init-opencode-CX5YQG7X.js.map → init-opencode-ZF56EXKA.js.map} +0 -0
- /package/dist/{issue-triage-FQXZ2UCS.js.map → issue-triage-JCPJ27PG.js.map} +0 -0
- /package/dist/{pr-reviewer-helpers-BVQYKJQC.js.map → pr-reviewer-helpers-TZXSQZS7.js.map} +0 -0
- /package/dist/{registry-command-AM4NCHY6.js.map → registry-command-QFGRDD2U.js.map} +0 -0
- /package/dist/{repo-security-plan-4LB6D3NE.js.map → repo-security-plan-CMAAJI2S.js.map} +0 -0
- /package/dist/{research-helpers-synthesize-R3NHYY7G.js.map → research-helpers-synthesize-M5BOALWE.js.map} +0 -0
- /package/dist/{routing-memory-UFJLIHRW.js.map → routing-memory-A3YJZSFO.js.map} +0 -0
- /package/dist/{session-memory-47LD45HS.js.map → session-memory-PHJHGRRQ.js.map} +0 -0
- /package/dist/{setup-config-CZ4ATPBX.js.map → setup-config-QTUVOUZ4.js.map} +0 -0
- /package/dist/{setup-custom-api-7W5AHZVX.js.map → setup-custom-api-FBTU6BYC.js.map} +0 -0
- /package/dist/{setup-data-dir-24U27GCS.js.map → setup-data-dir-QH5D7IYY.js.map} +0 -0
- /package/dist/{tool-memory-FTLUCKZI.js.map → tool-memory-BL6YZ7WW.js.map} +0 -0
- /package/dist/{unified-registry-GBD77P3U.js.map → unified-registry-HVXWIHRL.js.map} +0 -0
- /package/dist/{weather-report-C6HWZL3B.js.map → weather-report-CVPWMDQF.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
GitHubProvider,
|
|
3
3
|
ScmError
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-FJPF6NUY.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-A337QC7T.js";
|
|
15
15
|
import {
|
|
16
16
|
emitPolicyEvent
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-J2WPQTXB.js";
|
|
18
18
|
import {
|
|
19
19
|
hasToken
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-Q7FAI4JO.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-B5BCAZ67.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-OTNFLBKH.js.map
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
lookupInTreeCapability,
|
|
14
14
|
ok,
|
|
15
15
|
resolveRetryAfterMs
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-B5BCAZ67.js";
|
|
17
17
|
|
|
18
18
|
// src/config/model-parameter-support.ts
|
|
19
19
|
function parseClaudeMajorMinor(bareId) {
|
|
@@ -834,4 +834,4 @@ export {
|
|
|
834
834
|
DEFAULT_COLLECT_STREAM_MAX_CHUNKS,
|
|
835
835
|
collectStream
|
|
836
836
|
};
|
|
837
|
-
//# sourceMappingURL=chunk-
|
|
837
|
+
//# sourceMappingURL=chunk-P2KRXJI7.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
createLogger,
|
|
4
4
|
err,
|
|
5
5
|
ok
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-B5BCAZ67.js";
|
|
7
7
|
|
|
8
8
|
// src/adapters/sdk/types.ts
|
|
9
9
|
var PROVIDER_ENV_KEYS = {
|
|
@@ -260,4 +260,4 @@ export {
|
|
|
260
260
|
validateCustomApiBaseUrl,
|
|
261
261
|
assertCustomApiHostResolvesPublic
|
|
262
262
|
};
|
|
263
|
-
//# sourceMappingURL=chunk-
|
|
263
|
+
//# sourceMappingURL=chunk-PYSJGQW3.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
createLogger,
|
|
3
3
|
err,
|
|
4
4
|
ok
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-B5BCAZ67.js";
|
|
6
6
|
|
|
7
7
|
// src/scm/token-resolver.ts
|
|
8
8
|
import { execFile } from "child_process";
|
|
@@ -87,4 +87,4 @@ export {
|
|
|
87
87
|
hasToken,
|
|
88
88
|
getTokenEnvVars
|
|
89
89
|
};
|
|
90
|
-
//# sourceMappingURL=chunk-
|
|
90
|
+
//# sourceMappingURL=chunk-Q7FAI4JO.js.map
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from "./chunk-6T3EPABN.js";
|
|
6
6
|
import {
|
|
7
7
|
SessionMemory
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-CWEAD5L5.js";
|
|
9
9
|
import {
|
|
10
10
|
StatsOnlyAdapter,
|
|
11
11
|
ensureSharedMemoryRegistry
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from "./chunk-KSQSWEFH.js";
|
|
16
16
|
import {
|
|
17
17
|
generateId
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-F7YLKM2N.js";
|
|
19
19
|
import {
|
|
20
20
|
ErrorCode,
|
|
21
21
|
NexusError,
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
getTimeProvider,
|
|
29
29
|
ok,
|
|
30
30
|
setSharedMobiMemDbPathResolver
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-B5BCAZ67.js";
|
|
32
32
|
import {
|
|
33
33
|
nexusDataPath
|
|
34
34
|
} from "./chunk-OGHEKPLD.js";
|
|
@@ -5622,4 +5622,4 @@ export {
|
|
|
5622
5622
|
reinitializeMemoryBackends,
|
|
5623
5623
|
ToolMemoryManager
|
|
5624
5624
|
};
|
|
5625
|
-
//# sourceMappingURL=chunk-
|
|
5625
|
+
//# sourceMappingURL=chunk-SMYCLSH6.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveCliSlot
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-2CZP5HI3.js";
|
|
4
4
|
import {
|
|
5
5
|
createLogger,
|
|
6
6
|
getTimeProvider,
|
|
7
7
|
isRateLimitText
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-B5BCAZ67.js";
|
|
9
9
|
|
|
10
10
|
// src/pipeline/expert-bridge.ts
|
|
11
11
|
function resolveCliFromModelString(model) {
|
|
@@ -21,7 +21,7 @@ async function getMcpConfigPath() {
|
|
|
21
21
|
if (cachedMcpConfigPath !== null) return cachedMcpConfigPath;
|
|
22
22
|
mcpConfigInitPromise ??= (async () => {
|
|
23
23
|
try {
|
|
24
|
-
const { generateMcpConfig } = await import("./child-mcp-config-
|
|
24
|
+
const { generateMcpConfig } = await import("./child-mcp-config-GM2RNTZL.js");
|
|
25
25
|
const config = await generateMcpConfig();
|
|
26
26
|
cachedMcpConfigPath = config.configPath;
|
|
27
27
|
cachedMcpConfigCleanup = config.cleanup;
|
|
@@ -93,8 +93,8 @@ var routerInitPromise = null;
|
|
|
93
93
|
async function getRouter() {
|
|
94
94
|
if (cachedRouter !== null) return cachedRouter;
|
|
95
95
|
routerInitPromise ??= (async () => {
|
|
96
|
-
const { createAllAdapters } = await import("./factory-
|
|
97
|
-
const { createCompositeRouter } = await import("./composite-router-
|
|
96
|
+
const { createAllAdapters } = await import("./factory-ABM4AGFY.js");
|
|
97
|
+
const { createCompositeRouter } = await import("./composite-router-4MOMC7ON.js");
|
|
98
98
|
const adapters = createAllAdapters();
|
|
99
99
|
if (adapters.size === 0) {
|
|
100
100
|
routerInitPromise = null;
|
|
@@ -102,7 +102,7 @@ async function getRouter() {
|
|
|
102
102
|
}
|
|
103
103
|
cachedRouter = adaptCompositeRouter(createCompositeRouter(adapters));
|
|
104
104
|
try {
|
|
105
|
-
const { createCliCircuitBreakerIntegration } = await import("./cli-circuit-breaker-
|
|
105
|
+
const { createCliCircuitBreakerIntegration } = await import("./cli-circuit-breaker-DW7LLHDL.js");
|
|
106
106
|
cachedCircuitBreaker = createCliCircuitBreakerIntegration([...adapters.values()]);
|
|
107
107
|
} catch (error) {
|
|
108
108
|
const msg = error instanceof Error ? error.message : String(error);
|
|
@@ -213,4 +213,4 @@ export {
|
|
|
213
213
|
tokenSplitFromUsage,
|
|
214
214
|
executeExpert
|
|
215
215
|
};
|
|
216
|
-
//# sourceMappingURL=chunk-
|
|
216
|
+
//# sourceMappingURL=chunk-UDOFXNIG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/pipeline/expert-bridge.ts"],"sourcesContent":["/**\n * Expert Bridge — Programmatic access to the execute_expert pipeline (#1693)\n *\n * Provides a clean wrapper for calling experts with the full pipeline:\n * timeout, fallback cascade, degradation detection, heartbeat, outcome recording.\n *\n * DRY: reuses createBuiltInExpert + CompositeRouter instead of reimplementing.\n *\n * @module pipeline/expert-bridge\n */\n\nimport { createLogger, getTimeProvider } from '../core/index.js';\nimport type { BuiltInExpertType } from '../agents/experts/expert-config.js';\nimport { isRateLimitText } from '../adapters/rate-limit-detector.js';\nimport { resolveCliSlot } from '../config/model-availability.js';\nimport type { CliNameLiteral } from '../config/model-capabilities-types.js';\n\n/**\n * Resolves a CLI slot from the model string a (CLI or API) adapter returned.\n * Known models resolve to their exact slot; **unknown** models — new releases\n * or API/openrouter models not in the curated registry — fall back to the\n * vendor-derived slot (#3317 / #3293) so the outcome is recorded against a real\n * slot instead of being dropped with an undefined cli (the api-mode gap).\n * Returns undefined only when no model is present (the bridge failed before\n * dispatch — no execution to attribute).\n */\nfunction resolveCliFromModelString(model: string | undefined): CliNameLiteral | undefined {\n return resolveCliSlot(model);\n}\n\nconst logger = createLogger({ component: 'expert-bridge' });\n\n/** Base delay for rate limit retry backoff (ms). Scales linearly: 3s, 6s, 9s. */\nconst RATE_LIMIT_BASE_DELAY_MS = 3000;\n\n/** Result of an expert execution. */\nexport interface ExpertBridgeResult {\n readonly success: boolean;\n readonly text: string;\n readonly expertType: BuiltInExpertType;\n readonly durationMs: number;\n readonly error?: string;\n /**\n * CLI that actually executed the task, resolved from the underlying\n * `CliResponse.model` via `getCliForModelId`. Undefined when the bridge\n * failed before dispatch (no adapters / circuit-open / rate-limit cap).\n * Callers writing to OutcomeStore should use this rather than hardcoding\n * a cli — see #2823 (#1154 regression).\n */\n readonly cli?: CliNameLiteral;\n /**\n * Total tokens (input + output) the underlying CLI/adapter reported for this\n * call, when available (#3396). Best-effort: `CliResponse.usage` is optional\n * — CLI-subprocess paths whose `extractUsage` returns null leave this\n * undefined. Consumers (budget enforcement #3395, model.called attribution\n * #3387, routing-experience metrics) must tolerate `undefined`.\n */\n readonly tokensUsed?: number;\n /**\n * Concrete model id the underlying adapter reported (`CliResponse.model`),\n * when present (#3387). Distinct from {@link cli} (the slot): one CLI can run\n * several models. Undefined when the adapter didn't report a model or the\n * bridge failed before dispatch. Required to emit a `model.called` event.\n */\n readonly model?: string;\n /**\n * Input/output token split from the adapter's `CliResponse.usage` (#3387),\n * when reported. Best-effort like {@link tokensUsed}; both undefined together\n * when no usage was available. `tokensIn + tokensOut` reconciles with\n * `tokensUsed` (single source of truth — both derive from the same record).\n */\n readonly tokensIn?: number;\n readonly tokensOut?: number;\n}\n\n/** Minimal router interface for the bridge. */\ninterface RouterLike {\n executeTask(task: { content: string; options?: Record<string, unknown> | undefined }): Promise<{\n ok: boolean;\n value: {\n text: string;\n cli?: CliNameLiteral;\n tokensUsed?: number;\n model?: string;\n tokensIn?: number;\n tokensOut?: number;\n };\n error: { message: string };\n }>;\n}\n\n// Cached router — lazily initialized, reused across calls within a session\nlet cachedRouter: RouterLike | null = null;\n\n// Cached MCP config — generated once, reused across expert calls (#1708)\nlet cachedMcpConfigPath: string | null = null;\n// Cached cleanup for the cached config's tempdir (closes #2946). Previously\n// the cleanup returned by `generateMcpConfig` was thrown away, so\n// `/tmp/nexus-mcp-XXXXXX/` accumulated one entry per MCP server lifetime.\n// Stored here + invoked by `shutdownExpertBridge()` from the server's\n// graceful-shutdown path.\nlet cachedMcpConfigCleanup: (() => Promise<void>) | null = null;\n// Coalesces concurrent init under voter fan-out (closes #2969). consensus_vote\n// fans out N=7 callers on cold start; without this each one ran the full init\n// including a mkdtemp() that the loser N-1 instances never cleaned up.\nlet mcpConfigInitPromise: Promise<string | null> | null = null;\n\n/** Get or create cached MCP config path for expert CLI sessions (#1708). */\nasync function getMcpConfigPath(): Promise<string | null> {\n if (cachedMcpConfigPath !== null) return cachedMcpConfigPath;\n mcpConfigInitPromise ??= (async (): Promise<string | null> => {\n try {\n const { generateMcpConfig } = await import('../cli-adapters/child-mcp-config.js');\n const config = await generateMcpConfig();\n cachedMcpConfigPath = config.configPath;\n cachedMcpConfigCleanup = config.cleanup;\n return cachedMcpConfigPath;\n } catch {\n mcpConfigInitPromise = null; // allow retry on next call\n return null; // MCP config not available — experts run without tools\n }\n })();\n return mcpConfigInitPromise;\n}\n\n/**\n * Removes the cached MCP-config tempdir (closes #2946). Invoke from the\n * server's graceful-shutdown path so stale nexus-mcp-* tempdirs (under\n * the OS tmpdir, see child-mcp-config.ts) don't accumulate across daemon\n * restarts. Idempotent; safe to call multiple times. Never throws —\n * cleanup failures are logged and swallowed.\n */\nexport async function shutdownExpertBridge(): Promise<void> {\n const cleanup = cachedMcpConfigCleanup;\n if (cleanup === null) return;\n cachedMcpConfigCleanup = null;\n cachedMcpConfigPath = null;\n mcpConfigInitPromise = null;\n try {\n await cleanup();\n } catch (error: unknown) {\n const msg = error instanceof Error ? error.message : String(error);\n logger.debug('Expert-bridge MCP-config cleanup failed', { error: msg });\n }\n}\n\n/** Cached circuit breaker for health monitoring (#1766). */\nlet cachedCircuitBreaker: {\n getHealthStatus(): {\n systemHealthy: boolean;\n healthyCount: number;\n clis: ReadonlyArray<{ name: string; healthy: boolean }>;\n };\n} | null = null;\n\n/**\n * Adapt a CompositeRouter to the narrower RouterLike interface used by this\n * bridge. Previously did `as unknown as RouterLike` which hid any structural\n * mismatch between CompositeRouter's `Result<CliResponse, CliError>` and\n * RouterLike's flat `{ ok, value: { text }, error: { message } }` shape.\n * If CliResponse renames `.text` → `.output` (or similar), this adapter\n * breaks at compile time instead of silently returning wrong data (#1921).\n */\n/**\n * Total tokens from a best-effort `CliResponse.usage` record (#3396). Prefers\n * the reported `totalTokens`; falls back to input+output; returns undefined\n * when no usage was reported (so callers can distinguish \"0 tokens\" — which\n * never happens for a real call — from \"unknown\").\n */\nexport function totalTokensFromUsage(\n usage: { totalTokens?: number; inputTokens?: number; outputTokens?: number } | undefined\n): number | undefined {\n if (usage === undefined) return undefined;\n if (typeof usage.totalTokens === 'number') return usage.totalTokens;\n const total = (usage.inputTokens ?? 0) + (usage.outputTokens ?? 0);\n return total > 0 ? total : undefined;\n}\n\n/**\n * Per-direction token split from a best-effort `CliResponse.usage` record\n * (#3387). Unlike {@link totalTokensFromUsage} this keeps `tokensIn`/`tokensOut`\n * separate — the granularity `ModelCalledEvent` requires for attribution.\n * Returns undefined when no usage was reported or both directions are zero (no\n * real call), so callers skip emitting a noise event instead of recording\n * zeros. Reconciles with the total: `tokensIn + tokensOut === totalTokensFromUsage`.\n */\nexport function tokenSplitFromUsage(\n usage: { inputTokens?: number; outputTokens?: number; totalTokens?: number } | undefined\n): { tokensIn: number; tokensOut: number } | undefined {\n if (usage === undefined) return undefined;\n const tokensIn = usage.inputTokens ?? 0;\n const tokensOut = usage.outputTokens ?? 0;\n if (tokensIn + tokensOut === 0) return undefined;\n return { tokensIn, tokensOut };\n}\n\nfunction adaptCompositeRouter(\n compositeRouter: import('../cli-adapters/composite-router.js').ICompositeRouter\n): RouterLike {\n return {\n async executeTask(task): Promise<{\n ok: boolean;\n value: {\n text: string;\n cli?: CliNameLiteral;\n tokensUsed?: number;\n model?: string;\n tokensIn?: number;\n tokensOut?: number;\n };\n error: { message: string };\n }> {\n const cliTask: import('../cli-adapters/types.js').CliTask = {\n content: task.content,\n ...(task.options !== undefined ? { options: task.options } : {}),\n };\n const result = await compositeRouter.executeTask(cliTask);\n if (result.ok) {\n // #2823: surface which CLI actually executed so callers writing to\n // OutcomeStore don't have to hardcode 'claude' (the bug #1154 fixed\n // and that regressed into the pipeline/ tree). Derive via the\n // canonical model→cli mapping in the registry — if the underlying\n // adapter didn't set `model` or the model isn't in the registry,\n // cli stays undefined and downstream code can skip the record\n // rather than lie.\n const cli = resolveCliFromModelString(result.value.model);\n // #3396: surface token usage (best-effort) so budget enforcement,\n // attribution, and routing-experience metrics get real numbers instead\n // of zeros. `usage` is optional and `totalTokens` may be absent — fall\n // back to input+output, and leave undefined when no usage was reported.\n const tokensUsed = totalTokensFromUsage(result.value.usage);\n // #3387: also surface the concrete model + per-direction token split so\n // a meaningful `model.called` event can be emitted. Both derive from the\n // same CliResponse, so tokensIn+tokensOut reconciles with tokensUsed.\n const model = result.value.model;\n const split = tokenSplitFromUsage(result.value.usage);\n return {\n ok: true,\n value: {\n text: result.value.text,\n ...(cli !== undefined && { cli }),\n ...(tokensUsed !== undefined && { tokensUsed }),\n ...(model !== undefined && { model }),\n ...(split !== undefined && { tokensIn: split.tokensIn, tokensOut: split.tokensOut }),\n },\n error: { message: '' },\n };\n }\n return { ok: false, value: { text: '' }, error: { message: result.error.message } };\n },\n };\n}\n\n// Coalesces concurrent router init the same way mcpConfigInitPromise does\n// (closes #2969). N=7 voter fan-out previously ran createAllAdapters() N times\n// — N sets of CLI probe subprocesses, all but one discarded.\nlet routerInitPromise: Promise<RouterLike | null> | null = null;\n\n/** Get or create a cached CompositeRouter with circuit breaker monitoring. */\nasync function getRouter(): Promise<RouterLike | null> {\n if (cachedRouter !== null) return cachedRouter;\n routerInitPromise ??= (async (): Promise<RouterLike | null> => {\n // ROUTER CONSTRUCTION, a distinct operation from adapter acquisition\n // (#5191, ratified 5/6). `createCompositeRouter` needs\n // `Map<RoutingArmId, ICliAdapter>`; `getGlobalRegistry()` returns\n // `IResilientAdapter` (extends `IModelAdapter`) one CLI at a time, so the\n // canonical path cannot type-check here.\n //\n // It also should not be used: the router IS the selection/failover layer,\n // so resilient-wrapped arms would nest two failover mechanisms, and the\n // shared circuit breaker would make an arm report unavailable without the\n // router ever testing it. That is the doctor-probe defect (#5209) applied\n // to routing — and this map is the LinUCB arm space, so a coupled arm\n // availability would distort exploration signals.\n //\n // Pinned by `router-operation.test.ts`.\n const { createAllAdapters } = await import('../cli-adapters/factory.js');\n const { createCompositeRouter } = await import('../cli-adapters/composite-router.js');\n const adapters = createAllAdapters();\n if (adapters.size === 0) {\n routerInitPromise = null; // allow retry once adapters become available\n return null;\n }\n cachedRouter = adaptCompositeRouter(createCompositeRouter(adapters));\n\n // Initialize circuit breaker monitoring (#1766)\n try {\n const { createCliCircuitBreakerIntegration } =\n await import('../cli-adapters/cli-circuit-breaker.js');\n cachedCircuitBreaker = createCliCircuitBreakerIntegration([...adapters.values()]);\n } catch (error: unknown) {\n // Circuit breaker not available — continue without it. Log so we can\n // notice if initialization silently stops working (#1913 Class B).\n const msg = error instanceof Error ? error.message : String(error);\n logger.debug('Circuit breaker init failed; continuing without it', { error: msg });\n }\n\n return cachedRouter;\n })();\n return routerInitPromise;\n}\n\n/** Check CLI health before dispatch (#1766). */\nfunction checkCircuitHealth(): { healthy: boolean; message: string } {\n if (cachedCircuitBreaker === null) return { healthy: true, message: '' };\n const status = cachedCircuitBreaker.getHealthStatus();\n if (!status.systemHealthy) {\n return {\n healthy: false,\n message: `All CLI circuits open (${String(status.healthyCount)}/${String(status.clis.length)} healthy)`,\n };\n }\n return { healthy: true, message: '' };\n}\n\n/** Dispatch task to router with rate limit retry (#1802). */\nasync function dispatchWithRateLimitRetry(\n router: RouterLike,\n task: { content: string; options?: Record<string, unknown> | undefined },\n expertType: BuiltInExpertType,\n start: number\n): Promise<ExpertBridgeResult> {\n const maxAttempts = 3;\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n const result = await router.executeTask(task);\n const durationMs = getTimeProvider().now() - start;\n\n if (result.ok) {\n logger.info('Expert executed successfully', {\n expertType,\n durationMs,\n cli: result.value.cli,\n });\n return {\n success: true,\n text: result.value.text,\n expertType,\n durationMs,\n ...(result.value.cli !== undefined && { cli: result.value.cli }),\n ...(result.value.tokensUsed !== undefined && { tokensUsed: result.value.tokensUsed }),\n ...(result.value.model !== undefined && { model: result.value.model }),\n ...(result.value.tokensIn !== undefined && { tokensIn: result.value.tokensIn }),\n ...(result.value.tokensOut !== undefined && { tokensOut: result.value.tokensOut }),\n };\n }\n\n const isRateLimit = isRateLimitText(result.error.message);\n if (isRateLimit && attempt < maxAttempts - 1) {\n const backoffMs = RATE_LIMIT_BASE_DELAY_MS * (attempt + 1);\n logger.warn('Expert rate limited, retrying', { expertType, attempt: attempt + 1, backoffMs });\n await new Promise((resolve) => setTimeout(resolve, backoffMs));\n continue;\n }\n\n logger.warn('Expert execution failed', { expertType, error: result.error.message });\n return { success: false, text: '', expertType, durationMs, error: result.error.message };\n }\n\n return {\n success: false,\n text: '',\n expertType,\n durationMs: getTimeProvider().now() - start,\n error: 'Max retry attempts exceeded',\n };\n}\n\n/**\n * Execute an expert task with the full nexus-agents expert pipeline.\n *\n * Creates a built-in expert, executes via CompositeRouter (for intelligent\n * CLI routing), and records outcomes. Falls back gracefully on failure.\n *\n * @param expertType - Built-in expert type (code, architecture, security, qa, etc.)\n * @param prompt - Task prompt for the expert\n * @returns Expert result with text output\n */\nexport async function executeExpert(\n expertType: BuiltInExpertType,\n prompt: string\n): Promise<ExpertBridgeResult> {\n const start = getTimeProvider().now();\n try {\n const { BUILT_IN_EXPERTS } = await import('../agents/experts/expert-config.js');\n const config = BUILT_IN_EXPERTS[expertType];\n const fullPrompt = `${config.systemPrompt}\\n\\n${prompt}`;\n\n const router = await getRouter();\n if (router === null) {\n return {\n success: false,\n text: `[No adapters] ${prompt}`,\n expertType,\n durationMs: getTimeProvider().now() - start,\n error: 'No CLI adapters available',\n };\n }\n\n // Check circuit breaker health before dispatch (#1766)\n const health = checkCircuitHealth();\n if (!health.healthy) {\n logger.warn('Circuit breaker: all CLIs unavailable', { expertType, reason: health.message });\n return {\n success: false,\n text: '',\n expertType,\n durationMs: getTimeProvider().now() - start,\n error: health.message,\n };\n }\n\n // Pass MCP config so CLI experts can call nexus-agents tools (#1708)\n const mcpConfigPath = await getMcpConfigPath();\n const task: { content: string; options?: Record<string, unknown> | undefined } = {\n content: fullPrompt,\n };\n if (mcpConfigPath !== null) task.options = { mcpConfigPath };\n\n return await dispatchWithRateLimitRetry(router, task, expertType, start);\n } catch (error) {\n const durationMs = getTimeProvider().now() - start;\n const msg = error instanceof Error ? error.message : String(error);\n logger.warn('Expert bridge error', { expertType, error: msg });\n return { success: false, text: '', expertType, durationMs, error: msg };\n }\n}\n"],"mappings":";;;;;;;;;;AA0BA,SAAS,0BAA0B,OAAuD;AACxF,SAAO,eAAe,KAAK;AAC7B;AAEA,IAAM,SAAS,aAAa,EAAE,WAAW,gBAAgB,CAAC;AAG1D,IAAM,2BAA2B;AA2DjC,IAAI,eAAkC;AAGtC,IAAI,sBAAqC;AAMzC,IAAI,yBAAuD;AAI3D,IAAI,uBAAsD;AAG1D,eAAe,mBAA2C;AACxD,MAAI,wBAAwB,KAAM,QAAO;AACzC,4BAA0B,YAAoC;AAC5D,QAAI;AACF,YAAM,EAAE,kBAAkB,IAAI,MAAM,OAAO,gCAAqC;AAChF,YAAM,SAAS,MAAM,kBAAkB;AACvC,4BAAsB,OAAO;AAC7B,+BAAyB,OAAO;AAChC,aAAO;AAAA,IACT,QAAQ;AACN,6BAAuB;AACvB,aAAO;AAAA,IACT;AAAA,EACF,GAAG;AACH,SAAO;AACT;AASA,eAAsB,uBAAsC;AAC1D,QAAM,UAAU;AAChB,MAAI,YAAY,KAAM;AACtB,2BAAyB;AACzB,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,WAAO,EAAE,SAAS,OAAO,MAAM,IAAI,YAAY,YAAY,OAAO,IAAI;AAAA,EACxE;AACF;","names":[]}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
GitHubProvider,
|
|
3
3
|
ScmError
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-FJPF6NUY.js";
|
|
5
5
|
import {
|
|
6
6
|
resolveToken
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-Q7FAI4JO.js";
|
|
8
8
|
import {
|
|
9
9
|
err,
|
|
10
10
|
ok
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-B5BCAZ67.js";
|
|
12
12
|
|
|
13
13
|
// src/scm/factory.ts
|
|
14
14
|
async function createScmProvider(config) {
|
|
@@ -41,4 +41,4 @@ export {
|
|
|
41
41
|
createScmProvider,
|
|
42
42
|
createGitHubProvider
|
|
43
43
|
};
|
|
44
|
-
//# sourceMappingURL=chunk-
|
|
44
|
+
//# sourceMappingURL=chunk-UI5JIET2.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
TASK_CATEGORIES,
|
|
3
3
|
getAdaptiveBonus,
|
|
4
4
|
getOutcomeStore
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-B5BCAZ67.js";
|
|
6
6
|
|
|
7
7
|
// src/cli/doctor-deep.ts
|
|
8
8
|
var CLI_NAMES = ["claude", "gemini", "codex", "opencode"];
|
|
@@ -106,4 +106,4 @@ export {
|
|
|
106
106
|
runDeepDiagnostics,
|
|
107
107
|
formatDeepDiagnostics
|
|
108
108
|
};
|
|
109
|
-
//# sourceMappingURL=chunk-
|
|
109
|
+
//# sourceMappingURL=chunk-UYNAJJQR.js.map
|
|
@@ -5,34 +5,34 @@ import {
|
|
|
5
5
|
planOptionalParams,
|
|
6
6
|
requireApiKey,
|
|
7
7
|
validateApiKeyPresence
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-P2KRXJI7.js";
|
|
9
9
|
import {
|
|
10
10
|
CUSTOM_API_DEFAULT_MODEL
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-56FMLTYA.js";
|
|
12
12
|
import {
|
|
13
13
|
CUSTOM_API_BASE_URL_ENV,
|
|
14
14
|
PROVIDER_ENV_KEYS,
|
|
15
15
|
assertCustomApiHostResolvesPublic,
|
|
16
16
|
validateCustomApiBaseUrl
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-PYSJGQW3.js";
|
|
18
18
|
import {
|
|
19
19
|
nexusMkdtempSync
|
|
20
20
|
} from "./chunk-4OW67KT2.js";
|
|
21
21
|
import {
|
|
22
22
|
getAvailabilityCache
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-2CZP5HI3.js";
|
|
24
24
|
import {
|
|
25
25
|
extractSystemPrompt
|
|
26
26
|
} from "./chunk-QZUG667L.js";
|
|
27
27
|
import {
|
|
28
28
|
generateHyphenId
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-F7YLKM2N.js";
|
|
30
30
|
import {
|
|
31
31
|
CliCircuitBreaker,
|
|
32
32
|
DEFAULT_CIRCUIT_BREAKER_CONFIG,
|
|
33
33
|
getCliCircuitBreakerSnapshot,
|
|
34
34
|
getDefaultCliCircuitBreakerRegistry
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-LWDEI43X.js";
|
|
36
36
|
import {
|
|
37
37
|
CLI_SUBPROCESS_TIMEOUTS,
|
|
38
38
|
CLI_TIMEOUTS,
|
|
@@ -72,7 +72,7 @@ import {
|
|
|
72
72
|
resolveCliAlias,
|
|
73
73
|
resolveRetryAfterMs,
|
|
74
74
|
retryAfterMsFromContext
|
|
75
|
-
} from "./chunk-
|
|
75
|
+
} from "./chunk-B5BCAZ67.js";
|
|
76
76
|
|
|
77
77
|
// src/cli-adapters/cli-to-model-adapter.ts
|
|
78
78
|
var CliToModelAdapter = class {
|
|
@@ -2907,11 +2907,13 @@ var SubprocessCliAdapter = class extends BaseCliAdapter {
|
|
|
2907
2907
|
}
|
|
2908
2908
|
const usage = this.parser.extractUsage(stdout);
|
|
2909
2909
|
const sessionId = this.parser.extractSessionId(stdout);
|
|
2910
|
+
const costUsd = this.parser.extractCostUsd?.(stdout) ?? null;
|
|
2910
2911
|
return ok(
|
|
2911
2912
|
this.normalizeResponse(text, usage ?? void 0, {
|
|
2912
2913
|
durationMs: getTimeProvider().now() - startTime,
|
|
2913
2914
|
raw: stdout,
|
|
2914
|
-
...sessionId !== null && { sessionId }
|
|
2915
|
+
...sessionId !== null && { sessionId },
|
|
2916
|
+
...costUsd !== null && { costUsd }
|
|
2915
2917
|
})
|
|
2916
2918
|
);
|
|
2917
2919
|
}
|
|
@@ -3023,6 +3025,24 @@ function extractNumberField(record, key) {
|
|
|
3023
3025
|
|
|
3024
3026
|
// src/cli-adapters/parsers/claude-parser.ts
|
|
3025
3027
|
var logger = createLogger({ component: "claude-parser" });
|
|
3028
|
+
function isUsableCost(value) {
|
|
3029
|
+
return Number.isFinite(value) && value >= 0;
|
|
3030
|
+
}
|
|
3031
|
+
function sumModelUsageCost(raw) {
|
|
3032
|
+
const modelUsage = asRecord(raw);
|
|
3033
|
+
if (modelUsage === null) return null;
|
|
3034
|
+
let sum = 0;
|
|
3035
|
+
let sawCost = false;
|
|
3036
|
+
for (const entry of Object.values(modelUsage)) {
|
|
3037
|
+
const perModel = asRecord(entry);
|
|
3038
|
+
if (perModel === null) continue;
|
|
3039
|
+
const cost = perModel.costUSD;
|
|
3040
|
+
if (typeof cost !== "number" || !isUsableCost(cost)) continue;
|
|
3041
|
+
sum += cost;
|
|
3042
|
+
sawCost = true;
|
|
3043
|
+
}
|
|
3044
|
+
return sawCost ? sum : null;
|
|
3045
|
+
}
|
|
3026
3046
|
var ClaudeResponseParser = class {
|
|
3027
3047
|
name = "claude-parser";
|
|
3028
3048
|
supportedVersionRange = ">=2.0.0 <3.0.0";
|
|
@@ -3098,6 +3118,29 @@ var ClaudeResponseParser = class {
|
|
|
3098
3118
|
return null;
|
|
3099
3119
|
}
|
|
3100
3120
|
}
|
|
3121
|
+
/**
|
|
3122
|
+
* Extracts the cost the Claude CLI reported for this call.
|
|
3123
|
+
*
|
|
3124
|
+
* Prefers `total_cost_usd` — the vendor's own total — over summing
|
|
3125
|
+
* `modelUsage[*].costUSD`, because a per-model breakdown can omit a component
|
|
3126
|
+
* the total includes. Both are declared on {@link ClaudeCliResponse} and
|
|
3127
|
+
* neither reached `CliResponse` before #5241.
|
|
3128
|
+
*
|
|
3129
|
+
* Rejects a negative or non-finite figure: a cost is a measurement, and
|
|
3130
|
+
* letting a corrupt one through would debit the budget router with garbage.
|
|
3131
|
+
*/
|
|
3132
|
+
extractCostUsd(raw) {
|
|
3133
|
+
try {
|
|
3134
|
+
const record = asRecord(JSON.parse(raw));
|
|
3135
|
+
if (record === null) return null;
|
|
3136
|
+
const total = record.total_cost_usd;
|
|
3137
|
+
if (typeof total === "number") return isUsableCost(total) ? total : null;
|
|
3138
|
+
return sumModelUsageCost(record.modelUsage);
|
|
3139
|
+
} catch {
|
|
3140
|
+
logger.debug("Skipped malformed output line", { snippet: raw.slice(0, 100) });
|
|
3141
|
+
return null;
|
|
3142
|
+
}
|
|
3143
|
+
}
|
|
3101
3144
|
/**
|
|
3102
3145
|
* Extracts session ID for resumption.
|
|
3103
3146
|
*/
|
|
@@ -4903,4 +4946,4 @@ export {
|
|
|
4903
4946
|
SdkAdapter,
|
|
4904
4947
|
createAutoAdapter
|
|
4905
4948
|
};
|
|
4906
|
-
//# sourceMappingURL=chunk-
|
|
4949
|
+
//# sourceMappingURL=chunk-VECTXFPX.js.map
|