nexus-agents 8.89.0 → 8.89.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.
Files changed (148) hide show
  1. package/dist/{ast-rule-runner-HYMHJPAG.js → ast-rule-runner-AMZCLKRV.js} +5 -5
  2. package/dist/{child-mcp-config-V2KDXRWX.js → child-mcp-config-7DSYI325.js} +5 -5
  3. package/dist/{chunk-V2DMA45O.js → chunk-3IBALX36.js} +2 -2
  4. package/dist/{chunk-KTYUDC5Q.js → chunk-3PQIIMHN.js} +2 -2
  5. package/dist/{chunk-DQ3XMBOE.js → chunk-4IV25ZUM.js} +2 -2
  6. package/dist/{chunk-2KSAG3VC.js → chunk-5GZ4UN5F.js} +2 -2
  7. package/dist/{chunk-EEVZ7GLC.js → chunk-5UCGVAEZ.js} +4 -4
  8. package/dist/{chunk-4LRBHXR2.js → chunk-5XZCL7QT.js} +13 -13
  9. package/dist/{chunk-NOJ6LVFH.js → chunk-6FFBX665.js} +2 -2
  10. package/dist/{chunk-V6D32OOI.js → chunk-AXBEG6VW.js} +3 -3
  11. package/dist/{chunk-AQE77PSX.js → chunk-BJXSG5YL.js} +4 -4
  12. package/dist/{chunk-KZPXD7U6.js → chunk-CG7OSI5P.js} +3 -3
  13. package/dist/{chunk-W4VUK2R4.js → chunk-E6AJH4F4.js} +42 -41
  14. package/dist/{chunk-W4VUK2R4.js.map → chunk-E6AJH4F4.js.map} +1 -1
  15. package/dist/{chunk-VD5K6GS2.js → chunk-EKZ6V7SE.js} +9 -7
  16. package/dist/chunk-EKZ6V7SE.js.map +1 -0
  17. package/dist/{chunk-Z5UEPOL6.js → chunk-GXBXZCY7.js} +193 -34
  18. package/dist/chunk-GXBXZCY7.js.map +1 -0
  19. package/dist/{chunk-7EOV55QT.js → chunk-GYQIIAVM.js} +4 -4
  20. package/dist/{chunk-ZRHH7LN6.js → chunk-HLXXP3CS.js} +4 -4
  21. package/dist/{chunk-EPAGKDF6.js → chunk-ILA4UGXI.js} +2 -2
  22. package/dist/{chunk-BHU67ATO.js → chunk-JRZEB4OQ.js} +2 -2
  23. package/dist/{chunk-RGS3FYTS.js → chunk-JYKRCQSU.js} +5 -5
  24. package/dist/{chunk-WV23K2TM.js → chunk-JYZNPK62.js} +10 -10
  25. package/dist/{chunk-NQFMVMAK.js → chunk-KQE7EFBF.js} +7 -7
  26. package/dist/{chunk-HRZGFSSS.js → chunk-LFFXUHX3.js} +2 -2
  27. package/dist/{chunk-RNDHNRSX.js → chunk-LWOX65CP.js} +102 -21
  28. package/dist/chunk-LWOX65CP.js.map +1 -0
  29. package/dist/{chunk-BYQNCZSZ.js → chunk-LZNYQYDU.js} +2 -2
  30. package/dist/{chunk-4DSPBZY3.js → chunk-NZN3SWSZ.js} +17 -9
  31. package/dist/chunk-NZN3SWSZ.js.map +1 -0
  32. package/dist/{chunk-HERI7LXN.js → chunk-OITVVSWO.js} +2 -2
  33. package/dist/{chunk-O5L3O6ZP.js → chunk-PENEGF75.js} +2 -2
  34. package/dist/{chunk-X5JKKMNU.js → chunk-SCXCJSTT.js} +2 -2
  35. package/dist/{chunk-RE4CUPIU.js → chunk-TLFZPJOY.js} +4 -4
  36. package/dist/{chunk-6NHMBRTQ.js → chunk-TRCYUQ4M.js} +2 -2
  37. package/dist/{chunk-Z2JDWZNH.js → chunk-UDWZJY3V.js} +2 -2
  38. package/dist/{chunk-RQLIPUQK.js → chunk-UE7A2XHM.js} +2 -2
  39. package/dist/{chunk-HNWZNCST.js → chunk-VM4HZT3B.js} +6 -6
  40. package/dist/{chunk-BYVS6N3C.js → chunk-XJAGCUMD.js} +3 -3
  41. package/dist/{chunk-RKLT2TOT.js → chunk-XJWIBTUM.js} +2 -2
  42. package/dist/{chunk-ICPAPQKC.js → chunk-XU2SJKFK.js} +2 -2
  43. package/dist/{chunk-7D6D6SG2.js → chunk-Z5VUMKF5.js} +3 -3
  44. package/dist/{chunk-NLN7YJDT.js → chunk-ZTTBGME2.js} +2 -2
  45. package/dist/{cli-circuit-breaker-V3JIKQNR.js → cli-circuit-breaker-MCQG3PQK.js} +5 -5
  46. package/dist/cli.d.ts +1 -1
  47. package/dist/cli.js +62 -58
  48. package/dist/cli.js.map +1 -1
  49. package/dist/{composite-router-GY36ICWT.js → composite-router-QAYCHEFG.js} +4 -4
  50. package/dist/{consensus-vote-6ZU7GKSG.js → consensus-vote-UHNEKOO7.js} +20 -20
  51. package/dist/{consensus-vote-types-ptxFNv55.d.ts → consensus-vote-types-DhmacUE7.d.ts} +12 -0
  52. package/dist/{context-retriever-MIEU5JEN.js → context-retriever-UXQCDDRY.js} +11 -11
  53. package/dist/doctor-deep-QRLRDFM4.js +13 -0
  54. package/dist/{doctor-live-LTNJVKXN.js → doctor-live-CUKBQSSH.js} +13 -13
  55. package/dist/{expert-bridge-RU2W64EM.js → expert-bridge-ZG2IA3RJ.js} +6 -6
  56. package/dist/factory-FPNYFKXU.js +15 -0
  57. package/dist/factory-RQEHJ4AW.js +27 -0
  58. package/dist/{improvement-review-THY3BKTW.js → improvement-review-N36SVUDG.js} +7 -7
  59. package/dist/index.d.ts +12 -5
  60. package/dist/index.js +34 -34
  61. package/dist/{init-opencode-EZKEBCXO.js → init-opencode-4QECASK4.js} +7 -7
  62. package/dist/issue-triage-BIEZBWV2.js +16 -0
  63. package/dist/{learning-persistence-ER7E5Q6T.js → learning-persistence-FB4U5AX2.js} +3 -3
  64. package/dist/{pr-reviewer-helpers-NSXZZZPF.js → pr-reviewer-helpers-RK5IT4US.js} +6 -6
  65. package/dist/{registry-command-WZYYQVRI.js → registry-command-MBZFFDWS.js} +4 -4
  66. package/dist/{repo-security-plan-6BINWUKE.js → repo-security-plan-W76YLC2M.js} +5 -5
  67. package/dist/research-helpers-synthesize-GI5JFAQM.js +14 -0
  68. package/dist/{routing-memory-DLFZLG4R.js → routing-memory-WLCUOPDE.js} +4 -4
  69. package/dist/{session-memory-DHPZAKZW.js → session-memory-HU3XMQEH.js} +5 -5
  70. package/dist/setup-config-XA756R2O.js +11 -0
  71. package/dist/{setup-custom-api-5YAYMVXH.js → setup-custom-api-ETBGOE7O.js} +6 -6
  72. package/dist/setup-data-dir-UNM34FGW.js +32 -0
  73. package/dist/{tool-memory-TQCQJUC2.js → tool-memory-7XMQAQQM.js} +8 -8
  74. package/dist/{tool-memory-registry-adapters-2WWNV55A.js → tool-memory-registry-adapters-7CNLBBZU.js} +3 -3
  75. package/dist/{unified-registry-AGIN3Q3S.js → unified-registry-LR4OCUFI.js} +13 -13
  76. package/dist/{weather-report-5FMZQP5L.js → weather-report-UYKQUSBB.js} +4 -4
  77. package/package.json +1 -1
  78. package/dist/chunk-4DSPBZY3.js.map +0 -1
  79. package/dist/chunk-RNDHNRSX.js.map +0 -1
  80. package/dist/chunk-VD5K6GS2.js.map +0 -1
  81. package/dist/chunk-Z5UEPOL6.js.map +0 -1
  82. package/dist/doctor-deep-4J6BX5BV.js +0 -13
  83. package/dist/factory-2H6BJGI5.js +0 -27
  84. package/dist/factory-OJHA452T.js +0 -15
  85. package/dist/issue-triage-KSW7SNU6.js +0 -16
  86. package/dist/research-helpers-synthesize-F6PQD2SG.js +0 -14
  87. package/dist/setup-config-SLS5DTFQ.js +0 -11
  88. package/dist/setup-data-dir-J2AJOTLA.js +0 -32
  89. /package/dist/{ast-rule-runner-HYMHJPAG.js.map → ast-rule-runner-AMZCLKRV.js.map} +0 -0
  90. /package/dist/{child-mcp-config-V2KDXRWX.js.map → child-mcp-config-7DSYI325.js.map} +0 -0
  91. /package/dist/{chunk-V2DMA45O.js.map → chunk-3IBALX36.js.map} +0 -0
  92. /package/dist/{chunk-KTYUDC5Q.js.map → chunk-3PQIIMHN.js.map} +0 -0
  93. /package/dist/{chunk-DQ3XMBOE.js.map → chunk-4IV25ZUM.js.map} +0 -0
  94. /package/dist/{chunk-2KSAG3VC.js.map → chunk-5GZ4UN5F.js.map} +0 -0
  95. /package/dist/{chunk-EEVZ7GLC.js.map → chunk-5UCGVAEZ.js.map} +0 -0
  96. /package/dist/{chunk-4LRBHXR2.js.map → chunk-5XZCL7QT.js.map} +0 -0
  97. /package/dist/{chunk-NOJ6LVFH.js.map → chunk-6FFBX665.js.map} +0 -0
  98. /package/dist/{chunk-V6D32OOI.js.map → chunk-AXBEG6VW.js.map} +0 -0
  99. /package/dist/{chunk-AQE77PSX.js.map → chunk-BJXSG5YL.js.map} +0 -0
  100. /package/dist/{chunk-KZPXD7U6.js.map → chunk-CG7OSI5P.js.map} +0 -0
  101. /package/dist/{chunk-7EOV55QT.js.map → chunk-GYQIIAVM.js.map} +0 -0
  102. /package/dist/{chunk-ZRHH7LN6.js.map → chunk-HLXXP3CS.js.map} +0 -0
  103. /package/dist/{chunk-EPAGKDF6.js.map → chunk-ILA4UGXI.js.map} +0 -0
  104. /package/dist/{chunk-BHU67ATO.js.map → chunk-JRZEB4OQ.js.map} +0 -0
  105. /package/dist/{chunk-RGS3FYTS.js.map → chunk-JYKRCQSU.js.map} +0 -0
  106. /package/dist/{chunk-WV23K2TM.js.map → chunk-JYZNPK62.js.map} +0 -0
  107. /package/dist/{chunk-NQFMVMAK.js.map → chunk-KQE7EFBF.js.map} +0 -0
  108. /package/dist/{chunk-HRZGFSSS.js.map → chunk-LFFXUHX3.js.map} +0 -0
  109. /package/dist/{chunk-BYQNCZSZ.js.map → chunk-LZNYQYDU.js.map} +0 -0
  110. /package/dist/{chunk-HERI7LXN.js.map → chunk-OITVVSWO.js.map} +0 -0
  111. /package/dist/{chunk-O5L3O6ZP.js.map → chunk-PENEGF75.js.map} +0 -0
  112. /package/dist/{chunk-X5JKKMNU.js.map → chunk-SCXCJSTT.js.map} +0 -0
  113. /package/dist/{chunk-RE4CUPIU.js.map → chunk-TLFZPJOY.js.map} +0 -0
  114. /package/dist/{chunk-6NHMBRTQ.js.map → chunk-TRCYUQ4M.js.map} +0 -0
  115. /package/dist/{chunk-Z2JDWZNH.js.map → chunk-UDWZJY3V.js.map} +0 -0
  116. /package/dist/{chunk-RQLIPUQK.js.map → chunk-UE7A2XHM.js.map} +0 -0
  117. /package/dist/{chunk-HNWZNCST.js.map → chunk-VM4HZT3B.js.map} +0 -0
  118. /package/dist/{chunk-BYVS6N3C.js.map → chunk-XJAGCUMD.js.map} +0 -0
  119. /package/dist/{chunk-RKLT2TOT.js.map → chunk-XJWIBTUM.js.map} +0 -0
  120. /package/dist/{chunk-ICPAPQKC.js.map → chunk-XU2SJKFK.js.map} +0 -0
  121. /package/dist/{chunk-7D6D6SG2.js.map → chunk-Z5VUMKF5.js.map} +0 -0
  122. /package/dist/{chunk-NLN7YJDT.js.map → chunk-ZTTBGME2.js.map} +0 -0
  123. /package/dist/{cli-circuit-breaker-V3JIKQNR.js.map → cli-circuit-breaker-MCQG3PQK.js.map} +0 -0
  124. /package/dist/{composite-router-GY36ICWT.js.map → composite-router-QAYCHEFG.js.map} +0 -0
  125. /package/dist/{consensus-vote-6ZU7GKSG.js.map → consensus-vote-UHNEKOO7.js.map} +0 -0
  126. /package/dist/{context-retriever-MIEU5JEN.js.map → context-retriever-UXQCDDRY.js.map} +0 -0
  127. /package/dist/{doctor-deep-4J6BX5BV.js.map → doctor-deep-QRLRDFM4.js.map} +0 -0
  128. /package/dist/{doctor-live-LTNJVKXN.js.map → doctor-live-CUKBQSSH.js.map} +0 -0
  129. /package/dist/{expert-bridge-RU2W64EM.js.map → expert-bridge-ZG2IA3RJ.js.map} +0 -0
  130. /package/dist/{factory-2H6BJGI5.js.map → factory-FPNYFKXU.js.map} +0 -0
  131. /package/dist/{factory-OJHA452T.js.map → factory-RQEHJ4AW.js.map} +0 -0
  132. /package/dist/{improvement-review-THY3BKTW.js.map → improvement-review-N36SVUDG.js.map} +0 -0
  133. /package/dist/{init-opencode-EZKEBCXO.js.map → init-opencode-4QECASK4.js.map} +0 -0
  134. /package/dist/{issue-triage-KSW7SNU6.js.map → issue-triage-BIEZBWV2.js.map} +0 -0
  135. /package/dist/{learning-persistence-ER7E5Q6T.js.map → learning-persistence-FB4U5AX2.js.map} +0 -0
  136. /package/dist/{pr-reviewer-helpers-NSXZZZPF.js.map → pr-reviewer-helpers-RK5IT4US.js.map} +0 -0
  137. /package/dist/{registry-command-WZYYQVRI.js.map → registry-command-MBZFFDWS.js.map} +0 -0
  138. /package/dist/{repo-security-plan-6BINWUKE.js.map → repo-security-plan-W76YLC2M.js.map} +0 -0
  139. /package/dist/{research-helpers-synthesize-F6PQD2SG.js.map → research-helpers-synthesize-GI5JFAQM.js.map} +0 -0
  140. /package/dist/{routing-memory-DLFZLG4R.js.map → routing-memory-WLCUOPDE.js.map} +0 -0
  141. /package/dist/{session-memory-DHPZAKZW.js.map → session-memory-HU3XMQEH.js.map} +0 -0
  142. /package/dist/{setup-config-SLS5DTFQ.js.map → setup-config-XA756R2O.js.map} +0 -0
  143. /package/dist/{setup-custom-api-5YAYMVXH.js.map → setup-custom-api-ETBGOE7O.js.map} +0 -0
  144. /package/dist/{setup-data-dir-J2AJOTLA.js.map → setup-data-dir-UNM34FGW.js.map} +0 -0
  145. /package/dist/{tool-memory-TQCQJUC2.js.map → tool-memory-7XMQAQQM.js.map} +0 -0
  146. /package/dist/{tool-memory-registry-adapters-2WWNV55A.js.map → tool-memory-registry-adapters-7CNLBBZU.js.map} +0 -0
  147. /package/dist/{unified-registry-AGIN3Q3S.js.map → unified-registry-LR4OCUFI.js.map} +0 -0
  148. /package/dist/{weather-report-5FMZQP5L.js.map → weather-report-UYKQUSBB.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  VERSION
3
- } from "./chunk-BHU67ATO.js";
3
+ } from "./chunk-JRZEB4OQ.js";
4
4
  import {
5
5
  sanitizeErrorDetails
6
6
  } from "./chunk-2NDA4DHW.js";
@@ -23,11 +23,11 @@ import {
23
23
  getTimeProvider,
24
24
  ok,
25
25
  resolveToolClassGuardMs
26
- } from "./chunk-4DSPBZY3.js";
26
+ } from "./chunk-NZN3SWSZ.js";
27
27
  import {
28
28
  getNexusDataDir,
29
29
  parseBoolValue
30
- } from "./chunk-RNDHNRSX.js";
30
+ } from "./chunk-LWOX65CP.js";
31
31
 
32
32
  // src/mcp/middleware/validation.ts
33
33
  function validateToolInput(schema, args) {
@@ -2342,4 +2342,4 @@ export {
2342
2342
  DEFAULT_CONSENSUS_CONFIG,
2343
2343
  ConsensusMetricsSchema
2344
2344
  };
2345
- //# sourceMappingURL=chunk-7EOV55QT.js.map
2345
+ //# sourceMappingURL=chunk-GYQIIAVM.js.map
@@ -7,7 +7,7 @@ import {
7
7
  toolStructuredError,
8
8
  toolSuccessStructured,
9
9
  wrapToolWithTimeout
10
- } from "./chunk-7EOV55QT.js";
10
+ } from "./chunk-GYQIIAVM.js";
11
11
  import {
12
12
  JsonlStore,
13
13
  SECURITY_KEYWORDS,
@@ -20,11 +20,11 @@ import {
20
20
  getTimeProvider,
21
21
  isDeclaredNeverDeprecate,
22
22
  isRegisteredToolName
23
- } from "./chunk-4DSPBZY3.js";
23
+ } from "./chunk-NZN3SWSZ.js";
24
24
  import {
25
25
  getNexusDataDir,
26
26
  nexusDataPath
27
- } from "./chunk-RNDHNRSX.js";
27
+ } from "./chunk-LWOX65CP.js";
28
28
 
29
29
  // src/mcp/tools/improvement-review.ts
30
30
  import { readFile } from "node:fs/promises";
@@ -2282,4 +2282,4 @@ export {
2282
2282
  runImprovementReview,
2283
2283
  registerImprovementReviewTool
2284
2284
  };
2285
- //# sourceMappingURL=chunk-ZRHH7LN6.js.map
2285
+ //# sourceMappingURL=chunk-HLXXP3CS.js.map
@@ -4,7 +4,7 @@ import {
4
4
  getErrorMessage,
5
5
  getTimeProvider,
6
6
  ok
7
- } from "./chunk-4DSPBZY3.js";
7
+ } from "./chunk-NZN3SWSZ.js";
8
8
 
9
9
  // src/context/session-memory.ts
10
10
  import * as fs from "node:fs";
@@ -370,4 +370,4 @@ export {
370
370
  SessionMemory,
371
371
  createSessionMemory
372
372
  };
373
- //# sourceMappingURL=chunk-EPAGKDF6.js.map
373
+ //# sourceMappingURL=chunk-ILA4UGXI.js.map
@@ -1,6 +1,6 @@
1
1
  // src/version.ts
2
2
  import semver from "semver";
3
- var VERSION = true ? "8.89.0" : "dev";
3
+ var VERSION = true ? "8.89.2" : "dev";
4
4
  var NODE_ENGINE_RANGE = ">=22.5.0";
5
5
  function isNodeVersionSupported(version) {
6
6
  return semver.satisfies(version, NODE_ENGINE_RANGE);
@@ -11,4 +11,4 @@ export {
11
11
  NODE_ENGINE_RANGE,
12
12
  isNodeVersionSupported
13
13
  };
14
- //# sourceMappingURL=chunk-BHU67ATO.js.map
14
+ //# sourceMappingURL=chunk-JRZEB4OQ.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  GitHubProvider,
3
3
  ScmError
4
- } from "./chunk-X5JKKMNU.js";
4
+ } from "./chunk-SCXCJSTT.js";
5
5
  import {
6
6
  ROLE_DEFAULT_TRUST,
7
7
  ReputationCache,
@@ -12,10 +12,10 @@ import {
12
12
  resolveEnvMode,
13
13
  resolveReputationGatingMode,
14
14
  sanitizeInput
15
- } from "./chunk-2KSAG3VC.js";
15
+ } from "./chunk-5GZ4UN5F.js";
16
16
  import {
17
17
  hasToken
18
- } from "./chunk-Z2JDWZNH.js";
18
+ } from "./chunk-UDWZJY3V.js";
19
19
  import {
20
20
  CLI_SUBPROCESS_TIMEOUTS,
21
21
  createLogger,
@@ -23,7 +23,7 @@ import {
23
23
  getErrorMessage,
24
24
  getTimeProvider,
25
25
  ok
26
- } from "./chunk-4DSPBZY3.js";
26
+ } from "./chunk-NZN3SWSZ.js";
27
27
 
28
28
  // src/security/firewall/firewall-policy-mode.ts
29
29
  import { z } from "zod";
@@ -2650,4 +2650,4 @@ export {
2650
2650
  IssueTriage,
2651
2651
  createIssueTriage
2652
2652
  };
2653
- //# sourceMappingURL=chunk-RGS3FYTS.js.map
2653
+ //# sourceMappingURL=chunk-JYKRCQSU.js.map
@@ -5,23 +5,23 @@ import {
5
5
  planOptionalParams,
6
6
  requireApiKey,
7
7
  validateApiKeyPresence
8
- } from "./chunk-NLN7YJDT.js";
8
+ } from "./chunk-ZTTBGME2.js";
9
9
  import {
10
10
  CUSTOM_API_DEFAULT_MODEL
11
- } from "./chunk-BYVS6N3C.js";
11
+ } from "./chunk-XJAGCUMD.js";
12
12
  import {
13
13
  assertCustomApiHostResolvesPublic,
14
14
  hostnameOf,
15
15
  readGatewayEnv,
16
16
  redactApiKey,
17
17
  validateCustomApiBaseUrl
18
- } from "./chunk-BYQNCZSZ.js";
18
+ } from "./chunk-LZNYQYDU.js";
19
19
  import {
20
20
  nexusMkdtempSync
21
- } from "./chunk-HERI7LXN.js";
21
+ } from "./chunk-OITVVSWO.js";
22
22
  import {
23
23
  getAvailabilityCache
24
- } from "./chunk-NOJ6LVFH.js";
24
+ } from "./chunk-6FFBX665.js";
25
25
  import {
26
26
  sanitizeOutput
27
27
  } from "./chunk-2NDA4DHW.js";
@@ -30,13 +30,13 @@ import {
30
30
  } from "./chunk-QZUG667L.js";
31
31
  import {
32
32
  generateHyphenId
33
- } from "./chunk-DQ3XMBOE.js";
33
+ } from "./chunk-4IV25ZUM.js";
34
34
  import {
35
35
  CliCircuitBreaker,
36
36
  DEFAULT_CIRCUIT_BREAKER_CONFIG,
37
37
  getCliCircuitBreakerSnapshot,
38
38
  getDefaultCliCircuitBreakerRegistry
39
- } from "./chunk-ICPAPQKC.js";
39
+ } from "./chunk-XU2SJKFK.js";
40
40
  import {
41
41
  CLI_SUBPROCESS_TIMEOUTS,
42
42
  CLI_TIMEOUTS,
@@ -81,10 +81,10 @@ import {
81
81
  resolveRetryAfterMs,
82
82
  retryAfterMsFromContext,
83
83
  warnIfGatewayCostUndeclared
84
- } from "./chunk-4DSPBZY3.js";
84
+ } from "./chunk-NZN3SWSZ.js";
85
85
  import {
86
86
  parseBoolValue
87
- } from "./chunk-RNDHNRSX.js";
87
+ } from "./chunk-LWOX65CP.js";
88
88
 
89
89
  // src/cli-adapters/token-usage-bridge.ts
90
90
  function toModelTokenUsage(usage) {
@@ -5263,4 +5263,4 @@ export {
5263
5263
  SdkAdapter,
5264
5264
  createAutoAdapter
5265
5265
  };
5266
- //# sourceMappingURL=chunk-WV23K2TM.js.map
5266
+ //# sourceMappingURL=chunk-JYZNPK62.js.map
@@ -8,13 +8,13 @@ import {
8
8
  loadTechniquesRegistry,
9
9
  resolveInsideRoot,
10
10
  savePapersRegistry
11
- } from "./chunk-KZPXD7U6.js";
11
+ } from "./chunk-CG7OSI5P.js";
12
12
  import {
13
13
  resolveToken
14
- } from "./chunk-Z2JDWZNH.js";
14
+ } from "./chunk-UDWZJY3V.js";
15
15
  import {
16
16
  getToolMemory
17
- } from "./chunk-HNWZNCST.js";
17
+ } from "./chunk-VM4HZT3B.js";
18
18
  import {
19
19
  capitalizeWords,
20
20
  tokenizeFiltered,
@@ -43,15 +43,15 @@ import {
43
43
  ok,
44
44
  registerPersistentDistillerFactory,
45
45
  sigmoidConfidence
46
- } from "./chunk-4DSPBZY3.js";
46
+ } from "./chunk-NZN3SWSZ.js";
47
47
  import {
48
48
  ensureLearningDir,
49
49
  getRulesFile
50
- } from "./chunk-RQLIPUQK.js";
50
+ } from "./chunk-UE7A2XHM.js";
51
51
  import {
52
52
  nexusDataPath,
53
53
  parseBoolEnv
54
- } from "./chunk-RNDHNRSX.js";
54
+ } from "./chunk-LWOX65CP.js";
55
55
 
56
56
  // src/learning/strategy-distiller-persistence.ts
57
57
  import { writeFileSync, readFileSync, renameSync, unlinkSync, existsSync } from "node:fs";
@@ -4275,4 +4275,4 @@ export {
4275
4275
  DEFAULT_CONTEXT_BUDGET_TOKENS,
4276
4276
  getContextPromptPrefix
4277
4277
  };
4278
- //# sourceMappingURL=chunk-NQFMVMAK.js.map
4278
+ //# sourceMappingURL=chunk-KQE7EFBF.js.map
@@ -3,7 +3,7 @@ import {
3
3
  ValidationError,
4
4
  createLogger,
5
5
  formatZodError
6
- } from "./chunk-4DSPBZY3.js";
6
+ } from "./chunk-NZN3SWSZ.js";
7
7
 
8
8
  // src/security/ast-rule-runner.ts
9
9
  import { existsSync } from "node:fs";
@@ -241,4 +241,4 @@ export {
241
241
  collectAstQaFindings,
242
242
  runAstQaRules
243
243
  };
244
- //# sourceMappingURL=chunk-HRZGFSSS.js.map
244
+ //# sourceMappingURL=chunk-LFFXUHX3.js.map
@@ -38,7 +38,7 @@ import {
38
38
  unlinkSync
39
39
  } from "node:fs";
40
40
  import { homedir as homedir2 } from "node:os";
41
- import { dirname as dirname2, isAbsolute as isAbsolute2, join as join2, resolve as resolve3 } from "node:path";
41
+ import { dirname as dirname2, isAbsolute as isAbsolute2, join as join3, resolve as resolve3 } from "node:path";
42
42
 
43
43
  // src/config/sandbox-detection.ts
44
44
  import { existsSync, readFileSync } from "node:fs";
@@ -71,8 +71,9 @@ function detectContainerHeuristic() {
71
71
  }
72
72
 
73
73
  // src/config/repo-root-detection.ts
74
+ import { execFileSync } from "node:child_process";
74
75
  import { existsSync as existsSync2, readFileSync as readFileSync2, realpathSync, statSync } from "node:fs";
75
- import { dirname, isAbsolute, resolve } from "node:path";
76
+ import { dirname, isAbsolute, join, resolve } from "node:path";
76
77
  function findRepoRoot(start) {
77
78
  if (!isAbsolute(start)) {
78
79
  start = resolve(start);
@@ -123,11 +124,89 @@ function isRepoRoot(dir) {
123
124
  }
124
125
  return false;
125
126
  }
127
+ var MAX_GIT_METADATA_BYTES = 4096;
128
+ function readGitMetadataLine(path) {
129
+ try {
130
+ if (!statSync(path).isFile() || statSync(path).size > MAX_GIT_METADATA_BYTES) return void 0;
131
+ const line = readFileSync2(path, "utf-8").split("\n")[0]?.trim();
132
+ return line === void 0 || line === "" ? void 0 : line;
133
+ } catch {
134
+ return void 0;
135
+ }
136
+ }
137
+ function realpathOrUndefined(path) {
138
+ try {
139
+ return realpathSync(path);
140
+ } catch {
141
+ return void 0;
142
+ }
143
+ }
144
+ var GIT_TIMEOUT_MS = 5e3;
145
+ function gitOutput(args) {
146
+ const env = Object.fromEntries(
147
+ Object.entries(process.env).filter(([key]) => !key.startsWith("GIT_"))
148
+ );
149
+ try {
150
+ const out = execFileSync("git", [...args], {
151
+ encoding: "utf-8",
152
+ stdio: ["ignore", "pipe", "ignore"],
153
+ timeout: GIT_TIMEOUT_MS,
154
+ env
155
+ }).trim();
156
+ return out === "" ? void 0 : out;
157
+ } catch {
158
+ return void 0;
159
+ }
160
+ }
161
+ function gitCommonDir(dir) {
162
+ const common = gitOutput(["-C", dir, "rev-parse", "--path-format=absolute", "--git-common-dir"]);
163
+ return common === void 0 ? void 0 : realpathOrUndefined(common);
164
+ }
165
+ function resolveMainCheckoutRoot(repoRoot) {
166
+ const adminDir = backReferencedAdminDir(repoRoot);
167
+ if (adminDir === void 0) return repoRoot;
168
+ const commonDir = gitCommonDir(repoRoot);
169
+ if (commonDir === void 0 || dirname(adminDir) !== join(commonDir, "worktrees")) {
170
+ return repoRoot;
171
+ }
172
+ return mainCheckoutOf(commonDir) ?? repoRoot;
173
+ }
174
+ function backReferencedAdminDir(repoRoot) {
175
+ const dotGit = join(repoRoot, ".git");
176
+ const target = readGitMetadataLine(dotGit)?.match(/^gitdir:\s*(.+)$/)?.[1]?.trim();
177
+ if (target === void 0) return void 0;
178
+ const adminDir = resolveGitPath(repoRoot, target);
179
+ if (adminDir === void 0) return void 0;
180
+ const backRef = readGitMetadataLine(join(adminDir, "gitdir"));
181
+ if (backRef === void 0) return void 0;
182
+ const pointsBack = resolveGitPath(adminDir, backRef) === realpathOrUndefined(dotGit);
183
+ return pointsBack ? adminDir : void 0;
184
+ }
185
+ function resolveGitPath(base, value) {
186
+ return realpathOrUndefined(isAbsolute(value) ? value : resolve(base, value));
187
+ }
188
+ function mainCheckoutOf(commonDir) {
189
+ const config = join(commonDir, "config");
190
+ if (gitOutput(["config", "--file", config, "--bool", "--get", "core.bare"]) === "true") {
191
+ return void 0;
192
+ }
193
+ const worktree = gitOutput(["config", "--file", config, "--get", "core.worktree"]);
194
+ const candidate = realpathOrUndefined(
195
+ worktree === void 0 ? dirname(commonDir) : resolveUnder(commonDir, worktree)
196
+ );
197
+ if (candidate === void 0 || gitCommonDir(candidate) !== commonDir) return void 0;
198
+ const topLevel = gitOutput(["-C", candidate, "rev-parse", "--show-toplevel"]);
199
+ if (topLevel === void 0 || realpathOrUndefined(topLevel) !== candidate) return void 0;
200
+ return candidate;
201
+ }
202
+ function resolveUnder(base, value) {
203
+ return isAbsolute(value) ? value : resolve(base, value);
204
+ }
126
205
 
127
206
  // src/config/portable-mode.ts
128
207
  import { accessSync, constants, existsSync as existsSync3, readFileSync as readFileSync3, appendFileSync, statSync as statSync2 } from "node:fs";
129
208
  import { homedir } from "node:os";
130
- import { join, resolve as resolve2 } from "node:path";
209
+ import { join as join2, resolve as resolve2 } from "node:path";
131
210
  var SANDBOX_ENV_VARS = [
132
211
  "KUBERNETES_SERVICE_HOST",
133
212
  "DOCKER_CONTAINER",
@@ -165,22 +244,22 @@ function checkExplicitEnv(cwd) {
165
244
  }
166
245
  const portableEnv = process.env["NEXUS_PORTABLE_MODE"];
167
246
  if (portableEnv === "0" || portableEnv === "false") {
168
- return { portable: false, dataDir: join(homedir(), ".nexus-agents"), reason: "env-opt-out" };
247
+ return { portable: false, dataDir: join2(homedir(), ".nexus-agents"), reason: "env-opt-out" };
169
248
  }
170
249
  if (portableEnv === "1" || portableEnv === "true") {
171
- return { portable: true, dataDir: join(cwd, ".nexus-agents"), reason: "env-opt-in" };
250
+ return { portable: true, dataDir: join2(cwd, ".nexus-agents"), reason: "env-opt-in" };
172
251
  }
173
252
  return null;
174
253
  }
175
254
  function checkHeuristics(cwd) {
176
255
  if (!isHomeWritable()) {
177
- return { portable: true, dataDir: join(cwd, ".nexus-agents"), reason: "home-unwritable" };
256
+ return { portable: true, dataDir: join2(cwd, ".nexus-agents"), reason: "home-unwritable" };
178
257
  }
179
258
  if (inSandboxEnv()) {
180
259
  const declaredRoot = sandboxRootFromEnv();
181
260
  return {
182
261
  portable: true,
183
- dataDir: join(declaredRoot ?? cwd, ".nexus-agents"),
262
+ dataDir: join2(declaredRoot ?? cwd, ".nexus-agents"),
184
263
  reason: "container-env"
185
264
  };
186
265
  }
@@ -189,7 +268,7 @@ function checkHeuristics(cwd) {
189
268
  function detectPortableMode(cwd = process.cwd()) {
190
269
  return checkExplicitEnv(cwd) ?? checkHeuristics(cwd) ?? {
191
270
  portable: false,
192
- dataDir: join(homedir(), ".nexus-agents"),
271
+ dataDir: join2(homedir(), ".nexus-agents"),
193
272
  reason: "default"
194
273
  };
195
274
  }
@@ -212,14 +291,14 @@ function applyPortableMode(cwd = process.cwd()) {
212
291
  }
213
292
  function isInsideGitRepo(cwd) {
214
293
  try {
215
- const gitDir = join(cwd, ".git");
294
+ const gitDir = join2(cwd, ".git");
216
295
  return existsSync3(gitDir) && statSync2(gitDir).isDirectory();
217
296
  } catch {
218
297
  return false;
219
298
  }
220
299
  }
221
300
  function ensureGitignored(cwd, entry) {
222
- const path = join(cwd, ".gitignore");
301
+ const path = join2(cwd, ".gitignore");
223
302
  try {
224
303
  const existing = existsSync3(path) ? readFileSync3(path, "utf-8") : "";
225
304
  const lines = existing.split("\n").map((l) => l.trim());
@@ -276,6 +355,7 @@ var PER_REPO_SUBDIRS = /* @__PURE__ */ new Set([
276
355
  // explicit `NEXUS_VOTE_RECORDS_PATH` override (#3991).
277
356
  "governance"
278
357
  ]);
358
+ var MAIN_CHECKOUT_SUBDIRS = /* @__PURE__ */ new Set(["governance"]);
279
359
  function getNexusDataDir() {
280
360
  const fromEnv = process.env["NEXUS_DATA_DIR"]?.trim();
281
361
  if (fromEnv !== void 0 && fromEnv !== "") {
@@ -285,7 +365,7 @@ function getNexusDataDir() {
285
365
  if (sandbox.active) {
286
366
  return resolve3(sandbox.root ?? "/", ".nexus-agents");
287
367
  }
288
- return join2(homedir2(), ".nexus-agents");
368
+ return join3(homedir2(), ".nexus-agents");
289
369
  }
290
370
  var gitignoredRoots = /* @__PURE__ */ new Set();
291
371
  var activeWorkspaceRoot;
@@ -307,15 +387,16 @@ function setActiveWorkspaceRoot(root) {
307
387
  function getActiveWorkspaceRoot() {
308
388
  return activeWorkspaceRoot;
309
389
  }
310
- function getNexusRepoDir() {
390
+ function getNexusRepoDir(options = {}) {
311
391
  if (!parseBoolEnv("NEXUS_REPO_PREFERRED", true)) return null;
312
392
  const fromEnv = process.env["NEXUS_DATA_DIR"]?.trim();
313
393
  if (fromEnv !== void 0 && fromEnv !== "") return null;
314
394
  if (detectSandbox().active) return null;
315
- const root = activeWorkspaceRoot ?? findRepoRoot(process.cwd());
316
- if (root === null) return null;
395
+ const found = activeWorkspaceRoot ?? findRepoRoot(process.cwd());
396
+ if (found === null) return null;
397
+ const root = options.mainCheckout === true ? resolveMainCheckoutRoot(found) : found;
317
398
  maybeAutoGitignore(root);
318
- return join2(root, ".nexus-agents");
399
+ return join3(root, ".nexus-agents");
319
400
  }
320
401
  function maybeAutoGitignore(repoRoot) {
321
402
  if (!parseBoolEnv("NEXUS_GITIGNORE_AUTO", true)) return;
@@ -349,20 +430,20 @@ function announceCrossRepoFallback(subdir, repoPath) {
349
430
  function nexusDataPath(...segments) {
350
431
  const first = segments[0];
351
432
  if (first !== void 0 && PER_REPO_SUBDIRS.has(first)) {
352
- const repoDir = getNexusRepoDir();
433
+ const repoDir = getNexusRepoDir({ mainCheckout: MAIN_CHECKOUT_SUBDIRS.has(first) });
353
434
  if (repoDir !== null) {
354
- return join2(repoDir, ...segments);
435
+ return join3(repoDir, ...segments);
355
436
  }
356
437
  }
357
438
  if (first !== void 0 && !isHomedirBaseWritable()) {
358
439
  const repoDir = getNexusRepoDir();
359
440
  if (repoDir !== null) {
360
- const fallbackPath = join2(repoDir, ...segments);
441
+ const fallbackPath = join3(repoDir, ...segments);
361
442
  announceCrossRepoFallback(first, fallbackPath);
362
443
  return fallbackPath;
363
444
  }
364
445
  }
365
- return join2(getNexusDataDir(), ...segments);
446
+ return join3(getNexusDataDir(), ...segments);
366
447
  }
367
448
  function nexusDataPathEnsure(...segments) {
368
449
  const resolved = nexusDataPath(...segments);
@@ -371,7 +452,7 @@ function nexusDataPathEnsure(...segments) {
371
452
  return resolved;
372
453
  }
373
454
  function nexusSharedPath(...segments) {
374
- return join2(getNexusDataDir(), ...segments);
455
+ return join3(getNexusDataDir(), ...segments);
375
456
  }
376
457
  function getPerRepoSubdirs() {
377
458
  return PER_REPO_SUBDIRS;
@@ -428,4 +509,4 @@ export {
428
509
  getPerRepoSubdirs,
429
510
  sessionsDbPath
430
511
  };
431
- //# sourceMappingURL=chunk-RNDHNRSX.js.map
512
+ //# sourceMappingURL=chunk-LWOX65CP.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/config/defaults-env.ts","../src/config/nexus-data-dir.ts","../src/config/sandbox-detection.ts","../src/config/repo-root-detection.ts","../src/config/portable-mode.ts"],"sourcesContent":["/**\n * Environment Variable Override Helpers\n *\n * Provides utilities for reading configuration from environment variables\n * with type-safe fallbacks to defaults.\n *\n * @module config/defaults-env\n */\n\nimport type { ToolRateLimitConfig } from './defaults-types.js';\n\n// ============================================================================\n// Environment Variable Parsers\n// ============================================================================\n\n/**\n * Parses an integer from an environment variable with fallback.\n */\nexport function parseIntEnv(envKey: string, fallback: number): number {\n const envValue = process.env[envKey];\n if (envValue === undefined) {\n return fallback;\n }\n const parsed = parseInt(envValue, 10);\n return isNaN(parsed) || parsed <= 0 ? fallback : parsed;\n}\n\n/**\n * Parses a float from an environment variable with fallback.\n */\nexport function parseFloatEnv(envKey: string, fallback: number): number {\n const envValue = process.env[envKey];\n if (envValue === undefined) {\n return fallback;\n }\n const parsed = parseFloat(envValue);\n return isNaN(parsed) || !isFinite(parsed) ? fallback : parsed;\n}\n\n/**\n * Parses a boolean flag value with fallback — the ONE accept-set for every\n * `NEXUS_*` boolean flag (#5155): `true`/`1` are truthy, `false`/`0` are\n * falsy, case-insensitively. Any other value (including `yes`/`no`/`on`/`off`\n * and the empty string) returns the fallback; `config/env-schema.ts`\n * (`boolLooseStr`) reports those at startup so the fallback is never silent.\n *\n * Pure so consumers that read an injected env object rather than\n * `process.env` (e.g. `cli-adapters/subprocess-env.ts`) share the same set.\n */\nexport function parseBoolValue(value: string | undefined, fallback: boolean): boolean {\n const normalized = value?.toLowerCase();\n if (normalized === undefined) {\n return fallback;\n }\n if (normalized === 'true' || normalized === '1') return true;\n if (normalized === 'false' || normalized === '0') return false;\n return fallback;\n}\n\n/**\n * Parses a boolean from an environment variable with fallback.\n * Delegates to {@link parseBoolValue}: only 'true'/'1' are truthy,\n * 'false'/'0' are falsy (case-insensitive); any other value returns the fallback.\n */\nexport function parseBoolEnv(envKey: string, fallback: boolean): boolean {\n return parseBoolValue(process.env[envKey], fallback);\n}\n\n// ============================================================================\n// Config Getter Types (for lazy initialization)\n// ============================================================================\n\n// The hand-written TimeoutDefaultsConst interface that lived here was removed\n// in #4939 with its last consumer (createGetTimeout); the exported type of the\n// same name is `typeof DEFAULTS.TIMEOUT_DEFAULTS` in config/defaults.ts.\n\n/** Tool rate limits type from DEFAULTS object */\nexport interface ToolRateLimitsConst {\n readonly orchestrate: ToolRateLimitConfig;\n readonly delegate: ToolRateLimitConfig;\n readonly workflow: ToolRateLimitConfig;\n readonly expert: ToolRateLimitConfig;\n}\n\n// ============================================================================\n// Config Getter Factory Functions\n// ============================================================================\n\n// createGetTimeout removed in #4939. It built `NEXUS_TIMEOUT_<KEY>` names at\n// runtime for a getter (getTimeout) with zero production callers, so the four\n// registered names — NEXUS_TIMEOUT_{CLI,API,WORKFLOW,MCP} — were read by nothing\n// that runs. Same class as the removals below.\n//\n// createGetWorkerConfig removed in #2977. createGetRetryConfig,\n// createGetRateLimitConfig and createGetCircuitBreakerConfig removed in #5903\n// for the same reason: their twelve NEXUS_* variables were registered,\n// documented and echoed back by `config get` as `Source: (env)`, and read by\n// nothing that runs. The rate limiter takes `enabled` from the config file\n// (`cli-server-tools.ts`), retry builds DEFAULT_RETRY_CONFIG from the static\n// DEFAULTS (`adapters/retry.ts`), and the production circuit breakers carry\n// their own config. See the comment in config/defaults.ts.\n\n/**\n * Creates a tool rate limit getter function bound to the DEFAULTS object.\n */\nexport function createGetToolRateLimit(\n toolRateLimits: ToolRateLimitsConst\n): (tool: keyof ToolRateLimitsConst) => ToolRateLimitConfig {\n return (tool: keyof ToolRateLimitsConst): ToolRateLimitConfig => {\n return toolRateLimits[tool];\n };\n}\n\n// createGetEnvVarDocumentation removed in #4939: its last remaining table was\n// the four NEXUS_TIMEOUT_* rows, all of which named unread variables.\n","/**\n * Nexus runtime data directory resolver (#2302, child of #2301).\n *\n * Returns the absolute path under which nexus-agents stores runtime state.\n * Two categories of state exist (epic #2872, vote #2876):\n *\n * - **Per-repo** state (sessions, checkpoints, traces, runs, audit,\n * pipeline, tasks) — tied to the work happening in a specific codebase.\n * When `NEXUS_REPO_PREFERRED=1` is set and the caller is inside a git\n * repo, these resolve to `<repo-root>/.nexus-agents/<subdir>/`.\n * - **Cross-repo** state (learning, voting, memory, weather, research,\n * auth, usage, models manifest) — accumulates across the operator's\n * whole workflow. Always resolves to `~/.nexus-agents/<subdir>/` so the\n * learning/routing feedback loop from #1389 / #1407 keeps working.\n *\n * Resolution order (first match wins):\n * 1. `NEXUS_DATA_DIR` env var if set + non-empty. Wins for both categories\n * — the operator's explicit choice overrides the split.\n * 2. Sandbox-mode default (#2501): when `NEXUS_SANDBOX` is set, use\n * `${NEXUS_SANDBOX_ROOT ?? '/'}/.nexus-agents`. Sandboxed deployments\n * typically mount a multi-repo root; state goes there, shared across\n * repo subfolders rather than buried inside one.\n * 3. Per-repo subdirs (when a repo root is known AND `NEXUS_REPO_PREFERRED`\n * is not explicitly `'0'`): `<repo-root>/.nexus-agents/<subdir>/`. The\n * repo root is the active workspace root when one has been set via\n * `setActiveWorkspaceRoot()` (the MCP server derives it from the client's\n * declared `roots`, MCP spec — see #3991), otherwise `findRepoRoot(cwd)`.\n * The active-root path exists because a globally-installed MCP server runs\n * with `process.cwd()` outside the repo, so cwd-based detection would\n * wrongly route per-repo state to homedir. Auto-adds `.nexus-agents/` to\n * the repo's `.gitignore` on first resolution (fail-closed).\n * 4. Cross-repo subdirs when `~/.nexus-agents/` is unwritable AND we're\n * in a repo: per-repo fallback at `<repo-root>/.nexus-agents/<subdir>/`\n * with one-time stderr announce. Issue #2888 — gives sandbox users\n * a working `research/`, `memory/`, etc. without env-var wrangling\n * while preserving the vote #2876 default for normal-machine users.\n * 5. `<homedir>/.nexus-agents` (cross-repo state on normal machines,\n * plus everything when not in a git repo or when\n * `NEXUS_REPO_PREFERRED=0`).\n *\n * `NEXUS_REPO_PREFERRED` defaults **ON** as of this release per vote\n * #2876. Escape hatches preserved:\n * - `NEXUS_REPO_PREFERRED=0` — fully opt out (homedir for everything).\n * - `NEXUS_DATA_DIR=~/.nexus-agents` — explicit override wins over\n * the tier and the categorization both.\n * - `nexus-agents migrate` (#2879) — relocate existing homedir state\n * into `<repo>/.nexus-agents/` before flipping in production.\n *\n * @module config/nexus-data-dir\n */\n\nimport {\n accessSync,\n constants as fsConstants,\n copyFileSync,\n existsSync,\n mkdirSync,\n realpathSync,\n renameSync,\n statSync,\n unlinkSync,\n} from 'node:fs';\nimport { homedir } from 'node:os';\nimport { dirname, isAbsolute, join, resolve } from 'node:path';\n\nimport { detectSandbox } from './sandbox-detection.js';\nimport { findRepoRoot, resolveMainCheckoutRoot } from './repo-root-detection.js';\nimport { ensureGitignored } from './portable-mode.js';\nimport { parseBoolEnv } from './defaults-env.js';\n\n/**\n * Subdirs scoped to a single repo's work (per the epic #2872 vote).\n * When `NEXUS_REPO_PREFERRED=1` and the caller is inside a git repo, these\n * route to `<repo-root>/.nexus-agents/`; otherwise homedir. The complement\n * (everything not in this set) always goes to homedir so cross-project\n * learning state stays intact.\n *\n * Source-of-truth for the categorization: vote #2876 conditions + audit\n * thread on epic #2872. Adding a new entry here is the appropriate way to\n * mark new state as per-repo — do that as a deliberate decision, not by\n * default.\n */\nconst PER_REPO_SUBDIRS: ReadonlySet<string> = new Set([\n // Scratch space for short-lived work (worktrees, prompt files, MCP configs).\n // Per-repo because a throwaway worktree of repo A is meaningless to repo B,\n // and because containing it here keeps it inside the already-gitignored\n // `.nexus-agents/` tree instead of accumulating in a shared `/tmp` nobody\n // reaps. A full `/tmp` is not a theoretical problem: it silently broke this\n // repo's own test suite, with ~1,100 files failing to COLLECT and zero\n // assertion failures, which reads like a code fault and is not one.\n 'tmp',\n 'sessions',\n 'checkpoints',\n 'traces',\n 'runs',\n 'audit',\n 'pipeline',\n 'tasks',\n // Async-mode job results (#3042 / epic #2631). Tied to work happening\n // in a specific codebase — a job dispatched on repo A shouldn't be\n // polled-against on repo B, which would happen if jobs/ were homedir-scoped.\n 'jobs',\n // CI health-check events (#3076 / #3084). Per-repo because outages\n // reported via `ci_health_check({ repo })` are repo-correlated; a wedge\n // on repo A's queue does not predict repo B's health.\n 'ci-health',\n // Governance artifacts — the runtime authentic-vote-record ledger\n // (`governance/vote-records.jsonl`, #3897/#3927/#3991). Per-repo because a\n // promotion proposal is scoped to the codebase being changed; with\n // `NEXUS_REPO_PREFERRED=1` (default) these route to\n // `<repo>/.nexus-agents/governance/` (gitignored), and to\n // `~/.nexus-agents/governance/` otherwise (global / non-repo install). This\n // is DISTINCT from the committed `<repo>/governance/vote-records.jsonl`\n // ledger the promotion gate reads — that artifact is reached only via the\n // explicit `NEXUS_VOTE_RECORDS_PATH` override (#3991).\n 'governance',\n]);\n\n/**\n * Per-repo subdirs that belong to the MAIN checkout even when the caller runs\n * inside a linked git worktree (#6531). A worktree is reaped when its work\n * lands; a governance record written into `<worktree>/.nexus-agents/` went with\n * it, while the CLI reported it written. Everything else per-repo stays\n * worktree-local: a quick panel chose governance-only (option B, 2-1) over\n * routing all per-repo state, to keep parallel worktrees' scratch, sessions and\n * jobs isolated. Must be a subset of {@link PER_REPO_SUBDIRS}.\n */\nconst MAIN_CHECKOUT_SUBDIRS: ReadonlySet<string> = new Set(['governance']);\n\n/** Returns the absolute path to the nexus-agents data directory. */\nexport function getNexusDataDir(): string {\n const fromEnv = process.env['NEXUS_DATA_DIR']?.trim();\n if (fromEnv !== undefined && fromEnv !== '') {\n return resolve(fromEnv);\n }\n const sandbox = detectSandbox();\n if (sandbox.active) {\n return resolve(sandbox.root ?? '/', '.nexus-agents');\n }\n return join(homedir(), '.nexus-agents');\n}\n\n/**\n * No-op kept for source-compatibility with consumers that called this\n * earlier in development. The resolver is no longer cached, so resetting\n * is unnecessary. Kept exported (rather than removed) to avoid breaking\n * imports in tests that may have already adopted it.\n */\nexport function resetNexusDataDirCache(): void {\n // intentionally empty — see module docstring\n}\n\n/**\n * Tracks per-process state for the auto-gitignore wiring: we only need\n * to (a) probe + append to `.gitignore` once per repo, and (b) bail\n * cleanly if the operator has explicitly silenced the auto-add via\n * `NEXUS_GITIGNORE_AUTO=false`. Reset in tests via the helper below.\n */\nconst gitignoredRoots = new Set<string>();\n\n/** Test helper — clears the auto-gitignore \"already did this\" memo. */\nexport function _resetGitignoreMemoForTests(): void {\n gitignoredRoots.clear();\n}\n\n/**\n * Active workspace root, when known from a source more authoritative than\n * `process.cwd()`. Set by the MCP server (#3991) from the client's declared\n * `roots` (MCP spec) once the initialize handshake completes, because a\n * globally-installed server runs with cwd OUTSIDE the repo being worked on —\n * so cwd-based repo detection would route per-repo `.nexus-agents` state to\n * homedir instead of `<repo>/.nexus-agents/`. CLI / in-repo callers never set\n * this, so they keep resolving via `findRepoRoot(cwd)` exactly as before.\n */\nlet activeWorkspaceRoot: string | undefined;\n\n/**\n * Records the active workspace root for repo-scoped data resolution. The\n * value is cross-trust-boundary input (it arrives over the MCP transport from\n * the client), so it is validated before use: resolved to an absolute path,\n * canonicalized via `realpathSync` (defeats symlink games), and required to\n * be an existing directory. Returns `true` when accepted, `false` when the\n * value is empty/invalid (in which case the previous root is left untouched).\n * Passing `null`/empty explicitly clears any previously-set root.\n */\nexport function setActiveWorkspaceRoot(root: string | null | undefined): boolean {\n const trimmed = root?.trim();\n if (trimmed === undefined || trimmed === '') {\n activeWorkspaceRoot = undefined;\n return false;\n }\n try {\n const canonical = realpathSync(resolve(trimmed));\n if (!isAbsolute(canonical) || !statSync(canonical).isDirectory()) return false;\n activeWorkspaceRoot = canonical;\n return true;\n } catch {\n // Nonexistent path, permission error, or broken symlink — reject and keep\n // whatever was set before so a bad late signal can't corrupt resolution.\n return false;\n }\n}\n\n/** Returns the active workspace root if one has been set, else `undefined`. */\nexport function getActiveWorkspaceRoot(): string | undefined {\n return activeWorkspaceRoot;\n}\n\n/** Test helper — clears the active workspace root memo. */\nexport function _resetActiveWorkspaceRootForTests(): void {\n activeWorkspaceRoot = undefined;\n}\n\n/**\n * Returns the repo-scoped `.nexus-agents/` directory if all of the\n * following hold: `NEXUS_REPO_PREFERRED` is NOT explicitly `'0'` (it\n * defaults ON as of vote #2876), `NEXUS_DATA_DIR` is not explicitly set\n * (explicit override always wins), no sandbox is active, and a repo root is\n * known — either the active workspace root (set via\n * `setActiveWorkspaceRoot()`) or an ancestor `.git` found by\n * `findRepoRoot(cwd)`.\n *\n * Side effect: on the first successful resolution per process per repo,\n * appends `.nexus-agents/` to the repo's `.gitignore` if not already\n * present. The operator can silence this with the boolean\n * `NEXUS_GITIGNORE_AUTO` set to `false`/`0` (e.g. on CI runners with a\n * frozen working tree).\n *\n * `options.mainCheckout` (#6531): when the root found is a linked git\n * worktree, return the `.nexus-agents/` of the MAIN checkout it belongs to\n * (see `resolveMainCheckoutRoot`), so the state outlives the worktree.\n *\n * Returns `null` when any precondition fails; callers fall back to\n * `getNexusDataDir()` (homedir).\n */\nexport function getNexusRepoDir(options: { readonly mainCheckout?: boolean } = {}): string | null {\n if (!parseBoolEnv('NEXUS_REPO_PREFERRED', true)) return null;\n const fromEnv = process.env['NEXUS_DATA_DIR']?.trim();\n if (fromEnv !== undefined && fromEnv !== '') return null;\n if (detectSandbox().active) return null;\n // Prefer the MCP-client-declared workspace root (#3991) when the server has\n // set it; fall back to walking up from cwd for CLI / in-repo callers.\n const found = activeWorkspaceRoot ?? findRepoRoot(process.cwd());\n if (found === null) return null;\n // #6531: `mainCheckout` maps a linked worktree to the checkout it belongs to.\n const root = options.mainCheckout === true ? resolveMainCheckoutRoot(found) : found;\n maybeAutoGitignore(root);\n return join(root, '.nexus-agents');\n}\n\n/**\n * Best-effort fail-closed wiring: once per process per repo, ensure\n * `.nexus-agents/` is in `<repo>/.gitignore`. Silenced via the boolean\n * `NEXUS_GITIGNORE_AUTO=false` (or `0`; default on — #5155). Failures are\n * non-fatal — the helper logs to stderr and continues.\n */\nfunction maybeAutoGitignore(repoRoot: string): void {\n if (!parseBoolEnv('NEXUS_GITIGNORE_AUTO', true)) return;\n if (gitignoredRoots.has(repoRoot)) return;\n gitignoredRoots.add(repoRoot);\n // Only attempt when the repo root looks real — avoid spamming stderr\n // from temp-dir test fixtures that race the lifecycle.\n if (!existsSync(repoRoot)) return;\n ensureGitignored(repoRoot, '.nexus-agents/');\n}\n\n/**\n * Per-process memo: was the homedir base directory found writable on first\n * probe? Used to short-circuit the sandbox-fallback decision in\n * `nexusDataPath()` without spending a syscall on every call.\n */\nlet homedirWritable: boolean | undefined;\n\n/** Per-process memo: have we already announced a fallback for this subdir? */\nconst announcedFallbacks = new Set<string>();\n\n/** Test helper — clears the homedir-writability + announcement memos. */\nexport function _resetWritabilityMemoForTests(): void {\n homedirWritable = undefined;\n announcedFallbacks.clear();\n}\n\n/**\n * Returns true if `getNexusDataDir()` resolves to a writable location. Probed\n * once per process and memo'd — flips the sandbox-fallback on/off for\n * cross-repo subdirs. `mkdirSync(recursive: true)` is the safest probe\n * because it both creates the dir if missing and surfaces ENOENT/EACCES\n * issues at the same point. Failures here are non-fatal — they just route\n * cross-repo state to the per-repo fallback (issue #2888).\n */\nfunction isHomedirBaseWritable(): boolean {\n if (homedirWritable !== undefined) return homedirWritable;\n const base = getNexusDataDir();\n try {\n mkdirSync(base, { recursive: true });\n accessSync(base, fsConstants.W_OK);\n homedirWritable = true;\n } catch {\n homedirWritable = false;\n }\n return homedirWritable;\n}\n\n/**\n * Emit a one-time stderr warning when a cross-repo subdir falls back to\n * the per-repo location. Operators in sandboxes get a clear signal about\n * what happened without per-call noise.\n */\nfunction announceCrossRepoFallback(subdir: string, repoPath: string): void {\n if (announcedFallbacks.has(subdir)) return;\n announcedFallbacks.add(subdir);\n process.stderr.write(\n `[nexus] ${subdir}: homedir ~/.nexus-agents is not writable; ` +\n `using per-repo fallback at ${repoPath}. See docs/guides/SANDBOXED-USAGE.md.\\n`\n );\n}\n\n/**\n * Returns a path joined under the appropriate data directory for the\n * given subdir.\n *\n * Routing decision (first match wins):\n * 1. **Per-repo subdir + in a repo + `NEXUS_REPO_PREFERRED` not '0'** →\n * `<repo>/.nexus-agents/<subdir>/...`. Standard behavior since #2884.\n * 2. **Cross-repo subdir + homedir unwritable + in a repo** →\n * `<repo>/.nexus-agents/<subdir>/...` as a sandbox-friendly fallback\n * (issue #2888). Emits a one-time stderr warning per subdir.\n * 3. **Otherwise** → `<homedir>/.nexus-agents/<subdir>/...`. If homedir\n * is also unwritable, the actual write will surface the error.\n *\n * Existing callers don't need to change — the routing decision is driven\n * by the first segment, not by caller-declared intent.\n */\nexport function nexusDataPath(...segments: string[]): string {\n const first = segments[0];\n\n // Tier 1: per-repo subdir + repo-preferred default.\n if (first !== undefined && PER_REPO_SUBDIRS.has(first)) {\n const repoDir = getNexusRepoDir({ mainCheckout: MAIN_CHECKOUT_SUBDIRS.has(first) });\n if (repoDir !== null) {\n return join(repoDir, ...segments);\n }\n }\n\n // Tier 2: cross-repo subdir but homedir isn't reachable. Fall back to\n // the per-repo location if we're in a repo, so sandbox users get a\n // working `research/`, `memory/`, etc. without manual env-var setup.\n // Vote #2876 preserved: this only fires when homedir is physically\n // unreachable; normal-machine users see no change.\n if (first !== undefined && !isHomedirBaseWritable()) {\n const repoDir = getNexusRepoDir();\n if (repoDir !== null) {\n const fallbackPath = join(repoDir, ...segments);\n announceCrossRepoFallback(first, fallbackPath);\n return fallbackPath;\n }\n // No repo to fall back to AND homedir unreachable — return the\n // homedir path anyway. The caller's eventual write will surface\n // the underlying EACCES/ENOENT, which is the right error to show\n // because the environment is genuinely broken at that point.\n }\n\n return join(getNexusDataDir(), ...segments);\n}\n\n/**\n * Like `nexusDataPath()` but eagerly creates the parent directory so\n * callers don't have to remember `mkdirSync(dirname(p), { recursive: true })`\n * before every write. Issue #2890. Use when the returned path will be\n * written to immediately; for read-only resolution prefer `nexusDataPath()`.\n *\n * If the call resolves to a directory (single segment or no segments),\n * the target IS the resolved path. If it resolves to a file (multiple\n * segments), the target is its parent.\n */\nexport function nexusDataPathEnsure(...segments: string[]): string {\n const resolved = nexusDataPath(...segments);\n const target = segments.length > 1 ? dirname(resolved) : resolved;\n mkdirSync(target, { recursive: true });\n return resolved;\n}\n\n/**\n * Explicitly homedir-scoped path. Use this in code that handles\n * cross-project state (routing memory, model registry cache, auth,\n * research catalog) where you want a hard guarantee that the resolver\n * never routes per-repo, even if a new subdir gets accidentally added\n * to the `PER_REPO_SUBDIRS` allowlist later.\n */\nexport function nexusSharedPath(...segments: string[]): string {\n return join(getNexusDataDir(), ...segments);\n}\n\n/**\n * Returns the read-only categorization used by `nexusDataPath()`.\n * Exposed for tests and for tooling that wants to introspect which\n * subdirs are per-repo (e.g. the `nexus-agents migrate` command).\n */\nexport function getPerRepoSubdirs(): ReadonlySet<string> {\n return PER_REPO_SUBDIRS;\n}\n\n/** Per-process memo — the legacy session-DB relocation runs at most once. */\nlet legacySessionsDbMigrated = false;\n\n/** Test helper — clears the session-DB migration \"already did this\" memo. */\nexport function _resetSessionsDbMigrationMemoForTests(): void {\n legacySessionsDbMigrated = false;\n}\n\n/** SQLite sidecar suffixes that must travel with the main DB file. */\nconst SQLITE_SIDECAR_SUFFIXES = ['', '-wal', '-shm', '-journal'] as const;\n\n/**\n * Resolves the session-database path, performing a one-time relocation\n * of any pre-#2902 database on the first call per process.\n *\n * The session DB is per-repo episodic state and belongs in the\n * `sessions/` bucket alongside the session journals — vote #2876\n * categorized `sessions/` as per-repo, and issue #2902 (consensus\n * 3/3) extended that to the DB. Before #2902 the DB resolved via\n * `nexusDataPath('sessions.db')`; because `sessions.db` is not a\n * per-repo first segment, that landed cross-repo at\n * `~/.nexus-agents/sessions.db`, so a DB started in one repo leaked\n * into every other repo.\n *\n * If a legacy DB exists at the old location and none exists at the\n * new one, the legacy file (and any SQLite sidecars) is moved so\n * existing session history is preserved rather than silently\n * orphaned. The move is best-effort: a failure leaves the legacy DB\n * untouched for manual recovery and the caller gets a fresh DB at the\n * new path. `NEXUS_DATA_DIR` / `NEXUS_REPO_PREFERRED` / the\n * `NEXUS_SESSIONS_DB` override all sit upstream of this resolver.\n */\nexport function sessionsDbPath(): string {\n const target = nexusDataPath('sessions', 'sessions.db');\n if (!legacySessionsDbMigrated) {\n legacySessionsDbMigrated = true;\n migrateLegacySessionsDb(target);\n }\n return target;\n}\n\n/** One-time relocation of a pre-#2902 session DB. Best-effort — see `sessionsDbPath`. */\nfunction migrateLegacySessionsDb(target: string): void {\n const legacy = nexusDataPath('sessions.db'); // pre-#2902 resolution\n if (legacy === target || !existsSync(legacy) || existsSync(target)) return;\n try {\n mkdirSync(dirname(target), { recursive: true });\n for (const suffix of SQLITE_SIDECAR_SUFFIXES) {\n const from = `${legacy}${suffix}`;\n if (existsSync(from)) moveFile(from, `${target}${suffix}`);\n }\n } catch {\n // Best-effort — a migration failure must never break session storage.\n }\n}\n\n/** Moves a file, falling back to copy+unlink across a filesystem boundary. */\nfunction moveFile(from: string, to: string): void {\n try {\n renameSync(from, to);\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code !== 'EXDEV') throw err;\n copyFileSync(from, to);\n unlinkSync(from);\n }\n}\n","/**\n * Sandbox detection (#2501, child 1 of epic #2500).\n *\n * nexus-agents needs to know whether it's running inside a host-provided\n * sandbox (Docker Desktop Sandbox + OpenCode, Codex sandbox, locked-down\n * CI runner) so it can adjust behaviour:\n *\n * - default `NEXUS_DATA_DIR` to the multi-repo root rather than `~/...`\n * - skip CLI subprocess detection (binaries aren't there)\n * - fail-fast when the gateway is unreachable instead of degrading\n * - suppress diagnostics that don't apply\n *\n * The signal is **explicit**: the image author (Dockerfile, devcontainer,\n * harness wrapper) sets `NEXUS_SANDBOX=<flavor>`. The flavor string is\n * for diagnostics + per-flavor branching (`docker-opencode`, `codex`,\n * `claude-code`, `ci-restricted`, …); presence is the on/off signal.\n *\n * A heuristic check runs alongside for verification — if `NEXUS_SANDBOX`\n * claims `docker-opencode` but `/.dockerenv` is missing, that's a\n * misconfiguration worth surfacing to the operator.\n *\n * @module config/sandbox-detection\n */\n\nimport { existsSync, readFileSync } from 'node:fs';\n\n/**\n * Heuristic detection result. Independent from the explicit\n * `NEXUS_SANDBOX` env var; produced by inspecting filesystem markers.\n */\nexport type SandboxHeuristic = 'docker' | 'podman' | 'unknown' | null;\n\nexport interface SandboxInfo {\n /**\n * True iff `NEXUS_SANDBOX` is set + non-empty. The explicit signal\n * the rest of the codebase keys off — never `true` by heuristic alone.\n */\n readonly active: boolean;\n /**\n * Operator-supplied flavor string, e.g. `docker-opencode`. Undefined\n * when `active === false` or the env var is empty.\n */\n readonly flavor: string | undefined;\n /**\n * Multi-repo root the user mounted. From `NEXUS_SANDBOX_ROOT`. Undefined\n * when unset; consumers that need a default substitute `/`.\n */\n readonly root: string | undefined;\n /**\n * Independent heuristic match — `null` when we couldn't run the check,\n * `'unknown'` when ran but no marker matched. Used by `doctor` to flag\n * mismatches between the explicit signal and the runtime environment.\n */\n readonly heuristicMatch: SandboxHeuristic;\n}\n\n/**\n * Detect whether nexus-agents is running inside a host-provided sandbox.\n * Pure read of env + filesystem; no caching (cheap enough to recompute,\n * and tests routinely mutate process.env).\n */\nexport function detectSandbox(): SandboxInfo {\n const flavorRaw = process.env['NEXUS_SANDBOX']?.trim();\n const flavor = flavorRaw !== undefined && flavorRaw !== '' ? flavorRaw : undefined;\n const active = flavor !== undefined;\n\n const rootRaw = process.env['NEXUS_SANDBOX_ROOT']?.trim();\n const root = rootRaw !== undefined && rootRaw !== '' ? rootRaw : undefined;\n\n return {\n active,\n flavor,\n root,\n heuristicMatch: detectContainerHeuristic(),\n };\n}\n\n/**\n * Look for filesystem markers indicating a container runtime. Used as a\n * cross-check against the explicit `NEXUS_SANDBOX` signal.\n *\n * Order of checks:\n * 1. `/.dockerenv` (Docker)\n * 2. `/run/.containerenv` (Podman)\n * 3. `/proc/1/cgroup` containing `docker` or `containerd` strings\n *\n * Returns `null` when none of the checks could run (non-Linux host with\n * no `/proc`, sandbox blocks `existsSync`, etc.) — distinct from\n * `'unknown'` (checks ran, no marker matched) so the doctor message can\n * differentiate \"we couldn't tell\" from \"we checked, no container\".\n */\nfunction detectContainerHeuristic(): SandboxHeuristic {\n try {\n if (existsSync('/.dockerenv')) return 'docker';\n if (existsSync('/run/.containerenv')) return 'podman';\n if (existsSync('/proc/1/cgroup')) {\n const cgroup = readFileSync('/proc/1/cgroup', 'utf8');\n if (/\\bdocker\\b/.test(cgroup)) return 'docker';\n if (/\\bcontainerd\\b/.test(cgroup)) return 'docker';\n }\n return 'unknown';\n } catch {\n return null;\n }\n}\n","/**\n * Repo-root detection — walks upward from a starting directory looking for\n * `.git` so callers can scope state to the current git repo. Built for\n * epic #2872 (issue #2882) to support the per-repo `.nexus-agents/` data\n * directory ratified by vote #2876.\n *\n * Defenses adopted:\n * - Walks upward but stops at filesystem root (no infinite loop on\n * symlinks-to-self).\n * - Stops at filesystem boundary (different `stat.dev`) — refuses to\n * escape across mount points. Prevents a sandboxed workdir from\n * resolving a `.git` on the host filesystem.\n * - Detects git worktrees: `.git` may be a *file* containing\n * `gitdir: <path>` rather than a directory.\n * - Realpath's the final root and rejects results that escape the\n * starting cwd by symlink.\n *\n * Deferred (tracked separately; not blocking #2882):\n * - CVE-2022-24765-style ownership check (refuse `.git` owned by a\n * different uid than the running process). The git CLI added\n * `safe.directory` for this; we don't have a comparable allowlist\n * surface yet. In CI the heuristic is too noisy to be useful\n * (runners often clone as a different uid than the workload).\n * File-system isolation (the `stat.dev` check above) covers the\n * bulk of the attack class.\n *\n * @module config/repo-root-detection\n */\n\nimport { execFileSync } from 'node:child_process';\nimport { existsSync, readFileSync, realpathSync, statSync } from 'node:fs';\nimport { dirname, isAbsolute, join, resolve } from 'node:path';\n\n/**\n * Walks upward from `start` looking for `.git` (file or directory).\n * Returns the absolute path to the directory containing it, or `null`.\n *\n * Worktrees: a `.git` file (not dir) with contents `gitdir: <path>` is\n * still recognised as marking the repo root. The pointed-to gitdir is\n * NOT followed — we just need the worktree's own root.\n *\n * Filesystem boundary: stops walking if the next ancestor lives on a\n * different filesystem (different `stat.dev`). This prevents a workdir\n * mounted inside a sandbox from finding a host-side `.git`.\n */\nexport function findRepoRoot(start: string): string | null {\n if (!isAbsolute(start)) {\n start = resolve(start);\n }\n\n let current: string;\n try {\n current = realpathSync(start);\n } catch {\n return null;\n }\n\n let startDev: number | undefined;\n try {\n startDev = statSync(current).dev;\n } catch {\n return null;\n }\n\n // Walk up. Depth cap is paranoid but bounds the loop on pathological\n // symlinks even though realpathSync above should already prevent cycles.\n for (let i = 0; i < 64; i++) {\n if (isRepoRoot(current)) {\n return current;\n }\n const parent = dirname(current);\n if (parent === current) {\n // Hit filesystem root.\n return null;\n }\n try {\n if (statSync(parent).dev !== startDev) {\n // Crossed a mount point; refuse to escape.\n return null;\n }\n } catch {\n return null;\n }\n current = parent;\n }\n return null;\n}\n\n/** True iff `dir/.git` exists as a directory or a git-worktree marker file. */\nexport function isRepoRoot(dir: string): boolean {\n const gitPath = `${dir}/.git`;\n if (!existsSync(gitPath)) return false;\n try {\n const st = statSync(gitPath);\n if (st.isDirectory()) return true;\n if (st.isFile()) {\n // Worktree: first line should be `gitdir: <path>`.\n const head = readFileSync(gitPath, 'utf-8').slice(0, 256);\n return head.startsWith('gitdir:');\n }\n } catch {\n return false;\n }\n return false;\n}\n\n/** Upper bound on a git metadata file read; real ones are one short line. */\nconst MAX_GIT_METADATA_BYTES = 4096;\n\n/** First line of a small file, trimmed; undefined when absent, oversized or empty. */\nfunction readGitMetadataLine(path: string): string | undefined {\n try {\n if (!statSync(path).isFile() || statSync(path).size > MAX_GIT_METADATA_BYTES) return undefined;\n const line = readFileSync(path, 'utf-8').split('\\n')[0]?.trim();\n return line === undefined || line === '' ? undefined : line;\n } catch {\n return undefined;\n }\n}\n\n/** realpath, or undefined when the path does not resolve. */\nfunction realpathOrUndefined(path: string): string | undefined {\n try {\n return realpathSync(path);\n } catch {\n return undefined;\n }\n}\n\n/** Bound on each git call; a hung git must not hang data-dir resolution. */\nconst GIT_TIMEOUT_MS = 5_000;\n\n/**\n * Run git and return trimmed stdout, or undefined on any failure (git absent,\n * not a repository, unset config key, timeout). `GIT_*` variables are dropped\n * so an inherited `GIT_DIR`/`GIT_WORK_TREE` cannot answer for a different\n * repository than the one asked about.\n */\nfunction gitOutput(args: readonly string[]): string | undefined {\n const env = Object.fromEntries(\n Object.entries(process.env).filter(([key]) => !key.startsWith('GIT_'))\n );\n try {\n const out = execFileSync('git', [...args], {\n encoding: 'utf-8',\n stdio: ['ignore', 'pipe', 'ignore'],\n timeout: GIT_TIMEOUT_MS,\n env,\n }).trim();\n return out === '' ? undefined : out;\n } catch {\n return undefined;\n }\n}\n\n/** git's common dir for the repository at `dir`, realpath'd. */\nfunction gitCommonDir(dir: string): string | undefined {\n const common = gitOutput(['-C', dir, 'rev-parse', '--path-format=absolute', '--git-common-dir']);\n return common === undefined ? undefined : realpathOrUndefined(common);\n}\n\n/**\n * The MAIN checkout that a linked worktree belongs to, or `repoRoot` itself\n * (#6531).\n *\n * `findRepoRoot` deliberately stops at a worktree's own root; this is the one\n * extra hop for state that must outlive the worktree. Every decision is git's\n * own answer (#6548 review), not a name heuristic:\n *\n * 1. Only a LINKED worktree moves: `repoRoot/.git` is a file whose admin dir\n * sits at `<common>/worktrees/<name>` and whose `gitdir` file points BACK\n * at this worktree (git writes it inside the main repository, not the\n * worktree — the guard against a forged marker redirecting writes, possibly\n * across a mount boundary). A submodule or `--separate-git-dir` checkout\n * also has a `.git` file, but no back-reference: it is a main checkout.\n * 2. `<common>` is `git rev-parse --git-common-dir`.\n * 3. `core.bare` in `<common>/config` → no main checkout; keep `repoRoot`.\n * 4. `core.worktree` set → that is the main checkout (a submodule: its common\n * dir is `<super>/.git/modules/<name>`). Otherwise the candidate is\n * `<common>`'s parent (the standard layout).\n * 5. The candidate is accepted only if git, run there, reports the same common\n * dir AND the candidate as its top level. A `--separate-git-dir` clone\n * records no path back to its checkout (git's own `worktree list` names the\n * git dir), so its worktrees fail here and keep their own root.\n */\nexport function resolveMainCheckoutRoot(repoRoot: string): string {\n const adminDir = backReferencedAdminDir(repoRoot);\n if (adminDir === undefined) return repoRoot;\n const commonDir = gitCommonDir(repoRoot);\n if (commonDir === undefined || dirname(adminDir) !== join(commonDir, 'worktrees')) {\n return repoRoot;\n }\n return mainCheckoutOf(commonDir) ?? repoRoot;\n}\n\n/**\n * The admin dir a worktree's `.git` marker names, only when that admin dir's\n * `gitdir` file points back at the same marker; undefined otherwise.\n */\nfunction backReferencedAdminDir(repoRoot: string): string | undefined {\n const dotGit = join(repoRoot, '.git');\n const target = readGitMetadataLine(dotGit)\n ?.match(/^gitdir:\\s*(.+)$/)?.[1]\n ?.trim();\n if (target === undefined) return undefined;\n const adminDir = resolveGitPath(repoRoot, target);\n if (adminDir === undefined) return undefined;\n const backRef = readGitMetadataLine(join(adminDir, 'gitdir'));\n if (backRef === undefined) return undefined;\n const pointsBack = resolveGitPath(adminDir, backRef) === realpathOrUndefined(dotGit);\n return pointsBack ? adminDir : undefined;\n}\n\n/** Resolve a git metadata path the way git does: relative to `base`, then realpath. */\nfunction resolveGitPath(base: string, value: string): string | undefined {\n return realpathOrUndefined(isAbsolute(value) ? value : resolve(base, value));\n}\n\n/** The checkout whose git dir is `commonDir`, per git; undefined when there is none. */\nfunction mainCheckoutOf(commonDir: string): string | undefined {\n const config = join(commonDir, 'config');\n if (gitOutput(['config', '--file', config, '--bool', '--get', 'core.bare']) === 'true') {\n return undefined;\n }\n const worktree = gitOutput(['config', '--file', config, '--get', 'core.worktree']);\n const candidate = realpathOrUndefined(\n worktree === undefined ? dirname(commonDir) : resolveUnder(commonDir, worktree)\n );\n if (candidate === undefined || gitCommonDir(candidate) !== commonDir) return undefined;\n const topLevel = gitOutput(['-C', candidate, 'rev-parse', '--show-toplevel']);\n if (topLevel === undefined || realpathOrUndefined(topLevel) !== candidate) return undefined;\n return candidate;\n}\n\n/** `value` resolved against `base` unless already absolute (core.worktree semantics). */\nfunction resolveUnder(base: string, value: string): string {\n return isAbsolute(value) ? value : resolve(base, value);\n}\n","/**\n * portable-mode — auto-detect sandboxed execution environments and\n * redirect nexus-agents data to a workspace-local directory.\n *\n * The existing `getNexusDataDir()` already respects `NEXUS_DATA_DIR` and\n * `NEXUS_PORTABLE_MODE`. This module wires up the *auto-detection* path\n * so operators running inside a Docker / restricted-FS / sandboxed\n * environment don't have to set the env vars manually — nexus-agents\n * notices and announces the flip.\n *\n * Source: Issue #2471 (epic #2467 child).\n *\n * Detection rules (first match wins):\n * 1. `NEXUS_DATA_DIR` already set → respect, no auto-detect\n * 2. `NEXUS_PORTABLE_MODE=0` → operator opted out, no auto-detect\n * 3. `NEXUS_PORTABLE_MODE=1` → portable mode, no detection needed\n * 4. Heuristic: home directory not writable\n * 5. Heuristic: container env vars set (KUBERNETES_SERVICE_HOST,\n * DOCKER_CONTAINER, ECS_CONTAINER_METADATA_URI, SANDBOX, etc.)\n *\n * When portable mode fires:\n * - Sets `process.env.NEXUS_DATA_DIR` to `<cwd>/.nexus-agents`\n * - Announces once on stderr (subsequent calls are silent)\n * - If cwd is a git repo, appends `.nexus-agents/` to .gitignore\n *\n * To force off: `NEXUS_PORTABLE_MODE=0`. To force on without heuristics:\n * `NEXUS_PORTABLE_MODE=1`. To override target dir: `NEXUS_DATA_DIR=...`.\n */\n\nimport { accessSync, constants, existsSync, readFileSync, appendFileSync, statSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { join, resolve } from 'node:path';\n\n/** Container / sandbox environment variables that strongly imply portable mode. */\nconst SANDBOX_ENV_VARS: readonly string[] = [\n 'KUBERNETES_SERVICE_HOST',\n 'DOCKER_CONTAINER',\n 'ECS_CONTAINER_METADATA_URI',\n 'ECS_CONTAINER_METADATA_URI_V4',\n 'SANDBOX',\n 'NEXUS_SANDBOX',\n];\n\nlet DETECTED = false;\n\ninterface DetectionResult {\n readonly portable: boolean;\n readonly dataDir: string;\n readonly reason:\n 'env-data-dir' | 'env-opt-out' | 'env-opt-in' | 'home-unwritable' | 'container-env' | 'default';\n}\n\nfunction isHomeWritable(): boolean {\n try {\n const home = homedir();\n if (!existsSync(home)) return false;\n accessSync(home, constants.W_OK);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction inSandboxEnv(): boolean {\n for (const v of SANDBOX_ENV_VARS) {\n const val = process.env[v];\n if (val !== undefined && val !== '') return true;\n }\n return false;\n}\n\n/**\n * The operator-declared sandbox root, when set (#5026).\n *\n * Read directly rather than through `detectSandbox()` to keep this module free\n * of imports — it runs as a side effect of `cli-log-bootstrap` before anything\n * else loads.\n */\nfunction sandboxRootFromEnv(): string | undefined {\n const raw = process.env['NEXUS_SANDBOX_ROOT']?.trim();\n return raw !== undefined && raw !== '' ? resolve(raw) : undefined;\n}\n\nfunction checkExplicitEnv(cwd: string): DetectionResult | null {\n const fromEnv = process.env['NEXUS_DATA_DIR']?.trim();\n if (fromEnv !== undefined && fromEnv !== '') {\n return { portable: false, dataDir: resolve(fromEnv), reason: 'env-data-dir' };\n }\n const portableEnv = process.env['NEXUS_PORTABLE_MODE'];\n if (portableEnv === '0' || portableEnv === 'false') {\n return { portable: false, dataDir: join(homedir(), '.nexus-agents'), reason: 'env-opt-out' };\n }\n if (portableEnv === '1' || portableEnv === 'true') {\n return { portable: true, dataDir: join(cwd, '.nexus-agents'), reason: 'env-opt-in' };\n }\n return null;\n}\n\nfunction checkHeuristics(cwd: string): DetectionResult | null {\n if (!isHomeWritable()) {\n return { portable: true, dataDir: join(cwd, '.nexus-agents'), reason: 'home-unwritable' };\n }\n if (inSandboxEnv()) {\n // #5026: prefer an explicitly declared sandbox root over cwd. `NEXUS_SANDBOX`\n // is one of SANDBOX_ENV_VARS, so setting it makes this heuristic fire and\n // stamp `NEXUS_DATA_DIR = <cwd>/.nexus-agents` — which then short-circuits\n // `getNexusDataDir`'s own sandbox branch (`nexus-data-dir.ts:124-127`)\n // before it can honour `NEXUS_SANDBOX_ROOT`. The documented purpose of that\n // variable (\"default NEXUS_DATA_DIR to the multi-repo root\") therefore never\n // happened, and state fragmented per working directory across a multi-repo\n // mount. `doctor`'s dataDirInsideRepo check exists to detect exactly that\n // layout and reports it as operator misconfiguration.\n const declaredRoot = sandboxRootFromEnv();\n return {\n portable: true,\n dataDir: join(declaredRoot ?? cwd, '.nexus-agents'),\n reason: 'container-env',\n };\n }\n return null;\n}\n\n/**\n * Decide whether to flip nexus-agents to portable mode and what data dir\n * to use. Pure function; no side effects beyond reading env + filesystem.\n */\nexport function detectPortableMode(cwd: string = process.cwd()): DetectionResult {\n return (\n checkExplicitEnv(cwd) ??\n checkHeuristics(cwd) ?? {\n portable: false,\n dataDir: join(homedir(), '.nexus-agents'),\n reason: 'default',\n }\n );\n}\n\n/**\n * Apply detected portable mode at process startup. Idempotent (subsequent\n * calls are no-ops). Announces on stderr once when the auto-detection\n * heuristic triggers — env-opt-in/out doesn't announce because the\n * operator already knows.\n */\nexport function applyPortableMode(cwd: string = process.cwd()): void {\n if (DETECTED) return;\n DETECTED = true;\n\n const result = detectPortableMode(cwd);\n\n // No env, no heuristic match — nothing to do.\n if (!result.portable) return;\n\n // The heuristic-driven cases announce; explicit opt-in is silent.\n if (result.reason === 'home-unwritable' || result.reason === 'container-env') {\n process.stderr.write(\n `[portable-mode] Sandbox detected (${result.reason}). Using ${result.dataDir} for all nexus-agents data.\\n` +\n ` Set NEXUS_PORTABLE_MODE=0 to override; see docs/guides/SANDBOXED-USAGE.md\\n`\n );\n }\n\n process.env['NEXUS_DATA_DIR'] = result.dataDir;\n\n if (isInsideGitRepo(cwd)) {\n ensureGitignored(cwd, '.nexus-agents/');\n }\n}\n\nfunction isInsideGitRepo(cwd: string): boolean {\n try {\n const gitDir = join(cwd, '.git');\n return existsSync(gitDir) && statSync(gitDir).isDirectory();\n } catch {\n return false;\n }\n}\n\n/**\n * Append `entry` to `<cwd>/.gitignore` if not already present. Stderr\n * announce on the first append. Exported because the repo-preferred\n * resolver in `nexus-data-dir.ts` reuses the same auto-gitignore behavior\n * when `<repo>/.nexus-agents/` becomes the active data dir (epic #2872).\n */\nexport function ensureGitignored(cwd: string, entry: string): void {\n const path = join(cwd, '.gitignore');\n try {\n const existing = existsSync(path) ? readFileSync(path, 'utf-8') : '';\n const lines = existing.split('\\n').map((l) => l.trim());\n if (lines.includes(entry) || lines.includes(entry.replace(/\\/$/, ''))) return;\n const sep = existing.length > 0 && !existing.endsWith('\\n') ? '\\n' : '';\n appendFileSync(path, `${sep}${entry}\\n`, 'utf-8');\n process.stderr.write(\n `[portable-mode] Added '${entry}' to ${path} so nexus-agents data is gitignored.\\n`\n );\n } catch (e: unknown) {\n // Non-fatal — operator can add the line themselves.\n const msg = e instanceof Error ? e.message : String(e);\n process.stderr.write(\n `[portable-mode] Could not auto-update ${path} (${msg}). Add '${entry}' manually if you don't want nexus-agents data tracked by git.\\n`\n );\n }\n}\n\n/** Test-only reset of the once-only state. */\nexport function _resetDetectedForTests(): void {\n DETECTED = false;\n}\n"],"mappings":";AAkBO,SAAS,YAAY,QAAgB,UAA0B;AACpE,QAAM,WAAW,QAAQ,IAAI,MAAM;AACnC,MAAI,aAAa,QAAW;AAC1B,WAAO;AAAA,EACT;AACA,QAAM,SAAS,SAAS,UAAU,EAAE;AACpC,SAAO,MAAM,MAAM,KAAK,UAAU,IAAI,WAAW;AACnD;AAwBO,SAAS,eAAe,OAA2B,UAA4B;AACpF,QAAM,aAAa,OAAO,YAAY;AACtC,MAAI,eAAe,QAAW;AAC5B,WAAO;AAAA,EACT;AACA,MAAI,eAAe,UAAU,eAAe,IAAK,QAAO;AACxD,MAAI,eAAe,WAAW,eAAe,IAAK,QAAO;AACzD,SAAO;A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,MAAM,EAAG;AACpE,MAAI;AACF,cAAUC,SAAQ,MAAM,GAAG,EAAE,WAAW,KAAK,CAAC;AAC9C,eAAW,UAAU,yBAAyB;AAC5C,YAAM,OAAO,GAAG,MAAM,GAAG,MAAM;AAC/B,UAAID,YAAW,IAAI,EAAG,UAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE;AAAA,IAC3D;AAAA,EACF,QAAQ;AAAA,EAER;AACF;AAGA,SAAS,SAAS,MAAc,IAAkB;AAChD,MAAI;AACF,eAAW,MAAM,EAAE;AAAA,EACrB,SAAS,KAAK;AACZ,QAAK,IAA8B,SAAS,QAAS,OAAM;AAC3D,iBAAa,MAAM,EAAE;AACrB,eAAW,IAAI;AAAA,EACjB;AACF;","names":["accessSync","existsSync","realpathSync","statSync","homedir","dirname","isAbsolute","join","resolve","existsSync","readFileSync","existsSync","readFileSync","statSync","join","resolve","resolve","join","homedir","realpathSync","resolve","isAbsolute","statSync","join","existsSync","accessSync","join","dirname","existsSync","dirname"]}
@@ -7,7 +7,7 @@ import {
7
7
  createLogger,
8
8
  err,
9
9
  ok
10
- } from "./chunk-4DSPBZY3.js";
10
+ } from "./chunk-NZN3SWSZ.js";
11
11
 
12
12
  // src/adapters/sdk/gateway-env.ts
13
13
  function readTrimmed(env, name) {
@@ -315,4 +315,4 @@ export {
315
315
  validateCustomApiBaseUrl,
316
316
  assertCustomApiHostResolvesPublic
317
317
  };
318
- //# sourceMappingURL=chunk-BYQNCZSZ.js.map
318
+ //# sourceMappingURL=chunk-LZNYQYDU.js.map