nexus-agents 10.2.0 → 11.0.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 (179) hide show
  1. package/README.md +4 -1
  2. package/dist/{ast-rule-runner-RI7ZJ4ZI.js → ast-rule-runner-3QRCP53C.js} +5 -5
  3. package/dist/{child-mcp-config-73BX4OTR.js → child-mcp-config-NWPUDUVE.js} +5 -5
  4. package/dist/{chunk-GAX75XCV.js → chunk-2BZXKNLN.js} +2 -2
  5. package/dist/{chunk-QG3VDSWD.js → chunk-2HYJTIDY.js} +3 -3
  6. package/dist/{chunk-OMSKBBL7.js → chunk-377L2ZEK.js} +18 -19
  7. package/dist/chunk-377L2ZEK.js.map +1 -0
  8. package/dist/{chunk-VLOPXV47.js → chunk-53XY7YJD.js} +7 -7
  9. package/dist/chunk-5CUI42NO.js +1046 -0
  10. package/dist/chunk-5CUI42NO.js.map +1 -0
  11. package/dist/{chunk-23QA6GQD.js → chunk-66BE4KF4.js} +7 -7
  12. package/dist/{chunk-TDUXUVUU.js → chunk-6LWUJOAS.js} +2 -2
  13. package/dist/{chunk-XDUTAUK3.js → chunk-7H3SOL4O.js} +65 -57
  14. package/dist/chunk-7H3SOL4O.js.map +1 -0
  15. package/dist/{chunk-JGY5HMWI.js → chunk-7HHXY7LM.js} +2 -2
  16. package/dist/{chunk-J44RKRGQ.js → chunk-AFJE7K6Q.js} +4 -4
  17. package/dist/{chunk-WD4DENPC.js → chunk-B3RAA47W.js} +3 -3
  18. package/dist/{chunk-TW6PJYTP.js → chunk-C73VZSC5.js} +1 -1
  19. package/dist/chunk-C73VZSC5.js.map +1 -0
  20. package/dist/{chunk-LWOX65CP.js → chunk-CH6IBWXH.js} +31 -31
  21. package/dist/chunk-CH6IBWXH.js.map +1 -0
  22. package/dist/{chunk-RIYFVDYN.js → chunk-CSDGNGAG.js} +2 -2
  23. package/dist/{chunk-KASBBKAQ.js → chunk-D33IH5VS.js} +54 -54
  24. package/dist/chunk-D33IH5VS.js.map +1 -0
  25. package/dist/{chunk-U37AITDA.js → chunk-DCPCO2XG.js} +2 -2
  26. package/dist/{chunk-SS53PZO6.js → chunk-EFZRQ67X.js} +5 -5
  27. package/dist/{chunk-WKFPKPEM.js → chunk-GPRYEKAA.js} +434 -124
  28. package/dist/chunk-GPRYEKAA.js.map +1 -0
  29. package/dist/{chunk-7EV3QAKO.js → chunk-HUYVIUF3.js} +2 -2
  30. package/dist/{chunk-V26YQQK4.js → chunk-I7VX7JWV.js} +2 -2
  31. package/dist/{chunk-LXYT2P2Y.js → chunk-IGYZQEKM.js} +3 -3
  32. package/dist/{chunk-XSAUVC6D.js → chunk-NLFCAEEK.js} +2 -2
  33. package/dist/{chunk-2TA6KTRF.js → chunk-OJ3PXTN3.js} +16 -18
  34. package/dist/{chunk-2TA6KTRF.js.map → chunk-OJ3PXTN3.js.map} +1 -1
  35. package/dist/{chunk-QRC3QLUQ.js → chunk-PY6HJQYC.js} +1086 -14
  36. package/dist/chunk-PY6HJQYC.js.map +1 -0
  37. package/dist/{chunk-QM5W3T3O.js → chunk-PZMODRBC.js} +2 -2
  38. package/dist/{chunk-GX5ZHZR2.js → chunk-QARJHIQM.js} +7 -7
  39. package/dist/{chunk-EJ5EBTAV.js → chunk-QTRPH2ZF.js} +2 -2
  40. package/dist/{chunk-FNHVTDHZ.js → chunk-R75NZRON.js} +3 -3
  41. package/dist/{chunk-UE7A2XHM.js → chunk-RUHKJC3X.js} +2 -2
  42. package/dist/{chunk-4JJI34RV.js → chunk-S6XQFO4A.js} +3 -3
  43. package/dist/{chunk-LP5ISXKM.js → chunk-SFWQ72ZS.js} +5 -5
  44. package/dist/{chunk-KLSNDPU6.js → chunk-SKM75Y7E.js} +17 -32
  45. package/dist/chunk-SKM75Y7E.js.map +1 -0
  46. package/dist/{chunk-D6E3LJGP.js → chunk-T4WTZTZY.js} +4 -4
  47. package/dist/{chunk-JPFRRNRR.js → chunk-U7HL7FGS.js} +2 -2
  48. package/dist/{chunk-SX2XWCGA.js → chunk-V6AJCRAU.js} +22 -7
  49. package/dist/chunk-V6AJCRAU.js.map +1 -0
  50. package/dist/{chunk-2DYCHHWW.js → chunk-VVMSE5LF.js} +4 -4
  51. package/dist/{chunk-QS5HGPCN.js → chunk-VZ7YZ2EF.js} +2 -2
  52. package/dist/{chunk-PXYSAG5B.js → chunk-WFMMJWMO.js} +2 -2
  53. package/dist/{chunk-FWQSOPBA.js → chunk-YOT3XEZM.js} +6 -6
  54. package/dist/{chunk-JUUGLXSN.js → chunk-YRZV6KXZ.js} +5 -5
  55. package/dist/{cli-auth-probe-A7ANEHJ7.js → cli-auth-probe-GUK3NXW3.js} +2 -2
  56. package/dist/{cli-circuit-breaker-62YOQQT3.js → cli-circuit-breaker-VWARWNGU.js} +5 -5
  57. package/dist/{cli-readiness-O6EOQV4L.js → cli-readiness-S23DWZCS.js} +9 -9
  58. package/dist/cli-server-gateway-DJXSHHXA.js +34 -0
  59. package/dist/cli.d.ts +1 -1
  60. package/dist/cli.js +80 -1215
  61. package/dist/cli.js.map +1 -1
  62. package/dist/{composite-router-YPZ3D5Y6.js → composite-router-3CBLBUGZ.js} +4 -4
  63. package/dist/{consensus-vote-RNQQUBXO.js → consensus-vote-JMWTJO4M.js} +21 -22
  64. package/dist/{consensus-vote-types-DexdhOdB.d.ts → consensus-vote-types-Ca0BY3kZ.d.ts} +5 -5
  65. package/dist/{context-retriever-HVPLM6DH.js → context-retriever-P6ZE6UXS.js} +11 -11
  66. package/dist/{doctor-deep-UZQTD65D.js → doctor-deep-HBIDPGWI.js} +5 -5
  67. package/dist/doctor-gateway-report-FWV7UN2Q.js +20 -0
  68. package/dist/{doctor-live-QFLT5SDB.js → doctor-live-676TWMP6.js} +18 -16
  69. package/dist/doctor-live-676TWMP6.js.map +1 -0
  70. package/dist/{expert-bridge-O3UZXLGB.js → expert-bridge-3VWOHLC7.js} +6 -6
  71. package/dist/factory-A44THDRG.js +31 -0
  72. package/dist/factory-YPJXDMN4.js +17 -0
  73. package/dist/{improvement-review-7IABFAU3.js → improvement-review-FIKPTCPE.js} +8 -8
  74. package/dist/index.d.ts +69 -77
  75. package/dist/index.js +65 -56
  76. package/dist/index.js.map +1 -1
  77. package/dist/{init-opencode-RYPBCM4P.js → init-opencode-YRHLGHIE.js} +7 -7
  78. package/dist/issue-triage-BLZHWC6U.js +20 -0
  79. package/dist/{learning-persistence-FB4U5AX2.js → learning-persistence-X24OOBYY.js} +3 -3
  80. package/dist/{model-config-helpers-QNV3KD2W.js → model-config-helpers-OQEZU2ZG.js} +4 -4
  81. package/dist/{openai-compat-adapter-GPZDIR3D.js → openai-compat-adapter-GRJA6RPZ.js} +7 -7
  82. package/dist/{outcome-store-adapter-WRONSTUD.js → outcome-store-adapter-7CKYWUZV.js} +4 -4
  83. package/dist/{pr-reviewer-helpers-7SMNNDFJ.js → pr-reviewer-helpers-LKHPRW3X.js} +6 -6
  84. package/dist/{registry-command-U7K6HIBK.js → registry-command-4LP4OSND.js} +4 -4
  85. package/dist/{repo-security-plan-LFWLVEL2.js → repo-security-plan-SOFUCHO4.js} +5 -5
  86. package/dist/research-helpers-synthesize-SXNAJWHX.js +16 -0
  87. package/dist/{routing-memory-OCIVXKOU.js → routing-memory-TWCXFPAD.js} +4 -4
  88. package/dist/{session-memory-4LMEWO3X.js → session-memory-YVT5M4AN.js} +5 -5
  89. package/dist/setup-config-JGHFR4P3.js +13 -0
  90. package/dist/{setup-custom-api-QEPUCHOX.js → setup-custom-api-EFAWNJ2D.js} +6 -6
  91. package/dist/setup-data-dir-Z4IQNMRC.js +34 -0
  92. package/dist/{tool-memory-EFGFXF65.js → tool-memory-5Y3HKHCB.js} +8 -8
  93. package/dist/{tool-memory-registry-adapters-FO6JVQSX.js → tool-memory-registry-adapters-IIORYBCC.js} +3 -3
  94. package/dist/unified-registry-IDUII5J7.js +35 -0
  95. package/dist/{weather-report-PMYQ3WBW.js → weather-report-KA5RT57Q.js} +4 -4
  96. package/dist/weather-report-KA5RT57Q.js.map +1 -0
  97. package/package.json +1 -1
  98. package/dist/chunk-KASBBKAQ.js.map +0 -1
  99. package/dist/chunk-KLSNDPU6.js.map +0 -1
  100. package/dist/chunk-LWOX65CP.js.map +0 -1
  101. package/dist/chunk-OMSKBBL7.js.map +0 -1
  102. package/dist/chunk-QRC3QLUQ.js.map +0 -1
  103. package/dist/chunk-SX2XWCGA.js.map +0 -1
  104. package/dist/chunk-TW6PJYTP.js.map +0 -1
  105. package/dist/chunk-UZJ6IPJR.js +0 -1057
  106. package/dist/chunk-UZJ6IPJR.js.map +0 -1
  107. package/dist/chunk-WKFPKPEM.js.map +0 -1
  108. package/dist/chunk-XDUTAUK3.js.map +0 -1
  109. package/dist/doctor-gateway-report-LRBPPJD4.js +0 -20
  110. package/dist/doctor-live-QFLT5SDB.js.map +0 -1
  111. package/dist/factory-KCKQQAEH.js +0 -31
  112. package/dist/factory-LUKUIB6C.js +0 -17
  113. package/dist/issue-triage-YBVJVAUU.js +0 -20
  114. package/dist/research-helpers-synthesize-X6MVAAKT.js +0 -16
  115. package/dist/setup-config-YNNNR4AE.js +0 -13
  116. package/dist/setup-data-dir-XM5DWH7R.js +0 -35
  117. package/dist/unified-registry-KLNC24HA.js +0 -36
  118. /package/dist/{ast-rule-runner-RI7ZJ4ZI.js.map → ast-rule-runner-3QRCP53C.js.map} +0 -0
  119. /package/dist/{child-mcp-config-73BX4OTR.js.map → child-mcp-config-NWPUDUVE.js.map} +0 -0
  120. /package/dist/{chunk-GAX75XCV.js.map → chunk-2BZXKNLN.js.map} +0 -0
  121. /package/dist/{chunk-QG3VDSWD.js.map → chunk-2HYJTIDY.js.map} +0 -0
  122. /package/dist/{chunk-VLOPXV47.js.map → chunk-53XY7YJD.js.map} +0 -0
  123. /package/dist/{chunk-23QA6GQD.js.map → chunk-66BE4KF4.js.map} +0 -0
  124. /package/dist/{chunk-TDUXUVUU.js.map → chunk-6LWUJOAS.js.map} +0 -0
  125. /package/dist/{chunk-JGY5HMWI.js.map → chunk-7HHXY7LM.js.map} +0 -0
  126. /package/dist/{chunk-J44RKRGQ.js.map → chunk-AFJE7K6Q.js.map} +0 -0
  127. /package/dist/{chunk-WD4DENPC.js.map → chunk-B3RAA47W.js.map} +0 -0
  128. /package/dist/{chunk-RIYFVDYN.js.map → chunk-CSDGNGAG.js.map} +0 -0
  129. /package/dist/{chunk-U37AITDA.js.map → chunk-DCPCO2XG.js.map} +0 -0
  130. /package/dist/{chunk-SS53PZO6.js.map → chunk-EFZRQ67X.js.map} +0 -0
  131. /package/dist/{chunk-7EV3QAKO.js.map → chunk-HUYVIUF3.js.map} +0 -0
  132. /package/dist/{chunk-V26YQQK4.js.map → chunk-I7VX7JWV.js.map} +0 -0
  133. /package/dist/{chunk-LXYT2P2Y.js.map → chunk-IGYZQEKM.js.map} +0 -0
  134. /package/dist/{chunk-XSAUVC6D.js.map → chunk-NLFCAEEK.js.map} +0 -0
  135. /package/dist/{chunk-QM5W3T3O.js.map → chunk-PZMODRBC.js.map} +0 -0
  136. /package/dist/{chunk-GX5ZHZR2.js.map → chunk-QARJHIQM.js.map} +0 -0
  137. /package/dist/{chunk-EJ5EBTAV.js.map → chunk-QTRPH2ZF.js.map} +0 -0
  138. /package/dist/{chunk-FNHVTDHZ.js.map → chunk-R75NZRON.js.map} +0 -0
  139. /package/dist/{chunk-UE7A2XHM.js.map → chunk-RUHKJC3X.js.map} +0 -0
  140. /package/dist/{chunk-4JJI34RV.js.map → chunk-S6XQFO4A.js.map} +0 -0
  141. /package/dist/{chunk-LP5ISXKM.js.map → chunk-SFWQ72ZS.js.map} +0 -0
  142. /package/dist/{chunk-D6E3LJGP.js.map → chunk-T4WTZTZY.js.map} +0 -0
  143. /package/dist/{chunk-JPFRRNRR.js.map → chunk-U7HL7FGS.js.map} +0 -0
  144. /package/dist/{chunk-2DYCHHWW.js.map → chunk-VVMSE5LF.js.map} +0 -0
  145. /package/dist/{chunk-QS5HGPCN.js.map → chunk-VZ7YZ2EF.js.map} +0 -0
  146. /package/dist/{chunk-PXYSAG5B.js.map → chunk-WFMMJWMO.js.map} +0 -0
  147. /package/dist/{chunk-FWQSOPBA.js.map → chunk-YOT3XEZM.js.map} +0 -0
  148. /package/dist/{chunk-JUUGLXSN.js.map → chunk-YRZV6KXZ.js.map} +0 -0
  149. /package/dist/{cli-auth-probe-A7ANEHJ7.js.map → cli-auth-probe-GUK3NXW3.js.map} +0 -0
  150. /package/dist/{cli-circuit-breaker-62YOQQT3.js.map → cli-circuit-breaker-VWARWNGU.js.map} +0 -0
  151. /package/dist/{cli-readiness-O6EOQV4L.js.map → cli-readiness-S23DWZCS.js.map} +0 -0
  152. /package/dist/{composite-router-YPZ3D5Y6.js.map → cli-server-gateway-DJXSHHXA.js.map} +0 -0
  153. /package/dist/{consensus-vote-RNQQUBXO.js.map → composite-router-3CBLBUGZ.js.map} +0 -0
  154. /package/dist/{context-retriever-HVPLM6DH.js.map → consensus-vote-JMWTJO4M.js.map} +0 -0
  155. /package/dist/{doctor-deep-UZQTD65D.js.map → context-retriever-P6ZE6UXS.js.map} +0 -0
  156. /package/dist/{doctor-gateway-report-LRBPPJD4.js.map → doctor-deep-HBIDPGWI.js.map} +0 -0
  157. /package/dist/{expert-bridge-O3UZXLGB.js.map → doctor-gateway-report-FWV7UN2Q.js.map} +0 -0
  158. /package/dist/{factory-KCKQQAEH.js.map → expert-bridge-3VWOHLC7.js.map} +0 -0
  159. /package/dist/{factory-LUKUIB6C.js.map → factory-A44THDRG.js.map} +0 -0
  160. /package/dist/{improvement-review-7IABFAU3.js.map → factory-YPJXDMN4.js.map} +0 -0
  161. /package/dist/{issue-triage-YBVJVAUU.js.map → improvement-review-FIKPTCPE.js.map} +0 -0
  162. /package/dist/{init-opencode-RYPBCM4P.js.map → init-opencode-YRHLGHIE.js.map} +0 -0
  163. /package/dist/{learning-persistence-FB4U5AX2.js.map → issue-triage-BLZHWC6U.js.map} +0 -0
  164. /package/dist/{model-config-helpers-QNV3KD2W.js.map → learning-persistence-X24OOBYY.js.map} +0 -0
  165. /package/dist/{openai-compat-adapter-GPZDIR3D.js.map → model-config-helpers-OQEZU2ZG.js.map} +0 -0
  166. /package/dist/{pr-reviewer-helpers-7SMNNDFJ.js.map → openai-compat-adapter-GRJA6RPZ.js.map} +0 -0
  167. /package/dist/{outcome-store-adapter-WRONSTUD.js.map → outcome-store-adapter-7CKYWUZV.js.map} +0 -0
  168. /package/dist/{repo-security-plan-LFWLVEL2.js.map → pr-reviewer-helpers-LKHPRW3X.js.map} +0 -0
  169. /package/dist/{registry-command-U7K6HIBK.js.map → registry-command-4LP4OSND.js.map} +0 -0
  170. /package/dist/{research-helpers-synthesize-X6MVAAKT.js.map → repo-security-plan-SOFUCHO4.js.map} +0 -0
  171. /package/dist/{routing-memory-OCIVXKOU.js.map → research-helpers-synthesize-SXNAJWHX.js.map} +0 -0
  172. /package/dist/{session-memory-4LMEWO3X.js.map → routing-memory-TWCXFPAD.js.map} +0 -0
  173. /package/dist/{setup-config-YNNNR4AE.js.map → session-memory-YVT5M4AN.js.map} +0 -0
  174. /package/dist/{setup-data-dir-XM5DWH7R.js.map → setup-config-JGHFR4P3.js.map} +0 -0
  175. /package/dist/{setup-custom-api-QEPUCHOX.js.map → setup-custom-api-EFAWNJ2D.js.map} +0 -0
  176. /package/dist/{tool-memory-EFGFXF65.js.map → setup-data-dir-Z4IQNMRC.js.map} +0 -0
  177. /package/dist/{tool-memory-registry-adapters-FO6JVQSX.js.map → tool-memory-5Y3HKHCB.js.map} +0 -0
  178. /package/dist/{unified-registry-KLNC24HA.js.map → tool-memory-registry-adapters-IIORYBCC.js.map} +0 -0
  179. /package/dist/{weather-report-PMYQ3WBW.js.map → unified-registry-IDUII5J7.js.map} +0 -0
@@ -0,0 +1,1046 @@
1
+ import {
2
+ getGlobalRegistry
3
+ } from "./chunk-PY6HJQYC.js";
4
+ import {
5
+ GatewayRediscovery,
6
+ discoverGatewayOnce,
7
+ setGatewayRediscovery
8
+ } from "./chunk-IGYZQEKM.js";
9
+ import {
10
+ GatewayHostRefusedError,
11
+ buildOpenAICompatAdapters,
12
+ readOpenAICompatEndpoint,
13
+ readOpenAICompatEnv
14
+ } from "./chunk-SKM75Y7E.js";
15
+ import {
16
+ hostnameOf
17
+ } from "./chunk-D33IH5VS.js";
18
+ import {
19
+ getDefaultCliCircuitBreakerRegistry
20
+ } from "./chunk-V6AJCRAU.js";
21
+ import {
22
+ createGatewayArmAdapter,
23
+ gatewayEndpointRejection,
24
+ isEndpointArmId,
25
+ logGatewaySlotMapping,
26
+ resolveGatewayDefault,
27
+ setGatewayCatalog,
28
+ setGatewaySlotCatalog
29
+ } from "./chunk-GPRYEKAA.js";
30
+ import {
31
+ detectSandbox,
32
+ parseBoolEnv
33
+ } from "./chunk-CH6IBWXH.js";
34
+ import {
35
+ VOTE_TIMEOUTS
36
+ } from "./chunk-4PN3UVZV.js";
37
+
38
+ // src/cli-command-catalog.ts
39
+ var COMMAND_CATALOG = [
40
+ // ── Essential ────────────────────────────────────────────────────────────
41
+ {
42
+ command: "(default)",
43
+ description: "Start MCP server with stdio transport",
44
+ audience: "essential"
45
+ },
46
+ {
47
+ command: "hello",
48
+ description: "Show welcome message and quick start (no API keys needed)",
49
+ audience: "essential"
50
+ },
51
+ {
52
+ command: "setup",
53
+ description: "Configure CLI integration (MCP + .rules + data dirs)",
54
+ audience: "essential"
55
+ },
56
+ {
57
+ command: "verify",
58
+ description: "Check install health (sqlite, adapters, config)",
59
+ audience: "essential"
60
+ },
61
+ {
62
+ command: "doctor",
63
+ description: "Detailed health check; no model completions by default; --live probes models",
64
+ audience: "essential"
65
+ },
66
+ {
67
+ command: "config",
68
+ description: "Manage configuration (init, get, set, list, export, import)",
69
+ audience: "essential"
70
+ },
71
+ {
72
+ command: "orchestrate",
73
+ description: "Execute a task via CLI tools (standalone mode)",
74
+ audience: "essential"
75
+ },
76
+ {
77
+ command: "vote",
78
+ // Default panel is 7 roles; `--quick` runs 3 (getVoterRoles in
79
+ // mcp/tools/consensus-vote.ts). Prior drift: "5-6 agents" here, "6 agents"
80
+ // in HELP_TEXT, "6 agents by default" in COMMAND_HELP — all wrong (#3209).
81
+ description: "Run consensus vote on a proposal (7 agents; --quick uses 3)",
82
+ audience: "essential"
83
+ },
84
+ {
85
+ command: "workflow",
86
+ description: "Manage and run workflow templates (list, run)",
87
+ audience: "essential"
88
+ },
89
+ {
90
+ command: "expert",
91
+ description: "Manage expert agents (list, create, execute)",
92
+ audience: "essential"
93
+ },
94
+ {
95
+ command: "research",
96
+ description: "Manage research registry (status, add, stats, refresh)",
97
+ audience: "essential"
98
+ },
99
+ // ── Advanced ─────────────────────────────────────────────────────────────
100
+ {
101
+ command: "tour",
102
+ description: "Guided walkthrough of the four headline tools \u2014 no API keys, no quota (#2851). --non-interactive runs straight through.",
103
+ audience: "advanced"
104
+ },
105
+ {
106
+ command: "session",
107
+ description: "Manage session persistence (list, show, export, delete)",
108
+ audience: "advanced"
109
+ },
110
+ {
111
+ command: "auth",
112
+ description: "Manage authentication: init/show/rotate MCP tokens; status shows per-CLI auth state",
113
+ audience: "essential"
114
+ },
115
+ {
116
+ command: "login",
117
+ description: '[deprecated alias] Soft alias of "auth status"; renamed in #2449',
118
+ audience: "maintainer"
119
+ },
120
+ {
121
+ command: "usage",
122
+ description: "Cost / usage / quality dashboard from per-call telemetry (#2469). --format=json for scripting.",
123
+ audience: "advanced"
124
+ },
125
+ {
126
+ command: "status",
127
+ description: "At-a-glance project health dashboard",
128
+ audience: "advanced"
129
+ },
130
+ {
131
+ command: "capabilities",
132
+ description: "Show model capabilities matrix",
133
+ audience: "advanced"
134
+ },
135
+ {
136
+ command: "mode",
137
+ description: "Inspect detected mode (server/orchestrator) + signals + reasoning (#3214)",
138
+ audience: "advanced"
139
+ },
140
+ {
141
+ command: "jobs",
142
+ description: "Async job-record maintenance (#6224): `prune` deletes terminal records past the 7-day retention window and marks abandoned pending records failed; --dry-run prints the counts only.",
143
+ audience: "advanced"
144
+ },
145
+ {
146
+ command: "registry",
147
+ description: "Inspect + refresh the dynamic model registry (doctor / refresh)",
148
+ audience: "advanced"
149
+ },
150
+ {
151
+ command: "migrate",
152
+ description: "Relocate homedir state (sessions, checkpoints, traces, runs, audit, pipeline, tasks) into <repo>/.nexus-agents/ for users adopting NEXUS_REPO_PREFERRED=1. Cross-repo state stays homedir. --dry-run for a no-op plan. Epic #2872.",
153
+ audience: "advanced"
154
+ },
155
+ {
156
+ command: "init",
157
+ description: "Initialize portable nexus-agents config in a repo. Flags: --portable (#2305/#2308/#2311), --install / --uninstall (#2311), --gitignore, --mcp-config, --opencode <path> (#2504), --force, --dry-run.",
158
+ audience: "advanced"
159
+ },
160
+ {
161
+ command: "review",
162
+ description: "Review a GitHub PR (dogfooding helper)",
163
+ audience: "advanced"
164
+ },
165
+ {
166
+ command: "scaffold",
167
+ description: "Generate project files from templates",
168
+ audience: "advanced"
169
+ },
170
+ {
171
+ command: "validate",
172
+ description: "Run unified validation (doctor + fitness + config)",
173
+ audience: "advanced"
174
+ },
175
+ {
176
+ command: "index",
177
+ description: "Generate and manage codebase index",
178
+ audience: "advanced"
179
+ },
180
+ {
181
+ command: "improvement-review",
182
+ description: "Observability-driven improvement loop (#2402). Surfaces threshold breaches; --file-issues opt-in.",
183
+ audience: "advanced"
184
+ },
185
+ {
186
+ command: "model-drift",
187
+ description: "Report models the registry does not know and registry models no source lists (#6625). --json; --file-issue opt-in.",
188
+ audience: "maintainer"
189
+ },
190
+ {
191
+ command: "auto-remediate",
192
+ description: "Run one auto-remediation cycle (#3540). OFF unless NEXUS_AUTO_REMEDIATE=audit|enforce; never auto-merges.",
193
+ audience: "maintainer"
194
+ },
195
+ {
196
+ command: "remediation-review",
197
+ description: "Review audit-mode selections: list \xB7 panel-judge --batch N [--quick] \xB7 sample --n 10 [--seed S] \xB7 mark --evaluator --sound|--unsound [--sample id] \xB7 sign-off --owner \xB7 readiness (human, panel and owner-sample judgments + soak-store alarm).",
198
+ audience: "maintainer"
199
+ },
200
+ // ── Maintainer (hidden by default) ───────────────────────────────────────
201
+ {
202
+ command: "demo",
203
+ description: "API-free exploration mode (marketing/demo flow)",
204
+ audience: "maintainer"
205
+ },
206
+ {
207
+ command: "hooks",
208
+ description: "Claude CLI hook integration commands",
209
+ audience: "maintainer"
210
+ },
211
+ {
212
+ command: "routing-audit",
213
+ description: "Debug model routing decisions",
214
+ audience: "maintainer"
215
+ },
216
+ {
217
+ command: "fitness-audit",
218
+ description: "Run CLI orchestration fitness score audit",
219
+ audience: "maintainer"
220
+ },
221
+ {
222
+ command: "system-review",
223
+ description: "Automated system review (5-phase checklist)",
224
+ audience: "maintainer"
225
+ },
226
+ {
227
+ command: "sprint",
228
+ description: "Automated sprint planning from open issues",
229
+ audience: "maintainer"
230
+ },
231
+ {
232
+ command: "evaluate",
233
+ description: "Self-evaluation of codebase components",
234
+ audience: "maintainer"
235
+ },
236
+ {
237
+ command: "issue",
238
+ description: "Issue template validation and management",
239
+ audience: "maintainer"
240
+ },
241
+ {
242
+ command: "validation",
243
+ description: "Learning validation dashboard",
244
+ audience: "maintainer"
245
+ },
246
+ {
247
+ command: "learning-metrics",
248
+ description: "Aggregated learning metrics dashboard",
249
+ audience: "maintainer"
250
+ },
251
+ {
252
+ command: "visualize",
253
+ description: "Generate Mermaid diagrams and ASCII dashboards",
254
+ audience: "maintainer"
255
+ },
256
+ {
257
+ command: "health",
258
+ description: "Swarm health metrics dashboard",
259
+ audience: "maintainer"
260
+ },
261
+ {
262
+ command: "release-notes",
263
+ description: "Generate release notes from git commits",
264
+ audience: "maintainer"
265
+ },
266
+ {
267
+ command: "release-validate",
268
+ description: "Run expert swarm validation for releases",
269
+ audience: "maintainer"
270
+ },
271
+ {
272
+ command: "release-announce",
273
+ description: "Generate release announcements (blog, social)",
274
+ audience: "maintainer"
275
+ },
276
+ // ── Internal (hidden everywhere; here for extractor/index completeness) ──
277
+ {
278
+ command: "server",
279
+ // Synonym for the no-arg invocation — `nexus-agents` and
280
+ // `nexus-agents server` both run `handleServerCommand`. Listed here for
281
+ // extractor completeness; humans see `(default)` in --help.
282
+ description: "Start MCP server with stdio transport (explicit form)",
283
+ audience: "internal"
284
+ },
285
+ {
286
+ command: "e2e-eval",
287
+ description: "E2E evaluation scenario runner (dev loop)",
288
+ audience: "internal"
289
+ },
290
+ {
291
+ command: "memory-benchmark",
292
+ description: "Memory-system benchmark runner (dev loop)",
293
+ audience: "internal"
294
+ },
295
+ {
296
+ command: "memory-eval",
297
+ description: "Comparative memory evaluation benchmark (dev loop)",
298
+ audience: "internal"
299
+ },
300
+ {
301
+ command: "routing-ab",
302
+ description: "A/B comparison of routing strategies (dev loop)",
303
+ audience: "internal"
304
+ },
305
+ {
306
+ command: "scenario",
307
+ description: "Execute a named scenario from the testing framework",
308
+ audience: "internal"
309
+ },
310
+ {
311
+ command: "warm-up",
312
+ description: "Warm the model/adapter caches before a run",
313
+ audience: "internal"
314
+ }
315
+ ];
316
+ function filterCatalog(showAll) {
317
+ const visible = COMMAND_CATALOG.filter((e) => e.audience !== "internal");
318
+ if (showAll) return visible;
319
+ return visible.filter((e) => e.audience !== "maintainer");
320
+ }
321
+ function catalogForExtractors() {
322
+ return COMMAND_CATALOG.filter((e) => e.command !== "(default)");
323
+ }
324
+ function getCommandDescription(command) {
325
+ return COMMAND_CATALOG.find((e) => e.command === command)?.description;
326
+ }
327
+ function groupByAudience(entries) {
328
+ const groups = /* @__PURE__ */ new Map();
329
+ for (const entry of entries) {
330
+ const existing = groups.get(entry.audience) ?? [];
331
+ existing.push(entry);
332
+ groups.set(entry.audience, existing);
333
+ }
334
+ return groups;
335
+ }
336
+ var AUDIENCE_HEADINGS = {
337
+ essential: "Essential \u2014 install, configure, run",
338
+ advanced: "Advanced \u2014 day-to-day extras",
339
+ maintainer: "Maintainer \u2014 benchmarks, releases, deep diagnostics",
340
+ // Never rendered (filterCatalog strips internal before renderCommandsSection
341
+ // iterates), but required by the Record<CommandAudience, string> contract.
342
+ internal: "Internal \u2014 dev/eval loops (hidden from --help)"
343
+ };
344
+ function renderCommandsSection(showAll) {
345
+ const filtered = filterCatalog(showAll);
346
+ const groups = groupByAudience(filtered);
347
+ const lines = [];
348
+ const order = showAll ? ["essential", "advanced", "maintainer"] : ["essential", "advanced"];
349
+ for (const audience of order) {
350
+ const entries = groups.get(audience);
351
+ if (entries === void 0 || entries.length === 0) continue;
352
+ lines.push(` ${AUDIENCE_HEADINGS[audience]}`);
353
+ for (const entry of entries) {
354
+ lines.push(` ${entry.command.padEnd(16)} ${entry.description}`);
355
+ }
356
+ lines.push("");
357
+ }
358
+ if (!showAll) {
359
+ lines.push(" Run with --all to show maintainer commands (benchmarks, release tooling).");
360
+ }
361
+ return lines.join("\n").replace(/\n+$/, "");
362
+ }
363
+
364
+ // src/cli-help-text.ts
365
+ var COMMANDS_PLACEHOLDER = "__COMMANDS__";
366
+ var HELP_TEXT_FRAME = `
367
+ nexus-agents - Intelligent orchestration platform for AI coding tools
368
+
369
+ USAGE:
370
+ nexus-agents [OPTIONS]
371
+ nexus-agents [COMMAND] [SUBCOMMAND] [OPTIONS]
372
+
373
+ COMMANDS:
374
+ ${COMMANDS_PLACEHOLDER}
375
+
376
+ OPTIONS:
377
+ -h, --help Show this help message
378
+ -v, --version Show version information
379
+ --verbose Enable verbose output
380
+ --interactive Start interactive REPL mode
381
+ -m, --mode <mode> Server mode: server, orchestrator (default: server)
382
+ - server: MCP server only (for Claude CLI integration)
383
+ - orchestrator: CLI orchestrator (calls Gemini/Codex CLIs)
384
+
385
+ For command-specific options, run: nexus-agents <command> --help
386
+ (For example: nexus-agents vote --help)
387
+
388
+ EXAMPLES:
389
+ nexus-agents hello Show welcome + quick start (no API keys needed)
390
+ nexus-agents setup --interactive Run guided setup wizard
391
+ nexus-agents verify Quick install check (run first)
392
+ nexus-agents auth status Per-CLI auth state + login fix instructions
393
+ nexus-agents doctor Detailed CLI/adapter health check
394
+ nexus-agents orchestrate -t "..." Run a one-off task via the CLI orchestrator
395
+ nexus-agents vote --quick -p "X" 3-agent consensus vote on proposal "X"
396
+ nexus-agents --help --all Show every command (incl. maintainer tools)
397
+
398
+ For more information, visit: https://github.com/nexus-substrate/nexus-agents
399
+ `.trim();
400
+ function composeHelp(commandsSection) {
401
+ return HELP_TEXT_FRAME.replace(COMMANDS_PLACEHOLDER, commandsSection);
402
+ }
403
+ var HELP_TEXT = composeHelp(renderCommandsSection(true));
404
+ function renderHelp(opts) {
405
+ if (opts.all) return HELP_TEXT;
406
+ return composeHelp(renderCommandsSection(false));
407
+ }
408
+
409
+ // src/cli-types.ts
410
+ var EXIT_CODES = {
411
+ SUCCESS: 0,
412
+ SERVER_START_FAILED: 1,
413
+ SHUTDOWN_ERROR: 2,
414
+ INVALID_ARGS: 3,
415
+ /** Subcommand is stubbed / advertised but not implemented (#2727). */
416
+ NOT_IMPLEMENTED: 4
417
+ };
418
+ function cliExit(exitCode, message) {
419
+ return message === void 0 ? { success: exitCode === EXIT_CODES.SUCCESS, exitCode } : { success: exitCode === EXIT_CODES.SUCCESS, exitCode, message };
420
+ }
421
+ function cliExitFromStatus(status, message) {
422
+ return cliExit(
423
+ status === EXIT_CODES.SUCCESS ? EXIT_CODES.SUCCESS : EXIT_CODES.SERVER_START_FAILED,
424
+ message
425
+ );
426
+ }
427
+ var LIFECYCLE_DELEGATED = {
428
+ __lifecycleDelegated: true
429
+ };
430
+ function isLifecycleDelegated(result) {
431
+ return result.__lifecycleDelegated === true && !("exitCode" in result);
432
+ }
433
+ var PARSE_ARGS_CONFIG = {
434
+ options: {
435
+ help: {
436
+ type: "boolean",
437
+ short: "h",
438
+ default: false
439
+ },
440
+ version: {
441
+ type: "boolean",
442
+ short: "v",
443
+ default: false
444
+ },
445
+ verbose: {
446
+ type: "boolean",
447
+ default: false
448
+ },
449
+ interactive: {
450
+ type: "boolean",
451
+ default: false
452
+ },
453
+ // Tiered --help output (Issue #2135): `--help --all` unhides maintainer commands
454
+ all: {
455
+ type: "boolean",
456
+ default: false
457
+ },
458
+ mode: {
459
+ type: "string",
460
+ short: "m",
461
+ default: "server"
462
+ },
463
+ output: {
464
+ type: "string",
465
+ short: "o"
466
+ },
467
+ force: {
468
+ type: "boolean",
469
+ short: "f",
470
+ default: false
471
+ },
472
+ format: {
473
+ type: "string",
474
+ default: "table"
475
+ },
476
+ input: {
477
+ type: "string",
478
+ short: "i"
479
+ },
480
+ "dry-run": {
481
+ type: "boolean",
482
+ default: false
483
+ },
484
+ "bandit-stats": {
485
+ type: "boolean",
486
+ default: false
487
+ },
488
+ // Review command options
489
+ setup: {
490
+ type: "boolean",
491
+ default: false
492
+ },
493
+ "skip-checks": {
494
+ type: "boolean",
495
+ default: false
496
+ },
497
+ // Orchestrate command options (also used in orchestrator mode)
498
+ task: {
499
+ type: "string",
500
+ short: "t"
501
+ },
502
+ model: {
503
+ type: "string"
504
+ },
505
+ "max-tokens": {
506
+ type: "string"
507
+ },
508
+ "max-cost-usd": {
509
+ type: "string"
510
+ },
511
+ // Orchestrate engine options (Issue #386)
512
+ engine: {
513
+ type: "string",
514
+ default: "router"
515
+ },
516
+ learn: {
517
+ type: "boolean",
518
+ default: false
519
+ },
520
+ "policy-path": {
521
+ type: "string"
522
+ },
523
+ "max-steps": {
524
+ type: "string"
525
+ },
526
+ // System review command options
527
+ "create-issue": {
528
+ type: "boolean",
529
+ default: false
530
+ },
531
+ fix: {
532
+ type: "boolean",
533
+ default: false
534
+ },
535
+ // Vote command options
536
+ proposal: {
537
+ type: "string",
538
+ short: "p"
539
+ },
540
+ // Repeatable. No short letter: every free one is taken, and the two
541
+ // collisions that already existed silently bound the wrong option (#4922).
542
+ option: {
543
+ type: "string",
544
+ multiple: true
545
+ },
546
+ // No `short`. `parseArgs` takes one options object for every command, so
547
+ // a short letter is global: `-t` was already `task`, which won, and
548
+ // `vote -t supermajority` silently ran a simple-majority vote. Long form
549
+ // only — `cli-types.test.ts` pins that no two options share a letter.
550
+ threshold: {
551
+ type: "string"
552
+ },
553
+ // #6227 — the bar as the tool spells it. `threshold` is the legacy spelling;
554
+ // the engine's `resolveStrategy` lets `strategy` win when both are given.
555
+ strategy: {
556
+ type: "string"
557
+ },
558
+ "artifact-file": {
559
+ type: "string"
560
+ },
561
+ // #6227 — `<pr>@<40-hex sha>`: binds the record to a governor-path PR for
562
+ // `scripts/append-ratification-record.ts`. Validated in `buildVoteOptions`.
563
+ "ratifies-pr": {
564
+ type: "string"
565
+ },
566
+ quick: {
567
+ type: "boolean",
568
+ short: "q",
569
+ default: false
570
+ },
571
+ // #6236 — seconds, read from the same constant `vote --help` renders and
572
+ // `runVote` falls back to. A hard-coded '90' here ran every seat at less
573
+ // than a third of the #1640 budget while the help said 300.
574
+ timeout: {
575
+ type: "string",
576
+ default: String(VOTE_TIMEOUTS.defaultMs / 1e3)
577
+ },
578
+ // #2630 — error policy for the vote command.
579
+ "error-policy": {
580
+ type: "string"
581
+ },
582
+ // #4135 — how the vote command maps a no_quorum decision (fail|exit2|retry).
583
+ "on-no-quorum": {
584
+ type: "string"
585
+ },
586
+ // #6110 — the project the voter prompts name; derived from the cwd when absent.
587
+ project: {
588
+ type: "string"
589
+ },
590
+ // Learning-metrics command options
591
+ // No `short` — `-p` is `proposal`, which was declared first and won. See
592
+ // the note on `threshold`.
593
+ period: {
594
+ type: "string"
595
+ },
596
+ export: {
597
+ type: "string"
598
+ },
599
+ "no-trends": {
600
+ type: "boolean",
601
+ default: false
602
+ },
603
+ // Setup command options (Issue #363)
604
+ "non-interactive": {
605
+ type: "boolean",
606
+ default: false
607
+ },
608
+ "skip-mcp": {
609
+ type: "boolean",
610
+ default: false
611
+ },
612
+ "skip-rules": {
613
+ type: "boolean",
614
+ default: false
615
+ },
616
+ "skip-hooks": {
617
+ type: "boolean",
618
+ default: false
619
+ },
620
+ "skip-config": {
621
+ type: "boolean",
622
+ default: false
623
+ },
624
+ "skip-opencode": {
625
+ type: "boolean",
626
+ default: false
627
+ },
628
+ "skip-gemini": {
629
+ type: "boolean",
630
+ default: false
631
+ },
632
+ "skip-codex": {
633
+ type: "boolean",
634
+ default: false
635
+ },
636
+ scope: {
637
+ type: "string",
638
+ default: "user"
639
+ },
640
+ // Setup --custom-api for OpenAI-compatible gateway configuration (#2124)
641
+ "custom-api": {
642
+ type: "string"
643
+ },
644
+ "custom-api-key": {
645
+ type: "string"
646
+ },
647
+ "custom-model": {
648
+ type: "string"
649
+ },
650
+ // Demo command options
651
+ mock: {
652
+ type: "boolean",
653
+ default: false
654
+ },
655
+ // Doctor command options (Issue #1031)
656
+ deep: {
657
+ type: "boolean",
658
+ default: false
659
+ },
660
+ // Doctor live readiness probe (#4376)
661
+ live: {
662
+ type: "boolean",
663
+ default: false
664
+ },
665
+ // Doctor gateway section and opt-in completion probe (#6609)
666
+ gateway: {
667
+ type: "boolean",
668
+ default: false
669
+ },
670
+ probe: {
671
+ type: "boolean",
672
+ default: false
673
+ },
674
+ // Registry command options (#2179)
675
+ json: {
676
+ type: "boolean",
677
+ default: false
678
+ },
679
+ // model-drift command option (#6625)
680
+ "file-issue": {
681
+ type: "boolean",
682
+ default: false
683
+ },
684
+ source: {
685
+ type: "string"
686
+ },
687
+ // init --portable command options (#2305)
688
+ portable: {
689
+ type: "boolean",
690
+ default: false
691
+ },
692
+ gitignore: {
693
+ type: "boolean",
694
+ default: false
695
+ },
696
+ // init --portable --mcp-config flag (#2308)
697
+ "mcp-config": {
698
+ type: "boolean",
699
+ default: false
700
+ },
701
+ // init --portable --install / --uninstall flags (#2311)
702
+ install: {
703
+ type: "boolean",
704
+ default: false
705
+ },
706
+ uninstall: {
707
+ type: "boolean",
708
+ default: false
709
+ },
710
+ // improvement-review command options (#2444)
711
+ "lookback-days": {
712
+ type: "string"
713
+ },
714
+ "file-issues": {
715
+ type: "boolean",
716
+ default: false
717
+ },
718
+ "min-sample-size": {
719
+ type: "string"
720
+ },
721
+ "fitness-floor": {
722
+ type: "string"
723
+ },
724
+ // init --opencode <path> flag (#2504)
725
+ opencode: {
726
+ type: "string"
727
+ },
728
+ validate: {
729
+ type: "boolean",
730
+ default: false
731
+ },
732
+ // remediation-review command options (#3765)
733
+ evaluator: {
734
+ type: "string"
735
+ },
736
+ owner: {
737
+ type: "string"
738
+ },
739
+ note: {
740
+ type: "string"
741
+ },
742
+ sound: {
743
+ type: "boolean",
744
+ default: false
745
+ },
746
+ unsound: {
747
+ type: "boolean",
748
+ default: false
749
+ },
750
+ batch: { type: "string" },
751
+ n: { type: "string" },
752
+ seed: { type: "string" },
753
+ sample: { type: "string" },
754
+ // session command options (#6693)
755
+ limit: {
756
+ type: "string"
757
+ },
758
+ markdown: {
759
+ type: "boolean",
760
+ default: false
761
+ },
762
+ // usage command options (#6693)
763
+ since: {
764
+ type: "string"
765
+ },
766
+ until: {
767
+ type: "string"
768
+ },
769
+ // validation command options (#6693)
770
+ "task-type": {
771
+ type: "string"
772
+ },
773
+ "min-sample": {
774
+ type: "string"
775
+ },
776
+ // #6693 follow-up — subcommand flags that usage text advertised and
777
+ // handlers read, still rejected after #6705. Forwarded by
778
+ // `buildSubcommandFlagOptions` (cli/subcommand-flag-options.ts). No short
779
+ // letters: a short letter is global (see the note on `threshold`).
780
+ vote: { type: "boolean", default: false },
781
+ topic: { type: "string" },
782
+ status: { type: "string" },
783
+ "create-issues": { type: "boolean", default: false },
784
+ max: { type: "string" },
785
+ generate: { type: "boolean", default: false },
786
+ check: { type: "boolean", default: false },
787
+ strict: { type: "boolean", default: false },
788
+ silent: { type: "boolean", default: false },
789
+ "no-check-files": { type: "boolean", default: false },
790
+ skip: { type: "string", multiple: true }
791
+ },
792
+ allowPositionals: true,
793
+ strict: true
794
+ };
795
+ var VALID_COMMANDS = [
796
+ "server",
797
+ "help",
798
+ "version",
799
+ "hello",
800
+ "config",
801
+ "expert",
802
+ "workflow",
803
+ "doctor",
804
+ "verify",
805
+ "review",
806
+ "routing-audit",
807
+ "orchestrate",
808
+ "system-review",
809
+ "vote",
810
+ "index",
811
+ "research",
812
+ "validation",
813
+ "learning-metrics",
814
+ "setup",
815
+ "hooks",
816
+ "demo",
817
+ "sprint",
818
+ "session",
819
+ "evaluate",
820
+ "issue",
821
+ "fitness-audit",
822
+ "release-notes",
823
+ "release-validate",
824
+ "release-announce",
825
+ "scaffold",
826
+ "visualize",
827
+ "capabilities",
828
+ "status",
829
+ "memory-benchmark",
830
+ "auth",
831
+ "scenario",
832
+ "warm-up",
833
+ "e2e-eval",
834
+ "routing-ab",
835
+ "memory-eval",
836
+ "health",
837
+ "init",
838
+ "validate",
839
+ "registry",
840
+ "login",
841
+ "usage",
842
+ "improvement-review",
843
+ "model-drift",
844
+ "migrate",
845
+ "tour",
846
+ "auto-remediate",
847
+ "remediation-review",
848
+ "mode",
849
+ "jobs"
850
+ ];
851
+ function isValidCommand(value) {
852
+ return VALID_COMMANDS.includes(value);
853
+ }
854
+
855
+ // src/cli-server-gateway.ts
856
+ async function tryWireGatewayAdapters(logger) {
857
+ return (await wireGatewayOnce(logger)).adapters;
858
+ }
859
+ async function wireGatewayOnce(logger) {
860
+ const sandboxActive = detectSandbox().active;
861
+ const env = readOpenAICompatEnv();
862
+ if (env === null) {
863
+ handleMissingEnv(logger, sandboxActive);
864
+ noticeCliSubprocessFallback(logger);
865
+ return { adapters: void 0, retryable: false };
866
+ }
867
+ const result = await discoverGatewayOnce(logger);
868
+ if (result === null) {
869
+ noticeCliSubprocessFallback(logger);
870
+ return { adapters: void 0, retryable: false };
871
+ }
872
+ if (!result.ok && result.error instanceof GatewayHostRefusedError) {
873
+ handleHostRefused(logger, sandboxActive, result.error.status);
874
+ noticeCliSubprocessFallback(logger);
875
+ return { adapters: void 0, retryable: false };
876
+ }
877
+ if (!result.ok) {
878
+ handleProbeFailure(logger, sandboxActive, result.error.message);
879
+ noticeCliSubprocessFallback(logger);
880
+ return { adapters: void 0, retryable: true };
881
+ }
882
+ if (result.value.length === 0) {
883
+ handleZeroModels(logger, sandboxActive);
884
+ noticeCliSubprocessFallback(logger);
885
+ return { adapters: void 0, retryable: true };
886
+ }
887
+ logger.info("OpenAI-compatible gateway wired", {
888
+ host: hostnameOf(env.baseUrl),
889
+ modelCount: result.value.length,
890
+ models: result.value.map((a) => a.modelId)
891
+ });
892
+ return { adapters: result.value, retryable: false };
893
+ }
894
+ var cliSubprocessFallbackNoticeLogged = false;
895
+ function noticeCliSubprocessFallback(logger) {
896
+ if (cliSubprocessFallbackNoticeLogged) return;
897
+ cliSubprocessFallbackNoticeLogged = true;
898
+ logger.info(
899
+ "No in-process gateway is configured, so voter/consensus calls will spawn CLI subprocesses (slower per-vote startup, subject to each CLI's own auth/quota). Set NEXUS_OPENAI_COMPAT_URL and NEXUS_OPENAI_COMPAT_KEY to route voters through an OpenAI-compatible gateway in-process instead (lower latency, no subprocess spawn)."
900
+ );
901
+ }
902
+ function _resetCliSubprocessFallbackNotice() {
903
+ cliSubprocessFallbackNoticeLogged = false;
904
+ }
905
+ function resolveDefaultModelAdapter(gatewayAdapters, adapterRegistry) {
906
+ const primary = gatewayAdapters?.[0];
907
+ if (primary === void 0) return adapterRegistry.getDefault();
908
+ const ranked = resolveGatewayDefault();
909
+ return ranked.kind === "resolved" ? ranked.adapter : primary;
910
+ }
911
+ function registerGatewayArm(adapters, endpoint, registry) {
912
+ const logger = registry.getLogger();
913
+ if (adapters === void 0 || adapters.length === 0) {
914
+ logger.debug("No gateway adapters discovered; no api: arm registered");
915
+ return void 0;
916
+ }
917
+ const armId = `api:${endpoint}`;
918
+ const rejection = gatewayEndpointRejection(endpoint);
919
+ if (rejection !== void 0 || !isEndpointArmId(armId)) {
920
+ logger.warn("Gateway endpoint is not a valid gateway endpoint; no api: arm registered", {
921
+ reason: rejection ?? "not a valid endpoint id"
922
+ });
923
+ return void 0;
924
+ }
925
+ registry.registerApiArm(
926
+ armId,
927
+ createGatewayArmAdapter(armId, adapters, {
928
+ circuitBreakerRegistry: getDefaultCliCircuitBreakerRegistry(),
929
+ logger
930
+ })
931
+ );
932
+ setGatewayCatalog(
933
+ armId,
934
+ adapters.map((a) => a.modelId)
935
+ );
936
+ logger.info("Gateway registered as one api: arm", { arm: armId, modelCount: adapters.length });
937
+ return armId;
938
+ }
939
+ async function wireGateway(logger, registry = getGlobalRegistry()) {
940
+ const { adapters, retryable } = await wireGatewayOnce(logger);
941
+ const endpoint = readOpenAICompatEndpoint(process.env, logger);
942
+ const registerArms = (found) => {
943
+ registerGatewayArm(found, endpoint, registry);
944
+ if (parseBoolEnv("NEXUS_ROUTE_GATEWAY_ARMS", false)) {
945
+ const global = getGlobalRegistry();
946
+ if (global !== registry) registerGatewayArm(found, endpoint, global);
947
+ }
948
+ };
949
+ registerArms(adapters);
950
+ registerFamilySlots(adapters, logger);
951
+ if (!retryable) return adapters;
952
+ const live = [];
953
+ setGatewayRediscovery(
954
+ new GatewayRediscovery({
955
+ target: live,
956
+ logger,
957
+ discover: () => rediscoverGateway(logger),
958
+ onDiscovered: (found) => {
959
+ registerArms(found);
960
+ registerFamilySlots(found, logger);
961
+ }
962
+ })
963
+ );
964
+ return live;
965
+ }
966
+ function registerFamilySlots(adapters, logger) {
967
+ setGatewaySlotCatalog(adapters ?? []);
968
+ logGatewaySlotMapping(logger);
969
+ }
970
+ async function rediscoverGateway(logger) {
971
+ const result = await buildOpenAICompatAdapters(logger);
972
+ if (result === null) return void 0;
973
+ if (!result.ok && result.error instanceof GatewayHostRefusedError) {
974
+ handleHostRefused(logger, false, result.error.status);
975
+ return "refused";
976
+ }
977
+ if (!result.ok) {
978
+ logger.warn("Gateway re-discovery failed; calls stay on CLI subprocesses", {
979
+ error: result.error.message
980
+ });
981
+ return void 0;
982
+ }
983
+ return result.value;
984
+ }
985
+ function handleMissingEnv(logger, sandboxActive) {
986
+ if (sandboxActive) {
987
+ logger.error(
988
+ "Sandbox mode active but NEXUS_OPENAI_COMPAT_URL / NEXUS_OPENAI_COMPAT_KEY are not set. Configure the gateway in your launch env or opencode.json. See docs/guides/SANDBOXED-USAGE.md.",
989
+ new Error("Missing gateway configuration in sandbox mode")
990
+ );
991
+ process.exit(EXIT_CODES.SERVER_START_FAILED);
992
+ }
993
+ return void 0;
994
+ }
995
+ function handleProbeFailure(logger, sandboxActive, reason) {
996
+ if (sandboxActive) {
997
+ logger.error(
998
+ "Sandbox mode active and OpenAI-compatible gateway probe failed.",
999
+ new Error(reason)
1000
+ );
1001
+ process.exit(EXIT_CODES.SERVER_START_FAILED);
1002
+ }
1003
+ logger.warn("OpenAI-compatible gateway probe failed; continuing with CLI adapters", {
1004
+ error: reason
1005
+ });
1006
+ return void 0;
1007
+ }
1008
+ function handleHostRefused(logger, sandboxActive, status) {
1009
+ const message = `Gateway host ${status.host} refused by the private-address guard: the in-process gateway is NOT in use, and voter/consensus calls fall back to CLI subprocesses. ` + status.remedy;
1010
+ if (sandboxActive) {
1011
+ logger.error(message, new Error(status.reason));
1012
+ process.exit(EXIT_CODES.SERVER_START_FAILED);
1013
+ }
1014
+ logger.warn(message, { host: status.host, reason: status.reason });
1015
+ }
1016
+ function handleZeroModels(logger, sandboxActive) {
1017
+ if (sandboxActive) {
1018
+ logger.error(
1019
+ "Sandbox mode active and gateway returned 0 models. Check upstream provider quotas / list filters.",
1020
+ new Error("Gateway discovered 0 models")
1021
+ );
1022
+ process.exit(EXIT_CODES.SERVER_START_FAILED);
1023
+ }
1024
+ logger.warn("OpenAI-compatible gateway returned 0 models; ignoring");
1025
+ return void 0;
1026
+ }
1027
+
1028
+ export {
1029
+ COMMAND_CATALOG,
1030
+ catalogForExtractors,
1031
+ getCommandDescription,
1032
+ renderHelp,
1033
+ EXIT_CODES,
1034
+ cliExit,
1035
+ cliExitFromStatus,
1036
+ LIFECYCLE_DELEGATED,
1037
+ isLifecycleDelegated,
1038
+ PARSE_ARGS_CONFIG,
1039
+ isValidCommand,
1040
+ tryWireGatewayAdapters,
1041
+ _resetCliSubprocessFallbackNotice,
1042
+ resolveDefaultModelAdapter,
1043
+ registerGatewayArm,
1044
+ wireGateway
1045
+ };
1046
+ //# sourceMappingURL=chunk-5CUI42NO.js.map