remoteclaw 0.1.0-next.049f396 → 0.1.0-next.05abcca

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 (1199) hide show
  1. package/README.md +11 -9
  2. package/dist/accounts-79XhjwAj.js +32 -0
  3. package/dist/accounts-B1M3fOxL.js +272 -0
  4. package/dist/accounts-BwbvnKsW.js +205 -0
  5. package/dist/accounts-CIVjmTg9.js +270 -0
  6. package/dist/accounts-D1awQXKu.js +36 -0
  7. package/dist/accounts-DHkGVGUR.js +36 -0
  8. package/dist/accounts-P7cmIXUM.js +206 -0
  9. package/dist/accounts-XFgBY644.js +47 -0
  10. package/dist/accounts-_ZuNC5bz.js +47 -0
  11. package/dist/ack-reactions-BGJ9Vigf.js +621 -0
  12. package/dist/ack-reactions-Diu9O24z.js +621 -0
  13. package/dist/acp-cli-BwZ-va2P.js +1316 -0
  14. package/dist/acp-cli-eVKByz-j.js +1311 -0
  15. package/dist/active-listener--jrUO-8L.js +37 -0
  16. package/dist/active-listener-C7SyMcNY.js +37 -0
  17. package/dist/agent-BAxK2KQW.js +688 -0
  18. package/dist/agent-Dd5Yfhmq.js +687 -0
  19. package/dist/agent-helpers-5F0tdxud.js +400 -0
  20. package/dist/agent-helpers-Bs2nBXeI.js +400 -0
  21. package/dist/agent-scope-BA1HP4K6.js +114 -0
  22. package/dist/agent-scope-CAQLm3LP.js +116 -0
  23. package/dist/agents-D--9DD91.js +754 -0
  24. package/dist/agents.config-CmyzLYqW.js +116 -0
  25. package/dist/agents.config-DerBqRzk.js +116 -0
  26. package/dist/ansi-DtaiOnt1.js +107 -0
  27. package/dist/audio-ClIuKwkl.js +43 -0
  28. package/dist/audio-DqlIYYTb.js +43 -0
  29. package/dist/audit-Cn0cNCE4.js +3114 -0
  30. package/dist/audit-DXY4NHBC.js +3114 -0
  31. package/dist/auth-B-QK8JhI.js +315 -0
  32. package/dist/auth-C1zx1O24.js +314 -0
  33. package/dist/auth-DDmNYVMW.js +448 -0
  34. package/dist/auth-DH1wEw0w.js +448 -0
  35. package/dist/banner-CBWZhANO.js +294 -0
  36. package/dist/binaries-CYwLdubd.js +13 -0
  37. package/dist/bindings-DFAFatwT.js +69 -0
  38. package/dist/bindings-GUKIzFCp.js +69 -0
  39. package/dist/bonjour-discovery-AQMJqY4V.js +378 -0
  40. package/dist/bonjour-discovery-BLcPWHFJ.js +378 -0
  41. package/dist/boot/handler.js +41 -84
  42. package/dist/browser-cli-8Dv5ogFT.js +1690 -0
  43. package/dist/browser-cli-wNLo8SOy.js +1694 -0
  44. package/dist/build-info.json +3 -3
  45. package/dist/call-BTHzKFbN.js +518 -0
  46. package/dist/call-D_NchaCs.js +517 -0
  47. package/dist/canvas-host/a2ui/.bundle.hash +1 -1
  48. package/dist/catalog-DgpN5jxU.js +186 -0
  49. package/dist/catalog-k056Nh93.js +186 -0
  50. package/dist/channel-account-context-BHIy71Yh.js +133 -0
  51. package/dist/channel-account-context-DXU_-EkJ.js +133 -0
  52. package/dist/channel-activity-BatlvP_U.js +292 -0
  53. package/dist/channel-activity-BhT7NQ_v.js +94 -0
  54. package/dist/channel-activity-CvjEwpJz.js +94 -0
  55. package/dist/channel-options-BCccA2WC.js +32 -0
  56. package/dist/channel-options-VPR_pNyS.js +33 -0
  57. package/dist/channel-selection-AH6_y6RS.js +51 -0
  58. package/dist/channel-selection-ovohyJQZ.js +51 -0
  59. package/dist/channel-web-APDaQ_wp.js +2134 -0
  60. package/dist/channel-web-BW_YuNlT.js +2132 -0
  61. package/dist/channels-cli-DVsZyaU5.js +1436 -0
  62. package/dist/channels-cli-ubrg5vcL.js +1440 -0
  63. package/dist/channels-status-issues-BbYNzwLp.js +18 -0
  64. package/dist/channels-status-issues-DRybAijg.js +18 -0
  65. package/dist/chat-envelope-AJFUAuBM.js +248 -0
  66. package/dist/chat-envelope-BrfcPlDM.js +248 -0
  67. package/dist/chrome-Bv2UtAMQ.js +1732 -0
  68. package/dist/chrome-C6Vc_7su.js +1733 -0
  69. package/dist/chunk-BAMyFYtF.js +341 -0
  70. package/dist/chunk-BzVoFUZL.js +341 -0
  71. package/dist/clack-prompter-C6mBTOzE.js +122 -0
  72. package/dist/clack-prompter-DKcYqv3o.js +121 -0
  73. package/dist/cleanup-utils-Cb-leJcy.js +94 -0
  74. package/dist/cli/daemon-cli.js +1 -1
  75. package/dist/cli-Cs1n6-eD.js +135 -0
  76. package/dist/cli-Di3p1tLN.js +131 -0
  77. package/dist/client-B6h7bgbF.js +2311 -0
  78. package/dist/client-CMtdm9Ii.js +2311 -0
  79. package/dist/clipboard-A06eV_5C.js +31 -0
  80. package/dist/clipboard-DQBl3coj.js +31 -0
  81. package/dist/command-format-BiiNHkWG.js +18 -0
  82. package/dist/command-format-Dntg_tnC.js +32 -0
  83. package/dist/command-logger/handler.js +1 -1
  84. package/dist/command-registry-CCAvdWh2.js +215 -0
  85. package/dist/commands-D93TXYhv.js +41 -0
  86. package/dist/commands-UD7V7QC9.js +41 -0
  87. package/dist/commands-registry-CCbTtSSK.js +891 -0
  88. package/dist/commands-registry-De8JhZLG.js +890 -0
  89. package/dist/common-D4fL3S2m.js +156 -0
  90. package/dist/common-DXNisGxw.js +156 -0
  91. package/dist/completion-cli-CLo-r-UP.js +452 -0
  92. package/dist/completion-cli-D4ajG3yt.js +452 -0
  93. package/dist/config-BTH7fB_v.js +3345 -0
  94. package/dist/config-DwuBnd6D.js +3347 -0
  95. package/dist/config-cli-D0D1LSNt.js +243 -0
  96. package/dist/config-cli-tWsFNKQM.js +247 -0
  97. package/dist/config-guard-BcT7soTj.js +92 -0
  98. package/dist/config-guard-Bqak3bDc.js +75 -0
  99. package/dist/config-validation-CHEjSJ5K.js +18 -0
  100. package/dist/config-validation-CvgqLhyG.js +18 -0
  101. package/dist/configure-CK_0tFJG.js +889 -0
  102. package/dist/configure-D0z0kE-B.js +891 -0
  103. package/dist/constants-BBVTjb1j.js +75 -0
  104. package/dist/constants-PMRtHBHU.js +75 -0
  105. package/dist/control-auth-DrGYtMJM.js +397 -0
  106. package/dist/control-auth-KY4Qdr2I.js +397 -0
  107. package/dist/control-ui/assets/index-DdiU_ccM.css +1 -0
  108. package/dist/control-ui/assets/index-kVUYi64u.js +7723 -0
  109. package/dist/control-ui/assets/index-kVUYi64u.js.map +1 -0
  110. package/dist/control-ui/index.html +2 -2
  111. package/dist/control-ui-assets-DO1L6M0S.js +186 -0
  112. package/dist/control-ui-assets-S_TLo6Fs.js +186 -0
  113. package/dist/conversation-label-CDH4rKMG.js +36 -0
  114. package/dist/conversation-label-CMOfgCVl.js +36 -0
  115. package/dist/cron-cli-C7h_hLHu.js +495 -0
  116. package/dist/cron-cli-DTNg0Uvl.js +499 -0
  117. package/dist/daemon-cli-BlJS9zWM.js +737 -0
  118. package/dist/daemon-cli-Cfc1yszp.js +735 -0
  119. package/dist/daemon-cli.js +174 -1167
  120. package/dist/daemon-install-BbBLuLWg.js +60 -0
  121. package/dist/daemon-install-WEBvqVOj.js +56 -0
  122. package/dist/daemon-install-helpers-BVtPC2TK.js +504 -0
  123. package/dist/daemon-install-helpers-DVr51zvE.js +504 -0
  124. package/dist/deliver-EB272zWh.js +481 -0
  125. package/dist/deliver-iGD_woru.js +481 -0
  126. package/dist/delivery-queue-BDvalA10.js +244 -0
  127. package/dist/delivery-queue-BimvYz5E.js +244 -0
  128. package/dist/devices-cli-BXCOsNFc.js +323 -0
  129. package/dist/devices-cli-CHGdYfrz.js +319 -0
  130. package/dist/diagnostics-BzzhTQzK.js +35 -0
  131. package/dist/diagnostics-DILtxtcE.js +35 -0
  132. package/dist/directory-cli-COS40yI9.js +221 -0
  133. package/dist/directory-cli-Cb5j1JTC.js +225 -0
  134. package/dist/dispatcher-BUqxh_mA.js +174 -0
  135. package/dist/dispatcher-By-KZRWZ.js +173 -0
  136. package/dist/dm-policy-shared-BCp9_z3w.js +22 -0
  137. package/dist/dm-policy-shared-DgeKqjOu.js +22 -0
  138. package/dist/dns-cli-B8yyXB2N.js +203 -0
  139. package/dist/dns-cli-DAkTk-gM.js +199 -0
  140. package/dist/dock-B0bIIDS3.js +906 -0
  141. package/dist/dock-C3PzQ6CS.js +907 -0
  142. package/dist/doctor-completion-BXGEqLhU.js +92 -0
  143. package/dist/doctor-completion-D_mNzioP.js +92 -0
  144. package/dist/doctor-config-flow-BDDsR2J1.js +978 -0
  145. package/dist/doctor-config-flow-CwFFRUic.js +979 -0
  146. package/dist/enable-C3I9dWel.js +59 -0
  147. package/dist/enable-DnwKeWnR.js +59 -0
  148. package/dist/entry.js +75 -21
  149. package/dist/env-DyyqmxSM.js +60 -0
  150. package/dist/env-vars-CD2_baIP.js +43 -0
  151. package/dist/env-vars-a7S70ba7.js +43 -0
  152. package/dist/errors-0dfGxeYQ.js +35 -0
  153. package/dist/errors-C1kDByVU.js +35 -0
  154. package/dist/exec-CAk1dxq_.js +164 -0
  155. package/dist/exec-epNpA1aU.js +164 -0
  156. package/dist/export-html/template.css +0 -36
  157. package/dist/export-html/template.js +1 -32
  158. package/dist/extensionAPI.js +1765 -1590
  159. package/dist/fetch-BMQq41sB.js +281 -0
  160. package/dist/fetch-Cky99wYB.js +281 -0
  161. package/dist/fetch-D3tw4B4n.js +67 -0
  162. package/dist/fetch-DTsU2XnC.js +67 -0
  163. package/dist/fetch-Dgm9ZHFm.js +67 -0
  164. package/dist/file-lock-DWH0TfVu.js +107 -0
  165. package/dist/file-lock-DXW9h9ek.js +107 -0
  166. package/dist/fs-safe-BjSd07M4.js +115 -0
  167. package/dist/fs-safe-aWIhCWlb.js +125 -0
  168. package/dist/gateway-cli-C4y4H61g.js +24546 -0
  169. package/dist/gateway-cli-CtFr42NV.js +24550 -0
  170. package/dist/gateway-rpc-B92CH0D3.js +28 -0
  171. package/dist/gateway-rpc-DZNlWapO.js +28 -0
  172. package/dist/gmail-setup-utils-CKyh29_R.js +422 -0
  173. package/dist/gmail-setup-utils-DquflkMR.js +423 -0
  174. package/dist/health-BYl7T-4m.js +1417 -0
  175. package/dist/health-DdviISKg.js +1414 -0
  176. package/dist/health-format-BE5TK5bs.js +28 -0
  177. package/dist/heartbeat-visibility-BO3iRpB6.js +125 -0
  178. package/dist/heartbeat-visibility-Cwp4TrTv.js +125 -0
  179. package/dist/help-format-D3JhWp1E.js +17 -0
  180. package/dist/helpers-DAEoFkbn.js +10 -0
  181. package/dist/helpers-ndPQWl6m.js +10 -0
  182. package/dist/hook-runner-global-C1thol1d.js +527 -0
  183. package/dist/hooks-cli-BKS9uZ0H.js +1221 -0
  184. package/dist/hooks-cli-FLWcCr9q.js +1217 -0
  185. package/dist/host-env-security-BGibnCbS.js +106 -0
  186. package/dist/host-env-security-axRnIi8d.js +106 -0
  187. package/dist/image-ops-CX41n0v5.js +354 -0
  188. package/dist/image-ops-DSL3eFfQ.js +354 -0
  189. package/dist/import-BSFgt760.js +604 -0
  190. package/dist/import-Da1CHJJg.js +606 -0
  191. package/dist/inbound-context-BLy-G2Eq.js +68 -0
  192. package/dist/inbound-context-a5bzQvRt.js +68 -0
  193. package/dist/index.js +137 -108
  194. package/dist/inspect-BEpFbi0c.js +286 -0
  195. package/dist/inspect-BeNNpWna.js +286 -0
  196. package/dist/installs-CH7Qq_m_.js +319 -0
  197. package/dist/installs-CcM8H2YA.js +319 -0
  198. package/dist/ipv4-DNo9AFDu.js +46 -0
  199. package/dist/ipv4-VfoVR5uR.js +46 -0
  200. package/dist/ir-BPwP8hIc.js +972 -0
  201. package/dist/json-files-BI20PLIm.js +46 -0
  202. package/dist/lifecycle-core-5Zxqwa6V.js +476 -0
  203. package/dist/lifecycle-core-C1bGeLby.js +474 -0
  204. package/dist/links-CtGBIrG8.js +15 -0
  205. package/dist/loader-BoP3JA-r.js +22411 -0
  206. package/dist/loader-DXbpue-L.js +22414 -0
  207. package/dist/logger-ASsO5Nz-.js +49 -0
  208. package/dist/logging-Cd9y2AdQ.js +20 -0
  209. package/dist/logging-DRwtiLIS.js +1 -0
  210. package/dist/logging-fywhKCmE.js +1 -0
  211. package/dist/login-B2UXzgaB.js +61 -0
  212. package/dist/login-BEFL3xY9.js +62 -0
  213. package/dist/login-qr-C7wAz2fe.js +329 -0
  214. package/dist/login-qr-DWpUP1Ud.js +325 -0
  215. package/dist/logs-cli-CAcd-pXA.js +240 -0
  216. package/dist/logs-cli-D7Bzarht.js +236 -0
  217. package/dist/markdown-tables-BBNUZp4n.js +29 -0
  218. package/dist/markdown-tables-NgPcfXoF.js +29 -0
  219. package/dist/media-4-qOIjO-.js +971 -0
  220. package/dist/media-DTwJhAbE.js +9481 -0
  221. package/dist/message-action-names-BsNTjuBE.js +2520 -0
  222. package/dist/message-action-names-ocKcq8_3.js +2520 -0
  223. package/dist/message-channel-CtcVHawF.js +91 -0
  224. package/dist/message-channel-tuc9CdEw.js +91 -0
  225. package/dist/mime-CAqaK3kp.js +146 -0
  226. package/dist/mime-ViuhRuMM.js +146 -0
  227. package/dist/net-DSkFMHJ8.js +225 -0
  228. package/dist/net-DTqfFYzt.js +225 -0
  229. package/dist/node-cli-BeXU67eQ.js +1458 -0
  230. package/dist/node-cli-i2aCtnmM.js +1462 -0
  231. package/dist/node-service-RyMlWp8N.js +67 -0
  232. package/dist/node-service-TL9b6Qfz.js +67 -0
  233. package/dist/nodes-cli-CtqnXBMD.js +1346 -0
  234. package/dist/nodes-cli-DgQU3LrG.js +1350 -0
  235. package/dist/nodes-screen-B7HJugJ0.js +250 -0
  236. package/dist/nodes-screen-nCRd71Mk.js +250 -0
  237. package/dist/note-B6142LyJ.js +92 -0
  238. package/dist/note-D-EI0czq.js +92 -0
  239. package/dist/npm-registry-spec-PPyRXSpx.js +786 -0
  240. package/dist/npm-registry-spec-uUmDWe6v.js +786 -0
  241. package/dist/npm-resolution-BC1LqCm2.js +86 -0
  242. package/dist/npm-resolution-DhlhUmRF.js +86 -0
  243. package/dist/onboard-CGpC2ecw.js +647 -0
  244. package/dist/onboard-auth-cNtb3FTP.js +211 -0
  245. package/dist/onboard-auth-gwz-0mZ6.js +207 -0
  246. package/dist/onboard-channels-CXjJYzHC.js +2548 -0
  247. package/dist/onboard-channels-vtaIxYml.js +2549 -0
  248. package/dist/onboard-config-DOmXYEvJ.js +39 -0
  249. package/dist/onboard-config-JmR21VYa.js +39 -0
  250. package/dist/onboard-helpers-8afRV_Tm.js +364 -0
  251. package/dist/onboard-helpers-DTRrJLj-.js +363 -0
  252. package/dist/onboard-jLzfwoPx.js +649 -0
  253. package/dist/onboard-remote-CFkvVAYg.js +127 -0
  254. package/dist/onboard-remote-JfBnmK70.js +127 -0
  255. package/dist/onboarding-Dt0LKvZn.js +586 -0
  256. package/dist/onboarding-gMKlA2bP.js +588 -0
  257. package/dist/onboarding.finalize-BDML6Jx7.js +403 -0
  258. package/dist/onboarding.finalize-D850VgMA.js +405 -0
  259. package/dist/onboarding.gateway-config-DolBTXWT.js +196 -0
  260. package/dist/onboarding.gateway-config-rJkIamlG.js +202 -0
  261. package/dist/outbound-CPMaDtgC.js +220 -0
  262. package/dist/outbound-CYSuCMiW.js +221 -0
  263. package/dist/outbound-attachment-Ci02LXoq.js +18 -0
  264. package/dist/outbound-attachment-CqZ7Qc_o.js +18 -0
  265. package/dist/outbound-attachment-CuqWdsdV.js +18 -0
  266. package/dist/pairing-cli-B9JKvvST.js +126 -0
  267. package/dist/pairing-cli-C4HrfIHe.js +130 -0
  268. package/dist/pairing-labels-CBmGQ31P.js +9 -0
  269. package/dist/pairing-labels-D0xwC7Xb.js +9 -0
  270. package/dist/pairing-store-BoF0g-iN.js +459 -0
  271. package/dist/pairing-store-CseXj-5p.js +460 -0
  272. package/dist/path-env-CPZbb7me.js +89 -0
  273. package/dist/path-env-GTM4HXCN.js +89 -0
  274. package/dist/path-safety-BFE0XmGC.js +14 -0
  275. package/dist/path-safety-BJ8ge6Ho.js +14 -0
  276. package/dist/paths-DHuXVC00.js +229 -0
  277. package/dist/plugin-auto-enable-B_9J1XED.js +302 -0
  278. package/dist/plugin-auto-enable-DghjlFCL.js +301 -0
  279. package/dist/plugin-registry-68h2T8vi.js +33 -0
  280. package/dist/plugin-registry-BitdVPb4.js +33 -0
  281. package/dist/plugin-sdk/agents/agent-helpers.d.ts +0 -1
  282. package/dist/plugin-sdk/agents/agent-scope.d.ts +11 -0
  283. package/dist/plugin-sdk/agents/agent-types.d.ts +1 -6
  284. package/dist/plugin-sdk/agents/agent-utils.d.ts +0 -14
  285. package/dist/plugin-sdk/agents/provider-utils.d.ts +0 -1
  286. package/dist/plugin-sdk/agents/subagent-registry.store.d.ts +0 -1
  287. package/dist/plugin-sdk/agents/subagent-spawn.d.ts +0 -1
  288. package/dist/plugin-sdk/agents/tools/sessions-helpers.d.ts +0 -1
  289. package/dist/plugin-sdk/auth/constants.d.ts +15 -0
  290. package/dist/plugin-sdk/auth/display.d.ts +7 -0
  291. package/dist/plugin-sdk/auth/doctor.d.ts +8 -0
  292. package/dist/plugin-sdk/auth/env-injection.d.ts +38 -0
  293. package/dist/plugin-sdk/auth/index.d.ts +10 -0
  294. package/dist/plugin-sdk/auth/oauth.d.ts +13 -0
  295. package/dist/plugin-sdk/auth/order.d.ts +8 -0
  296. package/dist/plugin-sdk/auth/paths.d.ts +3 -0
  297. package/dist/plugin-sdk/auth/profiles.d.ts +11 -0
  298. package/dist/plugin-sdk/auth/provider-auth.d.ts +32 -0
  299. package/dist/plugin-sdk/auth/store.d.ts +7 -0
  300. package/dist/plugin-sdk/auth/types.d.ts +45 -0
  301. package/dist/plugin-sdk/auth/usage.d.ts +80 -0
  302. package/dist/plugin-sdk/auto-reply/reply/agent-runner-execution.d.ts +0 -1
  303. package/dist/plugin-sdk/auto-reply/reply/agent-runner-utils.d.ts +3 -36
  304. package/dist/plugin-sdk/auto-reply/reply/commands-status.d.ts +1 -7
  305. package/dist/plugin-sdk/auto-reply/reply/commands-subagents/shared.d.ts +1 -1
  306. package/dist/plugin-sdk/auto-reply/reply/commands-types.d.ts +1 -13
  307. package/dist/plugin-sdk/auto-reply/reply/directive-handling.levels.d.ts +1 -10
  308. package/dist/plugin-sdk/auto-reply/reply/directive-handling.params.d.ts +1 -11
  309. package/dist/plugin-sdk/auto-reply/reply/directive-handling.parse.d.ts +1 -29
  310. package/dist/plugin-sdk/auto-reply/reply/directive-handling.persist.d.ts +0 -3
  311. package/dist/plugin-sdk/auto-reply/reply/directive-handling.shared.d.ts +0 -25
  312. package/dist/plugin-sdk/auto-reply/reply/directives.d.ts +3 -42
  313. package/dist/plugin-sdk/auto-reply/reply/get-reply-directives-apply.d.ts +0 -9
  314. package/dist/plugin-sdk/auto-reply/reply/get-reply-directives-utils.d.ts +0 -1
  315. package/dist/plugin-sdk/auto-reply/reply/get-reply-directives.d.ts +1 -20
  316. package/dist/plugin-sdk/auto-reply/reply/get-reply-inline-actions.d.ts +1 -12
  317. package/dist/plugin-sdk/auto-reply/reply/get-reply-run.d.ts +1 -15
  318. package/dist/plugin-sdk/auto-reply/reply/queue/types.d.ts +1 -17
  319. package/dist/plugin-sdk/auto-reply/reply/response-prefix-template.d.ts +4 -6
  320. package/dist/plugin-sdk/auto-reply/reply/session-run-accounting.d.ts +0 -7
  321. package/dist/plugin-sdk/auto-reply/reply/session-updates.d.ts +0 -10
  322. package/dist/plugin-sdk/auto-reply/reply.d.ts +1 -1
  323. package/dist/plugin-sdk/auto-reply/status.d.ts +3 -12
  324. package/dist/plugin-sdk/auto-reply/templating.d.ts +0 -4
  325. package/dist/plugin-sdk/auto-reply/thinking.d.ts +0 -15
  326. package/dist/plugin-sdk/auto-reply/types.d.ts +1 -2
  327. package/dist/plugin-sdk/channels/dock.d.ts +1 -2
  328. package/dist/plugin-sdk/channels/plugins/types.adapters.d.ts +0 -6
  329. package/dist/plugin-sdk/channels/plugins/types.core.d.ts +1 -0
  330. package/dist/plugin-sdk/channels/plugins/types.d.ts +1 -1
  331. package/dist/plugin-sdk/channels/plugins/types.plugin.d.ts +1 -2
  332. package/dist/plugin-sdk/channels/voice-credentials.d.ts +26 -0
  333. package/dist/plugin-sdk/commands/agent/session.d.ts +1 -2
  334. package/dist/plugin-sdk/commands/onboard-helpers.d.ts +0 -1
  335. package/dist/plugin-sdk/commands/onboard-types.d.ts +2 -1
  336. package/dist/plugin-sdk/config/defaults.d.ts +0 -1
  337. package/dist/plugin-sdk/config/legacy.migrations.d.ts +2 -1
  338. package/dist/plugin-sdk/config/legacy.shared.d.ts +0 -9
  339. package/dist/plugin-sdk/config/sessions/types.d.ts +0 -17
  340. package/dist/plugin-sdk/config/types.agent-defaults.d.ts +28 -120
  341. package/dist/plugin-sdk/config/types.agents.d.ts +8 -0
  342. package/dist/plugin-sdk/config/types.base.d.ts +0 -1
  343. package/dist/plugin-sdk/config/types.messages.d.ts +1 -6
  344. package/dist/plugin-sdk/config/types.remoteclaw.d.ts +2 -2
  345. package/dist/plugin-sdk/config/types.tools.d.ts +1 -74
  346. package/dist/plugin-sdk/config/types.tts.d.ts +2 -1
  347. package/dist/plugin-sdk/config/zod-schema.agent-defaults.d.ts +9 -70
  348. package/dist/plugin-sdk/config/zod-schema.agent-runtime.d.ts +12 -210
  349. package/dist/plugin-sdk/config/zod-schema.agents.d.ts +14 -86
  350. package/dist/plugin-sdk/config/zod-schema.core.d.ts +6 -234
  351. package/dist/plugin-sdk/config/zod-schema.d.ts +111 -378
  352. package/dist/plugin-sdk/config/zod-schema.providers-core.d.ts +148 -160
  353. package/dist/plugin-sdk/config/zod-schema.providers-whatsapp.d.ts +12 -12
  354. package/dist/plugin-sdk/config/zod-schema.providers.d.ts +88 -96
  355. package/dist/plugin-sdk/config/zod-schema.session.d.ts +4 -10
  356. package/dist/plugin-sdk/daemon/constants.d.ts +2 -2
  357. package/dist/plugin-sdk/gateway/protocol/index.d.ts +10 -17
  358. package/dist/plugin-sdk/gateway/protocol/schema/sessions.d.ts +0 -7
  359. package/dist/plugin-sdk/gateway/server/ws-types.d.ts +2 -0
  360. package/dist/plugin-sdk/gateway/session-utils.types.d.ts +0 -3
  361. package/dist/plugin-sdk/index.js +722 -1283
  362. package/dist/plugin-sdk/infra/agent-events.d.ts +1 -1
  363. package/dist/plugin-sdk/infra/provider-usage.auth.d.ts +0 -1
  364. package/dist/plugin-sdk/infra/provider-usage.load.d.ts +0 -1
  365. package/dist/plugin-sdk/line/config-schema.d.ts +4 -4
  366. package/dist/plugin-sdk/logging/levels.d.ts +1 -1
  367. package/dist/plugin-sdk/middleware/auth-key-retry.d.ts +31 -0
  368. package/dist/plugin-sdk/middleware/channel-bridge.d.ts +4 -0
  369. package/dist/plugin-sdk/middleware/cli-runtime-base.d.ts +6 -0
  370. package/dist/plugin-sdk/middleware/error-classifier.d.ts +5 -0
  371. package/dist/plugin-sdk/middleware/media-capability.d.ts +21 -0
  372. package/dist/plugin-sdk/middleware/media-resolver.d.ts +12 -0
  373. package/dist/plugin-sdk/middleware/runtime-factory.d.ts +42 -0
  374. package/dist/plugin-sdk/middleware/runtimes/claude.d.ts +10 -0
  375. package/dist/plugin-sdk/middleware/runtimes/codex.d.ts +5 -0
  376. package/dist/plugin-sdk/middleware/runtimes/gemini.d.ts +11 -0
  377. package/dist/plugin-sdk/middleware/runtimes/opencode.d.ts +5 -0
  378. package/dist/plugin-sdk/middleware/types.d.ts +41 -1
  379. package/dist/plugin-sdk/plugin-sdk/index.d.ts +5 -1
  380. package/dist/plugin-sdk/plugins/manifest-registry.d.ts +2 -0
  381. package/dist/plugin-sdk/plugins/manifest.d.ts +4 -4
  382. package/dist/plugin-sdk/plugins/registry.d.ts +18 -0
  383. package/dist/plugin-sdk/plugins/types.d.ts +5 -1
  384. package/dist/plugin-sdk/stt/defaults.d.ts +2 -0
  385. package/dist/plugin-sdk/stt/preflight.d.ts +14 -0
  386. package/dist/plugin-sdk/stt/providers/deepgram/index.d.ts +2 -0
  387. package/dist/plugin-sdk/stt/providers/google/index.d.ts +2 -0
  388. package/dist/plugin-sdk/stt/providers/groq/index.d.ts +2 -0
  389. package/dist/plugin-sdk/stt/providers/index.d.ts +4 -0
  390. package/dist/plugin-sdk/stt/providers/mistral/index.d.ts +2 -0
  391. package/dist/plugin-sdk/stt/providers/openai/index.d.ts +2 -0
  392. package/dist/plugin-sdk/stt/stt.d.ts +27 -0
  393. package/dist/plugin-sdk/stt/types.d.ts +22 -0
  394. package/dist/plugin-sdk/terminal/palette.d.ts +2 -2
  395. package/dist/plugin-sdk/tts/providers/edge.d.ts +2 -0
  396. package/dist/plugin-sdk/tts/providers/elevenlabs.d.ts +2 -0
  397. package/dist/plugin-sdk/tts/providers/index.d.ts +4 -0
  398. package/dist/plugin-sdk/tts/providers/openai.d.ts +2 -0
  399. package/dist/plugin-sdk/tts/tts.d.ts +13 -5
  400. package/dist/plugin-sdk/tts/types.d.ts +21 -0
  401. package/dist/plugins-BviLFPLV.js +255 -0
  402. package/dist/plugins-CaudBUbl.js +254 -0
  403. package/dist/plugins-cli-CsLhphNr.js +803 -0
  404. package/dist/plugins-cli-CujSP9NS.js +807 -0
  405. package/dist/ports-BtuzUQHl.js +370 -0
  406. package/dist/ports-CMcHia07.js +96 -0
  407. package/dist/ports-DALdfBQy.js +96 -0
  408. package/dist/ports-gRBeuUtp.js +316 -0
  409. package/dist/preflight-Bq8rimP-.js +667 -0
  410. package/dist/preflight-DyYbEp9X.js +667 -0
  411. package/dist/program-D64vUv0b.js +250 -0
  412. package/dist/program-context-CTFkimUr.js +474 -0
  413. package/dist/progress-BcwxtM9Q.js +124 -0
  414. package/dist/prompt-DtWGd43j.js +21 -0
  415. package/dist/prompt-select-styled-GW2PexAK.js +1672 -0
  416. package/dist/prompt-select-styled-JOuWGHX7.js +1669 -0
  417. package/dist/prompt-style-BpUMhEHC.js +9 -0
  418. package/dist/provider-auth-B7QgxlKt.js +187 -0
  419. package/dist/provider-auth-j-EQvvIk.js +187 -0
  420. package/dist/provider-dispatcher-Bx6CaIoV.js +660 -0
  421. package/dist/provider-dispatcher-DhkvjhO5.js +659 -0
  422. package/dist/push-apns--nEiZmEN.js +711 -0
  423. package/dist/push-apns-BtS6B6lb.js +713 -0
  424. package/dist/pw-ai-BpCsXF-x.js +1908 -0
  425. package/dist/pw-ai-ud_Kbn5S.js +1911 -0
  426. package/dist/qr-cli-BCeVLGfz.js +353 -0
  427. package/dist/qr-cli-Crsqtw01.js +349 -0
  428. package/dist/redact-Ci96Gj0O.js +191 -0
  429. package/dist/redact-snapshot-B9nof-Pb.js +1952 -0
  430. package/dist/redact-snapshot-BKiS91Mj.js +1952 -0
  431. package/dist/register.agent-CcvOeVnL.js +292 -0
  432. package/dist/register.agent-azH_tdVX.js +1014 -0
  433. package/dist/register.configure-DAaZLjHs.js +130 -0
  434. package/dist/register.configure-lUl8O79m.js +135 -0
  435. package/dist/register.import-B83Dn36B.js +29 -0
  436. package/dist/register.import-wIYU2cVW.js +31 -0
  437. package/dist/register.maintenance-Bo-ooQDU.js +501 -0
  438. package/dist/register.maintenance-BwZ4OkK2.js +503 -0
  439. package/dist/register.message-BQhRoEQQ.js +687 -0
  440. package/dist/register.message-CvZKWeGb.js +691 -0
  441. package/dist/register.onboard---3EPh-O.js +98 -0
  442. package/dist/register.onboard-rsHSJUvQ.js +94 -0
  443. package/dist/register.setup-B0gc_lne.js +118 -0
  444. package/dist/register.setup-MWpb7jxL.js +114 -0
  445. package/dist/register.status-health-sessions-BZJ0wTSa.js +429 -0
  446. package/dist/register.status-health-sessions-CyrUwwtB.js +667 -0
  447. package/dist/register.subclis-i2d2ugaJ.js +267 -0
  448. package/dist/replies-BIx-MbQ7.js +136 -0
  449. package/dist/replies-DVU655H4.js +136 -0
  450. package/dist/reply-CL5VMSKN.js +12372 -0
  451. package/dist/reply-XKyfU3rS.js +12375 -0
  452. package/dist/reply-directives-DQfJ001O.js +182 -0
  453. package/dist/reply-directives-DfUITt7C.js +182 -0
  454. package/dist/reply-payloads-ZHo6kfTS.js +527 -0
  455. package/dist/reply-prefix-BSf3PC0x.js +37 -0
  456. package/dist/reply-prefix-DBTlMHLK.js +37 -0
  457. package/dist/resolve-route-B-_IgETc.js +249 -0
  458. package/dist/resolve-route-C8ZsgWDQ.js +249 -0
  459. package/dist/response-prefix-template-3LeqJx2X.js +134 -0
  460. package/dist/response-prefix-template-DBrUVx5V.js +134 -0
  461. package/dist/retry-CDrH81GP.js +77 -0
  462. package/dist/retry-Dar_7pCv.js +77 -0
  463. package/dist/run-main-rOudcbbs.js +308 -0
  464. package/dist/runtime-guard-CK80eucm.js +60 -0
  465. package/dist/runtime-status-CR9445g5.js +12 -0
  466. package/dist/runtime-status-hFVEC3wO.js +12 -0
  467. package/dist/secure-random-CLWSvf8A.js +44 -0
  468. package/dist/security-cli-B8lXw9ke.js +488 -0
  469. package/dist/security-cli-CRkS3VAf.js +483 -0
  470. package/dist/send-6g8QKfWj.js +374 -0
  471. package/dist/send-B5Hz1PIn.js +29 -0
  472. package/dist/send-B8eIlA1u.js +349 -0
  473. package/dist/send-BFZPQE4j.js +492 -0
  474. package/dist/send-BpTDvE0D.js +1779 -0
  475. package/dist/send-BxOrO1Wv.js +1776 -0
  476. package/dist/send-C6gPJu-Z.js +11 -0
  477. package/dist/send-C7MoKtkN.js +426 -0
  478. package/dist/send-CXzq2LI6.js +2245 -0
  479. package/dist/send-CYOZoObr.js +547 -0
  480. package/dist/send-CfQyIvcC.js +332 -0
  481. package/dist/send-DUtuuwhw.js +492 -0
  482. package/dist/send-DbafVwxp.js +2245 -0
  483. package/dist/send-DeZg8K7y.js +349 -0
  484. package/dist/send-DwkjxJlv.js +547 -0
  485. package/dist/send-iX9xbxlU.js +1178 -0
  486. package/dist/server-BKfCzEzd.js +206 -0
  487. package/dist/server-fmO4eo7K.js +202 -0
  488. package/dist/server-lifecycle-CgPpP10P.js +2437 -0
  489. package/dist/server-lifecycle-Cn8yY5MW.js +2437 -0
  490. package/dist/server-node-events-C-ZzSBYh.js +391 -0
  491. package/dist/server-node-events-DYlyfDHM.js +395 -0
  492. package/dist/service-C2j81L86.js +670 -0
  493. package/dist/service-C8a0SXHD.js +670 -0
  494. package/dist/session-AulYhqOb.js +170 -0
  495. package/dist/session-C6VKWvx6.js +170 -0
  496. package/dist/session-cost-usage-0Vs4hgMe.js +627 -0
  497. package/dist/session-cost-usage-C-DsaOfN.js +627 -0
  498. package/dist/session-dirs-CO1f2ArM.js +318 -0
  499. package/dist/session-dirs-DoboH7Oy.js +318 -0
  500. package/dist/session-utils-CRK8ToKG.js +621 -0
  501. package/dist/session-utils-DWlkmCX8.js +621 -0
  502. package/dist/sessions-DtqrmUJS.js +2553 -0
  503. package/dist/sessions-gT-4fcX-.js +245 -0
  504. package/dist/shell-env-DBS5su07.js +163 -0
  505. package/dist/shell-env-c3j5zcU9.js +163 -0
  506. package/dist/ssrf-8wNqPNzN.js +183 -0
  507. package/dist/ssrf-CJIdPXuS.js +183 -0
  508. package/dist/status-BI_-xpDt.js +1947 -0
  509. package/dist/status-PZVwjKjl.js +1943 -0
  510. package/dist/status.update-BmuDZ7E7.js +449 -0
  511. package/dist/status.update-Mf6HSRvU.js +449 -0
  512. package/dist/store-B7PGEdFf.js +2555 -0
  513. package/dist/store-CzhBjUCN.js +64 -0
  514. package/dist/store-YkSxKAey.js +53 -0
  515. package/dist/store-ZNeFv2Q7.js +64 -0
  516. package/dist/subagent-registry-R1DiAM4R.js +4839 -0
  517. package/dist/subagent-registry-xLRXC8Bg.js +4841 -0
  518. package/dist/subsystem-BAW_f3DI.js +1195 -0
  519. package/dist/subsystem-DGSHVL8I.js +1081 -0
  520. package/dist/system-cli-9SvRrT9D.js +77 -0
  521. package/dist/system-cli-yCa5Q1YM.js +73 -0
  522. package/dist/systemd-40Rij3QR.js +547 -0
  523. package/dist/systemd-5C97CSzd.js +547 -0
  524. package/dist/systemd-hints-3iQteJw-.js +278 -0
  525. package/dist/systemd-hints-CyQqHq1i.js +278 -0
  526. package/dist/systemd-linger-B2rPbnAi.js +75 -0
  527. package/dist/systemd-linger-DDvkfxH-.js +75 -0
  528. package/dist/table-DFx25vNb.js +279 -0
  529. package/dist/tables-C5fI0PmT.js +55 -0
  530. package/dist/tables-Cm9qvQ9D.js +55 -0
  531. package/dist/tables-fRe01eP1.js +55 -0
  532. package/dist/tailnet-Da-_9e8E.js +40 -0
  533. package/dist/tailnet-xt92Yaop.js +40 -0
  534. package/dist/tailscale-CnV0JWca.js +230 -0
  535. package/dist/tailscale-VkEC8dzj.js +230 -0
  536. package/dist/targets-C99szk_e.js +114 -0
  537. package/dist/targets-CPaTjbpp.js +2607 -0
  538. package/dist/targets-D-p4rJVS.js +650 -0
  539. package/dist/targets-D2OQt8-7.js +650 -0
  540. package/dist/targets-D94MtTiZ.js +2606 -0
  541. package/dist/targets-RajrXTl7.js +220 -0
  542. package/dist/targets-_UWmnyI9.js +53 -0
  543. package/dist/targets-tDrl_ioQ.js +46 -0
  544. package/dist/thinking-4nOZPunr.js +60 -0
  545. package/dist/thinking-ZfH2V9Os.js +60 -0
  546. package/dist/tokens-TtJJxzRr.js +21 -0
  547. package/dist/tool-display-Bxs_1jIn.js +785 -0
  548. package/dist/tool-display-D9p_Ttkq.js +785 -0
  549. package/dist/tool-images-9Ron321Q.js +263 -0
  550. package/dist/tool-images-BWhy6WRN.js +263 -0
  551. package/dist/trash-B5xyvBDf.js +125 -0
  552. package/dist/trash-BpB96kHe.js +125 -0
  553. package/dist/tui-Ba0uZDrg.js +3237 -0
  554. package/dist/tui-Biz0HqDj.js +3237 -0
  555. package/dist/tui-cli-C-UV6o2v.js +63 -0
  556. package/dist/tui-cli-Ds_bLT-h.js +67 -0
  557. package/dist/types.tools-BBb2rl3g.js +23 -0
  558. package/dist/types.tools-BDJw1yFx.js +23 -0
  559. package/dist/update-Barj5dsg.js +349 -0
  560. package/dist/update-D839Q8su.js +349 -0
  561. package/dist/update-cli-C0LnrpIt.js +1148 -0
  562. package/dist/update-cli-CUypa-T-.js +1150 -0
  563. package/dist/usage-BI9kergH.js +5465 -0
  564. package/dist/utils-DPoNpP7D.js +631 -0
  565. package/dist/version-3QUZW8EP.js +52 -0
  566. package/dist/version-CVMnqdzu.js +52 -0
  567. package/dist/voice-credentials-64XAMSJm.js +46 -0
  568. package/dist/voice-credentials-v-CQkTpD.js +46 -0
  569. package/dist/web-63IbbidQ.js +3051 -0
  570. package/dist/web-D9N764Da.js +80 -0
  571. package/dist/web-DUvNYLzr.js +75 -0
  572. package/dist/webhooks-cli-owhVNNkz.js +334 -0
  573. package/dist/webhooks-cli-zlvka6QD.js +330 -0
  574. package/dist/whatsapp-actions-8DejyRG5.js +126 -0
  575. package/dist/whatsapp-actions-DCzp5LKe.js +131 -0
  576. package/dist/widearea-dns-CQqZIeu8.js +127 -0
  577. package/dist/workspace-CB7pVojf.js +441 -0
  578. package/dist/workspace-DWEyzM0F.js +439 -0
  579. package/dist/zod-schema-CvFqwpNE.js +2719 -0
  580. package/dist/zod-schema-Y5SQgJLm.js +2719 -0
  581. package/extensions/matrix/src/matrix/monitor/replies.ts +0 -24
  582. package/extensions/mattermost/src/mattermost/monitor-helpers.ts +0 -1
  583. package/extensions/voice-call/index.ts +18 -1
  584. package/package.json +3 -4
  585. package/dist/accounts-7fm_KzPm.js +0 -32
  586. package/dist/accounts-BFy_Z3od.js +0 -272
  587. package/dist/accounts-BTXSfPWi.js +0 -270
  588. package/dist/accounts-BxGS70Do.js +0 -36
  589. package/dist/accounts-CNY1TGj1.js +0 -47
  590. package/dist/accounts-DqRQ75w3.js +0 -36
  591. package/dist/accounts-iODF3SK2.js +0 -47
  592. package/dist/ack-reactions-C1hk85VE.js +0 -446
  593. package/dist/ack-reactions-DRC2CiDQ.js +0 -446
  594. package/dist/acp-cli-DD-PD4NM.js +0 -1326
  595. package/dist/acp-cli-DIyRCOum.js +0 -1320
  596. package/dist/active-listener-VzhWW8W6.js +0 -37
  597. package/dist/active-listener-z0qVEcom.js +0 -37
  598. package/dist/agent-D2HeDFFR.js +0 -731
  599. package/dist/agent-Da_eZ5BP.js +0 -732
  600. package/dist/agent-helpers-B6VfZ9_u.js +0 -606
  601. package/dist/agent-helpers-CTx5KKJu.js +0 -606
  602. package/dist/agent-scope-BqPmD-Ax.js +0 -114
  603. package/dist/agent-scope-DgQzamQB.js +0 -116
  604. package/dist/agents-TB3QpHoo.js +0 -788
  605. package/dist/agents.config-BsAQTYe1.js +0 -116
  606. package/dist/agents.config-C9fyYfAh.js +0 -116
  607. package/dist/ansi-D04X81yq.js +0 -14
  608. package/dist/audio-DPOuhNq7.js +0 -43
  609. package/dist/audio-VBcVDa08.js +0 -43
  610. package/dist/audio-preflight-CK3EA3Dv.js +0 -69
  611. package/dist/audio-preflight-tdXtrutj.js +0 -64
  612. package/dist/audit-CJipUWDi.js +0 -3138
  613. package/dist/audit-COWzB9Y1.js +0 -3138
  614. package/dist/auth-CAczFgAO.js +0 -448
  615. package/dist/auth-Deh9i9Eg.js +0 -448
  616. package/dist/auth-profiles-BquJGKLC.js +0 -279
  617. package/dist/auth-profiles-D8vKiBPq.js +0 -281
  618. package/dist/banner-CUWBOR42.js +0 -294
  619. package/dist/binaries-DXW6oATV.js +0 -13
  620. package/dist/bindings-8YtSWb91.js +0 -69
  621. package/dist/bindings-l1R5LQQH.js +0 -69
  622. package/dist/bonjour-discovery-DdAk1VyO.js +0 -378
  623. package/dist/bonjour-discovery-DuhiIZZx.js +0 -378
  624. package/dist/browser-cli-5Q9lhGdd.js +0 -1687
  625. package/dist/browser-cli-D2qMeSx1.js +0 -1692
  626. package/dist/call-CZHVeMf1.js +0 -2828
  627. package/dist/call-CoMjY7ah.js +0 -2829
  628. package/dist/catalog-CYiAleBT.js +0 -185
  629. package/dist/catalog-pjPqB2hC.js +0 -185
  630. package/dist/channel-account-context-CvIDAtHS.js +0 -550
  631. package/dist/channel-account-context-q-o0pG1A.js +0 -550
  632. package/dist/channel-activity-BaCNOZpP.js +0 -94
  633. package/dist/channel-activity-Cd1JhIUj.js +0 -292
  634. package/dist/channel-activity-DTKGf3j5.js +0 -94
  635. package/dist/channel-options-8SjIcDDI.js +0 -33
  636. package/dist/channel-options-BtQGtMF4.js +0 -32
  637. package/dist/channel-selection-C4DzrynU.js +0 -51
  638. package/dist/channel-selection-DdfhwFuY.js +0 -51
  639. package/dist/channel-web-BKJSXnwf.js +0 -2136
  640. package/dist/channel-web-BUzvNE_A.js +0 -2134
  641. package/dist/channels-cli-CCXY796Z.js +0 -1421
  642. package/dist/channels-cli-DTfx1zFC.js +0 -1426
  643. package/dist/channels-status-issues-DnmuqPsi.js +0 -18
  644. package/dist/channels-status-issues-p1pCvTh8.js +0 -18
  645. package/dist/chat-envelope-DEZ-5RY8.js +0 -248
  646. package/dist/chat-envelope-el7Uo-Fe.js +0 -248
  647. package/dist/chrome-Dd4dv0Vh.js +0 -1732
  648. package/dist/chrome-DdNEInwI.js +0 -1733
  649. package/dist/chunk-CSQfUhgF.js +0 -341
  650. package/dist/chunk-D0Y_w4oX.js +0 -341
  651. package/dist/clack-prompter-B7tOxhJd.js +0 -122
  652. package/dist/clack-prompter-CCFnKP_1.js +0 -121
  653. package/dist/cleanup-utils-CqAVZz2b.js +0 -94
  654. package/dist/cli-BRwDPW0r.js +0 -125
  655. package/dist/cli-CV86F7iv.js +0 -130
  656. package/dist/clipboard-D7_SKHPK.js +0 -31
  657. package/dist/clipboard-Dzkx6Q2K.js +0 -31
  658. package/dist/command-format-CVfo8I5f.js +0 -18
  659. package/dist/command-format-DgXcqxBt.js +0 -32
  660. package/dist/command-registry-BvLC28b4.js +0 -215
  661. package/dist/commands-B49Lu-pa.js +0 -41
  662. package/dist/commands-DI1BCqnj.js +0 -41
  663. package/dist/commands-registry-Cr6SIR3n.js +0 -892
  664. package/dist/commands-registry-agiTEGDz.js +0 -893
  665. package/dist/common-CMI-qsF8.js +0 -156
  666. package/dist/common-DSVmydhm.js +0 -156
  667. package/dist/completion-cli-C7O4JU8t.js +0 -452
  668. package/dist/completion-cli-CQNXtEJ7.js +0 -452
  669. package/dist/config-ChYRSJQt.js +0 -6953
  670. package/dist/config-CwtWvygh.js +0 -6951
  671. package/dist/config-cli-Df5nJcfO.js +0 -241
  672. package/dist/config-cli-Dqe5O1pl.js +0 -246
  673. package/dist/config-guard-C6hyuH-z.js +0 -75
  674. package/dist/config-guard-kNMQS_tm.js +0 -97
  675. package/dist/config-validation-BZBaBH69.js +0 -18
  676. package/dist/config-validation-DkrbzCyL.js +0 -18
  677. package/dist/configure-CoJmCHqT.js +0 -891
  678. package/dist/configure-DJbojDRf.js +0 -889
  679. package/dist/constants-BmRFoHl0.js +0 -67
  680. package/dist/constants-C9WPAluB.js +0 -67
  681. package/dist/control-auth-7k6Cb2zH.js +0 -397
  682. package/dist/control-auth-DBxfkJ3g.js +0 -397
  683. package/dist/control-ui/assets/index-B4ZM1lW1.js +0 -7738
  684. package/dist/control-ui/assets/index-B4ZM1lW1.js.map +0 -1
  685. package/dist/control-ui/assets/index-PED72sKF.css +0 -1
  686. package/dist/control-ui-assets-Cx_mw4D0.js +0 -186
  687. package/dist/control-ui-assets-W1AUuGrO.js +0 -186
  688. package/dist/conversation-label-C4SDz4sT.js +0 -36
  689. package/dist/conversation-label-D1frnvYe.js +0 -36
  690. package/dist/cron-cli-BJXQKtR3.js +0 -495
  691. package/dist/cron-cli-CTIj0WPW.js +0 -490
  692. package/dist/daemon-cli-CZbHvkRG.js +0 -1197
  693. package/dist/daemon-cli-Cf_YKWvV.js +0 -1199
  694. package/dist/daemon-install-CcohRvKV.js +0 -55
  695. package/dist/daemon-install-DDshfT0J.js +0 -60
  696. package/dist/daemon-install-helpers-CFGAfRlj.js +0 -462
  697. package/dist/daemon-install-helpers-DIUzSFG1.js +0 -462
  698. package/dist/defaults-B5KStIBg.js +0 -7
  699. package/dist/defaults-xUAL2Z-F.js +0 -7
  700. package/dist/deliver-BDf2lIEK.js +0 -481
  701. package/dist/deliver-DvmkSwLt.js +0 -481
  702. package/dist/delivery-queue-Cfa9Wmxp.js +0 -244
  703. package/dist/delivery-queue-CxVRi4tw.js +0 -244
  704. package/dist/devices-cli-CRsW5WOw.js +0 -316
  705. package/dist/devices-cli-Crzrk5uf.js +0 -321
  706. package/dist/diagnostics-99iCgBUh.js +0 -46
  707. package/dist/diagnostics-VC0cz7kX.js +0 -46
  708. package/dist/directory-cli-BnoQqeOX.js +0 -222
  709. package/dist/directory-cli-DdBAX3AV.js +0 -217
  710. package/dist/dm-policy-shared-DNqPbnip.js +0 -22
  711. package/dist/dm-policy-shared-vCb_hnqo.js +0 -22
  712. package/dist/dns-cli-D410XQr9.js +0 -197
  713. package/dist/dns-cli-Fgg96Xkg.js +0 -202
  714. package/dist/dock-DXSgTbDw.js +0 -928
  715. package/dist/dock-FtQwUHXE.js +0 -929
  716. package/dist/doctor-completion-BWmtCiFR.js +0 -92
  717. package/dist/doctor-completion-DTM_wDxy.js +0 -92
  718. package/dist/doctor-config-flow-Ccna5fPs.js +0 -1934
  719. package/dist/doctor-config-flow-DqzrK_jh.js +0 -1933
  720. package/dist/enable-DcJnkzfz.js +0 -59
  721. package/dist/enable-ibNq4UWy.js +0 -59
  722. package/dist/env-DeF64iu0.js +0 -60
  723. package/dist/env-vars-7aZqKPhk.js +0 -93
  724. package/dist/env-vars-CLGbxdpL.js +0 -93
  725. package/dist/errors-8F-77i6m.js +0 -35
  726. package/dist/errors-DZ199hOo.js +0 -35
  727. package/dist/exec-DbKuYyM1.js +0 -164
  728. package/dist/exec-DkFE7lqU.js +0 -164
  729. package/dist/fetch-C6XKGA11.js +0 -67
  730. package/dist/fetch-CEDsOiql.js +0 -67
  731. package/dist/fetch-ePscvwi1.js +0 -67
  732. package/dist/file-lock-CIvloidc.js +0 -107
  733. package/dist/file-lock-CzBL_VIx.js +0 -107
  734. package/dist/fs-safe-DSwT85uK.js +0 -88
  735. package/dist/fs-safe-DkBhNAc3.js +0 -98
  736. package/dist/gateway-cli-BJooqlkO.js +0 -23747
  737. package/dist/gateway-cli-C2wPjxY4.js +0 -23742
  738. package/dist/gateway-rpc-BcT4FqJQ.js +0 -28
  739. package/dist/gateway-rpc-DhKAJ5EW.js +0 -28
  740. package/dist/gmail-setup-utils-Cnx8A5pW.js +0 -422
  741. package/dist/gmail-setup-utils-nkabbKOE.js +0 -423
  742. package/dist/health-BZX-PyP0.js +0 -1420
  743. package/dist/health-BgD0koJx.js +0 -1423
  744. package/dist/health-format-BG95OE6N.js +0 -28
  745. package/dist/heartbeat-visibility-DeW9EIeS.js +0 -125
  746. package/dist/heartbeat-visibility-DvogUlnZ.js +0 -125
  747. package/dist/help-format-DAxf0l_h.js +0 -17
  748. package/dist/helpers-R7bU5IBz.js +0 -10
  749. package/dist/helpers-kkeXif0Q.js +0 -10
  750. package/dist/hook-runner-global-cyaKukZP.js +0 -527
  751. package/dist/hooks-cli-DTygpzqS.js +0 -1217
  752. package/dist/hooks-cli-Dg853OdZ.js +0 -1222
  753. package/dist/host-env-security-Bms2_EMV.js +0 -92
  754. package/dist/host-env-security-szwfmhC4.js +0 -92
  755. package/dist/image-ops-Bi6JPSkD.js +0 -354
  756. package/dist/image-ops-DWytvdh_.js +0 -354
  757. package/dist/import-D8BBZQgl.js +0 -170
  758. package/dist/import-DQ6NI4Fz.js +0 -168
  759. package/dist/inbound-context-CPkkQW0i.js +0 -68
  760. package/dist/inbound-context-DS_kpIYI.js +0 -68
  761. package/dist/inbound-path-policy-Bg4gZBx-.js +0 -250
  762. package/dist/inbound-path-policy-sdr5Ji0k.js +0 -250
  763. package/dist/inspect-Dt8hogS3.js +0 -559
  764. package/dist/inspect-vYIL1oA0.js +0 -559
  765. package/dist/installs-ClX3qQmh.js +0 -325
  766. package/dist/installs-CxjOiLUM.js +0 -325
  767. package/dist/ipv4--2WXMVtE.js +0 -46
  768. package/dist/ipv4-CDQpx1A7.js +0 -46
  769. package/dist/ir-BvKdMuSP.js +0 -940
  770. package/dist/json-files-DzpTak5i.js +0 -46
  771. package/dist/links-C3soDNDH.js +0 -15
  772. package/dist/loader-BWZ_iRxI.js +0 -22624
  773. package/dist/loader-ClFP7wvS.js +0 -22621
  774. package/dist/local-roots-B6rSCu4U.js +0 -314
  775. package/dist/local-roots-v2HlOaG5.js +0 -313
  776. package/dist/logger-Bw3cFE5t.js +0 -49
  777. package/dist/logging-C-nxX2fn.js +0 -20
  778. package/dist/login-Cmpeb59f.js +0 -62
  779. package/dist/login-D1CV2eNF.js +0 -61
  780. package/dist/login-qr-B3tpFLRV.js +0 -327
  781. package/dist/login-qr-CSQzrtFX.js +0 -322
  782. package/dist/logs-cli-BSiUZwb2.js +0 -238
  783. package/dist/logs-cli-DDtoJ1Fr.js +0 -233
  784. package/dist/markdown-tables-PJUMrC4T.js +0 -29
  785. package/dist/markdown-tables-dDWBbtqd.js +0 -29
  786. package/dist/media-Dqv7Q0aS.js +0 -10492
  787. package/dist/media-DtN0R9A0.js +0 -940
  788. package/dist/message-action-names-Bs50Ia1g.js +0 -2521
  789. package/dist/message-action-names-Btd7cMvx.js +0 -2521
  790. package/dist/message-channel-DzJqHVZD.js +0 -91
  791. package/dist/message-channel-uWMAiywE.js +0 -91
  792. package/dist/mime-BS3jhcZE.js +0 -149
  793. package/dist/mime-Cxh_64P6.js +0 -149
  794. package/dist/net-Cg8AQeke.js +0 -225
  795. package/dist/net-D6D0wgcF.js +0 -225
  796. package/dist/node-cli-Q2-n3Fgv.js +0 -24
  797. package/dist/node-cli-Uf6lAntf.js +0 -24
  798. package/dist/nodes-cli-DVLvMgBV.js +0 -1343
  799. package/dist/nodes-cli-Dxf7vAKk.js +0 -1348
  800. package/dist/nodes-screen-BR9sYoPa.js +0 -250
  801. package/dist/nodes-screen-Cw7Hv7M2.js +0 -250
  802. package/dist/note-Dlv4NmlQ.js +0 -92
  803. package/dist/note-kvWV4xtw.js +0 -92
  804. package/dist/npm-registry-spec-0qiKawvv.js +0 -786
  805. package/dist/npm-registry-spec-COvUzy5J.js +0 -786
  806. package/dist/npm-resolution-DJnq5QBs.js +0 -86
  807. package/dist/npm-resolution-DVl2spoD.js +0 -86
  808. package/dist/onboard-BcQWYGY3.js +0 -405
  809. package/dist/onboard-RQ_FAMyg.js +0 -407
  810. package/dist/onboard-channels-CHh_BuxJ.js +0 -2547
  811. package/dist/onboard-channels-DXD-CK_M.js +0 -2548
  812. package/dist/onboard-config-BCTthQ7J.js +0 -24
  813. package/dist/onboard-config-y-2cgT0V.js +0 -24
  814. package/dist/onboard-helpers-BRMP8mup.js +0 -362
  815. package/dist/onboard-helpers-CUGbuZwH.js +0 -363
  816. package/dist/onboard-remote-D-qWujdL.js +0 -127
  817. package/dist/onboard-remote-o_OW-uzc.js +0 -127
  818. package/dist/onboarding-Bf9kVcef.js +0 -541
  819. package/dist/onboarding-CVlOLLp1.js +0 -543
  820. package/dist/onboarding.finalize-CQSt37fw.js +0 -398
  821. package/dist/onboarding.finalize-DggVL7Ay.js +0 -401
  822. package/dist/onboarding.gateway-config-BLca3Td2.js +0 -198
  823. package/dist/onboarding.gateway-config-C1mcOkRh.js +0 -191
  824. package/dist/outbound-DXXccLDS.js +0 -220
  825. package/dist/outbound-ZnVvUReT.js +0 -221
  826. package/dist/outbound-attachment-CfRb07J7.js +0 -18
  827. package/dist/outbound-attachment-DGXTtERK.js +0 -18
  828. package/dist/outbound-attachment-_jj74QBM.js +0 -18
  829. package/dist/pairing-cli-Bgm4fRA3.js +0 -127
  830. package/dist/pairing-cli-J0uGb1nU.js +0 -122
  831. package/dist/pairing-labels-CVm65Jkh.js +0 -9
  832. package/dist/pairing-labels-DD1mcvQG.js +0 -9
  833. package/dist/pairing-store-5qapT5-t.js +0 -460
  834. package/dist/pairing-store-MLceBEeL.js +0 -459
  835. package/dist/path-env-DR5vn3QL.js +0 -89
  836. package/dist/path-env-qRJbjJzj.js +0 -89
  837. package/dist/path-guards-CIx4hURU.js +0 -31
  838. package/dist/path-guards-CrQOUlsq.js +0 -31
  839. package/dist/path-safety-DkT9RmTG.js +0 -14
  840. package/dist/path-safety-juI2XbO1.js +0 -14
  841. package/dist/paths-BTaH3rLn.js +0 -232
  842. package/dist/plugin-auto-enable-BUSF117F.js +0 -301
  843. package/dist/plugin-auto-enable-CoDnqA0S.js +0 -302
  844. package/dist/plugin-registry-D2B6nbn1.js +0 -33
  845. package/dist/plugin-registry-fLaMC0ik.js +0 -33
  846. package/dist/plugin-sdk/agents/agent-helpers/thinking.d.ts +0 -5
  847. package/dist/plugin-sdk/agents/agent-paths.d.ts +0 -1
  848. package/dist/plugin-sdk/agents/auth-profiles/constants.d.ts +0 -16
  849. package/dist/plugin-sdk/agents/auth-profiles/display.d.ts +0 -7
  850. package/dist/plugin-sdk/agents/auth-profiles/doctor.d.ts +0 -8
  851. package/dist/plugin-sdk/agents/auth-profiles/oauth.d.ts +0 -14
  852. package/dist/plugin-sdk/agents/auth-profiles/paths.d.ts +0 -4
  853. package/dist/plugin-sdk/agents/auth-profiles/profiles.d.ts +0 -12
  854. package/dist/plugin-sdk/agents/auth-profiles/session-override.d.ts +0 -18
  855. package/dist/plugin-sdk/agents/auth-profiles/store.d.ts +0 -10
  856. package/dist/plugin-sdk/agents/auth-profiles/types.d.ts +0 -13
  857. package/dist/plugin-sdk/agents/auth-profiles.d.ts +0 -8
  858. package/dist/plugin-sdk/agents/defaults.d.ts +0 -3
  859. package/dist/plugin-sdk/agents/provider-auth.d.ts +0 -40
  860. package/dist/plugin-sdk/auto-reply/model-runtime.d.ts +0 -17
  861. package/dist/plugin-sdk/auto-reply/reply/directive-handling.auth.d.ts +0 -19
  862. package/dist/plugin-sdk/auto-reply/reply/elevated-allowlist-matcher.d.ts +0 -20
  863. package/dist/plugin-sdk/auto-reply/reply/elevated-unavailable.d.ts +0 -8
  864. package/dist/plugin-sdk/auto-reply/reply/reply-elevated.d.ts +0 -16
  865. package/dist/plugin-sdk/compat/legacy-names.d.ts +0 -8
  866. package/dist/plugin-sdk/config/legacy.migrations.part-1.d.ts +0 -2
  867. package/dist/plugin-sdk/config/legacy.migrations.part-2.d.ts +0 -2
  868. package/dist/plugin-sdk/config/legacy.migrations.part-3.d.ts +0 -2
  869. package/dist/plugin-sdk/config/model-input.d.ts +0 -9
  870. package/dist/plugin-sdk/config/zod-schema.agent-model.d.ts +0 -5
  871. package/dist/plugin-sdk/link-understanding/apply.d.ts +0 -10
  872. package/dist/plugin-sdk/link-understanding/defaults.d.ts +0 -2
  873. package/dist/plugin-sdk/link-understanding/detect.d.ts +0 -3
  874. package/dist/plugin-sdk/link-understanding/format.d.ts +0 -4
  875. package/dist/plugin-sdk/link-understanding/runner.d.ts +0 -11
  876. package/dist/plugin-sdk/media/input-files.d.ts +0 -95
  877. package/dist/plugin-sdk/media-understanding/apply.d.ts +0 -19
  878. package/dist/plugin-sdk/media-understanding/attachments.d.ts +0 -49
  879. package/dist/plugin-sdk/media-understanding/audio-preflight.d.ts +0 -16
  880. package/dist/plugin-sdk/media-understanding/concurrency.d.ts +0 -1
  881. package/dist/plugin-sdk/media-understanding/defaults.d.ts +0 -12
  882. package/dist/plugin-sdk/media-understanding/errors.d.ts +0 -6
  883. package/dist/plugin-sdk/media-understanding/format.d.ts +0 -7
  884. package/dist/plugin-sdk/media-understanding/fs.d.ts +0 -1
  885. package/dist/plugin-sdk/media-understanding/output-extract.d.ts +0 -2
  886. package/dist/plugin-sdk/media-understanding/providers/anthropic/index.d.ts +0 -2
  887. package/dist/plugin-sdk/media-understanding/providers/deepgram/index.d.ts +0 -2
  888. package/dist/plugin-sdk/media-understanding/providers/google/index.d.ts +0 -2
  889. package/dist/plugin-sdk/media-understanding/providers/google/video.d.ts +0 -3
  890. package/dist/plugin-sdk/media-understanding/providers/groq/index.d.ts +0 -2
  891. package/dist/plugin-sdk/media-understanding/providers/index.d.ts +0 -4
  892. package/dist/plugin-sdk/media-understanding/providers/minimax/index.d.ts +0 -2
  893. package/dist/plugin-sdk/media-understanding/providers/mistral/index.d.ts +0 -2
  894. package/dist/plugin-sdk/media-understanding/providers/moonshot/index.d.ts +0 -2
  895. package/dist/plugin-sdk/media-understanding/providers/moonshot/video.d.ts +0 -3
  896. package/dist/plugin-sdk/media-understanding/providers/openai/index.d.ts +0 -2
  897. package/dist/plugin-sdk/media-understanding/providers/zai/index.d.ts +0 -2
  898. package/dist/plugin-sdk/media-understanding/resolve.d.ts +0 -44
  899. package/dist/plugin-sdk/media-understanding/runner.d.ts +0 -34
  900. package/dist/plugin-sdk/media-understanding/runner.entries.d.ts +0 -33
  901. package/dist/plugin-sdk/media-understanding/scope.d.ts +0 -9
  902. package/dist/plugin-sdk/media-understanding/types.d.ts +0 -74
  903. package/dist/plugin-sdk/media-understanding/video.d.ts +0 -2
  904. package/dist/plugin-sdk/sessions/model-overrides.d.ts +0 -14
  905. package/dist/plugin-sdk/telegram/reasoning-lane-coordinator.d.ts +0 -18
  906. package/dist/plugin-sdk/utils/mask-api-key.d.ts +0 -1
  907. package/dist/plugin-sdk/utils/run-with-concurrency.d.ts +0 -11
  908. package/dist/plugins-CsYMlnVa.js +0 -455
  909. package/dist/plugins-Dhit-VHt.js +0 -453
  910. package/dist/plugins-cli-BwuvKtN-.js +0 -798
  911. package/dist/plugins-cli-D34k2VsI.js +0 -793
  912. package/dist/ports-DrruB2fK.js +0 -370
  913. package/dist/ports-GT1yV-Tg.js +0 -96
  914. package/dist/ports-NPqtlfp0.js +0 -316
  915. package/dist/ports-QMI4-F9m.js +0 -96
  916. package/dist/program-C5ukTU6N.js +0 -244
  917. package/dist/program-context-D55P0vBV.js +0 -474
  918. package/dist/progress-CBkSaM6z.js +0 -124
  919. package/dist/prompt-Bllj1dhc.js +0 -21
  920. package/dist/prompt-select-styled-WStiI-bz.js +0 -1647
  921. package/dist/prompt-select-styled-ram-aXWu.js +0 -1650
  922. package/dist/prompt-style-DVEm3BZW.js +0 -9
  923. package/dist/provider-dispatcher-epFKwpGK.js +0 -659
  924. package/dist/provider-dispatcher-vEBMmwZ0.js +0 -660
  925. package/dist/push-apns-C0LyG-WB.js +0 -713
  926. package/dist/push-apns-DuG95AKC.js +0 -711
  927. package/dist/pw-ai-TygsEDgY.js +0 -1906
  928. package/dist/pw-ai-eS0sIkZo.js +0 -1910
  929. package/dist/qr-cli-B8sYhugo.js +0 -352
  930. package/dist/qr-cli-yP8i4Iv1.js +0 -347
  931. package/dist/redact-eZq1uwNK.js +0 -191
  932. package/dist/redact-snapshot-gOLgfKp3.js +0 -2028
  933. package/dist/redact-snapshot-uT-CXbM8.js +0 -2028
  934. package/dist/register.agent-CSoigVGq.js +0 -1043
  935. package/dist/register.agent-GZLrbUPm.js +0 -286
  936. package/dist/register.configure-CXpiRohq.js +0 -124
  937. package/dist/register.configure-RaqiHe5L.js +0 -130
  938. package/dist/register.import-Bs-UkOs-.js +0 -27
  939. package/dist/register.import-DLng8g-e.js +0 -30
  940. package/dist/register.maintenance-B-ZLQ56Y.js +0 -494
  941. package/dist/register.maintenance-Bjr_SmG9.js +0 -497
  942. package/dist/register.message-BCQ8Vg4O.js +0 -686
  943. package/dist/register.message-ChhiSr7g.js +0 -681
  944. package/dist/register.onboard-DJCqNufv.js +0 -257
  945. package/dist/register.onboard-jlxjsrv6.js +0 -262
  946. package/dist/register.setup-C-sdixz5.js +0 -114
  947. package/dist/register.setup-Dwpe4ArC.js +0 -109
  948. package/dist/register.status-health-sessions-BWFRHBCZ.js +0 -669
  949. package/dist/register.status-health-sessions-D7noMz9y.js +0 -423
  950. package/dist/register.subclis-DFI5u4a6.js +0 -267
  951. package/dist/replies-Bzcj-R8d.js +0 -136
  952. package/dist/replies-uvTI-4lg.js +0 -136
  953. package/dist/reply-B9qz9Wwk.js +0 -13897
  954. package/dist/reply-CmGAXQKc.js +0 -13900
  955. package/dist/reply-directives-Be97YiyM.js +0 -182
  956. package/dist/reply-directives-DsLughUT.js +0 -182
  957. package/dist/reply-payloads-DW0YgT82.js +0 -527
  958. package/dist/reply-prefix-BzoT8h8o.js +0 -38
  959. package/dist/reply-prefix-CSaiVnkC.js +0 -38
  960. package/dist/resolve-route-2P40JKXk.js +0 -249
  961. package/dist/resolve-route-_CwEKLq6.js +0 -249
  962. package/dist/response-prefix-template-BAlvtSjL.js +0 -136
  963. package/dist/response-prefix-template-D-tls8tI.js +0 -136
  964. package/dist/retry-B042l5UJ.js +0 -77
  965. package/dist/retry-BhuXOEVR.js +0 -77
  966. package/dist/run-main-B-O5ZtbU.js +0 -320
  967. package/dist/runner-DGkTSlOS.js +0 -2294
  968. package/dist/runner-hs4uxAUP.js +0 -2294
  969. package/dist/runtime-DJNp29jv.js +0 -94
  970. package/dist/runtime-guard-DZ_xuCc4.js +0 -60
  971. package/dist/secure-random-DTcQnwrI.js +0 -44
  972. package/dist/security-cli-1iY1lW6F.js +0 -484
  973. package/dist/security-cli-BuiPPQYU.js +0 -478
  974. package/dist/send-3lgWtHHf.js +0 -349
  975. package/dist/send-6l2S1bcr.js +0 -11
  976. package/dist/send-9NV7sSlD.js +0 -2245
  977. package/dist/send-B0TcjZUD.js +0 -1778
  978. package/dist/send-Bb6K_10X.js +0 -2245
  979. package/dist/send-BzN7X1Om.js +0 -374
  980. package/dist/send-CLrRM0El.js +0 -426
  981. package/dist/send-Caz-txXK.js +0 -492
  982. package/dist/send-DJEr4rP6.js +0 -547
  983. package/dist/send-DJiDHXsu.js +0 -349
  984. package/dist/send-DOjg7kJj.js +0 -1775
  985. package/dist/send-DVXOiKT4.js +0 -1174
  986. package/dist/send-Dc_K995l.js +0 -547
  987. package/dist/send-Dh6d3CLl.js +0 -332
  988. package/dist/send-iPAfbiYM.js +0 -492
  989. package/dist/send-pwe9Gu8e.js +0 -29
  990. package/dist/server-B0IC-Osg.js +0 -205
  991. package/dist/server-MccRxMpb.js +0 -200
  992. package/dist/server-lifecycle-C_0CfoP7.js +0 -2437
  993. package/dist/server-lifecycle-IKdGw1kM.js +0 -2437
  994. package/dist/server-node-events-Czr2gXp_.js +0 -393
  995. package/dist/server-node-events-DFG6cXud.js +0 -398
  996. package/dist/service-Bjqii5nW.js +0 -670
  997. package/dist/service-fp29z5Ww.js +0 -670
  998. package/dist/session-DBL5nHDy.js +0 -170
  999. package/dist/session-cost-usage-DX09eTPU.js +0 -627
  1000. package/dist/session-cost-usage-yYi525j3.js +0 -627
  1001. package/dist/session-dirs-Cj5xi7zX.js +0 -947
  1002. package/dist/session-dirs-DdF6TDsE.js +0 -947
  1003. package/dist/session-utils-C7BtKlun.js +0 -625
  1004. package/dist/session-utils-CLe1dano.js +0 -625
  1005. package/dist/session-xKIW6gL2.js +0 -170
  1006. package/dist/sessions-C65iUuN9.js +0 -2593
  1007. package/dist/sessions-DjZ9IshB.js +0 -252
  1008. package/dist/ssrf-Ck9HDZpv.js +0 -183
  1009. package/dist/ssrf-m7kFIobZ.js +0 -183
  1010. package/dist/status-C6ghjxvX.js +0 -2072
  1011. package/dist/status-D-qTB8aZ.js +0 -2068
  1012. package/dist/status.update-C55QM2xs.js +0 -79
  1013. package/dist/status.update-CBmPXwYN.js +0 -79
  1014. package/dist/store-Bjk6rTC_.js +0 -53
  1015. package/dist/store-C3tOpizT.js +0 -64
  1016. package/dist/store-uRA67h-o.js +0 -2595
  1017. package/dist/store-v3P-OWhi.js +0 -64
  1018. package/dist/subagent-registry-BTG1aAZ8.js +0 -4860
  1019. package/dist/subagent-registry-CoclNL5c.js +0 -4858
  1020. package/dist/subsystem-COd61u0P.js +0 -1139
  1021. package/dist/subsystem-D9ZpRKFP.js +0 -1079
  1022. package/dist/system-cli-C__5QOMX.js +0 -70
  1023. package/dist/system-cli-Dr4XoVTq.js +0 -75
  1024. package/dist/systemd-DSnlM3jX.js +0 -547
  1025. package/dist/systemd-TfK8GuTx.js +0 -547
  1026. package/dist/systemd-linger-Axnc1xCb.js +0 -75
  1027. package/dist/systemd-linger-_0_-RY4v.js +0 -75
  1028. package/dist/table-DPTzZyhu.js +0 -279
  1029. package/dist/tables-BQ-CvUfT.js +0 -55
  1030. package/dist/tables-D3a9iSU1.js +0 -55
  1031. package/dist/tables-D3zdgEuK.js +0 -55
  1032. package/dist/tailnet-CEudzG0i.js +0 -40
  1033. package/dist/tailnet-PnMrjwGT.js +0 -40
  1034. package/dist/tailscale-DTATQxAG.js +0 -230
  1035. package/dist/tailscale-Dbyahx0J.js +0 -230
  1036. package/dist/targets-B_0Y1i-1.js +0 -2173
  1037. package/dist/targets-CMhBAn87.js +0 -120
  1038. package/dist/targets-CTmhieRB.js +0 -650
  1039. package/dist/targets-CcTME3bp.js +0 -46
  1040. package/dist/targets-DfaVEd_u.js +0 -220
  1041. package/dist/targets-DtiQgjEL.js +0 -2172
  1042. package/dist/targets-DyybKefq.js +0 -53
  1043. package/dist/targets-rDolm5YS.js +0 -650
  1044. package/dist/tokens-DzFOtLlW.js +0 -21
  1045. package/dist/tool-display-Br6mwaJc.js +0 -785
  1046. package/dist/tool-display-sgNwLOBj.js +0 -785
  1047. package/dist/tool-images-BNfIJ_Kj.js +0 -263
  1048. package/dist/tool-images-kloBqxqK.js +0 -263
  1049. package/dist/trash-DPi0aCCQ.js +0 -125
  1050. package/dist/trash-D_Jd_yQZ.js +0 -125
  1051. package/dist/tui-BSDCI2hh.js +0 -3392
  1052. package/dist/tui-DT7hLOBk.js +0 -3392
  1053. package/dist/tui-cli-DUWvLaoG.js +0 -58
  1054. package/dist/tui-cli-Dn2iXQTO.js +0 -63
  1055. package/dist/update-Bgl3Pk2N.js +0 -349
  1056. package/dist/update-CFPFib4P.js +0 -349
  1057. package/dist/update-cli-DSDSQ2Xi.js +0 -1373
  1058. package/dist/update-cli-DYR_7NLy.js +0 -1370
  1059. package/dist/usage-CS1zeIan.js +0 -5279
  1060. package/dist/utils-LBKvDoPx.js +0 -631
  1061. package/dist/web-BECD5Akw.js +0 -70
  1062. package/dist/web-D4oENnAL.js +0 -3065
  1063. package/dist/web-KP-TI2sO.js +0 -76
  1064. package/dist/webhooks-cli-BqoG_i-D.js +0 -328
  1065. package/dist/webhooks-cli-Ddu7dfdE.js +0 -333
  1066. package/dist/whatsapp-actions-BZLIjQ8J.js +0 -122
  1067. package/dist/whatsapp-actions-KCc1vHN5.js +0 -128
  1068. package/dist/widearea-dns-DSoaA-eH.js +0 -127
  1069. package/dist/workspace-4EaHHEWi.js +0 -447
  1070. package/dist/workspace-B_1t_yq3.js +0 -449
  1071. /package/dist/{account-lookup-0KDSp5Mj.js → account-lookup-C0ndrpt-.js} +0 -0
  1072. /package/dist/{account-lookup-zvANGr2x.js → account-lookup-CIY_RKhi.js} +0 -0
  1073. /package/dist/{api-BeQMq2iS.js → api-BE4ZCWWB.js} +0 -0
  1074. /package/dist/{api-CxX8-gGz.js → api-wsk9zRVi.js} +0 -0
  1075. /package/dist/{argv-Co-b9Zsc.js → argv-BY8EVMTP.js} +0 -0
  1076. /package/dist/{brew-DbSbN8sD.js → brew-CmTYeZk1.js} +0 -0
  1077. /package/dist/{brew-C4zKZsHX.js → brew-V4lMBeE3.js} +0 -0
  1078. /package/dist/{chat-type-CYPyHAj-.js → chat-type-BP9akbag.js} +0 -0
  1079. /package/dist/{chat-type-DKb2TlGZ.js → chat-type-CH3W-zKy.js} +0 -0
  1080. /package/dist/{cleanup-utils-CwQvD73q.js → cleanup-utils-ZC2zvntc.js} +0 -0
  1081. /package/dist/{cli-name-BicfmwQX.js → cli-name-BZsYSp9l.js} +0 -0
  1082. /package/dist/{cli-name-C6rJGl18.js → cli-name-CRe5Ow_t.js} +0 -0
  1083. /package/dist/{cli-utils-BhXbz2UF.js → cli-utils-BUOtyfnU.js} +0 -0
  1084. /package/dist/{cli-utils-DZe_rVkZ.js → cli-utils-CGB3cBZm.js} +0 -0
  1085. /package/dist/{client-C61M8zI3.js → client-9dK56xly.js} +0 -0
  1086. /package/dist/{client-DdpmATKq.js → client-D-R1YdRD.js} +0 -0
  1087. /package/dist/{command-options-C4paWSGf.js → command-options-CnHA4TzR.js} +0 -0
  1088. /package/dist/{command-options-CA30lfLK.js → command-options-D2nN4AXX.js} +0 -0
  1089. /package/dist/{config-eval-CjGZtLwx.js → config-eval-BQIR-wSg.js} +0 -0
  1090. /package/dist/{config-eval-H_wlEYIG.js → config-eval-Bh82JoXK.js} +0 -0
  1091. /package/dist/{constants-ChptG3d7.js → constants-C7j1VA2S.js} +0 -0
  1092. /package/dist/{constants-DY6b-_Wl.js → constants-DoYLsBmv.js} +0 -0
  1093. /package/dist/{credentials-BHWUBHMd.js → credentials-C_RoJFmK.js} +0 -0
  1094. /package/dist/{credentials-DFsi1_e8.js → credentials-DM_Dj0m8.js} +0 -0
  1095. /package/dist/{daemon-runtime-CMnbwryP.js → daemon-runtime-9oDBR7YW.js} +0 -0
  1096. /package/dist/{daemon-runtime-CvqE4ysg.js → daemon-runtime-CzFI2dPw.js} +0 -0
  1097. /package/dist/{dangerous-name-matching-BzmiLXmA.js → dangerous-name-matching-BlTBBZns.js} +0 -0
  1098. /package/dist/{dangerous-name-matching-DaVRgwer.js → dangerous-name-matching-CSq9sJDG.js} +0 -0
  1099. /package/dist/{dangerous-tools-BOLoCRv4.js → dangerous-tools-BRmbBvRf.js} +0 -0
  1100. /package/dist/{dangerous-tools-Baq7Q-i6.js → dangerous-tools-D4jtl72G.js} +0 -0
  1101. /package/dist/{fetch-timeout-DTIN7CGM.js → fetch-timeout-CytN1wiO.js} +0 -0
  1102. /package/dist/{fetch-timeout-DoySHqfO.js → fetch-timeout-DBRRPNBi.js} +0 -0
  1103. /package/dist/{file-identity-BxlKD8Ys.js → file-identity-CeRK5CJC.js} +0 -0
  1104. /package/dist/{format-duration-CqUERz51.js → format-duration-B-Uv5nOi.js} +0 -0
  1105. /package/dist/{format-duration-Ct-yiwkS.js → format-duration-D1M3Zxu6.js} +0 -0
  1106. /package/dist/{format-relative-79_Y1n2Y.js → format-relative-Czf5fUjn.js} +0 -0
  1107. /package/dist/{format-relative-CxLpEQOX.js → format-relative-zwkkXJvs.js} +0 -0
  1108. /package/dist/{health-format-B_QRD8Si.js → health-format-DF54wvUU.js} +0 -0
  1109. /package/dist/{heartbeat-wake-LGEgcXjs.js → heartbeat-wake-CvHncCjP.js} +0 -0
  1110. /package/dist/{heartbeat-wake-Y97geucO.js → heartbeat-wake-DLxQm6-U.js} +0 -0
  1111. /package/dist/{help-format-NNm_Ov4H.js → help-format-CJQ7APRn.js} +0 -0
  1112. /package/dist/{helpers-BAsMXprO.js → helpers-BER76F_2.js} +0 -0
  1113. /package/dist/{helpers-DLgbkcEn.js → helpers-n2CtWpm9.js} +0 -0
  1114. /package/dist/{input-provenance-Bn6thJNm.js → input-provenance-gIfDn1ki.js} +0 -0
  1115. /package/dist/{input-provenance-xUsSMOsz.js → input-provenance-wkso1o5V.js} +0 -0
  1116. /package/dist/{ip-C9q3Oq20.js → ip-D4VG5EJO.js} +0 -0
  1117. /package/dist/{ip-D0zgNmBV.js → ip-MwCwRA7c.js} +0 -0
  1118. /package/dist/{is-main-DN8-sNR5.js → is-main-BmHYGRhd.js} +0 -0
  1119. /package/dist/{json-file-B7l5-Xhr.js → json-file-BW22hGtf.js} +0 -0
  1120. /package/dist/{json-file-ChO_R9yh.js → json-file-DwRAfAAy.js} +0 -0
  1121. /package/dist/{json-files-CmpYSF4G.js → json-files-Dy52honG.js} +0 -0
  1122. /package/dist/{lanes-ByWMUgrz.js → lanes-1CBKdsiR.js} +0 -0
  1123. /package/dist/{lanes-cHJ5arWg.js → lanes-DqVYfPRG.js} +0 -0
  1124. /package/dist/{links-Bz4V7R_p.js → links-CwTlzaPe.js} +0 -0
  1125. /package/dist/{location-DBWCGNLq.js → location-50gaJF5Z.js} +0 -0
  1126. /package/dist/{location-GbZ0bBRU.js → location-Qo8Ii1zo.js} +0 -0
  1127. /package/dist/{logger-DyL5G2DO.js → logger-B8BE0PyS.js} +0 -0
  1128. /package/dist/{logger-BWMPnILd.js → logger-CPvz-aPM.js} +0 -0
  1129. /package/dist/{logger-GvipVDfh.js → logger-cL0D2DCr.js} +0 -0
  1130. /package/dist/{logging-D8-Kozjc.js → logging-DTEoeoa3.js} +0 -0
  1131. /package/dist/{mutable-allowlist-detectors-DiZDtmlZ.js → mutable-allowlist-detectors-BXE7Hr7F.js} +0 -0
  1132. /package/dist/{mutable-allowlist-detectors-U5ThQr9V.js → mutable-allowlist-detectors-CtKavajp.js} +0 -0
  1133. /package/dist/{parse-log-line-enq8pduH.js → parse-log-line-GisaZn5H.js} +0 -0
  1134. /package/dist/{parse-log-line-mz9TG6ig.js → parse-log-line-ZsbwG_u7.js} +0 -0
  1135. /package/dist/{parse-timeout-BMP8a0_a.js → parse-timeout-BpphuwYl.js} +0 -0
  1136. /package/dist/{parse-timeout-CDkco8kd.js → parse-timeout-CE6BjmGU.js} +0 -0
  1137. /package/dist/plugin-sdk/{agents → auth}/api-key-rotation.d.ts +0 -0
  1138. /package/dist/plugin-sdk/{media-understanding → stt}/providers/deepgram/audio.d.ts +0 -0
  1139. /package/dist/plugin-sdk/{media-understanding → stt}/providers/google/audio.d.ts +0 -0
  1140. /package/dist/plugin-sdk/{media-understanding → stt}/providers/google/inline-data.d.ts +0 -0
  1141. /package/dist/plugin-sdk/{media-understanding → stt}/providers/openai/audio.d.ts +0 -0
  1142. /package/dist/plugin-sdk/{media-understanding → stt}/providers/shared.d.ts +0 -0
  1143. /package/dist/{plugins-allowlist-BbTQ5Z2k.js → plugins-allowlist-A38nxBRG.js} +0 -0
  1144. /package/dist/{plugins-allowlist-C20oaESO.js → plugins-allowlist-D2tS9tcu.js} +0 -0
  1145. /package/dist/{polls-B0CCBDeR.js → polls-BLyT08ZI.js} +0 -0
  1146. /package/dist/{polls-CwwHzYBM.js → polls-BmymsJEe.js} +0 -0
  1147. /package/dist/{ports-lsof-Wteul3ju.js → ports-lsof-CDyv5GJd.js} +0 -0
  1148. /package/dist/{process-scoped-map-CV9kDvfG.js → process-scoped-map-BCJR56ZB.js} +0 -0
  1149. /package/dist/{process-scoped-map-PEvnG75N.js → process-scoped-map-Cb1EHPyN.js} +0 -0
  1150. /package/dist/{program-context-jqeI5alP.js → program-context-DlXnmuB7.js} +0 -0
  1151. /package/dist/{progress-C1kUfYL-.js → progress-DRLmcFiG.js} +0 -0
  1152. /package/dist/{prompt-Yn2yClg1.js → prompt-BRGfic91.js} +0 -0
  1153. /package/dist/{prompt-style-DjEYC_s-.js → prompt-style-CUuA6OCy.js} +0 -0
  1154. /package/dist/{provider-utils-3JTMJroG.js → provider-utils-C9kBVF1f.js} +0 -0
  1155. /package/dist/{provider-utils-FaBmofiq.js → provider-utils-DiLhkKQp.js} +0 -0
  1156. /package/dist/{proxy-DL3MD6-P.js → proxy-BMJL0Qog.js} +0 -0
  1157. /package/dist/{proxy-DpNv2cSV.js → proxy-D-qGA1vm.js} +0 -0
  1158. /package/dist/{pw-ai-state-CGfLv6nV.js → pw-ai-state--TxTVwRW.js} +0 -0
  1159. /package/dist/{pw-ai-state-Dynx20hr.js → pw-ai-state-CwXeO5d0.js} +0 -0
  1160. /package/dist/{redact-Dx1Fue21.js → redact-BW8tobyp.js} +0 -0
  1161. /package/dist/{redact-identifier-BTIWtaa-.js → redact-identifier-BJOQDEj0.js} +0 -0
  1162. /package/dist/{redact-identifier-CAagcfWA.js → redact-identifier-Bv5SUUw-.js} +0 -0
  1163. /package/dist/{remoteclaw-root-C2HV2VeC.js → remoteclaw-root-BfPjgewe.js} +0 -0
  1164. /package/dist/{remoteclaw-root-DybYl8PL.js → remoteclaw-root-E4-hmb4E.js} +0 -0
  1165. /package/dist/{render-CCLsW6Lz.js → render-BhKzKdV0.js} +0 -0
  1166. /package/dist/{render-uf6PvGMV.js → render-e7fENCYH.js} +0 -0
  1167. /package/dist/{retry-DnqPAqWp.js → retry-BWv_fy4u.js} +0 -0
  1168. /package/dist/{runtime-guard-U-ewY_QH.js → runtime-guard-Bhx-pb8_.js} +0 -0
  1169. /package/dist/{secret-equal-BbHdTtqY.js → secret-equal-D6AoXne1.js} +0 -0
  1170. /package/dist/{secret-equal-CXJEZiWb.js → secret-equal-DLnUuWM3.js} +0 -0
  1171. /package/dist/{secure-random-CS2mSdTn.js → secure-random-CJtykx_p.js} +0 -0
  1172. /package/dist/{secure-random-_dzDDlFo.js → secure-random-CRVHgtmO.js} +0 -0
  1173. /package/dist/{session-key-5YLnn_qf.js → session-key-BF-9YzxC.js} +0 -0
  1174. /package/dist/{session-key-C2n-VILA.js → session-key-CgKWfjoZ.js} +0 -0
  1175. /package/dist/{stagger-BXv_apuy.js → stagger--wvODnNe.js} +0 -0
  1176. /package/dist/{stagger-MI9gd2rQ.js → stagger-BLmTO4cK.js} +0 -0
  1177. /package/dist/{status-BmtCS3T1.js → status-1zVD-Clq.js} +0 -0
  1178. /package/dist/{status-BrwHRn2B.js → status-BtRY0nXQ.js} +0 -0
  1179. /package/dist/{strip-inbound-meta-DjKcSFaW.js → strip-inbound-meta-zmUXypSS.js} +0 -0
  1180. /package/dist/{strip-inbound-meta-jy3bkUab.js → strip-inbound-meta-zqtN9FTK.js} +0 -0
  1181. /package/dist/{table-C1rdyYl9.js → table-On3hkCqi.js} +0 -0
  1182. /package/dist/{target-errors-BDpPcwh5.js → target-errors-DJVRKFcU.js} +0 -0
  1183. /package/dist/{target-errors-DdIAPcMM.js → target-errors-GZXDqlUu.js} +0 -0
  1184. /package/dist/{targets-C-2xwh9f.js → targets-B46m7u5J.js} +0 -0
  1185. /package/dist/{targets-D-qLBpTA.js → targets-B_d_1z3N.js} +0 -0
  1186. /package/dist/{targets-UncQvCVs.js → targets-D01MJGnh.js} +0 -0
  1187. /package/dist/{targets-BMenhVHg.js → targets-D3r6Zgic.js} +0 -0
  1188. /package/dist/{text-format-BQ3z_OXA.js → text-format-DarxU3JH.js} +0 -0
  1189. /package/dist/{text-format-oWqzVmah.js → text-format-Ds92M9UT.js} +0 -0
  1190. /package/dist/{tokens-B-jmvNR9.js → tokens-Dw7ZdYwT.js} +0 -0
  1191. /package/dist/{usage-BdhBT0Vz.js → usage-BIzKZ5dT.js} +0 -0
  1192. /package/dist/{usage-BtQcAnf6.js → usage-BvZOzIC7.js} +0 -0
  1193. /package/dist/{usage-format-C3mNLfhI.js → usage-format-CmniSPCG.js} +0 -0
  1194. /package/dist/{usage-format-DAaPzr_z.js → usage-format-D_KQYQ-w.js} +0 -0
  1195. /package/dist/{widearea-dns-CsmBVbez.js → widearea-dns-D01FFYZ8.js} +0 -0
  1196. /package/dist/{workspace-BzPeZDew.js → workspace-BJCKO8Ns.js} +0 -0
  1197. /package/dist/{workspace-DkGLVfOl.js → workspace-BisvA9oA.js} +0 -0
  1198. /package/dist/{wsl-B_sPlzWw.js → wsl-PDLKeX04.js} +0 -0
  1199. /package/dist/{wsl-BCnYV9O0.js → wsl-kFaeW76c.js} +0 -0
@@ -0,0 +1,3347 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-Cbj13DAv.js";
2
+ import { _ as resolveRequiredHomeDir, a as resolveCanonicalConfigPath, c as resolveDefaultConfigCandidates, d as resolveIsNixMode, f as resolveNewStateDir, i as isNixMode, l as resolveGatewayLockDir, m as resolveStateDir, n as DEFAULT_GATEWAY_PORT, o as resolveConfigPath, p as resolveOAuthDir, r as STATE_DIR, s as resolveConfigPathCandidate, t as CONFIG_PATH, u as resolveGatewayPort } from "./paths-DHuXVC00.js";
3
+ import { _ as resolveUserPath, l as isRecord, m as resolveConfigDir, w as isPlainObject$2 } from "./utils-DPoNpP7D.js";
4
+ import { _ as normalizeChatChannelId, l as CHANNEL_IDS } from "./subsystem-BAW_f3DI.js";
5
+ import { _ as isBlockedObjectKey, s as normalizeAgentId, t as DEFAULT_AGENT_ID } from "./session-key-CgKWfjoZ.js";
6
+ import { c as resolveDefaultAgentId, s as resolveAgentWorkspaceDirOrNull } from "./agent-scope-CAQLm3LP.js";
7
+ import { o as parseModelRef } from "./provider-utils-C9kBVF1f.js";
8
+ import { a as shouldEnableShellEnvFallback, i as shouldDeferShellEnvFallback, n as loadShellEnvFallback, r as resolveShellEnvFallbackTimeoutMs } from "./shell-env-c3j5zcU9.js";
9
+ import { t as VERSION } from "./version-CVMnqdzu.js";
10
+ import { t as applyConfigEnvVars } from "./env-vars-a7S70ba7.js";
11
+ import { t as RemoteClawSchema } from "./zod-schema-Y5SQgJLm.js";
12
+ import { n as parseToolsBySenderTypedKey, t as TOOLS_BY_SENDER_KEY_TYPES } from "./types.tools-BDJw1yFx.js";
13
+ import { fileURLToPath } from "node:url";
14
+ import fs from "node:fs";
15
+ import os from "node:os";
16
+ import path from "node:path";
17
+ import JSON5 from "json5";
18
+ import { isDeepStrictEqual } from "node:util";
19
+ import crypto from "node:crypto";
20
+ import dotenv from "dotenv";
21
+ import AjvPkg from "ajv";
22
+
23
+ //#region src/agents/owner-display.ts
24
+ function trimToUndefined(value) {
25
+ const trimmed = value?.trim();
26
+ return trimmed ? trimmed : void 0;
27
+ }
28
+ /**
29
+ * Resolve owner display settings for prompt rendering.
30
+ * Keep auth secrets decoupled from owner hash secrets.
31
+ */
32
+ function resolveOwnerDisplaySetting(config) {
33
+ const ownerDisplay = config?.commands?.ownerDisplay;
34
+ if (ownerDisplay !== "hash") return {
35
+ ownerDisplay,
36
+ ownerDisplaySecret: void 0
37
+ };
38
+ return {
39
+ ownerDisplay: "hash",
40
+ ownerDisplaySecret: trimToUndefined(config?.commands?.ownerDisplaySecret)
41
+ };
42
+ }
43
+ /**
44
+ * Ensure hash mode has a dedicated secret.
45
+ * Returns updated config and generated secret when autofill was needed.
46
+ */
47
+ function ensureOwnerDisplaySecret(config, generateSecret = () => crypto.randomBytes(32).toString("hex")) {
48
+ const settings = resolveOwnerDisplaySetting(config);
49
+ if (settings.ownerDisplay !== "hash" || settings.ownerDisplaySecret) return { config };
50
+ const generatedSecret = generateSecret();
51
+ return {
52
+ config: {
53
+ ...config,
54
+ commands: {
55
+ ...config.commands,
56
+ ownerDisplay: "hash",
57
+ ownerDisplaySecret: generatedSecret
58
+ }
59
+ },
60
+ generatedSecret
61
+ };
62
+ }
63
+
64
+ //#endregion
65
+ //#region src/infra/dotenv.ts
66
+ function loadDotEnv(opts) {
67
+ const quiet = opts?.quiet ?? true;
68
+ dotenv.config({ quiet });
69
+ const globalEnvPath = path.join(resolveConfigDir(process.env), ".env");
70
+ if (!fs.existsSync(globalEnvPath)) return;
71
+ dotenv.config({
72
+ quiet,
73
+ path: globalEnvPath,
74
+ override: false
75
+ });
76
+ }
77
+
78
+ //#endregion
79
+ //#region src/config/agent-dirs.ts
80
+ var DuplicateAgentDirError = class extends Error {
81
+ constructor(duplicates) {
82
+ super(formatDuplicateAgentDirError(duplicates));
83
+ this.name = "DuplicateAgentDirError";
84
+ this.duplicates = duplicates;
85
+ }
86
+ };
87
+ function canonicalizeAgentDir(agentDir) {
88
+ const resolved = path.resolve(agentDir);
89
+ if (process.platform === "darwin" || process.platform === "win32") return resolved.toLowerCase();
90
+ return resolved;
91
+ }
92
+ function collectReferencedAgentIds(cfg) {
93
+ const ids = /* @__PURE__ */ new Set();
94
+ const agents = Array.isArray(cfg.agents?.list) ? cfg.agents?.list : [];
95
+ const defaultAgentId = agents.find((agent) => agent?.default)?.id ?? agents[0]?.id ?? DEFAULT_AGENT_ID;
96
+ ids.add(normalizeAgentId(defaultAgentId));
97
+ for (const entry of agents) if (entry?.id) ids.add(normalizeAgentId(entry.id));
98
+ const bindings = cfg.bindings;
99
+ if (Array.isArray(bindings)) for (const binding of bindings) {
100
+ const id = binding?.agentId;
101
+ if (typeof id === "string" && id.trim()) ids.add(normalizeAgentId(id));
102
+ }
103
+ return [...ids];
104
+ }
105
+ function resolveEffectiveAgentDir(cfg, agentId, deps) {
106
+ const id = normalizeAgentId(agentId);
107
+ const trimmed = (Array.isArray(cfg.agents?.list) ? cfg.agents?.list.find((agent) => normalizeAgentId(agent.id) === id)?.agentDir : void 0)?.trim();
108
+ if (trimmed) return resolveUserPath(trimmed);
109
+ const env = deps?.env ?? process.env;
110
+ const root = resolveStateDir(env, deps?.homedir ?? (() => resolveRequiredHomeDir(env, os.homedir)));
111
+ return path.join(root, "agents", id, "agent");
112
+ }
113
+ function findDuplicateAgentDirs(cfg, deps) {
114
+ const byDir = /* @__PURE__ */ new Map();
115
+ for (const agentId of collectReferencedAgentIds(cfg)) {
116
+ const agentDir = resolveEffectiveAgentDir(cfg, agentId, deps);
117
+ const key = canonicalizeAgentDir(agentDir);
118
+ const entry = byDir.get(key);
119
+ if (entry) entry.agentIds.push(agentId);
120
+ else byDir.set(key, {
121
+ agentDir,
122
+ agentIds: [agentId]
123
+ });
124
+ }
125
+ return [...byDir.values()].filter((v) => v.agentIds.length > 1);
126
+ }
127
+ function formatDuplicateAgentDirError(dups) {
128
+ return [
129
+ "Duplicate agentDir detected (multi-agent config).",
130
+ "Each agent must have a unique agentDir; sharing it causes session state collisions.",
131
+ "",
132
+ "Conflicts:",
133
+ ...dups.map((d) => `- ${d.agentDir}: ${d.agentIds.map((id) => `"${id}"`).join(", ")}`),
134
+ "",
135
+ "Fix: remove the shared agents.list[].agentDir override (or give each agent its own directory)."
136
+ ].join("\n");
137
+ }
138
+
139
+ //#endregion
140
+ //#region src/config/backup-rotation.ts
141
+ const CONFIG_BACKUP_COUNT = 5;
142
+ async function rotateConfigBackups(configPath, ioFs) {
143
+ if (CONFIG_BACKUP_COUNT <= 1) return;
144
+ const backupBase = `${configPath}.bak`;
145
+ const maxIndex = CONFIG_BACKUP_COUNT - 1;
146
+ await ioFs.unlink(`${backupBase}.${maxIndex}`).catch(() => {});
147
+ for (let index = maxIndex - 1; index >= 1; index -= 1) await ioFs.rename(`${backupBase}.${index}`, `${backupBase}.${index + 1}`).catch(() => {});
148
+ await ioFs.rename(backupBase, `${backupBase}.1`).catch(() => {});
149
+ }
150
+
151
+ //#endregion
152
+ //#region src/config/agent-limits.ts
153
+ const DEFAULT_AGENT_MAX_CONCURRENT = 4;
154
+ const DEFAULT_SUBAGENT_MAX_CONCURRENT = 8;
155
+ const DEFAULT_SUBAGENT_MAX_SPAWN_DEPTH = 1;
156
+ function resolveAgentMaxConcurrent(cfg) {
157
+ const raw = cfg?.agents?.defaults?.maxConcurrent;
158
+ if (typeof raw === "number" && Number.isFinite(raw)) return Math.max(1, Math.floor(raw));
159
+ return DEFAULT_AGENT_MAX_CONCURRENT;
160
+ }
161
+ function resolveSubagentMaxConcurrent(cfg) {
162
+ const raw = cfg?.agents?.defaults?.subagents?.maxConcurrent;
163
+ if (typeof raw === "number" && Number.isFinite(raw)) return Math.max(1, Math.floor(raw));
164
+ return DEFAULT_SUBAGENT_MAX_CONCURRENT;
165
+ }
166
+
167
+ //#endregion
168
+ //#region src/config/talk.ts
169
+ const DEFAULT_TALK_PROVIDER = "elevenlabs";
170
+ function isPlainObject$1(value) {
171
+ return typeof value === "object" && value !== null && !Array.isArray(value);
172
+ }
173
+ function normalizeString(value) {
174
+ if (typeof value !== "string") return;
175
+ const trimmed = value.trim();
176
+ return trimmed.length > 0 ? trimmed : void 0;
177
+ }
178
+ function normalizeVoiceAliases(value) {
179
+ if (!isPlainObject$1(value)) return;
180
+ const aliases = {};
181
+ for (const [alias, rawId] of Object.entries(value)) {
182
+ if (typeof rawId !== "string") continue;
183
+ aliases[alias] = rawId;
184
+ }
185
+ return Object.keys(aliases).length > 0 ? aliases : void 0;
186
+ }
187
+ function normalizeTalkProviderConfig(value) {
188
+ if (!isPlainObject$1(value)) return;
189
+ const provider = {};
190
+ for (const [key, raw] of Object.entries(value)) {
191
+ if (raw === void 0) continue;
192
+ if (key === "voiceAliases") {
193
+ const aliases = normalizeVoiceAliases(raw);
194
+ if (aliases) provider.voiceAliases = aliases;
195
+ continue;
196
+ }
197
+ if (key === "voiceId" || key === "modelId" || key === "outputFormat" || key === "apiKey") {
198
+ const normalized = normalizeString(raw);
199
+ if (normalized) provider[key] = normalized;
200
+ continue;
201
+ }
202
+ provider[key] = raw;
203
+ }
204
+ return Object.keys(provider).length > 0 ? provider : void 0;
205
+ }
206
+ function normalizeTalkProviders(value) {
207
+ if (!isPlainObject$1(value)) return;
208
+ const providers = {};
209
+ for (const [rawProviderId, providerConfig] of Object.entries(value)) {
210
+ const providerId = normalizeString(rawProviderId);
211
+ if (!providerId) continue;
212
+ const normalizedProvider = normalizeTalkProviderConfig(providerConfig);
213
+ if (!normalizedProvider) continue;
214
+ providers[providerId] = normalizedProvider;
215
+ }
216
+ return Object.keys(providers).length > 0 ? providers : void 0;
217
+ }
218
+ function normalizedLegacyTalkFields(source) {
219
+ const legacy = {};
220
+ const voiceId = normalizeString(source.voiceId);
221
+ if (voiceId) legacy.voiceId = voiceId;
222
+ const voiceAliases = normalizeVoiceAliases(source.voiceAliases);
223
+ if (voiceAliases) legacy.voiceAliases = voiceAliases;
224
+ const modelId = normalizeString(source.modelId);
225
+ if (modelId) legacy.modelId = modelId;
226
+ const outputFormat = normalizeString(source.outputFormat);
227
+ if (outputFormat) legacy.outputFormat = outputFormat;
228
+ const apiKey = normalizeString(source.apiKey);
229
+ if (apiKey) legacy.apiKey = apiKey;
230
+ return legacy;
231
+ }
232
+ function legacyProviderConfigFromTalk(source) {
233
+ return normalizeTalkProviderConfig({
234
+ voiceId: source.voiceId,
235
+ voiceAliases: source.voiceAliases,
236
+ modelId: source.modelId,
237
+ outputFormat: source.outputFormat,
238
+ apiKey: source.apiKey
239
+ });
240
+ }
241
+ function activeProviderFromTalk(talk) {
242
+ const provider = normalizeString(talk.provider);
243
+ if (provider) return provider;
244
+ const providerIds = talk.providers ? Object.keys(talk.providers) : [];
245
+ return providerIds.length === 1 ? providerIds[0] : void 0;
246
+ }
247
+ function legacyTalkFieldsFromProviderConfig(config) {
248
+ if (!config) return {};
249
+ const legacy = {};
250
+ if (typeof config.voiceId === "string") legacy.voiceId = config.voiceId;
251
+ if (config.voiceAliases && typeof config.voiceAliases === "object" && !Array.isArray(config.voiceAliases)) {
252
+ const aliases = normalizeVoiceAliases(config.voiceAliases);
253
+ if (aliases) legacy.voiceAliases = aliases;
254
+ }
255
+ if (typeof config.modelId === "string") legacy.modelId = config.modelId;
256
+ if (typeof config.outputFormat === "string") legacy.outputFormat = config.outputFormat;
257
+ if (typeof config.apiKey === "string") legacy.apiKey = config.apiKey;
258
+ return legacy;
259
+ }
260
+ function normalizeTalkSection(value) {
261
+ if (!isPlainObject$1(value)) return;
262
+ const source = value;
263
+ const hasNormalizedShape = typeof source.provider === "string" || isPlainObject$1(source.providers);
264
+ const normalized = {};
265
+ const legacy = normalizedLegacyTalkFields(source);
266
+ if (Object.keys(legacy).length > 0) Object.assign(normalized, legacy);
267
+ if (typeof source.interruptOnSpeech === "boolean") normalized.interruptOnSpeech = source.interruptOnSpeech;
268
+ if (hasNormalizedShape) {
269
+ const providers = normalizeTalkProviders(source.providers);
270
+ const provider = normalizeString(source.provider);
271
+ if (providers) normalized.providers = providers;
272
+ if (provider) normalized.provider = provider;
273
+ else if (providers) {
274
+ const ids = Object.keys(providers);
275
+ if (ids.length === 1) normalized.provider = ids[0];
276
+ }
277
+ return Object.keys(normalized).length > 0 ? normalized : void 0;
278
+ }
279
+ const legacyProviderConfig = legacyProviderConfigFromTalk(source);
280
+ if (legacyProviderConfig) {
281
+ normalized.provider = DEFAULT_TALK_PROVIDER;
282
+ normalized.providers = { [DEFAULT_TALK_PROVIDER]: legacyProviderConfig };
283
+ }
284
+ return Object.keys(normalized).length > 0 ? normalized : void 0;
285
+ }
286
+ function normalizeTalkConfig(config) {
287
+ if (!config.talk) return config;
288
+ const normalizedTalk = normalizeTalkSection(config.talk);
289
+ if (!normalizedTalk) return config;
290
+ return {
291
+ ...config,
292
+ talk: normalizedTalk
293
+ };
294
+ }
295
+ function resolveActiveTalkProviderConfig(talk) {
296
+ const normalizedTalk = normalizeTalkSection(talk);
297
+ if (!normalizedTalk) return {};
298
+ const provider = activeProviderFromTalk(normalizedTalk);
299
+ if (!provider) return {};
300
+ return {
301
+ provider,
302
+ config: normalizedTalk.providers?.[provider]
303
+ };
304
+ }
305
+ function buildTalkConfigResponse(value) {
306
+ if (!isPlainObject$1(value)) return;
307
+ const normalized = normalizeTalkSection(value);
308
+ if (!normalized) return;
309
+ const payload = {};
310
+ if (typeof normalized.interruptOnSpeech === "boolean") payload.interruptOnSpeech = normalized.interruptOnSpeech;
311
+ if (normalized.providers && Object.keys(normalized.providers).length > 0) payload.providers = normalized.providers;
312
+ if (typeof normalized.provider === "string") payload.provider = normalized.provider;
313
+ const activeProvider = activeProviderFromTalk(normalized);
314
+ const providerCompatibilityLegacy = legacyTalkFieldsFromProviderConfig(activeProvider ? normalized.providers?.[activeProvider] : void 0);
315
+ const compatibilityLegacy = Object.keys(providerCompatibilityLegacy).length > 0 ? providerCompatibilityLegacy : normalizedLegacyTalkFields(normalized);
316
+ Object.assign(payload, compatibilityLegacy);
317
+ return Object.keys(payload).length > 0 ? payload : void 0;
318
+ }
319
+ function readTalkApiKeyFromProfile(deps = {}) {
320
+ const fsImpl = deps.fs ?? fs;
321
+ const osImpl = deps.os ?? os;
322
+ const pathImpl = deps.path ?? path;
323
+ const home = osImpl.homedir();
324
+ const candidates = [
325
+ ".profile",
326
+ ".zprofile",
327
+ ".zshrc",
328
+ ".bashrc"
329
+ ].map((name) => pathImpl.join(home, name));
330
+ for (const candidate of candidates) {
331
+ if (!fsImpl.existsSync(candidate)) continue;
332
+ try {
333
+ const value = fsImpl.readFileSync(candidate, "utf-8").match(/(?:^|\n)\s*(?:export\s+)?ELEVENLABS_API_KEY\s*=\s*["']?([^\n"']+)["']?/)?.[1]?.trim();
334
+ if (value) return value;
335
+ } catch {}
336
+ }
337
+ return null;
338
+ }
339
+ function resolveTalkApiKey(env = process.env, deps = {}) {
340
+ const envValue = (env.ELEVENLABS_API_KEY ?? "").trim();
341
+ if (envValue) return envValue;
342
+ return readTalkApiKeyFromProfile(deps);
343
+ }
344
+
345
+ //#endregion
346
+ //#region src/config/defaults.ts
347
+ let defaultWarnState = { warned: false };
348
+ const DEFAULT_MODEL_ALIASES = {
349
+ opus: "anthropic/claude-opus-4-6",
350
+ sonnet: "anthropic/claude-sonnet-4-6",
351
+ gpt: "openai/gpt-5.2",
352
+ "gpt-mini": "openai/gpt-5-mini",
353
+ gemini: "google/gemini-3-pro-preview",
354
+ "gemini-flash": "google/gemini-3-flash-preview"
355
+ };
356
+ function resolveAnthropicDefaultAuthMode(cfg) {
357
+ const profiles = cfg.auth?.profiles ?? {};
358
+ const anthropicProfiles = Object.entries(profiles).filter(([, profile]) => profile?.provider === "anthropic");
359
+ const order = cfg.auth?.order?.anthropic ?? [];
360
+ for (const profileId of order) {
361
+ const entry = profiles[profileId];
362
+ if (!entry || entry.provider !== "anthropic") continue;
363
+ if (entry.mode === "api_key") return "api_key";
364
+ if (entry.mode === "oauth" || entry.mode === "token") return "oauth";
365
+ }
366
+ const hasApiKey = anthropicProfiles.some(([, profile]) => profile?.mode === "api_key");
367
+ const hasOauth = anthropicProfiles.some(([, profile]) => profile?.mode === "oauth" || profile?.mode === "token");
368
+ if (hasApiKey && !hasOauth) return "api_key";
369
+ if (hasOauth && !hasApiKey) return "oauth";
370
+ if (process.env.ANTHROPIC_OAUTH_TOKEN?.trim()) return "oauth";
371
+ if (process.env.ANTHROPIC_API_KEY?.trim()) return "api_key";
372
+ return null;
373
+ }
374
+ function resolvePrimaryModelRef(raw) {
375
+ if (!raw || typeof raw !== "string") return null;
376
+ const trimmed = raw.trim();
377
+ if (!trimmed) return null;
378
+ return DEFAULT_MODEL_ALIASES[trimmed.toLowerCase()] ?? trimmed;
379
+ }
380
+ function applyMessageDefaults(cfg) {
381
+ const messages = cfg.messages;
382
+ if (messages?.ackReactionScope !== void 0) return cfg;
383
+ const nextMessages = messages ? { ...messages } : {};
384
+ nextMessages.ackReactionScope = "group-mentions";
385
+ return {
386
+ ...cfg,
387
+ messages: nextMessages
388
+ };
389
+ }
390
+ function applySessionDefaults(cfg, options = {}) {
391
+ const session = cfg.session;
392
+ if (!session || session.mainKey === void 0) return cfg;
393
+ const trimmed = session.mainKey.trim();
394
+ const warn = options.warn ?? console.warn;
395
+ const warnState = options.warnState ?? defaultWarnState;
396
+ const next = {
397
+ ...cfg,
398
+ session: {
399
+ ...session,
400
+ mainKey: "main"
401
+ }
402
+ };
403
+ if (trimmed && trimmed !== "main" && !warnState.warned) {
404
+ warnState.warned = true;
405
+ warn("session.mainKey is ignored; main session is always \"main\".");
406
+ }
407
+ return next;
408
+ }
409
+ function applyTalkApiKey(config) {
410
+ const normalized = normalizeTalkConfig(config);
411
+ const resolved = resolveTalkApiKey();
412
+ if (!resolved) return normalized;
413
+ const talk = normalized.talk;
414
+ const active = resolveActiveTalkProviderConfig(talk);
415
+ if (active.provider && active.provider !== DEFAULT_TALK_PROVIDER) return normalized;
416
+ const existingProviderApiKey = typeof active.config?.apiKey === "string" ? active.config.apiKey.trim() : "";
417
+ const existingLegacyApiKey = typeof talk?.apiKey === "string" ? talk.apiKey.trim() : "";
418
+ if (existingProviderApiKey || existingLegacyApiKey) return normalized;
419
+ const providerId = active.provider ?? DEFAULT_TALK_PROVIDER;
420
+ const providers = { ...talk?.providers };
421
+ providers[providerId] = {
422
+ ...providers[providerId],
423
+ apiKey: resolved
424
+ };
425
+ const nextTalk = {
426
+ ...talk,
427
+ provider: talk?.provider ?? providerId,
428
+ providers,
429
+ apiKey: resolved
430
+ };
431
+ return {
432
+ ...normalized,
433
+ talk: nextTalk
434
+ };
435
+ }
436
+ function applyTalkConfigNormalization(config) {
437
+ return normalizeTalkConfig(config);
438
+ }
439
+ function applyModelDefaults(cfg) {
440
+ const existingAgent = cfg.agents?.defaults;
441
+ if (!existingAgent) return cfg;
442
+ const existingModels = existingAgent.models ?? {};
443
+ if (Object.keys(existingModels).length === 0) return cfg;
444
+ const nextModels = { ...existingModels };
445
+ let mutated = false;
446
+ for (const [alias, target] of Object.entries(DEFAULT_MODEL_ALIASES)) {
447
+ const entry = nextModels[target];
448
+ if (!entry) continue;
449
+ if (entry.alias !== void 0) continue;
450
+ nextModels[target] = {
451
+ ...entry,
452
+ alias
453
+ };
454
+ mutated = true;
455
+ }
456
+ if (!mutated) return cfg;
457
+ return {
458
+ ...cfg,
459
+ agents: {
460
+ ...cfg.agents,
461
+ defaults: {
462
+ ...existingAgent,
463
+ models: nextModels
464
+ }
465
+ }
466
+ };
467
+ }
468
+ function applyAgentDefaults(cfg) {
469
+ const agents = cfg.agents;
470
+ const defaults = agents?.defaults;
471
+ const hasMax = typeof defaults?.maxConcurrent === "number" && Number.isFinite(defaults.maxConcurrent);
472
+ const hasSubMax = typeof defaults?.subagents?.maxConcurrent === "number" && Number.isFinite(defaults.subagents.maxConcurrent);
473
+ if (hasMax && hasSubMax) return cfg;
474
+ let mutated = false;
475
+ const nextDefaults = defaults ? { ...defaults } : {};
476
+ if (!hasMax) {
477
+ nextDefaults.maxConcurrent = DEFAULT_AGENT_MAX_CONCURRENT;
478
+ mutated = true;
479
+ }
480
+ const nextSubagents = defaults?.subagents ? { ...defaults.subagents } : {};
481
+ if (!hasSubMax) {
482
+ nextSubagents.maxConcurrent = DEFAULT_SUBAGENT_MAX_CONCURRENT;
483
+ mutated = true;
484
+ }
485
+ if (!mutated) return cfg;
486
+ return {
487
+ ...cfg,
488
+ agents: {
489
+ ...agents,
490
+ defaults: {
491
+ ...nextDefaults,
492
+ subagents: nextSubagents
493
+ }
494
+ }
495
+ };
496
+ }
497
+ function applyLoggingDefaults(cfg) {
498
+ const logging = cfg.logging;
499
+ if (!logging) return cfg;
500
+ if (logging.redactSensitive) return cfg;
501
+ return {
502
+ ...cfg,
503
+ logging: {
504
+ ...logging,
505
+ redactSensitive: "tools"
506
+ }
507
+ };
508
+ }
509
+ function applyContextPruningDefaults(cfg) {
510
+ const defaults = cfg.agents?.defaults;
511
+ if (!defaults) return cfg;
512
+ const authMode = resolveAnthropicDefaultAuthMode(cfg);
513
+ if (!authMode) return cfg;
514
+ let mutated = false;
515
+ const nextDefaults = { ...defaults };
516
+ const contextPruning = defaults.contextPruning ?? {};
517
+ const heartbeat = defaults.heartbeat ?? {};
518
+ if (defaults.contextPruning?.mode === void 0) {
519
+ nextDefaults.contextPruning = {
520
+ ...contextPruning,
521
+ mode: "cache-ttl",
522
+ ttl: defaults.contextPruning?.ttl ?? "1h"
523
+ };
524
+ mutated = true;
525
+ }
526
+ if (defaults.heartbeat?.every === void 0) {
527
+ nextDefaults.heartbeat = {
528
+ ...heartbeat,
529
+ every: authMode === "oauth" ? "1h" : "30m"
530
+ };
531
+ mutated = true;
532
+ }
533
+ if (authMode === "api_key") {
534
+ const nextModels = defaults.models ? { ...defaults.models } : {};
535
+ let modelsMutated = false;
536
+ const isAnthropicCacheRetentionTarget = (parsed) => Boolean(parsed && (parsed.provider === "anthropic" || parsed.provider === "amazon-bedrock" && parsed.model.toLowerCase().includes("anthropic.claude")));
537
+ for (const [key, entry] of Object.entries(nextModels)) {
538
+ if (!isAnthropicCacheRetentionTarget(parseModelRef(key, "anthropic"))) continue;
539
+ const current = entry ?? {};
540
+ const params = current.params ?? {};
541
+ if (typeof params.cacheRetention === "string") continue;
542
+ nextModels[key] = {
543
+ ...current,
544
+ params: {
545
+ ...params,
546
+ cacheRetention: "short"
547
+ }
548
+ };
549
+ modelsMutated = true;
550
+ }
551
+ const rawModel = defaults.model;
552
+ const rawPrimary = typeof rawModel === "string" ? rawModel : rawModel?.primary;
553
+ const primary = resolvePrimaryModelRef(typeof rawPrimary === "string" ? rawPrimary : void 0);
554
+ if (primary) {
555
+ const parsedPrimary = parseModelRef(primary, "anthropic");
556
+ if (isAnthropicCacheRetentionTarget(parsedPrimary)) {
557
+ const key = `${parsedPrimary.provider}/${parsedPrimary.model}`;
558
+ const current = nextModels[key] ?? {};
559
+ const params = current.params ?? {};
560
+ if (typeof params.cacheRetention !== "string") {
561
+ nextModels[key] = {
562
+ ...current,
563
+ params: {
564
+ ...params,
565
+ cacheRetention: "short"
566
+ }
567
+ };
568
+ modelsMutated = true;
569
+ }
570
+ }
571
+ }
572
+ if (modelsMutated) {
573
+ nextDefaults.models = nextModels;
574
+ mutated = true;
575
+ }
576
+ }
577
+ if (!mutated) return cfg;
578
+ return {
579
+ ...cfg,
580
+ agents: {
581
+ ...cfg.agents,
582
+ defaults: nextDefaults
583
+ }
584
+ };
585
+ }
586
+
587
+ //#endregion
588
+ //#region src/config/env-preserve.ts
589
+ /**
590
+ * Preserves `${VAR}` environment variable references during config write-back.
591
+ *
592
+ * When config is read, `${VAR}` references are resolved to their values.
593
+ * When writing back, callers pass the resolved config. This module detects
594
+ * values that match what a `${VAR}` reference would resolve to and restores
595
+ * the original reference, so env var references survive config round-trips.
596
+ *
597
+ * A value is restored only if:
598
+ * 1. The pre-substitution value contained a `${VAR}` pattern
599
+ * 2. Resolving that pattern with current env vars produces the incoming value
600
+ *
601
+ * If a caller intentionally set a new value (different from what the env var
602
+ * resolves to), the new value is kept as-is.
603
+ */
604
+ const ENV_VAR_PATTERN = /\$\{[A-Z_][A-Z0-9_]*\}/;
605
+ /**
606
+ * Check if a string contains any `${VAR}` env var references.
607
+ */
608
+ function hasEnvVarRef(value) {
609
+ return ENV_VAR_PATTERN.test(value);
610
+ }
611
+ /**
612
+ * Resolve `${VAR}` references in a single string using the given env.
613
+ * Returns null if any referenced var is missing (instead of throwing).
614
+ *
615
+ * Mirrors the substitution semantics of `substituteString` in env-substitution.ts:
616
+ * - `${VAR}` → env value (returns null if missing)
617
+ * - `$${VAR}` → literal `${VAR}` (escape sequence)
618
+ */
619
+ function tryResolveString(template, env) {
620
+ const ENV_VAR_NAME = /^[A-Z_][A-Z0-9_]*$/;
621
+ const chunks = [];
622
+ for (let i = 0; i < template.length; i++) {
623
+ if (template[i] === "$") {
624
+ if (template[i + 1] === "$" && template[i + 2] === "{") {
625
+ const start = i + 3;
626
+ const end = template.indexOf("}", start);
627
+ if (end !== -1) {
628
+ const name = template.slice(start, end);
629
+ if (ENV_VAR_NAME.test(name)) {
630
+ chunks.push(`\${${name}}`);
631
+ i = end;
632
+ continue;
633
+ }
634
+ }
635
+ }
636
+ if (template[i + 1] === "{") {
637
+ const start = i + 2;
638
+ const end = template.indexOf("}", start);
639
+ if (end !== -1) {
640
+ const name = template.slice(start, end);
641
+ if (ENV_VAR_NAME.test(name)) {
642
+ const val = env[name];
643
+ if (val === void 0 || val === "") return null;
644
+ chunks.push(val);
645
+ i = end;
646
+ continue;
647
+ }
648
+ }
649
+ }
650
+ }
651
+ chunks.push(template[i]);
652
+ }
653
+ return chunks.join("");
654
+ }
655
+ /**
656
+ * Deep-walk the incoming config and restore `${VAR}` references from the
657
+ * pre-substitution parsed config wherever the resolved value matches.
658
+ *
659
+ * @param incoming - The resolved config about to be written
660
+ * @param parsed - The pre-substitution parsed config (from the current file on disk)
661
+ * @param env - Environment variables for verification
662
+ * @returns A new config object with env var references restored where appropriate
663
+ */
664
+ function restoreEnvVarRefs(incoming, parsed, env = process.env) {
665
+ if (parsed === null || parsed === void 0) return incoming;
666
+ if (typeof incoming === "string" && typeof parsed === "string") {
667
+ if (hasEnvVarRef(parsed)) {
668
+ if (tryResolveString(parsed, env) === incoming) return parsed;
669
+ }
670
+ return incoming;
671
+ }
672
+ if (Array.isArray(incoming) && Array.isArray(parsed)) return incoming.map((item, i) => i < parsed.length ? restoreEnvVarRefs(item, parsed[i], env) : item);
673
+ if (isPlainObject$2(incoming) && isPlainObject$2(parsed)) {
674
+ const result = {};
675
+ for (const [key, value] of Object.entries(incoming)) if (key in parsed) result[key] = restoreEnvVarRefs(value, parsed[key], env);
676
+ else result[key] = value;
677
+ return result;
678
+ }
679
+ return incoming;
680
+ }
681
+
682
+ //#endregion
683
+ //#region src/config/env-substitution.ts
684
+ /**
685
+ * Environment variable substitution for config values.
686
+ *
687
+ * Supports `${VAR_NAME}` syntax in string values, substituted at config load time.
688
+ * - Only uppercase env vars are matched: `[A-Z_][A-Z0-9_]*`
689
+ * - Escape with `$${}` to output literal `${}`
690
+ * - Missing env vars throw `MissingEnvVarError` with context
691
+ *
692
+ * @example
693
+ * ```json5
694
+ * {
695
+ * models: {
696
+ * providers: {
697
+ * "vercel-gateway": {
698
+ * apiKey: "${VERCEL_GATEWAY_API_KEY}"
699
+ * }
700
+ * }
701
+ * }
702
+ * }
703
+ * ```
704
+ */
705
+ const ENV_VAR_NAME_PATTERN = /^[A-Z_][A-Z0-9_]*$/;
706
+ var MissingEnvVarError = class extends Error {
707
+ constructor(varName, configPath) {
708
+ super(`Missing env var "${varName}" referenced at config path: ${configPath}`);
709
+ this.varName = varName;
710
+ this.configPath = configPath;
711
+ this.name = "MissingEnvVarError";
712
+ }
713
+ };
714
+ function parseEnvTokenAt(value, index) {
715
+ if (value[index] !== "$") return null;
716
+ const next = value[index + 1];
717
+ const afterNext = value[index + 2];
718
+ if (next === "$" && afterNext === "{") {
719
+ const start = index + 3;
720
+ const end = value.indexOf("}", start);
721
+ if (end !== -1) {
722
+ const name = value.slice(start, end);
723
+ if (ENV_VAR_NAME_PATTERN.test(name)) return {
724
+ kind: "escaped",
725
+ name,
726
+ end
727
+ };
728
+ }
729
+ }
730
+ if (next === "{") {
731
+ const start = index + 2;
732
+ const end = value.indexOf("}", start);
733
+ if (end !== -1) {
734
+ const name = value.slice(start, end);
735
+ if (ENV_VAR_NAME_PATTERN.test(name)) return {
736
+ kind: "substitution",
737
+ name,
738
+ end
739
+ };
740
+ }
741
+ }
742
+ return null;
743
+ }
744
+ function substituteString(value, env, configPath) {
745
+ if (!value.includes("$")) return value;
746
+ const chunks = [];
747
+ for (let i = 0; i < value.length; i += 1) {
748
+ const char = value[i];
749
+ if (char !== "$") {
750
+ chunks.push(char);
751
+ continue;
752
+ }
753
+ const token = parseEnvTokenAt(value, i);
754
+ if (token?.kind === "escaped") {
755
+ chunks.push(`\${${token.name}}`);
756
+ i = token.end;
757
+ continue;
758
+ }
759
+ if (token?.kind === "substitution") {
760
+ const envValue = env[token.name];
761
+ if (envValue === void 0 || envValue === "") throw new MissingEnvVarError(token.name, configPath);
762
+ chunks.push(envValue);
763
+ i = token.end;
764
+ continue;
765
+ }
766
+ chunks.push(char);
767
+ }
768
+ return chunks.join("");
769
+ }
770
+ function containsEnvVarReference(value) {
771
+ if (!value.includes("$")) return false;
772
+ for (let i = 0; i < value.length; i += 1) {
773
+ if (value[i] !== "$") continue;
774
+ const token = parseEnvTokenAt(value, i);
775
+ if (token?.kind === "escaped") {
776
+ i = token.end;
777
+ continue;
778
+ }
779
+ if (token?.kind === "substitution") return true;
780
+ }
781
+ return false;
782
+ }
783
+ function substituteAny(value, env, path) {
784
+ if (typeof value === "string") return substituteString(value, env, path);
785
+ if (Array.isArray(value)) return value.map((item, index) => substituteAny(item, env, `${path}[${index}]`));
786
+ if (isPlainObject$2(value)) {
787
+ const result = {};
788
+ for (const [key, val] of Object.entries(value)) result[key] = substituteAny(val, env, path ? `${path}.${key}` : key);
789
+ return result;
790
+ }
791
+ return value;
792
+ }
793
+ /**
794
+ * Resolves `${VAR_NAME}` environment variable references in config values.
795
+ *
796
+ * @param obj - The parsed config object (after JSON5 parse and $include resolution)
797
+ * @param env - Environment variables to use for substitution (defaults to process.env)
798
+ * @returns The config object with env vars substituted
799
+ * @throws {MissingEnvVarError} If a referenced env var is not set or empty
800
+ */
801
+ function resolveConfigEnvVars(obj, env = process.env) {
802
+ return substituteAny(obj, env, "");
803
+ }
804
+
805
+ //#endregion
806
+ //#region src/security/scan-paths.ts
807
+ function isPathInside$1(basePath, candidatePath) {
808
+ const base = path.resolve(basePath);
809
+ const candidate = path.resolve(candidatePath);
810
+ const rel = path.relative(base, candidate);
811
+ return rel === "" || !rel.startsWith(`..${path.sep}`) && rel !== ".." && !path.isAbsolute(rel);
812
+ }
813
+ function safeRealpathSync$1(filePath) {
814
+ try {
815
+ return fs.realpathSync(filePath);
816
+ } catch {
817
+ return null;
818
+ }
819
+ }
820
+ function isPathInsideWithRealpath(basePath, candidatePath, opts) {
821
+ if (!isPathInside$1(basePath, candidatePath)) return false;
822
+ const baseReal = safeRealpathSync$1(basePath);
823
+ const candidateReal = safeRealpathSync$1(candidatePath);
824
+ if (!baseReal || !candidateReal) return opts?.requireRealpath !== true;
825
+ return isPathInside$1(baseReal, candidateReal);
826
+ }
827
+ function extensionUsesSkippedScannerPath(entry) {
828
+ return entry.split(/[\\/]+/).filter(Boolean).some((segment) => segment === "node_modules" || segment.startsWith(".") && segment !== "." && segment !== "..");
829
+ }
830
+
831
+ //#endregion
832
+ //#region src/config/includes.ts
833
+ /**
834
+ * Config includes: $include directive for modular configs
835
+ *
836
+ * @example
837
+ * ```json5
838
+ * {
839
+ * "$include": "./base.json5", // single file
840
+ * "$include": ["./a.json5", "./b.json5"] // merge multiple
841
+ * }
842
+ * ```
843
+ */
844
+ const INCLUDE_KEY = "$include";
845
+ const MAX_INCLUDE_DEPTH = 10;
846
+ var ConfigIncludeError = class extends Error {
847
+ constructor(message, includePath, cause) {
848
+ super(message);
849
+ this.includePath = includePath;
850
+ this.cause = cause;
851
+ this.name = "ConfigIncludeError";
852
+ }
853
+ };
854
+ var CircularIncludeError = class extends ConfigIncludeError {
855
+ constructor(chain) {
856
+ super(`Circular include detected: ${chain.join(" -> ")}`, chain[chain.length - 1]);
857
+ this.chain = chain;
858
+ this.name = "CircularIncludeError";
859
+ }
860
+ };
861
+ /** Deep merge: arrays concatenate, objects merge recursively, primitives: source wins */
862
+ function deepMerge(target, source) {
863
+ if (Array.isArray(target) && Array.isArray(source)) return [...target, ...source];
864
+ if (isPlainObject$2(target) && isPlainObject$2(source)) {
865
+ const result = { ...target };
866
+ for (const key of Object.keys(source)) {
867
+ if (isBlockedObjectKey(key)) continue;
868
+ result[key] = key in result ? deepMerge(result[key], source[key]) : source[key];
869
+ }
870
+ return result;
871
+ }
872
+ return source;
873
+ }
874
+ var IncludeProcessor = class IncludeProcessor {
875
+ constructor(basePath, resolver, rootDir) {
876
+ this.basePath = basePath;
877
+ this.resolver = resolver;
878
+ this.visited = /* @__PURE__ */ new Set();
879
+ this.depth = 0;
880
+ this.visited.add(path.normalize(basePath));
881
+ this.rootDir = path.normalize(rootDir ?? path.dirname(basePath));
882
+ this.rootRealDir = path.normalize(safeRealpath(this.rootDir));
883
+ }
884
+ process(obj) {
885
+ if (Array.isArray(obj)) return obj.map((item) => this.process(item));
886
+ if (!isPlainObject$2(obj)) return obj;
887
+ if (!(INCLUDE_KEY in obj)) return this.processObject(obj);
888
+ return this.processInclude(obj);
889
+ }
890
+ processObject(obj) {
891
+ const result = {};
892
+ for (const [key, value] of Object.entries(obj)) result[key] = this.process(value);
893
+ return result;
894
+ }
895
+ processInclude(obj) {
896
+ const includeValue = obj[INCLUDE_KEY];
897
+ const otherKeys = Object.keys(obj).filter((k) => k !== INCLUDE_KEY);
898
+ const included = this.resolveInclude(includeValue);
899
+ if (otherKeys.length === 0) return included;
900
+ if (!isPlainObject$2(included)) throw new ConfigIncludeError("Sibling keys require included content to be an object", typeof includeValue === "string" ? includeValue : INCLUDE_KEY);
901
+ const rest = {};
902
+ for (const key of otherKeys) rest[key] = this.process(obj[key]);
903
+ return deepMerge(included, rest);
904
+ }
905
+ resolveInclude(value) {
906
+ if (typeof value === "string") return this.loadFile(value);
907
+ if (Array.isArray(value)) return value.reduce((merged, item) => {
908
+ if (typeof item !== "string") throw new ConfigIncludeError(`Invalid $include array item: expected string, got ${typeof item}`, String(item));
909
+ return deepMerge(merged, this.loadFile(item));
910
+ }, {});
911
+ throw new ConfigIncludeError(`Invalid $include value: expected string or array of strings, got ${typeof value}`, String(value));
912
+ }
913
+ loadFile(includePath) {
914
+ const resolvedPath = this.resolvePath(includePath);
915
+ this.checkCircular(resolvedPath);
916
+ this.checkDepth(includePath);
917
+ const raw = this.readFile(includePath, resolvedPath);
918
+ const parsed = this.parseFile(includePath, resolvedPath, raw);
919
+ return this.processNested(resolvedPath, parsed);
920
+ }
921
+ resolvePath(includePath) {
922
+ const configDir = path.dirname(this.basePath);
923
+ const resolved = path.isAbsolute(includePath) ? includePath : path.resolve(configDir, includePath);
924
+ const normalized = path.normalize(resolved);
925
+ if (!isPathInside$1(this.rootDir, normalized)) throw new ConfigIncludeError(`Include path escapes config directory: ${includePath} (root: ${this.rootDir})`, includePath);
926
+ try {
927
+ const real = fs.realpathSync(normalized);
928
+ if (!isPathInside$1(this.rootRealDir, real)) throw new ConfigIncludeError(`Include path resolves outside config directory (symlink): ${includePath} (root: ${this.rootDir})`, includePath);
929
+ } catch (err) {
930
+ if (err instanceof ConfigIncludeError) throw err;
931
+ }
932
+ return normalized;
933
+ }
934
+ checkCircular(resolvedPath) {
935
+ if (this.visited.has(resolvedPath)) throw new CircularIncludeError([...this.visited, resolvedPath]);
936
+ }
937
+ checkDepth(includePath) {
938
+ if (this.depth >= MAX_INCLUDE_DEPTH) throw new ConfigIncludeError(`Maximum include depth (${MAX_INCLUDE_DEPTH}) exceeded at: ${includePath}`, includePath);
939
+ }
940
+ readFile(includePath, resolvedPath) {
941
+ try {
942
+ return this.resolver.readFile(resolvedPath);
943
+ } catch (err) {
944
+ throw new ConfigIncludeError(`Failed to read include file: ${includePath} (resolved: ${resolvedPath})`, includePath, err instanceof Error ? err : void 0);
945
+ }
946
+ }
947
+ parseFile(includePath, resolvedPath, raw) {
948
+ try {
949
+ return this.resolver.parseJson(raw);
950
+ } catch (err) {
951
+ throw new ConfigIncludeError(`Failed to parse include file: ${includePath} (resolved: ${resolvedPath})`, includePath, err instanceof Error ? err : void 0);
952
+ }
953
+ }
954
+ processNested(resolvedPath, parsed) {
955
+ const nested = new IncludeProcessor(resolvedPath, this.resolver, this.rootDir);
956
+ nested.visited = new Set([...this.visited, resolvedPath]);
957
+ nested.depth = this.depth + 1;
958
+ return nested.process(parsed);
959
+ }
960
+ };
961
+ function safeRealpath(target) {
962
+ try {
963
+ return fs.realpathSync(target);
964
+ } catch {
965
+ return target;
966
+ }
967
+ }
968
+ const defaultResolver = {
969
+ readFile: (p) => fs.readFileSync(p, "utf-8"),
970
+ parseJson: (raw) => JSON5.parse(raw)
971
+ };
972
+ /**
973
+ * Resolves all $include directives in a parsed config object.
974
+ */
975
+ function resolveConfigIncludes(obj, configPath, resolver = defaultResolver) {
976
+ return new IncludeProcessor(configPath, resolver).process(obj);
977
+ }
978
+
979
+ //#endregion
980
+ //#region src/config/legacy.migrations.ts
981
+ const LEGACY_CONFIG_MIGRATIONS = [];
982
+
983
+ //#endregion
984
+ //#region src/config/legacy.rules.ts
985
+ const LEGACY_CONFIG_RULES = [];
986
+
987
+ //#endregion
988
+ //#region src/config/legacy.ts
989
+ function findLegacyConfigIssues(raw) {
990
+ if (!raw || typeof raw !== "object") return [];
991
+ const root = raw;
992
+ const issues = [];
993
+ for (const rule of LEGACY_CONFIG_RULES) {
994
+ let cursor = root;
995
+ for (const key of rule.path) {
996
+ if (!cursor || typeof cursor !== "object") {
997
+ cursor = void 0;
998
+ break;
999
+ }
1000
+ cursor = cursor[key];
1001
+ }
1002
+ if (cursor !== void 0 && (!rule.match || rule.match(cursor, root))) issues.push({
1003
+ path: rule.path.join("."),
1004
+ message: rule.message
1005
+ });
1006
+ }
1007
+ return issues;
1008
+ }
1009
+ function applyLegacyMigrations(raw) {
1010
+ if (!raw || typeof raw !== "object") return {
1011
+ next: null,
1012
+ changes: []
1013
+ };
1014
+ const next = structuredClone(raw);
1015
+ const changes = [];
1016
+ for (const migration of LEGACY_CONFIG_MIGRATIONS) migration.apply(next, changes);
1017
+ if (changes.length === 0) return {
1018
+ next: null,
1019
+ changes: []
1020
+ };
1021
+ return {
1022
+ next,
1023
+ changes
1024
+ };
1025
+ }
1026
+
1027
+ //#endregion
1028
+ //#region src/config/merge-patch.ts
1029
+ function isObjectWithStringId(value) {
1030
+ if (!isPlainObject$2(value)) return false;
1031
+ return typeof value.id === "string" && value.id.length > 0;
1032
+ }
1033
+ /**
1034
+ * Merge arrays of object-like entries keyed by `id`.
1035
+ *
1036
+ * Contract:
1037
+ * - Base array must be fully id-keyed; otherwise return undefined (caller should replace).
1038
+ * - Patch entries with valid id merge by id (or append when the id is new).
1039
+ * - Patch entries without valid id append as-is, avoiding destructive full-array replacement.
1040
+ */
1041
+ function mergeObjectArraysById(base, patch, options) {
1042
+ if (!base.every(isObjectWithStringId)) return;
1043
+ const merged = [...base];
1044
+ const indexById = /* @__PURE__ */ new Map();
1045
+ for (const [index, entry] of merged.entries()) {
1046
+ if (!isObjectWithStringId(entry)) return;
1047
+ indexById.set(entry.id, index);
1048
+ }
1049
+ for (const patchEntry of patch) {
1050
+ if (!isObjectWithStringId(patchEntry)) {
1051
+ merged.push(structuredClone(patchEntry));
1052
+ continue;
1053
+ }
1054
+ const existingIndex = indexById.get(patchEntry.id);
1055
+ if (existingIndex === void 0) {
1056
+ merged.push(structuredClone(patchEntry));
1057
+ indexById.set(patchEntry.id, merged.length - 1);
1058
+ continue;
1059
+ }
1060
+ merged[existingIndex] = applyMergePatch(merged[existingIndex], patchEntry, options);
1061
+ }
1062
+ return merged;
1063
+ }
1064
+ function applyMergePatch(base, patch, options = {}) {
1065
+ if (!isPlainObject$2(patch)) return patch;
1066
+ const result = isPlainObject$2(base) ? { ...base } : {};
1067
+ for (const [key, value] of Object.entries(patch)) {
1068
+ if (isBlockedObjectKey(key)) continue;
1069
+ if (value === null) {
1070
+ delete result[key];
1071
+ continue;
1072
+ }
1073
+ if (options.mergeObjectArraysById && Array.isArray(result[key]) && Array.isArray(value)) {
1074
+ const mergedArray = mergeObjectArraysById(result[key], value, options);
1075
+ if (mergedArray) {
1076
+ result[key] = mergedArray;
1077
+ continue;
1078
+ }
1079
+ }
1080
+ if (isPlainObject$2(value)) {
1081
+ const baseValue = result[key];
1082
+ result[key] = applyMergePatch(isPlainObject$2(baseValue) ? baseValue : {}, value, options);
1083
+ continue;
1084
+ }
1085
+ result[key] = value;
1086
+ }
1087
+ return result;
1088
+ }
1089
+
1090
+ //#endregion
1091
+ //#region src/config/normalize-paths.ts
1092
+ const PATH_VALUE_RE = /^~(?=$|[\\/])/;
1093
+ const PATH_KEY_RE = /(dir|path|paths|file|root|workspace)$/i;
1094
+ const PATH_LIST_KEYS = new Set(["paths", "pathPrepend"]);
1095
+ function normalizeStringValue(key, value) {
1096
+ if (!PATH_VALUE_RE.test(value.trim())) return value;
1097
+ if (!key) return value;
1098
+ if (PATH_KEY_RE.test(key) || PATH_LIST_KEYS.has(key)) return resolveUserPath(value);
1099
+ return value;
1100
+ }
1101
+ function normalizeAny(key, value) {
1102
+ if (typeof value === "string") return normalizeStringValue(key, value);
1103
+ if (Array.isArray(value)) {
1104
+ const normalizeChildren = Boolean(key && PATH_LIST_KEYS.has(key));
1105
+ return value.map((entry) => {
1106
+ if (typeof entry === "string") return normalizeChildren ? normalizeStringValue(key, entry) : entry;
1107
+ if (Array.isArray(entry)) return normalizeAny(void 0, entry);
1108
+ if (isPlainObject$2(entry)) return normalizeAny(void 0, entry);
1109
+ return entry;
1110
+ });
1111
+ }
1112
+ if (!isPlainObject$2(value)) return value;
1113
+ for (const [childKey, childValue] of Object.entries(value)) {
1114
+ const next = normalizeAny(childKey, childValue);
1115
+ if (next !== childValue) value[childKey] = next;
1116
+ }
1117
+ return value;
1118
+ }
1119
+ /**
1120
+ * Normalize "~" paths in path-ish config fields.
1121
+ *
1122
+ * Goal: accept `~/...` consistently across config file + env overrides, while
1123
+ * keeping the surface area small and predictable.
1124
+ */
1125
+ function normalizeConfigPaths(cfg) {
1126
+ if (!cfg || typeof cfg !== "object") return cfg;
1127
+ normalizeAny(void 0, cfg);
1128
+ return cfg;
1129
+ }
1130
+
1131
+ //#endregion
1132
+ //#region src/config/config-paths.ts
1133
+ function parseConfigPath(raw) {
1134
+ const trimmed = raw.trim();
1135
+ if (!trimmed) return {
1136
+ ok: false,
1137
+ error: "Invalid path. Use dot notation (e.g. foo.bar)."
1138
+ };
1139
+ const parts = trimmed.split(".").map((part) => part.trim());
1140
+ if (parts.some((part) => !part)) return {
1141
+ ok: false,
1142
+ error: "Invalid path. Use dot notation (e.g. foo.bar)."
1143
+ };
1144
+ if (parts.some((part) => isBlockedObjectKey(part))) return {
1145
+ ok: false,
1146
+ error: "Invalid path segment."
1147
+ };
1148
+ return {
1149
+ ok: true,
1150
+ path: parts
1151
+ };
1152
+ }
1153
+ function setConfigValueAtPath(root, path, value) {
1154
+ let cursor = root;
1155
+ for (let idx = 0; idx < path.length - 1; idx += 1) {
1156
+ const key = path[idx];
1157
+ const next = cursor[key];
1158
+ if (!isPlainObject$2(next)) cursor[key] = {};
1159
+ cursor = cursor[key];
1160
+ }
1161
+ cursor[path[path.length - 1]] = value;
1162
+ }
1163
+ function unsetConfigValueAtPath(root, path) {
1164
+ const stack = [];
1165
+ let cursor = root;
1166
+ for (let idx = 0; idx < path.length - 1; idx += 1) {
1167
+ const key = path[idx];
1168
+ const next = cursor[key];
1169
+ if (!isPlainObject$2(next)) return false;
1170
+ stack.push({
1171
+ node: cursor,
1172
+ key
1173
+ });
1174
+ cursor = next;
1175
+ }
1176
+ const leafKey = path[path.length - 1];
1177
+ if (!(leafKey in cursor)) return false;
1178
+ delete cursor[leafKey];
1179
+ for (let idx = stack.length - 1; idx >= 0; idx -= 1) {
1180
+ const { node, key } = stack[idx];
1181
+ const child = node[key];
1182
+ if (isPlainObject$2(child) && Object.keys(child).length === 0) delete node[key];
1183
+ else break;
1184
+ }
1185
+ return true;
1186
+ }
1187
+ function getConfigValueAtPath(root, path) {
1188
+ let cursor = root;
1189
+ for (const key of path) {
1190
+ if (!isPlainObject$2(cursor)) return;
1191
+ cursor = cursor[key];
1192
+ }
1193
+ return cursor;
1194
+ }
1195
+
1196
+ //#endregion
1197
+ //#region src/config/runtime-overrides.ts
1198
+ let overrides = {};
1199
+ function sanitizeOverrideValue(value, seen = /* @__PURE__ */ new WeakSet()) {
1200
+ if (Array.isArray(value)) return value.map((entry) => sanitizeOverrideValue(entry, seen));
1201
+ if (!isPlainObject$2(value)) return value;
1202
+ if (seen.has(value)) return {};
1203
+ seen.add(value);
1204
+ const sanitized = {};
1205
+ for (const [key, entry] of Object.entries(value)) {
1206
+ if (entry === void 0 || isBlockedObjectKey(key)) continue;
1207
+ sanitized[key] = sanitizeOverrideValue(entry, seen);
1208
+ }
1209
+ seen.delete(value);
1210
+ return sanitized;
1211
+ }
1212
+ function mergeOverrides(base, override) {
1213
+ if (!isPlainObject$2(base) || !isPlainObject$2(override)) return override;
1214
+ const next = { ...base };
1215
+ for (const [key, value] of Object.entries(override)) {
1216
+ if (value === void 0 || isBlockedObjectKey(key)) continue;
1217
+ next[key] = mergeOverrides(base[key], value);
1218
+ }
1219
+ return next;
1220
+ }
1221
+ function getConfigOverrides() {
1222
+ return overrides;
1223
+ }
1224
+ function resetConfigOverrides() {
1225
+ overrides = {};
1226
+ }
1227
+ function setConfigOverride(pathRaw, value) {
1228
+ const parsed = parseConfigPath(pathRaw);
1229
+ if (!parsed.ok || !parsed.path) return {
1230
+ ok: false,
1231
+ error: parsed.error ?? "Invalid path."
1232
+ };
1233
+ setConfigValueAtPath(overrides, parsed.path, sanitizeOverrideValue(value));
1234
+ return { ok: true };
1235
+ }
1236
+ function unsetConfigOverride(pathRaw) {
1237
+ const parsed = parseConfigPath(pathRaw);
1238
+ if (!parsed.ok || !parsed.path) return {
1239
+ ok: false,
1240
+ removed: false,
1241
+ error: parsed.error ?? "Invalid path."
1242
+ };
1243
+ return {
1244
+ ok: true,
1245
+ removed: unsetConfigValueAtPath(overrides, parsed.path)
1246
+ };
1247
+ }
1248
+ function applyConfigOverrides(cfg) {
1249
+ if (!overrides || Object.keys(overrides).length === 0) return cfg;
1250
+ return mergeOverrides(cfg, overrides);
1251
+ }
1252
+
1253
+ //#endregion
1254
+ //#region src/plugins/config-state.ts
1255
+ const BUNDLED_ENABLED_BY_DEFAULT = new Set([
1256
+ "device-pair",
1257
+ "phone-control",
1258
+ "talk-voice"
1259
+ ]);
1260
+ const normalizeList = (value) => {
1261
+ if (!Array.isArray(value)) return [];
1262
+ return value.map((entry) => typeof entry === "string" ? entry.trim() : "").filter(Boolean);
1263
+ };
1264
+ const normalizePluginEntries = (entries) => {
1265
+ if (!entries || typeof entries !== "object" || Array.isArray(entries)) return {};
1266
+ const normalized = {};
1267
+ for (const [key, value] of Object.entries(entries)) {
1268
+ if (!key.trim()) continue;
1269
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
1270
+ normalized[key] = {};
1271
+ continue;
1272
+ }
1273
+ const entry = value;
1274
+ normalized[key] = {
1275
+ enabled: typeof entry.enabled === "boolean" ? entry.enabled : void 0,
1276
+ config: "config" in entry ? entry.config : void 0
1277
+ };
1278
+ }
1279
+ return normalized;
1280
+ };
1281
+ const normalizePluginsConfig = (config) => {
1282
+ return {
1283
+ enabled: config?.enabled !== false,
1284
+ allow: normalizeList(config?.allow),
1285
+ deny: normalizeList(config?.deny),
1286
+ loadPaths: normalizeList(config?.load?.paths),
1287
+ slots: {},
1288
+ entries: normalizePluginEntries(config?.entries)
1289
+ };
1290
+ };
1291
+ const hasExplicitPluginConfig = (plugins) => {
1292
+ if (!plugins) return false;
1293
+ if (typeof plugins.enabled === "boolean") return true;
1294
+ if (Array.isArray(plugins.allow) && plugins.allow.length > 0) return true;
1295
+ if (Array.isArray(plugins.deny) && plugins.deny.length > 0) return true;
1296
+ if (plugins.load?.paths && Array.isArray(plugins.load.paths) && plugins.load.paths.length > 0) return true;
1297
+ if (plugins.slots && Object.keys(plugins.slots).length > 0) return true;
1298
+ if (plugins.entries && Object.keys(plugins.entries).length > 0) return true;
1299
+ return false;
1300
+ };
1301
+ function applyTestPluginDefaults(cfg, env = process.env) {
1302
+ if (!env.VITEST) return cfg;
1303
+ const plugins = cfg.plugins;
1304
+ if (hasExplicitPluginConfig(plugins)) return cfg;
1305
+ return {
1306
+ ...cfg,
1307
+ plugins: {
1308
+ ...plugins,
1309
+ enabled: false
1310
+ }
1311
+ };
1312
+ }
1313
+ function resolveEnableState(id, origin, config) {
1314
+ if (!config.enabled) return {
1315
+ enabled: false,
1316
+ reason: "plugins disabled"
1317
+ };
1318
+ if (config.deny.includes(id)) return {
1319
+ enabled: false,
1320
+ reason: "blocked by denylist"
1321
+ };
1322
+ if (config.allow.length > 0 && !config.allow.includes(id)) return {
1323
+ enabled: false,
1324
+ reason: "not in allowlist"
1325
+ };
1326
+ const entry = config.entries[id];
1327
+ if (entry?.enabled === true) return { enabled: true };
1328
+ if (entry?.enabled === false) return {
1329
+ enabled: false,
1330
+ reason: "disabled in config"
1331
+ };
1332
+ if (origin === "bundled" && BUNDLED_ENABLED_BY_DEFAULT.has(id)) return { enabled: true };
1333
+ if (origin === "bundled") return {
1334
+ enabled: false,
1335
+ reason: "bundled (disabled by default)"
1336
+ };
1337
+ return { enabled: true };
1338
+ }
1339
+ function isBundledChannelEnabledByChannelConfig(cfg, pluginId) {
1340
+ if (!cfg) return false;
1341
+ const channelId = normalizeChatChannelId(pluginId);
1342
+ if (!channelId) return false;
1343
+ const entry = cfg.channels?.[channelId];
1344
+ if (!entry || typeof entry !== "object" || Array.isArray(entry)) return false;
1345
+ return entry.enabled === true;
1346
+ }
1347
+ function resolveEffectiveEnableState(params) {
1348
+ const base = resolveEnableState(params.id, params.origin, params.config);
1349
+ if (!base.enabled && base.reason === "bundled (disabled by default)" && isBundledChannelEnabledByChannelConfig(params.rootConfig, params.id)) return { enabled: true };
1350
+ return base;
1351
+ }
1352
+
1353
+ //#endregion
1354
+ //#region src/plugins/bundled-dir.ts
1355
+ function resolveBundledPluginsDir() {
1356
+ const override = process.env.REMOTECLAW_BUNDLED_PLUGINS_DIR?.trim();
1357
+ if (override) return override;
1358
+ try {
1359
+ const execDir = path.dirname(process.execPath);
1360
+ const sibling = path.join(execDir, "extensions");
1361
+ if (fs.existsSync(sibling)) return sibling;
1362
+ } catch {}
1363
+ try {
1364
+ let cursor = path.dirname(fileURLToPath(import.meta.url));
1365
+ for (let i = 0; i < 6; i += 1) {
1366
+ const candidate = path.join(cursor, "extensions");
1367
+ if (fs.existsSync(candidate)) return candidate;
1368
+ const parent = path.dirname(cursor);
1369
+ if (parent === cursor) break;
1370
+ cursor = parent;
1371
+ }
1372
+ } catch {}
1373
+ }
1374
+
1375
+ //#endregion
1376
+ //#region src/plugins/manifest.ts
1377
+ const MANIFEST_KEY = "remoteclaw";
1378
+ const PLUGIN_MANIFEST_FILENAME = "remoteclaw.plugin.json";
1379
+ function normalizeStringList(value) {
1380
+ if (!Array.isArray(value)) return [];
1381
+ return value.map((entry) => typeof entry === "string" ? entry.trim() : "").filter(Boolean);
1382
+ }
1383
+ function resolvePluginManifestPath(rootDir) {
1384
+ return path.join(rootDir, PLUGIN_MANIFEST_FILENAME);
1385
+ }
1386
+ function loadPluginManifest(rootDir) {
1387
+ const manifestPath = resolvePluginManifestPath(rootDir);
1388
+ if (!fs.existsSync(manifestPath)) return {
1389
+ ok: false,
1390
+ error: `plugin manifest not found: ${manifestPath}`,
1391
+ manifestPath
1392
+ };
1393
+ let raw;
1394
+ try {
1395
+ raw = JSON.parse(fs.readFileSync(manifestPath, "utf-8"));
1396
+ } catch (err) {
1397
+ return {
1398
+ ok: false,
1399
+ error: `failed to parse plugin manifest: ${String(err)}`,
1400
+ manifestPath
1401
+ };
1402
+ }
1403
+ if (!isRecord(raw)) return {
1404
+ ok: false,
1405
+ error: "plugin manifest must be an object",
1406
+ manifestPath
1407
+ };
1408
+ const id = typeof raw.id === "string" ? raw.id.trim() : "";
1409
+ if (!id) return {
1410
+ ok: false,
1411
+ error: "plugin manifest requires id",
1412
+ manifestPath
1413
+ };
1414
+ const configSchema = isRecord(raw.configSchema) ? raw.configSchema : null;
1415
+ if (!configSchema) return {
1416
+ ok: false,
1417
+ error: "plugin manifest requires configSchema",
1418
+ manifestPath
1419
+ };
1420
+ const kind = typeof raw.kind === "string" ? raw.kind : void 0;
1421
+ const name = typeof raw.name === "string" ? raw.name.trim() : void 0;
1422
+ const description = typeof raw.description === "string" ? raw.description.trim() : void 0;
1423
+ const version = typeof raw.version === "string" ? raw.version.trim() : void 0;
1424
+ const channels = normalizeStringList(raw.channels);
1425
+ const providers = normalizeStringList(raw.providers);
1426
+ const skills = normalizeStringList(raw.skills);
1427
+ const stt = normalizeStringList(raw.stt);
1428
+ const tts = normalizeStringList(raw.tts);
1429
+ let uiHints;
1430
+ if (isRecord(raw.uiHints)) uiHints = raw.uiHints;
1431
+ return {
1432
+ ok: true,
1433
+ manifest: {
1434
+ id,
1435
+ configSchema,
1436
+ kind,
1437
+ channels,
1438
+ providers,
1439
+ skills,
1440
+ stt,
1441
+ tts,
1442
+ name,
1443
+ description,
1444
+ version,
1445
+ uiHints
1446
+ },
1447
+ manifestPath
1448
+ };
1449
+ }
1450
+ function getPackageManifestMetadata(manifest) {
1451
+ if (!manifest) return;
1452
+ return manifest[MANIFEST_KEY];
1453
+ }
1454
+
1455
+ //#endregion
1456
+ //#region src/plugins/path-safety.ts
1457
+ function isPathInside(baseDir, targetPath) {
1458
+ const rel = path.relative(baseDir, targetPath);
1459
+ if (!rel) return true;
1460
+ return !rel.startsWith("..") && !path.isAbsolute(rel);
1461
+ }
1462
+ function safeRealpathSync(targetPath, cache) {
1463
+ const cached = cache?.get(targetPath);
1464
+ if (cached) return cached;
1465
+ try {
1466
+ const resolved = fs.realpathSync(targetPath);
1467
+ cache?.set(targetPath, resolved);
1468
+ return resolved;
1469
+ } catch {
1470
+ return null;
1471
+ }
1472
+ }
1473
+ function safeStatSync(targetPath) {
1474
+ try {
1475
+ return fs.statSync(targetPath);
1476
+ } catch {
1477
+ return null;
1478
+ }
1479
+ }
1480
+ function formatPosixMode(mode) {
1481
+ return (mode & 511).toString(8).padStart(3, "0");
1482
+ }
1483
+
1484
+ //#endregion
1485
+ //#region src/plugins/discovery.ts
1486
+ const EXTENSION_EXTS = new Set([
1487
+ ".ts",
1488
+ ".js",
1489
+ ".mts",
1490
+ ".cts",
1491
+ ".mjs",
1492
+ ".cjs"
1493
+ ]);
1494
+ function currentUid(overrideUid) {
1495
+ if (overrideUid !== void 0) return overrideUid;
1496
+ if (process.platform === "win32") return null;
1497
+ if (typeof process.getuid !== "function") return null;
1498
+ return process.getuid();
1499
+ }
1500
+ function checkSourceEscapesRoot(params) {
1501
+ const sourceRealPath = safeRealpathSync(params.source);
1502
+ const rootRealPath = safeRealpathSync(params.rootDir);
1503
+ if (!sourceRealPath || !rootRealPath) return null;
1504
+ if (isPathInside(rootRealPath, sourceRealPath)) return null;
1505
+ return {
1506
+ reason: "source_escapes_root",
1507
+ sourcePath: params.source,
1508
+ rootPath: params.rootDir,
1509
+ targetPath: params.source,
1510
+ sourceRealPath,
1511
+ rootRealPath
1512
+ };
1513
+ }
1514
+ function checkPathStatAndPermissions(params) {
1515
+ if (process.platform === "win32") return null;
1516
+ const pathsToCheck = [params.rootDir, params.source];
1517
+ const seen = /* @__PURE__ */ new Set();
1518
+ for (const targetPath of pathsToCheck) {
1519
+ const normalized = path.resolve(targetPath);
1520
+ if (seen.has(normalized)) continue;
1521
+ seen.add(normalized);
1522
+ const stat = safeStatSync(targetPath);
1523
+ if (!stat) return {
1524
+ reason: "path_stat_failed",
1525
+ sourcePath: params.source,
1526
+ rootPath: params.rootDir,
1527
+ targetPath
1528
+ };
1529
+ const modeBits = stat.mode & 511;
1530
+ if ((modeBits & 2) !== 0) return {
1531
+ reason: "path_world_writable",
1532
+ sourcePath: params.source,
1533
+ rootPath: params.rootDir,
1534
+ targetPath,
1535
+ modeBits
1536
+ };
1537
+ if (params.origin !== "bundled" && params.uid !== null && typeof stat.uid === "number" && stat.uid !== params.uid && stat.uid !== 0) return {
1538
+ reason: "path_suspicious_ownership",
1539
+ sourcePath: params.source,
1540
+ rootPath: params.rootDir,
1541
+ targetPath,
1542
+ foundUid: stat.uid,
1543
+ expectedUid: params.uid
1544
+ };
1545
+ }
1546
+ return null;
1547
+ }
1548
+ function findCandidateBlockIssue(params) {
1549
+ const escaped = checkSourceEscapesRoot({
1550
+ source: params.source,
1551
+ rootDir: params.rootDir
1552
+ });
1553
+ if (escaped) return escaped;
1554
+ return checkPathStatAndPermissions({
1555
+ source: params.source,
1556
+ rootDir: params.rootDir,
1557
+ origin: params.origin,
1558
+ uid: currentUid(params.ownershipUid)
1559
+ });
1560
+ }
1561
+ function formatCandidateBlockMessage(issue) {
1562
+ if (issue.reason === "source_escapes_root") return `blocked plugin candidate: source escapes plugin root (${issue.sourcePath} -> ${issue.sourceRealPath}; root=${issue.rootRealPath})`;
1563
+ if (issue.reason === "path_stat_failed") return `blocked plugin candidate: cannot stat path (${issue.targetPath})`;
1564
+ if (issue.reason === "path_world_writable") return `blocked plugin candidate: world-writable path (${issue.targetPath}, mode=${formatPosixMode(issue.modeBits ?? 0)})`;
1565
+ return `blocked plugin candidate: suspicious ownership (${issue.targetPath}, uid=${issue.foundUid}, expected uid=${issue.expectedUid} or root)`;
1566
+ }
1567
+ function isUnsafePluginCandidate(params) {
1568
+ const issue = findCandidateBlockIssue({
1569
+ source: params.source,
1570
+ rootDir: params.rootDir,
1571
+ origin: params.origin,
1572
+ ownershipUid: params.ownershipUid
1573
+ });
1574
+ if (!issue) return false;
1575
+ params.diagnostics.push({
1576
+ level: "warn",
1577
+ source: issue.targetPath,
1578
+ message: formatCandidateBlockMessage(issue)
1579
+ });
1580
+ return true;
1581
+ }
1582
+ function isExtensionFile(filePath) {
1583
+ const ext = path.extname(filePath);
1584
+ if (!EXTENSION_EXTS.has(ext)) return false;
1585
+ return !filePath.endsWith(".d.ts");
1586
+ }
1587
+ function shouldIgnoreScannedDirectory(dirName) {
1588
+ const normalized = dirName.trim().toLowerCase();
1589
+ if (!normalized) return true;
1590
+ if (normalized.endsWith(".bak")) return true;
1591
+ if (normalized.includes(".backup-")) return true;
1592
+ if (normalized.includes(".disabled")) return true;
1593
+ return false;
1594
+ }
1595
+ function readPackageManifest(dir) {
1596
+ const manifestPath = path.join(dir, "package.json");
1597
+ if (!fs.existsSync(manifestPath)) return null;
1598
+ try {
1599
+ const raw = fs.readFileSync(manifestPath, "utf-8");
1600
+ return JSON.parse(raw);
1601
+ } catch {
1602
+ return null;
1603
+ }
1604
+ }
1605
+ function resolvePackageExtensions(manifest) {
1606
+ const raw = getPackageManifestMetadata(manifest)?.extensions;
1607
+ if (!Array.isArray(raw)) return [];
1608
+ return raw.map((entry) => typeof entry === "string" ? entry.trim() : "").filter(Boolean);
1609
+ }
1610
+ function deriveIdHint(params) {
1611
+ const base = path.basename(params.filePath, path.extname(params.filePath));
1612
+ const rawPackageName = params.packageName?.trim();
1613
+ if (!rawPackageName) return base;
1614
+ const unscoped = rawPackageName.includes("/") ? rawPackageName.split("/").pop() ?? rawPackageName : rawPackageName;
1615
+ if (!params.hasMultipleExtensions) return unscoped;
1616
+ return `${unscoped}/${base}`;
1617
+ }
1618
+ function addCandidate(params) {
1619
+ const resolved = path.resolve(params.source);
1620
+ if (params.seen.has(resolved)) return;
1621
+ const resolvedRoot = path.resolve(params.rootDir);
1622
+ if (isUnsafePluginCandidate({
1623
+ source: resolved,
1624
+ rootDir: resolvedRoot,
1625
+ origin: params.origin,
1626
+ diagnostics: params.diagnostics,
1627
+ ownershipUid: params.ownershipUid
1628
+ })) return;
1629
+ params.seen.add(resolved);
1630
+ const manifest = params.manifest ?? null;
1631
+ params.candidates.push({
1632
+ idHint: params.idHint,
1633
+ source: resolved,
1634
+ rootDir: resolvedRoot,
1635
+ origin: params.origin,
1636
+ workspaceDir: params.workspaceDir,
1637
+ packageName: manifest?.name?.trim() || void 0,
1638
+ packageVersion: manifest?.version?.trim() || void 0,
1639
+ packageDescription: manifest?.description?.trim() || void 0,
1640
+ packageDir: params.packageDir,
1641
+ packageManifest: getPackageManifestMetadata(manifest ?? void 0)
1642
+ });
1643
+ }
1644
+ function resolvePackageEntrySource(params) {
1645
+ const source = path.resolve(params.packageDir, params.entryPath);
1646
+ if (!isPathInsideWithRealpath(params.packageDir, source, { requireRealpath: true })) {
1647
+ params.diagnostics.push({
1648
+ level: "error",
1649
+ message: `extension entry escapes package directory: ${params.entryPath}`,
1650
+ source: params.sourceLabel
1651
+ });
1652
+ return null;
1653
+ }
1654
+ return source;
1655
+ }
1656
+ function discoverInDirectory(params) {
1657
+ if (!fs.existsSync(params.dir)) return;
1658
+ let entries = [];
1659
+ try {
1660
+ entries = fs.readdirSync(params.dir, { withFileTypes: true });
1661
+ } catch (err) {
1662
+ params.diagnostics.push({
1663
+ level: "warn",
1664
+ message: `failed to read extensions dir: ${params.dir} (${String(err)})`,
1665
+ source: params.dir
1666
+ });
1667
+ return;
1668
+ }
1669
+ for (const entry of entries) {
1670
+ const fullPath = path.join(params.dir, entry.name);
1671
+ if (entry.isFile()) {
1672
+ if (!isExtensionFile(fullPath)) continue;
1673
+ addCandidate({
1674
+ candidates: params.candidates,
1675
+ diagnostics: params.diagnostics,
1676
+ seen: params.seen,
1677
+ idHint: path.basename(entry.name, path.extname(entry.name)),
1678
+ source: fullPath,
1679
+ rootDir: path.dirname(fullPath),
1680
+ origin: params.origin,
1681
+ ownershipUid: params.ownershipUid,
1682
+ workspaceDir: params.workspaceDir
1683
+ });
1684
+ }
1685
+ if (!entry.isDirectory()) continue;
1686
+ if (shouldIgnoreScannedDirectory(entry.name)) continue;
1687
+ const manifest = readPackageManifest(fullPath);
1688
+ const extensions = manifest ? resolvePackageExtensions(manifest) : [];
1689
+ if (extensions.length > 0) {
1690
+ for (const extPath of extensions) {
1691
+ const resolved = resolvePackageEntrySource({
1692
+ packageDir: fullPath,
1693
+ entryPath: extPath,
1694
+ sourceLabel: fullPath,
1695
+ diagnostics: params.diagnostics
1696
+ });
1697
+ if (!resolved) continue;
1698
+ addCandidate({
1699
+ candidates: params.candidates,
1700
+ diagnostics: params.diagnostics,
1701
+ seen: params.seen,
1702
+ idHint: deriveIdHint({
1703
+ filePath: resolved,
1704
+ packageName: manifest?.name,
1705
+ hasMultipleExtensions: extensions.length > 1
1706
+ }),
1707
+ source: resolved,
1708
+ rootDir: fullPath,
1709
+ origin: params.origin,
1710
+ ownershipUid: params.ownershipUid,
1711
+ workspaceDir: params.workspaceDir,
1712
+ manifest,
1713
+ packageDir: fullPath
1714
+ });
1715
+ }
1716
+ continue;
1717
+ }
1718
+ const indexFile = [
1719
+ "index.ts",
1720
+ "index.js",
1721
+ "index.mjs",
1722
+ "index.cjs"
1723
+ ].map((candidate) => path.join(fullPath, candidate)).find((candidate) => fs.existsSync(candidate));
1724
+ if (indexFile && isExtensionFile(indexFile)) addCandidate({
1725
+ candidates: params.candidates,
1726
+ diagnostics: params.diagnostics,
1727
+ seen: params.seen,
1728
+ idHint: entry.name,
1729
+ source: indexFile,
1730
+ rootDir: fullPath,
1731
+ origin: params.origin,
1732
+ ownershipUid: params.ownershipUid,
1733
+ workspaceDir: params.workspaceDir,
1734
+ manifest,
1735
+ packageDir: fullPath
1736
+ });
1737
+ }
1738
+ }
1739
+ function discoverFromPath(params) {
1740
+ const resolved = resolveUserPath(params.rawPath);
1741
+ if (!fs.existsSync(resolved)) {
1742
+ params.diagnostics.push({
1743
+ level: "error",
1744
+ message: `plugin path not found: ${resolved}`,
1745
+ source: resolved
1746
+ });
1747
+ return;
1748
+ }
1749
+ const stat = fs.statSync(resolved);
1750
+ if (stat.isFile()) {
1751
+ if (!isExtensionFile(resolved)) {
1752
+ params.diagnostics.push({
1753
+ level: "error",
1754
+ message: `plugin path is not a supported file: ${resolved}`,
1755
+ source: resolved
1756
+ });
1757
+ return;
1758
+ }
1759
+ addCandidate({
1760
+ candidates: params.candidates,
1761
+ diagnostics: params.diagnostics,
1762
+ seen: params.seen,
1763
+ idHint: path.basename(resolved, path.extname(resolved)),
1764
+ source: resolved,
1765
+ rootDir: path.dirname(resolved),
1766
+ origin: params.origin,
1767
+ ownershipUid: params.ownershipUid,
1768
+ workspaceDir: params.workspaceDir
1769
+ });
1770
+ return;
1771
+ }
1772
+ if (stat.isDirectory()) {
1773
+ const manifest = readPackageManifest(resolved);
1774
+ const extensions = manifest ? resolvePackageExtensions(manifest) : [];
1775
+ if (extensions.length > 0) {
1776
+ for (const extPath of extensions) {
1777
+ const source = resolvePackageEntrySource({
1778
+ packageDir: resolved,
1779
+ entryPath: extPath,
1780
+ sourceLabel: resolved,
1781
+ diagnostics: params.diagnostics
1782
+ });
1783
+ if (!source) continue;
1784
+ addCandidate({
1785
+ candidates: params.candidates,
1786
+ diagnostics: params.diagnostics,
1787
+ seen: params.seen,
1788
+ idHint: deriveIdHint({
1789
+ filePath: source,
1790
+ packageName: manifest?.name,
1791
+ hasMultipleExtensions: extensions.length > 1
1792
+ }),
1793
+ source,
1794
+ rootDir: resolved,
1795
+ origin: params.origin,
1796
+ ownershipUid: params.ownershipUid,
1797
+ workspaceDir: params.workspaceDir,
1798
+ manifest,
1799
+ packageDir: resolved
1800
+ });
1801
+ }
1802
+ return;
1803
+ }
1804
+ const indexFile = [
1805
+ "index.ts",
1806
+ "index.js",
1807
+ "index.mjs",
1808
+ "index.cjs"
1809
+ ].map((candidate) => path.join(resolved, candidate)).find((candidate) => fs.existsSync(candidate));
1810
+ if (indexFile && isExtensionFile(indexFile)) {
1811
+ addCandidate({
1812
+ candidates: params.candidates,
1813
+ diagnostics: params.diagnostics,
1814
+ seen: params.seen,
1815
+ idHint: path.basename(resolved),
1816
+ source: indexFile,
1817
+ rootDir: resolved,
1818
+ origin: params.origin,
1819
+ ownershipUid: params.ownershipUid,
1820
+ workspaceDir: params.workspaceDir,
1821
+ manifest,
1822
+ packageDir: resolved
1823
+ });
1824
+ return;
1825
+ }
1826
+ discoverInDirectory({
1827
+ dir: resolved,
1828
+ origin: params.origin,
1829
+ ownershipUid: params.ownershipUid,
1830
+ workspaceDir: params.workspaceDir,
1831
+ candidates: params.candidates,
1832
+ diagnostics: params.diagnostics,
1833
+ seen: params.seen
1834
+ });
1835
+ return;
1836
+ }
1837
+ }
1838
+ function discoverRemoteClawPlugins(params) {
1839
+ const candidates = [];
1840
+ const diagnostics = [];
1841
+ const seen = /* @__PURE__ */ new Set();
1842
+ const workspaceDir = params.workspaceDir?.trim();
1843
+ const extra = params.extraPaths ?? [];
1844
+ for (const extraPath of extra) {
1845
+ if (typeof extraPath !== "string") continue;
1846
+ const trimmed = extraPath.trim();
1847
+ if (!trimmed) continue;
1848
+ discoverFromPath({
1849
+ rawPath: trimmed,
1850
+ origin: "config",
1851
+ ownershipUid: params.ownershipUid,
1852
+ workspaceDir: workspaceDir?.trim() || void 0,
1853
+ candidates,
1854
+ diagnostics,
1855
+ seen
1856
+ });
1857
+ }
1858
+ if (workspaceDir) {
1859
+ const workspaceRoot = resolveUserPath(workspaceDir);
1860
+ const workspaceExtDirs = [path.join(workspaceRoot, ".remoteclaw", "extensions")];
1861
+ for (const dir of workspaceExtDirs) discoverInDirectory({
1862
+ dir,
1863
+ origin: "workspace",
1864
+ ownershipUid: params.ownershipUid,
1865
+ workspaceDir: workspaceRoot,
1866
+ candidates,
1867
+ diagnostics,
1868
+ seen
1869
+ });
1870
+ }
1871
+ discoverInDirectory({
1872
+ dir: path.join(resolveConfigDir(), "extensions"),
1873
+ origin: "global",
1874
+ ownershipUid: params.ownershipUid,
1875
+ candidates,
1876
+ diagnostics,
1877
+ seen
1878
+ });
1879
+ const bundledDir = resolveBundledPluginsDir();
1880
+ if (bundledDir) discoverInDirectory({
1881
+ dir: bundledDir,
1882
+ origin: "bundled",
1883
+ ownershipUid: params.ownershipUid,
1884
+ candidates,
1885
+ diagnostics,
1886
+ seen
1887
+ });
1888
+ return {
1889
+ candidates,
1890
+ diagnostics
1891
+ };
1892
+ }
1893
+
1894
+ //#endregion
1895
+ //#region src/plugins/manifest-registry.ts
1896
+ const PLUGIN_ORIGIN_RANK = {
1897
+ config: 0,
1898
+ workspace: 1,
1899
+ global: 2,
1900
+ bundled: 3
1901
+ };
1902
+ const registryCache = /* @__PURE__ */ new Map();
1903
+ const DEFAULT_MANIFEST_CACHE_MS = 200;
1904
+ function clearPluginManifestRegistryCache() {
1905
+ registryCache.clear();
1906
+ }
1907
+ function resolveManifestCacheMs(env) {
1908
+ const raw = env.REMOTECLAW_PLUGIN_MANIFEST_CACHE_MS?.trim();
1909
+ if (raw === "" || raw === "0") return 0;
1910
+ if (!raw) return DEFAULT_MANIFEST_CACHE_MS;
1911
+ const parsed = Number.parseInt(raw, 10);
1912
+ if (!Number.isFinite(parsed)) return DEFAULT_MANIFEST_CACHE_MS;
1913
+ return Math.max(0, parsed);
1914
+ }
1915
+ function shouldUseManifestCache(env) {
1916
+ if (env.REMOTECLAW_DISABLE_PLUGIN_MANIFEST_CACHE?.trim()) return false;
1917
+ return resolveManifestCacheMs(env) > 0;
1918
+ }
1919
+ function buildCacheKey(params) {
1920
+ const workspaceKey = params.workspaceDir ? resolveUserPath(params.workspaceDir) : "";
1921
+ const loadPaths = params.plugins.loadPaths.map((p) => resolveUserPath(p)).map((p) => p.trim()).filter(Boolean).toSorted();
1922
+ return `${workspaceKey}::${JSON.stringify(loadPaths)}`;
1923
+ }
1924
+ function safeStatMtimeMs(filePath) {
1925
+ try {
1926
+ return fs.statSync(filePath).mtimeMs;
1927
+ } catch {
1928
+ return null;
1929
+ }
1930
+ }
1931
+ function normalizeManifestLabel(raw) {
1932
+ const trimmed = raw?.trim();
1933
+ return trimmed ? trimmed : void 0;
1934
+ }
1935
+ function buildRecord(params) {
1936
+ return {
1937
+ id: params.manifest.id,
1938
+ name: normalizeManifestLabel(params.manifest.name) ?? params.candidate.packageName,
1939
+ description: normalizeManifestLabel(params.manifest.description) ?? params.candidate.packageDescription,
1940
+ version: normalizeManifestLabel(params.manifest.version) ?? params.candidate.packageVersion,
1941
+ kind: params.manifest.kind,
1942
+ channels: params.manifest.channels ?? [],
1943
+ providers: params.manifest.providers ?? [],
1944
+ skills: params.manifest.skills ?? [],
1945
+ stt: params.manifest.stt ?? [],
1946
+ tts: params.manifest.tts ?? [],
1947
+ origin: params.candidate.origin,
1948
+ workspaceDir: params.candidate.workspaceDir,
1949
+ rootDir: params.candidate.rootDir,
1950
+ source: params.candidate.source,
1951
+ manifestPath: params.manifestPath,
1952
+ schemaCacheKey: params.schemaCacheKey,
1953
+ configSchema: params.configSchema,
1954
+ configUiHints: params.manifest.uiHints
1955
+ };
1956
+ }
1957
+ function loadPluginManifestRegistry(params) {
1958
+ const normalized = normalizePluginsConfig((params.config ?? {}).plugins);
1959
+ const cacheKey = buildCacheKey({
1960
+ workspaceDir: params.workspaceDir,
1961
+ plugins: normalized
1962
+ });
1963
+ const env = params.env ?? process.env;
1964
+ const cacheEnabled = params.cache !== false && shouldUseManifestCache(env);
1965
+ if (cacheEnabled) {
1966
+ const cached = registryCache.get(cacheKey);
1967
+ if (cached && cached.expiresAt > Date.now()) return cached.registry;
1968
+ }
1969
+ const discovery = params.candidates ? {
1970
+ candidates: params.candidates,
1971
+ diagnostics: params.diagnostics ?? []
1972
+ } : discoverRemoteClawPlugins({
1973
+ workspaceDir: params.workspaceDir,
1974
+ extraPaths: normalized.loadPaths
1975
+ });
1976
+ const diagnostics = [...discovery.diagnostics];
1977
+ const candidates = discovery.candidates;
1978
+ const records = [];
1979
+ const seenIds = /* @__PURE__ */ new Map();
1980
+ const realpathCache = /* @__PURE__ */ new Map();
1981
+ for (const candidate of candidates) {
1982
+ const manifestRes = loadPluginManifest(candidate.rootDir);
1983
+ if (!manifestRes.ok) {
1984
+ diagnostics.push({
1985
+ level: "error",
1986
+ message: manifestRes.error,
1987
+ source: manifestRes.manifestPath
1988
+ });
1989
+ continue;
1990
+ }
1991
+ const manifest = manifestRes.manifest;
1992
+ if (candidate.idHint && candidate.idHint !== manifest.id) diagnostics.push({
1993
+ level: "warn",
1994
+ pluginId: manifest.id,
1995
+ source: candidate.source,
1996
+ message: `plugin id mismatch (manifest uses "${manifest.id}", entry hints "${candidate.idHint}")`
1997
+ });
1998
+ const configSchema = manifest.configSchema;
1999
+ const manifestMtime = safeStatMtimeMs(manifestRes.manifestPath);
2000
+ const schemaCacheKey = manifestMtime ? `${manifestRes.manifestPath}:${manifestMtime}` : manifestRes.manifestPath;
2001
+ const existing = seenIds.get(manifest.id);
2002
+ if (existing) {
2003
+ const existingReal = safeRealpathSync(existing.candidate.rootDir, realpathCache);
2004
+ const candidateReal = safeRealpathSync(candidate.rootDir, realpathCache);
2005
+ if (Boolean(existingReal && candidateReal && existingReal === candidateReal)) {
2006
+ if (PLUGIN_ORIGIN_RANK[candidate.origin] < PLUGIN_ORIGIN_RANK[existing.candidate.origin]) {
2007
+ records[existing.recordIndex] = buildRecord({
2008
+ manifest,
2009
+ candidate,
2010
+ manifestPath: manifestRes.manifestPath,
2011
+ schemaCacheKey,
2012
+ configSchema
2013
+ });
2014
+ seenIds.set(manifest.id, {
2015
+ candidate,
2016
+ recordIndex: existing.recordIndex
2017
+ });
2018
+ }
2019
+ continue;
2020
+ }
2021
+ diagnostics.push({
2022
+ level: "warn",
2023
+ pluginId: manifest.id,
2024
+ source: candidate.source,
2025
+ message: `duplicate plugin id detected; later plugin may be overridden (${candidate.source})`
2026
+ });
2027
+ } else seenIds.set(manifest.id, {
2028
+ candidate,
2029
+ recordIndex: records.length
2030
+ });
2031
+ records.push(buildRecord({
2032
+ manifest,
2033
+ candidate,
2034
+ manifestPath: manifestRes.manifestPath,
2035
+ schemaCacheKey,
2036
+ configSchema
2037
+ }));
2038
+ }
2039
+ const registry = {
2040
+ plugins: records,
2041
+ diagnostics
2042
+ };
2043
+ if (cacheEnabled) {
2044
+ const ttl = resolveManifestCacheMs(env);
2045
+ if (ttl > 0) registryCache.set(cacheKey, {
2046
+ expiresAt: Date.now() + ttl,
2047
+ registry
2048
+ });
2049
+ }
2050
+ return registry;
2051
+ }
2052
+
2053
+ //#endregion
2054
+ //#region src/plugins/schema-validator.ts
2055
+ const ajv = new AjvPkg({
2056
+ allErrors: true,
2057
+ strict: false,
2058
+ removeAdditional: false
2059
+ });
2060
+ const schemaCache = /* @__PURE__ */ new Map();
2061
+ function formatAjvErrors(errors) {
2062
+ if (!errors || errors.length === 0) return ["invalid config"];
2063
+ return errors.map((error) => {
2064
+ return `${error.instancePath?.replace(/^\//, "").replace(/\//g, ".") || "<root>"}: ${error.message ?? "invalid"}`;
2065
+ });
2066
+ }
2067
+ function validateJsonSchemaValue(params) {
2068
+ let cached = schemaCache.get(params.cacheKey);
2069
+ if (!cached || cached.schema !== params.schema) {
2070
+ cached = {
2071
+ validate: ajv.compile(params.schema),
2072
+ schema: params.schema
2073
+ };
2074
+ schemaCache.set(params.cacheKey, cached);
2075
+ }
2076
+ if (cached.validate(params.value)) return { ok: true };
2077
+ return {
2078
+ ok: false,
2079
+ errors: formatAjvErrors(cached.validate.errors)
2080
+ };
2081
+ }
2082
+
2083
+ //#endregion
2084
+ //#region src/shared/avatar-policy.ts
2085
+ const AVATAR_MAX_BYTES = 2 * 1024 * 1024;
2086
+ const LOCAL_AVATAR_EXTENSIONS = new Set([
2087
+ ".png",
2088
+ ".jpg",
2089
+ ".jpeg",
2090
+ ".gif",
2091
+ ".webp",
2092
+ ".svg"
2093
+ ]);
2094
+ const AVATAR_MIME_BY_EXT = {
2095
+ ".png": "image/png",
2096
+ ".jpg": "image/jpeg",
2097
+ ".jpeg": "image/jpeg",
2098
+ ".webp": "image/webp",
2099
+ ".gif": "image/gif",
2100
+ ".svg": "image/svg+xml",
2101
+ ".bmp": "image/bmp",
2102
+ ".tif": "image/tiff",
2103
+ ".tiff": "image/tiff"
2104
+ };
2105
+ const AVATAR_DATA_RE = /^data:/i;
2106
+ const AVATAR_IMAGE_DATA_RE = /^data:image\//i;
2107
+ const AVATAR_HTTP_RE = /^https?:\/\//i;
2108
+ const AVATAR_SCHEME_RE = /^[a-z][a-z0-9+.-]*:/i;
2109
+ const WINDOWS_ABS_RE = /^[a-zA-Z]:[\\/]/;
2110
+ const AVATAR_PATH_EXT_RE = /\.(png|jpe?g|gif|webp|svg|ico)$/i;
2111
+ function resolveAvatarMime(filePath) {
2112
+ return AVATAR_MIME_BY_EXT[path.extname(filePath).toLowerCase()] ?? "application/octet-stream";
2113
+ }
2114
+ function isAvatarDataUrl(value) {
2115
+ return AVATAR_DATA_RE.test(value);
2116
+ }
2117
+ function isAvatarImageDataUrl(value) {
2118
+ return AVATAR_IMAGE_DATA_RE.test(value);
2119
+ }
2120
+ function isAvatarHttpUrl(value) {
2121
+ return AVATAR_HTTP_RE.test(value);
2122
+ }
2123
+ function hasAvatarUriScheme(value) {
2124
+ return AVATAR_SCHEME_RE.test(value);
2125
+ }
2126
+ function isWindowsAbsolutePath(value) {
2127
+ return WINDOWS_ABS_RE.test(value);
2128
+ }
2129
+ function isWorkspaceRelativeAvatarPath(value) {
2130
+ if (!value) return false;
2131
+ if (value.startsWith("~")) return false;
2132
+ if (hasAvatarUriScheme(value) && !isWindowsAbsolutePath(value)) return false;
2133
+ return true;
2134
+ }
2135
+ function isPathWithinRoot(rootDir, targetPath) {
2136
+ const relative = path.relative(rootDir, targetPath);
2137
+ if (relative === "") return true;
2138
+ return !relative.startsWith("..") && !path.isAbsolute(relative);
2139
+ }
2140
+ function looksLikeAvatarPath(value) {
2141
+ if (/[\\/]/.test(value)) return true;
2142
+ return AVATAR_PATH_EXT_RE.test(value);
2143
+ }
2144
+ function isSupportedLocalAvatarExtension(filePath) {
2145
+ const ext = path.extname(filePath).toLowerCase();
2146
+ return LOCAL_AVATAR_EXTENSIONS.has(ext);
2147
+ }
2148
+
2149
+ //#endregion
2150
+ //#region src/config/validation.ts
2151
+ const LEGACY_REMOVED_PLUGIN_IDS = new Set(["google-antigravity-auth"]);
2152
+ function isWorkspaceAvatarPath(value, workspaceDir) {
2153
+ const workspaceRoot = path.resolve(workspaceDir);
2154
+ return isPathWithinRoot(workspaceRoot, path.resolve(workspaceRoot, value));
2155
+ }
2156
+ function validateIdentityAvatar(config) {
2157
+ const agents = config.agents?.list;
2158
+ if (!Array.isArray(agents) || agents.length === 0) return [];
2159
+ const issues = [];
2160
+ for (const [index, entry] of agents.entries()) {
2161
+ if (!entry || typeof entry !== "object") continue;
2162
+ const avatarRaw = entry.identity?.avatar;
2163
+ if (typeof avatarRaw !== "string") continue;
2164
+ const avatar = avatarRaw.trim();
2165
+ if (!avatar) continue;
2166
+ if (isAvatarDataUrl(avatar) || isAvatarHttpUrl(avatar)) continue;
2167
+ if (avatar.startsWith("~")) {
2168
+ issues.push({
2169
+ path: `agents.list.${index}.identity.avatar`,
2170
+ message: "identity.avatar must be a workspace-relative path, http(s) URL, or data URI."
2171
+ });
2172
+ continue;
2173
+ }
2174
+ if (hasAvatarUriScheme(avatar) && !isWindowsAbsolutePath(avatar)) {
2175
+ issues.push({
2176
+ path: `agents.list.${index}.identity.avatar`,
2177
+ message: "identity.avatar must be a workspace-relative path, http(s) URL, or data URI."
2178
+ });
2179
+ continue;
2180
+ }
2181
+ const workspaceDir = resolveAgentWorkspaceDirOrNull(config, entry.id ?? resolveDefaultAgentId(config));
2182
+ if (workspaceDir != null && !isWorkspaceAvatarPath(avatar, workspaceDir)) issues.push({
2183
+ path: `agents.list.${index}.identity.avatar`,
2184
+ message: "identity.avatar must stay within the agent workspace."
2185
+ });
2186
+ }
2187
+ return issues;
2188
+ }
2189
+ /**
2190
+ * Validates config without applying runtime defaults.
2191
+ * Use this when you need the raw validated config (e.g., for writing back to file).
2192
+ */
2193
+ function validateConfigObjectRaw(raw) {
2194
+ const legacyIssues = findLegacyConfigIssues(raw);
2195
+ if (legacyIssues.length > 0) return {
2196
+ ok: false,
2197
+ issues: legacyIssues.map((iss) => ({
2198
+ path: iss.path,
2199
+ message: iss.message
2200
+ }))
2201
+ };
2202
+ const validated = RemoteClawSchema.safeParse(raw);
2203
+ if (!validated.success) return {
2204
+ ok: false,
2205
+ issues: validated.error.issues.map((iss) => ({
2206
+ path: iss.path.join("."),
2207
+ message: iss.message
2208
+ }))
2209
+ };
2210
+ const duplicates = findDuplicateAgentDirs(validated.data);
2211
+ if (duplicates.length > 0) return {
2212
+ ok: false,
2213
+ issues: [{
2214
+ path: "agents.list",
2215
+ message: formatDuplicateAgentDirError(duplicates)
2216
+ }]
2217
+ };
2218
+ const avatarIssues = validateIdentityAvatar(validated.data);
2219
+ if (avatarIssues.length > 0) return {
2220
+ ok: false,
2221
+ issues: avatarIssues
2222
+ };
2223
+ return {
2224
+ ok: true,
2225
+ config: validated.data
2226
+ };
2227
+ }
2228
+ function validateConfigObject(raw) {
2229
+ const result = validateConfigObjectRaw(raw);
2230
+ if (!result.ok) return result;
2231
+ return {
2232
+ ok: true,
2233
+ config: applyModelDefaults(applyAgentDefaults(applySessionDefaults(result.config)))
2234
+ };
2235
+ }
2236
+ function validateConfigObjectWithPlugins(raw) {
2237
+ return validateConfigObjectWithPluginsBase(raw, { applyDefaults: true });
2238
+ }
2239
+ function validateConfigObjectRawWithPlugins(raw) {
2240
+ return validateConfigObjectWithPluginsBase(raw, { applyDefaults: false });
2241
+ }
2242
+ function validateConfigObjectWithPluginsBase(raw, opts) {
2243
+ const base = opts.applyDefaults ? validateConfigObject(raw) : validateConfigObjectRaw(raw);
2244
+ if (!base.ok) return {
2245
+ ok: false,
2246
+ issues: base.issues,
2247
+ warnings: []
2248
+ };
2249
+ const config = base.config;
2250
+ const issues = [];
2251
+ const warnings = [];
2252
+ const hasExplicitPluginsConfig = isRecord(raw) && Object.prototype.hasOwnProperty.call(raw, "plugins");
2253
+ let registryInfo = null;
2254
+ const ensureRegistry = () => {
2255
+ if (registryInfo) return registryInfo;
2256
+ const registry = loadPluginManifestRegistry({
2257
+ config,
2258
+ workspaceDir: resolveAgentWorkspaceDirOrNull(config, resolveDefaultAgentId(config)) ?? void 0
2259
+ });
2260
+ const knownIds = new Set(registry.plugins.map((record) => record.id));
2261
+ const normalizedPlugins = normalizePluginsConfig(config.plugins);
2262
+ for (const diag of registry.diagnostics) {
2263
+ let path = diag.pluginId ? `plugins.entries.${diag.pluginId}` : "plugins";
2264
+ if (!diag.pluginId && diag.message.includes("plugin path not found")) path = "plugins.load.paths";
2265
+ const message = `${diag.pluginId ? `plugin ${diag.pluginId}` : "plugin"}: ${diag.message}`;
2266
+ if (diag.level === "error") issues.push({
2267
+ path,
2268
+ message
2269
+ });
2270
+ else warnings.push({
2271
+ path,
2272
+ message
2273
+ });
2274
+ }
2275
+ registryInfo = {
2276
+ registry,
2277
+ knownIds,
2278
+ normalizedPlugins
2279
+ };
2280
+ return registryInfo;
2281
+ };
2282
+ const allowedChannels = new Set([
2283
+ "defaults",
2284
+ "modelByChannel",
2285
+ ...CHANNEL_IDS
2286
+ ]);
2287
+ if (config.channels && isRecord(config.channels)) for (const key of Object.keys(config.channels)) {
2288
+ const trimmed = key.trim();
2289
+ if (!trimmed) continue;
2290
+ if (!allowedChannels.has(trimmed)) {
2291
+ const { registry } = ensureRegistry();
2292
+ for (const record of registry.plugins) for (const channelId of record.channels) allowedChannels.add(channelId);
2293
+ }
2294
+ if (!allowedChannels.has(trimmed)) issues.push({
2295
+ path: `channels.${trimmed}`,
2296
+ message: `unknown channel id: ${trimmed}`
2297
+ });
2298
+ }
2299
+ const heartbeatChannelIds = /* @__PURE__ */ new Set();
2300
+ for (const channelId of CHANNEL_IDS) heartbeatChannelIds.add(channelId.toLowerCase());
2301
+ const validateHeartbeatTarget = (target, path) => {
2302
+ if (typeof target !== "string") return;
2303
+ const trimmed = target.trim();
2304
+ if (!trimmed) {
2305
+ issues.push({
2306
+ path,
2307
+ message: "heartbeat target must not be empty"
2308
+ });
2309
+ return;
2310
+ }
2311
+ const normalized = trimmed.toLowerCase();
2312
+ if (normalized === "last" || normalized === "none") return;
2313
+ if (normalizeChatChannelId(trimmed)) return;
2314
+ if (!heartbeatChannelIds.has(normalized)) {
2315
+ const { registry } = ensureRegistry();
2316
+ for (const record of registry.plugins) for (const channelId of record.channels) {
2317
+ const pluginChannel = channelId.trim();
2318
+ if (pluginChannel) heartbeatChannelIds.add(pluginChannel.toLowerCase());
2319
+ }
2320
+ }
2321
+ if (heartbeatChannelIds.has(normalized)) return;
2322
+ issues.push({
2323
+ path,
2324
+ message: `unknown heartbeat target: ${target}`
2325
+ });
2326
+ };
2327
+ validateHeartbeatTarget(config.agents?.defaults?.heartbeat?.target, "agents.defaults.heartbeat.target");
2328
+ if (Array.isArray(config.agents?.list)) for (const [index, entry] of config.agents.list.entries()) validateHeartbeatTarget(entry?.heartbeat?.target, `agents.list.${index}.heartbeat.target`);
2329
+ if (!hasExplicitPluginsConfig) {
2330
+ if (issues.length > 0) return {
2331
+ ok: false,
2332
+ issues,
2333
+ warnings
2334
+ };
2335
+ return {
2336
+ ok: true,
2337
+ config,
2338
+ warnings
2339
+ };
2340
+ }
2341
+ const { registry, knownIds, normalizedPlugins } = ensureRegistry();
2342
+ const pushMissingPluginIssue = (path, pluginId) => {
2343
+ if (LEGACY_REMOVED_PLUGIN_IDS.has(pluginId)) {
2344
+ warnings.push({
2345
+ path,
2346
+ message: `plugin removed: ${pluginId} (stale config entry ignored; remove it from plugins config)`
2347
+ });
2348
+ return;
2349
+ }
2350
+ issues.push({
2351
+ path,
2352
+ message: `plugin not found: ${pluginId}`
2353
+ });
2354
+ };
2355
+ const pluginsConfig = config.plugins;
2356
+ const entries = pluginsConfig?.entries;
2357
+ if (entries && isRecord(entries)) {
2358
+ for (const pluginId of Object.keys(entries)) if (!knownIds.has(pluginId)) pushMissingPluginIssue(`plugins.entries.${pluginId}`, pluginId);
2359
+ }
2360
+ const allow = pluginsConfig?.allow ?? [];
2361
+ for (const pluginId of allow) {
2362
+ if (typeof pluginId !== "string" || !pluginId.trim()) continue;
2363
+ if (!knownIds.has(pluginId)) pushMissingPluginIssue("plugins.allow", pluginId);
2364
+ }
2365
+ const deny = pluginsConfig?.deny ?? [];
2366
+ for (const pluginId of deny) {
2367
+ if (typeof pluginId !== "string" || !pluginId.trim()) continue;
2368
+ if (!knownIds.has(pluginId)) pushMissingPluginIssue("plugins.deny", pluginId);
2369
+ }
2370
+ const seenPlugins = /* @__PURE__ */ new Set();
2371
+ for (const record of registry.plugins) {
2372
+ const pluginId = record.id;
2373
+ if (seenPlugins.has(pluginId)) continue;
2374
+ seenPlugins.add(pluginId);
2375
+ const entry = normalizedPlugins.entries[pluginId];
2376
+ const entryHasConfig = Boolean(entry?.config);
2377
+ const enableState = resolveEffectiveEnableState({
2378
+ id: pluginId,
2379
+ origin: record.origin,
2380
+ config: normalizedPlugins,
2381
+ rootConfig: config
2382
+ });
2383
+ let enabled = enableState.enabled;
2384
+ let reason = enableState.reason;
2385
+ if (enabled || entryHasConfig) if (record.configSchema) {
2386
+ const res = validateJsonSchemaValue({
2387
+ schema: record.configSchema,
2388
+ cacheKey: record.schemaCacheKey ?? record.manifestPath ?? pluginId,
2389
+ value: entry?.config ?? {}
2390
+ });
2391
+ if (!res.ok) for (const error of res.errors) issues.push({
2392
+ path: `plugins.entries.${pluginId}.config`,
2393
+ message: `invalid config: ${error}`
2394
+ });
2395
+ } else issues.push({
2396
+ path: `plugins.entries.${pluginId}`,
2397
+ message: `plugin schema missing for ${pluginId}`
2398
+ });
2399
+ if (!enabled && entryHasConfig) warnings.push({
2400
+ path: `plugins.entries.${pluginId}`,
2401
+ message: `plugin disabled (${reason ?? "disabled"}) but config is present`
2402
+ });
2403
+ }
2404
+ if (issues.length > 0) return {
2405
+ ok: false,
2406
+ issues,
2407
+ warnings
2408
+ };
2409
+ return {
2410
+ ok: true,
2411
+ config,
2412
+ warnings
2413
+ };
2414
+ }
2415
+
2416
+ //#endregion
2417
+ //#region src/config/version.ts
2418
+ const VERSION_RE = /^v?(\d+)\.(\d+)\.(\d+)(?:-(\d+))?/;
2419
+ function parseRemoteClawVersion(raw) {
2420
+ if (!raw) return null;
2421
+ const match = raw.trim().match(VERSION_RE);
2422
+ if (!match) return null;
2423
+ const [, major, minor, patch, revision] = match;
2424
+ return {
2425
+ major: Number.parseInt(major, 10),
2426
+ minor: Number.parseInt(minor, 10),
2427
+ patch: Number.parseInt(patch, 10),
2428
+ revision: revision ? Number.parseInt(revision, 10) : 0
2429
+ };
2430
+ }
2431
+ function compareRemoteClawVersions(a, b) {
2432
+ const parsedA = parseRemoteClawVersion(a);
2433
+ const parsedB = parseRemoteClawVersion(b);
2434
+ if (!parsedA || !parsedB) return null;
2435
+ if (parsedA.major !== parsedB.major) return parsedA.major < parsedB.major ? -1 : 1;
2436
+ if (parsedA.minor !== parsedB.minor) return parsedA.minor < parsedB.minor ? -1 : 1;
2437
+ if (parsedA.patch !== parsedB.patch) return parsedA.patch < parsedB.patch ? -1 : 1;
2438
+ if (parsedA.revision !== parsedB.revision) return parsedA.revision < parsedB.revision ? -1 : 1;
2439
+ return 0;
2440
+ }
2441
+
2442
+ //#endregion
2443
+ //#region src/config/io.ts
2444
+ const SHELL_ENV_EXPECTED_KEYS = [
2445
+ "OPENAI_API_KEY",
2446
+ "ANTHROPIC_API_KEY",
2447
+ "ANTHROPIC_OAUTH_TOKEN",
2448
+ "GEMINI_API_KEY",
2449
+ "ZAI_API_KEY",
2450
+ "OPENROUTER_API_KEY",
2451
+ "AI_GATEWAY_API_KEY",
2452
+ "MINIMAX_API_KEY",
2453
+ "SYNTHETIC_API_KEY",
2454
+ "KILOCODE_API_KEY",
2455
+ "ELEVENLABS_API_KEY",
2456
+ "TELEGRAM_BOT_TOKEN",
2457
+ "DISCORD_BOT_TOKEN",
2458
+ "SLACK_BOT_TOKEN",
2459
+ "SLACK_APP_TOKEN",
2460
+ "REMOTECLAW_GATEWAY_TOKEN",
2461
+ "REMOTECLAW_GATEWAY_PASSWORD"
2462
+ ];
2463
+ const OPEN_DM_POLICY_ALLOW_FROM_RE = /^(?<policyPath>[a-z0-9_.-]+)\s*=\s*"open"\s+requires\s+(?<allowPath>[a-z0-9_.-]+)(?:\s+\(or\s+[a-z0-9_.-]+\))?\s+to include "\*"$/i;
2464
+ const CONFIG_AUDIT_LOG_FILENAME = "config-audit.jsonl";
2465
+ const loggedInvalidConfigs = /* @__PURE__ */ new Set();
2466
+ function hashConfigRaw(raw) {
2467
+ return crypto.createHash("sha256").update(raw ?? "").digest("hex");
2468
+ }
2469
+ function formatConfigValidationFailure(pathLabel, issueMessage) {
2470
+ const match = issueMessage.match(OPEN_DM_POLICY_ALLOW_FROM_RE);
2471
+ const policyPath = match?.groups?.policyPath?.trim();
2472
+ const allowPath = match?.groups?.allowPath?.trim();
2473
+ if (!policyPath || !allowPath) return `Config validation failed: ${pathLabel}: ${issueMessage}`;
2474
+ return [
2475
+ `Config validation failed: ${pathLabel}`,
2476
+ "",
2477
+ `Configuration mismatch: ${policyPath} is "open", but ${allowPath} does not include "*".`,
2478
+ "",
2479
+ "Fix with:",
2480
+ ` remoteclaw config set ${allowPath} '["*"]'`,
2481
+ "",
2482
+ "Or switch policy:",
2483
+ ` remoteclaw config set ${policyPath} "pairing"`
2484
+ ].join("\n");
2485
+ }
2486
+ function isNumericPathSegment(raw) {
2487
+ return /^[0-9]+$/.test(raw);
2488
+ }
2489
+ function isWritePlainObject(value) {
2490
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
2491
+ }
2492
+ function hasOwnObjectKey(value, key) {
2493
+ return Object.prototype.hasOwnProperty.call(value, key);
2494
+ }
2495
+ const WRITE_PRUNED_OBJECT = Symbol("write-pruned-object");
2496
+ function unsetPathForWriteAt(value, pathSegments, depth) {
2497
+ if (depth >= pathSegments.length) return {
2498
+ changed: false,
2499
+ value
2500
+ };
2501
+ const segment = pathSegments[depth];
2502
+ const isLeaf = depth === pathSegments.length - 1;
2503
+ if (Array.isArray(value)) {
2504
+ if (!isNumericPathSegment(segment)) return {
2505
+ changed: false,
2506
+ value
2507
+ };
2508
+ const index = Number.parseInt(segment, 10);
2509
+ if (!Number.isFinite(index) || index < 0 || index >= value.length) return {
2510
+ changed: false,
2511
+ value
2512
+ };
2513
+ if (isLeaf) {
2514
+ const next = value.slice();
2515
+ next.splice(index, 1);
2516
+ return {
2517
+ changed: true,
2518
+ value: next
2519
+ };
2520
+ }
2521
+ const child = unsetPathForWriteAt(value[index], pathSegments, depth + 1);
2522
+ if (!child.changed) return {
2523
+ changed: false,
2524
+ value
2525
+ };
2526
+ const next = value.slice();
2527
+ if (child.value === WRITE_PRUNED_OBJECT) next.splice(index, 1);
2528
+ else next[index] = child.value;
2529
+ return {
2530
+ changed: true,
2531
+ value: next
2532
+ };
2533
+ }
2534
+ if (isBlockedObjectKey(segment) || !isWritePlainObject(value) || !hasOwnObjectKey(value, segment)) return {
2535
+ changed: false,
2536
+ value
2537
+ };
2538
+ if (isLeaf) {
2539
+ const next = { ...value };
2540
+ delete next[segment];
2541
+ return {
2542
+ changed: true,
2543
+ value: Object.keys(next).length === 0 ? WRITE_PRUNED_OBJECT : next
2544
+ };
2545
+ }
2546
+ const child = unsetPathForWriteAt(value[segment], pathSegments, depth + 1);
2547
+ if (!child.changed) return {
2548
+ changed: false,
2549
+ value
2550
+ };
2551
+ const next = { ...value };
2552
+ if (child.value === WRITE_PRUNED_OBJECT) delete next[segment];
2553
+ else next[segment] = child.value;
2554
+ return {
2555
+ changed: true,
2556
+ value: Object.keys(next).length === 0 ? WRITE_PRUNED_OBJECT : next
2557
+ };
2558
+ }
2559
+ function unsetPathForWrite(root, pathSegments) {
2560
+ if (pathSegments.length === 0) return {
2561
+ changed: false,
2562
+ next: root
2563
+ };
2564
+ const result = unsetPathForWriteAt(root, pathSegments, 0);
2565
+ if (!result.changed) return {
2566
+ changed: false,
2567
+ next: root
2568
+ };
2569
+ if (result.value === WRITE_PRUNED_OBJECT) return {
2570
+ changed: true,
2571
+ next: {}
2572
+ };
2573
+ if (isWritePlainObject(result.value)) return {
2574
+ changed: true,
2575
+ next: coerceConfig(result.value)
2576
+ };
2577
+ return {
2578
+ changed: false,
2579
+ next: root
2580
+ };
2581
+ }
2582
+ function resolveConfigSnapshotHash(snapshot) {
2583
+ if (typeof snapshot.hash === "string") {
2584
+ const trimmed = snapshot.hash.trim();
2585
+ if (trimmed) return trimmed;
2586
+ }
2587
+ if (typeof snapshot.raw !== "string") return null;
2588
+ return hashConfigRaw(snapshot.raw);
2589
+ }
2590
+ function coerceConfig(value) {
2591
+ if (!value || typeof value !== "object" || Array.isArray(value)) return {};
2592
+ return value;
2593
+ }
2594
+ function isPlainObject(value) {
2595
+ return typeof value === "object" && value !== null && !Array.isArray(value);
2596
+ }
2597
+ function hasConfigMeta(value) {
2598
+ if (!isPlainObject(value)) return false;
2599
+ const meta = value.meta;
2600
+ return isPlainObject(meta);
2601
+ }
2602
+ function resolveGatewayMode(value) {
2603
+ if (!isPlainObject(value)) return null;
2604
+ const gateway = value.gateway;
2605
+ if (!isPlainObject(gateway) || typeof gateway.mode !== "string") return null;
2606
+ const trimmed = gateway.mode.trim();
2607
+ return trimmed.length > 0 ? trimmed : null;
2608
+ }
2609
+ function cloneUnknown(value) {
2610
+ return structuredClone(value);
2611
+ }
2612
+ function createMergePatch(base, target) {
2613
+ if (!isPlainObject(base) || !isPlainObject(target)) return cloneUnknown(target);
2614
+ const patch = {};
2615
+ const keys = new Set([...Object.keys(base), ...Object.keys(target)]);
2616
+ for (const key of keys) {
2617
+ const hasBase = key in base;
2618
+ if (!(key in target)) {
2619
+ patch[key] = null;
2620
+ continue;
2621
+ }
2622
+ const targetValue = target[key];
2623
+ if (!hasBase) {
2624
+ patch[key] = cloneUnknown(targetValue);
2625
+ continue;
2626
+ }
2627
+ const baseValue = base[key];
2628
+ if (isPlainObject(baseValue) && isPlainObject(targetValue)) {
2629
+ const childPatch = createMergePatch(baseValue, targetValue);
2630
+ if (isPlainObject(childPatch) && Object.keys(childPatch).length === 0) continue;
2631
+ patch[key] = childPatch;
2632
+ continue;
2633
+ }
2634
+ if (!isDeepStrictEqual(baseValue, targetValue)) patch[key] = cloneUnknown(targetValue);
2635
+ }
2636
+ return patch;
2637
+ }
2638
+ function collectEnvRefPaths(value, path, output) {
2639
+ if (typeof value === "string") {
2640
+ if (containsEnvVarReference(value)) output.set(path, value);
2641
+ return;
2642
+ }
2643
+ if (Array.isArray(value)) {
2644
+ value.forEach((item, index) => {
2645
+ collectEnvRefPaths(item, `${path}[${index}]`, output);
2646
+ });
2647
+ return;
2648
+ }
2649
+ if (isPlainObject(value)) for (const [key, child] of Object.entries(value)) collectEnvRefPaths(child, path ? `${path}.${key}` : key, output);
2650
+ }
2651
+ function collectChangedPaths(base, target, path, output) {
2652
+ if (Array.isArray(base) && Array.isArray(target)) {
2653
+ const max = Math.max(base.length, target.length);
2654
+ for (let index = 0; index < max; index += 1) {
2655
+ const childPath = path ? `${path}[${index}]` : `[${index}]`;
2656
+ if (index >= base.length || index >= target.length) {
2657
+ output.add(childPath);
2658
+ continue;
2659
+ }
2660
+ collectChangedPaths(base[index], target[index], childPath, output);
2661
+ }
2662
+ return;
2663
+ }
2664
+ if (isPlainObject(base) && isPlainObject(target)) {
2665
+ const keys = new Set([...Object.keys(base), ...Object.keys(target)]);
2666
+ for (const key of keys) {
2667
+ const childPath = path ? `${path}.${key}` : key;
2668
+ const hasBase = key in base;
2669
+ if (!(key in target) || !hasBase) {
2670
+ output.add(childPath);
2671
+ continue;
2672
+ }
2673
+ collectChangedPaths(base[key], target[key], childPath, output);
2674
+ }
2675
+ return;
2676
+ }
2677
+ if (!isDeepStrictEqual(base, target)) output.add(path);
2678
+ }
2679
+ function parentPath(value) {
2680
+ if (!value) return "";
2681
+ if (value.endsWith("]")) {
2682
+ const index = value.lastIndexOf("[");
2683
+ return index > 0 ? value.slice(0, index) : "";
2684
+ }
2685
+ const index = value.lastIndexOf(".");
2686
+ return index >= 0 ? value.slice(0, index) : "";
2687
+ }
2688
+ function isPathChanged(path, changedPaths) {
2689
+ if (changedPaths.has(path)) return true;
2690
+ let current = parentPath(path);
2691
+ while (current) {
2692
+ if (changedPaths.has(current)) return true;
2693
+ current = parentPath(current);
2694
+ }
2695
+ return changedPaths.has("");
2696
+ }
2697
+ function restoreEnvRefsFromMap(value, path, envRefMap, changedPaths) {
2698
+ if (typeof value === "string") {
2699
+ if (!isPathChanged(path, changedPaths)) {
2700
+ const original = envRefMap.get(path);
2701
+ if (original !== void 0) return original;
2702
+ }
2703
+ return value;
2704
+ }
2705
+ if (Array.isArray(value)) {
2706
+ let changed = false;
2707
+ const next = value.map((item, index) => {
2708
+ const updated = restoreEnvRefsFromMap(item, `${path}[${index}]`, envRefMap, changedPaths);
2709
+ if (updated !== item) changed = true;
2710
+ return updated;
2711
+ });
2712
+ return changed ? next : value;
2713
+ }
2714
+ if (isPlainObject(value)) {
2715
+ let changed = false;
2716
+ const next = {};
2717
+ for (const [key, child] of Object.entries(value)) {
2718
+ const updated = restoreEnvRefsFromMap(child, path ? `${path}.${key}` : key, envRefMap, changedPaths);
2719
+ if (updated !== child) changed = true;
2720
+ next[key] = updated;
2721
+ }
2722
+ return changed ? next : value;
2723
+ }
2724
+ return value;
2725
+ }
2726
+ function resolveConfigAuditLogPath(env, homedir) {
2727
+ return path.join(resolveStateDir(env, homedir), "logs", CONFIG_AUDIT_LOG_FILENAME);
2728
+ }
2729
+ function resolveConfigWriteSuspiciousReasons(params) {
2730
+ const reasons = [];
2731
+ if (!params.existsBefore) return reasons;
2732
+ if (typeof params.previousBytes === "number" && typeof params.nextBytes === "number" && params.previousBytes >= 512 && params.nextBytes < Math.floor(params.previousBytes * .5)) reasons.push(`size-drop:${params.previousBytes}->${params.nextBytes}`);
2733
+ if (!params.hasMetaBefore) reasons.push("missing-meta-before-write");
2734
+ if (params.gatewayModeBefore && !params.gatewayModeAfter) reasons.push("gateway-mode-removed");
2735
+ return reasons;
2736
+ }
2737
+ async function appendConfigWriteAuditRecord(deps, record) {
2738
+ try {
2739
+ const auditPath = resolveConfigAuditLogPath(deps.env, deps.homedir);
2740
+ await deps.fs.promises.mkdir(path.dirname(auditPath), {
2741
+ recursive: true,
2742
+ mode: 448
2743
+ });
2744
+ await deps.fs.promises.appendFile(auditPath, `${JSON.stringify(record)}\n`, {
2745
+ encoding: "utf-8",
2746
+ mode: 384
2747
+ });
2748
+ } catch {}
2749
+ }
2750
+ function warnOnConfigMiskeys(raw, logger) {
2751
+ if (!raw || typeof raw !== "object") return;
2752
+ const gateway = raw.gateway;
2753
+ if (!gateway || typeof gateway !== "object") return;
2754
+ if ("token" in gateway) logger.warn("Config uses \"gateway.token\". This key is ignored; use \"gateway.auth.token\" instead.");
2755
+ }
2756
+ function stampConfigVersion(cfg) {
2757
+ const now = (/* @__PURE__ */ new Date()).toISOString();
2758
+ return {
2759
+ ...cfg,
2760
+ meta: {
2761
+ ...cfg.meta,
2762
+ lastTouchedVersion: VERSION,
2763
+ lastTouchedAt: now
2764
+ }
2765
+ };
2766
+ }
2767
+ function warnIfConfigFromFuture(cfg, logger) {
2768
+ const touched = cfg.meta?.lastTouchedVersion;
2769
+ if (!touched) return;
2770
+ const cmp = compareRemoteClawVersions(VERSION, touched);
2771
+ if (cmp === null) return;
2772
+ if (cmp < 0) logger.warn(`Config was last written by a newer RemoteClaw (${touched}); current version is ${VERSION}.`);
2773
+ }
2774
+ function resolveConfigPathForDeps(deps) {
2775
+ if (deps.configPath) return deps.configPath;
2776
+ return resolveConfigPath(deps.env, resolveStateDir(deps.env, deps.homedir));
2777
+ }
2778
+ function normalizeDeps(overrides = {}) {
2779
+ return {
2780
+ fs: overrides.fs ?? fs,
2781
+ json5: overrides.json5 ?? JSON5,
2782
+ env: overrides.env ?? process.env,
2783
+ homedir: overrides.homedir ?? (() => resolveRequiredHomeDir(overrides.env ?? process.env, os.homedir)),
2784
+ configPath: overrides.configPath ?? "",
2785
+ logger: overrides.logger ?? console
2786
+ };
2787
+ }
2788
+ function maybeLoadDotEnvForConfig(env) {
2789
+ if (env !== process.env) return;
2790
+ loadDotEnv({ quiet: true });
2791
+ }
2792
+ function parseConfigJson5(raw, json5 = JSON5) {
2793
+ try {
2794
+ return {
2795
+ ok: true,
2796
+ parsed: json5.parse(raw)
2797
+ };
2798
+ } catch (err) {
2799
+ return {
2800
+ ok: false,
2801
+ error: String(err)
2802
+ };
2803
+ }
2804
+ }
2805
+ function resolveConfigIncludesForRead(parsed, configPath, deps) {
2806
+ return resolveConfigIncludes(parsed, configPath, {
2807
+ readFile: (candidate) => deps.fs.readFileSync(candidate, "utf-8"),
2808
+ parseJson: (raw) => deps.json5.parse(raw)
2809
+ });
2810
+ }
2811
+ function resolveConfigForRead(resolvedIncludes, env) {
2812
+ if (resolvedIncludes && typeof resolvedIncludes === "object" && "env" in resolvedIncludes) applyConfigEnvVars(resolvedIncludes, env);
2813
+ return {
2814
+ resolvedConfigRaw: resolveConfigEnvVars(resolvedIncludes, env),
2815
+ envSnapshotForRestore: { ...env }
2816
+ };
2817
+ }
2818
+ function createConfigIO(overrides = {}) {
2819
+ const deps = normalizeDeps(overrides);
2820
+ const requestedConfigPath = resolveConfigPathForDeps(deps);
2821
+ const configPath = (deps.configPath ? [requestedConfigPath] : resolveDefaultConfigCandidates(deps.env, deps.homedir)).find((candidate) => deps.fs.existsSync(candidate)) ?? requestedConfigPath;
2822
+ function loadConfig() {
2823
+ try {
2824
+ maybeLoadDotEnvForConfig(deps.env);
2825
+ if (!deps.fs.existsSync(configPath)) {
2826
+ if (shouldEnableShellEnvFallback(deps.env) && !shouldDeferShellEnvFallback(deps.env)) loadShellEnvFallback({
2827
+ enabled: true,
2828
+ env: deps.env,
2829
+ expectedKeys: SHELL_ENV_EXPECTED_KEYS,
2830
+ logger: deps.logger,
2831
+ timeoutMs: resolveShellEnvFallbackTimeoutMs(deps.env)
2832
+ });
2833
+ return {};
2834
+ }
2835
+ const raw = deps.fs.readFileSync(configPath, "utf-8");
2836
+ const { resolvedConfigRaw: resolvedConfig } = resolveConfigForRead(resolveConfigIncludesForRead(deps.json5.parse(raw), configPath, deps), deps.env);
2837
+ warnOnConfigMiskeys(resolvedConfig, deps.logger);
2838
+ if (typeof resolvedConfig !== "object" || resolvedConfig === null) return {};
2839
+ const preValidationDuplicates = findDuplicateAgentDirs(resolvedConfig, {
2840
+ env: deps.env,
2841
+ homedir: deps.homedir
2842
+ });
2843
+ if (preValidationDuplicates.length > 0) throw new DuplicateAgentDirError(preValidationDuplicates);
2844
+ const validated = validateConfigObjectWithPlugins(resolvedConfig);
2845
+ if (!validated.ok) {
2846
+ const details = validated.issues.map((iss) => `- ${iss.path || "<root>"}: ${iss.message}`).join("\n");
2847
+ if (!loggedInvalidConfigs.has(configPath)) {
2848
+ loggedInvalidConfigs.add(configPath);
2849
+ deps.logger.error(`Invalid config at ${configPath}:\\n${details}`);
2850
+ }
2851
+ const error = /* @__PURE__ */ new Error("Invalid config");
2852
+ error.code = "INVALID_CONFIG";
2853
+ error.details = details;
2854
+ throw error;
2855
+ }
2856
+ if (validated.warnings.length > 0) {
2857
+ const details = validated.warnings.map((iss) => `- ${iss.path || "<root>"}: ${iss.message}`).join("\n");
2858
+ deps.logger.warn(`Config warnings:\\n${details}`);
2859
+ }
2860
+ warnIfConfigFromFuture(validated.config, deps.logger);
2861
+ const cfg = applyTalkConfigNormalization(applyModelDefaults(applyContextPruningDefaults(applyAgentDefaults(applySessionDefaults(applyLoggingDefaults(applyMessageDefaults(validated.config)))))));
2862
+ normalizeConfigPaths(cfg);
2863
+ const duplicates = findDuplicateAgentDirs(cfg, {
2864
+ env: deps.env,
2865
+ homedir: deps.homedir
2866
+ });
2867
+ if (duplicates.length > 0) throw new DuplicateAgentDirError(duplicates);
2868
+ applyConfigEnvVars(cfg, deps.env);
2869
+ if ((shouldEnableShellEnvFallback(deps.env) || cfg.env?.shellEnv?.enabled === true) && !shouldDeferShellEnvFallback(deps.env)) loadShellEnvFallback({
2870
+ enabled: true,
2871
+ env: deps.env,
2872
+ expectedKeys: SHELL_ENV_EXPECTED_KEYS,
2873
+ logger: deps.logger,
2874
+ timeoutMs: cfg.env?.shellEnv?.timeoutMs ?? resolveShellEnvFallbackTimeoutMs(deps.env)
2875
+ });
2876
+ const pendingSecret = AUTO_OWNER_DISPLAY_SECRET_BY_PATH.get(configPath);
2877
+ const ownerDisplaySecretResolution = ensureOwnerDisplaySecret(cfg, () => pendingSecret ?? crypto.randomBytes(32).toString("hex"));
2878
+ const cfgWithOwnerDisplaySecret = ownerDisplaySecretResolution.config;
2879
+ if (ownerDisplaySecretResolution.generatedSecret) {
2880
+ AUTO_OWNER_DISPLAY_SECRET_BY_PATH.set(configPath, ownerDisplaySecretResolution.generatedSecret);
2881
+ if (!AUTO_OWNER_DISPLAY_SECRET_PERSIST_IN_FLIGHT.has(configPath)) {
2882
+ AUTO_OWNER_DISPLAY_SECRET_PERSIST_IN_FLIGHT.add(configPath);
2883
+ writeConfigFile(cfgWithOwnerDisplaySecret, { expectedConfigPath: configPath }).then(() => {
2884
+ AUTO_OWNER_DISPLAY_SECRET_BY_PATH.delete(configPath);
2885
+ AUTO_OWNER_DISPLAY_SECRET_PERSIST_WARNED.delete(configPath);
2886
+ }).catch((err) => {
2887
+ if (!AUTO_OWNER_DISPLAY_SECRET_PERSIST_WARNED.has(configPath)) {
2888
+ AUTO_OWNER_DISPLAY_SECRET_PERSIST_WARNED.add(configPath);
2889
+ deps.logger.warn(`Failed to persist auto-generated commands.ownerDisplaySecret at ${configPath}: ${String(err)}`);
2890
+ }
2891
+ }).finally(() => {
2892
+ AUTO_OWNER_DISPLAY_SECRET_PERSIST_IN_FLIGHT.delete(configPath);
2893
+ });
2894
+ }
2895
+ } else {
2896
+ AUTO_OWNER_DISPLAY_SECRET_BY_PATH.delete(configPath);
2897
+ AUTO_OWNER_DISPLAY_SECRET_PERSIST_WARNED.delete(configPath);
2898
+ }
2899
+ return applyConfigOverrides(cfgWithOwnerDisplaySecret);
2900
+ } catch (err) {
2901
+ if (err instanceof DuplicateAgentDirError) {
2902
+ deps.logger.error(err.message);
2903
+ throw err;
2904
+ }
2905
+ if (err?.code === "INVALID_CONFIG") return {};
2906
+ deps.logger.error(`Failed to read config at ${configPath}`, err);
2907
+ return {};
2908
+ }
2909
+ }
2910
+ async function readConfigFileSnapshotInternal() {
2911
+ maybeLoadDotEnvForConfig(deps.env);
2912
+ if (!deps.fs.existsSync(configPath)) {
2913
+ const hash = hashConfigRaw(null);
2914
+ return { snapshot: {
2915
+ path: configPath,
2916
+ exists: false,
2917
+ raw: null,
2918
+ parsed: {},
2919
+ resolved: {},
2920
+ valid: true,
2921
+ config: applyTalkApiKey(applyTalkConfigNormalization(applyModelDefaults(applyContextPruningDefaults(applyAgentDefaults(applySessionDefaults(applyMessageDefaults({}))))))),
2922
+ hash,
2923
+ issues: [],
2924
+ warnings: [],
2925
+ legacyIssues: []
2926
+ } };
2927
+ }
2928
+ try {
2929
+ const raw = deps.fs.readFileSync(configPath, "utf-8");
2930
+ const hash = hashConfigRaw(raw);
2931
+ const parsedRes = parseConfigJson5(raw, deps.json5);
2932
+ if (!parsedRes.ok) return { snapshot: {
2933
+ path: configPath,
2934
+ exists: true,
2935
+ raw,
2936
+ parsed: {},
2937
+ resolved: {},
2938
+ valid: false,
2939
+ config: {},
2940
+ hash,
2941
+ issues: [{
2942
+ path: "",
2943
+ message: `JSON5 parse failed: ${parsedRes.error}`
2944
+ }],
2945
+ warnings: [],
2946
+ legacyIssues: []
2947
+ } };
2948
+ let resolved;
2949
+ try {
2950
+ resolved = resolveConfigIncludesForRead(parsedRes.parsed, configPath, deps);
2951
+ } catch (err) {
2952
+ const message = err instanceof ConfigIncludeError ? err.message : `Include resolution failed: ${String(err)}`;
2953
+ return { snapshot: {
2954
+ path: configPath,
2955
+ exists: true,
2956
+ raw,
2957
+ parsed: parsedRes.parsed,
2958
+ resolved: coerceConfig(parsedRes.parsed),
2959
+ valid: false,
2960
+ config: coerceConfig(parsedRes.parsed),
2961
+ hash,
2962
+ issues: [{
2963
+ path: "",
2964
+ message
2965
+ }],
2966
+ warnings: [],
2967
+ legacyIssues: []
2968
+ } };
2969
+ }
2970
+ let readResolution;
2971
+ try {
2972
+ readResolution = resolveConfigForRead(resolved, deps.env);
2973
+ } catch (err) {
2974
+ const message = err instanceof MissingEnvVarError ? err.message : `Env var substitution failed: ${String(err)}`;
2975
+ return { snapshot: {
2976
+ path: configPath,
2977
+ exists: true,
2978
+ raw,
2979
+ parsed: parsedRes.parsed,
2980
+ resolved: coerceConfig(resolved),
2981
+ valid: false,
2982
+ config: coerceConfig(resolved),
2983
+ hash,
2984
+ issues: [{
2985
+ path: "",
2986
+ message
2987
+ }],
2988
+ warnings: [],
2989
+ legacyIssues: []
2990
+ } };
2991
+ }
2992
+ const resolvedConfigRaw = readResolution.resolvedConfigRaw;
2993
+ const legacyIssues = findLegacyConfigIssues(resolvedConfigRaw);
2994
+ const validated = validateConfigObjectWithPlugins(resolvedConfigRaw);
2995
+ if (!validated.ok) return { snapshot: {
2996
+ path: configPath,
2997
+ exists: true,
2998
+ raw,
2999
+ parsed: parsedRes.parsed,
3000
+ resolved: coerceConfig(resolvedConfigRaw),
3001
+ valid: false,
3002
+ config: coerceConfig(resolvedConfigRaw),
3003
+ hash,
3004
+ issues: validated.issues,
3005
+ warnings: validated.warnings,
3006
+ legacyIssues
3007
+ } };
3008
+ warnIfConfigFromFuture(validated.config, deps.logger);
3009
+ const snapshotConfig = normalizeConfigPaths(applyTalkApiKey(applyTalkConfigNormalization(applyModelDefaults(applyAgentDefaults(applySessionDefaults(applyLoggingDefaults(applyMessageDefaults(validated.config))))))));
3010
+ return {
3011
+ snapshot: {
3012
+ path: configPath,
3013
+ exists: true,
3014
+ raw,
3015
+ parsed: parsedRes.parsed,
3016
+ resolved: coerceConfig(resolvedConfigRaw),
3017
+ valid: true,
3018
+ config: snapshotConfig,
3019
+ hash,
3020
+ issues: [],
3021
+ warnings: validated.warnings,
3022
+ legacyIssues
3023
+ },
3024
+ envSnapshotForRestore: readResolution.envSnapshotForRestore
3025
+ };
3026
+ } catch (err) {
3027
+ const nodeErr = err;
3028
+ let message;
3029
+ if (nodeErr?.code === "EACCES") {
3030
+ const uid = process.getuid?.();
3031
+ const uidHint = typeof uid === "number" ? String(uid) : "$(id -u)";
3032
+ message = [
3033
+ `read failed: ${String(err)}`,
3034
+ ``,
3035
+ `Config file is not readable by the current process. If running in a container`,
3036
+ `or 1-click deployment, fix ownership with:`,
3037
+ ` chown ${uidHint} "${configPath}"`,
3038
+ `Then restart the gateway.`
3039
+ ].join("\n");
3040
+ deps.logger.error(message);
3041
+ } else message = `read failed: ${String(err)}`;
3042
+ return { snapshot: {
3043
+ path: configPath,
3044
+ exists: true,
3045
+ raw: null,
3046
+ parsed: {},
3047
+ resolved: {},
3048
+ valid: false,
3049
+ config: {},
3050
+ hash: hashConfigRaw(null),
3051
+ issues: [{
3052
+ path: "",
3053
+ message
3054
+ }],
3055
+ warnings: [],
3056
+ legacyIssues: []
3057
+ } };
3058
+ }
3059
+ }
3060
+ async function readConfigFileSnapshot() {
3061
+ return (await readConfigFileSnapshotInternal()).snapshot;
3062
+ }
3063
+ async function readConfigFileSnapshotForWrite() {
3064
+ const result = await readConfigFileSnapshotInternal();
3065
+ return {
3066
+ snapshot: result.snapshot,
3067
+ writeOptions: {
3068
+ envSnapshotForRestore: result.envSnapshotForRestore,
3069
+ expectedConfigPath: configPath
3070
+ }
3071
+ };
3072
+ }
3073
+ async function writeConfigFile(cfg, options = {}) {
3074
+ clearConfigCache();
3075
+ let persistCandidate = cfg;
3076
+ const { snapshot } = await readConfigFileSnapshotInternal();
3077
+ let envRefMap = null;
3078
+ let changedPaths = null;
3079
+ if (snapshot.valid && snapshot.exists) {
3080
+ const patch = createMergePatch(snapshot.config, cfg);
3081
+ persistCandidate = applyMergePatch(snapshot.resolved, patch);
3082
+ try {
3083
+ const resolvedIncludes = resolveConfigIncludes(snapshot.parsed, configPath, {
3084
+ readFile: (candidate) => deps.fs.readFileSync(candidate, "utf-8"),
3085
+ parseJson: (raw) => deps.json5.parse(raw)
3086
+ });
3087
+ const collected = /* @__PURE__ */ new Map();
3088
+ collectEnvRefPaths(resolvedIncludes, "", collected);
3089
+ if (collected.size > 0) {
3090
+ envRefMap = collected;
3091
+ changedPaths = /* @__PURE__ */ new Set();
3092
+ collectChangedPaths(snapshot.config, cfg, "", changedPaths);
3093
+ }
3094
+ } catch {
3095
+ envRefMap = null;
3096
+ }
3097
+ }
3098
+ const validated = validateConfigObjectRawWithPlugins(persistCandidate);
3099
+ if (!validated.ok) {
3100
+ const issue = validated.issues[0];
3101
+ const pathLabel = issue?.path ? issue.path : "<root>";
3102
+ const issueMessage = issue?.message ?? "invalid";
3103
+ throw new Error(formatConfigValidationFailure(pathLabel, issueMessage));
3104
+ }
3105
+ if (validated.warnings.length > 0) {
3106
+ const details = validated.warnings.map((warning) => `- ${warning.path}: ${warning.message}`).join("\n");
3107
+ deps.logger.warn(`Config warnings:\n${details}`);
3108
+ }
3109
+ let cfgToWrite = validated.config;
3110
+ try {
3111
+ if (deps.fs.existsSync(configPath)) {
3112
+ const parsedRes = parseConfigJson5(await deps.fs.promises.readFile(configPath, "utf-8"), deps.json5);
3113
+ if (parsedRes.ok) {
3114
+ const envForRestore = options.envSnapshotForRestore ?? deps.env;
3115
+ cfgToWrite = restoreEnvVarRefs(cfgToWrite, parsedRes.parsed, envForRestore);
3116
+ }
3117
+ }
3118
+ } catch {}
3119
+ const dir = path.dirname(configPath);
3120
+ await deps.fs.promises.mkdir(dir, {
3121
+ recursive: true,
3122
+ mode: 448
3123
+ });
3124
+ let outputConfig = envRefMap && changedPaths ? restoreEnvRefsFromMap(cfgToWrite, "", envRefMap, changedPaths) : cfgToWrite;
3125
+ if (options.unsetPaths?.length) for (const unsetPath of options.unsetPaths) {
3126
+ if (!Array.isArray(unsetPath) || unsetPath.length === 0) continue;
3127
+ const unsetResult = unsetPathForWrite(outputConfig, unsetPath);
3128
+ if (unsetResult.changed) outputConfig = unsetResult.next;
3129
+ }
3130
+ const stampedOutputConfig = stampConfigVersion(outputConfig);
3131
+ const json = JSON.stringify(stampedOutputConfig, null, 2).trimEnd().concat("\n");
3132
+ const nextHash = hashConfigRaw(json);
3133
+ const previousHash = resolveConfigSnapshotHash(snapshot);
3134
+ const changedPathCount = changedPaths?.size;
3135
+ const previousBytes = typeof snapshot.raw === "string" ? Buffer.byteLength(snapshot.raw, "utf-8") : null;
3136
+ const nextBytes = Buffer.byteLength(json, "utf-8");
3137
+ const hasMetaBefore = hasConfigMeta(snapshot.parsed);
3138
+ const hasMetaAfter = hasConfigMeta(stampedOutputConfig);
3139
+ const gatewayModeBefore = resolveGatewayMode(snapshot.resolved);
3140
+ const gatewayModeAfter = resolveGatewayMode(stampedOutputConfig);
3141
+ const suspiciousReasons = resolveConfigWriteSuspiciousReasons({
3142
+ existsBefore: snapshot.exists,
3143
+ previousBytes,
3144
+ nextBytes,
3145
+ hasMetaBefore,
3146
+ gatewayModeBefore,
3147
+ gatewayModeAfter
3148
+ });
3149
+ const logConfigOverwrite = () => {
3150
+ if (!snapshot.exists) return;
3151
+ const isVitest = deps.env.VITEST === "true";
3152
+ const shouldLogInVitest = deps.env.REMOTECLAW_TEST_CONFIG_OVERWRITE_LOG === "1";
3153
+ if (isVitest && !shouldLogInVitest) return;
3154
+ const changeSummary = typeof changedPathCount === "number" ? `, changedPaths=${changedPathCount}` : "";
3155
+ deps.logger.warn(`Config overwrite: ${configPath} (sha256 ${previousHash ?? "unknown"} -> ${nextHash}, backup=${configPath}.bak${changeSummary})`);
3156
+ };
3157
+ const logConfigWriteAnomalies = () => {
3158
+ if (suspiciousReasons.length === 0) return;
3159
+ const isVitest = deps.env.VITEST === "true";
3160
+ const shouldLogInVitest = deps.env.REMOTECLAW_TEST_CONFIG_WRITE_ANOMALY_LOG === "1";
3161
+ if (isVitest && !shouldLogInVitest) return;
3162
+ deps.logger.warn(`Config write anomaly: ${configPath} (${suspiciousReasons.join(", ")})`);
3163
+ };
3164
+ const auditRecordBase = {
3165
+ ts: (/* @__PURE__ */ new Date()).toISOString(),
3166
+ source: "config-io",
3167
+ event: "config.write",
3168
+ configPath,
3169
+ pid: process.pid,
3170
+ ppid: process.ppid,
3171
+ cwd: process.cwd(),
3172
+ argv: process.argv.slice(0, 8),
3173
+ execArgv: process.execArgv.slice(0, 8),
3174
+ watchMode: deps.env.REMOTECLAW_WATCH_MODE === "1",
3175
+ watchSession: typeof deps.env.REMOTECLAW_WATCH_SESSION === "string" && deps.env.REMOTECLAW_WATCH_SESSION.trim().length > 0 ? deps.env.REMOTECLAW_WATCH_SESSION.trim() : null,
3176
+ watchCommand: typeof deps.env.REMOTECLAW_WATCH_COMMAND === "string" && deps.env.REMOTECLAW_WATCH_COMMAND.trim().length > 0 ? deps.env.REMOTECLAW_WATCH_COMMAND.trim() : null,
3177
+ existsBefore: snapshot.exists,
3178
+ previousHash: previousHash ?? null,
3179
+ nextHash,
3180
+ previousBytes,
3181
+ nextBytes,
3182
+ changedPathCount: typeof changedPathCount === "number" ? changedPathCount : null,
3183
+ hasMetaBefore,
3184
+ hasMetaAfter,
3185
+ gatewayModeBefore,
3186
+ gatewayModeAfter,
3187
+ suspicious: suspiciousReasons
3188
+ };
3189
+ const appendWriteAudit = async (result, err) => {
3190
+ const errorCode = err && typeof err === "object" && "code" in err && typeof err.code === "string" ? err.code : void 0;
3191
+ const errorMessage = err && typeof err === "object" && "message" in err && typeof err.message === "string" ? err.message : void 0;
3192
+ await appendConfigWriteAuditRecord(deps, {
3193
+ ...auditRecordBase,
3194
+ result,
3195
+ nextHash: result === "failed" ? null : auditRecordBase.nextHash,
3196
+ nextBytes: result === "failed" ? null : auditRecordBase.nextBytes,
3197
+ errorCode,
3198
+ errorMessage
3199
+ });
3200
+ };
3201
+ const tmp = path.join(dir, `${path.basename(configPath)}.${process.pid}.${crypto.randomUUID()}.tmp`);
3202
+ try {
3203
+ await deps.fs.promises.writeFile(tmp, json, {
3204
+ encoding: "utf-8",
3205
+ mode: 384
3206
+ });
3207
+ if (deps.fs.existsSync(configPath)) {
3208
+ await rotateConfigBackups(configPath, deps.fs.promises);
3209
+ await deps.fs.promises.copyFile(configPath, `${configPath}.bak`).catch(() => {});
3210
+ }
3211
+ try {
3212
+ await deps.fs.promises.rename(tmp, configPath);
3213
+ } catch (err) {
3214
+ const code = err.code;
3215
+ if (code === "EPERM" || code === "EEXIST") {
3216
+ await deps.fs.promises.copyFile(tmp, configPath);
3217
+ await deps.fs.promises.chmod(configPath, 384).catch(() => {});
3218
+ await deps.fs.promises.unlink(tmp).catch(() => {});
3219
+ logConfigOverwrite();
3220
+ logConfigWriteAnomalies();
3221
+ await appendWriteAudit("copy-fallback");
3222
+ return;
3223
+ }
3224
+ await deps.fs.promises.unlink(tmp).catch(() => {});
3225
+ throw err;
3226
+ }
3227
+ logConfigOverwrite();
3228
+ logConfigWriteAnomalies();
3229
+ await appendWriteAudit("rename");
3230
+ } catch (err) {
3231
+ await appendWriteAudit("failed", err);
3232
+ throw err;
3233
+ }
3234
+ }
3235
+ return {
3236
+ configPath,
3237
+ loadConfig,
3238
+ readConfigFileSnapshot,
3239
+ readConfigFileSnapshotForWrite,
3240
+ writeConfigFile
3241
+ };
3242
+ }
3243
+ const DEFAULT_CONFIG_CACHE_MS = 200;
3244
+ const AUTO_OWNER_DISPLAY_SECRET_BY_PATH = /* @__PURE__ */ new Map();
3245
+ const AUTO_OWNER_DISPLAY_SECRET_PERSIST_IN_FLIGHT = /* @__PURE__ */ new Set();
3246
+ const AUTO_OWNER_DISPLAY_SECRET_PERSIST_WARNED = /* @__PURE__ */ new Set();
3247
+ let configCache = null;
3248
+ function resolveConfigCacheMs(env) {
3249
+ const raw = env.REMOTECLAW_CONFIG_CACHE_MS?.trim();
3250
+ if (raw === "" || raw === "0") return 0;
3251
+ if (!raw) return DEFAULT_CONFIG_CACHE_MS;
3252
+ const parsed = Number.parseInt(raw, 10);
3253
+ if (!Number.isFinite(parsed)) return DEFAULT_CONFIG_CACHE_MS;
3254
+ return Math.max(0, parsed);
3255
+ }
3256
+ function shouldUseConfigCache(env) {
3257
+ if (env.REMOTECLAW_DISABLE_CONFIG_CACHE?.trim()) return false;
3258
+ return resolveConfigCacheMs(env) > 0;
3259
+ }
3260
+ function clearConfigCache() {
3261
+ configCache = null;
3262
+ }
3263
+ function loadConfig() {
3264
+ const io = createConfigIO();
3265
+ const configPath = io.configPath;
3266
+ const now = Date.now();
3267
+ if (shouldUseConfigCache(process.env)) {
3268
+ const cached = configCache;
3269
+ if (cached && cached.configPath === configPath && cached.expiresAt > now) return cached.config;
3270
+ }
3271
+ const config = io.loadConfig();
3272
+ if (shouldUseConfigCache(process.env)) {
3273
+ const cacheMs = resolveConfigCacheMs(process.env);
3274
+ if (cacheMs > 0) configCache = {
3275
+ configPath,
3276
+ expiresAt: now + cacheMs,
3277
+ config
3278
+ };
3279
+ }
3280
+ return config;
3281
+ }
3282
+ async function readConfigFileSnapshot() {
3283
+ return await createConfigIO().readConfigFileSnapshot();
3284
+ }
3285
+ async function readConfigFileSnapshotForWrite() {
3286
+ return await createConfigIO().readConfigFileSnapshotForWrite();
3287
+ }
3288
+ async function writeConfigFile(cfg, options = {}) {
3289
+ const io = createConfigIO();
3290
+ const sameConfigPath = options.expectedConfigPath === void 0 || options.expectedConfigPath === io.configPath;
3291
+ await io.writeConfigFile(cfg, {
3292
+ envSnapshotForRestore: sameConfigPath ? options.envSnapshotForRestore : void 0,
3293
+ unsetPaths: options.unsetPaths
3294
+ });
3295
+ }
3296
+
3297
+ //#endregion
3298
+ //#region src/config/legacy-migrate.ts
3299
+ function migrateLegacyConfig(raw) {
3300
+ const { next, changes } = applyLegacyMigrations(raw);
3301
+ if (!next) return {
3302
+ config: null,
3303
+ changes: []
3304
+ };
3305
+ const validated = validateConfigObjectWithPlugins(next);
3306
+ if (!validated.ok) {
3307
+ changes.push("Migration applied, but config still invalid; fix remaining issues manually.");
3308
+ return {
3309
+ config: null,
3310
+ changes
3311
+ };
3312
+ }
3313
+ return {
3314
+ config: validated.config,
3315
+ changes
3316
+ };
3317
+ }
3318
+
3319
+ //#endregion
3320
+ //#region src/config/config.ts
3321
+ var config_exports = /* @__PURE__ */ __exportAll({
3322
+ CONFIG_PATH: () => CONFIG_PATH,
3323
+ DEFAULT_GATEWAY_PORT: () => DEFAULT_GATEWAY_PORT,
3324
+ STATE_DIR: () => STATE_DIR,
3325
+ TOOLS_BY_SENDER_KEY_TYPES: () => TOOLS_BY_SENDER_KEY_TYPES,
3326
+ applyConfigOverrides: () => applyConfigOverrides,
3327
+ getConfigOverrides: () => getConfigOverrides,
3328
+ isNixMode: () => isNixMode,
3329
+ loadConfig: () => loadConfig,
3330
+ parseToolsBySenderTypedKey: () => parseToolsBySenderTypedKey,
3331
+ resetConfigOverrides: () => resetConfigOverrides,
3332
+ resolveCanonicalConfigPath: () => resolveCanonicalConfigPath,
3333
+ resolveConfigPath: () => resolveConfigPath,
3334
+ resolveConfigPathCandidate: () => resolveConfigPathCandidate,
3335
+ resolveDefaultConfigCandidates: () => resolveDefaultConfigCandidates,
3336
+ resolveGatewayLockDir: () => resolveGatewayLockDir,
3337
+ resolveGatewayPort: () => resolveGatewayPort,
3338
+ resolveIsNixMode: () => resolveIsNixMode,
3339
+ resolveNewStateDir: () => resolveNewStateDir,
3340
+ resolveOAuthDir: () => resolveOAuthDir,
3341
+ resolveStateDir: () => resolveStateDir,
3342
+ setConfigOverride: () => setConfigOverride,
3343
+ unsetConfigOverride: () => unsetConfigOverride
3344
+ });
3345
+
3346
+ //#endregion
3347
+ export { resolveEffectiveEnableState as A, applyLegacyMigrations as B, discoverRemoteClawPlugins as C, resolveBundledPluginsDir as D, loadPluginManifest as E, getConfigValueAtPath as F, isPathInsideWithRealpath as G, MAX_INCLUDE_DEPTH as H, parseConfigPath as I, resolveAgentMaxConcurrent as J, buildTalkConfigResponse as K, setConfigValueAtPath as L, resetConfigOverrides as M, setConfigOverride as N, applyTestPluginDefaults as O, unsetConfigOverride as P, unsetConfigValueAtPath as R, loadPluginManifestRegistry as S, safeStatSync as T, extensionUsesSkippedScannerPath as U, INCLUDE_KEY as V, isPathInside$1 as W, loadDotEnv as X, resolveSubagentMaxConcurrent as Y, isWorkspaceRelativeAvatarPath as _, parseConfigJson5 as a, validateJsonSchemaValue as b, resolveConfigSnapshotHash as c, AVATAR_MAX_BYTES as d, isAvatarDataUrl as f, isSupportedLocalAvatarExtension as g, isPathWithinRoot as h, loadConfig as i, getConfigOverrides as j, normalizePluginsConfig as k, writeConfigFile as l, isAvatarImageDataUrl as m, migrateLegacyConfig as n, readConfigFileSnapshot as o, isAvatarHttpUrl as p, DEFAULT_SUBAGENT_MAX_SPAWN_DEPTH as q, createConfigIO as r, readConfigFileSnapshotForWrite as s, config_exports as t, validateConfigObjectWithPlugins as u, looksLikeAvatarPath as v, isPathInside as w, clearPluginManifestRegistryCache as x, resolveAvatarMime as y, applyMergePatch as z };