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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1199) hide show
  1. package/README.md +11 -9
  2. package/dist/accounts-79XhjwAj.js +32 -0
  3. package/dist/accounts-B1M3fOxL.js +272 -0
  4. package/dist/accounts-BwbvnKsW.js +205 -0
  5. package/dist/accounts-CIVjmTg9.js +270 -0
  6. package/dist/accounts-D1awQXKu.js +36 -0
  7. package/dist/accounts-DHkGVGUR.js +36 -0
  8. package/dist/accounts-P7cmIXUM.js +206 -0
  9. package/dist/accounts-XFgBY644.js +47 -0
  10. package/dist/accounts-_ZuNC5bz.js +47 -0
  11. package/dist/ack-reactions-BGJ9Vigf.js +621 -0
  12. package/dist/ack-reactions-Diu9O24z.js +621 -0
  13. package/dist/acp-cli-BwZ-va2P.js +1316 -0
  14. package/dist/acp-cli-eVKByz-j.js +1311 -0
  15. package/dist/active-listener--jrUO-8L.js +37 -0
  16. package/dist/active-listener-C7SyMcNY.js +37 -0
  17. package/dist/agent-BAxK2KQW.js +688 -0
  18. package/dist/agent-Dd5Yfhmq.js +687 -0
  19. package/dist/agent-helpers-5F0tdxud.js +400 -0
  20. package/dist/agent-helpers-Bs2nBXeI.js +400 -0
  21. package/dist/agent-scope-BA1HP4K6.js +114 -0
  22. package/dist/agent-scope-CAQLm3LP.js +116 -0
  23. package/dist/agents-D--9DD91.js +754 -0
  24. package/dist/agents.config-CmyzLYqW.js +116 -0
  25. package/dist/agents.config-DerBqRzk.js +116 -0
  26. package/dist/ansi-DtaiOnt1.js +107 -0
  27. package/dist/audio-ClIuKwkl.js +43 -0
  28. package/dist/audio-DqlIYYTb.js +43 -0
  29. package/dist/audit-Cn0cNCE4.js +3114 -0
  30. package/dist/audit-DXY4NHBC.js +3114 -0
  31. package/dist/auth-B-QK8JhI.js +315 -0
  32. package/dist/auth-C1zx1O24.js +314 -0
  33. package/dist/auth-DDmNYVMW.js +448 -0
  34. package/dist/auth-DH1wEw0w.js +448 -0
  35. package/dist/banner-CBWZhANO.js +294 -0
  36. package/dist/binaries-CYwLdubd.js +13 -0
  37. package/dist/bindings-DFAFatwT.js +69 -0
  38. package/dist/bindings-GUKIzFCp.js +69 -0
  39. package/dist/bonjour-discovery-AQMJqY4V.js +378 -0
  40. package/dist/bonjour-discovery-BLcPWHFJ.js +378 -0
  41. package/dist/boot/handler.js +41 -84
  42. package/dist/browser-cli-8Dv5ogFT.js +1690 -0
  43. package/dist/browser-cli-wNLo8SOy.js +1694 -0
  44. package/dist/build-info.json +3 -3
  45. package/dist/call-BTHzKFbN.js +518 -0
  46. package/dist/call-D_NchaCs.js +517 -0
  47. package/dist/canvas-host/a2ui/.bundle.hash +1 -1
  48. package/dist/catalog-DgpN5jxU.js +186 -0
  49. package/dist/catalog-k056Nh93.js +186 -0
  50. package/dist/channel-account-context-BHIy71Yh.js +133 -0
  51. package/dist/channel-account-context-DXU_-EkJ.js +133 -0
  52. package/dist/channel-activity-BatlvP_U.js +292 -0
  53. package/dist/channel-activity-BhT7NQ_v.js +94 -0
  54. package/dist/channel-activity-CvjEwpJz.js +94 -0
  55. package/dist/channel-options-BCccA2WC.js +32 -0
  56. package/dist/channel-options-VPR_pNyS.js +33 -0
  57. package/dist/channel-selection-AH6_y6RS.js +51 -0
  58. package/dist/channel-selection-ovohyJQZ.js +51 -0
  59. package/dist/channel-web-APDaQ_wp.js +2134 -0
  60. package/dist/channel-web-BW_YuNlT.js +2132 -0
  61. package/dist/channels-cli-DVsZyaU5.js +1436 -0
  62. package/dist/channels-cli-ubrg5vcL.js +1440 -0
  63. package/dist/channels-status-issues-BbYNzwLp.js +18 -0
  64. package/dist/channels-status-issues-DRybAijg.js +18 -0
  65. package/dist/chat-envelope-AJFUAuBM.js +248 -0
  66. package/dist/chat-envelope-BrfcPlDM.js +248 -0
  67. package/dist/chrome-Bv2UtAMQ.js +1732 -0
  68. package/dist/chrome-C6Vc_7su.js +1733 -0
  69. package/dist/chunk-BAMyFYtF.js +341 -0
  70. package/dist/chunk-BzVoFUZL.js +341 -0
  71. package/dist/clack-prompter-C6mBTOzE.js +122 -0
  72. package/dist/clack-prompter-DKcYqv3o.js +121 -0
  73. package/dist/cleanup-utils-Cb-leJcy.js +94 -0
  74. package/dist/cli/daemon-cli.js +1 -1
  75. package/dist/cli-Cs1n6-eD.js +135 -0
  76. package/dist/cli-Di3p1tLN.js +131 -0
  77. package/dist/client-B6h7bgbF.js +2311 -0
  78. package/dist/client-CMtdm9Ii.js +2311 -0
  79. package/dist/clipboard-A06eV_5C.js +31 -0
  80. package/dist/clipboard-DQBl3coj.js +31 -0
  81. package/dist/command-format-BiiNHkWG.js +18 -0
  82. package/dist/command-format-Dntg_tnC.js +32 -0
  83. package/dist/command-logger/handler.js +1 -1
  84. package/dist/command-registry-CCAvdWh2.js +215 -0
  85. package/dist/commands-D93TXYhv.js +41 -0
  86. package/dist/commands-UD7V7QC9.js +41 -0
  87. package/dist/commands-registry-CCbTtSSK.js +891 -0
  88. package/dist/commands-registry-De8JhZLG.js +890 -0
  89. package/dist/common-D4fL3S2m.js +156 -0
  90. package/dist/common-DXNisGxw.js +156 -0
  91. package/dist/completion-cli-CLo-r-UP.js +452 -0
  92. package/dist/completion-cli-D4ajG3yt.js +452 -0
  93. package/dist/config-BTH7fB_v.js +3345 -0
  94. package/dist/config-DwuBnd6D.js +3347 -0
  95. package/dist/config-cli-D0D1LSNt.js +243 -0
  96. package/dist/config-cli-tWsFNKQM.js +247 -0
  97. package/dist/config-guard-BcT7soTj.js +92 -0
  98. package/dist/config-guard-Bqak3bDc.js +75 -0
  99. package/dist/config-validation-CHEjSJ5K.js +18 -0
  100. package/dist/config-validation-CvgqLhyG.js +18 -0
  101. package/dist/configure-CK_0tFJG.js +889 -0
  102. package/dist/configure-D0z0kE-B.js +891 -0
  103. package/dist/constants-BBVTjb1j.js +75 -0
  104. package/dist/constants-PMRtHBHU.js +75 -0
  105. package/dist/control-auth-DrGYtMJM.js +397 -0
  106. package/dist/control-auth-KY4Qdr2I.js +397 -0
  107. package/dist/control-ui/assets/index-DdiU_ccM.css +1 -0
  108. package/dist/control-ui/assets/index-kVUYi64u.js +7723 -0
  109. package/dist/control-ui/assets/index-kVUYi64u.js.map +1 -0
  110. package/dist/control-ui/index.html +2 -2
  111. package/dist/control-ui-assets-DO1L6M0S.js +186 -0
  112. package/dist/control-ui-assets-S_TLo6Fs.js +186 -0
  113. package/dist/conversation-label-CDH4rKMG.js +36 -0
  114. package/dist/conversation-label-CMOfgCVl.js +36 -0
  115. package/dist/cron-cli-C7h_hLHu.js +495 -0
  116. package/dist/cron-cli-DTNg0Uvl.js +499 -0
  117. package/dist/daemon-cli-BlJS9zWM.js +737 -0
  118. package/dist/daemon-cli-Cfc1yszp.js +735 -0
  119. package/dist/daemon-cli.js +174 -1167
  120. package/dist/daemon-install-BbBLuLWg.js +60 -0
  121. package/dist/daemon-install-WEBvqVOj.js +56 -0
  122. package/dist/daemon-install-helpers-BVtPC2TK.js +504 -0
  123. package/dist/daemon-install-helpers-DVr51zvE.js +504 -0
  124. package/dist/deliver-EB272zWh.js +481 -0
  125. package/dist/deliver-iGD_woru.js +481 -0
  126. package/dist/delivery-queue-BDvalA10.js +244 -0
  127. package/dist/delivery-queue-BimvYz5E.js +244 -0
  128. package/dist/devices-cli-BXCOsNFc.js +323 -0
  129. package/dist/devices-cli-CHGdYfrz.js +319 -0
  130. package/dist/diagnostics-BzzhTQzK.js +35 -0
  131. package/dist/diagnostics-DILtxtcE.js +35 -0
  132. package/dist/directory-cli-COS40yI9.js +221 -0
  133. package/dist/directory-cli-Cb5j1JTC.js +225 -0
  134. package/dist/dispatcher-BUqxh_mA.js +174 -0
  135. package/dist/dispatcher-By-KZRWZ.js +173 -0
  136. package/dist/dm-policy-shared-BCp9_z3w.js +22 -0
  137. package/dist/dm-policy-shared-DgeKqjOu.js +22 -0
  138. package/dist/dns-cli-B8yyXB2N.js +203 -0
  139. package/dist/dns-cli-DAkTk-gM.js +199 -0
  140. package/dist/dock-B0bIIDS3.js +906 -0
  141. package/dist/dock-C3PzQ6CS.js +907 -0
  142. package/dist/doctor-completion-BXGEqLhU.js +92 -0
  143. package/dist/doctor-completion-D_mNzioP.js +92 -0
  144. package/dist/doctor-config-flow-BDDsR2J1.js +978 -0
  145. package/dist/doctor-config-flow-CwFFRUic.js +979 -0
  146. package/dist/enable-C3I9dWel.js +59 -0
  147. package/dist/enable-DnwKeWnR.js +59 -0
  148. package/dist/entry.js +75 -21
  149. package/dist/env-DyyqmxSM.js +60 -0
  150. package/dist/env-vars-CD2_baIP.js +43 -0
  151. package/dist/env-vars-a7S70ba7.js +43 -0
  152. package/dist/errors-0dfGxeYQ.js +35 -0
  153. package/dist/errors-C1kDByVU.js +35 -0
  154. package/dist/exec-CAk1dxq_.js +164 -0
  155. package/dist/exec-epNpA1aU.js +164 -0
  156. package/dist/export-html/template.css +0 -36
  157. package/dist/export-html/template.js +1 -32
  158. package/dist/extensionAPI.js +1765 -1590
  159. package/dist/fetch-BMQq41sB.js +281 -0
  160. package/dist/fetch-Cky99wYB.js +281 -0
  161. package/dist/fetch-D3tw4B4n.js +67 -0
  162. package/dist/fetch-DTsU2XnC.js +67 -0
  163. package/dist/fetch-Dgm9ZHFm.js +67 -0
  164. package/dist/file-lock-DWH0TfVu.js +107 -0
  165. package/dist/file-lock-DXW9h9ek.js +107 -0
  166. package/dist/fs-safe-BjSd07M4.js +115 -0
  167. package/dist/fs-safe-aWIhCWlb.js +125 -0
  168. package/dist/gateway-cli-C4y4H61g.js +24546 -0
  169. package/dist/gateway-cli-CtFr42NV.js +24550 -0
  170. package/dist/gateway-rpc-B92CH0D3.js +28 -0
  171. package/dist/gateway-rpc-DZNlWapO.js +28 -0
  172. package/dist/gmail-setup-utils-CKyh29_R.js +422 -0
  173. package/dist/gmail-setup-utils-DquflkMR.js +423 -0
  174. package/dist/health-BYl7T-4m.js +1417 -0
  175. package/dist/health-DdviISKg.js +1414 -0
  176. package/dist/health-format-BE5TK5bs.js +28 -0
  177. package/dist/heartbeat-visibility-BO3iRpB6.js +125 -0
  178. package/dist/heartbeat-visibility-Cwp4TrTv.js +125 -0
  179. package/dist/help-format-D3JhWp1E.js +17 -0
  180. package/dist/helpers-DAEoFkbn.js +10 -0
  181. package/dist/helpers-ndPQWl6m.js +10 -0
  182. package/dist/hook-runner-global-C1thol1d.js +527 -0
  183. package/dist/hooks-cli-BKS9uZ0H.js +1221 -0
  184. package/dist/hooks-cli-FLWcCr9q.js +1217 -0
  185. package/dist/host-env-security-BGibnCbS.js +106 -0
  186. package/dist/host-env-security-axRnIi8d.js +106 -0
  187. package/dist/image-ops-CX41n0v5.js +354 -0
  188. package/dist/image-ops-DSL3eFfQ.js +354 -0
  189. package/dist/import-BSFgt760.js +604 -0
  190. package/dist/import-Da1CHJJg.js +606 -0
  191. package/dist/inbound-context-BLy-G2Eq.js +68 -0
  192. package/dist/inbound-context-a5bzQvRt.js +68 -0
  193. package/dist/index.js +137 -108
  194. package/dist/inspect-BEpFbi0c.js +286 -0
  195. package/dist/inspect-BeNNpWna.js +286 -0
  196. package/dist/installs-CH7Qq_m_.js +319 -0
  197. package/dist/installs-CcM8H2YA.js +319 -0
  198. package/dist/ipv4-DNo9AFDu.js +46 -0
  199. package/dist/ipv4-VfoVR5uR.js +46 -0
  200. package/dist/ir-BPwP8hIc.js +972 -0
  201. package/dist/json-files-BI20PLIm.js +46 -0
  202. package/dist/lifecycle-core-5Zxqwa6V.js +476 -0
  203. package/dist/lifecycle-core-C1bGeLby.js +474 -0
  204. package/dist/links-CtGBIrG8.js +15 -0
  205. package/dist/loader-BoP3JA-r.js +22411 -0
  206. package/dist/loader-DXbpue-L.js +22414 -0
  207. package/dist/logger-ASsO5Nz-.js +49 -0
  208. package/dist/logging-Cd9y2AdQ.js +20 -0
  209. package/dist/logging-DRwtiLIS.js +1 -0
  210. package/dist/logging-fywhKCmE.js +1 -0
  211. package/dist/login-B2UXzgaB.js +61 -0
  212. package/dist/login-BEFL3xY9.js +62 -0
  213. package/dist/login-qr-C7wAz2fe.js +329 -0
  214. package/dist/login-qr-DWpUP1Ud.js +325 -0
  215. package/dist/logs-cli-CAcd-pXA.js +240 -0
  216. package/dist/logs-cli-D7Bzarht.js +236 -0
  217. package/dist/markdown-tables-BBNUZp4n.js +29 -0
  218. package/dist/markdown-tables-NgPcfXoF.js +29 -0
  219. package/dist/media-4-qOIjO-.js +971 -0
  220. package/dist/media-DTwJhAbE.js +9481 -0
  221. package/dist/message-action-names-BsNTjuBE.js +2520 -0
  222. package/dist/message-action-names-ocKcq8_3.js +2520 -0
  223. package/dist/message-channel-CtcVHawF.js +91 -0
  224. package/dist/message-channel-tuc9CdEw.js +91 -0
  225. package/dist/mime-CAqaK3kp.js +146 -0
  226. package/dist/mime-ViuhRuMM.js +146 -0
  227. package/dist/net-DSkFMHJ8.js +225 -0
  228. package/dist/net-DTqfFYzt.js +225 -0
  229. package/dist/node-cli-BeXU67eQ.js +1458 -0
  230. package/dist/node-cli-i2aCtnmM.js +1462 -0
  231. package/dist/node-service-RyMlWp8N.js +67 -0
  232. package/dist/node-service-TL9b6Qfz.js +67 -0
  233. package/dist/nodes-cli-CtqnXBMD.js +1346 -0
  234. package/dist/nodes-cli-DgQU3LrG.js +1350 -0
  235. package/dist/nodes-screen-B7HJugJ0.js +250 -0
  236. package/dist/nodes-screen-nCRd71Mk.js +250 -0
  237. package/dist/note-B6142LyJ.js +92 -0
  238. package/dist/note-D-EI0czq.js +92 -0
  239. package/dist/npm-registry-spec-PPyRXSpx.js +786 -0
  240. package/dist/npm-registry-spec-uUmDWe6v.js +786 -0
  241. package/dist/npm-resolution-BC1LqCm2.js +86 -0
  242. package/dist/npm-resolution-DhlhUmRF.js +86 -0
  243. package/dist/onboard-CGpC2ecw.js +647 -0
  244. package/dist/onboard-auth-cNtb3FTP.js +211 -0
  245. package/dist/onboard-auth-gwz-0mZ6.js +207 -0
  246. package/dist/onboard-channels-CXjJYzHC.js +2548 -0
  247. package/dist/onboard-channels-vtaIxYml.js +2549 -0
  248. package/dist/onboard-config-DOmXYEvJ.js +39 -0
  249. package/dist/onboard-config-JmR21VYa.js +39 -0
  250. package/dist/onboard-helpers-8afRV_Tm.js +364 -0
  251. package/dist/onboard-helpers-DTRrJLj-.js +363 -0
  252. package/dist/onboard-jLzfwoPx.js +649 -0
  253. package/dist/onboard-remote-CFkvVAYg.js +127 -0
  254. package/dist/onboard-remote-JfBnmK70.js +127 -0
  255. package/dist/onboarding-Dt0LKvZn.js +586 -0
  256. package/dist/onboarding-gMKlA2bP.js +588 -0
  257. package/dist/onboarding.finalize-BDML6Jx7.js +403 -0
  258. package/dist/onboarding.finalize-D850VgMA.js +405 -0
  259. package/dist/onboarding.gateway-config-DolBTXWT.js +196 -0
  260. package/dist/onboarding.gateway-config-rJkIamlG.js +202 -0
  261. package/dist/outbound-CPMaDtgC.js +220 -0
  262. package/dist/outbound-CYSuCMiW.js +221 -0
  263. package/dist/outbound-attachment-Ci02LXoq.js +18 -0
  264. package/dist/outbound-attachment-CqZ7Qc_o.js +18 -0
  265. package/dist/outbound-attachment-CuqWdsdV.js +18 -0
  266. package/dist/pairing-cli-B9JKvvST.js +126 -0
  267. package/dist/pairing-cli-C4HrfIHe.js +130 -0
  268. package/dist/pairing-labels-CBmGQ31P.js +9 -0
  269. package/dist/pairing-labels-D0xwC7Xb.js +9 -0
  270. package/dist/pairing-store-BoF0g-iN.js +459 -0
  271. package/dist/pairing-store-CseXj-5p.js +460 -0
  272. package/dist/path-env-CPZbb7me.js +89 -0
  273. package/dist/path-env-GTM4HXCN.js +89 -0
  274. package/dist/path-safety-BFE0XmGC.js +14 -0
  275. package/dist/path-safety-BJ8ge6Ho.js +14 -0
  276. package/dist/paths-DHuXVC00.js +229 -0
  277. package/dist/plugin-auto-enable-B_9J1XED.js +302 -0
  278. package/dist/plugin-auto-enable-DghjlFCL.js +301 -0
  279. package/dist/plugin-registry-68h2T8vi.js +33 -0
  280. package/dist/plugin-registry-BitdVPb4.js +33 -0
  281. package/dist/plugin-sdk/agents/agent-helpers.d.ts +0 -1
  282. package/dist/plugin-sdk/agents/agent-scope.d.ts +11 -0
  283. package/dist/plugin-sdk/agents/agent-types.d.ts +1 -6
  284. package/dist/plugin-sdk/agents/agent-utils.d.ts +0 -14
  285. package/dist/plugin-sdk/agents/provider-utils.d.ts +0 -1
  286. package/dist/plugin-sdk/agents/subagent-registry.store.d.ts +0 -1
  287. package/dist/plugin-sdk/agents/subagent-spawn.d.ts +0 -1
  288. package/dist/plugin-sdk/agents/tools/sessions-helpers.d.ts +0 -1
  289. package/dist/plugin-sdk/auth/constants.d.ts +15 -0
  290. package/dist/plugin-sdk/auth/display.d.ts +7 -0
  291. package/dist/plugin-sdk/auth/doctor.d.ts +8 -0
  292. package/dist/plugin-sdk/auth/env-injection.d.ts +38 -0
  293. package/dist/plugin-sdk/auth/index.d.ts +10 -0
  294. package/dist/plugin-sdk/auth/oauth.d.ts +13 -0
  295. package/dist/plugin-sdk/auth/order.d.ts +8 -0
  296. package/dist/plugin-sdk/auth/paths.d.ts +3 -0
  297. package/dist/plugin-sdk/auth/profiles.d.ts +11 -0
  298. package/dist/plugin-sdk/auth/provider-auth.d.ts +32 -0
  299. package/dist/plugin-sdk/auth/store.d.ts +7 -0
  300. package/dist/plugin-sdk/auth/types.d.ts +45 -0
  301. package/dist/plugin-sdk/auth/usage.d.ts +80 -0
  302. package/dist/plugin-sdk/auto-reply/reply/agent-runner-execution.d.ts +0 -1
  303. package/dist/plugin-sdk/auto-reply/reply/agent-runner-utils.d.ts +3 -36
  304. package/dist/plugin-sdk/auto-reply/reply/commands-status.d.ts +1 -7
  305. package/dist/plugin-sdk/auto-reply/reply/commands-subagents/shared.d.ts +1 -1
  306. package/dist/plugin-sdk/auto-reply/reply/commands-types.d.ts +1 -13
  307. package/dist/plugin-sdk/auto-reply/reply/directive-handling.levels.d.ts +1 -10
  308. package/dist/plugin-sdk/auto-reply/reply/directive-handling.params.d.ts +1 -11
  309. package/dist/plugin-sdk/auto-reply/reply/directive-handling.parse.d.ts +1 -29
  310. package/dist/plugin-sdk/auto-reply/reply/directive-handling.persist.d.ts +0 -3
  311. package/dist/plugin-sdk/auto-reply/reply/directive-handling.shared.d.ts +0 -25
  312. package/dist/plugin-sdk/auto-reply/reply/directives.d.ts +3 -42
  313. package/dist/plugin-sdk/auto-reply/reply/get-reply-directives-apply.d.ts +0 -9
  314. package/dist/plugin-sdk/auto-reply/reply/get-reply-directives-utils.d.ts +0 -1
  315. package/dist/plugin-sdk/auto-reply/reply/get-reply-directives.d.ts +1 -20
  316. package/dist/plugin-sdk/auto-reply/reply/get-reply-inline-actions.d.ts +1 -12
  317. package/dist/plugin-sdk/auto-reply/reply/get-reply-run.d.ts +1 -15
  318. package/dist/plugin-sdk/auto-reply/reply/queue/types.d.ts +1 -17
  319. package/dist/plugin-sdk/auto-reply/reply/response-prefix-template.d.ts +4 -6
  320. package/dist/plugin-sdk/auto-reply/reply/session-run-accounting.d.ts +0 -7
  321. package/dist/plugin-sdk/auto-reply/reply/session-updates.d.ts +0 -10
  322. package/dist/plugin-sdk/auto-reply/reply.d.ts +1 -1
  323. package/dist/plugin-sdk/auto-reply/status.d.ts +3 -12
  324. package/dist/plugin-sdk/auto-reply/templating.d.ts +0 -4
  325. package/dist/plugin-sdk/auto-reply/thinking.d.ts +0 -15
  326. package/dist/plugin-sdk/auto-reply/types.d.ts +1 -2
  327. package/dist/plugin-sdk/channels/dock.d.ts +1 -2
  328. package/dist/plugin-sdk/channels/plugins/types.adapters.d.ts +0 -6
  329. package/dist/plugin-sdk/channels/plugins/types.core.d.ts +1 -0
  330. package/dist/plugin-sdk/channels/plugins/types.d.ts +1 -1
  331. package/dist/plugin-sdk/channels/plugins/types.plugin.d.ts +1 -2
  332. package/dist/plugin-sdk/channels/voice-credentials.d.ts +26 -0
  333. package/dist/plugin-sdk/commands/agent/session.d.ts +1 -2
  334. package/dist/plugin-sdk/commands/onboard-helpers.d.ts +0 -1
  335. package/dist/plugin-sdk/commands/onboard-types.d.ts +2 -1
  336. package/dist/plugin-sdk/config/defaults.d.ts +0 -1
  337. package/dist/plugin-sdk/config/legacy.migrations.d.ts +2 -1
  338. package/dist/plugin-sdk/config/legacy.shared.d.ts +0 -9
  339. package/dist/plugin-sdk/config/sessions/types.d.ts +0 -17
  340. package/dist/plugin-sdk/config/types.agent-defaults.d.ts +28 -120
  341. package/dist/plugin-sdk/config/types.agents.d.ts +8 -0
  342. package/dist/plugin-sdk/config/types.base.d.ts +0 -1
  343. package/dist/plugin-sdk/config/types.messages.d.ts +1 -6
  344. package/dist/plugin-sdk/config/types.remoteclaw.d.ts +2 -2
  345. package/dist/plugin-sdk/config/types.tools.d.ts +1 -74
  346. package/dist/plugin-sdk/config/types.tts.d.ts +2 -1
  347. package/dist/plugin-sdk/config/zod-schema.agent-defaults.d.ts +9 -70
  348. package/dist/plugin-sdk/config/zod-schema.agent-runtime.d.ts +12 -210
  349. package/dist/plugin-sdk/config/zod-schema.agents.d.ts +14 -86
  350. package/dist/plugin-sdk/config/zod-schema.core.d.ts +6 -234
  351. package/dist/plugin-sdk/config/zod-schema.d.ts +111 -378
  352. package/dist/plugin-sdk/config/zod-schema.providers-core.d.ts +148 -160
  353. package/dist/plugin-sdk/config/zod-schema.providers-whatsapp.d.ts +12 -12
  354. package/dist/plugin-sdk/config/zod-schema.providers.d.ts +88 -96
  355. package/dist/plugin-sdk/config/zod-schema.session.d.ts +4 -10
  356. package/dist/plugin-sdk/daemon/constants.d.ts +2 -2
  357. package/dist/plugin-sdk/gateway/protocol/index.d.ts +10 -17
  358. package/dist/plugin-sdk/gateway/protocol/schema/sessions.d.ts +0 -7
  359. package/dist/plugin-sdk/gateway/server/ws-types.d.ts +2 -0
  360. package/dist/plugin-sdk/gateway/session-utils.types.d.ts +0 -3
  361. package/dist/plugin-sdk/index.js +722 -1283
  362. package/dist/plugin-sdk/infra/agent-events.d.ts +1 -1
  363. package/dist/plugin-sdk/infra/provider-usage.auth.d.ts +0 -1
  364. package/dist/plugin-sdk/infra/provider-usage.load.d.ts +0 -1
  365. package/dist/plugin-sdk/line/config-schema.d.ts +4 -4
  366. package/dist/plugin-sdk/logging/levels.d.ts +1 -1
  367. package/dist/plugin-sdk/middleware/auth-key-retry.d.ts +31 -0
  368. package/dist/plugin-sdk/middleware/channel-bridge.d.ts +4 -0
  369. package/dist/plugin-sdk/middleware/cli-runtime-base.d.ts +6 -0
  370. package/dist/plugin-sdk/middleware/error-classifier.d.ts +5 -0
  371. package/dist/plugin-sdk/middleware/media-capability.d.ts +21 -0
  372. package/dist/plugin-sdk/middleware/media-resolver.d.ts +12 -0
  373. package/dist/plugin-sdk/middleware/runtime-factory.d.ts +42 -0
  374. package/dist/plugin-sdk/middleware/runtimes/claude.d.ts +10 -0
  375. package/dist/plugin-sdk/middleware/runtimes/codex.d.ts +5 -0
  376. package/dist/plugin-sdk/middleware/runtimes/gemini.d.ts +11 -0
  377. package/dist/plugin-sdk/middleware/runtimes/opencode.d.ts +5 -0
  378. package/dist/plugin-sdk/middleware/types.d.ts +41 -1
  379. package/dist/plugin-sdk/plugin-sdk/index.d.ts +5 -1
  380. package/dist/plugin-sdk/plugins/manifest-registry.d.ts +2 -0
  381. package/dist/plugin-sdk/plugins/manifest.d.ts +4 -4
  382. package/dist/plugin-sdk/plugins/registry.d.ts +18 -0
  383. package/dist/plugin-sdk/plugins/types.d.ts +5 -1
  384. package/dist/plugin-sdk/stt/defaults.d.ts +2 -0
  385. package/dist/plugin-sdk/stt/preflight.d.ts +14 -0
  386. package/dist/plugin-sdk/stt/providers/deepgram/index.d.ts +2 -0
  387. package/dist/plugin-sdk/stt/providers/google/index.d.ts +2 -0
  388. package/dist/plugin-sdk/stt/providers/groq/index.d.ts +2 -0
  389. package/dist/plugin-sdk/stt/providers/index.d.ts +4 -0
  390. package/dist/plugin-sdk/stt/providers/mistral/index.d.ts +2 -0
  391. package/dist/plugin-sdk/stt/providers/openai/index.d.ts +2 -0
  392. package/dist/plugin-sdk/stt/stt.d.ts +27 -0
  393. package/dist/plugin-sdk/stt/types.d.ts +22 -0
  394. package/dist/plugin-sdk/terminal/palette.d.ts +2 -2
  395. package/dist/plugin-sdk/tts/providers/edge.d.ts +2 -0
  396. package/dist/plugin-sdk/tts/providers/elevenlabs.d.ts +2 -0
  397. package/dist/plugin-sdk/tts/providers/index.d.ts +4 -0
  398. package/dist/plugin-sdk/tts/providers/openai.d.ts +2 -0
  399. package/dist/plugin-sdk/tts/tts.d.ts +13 -5
  400. package/dist/plugin-sdk/tts/types.d.ts +21 -0
  401. package/dist/plugins-BviLFPLV.js +255 -0
  402. package/dist/plugins-CaudBUbl.js +254 -0
  403. package/dist/plugins-cli-CsLhphNr.js +803 -0
  404. package/dist/plugins-cli-CujSP9NS.js +807 -0
  405. package/dist/ports-BtuzUQHl.js +370 -0
  406. package/dist/ports-CMcHia07.js +96 -0
  407. package/dist/ports-DALdfBQy.js +96 -0
  408. package/dist/ports-gRBeuUtp.js +316 -0
  409. package/dist/preflight-Bq8rimP-.js +667 -0
  410. package/dist/preflight-DyYbEp9X.js +667 -0
  411. package/dist/program-D64vUv0b.js +250 -0
  412. package/dist/program-context-CTFkimUr.js +474 -0
  413. package/dist/progress-BcwxtM9Q.js +124 -0
  414. package/dist/prompt-DtWGd43j.js +21 -0
  415. package/dist/prompt-select-styled-GW2PexAK.js +1672 -0
  416. package/dist/prompt-select-styled-JOuWGHX7.js +1669 -0
  417. package/dist/prompt-style-BpUMhEHC.js +9 -0
  418. package/dist/provider-auth-B7QgxlKt.js +187 -0
  419. package/dist/provider-auth-j-EQvvIk.js +187 -0
  420. package/dist/provider-dispatcher-Bx6CaIoV.js +660 -0
  421. package/dist/provider-dispatcher-DhkvjhO5.js +659 -0
  422. package/dist/push-apns--nEiZmEN.js +711 -0
  423. package/dist/push-apns-BtS6B6lb.js +713 -0
  424. package/dist/pw-ai-BpCsXF-x.js +1908 -0
  425. package/dist/pw-ai-ud_Kbn5S.js +1911 -0
  426. package/dist/qr-cli-BCeVLGfz.js +353 -0
  427. package/dist/qr-cli-Crsqtw01.js +349 -0
  428. package/dist/redact-Ci96Gj0O.js +191 -0
  429. package/dist/redact-snapshot-B9nof-Pb.js +1952 -0
  430. package/dist/redact-snapshot-BKiS91Mj.js +1952 -0
  431. package/dist/register.agent-CcvOeVnL.js +292 -0
  432. package/dist/register.agent-azH_tdVX.js +1014 -0
  433. package/dist/register.configure-DAaZLjHs.js +130 -0
  434. package/dist/register.configure-lUl8O79m.js +135 -0
  435. package/dist/register.import-B83Dn36B.js +29 -0
  436. package/dist/register.import-wIYU2cVW.js +31 -0
  437. package/dist/register.maintenance-Bo-ooQDU.js +501 -0
  438. package/dist/register.maintenance-BwZ4OkK2.js +503 -0
  439. package/dist/register.message-BQhRoEQQ.js +687 -0
  440. package/dist/register.message-CvZKWeGb.js +691 -0
  441. package/dist/register.onboard---3EPh-O.js +98 -0
  442. package/dist/register.onboard-rsHSJUvQ.js +94 -0
  443. package/dist/register.setup-B0gc_lne.js +118 -0
  444. package/dist/register.setup-MWpb7jxL.js +114 -0
  445. package/dist/register.status-health-sessions-BZJ0wTSa.js +429 -0
  446. package/dist/register.status-health-sessions-CyrUwwtB.js +667 -0
  447. package/dist/register.subclis-i2d2ugaJ.js +267 -0
  448. package/dist/replies-BIx-MbQ7.js +136 -0
  449. package/dist/replies-DVU655H4.js +136 -0
  450. package/dist/reply-CL5VMSKN.js +12372 -0
  451. package/dist/reply-XKyfU3rS.js +12375 -0
  452. package/dist/reply-directives-DQfJ001O.js +182 -0
  453. package/dist/reply-directives-DfUITt7C.js +182 -0
  454. package/dist/reply-payloads-ZHo6kfTS.js +527 -0
  455. package/dist/reply-prefix-BSf3PC0x.js +37 -0
  456. package/dist/reply-prefix-DBTlMHLK.js +37 -0
  457. package/dist/resolve-route-B-_IgETc.js +249 -0
  458. package/dist/resolve-route-C8ZsgWDQ.js +249 -0
  459. package/dist/response-prefix-template-3LeqJx2X.js +134 -0
  460. package/dist/response-prefix-template-DBrUVx5V.js +134 -0
  461. package/dist/retry-CDrH81GP.js +77 -0
  462. package/dist/retry-Dar_7pCv.js +77 -0
  463. package/dist/run-main-rOudcbbs.js +308 -0
  464. package/dist/runtime-guard-CK80eucm.js +60 -0
  465. package/dist/runtime-status-CR9445g5.js +12 -0
  466. package/dist/runtime-status-hFVEC3wO.js +12 -0
  467. package/dist/secure-random-CLWSvf8A.js +44 -0
  468. package/dist/security-cli-B8lXw9ke.js +488 -0
  469. package/dist/security-cli-CRkS3VAf.js +483 -0
  470. package/dist/send-6g8QKfWj.js +374 -0
  471. package/dist/send-B5Hz1PIn.js +29 -0
  472. package/dist/send-B8eIlA1u.js +349 -0
  473. package/dist/send-BFZPQE4j.js +492 -0
  474. package/dist/send-BpTDvE0D.js +1779 -0
  475. package/dist/send-BxOrO1Wv.js +1776 -0
  476. package/dist/send-C6gPJu-Z.js +11 -0
  477. package/dist/send-C7MoKtkN.js +426 -0
  478. package/dist/send-CXzq2LI6.js +2245 -0
  479. package/dist/send-CYOZoObr.js +547 -0
  480. package/dist/send-CfQyIvcC.js +332 -0
  481. package/dist/send-DUtuuwhw.js +492 -0
  482. package/dist/send-DbafVwxp.js +2245 -0
  483. package/dist/send-DeZg8K7y.js +349 -0
  484. package/dist/send-DwkjxJlv.js +547 -0
  485. package/dist/send-iX9xbxlU.js +1178 -0
  486. package/dist/server-BKfCzEzd.js +206 -0
  487. package/dist/server-fmO4eo7K.js +202 -0
  488. package/dist/server-lifecycle-CgPpP10P.js +2437 -0
  489. package/dist/server-lifecycle-Cn8yY5MW.js +2437 -0
  490. package/dist/server-node-events-C-ZzSBYh.js +391 -0
  491. package/dist/server-node-events-DYlyfDHM.js +395 -0
  492. package/dist/service-C2j81L86.js +670 -0
  493. package/dist/service-C8a0SXHD.js +670 -0
  494. package/dist/session-AulYhqOb.js +170 -0
  495. package/dist/session-C6VKWvx6.js +170 -0
  496. package/dist/session-cost-usage-0Vs4hgMe.js +627 -0
  497. package/dist/session-cost-usage-C-DsaOfN.js +627 -0
  498. package/dist/session-dirs-CO1f2ArM.js +318 -0
  499. package/dist/session-dirs-DoboH7Oy.js +318 -0
  500. package/dist/session-utils-CRK8ToKG.js +621 -0
  501. package/dist/session-utils-DWlkmCX8.js +621 -0
  502. package/dist/sessions-DtqrmUJS.js +2553 -0
  503. package/dist/sessions-gT-4fcX-.js +245 -0
  504. package/dist/shell-env-DBS5su07.js +163 -0
  505. package/dist/shell-env-c3j5zcU9.js +163 -0
  506. package/dist/ssrf-8wNqPNzN.js +183 -0
  507. package/dist/ssrf-CJIdPXuS.js +183 -0
  508. package/dist/status-BI_-xpDt.js +1947 -0
  509. package/dist/status-PZVwjKjl.js +1943 -0
  510. package/dist/status.update-BmuDZ7E7.js +449 -0
  511. package/dist/status.update-Mf6HSRvU.js +449 -0
  512. package/dist/store-B7PGEdFf.js +2555 -0
  513. package/dist/store-CzhBjUCN.js +64 -0
  514. package/dist/store-YkSxKAey.js +53 -0
  515. package/dist/store-ZNeFv2Q7.js +64 -0
  516. package/dist/subagent-registry-R1DiAM4R.js +4839 -0
  517. package/dist/subagent-registry-xLRXC8Bg.js +4841 -0
  518. package/dist/subsystem-BAW_f3DI.js +1195 -0
  519. package/dist/subsystem-DGSHVL8I.js +1081 -0
  520. package/dist/system-cli-9SvRrT9D.js +77 -0
  521. package/dist/system-cli-yCa5Q1YM.js +73 -0
  522. package/dist/systemd-40Rij3QR.js +547 -0
  523. package/dist/systemd-5C97CSzd.js +547 -0
  524. package/dist/systemd-hints-3iQteJw-.js +278 -0
  525. package/dist/systemd-hints-CyQqHq1i.js +278 -0
  526. package/dist/systemd-linger-B2rPbnAi.js +75 -0
  527. package/dist/systemd-linger-DDvkfxH-.js +75 -0
  528. package/dist/table-DFx25vNb.js +279 -0
  529. package/dist/tables-C5fI0PmT.js +55 -0
  530. package/dist/tables-Cm9qvQ9D.js +55 -0
  531. package/dist/tables-fRe01eP1.js +55 -0
  532. package/dist/tailnet-Da-_9e8E.js +40 -0
  533. package/dist/tailnet-xt92Yaop.js +40 -0
  534. package/dist/tailscale-CnV0JWca.js +230 -0
  535. package/dist/tailscale-VkEC8dzj.js +230 -0
  536. package/dist/targets-C99szk_e.js +114 -0
  537. package/dist/targets-CPaTjbpp.js +2607 -0
  538. package/dist/targets-D-p4rJVS.js +650 -0
  539. package/dist/targets-D2OQt8-7.js +650 -0
  540. package/dist/targets-D94MtTiZ.js +2606 -0
  541. package/dist/targets-RajrXTl7.js +220 -0
  542. package/dist/targets-_UWmnyI9.js +53 -0
  543. package/dist/targets-tDrl_ioQ.js +46 -0
  544. package/dist/thinking-4nOZPunr.js +60 -0
  545. package/dist/thinking-ZfH2V9Os.js +60 -0
  546. package/dist/tokens-TtJJxzRr.js +21 -0
  547. package/dist/tool-display-Bxs_1jIn.js +785 -0
  548. package/dist/tool-display-D9p_Ttkq.js +785 -0
  549. package/dist/tool-images-9Ron321Q.js +263 -0
  550. package/dist/tool-images-BWhy6WRN.js +263 -0
  551. package/dist/trash-B5xyvBDf.js +125 -0
  552. package/dist/trash-BpB96kHe.js +125 -0
  553. package/dist/tui-Ba0uZDrg.js +3237 -0
  554. package/dist/tui-Biz0HqDj.js +3237 -0
  555. package/dist/tui-cli-C-UV6o2v.js +63 -0
  556. package/dist/tui-cli-Ds_bLT-h.js +67 -0
  557. package/dist/types.tools-BBb2rl3g.js +23 -0
  558. package/dist/types.tools-BDJw1yFx.js +23 -0
  559. package/dist/update-Barj5dsg.js +349 -0
  560. package/dist/update-D839Q8su.js +349 -0
  561. package/dist/update-cli-C0LnrpIt.js +1148 -0
  562. package/dist/update-cli-CUypa-T-.js +1150 -0
  563. package/dist/usage-BI9kergH.js +5465 -0
  564. package/dist/utils-DPoNpP7D.js +631 -0
  565. package/dist/version-3QUZW8EP.js +52 -0
  566. package/dist/version-CVMnqdzu.js +52 -0
  567. package/dist/voice-credentials-64XAMSJm.js +46 -0
  568. package/dist/voice-credentials-v-CQkTpD.js +46 -0
  569. package/dist/web-63IbbidQ.js +3051 -0
  570. package/dist/web-D9N764Da.js +80 -0
  571. package/dist/web-DUvNYLzr.js +75 -0
  572. package/dist/webhooks-cli-owhVNNkz.js +334 -0
  573. package/dist/webhooks-cli-zlvka6QD.js +330 -0
  574. package/dist/whatsapp-actions-8DejyRG5.js +126 -0
  575. package/dist/whatsapp-actions-DCzp5LKe.js +131 -0
  576. package/dist/widearea-dns-CQqZIeu8.js +127 -0
  577. package/dist/workspace-CB7pVojf.js +441 -0
  578. package/dist/workspace-DWEyzM0F.js +439 -0
  579. package/dist/zod-schema-CvFqwpNE.js +2719 -0
  580. package/dist/zod-schema-Y5SQgJLm.js +2719 -0
  581. package/extensions/matrix/src/matrix/monitor/replies.ts +0 -24
  582. package/extensions/mattermost/src/mattermost/monitor-helpers.ts +0 -1
  583. package/extensions/voice-call/index.ts +18 -1
  584. package/package.json +3 -4
  585. package/dist/accounts-7fm_KzPm.js +0 -32
  586. package/dist/accounts-BFy_Z3od.js +0 -272
  587. package/dist/accounts-BTXSfPWi.js +0 -270
  588. package/dist/accounts-BxGS70Do.js +0 -36
  589. package/dist/accounts-CNY1TGj1.js +0 -47
  590. package/dist/accounts-DqRQ75w3.js +0 -36
  591. package/dist/accounts-iODF3SK2.js +0 -47
  592. package/dist/ack-reactions-C1hk85VE.js +0 -446
  593. package/dist/ack-reactions-DRC2CiDQ.js +0 -446
  594. package/dist/acp-cli-DD-PD4NM.js +0 -1326
  595. package/dist/acp-cli-DIyRCOum.js +0 -1320
  596. package/dist/active-listener-VzhWW8W6.js +0 -37
  597. package/dist/active-listener-z0qVEcom.js +0 -37
  598. package/dist/agent-D2HeDFFR.js +0 -731
  599. package/dist/agent-Da_eZ5BP.js +0 -732
  600. package/dist/agent-helpers-B6VfZ9_u.js +0 -606
  601. package/dist/agent-helpers-CTx5KKJu.js +0 -606
  602. package/dist/agent-scope-BqPmD-Ax.js +0 -114
  603. package/dist/agent-scope-DgQzamQB.js +0 -116
  604. package/dist/agents-TB3QpHoo.js +0 -788
  605. package/dist/agents.config-BsAQTYe1.js +0 -116
  606. package/dist/agents.config-C9fyYfAh.js +0 -116
  607. package/dist/ansi-D04X81yq.js +0 -14
  608. package/dist/audio-DPOuhNq7.js +0 -43
  609. package/dist/audio-VBcVDa08.js +0 -43
  610. package/dist/audio-preflight-CK3EA3Dv.js +0 -69
  611. package/dist/audio-preflight-tdXtrutj.js +0 -64
  612. package/dist/audit-CJipUWDi.js +0 -3138
  613. package/dist/audit-COWzB9Y1.js +0 -3138
  614. package/dist/auth-CAczFgAO.js +0 -448
  615. package/dist/auth-Deh9i9Eg.js +0 -448
  616. package/dist/auth-profiles-BquJGKLC.js +0 -279
  617. package/dist/auth-profiles-D8vKiBPq.js +0 -281
  618. package/dist/banner-CUWBOR42.js +0 -294
  619. package/dist/binaries-DXW6oATV.js +0 -13
  620. package/dist/bindings-8YtSWb91.js +0 -69
  621. package/dist/bindings-l1R5LQQH.js +0 -69
  622. package/dist/bonjour-discovery-DdAk1VyO.js +0 -378
  623. package/dist/bonjour-discovery-DuhiIZZx.js +0 -378
  624. package/dist/browser-cli-5Q9lhGdd.js +0 -1687
  625. package/dist/browser-cli-D2qMeSx1.js +0 -1692
  626. package/dist/call-CZHVeMf1.js +0 -2828
  627. package/dist/call-CoMjY7ah.js +0 -2829
  628. package/dist/catalog-CYiAleBT.js +0 -185
  629. package/dist/catalog-pjPqB2hC.js +0 -185
  630. package/dist/channel-account-context-CvIDAtHS.js +0 -550
  631. package/dist/channel-account-context-q-o0pG1A.js +0 -550
  632. package/dist/channel-activity-BaCNOZpP.js +0 -94
  633. package/dist/channel-activity-Cd1JhIUj.js +0 -292
  634. package/dist/channel-activity-DTKGf3j5.js +0 -94
  635. package/dist/channel-options-8SjIcDDI.js +0 -33
  636. package/dist/channel-options-BtQGtMF4.js +0 -32
  637. package/dist/channel-selection-C4DzrynU.js +0 -51
  638. package/dist/channel-selection-DdfhwFuY.js +0 -51
  639. package/dist/channel-web-BKJSXnwf.js +0 -2136
  640. package/dist/channel-web-BUzvNE_A.js +0 -2134
  641. package/dist/channels-cli-CCXY796Z.js +0 -1421
  642. package/dist/channels-cli-DTfx1zFC.js +0 -1426
  643. package/dist/channels-status-issues-DnmuqPsi.js +0 -18
  644. package/dist/channels-status-issues-p1pCvTh8.js +0 -18
  645. package/dist/chat-envelope-DEZ-5RY8.js +0 -248
  646. package/dist/chat-envelope-el7Uo-Fe.js +0 -248
  647. package/dist/chrome-Dd4dv0Vh.js +0 -1732
  648. package/dist/chrome-DdNEInwI.js +0 -1733
  649. package/dist/chunk-CSQfUhgF.js +0 -341
  650. package/dist/chunk-D0Y_w4oX.js +0 -341
  651. package/dist/clack-prompter-B7tOxhJd.js +0 -122
  652. package/dist/clack-prompter-CCFnKP_1.js +0 -121
  653. package/dist/cleanup-utils-CqAVZz2b.js +0 -94
  654. package/dist/cli-BRwDPW0r.js +0 -125
  655. package/dist/cli-CV86F7iv.js +0 -130
  656. package/dist/clipboard-D7_SKHPK.js +0 -31
  657. package/dist/clipboard-Dzkx6Q2K.js +0 -31
  658. package/dist/command-format-CVfo8I5f.js +0 -18
  659. package/dist/command-format-DgXcqxBt.js +0 -32
  660. package/dist/command-registry-BvLC28b4.js +0 -215
  661. package/dist/commands-B49Lu-pa.js +0 -41
  662. package/dist/commands-DI1BCqnj.js +0 -41
  663. package/dist/commands-registry-Cr6SIR3n.js +0 -892
  664. package/dist/commands-registry-agiTEGDz.js +0 -893
  665. package/dist/common-CMI-qsF8.js +0 -156
  666. package/dist/common-DSVmydhm.js +0 -156
  667. package/dist/completion-cli-C7O4JU8t.js +0 -452
  668. package/dist/completion-cli-CQNXtEJ7.js +0 -452
  669. package/dist/config-ChYRSJQt.js +0 -6953
  670. package/dist/config-CwtWvygh.js +0 -6951
  671. package/dist/config-cli-Df5nJcfO.js +0 -241
  672. package/dist/config-cli-Dqe5O1pl.js +0 -246
  673. package/dist/config-guard-C6hyuH-z.js +0 -75
  674. package/dist/config-guard-kNMQS_tm.js +0 -97
  675. package/dist/config-validation-BZBaBH69.js +0 -18
  676. package/dist/config-validation-DkrbzCyL.js +0 -18
  677. package/dist/configure-CoJmCHqT.js +0 -891
  678. package/dist/configure-DJbojDRf.js +0 -889
  679. package/dist/constants-BmRFoHl0.js +0 -67
  680. package/dist/constants-C9WPAluB.js +0 -67
  681. package/dist/control-auth-7k6Cb2zH.js +0 -397
  682. package/dist/control-auth-DBxfkJ3g.js +0 -397
  683. package/dist/control-ui/assets/index-B4ZM1lW1.js +0 -7738
  684. package/dist/control-ui/assets/index-B4ZM1lW1.js.map +0 -1
  685. package/dist/control-ui/assets/index-PED72sKF.css +0 -1
  686. package/dist/control-ui-assets-Cx_mw4D0.js +0 -186
  687. package/dist/control-ui-assets-W1AUuGrO.js +0 -186
  688. package/dist/conversation-label-C4SDz4sT.js +0 -36
  689. package/dist/conversation-label-D1frnvYe.js +0 -36
  690. package/dist/cron-cli-BJXQKtR3.js +0 -495
  691. package/dist/cron-cli-CTIj0WPW.js +0 -490
  692. package/dist/daemon-cli-CZbHvkRG.js +0 -1197
  693. package/dist/daemon-cli-Cf_YKWvV.js +0 -1199
  694. package/dist/daemon-install-CcohRvKV.js +0 -55
  695. package/dist/daemon-install-DDshfT0J.js +0 -60
  696. package/dist/daemon-install-helpers-CFGAfRlj.js +0 -462
  697. package/dist/daemon-install-helpers-DIUzSFG1.js +0 -462
  698. package/dist/defaults-B5KStIBg.js +0 -7
  699. package/dist/defaults-xUAL2Z-F.js +0 -7
  700. package/dist/deliver-BDf2lIEK.js +0 -481
  701. package/dist/deliver-DvmkSwLt.js +0 -481
  702. package/dist/delivery-queue-Cfa9Wmxp.js +0 -244
  703. package/dist/delivery-queue-CxVRi4tw.js +0 -244
  704. package/dist/devices-cli-CRsW5WOw.js +0 -316
  705. package/dist/devices-cli-Crzrk5uf.js +0 -321
  706. package/dist/diagnostics-99iCgBUh.js +0 -46
  707. package/dist/diagnostics-VC0cz7kX.js +0 -46
  708. package/dist/directory-cli-BnoQqeOX.js +0 -222
  709. package/dist/directory-cli-DdBAX3AV.js +0 -217
  710. package/dist/dm-policy-shared-DNqPbnip.js +0 -22
  711. package/dist/dm-policy-shared-vCb_hnqo.js +0 -22
  712. package/dist/dns-cli-D410XQr9.js +0 -197
  713. package/dist/dns-cli-Fgg96Xkg.js +0 -202
  714. package/dist/dock-DXSgTbDw.js +0 -928
  715. package/dist/dock-FtQwUHXE.js +0 -929
  716. package/dist/doctor-completion-BWmtCiFR.js +0 -92
  717. package/dist/doctor-completion-DTM_wDxy.js +0 -92
  718. package/dist/doctor-config-flow-Ccna5fPs.js +0 -1934
  719. package/dist/doctor-config-flow-DqzrK_jh.js +0 -1933
  720. package/dist/enable-DcJnkzfz.js +0 -59
  721. package/dist/enable-ibNq4UWy.js +0 -59
  722. package/dist/env-DeF64iu0.js +0 -60
  723. package/dist/env-vars-7aZqKPhk.js +0 -93
  724. package/dist/env-vars-CLGbxdpL.js +0 -93
  725. package/dist/errors-8F-77i6m.js +0 -35
  726. package/dist/errors-DZ199hOo.js +0 -35
  727. package/dist/exec-DbKuYyM1.js +0 -164
  728. package/dist/exec-DkFE7lqU.js +0 -164
  729. package/dist/fetch-C6XKGA11.js +0 -67
  730. package/dist/fetch-CEDsOiql.js +0 -67
  731. package/dist/fetch-ePscvwi1.js +0 -67
  732. package/dist/file-lock-CIvloidc.js +0 -107
  733. package/dist/file-lock-CzBL_VIx.js +0 -107
  734. package/dist/fs-safe-DSwT85uK.js +0 -88
  735. package/dist/fs-safe-DkBhNAc3.js +0 -98
  736. package/dist/gateway-cli-BJooqlkO.js +0 -23747
  737. package/dist/gateway-cli-C2wPjxY4.js +0 -23742
  738. package/dist/gateway-rpc-BcT4FqJQ.js +0 -28
  739. package/dist/gateway-rpc-DhKAJ5EW.js +0 -28
  740. package/dist/gmail-setup-utils-Cnx8A5pW.js +0 -422
  741. package/dist/gmail-setup-utils-nkabbKOE.js +0 -423
  742. package/dist/health-BZX-PyP0.js +0 -1420
  743. package/dist/health-BgD0koJx.js +0 -1423
  744. package/dist/health-format-BG95OE6N.js +0 -28
  745. package/dist/heartbeat-visibility-DeW9EIeS.js +0 -125
  746. package/dist/heartbeat-visibility-DvogUlnZ.js +0 -125
  747. package/dist/help-format-DAxf0l_h.js +0 -17
  748. package/dist/helpers-R7bU5IBz.js +0 -10
  749. package/dist/helpers-kkeXif0Q.js +0 -10
  750. package/dist/hook-runner-global-cyaKukZP.js +0 -527
  751. package/dist/hooks-cli-DTygpzqS.js +0 -1217
  752. package/dist/hooks-cli-Dg853OdZ.js +0 -1222
  753. package/dist/host-env-security-Bms2_EMV.js +0 -92
  754. package/dist/host-env-security-szwfmhC4.js +0 -92
  755. package/dist/image-ops-Bi6JPSkD.js +0 -354
  756. package/dist/image-ops-DWytvdh_.js +0 -354
  757. package/dist/import-D8BBZQgl.js +0 -170
  758. package/dist/import-DQ6NI4Fz.js +0 -168
  759. package/dist/inbound-context-CPkkQW0i.js +0 -68
  760. package/dist/inbound-context-DS_kpIYI.js +0 -68
  761. package/dist/inbound-path-policy-Bg4gZBx-.js +0 -250
  762. package/dist/inbound-path-policy-sdr5Ji0k.js +0 -250
  763. package/dist/inspect-Dt8hogS3.js +0 -559
  764. package/dist/inspect-vYIL1oA0.js +0 -559
  765. package/dist/installs-ClX3qQmh.js +0 -325
  766. package/dist/installs-CxjOiLUM.js +0 -325
  767. package/dist/ipv4--2WXMVtE.js +0 -46
  768. package/dist/ipv4-CDQpx1A7.js +0 -46
  769. package/dist/ir-BvKdMuSP.js +0 -940
  770. package/dist/json-files-DzpTak5i.js +0 -46
  771. package/dist/links-C3soDNDH.js +0 -15
  772. package/dist/loader-BWZ_iRxI.js +0 -22624
  773. package/dist/loader-ClFP7wvS.js +0 -22621
  774. package/dist/local-roots-B6rSCu4U.js +0 -314
  775. package/dist/local-roots-v2HlOaG5.js +0 -313
  776. package/dist/logger-Bw3cFE5t.js +0 -49
  777. package/dist/logging-C-nxX2fn.js +0 -20
  778. package/dist/login-Cmpeb59f.js +0 -62
  779. package/dist/login-D1CV2eNF.js +0 -61
  780. package/dist/login-qr-B3tpFLRV.js +0 -327
  781. package/dist/login-qr-CSQzrtFX.js +0 -322
  782. package/dist/logs-cli-BSiUZwb2.js +0 -238
  783. package/dist/logs-cli-DDtoJ1Fr.js +0 -233
  784. package/dist/markdown-tables-PJUMrC4T.js +0 -29
  785. package/dist/markdown-tables-dDWBbtqd.js +0 -29
  786. package/dist/media-Dqv7Q0aS.js +0 -10492
  787. package/dist/media-DtN0R9A0.js +0 -940
  788. package/dist/message-action-names-Bs50Ia1g.js +0 -2521
  789. package/dist/message-action-names-Btd7cMvx.js +0 -2521
  790. package/dist/message-channel-DzJqHVZD.js +0 -91
  791. package/dist/message-channel-uWMAiywE.js +0 -91
  792. package/dist/mime-BS3jhcZE.js +0 -149
  793. package/dist/mime-Cxh_64P6.js +0 -149
  794. package/dist/net-Cg8AQeke.js +0 -225
  795. package/dist/net-D6D0wgcF.js +0 -225
  796. package/dist/node-cli-Q2-n3Fgv.js +0 -24
  797. package/dist/node-cli-Uf6lAntf.js +0 -24
  798. package/dist/nodes-cli-DVLvMgBV.js +0 -1343
  799. package/dist/nodes-cli-Dxf7vAKk.js +0 -1348
  800. package/dist/nodes-screen-BR9sYoPa.js +0 -250
  801. package/dist/nodes-screen-Cw7Hv7M2.js +0 -250
  802. package/dist/note-Dlv4NmlQ.js +0 -92
  803. package/dist/note-kvWV4xtw.js +0 -92
  804. package/dist/npm-registry-spec-0qiKawvv.js +0 -786
  805. package/dist/npm-registry-spec-COvUzy5J.js +0 -786
  806. package/dist/npm-resolution-DJnq5QBs.js +0 -86
  807. package/dist/npm-resolution-DVl2spoD.js +0 -86
  808. package/dist/onboard-BcQWYGY3.js +0 -405
  809. package/dist/onboard-RQ_FAMyg.js +0 -407
  810. package/dist/onboard-channels-CHh_BuxJ.js +0 -2547
  811. package/dist/onboard-channels-DXD-CK_M.js +0 -2548
  812. package/dist/onboard-config-BCTthQ7J.js +0 -24
  813. package/dist/onboard-config-y-2cgT0V.js +0 -24
  814. package/dist/onboard-helpers-BRMP8mup.js +0 -362
  815. package/dist/onboard-helpers-CUGbuZwH.js +0 -363
  816. package/dist/onboard-remote-D-qWujdL.js +0 -127
  817. package/dist/onboard-remote-o_OW-uzc.js +0 -127
  818. package/dist/onboarding-Bf9kVcef.js +0 -541
  819. package/dist/onboarding-CVlOLLp1.js +0 -543
  820. package/dist/onboarding.finalize-CQSt37fw.js +0 -398
  821. package/dist/onboarding.finalize-DggVL7Ay.js +0 -401
  822. package/dist/onboarding.gateway-config-BLca3Td2.js +0 -198
  823. package/dist/onboarding.gateway-config-C1mcOkRh.js +0 -191
  824. package/dist/outbound-DXXccLDS.js +0 -220
  825. package/dist/outbound-ZnVvUReT.js +0 -221
  826. package/dist/outbound-attachment-CfRb07J7.js +0 -18
  827. package/dist/outbound-attachment-DGXTtERK.js +0 -18
  828. package/dist/outbound-attachment-_jj74QBM.js +0 -18
  829. package/dist/pairing-cli-Bgm4fRA3.js +0 -127
  830. package/dist/pairing-cli-J0uGb1nU.js +0 -122
  831. package/dist/pairing-labels-CVm65Jkh.js +0 -9
  832. package/dist/pairing-labels-DD1mcvQG.js +0 -9
  833. package/dist/pairing-store-5qapT5-t.js +0 -460
  834. package/dist/pairing-store-MLceBEeL.js +0 -459
  835. package/dist/path-env-DR5vn3QL.js +0 -89
  836. package/dist/path-env-qRJbjJzj.js +0 -89
  837. package/dist/path-guards-CIx4hURU.js +0 -31
  838. package/dist/path-guards-CrQOUlsq.js +0 -31
  839. package/dist/path-safety-DkT9RmTG.js +0 -14
  840. package/dist/path-safety-juI2XbO1.js +0 -14
  841. package/dist/paths-BTaH3rLn.js +0 -232
  842. package/dist/plugin-auto-enable-BUSF117F.js +0 -301
  843. package/dist/plugin-auto-enable-CoDnqA0S.js +0 -302
  844. package/dist/plugin-registry-D2B6nbn1.js +0 -33
  845. package/dist/plugin-registry-fLaMC0ik.js +0 -33
  846. package/dist/plugin-sdk/agents/agent-helpers/thinking.d.ts +0 -5
  847. package/dist/plugin-sdk/agents/agent-paths.d.ts +0 -1
  848. package/dist/plugin-sdk/agents/auth-profiles/constants.d.ts +0 -16
  849. package/dist/plugin-sdk/agents/auth-profiles/display.d.ts +0 -7
  850. package/dist/plugin-sdk/agents/auth-profiles/doctor.d.ts +0 -8
  851. package/dist/plugin-sdk/agents/auth-profiles/oauth.d.ts +0 -14
  852. package/dist/plugin-sdk/agents/auth-profiles/paths.d.ts +0 -4
  853. package/dist/plugin-sdk/agents/auth-profiles/profiles.d.ts +0 -12
  854. package/dist/plugin-sdk/agents/auth-profiles/session-override.d.ts +0 -18
  855. package/dist/plugin-sdk/agents/auth-profiles/store.d.ts +0 -10
  856. package/dist/plugin-sdk/agents/auth-profiles/types.d.ts +0 -13
  857. package/dist/plugin-sdk/agents/auth-profiles.d.ts +0 -8
  858. package/dist/plugin-sdk/agents/defaults.d.ts +0 -3
  859. package/dist/plugin-sdk/agents/provider-auth.d.ts +0 -40
  860. package/dist/plugin-sdk/auto-reply/model-runtime.d.ts +0 -17
  861. package/dist/plugin-sdk/auto-reply/reply/directive-handling.auth.d.ts +0 -19
  862. package/dist/plugin-sdk/auto-reply/reply/elevated-allowlist-matcher.d.ts +0 -20
  863. package/dist/plugin-sdk/auto-reply/reply/elevated-unavailable.d.ts +0 -8
  864. package/dist/plugin-sdk/auto-reply/reply/reply-elevated.d.ts +0 -16
  865. package/dist/plugin-sdk/compat/legacy-names.d.ts +0 -8
  866. package/dist/plugin-sdk/config/legacy.migrations.part-1.d.ts +0 -2
  867. package/dist/plugin-sdk/config/legacy.migrations.part-2.d.ts +0 -2
  868. package/dist/plugin-sdk/config/legacy.migrations.part-3.d.ts +0 -2
  869. package/dist/plugin-sdk/config/model-input.d.ts +0 -9
  870. package/dist/plugin-sdk/config/zod-schema.agent-model.d.ts +0 -5
  871. package/dist/plugin-sdk/link-understanding/apply.d.ts +0 -10
  872. package/dist/plugin-sdk/link-understanding/defaults.d.ts +0 -2
  873. package/dist/plugin-sdk/link-understanding/detect.d.ts +0 -3
  874. package/dist/plugin-sdk/link-understanding/format.d.ts +0 -4
  875. package/dist/plugin-sdk/link-understanding/runner.d.ts +0 -11
  876. package/dist/plugin-sdk/media/input-files.d.ts +0 -95
  877. package/dist/plugin-sdk/media-understanding/apply.d.ts +0 -19
  878. package/dist/plugin-sdk/media-understanding/attachments.d.ts +0 -49
  879. package/dist/plugin-sdk/media-understanding/audio-preflight.d.ts +0 -16
  880. package/dist/plugin-sdk/media-understanding/concurrency.d.ts +0 -1
  881. package/dist/plugin-sdk/media-understanding/defaults.d.ts +0 -12
  882. package/dist/plugin-sdk/media-understanding/errors.d.ts +0 -6
  883. package/dist/plugin-sdk/media-understanding/format.d.ts +0 -7
  884. package/dist/plugin-sdk/media-understanding/fs.d.ts +0 -1
  885. package/dist/plugin-sdk/media-understanding/output-extract.d.ts +0 -2
  886. package/dist/plugin-sdk/media-understanding/providers/anthropic/index.d.ts +0 -2
  887. package/dist/plugin-sdk/media-understanding/providers/deepgram/index.d.ts +0 -2
  888. package/dist/plugin-sdk/media-understanding/providers/google/index.d.ts +0 -2
  889. package/dist/plugin-sdk/media-understanding/providers/google/video.d.ts +0 -3
  890. package/dist/plugin-sdk/media-understanding/providers/groq/index.d.ts +0 -2
  891. package/dist/plugin-sdk/media-understanding/providers/index.d.ts +0 -4
  892. package/dist/plugin-sdk/media-understanding/providers/minimax/index.d.ts +0 -2
  893. package/dist/plugin-sdk/media-understanding/providers/mistral/index.d.ts +0 -2
  894. package/dist/plugin-sdk/media-understanding/providers/moonshot/index.d.ts +0 -2
  895. package/dist/plugin-sdk/media-understanding/providers/moonshot/video.d.ts +0 -3
  896. package/dist/plugin-sdk/media-understanding/providers/openai/index.d.ts +0 -2
  897. package/dist/plugin-sdk/media-understanding/providers/zai/index.d.ts +0 -2
  898. package/dist/plugin-sdk/media-understanding/resolve.d.ts +0 -44
  899. package/dist/plugin-sdk/media-understanding/runner.d.ts +0 -34
  900. package/dist/plugin-sdk/media-understanding/runner.entries.d.ts +0 -33
  901. package/dist/plugin-sdk/media-understanding/scope.d.ts +0 -9
  902. package/dist/plugin-sdk/media-understanding/types.d.ts +0 -74
  903. package/dist/plugin-sdk/media-understanding/video.d.ts +0 -2
  904. package/dist/plugin-sdk/sessions/model-overrides.d.ts +0 -14
  905. package/dist/plugin-sdk/telegram/reasoning-lane-coordinator.d.ts +0 -18
  906. package/dist/plugin-sdk/utils/mask-api-key.d.ts +0 -1
  907. package/dist/plugin-sdk/utils/run-with-concurrency.d.ts +0 -11
  908. package/dist/plugins-CsYMlnVa.js +0 -455
  909. package/dist/plugins-Dhit-VHt.js +0 -453
  910. package/dist/plugins-cli-BwuvKtN-.js +0 -798
  911. package/dist/plugins-cli-D34k2VsI.js +0 -793
  912. package/dist/ports-DrruB2fK.js +0 -370
  913. package/dist/ports-GT1yV-Tg.js +0 -96
  914. package/dist/ports-NPqtlfp0.js +0 -316
  915. package/dist/ports-QMI4-F9m.js +0 -96
  916. package/dist/program-C5ukTU6N.js +0 -244
  917. package/dist/program-context-D55P0vBV.js +0 -474
  918. package/dist/progress-CBkSaM6z.js +0 -124
  919. package/dist/prompt-Bllj1dhc.js +0 -21
  920. package/dist/prompt-select-styled-WStiI-bz.js +0 -1647
  921. package/dist/prompt-select-styled-ram-aXWu.js +0 -1650
  922. package/dist/prompt-style-DVEm3BZW.js +0 -9
  923. package/dist/provider-dispatcher-epFKwpGK.js +0 -659
  924. package/dist/provider-dispatcher-vEBMmwZ0.js +0 -660
  925. package/dist/push-apns-C0LyG-WB.js +0 -713
  926. package/dist/push-apns-DuG95AKC.js +0 -711
  927. package/dist/pw-ai-TygsEDgY.js +0 -1906
  928. package/dist/pw-ai-eS0sIkZo.js +0 -1910
  929. package/dist/qr-cli-B8sYhugo.js +0 -352
  930. package/dist/qr-cli-yP8i4Iv1.js +0 -347
  931. package/dist/redact-eZq1uwNK.js +0 -191
  932. package/dist/redact-snapshot-gOLgfKp3.js +0 -2028
  933. package/dist/redact-snapshot-uT-CXbM8.js +0 -2028
  934. package/dist/register.agent-CSoigVGq.js +0 -1043
  935. package/dist/register.agent-GZLrbUPm.js +0 -286
  936. package/dist/register.configure-CXpiRohq.js +0 -124
  937. package/dist/register.configure-RaqiHe5L.js +0 -130
  938. package/dist/register.import-Bs-UkOs-.js +0 -27
  939. package/dist/register.import-DLng8g-e.js +0 -30
  940. package/dist/register.maintenance-B-ZLQ56Y.js +0 -494
  941. package/dist/register.maintenance-Bjr_SmG9.js +0 -497
  942. package/dist/register.message-BCQ8Vg4O.js +0 -686
  943. package/dist/register.message-ChhiSr7g.js +0 -681
  944. package/dist/register.onboard-DJCqNufv.js +0 -257
  945. package/dist/register.onboard-jlxjsrv6.js +0 -262
  946. package/dist/register.setup-C-sdixz5.js +0 -114
  947. package/dist/register.setup-Dwpe4ArC.js +0 -109
  948. package/dist/register.status-health-sessions-BWFRHBCZ.js +0 -669
  949. package/dist/register.status-health-sessions-D7noMz9y.js +0 -423
  950. package/dist/register.subclis-DFI5u4a6.js +0 -267
  951. package/dist/replies-Bzcj-R8d.js +0 -136
  952. package/dist/replies-uvTI-4lg.js +0 -136
  953. package/dist/reply-B9qz9Wwk.js +0 -13897
  954. package/dist/reply-CmGAXQKc.js +0 -13900
  955. package/dist/reply-directives-Be97YiyM.js +0 -182
  956. package/dist/reply-directives-DsLughUT.js +0 -182
  957. package/dist/reply-payloads-DW0YgT82.js +0 -527
  958. package/dist/reply-prefix-BzoT8h8o.js +0 -38
  959. package/dist/reply-prefix-CSaiVnkC.js +0 -38
  960. package/dist/resolve-route-2P40JKXk.js +0 -249
  961. package/dist/resolve-route-_CwEKLq6.js +0 -249
  962. package/dist/response-prefix-template-BAlvtSjL.js +0 -136
  963. package/dist/response-prefix-template-D-tls8tI.js +0 -136
  964. package/dist/retry-B042l5UJ.js +0 -77
  965. package/dist/retry-BhuXOEVR.js +0 -77
  966. package/dist/run-main-B-O5ZtbU.js +0 -320
  967. package/dist/runner-DGkTSlOS.js +0 -2294
  968. package/dist/runner-hs4uxAUP.js +0 -2294
  969. package/dist/runtime-DJNp29jv.js +0 -94
  970. package/dist/runtime-guard-DZ_xuCc4.js +0 -60
  971. package/dist/secure-random-DTcQnwrI.js +0 -44
  972. package/dist/security-cli-1iY1lW6F.js +0 -484
  973. package/dist/security-cli-BuiPPQYU.js +0 -478
  974. package/dist/send-3lgWtHHf.js +0 -349
  975. package/dist/send-6l2S1bcr.js +0 -11
  976. package/dist/send-9NV7sSlD.js +0 -2245
  977. package/dist/send-B0TcjZUD.js +0 -1778
  978. package/dist/send-Bb6K_10X.js +0 -2245
  979. package/dist/send-BzN7X1Om.js +0 -374
  980. package/dist/send-CLrRM0El.js +0 -426
  981. package/dist/send-Caz-txXK.js +0 -492
  982. package/dist/send-DJEr4rP6.js +0 -547
  983. package/dist/send-DJiDHXsu.js +0 -349
  984. package/dist/send-DOjg7kJj.js +0 -1775
  985. package/dist/send-DVXOiKT4.js +0 -1174
  986. package/dist/send-Dc_K995l.js +0 -547
  987. package/dist/send-Dh6d3CLl.js +0 -332
  988. package/dist/send-iPAfbiYM.js +0 -492
  989. package/dist/send-pwe9Gu8e.js +0 -29
  990. package/dist/server-B0IC-Osg.js +0 -205
  991. package/dist/server-MccRxMpb.js +0 -200
  992. package/dist/server-lifecycle-C_0CfoP7.js +0 -2437
  993. package/dist/server-lifecycle-IKdGw1kM.js +0 -2437
  994. package/dist/server-node-events-Czr2gXp_.js +0 -393
  995. package/dist/server-node-events-DFG6cXud.js +0 -398
  996. package/dist/service-Bjqii5nW.js +0 -670
  997. package/dist/service-fp29z5Ww.js +0 -670
  998. package/dist/session-DBL5nHDy.js +0 -170
  999. package/dist/session-cost-usage-DX09eTPU.js +0 -627
  1000. package/dist/session-cost-usage-yYi525j3.js +0 -627
  1001. package/dist/session-dirs-Cj5xi7zX.js +0 -947
  1002. package/dist/session-dirs-DdF6TDsE.js +0 -947
  1003. package/dist/session-utils-C7BtKlun.js +0 -625
  1004. package/dist/session-utils-CLe1dano.js +0 -625
  1005. package/dist/session-xKIW6gL2.js +0 -170
  1006. package/dist/sessions-C65iUuN9.js +0 -2593
  1007. package/dist/sessions-DjZ9IshB.js +0 -252
  1008. package/dist/ssrf-Ck9HDZpv.js +0 -183
  1009. package/dist/ssrf-m7kFIobZ.js +0 -183
  1010. package/dist/status-C6ghjxvX.js +0 -2072
  1011. package/dist/status-D-qTB8aZ.js +0 -2068
  1012. package/dist/status.update-C55QM2xs.js +0 -79
  1013. package/dist/status.update-CBmPXwYN.js +0 -79
  1014. package/dist/store-Bjk6rTC_.js +0 -53
  1015. package/dist/store-C3tOpizT.js +0 -64
  1016. package/dist/store-uRA67h-o.js +0 -2595
  1017. package/dist/store-v3P-OWhi.js +0 -64
  1018. package/dist/subagent-registry-BTG1aAZ8.js +0 -4860
  1019. package/dist/subagent-registry-CoclNL5c.js +0 -4858
  1020. package/dist/subsystem-COd61u0P.js +0 -1139
  1021. package/dist/subsystem-D9ZpRKFP.js +0 -1079
  1022. package/dist/system-cli-C__5QOMX.js +0 -70
  1023. package/dist/system-cli-Dr4XoVTq.js +0 -75
  1024. package/dist/systemd-DSnlM3jX.js +0 -547
  1025. package/dist/systemd-TfK8GuTx.js +0 -547
  1026. package/dist/systemd-linger-Axnc1xCb.js +0 -75
  1027. package/dist/systemd-linger-_0_-RY4v.js +0 -75
  1028. package/dist/table-DPTzZyhu.js +0 -279
  1029. package/dist/tables-BQ-CvUfT.js +0 -55
  1030. package/dist/tables-D3a9iSU1.js +0 -55
  1031. package/dist/tables-D3zdgEuK.js +0 -55
  1032. package/dist/tailnet-CEudzG0i.js +0 -40
  1033. package/dist/tailnet-PnMrjwGT.js +0 -40
  1034. package/dist/tailscale-DTATQxAG.js +0 -230
  1035. package/dist/tailscale-Dbyahx0J.js +0 -230
  1036. package/dist/targets-B_0Y1i-1.js +0 -2173
  1037. package/dist/targets-CMhBAn87.js +0 -120
  1038. package/dist/targets-CTmhieRB.js +0 -650
  1039. package/dist/targets-CcTME3bp.js +0 -46
  1040. package/dist/targets-DfaVEd_u.js +0 -220
  1041. package/dist/targets-DtiQgjEL.js +0 -2172
  1042. package/dist/targets-DyybKefq.js +0 -53
  1043. package/dist/targets-rDolm5YS.js +0 -650
  1044. package/dist/tokens-DzFOtLlW.js +0 -21
  1045. package/dist/tool-display-Br6mwaJc.js +0 -785
  1046. package/dist/tool-display-sgNwLOBj.js +0 -785
  1047. package/dist/tool-images-BNfIJ_Kj.js +0 -263
  1048. package/dist/tool-images-kloBqxqK.js +0 -263
  1049. package/dist/trash-DPi0aCCQ.js +0 -125
  1050. package/dist/trash-D_Jd_yQZ.js +0 -125
  1051. package/dist/tui-BSDCI2hh.js +0 -3392
  1052. package/dist/tui-DT7hLOBk.js +0 -3392
  1053. package/dist/tui-cli-DUWvLaoG.js +0 -58
  1054. package/dist/tui-cli-Dn2iXQTO.js +0 -63
  1055. package/dist/update-Bgl3Pk2N.js +0 -349
  1056. package/dist/update-CFPFib4P.js +0 -349
  1057. package/dist/update-cli-DSDSQ2Xi.js +0 -1373
  1058. package/dist/update-cli-DYR_7NLy.js +0 -1370
  1059. package/dist/usage-CS1zeIan.js +0 -5279
  1060. package/dist/utils-LBKvDoPx.js +0 -631
  1061. package/dist/web-BECD5Akw.js +0 -70
  1062. package/dist/web-D4oENnAL.js +0 -3065
  1063. package/dist/web-KP-TI2sO.js +0 -76
  1064. package/dist/webhooks-cli-BqoG_i-D.js +0 -328
  1065. package/dist/webhooks-cli-Ddu7dfdE.js +0 -333
  1066. package/dist/whatsapp-actions-BZLIjQ8J.js +0 -122
  1067. package/dist/whatsapp-actions-KCc1vHN5.js +0 -128
  1068. package/dist/widearea-dns-DSoaA-eH.js +0 -127
  1069. package/dist/workspace-4EaHHEWi.js +0 -447
  1070. package/dist/workspace-B_1t_yq3.js +0 -449
  1071. /package/dist/{account-lookup-0KDSp5Mj.js → account-lookup-C0ndrpt-.js} +0 -0
  1072. /package/dist/{account-lookup-zvANGr2x.js → account-lookup-CIY_RKhi.js} +0 -0
  1073. /package/dist/{api-BeQMq2iS.js → api-BE4ZCWWB.js} +0 -0
  1074. /package/dist/{api-CxX8-gGz.js → api-wsk9zRVi.js} +0 -0
  1075. /package/dist/{argv-Co-b9Zsc.js → argv-BY8EVMTP.js} +0 -0
  1076. /package/dist/{brew-DbSbN8sD.js → brew-CmTYeZk1.js} +0 -0
  1077. /package/dist/{brew-C4zKZsHX.js → brew-V4lMBeE3.js} +0 -0
  1078. /package/dist/{chat-type-CYPyHAj-.js → chat-type-BP9akbag.js} +0 -0
  1079. /package/dist/{chat-type-DKb2TlGZ.js → chat-type-CH3W-zKy.js} +0 -0
  1080. /package/dist/{cleanup-utils-CwQvD73q.js → cleanup-utils-ZC2zvntc.js} +0 -0
  1081. /package/dist/{cli-name-BicfmwQX.js → cli-name-BZsYSp9l.js} +0 -0
  1082. /package/dist/{cli-name-C6rJGl18.js → cli-name-CRe5Ow_t.js} +0 -0
  1083. /package/dist/{cli-utils-BhXbz2UF.js → cli-utils-BUOtyfnU.js} +0 -0
  1084. /package/dist/{cli-utils-DZe_rVkZ.js → cli-utils-CGB3cBZm.js} +0 -0
  1085. /package/dist/{client-C61M8zI3.js → client-9dK56xly.js} +0 -0
  1086. /package/dist/{client-DdpmATKq.js → client-D-R1YdRD.js} +0 -0
  1087. /package/dist/{command-options-C4paWSGf.js → command-options-CnHA4TzR.js} +0 -0
  1088. /package/dist/{command-options-CA30lfLK.js → command-options-D2nN4AXX.js} +0 -0
  1089. /package/dist/{config-eval-CjGZtLwx.js → config-eval-BQIR-wSg.js} +0 -0
  1090. /package/dist/{config-eval-H_wlEYIG.js → config-eval-Bh82JoXK.js} +0 -0
  1091. /package/dist/{constants-ChptG3d7.js → constants-C7j1VA2S.js} +0 -0
  1092. /package/dist/{constants-DY6b-_Wl.js → constants-DoYLsBmv.js} +0 -0
  1093. /package/dist/{credentials-BHWUBHMd.js → credentials-C_RoJFmK.js} +0 -0
  1094. /package/dist/{credentials-DFsi1_e8.js → credentials-DM_Dj0m8.js} +0 -0
  1095. /package/dist/{daemon-runtime-CMnbwryP.js → daemon-runtime-9oDBR7YW.js} +0 -0
  1096. /package/dist/{daemon-runtime-CvqE4ysg.js → daemon-runtime-CzFI2dPw.js} +0 -0
  1097. /package/dist/{dangerous-name-matching-BzmiLXmA.js → dangerous-name-matching-BlTBBZns.js} +0 -0
  1098. /package/dist/{dangerous-name-matching-DaVRgwer.js → dangerous-name-matching-CSq9sJDG.js} +0 -0
  1099. /package/dist/{dangerous-tools-BOLoCRv4.js → dangerous-tools-BRmbBvRf.js} +0 -0
  1100. /package/dist/{dangerous-tools-Baq7Q-i6.js → dangerous-tools-D4jtl72G.js} +0 -0
  1101. /package/dist/{fetch-timeout-DTIN7CGM.js → fetch-timeout-CytN1wiO.js} +0 -0
  1102. /package/dist/{fetch-timeout-DoySHqfO.js → fetch-timeout-DBRRPNBi.js} +0 -0
  1103. /package/dist/{file-identity-BxlKD8Ys.js → file-identity-CeRK5CJC.js} +0 -0
  1104. /package/dist/{format-duration-CqUERz51.js → format-duration-B-Uv5nOi.js} +0 -0
  1105. /package/dist/{format-duration-Ct-yiwkS.js → format-duration-D1M3Zxu6.js} +0 -0
  1106. /package/dist/{format-relative-79_Y1n2Y.js → format-relative-Czf5fUjn.js} +0 -0
  1107. /package/dist/{format-relative-CxLpEQOX.js → format-relative-zwkkXJvs.js} +0 -0
  1108. /package/dist/{health-format-B_QRD8Si.js → health-format-DF54wvUU.js} +0 -0
  1109. /package/dist/{heartbeat-wake-LGEgcXjs.js → heartbeat-wake-CvHncCjP.js} +0 -0
  1110. /package/dist/{heartbeat-wake-Y97geucO.js → heartbeat-wake-DLxQm6-U.js} +0 -0
  1111. /package/dist/{help-format-NNm_Ov4H.js → help-format-CJQ7APRn.js} +0 -0
  1112. /package/dist/{helpers-BAsMXprO.js → helpers-BER76F_2.js} +0 -0
  1113. /package/dist/{helpers-DLgbkcEn.js → helpers-n2CtWpm9.js} +0 -0
  1114. /package/dist/{input-provenance-Bn6thJNm.js → input-provenance-gIfDn1ki.js} +0 -0
  1115. /package/dist/{input-provenance-xUsSMOsz.js → input-provenance-wkso1o5V.js} +0 -0
  1116. /package/dist/{ip-C9q3Oq20.js → ip-D4VG5EJO.js} +0 -0
  1117. /package/dist/{ip-D0zgNmBV.js → ip-MwCwRA7c.js} +0 -0
  1118. /package/dist/{is-main-DN8-sNR5.js → is-main-BmHYGRhd.js} +0 -0
  1119. /package/dist/{json-file-B7l5-Xhr.js → json-file-BW22hGtf.js} +0 -0
  1120. /package/dist/{json-file-ChO_R9yh.js → json-file-DwRAfAAy.js} +0 -0
  1121. /package/dist/{json-files-CmpYSF4G.js → json-files-Dy52honG.js} +0 -0
  1122. /package/dist/{lanes-ByWMUgrz.js → lanes-1CBKdsiR.js} +0 -0
  1123. /package/dist/{lanes-cHJ5arWg.js → lanes-DqVYfPRG.js} +0 -0
  1124. /package/dist/{links-Bz4V7R_p.js → links-CwTlzaPe.js} +0 -0
  1125. /package/dist/{location-DBWCGNLq.js → location-50gaJF5Z.js} +0 -0
  1126. /package/dist/{location-GbZ0bBRU.js → location-Qo8Ii1zo.js} +0 -0
  1127. /package/dist/{logger-DyL5G2DO.js → logger-B8BE0PyS.js} +0 -0
  1128. /package/dist/{logger-BWMPnILd.js → logger-CPvz-aPM.js} +0 -0
  1129. /package/dist/{logger-GvipVDfh.js → logger-cL0D2DCr.js} +0 -0
  1130. /package/dist/{logging-D8-Kozjc.js → logging-DTEoeoa3.js} +0 -0
  1131. /package/dist/{mutable-allowlist-detectors-DiZDtmlZ.js → mutable-allowlist-detectors-BXE7Hr7F.js} +0 -0
  1132. /package/dist/{mutable-allowlist-detectors-U5ThQr9V.js → mutable-allowlist-detectors-CtKavajp.js} +0 -0
  1133. /package/dist/{parse-log-line-enq8pduH.js → parse-log-line-GisaZn5H.js} +0 -0
  1134. /package/dist/{parse-log-line-mz9TG6ig.js → parse-log-line-ZsbwG_u7.js} +0 -0
  1135. /package/dist/{parse-timeout-BMP8a0_a.js → parse-timeout-BpphuwYl.js} +0 -0
  1136. /package/dist/{parse-timeout-CDkco8kd.js → parse-timeout-CE6BjmGU.js} +0 -0
  1137. /package/dist/plugin-sdk/{agents → auth}/api-key-rotation.d.ts +0 -0
  1138. /package/dist/plugin-sdk/{media-understanding → stt}/providers/deepgram/audio.d.ts +0 -0
  1139. /package/dist/plugin-sdk/{media-understanding → stt}/providers/google/audio.d.ts +0 -0
  1140. /package/dist/plugin-sdk/{media-understanding → stt}/providers/google/inline-data.d.ts +0 -0
  1141. /package/dist/plugin-sdk/{media-understanding → stt}/providers/openai/audio.d.ts +0 -0
  1142. /package/dist/plugin-sdk/{media-understanding → stt}/providers/shared.d.ts +0 -0
  1143. /package/dist/{plugins-allowlist-BbTQ5Z2k.js → plugins-allowlist-A38nxBRG.js} +0 -0
  1144. /package/dist/{plugins-allowlist-C20oaESO.js → plugins-allowlist-D2tS9tcu.js} +0 -0
  1145. /package/dist/{polls-B0CCBDeR.js → polls-BLyT08ZI.js} +0 -0
  1146. /package/dist/{polls-CwwHzYBM.js → polls-BmymsJEe.js} +0 -0
  1147. /package/dist/{ports-lsof-Wteul3ju.js → ports-lsof-CDyv5GJd.js} +0 -0
  1148. /package/dist/{process-scoped-map-CV9kDvfG.js → process-scoped-map-BCJR56ZB.js} +0 -0
  1149. /package/dist/{process-scoped-map-PEvnG75N.js → process-scoped-map-Cb1EHPyN.js} +0 -0
  1150. /package/dist/{program-context-jqeI5alP.js → program-context-DlXnmuB7.js} +0 -0
  1151. /package/dist/{progress-C1kUfYL-.js → progress-DRLmcFiG.js} +0 -0
  1152. /package/dist/{prompt-Yn2yClg1.js → prompt-BRGfic91.js} +0 -0
  1153. /package/dist/{prompt-style-DjEYC_s-.js → prompt-style-CUuA6OCy.js} +0 -0
  1154. /package/dist/{provider-utils-3JTMJroG.js → provider-utils-C9kBVF1f.js} +0 -0
  1155. /package/dist/{provider-utils-FaBmofiq.js → provider-utils-DiLhkKQp.js} +0 -0
  1156. /package/dist/{proxy-DL3MD6-P.js → proxy-BMJL0Qog.js} +0 -0
  1157. /package/dist/{proxy-DpNv2cSV.js → proxy-D-qGA1vm.js} +0 -0
  1158. /package/dist/{pw-ai-state-CGfLv6nV.js → pw-ai-state--TxTVwRW.js} +0 -0
  1159. /package/dist/{pw-ai-state-Dynx20hr.js → pw-ai-state-CwXeO5d0.js} +0 -0
  1160. /package/dist/{redact-Dx1Fue21.js → redact-BW8tobyp.js} +0 -0
  1161. /package/dist/{redact-identifier-BTIWtaa-.js → redact-identifier-BJOQDEj0.js} +0 -0
  1162. /package/dist/{redact-identifier-CAagcfWA.js → redact-identifier-Bv5SUUw-.js} +0 -0
  1163. /package/dist/{remoteclaw-root-C2HV2VeC.js → remoteclaw-root-BfPjgewe.js} +0 -0
  1164. /package/dist/{remoteclaw-root-DybYl8PL.js → remoteclaw-root-E4-hmb4E.js} +0 -0
  1165. /package/dist/{render-CCLsW6Lz.js → render-BhKzKdV0.js} +0 -0
  1166. /package/dist/{render-uf6PvGMV.js → render-e7fENCYH.js} +0 -0
  1167. /package/dist/{retry-DnqPAqWp.js → retry-BWv_fy4u.js} +0 -0
  1168. /package/dist/{runtime-guard-U-ewY_QH.js → runtime-guard-Bhx-pb8_.js} +0 -0
  1169. /package/dist/{secret-equal-BbHdTtqY.js → secret-equal-D6AoXne1.js} +0 -0
  1170. /package/dist/{secret-equal-CXJEZiWb.js → secret-equal-DLnUuWM3.js} +0 -0
  1171. /package/dist/{secure-random-CS2mSdTn.js → secure-random-CJtykx_p.js} +0 -0
  1172. /package/dist/{secure-random-_dzDDlFo.js → secure-random-CRVHgtmO.js} +0 -0
  1173. /package/dist/{session-key-5YLnn_qf.js → session-key-BF-9YzxC.js} +0 -0
  1174. /package/dist/{session-key-C2n-VILA.js → session-key-CgKWfjoZ.js} +0 -0
  1175. /package/dist/{stagger-BXv_apuy.js → stagger--wvODnNe.js} +0 -0
  1176. /package/dist/{stagger-MI9gd2rQ.js → stagger-BLmTO4cK.js} +0 -0
  1177. /package/dist/{status-BmtCS3T1.js → status-1zVD-Clq.js} +0 -0
  1178. /package/dist/{status-BrwHRn2B.js → status-BtRY0nXQ.js} +0 -0
  1179. /package/dist/{strip-inbound-meta-DjKcSFaW.js → strip-inbound-meta-zmUXypSS.js} +0 -0
  1180. /package/dist/{strip-inbound-meta-jy3bkUab.js → strip-inbound-meta-zqtN9FTK.js} +0 -0
  1181. /package/dist/{table-C1rdyYl9.js → table-On3hkCqi.js} +0 -0
  1182. /package/dist/{target-errors-BDpPcwh5.js → target-errors-DJVRKFcU.js} +0 -0
  1183. /package/dist/{target-errors-DdIAPcMM.js → target-errors-GZXDqlUu.js} +0 -0
  1184. /package/dist/{targets-C-2xwh9f.js → targets-B46m7u5J.js} +0 -0
  1185. /package/dist/{targets-D-qLBpTA.js → targets-B_d_1z3N.js} +0 -0
  1186. /package/dist/{targets-UncQvCVs.js → targets-D01MJGnh.js} +0 -0
  1187. /package/dist/{targets-BMenhVHg.js → targets-D3r6Zgic.js} +0 -0
  1188. /package/dist/{text-format-BQ3z_OXA.js → text-format-DarxU3JH.js} +0 -0
  1189. /package/dist/{text-format-oWqzVmah.js → text-format-Ds92M9UT.js} +0 -0
  1190. /package/dist/{tokens-B-jmvNR9.js → tokens-Dw7ZdYwT.js} +0 -0
  1191. /package/dist/{usage-BdhBT0Vz.js → usage-BIzKZ5dT.js} +0 -0
  1192. /package/dist/{usage-BtQcAnf6.js → usage-BvZOzIC7.js} +0 -0
  1193. /package/dist/{usage-format-C3mNLfhI.js → usage-format-CmniSPCG.js} +0 -0
  1194. /package/dist/{usage-format-DAaPzr_z.js → usage-format-D_KQYQ-w.js} +0 -0
  1195. /package/dist/{widearea-dns-CsmBVbez.js → widearea-dns-D01FFYZ8.js} +0 -0
  1196. /package/dist/{workspace-BzPeZDew.js → workspace-BJCKO8Ns.js} +0 -0
  1197. /package/dist/{workspace-DkGLVfOl.js → workspace-BisvA9oA.js} +0 -0
  1198. /package/dist/{wsl-B_sPlzWw.js → wsl-PDLKeX04.js} +0 -0
  1199. /package/dist/{wsl-BCnYV9O0.js → wsl-kFaeW76c.js} +0 -0
@@ -0,0 +1,2606 @@
1
+ import { O as normalizeAnyChannelId, _ as defaultRuntime } from "./entry.js";
2
+ import { h as normalizeAccountId, v as deriveSessionChatType } from "./session-key-BF-9YzxC.js";
3
+ import { a as normalizeProviderId } from "./provider-utils-DiLhkKQp.js";
4
+ import { t as getChannelDock } from "./dock-B0bIIDS3.js";
5
+ import { c as normalizeMessageChannel, n as isDeliverableMessageChannel, t as INTERNAL_MESSAGE_CHANNEL } from "./message-channel-tuc9CdEw.js";
6
+ import { y as deliveryContextFromSession } from "./sessions-DtqrmUJS.js";
7
+ import { t as normalizeChatType } from "./chat-type-CH3W-zKy.js";
8
+ import { a as isWhatsAppGroupJid, o as normalizeWhatsAppTarget, r as normalizeChannelId, t as getChannelPlugin } from "./plugins-CaudBUbl.js";
9
+ import { t as formatCliCommand } from "./command-format-BiiNHkWG.js";
10
+ import { t as parseSlackTarget } from "./targets-CmC5m7Ey.js";
11
+ import { t as parseDiscordTarget } from "./targets-D2OQt8-7.js";
12
+ import { t as logDebug } from "./logger-CPvz-aPM.js";
13
+ import { t as SILENT_REPLY_TOKEN } from "./tokens-Dw7ZdYwT.js";
14
+ import { t as getGlobalHookRunner } from "./hook-runner-global-C1thol1d.js";
15
+ import { n as extensionForMime$1, t as detectMime } from "./mime-ViuhRuMM.js";
16
+ import { n as fetchRemoteMedia } from "./fetch-Cky99wYB.js";
17
+ import { n as missingTargetError } from "./target-errors-GZXDqlUu.js";
18
+ import { n as normalizeVerboseLevel } from "./thinking-ZfH2V9Os.js";
19
+ import { i as resolveTelegramTargetChatType, r as parseTelegramTarget } from "./targets-D01MJGnh.js";
20
+ import { execFileSync, spawn } from "node:child_process";
21
+ import { homedir, tmpdir } from "node:os";
22
+ import { join } from "node:path";
23
+ import { randomUUID } from "node:crypto";
24
+ import { mkdir, mkdtemp, readFile, readdir, rm, rmdir, writeFile } from "node:fs/promises";
25
+ import { createInterface } from "node:readline";
26
+
27
+ //#region src/sessions/send-policy.ts
28
+ function normalizeSendPolicy(raw) {
29
+ const value = raw?.trim().toLowerCase();
30
+ if (value === "allow") return "allow";
31
+ if (value === "deny") return "deny";
32
+ }
33
+ function normalizeMatchValue(raw) {
34
+ const value = raw?.trim().toLowerCase();
35
+ return value ? value : void 0;
36
+ }
37
+ function stripAgentSessionKeyPrefix(key) {
38
+ if (!key) return;
39
+ const parts = key.split(":").filter(Boolean);
40
+ if (parts.length >= 3 && parts[0] === "agent") return parts.slice(2).join(":");
41
+ return key;
42
+ }
43
+ function deriveChannelFromKey(key) {
44
+ const normalizedKey = stripAgentSessionKeyPrefix(key);
45
+ if (!normalizedKey) return;
46
+ const parts = normalizedKey.split(":").filter(Boolean);
47
+ if (parts.length >= 3 && (parts[1] === "group" || parts[1] === "channel")) return normalizeMatchValue(parts[0]);
48
+ }
49
+ function deriveChatTypeFromKey(key) {
50
+ const chatType = deriveSessionChatType(key);
51
+ return chatType === "unknown" ? void 0 : chatType;
52
+ }
53
+ function resolveSendPolicy(params) {
54
+ const override = normalizeSendPolicy(params.entry?.sendPolicy);
55
+ if (override) return override;
56
+ const policy = params.cfg.session?.sendPolicy;
57
+ if (!policy) return "allow";
58
+ const channel = normalizeMatchValue(params.channel) ?? normalizeMatchValue(params.entry?.channel) ?? normalizeMatchValue(params.entry?.lastChannel) ?? deriveChannelFromKey(params.sessionKey);
59
+ const chatType = normalizeChatType(params.chatType ?? params.entry?.chatType) ?? normalizeChatType(deriveChatTypeFromKey(params.sessionKey));
60
+ const rawSessionKey = params.sessionKey ?? "";
61
+ const strippedSessionKey = stripAgentSessionKeyPrefix(rawSessionKey) ?? "";
62
+ const rawSessionKeyNorm = rawSessionKey.toLowerCase();
63
+ const strippedSessionKeyNorm = strippedSessionKey.toLowerCase();
64
+ let allowedMatch = false;
65
+ for (const rule of policy.rules ?? []) {
66
+ if (!rule) continue;
67
+ const action = normalizeSendPolicy(rule.action) ?? "allow";
68
+ const match = rule.match ?? {};
69
+ const matchChannel = normalizeMatchValue(match.channel);
70
+ const matchChatType = normalizeChatType(match.chatType);
71
+ const matchPrefix = normalizeMatchValue(match.keyPrefix);
72
+ const matchRawPrefix = normalizeMatchValue(match.rawKeyPrefix);
73
+ if (matchChannel && matchChannel !== channel) continue;
74
+ if (matchChatType && matchChatType !== chatType) continue;
75
+ if (matchRawPrefix && !rawSessionKeyNorm.startsWith(matchRawPrefix)) continue;
76
+ if (matchPrefix && !rawSessionKeyNorm.startsWith(matchPrefix) && !strippedSessionKeyNorm.startsWith(matchPrefix)) continue;
77
+ if (action === "deny") return "deny";
78
+ allowedMatch = true;
79
+ }
80
+ if (allowedMatch) return "allow";
81
+ return normalizeSendPolicy(policy.default) ?? "allow";
82
+ }
83
+
84
+ //#endregion
85
+ //#region src/sessions/level-overrides.ts
86
+ function parseVerboseOverride(raw) {
87
+ if (raw === null) return {
88
+ ok: true,
89
+ value: null
90
+ };
91
+ if (raw === void 0) return {
92
+ ok: true,
93
+ value: void 0
94
+ };
95
+ if (typeof raw !== "string") return {
96
+ ok: false,
97
+ error: "invalid verboseLevel (use \"on\"|\"off\")"
98
+ };
99
+ const normalized = normalizeVerboseLevel(raw);
100
+ if (!normalized) return {
101
+ ok: false,
102
+ error: "invalid verboseLevel (use \"on\"|\"off\")"
103
+ };
104
+ return {
105
+ ok: true,
106
+ value: normalized
107
+ };
108
+ }
109
+ function applyVerboseOverride(entry, level) {
110
+ if (level === void 0) return;
111
+ if (level === null) {
112
+ delete entry.verboseLevel;
113
+ return;
114
+ }
115
+ entry.verboseLevel = level;
116
+ }
117
+
118
+ //#endregion
119
+ //#region src/infra/system-events.ts
120
+ const MAX_EVENTS = 20;
121
+ const queues = /* @__PURE__ */ new Map();
122
+ function requireSessionKey(key) {
123
+ const trimmed = typeof key === "string" ? key.trim() : "";
124
+ if (!trimmed) throw new Error("system events require a sessionKey");
125
+ return trimmed;
126
+ }
127
+ function normalizeContextKey(key) {
128
+ if (!key) return null;
129
+ const trimmed = key.trim();
130
+ if (!trimmed) return null;
131
+ return trimmed.toLowerCase();
132
+ }
133
+ function isSystemEventContextChanged(sessionKey, contextKey) {
134
+ const key = requireSessionKey(sessionKey);
135
+ const existing = queues.get(key);
136
+ return normalizeContextKey(contextKey) !== (existing?.lastContextKey ?? null);
137
+ }
138
+ function enqueueSystemEvent(text, options) {
139
+ const key = requireSessionKey(options?.sessionKey);
140
+ const entry = queues.get(key) ?? (() => {
141
+ const created = {
142
+ queue: [],
143
+ lastText: null,
144
+ lastContextKey: null
145
+ };
146
+ queues.set(key, created);
147
+ return created;
148
+ })();
149
+ const cleaned = text.trim();
150
+ if (!cleaned) return;
151
+ const normalizedContextKey = normalizeContextKey(options?.contextKey);
152
+ entry.lastContextKey = normalizedContextKey;
153
+ if (entry.lastText === cleaned) return;
154
+ entry.lastText = cleaned;
155
+ entry.queue.push({
156
+ text: cleaned,
157
+ ts: Date.now(),
158
+ contextKey: normalizedContextKey
159
+ });
160
+ if (entry.queue.length > MAX_EVENTS) entry.queue.shift();
161
+ }
162
+ function drainSystemEventEntries(sessionKey) {
163
+ const key = requireSessionKey(sessionKey);
164
+ const entry = queues.get(key);
165
+ if (!entry || entry.queue.length === 0) return [];
166
+ const out = entry.queue.slice();
167
+ entry.queue.length = 0;
168
+ entry.lastText = null;
169
+ entry.lastContextKey = null;
170
+ queues.delete(key);
171
+ return out;
172
+ }
173
+ function peekSystemEventEntries(sessionKey) {
174
+ const key = requireSessionKey(sessionKey);
175
+ return queues.get(key)?.queue.map((event) => ({ ...event })) ?? [];
176
+ }
177
+ function peekSystemEvents(sessionKey) {
178
+ return peekSystemEventEntries(sessionKey).map((event) => event.text);
179
+ }
180
+
181
+ //#endregion
182
+ //#region src/agents/channel-tools.ts
183
+ /**
184
+ * Get the list of supported message actions for a specific channel.
185
+ * Returns an empty array if channel is not found or has no actions configured.
186
+ */
187
+ function listChannelSupportedActions(params) {
188
+ if (!params.channel) return [];
189
+ const plugin = getChannelPlugin(params.channel);
190
+ if (!plugin?.actions?.listActions) return [];
191
+ return runPluginListActions(plugin, params.cfg ?? {});
192
+ }
193
+ function resolveChannelMessageToolHints(params) {
194
+ const channelId = normalizeAnyChannelId(params.channel);
195
+ if (!channelId) return [];
196
+ const resolve = getChannelDock(channelId)?.agentPrompt?.messageToolHints;
197
+ if (!resolve) return [];
198
+ return (resolve({
199
+ cfg: params.cfg ?? {},
200
+ accountId: params.accountId
201
+ }) ?? []).map((entry) => entry.trim()).filter(Boolean);
202
+ }
203
+ const loggedListActionErrors = /* @__PURE__ */ new Set();
204
+ function runPluginListActions(plugin, cfg) {
205
+ if (!plugin.actions?.listActions) return [];
206
+ try {
207
+ const listed = plugin.actions.listActions({ cfg });
208
+ return Array.isArray(listed) ? listed : [];
209
+ } catch (err) {
210
+ logListActionsError(plugin.id, err);
211
+ return [];
212
+ }
213
+ }
214
+ function logListActionsError(pluginId, err) {
215
+ const message = err instanceof Error ? err.message : String(err);
216
+ const key = `${pluginId}:${message}`;
217
+ if (loggedListActionErrors.has(key)) return;
218
+ loggedListActionErrors.add(key);
219
+ const details = (err instanceof Error && err.stack ? err.stack : null) ?? message;
220
+ defaultRuntime.error?.(`[channel-tools] ${pluginId}.actions.listActions failed: ${details}`);
221
+ }
222
+
223
+ //#endregion
224
+ //#region src/middleware/error-classifier.ts
225
+ const retryablePatterns = [
226
+ /rate.?limit/i,
227
+ /429/i,
228
+ /503/i,
229
+ /overloaded/i,
230
+ /ETIMEDOUT/i,
231
+ /ECONNRESET/i,
232
+ /ECONNREFUSED/i,
233
+ /network/i
234
+ ];
235
+ const contextOverflowPatterns = [
236
+ /context.?length/i,
237
+ /context.?window/i,
238
+ /context.?overflow/i,
239
+ /too many tokens/i,
240
+ /maximum context/i,
241
+ /token.?limit/i
242
+ ];
243
+ const fatalAuthPatterns = [
244
+ /401/i,
245
+ /403/i,
246
+ /unauthorized/i,
247
+ /forbidden/i,
248
+ /invalid.?key/i,
249
+ /authentication/i
250
+ ];
251
+ /**
252
+ * Rate-limit and auth failure patterns that may benefit from key rotation.
253
+ *
254
+ * Includes rate-limit indicators (429, quota) and auth failures
255
+ * (401, invalid key) — a different API key might succeed in either case.
256
+ */
257
+ const authRotatablePatterns = [
258
+ /rate.?limit/i,
259
+ /\b429\b/,
260
+ /quota.?exceeded/i,
261
+ /resource.?exhausted/i,
262
+ /too many requests/i,
263
+ /\b401\b/,
264
+ /unauthorized/i,
265
+ /invalid.?key/i
266
+ ];
267
+ /**
268
+ * Test whether an error message indicates a rate-limit or auth failure
269
+ * that could be resolved by rotating to a different API key.
270
+ */
271
+ function isAuthRotatableError(message) {
272
+ return authRotatablePatterns.some((pattern) => pattern.test(message));
273
+ }
274
+ /**
275
+ * Classify an error message string into an actionable category.
276
+ *
277
+ * Uses first-match-wins semantics across ordered pattern arrays:
278
+ * 1. Retryable patterns checked first
279
+ * 2. Context overflow patterns checked second
280
+ * 3. Fatal auth patterns checked third
281
+ * 4. Default: "fatal" for unmatched messages
282
+ *
283
+ * Case-insensitive matching throughout.
284
+ */
285
+ function classifyError(message) {
286
+ for (const pattern of retryablePatterns) if (pattern.test(message)) {
287
+ logDebug(`[error-classifier] classified as retryable: ${message.slice(0, 200)}`);
288
+ return "retryable";
289
+ }
290
+ for (const pattern of contextOverflowPatterns) if (pattern.test(message)) {
291
+ logDebug(`[error-classifier] classified as context_overflow: ${message.slice(0, 200)}`);
292
+ return "context_overflow";
293
+ }
294
+ for (const pattern of fatalAuthPatterns) if (pattern.test(message)) {
295
+ logDebug(`[error-classifier] classified as fatal (auth): ${message.slice(0, 200)}`);
296
+ return "fatal";
297
+ }
298
+ logDebug(`[error-classifier] classified as fatal (unmatched): ${message.slice(0, 200)}`);
299
+ return "fatal";
300
+ }
301
+
302
+ //#endregion
303
+ //#region src/middleware/delivery-adapter.ts
304
+ const DEFAULT_CHUNK_LIMIT = 4e3;
305
+ /**
306
+ * Converts AgentEvent async iterable into channel-deliverable ReplyPayload chunks.
307
+ *
308
+ * Handles:
309
+ * - Text accumulation and chunking at channel limits
310
+ * - Progressive streaming via BridgeCallbacks
311
+ * - Tool result formatting
312
+ * - Error event formatting
313
+ */
314
+ var DeliveryAdapter = class {
315
+ constructor(options) {
316
+ this.chunkLimit = options?.chunkLimit ?? DEFAULT_CHUNK_LIMIT;
317
+ }
318
+ /**
319
+ * Process an event stream, invoking callbacks for real-time delivery
320
+ * and returning final payloads for post-execution delivery.
321
+ *
322
+ * @param events - AgentEvent async iterable from runtime.execute()
323
+ * @param callbacks - Optional streaming callbacks for real-time delivery
324
+ * @returns Final ReplyPayload array for post-execution delivery
325
+ */
326
+ async process(events, callbacks) {
327
+ let textBuffer = "";
328
+ const payloads = [];
329
+ /** Track media delivered via streaming events to avoid duplicates from result.media. */
330
+ const deliveredMediaKeys = /* @__PURE__ */ new Set();
331
+ let eventCount = 0;
332
+ for await (const event of events) {
333
+ eventCount++;
334
+ switch (event.type) {
335
+ case "text":
336
+ if (event.text === "") break;
337
+ textBuffer += event.text;
338
+ while (textBuffer.length > this.chunkLimit) {
339
+ const { chunk, rest } = splitAtBoundary(textBuffer, this.chunkLimit);
340
+ textBuffer = rest;
341
+ const payload = { text: chunk };
342
+ payloads.push(payload);
343
+ await callbacks?.onPartialReply?.(payload);
344
+ }
345
+ break;
346
+ case "media": {
347
+ const mediaUrl = event.media.filePath ?? event.media.sourceUrl;
348
+ if (mediaUrl) {
349
+ if (textBuffer.length > 0) {
350
+ const textPayload = { text: textBuffer };
351
+ payloads.push(textPayload);
352
+ await callbacks?.onBlockReply?.(textPayload);
353
+ textBuffer = "";
354
+ }
355
+ deliveredMediaKeys.add(mediaUrl);
356
+ const payload = { mediaUrl };
357
+ payloads.push(payload);
358
+ await callbacks?.onBlockReply?.(payload);
359
+ }
360
+ break;
361
+ }
362
+ case "thinking":
363
+ if (event.text) callbacks?.onThinking?.({ text: event.text });
364
+ break;
365
+ case "tool_use": break;
366
+ case "tool_result": {
367
+ const payload = { text: formatToolResult(event.toolId, event.output, event.isError) };
368
+ await callbacks?.onToolResult?.(payload);
369
+ break;
370
+ }
371
+ case "error": {
372
+ const payload = {
373
+ text: event.code ? `[${event.code}] ${event.message}` : event.message,
374
+ isError: true
375
+ };
376
+ payloads.push(payload);
377
+ await callbacks?.onBlockReply?.(payload);
378
+ break;
379
+ }
380
+ case "done":
381
+ if (textBuffer.length > 0) {
382
+ const payload = { text: textBuffer };
383
+ payloads.push(payload);
384
+ await callbacks?.onBlockReply?.(payload);
385
+ textBuffer = "";
386
+ }
387
+ if (event.result.media?.length) for (const media of event.result.media) {
388
+ const url = media.filePath ?? media.sourceUrl;
389
+ if (url && !deliveredMediaKeys.has(url)) {
390
+ const payload = { mediaUrl: url };
391
+ payloads.push(payload);
392
+ await callbacks?.onBlockReply?.(payload);
393
+ }
394
+ }
395
+ break;
396
+ }
397
+ }
398
+ if (textBuffer.length > 0) {
399
+ const payload = { text: textBuffer };
400
+ payloads.push(payload);
401
+ }
402
+ logDebug(`[delivery-adapter] processed ${eventCount} events into ${payloads.length} payloads (chunkLimit=${this.chunkLimit})`);
403
+ return payloads;
404
+ }
405
+ };
406
+ /** Format a tool result for display. */
407
+ function formatToolResult(toolId, output, isError) {
408
+ return `${isError ? `Tool ${toolId} error` : `Tool ${toolId} result`}: ${output}`;
409
+ }
410
+ /**
411
+ * Split text at the nearest safe boundary before the limit.
412
+ *
413
+ * Preference order:
414
+ * 1. Paragraph break (\n\n)
415
+ * 2. Line break (\n)
416
+ * 3. Word boundary (space)
417
+ * 4. Hard split at limit
418
+ *
419
+ * Markdown-aware: preserves code fence boundaries by closing/reopening
420
+ * fences at split points when a split occurs inside a fenced code block.
421
+ */
422
+ function splitAtBoundary(text, limit) {
423
+ const fenceInfo = findOpenCodeFence(text, limit);
424
+ if (fenceInfo !== void 0) {
425
+ const beforeFence = text.substring(0, fenceInfo.fenceStart);
426
+ if (beforeFence.trimEnd().length > 0) {
427
+ const trimmed = beforeFence.trimEnd();
428
+ return {
429
+ chunk: trimmed,
430
+ rest: text.substring(trimmed.length).trimStart()
431
+ };
432
+ }
433
+ const closingFence = `\n${fenceInfo.fence}`;
434
+ const openingFence = `${fenceInfo.fence}\n`;
435
+ const splitPoint = findSplitPoint(text, limit - closingFence.length);
436
+ return {
437
+ chunk: text.substring(0, splitPoint) + closingFence,
438
+ rest: openingFence + text.substring(splitPoint)
439
+ };
440
+ }
441
+ const splitPoint = findSplitPoint(text, limit);
442
+ return {
443
+ chunk: text.substring(0, splitPoint),
444
+ rest: text.substring(splitPoint)
445
+ };
446
+ }
447
+ /** Find the best split point within the text up to the given limit. */
448
+ function findSplitPoint(text, limit) {
449
+ if (limit <= 0) return Math.min(1, text.length);
450
+ const searchRegion = text.substring(0, limit);
451
+ const paragraphIdx = searchRegion.lastIndexOf("\n\n");
452
+ if (paragraphIdx > 0) return paragraphIdx + 2;
453
+ const lineIdx = searchRegion.lastIndexOf("\n");
454
+ if (lineIdx > 0) return lineIdx + 1;
455
+ const spaceIdx = searchRegion.lastIndexOf(" ");
456
+ if (spaceIdx > 0) return spaceIdx + 1;
457
+ return limit;
458
+ }
459
+ /**
460
+ * Detect if the text has an unclosed code fence at or before the limit position.
461
+ * Returns info about the open fence, or undefined if no open fence.
462
+ */
463
+ function findOpenCodeFence(text, limit) {
464
+ const fenceRegex = /^(`{3,}|~{3,})/gm;
465
+ let openFence;
466
+ let match;
467
+ while ((match = fenceRegex.exec(text)) !== null) {
468
+ if (match.index >= limit) break;
469
+ if (openFence === void 0) openFence = {
470
+ fenceStart: match.index,
471
+ fence: match[1]
472
+ };
473
+ else if (match[1].charAt(0) === openFence.fence.charAt(0) && match[1].length >= openFence.fence.length) openFence = void 0;
474
+ }
475
+ return openFence;
476
+ }
477
+
478
+ //#endregion
479
+ //#region src/middleware/mcp-side-effects.ts
480
+ async function readMcpSideEffects(filePath) {
481
+ const result = {
482
+ sentTexts: [],
483
+ sentMediaUrls: [],
484
+ sentTargets: [],
485
+ cronAdds: 0
486
+ };
487
+ let content;
488
+ try {
489
+ content = await readFile(filePath, "utf-8");
490
+ } catch {
491
+ return result;
492
+ }
493
+ const lines = content.split("\n").filter(Boolean);
494
+ for (const line of lines) {
495
+ let record;
496
+ try {
497
+ record = JSON.parse(line);
498
+ } catch {
499
+ continue;
500
+ }
501
+ if (record.type === "message_sent") {
502
+ result.sentTexts.push(record.text);
503
+ if (record.mediaUrl) result.sentMediaUrls.push(record.mediaUrl);
504
+ const target = {
505
+ tool: record.tool,
506
+ provider: record.provider,
507
+ ...record.accountId ? { accountId: record.accountId } : {},
508
+ ...record.to ? { to: record.to } : {}
509
+ };
510
+ result.sentTargets.push(target);
511
+ } else if (record.type === "cron_added") result.cronAdds += 1;
512
+ else if (record.type === "heartbeat_report") result.heartbeatReport = {
513
+ anythingDone: record.anythingDone,
514
+ summary: record.summary
515
+ };
516
+ }
517
+ return result;
518
+ }
519
+
520
+ //#endregion
521
+ //#region src/middleware/media-capability.ts
522
+ /**
523
+ * Partition media attachments by whether the runtime accepts them.
524
+ *
525
+ * If the runtime does not declare `mediaCapabilities` at all, all media is
526
+ * treated as supported (backwards-compatible — the runtime decides what to do).
527
+ */
528
+ function partitionMedia(runtime, media) {
529
+ const prefixes = runtime.mediaCapabilities?.acceptsInbound;
530
+ if (prefixes === void 0) return {
531
+ supported: media,
532
+ unsupported: []
533
+ };
534
+ const supported = [];
535
+ const unsupported = [];
536
+ for (const attachment of media) if (prefixes.some((prefix) => attachment.mimeType.startsWith(prefix))) supported.push(attachment);
537
+ else unsupported.push(attachment);
538
+ return {
539
+ supported,
540
+ unsupported
541
+ };
542
+ }
543
+ /**
544
+ * Format a user-facing warning for media the runtime cannot handle.
545
+ *
546
+ * Returns `undefined` when there are no unsupported attachments.
547
+ */
548
+ function formatUnsupportedMediaWarning(unsupported, runtimeName) {
549
+ if (unsupported.length === 0) return;
550
+ const typeSummary = summarizeMediaTypes(unsupported);
551
+ const runtimeLabel = runtimeName.toLowerCase();
552
+ if (unsupported.length === 1) return `\u26a0\ufe0f Your ${typeSummary} was received but the current runtime (${runtimeLabel}) doesn't support ${typeSummary} input. Its content was not included in the conversation.`;
553
+ return `\u26a0\ufe0f ${unsupported.length} media attachments were received but the current runtime (${runtimeLabel}) doesn't support them: ${typeSummary}. Their content was not included in the conversation.`;
554
+ }
555
+ /**
556
+ * Produce a human-readable summary of MIME type categories.
557
+ *
558
+ * Groups by top-level type (image, audio, video) and deduplicates.
559
+ * Falls back to "media" for unknown types.
560
+ */
561
+ function summarizeMediaTypes(attachments) {
562
+ const categories = /* @__PURE__ */ new Set();
563
+ for (const a of attachments) switch (a.mimeType.split("/")[0]) {
564
+ case "image":
565
+ categories.add("image");
566
+ break;
567
+ case "audio":
568
+ categories.add("audio");
569
+ break;
570
+ case "video":
571
+ categories.add("video");
572
+ break;
573
+ default:
574
+ categories.add("media");
575
+ break;
576
+ }
577
+ return [...categories].toSorted().join("/");
578
+ }
579
+
580
+ //#endregion
581
+ //#region src/middleware/media-resolver.ts
582
+ /** Max download size for inbound channel media (100 MB). */
583
+ const MAX_INBOUND_MEDIA_BYTES = 100 * 1024 * 1024;
584
+ /**
585
+ * Resolve an array of media URLs (HTTP or local paths) into MediaAttachment
586
+ * objects suitable for passing to {@link AgentRuntime.execute}.
587
+ *
588
+ * Remote URLs are downloaded into `tempDir` so that CLI runtimes can access
589
+ * them as local files. Local paths are validated for MIME type only.
590
+ *
591
+ * Individual resolution failures are silently skipped — a single bad URL
592
+ * should not prevent the rest of the message from being processed.
593
+ */
594
+ async function resolveMediaAttachments(mediaUrls, tempDir) {
595
+ const results = [];
596
+ for (const [index, url] of mediaUrls.entries()) try {
597
+ const attachment = await resolveOne(url, tempDir, index);
598
+ if (attachment) {
599
+ logDebug(`[media-resolver] resolved: url=${url} mime=${attachment.mimeType} path=${attachment.filePath}`);
600
+ results.push(attachment);
601
+ }
602
+ } catch (err) {
603
+ logDebug(`[media-resolver] failed: url=${url} error=${String(err)}`);
604
+ }
605
+ return results;
606
+ }
607
+ async function resolveOne(url, tempDir, index) {
608
+ if (/^https?:\/\//i.test(url)) return downloadRemote(url, tempDir, index);
609
+ return resolveLocal(url);
610
+ }
611
+ async function downloadRemote(url, tempDir, index) {
612
+ const fetched = await fetchRemoteMedia({
613
+ url,
614
+ maxBytes: MAX_INBOUND_MEDIA_BYTES
615
+ });
616
+ const mimeType = fetched.contentType ?? "application/octet-stream";
617
+ const fileName = `inbound-media-${index}${extensionForMime$1(mimeType) ?? ""}`;
618
+ const filePath = join(tempDir, fileName);
619
+ await writeFile(filePath, fetched.buffer);
620
+ return {
621
+ mimeType,
622
+ filePath,
623
+ sourceUrl: url,
624
+ fileName: fetched.fileName ?? fileName
625
+ };
626
+ }
627
+ async function resolveLocal(filePath) {
628
+ return {
629
+ mimeType: await detectMime({ filePath }) ?? "application/octet-stream",
630
+ filePath
631
+ };
632
+ }
633
+
634
+ //#endregion
635
+ //#region src/middleware/cli-runtime-base.ts
636
+ /**
637
+ * Abstract base class encapsulating shared subprocess machinery for CLI-based agent runtimes.
638
+ *
639
+ * Concrete runtimes (Claude, Gemini, Codex, OpenCode) extend this and implement only
640
+ * the CLI-specific parts: argument construction, event extraction, and environment setup.
641
+ */
642
+ var CLIRuntimeBase = class CLIRuntimeBase {
643
+ static {
644
+ this.STDIN_PROMPT_THRESHOLD = 1e4;
645
+ }
646
+ constructor(command, timeoutMs = 3e5) {
647
+ this.command = command;
648
+ this.timeoutMs = timeoutMs;
649
+ }
650
+ /**
651
+ * Construct a custom stdin payload for the subprocess.
652
+ * When this returns a string, it is written to stdin instead of
653
+ * the default large-prompt fallback. Subclasses may override.
654
+ */
655
+ buildStdinPayload(_params) {}
656
+ /** Whether this CLI accepts prompts via stdin. Subclasses may override. */
657
+ get supportsStdinPrompt() {
658
+ return true;
659
+ }
660
+ /**
661
+ * Which subprocess stream carries NDJSON output.
662
+ * Defaults to `"stdout"`. Override to `"stderr"` for CLIs (like Claude)
663
+ * that emit structured output on stderr.
664
+ */
665
+ get ndjsonStream() {
666
+ return "stdout";
667
+ }
668
+ async *execute(params) {
669
+ const args = this.buildArgs(params);
670
+ if (params.extraArgs && params.extraArgs.length > 0) args.push(...params.extraArgs);
671
+ const runtimeEnv = this.buildEnv(params);
672
+ const callerEnv = params.env ?? {};
673
+ const env = {
674
+ ...process.env,
675
+ ...runtimeEnv,
676
+ ...callerEnv
677
+ };
678
+ logDebug(`[agent-runtime] spawn: ${this.command} ${args.map((a) => JSON.stringify(a)).join(" ")}`);
679
+ logDebug(`[agent-runtime] cwd: ${params.workingDirectory ?? process.cwd()}`);
680
+ if (Object.keys(runtimeEnv).length > 0) logDebug(`[agent-runtime] runtime env keys: ${Object.keys(runtimeEnv).join(", ")}`);
681
+ if (Object.keys(callerEnv).length > 0) logDebug(`[agent-runtime] caller env keys: ${Object.keys(callerEnv).join(", ")}`);
682
+ const child = spawn(this.command, args, {
683
+ cwd: params.workingDirectory,
684
+ env,
685
+ stdio: [
686
+ "pipe",
687
+ "pipe",
688
+ "pipe"
689
+ ]
690
+ });
691
+ logDebug(`[agent-runtime] spawned pid=${child.pid}`);
692
+ const startMs = Date.now();
693
+ const stderrChunks = [];
694
+ let aborted = false;
695
+ let yieldedEvents = false;
696
+ let escalationTimer;
697
+ const killWithEscalation = () => {
698
+ if (escalationTimer === void 0) escalationTimer = setTimeout(() => {
699
+ try {
700
+ child.kill("SIGKILL");
701
+ } catch {}
702
+ }, 1500);
703
+ child.kill("SIGTERM");
704
+ };
705
+ child.on("exit", () => {
706
+ if (escalationTimer !== void 0) {
707
+ clearTimeout(escalationTimer);
708
+ escalationTimer = void 0;
709
+ }
710
+ });
711
+ let watchdogTimer;
712
+ let watchdogFired = false;
713
+ const resetWatchdog = () => {
714
+ if (watchdogTimer !== void 0) clearTimeout(watchdogTimer);
715
+ watchdogTimer = setTimeout(() => {
716
+ watchdogFired = true;
717
+ logDebug(`[agent-runtime] pid=${child.pid}: watchdog timeout after ${this.timeoutMs}ms`);
718
+ killWithEscalation();
719
+ }, this.timeoutMs);
720
+ };
721
+ resetWatchdog();
722
+ const ndjsonSource = this.ndjsonStream === "stderr" ? child.stderr : child.stdout;
723
+ (this.ndjsonStream === "stderr" ? child.stdout : child.stderr)?.on("data", (chunk) => {
724
+ stderrChunks.push(chunk.toString());
725
+ });
726
+ const rl = createInterface({ input: ndjsonSource });
727
+ const eventQueue = [];
728
+ let resolveNext;
729
+ let streamDone = false;
730
+ const enqueue = (event) => {
731
+ eventQueue.push(event);
732
+ resolveNext?.();
733
+ };
734
+ rl.on("line", (line) => {
735
+ resetWatchdog();
736
+ if (!line.trim()) return;
737
+ try {
738
+ JSON.parse(line);
739
+ } catch {
740
+ return;
741
+ }
742
+ const event = this.extractEvent(line);
743
+ if (event) enqueue(event);
744
+ });
745
+ rl.on("close", () => {
746
+ streamDone = true;
747
+ enqueue(null);
748
+ });
749
+ const exitPromise = new Promise((resolve) => {
750
+ child.on("exit", (code, signal) => {
751
+ resolve({
752
+ code,
753
+ signal
754
+ });
755
+ });
756
+ });
757
+ const customStdin = this.buildStdinPayload(params);
758
+ if (customStdin !== void 0 && child.stdin) {
759
+ logDebug(`[agent-runtime] pid=${child.pid}: delivering custom stdin payload (${customStdin.length} chars)`);
760
+ child.stdin.write(customStdin);
761
+ } else if (this.supportsStdinPrompt && params.prompt.length > CLIRuntimeBase.STDIN_PROMPT_THRESHOLD && child.stdin) {
762
+ logDebug(`[agent-runtime] pid=${child.pid}: delivering prompt via stdin (${params.prompt.length} chars)`);
763
+ child.stdin.write(params.prompt);
764
+ }
765
+ child.stdin?.end();
766
+ const onAbort = () => {
767
+ aborted = true;
768
+ logDebug(`[agent-runtime] pid=${child.pid}: abort signal received`);
769
+ killWithEscalation();
770
+ };
771
+ if (params.abortSignal) if (params.abortSignal.aborted) {
772
+ aborted = true;
773
+ killWithEscalation();
774
+ } else params.abortSignal.addEventListener("abort", onAbort, { once: true });
775
+ try {
776
+ while (!streamDone) {
777
+ if (eventQueue.length === 0) await new Promise((resolve) => {
778
+ resolveNext = resolve;
779
+ });
780
+ while (eventQueue.length > 0) {
781
+ const event = eventQueue.shift();
782
+ if (event === null || event === void 0) break;
783
+ yieldedEvents = true;
784
+ yield event;
785
+ }
786
+ }
787
+ } finally {
788
+ if (watchdogTimer !== void 0) clearTimeout(watchdogTimer);
789
+ params.abortSignal?.removeEventListener("abort", onAbort);
790
+ }
791
+ const { code: exitCode, signal: exitSignal } = await exitPromise;
792
+ if (escalationTimer !== void 0) clearTimeout(escalationTimer);
793
+ const durationMs = Date.now() - startMs;
794
+ logDebug(`[agent-runtime] pid=${child.pid}: exited code=${exitCode} signal=${exitSignal} duration=${durationMs}ms`);
795
+ const stderr = stderrChunks.join("");
796
+ if (stderr && (exitCode !== 0 || !yieldedEvents)) yield {
797
+ type: "error",
798
+ message: stderr.trim(),
799
+ code: "CLI_STDERR"
800
+ };
801
+ if (watchdogFired) yield {
802
+ type: "error",
803
+ message: `Watchdog timeout: no output for ${this.timeoutMs}ms`,
804
+ code: "WATCHDOG_TIMEOUT"
805
+ };
806
+ if (aborted) yield {
807
+ type: "error",
808
+ message: "Execution aborted",
809
+ code: "ABORTED"
810
+ };
811
+ yield {
812
+ type: "done",
813
+ result: {
814
+ text: "",
815
+ sessionId: void 0,
816
+ durationMs,
817
+ usage: void 0,
818
+ aborted,
819
+ stderr: stderr || void 0
820
+ }
821
+ };
822
+ }
823
+ };
824
+
825
+ //#endregion
826
+ //#region src/middleware/runtimes/claude.ts
827
+ /**
828
+ * Claude CLI runtime — invokes `claude --print --output-format stream-json`
829
+ * and maps the streaming NDJSON output to {@link AgentEvent} instances.
830
+ */
831
+ var ClaudeCliRuntime = class extends CLIRuntimeBase {
832
+ constructor() {
833
+ super("claude");
834
+ this.mediaCapabilities = {
835
+ acceptsInbound: ["image/"],
836
+ emitsOutbound: false
837
+ };
838
+ this.accumulatedText = "";
839
+ this.toolBuffer = null;
840
+ }
841
+ async *execute(params) {
842
+ this.resetState();
843
+ const prepared = await this.prepareMedia(params);
844
+ for await (const event of super.execute(prepared)) {
845
+ if (event.type === "done") this.enrichDoneEvent(event);
846
+ yield event;
847
+ }
848
+ }
849
+ buildArgs(params) {
850
+ const args = [
851
+ "--output-format",
852
+ "stream-json",
853
+ "--verbose",
854
+ "--include-partial-messages"
855
+ ];
856
+ if (params.sessionId) args.push("--resume", params.sessionId);
857
+ if (params.mcpServers && Object.keys(params.mcpServers).length > 0) args.push("--mcp-config", JSON.stringify({ mcpServers: params.mcpServers }));
858
+ if (params.media?.some((m) => m.mimeType.startsWith("image/") && m.base64)) args.push("-p", "--input-format", "stream-json");
859
+ else args.push("--print", params.prompt);
860
+ return args;
861
+ }
862
+ buildStdinPayload(params) {
863
+ const images = params.media?.filter((m) => m.mimeType.startsWith("image/") && m.base64);
864
+ if (!images?.length) return;
865
+ const content = images.map((img) => ({
866
+ type: "image",
867
+ source: {
868
+ type: "base64",
869
+ media_type: img.mimeType,
870
+ data: img.base64
871
+ }
872
+ }));
873
+ content.push({
874
+ type: "text",
875
+ text: params.prompt
876
+ });
877
+ const envelope = {
878
+ type: "user",
879
+ message: {
880
+ role: "user",
881
+ content
882
+ }
883
+ };
884
+ return JSON.stringify(envelope) + "\n";
885
+ }
886
+ extractEvent(line) {
887
+ const parsed = JSON.parse(line);
888
+ if (!isObject$3(parsed)) return null;
889
+ if (parsed.type === "system") {
890
+ if (typeof parsed.session_id === "string" && !this.currentSessionId) this.currentSessionId = parsed.session_id;
891
+ return null;
892
+ }
893
+ if (parsed.type === "stream_event") {
894
+ if (typeof parsed.session_id === "string" && !this.currentSessionId) this.currentSessionId = parsed.session_id;
895
+ if (isObject$3(parsed.event)) return this.handleInnerEvent(parsed.event);
896
+ return null;
897
+ }
898
+ if (parsed.type === "result") {
899
+ this.storeResultData(parsed);
900
+ if (parsed.is_error === true && typeof parsed.result === "string" && parsed.result) return {
901
+ type: "error",
902
+ message: parsed.result,
903
+ code: "CLI_ERROR"
904
+ };
905
+ return null;
906
+ }
907
+ return null;
908
+ }
909
+ buildEnv(_params) {
910
+ return {};
911
+ }
912
+ handleInnerEvent(event) {
913
+ switch (event.type) {
914
+ case "content_block_start": return this.handleContentBlockStart(event);
915
+ case "content_block_delta": return this.handleContentBlockDelta(event);
916
+ case "content_block_stop": return this.handleContentBlockStop();
917
+ case "message_delta":
918
+ this.handleMessageDelta(event);
919
+ return null;
920
+ default: return null;
921
+ }
922
+ }
923
+ handleContentBlockStart(event) {
924
+ const contentBlock = isObject$3(event.content_block) ? event.content_block : null;
925
+ if (!contentBlock) return null;
926
+ if (contentBlock.type === "tool_use") this.toolBuffer = {
927
+ name: typeof contentBlock.name === "string" ? contentBlock.name : "",
928
+ id: typeof contentBlock.id === "string" ? contentBlock.id : "",
929
+ input: ""
930
+ };
931
+ return null;
932
+ }
933
+ handleContentBlockDelta(event) {
934
+ const delta = isObject$3(event.delta) ? event.delta : null;
935
+ if (!delta) return null;
936
+ if (delta.type === "text_delta" && typeof delta.text === "string") {
937
+ this.accumulatedText += delta.text;
938
+ return {
939
+ type: "text",
940
+ text: delta.text
941
+ };
942
+ }
943
+ if (delta.type === "input_json_delta" && typeof delta.partial_json === "string") {
944
+ if (this.toolBuffer) this.toolBuffer.input += delta.partial_json;
945
+ return null;
946
+ }
947
+ if (delta.type === "thinking_delta" && typeof delta.thinking === "string") return {
948
+ type: "thinking",
949
+ text: delta.thinking
950
+ };
951
+ return null;
952
+ }
953
+ handleContentBlockStop() {
954
+ if (this.toolBuffer) {
955
+ const { name, id, input } = this.toolBuffer;
956
+ this.toolBuffer = null;
957
+ let parsedInput = {};
958
+ if (input) try {
959
+ parsedInput = JSON.parse(input);
960
+ } catch {}
961
+ return {
962
+ type: "tool_use",
963
+ toolName: name,
964
+ toolId: id,
965
+ input: parsedInput
966
+ };
967
+ }
968
+ return null;
969
+ }
970
+ handleMessageDelta(event) {
971
+ const delta = isObject$3(event.delta) ? event.delta : null;
972
+ if (delta && typeof delta.stop_reason === "string") this.lastStopReason = delta.stop_reason;
973
+ const usage = isObject$3(event.usage) ? parseUsage(event.usage) : void 0;
974
+ if (usage) this.lastUsage = usage;
975
+ }
976
+ storeResultData(parsed) {
977
+ const usage = isObject$3(parsed.usage) ? parsed.usage : null;
978
+ this.resultData = {
979
+ sessionId: typeof parsed.session_id === "string" ? parsed.session_id : void 0,
980
+ costUsd: typeof parsed.cost_usd === "number" ? parsed.cost_usd : void 0,
981
+ durationApiMs: typeof parsed.duration_api_ms === "number" ? parsed.duration_api_ms : void 0,
982
+ numTurns: typeof parsed.num_turns === "number" ? parsed.num_turns : void 0,
983
+ subtype: typeof parsed.subtype === "string" ? parsed.subtype : void 0,
984
+ usage: usage ? parseUsage(usage) : void 0
985
+ };
986
+ }
987
+ enrichDoneEvent(event) {
988
+ const { result } = event;
989
+ result.text = this.accumulatedText;
990
+ result.sessionId = this.resultData?.sessionId ?? this.currentSessionId;
991
+ result.stopReason = this.lastStopReason ?? this.resultData?.subtype;
992
+ result.usage = this.resultData?.usage ?? this.lastUsage;
993
+ if (this.resultData?.costUsd !== void 0) result.totalCostUsd = this.resultData.costUsd;
994
+ if (this.resultData?.durationApiMs !== void 0) result.apiDurationMs = this.resultData.durationApiMs;
995
+ if (this.resultData?.numTurns !== void 0) result.numTurns = this.resultData.numTurns;
996
+ }
997
+ /**
998
+ * Read image files referenced by media attachments and populate their base64 field.
999
+ * Non-image media types are filtered out (audio/video are not supported natively).
1000
+ */
1001
+ async prepareMedia(params) {
1002
+ if (!params.media?.length) return params;
1003
+ const prepared = [];
1004
+ for (const attachment of params.media) {
1005
+ if (!attachment.mimeType.startsWith("image/")) continue;
1006
+ if (attachment.base64) {
1007
+ prepared.push(attachment);
1008
+ continue;
1009
+ }
1010
+ if (attachment.filePath) {
1011
+ try {
1012
+ const buffer = await readFile(attachment.filePath);
1013
+ prepared.push({
1014
+ ...attachment,
1015
+ base64: buffer.toString("base64")
1016
+ });
1017
+ } catch {
1018
+ logDebug(`[claude-runtime] failed to read media file: ${attachment.filePath}`);
1019
+ }
1020
+ continue;
1021
+ }
1022
+ }
1023
+ return {
1024
+ ...params,
1025
+ media: prepared.length > 0 ? prepared : void 0
1026
+ };
1027
+ }
1028
+ resetState() {
1029
+ this.currentSessionId = void 0;
1030
+ this.accumulatedText = "";
1031
+ this.toolBuffer = null;
1032
+ this.lastUsage = void 0;
1033
+ this.lastStopReason = void 0;
1034
+ this.resultData = void 0;
1035
+ }
1036
+ };
1037
+ function isObject$3(value) {
1038
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1039
+ }
1040
+ function parseUsage(raw) {
1041
+ return {
1042
+ inputTokens: typeof raw.input_tokens === "number" ? raw.input_tokens : 0,
1043
+ outputTokens: typeof raw.output_tokens === "number" ? raw.output_tokens : 0,
1044
+ ...typeof raw.cache_read_input_tokens === "number" ? { cacheReadTokens: raw.cache_read_input_tokens } : {},
1045
+ ...typeof raw.cache_creation_input_tokens === "number" ? { cacheWriteTokens: raw.cache_creation_input_tokens } : {}
1046
+ };
1047
+ }
1048
+
1049
+ //#endregion
1050
+ //#region src/middleware/runtimes/codex.ts
1051
+ /**
1052
+ * Codex CLI runtime — invokes `codex exec --json`
1053
+ * and maps the streaming NDJSON output to {@link AgentEvent} instances.
1054
+ *
1055
+ * The Codex CLI uses a two-level event model:
1056
+ * - Top-level events: thread.started, turn.started, item.started, item.updated,
1057
+ * item.completed, turn.completed, turn.failed, error
1058
+ * - Item types: agent_message, command_execution, mcp_tool_call, file_change,
1059
+ * reasoning, web_search, error, todo_list
1060
+ */
1061
+ var CodexCliRuntime = class extends CLIRuntimeBase {
1062
+ constructor() {
1063
+ super("codex");
1064
+ this.mediaCapabilities = {
1065
+ acceptsInbound: ["image/"],
1066
+ emitsOutbound: false
1067
+ };
1068
+ this.accumulatedText = "";
1069
+ this.lastEmittedTextLength = 0;
1070
+ this.itemCounter = 0;
1071
+ }
1072
+ get supportsStdinPrompt() {
1073
+ return false;
1074
+ }
1075
+ async *execute(params) {
1076
+ this.resetState();
1077
+ const mcpConfigManager = params.mcpServers && Object.keys(params.mcpServers).length > 0 ? new CodexMcpConfigManager(params.mcpServers) : null;
1078
+ try {
1079
+ await mcpConfigManager?.setup();
1080
+ for await (const event of super.execute(params)) {
1081
+ if (event.type === "done") this.enrichDoneEvent(event);
1082
+ yield event;
1083
+ }
1084
+ } finally {
1085
+ await mcpConfigManager?.teardown();
1086
+ }
1087
+ }
1088
+ buildArgs(params) {
1089
+ if (params.sessionId) return [
1090
+ "exec",
1091
+ "resume",
1092
+ "--json",
1093
+ params.sessionId,
1094
+ params.prompt
1095
+ ];
1096
+ const args = [
1097
+ "exec",
1098
+ "--json",
1099
+ "--color",
1100
+ "never"
1101
+ ];
1102
+ if (params.media) {
1103
+ for (const attachment of params.media) if (attachment.mimeType.startsWith("image/") && attachment.filePath) args.push("--image", attachment.filePath);
1104
+ }
1105
+ args.push(params.prompt);
1106
+ return args;
1107
+ }
1108
+ extractEvent(line) {
1109
+ const parsed = JSON.parse(line);
1110
+ if (!isObject$2(parsed) || typeof parsed.type !== "string") return null;
1111
+ switch (parsed.type) {
1112
+ case "thread.started": return this.handleThreadStarted(parsed);
1113
+ case "item.started": return this.handleItemStarted(parsed);
1114
+ case "item.updated": return this.handleItemUpdated(parsed);
1115
+ case "item.completed": return this.handleItemCompleted(parsed);
1116
+ case "turn.completed": return this.handleTurnCompleted(parsed);
1117
+ case "turn.failed": return this.handleTurnFailed(parsed);
1118
+ case "error": return this.handleError(parsed);
1119
+ default: return null;
1120
+ }
1121
+ }
1122
+ buildEnv(_params) {
1123
+ return {};
1124
+ }
1125
+ handleThreadStarted(parsed) {
1126
+ if (typeof parsed.thread_id === "string") this.currentSessionId = parsed.thread_id;
1127
+ return null;
1128
+ }
1129
+ handleItemStarted(parsed) {
1130
+ const item = isObject$2(parsed.item) ? parsed.item : null;
1131
+ if (!item || typeof item.type !== "string") return null;
1132
+ const toolId = this.extractToolId(item);
1133
+ switch (item.type) {
1134
+ case "command_execution":
1135
+ this.currentToolId = toolId;
1136
+ return {
1137
+ type: "tool_use",
1138
+ toolName: "command_execution",
1139
+ toolId,
1140
+ input: { command: typeof item.command === "string" ? item.command : "" }
1141
+ };
1142
+ case "mcp_tool_call":
1143
+ this.currentToolId = toolId;
1144
+ return {
1145
+ type: "tool_use",
1146
+ toolName: typeof item.name === "string" ? item.name : "",
1147
+ toolId,
1148
+ input: isObject$2(item.arguments) ? item.arguments : {}
1149
+ };
1150
+ case "agent_message":
1151
+ this.lastEmittedTextLength = 0;
1152
+ return null;
1153
+ case "reasoning": return null;
1154
+ default: return null;
1155
+ }
1156
+ }
1157
+ handleItemUpdated(parsed) {
1158
+ const item = isObject$2(parsed.item) ? parsed.item : null;
1159
+ if (!item) return null;
1160
+ if (item.type === "reasoning") {
1161
+ const text = this.extractReasoningText(item);
1162
+ if (text) return {
1163
+ type: "thinking",
1164
+ text
1165
+ };
1166
+ return null;
1167
+ }
1168
+ if (item.type !== "agent_message") return null;
1169
+ const fullText = this.extractMessageText(item);
1170
+ if (fullText === void 0) return null;
1171
+ const delta = fullText.substring(this.lastEmittedTextLength);
1172
+ this.lastEmittedTextLength = fullText.length;
1173
+ if (delta) {
1174
+ this.accumulatedText += delta;
1175
+ return {
1176
+ type: "text",
1177
+ text: delta
1178
+ };
1179
+ }
1180
+ return null;
1181
+ }
1182
+ handleItemCompleted(parsed) {
1183
+ const item = isObject$2(parsed.item) ? parsed.item : null;
1184
+ if (!item || typeof item.type !== "string") return null;
1185
+ switch (item.type) {
1186
+ case "agent_message": {
1187
+ const fullText = this.extractMessageText(item);
1188
+ if (fullText !== void 0) {
1189
+ const delta = fullText.substring(this.lastEmittedTextLength);
1190
+ this.lastEmittedTextLength = fullText.length;
1191
+ if (delta) {
1192
+ this.accumulatedText += delta;
1193
+ return {
1194
+ type: "text",
1195
+ text: delta
1196
+ };
1197
+ }
1198
+ }
1199
+ return null;
1200
+ }
1201
+ case "reasoning": {
1202
+ const text = this.extractReasoningText(item);
1203
+ if (text) return {
1204
+ type: "thinking",
1205
+ text
1206
+ };
1207
+ return null;
1208
+ }
1209
+ case "command_execution": {
1210
+ const toolId = this.currentToolId ?? this.extractToolId(item);
1211
+ this.currentToolId = void 0;
1212
+ return {
1213
+ type: "tool_result",
1214
+ toolId,
1215
+ output: typeof item.output === "string" ? item.output : "",
1216
+ isError: (typeof item.exit_code === "number" ? item.exit_code : 0) !== 0
1217
+ };
1218
+ }
1219
+ case "mcp_tool_call": {
1220
+ const toolId = this.currentToolId ?? this.extractToolId(item);
1221
+ this.currentToolId = void 0;
1222
+ return {
1223
+ type: "tool_result",
1224
+ toolId,
1225
+ output: typeof item.output === "string" ? item.output : "",
1226
+ isError: typeof item.error === "string" && item.error.length > 0
1227
+ };
1228
+ }
1229
+ case "error": return {
1230
+ type: "error",
1231
+ message: typeof item.message === "string" ? item.message : "Unknown error"
1232
+ };
1233
+ default: return null;
1234
+ }
1235
+ }
1236
+ handleTurnCompleted(parsed) {
1237
+ if (isObject$2(parsed.usage)) {
1238
+ const usage = parsed.usage;
1239
+ this.lastUsage = {
1240
+ inputTokens: typeof usage.input_tokens === "number" ? usage.input_tokens : 0,
1241
+ outputTokens: typeof usage.output_tokens === "number" ? usage.output_tokens : 0,
1242
+ ...typeof usage.cached_input_tokens === "number" && usage.cached_input_tokens > 0 ? { cacheReadTokens: usage.cached_input_tokens } : {}
1243
+ };
1244
+ }
1245
+ return null;
1246
+ }
1247
+ handleTurnFailed(parsed) {
1248
+ return {
1249
+ type: "error",
1250
+ message: typeof parsed.message === "string" ? parsed.message : "Turn failed",
1251
+ code: "turn_failed"
1252
+ };
1253
+ }
1254
+ handleError(parsed) {
1255
+ return {
1256
+ type: "error",
1257
+ message: typeof parsed.message === "string" ? parsed.message : "Unknown error"
1258
+ };
1259
+ }
1260
+ enrichDoneEvent(event) {
1261
+ const { result } = event;
1262
+ result.text = this.accumulatedText;
1263
+ result.sessionId = this.currentSessionId;
1264
+ if (this.lastUsage) result.usage = this.lastUsage;
1265
+ }
1266
+ extractToolId(item) {
1267
+ if (typeof item.id === "string") return item.id;
1268
+ return `codex-item-${this.itemCounter++}`;
1269
+ }
1270
+ extractMessageText(item) {
1271
+ if (Array.isArray(item.content)) {
1272
+ const textParts = [];
1273
+ for (const part of item.content) if (isObject$2(part) && part.type === "output_text" && typeof part.text === "string") textParts.push(part.text);
1274
+ if (textParts.length > 0) return textParts.join("");
1275
+ }
1276
+ if (typeof item.text === "string") return item.text;
1277
+ }
1278
+ extractReasoningText(item) {
1279
+ if (Array.isArray(item.summary)) {
1280
+ const textParts = [];
1281
+ for (const part of item.summary) if (isObject$2(part) && part.type === "summary_text" && typeof part.text === "string") textParts.push(part.text);
1282
+ if (textParts.length > 0) return textParts.join("");
1283
+ }
1284
+ if (typeof item.text === "string") return item.text;
1285
+ }
1286
+ resetState() {
1287
+ this.currentSessionId = void 0;
1288
+ this.accumulatedText = "";
1289
+ this.lastEmittedTextLength = 0;
1290
+ this.lastUsage = void 0;
1291
+ this.currentToolId = void 0;
1292
+ this.itemCounter = 0;
1293
+ }
1294
+ };
1295
+ /**
1296
+ * Manages the `~/.codex/config.toml` lifecycle for MCP server configuration.
1297
+ *
1298
+ * The Codex CLI reads MCP config from `~/.codex/config.toml`. The config uses
1299
+ * TOML format with `[mcp_servers.<name>]` sections.
1300
+ *
1301
+ * Uses a merge-restore pattern:
1302
+ * - **Setup**: read existing config (if any), save a copy, append `mcp_servers`
1303
+ * sections, write back.
1304
+ * - **Teardown** (always, via `finally`): restore original or delete created file.
1305
+ */
1306
+ var CodexMcpConfigManager = class {
1307
+ constructor(mcpServers, configDir) {
1308
+ this.mcpServers = mcpServers;
1309
+ this.originalContent = null;
1310
+ this.createdFile = false;
1311
+ this.createdDir = false;
1312
+ this.configDir = configDir ?? join(homedir(), ".codex");
1313
+ this.configPath = join(this.configDir, "config.toml");
1314
+ }
1315
+ async setup() {
1316
+ try {
1317
+ await mkdir(this.configDir, { recursive: true });
1318
+ } catch {}
1319
+ let existingContent = null;
1320
+ try {
1321
+ const content = await readFile(this.configPath, "utf-8");
1322
+ this.originalContent = content;
1323
+ existingContent = content;
1324
+ } catch {
1325
+ this.createdFile = true;
1326
+ try {
1327
+ if ((await readdir(this.configDir)).length === 0) this.createdDir = true;
1328
+ } catch {}
1329
+ }
1330
+ const mcpToml = serializeMcpServersToToml(this.mcpServers);
1331
+ if (existingContent) {
1332
+ const stripped = stripMcpServersSections(existingContent);
1333
+ const separator = stripped.endsWith("\n") ? "\n" : "\n\n";
1334
+ await writeFile(this.configPath, stripped + separator + mcpToml, "utf-8");
1335
+ } else await writeFile(this.configPath, mcpToml, "utf-8");
1336
+ }
1337
+ async teardown() {
1338
+ try {
1339
+ if (this.originalContent !== null) await writeFile(this.configPath, this.originalContent, "utf-8");
1340
+ else if (this.createdFile) {
1341
+ await rm(this.configPath, { force: true });
1342
+ if (this.createdDir) try {
1343
+ await rmdir(this.configDir);
1344
+ } catch {}
1345
+ }
1346
+ } catch {}
1347
+ }
1348
+ };
1349
+ /**
1350
+ * Serialize MCP server configs to TOML format for Codex config.
1351
+ *
1352
+ * Output format:
1353
+ * ```toml
1354
+ * [mcp_servers.server_name]
1355
+ * type = "stdio"
1356
+ * command = "node"
1357
+ * args = ["server.js"]
1358
+ *
1359
+ * [mcp_servers.server_name.env]
1360
+ * KEY = "VALUE"
1361
+ * ```
1362
+ */
1363
+ function serializeMcpServersToToml(mcpServers) {
1364
+ const sections = [];
1365
+ for (const [name, config] of Object.entries(mcpServers)) {
1366
+ const lines = [];
1367
+ lines.push(`[mcp_servers.${name}]`);
1368
+ lines.push(`type = "stdio"`);
1369
+ lines.push(`command = ${toTomlString(config.command)}`);
1370
+ const args = config.args ?? [];
1371
+ if (args.length > 0) lines.push(`args = [${args.map((s) => toTomlString(s)).join(", ")}]`);
1372
+ sections.push(lines.join("\n"));
1373
+ if (config.env && Object.keys(config.env).length > 0) {
1374
+ const envLines = [];
1375
+ envLines.push(`[mcp_servers.${name}.env]`);
1376
+ for (const [key, value] of Object.entries(config.env)) envLines.push(`${key} = ${toTomlString(value)}`);
1377
+ sections.push(envLines.join("\n"));
1378
+ }
1379
+ }
1380
+ return sections.join("\n\n") + "\n";
1381
+ }
1382
+ /**
1383
+ * Strip existing `[mcp_servers.*]` sections from TOML content.
1384
+ * This is a simple line-based approach that removes lines belonging to
1385
+ * mcp_servers sections (from header to next non-mcp_servers section).
1386
+ */
1387
+ function stripMcpServersSections(content) {
1388
+ const lines = content.split("\n");
1389
+ const result = [];
1390
+ let inMcpSection = false;
1391
+ for (const line of lines) {
1392
+ const trimmed = line.trim();
1393
+ if (trimmed.startsWith("[")) {
1394
+ if (trimmed.startsWith("[mcp_servers.") || trimmed === "[mcp_servers]") {
1395
+ inMcpSection = true;
1396
+ continue;
1397
+ }
1398
+ inMcpSection = false;
1399
+ }
1400
+ if (!inMcpSection) result.push(line);
1401
+ }
1402
+ while (result.length > 0 && result[result.length - 1].trim() === "") result.pop();
1403
+ return result.join("\n") + "\n";
1404
+ }
1405
+ /** Escape a string for TOML (basic string with double quotes). */
1406
+ function toTomlString(value) {
1407
+ return `"${value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t")}"`;
1408
+ }
1409
+ function isObject$2(value) {
1410
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1411
+ }
1412
+
1413
+ //#endregion
1414
+ //#region src/middleware/runtimes/gemini.ts
1415
+ /**
1416
+ * Gemini CLI runtime — invokes `gemini --output-format stream-json`
1417
+ * and maps the streaming NDJSON output to {@link AgentEvent} instances.
1418
+ */
1419
+ var GeminiCliRuntime = class extends CLIRuntimeBase {
1420
+ constructor() {
1421
+ super("gemini");
1422
+ this.mediaCapabilities = {
1423
+ acceptsInbound: [
1424
+ "image/",
1425
+ "audio/",
1426
+ "video/",
1427
+ "application/pdf"
1428
+ ],
1429
+ emitsOutbound: false
1430
+ };
1431
+ this.accumulatedText = "";
1432
+ }
1433
+ get supportsStdinPrompt() {
1434
+ return false;
1435
+ }
1436
+ async *execute(params) {
1437
+ this.resetState();
1438
+ const mcpConfigManager = params.mcpServers && Object.keys(params.mcpServers).length > 0 ? new GeminiMcpConfigManager(params.workingDirectory, params.mcpServers) : null;
1439
+ try {
1440
+ await mcpConfigManager?.setup();
1441
+ const prepared = await this.prepareMedia(params);
1442
+ for await (const event of super.execute(prepared)) {
1443
+ if (event.type === "done") this.enrichDoneEvent(event);
1444
+ yield event;
1445
+ }
1446
+ } finally {
1447
+ await mcpConfigManager?.teardown();
1448
+ await this.cleanupMediaTempDir();
1449
+ }
1450
+ }
1451
+ buildArgs(params) {
1452
+ const args = [
1453
+ "--output-format",
1454
+ "stream-json",
1455
+ "--prompt",
1456
+ params.prompt
1457
+ ];
1458
+ if (params.sessionId) args.push("--resume", params.sessionId);
1459
+ return args;
1460
+ }
1461
+ extractEvent(line) {
1462
+ const parsed = JSON.parse(line);
1463
+ if (!isObject$1(parsed) || typeof parsed.type !== "string") return null;
1464
+ switch (parsed.type) {
1465
+ case "init": return this.handleInit(parsed);
1466
+ case "message": return this.handleMessage(parsed);
1467
+ case "tool_use": return this.handleToolUse(parsed);
1468
+ case "tool_result": return this.handleToolResult(parsed);
1469
+ case "error": return this.handleError(parsed);
1470
+ case "result": return this.handleResult(parsed);
1471
+ default: return null;
1472
+ }
1473
+ }
1474
+ buildEnv(_params) {
1475
+ return {};
1476
+ }
1477
+ handleInit(parsed) {
1478
+ if (typeof parsed.session_id === "string") this.currentSessionId = parsed.session_id;
1479
+ return null;
1480
+ }
1481
+ handleMessage(parsed) {
1482
+ if (parsed.delta !== true || parsed.role !== "assistant") return null;
1483
+ const content = typeof parsed.content === "string" ? parsed.content : void 0;
1484
+ if (content === void 0) return null;
1485
+ this.accumulatedText += content;
1486
+ return {
1487
+ type: "text",
1488
+ text: content
1489
+ };
1490
+ }
1491
+ handleToolUse(parsed) {
1492
+ return {
1493
+ type: "tool_use",
1494
+ toolName: typeof parsed.tool_name === "string" ? parsed.tool_name : "",
1495
+ toolId: typeof parsed.tool_id === "string" ? parsed.tool_id : "",
1496
+ input: isObject$1(parsed.parameters) ? parsed.parameters : {}
1497
+ };
1498
+ }
1499
+ handleToolResult(parsed) {
1500
+ return {
1501
+ type: "tool_result",
1502
+ toolId: typeof parsed.tool_id === "string" ? parsed.tool_id : "",
1503
+ output: typeof parsed.output === "string" ? parsed.output : "",
1504
+ isError: parsed.status === "error"
1505
+ };
1506
+ }
1507
+ handleError(parsed) {
1508
+ return {
1509
+ type: "error",
1510
+ message: typeof parsed.message === "string" ? parsed.message : "Unknown error",
1511
+ code: typeof parsed.severity === "string" ? parsed.severity : void 0
1512
+ };
1513
+ }
1514
+ handleResult(parsed) {
1515
+ if (isObject$1(parsed.stats)) this.resultStats = {
1516
+ inputTokens: typeof parsed.stats.input_tokens === "number" ? parsed.stats.input_tokens : void 0,
1517
+ outputTokens: typeof parsed.stats.output_tokens === "number" ? parsed.stats.output_tokens : void 0,
1518
+ cached: typeof parsed.stats.cached === "number" ? parsed.stats.cached : void 0,
1519
+ durationMs: typeof parsed.stats.duration_ms === "number" ? parsed.stats.duration_ms : void 0,
1520
+ toolCalls: typeof parsed.stats.tool_calls === "number" ? parsed.stats.tool_calls : void 0
1521
+ };
1522
+ return null;
1523
+ }
1524
+ enrichDoneEvent(event) {
1525
+ const { result } = event;
1526
+ result.text = this.accumulatedText;
1527
+ result.sessionId = this.currentSessionId;
1528
+ if (this.resultStats) {
1529
+ result.usage = {
1530
+ inputTokens: this.resultStats.inputTokens ?? 0,
1531
+ outputTokens: this.resultStats.outputTokens ?? 0,
1532
+ ...this.resultStats.cached != null && this.resultStats.cached > 0 ? { cacheReadTokens: this.resultStats.cached } : {}
1533
+ };
1534
+ if (this.resultStats.durationMs !== void 0) result.apiDurationMs = this.resultStats.durationMs;
1535
+ if (this.resultStats.toolCalls !== void 0) result.numTurns = this.resultStats.toolCalls;
1536
+ }
1537
+ }
1538
+ /**
1539
+ * Save media attachments to temp files and inject `@path` references into
1540
+ * the prompt. Gemini CLI resolves `@path` inline references natively.
1541
+ */
1542
+ async prepareMedia(params) {
1543
+ if (!params.media?.length) return params;
1544
+ const tempDir = join(tmpdir(), `remoteclaw-gemini-media-${randomUUID()}`);
1545
+ await mkdir(tempDir, { recursive: true });
1546
+ this.mediaTempDir = tempDir;
1547
+ const mediaRefs = [];
1548
+ for (const attachment of params.media) {
1549
+ const ext = extensionForMime(attachment.mimeType);
1550
+ const filePath = join(tempDir, `media-${mediaRefs.length}${ext}`);
1551
+ if (attachment.base64) {
1552
+ await writeFile(filePath, Buffer.from(attachment.base64, "base64"));
1553
+ mediaRefs.push(filePath);
1554
+ } else if (attachment.filePath) try {
1555
+ await writeFile(filePath, await readFile(attachment.filePath));
1556
+ mediaRefs.push(filePath);
1557
+ } catch {
1558
+ logDebug(`[gemini-runtime] failed to read media file: ${attachment.filePath}`);
1559
+ }
1560
+ }
1561
+ if (mediaRefs.length === 0) return params;
1562
+ const mediaPrefix = mediaRefs.map((ref) => `@${ref}`).join(" ");
1563
+ return {
1564
+ ...params,
1565
+ prompt: `${mediaPrefix} ${params.prompt}`
1566
+ };
1567
+ }
1568
+ async cleanupMediaTempDir() {
1569
+ if (this.mediaTempDir) {
1570
+ try {
1571
+ await rm(this.mediaTempDir, {
1572
+ recursive: true,
1573
+ force: true
1574
+ });
1575
+ } catch {}
1576
+ this.mediaTempDir = void 0;
1577
+ }
1578
+ }
1579
+ resetState() {
1580
+ this.currentSessionId = void 0;
1581
+ this.accumulatedText = "";
1582
+ this.resultStats = void 0;
1583
+ this.mediaTempDir = void 0;
1584
+ }
1585
+ };
1586
+ /**
1587
+ * Manages the `.gemini/settings.json` lifecycle for MCP server configuration.
1588
+ *
1589
+ * The Gemini CLI reads MCP config from a fixed settings file hierarchy — there
1590
+ * is no `--mcp-config`, `--settings-dir`, or `--config` CLI flag. Project-level
1591
+ * settings live in `.gemini/settings.json` within the working directory.
1592
+ *
1593
+ * A `GEMINI_CONFIG_DIR` env var was requested (google-gemini/gemini-cli#2815)
1594
+ * but redirected to XDG spec compliance (#1825), which hasn't shipped as of
1595
+ * v0.11.x. Until a flag or env var exists, we use a merge-restore pattern:
1596
+ *
1597
+ * - **Setup**: read existing `.gemini/settings.json` (if any), save a copy,
1598
+ * merge `mcpServers` into it, write back.
1599
+ * - **Teardown** (always, via `finally`): restore the original file, or remove
1600
+ * the file/directory we created.
1601
+ */
1602
+ var GeminiMcpConfigManager = class {
1603
+ constructor(workingDirectory, mcpServers) {
1604
+ this.mcpServers = mcpServers;
1605
+ this.originalContent = null;
1606
+ this.createdFile = false;
1607
+ this.createdDir = false;
1608
+ this.settingsDir = join(workingDirectory ?? process.cwd(), ".gemini");
1609
+ this.settingsPath = join(this.settingsDir, "settings.json");
1610
+ }
1611
+ async setup() {
1612
+ try {
1613
+ await mkdir(this.settingsDir, { recursive: true });
1614
+ } catch {}
1615
+ let existingSettings = null;
1616
+ try {
1617
+ const content = await readFile(this.settingsPath, "utf-8");
1618
+ this.originalContent = content;
1619
+ existingSettings = JSON.parse(content);
1620
+ } catch {
1621
+ this.createdFile = true;
1622
+ try {
1623
+ if ((await readdir(this.settingsDir)).length === 0) this.createdDir = true;
1624
+ } catch {}
1625
+ }
1626
+ const mergedSettings = existingSettings ?? {};
1627
+ mergedSettings.mcpServers = this.mcpServers;
1628
+ await writeFile(this.settingsPath, JSON.stringify(mergedSettings, null, 2), "utf-8");
1629
+ }
1630
+ async teardown() {
1631
+ try {
1632
+ if (this.originalContent !== null) await writeFile(this.settingsPath, this.originalContent, "utf-8");
1633
+ else if (this.createdFile) {
1634
+ await rm(this.settingsPath, { force: true });
1635
+ if (this.createdDir) try {
1636
+ await rmdir(this.settingsDir);
1637
+ } catch {}
1638
+ }
1639
+ } catch {}
1640
+ }
1641
+ };
1642
+ function isObject$1(value) {
1643
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1644
+ }
1645
+ /** Map common MIME types to file extensions for Gemini CLI `@path` references. */
1646
+ function extensionForMime(mimeType) {
1647
+ return {
1648
+ "image/jpeg": ".jpg",
1649
+ "image/png": ".png",
1650
+ "image/gif": ".gif",
1651
+ "image/webp": ".webp",
1652
+ "audio/ogg": ".ogg",
1653
+ "audio/mpeg": ".mp3",
1654
+ "audio/wav": ".wav",
1655
+ "audio/webm": ".weba",
1656
+ "video/mp4": ".mp4",
1657
+ "video/webm": ".webm",
1658
+ "video/quicktime": ".mov",
1659
+ "application/pdf": ".pdf"
1660
+ }[mimeType] ?? "";
1661
+ }
1662
+
1663
+ //#endregion
1664
+ //#region src/middleware/runtimes/opencode.ts
1665
+ /**
1666
+ * OpenCode CLI runtime — invokes `opencode run --format json`
1667
+ * and maps the streaming NDJSON output to {@link AgentEvent} instances.
1668
+ *
1669
+ * OpenCode uses a per-line envelope model where every NDJSON line has:
1670
+ * `{ type, timestamp, sessionID, ...data }`
1671
+ *
1672
+ * Key differences from other runtimes:
1673
+ * - Text events are complete parts (no delta tracking needed)
1674
+ * - Tool events combine use + result in a single line (buffered drain pattern)
1675
+ * - Usage/cost comes from `step_finish` events
1676
+ */
1677
+ var OpenCodeCliRuntime = class extends CLIRuntimeBase {
1678
+ constructor() {
1679
+ super("opencode");
1680
+ this.mediaCapabilities = {
1681
+ acceptsInbound: [],
1682
+ emitsOutbound: false
1683
+ };
1684
+ this.accumulatedText = "";
1685
+ this.pendingEvents = [];
1686
+ this.toolCounter = 0;
1687
+ }
1688
+ async *execute(params) {
1689
+ this.resetState();
1690
+ const mcpConfigManager = params.mcpServers && Object.keys(params.mcpServers).length > 0 ? new OpenCodeMcpConfigManager(params.workingDirectory, params.mcpServers) : null;
1691
+ try {
1692
+ await mcpConfigManager?.setup();
1693
+ for await (const event of super.execute(params)) {
1694
+ if (event.type === "done") this.enrichDoneEvent(event);
1695
+ yield event;
1696
+ while (this.pendingEvents.length > 0) yield this.pendingEvents.shift();
1697
+ }
1698
+ } finally {
1699
+ await mcpConfigManager?.teardown();
1700
+ }
1701
+ }
1702
+ buildArgs(params) {
1703
+ const args = [
1704
+ "run",
1705
+ "--format",
1706
+ "json"
1707
+ ];
1708
+ if (params.sessionId) args.push("--session", params.sessionId);
1709
+ args.push(params.prompt);
1710
+ return args;
1711
+ }
1712
+ extractEvent(line) {
1713
+ const parsed = JSON.parse(line);
1714
+ if (!isObject(parsed) || typeof parsed.type !== "string") return null;
1715
+ if (typeof parsed.sessionID === "string" && this.currentSessionId === void 0) this.currentSessionId = parsed.sessionID;
1716
+ const data = isObject(parsed.part) ? parsed.part : parsed;
1717
+ switch (parsed.type) {
1718
+ case "text": return this.handleText(data);
1719
+ case "tool_use": return this.handleToolUse(data);
1720
+ case "step_start": return null;
1721
+ case "step_finish": return this.handleStepFinish(data);
1722
+ case "reasoning": return this.handleReasoning(data);
1723
+ case "error": return this.handleError(data);
1724
+ default: return null;
1725
+ }
1726
+ }
1727
+ buildEnv(_params) {
1728
+ return {};
1729
+ }
1730
+ handleText(parsed) {
1731
+ const content = typeof parsed.text === "string" ? parsed.text : typeof parsed.content === "string" ? parsed.content : "";
1732
+ this.accumulatedText += content;
1733
+ return {
1734
+ type: "text",
1735
+ text: content
1736
+ };
1737
+ }
1738
+ handleToolUse(parsed) {
1739
+ const toolId = typeof parsed.callID === "string" ? parsed.callID : `opencode-tool-${this.toolCounter++}`;
1740
+ const state = isObject(parsed.state) ? parsed.state : void 0;
1741
+ this.pendingEvents.push({
1742
+ type: "tool_result",
1743
+ toolId,
1744
+ output: typeof state?.output === "string" ? state.output : "",
1745
+ isError: typeof state?.error === "string" && state.error.length > 0
1746
+ });
1747
+ return {
1748
+ type: "tool_use",
1749
+ toolName: typeof parsed.name === "string" ? parsed.name : "",
1750
+ toolId,
1751
+ input: isObject(parsed.input) ? parsed.input : {}
1752
+ };
1753
+ }
1754
+ handleStepFinish(parsed) {
1755
+ this.lastStepFinish = {
1756
+ tokens: isObject(parsed.tokens) ? parsed.tokens : void 0,
1757
+ cost: typeof parsed.cost === "number" ? parsed.cost : void 0,
1758
+ reason: typeof parsed.reason === "string" ? parsed.reason : void 0
1759
+ };
1760
+ return null;
1761
+ }
1762
+ handleError(parsed) {
1763
+ return {
1764
+ type: "error",
1765
+ message: typeof parsed.message === "string" ? parsed.message : "Unknown error"
1766
+ };
1767
+ }
1768
+ handleReasoning(parsed) {
1769
+ const content = typeof parsed.text === "string" ? parsed.text : typeof parsed.content === "string" ? parsed.content : "";
1770
+ if (!content) return null;
1771
+ return {
1772
+ type: "thinking",
1773
+ text: content
1774
+ };
1775
+ }
1776
+ enrichDoneEvent(event) {
1777
+ const { result } = event;
1778
+ result.text = this.accumulatedText;
1779
+ result.sessionId = this.currentSessionId;
1780
+ if (this.lastStepFinish) {
1781
+ const { tokens, cost, reason } = this.lastStepFinish;
1782
+ if (tokens) {
1783
+ const input = typeof tokens.input === "number" ? tokens.input : 0;
1784
+ const output = typeof tokens.output === "number" ? tokens.output : 0;
1785
+ const cache = isObject(tokens.cache) ? tokens.cache : void 0;
1786
+ const cacheRead = typeof cache?.read === "number" ? cache.read : 0;
1787
+ const cacheWrite = typeof cache?.write === "number" ? cache.write : 0;
1788
+ result.usage = {
1789
+ inputTokens: input,
1790
+ outputTokens: output,
1791
+ ...cacheRead > 0 ? { cacheReadTokens: cacheRead } : {},
1792
+ ...cacheWrite > 0 ? { cacheWriteTokens: cacheWrite } : {}
1793
+ };
1794
+ }
1795
+ if (cost !== void 0) result.totalCostUsd = cost;
1796
+ if (reason !== void 0) result.stopReason = reason;
1797
+ }
1798
+ }
1799
+ resetState() {
1800
+ this.currentSessionId = void 0;
1801
+ this.accumulatedText = "";
1802
+ this.lastStepFinish = void 0;
1803
+ this.pendingEvents = [];
1804
+ this.toolCounter = 0;
1805
+ }
1806
+ };
1807
+ /**
1808
+ * Manages the `.opencode/config.json` lifecycle for MCP server configuration.
1809
+ *
1810
+ * OpenCode reads MCP config from its project-level settings file. Uses a
1811
+ * merge-restore pattern (same as Gemini and Codex):
1812
+ *
1813
+ * - **Setup**: read existing `.opencode/config.json` (if any), save a copy,
1814
+ * merge `mcpServers` into it, write back.
1815
+ * - **Teardown** (always, via `finally`): restore the original file, or remove
1816
+ * the file/directory we created.
1817
+ */
1818
+ var OpenCodeMcpConfigManager = class {
1819
+ constructor(workingDirectory, mcpServers) {
1820
+ this.mcpServers = mcpServers;
1821
+ this.originalContent = null;
1822
+ this.createdFile = false;
1823
+ this.createdDir = false;
1824
+ this.configDir = join(workingDirectory ?? process.cwd(), ".opencode");
1825
+ this.configPath = join(this.configDir, "config.json");
1826
+ }
1827
+ async setup() {
1828
+ try {
1829
+ await mkdir(this.configDir, { recursive: true });
1830
+ } catch {}
1831
+ let existingConfig = null;
1832
+ try {
1833
+ const content = await readFile(this.configPath, "utf-8");
1834
+ this.originalContent = content;
1835
+ existingConfig = JSON.parse(content);
1836
+ } catch {
1837
+ this.createdFile = true;
1838
+ try {
1839
+ if ((await readdir(this.configDir)).length === 0) this.createdDir = true;
1840
+ } catch {}
1841
+ }
1842
+ const mergedConfig = existingConfig ?? {};
1843
+ mergedConfig.mcpServers = this.mcpServers;
1844
+ await writeFile(this.configPath, JSON.stringify(mergedConfig, null, 2), "utf-8");
1845
+ }
1846
+ async teardown() {
1847
+ try {
1848
+ if (this.originalContent !== null) await writeFile(this.configPath, this.originalContent, "utf-8");
1849
+ else if (this.createdFile) {
1850
+ await rm(this.configPath, { force: true });
1851
+ if (this.createdDir) try {
1852
+ await rmdir(this.configDir);
1853
+ } catch {}
1854
+ }
1855
+ } catch {}
1856
+ }
1857
+ };
1858
+ function isObject(value) {
1859
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1860
+ }
1861
+
1862
+ //#endregion
1863
+ //#region src/middleware/runtime-factory.ts
1864
+ const SUPPORTED_PROVIDERS = [
1865
+ "claude",
1866
+ "gemini",
1867
+ "codex",
1868
+ "opencode"
1869
+ ];
1870
+ const validatedCommands = /* @__PURE__ */ new Set();
1871
+ /**
1872
+ * Verify that a CLI binary exists on PATH.
1873
+ *
1874
+ * Results are cached per process lifetime so the `which` lookup runs at most
1875
+ * once per command.
1876
+ */
1877
+ function validateExecutable(command) {
1878
+ if (validatedCommands.has(command)) {
1879
+ logDebug(`[runtime-factory] executable already validated: ${command}`);
1880
+ return;
1881
+ }
1882
+ try {
1883
+ execFileSync("which", [command], { stdio: "ignore" });
1884
+ logDebug(`[runtime-factory] executable validated: ${command}`);
1885
+ validatedCommands.add(command);
1886
+ } catch {
1887
+ throw new Error(`Runtime '${command}' is configured but the '${command}' binary was not found on PATH. Install it or set agents.defaults.runtime to a different provider.`);
1888
+ }
1889
+ }
1890
+ /**
1891
+ * Resolve the CLI runtime provider from config.
1892
+ *
1893
+ * Reads `agents.defaults.runtime` (set during onboarding) and throws when
1894
+ * unset. This is the **CLI runtime** (which binary to spawn), NOT the
1895
+ * model-API provider (e.g. "anthropic").
1896
+ */
1897
+ function resolveCliRuntimeProvider(cfg) {
1898
+ const runtime = cfg?.agents?.defaults?.runtime;
1899
+ if (!runtime) throw new Error(`No runtime configured. Set agents.defaults.runtime to one of: ${SUPPORTED_PROVIDERS.join(", ")}`);
1900
+ return runtime;
1901
+ }
1902
+ /**
1903
+ * Resolve extra CLI runtime args from config.
1904
+ *
1905
+ * Reads `agents.defaults.runtimeArgs` — extra CLI flags appended to every
1906
+ * runtime invocation (e.g. `["--dangerously-skip-permissions"]`).
1907
+ */
1908
+ function resolveCliRuntimeArgs(cfg) {
1909
+ return cfg?.agents?.defaults?.runtimeArgs;
1910
+ }
1911
+ /**
1912
+ * Resolve extra CLI runtime env vars from config.
1913
+ *
1914
+ * Reads `agents.defaults.runtimeEnv` — environment variables injected into
1915
+ * every runtime invocation (e.g. `{ "ANTHROPIC_API_KEY": "sk-ant-..." }`).
1916
+ */
1917
+ function resolveCliRuntimeEnv(cfg) {
1918
+ return cfg?.agents?.defaults?.runtimeEnv;
1919
+ }
1920
+ function createCliRuntime(provider) {
1921
+ const normalized = provider.trim().toLowerCase();
1922
+ logDebug(`[runtime-factory] creating runtime: provider=${normalized}`);
1923
+ switch (normalized) {
1924
+ case "claude":
1925
+ validateExecutable(normalized);
1926
+ return new ClaudeCliRuntime();
1927
+ case "gemini":
1928
+ validateExecutable(normalized);
1929
+ return new GeminiCliRuntime();
1930
+ case "codex":
1931
+ validateExecutable(normalized);
1932
+ return new CodexCliRuntime();
1933
+ case "opencode":
1934
+ validateExecutable(normalized);
1935
+ return new OpenCodeCliRuntime();
1936
+ default: throw new Error(`Unknown runtime provider "${provider}". Supported providers: ${SUPPORTED_PROVIDERS.join(", ")}`);
1937
+ }
1938
+ }
1939
+
1940
+ //#endregion
1941
+ //#region src/middleware/system-prompt.ts
1942
+ const SAFETY_SECTION = [
1943
+ "## Safety",
1944
+ "You have no independent goals: do not pursue self-preservation, replication, resource acquisition, or power-seeking; avoid long-term plans beyond the user's request.",
1945
+ "Prioritize safety and human oversight over completion; if instructions conflict, pause and ask; comply with stop/pause/audit requests and never bypass safeguards.",
1946
+ "Do not manipulate or persuade anyone to expand access or disable safeguards. Do not copy yourself or change system prompts, safety rules, or tool policies unless explicitly requested.",
1947
+ "Never expose credentials, API keys, or secrets in replies or tool calls. Respect user privacy."
1948
+ ].join("\n");
1949
+ const MESSAGING_SECTION = [
1950
+ "## Messaging",
1951
+ "- Reply in current session: automatically routes to the source channel.",
1952
+ "- Cross-session messaging: use sessions_send(sessionKey, message) to reach other channels.",
1953
+ "- `[System Message] ...` blocks are internal context and are not user-visible.",
1954
+ `- If a \`[System Message]\` reports completed work and asks for a user update, rewrite it in your normal assistant voice and send that update (do not forward raw system text or default to ${SILENT_REPLY_TOKEN}).`,
1955
+ "- Never use exec/curl for provider messaging; RemoteClaw handles all routing internally."
1956
+ ].join("\n");
1957
+ const REPLY_TAGS_SECTION = [
1958
+ "## Reply Tags",
1959
+ "To request a native reply/quote on supported surfaces, include one tag in your reply:",
1960
+ "- Reply tags must be the very first token in the message (no leading text/newlines): [[reply_to_current]] your reply.",
1961
+ "- [[reply_to_current]] replies to the triggering message.",
1962
+ "- Prefer [[reply_to_current]]. Use [[reply_to:<id>]] only when an id was explicitly provided (e.g. by the user or a tool).",
1963
+ "Whitespace inside the tag is allowed (e.g. [[ reply_to_current ]] / [[ reply_to: 123 ]]).",
1964
+ "Tags are stripped before sending; support depends on the current channel config."
1965
+ ].join("\n");
1966
+ const SILENT_REPLIES_SECTION = [
1967
+ "## Silent Replies",
1968
+ `When you have nothing to say, respond with ONLY: ${SILENT_REPLY_TOKEN}`,
1969
+ "",
1970
+ "Rules:",
1971
+ "- It must be your ENTIRE message — nothing else.",
1972
+ `- Never append it to an actual response (never include "${SILENT_REPLY_TOKEN}" in real replies).`,
1973
+ "- Never wrap it in markdown or code blocks."
1974
+ ].join("\n");
1975
+ function buildIdentitySection(channelName, userName) {
1976
+ const intro = "You are running inside RemoteClaw, a middleware that connects AI agents to messaging channels.";
1977
+ return userName ? `${intro}\nYou are responding to a message from ${userName} on ${channelName}.` : `${intro}\nYou are responding to a message on ${channelName}.`;
1978
+ }
1979
+ function buildRuntimeSection(params) {
1980
+ const parts = [`channel=${params.channelName}`];
1981
+ if (params.timezone) parts.push(`timezone=${params.timezone}`);
1982
+ if (params.agentId) parts.push(`agent=${params.agentId}`);
1983
+ return `## Runtime\nRuntime: ${parts.join(" | ")}`;
1984
+ }
1985
+ function buildWorkspaceSection(workspaceDir) {
1986
+ return [
1987
+ "## Workspace",
1988
+ `Your working directory is: ${workspaceDir}`,
1989
+ "Treat this directory as the single global workspace for file operations unless explicitly instructed otherwise."
1990
+ ].join("\n");
1991
+ }
1992
+ function buildMessageToolHintsSection(hints) {
1993
+ if (!hints || hints.length === 0) return;
1994
+ return `## Message Formatting\n${hints.join("\n")}`;
1995
+ }
1996
+ function buildAuthorizedSendersSection(senders) {
1997
+ const filtered = senders?.filter(Boolean);
1998
+ if (!filtered || filtered.length === 0) return;
1999
+ return `## Authorized Senders\nAuthorized senders: ${filtered.join(", ")}. These senders are allowlisted; do not assume they are the owner.`;
2000
+ }
2001
+ function buildReactionsSection(guidance) {
2002
+ if (!guidance) return;
2003
+ const { level, channel } = guidance;
2004
+ if (level === "minimal") return [
2005
+ "## Reactions",
2006
+ `Reactions are enabled for ${channel} in MINIMAL mode.`,
2007
+ "React ONLY when truly relevant:",
2008
+ "- Acknowledge important user requests or confirmations",
2009
+ "- Express genuine sentiment (humor, appreciation) sparingly",
2010
+ "- Avoid reacting to routine messages or your own replies",
2011
+ "Guideline: at most 1 reaction per 5-10 exchanges."
2012
+ ].join("\n");
2013
+ return [
2014
+ "## Reactions",
2015
+ `Reactions are enabled for ${channel} in EXTENSIVE mode.`,
2016
+ "Feel free to react liberally:",
2017
+ "- Acknowledge messages with appropriate emojis",
2018
+ "- Express sentiment and personality through reactions",
2019
+ "- React to interesting content, humor, or notable events",
2020
+ "- Use reactions to confirm understanding or agreement",
2021
+ "Guideline: react whenever it feels natural."
2022
+ ].join("\n");
2023
+ }
2024
+ /**
2025
+ * Build the RemoteClaw system prompt for injection into CLI subprocess agents.
2026
+ *
2027
+ * Assembles ~10 sections totaling ~3,000-5,000 chars (~770-1,270 tokens).
2028
+ * No promptMode switch (always full), no bootstrap context (CLI agent handles),
2029
+ * no tool list (MCP handles), no skills/memory/sandbox sections.
2030
+ */
2031
+ function buildSystemPrompt(params) {
2032
+ const sections = [
2033
+ buildIdentitySection(params.channelName, params.userName),
2034
+ SAFETY_SECTION,
2035
+ MESSAGING_SECTION
2036
+ ];
2037
+ const hintsSection = buildMessageToolHintsSection(params.messageToolHints);
2038
+ if (hintsSection) sections.push(hintsSection);
2039
+ sections.push(REPLY_TAGS_SECTION);
2040
+ sections.push(SILENT_REPLIES_SECTION);
2041
+ const sendersSection = buildAuthorizedSendersSection(params.authorizedSenders);
2042
+ if (sendersSection) sections.push(sendersSection);
2043
+ const reactionsSection = buildReactionsSection(params.reactionGuidance);
2044
+ if (reactionsSection) sections.push(reactionsSection);
2045
+ sections.push(buildRuntimeSection(params));
2046
+ sections.push(buildWorkspaceSection(params.workspaceDir));
2047
+ return sections.join("\n\n");
2048
+ }
2049
+
2050
+ //#endregion
2051
+ //#region src/middleware/channel-bridge.ts
2052
+ const DEFAULT_WORKSPACE_DIR = ".";
2053
+ const DEFAULT_MCP_SERVER_PATH = join("dist", "middleware", "mcp-server.js");
2054
+ const EMPTY_SIDE_EFFECTS = {
2055
+ sentTexts: [],
2056
+ sentMediaUrls: [],
2057
+ sentTargets: [],
2058
+ cronAdds: 0
2059
+ };
2060
+ const DEFAULT_RUN_RESULT = {
2061
+ text: "",
2062
+ sessionId: void 0,
2063
+ durationMs: 0,
2064
+ usage: void 0,
2065
+ aborted: false
2066
+ };
2067
+ /**
2068
+ * Central orchestrator connecting incoming channel messages to CLI agent execution and delivery.
2069
+ *
2070
+ * `handle()` is the single entry point for all dispatch sites: agent command, auto-reply,
2071
+ * cron, and follow-up. It wires together runtime factory, session map, error classifier,
2072
+ * delivery adapter, system prompt builder, and MCP side effects.
2073
+ */
2074
+ var ChannelBridge = class {
2075
+ #provider;
2076
+ #sessionMap;
2077
+ #gatewayUrl;
2078
+ #gatewayToken;
2079
+ #workspaceDir;
2080
+ #chunkLimit;
2081
+ #mcpServerPath;
2082
+ #runtimeArgs;
2083
+ #runtimeEnv;
2084
+ constructor(options) {
2085
+ this.#provider = options.provider;
2086
+ this.#sessionMap = options.sessionMap;
2087
+ this.#gatewayUrl = options.gatewayUrl;
2088
+ this.#gatewayToken = options.gatewayToken;
2089
+ this.#workspaceDir = options.workspaceDir ?? DEFAULT_WORKSPACE_DIR;
2090
+ this.#chunkLimit = options.chunkLimit;
2091
+ this.#mcpServerPath = options.mcpServerPath ?? DEFAULT_MCP_SERVER_PATH;
2092
+ this.#runtimeArgs = options.runtimeArgs;
2093
+ this.#runtimeEnv = options.runtimeEnv;
2094
+ }
2095
+ /**
2096
+ * Process an incoming channel message through the full agent execution pipeline.
2097
+ *
2098
+ * Flow: session lookup → system prompt → MCP config → runtime execution →
2099
+ * event streaming → error classification → side effects → session update → result assembly.
2100
+ */
2101
+ async handle(message, callbacks, abortSignal) {
2102
+ const sessionKey = buildSessionKey(message);
2103
+ logDebug(`[channel-bridge] handle: channel=${message.provider} from=${message.from} channelId=${message.channelId} threadId=${message.replyToId ?? "none"} agentId=${message.agentId ?? "default"} media=${message.mediaUrls?.length ?? 0}`);
2104
+ const existingSessionId = await this.#sessionMap.get(sessionKey);
2105
+ logDebug(`[channel-bridge] session lookup: key=${formatSessionKeyString(sessionKey)} ${existingSessionId ? `hit=${existingSessionId}` : "miss"}`);
2106
+ const hookRunner = getGlobalHookRunner();
2107
+ if (existingSessionId && hookRunner?.hasHooks("session_resumed")) await hookRunner.runSessionResumed({
2108
+ sessionId: existingSessionId,
2109
+ runtimeName: this.#provider,
2110
+ channelId: message.channelId,
2111
+ userId: message.from,
2112
+ resumeMethod: "session_map"
2113
+ }, {
2114
+ sessionId: existingSessionId,
2115
+ channelId: message.channelId,
2116
+ runtimeName: this.#provider
2117
+ });
2118
+ const systemPrompt = buildSystemPrompt({
2119
+ channelName: message.provider,
2120
+ workspaceDir: this.#workspaceDir,
2121
+ messageToolHints: message.messageToolHints,
2122
+ userName: message.userName,
2123
+ agentId: message.agentId,
2124
+ timezone: message.timezone,
2125
+ authorizedSenders: message.authorizedSenders,
2126
+ reactionGuidance: message.reactionGuidance
2127
+ });
2128
+ const invocationDir = await createInvocationDir();
2129
+ const sideEffectsFile = join(invocationDir, "side-effects.ndjson");
2130
+ try {
2131
+ const mcpServers = this.#buildMcpConfig(message, sessionKey, sideEffectsFile);
2132
+ logDebug(`[channel-bridge] creating runtime: provider=${this.#provider}`);
2133
+ const runtime = createCliRuntime(this.#provider);
2134
+ let workspaceDir = this.#workspaceDir;
2135
+ let hookEnv;
2136
+ const runId = randomUUID();
2137
+ if (hookRunner?.hasHooks("before_runtime_spawn")) {
2138
+ const spawnResult = await hookRunner.runBeforeRuntimeSpawn({
2139
+ runtimeName: this.#provider,
2140
+ sessionId: existingSessionId,
2141
+ command: "node",
2142
+ args: [this.#mcpServerPath],
2143
+ env: mcpServers.remoteclaw?.env ?? {},
2144
+ workspaceDir,
2145
+ channelId: message.channelId
2146
+ }, {
2147
+ sessionId: existingSessionId,
2148
+ channelId: message.channelId,
2149
+ runtimeName: this.#provider
2150
+ });
2151
+ if (spawnResult?.workspaceDir) {
2152
+ logDebug(`[channel-bridge] hook overrode workspaceDir: ${this.#workspaceDir} -> ${spawnResult.workspaceDir}`);
2153
+ workspaceDir = spawnResult.workspaceDir;
2154
+ }
2155
+ if (spawnResult?.env) {
2156
+ logDebug(`[channel-bridge] hook injected env keys: ${Object.keys(spawnResult.env).join(", ")}`);
2157
+ hookEnv = spawnResult.env;
2158
+ }
2159
+ }
2160
+ const resolvedMedia = message.mediaUrls?.length ? await resolveMediaAttachments(message.mediaUrls, invocationDir) : void 0;
2161
+ if (resolvedMedia?.length) logDebug(`[channel-bridge] resolved ${resolvedMedia.length}/${message.mediaUrls.length} media attachments`);
2162
+ const { supported: supportedMedia, unsupported: unsupportedMedia } = resolvedMedia?.length ? partitionMedia(runtime, resolvedMedia) : {
2163
+ supported: [],
2164
+ unsupported: []
2165
+ };
2166
+ const mediaWarning = formatUnsupportedMediaWarning(unsupportedMedia, this.#provider);
2167
+ if (unsupportedMedia.length > 0) logDebug(`[channel-bridge] unsupported media: ${unsupportedMedia.length} attachment(s) not accepted by ${this.#provider}`);
2168
+ const adapter = new DeliveryAdapter(this.#chunkLimit !== void 0 ? { chunkLimit: this.#chunkLimit } : void 0);
2169
+ let runResult;
2170
+ let lastError;
2171
+ let payloads;
2172
+ try {
2173
+ const captured = captureResult(runtime.execute({
2174
+ prompt: systemPrompt + (message.extraContext ? "\n\n" + message.extraContext : "") + "\n\n" + message.text,
2175
+ media: supportedMedia?.length ? supportedMedia : void 0,
2176
+ sessionId: existingSessionId,
2177
+ mcpServers,
2178
+ abortSignal,
2179
+ workingDirectory: workspaceDir,
2180
+ env: this.#runtimeEnv || hookEnv ? {
2181
+ ...this.#runtimeEnv,
2182
+ ...hookEnv
2183
+ } : void 0,
2184
+ extraArgs: this.#runtimeArgs
2185
+ }));
2186
+ payloads = await adapter.process(captured.events, callbacks);
2187
+ runResult = captured.getResult();
2188
+ lastError = captured.getError();
2189
+ } catch (err) {
2190
+ const errMsg = String(err);
2191
+ const category = classifyError(errMsg);
2192
+ logDebug(`[channel-bridge] runtime threw: category=${category} error=${errMsg.slice(0, 500)}`);
2193
+ lastError = errMsg;
2194
+ payloads = [];
2195
+ runResult = {
2196
+ ...DEFAULT_RUN_RESULT,
2197
+ errorSubtype: category === "context_overflow" ? "context_window" : category
2198
+ };
2199
+ }
2200
+ if (mediaWarning) payloads.unshift({ text: mediaWarning });
2201
+ let mcp;
2202
+ try {
2203
+ mcp = await readMcpSideEffects(sideEffectsFile);
2204
+ } catch {
2205
+ mcp = { ...EMPTY_SIDE_EFFECTS };
2206
+ }
2207
+ logDebug(`[channel-bridge] side effects: sentTexts=${mcp.sentTexts.length} sentMedia=${mcp.sentMediaUrls.length} cronAdds=${mcp.cronAdds}`);
2208
+ if (runResult?.sessionId) {
2209
+ logDebug(`[channel-bridge] session update: key=${formatSessionKeyString(sessionKey)} sessionId=${runResult.sessionId}`);
2210
+ await this.#sessionMap.set(sessionKey, runResult.sessionId);
2211
+ }
2212
+ const finalResult = runResult ?? { ...DEFAULT_RUN_RESULT };
2213
+ if (hookRunner) {
2214
+ const runtimeCtx = {
2215
+ sessionId: finalResult.sessionId,
2216
+ channelId: message.channelId,
2217
+ runtimeName: this.#provider
2218
+ };
2219
+ if (hookRunner.hasHooks("after_runtime_exit")) hookRunner.runAfterRuntimeExit({
2220
+ runtimeName: this.#provider,
2221
+ sessionId: finalResult.sessionId,
2222
+ exitCode: finalResult.errorSubtype ? 1 : 0,
2223
+ durationMs: finalResult.durationMs,
2224
+ stdout: finalResult.text,
2225
+ stderr: lastError,
2226
+ mcpSideEffects: {
2227
+ sentTexts: mcp.sentTexts,
2228
+ sentMediaUrls: mcp.sentMediaUrls,
2229
+ cronAdds: mcp.cronAdds
2230
+ }
2231
+ }, runtimeCtx);
2232
+ if (hookRunner.hasHooks("agent_end")) hookRunner.runAgentEnd({
2233
+ runId,
2234
+ sessionId: finalResult.sessionId,
2235
+ success: !finalResult.errorSubtype && !lastError,
2236
+ durationMs: finalResult.durationMs
2237
+ }, runtimeCtx);
2238
+ }
2239
+ logDebug(`[channel-bridge] complete: runId=${runId} duration=${finalResult.durationMs}ms payloads=${payloads.length} error=${lastError ?? "none"}`);
2240
+ return {
2241
+ payloads,
2242
+ run: finalResult,
2243
+ mcp,
2244
+ error: lastError
2245
+ };
2246
+ } finally {
2247
+ await rm(invocationDir, {
2248
+ recursive: true,
2249
+ force: true
2250
+ }).catch(() => {});
2251
+ }
2252
+ }
2253
+ /** Build MCP server configuration for the remoteclaw MCP server. */
2254
+ #buildMcpConfig(message, sessionKey, sideEffectsFile) {
2255
+ return { remoteclaw: {
2256
+ command: "node",
2257
+ args: [this.#mcpServerPath],
2258
+ env: {
2259
+ REMOTECLAW_GATEWAY_URL: this.#gatewayUrl,
2260
+ REMOTECLAW_GATEWAY_TOKEN: this.#gatewayToken,
2261
+ REMOTECLAW_SESSION_KEY: formatSessionKeyString(sessionKey),
2262
+ REMOTECLAW_SIDE_EFFECTS_FILE: sideEffectsFile,
2263
+ REMOTECLAW_CHANNEL: message.provider,
2264
+ REMOTECLAW_ACCOUNT_ID: message.from,
2265
+ REMOTECLAW_TO: message.channelId,
2266
+ ...message.replyToId ? { REMOTECLAW_THREAD_ID: message.replyToId } : {},
2267
+ REMOTECLAW_SENDER_IS_OWNER: String(message.senderIsOwner ?? false),
2268
+ REMOTECLAW_TOOL_PROFILE: message.toolProfile ?? "full"
2269
+ }
2270
+ } };
2271
+ }
2272
+ };
2273
+ /** Build a SessionKey from a ChannelMessage. */
2274
+ function buildSessionKey(message) {
2275
+ return {
2276
+ channelId: message.channelId,
2277
+ userId: message.from,
2278
+ threadId: message.replyToId
2279
+ };
2280
+ }
2281
+ /** Format a SessionKey as a composite string (for env vars). */
2282
+ function formatSessionKeyString(key) {
2283
+ return `${key.channelId}:${key.userId}:${key.threadId ?? "_"}`;
2284
+ }
2285
+ /** Create a unique temp directory for an invocation. */
2286
+ async function createInvocationDir() {
2287
+ return mkdtemp(join(tmpdir(), "rc-"));
2288
+ }
2289
+ /**
2290
+ * Wrap an event stream to capture the AgentRunResult from the done event
2291
+ * and any error messages, while passing all events through to the consumer.
2292
+ */
2293
+ function captureResult(events) {
2294
+ let result;
2295
+ let error;
2296
+ async function* wrapped() {
2297
+ for await (const event of events) {
2298
+ if (event.type === "done") result = event.result;
2299
+ else if (event.type === "error") error = event.message;
2300
+ yield event;
2301
+ }
2302
+ }
2303
+ return {
2304
+ events: wrapped(),
2305
+ getResult: () => result,
2306
+ getError: () => error
2307
+ };
2308
+ }
2309
+
2310
+ //#endregion
2311
+ //#region src/agents/cli-session.ts
2312
+ function getCliSessionId(entry, provider) {
2313
+ if (!entry) return;
2314
+ const normalized = normalizeProviderId(provider);
2315
+ const fromMap = entry.cliSessionIds?.[normalized];
2316
+ if (fromMap?.trim()) return fromMap.trim();
2317
+ if (normalized === "claude-cli") {
2318
+ const legacy = entry.claudeCliSessionId?.trim();
2319
+ if (legacy) return legacy;
2320
+ }
2321
+ }
2322
+ function setCliSessionId(entry, provider, sessionId) {
2323
+ const normalized = normalizeProviderId(provider);
2324
+ const trimmed = sessionId.trim();
2325
+ if (!trimmed) return;
2326
+ entry.cliSessionIds = { ...entry.cliSessionIds ?? {} };
2327
+ entry.cliSessionIds[normalized] = trimmed;
2328
+ if (normalized === "claude-cli") entry.claudeCliSessionId = trimmed;
2329
+ }
2330
+
2331
+ //#endregion
2332
+ //#region src/infra/outbound/targets.ts
2333
+ function resolveSessionDeliveryTarget(params) {
2334
+ const context = deliveryContextFromSession(params.entry);
2335
+ const sessionLastChannel = context?.channel && isDeliverableMessageChannel(context.channel) ? context.channel : void 0;
2336
+ const hasTurnSourceChannel = params.turnSourceChannel != null;
2337
+ const lastChannel = hasTurnSourceChannel ? params.turnSourceChannel : sessionLastChannel;
2338
+ const lastTo = hasTurnSourceChannel ? params.turnSourceTo : context?.to;
2339
+ const lastAccountId = hasTurnSourceChannel ? params.turnSourceAccountId : context?.accountId;
2340
+ const lastThreadId = hasTurnSourceChannel ? params.turnSourceThreadId : context?.threadId;
2341
+ const rawRequested = params.requestedChannel ?? "last";
2342
+ const requested = rawRequested === "last" ? "last" : normalizeMessageChannel(rawRequested);
2343
+ const requestedChannel = requested === "last" ? "last" : requested && isDeliverableMessageChannel(requested) ? requested : void 0;
2344
+ const rawExplicitTo = typeof params.explicitTo === "string" && params.explicitTo.trim() ? params.explicitTo.trim() : void 0;
2345
+ let channel = requestedChannel === "last" ? lastChannel : requestedChannel;
2346
+ if (!channel && params.fallbackChannel && isDeliverableMessageChannel(params.fallbackChannel)) channel = params.fallbackChannel;
2347
+ const isTelegramContext = channel === "telegram" || !channel && lastChannel === "telegram";
2348
+ let explicitTo = rawExplicitTo;
2349
+ let parsedThreadId;
2350
+ if (isTelegramContext && rawExplicitTo && rawExplicitTo.includes(":topic:")) {
2351
+ const parsed = parseTelegramTarget(rawExplicitTo);
2352
+ explicitTo = parsed.chatId;
2353
+ parsedThreadId = parsed.messageThreadId;
2354
+ }
2355
+ const explicitThreadId = params.explicitThreadId != null && params.explicitThreadId !== "" ? params.explicitThreadId : parsedThreadId;
2356
+ let to = explicitTo;
2357
+ if (!to && lastTo) {
2358
+ if (channel && channel === lastChannel) to = lastTo;
2359
+ else if (params.allowMismatchedLastTo) to = lastTo;
2360
+ }
2361
+ const mode = params.mode ?? (explicitTo ? "explicit" : "implicit");
2362
+ const accountId = channel && channel === lastChannel ? lastAccountId : void 0;
2363
+ const resolvedThreadId = explicitThreadId ?? (mode !== "heartbeat" && channel && channel === lastChannel ? lastThreadId : void 0);
2364
+ return {
2365
+ channel,
2366
+ to,
2367
+ accountId,
2368
+ threadId: resolvedThreadId,
2369
+ threadIdExplicit: resolvedThreadId != null && explicitThreadId != null,
2370
+ mode,
2371
+ lastChannel,
2372
+ lastTo,
2373
+ lastAccountId,
2374
+ lastThreadId
2375
+ };
2376
+ }
2377
+ function resolveOutboundTarget(params) {
2378
+ if (params.channel === INTERNAL_MESSAGE_CHANNEL) return {
2379
+ ok: false,
2380
+ error: /* @__PURE__ */ new Error(`Delivering to WebChat is not supported via \`${formatCliCommand("remoteclaw agent")}\`; use WhatsApp/Telegram or run with --deliver=false.`)
2381
+ };
2382
+ const plugin = getChannelPlugin(params.channel);
2383
+ if (!plugin) return {
2384
+ ok: false,
2385
+ error: /* @__PURE__ */ new Error(`Unsupported channel: ${params.channel}`)
2386
+ };
2387
+ const allowFrom = (params.allowFrom ?? (params.cfg && plugin.config.resolveAllowFrom ? plugin.config.resolveAllowFrom({
2388
+ cfg: params.cfg,
2389
+ accountId: params.accountId ?? void 0
2390
+ }) : void 0))?.map((entry) => String(entry));
2391
+ const effectiveTo = params.to?.trim() || (params.cfg && plugin.config.resolveDefaultTo ? plugin.config.resolveDefaultTo({
2392
+ cfg: params.cfg,
2393
+ accountId: params.accountId ?? void 0
2394
+ }) : void 0);
2395
+ const resolveTarget = plugin.outbound?.resolveTarget;
2396
+ if (resolveTarget) return resolveTarget({
2397
+ cfg: params.cfg,
2398
+ to: effectiveTo,
2399
+ allowFrom,
2400
+ accountId: params.accountId ?? void 0,
2401
+ mode: params.mode ?? "explicit"
2402
+ });
2403
+ if (effectiveTo) return {
2404
+ ok: true,
2405
+ to: effectiveTo
2406
+ };
2407
+ const hint = plugin.messaging?.targetResolver?.hint;
2408
+ return {
2409
+ ok: false,
2410
+ error: missingTargetError(plugin.meta.label ?? params.channel, hint)
2411
+ };
2412
+ }
2413
+ function resolveHeartbeatDeliveryTarget(params) {
2414
+ const { cfg, entry } = params;
2415
+ const heartbeat = params.heartbeat ?? cfg.agents?.defaults?.heartbeat;
2416
+ const rawTarget = heartbeat?.target;
2417
+ let target = "none";
2418
+ if (rawTarget === "none" || rawTarget === "last") target = rawTarget;
2419
+ else if (typeof rawTarget === "string") {
2420
+ const normalized = normalizeChannelId(rawTarget);
2421
+ if (normalized) target = normalized;
2422
+ }
2423
+ if (target === "none") {
2424
+ const base = resolveSessionDeliveryTarget({ entry });
2425
+ return buildNoHeartbeatDeliveryTarget({
2426
+ reason: "target-none",
2427
+ lastChannel: base.lastChannel,
2428
+ lastAccountId: base.lastAccountId
2429
+ });
2430
+ }
2431
+ const resolvedTarget = resolveSessionDeliveryTarget({
2432
+ entry,
2433
+ requestedChannel: target === "last" ? "last" : target,
2434
+ explicitTo: heartbeat?.to,
2435
+ mode: "heartbeat"
2436
+ });
2437
+ const heartbeatAccountId = heartbeat?.accountId?.trim();
2438
+ let effectiveAccountId = heartbeatAccountId || resolvedTarget.accountId;
2439
+ if (heartbeatAccountId && resolvedTarget.channel) {
2440
+ const listAccountIds = getChannelPlugin(resolvedTarget.channel)?.config.listAccountIds;
2441
+ const accountIds = listAccountIds ? listAccountIds(cfg) : [];
2442
+ if (accountIds.length > 0) {
2443
+ const normalizedAccountId = normalizeAccountId(heartbeatAccountId);
2444
+ if (!new Set(accountIds.map((accountId) => normalizeAccountId(accountId))).has(normalizedAccountId)) return buildNoHeartbeatDeliveryTarget({
2445
+ reason: "unknown-account",
2446
+ accountId: normalizedAccountId,
2447
+ lastChannel: resolvedTarget.lastChannel,
2448
+ lastAccountId: resolvedTarget.lastAccountId
2449
+ });
2450
+ effectiveAccountId = normalizedAccountId;
2451
+ }
2452
+ }
2453
+ if (!resolvedTarget.channel || !resolvedTarget.to) return buildNoHeartbeatDeliveryTarget({
2454
+ reason: "no-target",
2455
+ accountId: effectiveAccountId,
2456
+ lastChannel: resolvedTarget.lastChannel,
2457
+ lastAccountId: resolvedTarget.lastAccountId
2458
+ });
2459
+ const resolved = resolveOutboundTarget({
2460
+ channel: resolvedTarget.channel,
2461
+ to: resolvedTarget.to,
2462
+ cfg,
2463
+ accountId: effectiveAccountId,
2464
+ mode: "heartbeat"
2465
+ });
2466
+ if (!resolved.ok) return buildNoHeartbeatDeliveryTarget({
2467
+ reason: "no-target",
2468
+ accountId: effectiveAccountId,
2469
+ lastChannel: resolvedTarget.lastChannel,
2470
+ lastAccountId: resolvedTarget.lastAccountId
2471
+ });
2472
+ const sessionChatTypeHint = target === "last" && !heartbeat?.to ? normalizeChatType(entry?.chatType) : void 0;
2473
+ if (resolveHeartbeatDeliveryChatType({
2474
+ channel: resolvedTarget.channel,
2475
+ to: resolved.to,
2476
+ sessionChatType: sessionChatTypeHint
2477
+ }) === "direct") return buildNoHeartbeatDeliveryTarget({
2478
+ reason: "dm-blocked",
2479
+ accountId: effectiveAccountId,
2480
+ lastChannel: resolvedTarget.lastChannel,
2481
+ lastAccountId: resolvedTarget.lastAccountId
2482
+ });
2483
+ let reason;
2484
+ if (getChannelPlugin(resolvedTarget.channel)?.config.resolveAllowFrom) {
2485
+ const explicit = resolveOutboundTarget({
2486
+ channel: resolvedTarget.channel,
2487
+ to: resolvedTarget.to,
2488
+ cfg,
2489
+ accountId: effectiveAccountId,
2490
+ mode: "explicit"
2491
+ });
2492
+ if (explicit.ok && explicit.to !== resolved.to) reason = "allowFrom-fallback";
2493
+ }
2494
+ return {
2495
+ channel: resolvedTarget.channel,
2496
+ to: resolved.to,
2497
+ reason,
2498
+ accountId: effectiveAccountId,
2499
+ threadId: resolvedTarget.threadId,
2500
+ lastChannel: resolvedTarget.lastChannel,
2501
+ lastAccountId: resolvedTarget.lastAccountId
2502
+ };
2503
+ }
2504
+ function buildNoHeartbeatDeliveryTarget(params) {
2505
+ return {
2506
+ channel: "none",
2507
+ reason: params.reason,
2508
+ accountId: params.accountId,
2509
+ lastChannel: params.lastChannel,
2510
+ lastAccountId: params.lastAccountId
2511
+ };
2512
+ }
2513
+ function inferDiscordTargetChatType(to) {
2514
+ try {
2515
+ const target = parseDiscordTarget(to, { defaultKind: "channel" });
2516
+ if (!target) return;
2517
+ return target.kind === "user" ? "direct" : "channel";
2518
+ } catch {
2519
+ return;
2520
+ }
2521
+ }
2522
+ function inferSlackTargetChatType(to) {
2523
+ const target = parseSlackTarget(to, { defaultKind: "channel" });
2524
+ if (!target) return;
2525
+ return target.kind === "user" ? "direct" : "channel";
2526
+ }
2527
+ function inferTelegramTargetChatType(to) {
2528
+ const chatType = resolveTelegramTargetChatType(to);
2529
+ return chatType === "unknown" ? void 0 : chatType;
2530
+ }
2531
+ function inferWhatsAppTargetChatType(to) {
2532
+ const normalized = normalizeWhatsAppTarget(to);
2533
+ if (!normalized) return;
2534
+ return isWhatsAppGroupJid(normalized) ? "group" : "direct";
2535
+ }
2536
+ function inferSignalTargetChatType(rawTo) {
2537
+ let to = rawTo.trim();
2538
+ if (!to) return;
2539
+ if (/^signal:/i.test(to)) to = to.replace(/^signal:/i, "").trim();
2540
+ if (!to) return;
2541
+ const lower = to.toLowerCase();
2542
+ if (lower.startsWith("group:")) return "group";
2543
+ if (lower.startsWith("username:") || lower.startsWith("u:")) return "direct";
2544
+ return "direct";
2545
+ }
2546
+ const HEARTBEAT_TARGET_CHAT_TYPE_INFERERS = {
2547
+ discord: inferDiscordTargetChatType,
2548
+ slack: inferSlackTargetChatType,
2549
+ telegram: inferTelegramTargetChatType,
2550
+ whatsapp: inferWhatsAppTargetChatType,
2551
+ signal: inferSignalTargetChatType
2552
+ };
2553
+ function inferChatTypeFromTarget(params) {
2554
+ const to = params.to.trim();
2555
+ if (!to) return;
2556
+ if (/^user:/i.test(to)) return "direct";
2557
+ if (/^(channel:|thread:)/i.test(to)) return "channel";
2558
+ if (/^group:/i.test(to)) return "group";
2559
+ return HEARTBEAT_TARGET_CHAT_TYPE_INFERERS[params.channel]?.(to);
2560
+ }
2561
+ function resolveHeartbeatDeliveryChatType(params) {
2562
+ if (params.sessionChatType) return params.sessionChatType;
2563
+ return inferChatTypeFromTarget({
2564
+ channel: params.channel,
2565
+ to: params.to
2566
+ });
2567
+ }
2568
+ function resolveHeartbeatSenderId(params) {
2569
+ const { allowFrom, deliveryTo, lastTo, provider } = params;
2570
+ const candidates = [
2571
+ deliveryTo?.trim(),
2572
+ provider && deliveryTo ? `${provider}:${deliveryTo}` : void 0,
2573
+ lastTo?.trim(),
2574
+ provider && lastTo ? `${provider}:${lastTo}` : void 0
2575
+ ].filter((val) => Boolean(val?.trim()));
2576
+ const allowList = allowFrom.map((entry) => String(entry)).filter((entry) => entry && entry !== "*");
2577
+ if (allowFrom.includes("*")) return candidates[0] ?? "heartbeat";
2578
+ if (candidates.length > 0 && allowList.length > 0) {
2579
+ const matched = candidates.find((candidate) => allowList.includes(candidate));
2580
+ if (matched) return matched;
2581
+ }
2582
+ if (candidates.length > 0 && allowList.length === 0) return candidates[0];
2583
+ if (allowList.length > 0) return allowList[0];
2584
+ return candidates[0] ?? "heartbeat";
2585
+ }
2586
+ function resolveHeartbeatSenderContext(params) {
2587
+ const provider = params.delivery.channel !== "none" ? params.delivery.channel : params.delivery.lastChannel;
2588
+ const accountId = params.delivery.accountId ?? (provider === params.delivery.lastChannel ? params.delivery.lastAccountId : void 0);
2589
+ const allowFrom = (provider ? getChannelPlugin(provider)?.config.resolveAllowFrom?.({
2590
+ cfg: params.cfg,
2591
+ accountId
2592
+ }) ?? [] : []).map((entry) => String(entry));
2593
+ return {
2594
+ sender: resolveHeartbeatSenderId({
2595
+ allowFrom,
2596
+ deliveryTo: params.delivery.to,
2597
+ lastTo: params.entry?.lastTo,
2598
+ provider
2599
+ }),
2600
+ provider,
2601
+ allowFrom
2602
+ };
2603
+ }
2604
+
2605
+ //#endregion
2606
+ export { resolveSendPolicy as S, peekSystemEventEntries as _, getCliSessionId as a, parseVerboseOverride as b, resolveCliRuntimeArgs as c, isAuthRotatableError as d, listChannelSupportedActions as f, isSystemEventContextChanged as g, enqueueSystemEvent as h, resolveSessionDeliveryTarget as i, resolveCliRuntimeEnv as l, drainSystemEventEntries as m, resolveHeartbeatSenderContext as n, setCliSessionId as o, resolveChannelMessageToolHints as p, resolveOutboundTarget as r, ChannelBridge as s, resolveHeartbeatDeliveryTarget as t, resolveCliRuntimeProvider as u, peekSystemEvents as v, normalizeSendPolicy as x, applyVerboseOverride as y };