remoteclaw 0.1.0-next.cd6ddde → 0.1.0-next.cf9ccbe

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 (1054) hide show
  1. package/dist/accounts-79XhjwAj.js +32 -0
  2. package/dist/accounts-B1M3fOxL.js +272 -0
  3. package/dist/accounts-BwbvnKsW.js +205 -0
  4. package/dist/accounts-CIVjmTg9.js +270 -0
  5. package/dist/accounts-D1awQXKu.js +36 -0
  6. package/dist/accounts-DHkGVGUR.js +36 -0
  7. package/dist/accounts-P7cmIXUM.js +206 -0
  8. package/dist/accounts-XFgBY644.js +47 -0
  9. package/dist/accounts-_ZuNC5bz.js +47 -0
  10. package/dist/ack-reactions-BGJ9Vigf.js +621 -0
  11. package/dist/ack-reactions-Diu9O24z.js +621 -0
  12. package/dist/acp-cli-BwZ-va2P.js +1316 -0
  13. package/dist/acp-cli-eVKByz-j.js +1311 -0
  14. package/dist/active-listener--jrUO-8L.js +37 -0
  15. package/dist/active-listener-C7SyMcNY.js +37 -0
  16. package/dist/agent-BAxK2KQW.js +688 -0
  17. package/dist/agent-Dd5Yfhmq.js +687 -0
  18. package/dist/agent-helpers-5F0tdxud.js +400 -0
  19. package/dist/agent-scope-BA1HP4K6.js +114 -0
  20. package/dist/agent-scope-CAQLm3LP.js +116 -0
  21. package/dist/agents-2VlLHxv-.js +754 -0
  22. package/dist/agents.config-CmyzLYqW.js +116 -0
  23. package/dist/agents.config-DerBqRzk.js +116 -0
  24. package/dist/audio-ClIuKwkl.js +43 -0
  25. package/dist/audio-DqlIYYTb.js +43 -0
  26. package/dist/audit-Cn0cNCE4.js +3114 -0
  27. package/dist/audit-DXY4NHBC.js +3114 -0
  28. package/dist/auth-B-QK8JhI.js +315 -0
  29. package/dist/auth-C1zx1O24.js +314 -0
  30. package/dist/auth-DDmNYVMW.js +448 -0
  31. package/dist/auth-DH1wEw0w.js +448 -0
  32. package/dist/banner-CBWZhANO.js +294 -0
  33. package/dist/binaries-CYwLdubd.js +13 -0
  34. package/dist/bindings-DFAFatwT.js +69 -0
  35. package/dist/bindings-GUKIzFCp.js +69 -0
  36. package/dist/bonjour-discovery-AQMJqY4V.js +378 -0
  37. package/dist/bonjour-discovery-BLcPWHFJ.js +378 -0
  38. package/dist/boot/handler.js +28 -28
  39. package/dist/browser-cli-8Dv5ogFT.js +1690 -0
  40. package/dist/browser-cli-wNLo8SOy.js +1694 -0
  41. package/dist/build-info.json +3 -3
  42. package/dist/call-BTHzKFbN.js +518 -0
  43. package/dist/call-D_NchaCs.js +517 -0
  44. package/dist/canvas-host/a2ui/.bundle.hash +1 -1
  45. package/dist/catalog-DgpN5jxU.js +186 -0
  46. package/dist/catalog-k056Nh93.js +186 -0
  47. package/dist/channel-account-context-BHIy71Yh.js +133 -0
  48. package/dist/channel-account-context-DXU_-EkJ.js +133 -0
  49. package/dist/channel-activity-BatlvP_U.js +292 -0
  50. package/dist/channel-activity-BhT7NQ_v.js +94 -0
  51. package/dist/channel-activity-CvjEwpJz.js +94 -0
  52. package/dist/channel-options-BCccA2WC.js +32 -0
  53. package/dist/channel-options-VPR_pNyS.js +33 -0
  54. package/dist/channel-selection-AH6_y6RS.js +51 -0
  55. package/dist/channel-selection-ovohyJQZ.js +51 -0
  56. package/dist/channel-web-APDaQ_wp.js +2134 -0
  57. package/dist/channel-web-BW_YuNlT.js +2132 -0
  58. package/dist/channels-cli-BBkHQtBI.js +1440 -0
  59. package/dist/channels-cli-CKcOwL-Q.js +1436 -0
  60. package/dist/channels-status-issues-BbYNzwLp.js +18 -0
  61. package/dist/channels-status-issues-DRybAijg.js +18 -0
  62. package/dist/chat-envelope-AJFUAuBM.js +248 -0
  63. package/dist/chat-envelope-BrfcPlDM.js +248 -0
  64. package/dist/chrome-Bv2UtAMQ.js +1732 -0
  65. package/dist/chrome-C6Vc_7su.js +1733 -0
  66. package/dist/chunk-BzVoFUZL.js +341 -0
  67. package/dist/clack-prompter-C6mBTOzE.js +122 -0
  68. package/dist/clack-prompter-DKcYqv3o.js +121 -0
  69. package/dist/cleanup-utils-Cb-leJcy.js +94 -0
  70. package/dist/cli/daemon-cli.js +1 -1
  71. package/dist/cli-Cs1n6-eD.js +135 -0
  72. package/dist/cli-Di3p1tLN.js +131 -0
  73. package/dist/client-B6h7bgbF.js +2311 -0
  74. package/dist/client-CMtdm9Ii.js +2311 -0
  75. package/dist/clipboard-A06eV_5C.js +31 -0
  76. package/dist/clipboard-DQBl3coj.js +31 -0
  77. package/dist/command-format-BiiNHkWG.js +18 -0
  78. package/dist/command-format-Dntg_tnC.js +32 -0
  79. package/dist/command-logger/handler.js +1 -1
  80. package/dist/command-registry-BV2MH_iw.js +215 -0
  81. package/dist/commands-D93TXYhv.js +41 -0
  82. package/dist/commands-UD7V7QC9.js +41 -0
  83. package/dist/commands-registry-CCbTtSSK.js +891 -0
  84. package/dist/commands-registry-De8JhZLG.js +890 -0
  85. package/dist/common-D4fL3S2m.js +156 -0
  86. package/dist/common-DXNisGxw.js +156 -0
  87. package/dist/completion-cli-319xyosV.js +452 -0
  88. package/dist/completion-cli-B6Zimnek.js +452 -0
  89. package/dist/config-BTH7fB_v.js +3345 -0
  90. package/dist/config-DwuBnd6D.js +3347 -0
  91. package/dist/config-cli-c_Itt86J.js +247 -0
  92. package/dist/config-cli-rcMB3A3B.js +243 -0
  93. package/dist/config-guard-BcT7soTj.js +92 -0
  94. package/dist/config-guard-Bqak3bDc.js +75 -0
  95. package/dist/config-validation-CHEjSJ5K.js +18 -0
  96. package/dist/config-validation-CvgqLhyG.js +18 -0
  97. package/dist/configure-Cb3bbYnh.js +891 -0
  98. package/dist/configure-R2gWNv5y.js +889 -0
  99. package/dist/control-auth-DrGYtMJM.js +397 -0
  100. package/dist/control-auth-KY4Qdr2I.js +397 -0
  101. package/dist/control-ui-assets-DO1L6M0S.js +186 -0
  102. package/dist/control-ui-assets-S_TLo6Fs.js +186 -0
  103. package/dist/conversation-label-CMOfgCVl.js +36 -0
  104. package/dist/cron-cli-C7h_hLHu.js +495 -0
  105. package/dist/cron-cli-DTNg0Uvl.js +499 -0
  106. package/dist/daemon-cli-BlJS9zWM.js +737 -0
  107. package/dist/daemon-cli-Cfc1yszp.js +735 -0
  108. package/dist/daemon-cli.js +124 -1071
  109. package/dist/daemon-install-BbBLuLWg.js +60 -0
  110. package/dist/daemon-install-WEBvqVOj.js +56 -0
  111. package/dist/daemon-install-helpers-BVtPC2TK.js +504 -0
  112. package/dist/daemon-install-helpers-DVr51zvE.js +504 -0
  113. package/dist/deliver-EB272zWh.js +481 -0
  114. package/dist/deliver-iGD_woru.js +481 -0
  115. package/dist/delivery-queue-BDvalA10.js +244 -0
  116. package/dist/delivery-queue-BimvYz5E.js +244 -0
  117. package/dist/devices-cli-BXCOsNFc.js +323 -0
  118. package/dist/devices-cli-CHGdYfrz.js +319 -0
  119. package/dist/diagnostics-BzzhTQzK.js +35 -0
  120. package/dist/diagnostics-DILtxtcE.js +35 -0
  121. package/dist/directory-cli-COS40yI9.js +221 -0
  122. package/dist/directory-cli-Cb5j1JTC.js +225 -0
  123. package/dist/dispatcher-BUqxh_mA.js +174 -0
  124. package/dist/dispatcher-By-KZRWZ.js +173 -0
  125. package/dist/dm-policy-shared-BCp9_z3w.js +22 -0
  126. package/dist/dm-policy-shared-DgeKqjOu.js +22 -0
  127. package/dist/dns-cli-B8yyXB2N.js +203 -0
  128. package/dist/dns-cli-DAkTk-gM.js +199 -0
  129. package/dist/dock-B0bIIDS3.js +906 -0
  130. package/dist/dock-C3PzQ6CS.js +907 -0
  131. package/dist/doctor-completion-B_Zp4fZk.js +92 -0
  132. package/dist/doctor-completion-CZ1P5laQ.js +92 -0
  133. package/dist/doctor-config-flow-BDDsR2J1.js +978 -0
  134. package/dist/doctor-config-flow-CwFFRUic.js +979 -0
  135. package/dist/enable-C3I9dWel.js +59 -0
  136. package/dist/enable-DnwKeWnR.js +59 -0
  137. package/dist/entry.js +62 -6
  138. package/dist/env-DyyqmxSM.js +60 -0
  139. package/dist/errors-0dfGxeYQ.js +35 -0
  140. package/dist/errors-C1kDByVU.js +35 -0
  141. package/dist/exec-CAk1dxq_.js +164 -0
  142. package/dist/exec-epNpA1aU.js +164 -0
  143. package/dist/extensionAPI.js +263 -1088
  144. package/dist/fetch-BMQq41sB.js +281 -0
  145. package/dist/fetch-Cky99wYB.js +281 -0
  146. package/dist/fetch-D3tw4B4n.js +67 -0
  147. package/dist/fetch-Dgm9ZHFm.js +67 -0
  148. package/dist/file-lock-DWH0TfVu.js +107 -0
  149. package/dist/file-lock-DXW9h9ek.js +107 -0
  150. package/dist/fs-safe-BjSd07M4.js +115 -0
  151. package/dist/fs-safe-aWIhCWlb.js +125 -0
  152. package/dist/gateway-cli-BLeY_1DX.js +24154 -0
  153. package/dist/gateway-cli-Cu4vwhmi.js +24150 -0
  154. package/dist/gateway-rpc-B92CH0D3.js +28 -0
  155. package/dist/gateway-rpc-DZNlWapO.js +28 -0
  156. package/dist/gmail-setup-utils-CKyh29_R.js +422 -0
  157. package/dist/gmail-setup-utils-DquflkMR.js +423 -0
  158. package/dist/health-BYl7T-4m.js +1417 -0
  159. package/dist/health-DdviISKg.js +1414 -0
  160. package/dist/health-format-BE5TK5bs.js +28 -0
  161. package/dist/heartbeat-visibility-BO3iRpB6.js +125 -0
  162. package/dist/heartbeat-visibility-Cwp4TrTv.js +125 -0
  163. package/dist/help-format-D3JhWp1E.js +17 -0
  164. package/dist/hook-runner-global-C1thol1d.js +527 -0
  165. package/dist/hooks-cli-BKS9uZ0H.js +1221 -0
  166. package/dist/hooks-cli-FLWcCr9q.js +1217 -0
  167. package/dist/image-ops-CX41n0v5.js +354 -0
  168. package/dist/image-ops-DSL3eFfQ.js +354 -0
  169. package/dist/import-BSFgt760.js +604 -0
  170. package/dist/import-Da1CHJJg.js +606 -0
  171. package/dist/inbound-context-a5bzQvRt.js +68 -0
  172. package/dist/index.js +127 -101
  173. package/dist/inspect-BEpFbi0c.js +286 -0
  174. package/dist/inspect-BeNNpWna.js +286 -0
  175. package/dist/installs-CH7Qq_m_.js +319 -0
  176. package/dist/installs-CcM8H2YA.js +319 -0
  177. package/dist/ipv4-DNo9AFDu.js +46 -0
  178. package/dist/ipv4-VfoVR5uR.js +46 -0
  179. package/dist/ir-BPwP8hIc.js +972 -0
  180. package/dist/lifecycle-core-5Zxqwa6V.js +476 -0
  181. package/dist/lifecycle-core-C1bGeLby.js +474 -0
  182. package/dist/links-CtGBIrG8.js +15 -0
  183. package/dist/loader-BoP3JA-r.js +22411 -0
  184. package/dist/loader-DXbpue-L.js +22414 -0
  185. package/dist/logger-ASsO5Nz-.js +49 -0
  186. package/dist/logging-Cd9y2AdQ.js +20 -0
  187. package/dist/login-B2UXzgaB.js +61 -0
  188. package/dist/login-BEFL3xY9.js +62 -0
  189. package/dist/login-qr-C7wAz2fe.js +329 -0
  190. package/dist/login-qr-DWpUP1Ud.js +325 -0
  191. package/dist/logs-cli-CAcd-pXA.js +240 -0
  192. package/dist/logs-cli-D7Bzarht.js +236 -0
  193. package/dist/markdown-tables-BBNUZp4n.js +29 -0
  194. package/dist/markdown-tables-NgPcfXoF.js +29 -0
  195. package/dist/media-4-qOIjO-.js +971 -0
  196. package/dist/media-DTwJhAbE.js +9481 -0
  197. package/dist/message-action-names-BsNTjuBE.js +2520 -0
  198. package/dist/message-action-names-ocKcq8_3.js +2520 -0
  199. package/dist/message-channel-CtcVHawF.js +91 -0
  200. package/dist/mime-CAqaK3kp.js +146 -0
  201. package/dist/mime-ViuhRuMM.js +146 -0
  202. package/dist/net-DSkFMHJ8.js +225 -0
  203. package/dist/net-DTqfFYzt.js +225 -0
  204. package/dist/node-cli-BeXU67eQ.js +1458 -0
  205. package/dist/node-cli-i2aCtnmM.js +1462 -0
  206. package/dist/node-service-RyMlWp8N.js +67 -0
  207. package/dist/node-service-TL9b6Qfz.js +67 -0
  208. package/dist/nodes-cli-CtqnXBMD.js +1346 -0
  209. package/dist/nodes-cli-DgQU3LrG.js +1350 -0
  210. package/dist/nodes-screen-B7HJugJ0.js +250 -0
  211. package/dist/nodes-screen-nCRd71Mk.js +250 -0
  212. package/dist/note-B6142LyJ.js +92 -0
  213. package/dist/note-D-EI0czq.js +92 -0
  214. package/dist/npm-registry-spec-PPyRXSpx.js +786 -0
  215. package/dist/npm-registry-spec-uUmDWe6v.js +786 -0
  216. package/dist/npm-resolution-BC1LqCm2.js +86 -0
  217. package/dist/npm-resolution-DhlhUmRF.js +86 -0
  218. package/dist/onboard-CHowLVEG.js +647 -0
  219. package/dist/onboard-D_eCnKjt.js +649 -0
  220. package/dist/onboard-auth-cNtb3FTP.js +211 -0
  221. package/dist/onboard-auth-gwz-0mZ6.js +207 -0
  222. package/dist/onboard-channels-CFsUIDWq.js +2618 -0
  223. package/dist/onboard-channels-ZCML5CWb.js +2619 -0
  224. package/dist/onboard-helpers-8afRV_Tm.js +364 -0
  225. package/dist/onboard-helpers-DTRrJLj-.js +363 -0
  226. package/dist/onboard-remote-CFkvVAYg.js +127 -0
  227. package/dist/onboard-remote-JfBnmK70.js +127 -0
  228. package/dist/onboarding-DIxNghyi.js +586 -0
  229. package/dist/onboarding-Dhh0bjrb.js +588 -0
  230. package/dist/onboarding.finalize-5uipJuOl.js +403 -0
  231. package/dist/onboarding.finalize-De4etQul.js +405 -0
  232. package/dist/onboarding.gateway-config-DolBTXWT.js +196 -0
  233. package/dist/onboarding.gateway-config-rJkIamlG.js +202 -0
  234. package/dist/outbound-CPMaDtgC.js +220 -0
  235. package/dist/outbound-CYSuCMiW.js +221 -0
  236. package/dist/outbound-attachment-Ci02LXoq.js +18 -0
  237. package/dist/outbound-attachment-CqZ7Qc_o.js +18 -0
  238. package/dist/outbound-attachment-CuqWdsdV.js +18 -0
  239. package/dist/pairing-cli-B9JKvvST.js +126 -0
  240. package/dist/pairing-cli-C4HrfIHe.js +130 -0
  241. package/dist/pairing-labels-CBmGQ31P.js +9 -0
  242. package/dist/pairing-labels-D0xwC7Xb.js +9 -0
  243. package/dist/pairing-store-BoF0g-iN.js +459 -0
  244. package/dist/pairing-store-CseXj-5p.js +460 -0
  245. package/dist/path-env-CPZbb7me.js +89 -0
  246. package/dist/path-safety-BFE0XmGC.js +14 -0
  247. package/dist/path-safety-BJ8ge6Ho.js +14 -0
  248. package/dist/paths-DHuXVC00.js +229 -0
  249. package/dist/plugin-auto-enable-B_9J1XED.js +302 -0
  250. package/dist/plugin-auto-enable-DghjlFCL.js +301 -0
  251. package/dist/plugin-registry-68h2T8vi.js +33 -0
  252. package/dist/plugin-registry-BitdVPb4.js +33 -0
  253. package/dist/plugin-sdk/agents/subagent-registry.store.d.ts +0 -1
  254. package/dist/plugin-sdk/auto-reply/reply/agent-runner-utils.d.ts +0 -11
  255. package/dist/plugin-sdk/auto-reply/reply/commands-status.d.ts +1 -4
  256. package/dist/plugin-sdk/auto-reply/reply/commands-subagents/shared.d.ts +1 -1
  257. package/dist/plugin-sdk/auto-reply/reply/commands-types.d.ts +1 -10
  258. package/dist/plugin-sdk/auto-reply/reply/directive-handling.levels.d.ts +1 -4
  259. package/dist/plugin-sdk/auto-reply/reply/directive-handling.params.d.ts +1 -8
  260. package/dist/plugin-sdk/auto-reply/reply/directive-handling.parse.d.ts +1 -23
  261. package/dist/plugin-sdk/auto-reply/reply/directive-handling.persist.d.ts +0 -2
  262. package/dist/plugin-sdk/auto-reply/reply/directive-handling.shared.d.ts +0 -22
  263. package/dist/plugin-sdk/auto-reply/reply/directives.d.ts +2 -29
  264. package/dist/plugin-sdk/auto-reply/reply/get-reply-directives-apply.d.ts +0 -8
  265. package/dist/plugin-sdk/auto-reply/reply/get-reply-directives-utils.d.ts +0 -1
  266. package/dist/plugin-sdk/auto-reply/reply/get-reply-directives.d.ts +1 -15
  267. package/dist/plugin-sdk/auto-reply/reply/get-reply-inline-actions.d.ts +1 -8
  268. package/dist/plugin-sdk/auto-reply/reply/get-reply-run.d.ts +1 -11
  269. package/dist/plugin-sdk/auto-reply/reply/queue/types.d.ts +1 -13
  270. package/dist/plugin-sdk/auto-reply/reply.d.ts +1 -1
  271. package/dist/plugin-sdk/auto-reply/status.d.ts +1 -4
  272. package/dist/plugin-sdk/auto-reply/templating.d.ts +0 -4
  273. package/dist/plugin-sdk/auto-reply/thinking.d.ts +0 -4
  274. package/dist/plugin-sdk/channels/dock.d.ts +1 -2
  275. package/dist/plugin-sdk/channels/plugins/types.adapters.d.ts +0 -6
  276. package/dist/plugin-sdk/channels/plugins/types.d.ts +1 -1
  277. package/dist/plugin-sdk/channels/plugins/types.plugin.d.ts +1 -2
  278. package/dist/plugin-sdk/commands/onboard-helpers.d.ts +0 -1
  279. package/dist/plugin-sdk/commands/onboard-types.d.ts +0 -2
  280. package/dist/plugin-sdk/config/legacy.migrations.d.ts +2 -1
  281. package/dist/plugin-sdk/config/legacy.shared.d.ts +0 -9
  282. package/dist/plugin-sdk/config/sessions/types.d.ts +0 -7
  283. package/dist/plugin-sdk/config/types.agent-defaults.d.ts +0 -8
  284. package/dist/plugin-sdk/config/types.base.d.ts +0 -1
  285. package/dist/plugin-sdk/config/types.messages.d.ts +0 -4
  286. package/dist/plugin-sdk/config/types.tools.d.ts +0 -73
  287. package/dist/plugin-sdk/config/types.tts.d.ts +2 -1
  288. package/dist/plugin-sdk/config/zod-schema.agent-defaults.d.ts +0 -4
  289. package/dist/plugin-sdk/config/zod-schema.agent-runtime.d.ts +7 -197
  290. package/dist/plugin-sdk/config/zod-schema.agents.d.ts +2 -10
  291. package/dist/plugin-sdk/config/zod-schema.core.d.ts +6 -234
  292. package/dist/plugin-sdk/config/zod-schema.d.ts +98 -301
  293. package/dist/plugin-sdk/config/zod-schema.providers-core.d.ts +148 -160
  294. package/dist/plugin-sdk/config/zod-schema.providers-whatsapp.d.ts +12 -12
  295. package/dist/plugin-sdk/config/zod-schema.providers.d.ts +88 -96
  296. package/dist/plugin-sdk/config/zod-schema.session.d.ts +4 -10
  297. package/dist/plugin-sdk/gateway/protocol/index.d.ts +11 -16
  298. package/dist/plugin-sdk/gateway/protocol/schema/sessions.d.ts +0 -5
  299. package/dist/plugin-sdk/gateway/session-utils.types.d.ts +0 -1
  300. package/dist/plugin-sdk/index.js +295 -1236
  301. package/dist/plugin-sdk/line/config-schema.d.ts +4 -4
  302. package/dist/plugin-sdk/logging/levels.d.ts +1 -1
  303. package/dist/plugin-sdk/middleware/cli-runtime-base.d.ts +6 -0
  304. package/dist/plugin-sdk/middleware/runtimes/claude.d.ts +6 -0
  305. package/dist/plugin-sdk/middleware/runtimes/codex.d.ts +2 -2
  306. package/dist/plugin-sdk/middleware/runtimes/gemini.d.ts +8 -1
  307. package/dist/plugin-sdk/plugin-sdk/index.d.ts +3 -1
  308. package/dist/plugin-sdk/plugins/manifest-registry.d.ts +2 -0
  309. package/dist/plugin-sdk/plugins/manifest.d.ts +4 -4
  310. package/dist/plugin-sdk/plugins/registry.d.ts +18 -0
  311. package/dist/plugin-sdk/plugins/types.d.ts +4 -0
  312. package/dist/plugin-sdk/slack/manifest.d.ts +17 -0
  313. package/dist/plugin-sdk/stt/preflight.d.ts +2 -4
  314. package/dist/plugin-sdk/stt/providers/index.d.ts +1 -1
  315. package/dist/plugin-sdk/stt/providers/shared.d.ts +20 -1
  316. package/dist/plugin-sdk/tts/providers/edge.d.ts +2 -0
  317. package/dist/plugin-sdk/tts/providers/elevenlabs.d.ts +2 -0
  318. package/dist/plugin-sdk/tts/providers/index.d.ts +4 -0
  319. package/dist/plugin-sdk/tts/providers/openai.d.ts +2 -0
  320. package/dist/plugin-sdk/tts/tts.d.ts +13 -5
  321. package/dist/plugin-sdk/tts/types.d.ts +21 -0
  322. package/dist/plugins-BviLFPLV.js +255 -0
  323. package/dist/plugins-CaudBUbl.js +254 -0
  324. package/dist/plugins-cli-CsLhphNr.js +803 -0
  325. package/dist/plugins-cli-CujSP9NS.js +807 -0
  326. package/dist/ports-BtuzUQHl.js +370 -0
  327. package/dist/ports-CMcHia07.js +96 -0
  328. package/dist/ports-gRBeuUtp.js +316 -0
  329. package/dist/preflight-Bq8rimP-.js +667 -0
  330. package/dist/preflight-DyYbEp9X.js +667 -0
  331. package/dist/program-G8cGMPuz.js +250 -0
  332. package/dist/program-context-B9BwrbSx.js +474 -0
  333. package/dist/progress-BcwxtM9Q.js +124 -0
  334. package/dist/prompt-DtWGd43j.js +21 -0
  335. package/dist/prompt-select-styled-CpOsmtZi.js +1672 -0
  336. package/dist/prompt-select-styled-D-qBqrEJ.js +1669 -0
  337. package/dist/prompt-style-BpUMhEHC.js +9 -0
  338. package/dist/provider-auth-B7QgxlKt.js +187 -0
  339. package/dist/provider-auth-j-EQvvIk.js +187 -0
  340. package/dist/provider-dispatcher-Bx6CaIoV.js +660 -0
  341. package/dist/provider-dispatcher-DhkvjhO5.js +659 -0
  342. package/dist/push-apns--nEiZmEN.js +711 -0
  343. package/dist/push-apns-BtS6B6lb.js +713 -0
  344. package/dist/pw-ai-BpCsXF-x.js +1908 -0
  345. package/dist/pw-ai-ud_Kbn5S.js +1911 -0
  346. package/dist/qr-cli-BCeVLGfz.js +353 -0
  347. package/dist/qr-cli-Crsqtw01.js +349 -0
  348. package/dist/redact-Ci96Gj0O.js +191 -0
  349. package/dist/redact-snapshot-B9nof-Pb.js +1952 -0
  350. package/dist/redact-snapshot-BKiS91Mj.js +1952 -0
  351. package/dist/register.agent-GnCbOS2U.js +1014 -0
  352. package/dist/register.agent-Mwu5hgjA.js +292 -0
  353. package/dist/register.configure-By-Re240.js +130 -0
  354. package/dist/register.configure-rB-Q0WKu.js +135 -0
  355. package/dist/register.import-B83Dn36B.js +29 -0
  356. package/dist/register.import-wIYU2cVW.js +31 -0
  357. package/dist/register.maintenance-D5KctP9K.js +503 -0
  358. package/dist/register.maintenance-Er88Oxcm.js +501 -0
  359. package/dist/register.message-BQhRoEQQ.js +687 -0
  360. package/dist/register.message-CvZKWeGb.js +691 -0
  361. package/dist/register.onboard-BG064oHg.js +94 -0
  362. package/dist/register.onboard-CAKyc1Fc.js +98 -0
  363. package/dist/register.setup-C9sZLS_P.js +114 -0
  364. package/dist/register.setup-CVsZdhkJ.js +118 -0
  365. package/dist/register.status-health-sessions-BZJ0wTSa.js +429 -0
  366. package/dist/register.status-health-sessions-CyrUwwtB.js +667 -0
  367. package/dist/register.subclis-CQ_Pjkyv.js +267 -0
  368. package/dist/replies-BIx-MbQ7.js +136 -0
  369. package/dist/replies-DVU655H4.js +136 -0
  370. package/dist/reply-CL5VMSKN.js +12372 -0
  371. package/dist/reply-XKyfU3rS.js +12375 -0
  372. package/dist/reply-directives-DQfJ001O.js +182 -0
  373. package/dist/reply-directives-DfUITt7C.js +182 -0
  374. package/dist/reply-payloads-ZHo6kfTS.js +527 -0
  375. package/dist/reply-prefix-BSf3PC0x.js +37 -0
  376. package/dist/reply-prefix-DBTlMHLK.js +37 -0
  377. package/dist/resolve-route-B-_IgETc.js +249 -0
  378. package/dist/resolve-route-C8ZsgWDQ.js +249 -0
  379. package/dist/response-prefix-template-3LeqJx2X.js +134 -0
  380. package/dist/response-prefix-template-DBrUVx5V.js +134 -0
  381. package/dist/retry-CDrH81GP.js +77 -0
  382. package/dist/retry-Dar_7pCv.js +77 -0
  383. package/dist/run-main-DBFpx1kt.js +308 -0
  384. package/dist/secure-random-CLWSvf8A.js +44 -0
  385. package/dist/security-cli-B8lXw9ke.js +488 -0
  386. package/dist/security-cli-CRkS3VAf.js +483 -0
  387. package/dist/send-6g8QKfWj.js +374 -0
  388. package/dist/send-B5Hz1PIn.js +29 -0
  389. package/dist/send-B8eIlA1u.js +349 -0
  390. package/dist/send-BFZPQE4j.js +492 -0
  391. package/dist/send-BpTDvE0D.js +1779 -0
  392. package/dist/send-BxOrO1Wv.js +1776 -0
  393. package/dist/send-C6gPJu-Z.js +11 -0
  394. package/dist/send-C7MoKtkN.js +426 -0
  395. package/dist/send-CXzq2LI6.js +2245 -0
  396. package/dist/send-CYOZoObr.js +547 -0
  397. package/dist/send-CfQyIvcC.js +332 -0
  398. package/dist/send-DUtuuwhw.js +492 -0
  399. package/dist/send-DbafVwxp.js +2245 -0
  400. package/dist/send-DeZg8K7y.js +349 -0
  401. package/dist/send-DwkjxJlv.js +547 -0
  402. package/dist/send-iX9xbxlU.js +1178 -0
  403. package/dist/server-BKfCzEzd.js +206 -0
  404. package/dist/server-fmO4eo7K.js +202 -0
  405. package/dist/server-lifecycle-CgPpP10P.js +2437 -0
  406. package/dist/server-lifecycle-Cn8yY5MW.js +2437 -0
  407. package/dist/server-node-events-C-ZzSBYh.js +391 -0
  408. package/dist/server-node-events-DYlyfDHM.js +395 -0
  409. package/dist/service-C2j81L86.js +670 -0
  410. package/dist/service-C8a0SXHD.js +670 -0
  411. package/dist/session-AulYhqOb.js +170 -0
  412. package/dist/session-C6VKWvx6.js +170 -0
  413. package/dist/session-cost-usage-0Vs4hgMe.js +627 -0
  414. package/dist/session-cost-usage-C-DsaOfN.js +627 -0
  415. package/dist/session-dirs-CO1f2ArM.js +318 -0
  416. package/dist/session-dirs-DoboH7Oy.js +318 -0
  417. package/dist/session-utils-CRK8ToKG.js +621 -0
  418. package/dist/session-utils-DWlkmCX8.js +621 -0
  419. package/dist/sessions-DtqrmUJS.js +2553 -0
  420. package/dist/sessions-gT-4fcX-.js +245 -0
  421. package/dist/shell-env-c3j5zcU9.js +163 -0
  422. package/dist/ssrf-8wNqPNzN.js +183 -0
  423. package/dist/ssrf-CJIdPXuS.js +183 -0
  424. package/dist/status-BI_-xpDt.js +1947 -0
  425. package/dist/status-PZVwjKjl.js +1943 -0
  426. package/dist/status.update-BmuDZ7E7.js +449 -0
  427. package/dist/status.update-Mf6HSRvU.js +449 -0
  428. package/dist/store-B7PGEdFf.js +2555 -0
  429. package/dist/store-CzhBjUCN.js +64 -0
  430. package/dist/store-YkSxKAey.js +53 -0
  431. package/dist/store-ZNeFv2Q7.js +64 -0
  432. package/dist/subagent-registry-R1DiAM4R.js +4839 -0
  433. package/dist/subagent-registry-xLRXC8Bg.js +4841 -0
  434. package/dist/subsystem-BAW_f3DI.js +1195 -0
  435. package/dist/subsystem-DGSHVL8I.js +1081 -0
  436. package/dist/system-cli-9SvRrT9D.js +77 -0
  437. package/dist/system-cli-yCa5Q1YM.js +73 -0
  438. package/dist/systemd-40Rij3QR.js +547 -0
  439. package/dist/systemd-5C97CSzd.js +547 -0
  440. package/dist/systemd-hints-3iQteJw-.js +278 -0
  441. package/dist/systemd-hints-CyQqHq1i.js +278 -0
  442. package/dist/systemd-linger-B2rPbnAi.js +75 -0
  443. package/dist/systemd-linger-DDvkfxH-.js +75 -0
  444. package/dist/table-DFx25vNb.js +279 -0
  445. package/dist/tables-C5fI0PmT.js +55 -0
  446. package/dist/tables-Cm9qvQ9D.js +55 -0
  447. package/dist/tables-fRe01eP1.js +55 -0
  448. package/dist/tailnet-Da-_9e8E.js +40 -0
  449. package/dist/tailnet-xt92Yaop.js +40 -0
  450. package/dist/tailscale-CnV0JWca.js +230 -0
  451. package/dist/tailscale-VkEC8dzj.js +230 -0
  452. package/dist/targets-C99szk_e.js +114 -0
  453. package/dist/targets-CPaTjbpp.js +2607 -0
  454. package/dist/targets-CmC5m7Ey.js +53 -0
  455. package/dist/targets-D-p4rJVS.js +650 -0
  456. package/dist/targets-D2OQt8-7.js +650 -0
  457. package/dist/targets-D94MtTiZ.js +2606 -0
  458. package/dist/targets-RajrXTl7.js +220 -0
  459. package/dist/targets-_UWmnyI9.js +53 -0
  460. package/dist/thinking-4nOZPunr.js +60 -0
  461. package/dist/thinking-ZfH2V9Os.js +60 -0
  462. package/dist/tokens-TtJJxzRr.js +21 -0
  463. package/dist/tool-display-Bxs_1jIn.js +785 -0
  464. package/dist/tool-display-D9p_Ttkq.js +785 -0
  465. package/dist/tool-images-9Ron321Q.js +263 -0
  466. package/dist/tool-images-BWhy6WRN.js +263 -0
  467. package/dist/trash-B5xyvBDf.js +125 -0
  468. package/dist/trash-BpB96kHe.js +125 -0
  469. package/dist/tui-Ba0uZDrg.js +3237 -0
  470. package/dist/tui-Biz0HqDj.js +3237 -0
  471. package/dist/tui-cli-C-UV6o2v.js +63 -0
  472. package/dist/tui-cli-Ds_bLT-h.js +67 -0
  473. package/dist/types.tools-BBb2rl3g.js +23 -0
  474. package/dist/types.tools-BDJw1yFx.js +23 -0
  475. package/dist/update-Barj5dsg.js +349 -0
  476. package/dist/update-D839Q8su.js +349 -0
  477. package/dist/update-cli-2I4hm0Gy.js +1150 -0
  478. package/dist/update-cli-CcwXmMKB.js +1148 -0
  479. package/dist/usage-BI9kergH.js +5465 -0
  480. package/dist/utils-DPoNpP7D.js +631 -0
  481. package/dist/voice-credentials-64XAMSJm.js +46 -0
  482. package/dist/voice-credentials-v-CQkTpD.js +46 -0
  483. package/dist/web-63IbbidQ.js +3051 -0
  484. package/dist/web-D9N764Da.js +80 -0
  485. package/dist/web-DUvNYLzr.js +75 -0
  486. package/dist/webhooks-cli-owhVNNkz.js +334 -0
  487. package/dist/webhooks-cli-zlvka6QD.js +330 -0
  488. package/dist/whatsapp-actions-8DejyRG5.js +126 -0
  489. package/dist/whatsapp-actions-DCzp5LKe.js +131 -0
  490. package/dist/widearea-dns-CQqZIeu8.js +127 -0
  491. package/dist/workspace-CB7pVojf.js +441 -0
  492. package/dist/workspace-DWEyzM0F.js +439 -0
  493. package/dist/zod-schema-CvFqwpNE.js +2719 -0
  494. package/dist/zod-schema-Y5SQgJLm.js +2719 -0
  495. package/package.json +1 -1
  496. package/dist/accounts-Aqbb2_Fn.js +0 -270
  497. package/dist/accounts-Bo2bX8jP.js +0 -272
  498. package/dist/accounts-CJUdvsIZ.js +0 -32
  499. package/dist/accounts-D3fAPVzU.js +0 -36
  500. package/dist/accounts-DZmv4bXS.js +0 -47
  501. package/dist/accounts-DmB4SVPK.js +0 -47
  502. package/dist/accounts-DtkyfvwR.js +0 -36
  503. package/dist/ack-reactions-BqcZUQJ3.js +0 -446
  504. package/dist/ack-reactions-DXHaDBH-.js +0 -446
  505. package/dist/acp-cli-DVXhDMc6.js +0 -1324
  506. package/dist/acp-cli-QBL4_qcW.js +0 -1319
  507. package/dist/active-listener-CwxZ24bZ.js +0 -37
  508. package/dist/active-listener-v2sItamh.js +0 -37
  509. package/dist/agent-C5PZDKE1.js +0 -687
  510. package/dist/agent-helpers-BSGqeJr-.js +0 -400
  511. package/dist/agent-qCBPcUcF.js +0 -688
  512. package/dist/agent-scope-CJW7vnF8.js +0 -114
  513. package/dist/agent-scope-_ND_-bJy.js +0 -116
  514. package/dist/agents-Byc39Y4A.js +0 -760
  515. package/dist/agents.config-BgDBcY4h.js +0 -116
  516. package/dist/agents.config-D8gLHPWo.js +0 -116
  517. package/dist/audio-BIvUsncf.js +0 -43
  518. package/dist/audio-CQ8TfmVN.js +0 -43
  519. package/dist/audit-C0x7Cm6K.js +0 -3150
  520. package/dist/audit-CAY-uzWP.js +0 -3150
  521. package/dist/auth-DGqCLaQq.js +0 -448
  522. package/dist/auth-DLTRySEi.js +0 -314
  523. package/dist/auth-Drf91ntw.js +0 -315
  524. package/dist/auth-ku2khJyQ.js +0 -448
  525. package/dist/banner-CGI3XOm4.js +0 -294
  526. package/dist/binaries-BTvHIrCr.js +0 -13
  527. package/dist/bindings-Dr0bGRst.js +0 -69
  528. package/dist/bindings-DsWJQVKh.js +0 -69
  529. package/dist/bonjour-discovery-BElR62fH.js +0 -378
  530. package/dist/bonjour-discovery-C8XyVsjb.js +0 -378
  531. package/dist/browser-cli-DxJew43l.js +0 -1694
  532. package/dist/browser-cli-p0nakrjO.js +0 -1690
  533. package/dist/call-BrTmlOx3.js +0 -518
  534. package/dist/call-ChdUdwb4.js +0 -517
  535. package/dist/catalog-DTlcfTT9.js +0 -185
  536. package/dist/catalog-PixZqhZK.js +0 -185
  537. package/dist/channel-account-context-BO245Tcn.js +0 -133
  538. package/dist/channel-account-context-BgK0hm-I.js +0 -133
  539. package/dist/channel-activity-B0qlUR5e.js +0 -292
  540. package/dist/channel-activity-C-L6rDrQ.js +0 -94
  541. package/dist/channel-activity-DdgLBZ7M.js +0 -94
  542. package/dist/channel-options-C1Q9SUhv.js +0 -33
  543. package/dist/channel-options-zANFhRx_.js +0 -32
  544. package/dist/channel-selection-DW21dXB1.js +0 -51
  545. package/dist/channel-selection-wK_6S2Ku.js +0 -51
  546. package/dist/channel-web-DCSjrtlh.js +0 -2136
  547. package/dist/channel-web-JCgegBgG.js +0 -2134
  548. package/dist/channels-cli-D48ytzLq.js +0 -1438
  549. package/dist/channels-cli-hZbUcB3G.js +0 -1434
  550. package/dist/channels-status-issues-B6I2l7Sm.js +0 -18
  551. package/dist/channels-status-issues-DhDH2fWp.js +0 -18
  552. package/dist/chat-envelope-BIujl9Cj.js +0 -248
  553. package/dist/chat-envelope-CrM0X4sl.js +0 -248
  554. package/dist/chrome-Dqtq7zCc.js +0 -1733
  555. package/dist/chrome-XeSY99Z_.js +0 -1732
  556. package/dist/chunk-LUabyS9k.js +0 -341
  557. package/dist/clack-prompter-fAgbvPW4.js +0 -122
  558. package/dist/clack-prompter-kf9qTN5p.js +0 -121
  559. package/dist/cleanup-utils-CNwlTKyR.js +0 -94
  560. package/dist/cli-BTLaY8q4.js +0 -133
  561. package/dist/cli-CZV23GbW.js +0 -129
  562. package/dist/client-B9u3JdT_.js +0 -2316
  563. package/dist/client-DEEOhx0w.js +0 -2316
  564. package/dist/clipboard-B2nstLx7.js +0 -31
  565. package/dist/clipboard-C8QI9fes.js +0 -31
  566. package/dist/command-format-D0vKipG9.js +0 -32
  567. package/dist/command-format-LFmgWzKJ.js +0 -18
  568. package/dist/command-registry-BPXqH4ST.js +0 -215
  569. package/dist/commands-BAYwlS3d.js +0 -41
  570. package/dist/commands-D842kCjj.js +0 -41
  571. package/dist/commands-registry-Cg2GTT2J.js +0 -892
  572. package/dist/commands-registry-Yz-uV5oG.js +0 -891
  573. package/dist/common-B67cBSew.js +0 -156
  574. package/dist/common-DEoiTqOr.js +0 -156
  575. package/dist/completion-cli-D5J3fPka.js +0 -452
  576. package/dist/completion-cli-Dd1g-p7S.js +0 -452
  577. package/dist/config-CAa0rZSx.js +0 -4225
  578. package/dist/config-W0w-gi2j.js +0 -4223
  579. package/dist/config-cli-Ddz-yCdQ.js +0 -247
  580. package/dist/config-cli-shgSFYig.js +0 -243
  581. package/dist/config-guard-BI85dxHR.js +0 -99
  582. package/dist/config-guard-DQqnigKh.js +0 -75
  583. package/dist/config-validation-D-h4LHyA.js +0 -18
  584. package/dist/config-validation-Df_kroIQ.js +0 -18
  585. package/dist/configure-BnFwpZ3l.js +0 -891
  586. package/dist/configure-Cj4mlKSH.js +0 -889
  587. package/dist/control-auth-BrBr2xb8.js +0 -397
  588. package/dist/control-auth-CehjYKnL.js +0 -397
  589. package/dist/control-ui-assets-D8F383Mo.js +0 -186
  590. package/dist/control-ui-assets-DYKtRIm0.js +0 -186
  591. package/dist/conversation-label-Bn5j3lUT.js +0 -36
  592. package/dist/cron-cli-DVzDHzAX.js +0 -494
  593. package/dist/cron-cli-gkH2qKM4.js +0 -498
  594. package/dist/daemon-cli-BTdNO1vH.js +0 -737
  595. package/dist/daemon-cli-DNNqI2LD.js +0 -735
  596. package/dist/daemon-install-CaEHG92p.js +0 -56
  597. package/dist/daemon-install-DbpDSDfW.js +0 -60
  598. package/dist/daemon-install-helpers-DjE_WnlY.js +0 -504
  599. package/dist/daemon-install-helpers-DocTUxqQ.js +0 -504
  600. package/dist/deliver-CDcL8ok6.js +0 -481
  601. package/dist/deliver-CS8JsevV.js +0 -481
  602. package/dist/delivery-queue-CTaYZQ_8.js +0 -244
  603. package/dist/delivery-queue-DMZ7mH8P.js +0 -244
  604. package/dist/devices-cli-BBJ4His-.js +0 -319
  605. package/dist/devices-cli-DHSJSFW1.js +0 -323
  606. package/dist/diagnostics-BSvCaLNs.js +0 -35
  607. package/dist/diagnostics-mWFAsFeo.js +0 -35
  608. package/dist/directory-cli-C-oHD_XE.js +0 -224
  609. package/dist/directory-cli-Cw99VGvr.js +0 -220
  610. package/dist/dispatcher-C8d1NNLZ.js +0 -174
  611. package/dist/dispatcher-DY6Ga60j.js +0 -173
  612. package/dist/dm-policy-shared-CRQ-Wr5g.js +0 -22
  613. package/dist/dm-policy-shared-CXXf2ltd.js +0 -22
  614. package/dist/dns-cli-BOqx9qo1.js +0 -199
  615. package/dist/dns-cli-WfqSC3JU.js +0 -203
  616. package/dist/dock-Big-J2VN.js +0 -929
  617. package/dist/dock-Cj4PKiUh.js +0 -928
  618. package/dist/doctor-completion-B9RsNJKh.js +0 -92
  619. package/dist/doctor-completion-DhNvADTs.js +0 -92
  620. package/dist/doctor-config-flow-BUuADMDa.js +0 -1935
  621. package/dist/doctor-config-flow-yOUpQC2B.js +0 -1934
  622. package/dist/enable-DC9V0nTO.js +0 -59
  623. package/dist/enable-DzXMQJ-o.js +0 -59
  624. package/dist/env-B3zr72vQ.js +0 -60
  625. package/dist/errors-CdmXrBic.js +0 -35
  626. package/dist/errors-Cr_NbOb4.js +0 -35
  627. package/dist/exec-D_s-zAtY.js +0 -164
  628. package/dist/exec-Zz6eJ6YU.js +0 -164
  629. package/dist/fetch-C8pdlo4-.js +0 -67
  630. package/dist/fetch-DRVdxxEj.js +0 -67
  631. package/dist/file-lock-6NXMPZTT.js +0 -107
  632. package/dist/file-lock-C_KRlR7M.js +0 -107
  633. package/dist/fs-safe-DZHpH7TI.js +0 -98
  634. package/dist/fs-safe-vm3JMUkq.js +0 -88
  635. package/dist/gateway-cli-CebjflhZ.js +0 -24337
  636. package/dist/gateway-cli-Y9U6rbPB.js +0 -24333
  637. package/dist/gateway-rpc-BCFkQPa2.js +0 -28
  638. package/dist/gateway-rpc-DOgYbsOG.js +0 -28
  639. package/dist/gmail-setup-utils-DMeA1UM1.js +0 -423
  640. package/dist/gmail-setup-utils-FHWSAur3.js +0 -422
  641. package/dist/health-CXWQZGNz.js +0 -1414
  642. package/dist/health-DCC6hoLO.js +0 -1417
  643. package/dist/health-format-CVgQD-z9.js +0 -28
  644. package/dist/heartbeat-visibility-Cv0ejWJ-.js +0 -125
  645. package/dist/heartbeat-visibility-Da3TDQp2.js +0 -125
  646. package/dist/help-format-DM6-OBt-.js +0 -17
  647. package/dist/hook-runner-global-C0DFQmQw.js +0 -527
  648. package/dist/hooks-cli-CB5rKhHe.js +0 -1221
  649. package/dist/hooks-cli-Dy7m9hzM.js +0 -1225
  650. package/dist/image-ops-B9ofmzSq.js +0 -354
  651. package/dist/image-ops-CMuvRsMY.js +0 -354
  652. package/dist/import-BH13F5mT.js +0 -606
  653. package/dist/import-D8HVcDqO.js +0 -604
  654. package/dist/inbound-context-CmmmT8IP.js +0 -68
  655. package/dist/inbound-path-policy-BdmTOUka.js +0 -90
  656. package/dist/inbound-path-policy-BurOAu44.js +0 -90
  657. package/dist/inspect-nW8LAukU.js +0 -286
  658. package/dist/inspect-xy2EHy8G.js +0 -286
  659. package/dist/installs-CpfHmKY1.js +0 -325
  660. package/dist/installs-DebiMrGj.js +0 -325
  661. package/dist/ipv4-ysiNGssl.js +0 -46
  662. package/dist/ipv4-zc_Hfvbp.js +0 -46
  663. package/dist/ir-CaxTklDC.js +0 -940
  664. package/dist/lifecycle-core-Z5SScMlU.js +0 -476
  665. package/dist/lifecycle-core-pPwYSt7m.js +0 -474
  666. package/dist/links-D5vtq30Q.js +0 -15
  667. package/dist/loader-BVHaRcP7.js +0 -22404
  668. package/dist/loader-CxSGgugQ.js +0 -22401
  669. package/dist/local-roots-CrJ_Jv_G.js +0 -314
  670. package/dist/local-roots-n_Y4iYwb.js +0 -313
  671. package/dist/logger-B8yHnzPl.js +0 -49
  672. package/dist/logging-FctZEleJ.js +0 -20
  673. package/dist/login-C99fsB0N.js +0 -61
  674. package/dist/login-cLvGPjeO.js +0 -62
  675. package/dist/login-qr-CGqRFwgl.js +0 -329
  676. package/dist/login-qr-dnY5DC2C.js +0 -325
  677. package/dist/logs-cli-Bda7xY4N.js +0 -236
  678. package/dist/logs-cli-HzR-vnpD.js +0 -240
  679. package/dist/markdown-tables-58Hq__7K.js +0 -29
  680. package/dist/markdown-tables-GFEX0OR6.js +0 -29
  681. package/dist/media-C1SIfGTn.js +0 -10452
  682. package/dist/media-CFsyXs3H.js +0 -940
  683. package/dist/message-action-names-BgsKGLDS.js +0 -2521
  684. package/dist/message-action-names-DkZwEFhU.js +0 -2521
  685. package/dist/message-channel-FMNRI5Ax.js +0 -91
  686. package/dist/mime-AuIDUZPG.js +0 -149
  687. package/dist/mime-Cqg1jjia.js +0 -149
  688. package/dist/net-BEFkF-nI.js +0 -225
  689. package/dist/net-CNsUGiSw.js +0 -225
  690. package/dist/node-cli-Bu-InsO9.js +0 -1462
  691. package/dist/node-cli-DE7Pm7Fr.js +0 -1458
  692. package/dist/node-service-CumFZc9L.js +0 -67
  693. package/dist/node-service-DY1gG06I.js +0 -67
  694. package/dist/nodes-cli-B5aAExN0.js +0 -1350
  695. package/dist/nodes-cli-eKRqlKuO.js +0 -1346
  696. package/dist/nodes-screen-B3Sij1uT.js +0 -250
  697. package/dist/nodes-screen-DEvpoFmH.js +0 -250
  698. package/dist/note-CPFJCWJJ.js +0 -92
  699. package/dist/note-DHUJACHE.js +0 -92
  700. package/dist/npm-registry-spec-BgMtTHvq.js +0 -786
  701. package/dist/npm-registry-spec-Dz3z1Zpd.js +0 -786
  702. package/dist/npm-resolution-BXiQH99t.js +0 -86
  703. package/dist/npm-resolution-CqE0nhxJ.js +0 -86
  704. package/dist/onboard-DK2z3w1P.js +0 -649
  705. package/dist/onboard-auth-C_wHkop1.js +0 -207
  706. package/dist/onboard-auth-CkCBLvTg.js +0 -211
  707. package/dist/onboard-channels-C8_OLbPk.js +0 -2547
  708. package/dist/onboard-channels-w_tnOhVu.js +0 -2548
  709. package/dist/onboard-helpers-Q7M6vdzh.js +0 -363
  710. package/dist/onboard-helpers-SCO3k5Y8.js +0 -364
  711. package/dist/onboard-remote-Co2hv1AD.js +0 -127
  712. package/dist/onboard-remote-Dl3BFSg2.js +0 -127
  713. package/dist/onboard-rioH3DW6.js +0 -647
  714. package/dist/onboarding-CsXVuzFP.js +0 -586
  715. package/dist/onboarding-r5RCkc-Z.js +0 -588
  716. package/dist/onboarding.finalize-BY8uN1nD.js +0 -402
  717. package/dist/onboarding.finalize-C-kfj-aR.js +0 -404
  718. package/dist/onboarding.gateway-config-BL0Q7Wpg.js +0 -201
  719. package/dist/onboarding.gateway-config-D2QsXMYO.js +0 -195
  720. package/dist/outbound-CcaPcetn.js +0 -220
  721. package/dist/outbound-CeiW8z3a.js +0 -221
  722. package/dist/outbound-attachment-BLSGI2dJ.js +0 -18
  723. package/dist/outbound-attachment-Bfm5-JYe.js +0 -18
  724. package/dist/outbound-attachment-CZ7zoYxB.js +0 -18
  725. package/dist/pairing-cli-CgX79ujL.js +0 -125
  726. package/dist/pairing-cli-DvbbXFgC.js +0 -129
  727. package/dist/pairing-labels-3wDxaApH.js +0 -9
  728. package/dist/pairing-labels-DCbWnbWk.js +0 -9
  729. package/dist/pairing-store-CdY7iRS0.js +0 -459
  730. package/dist/pairing-store-DykkYpQ7.js +0 -460
  731. package/dist/path-env-Cqo5LZmw.js +0 -89
  732. package/dist/path-guards-DOpzcMXz.js +0 -31
  733. package/dist/path-guards-DipYoPVw.js +0 -31
  734. package/dist/path-safety-CXKAVpMp.js +0 -14
  735. package/dist/path-safety-DGB91qBk.js +0 -14
  736. package/dist/paths-BTaH3rLn.js +0 -232
  737. package/dist/plugin-auto-enable-C6FPGg_-.js +0 -301
  738. package/dist/plugin-auto-enable-L8eOc8iC.js +0 -302
  739. package/dist/plugin-registry-BTycBIix.js +0 -33
  740. package/dist/plugin-registry-CFty9Gym.js +0 -33
  741. package/dist/plugin-sdk/auto-reply/reply/elevated-allowlist-matcher.d.ts +0 -20
  742. package/dist/plugin-sdk/auto-reply/reply/elevated-unavailable.d.ts +0 -8
  743. package/dist/plugin-sdk/auto-reply/reply/reply-elevated.d.ts +0 -16
  744. package/dist/plugin-sdk/compat/legacy-names.d.ts +0 -8
  745. package/dist/plugin-sdk/config/legacy.migrations.part-1.d.ts +0 -2
  746. package/dist/plugin-sdk/config/legacy.migrations.part-2.d.ts +0 -2
  747. package/dist/plugin-sdk/config/legacy.migrations.part-3.d.ts +0 -2
  748. package/dist/plugin-sdk/cron/legacy-delivery.d.ts +0 -3
  749. package/dist/plugin-sdk/cron/payload-migration.d.ts +0 -3
  750. package/dist/plugin-sdk/link-understanding/apply.d.ts +0 -10
  751. package/dist/plugin-sdk/link-understanding/defaults.d.ts +0 -2
  752. package/dist/plugin-sdk/link-understanding/detect.d.ts +0 -3
  753. package/dist/plugin-sdk/link-understanding/format.d.ts +0 -4
  754. package/dist/plugin-sdk/link-understanding/runner.d.ts +0 -11
  755. package/dist/plugin-sdk/media/input-files.d.ts +0 -95
  756. package/dist/plugin-sdk/media-understanding/apply.d.ts +0 -19
  757. package/dist/plugin-sdk/media-understanding/attachments.d.ts +0 -49
  758. package/dist/plugin-sdk/media-understanding/concurrency.d.ts +0 -1
  759. package/dist/plugin-sdk/media-understanding/defaults.d.ts +0 -11
  760. package/dist/plugin-sdk/media-understanding/errors.d.ts +0 -6
  761. package/dist/plugin-sdk/media-understanding/format.d.ts +0 -7
  762. package/dist/plugin-sdk/media-understanding/fs.d.ts +0 -1
  763. package/dist/plugin-sdk/media-understanding/output-extract.d.ts +0 -2
  764. package/dist/plugin-sdk/media-understanding/providers/anthropic/index.d.ts +0 -2
  765. package/dist/plugin-sdk/media-understanding/providers/deepgram/audio.d.ts +0 -1
  766. package/dist/plugin-sdk/media-understanding/providers/deepgram/index.d.ts +0 -2
  767. package/dist/plugin-sdk/media-understanding/providers/google/audio.d.ts +0 -1
  768. package/dist/plugin-sdk/media-understanding/providers/google/index.d.ts +0 -2
  769. package/dist/plugin-sdk/media-understanding/providers/google/video.d.ts +0 -3
  770. package/dist/plugin-sdk/media-understanding/providers/groq/index.d.ts +0 -2
  771. package/dist/plugin-sdk/media-understanding/providers/index.d.ts +0 -4
  772. package/dist/plugin-sdk/media-understanding/providers/minimax/index.d.ts +0 -2
  773. package/dist/plugin-sdk/media-understanding/providers/mistral/index.d.ts +0 -2
  774. package/dist/plugin-sdk/media-understanding/providers/moonshot/index.d.ts +0 -2
  775. package/dist/plugin-sdk/media-understanding/providers/moonshot/video.d.ts +0 -3
  776. package/dist/plugin-sdk/media-understanding/providers/openai/audio.d.ts +0 -1
  777. package/dist/plugin-sdk/media-understanding/providers/openai/index.d.ts +0 -2
  778. package/dist/plugin-sdk/media-understanding/providers/shared.d.ts +0 -20
  779. package/dist/plugin-sdk/media-understanding/providers/zai/index.d.ts +0 -2
  780. package/dist/plugin-sdk/media-understanding/resolve.d.ts +0 -44
  781. package/dist/plugin-sdk/media-understanding/runner.d.ts +0 -34
  782. package/dist/plugin-sdk/media-understanding/runner.entries.d.ts +0 -33
  783. package/dist/plugin-sdk/media-understanding/scope.d.ts +0 -9
  784. package/dist/plugin-sdk/media-understanding/types.d.ts +0 -59
  785. package/dist/plugin-sdk/media-understanding/video.d.ts +0 -2
  786. package/dist/plugin-sdk/utils/run-with-concurrency.d.ts +0 -11
  787. package/dist/plugins-7B167wIj.js +0 -453
  788. package/dist/plugins-BRHOfy1Z.js +0 -455
  789. package/dist/plugins-cli-CQGW40I-.js +0 -797
  790. package/dist/plugins-cli-D-ZfWRTw.js +0 -801
  791. package/dist/ports-CAqyeQYZ.js +0 -316
  792. package/dist/ports-CTUgXF2d.js +0 -96
  793. package/dist/ports-DqfnVnCw.js +0 -370
  794. package/dist/preflight-CJqKHCYa.js +0 -64
  795. package/dist/preflight-TR92sc61.js +0 -68
  796. package/dist/program-_SGrjcuG.js +0 -248
  797. package/dist/program-context-B6yIPfYd.js +0 -474
  798. package/dist/progress-BOdRbOHD.js +0 -124
  799. package/dist/prompt-WEkXwIMT.js +0 -21
  800. package/dist/prompt-select-styled-BiBnOTh8.js +0 -1669
  801. package/dist/prompt-select-styled-DQacku67.js +0 -1672
  802. package/dist/prompt-style-B4Cq4PyQ.js +0 -9
  803. package/dist/provider-dispatcher-BjsUFEpi.js +0 -659
  804. package/dist/provider-dispatcher-BxNDRVIT.js +0 -660
  805. package/dist/push-apns-Cj0Ryn18.js +0 -713
  806. package/dist/push-apns-fFfYCqda.js +0 -711
  807. package/dist/pw-ai-CnN2sITD.js +0 -1908
  808. package/dist/pw-ai-fnX3cecw.js +0 -1911
  809. package/dist/qr-cli-CriPg41m.js +0 -349
  810. package/dist/qr-cli-DSURqD0D.js +0 -353
  811. package/dist/redact-gXuh8MFk.js +0 -191
  812. package/dist/redact-snapshot-BecRL_h6.js +0 -2016
  813. package/dist/redact-snapshot-pTdzSrex.js +0 -2016
  814. package/dist/register.agent-Bpwvc5By.js +0 -1018
  815. package/dist/register.agent-DQFcnOVQ.js +0 -290
  816. package/dist/register.configure-C5CK8tgd.js +0 -133
  817. package/dist/register.configure-CEJ5Wrkl.js +0 -128
  818. package/dist/register.import-CPQqqdje.js +0 -31
  819. package/dist/register.import-D1UaH1QV.js +0 -29
  820. package/dist/register.maintenance-Bpz-NOhG.js +0 -499
  821. package/dist/register.maintenance-DDwlfAfw.js +0 -501
  822. package/dist/register.message-BoNswT8e.js +0 -685
  823. package/dist/register.message-pvz70g_-.js +0 -689
  824. package/dist/register.onboard-BvcVLNp3.js +0 -93
  825. package/dist/register.onboard-CZV7LvZI.js +0 -97
  826. package/dist/register.setup-Cgv2uSPG.js +0 -117
  827. package/dist/register.setup-yTqvTinY.js +0 -113
  828. package/dist/register.status-health-sessions-LK50hWDT.js +0 -428
  829. package/dist/register.status-health-sessions-kDGDihye.js +0 -668
  830. package/dist/register.subclis-DSr7AHAr.js +0 -267
  831. package/dist/replies-IpiCq1Ht.js +0 -136
  832. package/dist/replies-LSx_XhsP.js +0 -136
  833. package/dist/reply-B8It91bP.js +0 -13652
  834. package/dist/reply-CbgHVTv2.js +0 -13649
  835. package/dist/reply-directives-Cz7622Qx.js +0 -182
  836. package/dist/reply-directives-ssnaPNiU.js +0 -182
  837. package/dist/reply-payloads-CQMtrphw.js +0 -527
  838. package/dist/reply-prefix-CWcAZKhE.js +0 -37
  839. package/dist/reply-prefix-Drq7Pf3A.js +0 -37
  840. package/dist/resolve-route-B8uIc2H3.js +0 -249
  841. package/dist/resolve-route-C8ooNlI4.js +0 -249
  842. package/dist/response-prefix-template-D3ZcJP4E.js +0 -134
  843. package/dist/response-prefix-template-DPOggmPO.js +0 -134
  844. package/dist/retry-B19gMxS7.js +0 -77
  845. package/dist/retry-BdhJlZQI.js +0 -77
  846. package/dist/run-main-BP3UHEJa.js +0 -306
  847. package/dist/runner-CD3YycXx.js +0 -2365
  848. package/dist/runner-D74Wiza_.js +0 -2365
  849. package/dist/secure-random-CQa3H-OL.js +0 -44
  850. package/dist/security-cli-05blEYyC.js +0 -482
  851. package/dist/security-cli-DYbt8duB.js +0 -487
  852. package/dist/send-7O3-bRtl.js +0 -547
  853. package/dist/send-9Huf62k3.js +0 -2245
  854. package/dist/send-B0C42B2A.js +0 -426
  855. package/dist/send-B9mIJdUo.js +0 -547
  856. package/dist/send-BHm9dk6D.js +0 -1178
  857. package/dist/send-BetMntNc.js +0 -11
  858. package/dist/send-Bj0RXr-a.js +0 -492
  859. package/dist/send-COuVtZ4b.js +0 -374
  860. package/dist/send-CXNuhYA-.js +0 -332
  861. package/dist/send-Ce_BDa8P.js +0 -349
  862. package/dist/send-ChvasRSh.js +0 -1779
  863. package/dist/send-DNVRlTEF.js +0 -29
  864. package/dist/send-DWf7BCPe.js +0 -492
  865. package/dist/send-Dd2_MykI.js +0 -2245
  866. package/dist/send-IJaUAa8H.js +0 -1776
  867. package/dist/send-vvZXksNU.js +0 -349
  868. package/dist/server-BrzR9JmX.js +0 -206
  869. package/dist/server-_h27-uP_.js +0 -202
  870. package/dist/server-lifecycle-CUdA6Far.js +0 -2437
  871. package/dist/server-lifecycle-DQZWL8iP.js +0 -2437
  872. package/dist/server-node-events-DSefRBGC.js +0 -394
  873. package/dist/server-node-events-jDiG1-M2.js +0 -390
  874. package/dist/service-9le8AnC-.js +0 -670
  875. package/dist/service-Drb0kx6I.js +0 -670
  876. package/dist/session-BIAOl5QR.js +0 -170
  877. package/dist/session-Wu00pCn_.js +0 -170
  878. package/dist/session-cost-usage-7plmOKbs.js +0 -627
  879. package/dist/session-cost-usage-CPFxBFUg.js +0 -627
  880. package/dist/session-dirs-CfIrIJxG.js +0 -318
  881. package/dist/session-dirs-DlPpWt5Q.js +0 -318
  882. package/dist/session-utils-Sd9w4vc1.js +0 -622
  883. package/dist/session-utils-iL47hYmZ.js +0 -622
  884. package/dist/sessions-6pKQ3gN3.js +0 -247
  885. package/dist/sessions-ZRmCDdj1.js +0 -2569
  886. package/dist/shell-env-DYZq9PqC.js +0 -163
  887. package/dist/ssrf-B-rF_tZB.js +0 -183
  888. package/dist/ssrf-DJW14Wkh.js +0 -183
  889. package/dist/status-BGM-EJGk.js +0 -1983
  890. package/dist/status-CGkrO9om.js +0 -1979
  891. package/dist/status.update-DlBReI5-.js +0 -449
  892. package/dist/status.update-v7fEQ7R9.js +0 -449
  893. package/dist/store-B5989JkX.js +0 -64
  894. package/dist/store-BpXxa0Uf.js +0 -53
  895. package/dist/store-DCrrxHyS.js +0 -2571
  896. package/dist/store-Ql6vAcsg.js +0 -64
  897. package/dist/subagent-registry-BGknZEUI.js +0 -4856
  898. package/dist/subagent-registry-CWeRBjfn.js +0 -4854
  899. package/dist/subsystem-Ct6qOOqZ.js +0 -1079
  900. package/dist/subsystem-PQ64_nsu.js +0 -1136
  901. package/dist/system-cli-CmO-4Rju.js +0 -77
  902. package/dist/system-cli-VBsa18K6.js +0 -73
  903. package/dist/systemd-CqFpK30Y.js +0 -547
  904. package/dist/systemd-fK9AV5bP.js +0 -547
  905. package/dist/systemd-hints-D3rr0j14.js +0 -278
  906. package/dist/systemd-hints-DNOSRaqA.js +0 -278
  907. package/dist/systemd-linger-B907NVVy.js +0 -75
  908. package/dist/systemd-linger-wYksBbM7.js +0 -75
  909. package/dist/table-C-dba-5-.js +0 -279
  910. package/dist/tables-CO_kxD0e.js +0 -55
  911. package/dist/tables-Rd6ZUH0u.js +0 -55
  912. package/dist/tables-WZp8Vt9n.js +0 -55
  913. package/dist/tailnet-CfZhpSnt.js +0 -40
  914. package/dist/tailnet-D0NV0tRJ.js +0 -40
  915. package/dist/tailscale-B__xvMjA.js +0 -230
  916. package/dist/tailscale-q_ZrxUCc.js +0 -230
  917. package/dist/targets-B4rMyQFJ.js +0 -53
  918. package/dist/targets-BEBzTa22.js +0 -114
  919. package/dist/targets-BjWhDMJM.js +0 -650
  920. package/dist/targets-BlEVuFSt.js +0 -2474
  921. package/dist/targets-CHwGDIgO.js +0 -650
  922. package/dist/targets-CbbmgMRV.js +0 -2473
  923. package/dist/targets-SpN-MPBH.js +0 -220
  924. package/dist/targets-mqj9GNg1.js +0 -53
  925. package/dist/thinking-BqJmU6Zp.js +0 -88
  926. package/dist/thinking-l-rrvZwu.js +0 -88
  927. package/dist/tokens-DAFBx5qr.js +0 -21
  928. package/dist/tool-display-C0hpLmkw.js +0 -785
  929. package/dist/tool-display-CQTRHo3Z.js +0 -785
  930. package/dist/tool-images-BYY11Gw3.js +0 -263
  931. package/dist/tool-images-CnJ0R8Fo.js +0 -263
  932. package/dist/trash-C0mjnHuW.js +0 -125
  933. package/dist/trash-Cgwc9mLD.js +0 -125
  934. package/dist/tui-9cJnR1dN.js +0 -3282
  935. package/dist/tui-BR3egaFJ.js +0 -3282
  936. package/dist/tui-cli-BYpkhE6J.js +0 -66
  937. package/dist/tui-cli-DndeZyup.js +0 -62
  938. package/dist/update-BJVdkzk7.js +0 -349
  939. package/dist/update-DjI6KTA5.js +0 -349
  940. package/dist/update-cli-DR-zFdCm.js +0 -1146
  941. package/dist/update-cli-EuHV_AUf.js +0 -1148
  942. package/dist/usage-BQUMGgBj.js +0 -5350
  943. package/dist/utils-C5daYcFn.js +0 -631
  944. package/dist/voice-credentials-CXdoE4IF.js +0 -45
  945. package/dist/voice-credentials-Cu7htUQq.js +0 -45
  946. package/dist/web-6WVkqhtO.js +0 -3087
  947. package/dist/web-BfSXKISl.js +0 -74
  948. package/dist/web-Cngqu3vs.js +0 -79
  949. package/dist/webhooks-cli-0yQha2yj.js +0 -334
  950. package/dist/webhooks-cli-ula0bTX-.js +0 -330
  951. package/dist/whatsapp-actions-3NdzsNg1.js +0 -130
  952. package/dist/whatsapp-actions-y_1vjkYY.js +0 -125
  953. package/dist/widearea-dns-C-0P7TRi.js +0 -127
  954. package/dist/workspace-BT3X-qCZ.js +0 -449
  955. package/dist/workspace-D5hHXubL.js +0 -447
  956. package/dist/zod-schema-CbqZAIYy.js +0 -2696
  957. package/dist/zod-schema-YGQJEcnj.js +0 -2696
  958. /package/dist/{account-lookup-BOCzCnir.js → account-lookup-CIY_RKhi.js} +0 -0
  959. /package/dist/{agent-helpers-eEHy5uX2.js → agent-helpers-Bs2nBXeI.js} +0 -0
  960. /package/dist/{api-Cd_7aESj.js → api-BE4ZCWWB.js} +0 -0
  961. /package/dist/{api-DJ_oWYus.js → api-wsk9zRVi.js} +0 -0
  962. /package/dist/{chat-type-DyovJwCt.js → chat-type-BP9akbag.js} +0 -0
  963. /package/dist/{chunk-CWD_zrz_.js → chunk-BAMyFYtF.js} +0 -0
  964. /package/dist/{cleanup-utils-gNzIs9yk.js → cleanup-utils-ZC2zvntc.js} +0 -0
  965. /package/dist/{cli-name-3MdfbvIR.js → cli-name-BZsYSp9l.js} +0 -0
  966. /package/dist/{cli-name-CRLBidNP.js → cli-name-CRe5Ow_t.js} +0 -0
  967. /package/dist/{cli-utils-5ZIfXAfM.js → cli-utils-CGB3cBZm.js} +0 -0
  968. /package/dist/{client-D5m46AuY.js → client-9dK56xly.js} +0 -0
  969. /package/dist/{client-DFyI5I0n.js → client-D-R1YdRD.js} +0 -0
  970. /package/dist/{command-options-Cn2fc1Of.js → command-options-CnHA4TzR.js} +0 -0
  971. /package/dist/{config-eval-BCKpAS_K.js → config-eval-BQIR-wSg.js} +0 -0
  972. /package/dist/{config-eval-CU2G7a83.js → config-eval-Bh82JoXK.js} +0 -0
  973. /package/dist/{constants-CRGAZ2ow.js → constants-C7j1VA2S.js} +0 -0
  974. /package/dist/{constants-BAZuhSRm.js → constants-PMRtHBHU.js} +0 -0
  975. /package/dist/{credentials-DMAWNZdV.js → credentials-C_RoJFmK.js} +0 -0
  976. /package/dist/{credentials-Dmc3H-jd.js → credentials-DM_Dj0m8.js} +0 -0
  977. /package/dist/{daemon-runtime-aQhinwSL.js → daemon-runtime-9oDBR7YW.js} +0 -0
  978. /package/dist/{dangerous-name-matching-BCaPvXy_.js → dangerous-name-matching-CSq9sJDG.js} +0 -0
  979. /package/dist/{dangerous-tools-E1i3IoxZ.js → dangerous-tools-D4jtl72G.js} +0 -0
  980. /package/dist/{fetch-DTR2MlOk.js → fetch-DTsU2XnC.js} +0 -0
  981. /package/dist/{fetch-timeout-l_6RdoMw.js → fetch-timeout-CytN1wiO.js} +0 -0
  982. /package/dist/{file-identity-BnGA6wyc.js → file-identity-CeRK5CJC.js} +0 -0
  983. /package/dist/{format-relative-Cywx6ldk.js → format-relative-Czf5fUjn.js} +0 -0
  984. /package/dist/{format-relative-DcQZUAYl.js → format-relative-zwkkXJvs.js} +0 -0
  985. /package/dist/{health-format-CL2Xq92A.js → health-format-DF54wvUU.js} +0 -0
  986. /package/dist/{heartbeat-wake-DjsTDzF3.js → heartbeat-wake-CvHncCjP.js} +0 -0
  987. /package/dist/{helpers-D-r6yhnI.js → helpers-DAEoFkbn.js} +0 -0
  988. /package/dist/{helpers-DSMIGYx2.js → helpers-n2CtWpm9.js} +0 -0
  989. /package/dist/{helpers-CRrn7Err.js → helpers-ndPQWl6m.js} +0 -0
  990. /package/dist/{input-provenance-BgfeDgck.js → input-provenance-gIfDn1ki.js} +0 -0
  991. /package/dist/{input-provenance-xUsSMOsz.js → input-provenance-wkso1o5V.js} +0 -0
  992. /package/dist/{ip-BAhS4rY2.js → ip-D4VG5EJO.js} +0 -0
  993. /package/dist/{ip-BUhsZdJu.js → ip-MwCwRA7c.js} +0 -0
  994. /package/dist/{json-file-Dbg7nZg1.js → json-file-BW22hGtf.js} +0 -0
  995. /package/dist/{json-file-B5WEJJye.js → json-file-DwRAfAAy.js} +0 -0
  996. /package/dist/{json-files-CfhnuGaC.js → json-files-BI20PLIm.js} +0 -0
  997. /package/dist/{json-files-BFGbyEzL.js → json-files-Dy52honG.js} +0 -0
  998. /package/dist/{lanes-4FoQemog.js → lanes-1CBKdsiR.js} +0 -0
  999. /package/dist/{lanes-BhdzrAIa.js → lanes-DqVYfPRG.js} +0 -0
  1000. /package/dist/{logger-IA_Dr_BT.js → logger-B8BE0PyS.js} +0 -0
  1001. /package/dist/{logger-nEdVxm5D.js → logger-CPvz-aPM.js} +0 -0
  1002. /package/dist/{logger-O6JX52kK.js → logger-cL0D2DCr.js} +0 -0
  1003. /package/dist/{logging-BiuZwq5D.js → logging-DRwtiLIS.js} +0 -0
  1004. /package/dist/{logging-Bs1VqVFL.js → logging-DTEoeoa3.js} +0 -0
  1005. /package/dist/{logging-JZEg5nDp.js → logging-fywhKCmE.js} +0 -0
  1006. /package/dist/{mutable-allowlist-detectors-TCG6mnbz.js → mutable-allowlist-detectors-BXE7Hr7F.js} +0 -0
  1007. /package/dist/{onboard-config-BxfgUqk6.js → onboard-config-DOmXYEvJ.js} +0 -0
  1008. /package/dist/{onboard-config-DNzlo8Cg.js → onboard-config-JmR21VYa.js} +0 -0
  1009. /package/dist/{parse-log-line-CT0H1-oQ.js → parse-log-line-GisaZn5H.js} +0 -0
  1010. /package/dist/{parse-log-line-pij_xhtE.js → parse-log-line-ZsbwG_u7.js} +0 -0
  1011. /package/dist/{parse-timeout-CvODy9RC.js → parse-timeout-BpphuwYl.js} +0 -0
  1012. /package/dist/{parse-timeout-CxYHsZWc.js → parse-timeout-CE6BjmGU.js} +0 -0
  1013. /package/dist/plugin-sdk/{media-understanding → stt}/providers/google/inline-data.d.ts +0 -0
  1014. /package/dist/{plugins-allowlist-Bcqe9Gd8.js → plugins-allowlist-A38nxBRG.js} +0 -0
  1015. /package/dist/{plugins-allowlist-ptAp-oPY.js → plugins-allowlist-D2tS9tcu.js} +0 -0
  1016. /package/dist/{polls-DQrR-qT3.js → polls-BLyT08ZI.js} +0 -0
  1017. /package/dist/{polls-ybwcqkWt.js → polls-BmymsJEe.js} +0 -0
  1018. /package/dist/{ports-BS8kQkd9.js → ports-DALdfBQy.js} +0 -0
  1019. /package/dist/{process-scoped-map-BwUkYFQV.js → process-scoped-map-BCJR56ZB.js} +0 -0
  1020. /package/dist/{process-scoped-map-_zxf_kLz.js → process-scoped-map-Cb1EHPyN.js} +0 -0
  1021. /package/dist/{program-context-CG-t6Yp-.js → program-context-DlXnmuB7.js} +0 -0
  1022. /package/dist/{prompt-style-B1740PBl.js → prompt-style-CUuA6OCy.js} +0 -0
  1023. /package/dist/{proxy-BdjLhNln.js → proxy-D-qGA1vm.js} +0 -0
  1024. /package/dist/{pw-ai-state-DaISdsXY.js → pw-ai-state--TxTVwRW.js} +0 -0
  1025. /package/dist/{redact-CqWx9rpK.js → redact-BW8tobyp.js} +0 -0
  1026. /package/dist/{redact-identifier-DR54qsoT.js → redact-identifier-Bv5SUUw-.js} +0 -0
  1027. /package/dist/{remoteclaw-root-u8dAeHID.js → remoteclaw-root-BfPjgewe.js} +0 -0
  1028. /package/dist/{remoteclaw-root-CgNyrbxc.js → remoteclaw-root-E4-hmb4E.js} +0 -0
  1029. /package/dist/{render-CDCvpfhh.js → render-BhKzKdV0.js} +0 -0
  1030. /package/dist/{render-CJl4GK1B.js → render-e7fENCYH.js} +0 -0
  1031. /package/dist/{retry-cXXk2j6_.js → retry-BWv_fy4u.js} +0 -0
  1032. /package/dist/{runtime-guard-BS55uiSW.js → runtime-guard-Bhx-pb8_.js} +0 -0
  1033. /package/dist/{runtime-status-BhW7hP_U.js → runtime-status-CR9445g5.js} +0 -0
  1034. /package/dist/{secret-equal-CJzes24Z.js → secret-equal-D6AoXne1.js} +0 -0
  1035. /package/dist/{secret-equal-CQAmGfGc.js → secret-equal-DLnUuWM3.js} +0 -0
  1036. /package/dist/{secure-random-B3f7Ri2X.js → secure-random-CJtykx_p.js} +0 -0
  1037. /package/dist/{secure-random-BkZFG9cd.js → secure-random-CRVHgtmO.js} +0 -0
  1038. /package/dist/{stagger-B-_Wnofy.js → stagger--wvODnNe.js} +0 -0
  1039. /package/dist/{stagger-B2ORDHsP.js → stagger-BLmTO4cK.js} +0 -0
  1040. /package/dist/{status-C6YNwimj.js → status-1zVD-Clq.js} +0 -0
  1041. /package/dist/{status-yrDGXYZM.js → status-BtRY0nXQ.js} +0 -0
  1042. /package/dist/{strip-inbound-meta-0cvL6itU.js → strip-inbound-meta-zmUXypSS.js} +0 -0
  1043. /package/dist/{strip-inbound-meta-DjKcSFaW.js → strip-inbound-meta-zqtN9FTK.js} +0 -0
  1044. /package/dist/{table-ByMyHTh_.js → table-On3hkCqi.js} +0 -0
  1045. /package/dist/{targets-DOJXjN1U.js → targets-B46m7u5J.js} +0 -0
  1046. /package/dist/{targets-WSwPflb6.js → targets-D7PT_rdO.js} +0 -0
  1047. /package/dist/{text-format-mr5bZq0f.js → text-format-Ds92M9UT.js} +0 -0
  1048. /package/dist/{tokens-C8yGxAcR.js → tokens-Dw7ZdYwT.js} +0 -0
  1049. /package/dist/{usage-BXi79Rq6.js → usage-BIzKZ5dT.js} +0 -0
  1050. /package/dist/{usage-C1lHaofV.js → usage-BvZOzIC7.js} +0 -0
  1051. /package/dist/{usage-format-CD5jsZY1.js → usage-format-CmniSPCG.js} +0 -0
  1052. /package/dist/{usage-format-CRVpDVj1.js → usage-format-D_KQYQ-w.js} +0 -0
  1053. /package/dist/{widearea-dns-DFZMcfLf.js → widearea-dns-D01FFYZ8.js} +0 -0
  1054. /package/dist/{wsl-D28w2jQC.js → wsl-PDLKeX04.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 };