nexus-agents 11.6.1 → 11.7.0

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.
Files changed (146) hide show
  1. package/dist/{ast-rule-runner-GRU2OC5H.js → ast-rule-runner-PIIAHXDA.js} +5 -5
  2. package/dist/{child-mcp-config-DNZN7CMS.js → child-mcp-config-B6BTYZT4.js} +4 -4
  3. package/dist/{chunk-L4QFWMXB.js → chunk-26WUCAGU.js} +4 -4
  4. package/dist/{chunk-MFBTGXR6.js → chunk-3QKRY72I.js} +8 -435
  5. package/dist/chunk-3QKRY72I.js.map +1 -0
  6. package/dist/{chunk-UMG4PRKT.js → chunk-4HOSKAB3.js} +4 -4
  7. package/dist/{chunk-2URHVZJR.js → chunk-4MKZAA6W.js} +5 -4
  8. package/dist/chunk-4MKZAA6W.js.map +1 -0
  9. package/dist/{chunk-JLJVZP7U.js → chunk-4NNCB7O2.js} +5 -5
  10. package/dist/{chunk-Z5XFIY4Q.js → chunk-5BEFQVPR.js} +2 -2
  11. package/dist/chunk-6IP3FOEC.js +365 -0
  12. package/dist/chunk-6IP3FOEC.js.map +1 -0
  13. package/dist/{chunk-4X4RJ6AP.js → chunk-6T6YL7MV.js} +4 -4
  14. package/dist/{chunk-RWBF3Y4A.js → chunk-7HI6EWY5.js} +2 -2
  15. package/dist/{chunk-45G5ZV3K.js → chunk-7Y6SB623.js} +2 -2
  16. package/dist/{chunk-N5YTX4UL.js → chunk-BSX3PMNN.js} +2 -2
  17. package/dist/{chunk-6A6YA4C4.js → chunk-BVUPPTAD.js} +6 -6
  18. package/dist/{chunk-L3VR5RXX.js → chunk-E5XKXB3G.js} +2 -2
  19. package/dist/chunk-ENX4WYFX.js +441 -0
  20. package/dist/chunk-ENX4WYFX.js.map +1 -0
  21. package/dist/{chunk-6WCFWNIR.js → chunk-FOJ2INSI.js} +3 -3
  22. package/dist/{chunk-OMQC4NWX.js → chunk-GCRXO43T.js} +2 -2
  23. package/dist/{chunk-U36QOTW3.js → chunk-HCTKX472.js} +8 -8
  24. package/dist/{chunk-2UEI7ZZ5.js → chunk-HT7QZ3JB.js} +5 -5
  25. package/dist/{chunk-SYLXKCXM.js → chunk-IHGMXLLO.js} +6 -5
  26. package/dist/chunk-IHGMXLLO.js.map +1 -0
  27. package/dist/{chunk-5RVD24RT.js → chunk-IJCEGKCM.js} +1181 -808
  28. package/dist/chunk-IJCEGKCM.js.map +1 -0
  29. package/dist/{chunk-4X3HAJWZ.js → chunk-IKGAI6ES.js} +2 -2
  30. package/dist/{chunk-GIW4L5PI.js → chunk-INVGMQKJ.js} +2 -2
  31. package/dist/{chunk-GP2O652R.js → chunk-JMKK6UBR.js} +34 -389
  32. package/dist/chunk-JMKK6UBR.js.map +1 -0
  33. package/dist/{chunk-STKHXNVO.js → chunk-ML7FSBBM.js} +4 -4
  34. package/dist/{chunk-CHYLIBKP.js → chunk-OHI6P6GE.js} +4 -4
  35. package/dist/{chunk-ZYZIRL4X.js → chunk-OMWOFIK5.js} +2657 -2525
  36. package/dist/chunk-OMWOFIK5.js.map +1 -0
  37. package/dist/{chunk-HWAJUCPO.js → chunk-PHLASJD2.js} +31 -26
  38. package/dist/chunk-PHLASJD2.js.map +1 -0
  39. package/dist/{chunk-2SFOJPJH.js → chunk-PYTN5UNL.js} +2 -2
  40. package/dist/{chunk-6KIQF3UT.js → chunk-RRZOCS22.js} +4 -4
  41. package/dist/{chunk-O6Z4MSLB.js → chunk-U4GRHZRQ.js} +1735 -1495
  42. package/dist/chunk-U4GRHZRQ.js.map +1 -0
  43. package/dist/{chunk-XTPDYH4R.js → chunk-VPRBPMVL.js} +3 -3
  44. package/dist/{chunk-O3FMPRQH.js → chunk-VVDPRJU7.js} +3 -1
  45. package/dist/chunk-VVDPRJU7.js.map +1 -0
  46. package/dist/{chunk-AZPPUDUR.js → chunk-YHW6FXKC.js} +7 -7
  47. package/dist/{chunk-PO2CMGVP.js → chunk-YI6DZGN6.js} +2 -2
  48. package/dist/{cli-circuit-breaker-KAOHEKYP.js → cli-circuit-breaker-HV7WXCVP.js} +5 -5
  49. package/dist/{cli-readiness-X7O3LCWW.js → cli-readiness-N4WWAROI.js} +10 -9
  50. package/dist/{cli-server-gateway-P4F66L2K.js → cli-server-gateway-5N7MHUO6.js} +15 -13
  51. package/dist/cli.js +88 -85
  52. package/dist/cli.js.map +1 -1
  53. package/dist/{composite-router-4QGXSANU.js → composite-router-TXGVXX56.js} +4 -4
  54. package/dist/{consensus-vote-7FWF4I2X.js → consensus-vote-BYEM44JH.js} +19 -17
  55. package/dist/{context-retriever-2XMORQMD.js → context-retriever-NT2DYPFG.js} +11 -11
  56. package/dist/{doctor-deep-RLYWXUJX.js → doctor-deep-RUWHL6R5.js} +5 -5
  57. package/dist/{doctor-gateway-report-AKE3S2UH.js → doctor-gateway-report-BBMWMMVQ.js} +8 -8
  58. package/dist/{doctor-live-IQHBI6LH.js → doctor-live-NI27JU6K.js} +17 -14
  59. package/dist/doctor-live-NI27JU6K.js.map +1 -0
  60. package/dist/{expert-bridge-2TNU6HKC.js → expert-bridge-V2R5PAXS.js} +6 -6
  61. package/dist/{factory-UCKSPZ5G.js → factory-3PBQNM44.js} +14 -12
  62. package/dist/{factory-5UWGAQOB.js → factory-YZILOS2Z.js} +7 -7
  63. package/dist/gemini-adapter-IZ3TS6KZ.js +28 -0
  64. package/dist/{improvement-review-I3Q34AJJ.js → improvement-review-N6W2FWFO.js} +7 -7
  65. package/dist/index.d.ts +72 -6
  66. package/dist/index.js +132 -128
  67. package/dist/index.js.map +1 -1
  68. package/dist/{init-opencode-CII5S6XH.js → init-opencode-PLMPOB55.js} +7 -7
  69. package/dist/{issue-triage-DO6ATHBV.js → issue-triage-W5XKE324.js} +7 -7
  70. package/dist/{model-config-helpers-3U6IEHM6.js → model-config-helpers-5DTFDWYR.js} +7 -3
  71. package/dist/{openai-compat-adapter-7G6JYZLY.js → openai-compat-adapter-4VREPXZT.js} +7 -7
  72. package/dist/{pr-reviewer-helpers-JSLG5YYG.js → pr-reviewer-helpers-RAPVW52Y.js} +6 -6
  73. package/dist/{registry-command-X5NLFI3D.js → registry-command-3XWS7G6F.js} +2 -2
  74. package/dist/{repo-security-plan-DLROWMDR.js → repo-security-plan-BITATHGO.js} +4 -4
  75. package/dist/{research-helpers-synthesize-NE3I56IC.js → research-helpers-synthesize-FW47ZIMK.js} +6 -6
  76. package/dist/{routing-memory-YFSHH2AN.js → routing-memory-POESZPDJ.js} +4 -4
  77. package/dist/{session-memory-ZE2FUHO3.js → session-memory-TBBFP3XP.js} +5 -5
  78. package/dist/{setup-config-SFNU2QL4.js → setup-config-AKFLKDMP.js} +5 -5
  79. package/dist/{setup-custom-api-JBCH5YAW.js → setup-custom-api-WQMO2OV7.js} +5 -5
  80. package/dist/{tool-memory-Z3X6EFMS.js → tool-memory-RLCP6WVV.js} +7 -7
  81. package/dist/{unified-registry-2YSSICSB.js → unified-registry-MIANRTCJ.js} +14 -12
  82. package/dist/{weather-report-YSGMEYVV.js → weather-report-QB2TYTYU.js} +4 -4
  83. package/dist/weather-report-QB2TYTYU.js.map +1 -0
  84. package/package.json +1 -1
  85. package/dist/chunk-2URHVZJR.js.map +0 -1
  86. package/dist/chunk-5RVD24RT.js.map +0 -1
  87. package/dist/chunk-GP2O652R.js.map +0 -1
  88. package/dist/chunk-HWAJUCPO.js.map +0 -1
  89. package/dist/chunk-MFBTGXR6.js.map +0 -1
  90. package/dist/chunk-O3FMPRQH.js.map +0 -1
  91. package/dist/chunk-O6Z4MSLB.js.map +0 -1
  92. package/dist/chunk-SYLXKCXM.js.map +0 -1
  93. package/dist/chunk-ZYZIRL4X.js.map +0 -1
  94. package/dist/doctor-live-IQHBI6LH.js.map +0 -1
  95. /package/dist/{ast-rule-runner-GRU2OC5H.js.map → ast-rule-runner-PIIAHXDA.js.map} +0 -0
  96. /package/dist/{child-mcp-config-DNZN7CMS.js.map → child-mcp-config-B6BTYZT4.js.map} +0 -0
  97. /package/dist/{chunk-L4QFWMXB.js.map → chunk-26WUCAGU.js.map} +0 -0
  98. /package/dist/{chunk-UMG4PRKT.js.map → chunk-4HOSKAB3.js.map} +0 -0
  99. /package/dist/{chunk-JLJVZP7U.js.map → chunk-4NNCB7O2.js.map} +0 -0
  100. /package/dist/{chunk-Z5XFIY4Q.js.map → chunk-5BEFQVPR.js.map} +0 -0
  101. /package/dist/{chunk-4X4RJ6AP.js.map → chunk-6T6YL7MV.js.map} +0 -0
  102. /package/dist/{chunk-RWBF3Y4A.js.map → chunk-7HI6EWY5.js.map} +0 -0
  103. /package/dist/{chunk-45G5ZV3K.js.map → chunk-7Y6SB623.js.map} +0 -0
  104. /package/dist/{chunk-N5YTX4UL.js.map → chunk-BSX3PMNN.js.map} +0 -0
  105. /package/dist/{chunk-6A6YA4C4.js.map → chunk-BVUPPTAD.js.map} +0 -0
  106. /package/dist/{chunk-L3VR5RXX.js.map → chunk-E5XKXB3G.js.map} +0 -0
  107. /package/dist/{chunk-6WCFWNIR.js.map → chunk-FOJ2INSI.js.map} +0 -0
  108. /package/dist/{chunk-OMQC4NWX.js.map → chunk-GCRXO43T.js.map} +0 -0
  109. /package/dist/{chunk-U36QOTW3.js.map → chunk-HCTKX472.js.map} +0 -0
  110. /package/dist/{chunk-2UEI7ZZ5.js.map → chunk-HT7QZ3JB.js.map} +0 -0
  111. /package/dist/{chunk-4X3HAJWZ.js.map → chunk-IKGAI6ES.js.map} +0 -0
  112. /package/dist/{chunk-GIW4L5PI.js.map → chunk-INVGMQKJ.js.map} +0 -0
  113. /package/dist/{chunk-STKHXNVO.js.map → chunk-ML7FSBBM.js.map} +0 -0
  114. /package/dist/{chunk-CHYLIBKP.js.map → chunk-OHI6P6GE.js.map} +0 -0
  115. /package/dist/{chunk-2SFOJPJH.js.map → chunk-PYTN5UNL.js.map} +0 -0
  116. /package/dist/{chunk-6KIQF3UT.js.map → chunk-RRZOCS22.js.map} +0 -0
  117. /package/dist/{chunk-XTPDYH4R.js.map → chunk-VPRBPMVL.js.map} +0 -0
  118. /package/dist/{chunk-AZPPUDUR.js.map → chunk-YHW6FXKC.js.map} +0 -0
  119. /package/dist/{chunk-PO2CMGVP.js.map → chunk-YI6DZGN6.js.map} +0 -0
  120. /package/dist/{cli-circuit-breaker-KAOHEKYP.js.map → cli-circuit-breaker-HV7WXCVP.js.map} +0 -0
  121. /package/dist/{cli-readiness-X7O3LCWW.js.map → cli-readiness-N4WWAROI.js.map} +0 -0
  122. /package/dist/{cli-server-gateway-P4F66L2K.js.map → cli-server-gateway-5N7MHUO6.js.map} +0 -0
  123. /package/dist/{composite-router-4QGXSANU.js.map → composite-router-TXGVXX56.js.map} +0 -0
  124. /package/dist/{consensus-vote-7FWF4I2X.js.map → consensus-vote-BYEM44JH.js.map} +0 -0
  125. /package/dist/{context-retriever-2XMORQMD.js.map → context-retriever-NT2DYPFG.js.map} +0 -0
  126. /package/dist/{doctor-deep-RLYWXUJX.js.map → doctor-deep-RUWHL6R5.js.map} +0 -0
  127. /package/dist/{doctor-gateway-report-AKE3S2UH.js.map → doctor-gateway-report-BBMWMMVQ.js.map} +0 -0
  128. /package/dist/{expert-bridge-2TNU6HKC.js.map → expert-bridge-V2R5PAXS.js.map} +0 -0
  129. /package/dist/{factory-5UWGAQOB.js.map → factory-3PBQNM44.js.map} +0 -0
  130. /package/dist/{factory-UCKSPZ5G.js.map → factory-YZILOS2Z.js.map} +0 -0
  131. /package/dist/{improvement-review-I3Q34AJJ.js.map → gemini-adapter-IZ3TS6KZ.js.map} +0 -0
  132. /package/dist/{issue-triage-DO6ATHBV.js.map → improvement-review-N6W2FWFO.js.map} +0 -0
  133. /package/dist/{init-opencode-CII5S6XH.js.map → init-opencode-PLMPOB55.js.map} +0 -0
  134. /package/dist/{model-config-helpers-3U6IEHM6.js.map → issue-triage-W5XKE324.js.map} +0 -0
  135. /package/dist/{openai-compat-adapter-7G6JYZLY.js.map → model-config-helpers-5DTFDWYR.js.map} +0 -0
  136. /package/dist/{pr-reviewer-helpers-JSLG5YYG.js.map → openai-compat-adapter-4VREPXZT.js.map} +0 -0
  137. /package/dist/{repo-security-plan-DLROWMDR.js.map → pr-reviewer-helpers-RAPVW52Y.js.map} +0 -0
  138. /package/dist/{registry-command-X5NLFI3D.js.map → registry-command-3XWS7G6F.js.map} +0 -0
  139. /package/dist/{research-helpers-synthesize-NE3I56IC.js.map → repo-security-plan-BITATHGO.js.map} +0 -0
  140. /package/dist/{routing-memory-YFSHH2AN.js.map → research-helpers-synthesize-FW47ZIMK.js.map} +0 -0
  141. /package/dist/{session-memory-ZE2FUHO3.js.map → routing-memory-POESZPDJ.js.map} +0 -0
  142. /package/dist/{setup-config-SFNU2QL4.js.map → session-memory-TBBFP3XP.js.map} +0 -0
  143. /package/dist/{tool-memory-Z3X6EFMS.js.map → setup-config-AKFLKDMP.js.map} +0 -0
  144. /package/dist/{setup-custom-api-JBCH5YAW.js.map → setup-custom-api-WQMO2OV7.js.map} +0 -0
  145. /package/dist/{unified-registry-2YSSICSB.js.map → tool-memory-RLCP6WVV.js.map} +0 -0
  146. /package/dist/{weather-report-YSGMEYVV.js.map → unified-registry-MIANRTCJ.js.map} +0 -0
@@ -9,11 +9,11 @@ import {
9
9
  getBuiltInAstRulesPath,
10
10
  loadRules,
11
11
  runAstQaRules
12
- } from "./chunk-L3VR5RXX.js";
13
- import "./chunk-ZYZIRL4X.js";
12
+ } from "./chunk-E5XKXB3G.js";
13
+ import "./chunk-OMWOFIK5.js";
14
14
  import "./chunk-XBEKMUTO.js";
15
- import "./chunk-HWAJUCPO.js";
16
- import "./chunk-2URHVZJR.js";
15
+ import "./chunk-PHLASJD2.js";
16
+ import "./chunk-4MKZAA6W.js";
17
17
  import "./chunk-G3M3UVAW.js";
18
18
  import "./chunk-VIT46LNO.js";
19
19
  import "./chunk-MQ23UGSY.js";
@@ -34,4 +34,4 @@ export {
34
34
  loadRules,
35
35
  runAstQaRules
36
36
  };
37
- //# sourceMappingURL=ast-rule-runner-GRU2OC5H.js.map
37
+ //# sourceMappingURL=ast-rule-runner-PIIAHXDA.js.map
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  nexusMkdtempSync
3
3
  } from "./chunk-EBKVMMWA.js";
4
- import "./chunk-ZYZIRL4X.js";
4
+ import "./chunk-OMWOFIK5.js";
5
5
  import "./chunk-XBEKMUTO.js";
6
- import "./chunk-HWAJUCPO.js";
7
- import "./chunk-2URHVZJR.js";
6
+ import "./chunk-PHLASJD2.js";
7
+ import "./chunk-4MKZAA6W.js";
8
8
  import "./chunk-G3M3UVAW.js";
9
9
  import "./chunk-VIT46LNO.js";
10
10
  import {
@@ -81,4 +81,4 @@ async function generateMcpConfig(options) {
81
81
  export {
82
82
  generateMcpConfig
83
83
  };
84
- //# sourceMappingURL=child-mcp-config-DNZN7CMS.js.map
84
+ //# sourceMappingURL=child-mcp-config-B6BTYZT4.js.map
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  GitHubProvider,
3
3
  ScmError
4
- } from "./chunk-2SFOJPJH.js";
4
+ } from "./chunk-PYTN5UNL.js";
5
5
  import {
6
6
  resolveToken
7
- } from "./chunk-45G5ZV3K.js";
7
+ } from "./chunk-7Y6SB623.js";
8
8
  import {
9
9
  err,
10
10
  ok
11
- } from "./chunk-ZYZIRL4X.js";
11
+ } from "./chunk-OMWOFIK5.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-L4QFWMXB.js.map
44
+ //# sourceMappingURL=chunk-26WUCAGU.js.map
@@ -1,26 +1,23 @@
1
1
  import {
2
2
  generateHyphenId
3
- } from "./chunk-GIW4L5PI.js";
3
+ } from "./chunk-INVGMQKJ.js";
4
4
  import {
5
5
  getDefaultCliCircuitBreakerRegistry
6
- } from "./chunk-OMQC4NWX.js";
6
+ } from "./chunk-GCRXO43T.js";
7
7
  import {
8
8
  sanitizeOutput
9
- } from "./chunk-O3FMPRQH.js";
9
+ } from "./chunk-VVDPRJU7.js";
10
10
  import {
11
11
  CLI_VERSION_REQUIREMENTS,
12
12
  DEFAULT_CAPABILITIES,
13
13
  RETRYABLE_ERROR_CODES,
14
- accessModeConflict,
15
14
  adapterReadiness,
16
- asRecord,
17
15
  breakerKeys,
18
16
  classifyExtractedError,
19
17
  createCallerAbortCliError,
20
18
  createCapacityTracker,
21
19
  createCliError,
22
20
  err,
23
- extractNumberField,
24
21
  getErrorMessage,
25
22
  getOutcomeStore,
26
23
  getRandomProvider,
@@ -28,28 +25,13 @@ import {
28
25
  isCallerCancelled,
29
26
  isDurableCapacityText,
30
27
  isRateLimitText,
31
- isReadOnlyAnalysis,
32
28
  isTimeoutText,
33
- isWorkspaceEdit,
34
- listModelsForCli,
35
29
  ok,
36
30
  parseCliErrorEnvelope,
37
- restrictedAccessMode,
38
31
  servesListedModel,
39
32
  unenforcedAccessModeRefusal,
40
33
  withEnforcedAccessMode
41
- } from "./chunk-ZYZIRL4X.js";
42
- import {
43
- FALLBACK_CONTEXT_WINDOW,
44
- FALLBACK_MAX_OUTPUT,
45
- buildModelInfo,
46
- findInTreeByCli,
47
- getCliModelName,
48
- getDefaultModelForCli
49
- } from "./chunk-HWAJUCPO.js";
50
- import {
51
- getDefaultRegistry
52
- } from "./chunk-2URHVZJR.js";
34
+ } from "./chunk-OMWOFIK5.js";
53
35
  import {
54
36
  createLogger,
55
37
  getTimeProvider
@@ -291,8 +273,8 @@ var BaseCliAdapter = class {
291
273
  * (#5864).
292
274
  */
293
275
  cachedVersionAt;
294
- constructor(logger2) {
295
- this.logger = logger2 ?? createLogger({ component: "cli-adapter" });
276
+ constructor(logger) {
277
+ this.logger = logger ?? createLogger({ component: "cli-adapter" });
296
278
  }
297
279
  /** Local CLI auth evidence from the canonical probe; makes no live API call. */
298
280
  async authStatus() {
@@ -1495,412 +1477,6 @@ var SubprocessCliAdapter = class extends BaseCliAdapter {
1495
1477
  }
1496
1478
  };
1497
1479
 
1498
- // src/cli-adapters/parsers/claude-parser.ts
1499
- var logger = createLogger({ component: "claude-parser" });
1500
- function isUsableCost(value) {
1501
- return Number.isFinite(value) && value >= 0;
1502
- }
1503
- function sumModelUsageCost(raw) {
1504
- const modelUsage = asRecord(raw);
1505
- if (modelUsage === null) return null;
1506
- let sum = 0;
1507
- let sawCost = false;
1508
- for (const entry of Object.values(modelUsage)) {
1509
- const perModel = asRecord(entry);
1510
- if (perModel === null) continue;
1511
- const cost = perModel.costUSD;
1512
- if (typeof cost !== "number" || !isUsableCost(cost)) continue;
1513
- sum += cost;
1514
- sawCost = true;
1515
- }
1516
- return sawCost ? sum : null;
1517
- }
1518
- var ClaudeResponseParser = class {
1519
- name = "claude-parser";
1520
- supportedVersionRange = ">=2.0.0 <3.0.0";
1521
- /**
1522
- * Parses complete Claude CLI response.
1523
- */
1524
- parse(raw) {
1525
- try {
1526
- const data = JSON.parse(raw);
1527
- if (!this.isValidResponse(data)) {
1528
- return null;
1529
- }
1530
- return data;
1531
- } catch {
1532
- logger.debug("Skipped malformed output line", { snippet: raw.slice(0, 100) });
1533
- return null;
1534
- }
1535
- }
1536
- /**
1537
- * Extracts just the response text (most stable field).
1538
- * Returns null if the response contains an error.
1539
- */
1540
- extractResponse(raw) {
1541
- try {
1542
- const data = JSON.parse(raw);
1543
- const record = asRecord(data);
1544
- if (record === null) return null;
1545
- if (record.is_error === true) {
1546
- return null;
1547
- }
1548
- const result = record.result;
1549
- if (typeof result === "string") {
1550
- return result;
1551
- }
1552
- return null;
1553
- } catch {
1554
- logger.debug("Skipped malformed output line", { snippet: raw.slice(0, 100) });
1555
- return null;
1556
- }
1557
- }
1558
- /**
1559
- * The error text of an `is_error: true` envelope, with its `stop_reason`
1560
- * (#6120).
1561
- *
1562
- * Before this the envelope reached the adapter only through the generic
1563
- * unparseable-output path, whose first step scans the WHOLE stdout for
1564
- * rate-limit text. The out-of-credits envelope carries `api_error_status:
1565
- * 429`, so that scan matched and the error message became the first 500
1566
- * characters of the envelope — `{"duration_api_ms":0,…` — while the one
1567
- * field that names the cause, `result`, never reached anyone. Surfacing it
1568
- * here routes the envelope through `classifyErrorOnlyStream`, which
1569
- * classifies the message text rather than the envelope bytes.
1570
- *
1571
- * `null` when the envelope is not an error, or when `result` is empty: an
1572
- * empty error text is not a message, and the caller's recovery order handles
1573
- * it as before.
1574
- */
1575
- extractErrorMessage(raw) {
1576
- try {
1577
- const record = asRecord(JSON.parse(raw));
1578
- if (record?.is_error !== true) return null;
1579
- const result = record.result;
1580
- if (typeof result !== "string" || result === "") return null;
1581
- const stopReason = record.stop_reason;
1582
- return typeof stopReason === "string" && stopReason !== "" ? `${result} (stop_reason: ${stopReason})` : result;
1583
- } catch {
1584
- logger.debug("Skipped malformed output line", { snippet: raw.slice(0, 100) });
1585
- return null;
1586
- }
1587
- }
1588
- /**
1589
- * The tool calls claude's permission layer refused (#6792), from the
1590
- * result envelope's `permission_denials`. `null` when the field is absent
1591
- * or empty, or the output is not JSON; an entry without a tool name is
1592
- * skipped rather than invented.
1593
- */
1594
- extractPermissionDenials(raw) {
1595
- try {
1596
- const denials = asRecord(JSON.parse(raw))?.permission_denials;
1597
- if (!Array.isArray(denials)) return null;
1598
- const parsed = denials.flatMap((entry) => {
1599
- const record = asRecord(entry);
1600
- const toolName = record?.tool_name;
1601
- if (typeof toolName !== "string" || toolName === "") return [];
1602
- const filePath = asRecord(record?.tool_input)?.file_path;
1603
- return [{ toolName, ...typeof filePath === "string" && { filePath } }];
1604
- });
1605
- return parsed.length > 0 ? parsed : null;
1606
- } catch {
1607
- return null;
1608
- }
1609
- }
1610
- /**
1611
- * Extracts token usage from response.
1612
- */
1613
- extractUsage(raw) {
1614
- try {
1615
- const data = JSON.parse(raw);
1616
- const record = asRecord(data);
1617
- if (record === null) return null;
1618
- const usageRecord = asRecord(record.usage);
1619
- if (usageRecord === null) return null;
1620
- const inputTokens = extractNumberField(usageRecord, "input_tokens");
1621
- const outputTokens = extractNumberField(usageRecord, "output_tokens");
1622
- if (inputTokens === null || outputTokens === null) {
1623
- return null;
1624
- }
1625
- const cachedInputTokens = extractNumberField(usageRecord, "cache_read_input_tokens");
1626
- const cacheCreationInputTokens = extractNumberField(
1627
- usageRecord,
1628
- "cache_creation_input_tokens"
1629
- );
1630
- return {
1631
- inputTokens,
1632
- outputTokens,
1633
- // NOTE: still uncached input + output. Folding the cache figures in
1634
- // here is a semantics change for every consumer of totalTokens and
1635
- // belongs with the threading increment on #4435, not this extraction.
1636
- totalTokens: inputTokens + outputTokens,
1637
- ...cachedInputTokens !== null && { cachedInputTokens },
1638
- ...cacheCreationInputTokens !== null && { cacheCreationInputTokens }
1639
- };
1640
- } catch {
1641
- logger.debug("Skipped malformed output line", { snippet: raw.slice(0, 100) });
1642
- return null;
1643
- }
1644
- }
1645
- /**
1646
- * Extracts the cost the Claude CLI reported for this call.
1647
- *
1648
- * Prefers `total_cost_usd` — the vendor's own total — over summing
1649
- * `modelUsage[*].costUSD`, because a per-model breakdown can omit a component
1650
- * the total includes. Both are declared on {@link ClaudeCliResponse} and
1651
- * neither reached `CliResponse` before #5241.
1652
- *
1653
- * Rejects a negative or non-finite figure: a cost is a measurement, and
1654
- * letting a corrupt one through would debit the budget router with garbage.
1655
- */
1656
- extractCostUsd(raw) {
1657
- try {
1658
- const record = asRecord(JSON.parse(raw));
1659
- if (record === null) return null;
1660
- const total = record.total_cost_usd;
1661
- if (typeof total === "number") return isUsableCost(total) ? total : null;
1662
- return sumModelUsageCost(record.modelUsage);
1663
- } catch {
1664
- logger.debug("Skipped malformed output line", { snippet: raw.slice(0, 100) });
1665
- return null;
1666
- }
1667
- }
1668
- /**
1669
- * Extracts session ID for resumption.
1670
- */
1671
- extractSessionId(raw) {
1672
- try {
1673
- const data = JSON.parse(raw);
1674
- const record = asRecord(data);
1675
- if (record === null) return null;
1676
- const sessionId = record.session_id;
1677
- if (typeof sessionId === "string") {
1678
- return sessionId;
1679
- }
1680
- return null;
1681
- } catch {
1682
- logger.debug("Skipped malformed output line", { snippet: raw.slice(0, 100) });
1683
- return null;
1684
- }
1685
- }
1686
- /**
1687
- * Type guard for valid response structure.
1688
- */
1689
- isValidResponse(data) {
1690
- const record = asRecord(data);
1691
- if (record === null) return false;
1692
- return typeof record.result === "string";
1693
- }
1694
- };
1695
-
1696
- // src/cli-adapters/adapters/claude-adapter.ts
1697
- var MODEL_TO_CLI_ALIAS = buildClaudeAliasMap();
1698
- function buildClaudeAliasMap() {
1699
- const map = {};
1700
- for (const model of findInTreeByCli("claude")) {
1701
- if (model.cliAlias === void 0) continue;
1702
- const alias = model.cliAlias;
1703
- map[alias] = alias;
1704
- map[model.id] = alias;
1705
- if (model.cliModelName !== void 0) map[model.cliModelName] = alias;
1706
- for (const legacyName of model.aliases ?? []) {
1707
- map[legacyName] = alias;
1708
- }
1709
- }
1710
- return map;
1711
- }
1712
- var UNKNOWN_MODEL_DEFAULT_INPUT_COST = 5;
1713
- var UNKNOWN_MODEL_DEFAULT_OUTPUT_COST = 25;
1714
- var IN_FAMILY_FALLBACK_OPTION = "inFamilyFallback";
1715
- function toCliAlias(internalModel) {
1716
- return MODEL_TO_CLI_ALIAS[internalModel] ?? internalModel;
1717
- }
1718
- function nextClaudeAlias(alias) {
1719
- const aliases = getDefaultRegistry().allEntries().flatMap(
1720
- (entry) => entry.cliName === "claude" && entry.cliAlias !== void 0 ? [entry.cliAlias] : []
1721
- );
1722
- const at = aliases.indexOf(alias);
1723
- return at === -1 ? void 0 : aliases[at + 1];
1724
- }
1725
- var CLAUDE_READ_ONLY_TOOLS = ["Read", "Grep", "Glob"];
1726
- var CLAUDE_READ_ONLY_DISALLOWED_TOOLS = [
1727
- "Bash",
1728
- "Edit",
1729
- "Write",
1730
- "NotebookEdit",
1731
- "WebFetch",
1732
- "WebSearch"
1733
- ];
1734
- var CLAUDE_WORKSPACE_EDIT_TOOLS = ["Read", "Grep", "Glob", "Edit", "Write"];
1735
- var CLAUDE_WORKSPACE_EDIT_DISALLOWED_TOOLS = [
1736
- "Bash",
1737
- "NotebookEdit",
1738
- "WebFetch",
1739
- "WebSearch"
1740
- ];
1741
- function restrictedModeArgs(task) {
1742
- if (isReadOnlyAnalysis(task)) {
1743
- return [
1744
- "--permission-mode",
1745
- "manual",
1746
- "--tools",
1747
- CLAUDE_READ_ONLY_TOOLS.join(","),
1748
- "--strict-mcp-config",
1749
- "--disallowedTools",
1750
- CLAUDE_READ_ONLY_DISALLOWED_TOOLS.join(",")
1751
- ];
1752
- }
1753
- if (isWorkspaceEdit(task)) {
1754
- return [
1755
- "--permission-mode",
1756
- "acceptEdits",
1757
- "--tools",
1758
- CLAUDE_WORKSPACE_EDIT_TOOLS.join(","),
1759
- "--strict-mcp-config",
1760
- "--disallowedTools",
1761
- CLAUDE_WORKSPACE_EDIT_DISALLOWED_TOOLS.join(",")
1762
- ];
1763
- }
1764
- return void 0;
1765
- }
1766
- var ClaudeCliAdapter = class extends SubprocessCliAdapter {
1767
- name = "claude";
1768
- enforcesReadOnlyAnalysis = true;
1769
- enforcesWorkspaceEdit = true;
1770
- claudeParser = new ClaudeResponseParser();
1771
- parser = this.claudeParser;
1772
- model;
1773
- constructor(options) {
1774
- super(options?.logger);
1775
- this.model = options?.model ?? getCliModelName(getDefaultModelForCli("claude"));
1776
- }
1777
- /**
1778
- * Key-free model enumeration (#3405): the claude CLI has no list-models
1779
- * command and its OAuth token can't call /v1/models, so we enumerate the
1780
- * vendor's models from the models.dev snapshot. Existence only.
1781
- */
1782
- listModels() {
1783
- return Promise.resolve(listModelsForCli(this.name));
1784
- }
1785
- /**
1786
- * Gets Claude model information.
1787
- * `buildModelInfo` matches `cliModelName`, `cliAlias`, and `aliases[]` —
1788
- * a single call handles 'opus', 'sonnet', 'haiku', current model names,
1789
- * and the legacy `claude-opus-4` / `claude-haiku-3` / etc. entries that
1790
- * live in the registry's aliases since #2200 Child 1.
1791
- *
1792
- * Truly unrecognized models fall through to conservative defaults
1793
- * (current Opus pricing).
1794
- */
1795
- getModelInfo() {
1796
- const fromRegistry = buildModelInfo("claude", this.model);
1797
- if (fromRegistry !== void 0) return fromRegistry;
1798
- return {
1799
- id: this.model,
1800
- name: this.model,
1801
- contextWindow: FALLBACK_CONTEXT_WINDOW,
1802
- maxOutput: FALLBACK_MAX_OUTPUT,
1803
- costPerMillionInput: UNKNOWN_MODEL_DEFAULT_INPUT_COST,
1804
- costPerMillionOutput: UNKNOWN_MODEL_DEFAULT_OUTPUT_COST
1805
- };
1806
- }
1807
- /**
1808
- * Run the task, and on an out-of-credits envelope for the requested model
1809
- * retry ONCE with the next claude alias the registry lists (#6120).
1810
- *
1811
- * The credit exhaustion the claude CLI reports is per MODEL — `fable`
1812
- * answered "You're out of usage credits" while `sonnet` answered the same
1813
- * prompt — so it is not evidence against the CLI, and it must not reach the
1814
- * per-CLI circuit breaker as one. The breaker records what leaves this
1815
- * method: a substituted success records nothing, and a second capacity
1816
- * error propagates as the typed error and counts once, because by then the
1817
- * family, not one model, has failed. A non-capacity `is_error` (auth, a
1818
- * server error) is returned as-is; another model would not fix it.
1819
- *
1820
- * The substitution is stamped on the response as `fallbackFrom` so a vote
1821
- * record can say which model actually answered (#6115).
1822
- *
1823
- * Tool calls claude's permission layer refused are copied from the result
1824
- * envelope onto the response as `permissionDenials` (#6792).
1825
- */
1826
- async executeTask(task, options) {
1827
- const result = await this.executeWithFallback(task, options);
1828
- if (!result.ok || typeof result.value.raw !== "string") return result;
1829
- const denials = this.claudeParser.extractPermissionDenials(result.value.raw);
1830
- return denials === null ? result : ok({ ...result.value, permissionDenials: denials });
1831
- }
1832
- /** {@link executeTask}'s run with the one in-family retry (#6120). */
1833
- async executeWithFallback(task, options) {
1834
- const first = await super.executeTask(task, options);
1835
- if (first.ok || !isDurableCapacityText(first.error.message)) return first;
1836
- if (task.options?.[IN_FAMILY_FALLBACK_OPTION] === false) return first;
1837
- const requested = toCliAlias(task.model ?? this.model);
1838
- const next = nextClaudeAlias(requested);
1839
- if (next === void 0) return first;
1840
- this.logger.warn("Claude model out of usage credits; retrying once with the next alias", {
1841
- requested,
1842
- next
1843
- });
1844
- const second = await super.executeTask({ ...task, model: next }, options);
1845
- if (!second.ok) return second;
1846
- return ok({ ...second.value, model: next, fallbackFrom: requested });
1847
- }
1848
- /**
1849
- * #6754/#6792: a permission bypass would defeat either restricted mode, so
1850
- * the combination is refused rather than resolved one way silently.
1851
- */
1852
- async accessModeRefusal(task) {
1853
- const base = await super.accessModeRefusal(task);
1854
- const mode = restrictedAccessMode(task);
1855
- if (base !== void 0 || mode === void 0) return base;
1856
- if (task.options?.["skipPermissions"] === true) {
1857
- return accessModeConflict(this.name, mode, "the task also asks to skip permissions");
1858
- }
1859
- if (typeof task.options?.["mcpConfigPath"] === "string") {
1860
- return accessModeConflict(this.name, mode, "the task also names an MCP config");
1861
- }
1862
- return void 0;
1863
- }
1864
- /** Appends optional string-type task options to CLI args. */
1865
- appendTaskOptions(args, task) {
1866
- const workDir = task.options?.["workDir"];
1867
- if (typeof workDir === "string" && workDir.length > 0) {
1868
- args.push("--add-dir", workDir);
1869
- }
1870
- const mcpConfigPath = task.options?.["mcpConfigPath"];
1871
- if (typeof mcpConfigPath === "string" && mcpConfigPath.length > 0) {
1872
- args.push("--mcp-config", mcpConfigPath);
1873
- }
1874
- const modeArgs = restrictedModeArgs(task);
1875
- if (modeArgs !== void 0) {
1876
- args.push(...modeArgs);
1877
- return;
1878
- }
1879
- if (task.options?.["skipPermissions"] === true) {
1880
- args.push("--dangerously-skip-permissions");
1881
- }
1882
- }
1883
- /**
1884
- * Gets CLI command and arguments for execution.
1885
- * Uses stdin for the prompt to avoid argument escaping issues,
1886
- * especially important when using --add-dir.
1887
- */
1888
- getCommand(task) {
1889
- const args = ["-p", "--output-format", "json"];
1890
- const internalModel = task.model ?? this.model;
1891
- const cliModel = toCliAlias(internalModel);
1892
- args.push("--model", cliModel);
1893
- if (task.systemPrompt !== void 0 && task.systemPrompt !== "") {
1894
- args.push("--system-prompt", task.systemPrompt);
1895
- }
1896
- if (task.sessionId !== void 0 && task.sessionId !== "") {
1897
- args.push("--resume", task.sessionId);
1898
- }
1899
- this.appendTaskOptions(args, task);
1900
- return { command: "claude", args, stdin: task.content };
1901
- }
1902
- };
1903
-
1904
1480
  export {
1905
1481
  CLI_TIMEOUT_PROFILES,
1906
1482
  DEFAULT_TIMEOUT_PROFILE,
@@ -1925,9 +1501,6 @@ export {
1925
1501
  getAbortObservation,
1926
1502
  MAX_RESPONSE_STDERR_CHARS,
1927
1503
  spawnCwd,
1928
- SubprocessCliAdapter,
1929
- ClaudeResponseParser,
1930
- IN_FAMILY_FALLBACK_OPTION,
1931
- ClaudeCliAdapter
1504
+ SubprocessCliAdapter
1932
1505
  };
1933
- //# sourceMappingURL=chunk-MFBTGXR6.js.map
1506
+ //# sourceMappingURL=chunk-3QKRY72I.js.map