remoteclaw 0.1.0-next.87fb2cd → 0.1.0-next.9f7caba

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 (849) hide show
  1. package/dist/accounts-B5BNJ_lk.js +36 -0
  2. package/dist/accounts-BnkzjNsj.js +32 -0
  3. package/dist/accounts-DOwpPNpJ.js +47 -0
  4. package/dist/accounts-Y6fBCsx_.js +272 -0
  5. package/dist/ack-reactions-DndoGKeN.js +446 -0
  6. package/dist/ack-reactions-XQPdJAzb.js +446 -0
  7. package/dist/acp-cli-C2sAKfGR.js +1326 -0
  8. package/dist/acp-cli-DSmofBAf.js +1320 -0
  9. package/dist/active-listener-D4pocaWh.js +37 -0
  10. package/dist/agent-BA1XT2jG.js +728 -0
  11. package/dist/agent-CyVs7WvP.js +727 -0
  12. package/dist/agent-helpers-DlqwUqOd.js +606 -0
  13. package/dist/agent-scope-BDF8U7HM.js +99 -0
  14. package/dist/agent-scope-Dzc3Pxwr.js +101 -0
  15. package/dist/agents-GDnr7rw4.js +788 -0
  16. package/dist/agents.config-Ba4A6sdg.js +116 -0
  17. package/dist/agents.config-CeN3byLA.js +116 -0
  18. package/dist/audio-preflight-BFPZB_BA.js +69 -0
  19. package/dist/audio-preflight-CowiaUIn.js +64 -0
  20. package/dist/audit-BHUOvUJw.js +3149 -0
  21. package/dist/audit-oXRhFtwT.js +3149 -0
  22. package/dist/auth-0nvm_vu0.js +448 -0
  23. package/dist/auth-DCGEkWB5.js +448 -0
  24. package/dist/auth-profiles-DJsaxEsz.js +281 -0
  25. package/dist/banner--jCLPIfU.js +294 -0
  26. package/dist/binaries-DEBQrQj9.js +13 -0
  27. package/dist/bindings-C6J0GYWO.js +69 -0
  28. package/dist/bindings-D0yqi_XP.js +69 -0
  29. package/dist/bonjour-discovery-JS2eV51P.js +378 -0
  30. package/dist/bonjour-discovery-hfRH88nW.js +378 -0
  31. package/dist/boot/handler.js +30 -33
  32. package/dist/browser-cli-BABicrdh.js +1692 -0
  33. package/dist/browser-cli-Qa_1PYDv.js +1687 -0
  34. package/dist/build-info.json +3 -3
  35. package/dist/call-fGA-3SDL.js +2828 -0
  36. package/dist/call-jLXWNKPQ.js +2829 -0
  37. package/dist/canvas-host/a2ui/.bundle.hash +1 -1
  38. package/dist/catalog-BzeCPOus.js +185 -0
  39. package/dist/catalog-oYxNmkeA.js +185 -0
  40. package/dist/channel-account-context-BVnz5r1H.js +550 -0
  41. package/dist/channel-account-context-BcPTaTZb.js +550 -0
  42. package/dist/channel-activity-BuZbH6WD.js +94 -0
  43. package/dist/channel-activity-CDdk0baN.js +94 -0
  44. package/dist/channel-activity-hL4KZrCz.js +292 -0
  45. package/dist/channel-options-XhTwtBf5.js +33 -0
  46. package/dist/channel-options-ctxY53Lc.js +32 -0
  47. package/dist/channel-selection-CMK4YLlO.js +51 -0
  48. package/dist/channel-selection-_eCHA2U9.js +51 -0
  49. package/dist/channel-web-BZpC6hhV.js +2134 -0
  50. package/dist/channel-web-CQ6_87Mm.js +2136 -0
  51. package/dist/channels-cli-BNl9vUWn.js +1421 -0
  52. package/dist/channels-cli-DZR57uHI.js +1426 -0
  53. package/dist/channels-status-issues-CVIgTe2p.js +18 -0
  54. package/dist/channels-status-issues-DcC43ljl.js +18 -0
  55. package/dist/chat-envelope-CRqgofiw.js +248 -0
  56. package/dist/chrome-8vydo3dJ.js +1733 -0
  57. package/dist/chrome-B_rPhRU5.js +1732 -0
  58. package/dist/chunk-Cx-gs159.js +341 -0
  59. package/dist/clack-prompter-BzCKGyUs.js +121 -0
  60. package/dist/clack-prompter-D7MCzOPT.js +122 -0
  61. package/dist/cli/daemon-cli.js +1 -1
  62. package/dist/cli-CpAjRQ-P.js +125 -0
  63. package/dist/cli-DUXK9wJZ.js +130 -0
  64. package/dist/clipboard-DIewy_WG.js +31 -0
  65. package/dist/command-logger/handler.js +1 -1
  66. package/dist/command-registry-DJNQEtnc.js +215 -0
  67. package/dist/commands-CX-o6Gzn.js +41 -0
  68. package/dist/commands-ChY7s9hy.js +41 -0
  69. package/dist/commands-registry-C-NFTH7P.js +891 -0
  70. package/dist/commands-registry-C_sd8Lmg.js +892 -0
  71. package/dist/common-Gc07uSGw.js +156 -0
  72. package/dist/completion-cli-DhuIE5Go.js +452 -0
  73. package/dist/completion-cli-DpaiSYzH.js +452 -0
  74. package/dist/config-BzYPJgWg.js +6919 -0
  75. package/dist/config-CxSZl93L.js +6917 -0
  76. package/dist/config-cli-CWeRxEJK.js +241 -0
  77. package/dist/config-cli-CYQ2SdRU.js +246 -0
  78. package/dist/config-guard-CYJDizl5.js +97 -0
  79. package/dist/config-guard-D1Q3ZQbe.js +75 -0
  80. package/dist/config-validation-BQqpcnJj.js +18 -0
  81. package/dist/config-validation-DFt9nI1w.js +18 -0
  82. package/dist/configure-BQw2dIdc.js +891 -0
  83. package/dist/configure-CXTvRKTB.js +889 -0
  84. package/dist/constants-CMq8PtHp.js +70 -0
  85. package/dist/constants-tLOgmZZ1.js +70 -0
  86. package/dist/control-auth-DWYlgWkO.js +397 -0
  87. package/dist/control-auth-pDCKtSlm.js +397 -0
  88. package/dist/control-ui/assets/index-D8iWlx90.js +7738 -0
  89. package/dist/control-ui/assets/index-D8iWlx90.js.map +1 -0
  90. package/dist/control-ui/assets/index-D_fjkN3g.css +1 -0
  91. package/dist/control-ui/index.html +2 -2
  92. package/dist/control-ui-assets-BQiFibyu.js +186 -0
  93. package/dist/control-ui-assets-DvQAtkDy.js +186 -0
  94. package/dist/cron-cli-B06geKKo.js +490 -0
  95. package/dist/cron-cli-Ct2y3uRB.js +495 -0
  96. package/dist/daemon-cli-Bt5Kcq3U.js +1197 -0
  97. package/dist/daemon-cli-Cd0bKq3g.js +1199 -0
  98. package/dist/daemon-cli.js +29 -69
  99. package/dist/daemon-install-C3Q8Jcx3.js +55 -0
  100. package/dist/daemon-install-helpers-B7UgD_mo.js +462 -0
  101. package/dist/daemon-install-helpers-Crqe5m8B.js +462 -0
  102. package/dist/daemon-install-oa7I86B_.js +60 -0
  103. package/dist/deliver-04fDIQb1.js +481 -0
  104. package/dist/deliver-D4QqtgMj.js +481 -0
  105. package/dist/delivery-queue-BM3aWQIK.js +244 -0
  106. package/dist/devices-cli-B7jdFjR6.js +316 -0
  107. package/dist/devices-cli-D-YMJZn1.js +321 -0
  108. package/dist/diagnostics-lMmEIZdJ.js +46 -0
  109. package/dist/diagnostics-rgiIJEXZ.js +46 -0
  110. package/dist/directory-cli-DWHQF2VD.js +222 -0
  111. package/dist/directory-cli-D_pT4Je0.js +217 -0
  112. package/dist/dm-policy-shared-BHRB2wzi.js +22 -0
  113. package/dist/dm-policy-shared-BTzThzqQ.js +22 -0
  114. package/dist/dns-cli-BbdtaLDe.js +202 -0
  115. package/dist/dns-cli-DghCMHgj.js +197 -0
  116. package/dist/dock-BtLbLczG.js +928 -0
  117. package/dist/dock-_qq4sBie.js +929 -0
  118. package/dist/doctor-completion-Cs6sL_IA.js +92 -0
  119. package/dist/doctor-completion-Cx2tN3vQ.js +92 -0
  120. package/dist/doctor-config-flow-CilyEptw.js +1934 -0
  121. package/dist/doctor-config-flow-PRWWIepI.js +1933 -0
  122. package/dist/enable-BEScoJBZ.js +59 -0
  123. package/dist/enable-Dt27_ZMm.js +59 -0
  124. package/dist/entry.js +1 -3
  125. package/dist/env-DUb5GiQe.js +60 -0
  126. package/dist/exec-D6PvFXKb.js +164 -0
  127. package/dist/export-html/template.css +0 -36
  128. package/dist/export-html/template.js +0 -26
  129. package/dist/extensionAPI.js +78 -77
  130. package/dist/fetch-Duxh68Ws.js +67 -0
  131. package/dist/fs-safe-S3Zvbabd.js +98 -0
  132. package/dist/gateway-cli-Mo6X1-yC.js +23756 -0
  133. package/dist/gateway-cli-P6QI1rgs.js +23761 -0
  134. package/dist/gateway-rpc-AYvHI3Um.js +28 -0
  135. package/dist/gateway-rpc-Bsz_VM32.js +28 -0
  136. package/dist/gmail-setup-utils-D_g2PQOA.js +423 -0
  137. package/dist/gmail-setup-utils-ni_zkMpC.js +422 -0
  138. package/dist/health-C903Uthy.js +1423 -0
  139. package/dist/health-vO9pggEr.js +1420 -0
  140. package/dist/heartbeat-visibility-BHb-m9Fu.js +125 -0
  141. package/dist/heartbeat-visibility-DgRcKpeV.js +125 -0
  142. package/dist/helpers-DkUEDuKD.js +10 -0
  143. package/dist/hook-runner-global-CyIDoO1Z.js +527 -0
  144. package/dist/hooks-cli-B5oVqP3O.js +1222 -0
  145. package/dist/hooks-cli-xRelj3fq.js +1217 -0
  146. package/dist/image-ops-XoE9nn-z.js +354 -0
  147. package/dist/import-buqTDG9j.js +250 -0
  148. package/dist/import-j_5xbT7b.js +248 -0
  149. package/dist/inbound-path-policy-gHabNHWN.js +250 -0
  150. package/dist/index.js +93 -93
  151. package/dist/inspect-CV7o4EFm.js +559 -0
  152. package/dist/inspect-CkEMQlFE.js +559 -0
  153. package/dist/installs--lvmS_5X.js +325 -0
  154. package/dist/installs-BA3T7VAz.js +325 -0
  155. package/dist/ir-BaHZnJJM.js +940 -0
  156. package/dist/loader-8b9zCJni.js +22621 -0
  157. package/dist/loader-FZXIZr3R.js +22624 -0
  158. package/dist/local-roots-CWQNmgUt.js +313 -0
  159. package/dist/local-roots-DJo8GN9l.js +314 -0
  160. package/dist/logger-BiVcvOhw.js +49 -0
  161. package/dist/login-9iJ6gWZk.js +61 -0
  162. package/dist/login-EqnFreqS.js +62 -0
  163. package/dist/login-qr-C-iNjUWs.js +327 -0
  164. package/dist/login-qr-WMfGy6v_.js +322 -0
  165. package/dist/logs-cli-DFZz2ger.js +238 -0
  166. package/dist/logs-cli-gX4_EMx4.js +233 -0
  167. package/dist/markdown-tables-Bry8gXRC.js +29 -0
  168. package/dist/markdown-tables-vq6-CCk-.js +29 -0
  169. package/dist/media-C0_rYTSG.js +10455 -0
  170. package/dist/media-DNm8s1nv.js +940 -0
  171. package/dist/message-action-names-BMv6kUc8.js +2521 -0
  172. package/dist/message-action-names-DSrGq84w.js +2521 -0
  173. package/dist/message-channel-DF4I2vOK.js +91 -0
  174. package/dist/net-Dl7oQfqm.js +225 -0
  175. package/dist/node-cli-Cv_2cuVQ.js +24 -0
  176. package/dist/nodes-cli-Bh5kE7rx.js +1343 -0
  177. package/dist/nodes-cli-C1nJHXNR.js +1348 -0
  178. package/dist/note-CAx7Id1-.js +92 -0
  179. package/dist/note-CpSd8qLI.js +92 -0
  180. package/dist/npm-registry-spec-CaHkYE_x.js +786 -0
  181. package/dist/npm-registry-spec-CocXp7ba.js +786 -0
  182. package/dist/npm-resolution-DQS5ZVqD.js +86 -0
  183. package/dist/npm-resolution-w3878lun.js +86 -0
  184. package/dist/onboard-BCal_4Gv.js +407 -0
  185. package/dist/onboard-YnHnBbNe.js +405 -0
  186. package/dist/onboard-channels-B87Gz5qD.js +2547 -0
  187. package/dist/onboard-channels-RBADpVYy.js +2548 -0
  188. package/dist/onboard-config-DgTNC3ZT.js +39 -0
  189. package/dist/onboard-config-x054Cod3.js +39 -0
  190. package/dist/onboard-helpers-CoKiZn8s.js +363 -0
  191. package/dist/onboard-helpers-DKApDaN3.js +362 -0
  192. package/dist/onboard-remote-B1RsWyDT.js +127 -0
  193. package/dist/onboard-remote-BKJJgiD6.js +127 -0
  194. package/dist/onboarding-B4xiRmix.js +534 -0
  195. package/dist/onboarding-CBzaoGrg.js +532 -0
  196. package/dist/onboarding.finalize-CmKkVYDg.js +401 -0
  197. package/dist/onboarding.finalize-Deue-iB5.js +398 -0
  198. package/dist/onboarding.gateway-config-CVzVE8Em.js +191 -0
  199. package/dist/onboarding.gateway-config-Z5kbnB3s.js +198 -0
  200. package/dist/outbound-BFD5_jba.js +221 -0
  201. package/dist/outbound-Cnqvf0fO.js +220 -0
  202. package/dist/outbound-attachment-BnqWk5_B.js +18 -0
  203. package/dist/outbound-attachment-D05iLA7W.js +18 -0
  204. package/dist/outbound-attachment-DEyKzFjb.js +18 -0
  205. package/dist/pairing-cli-Blm356D6.js +122 -0
  206. package/dist/pairing-cli-h_rEV_wP.js +127 -0
  207. package/dist/pairing-labels-D1m2vZ16.js +9 -0
  208. package/dist/pairing-labels-DtbcpHbW.js +9 -0
  209. package/dist/pairing-store-3EoUkpJk.js +459 -0
  210. package/dist/pairing-store-DlhFf9Sd.js +460 -0
  211. package/dist/path-env-BHe995Zs.js +89 -0
  212. package/dist/path-env-Dt0Pot3Y.js +89 -0
  213. package/dist/path-safety-BlhW64vx.js +14 -0
  214. package/dist/plugin-auto-enable-CAXV8TAD.js +301 -0
  215. package/dist/plugin-auto-enable-SoRyAF_8.js +302 -0
  216. package/dist/plugin-registry-B3Ovot-q.js +33 -0
  217. package/dist/plugin-registry-CLs2mk9g.js +33 -0
  218. package/dist/plugin-sdk/auto-reply/reply/agent-runner-execution.d.ts +0 -1
  219. package/dist/plugin-sdk/auto-reply/reply/session-run-accounting.d.ts +0 -7
  220. package/dist/plugin-sdk/auto-reply/reply/session-updates.d.ts +0 -10
  221. package/dist/plugin-sdk/auto-reply/status.d.ts +1 -3
  222. package/dist/plugin-sdk/config/defaults.d.ts +0 -1
  223. package/dist/plugin-sdk/config/sessions/types.d.ts +0 -6
  224. package/dist/plugin-sdk/config/types.agent-defaults.d.ts +21 -101
  225. package/dist/plugin-sdk/config/zod-schema.agent-defaults.d.ts +8 -63
  226. package/dist/plugin-sdk/config/zod-schema.agent-runtime.d.ts +2 -10
  227. package/dist/plugin-sdk/config/zod-schema.agents.d.ts +10 -71
  228. package/dist/plugin-sdk/config/zod-schema.d.ts +10 -71
  229. package/dist/plugin-sdk/daemon/constants.d.ts +2 -2
  230. package/dist/plugin-sdk/index.js +34 -67
  231. package/dist/plugin-sdk/middleware/channel-bridge.d.ts +4 -0
  232. package/dist/plugin-sdk/middleware/runtime-factory.d.ts +42 -0
  233. package/dist/plugin-sdk/middleware/types.d.ts +4 -0
  234. package/dist/plugins-BtMu6L8i.js +453 -0
  235. package/dist/plugins-HyUNaoYP.js +455 -0
  236. package/dist/plugins-cli-Bfz5q2Eu.js +793 -0
  237. package/dist/plugins-cli-IC5XEIJP.js +798 -0
  238. package/dist/ports-B5ckNet-.js +96 -0
  239. package/dist/ports-Bd3hoh8b.js +96 -0
  240. package/dist/ports-BookgaRI.js +370 -0
  241. package/dist/ports-UXImZGj6.js +316 -0
  242. package/dist/program-DHHHUVxq.js +244 -0
  243. package/dist/program-context-CJ5VtH21.js +474 -0
  244. package/dist/progress-WaSih6uF.js +124 -0
  245. package/dist/prompt-select-styled-CvndflSu.js +1647 -0
  246. package/dist/prompt-select-styled-DRpXaDjZ.js +1650 -0
  247. package/dist/provider-dispatcher-BtSfIQn3.js +659 -0
  248. package/dist/provider-dispatcher-CUXHJBTf.js +660 -0
  249. package/dist/push-apns-BH90TRlq.js +713 -0
  250. package/dist/pw-ai-89JDYEsx.js +1906 -0
  251. package/dist/pw-ai-DLMRJYTF.js +1910 -0
  252. package/dist/qr-cli-B-vXl2tJ.js +352 -0
  253. package/dist/qr-cli-CPLEROlB.js +347 -0
  254. package/dist/redact-snapshot-D6v5Y3cH.js +2016 -0
  255. package/dist/redact-snapshot-DRkh_GXw.js +2016 -0
  256. package/dist/register.agent-6t54SCKS.js +1043 -0
  257. package/dist/register.agent-CrTeig6j.js +286 -0
  258. package/dist/register.configure-CLKO7CBz.js +124 -0
  259. package/dist/register.configure-CYhzeMUN.js +130 -0
  260. package/dist/register.import-CwB3CVmx.js +30 -0
  261. package/dist/register.import-DuMlmKVZ.js +27 -0
  262. package/dist/register.maintenance-BywvjbLM.js +494 -0
  263. package/dist/register.maintenance-CmZiik6M.js +497 -0
  264. package/dist/register.message-C4uOmrmu.js +681 -0
  265. package/dist/register.message-_xLO9io6.js +686 -0
  266. package/dist/register.onboard-D70dDDQi.js +262 -0
  267. package/dist/register.onboard-FyyzQnPJ.js +257 -0
  268. package/dist/register.setup-D6gZLMvn.js +114 -0
  269. package/dist/register.setup-PQ_egL-s.js +109 -0
  270. package/dist/register.status-health-sessions-CPGqgxER.js +668 -0
  271. package/dist/register.status-health-sessions-D0hrBo9e.js +423 -0
  272. package/dist/register.subclis-B4JkPvWw.js +267 -0
  273. package/dist/replies-DwXyI317.js +136 -0
  274. package/dist/replies-vM-49F7Z.js +136 -0
  275. package/dist/reply-DO3tkAbl.js +13717 -0
  276. package/dist/reply-directives-BSHSMfOP.js +182 -0
  277. package/dist/reply-directives-Bd8xCxw5.js +182 -0
  278. package/dist/reply-gX7Zk9R8.js +13720 -0
  279. package/dist/reply-payloads-BzxytLE1.js +527 -0
  280. package/dist/reply-prefix-BPUsoqRv.js +38 -0
  281. package/dist/reply-prefix-Cz79Mk_9.js +38 -0
  282. package/dist/resolve-route-CbxnmqSZ.js +249 -0
  283. package/dist/resolve-route-RsSFZfEu.js +249 -0
  284. package/dist/response-prefix-template-BqmQwHFv.js +136 -0
  285. package/dist/response-prefix-template-oS-m4x5k.js +136 -0
  286. package/dist/retry-BMUvSHT-.js +77 -0
  287. package/dist/run-main-D_Yvs705.js +302 -0
  288. package/dist/runner-BvtNyNts.js +2294 -0
  289. package/dist/runner-bzffxuwY.js +2294 -0
  290. package/dist/runtime-guard-B43sm9Yk.js +60 -0
  291. package/dist/secure-random-CsKN1dAJ.js +44 -0
  292. package/dist/security-cli-ClDV4uPt.js +484 -0
  293. package/dist/security-cli-D578rt9i.js +478 -0
  294. package/dist/send-16QFH4iu.js +492 -0
  295. package/dist/send-1ch3HEta.js +29 -0
  296. package/dist/send-B5mtDLya.js +492 -0
  297. package/dist/send-BA-OQAbS.js +547 -0
  298. package/dist/send-BAki96aY.js +547 -0
  299. package/dist/send-BzYdvFV2.js +1775 -0
  300. package/dist/send-C-Vix83b.js +374 -0
  301. package/dist/send-C2vPu8jr.js +2245 -0
  302. package/dist/send-CCpFrPS3.js +426 -0
  303. package/dist/send-CXoL2Zzi.js +349 -0
  304. package/dist/send-Cp7xKp6y.js +2245 -0
  305. package/dist/send-DmR0m7rx.js +332 -0
  306. package/dist/send-MwvIhKYv.js +11 -0
  307. package/dist/send-YjzTu9Vf.js +1778 -0
  308. package/dist/send-jlq_MH8C.js +1174 -0
  309. package/dist/send-ysN09khs.js +349 -0
  310. package/dist/server-02ElXzP1.js +200 -0
  311. package/dist/server-lifecycle-B8xKnzsQ.js +2437 -0
  312. package/dist/server-lifecycle-CEvhrc0-.js +2437 -0
  313. package/dist/server-node-events-DU4X16h1.js +398 -0
  314. package/dist/server-node-events-DrH58PI5.js +393 -0
  315. package/dist/server-ur9b1Yzm.js +205 -0
  316. package/dist/service-CiiOMO48.js +670 -0
  317. package/dist/service-Csa_Zp8l.js +670 -0
  318. package/dist/session-BtRSSNK_.js +170 -0
  319. package/dist/session-cost-usage-Cd5Heqqu.js +627 -0
  320. package/dist/session-cost-usage-CnPZY4id.js +627 -0
  321. package/dist/session-dirs-DhnTK_rA.js +947 -0
  322. package/dist/session-dirs-Ii3gbgos.js +947 -0
  323. package/dist/session-utils-Cs0dVU0y.js +624 -0
  324. package/dist/session-utils-DuK3Cyeh.js +624 -0
  325. package/dist/sessions-B3mSpWqX.js +2568 -0
  326. package/dist/sessions-BKYYI9GY.js +251 -0
  327. package/dist/status-B2d7Lmls.js +2067 -0
  328. package/dist/status-DSrcpDkP.js +2071 -0
  329. package/dist/status.update-BdkJ6oB8.js +79 -0
  330. package/dist/status.update-Cx6moscN.js +79 -0
  331. package/dist/store-COXTNbLU.js +53 -0
  332. package/dist/store-DdUK8zTC.js +2570 -0
  333. package/dist/subagent-registry-CpaLEiLw.js +4860 -0
  334. package/dist/subagent-registry-CwfHcOru.js +4858 -0
  335. package/dist/subsystem-BgxIzx7w.js +1137 -0
  336. package/dist/system-cli-C_3mdl-Y.js +75 -0
  337. package/dist/system-cli-Cg3uYNSx.js +70 -0
  338. package/dist/systemd-C9CRJ1Vh.js +547 -0
  339. package/dist/systemd-Clsb90Zg.js +547 -0
  340. package/dist/systemd-linger-CeBq5lTN.js +75 -0
  341. package/dist/systemd-linger-D70Sc4ia.js +75 -0
  342. package/dist/table-DVVqt1iT.js +279 -0
  343. package/dist/tables-6RxRFEl1.js +55 -0
  344. package/dist/tables-CamcS9gx.js +55 -0
  345. package/dist/tables-CmbvfFUi.js +55 -0
  346. package/dist/tailscale-C_8-YaZu.js +230 -0
  347. package/dist/targets--D1Sgq6T.js +220 -0
  348. package/dist/targets-BEON1rlZ.js +650 -0
  349. package/dist/targets-DRd0Al1y.js +650 -0
  350. package/dist/targets-DzGG0A-J.js +2245 -0
  351. package/dist/targets-IkURIBGL.js +53 -0
  352. package/dist/targets-NcJOa0-P.js +2244 -0
  353. package/dist/tool-images-BLldmoMO.js +263 -0
  354. package/dist/trash-CLx3VKz0.js +125 -0
  355. package/dist/tui-BqrwhnqU.js +3392 -0
  356. package/dist/tui-D1yYpK5L.js +3392 -0
  357. package/dist/tui-cli-DSoJ3FKB.js +58 -0
  358. package/dist/tui-cli-DmT2z3u-.js +63 -0
  359. package/dist/update-Bqxd57w0.js +349 -0
  360. package/dist/update-DNLS8oRs.js +349 -0
  361. package/dist/update-cli-CU9ZXQY3.js +1373 -0
  362. package/dist/update-cli-CVyu40ky.js +1370 -0
  363. package/dist/usage-DmDjx45Z.js +5337 -0
  364. package/dist/web-BUwk0Z14.js +3065 -0
  365. package/dist/web-D0Q23mS6.js +70 -0
  366. package/dist/web-Dbsn7rM8.js +76 -0
  367. package/dist/webhooks-cli-CVkKq_i_.js +328 -0
  368. package/dist/webhooks-cli-DUcnf7Eh.js +333 -0
  369. package/dist/whatsapp-actions-Drtn7JXc.js +128 -0
  370. package/dist/whatsapp-actions-OYitul5l.js +122 -0
  371. package/dist/workspace-CZ3yxyNd.js +447 -0
  372. package/dist/workspace-DJ7hsM9r.js +449 -0
  373. package/package.json +3 -3
  374. package/dist/accounts-B1aJFYXr.js +0 -272
  375. package/dist/accounts-Bexa80SB.js +0 -32
  376. package/dist/accounts-Cl_cFv9X.js +0 -47
  377. package/dist/accounts-Dn9h7HHT.js +0 -36
  378. package/dist/ack-reactions-B11TAC2D.js +0 -446
  379. package/dist/ack-reactions-CDUSdN8O.js +0 -446
  380. package/dist/acp-cli-CA1xMmVo.js +0 -1320
  381. package/dist/acp-cli-Dr83tqAg.js +0 -1326
  382. package/dist/active-listener-VzhWW8W6.js +0 -37
  383. package/dist/agent-CFKgqSEH.js +0 -732
  384. package/dist/agent-D2RVoS5g.js +0 -731
  385. package/dist/agent-helpers-D_9mS2Ti.js +0 -606
  386. package/dist/agent-scope-9WY5O-KK.js +0 -121
  387. package/dist/agent-scope-C50VuLKh.js +0 -119
  388. package/dist/agents-BBXCuDMp.js +0 -788
  389. package/dist/agents.config-BPGQ3Qyn.js +0 -116
  390. package/dist/agents.config-p3V3b9u6.js +0 -116
  391. package/dist/audio-preflight-BwmCYeuM.js +0 -64
  392. package/dist/audio-preflight-Dj6hBcFR.js +0 -69
  393. package/dist/audit-DhIKIeXD.js +0 -3138
  394. package/dist/audit-qgtCT3ik.js +0 -3138
  395. package/dist/auth-C6VDYgb7.js +0 -448
  396. package/dist/auth-Deh9i9Eg.js +0 -448
  397. package/dist/auth-profiles-CeDgZz_7.js +0 -281
  398. package/dist/banner-HCssFZcB.js +0 -294
  399. package/dist/binaries-X6FW-wD4.js +0 -13
  400. package/dist/bindings-B582pDIa.js +0 -69
  401. package/dist/bindings-CRU_udk8.js +0 -69
  402. package/dist/bonjour-discovery-BtPaR8vb.js +0 -378
  403. package/dist/bonjour-discovery-DuhiIZZx.js +0 -378
  404. package/dist/browser-cli-HH45lxP0.js +0 -1687
  405. package/dist/browser-cli-TB-GNoZq.js +0 -1692
  406. package/dist/call-BbwtB9Y-.js +0 -2828
  407. package/dist/call-ByOzoLDI.js +0 -2829
  408. package/dist/catalog-BY7OPtnz.js +0 -185
  409. package/dist/catalog-BqO6yem_.js +0 -185
  410. package/dist/channel-account-context-CjXyzMXE.js +0 -550
  411. package/dist/channel-account-context-CvIDAtHS.js +0 -550
  412. package/dist/channel-activity-BeRrcCd8.js +0 -94
  413. package/dist/channel-activity-DTKGf3j5.js +0 -94
  414. package/dist/channel-activity-hPfValKp.js +0 -292
  415. package/dist/channel-options-BLdLu0xk.js +0 -33
  416. package/dist/channel-options-BQ61blla.js +0 -32
  417. package/dist/channel-selection-CJXZTxae.js +0 -51
  418. package/dist/channel-selection-NNPbxnyZ.js +0 -51
  419. package/dist/channel-web-D1_mlyPg.js +0 -2136
  420. package/dist/channel-web-DmhVkWbP.js +0 -2134
  421. package/dist/channels-cli-C4O8pp1S.js +0 -1426
  422. package/dist/channels-cli-DAu1TXTH.js +0 -1421
  423. package/dist/channels-status-issues-BDAHISWe.js +0 -18
  424. package/dist/channels-status-issues-DwRDzwrV.js +0 -18
  425. package/dist/chat-envelope-el7Uo-Fe.js +0 -248
  426. package/dist/chrome-CNDtczoM.js +0 -1733
  427. package/dist/chrome-CdcwZN9t.js +0 -1732
  428. package/dist/chunk-DAjFKt2g.js +0 -341
  429. package/dist/clack-prompter-CCFnKP_1.js +0 -121
  430. package/dist/clack-prompter-CabwzmG4.js +0 -122
  431. package/dist/cli-BuMX-jRY.js +0 -130
  432. package/dist/cli-Ci4DmAyk.js +0 -125
  433. package/dist/clipboard-B2j4qGIl.js +0 -31
  434. package/dist/command-registry-DxsFXB5t.js +0 -215
  435. package/dist/commands-C2uNKRTf.js +0 -41
  436. package/dist/commands-CDonBOrw.js +0 -41
  437. package/dist/commands-registry-BvESmXoK.js +0 -893
  438. package/dist/commands-registry-CWJv6xe2.js +0 -892
  439. package/dist/common-Cp3rsBqx.js +0 -156
  440. package/dist/completion-cli-B-X5nwdT.js +0 -452
  441. package/dist/completion-cli-DD3pVpPn.js +0 -452
  442. package/dist/config-BqY7k-L8.js +0 -6953
  443. package/dist/config-FHu9Bn4R.js +0 -6951
  444. package/dist/config-cli-CPH_PfVk.js +0 -241
  445. package/dist/config-cli-Czvt02PC.js +0 -246
  446. package/dist/config-guard-5oI2BiSY.js +0 -97
  447. package/dist/config-guard-cB5a_ANg.js +0 -75
  448. package/dist/config-validation-BPNyd9_3.js +0 -18
  449. package/dist/config-validation-J3cJ0OCa.js +0 -18
  450. package/dist/configure-Bi_9d94n.js +0 -889
  451. package/dist/configure-DiQaHI3s.js +0 -891
  452. package/dist/constants-BmRFoHl0.js +0 -67
  453. package/dist/constants-C9WPAluB.js +0 -67
  454. package/dist/control-auth-D0tpV3ts.js +0 -397
  455. package/dist/control-auth-q4zZXaoS.js +0 -397
  456. package/dist/control-ui/assets/index-B4ZM1lW1.js +0 -7738
  457. package/dist/control-ui/assets/index-B4ZM1lW1.js.map +0 -1
  458. package/dist/control-ui/assets/index-PED72sKF.css +0 -1
  459. package/dist/control-ui-assets-Cx_mw4D0.js +0 -186
  460. package/dist/control-ui-assets-D4yaD8jm.js +0 -186
  461. package/dist/cron-cli-Bfh7ftYz.js +0 -495
  462. package/dist/cron-cli-C8j_uslU.js +0 -490
  463. package/dist/daemon-cli-DQFZB1yM.js +0 -1197
  464. package/dist/daemon-cli-lTsfNeDm.js +0 -1199
  465. package/dist/daemon-install-CcohRvKV.js +0 -55
  466. package/dist/daemon-install-DrTvAWhM.js +0 -60
  467. package/dist/daemon-install-helpers-CFGAfRlj.js +0 -462
  468. package/dist/daemon-install-helpers-DIUzSFG1.js +0 -462
  469. package/dist/defaults-B5KStIBg.js +0 -7
  470. package/dist/defaults-xUAL2Z-F.js +0 -7
  471. package/dist/deliver-912khjLK.js +0 -481
  472. package/dist/deliver-D78pwuPC.js +0 -481
  473. package/dist/delivery-queue-CxVRi4tw.js +0 -244
  474. package/dist/devices-cli-0qDhTgZR.js +0 -316
  475. package/dist/devices-cli-CstkYXzr.js +0 -321
  476. package/dist/diagnostics-HGkN467d.js +0 -46
  477. package/dist/diagnostics-VC0cz7kX.js +0 -46
  478. package/dist/directory-cli-5YXdoVdn.js +0 -217
  479. package/dist/directory-cli-duhBZl2c.js +0 -222
  480. package/dist/dm-policy-shared-BBfEyAN1.js +0 -22
  481. package/dist/dm-policy-shared-D8lgnmrC.js +0 -22
  482. package/dist/dns-cli-11CtErVU.js +0 -197
  483. package/dist/dns-cli-Sr6SB9ei.js +0 -202
  484. package/dist/dock-BqNINg7k.js +0 -928
  485. package/dist/dock-O8ArYwed.js +0 -929
  486. package/dist/doctor-completion-B1UlvZFx.js +0 -92
  487. package/dist/doctor-completion-C0j7b_f8.js +0 -92
  488. package/dist/doctor-config-flow-BVkHcvoj.js +0 -1933
  489. package/dist/doctor-config-flow-BiShkCxs.js +0 -1934
  490. package/dist/enable-DMIq6evt.js +0 -59
  491. package/dist/enable-ibNq4UWy.js +0 -59
  492. package/dist/env-Br2Bl6Ht.js +0 -60
  493. package/dist/exec-C6ACg_Mn.js +0 -164
  494. package/dist/fetch-Bmv93nu9.js +0 -67
  495. package/dist/fs-safe-DkBhNAc3.js +0 -98
  496. package/dist/gateway-cli-D4cDhvZx.js +0 -23747
  497. package/dist/gateway-cli-DuMjB8Ff.js +0 -23742
  498. package/dist/gateway-rpc-B4jTtupy.js +0 -28
  499. package/dist/gateway-rpc-Dq44SkOv.js +0 -28
  500. package/dist/gmail-setup-utils-BPmUIqso.js +0 -423
  501. package/dist/gmail-setup-utils-Cnx8A5pW.js +0 -422
  502. package/dist/health-SOuaKNRa.js +0 -1420
  503. package/dist/health-wr-JDHlc.js +0 -1423
  504. package/dist/heartbeat-visibility-BxkZjE5m.js +0 -125
  505. package/dist/heartbeat-visibility-ossI_l4t.js +0 -125
  506. package/dist/helpers-kkeXif0Q.js +0 -10
  507. package/dist/hook-runner-global-DJ14gXFP.js +0 -527
  508. package/dist/hooks-cli-BUTtESiX.js +0 -1217
  509. package/dist/hooks-cli-eqPYjw4l.js +0 -1222
  510. package/dist/image-ops-DRdKC0uO.js +0 -354
  511. package/dist/import-Be73VPF2.js +0 -170
  512. package/dist/import-DQ6NI4Fz.js +0 -168
  513. package/dist/inbound-path-policy-C_Qo8rqg.js +0 -250
  514. package/dist/inspect-B1Fq39RC.js +0 -559
  515. package/dist/inspect-Dt8hogS3.js +0 -559
  516. package/dist/installs-C8apg11p.js +0 -325
  517. package/dist/installs-pWdqG8HL.js +0 -325
  518. package/dist/ir-Ch9FC9Z_.js +0 -940
  519. package/dist/loader-Cuq-saEl.js +0 -22621
  520. package/dist/loader-u9FC6kYG.js +0 -22624
  521. package/dist/local-roots-BrH0Q63K.js +0 -313
  522. package/dist/local-roots-z2u_s7jG.js +0 -314
  523. package/dist/logger-pznB_IdT.js +0 -49
  524. package/dist/login-CYq-visu.js +0 -62
  525. package/dist/login-DOmWDMeP.js +0 -61
  526. package/dist/login-qr-CXU0wC5K.js +0 -322
  527. package/dist/login-qr-D85vVatX.js +0 -327
  528. package/dist/logs-cli-Cu2S08Y3.js +0 -238
  529. package/dist/logs-cli-D7ayUvz_.js +0 -233
  530. package/dist/markdown-tables-hhOWaw8L.js +0 -29
  531. package/dist/markdown-tables-jrnSPvZ6.js +0 -29
  532. package/dist/media-DN7yRfrH.js +0 -940
  533. package/dist/media-DOQIalam.js +0 -10492
  534. package/dist/message-action-names-Dk9kxwRd.js +0 -2521
  535. package/dist/message-action-names-EsOcuFpq.js +0 -2521
  536. package/dist/message-channel-BlYrtmIp.js +0 -91
  537. package/dist/net-D6D0wgcF.js +0 -225
  538. package/dist/node-cli-Q2-n3Fgv.js +0 -24
  539. package/dist/nodes-cli-BDq-4dHm.js +0 -1348
  540. package/dist/nodes-cli-C2SoKfCv.js +0 -1343
  541. package/dist/note-DR8A0G5H.js +0 -92
  542. package/dist/note-Dlv4NmlQ.js +0 -92
  543. package/dist/npm-registry-spec-COvUzy5J.js +0 -786
  544. package/dist/npm-registry-spec-Cobb5KYR.js +0 -786
  545. package/dist/npm-resolution-BmgD7x45.js +0 -86
  546. package/dist/npm-resolution-DNYcV-Br.js +0 -86
  547. package/dist/onboard-Dy0q82Mj.js +0 -405
  548. package/dist/onboard-channels-9QS_7iph.js +0 -2548
  549. package/dist/onboard-channels-EH2wvu6Y.js +0 -2547
  550. package/dist/onboard-config-BCTthQ7J.js +0 -24
  551. package/dist/onboard-config-y-2cgT0V.js +0 -24
  552. package/dist/onboard-helpers-ChPmr3lh.js +0 -363
  553. package/dist/onboard-helpers-Jy3345Jk.js +0 -362
  554. package/dist/onboard-remote-CM6Yl1oL.js +0 -127
  555. package/dist/onboard-remote-Id80PV28.js +0 -127
  556. package/dist/onboard-uvDMehqu.js +0 -407
  557. package/dist/onboarding-BVtzeopT.js +0 -534
  558. package/dist/onboarding-DlXBAIDc.js +0 -532
  559. package/dist/onboarding.finalize-Dve-3p-y.js +0 -398
  560. package/dist/onboarding.finalize-GIK3ktiW.js +0 -401
  561. package/dist/onboarding.gateway-config-BCV5T35-.js +0 -198
  562. package/dist/onboarding.gateway-config-DW-09FX5.js +0 -191
  563. package/dist/outbound-CFfJC1j5.js +0 -220
  564. package/dist/outbound-CjFRpudN.js +0 -221
  565. package/dist/outbound-attachment-BxMSma9v.js +0 -18
  566. package/dist/outbound-attachment-DIiKB_mP.js +0 -18
  567. package/dist/outbound-attachment-o0seS0CP.js +0 -18
  568. package/dist/pairing-cli-BeydfoF9.js +0 -122
  569. package/dist/pairing-cli-GgwzEWJX.js +0 -127
  570. package/dist/pairing-labels-B_53dY5L.js +0 -9
  571. package/dist/pairing-labels-BiSZLitI.js +0 -9
  572. package/dist/pairing-store-BgAv4uN8.js +0 -460
  573. package/dist/pairing-store-CTkD51uW.js +0 -459
  574. package/dist/path-env-ErEKbxOI.js +0 -89
  575. package/dist/path-env-qRJbjJzj.js +0 -89
  576. package/dist/path-safety-juI2XbO1.js +0 -14
  577. package/dist/plugin-auto-enable-CloCFyTz.js +0 -302
  578. package/dist/plugin-auto-enable-DuPS9XiJ.js +0 -301
  579. package/dist/plugin-registry-D5QsH-IS.js +0 -33
  580. package/dist/plugin-registry-DnO3azwy.js +0 -33
  581. package/dist/plugin-sdk/agents/defaults.d.ts +0 -3
  582. package/dist/plugin-sdk/auto-reply/model-runtime.d.ts +0 -17
  583. package/dist/plugin-sdk/config/model-input.d.ts +0 -9
  584. package/dist/plugin-sdk/config/zod-schema.agent-model.d.ts +0 -5
  585. package/dist/plugin-sdk/sessions/model-overrides.d.ts +0 -14
  586. package/dist/plugins-BXkDApVh.js +0 -455
  587. package/dist/plugins-BflZz0sp.js +0 -453
  588. package/dist/plugins-cli-Cf_RP_bn.js +0 -798
  589. package/dist/plugins-cli-DmbjYnO9.js +0 -793
  590. package/dist/ports-DIYJq-SY.js +0 -370
  591. package/dist/ports-DPL-Pzfh.js +0 -96
  592. package/dist/ports-NPqtlfp0.js +0 -316
  593. package/dist/ports-QMI4-F9m.js +0 -96
  594. package/dist/program-BaATq6CL.js +0 -244
  595. package/dist/program-context-C7b5MQbg.js +0 -474
  596. package/dist/progress--dapuyZA.js +0 -124
  597. package/dist/prompt-select-styled-BAsxl6hj.js +0 -1650
  598. package/dist/prompt-select-styled-aqjxCbwP.js +0 -1647
  599. package/dist/provider-dispatcher-B4QMe-I6.js +0 -659
  600. package/dist/provider-dispatcher-mAkRbPyH.js +0 -660
  601. package/dist/push-apns-CLmNS5AZ.js +0 -713
  602. package/dist/pw-ai-DuK87zsJ.js +0 -1906
  603. package/dist/pw-ai-ulOU3Ya1.js +0 -1910
  604. package/dist/qr-cli-9WQBnauO.js +0 -352
  605. package/dist/qr-cli-hSLixZCe.js +0 -347
  606. package/dist/redact-snapshot-BZYLIqe-.js +0 -2028
  607. package/dist/redact-snapshot-D2P_lRgf.js +0 -2028
  608. package/dist/register.agent-CquY2yLI.js +0 -286
  609. package/dist/register.agent-DZL_fw2K.js +0 -1043
  610. package/dist/register.configure-C2HjaKO0.js +0 -124
  611. package/dist/register.configure-D7Di47Lb.js +0 -130
  612. package/dist/register.import-Bs-UkOs-.js +0 -27
  613. package/dist/register.import-CaJ0DS1t.js +0 -30
  614. package/dist/register.maintenance-CslelbHK.js +0 -497
  615. package/dist/register.maintenance-Dd4fn6oX.js +0 -494
  616. package/dist/register.message-D2xmx0xB.js +0 -681
  617. package/dist/register.message-_Q8ehgQP.js +0 -686
  618. package/dist/register.onboard-BFSwh5g4.js +0 -262
  619. package/dist/register.onboard-CIupEYmX.js +0 -257
  620. package/dist/register.setup-7pk1r-54.js +0 -114
  621. package/dist/register.setup-Bm1Jtx0c.js +0 -109
  622. package/dist/register.status-health-sessions-C-Pbi-qq.js +0 -669
  623. package/dist/register.status-health-sessions-Cn4yWBWw.js +0 -423
  624. package/dist/register.subclis-DXmLofHX.js +0 -267
  625. package/dist/replies-BKrzM0QI.js +0 -136
  626. package/dist/replies-BkXDql3c.js +0 -136
  627. package/dist/reply-DSKC8kyS.js +0 -13897
  628. package/dist/reply-directives-CBeNSCHL.js +0 -182
  629. package/dist/reply-directives-CD2WycBM.js +0 -182
  630. package/dist/reply-n8KWtBQB.js +0 -13900
  631. package/dist/reply-payloads-CeL_cBnD.js +0 -527
  632. package/dist/reply-prefix-4zLS7A1Y.js +0 -38
  633. package/dist/reply-prefix-DBLCYiup.js +0 -38
  634. package/dist/resolve-route-BDGdM-l3.js +0 -249
  635. package/dist/resolve-route-CBVbY0xS.js +0 -249
  636. package/dist/response-prefix-template-CSxp9HN5.js +0 -136
  637. package/dist/response-prefix-template-up4REfuR.js +0 -136
  638. package/dist/retry-C81p7BZU.js +0 -77
  639. package/dist/run-main-CuA7VmAq.js +0 -320
  640. package/dist/runner-BbLPl1dz.js +0 -2294
  641. package/dist/runner-z92MWZ3m.js +0 -2294
  642. package/dist/runtime-guard-DZ_xuCc4.js +0 -60
  643. package/dist/secure-random-D2IOpBkk.js +0 -44
  644. package/dist/security-cli-BR3Y1FBJ.js +0 -484
  645. package/dist/security-cli-DP5QJpa5.js +0 -478
  646. package/dist/send-0uEtKwU_.js +0 -2245
  647. package/dist/send-B3O7bzYU.js +0 -1174
  648. package/dist/send-BWSo3i3H.js +0 -1778
  649. package/dist/send-BkSUAGj6.js +0 -349
  650. package/dist/send-Bx9bUGav.js +0 -492
  651. package/dist/send-CBGSXjfD.js +0 -2245
  652. package/dist/send-CRS-OcnW.js +0 -29
  653. package/dist/send-DPttDPIR.js +0 -374
  654. package/dist/send-D_DUQJ6H.js +0 -349
  655. package/dist/send-DyftOlFD.js +0 -332
  656. package/dist/send-Lij9A7lk.js +0 -547
  657. package/dist/send-YRVDWfSs.js +0 -547
  658. package/dist/send-dzS4fa9O.js +0 -492
  659. package/dist/send-uchxcHYC.js +0 -11
  660. package/dist/send-xUPOqzUr.js +0 -426
  661. package/dist/send-xnwty9cY.js +0 -1775
  662. package/dist/server-BE5lybcS.js +0 -205
  663. package/dist/server-LdLsvPPw.js +0 -200
  664. package/dist/server-lifecycle-B3Rdmq7-.js +0 -2437
  665. package/dist/server-lifecycle-CFmE_Adm.js +0 -2437
  666. package/dist/server-node-events-De4WZQQD.js +0 -393
  667. package/dist/server-node-events-d7eK4LBW.js +0 -398
  668. package/dist/service-BHos7oX8.js +0 -670
  669. package/dist/service-Bjqii5nW.js +0 -670
  670. package/dist/session-aUptxSVD.js +0 -170
  671. package/dist/session-cost-usage-DX09eTPU.js +0 -627
  672. package/dist/session-cost-usage-yYi525j3.js +0 -627
  673. package/dist/session-dirs-BADAi9Iz.js +0 -947
  674. package/dist/session-dirs-DdF6TDsE.js +0 -947
  675. package/dist/session-key-5YLnn_qf.js +0 -235
  676. package/dist/session-utils-CEtEq6bi.js +0 -625
  677. package/dist/session-utils-CiXbZkM2.js +0 -625
  678. package/dist/sessions--PykPynp.js +0 -2593
  679. package/dist/sessions-Bw4LRnSr.js +0 -252
  680. package/dist/status-CrGLegI6.js +0 -2072
  681. package/dist/status-D_3sszaS.js +0 -2068
  682. package/dist/status.update-C55QM2xs.js +0 -79
  683. package/dist/status.update-CVnonGHu.js +0 -79
  684. package/dist/store-C6w1sB5x.js +0 -53
  685. package/dist/store-DoOPG3rl.js +0 -2595
  686. package/dist/subagent-registry-C-xI2uK4.js +0 -4860
  687. package/dist/subagent-registry-Db4Ho_2Y.js +0 -4858
  688. package/dist/subsystem-CrJCqjAh.js +0 -1139
  689. package/dist/system-cli-CCKzF3uh.js +0 -75
  690. package/dist/system-cli-eAk5wVbP.js +0 -70
  691. package/dist/systemd-B5lyaCc3.js +0 -547
  692. package/dist/systemd-DSnlM3jX.js +0 -547
  693. package/dist/systemd-linger-DRPSEQVw.js +0 -75
  694. package/dist/systemd-linger-_0_-RY4v.js +0 -75
  695. package/dist/table-CpmqqcxJ.js +0 -279
  696. package/dist/tables-DI5LGEr1.js +0 -55
  697. package/dist/tables-D_PTzthR.js +0 -55
  698. package/dist/tables-DcQUNIvB.js +0 -55
  699. package/dist/tailscale-Dxyz13fn.js +0 -230
  700. package/dist/targets-B2vBpQdr.js +0 -2173
  701. package/dist/targets-B54vK3wc.js +0 -220
  702. package/dist/targets-Cm1X3IyA.js +0 -650
  703. package/dist/targets-D7OKVXMI.js +0 -650
  704. package/dist/targets-DB4vBpIQ.js +0 -2172
  705. package/dist/targets-DyybKefq.js +0 -53
  706. package/dist/tool-images-DVrUJEqc.js +0 -263
  707. package/dist/trash-DzrtBoP1.js +0 -125
  708. package/dist/tui-CyHwc2uX.js +0 -3392
  709. package/dist/tui-cHd20SZm.js +0 -3392
  710. package/dist/tui-cli-C7kQj9ef.js +0 -63
  711. package/dist/tui-cli-C9I18SfW.js +0 -58
  712. package/dist/update-DeQGoaIC.js +0 -349
  713. package/dist/update-IX7vdqA8.js +0 -349
  714. package/dist/update-cli-C52dmo3x.js +0 -1370
  715. package/dist/update-cli-DY_iE1E5.js +0 -1373
  716. package/dist/usage-B--dL37U.js +0 -5279
  717. package/dist/web-CMxp78WA.js +0 -76
  718. package/dist/web-DMweaNnG.js +0 -3065
  719. package/dist/web-Dquzwqf4.js +0 -70
  720. package/dist/webhooks-cli-BpZHQlVd.js +0 -328
  721. package/dist/webhooks-cli-CqFX8Ywl.js +0 -333
  722. package/dist/whatsapp-actions-C31Zdwez.js +0 -128
  723. package/dist/whatsapp-actions-DaA291Ya.js +0 -122
  724. package/dist/workspace-B4ZvVYT9.js +0 -447
  725. package/dist/workspace-B8qk__ff.js +0 -449
  726. /package/dist/{ansi-D04X81yq.js → ansi-aRwLYlzD.js} +0 -0
  727. /package/dist/{api-BeQMq2iS.js → api-B5a-GhRx.js} +0 -0
  728. /package/dist/{api-CxX8-gGz.js → api-CIseA2oL.js} +0 -0
  729. /package/dist/{argv-Co-b9Zsc.js → argv-BpnfFual.js} +0 -0
  730. /package/dist/{audio-DPOuhNq7.js → audio-B_mzy948.js} +0 -0
  731. /package/dist/{audio-VBcVDa08.js → audio-DDvXRwh-.js} +0 -0
  732. /package/dist/{brew-DbSbN8sD.js → brew-DJ_dfLHZ.js} +0 -0
  733. /package/dist/{brew-C4zKZsHX.js → brew-j-qOseim.js} +0 -0
  734. /package/dist/{cleanup-utils-CwQvD73q.js → cleanup-utils-CELo1uhg.js} +0 -0
  735. /package/dist/{cleanup-utils-o2MM9xyf.js → cleanup-utils-iC7eNxVL.js} +0 -0
  736. /package/dist/{cli-utils-BhXbz2UF.js → cli-utils-BRpudJBb.js} +0 -0
  737. /package/dist/{cli-utils-DZe_rVkZ.js → cli-utils-DJwgT-LP.js} +0 -0
  738. /package/dist/{client-C61M8zI3.js → client-Ck9_YeG3.js} +0 -0
  739. /package/dist/{client-DdpmATKq.js → client-CwnX0nXo.js} +0 -0
  740. /package/dist/{clipboard-Dzkx6Q2K.js → clipboard-DT-6OtUP.js} +0 -0
  741. /package/dist/{command-options-C4paWSGf.js → command-options-BOLa_fOM.js} +0 -0
  742. /package/dist/{command-options-CA30lfLK.js → command-options-DbRrl8qF.js} +0 -0
  743. /package/dist/{config-eval-CjGZtLwx.js → config-eval-BsrVpg0A.js} +0 -0
  744. /package/dist/{config-eval-H_wlEYIG.js → config-eval-BzDtybYL.js} +0 -0
  745. /package/dist/{constants-ChptG3d7.js → constants-B1UiXFxs.js} +0 -0
  746. /package/dist/{constants-DY6b-_Wl.js → constants-DKUEbLZr.js} +0 -0
  747. /package/dist/{credentials-DFsi1_e8.js → credentials-C82aU5z-.js} +0 -0
  748. /package/dist/{daemon-runtime-CMnbwryP.js → daemon-runtime-BOcdJaFy.js} +0 -0
  749. /package/dist/{daemon-runtime-CvqE4ysg.js → daemon-runtime-CbyS9Xgu.js} +0 -0
  750. /package/dist/{dangerous-name-matching-BzmiLXmA.js → dangerous-name-matching-C2i9AEgf.js} +0 -0
  751. /package/dist/{dangerous-name-matching-DaVRgwer.js → dangerous-name-matching-CCBwBn49.js} +0 -0
  752. /package/dist/{dangerous-tools-BOLoCRv4.js → dangerous-tools-BRtX1d_K.js} +0 -0
  753. /package/dist/{dangerous-tools-Baq7Q-i6.js → dangerous-tools-D8hrp16Q.js} +0 -0
  754. /package/dist/{delivery-queue-Cfa9Wmxp.js → delivery-queue-CgAgO5_a.js} +0 -0
  755. /package/dist/{errors-DZ199hOo.js → errors-Dblex1kc.js} +0 -0
  756. /package/dist/{fetch-C6XKGA11.js → fetch-Du9BJ20J.js} +0 -0
  757. /package/dist/{fetch-CEDsOiql.js → fetch-KSHIFKGH.js} +0 -0
  758. /package/dist/{format-duration-CqUERz51.js → format-duration-BRNiDrqx.js} +0 -0
  759. /package/dist/{format-duration-Ct-yiwkS.js → format-duration-C11mR8D_.js} +0 -0
  760. /package/dist/{format-relative-79_Y1n2Y.js → format-relative-C6kUHuOj.js} +0 -0
  761. /package/dist/{format-relative-CxLpEQOX.js → format-relative-CEWK-aoC.js} +0 -0
  762. /package/dist/{health-format-B_QRD8Si.js → health-format-D-AQZK4v.js} +0 -0
  763. /package/dist/{health-format-Bygse7KA.js → health-format-DGyISuUh.js} +0 -0
  764. /package/dist/{heartbeat-wake-LGEgcXjs.js → heartbeat-wake-BtRrOB-t.js} +0 -0
  765. /package/dist/{heartbeat-wake-Y97geucO.js → heartbeat-wake-SJ-JCo-E.js} +0 -0
  766. /package/dist/{help-format-sqWgYEdL.js → help-format-BjjZaoq3.js} +0 -0
  767. /package/dist/{help-format-NNm_Ov4H.js → help-format-DB1wv6bQ.js} +0 -0
  768. /package/dist/{helpers-R7bU5IBz.js → helpers-BVw8gMr-.js} +0 -0
  769. /package/dist/{helpers-BAsMXprO.js → helpers-D-8vB6NY.js} +0 -0
  770. /package/dist/{helpers-DLgbkcEn.js → helpers-D04-Gim7.js} +0 -0
  771. /package/dist/{inbound-context-DS_kpIYI.js → inbound-context-D94rw0Oq.js} +0 -0
  772. /package/dist/{input-provenance-Bn6thJNm.js → input-provenance-BDPOaXFk.js} +0 -0
  773. /package/dist/{ipv4-CDQpx1A7.js → ipv4-Bp2lJpEb.js} +0 -0
  774. /package/dist/{ipv4--2WXMVtE.js → ipv4-D73_qHXL.js} +0 -0
  775. /package/dist/{is-main-DN8-sNR5.js → is-main-CqNDOs3L.js} +0 -0
  776. /package/dist/{json-files-CmpYSF4G.js → json-files-Ct2lDInr.js} +0 -0
  777. /package/dist/{lanes-ByWMUgrz.js → lanes-DKkroN9D.js} +0 -0
  778. /package/dist/{links-Cm43Vcft.js → links-BWZPW7Lq.js} +0 -0
  779. /package/dist/{links-Bz4V7R_p.js → links-Y3epeqjH.js} +0 -0
  780. /package/dist/{location-DBWCGNLq.js → location-BcldrVN7.js} +0 -0
  781. /package/dist/{location-GbZ0bBRU.js → location-BrkAgrz9.js} +0 -0
  782. /package/dist/{logger-DyL5G2DO.js → logger-BuGfr7KR.js} +0 -0
  783. /package/dist/{logger-GvipVDfh.js → logger-TzwNwShm.js} +0 -0
  784. /package/dist/{logging-D8-Kozjc.js → logging-BiGr95aB.js} +0 -0
  785. /package/dist/{logging-D8R0sLY9.js → logging-DZhZ5xLX.js} +0 -0
  786. /package/dist/{mutable-allowlist-detectors-DiZDtmlZ.js → mutable-allowlist-detectors-BaVrnZS3.js} +0 -0
  787. /package/dist/{mutable-allowlist-detectors-U5ThQr9V.js → mutable-allowlist-detectors-NtI6s4TE.js} +0 -0
  788. /package/dist/{node-cli-Uf6lAntf.js → node-cli-DFKT5s4K.js} +0 -0
  789. /package/dist/{nodes-screen-Bmp1l9wY.js → nodes-screen-ByJHtT0R.js} +0 -0
  790. /package/dist/{nodes-screen-Cw7Hv7M2.js → nodes-screen-C17NdAyR.js} +0 -0
  791. /package/dist/{parse-log-line-enq8pduH.js → parse-log-line-CM1cOe-W.js} +0 -0
  792. /package/dist/{parse-log-line-mz9TG6ig.js → parse-log-line-DXE28Ti3.js} +0 -0
  793. /package/dist/{parse-timeout-BMP8a0_a.js → parse-timeout-DFxbkOgy.js} +0 -0
  794. /package/dist/{parse-timeout-CDkco8kd.js → parse-timeout-dIdCY9EB.js} +0 -0
  795. /package/dist/{path-guards-CrQOUlsq.js → path-guards-DJteVA0d.js} +0 -0
  796. /package/dist/{path-safety-DkT9RmTG.js → path-safety-BGnQWeUs.js} +0 -0
  797. /package/dist/{plugins-allowlist-BbTQ5Z2k.js → plugins-allowlist-Bvd3WXPX.js} +0 -0
  798. /package/dist/{plugins-allowlist-C20oaESO.js → plugins-allowlist-DyoGDzwZ.js} +0 -0
  799. /package/dist/{polls-B0CCBDeR.js → polls-DXd67TD8.js} +0 -0
  800. /package/dist/{ports-lsof-Wteul3ju.js → ports-lsof-BNQJW1Qu.js} +0 -0
  801. /package/dist/{program-context-jqeI5alP.js → program-context-DpJ5udOA.js} +0 -0
  802. /package/dist/{progress-C1kUfYL-.js → progress-Dvx-ExOb.js} +0 -0
  803. /package/dist/{prompt-Yn2yClg1.js → prompt-DRT7xYvH.js} +0 -0
  804. /package/dist/{prompt-BVZVovoB.js → prompt-YAKpM1vg.js} +0 -0
  805. /package/dist/{prompt-style-D0LUnqXi.js → prompt-style-BsR0RICZ.js} +0 -0
  806. /package/dist/{prompt-style-DjEYC_s-.js → prompt-style-inF3A_oX.js} +0 -0
  807. /package/dist/{proxy-DL3MD6-P.js → proxy-GJkoUC6V.js} +0 -0
  808. /package/dist/{proxy-DpNv2cSV.js → proxy-yk1Oqe9p.js} +0 -0
  809. /package/dist/{push-apns-DuG95AKC.js → push-apns-Ak1TkhPj.js} +0 -0
  810. /package/dist/{pw-ai-state-CGfLv6nV.js → pw-ai-state-D2Fjn4L6.js} +0 -0
  811. /package/dist/{pw-ai-state-Dynx20hr.js → pw-ai-state-Ds_-5nzI.js} +0 -0
  812. /package/dist/{redact-identifier-CAagcfWA.js → redact-identifier-CKA9ZTIc.js} +0 -0
  813. /package/dist/{remoteclaw-root-DybYl8PL.js → remoteclaw-root-BbqPSH6q.js} +0 -0
  814. /package/dist/{remoteclaw-root-C2HV2VeC.js → remoteclaw-root-dHyfh_2E.js} +0 -0
  815. /package/dist/{render-CCLsW6Lz.js → render-CUAKPmvZ.js} +0 -0
  816. /package/dist/{retry-DnqPAqWp.js → retry-0uBjohL-.js} +0 -0
  817. /package/dist/{retry-CxXVRdes.js → retry-BbVJvOUo.js} +0 -0
  818. /package/dist/{runtime-DJNp29jv.js → runtime-Ds3E9SqF.js} +0 -0
  819. /package/dist/{runtime-guard-U-ewY_QH.js → runtime-guard-Dw19MuxF.js} +0 -0
  820. /package/dist/{secret-equal-BbHdTtqY.js → secret-equal-DgjJcvjv.js} +0 -0
  821. /package/dist/{secure-random-CS2mSdTn.js → secure-random-Bla7VjVG.js} +0 -0
  822. /package/dist/{session-DBL5nHDy.js → session-C7PLQQMA.js} +0 -0
  823. /package/dist/{stagger-BXv_apuy.js → stagger-Cu9_3JD_.js} +0 -0
  824. /package/dist/{stagger-MI9gd2rQ.js → stagger-NmUOU1S6.js} +0 -0
  825. /package/dist/{status-BmtCS3T1.js → status-BNw-xk6B.js} +0 -0
  826. /package/dist/{status-BrwHRn2B.js → status-D98glect.js} +0 -0
  827. /package/dist/{store-BPZo49zT.js → store-CmRidfgp.js} +0 -0
  828. /package/dist/{store-v3P-OWhi.js → store-oxFp4Iqf.js} +0 -0
  829. /package/dist/{strip-inbound-meta-jy3bkUab.js → strip-inbound-meta-B21Qdh8I.js} +0 -0
  830. /package/dist/{subsystem-CDhxwtDd.js → subsystem-SgROXN1v.js} +0 -0
  831. /package/dist/{table-C1rdyYl9.js → table-DhGVhmP-.js} +0 -0
  832. /package/dist/{tailnet-PnMrjwGT.js → tailnet-wUV6epIk.js} +0 -0
  833. /package/dist/{tailscale-Dbyahx0J.js → tailscale-DAa9lokU.js} +0 -0
  834. /package/dist/{target-errors-BDpPcwh5.js → target-errors-BDipwemU.js} +0 -0
  835. /package/dist/{targets-C-2xwh9f.js → targets-DfXObWaL.js} +0 -0
  836. /package/dist/{targets-UncQvCVs.js → targets-PM39J-YL.js} +0 -0
  837. /package/dist/{text-format-BQ3z_OXA.js → text-format-CFm4X8Ze.js} +0 -0
  838. /package/dist/{text-format-oWqzVmah.js → text-format-Cy1bnk2A.js} +0 -0
  839. /package/dist/{tool-display-B-nr7cSF.js → tool-display-BAIuLbtW.js} +0 -0
  840. /package/dist/{trash-DPi0aCCQ.js → trash-BS86zpVy.js} +0 -0
  841. /package/dist/{usage-BdhBT0Vz.js → usage-BvSX010R.js} +0 -0
  842. /package/dist/{usage-format-C3mNLfhI.js → usage-format-C6Iz_Ws9.js} +0 -0
  843. /package/dist/{usage-format-DAaPzr_z.js → usage-format-CHBrzgvG.js} +0 -0
  844. /package/dist/{usage-BtQcAnf6.js → usage-sF5tij7A.js} +0 -0
  845. /package/dist/{widearea-dns-CsmBVbez.js → widearea-dns-CsqvX85g.js} +0 -0
  846. /package/dist/{widearea-dns-BXGCmXnD.js → widearea-dns-DtACcM7M.js} +0 -0
  847. /package/dist/{workspace-BzPeZDew.js → workspace-DpbQppPf.js} +0 -0
  848. /package/dist/{wsl-B_sPlzWw.js → wsl-B5ccPr42.js} +0 -0
  849. /package/dist/{wsl-BCnYV9O0.js → wsl-BJW8nTyL.js} +0 -0
@@ -1,2294 +0,0 @@
1
- import { Mt as resolvePreferredRemoteClawTmpDir, ht as logVerbose, vt as shouldLogVerbose } from "./entry.js";
2
- import { a as ensureAuthProfileStore, d as normalizeSecretInput, f as resolveAuthProfileDisplayLabel, l as resolveAuthStorePathForDisplay, n as resolveApiKeyForProfile, r as listProfilesForProvider, u as normalizeOptionalSecretInput } from "./auth-profiles-BquJGKLC.js";
3
- import { t as formatCliCommand } from "./command-format-CVfo8I5f.js";
4
- import { a as normalizeProviderId, r as normalizeGoogleModelId } from "./provider-utils-3JTMJroG.js";
5
- import { a as resolveIMessageAttachmentRoots, i as mergeInboundPathRoots, n as isInboundPathAllowed, s as getShellEnvAppliedKeys, t as DEFAULT_IMESSAGE_ATTACHMENT_ROOTS } from "./inbound-path-policy-sdr5Ji0k.js";
6
- import { t as normalizeChatType } from "./chat-type-CYPyHAj-.js";
7
- import { n as runExec } from "./exec-DkFE7lqU.js";
8
- import { a as isAudioFileName, r as getFileExtension, s as kindFromMime, t as detectMime } from "./mime-Cxh_64P6.js";
9
- import { n as fetchWithTimeout } from "./fetch-timeout-DoySHqfO.js";
10
- import { i as fetchRemoteMedia, n as getDefaultMediaLocalRoots, o as fetchWithSsrFGuard, r as MediaFetchError } from "./local-roots-BrH0Q63K.js";
11
- import { n as formatErrorMessage, r as formatUncaughtError, t as extractErrorCode } from "./errors-DZ199hOo.js";
12
- import process$1 from "node:process";
13
- import { fileURLToPath } from "node:url";
14
- import os, { homedir } from "node:os";
15
- import path, { join } from "node:path";
16
- import { constants, existsSync } from "node:fs";
17
- import fsp, { mkdtemp, rm } from "node:fs/promises";
18
- import crypto from "node:crypto";
19
-
20
- //#region src/auto-reply/templating.ts
21
- function formatTemplateValue(value) {
22
- if (value == null) return "";
23
- if (typeof value === "string") return value;
24
- if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") return String(value);
25
- if (typeof value === "symbol" || typeof value === "function") return value.toString();
26
- if (Array.isArray(value)) return value.flatMap((entry) => {
27
- if (entry == null) return [];
28
- if (typeof entry === "string") return [entry];
29
- if (typeof entry === "number" || typeof entry === "boolean" || typeof entry === "bigint") return [String(entry)];
30
- return [];
31
- }).join(",");
32
- if (typeof value === "object") return "";
33
- return "";
34
- }
35
- function applyTemplate(str, ctx) {
36
- if (!str) return "";
37
- return str.replace(/{{\s*(\w+)\s*}}/g, (_, key) => {
38
- const value = ctx[key];
39
- return formatTemplateValue(value);
40
- });
41
- }
42
-
43
- //#endregion
44
- //#region src/media-understanding/defaults.ts
45
- const MB = 1024 * 1024;
46
- const DEFAULT_MAX_CHARS = 500;
47
- const DEFAULT_MAX_CHARS_BY_CAPABILITY = {
48
- image: DEFAULT_MAX_CHARS,
49
- audio: void 0,
50
- video: DEFAULT_MAX_CHARS
51
- };
52
- const DEFAULT_MAX_BYTES = {
53
- image: 10 * MB,
54
- audio: 20 * MB,
55
- video: 50 * MB
56
- };
57
- const DEFAULT_TIMEOUT_SECONDS = {
58
- image: 60,
59
- audio: 60,
60
- video: 120
61
- };
62
- const DEFAULT_PROMPT = {
63
- image: "Describe the image.",
64
- audio: "Transcribe the audio.",
65
- video: "Describe the video."
66
- };
67
- const DEFAULT_VIDEO_MAX_BASE64_BYTES = 70 * MB;
68
- const DEFAULT_AUDIO_MODELS = {
69
- groq: "whisper-large-v3-turbo",
70
- openai: "gpt-4o-mini-transcribe",
71
- deepgram: "nova-3",
72
- mistral: "voxtral-mini-latest"
73
- };
74
- const AUTO_AUDIO_KEY_PROVIDERS = [
75
- "openai",
76
- "groq",
77
- "deepgram",
78
- "google",
79
- "mistral"
80
- ];
81
- const AUTO_VIDEO_KEY_PROVIDERS = ["google", "moonshot"];
82
- const CLI_OUTPUT_MAX_BUFFER = 5 * MB;
83
- const DEFAULT_MEDIA_CONCURRENCY = 2;
84
-
85
- //#endregion
86
- //#region src/media-understanding/providers/anthropic/index.ts
87
- const anthropicProvider = { id: "anthropic" };
88
-
89
- //#endregion
90
- //#region src/media-understanding/providers/shared.ts
91
- const MAX_ERROR_CHARS = 300;
92
- function normalizeBaseUrl(baseUrl, fallback) {
93
- return (baseUrl?.trim() || fallback).replace(/\/+$/, "");
94
- }
95
- async function fetchWithTimeoutGuarded(url, init, timeoutMs, fetchFn, options) {
96
- return await fetchWithSsrFGuard({
97
- url,
98
- fetchImpl: fetchFn,
99
- init,
100
- timeoutMs,
101
- policy: options?.ssrfPolicy,
102
- lookupFn: options?.lookupFn,
103
- pinDns: options?.pinDns
104
- });
105
- }
106
- async function postTranscriptionRequest(params) {
107
- return fetchWithTimeoutGuarded(params.url, {
108
- method: "POST",
109
- headers: params.headers,
110
- body: params.body
111
- }, params.timeoutMs, params.fetchFn, params.allowPrivateNetwork ? { ssrfPolicy: { allowPrivateNetwork: true } } : void 0);
112
- }
113
- async function readErrorResponse(res) {
114
- try {
115
- const collapsed = (await res.text()).replace(/\s+/g, " ").trim();
116
- if (!collapsed) return;
117
- if (collapsed.length <= MAX_ERROR_CHARS) return collapsed;
118
- return `${collapsed.slice(0, MAX_ERROR_CHARS)}…`;
119
- } catch {
120
- return;
121
- }
122
- }
123
- async function assertOkOrThrowHttpError(res, label) {
124
- if (res.ok) return;
125
- const detail = await readErrorResponse(res);
126
- const suffix = detail ? `: ${detail}` : "";
127
- throw new Error(`${label} (HTTP ${res.status})${suffix}`);
128
- }
129
- function requireTranscriptionText(value, missingMessage) {
130
- const text = value?.trim();
131
- if (!text) throw new Error(missingMessage);
132
- return text;
133
- }
134
-
135
- //#endregion
136
- //#region src/media-understanding/providers/deepgram/audio.ts
137
- const DEFAULT_DEEPGRAM_AUDIO_BASE_URL = "https://api.deepgram.com/v1";
138
- const DEFAULT_DEEPGRAM_AUDIO_MODEL = "nova-3";
139
- function resolveModel$2(model) {
140
- return model?.trim() || DEFAULT_DEEPGRAM_AUDIO_MODEL;
141
- }
142
- async function transcribeDeepgramAudio(params) {
143
- const fetchFn = params.fetchFn ?? fetch;
144
- const baseUrl = normalizeBaseUrl(params.baseUrl, DEFAULT_DEEPGRAM_AUDIO_BASE_URL);
145
- const allowPrivate = Boolean(params.baseUrl?.trim());
146
- const model = resolveModel$2(params.model);
147
- const url = new URL(`${baseUrl}/listen`);
148
- url.searchParams.set("model", model);
149
- if (params.language?.trim()) url.searchParams.set("language", params.language.trim());
150
- if (params.query) for (const [key, value] of Object.entries(params.query)) {
151
- if (value === void 0) continue;
152
- url.searchParams.set(key, String(value));
153
- }
154
- const headers = new Headers(params.headers);
155
- if (!headers.has("authorization")) headers.set("authorization", `Token ${params.apiKey}`);
156
- if (!headers.has("content-type")) headers.set("content-type", params.mime ?? "application/octet-stream");
157
- const body = new Uint8Array(params.buffer);
158
- const { response: res, release } = await postTranscriptionRequest({
159
- url: url.toString(),
160
- headers,
161
- body,
162
- timeoutMs: params.timeoutMs,
163
- fetchFn,
164
- allowPrivateNetwork: allowPrivate
165
- });
166
- try {
167
- await assertOkOrThrowHttpError(res, "Audio transcription failed");
168
- return {
169
- text: requireTranscriptionText((await res.json()).results?.channels?.[0]?.alternatives?.[0]?.transcript, "Audio transcription response missing transcript"),
170
- model
171
- };
172
- } finally {
173
- await release();
174
- }
175
- }
176
-
177
- //#endregion
178
- //#region src/media-understanding/providers/deepgram/index.ts
179
- const deepgramProvider = {
180
- id: "deepgram",
181
- capabilities: ["audio"],
182
- transcribeAudio: transcribeDeepgramAudio
183
- };
184
-
185
- //#endregion
186
- //#region src/infra/gemini-auth.ts
187
- /**
188
- * Shared Gemini authentication utilities.
189
- *
190
- * Supports both traditional API keys and OAuth JSON format.
191
- */
192
- /**
193
- * Parse Gemini API key and return appropriate auth headers.
194
- *
195
- * OAuth format: `{"token": "...", "projectId": "..."}`
196
- *
197
- * @param apiKey - Either a traditional API key string or OAuth JSON
198
- * @returns Headers object with appropriate authentication
199
- */
200
- function parseGeminiAuth(apiKey) {
201
- if (apiKey.startsWith("{")) try {
202
- const parsed = JSON.parse(apiKey);
203
- if (typeof parsed.token === "string" && parsed.token) return { headers: {
204
- Authorization: `Bearer ${parsed.token}`,
205
- "Content-Type": "application/json"
206
- } };
207
- } catch {}
208
- return { headers: {
209
- "x-goog-api-key": apiKey,
210
- "Content-Type": "application/json"
211
- } };
212
- }
213
-
214
- //#endregion
215
- //#region src/media-understanding/providers/google/inline-data.ts
216
- async function generateGeminiInlineDataText(params) {
217
- const fetchFn = params.fetchFn ?? fetch;
218
- const baseUrl = normalizeBaseUrl(params.baseUrl, params.defaultBaseUrl);
219
- const allowPrivate = Boolean(params.baseUrl?.trim());
220
- const model = (() => {
221
- const trimmed = params.model?.trim();
222
- if (!trimmed) return params.defaultModel;
223
- return normalizeGoogleModelId(trimmed);
224
- })();
225
- const url = `${baseUrl}/models/${model}:generateContent`;
226
- const authHeaders = parseGeminiAuth(params.apiKey);
227
- const headers = new Headers(params.headers);
228
- for (const [key, value] of Object.entries(authHeaders.headers)) if (!headers.has(key)) headers.set(key, value);
229
- const body = { contents: [{
230
- role: "user",
231
- parts: [{ text: params.prompt?.trim() || params.defaultPrompt }, { inline_data: {
232
- mime_type: params.mime ?? params.defaultMime,
233
- data: params.buffer.toString("base64")
234
- } }]
235
- }] };
236
- const { response: res, release } = await fetchWithTimeoutGuarded(url, {
237
- method: "POST",
238
- headers,
239
- body: JSON.stringify(body)
240
- }, params.timeoutMs, fetchFn, allowPrivate ? { ssrfPolicy: { allowPrivateNetwork: true } } : void 0);
241
- try {
242
- await assertOkOrThrowHttpError(res, params.httpErrorLabel);
243
- const text = ((await res.json()).candidates?.[0]?.content?.parts ?? []).map((part) => part?.text?.trim()).filter(Boolean).join("\n");
244
- if (!text) throw new Error(params.missingTextError);
245
- return {
246
- text,
247
- model
248
- };
249
- } finally {
250
- await release();
251
- }
252
- }
253
-
254
- //#endregion
255
- //#region src/media-understanding/providers/google/audio.ts
256
- const DEFAULT_GOOGLE_AUDIO_BASE_URL = "https://generativelanguage.googleapis.com/v1beta";
257
- const DEFAULT_GOOGLE_AUDIO_MODEL = "gemini-3-flash-preview";
258
- const DEFAULT_GOOGLE_AUDIO_PROMPT = "Transcribe the audio.";
259
- async function transcribeGeminiAudio(params) {
260
- const { text, model } = await generateGeminiInlineDataText({
261
- ...params,
262
- defaultBaseUrl: DEFAULT_GOOGLE_AUDIO_BASE_URL,
263
- defaultModel: DEFAULT_GOOGLE_AUDIO_MODEL,
264
- defaultPrompt: DEFAULT_GOOGLE_AUDIO_PROMPT,
265
- defaultMime: "audio/wav",
266
- httpErrorLabel: "Audio transcription failed",
267
- missingTextError: "Audio transcription response missing text"
268
- });
269
- return {
270
- text,
271
- model
272
- };
273
- }
274
-
275
- //#endregion
276
- //#region src/media-understanding/providers/google/video.ts
277
- const DEFAULT_GOOGLE_VIDEO_BASE_URL = "https://generativelanguage.googleapis.com/v1beta";
278
- const DEFAULT_GOOGLE_VIDEO_MODEL = "gemini-3-flash-preview";
279
- const DEFAULT_GOOGLE_VIDEO_PROMPT = "Describe the video.";
280
- async function describeGeminiVideo(params) {
281
- const { text, model } = await generateGeminiInlineDataText({
282
- ...params,
283
- defaultBaseUrl: DEFAULT_GOOGLE_VIDEO_BASE_URL,
284
- defaultModel: DEFAULT_GOOGLE_VIDEO_MODEL,
285
- defaultPrompt: DEFAULT_GOOGLE_VIDEO_PROMPT,
286
- defaultMime: "video/mp4",
287
- httpErrorLabel: "Video description failed",
288
- missingTextError: "Video description response missing text"
289
- });
290
- return {
291
- text,
292
- model
293
- };
294
- }
295
-
296
- //#endregion
297
- //#region src/media-understanding/providers/google/index.ts
298
- const googleProvider = {
299
- id: "google",
300
- capabilities: ["audio", "video"],
301
- transcribeAudio: transcribeGeminiAudio,
302
- describeVideo: describeGeminiVideo
303
- };
304
-
305
- //#endregion
306
- //#region src/media-understanding/providers/openai/audio.ts
307
- const DEFAULT_OPENAI_AUDIO_BASE_URL = "https://api.openai.com/v1";
308
- const DEFAULT_OPENAI_AUDIO_MODEL = "gpt-4o-mini-transcribe";
309
- function resolveModel$1(model) {
310
- return model?.trim() || DEFAULT_OPENAI_AUDIO_MODEL;
311
- }
312
- async function transcribeOpenAiCompatibleAudio(params) {
313
- const fetchFn = params.fetchFn ?? fetch;
314
- const baseUrl = normalizeBaseUrl(params.baseUrl, DEFAULT_OPENAI_AUDIO_BASE_URL);
315
- const allowPrivate = Boolean(params.baseUrl?.trim());
316
- const url = `${baseUrl}/audio/transcriptions`;
317
- const model = resolveModel$1(params.model);
318
- const form = new FormData();
319
- const fileName = params.fileName?.trim() || path.basename(params.fileName) || "audio";
320
- const bytes = new Uint8Array(params.buffer);
321
- const blob = new Blob([bytes], { type: params.mime ?? "application/octet-stream" });
322
- form.append("file", blob, fileName);
323
- form.append("model", model);
324
- if (params.language?.trim()) form.append("language", params.language.trim());
325
- if (params.prompt?.trim()) form.append("prompt", params.prompt.trim());
326
- const headers = new Headers(params.headers);
327
- if (!headers.has("authorization")) headers.set("authorization", `Bearer ${params.apiKey}`);
328
- const { response: res, release } = await postTranscriptionRequest({
329
- url,
330
- headers,
331
- body: form,
332
- timeoutMs: params.timeoutMs,
333
- fetchFn,
334
- allowPrivateNetwork: allowPrivate
335
- });
336
- try {
337
- await assertOkOrThrowHttpError(res, "Audio transcription failed");
338
- return {
339
- text: requireTranscriptionText((await res.json()).text, "Audio transcription response missing text"),
340
- model
341
- };
342
- } finally {
343
- await release();
344
- }
345
- }
346
-
347
- //#endregion
348
- //#region src/media-understanding/providers/groq/index.ts
349
- const DEFAULT_GROQ_AUDIO_BASE_URL = "https://api.groq.com/openai/v1";
350
- const groqProvider = {
351
- id: "groq",
352
- capabilities: ["audio"],
353
- transcribeAudio: (req) => transcribeOpenAiCompatibleAudio({
354
- ...req,
355
- baseUrl: req.baseUrl ?? DEFAULT_GROQ_AUDIO_BASE_URL
356
- })
357
- };
358
-
359
- //#endregion
360
- //#region src/media-understanding/providers/minimax/index.ts
361
- const minimaxProvider = { id: "minimax" };
362
-
363
- //#endregion
364
- //#region src/media-understanding/providers/mistral/index.ts
365
- const DEFAULT_MISTRAL_AUDIO_BASE_URL = "https://api.mistral.ai/v1";
366
- const mistralProvider = {
367
- id: "mistral",
368
- capabilities: ["audio"],
369
- transcribeAudio: (req) => transcribeOpenAiCompatibleAudio({
370
- ...req,
371
- baseUrl: req.baseUrl ?? DEFAULT_MISTRAL_AUDIO_BASE_URL
372
- })
373
- };
374
-
375
- //#endregion
376
- //#region src/media-understanding/providers/moonshot/video.ts
377
- const DEFAULT_MOONSHOT_VIDEO_BASE_URL = "https://api.moonshot.ai/v1";
378
- const DEFAULT_MOONSHOT_VIDEO_MODEL = "kimi-k2.5";
379
- const DEFAULT_MOONSHOT_VIDEO_PROMPT = "Describe the video.";
380
- function resolveModel(model) {
381
- return model?.trim() || DEFAULT_MOONSHOT_VIDEO_MODEL;
382
- }
383
- function resolvePrompt$1(prompt) {
384
- return prompt?.trim() || DEFAULT_MOONSHOT_VIDEO_PROMPT;
385
- }
386
- function coerceMoonshotText(payload) {
387
- const message = payload.choices?.[0]?.message;
388
- if (!message) return null;
389
- if (typeof message.content === "string" && message.content.trim()) return message.content.trim();
390
- if (Array.isArray(message.content)) {
391
- const text = message.content.map((part) => typeof part.text === "string" ? part.text.trim() : "").filter(Boolean).join("\n").trim();
392
- if (text) return text;
393
- }
394
- if (typeof message.reasoning_content === "string" && message.reasoning_content.trim()) return message.reasoning_content.trim();
395
- return null;
396
- }
397
- async function describeMoonshotVideo(params) {
398
- const fetchFn = params.fetchFn ?? fetch;
399
- const baseUrl = normalizeBaseUrl(params.baseUrl, DEFAULT_MOONSHOT_VIDEO_BASE_URL);
400
- const model = resolveModel(params.model);
401
- const mime = params.mime ?? "video/mp4";
402
- const prompt = resolvePrompt$1(params.prompt);
403
- const url = `${baseUrl}/chat/completions`;
404
- const headers = new Headers(params.headers);
405
- if (!headers.has("content-type")) headers.set("content-type", "application/json");
406
- if (!headers.has("authorization")) headers.set("authorization", `Bearer ${params.apiKey}`);
407
- const body = {
408
- model,
409
- messages: [{
410
- role: "user",
411
- content: [{
412
- type: "text",
413
- text: prompt
414
- }, {
415
- type: "video_url",
416
- video_url: { url: `data:${mime};base64,${params.buffer.toString("base64")}` }
417
- }]
418
- }]
419
- };
420
- const { response: res, release } = await fetchWithTimeoutGuarded(url, {
421
- method: "POST",
422
- headers,
423
- body: JSON.stringify(body)
424
- }, params.timeoutMs, fetchFn);
425
- try {
426
- await assertOkOrThrowHttpError(res, "Moonshot video description failed");
427
- const text = coerceMoonshotText(await res.json());
428
- if (!text) throw new Error("Moonshot video description response missing content");
429
- return {
430
- text,
431
- model
432
- };
433
- } finally {
434
- await release();
435
- }
436
- }
437
-
438
- //#endregion
439
- //#region src/media-understanding/providers/moonshot/index.ts
440
- const moonshotProvider = {
441
- id: "moonshot",
442
- capabilities: ["video"],
443
- describeVideo: describeMoonshotVideo
444
- };
445
-
446
- //#endregion
447
- //#region src/media-understanding/providers/openai/index.ts
448
- const openaiProvider = {
449
- id: "openai",
450
- transcribeAudio: transcribeOpenAiCompatibleAudio
451
- };
452
-
453
- //#endregion
454
- //#region src/media-understanding/providers/zai/index.ts
455
- const zaiProvider = { id: "zai" };
456
-
457
- //#endregion
458
- //#region src/media-understanding/providers/index.ts
459
- const PROVIDERS = [
460
- groqProvider,
461
- openaiProvider,
462
- googleProvider,
463
- anthropicProvider,
464
- minimaxProvider,
465
- moonshotProvider,
466
- mistralProvider,
467
- zaiProvider,
468
- deepgramProvider
469
- ];
470
- function normalizeMediaProviderId(id) {
471
- const normalized = normalizeProviderId(id);
472
- if (normalized === "gemini") return "google";
473
- return normalized;
474
- }
475
- function buildMediaUnderstandingRegistry(overrides) {
476
- const registry = /* @__PURE__ */ new Map();
477
- for (const provider of PROVIDERS) registry.set(normalizeMediaProviderId(provider.id), provider);
478
- if (overrides) for (const [key, provider] of Object.entries(overrides)) {
479
- const normalizedKey = normalizeMediaProviderId(key);
480
- const existing = registry.get(normalizedKey);
481
- const merged = existing ? {
482
- ...existing,
483
- ...provider,
484
- capabilities: provider.capabilities ?? existing.capabilities
485
- } : provider;
486
- registry.set(normalizedKey, merged);
487
- }
488
- return registry;
489
- }
490
- function getMediaUnderstandingProvider(id, registry) {
491
- return registry.get(normalizeMediaProviderId(id));
492
- }
493
-
494
- //#endregion
495
- //#region src/media-understanding/scope.ts
496
- function normalizeDecision(value) {
497
- const normalized = value?.trim().toLowerCase();
498
- if (normalized === "allow") return "allow";
499
- if (normalized === "deny") return "deny";
500
- }
501
- function normalizeMatch(value) {
502
- return value?.trim().toLowerCase() || void 0;
503
- }
504
- function normalizeMediaUnderstandingChatType(raw) {
505
- return normalizeChatType(raw ?? void 0);
506
- }
507
- function resolveMediaUnderstandingScope(params) {
508
- const scope = params.scope;
509
- if (!scope) return "allow";
510
- const channel = normalizeMatch(params.channel);
511
- const chatType = normalizeMediaUnderstandingChatType(params.chatType);
512
- const sessionKey = normalizeMatch(params.sessionKey) ?? "";
513
- for (const rule of scope.rules ?? []) {
514
- if (!rule) continue;
515
- const action = normalizeDecision(rule.action) ?? "allow";
516
- const match = rule.match ?? {};
517
- const matchChannel = normalizeMatch(match.channel);
518
- const matchChatType = normalizeMediaUnderstandingChatType(match.chatType);
519
- const matchPrefix = normalizeMatch(match.keyPrefix);
520
- if (matchChannel && matchChannel !== channel) continue;
521
- if (matchChatType && matchChatType !== chatType) continue;
522
- if (matchPrefix && !sessionKey.startsWith(matchPrefix)) continue;
523
- return action;
524
- }
525
- return normalizeDecision(scope.default) ?? "allow";
526
- }
527
-
528
- //#endregion
529
- //#region src/media-understanding/resolve.ts
530
- function resolveTimeoutMs(seconds, fallbackSeconds) {
531
- const value = typeof seconds === "number" && Number.isFinite(seconds) ? seconds : fallbackSeconds;
532
- return Math.max(1e3, Math.floor(value * 1e3));
533
- }
534
- function resolvePrompt(capability, prompt, maxChars) {
535
- const base = prompt?.trim() || DEFAULT_PROMPT[capability];
536
- if (!maxChars || capability === "audio") return base;
537
- return `${base} Respond in at most ${maxChars} characters.`;
538
- }
539
- function resolveMaxChars(params) {
540
- const { capability, entry, cfg } = params;
541
- const configured = entry.maxChars ?? params.config?.maxChars ?? cfg.tools?.media?.[capability]?.maxChars;
542
- if (typeof configured === "number") return configured;
543
- return DEFAULT_MAX_CHARS_BY_CAPABILITY[capability];
544
- }
545
- function resolveMaxBytes(params) {
546
- const configured = params.entry.maxBytes ?? params.config?.maxBytes ?? params.cfg.tools?.media?.[params.capability]?.maxBytes;
547
- if (typeof configured === "number") return configured;
548
- return DEFAULT_MAX_BYTES[params.capability];
549
- }
550
- function resolveScopeDecision(params) {
551
- return resolveMediaUnderstandingScope({
552
- scope: params.scope,
553
- sessionKey: params.ctx.SessionKey,
554
- channel: params.ctx.Surface ?? params.ctx.Provider,
555
- chatType: normalizeMediaUnderstandingChatType(params.ctx.ChatType)
556
- });
557
- }
558
- function resolveEntryCapabilities(params) {
559
- if ((params.entry.type ?? (params.entry.command ? "cli" : "provider")) === "cli") return;
560
- const providerId = normalizeMediaProviderId(params.entry.provider ?? "");
561
- if (!providerId) return;
562
- return params.providerRegistry.get(providerId)?.capabilities;
563
- }
564
- function resolveModelEntries(params) {
565
- const { cfg, capability, config } = params;
566
- const sharedModels = cfg.tools?.media?.models ?? [];
567
- const entries = [...(config?.models ?? []).map((entry) => ({
568
- entry,
569
- source: "capability"
570
- })), ...sharedModels.map((entry) => ({
571
- entry,
572
- source: "shared"
573
- }))];
574
- if (entries.length === 0) return [];
575
- return entries.filter(({ entry, source }) => {
576
- const caps = entry.capabilities && entry.capabilities.length > 0 ? entry.capabilities : source === "shared" ? resolveEntryCapabilities({
577
- entry,
578
- providerRegistry: params.providerRegistry
579
- }) : void 0;
580
- if (!caps || caps.length === 0) {
581
- if (source === "shared") {
582
- if (shouldLogVerbose()) logVerbose(`Skipping shared media model without capabilities: ${entry.provider ?? entry.command ?? "unknown"}`);
583
- return false;
584
- }
585
- return true;
586
- }
587
- return caps.includes(capability);
588
- }).map(({ entry }) => entry);
589
- }
590
- function resolveConcurrency(cfg) {
591
- const configured = cfg.tools?.media?.concurrency;
592
- if (typeof configured === "number" && Number.isFinite(configured) && configured > 0) return Math.floor(configured);
593
- return DEFAULT_MEDIA_CONCURRENCY;
594
- }
595
-
596
- //#endregion
597
- //#region src/infra/unhandled-rejections.ts
598
- const handlers = /* @__PURE__ */ new Set();
599
- const FATAL_ERROR_CODES = new Set([
600
- "ERR_OUT_OF_MEMORY",
601
- "ERR_SCRIPT_EXECUTION_TIMEOUT",
602
- "ERR_WORKER_OUT_OF_MEMORY",
603
- "ERR_WORKER_UNCAUGHT_EXCEPTION",
604
- "ERR_WORKER_INITIALIZATION_FAILED"
605
- ]);
606
- const CONFIG_ERROR_CODES = new Set([
607
- "INVALID_CONFIG",
608
- "MISSING_API_KEY",
609
- "MISSING_CREDENTIALS"
610
- ]);
611
- const TRANSIENT_NETWORK_CODES = new Set([
612
- "ECONNRESET",
613
- "ECONNREFUSED",
614
- "ENOTFOUND",
615
- "ETIMEDOUT",
616
- "ESOCKETTIMEDOUT",
617
- "ECONNABORTED",
618
- "EPIPE",
619
- "EHOSTUNREACH",
620
- "ENETUNREACH",
621
- "EAI_AGAIN",
622
- "UND_ERR_CONNECT_TIMEOUT",
623
- "UND_ERR_DNS_RESOLVE_FAILED",
624
- "UND_ERR_CONNECT",
625
- "UND_ERR_SOCKET",
626
- "UND_ERR_HEADERS_TIMEOUT",
627
- "UND_ERR_BODY_TIMEOUT"
628
- ]);
629
- const TRANSIENT_NETWORK_ERROR_NAMES = new Set([
630
- "AbortError",
631
- "ConnectTimeoutError",
632
- "HeadersTimeoutError",
633
- "BodyTimeoutError",
634
- "TimeoutError"
635
- ]);
636
- const TRANSIENT_NETWORK_MESSAGE_CODE_RE = /\b(ECONNRESET|ECONNREFUSED|ENOTFOUND|ETIMEDOUT|ESOCKETTIMEDOUT|ECONNABORTED|EPIPE|EHOSTUNREACH|ENETUNREACH|EAI_AGAIN|UND_ERR_CONNECT_TIMEOUT|UND_ERR_DNS_RESOLVE_FAILED|UND_ERR_CONNECT|UND_ERR_SOCKET|UND_ERR_HEADERS_TIMEOUT|UND_ERR_BODY_TIMEOUT)\b/i;
637
- const TRANSIENT_NETWORK_MESSAGE_SNIPPETS = [
638
- "getaddrinfo",
639
- "socket hang up",
640
- "network error",
641
- "network is unreachable",
642
- "temporary failure in name resolution"
643
- ];
644
- function getErrorCause(err) {
645
- if (!err || typeof err !== "object") return;
646
- return err.cause;
647
- }
648
- function getErrorName(err) {
649
- if (!err || typeof err !== "object") return "";
650
- const name = err.name;
651
- return typeof name === "string" ? name : "";
652
- }
653
- function extractErrorCodeOrErrno(err) {
654
- const code = extractErrorCode(err);
655
- if (code) return code.trim().toUpperCase();
656
- if (!err || typeof err !== "object") return;
657
- const errno = err.errno;
658
- if (typeof errno === "string" && errno.trim()) return errno.trim().toUpperCase();
659
- if (typeof errno === "number" && Number.isFinite(errno)) return String(errno);
660
- }
661
- function extractErrorCodeWithCause(err) {
662
- const direct = extractErrorCode(err);
663
- if (direct) return direct;
664
- return extractErrorCode(getErrorCause(err));
665
- }
666
- function collectErrorCandidates(err) {
667
- const queue = [err];
668
- const seen = /* @__PURE__ */ new Set();
669
- const candidates = [];
670
- while (queue.length > 0) {
671
- const current = queue.shift();
672
- if (current == null || seen.has(current)) continue;
673
- seen.add(current);
674
- candidates.push(current);
675
- if (!current || typeof current !== "object") continue;
676
- const maybeNested = [
677
- current.cause,
678
- current.reason,
679
- current.original,
680
- current.error,
681
- current.data
682
- ];
683
- const errors = current.errors;
684
- if (Array.isArray(errors)) maybeNested.push(...errors);
685
- for (const nested of maybeNested) if (nested != null && !seen.has(nested)) queue.push(nested);
686
- }
687
- return candidates;
688
- }
689
- /**
690
- * Checks if an error is an AbortError.
691
- * These are typically intentional cancellations (e.g., during shutdown) and shouldn't crash.
692
- */
693
- function isAbortError(err) {
694
- if (!err || typeof err !== "object") return false;
695
- if (("name" in err ? String(err.name) : "") === "AbortError") return true;
696
- if (("message" in err && typeof err.message === "string" ? err.message : "") === "This operation was aborted") return true;
697
- return false;
698
- }
699
- function isFatalError(err) {
700
- const code = extractErrorCodeWithCause(err);
701
- return code !== void 0 && FATAL_ERROR_CODES.has(code);
702
- }
703
- function isConfigError(err) {
704
- const code = extractErrorCodeWithCause(err);
705
- return code !== void 0 && CONFIG_ERROR_CODES.has(code);
706
- }
707
- /**
708
- * Checks if an error is a transient network error that shouldn't crash the gateway.
709
- * These are typically temporary connectivity issues that will resolve on their own.
710
- */
711
- function isTransientNetworkError(err) {
712
- if (!err) return false;
713
- for (const candidate of collectErrorCandidates(err)) {
714
- const code = extractErrorCodeOrErrno(candidate);
715
- if (code && TRANSIENT_NETWORK_CODES.has(code)) return true;
716
- const name = getErrorName(candidate);
717
- if (name && TRANSIENT_NETWORK_ERROR_NAMES.has(name)) return true;
718
- if (candidate instanceof TypeError && candidate.message === "fetch failed") return true;
719
- if (!candidate || typeof candidate !== "object") continue;
720
- const rawMessage = candidate.message;
721
- const message = typeof rawMessage === "string" ? rawMessage.toLowerCase().trim() : "";
722
- if (!message) continue;
723
- if (TRANSIENT_NETWORK_MESSAGE_CODE_RE.test(message)) return true;
724
- if (message === "fetch failed") return true;
725
- if (TRANSIENT_NETWORK_MESSAGE_SNIPPETS.some((snippet) => message.includes(snippet))) return true;
726
- }
727
- return false;
728
- }
729
- function registerUnhandledRejectionHandler(handler) {
730
- handlers.add(handler);
731
- return () => {
732
- handlers.delete(handler);
733
- };
734
- }
735
- function isUnhandledRejectionHandled(reason) {
736
- for (const handler of handlers) try {
737
- if (handler(reason)) return true;
738
- } catch (err) {
739
- console.error("[remoteclaw] Unhandled rejection handler failed:", err instanceof Error ? err.stack ?? err.message : err);
740
- }
741
- return false;
742
- }
743
- function installUnhandledRejectionHandler() {
744
- process$1.on("unhandledRejection", (reason, _promise) => {
745
- if (isUnhandledRejectionHandled(reason)) return;
746
- if (isAbortError(reason)) {
747
- console.warn("[remoteclaw] Suppressed AbortError:", formatUncaughtError(reason));
748
- return;
749
- }
750
- if (isFatalError(reason)) {
751
- console.error("[remoteclaw] FATAL unhandled rejection:", formatUncaughtError(reason));
752
- process$1.exit(1);
753
- return;
754
- }
755
- if (isConfigError(reason)) {
756
- console.error("[remoteclaw] CONFIGURATION ERROR - requires fix:", formatUncaughtError(reason));
757
- process$1.exit(1);
758
- return;
759
- }
760
- if (isTransientNetworkError(reason)) {
761
- console.warn("[remoteclaw] Non-fatal unhandled rejection (continuing):", formatUncaughtError(reason));
762
- return;
763
- }
764
- console.error("[remoteclaw] Unhandled promise rejection:", formatUncaughtError(reason));
765
- process$1.exit(1);
766
- });
767
- }
768
-
769
- //#endregion
770
- //#region src/plugin-sdk/temp-path.ts
771
- function sanitizePrefix(prefix) {
772
- return prefix.replace(/[^a-zA-Z0-9_-]+/g, "-").replace(/^-+|-+$/g, "") || "tmp";
773
- }
774
- function sanitizeExtension(extension) {
775
- if (!extension) return "";
776
- const token = ((extension.startsWith(".") ? extension : `.${extension}`).match(/[a-zA-Z0-9._-]+$/)?.[0] ?? "").replace(/^[._-]+/, "");
777
- if (!token) return "";
778
- return `.${token}`;
779
- }
780
- function resolveTempRoot(tmpDir) {
781
- return tmpDir ?? resolvePreferredRemoteClawTmpDir();
782
- }
783
- function buildRandomTempFilePath(params) {
784
- const prefix = sanitizePrefix(params.prefix);
785
- const extension = sanitizeExtension(params.extension);
786
- const nowCandidate = params.now;
787
- const now = typeof nowCandidate === "number" && Number.isFinite(nowCandidate) ? Math.trunc(nowCandidate) : Date.now();
788
- const uuid = params.uuid?.trim() || crypto.randomUUID();
789
- return path.join(resolveTempRoot(params.tmpDir), `${prefix}-${now}-${uuid}${extension}`);
790
- }
791
-
792
- //#endregion
793
- //#region src/media-understanding/errors.ts
794
- var MediaUnderstandingSkipError = class extends Error {
795
- constructor(reason, message) {
796
- super(message);
797
- this.reason = reason;
798
- this.name = "MediaUnderstandingSkipError";
799
- }
800
- };
801
- function isMediaUnderstandingSkipError(err) {
802
- return err instanceof MediaUnderstandingSkipError;
803
- }
804
-
805
- //#endregion
806
- //#region src/media-understanding/attachments.ts
807
- const DEFAULT_MAX_ATTACHMENTS = 1;
808
- const DEFAULT_LOCAL_PATH_ROOTS = mergeInboundPathRoots(getDefaultMediaLocalRoots(), DEFAULT_IMESSAGE_ATTACHMENT_ROOTS);
809
- function normalizeAttachmentPath(raw) {
810
- const value = raw?.trim();
811
- if (!value) return;
812
- if (value.startsWith("file://")) try {
813
- return fileURLToPath(value);
814
- } catch {
815
- return;
816
- }
817
- return value;
818
- }
819
- function normalizeAttachments(ctx) {
820
- const pathsFromArray = Array.isArray(ctx.MediaPaths) ? ctx.MediaPaths : void 0;
821
- const urlsFromArray = Array.isArray(ctx.MediaUrls) ? ctx.MediaUrls : void 0;
822
- const typesFromArray = Array.isArray(ctx.MediaTypes) ? ctx.MediaTypes : void 0;
823
- const resolveMime = (count, index) => {
824
- const typeHint = typesFromArray?.[index];
825
- const trimmed = typeof typeHint === "string" ? typeHint.trim() : "";
826
- if (trimmed) return trimmed;
827
- return count === 1 ? ctx.MediaType : void 0;
828
- };
829
- if (pathsFromArray && pathsFromArray.length > 0) {
830
- const count = pathsFromArray.length;
831
- const urls = urlsFromArray && urlsFromArray.length > 0 ? urlsFromArray : void 0;
832
- return pathsFromArray.map((value, index) => ({
833
- path: value?.trim() || void 0,
834
- url: urls?.[index] ?? ctx.MediaUrl,
835
- mime: resolveMime(count, index),
836
- index
837
- })).filter((entry) => Boolean(entry.path?.trim() || entry.url?.trim()));
838
- }
839
- if (urlsFromArray && urlsFromArray.length > 0) {
840
- const count = urlsFromArray.length;
841
- return urlsFromArray.map((value, index) => ({
842
- path: void 0,
843
- url: value?.trim() || void 0,
844
- mime: resolveMime(count, index),
845
- index
846
- })).filter((entry) => Boolean(entry.url?.trim()));
847
- }
848
- const pathValue = ctx.MediaPath?.trim();
849
- const url = ctx.MediaUrl?.trim();
850
- if (!pathValue && !url) return [];
851
- return [{
852
- path: pathValue || void 0,
853
- url: url || void 0,
854
- mime: ctx.MediaType,
855
- index: 0
856
- }];
857
- }
858
- function resolveAttachmentKind(attachment) {
859
- const kind = kindFromMime(attachment.mime);
860
- if (kind === "image" || kind === "audio" || kind === "video") return kind;
861
- const ext = getFileExtension(attachment.path ?? attachment.url);
862
- if (!ext) return "unknown";
863
- if ([
864
- ".mp4",
865
- ".mov",
866
- ".mkv",
867
- ".webm",
868
- ".avi",
869
- ".m4v"
870
- ].includes(ext)) return "video";
871
- if (isAudioFileName(attachment.path ?? attachment.url)) return "audio";
872
- if ([
873
- ".png",
874
- ".jpg",
875
- ".jpeg",
876
- ".webp",
877
- ".gif",
878
- ".bmp",
879
- ".tiff",
880
- ".tif"
881
- ].includes(ext)) return "image";
882
- return "unknown";
883
- }
884
- function isVideoAttachment(attachment) {
885
- return resolveAttachmentKind(attachment) === "video";
886
- }
887
- function isAudioAttachment(attachment) {
888
- return resolveAttachmentKind(attachment) === "audio";
889
- }
890
- function isImageAttachment(attachment) {
891
- return resolveAttachmentKind(attachment) === "image";
892
- }
893
- function resolveRequestUrl(input) {
894
- if (typeof input === "string") return input;
895
- if (input instanceof URL) return input.toString();
896
- return input.url;
897
- }
898
- function orderAttachments(attachments, prefer) {
899
- if (!prefer || prefer === "first") return attachments;
900
- if (prefer === "last") return [...attachments].toReversed();
901
- if (prefer === "path") {
902
- const withPath = attachments.filter((item) => item.path);
903
- const withoutPath = attachments.filter((item) => !item.path);
904
- return [...withPath, ...withoutPath];
905
- }
906
- if (prefer === "url") {
907
- const withUrl = attachments.filter((item) => item.url);
908
- const withoutUrl = attachments.filter((item) => !item.url);
909
- return [...withUrl, ...withoutUrl];
910
- }
911
- return attachments;
912
- }
913
- function selectAttachments(params) {
914
- const { capability, attachments, policy } = params;
915
- const matches = attachments.filter((item) => {
916
- if (capability === "audio" && item.alreadyTranscribed) return false;
917
- if (capability === "image") return isImageAttachment(item);
918
- if (capability === "audio") return isAudioAttachment(item);
919
- return isVideoAttachment(item);
920
- });
921
- if (matches.length === 0) return [];
922
- const ordered = orderAttachments(matches, policy?.prefer);
923
- const mode = policy?.mode ?? "first";
924
- const maxAttachments = policy?.maxAttachments ?? DEFAULT_MAX_ATTACHMENTS;
925
- if (mode === "all") return ordered.slice(0, Math.max(1, maxAttachments));
926
- return ordered.slice(0, 1);
927
- }
928
- var MediaAttachmentCache = class {
929
- constructor(attachments, options) {
930
- this.entries = /* @__PURE__ */ new Map();
931
- this.attachments = attachments;
932
- this.localPathRoots = mergeInboundPathRoots(options?.localPathRoots, DEFAULT_LOCAL_PATH_ROOTS);
933
- for (const attachment of attachments) this.entries.set(attachment.index, { attachment });
934
- }
935
- async getBuffer(params) {
936
- const entry = await this.ensureEntry(params.attachmentIndex);
937
- if (entry.buffer) {
938
- if (entry.buffer.length > params.maxBytes) throw new MediaUnderstandingSkipError("maxBytes", `Attachment ${params.attachmentIndex + 1} exceeds maxBytes ${params.maxBytes}`);
939
- return {
940
- buffer: entry.buffer,
941
- mime: entry.bufferMime,
942
- fileName: entry.bufferFileName ?? `media-${params.attachmentIndex + 1}`,
943
- size: entry.buffer.length
944
- };
945
- }
946
- if (entry.resolvedPath) {
947
- const size = await this.ensureLocalStat(entry);
948
- if (entry.resolvedPath) {
949
- if (size !== void 0 && size > params.maxBytes) throw new MediaUnderstandingSkipError("maxBytes", `Attachment ${params.attachmentIndex + 1} exceeds maxBytes ${params.maxBytes}`);
950
- const buffer = await fsp.readFile(entry.resolvedPath);
951
- entry.buffer = buffer;
952
- entry.bufferMime = entry.bufferMime ?? entry.attachment.mime ?? await detectMime({
953
- buffer,
954
- filePath: entry.resolvedPath
955
- });
956
- entry.bufferFileName = path.basename(entry.resolvedPath) || `media-${params.attachmentIndex + 1}`;
957
- return {
958
- buffer,
959
- mime: entry.bufferMime,
960
- fileName: entry.bufferFileName,
961
- size: buffer.length
962
- };
963
- }
964
- }
965
- const url = entry.attachment.url?.trim();
966
- if (!url) throw new MediaUnderstandingSkipError("empty", `Attachment ${params.attachmentIndex + 1} has no path or URL.`);
967
- try {
968
- const fetchImpl = (input, init) => fetchWithTimeout(resolveRequestUrl(input), init ?? {}, params.timeoutMs, fetch);
969
- const fetched = await fetchRemoteMedia({
970
- url,
971
- fetchImpl,
972
- maxBytes: params.maxBytes
973
- });
974
- entry.buffer = fetched.buffer;
975
- entry.bufferMime = entry.attachment.mime ?? fetched.contentType ?? await detectMime({
976
- buffer: fetched.buffer,
977
- filePath: fetched.fileName ?? url
978
- });
979
- entry.bufferFileName = fetched.fileName ?? `media-${params.attachmentIndex + 1}`;
980
- return {
981
- buffer: fetched.buffer,
982
- mime: entry.bufferMime,
983
- fileName: entry.bufferFileName,
984
- size: fetched.buffer.length
985
- };
986
- } catch (err) {
987
- if (err instanceof MediaFetchError && err.code === "max_bytes") throw new MediaUnderstandingSkipError("maxBytes", `Attachment ${params.attachmentIndex + 1} exceeds maxBytes ${params.maxBytes}`);
988
- if (isAbortError(err)) throw new MediaUnderstandingSkipError("timeout", `Attachment ${params.attachmentIndex + 1} timed out while fetching.`);
989
- throw err;
990
- }
991
- }
992
- async getPath(params) {
993
- const entry = await this.ensureEntry(params.attachmentIndex);
994
- if (entry.resolvedPath) {
995
- if (params.maxBytes) {
996
- const size = await this.ensureLocalStat(entry);
997
- if (entry.resolvedPath) {
998
- if (size !== void 0 && size > params.maxBytes) throw new MediaUnderstandingSkipError("maxBytes", `Attachment ${params.attachmentIndex + 1} exceeds maxBytes ${params.maxBytes}`);
999
- }
1000
- }
1001
- if (entry.resolvedPath) return { path: entry.resolvedPath };
1002
- }
1003
- if (entry.tempPath) {
1004
- if (params.maxBytes && entry.buffer && entry.buffer.length > params.maxBytes) throw new MediaUnderstandingSkipError("maxBytes", `Attachment ${params.attachmentIndex + 1} exceeds maxBytes ${params.maxBytes}`);
1005
- return {
1006
- path: entry.tempPath,
1007
- cleanup: entry.tempCleanup
1008
- };
1009
- }
1010
- const maxBytes = params.maxBytes ?? Number.POSITIVE_INFINITY;
1011
- const bufferResult = await this.getBuffer({
1012
- attachmentIndex: params.attachmentIndex,
1013
- maxBytes,
1014
- timeoutMs: params.timeoutMs
1015
- });
1016
- const tmpPath = buildRandomTempFilePath({
1017
- prefix: "remoteclaw-media",
1018
- extension: path.extname(bufferResult.fileName || "") || ""
1019
- });
1020
- await fsp.writeFile(tmpPath, bufferResult.buffer);
1021
- entry.tempPath = tmpPath;
1022
- entry.tempCleanup = async () => {
1023
- await fsp.unlink(tmpPath).catch(() => {});
1024
- };
1025
- return {
1026
- path: tmpPath,
1027
- cleanup: entry.tempCleanup
1028
- };
1029
- }
1030
- async cleanup() {
1031
- const cleanups = [];
1032
- for (const entry of this.entries.values()) if (entry.tempCleanup) {
1033
- cleanups.push(Promise.resolve(entry.tempCleanup()));
1034
- entry.tempCleanup = void 0;
1035
- }
1036
- await Promise.all(cleanups);
1037
- }
1038
- async ensureEntry(attachmentIndex) {
1039
- const existing = this.entries.get(attachmentIndex);
1040
- if (existing) {
1041
- if (!existing.resolvedPath) existing.resolvedPath = this.resolveLocalPath(existing.attachment);
1042
- return existing;
1043
- }
1044
- const attachment = this.attachments.find((item) => item.index === attachmentIndex) ?? { index: attachmentIndex };
1045
- const entry = {
1046
- attachment,
1047
- resolvedPath: this.resolveLocalPath(attachment)
1048
- };
1049
- this.entries.set(attachmentIndex, entry);
1050
- return entry;
1051
- }
1052
- resolveLocalPath(attachment) {
1053
- const rawPath = normalizeAttachmentPath(attachment.path);
1054
- if (!rawPath) return;
1055
- return path.isAbsolute(rawPath) ? rawPath : path.resolve(rawPath);
1056
- }
1057
- async ensureLocalStat(entry) {
1058
- if (!entry.resolvedPath) return;
1059
- if (!isInboundPathAllowed({
1060
- filePath: entry.resolvedPath,
1061
- roots: this.localPathRoots
1062
- })) {
1063
- entry.resolvedPath = void 0;
1064
- if (shouldLogVerbose()) logVerbose(`Blocked attachment path outside allowed roots: ${entry.attachment.path ?? entry.attachment.url ?? "(unknown)"}`);
1065
- return;
1066
- }
1067
- if (entry.statSize !== void 0) return entry.statSize;
1068
- try {
1069
- const currentPath = entry.resolvedPath;
1070
- const stat = await fsp.stat(currentPath);
1071
- if (!stat.isFile()) {
1072
- entry.resolvedPath = void 0;
1073
- return;
1074
- }
1075
- const canonicalPath = await fsp.realpath(currentPath).catch(() => currentPath);
1076
- if (!isInboundPathAllowed({
1077
- filePath: canonicalPath,
1078
- roots: await this.getCanonicalLocalPathRoots()
1079
- })) {
1080
- entry.resolvedPath = void 0;
1081
- if (shouldLogVerbose()) logVerbose(`Blocked canonicalized attachment path outside allowed roots: ${canonicalPath}`);
1082
- return;
1083
- }
1084
- entry.resolvedPath = canonicalPath;
1085
- entry.statSize = stat.size;
1086
- return stat.size;
1087
- } catch (err) {
1088
- entry.resolvedPath = void 0;
1089
- if (shouldLogVerbose()) logVerbose(`Failed to read attachment ${entry.attachment.index + 1}: ${String(err)}`);
1090
- return;
1091
- }
1092
- }
1093
- async getCanonicalLocalPathRoots() {
1094
- if (this.canonicalLocalPathRoots) return await this.canonicalLocalPathRoots;
1095
- this.canonicalLocalPathRoots = (async () => mergeInboundPathRoots(this.localPathRoots, await Promise.all(this.localPathRoots.map(async (root) => {
1096
- if (root.includes("*")) return root;
1097
- return await fsp.realpath(root).catch(() => root);
1098
- }))))();
1099
- return await this.canonicalLocalPathRoots;
1100
- }
1101
- };
1102
-
1103
- //#endregion
1104
- //#region src/agents/provider-auth.ts
1105
- /**
1106
- * Provider auth resolution extracted from model-auth.ts.
1107
- *
1108
- * Resolves API keys for providers via auth profiles, environment variables,
1109
- * and AWS SDK credential chains. Used by media-understanding, onboarding,
1110
- * and status display.
1111
- */
1112
- const AWS_BEARER_ENV = "AWS_BEARER_TOKEN_BEDROCK";
1113
- const AWS_ACCESS_KEY_ENV = "AWS_ACCESS_KEY_ID";
1114
- const AWS_SECRET_KEY_ENV = "AWS_SECRET_ACCESS_KEY";
1115
- const AWS_PROFILE_ENV = "AWS_PROFILE";
1116
- function resolveEnvSourceLabel(params) {
1117
- return `${params.envVars.some((envVar) => params.applied.has(envVar)) ? "shell env: " : "env: "}${params.label}`;
1118
- }
1119
- function resolveAwsSdkAuthInfo() {
1120
- const applied = new Set(getShellEnvAppliedKeys());
1121
- if (process.env[AWS_BEARER_ENV]?.trim()) return {
1122
- mode: "api-key",
1123
- source: resolveEnvSourceLabel({
1124
- applied,
1125
- envVars: [AWS_BEARER_ENV],
1126
- label: AWS_BEARER_ENV
1127
- })
1128
- };
1129
- if (process.env[AWS_ACCESS_KEY_ENV]?.trim() && process.env[AWS_SECRET_KEY_ENV]?.trim()) return {
1130
- mode: "api-key",
1131
- source: resolveEnvSourceLabel({
1132
- applied,
1133
- envVars: [AWS_ACCESS_KEY_ENV, AWS_SECRET_KEY_ENV],
1134
- label: `${AWS_ACCESS_KEY_ENV} + ${AWS_SECRET_KEY_ENV}`
1135
- })
1136
- };
1137
- if (process.env[AWS_PROFILE_ENV]?.trim()) return {
1138
- mode: "api-key",
1139
- source: resolveEnvSourceLabel({
1140
- applied,
1141
- envVars: [AWS_PROFILE_ENV],
1142
- label: AWS_PROFILE_ENV
1143
- })
1144
- };
1145
- return {
1146
- mode: "api-key",
1147
- source: "aws-sdk default chain"
1148
- };
1149
- }
1150
- function hasVertexAdcCredentials() {
1151
- const gacPath = process.env.GOOGLE_APPLICATION_CREDENTIALS;
1152
- if (gacPath) return existsSync(gacPath);
1153
- return existsSync(join(homedir(), ".config", "gcloud", "application_default_credentials.json"));
1154
- }
1155
- async function resolveApiKeyForProvider(params) {
1156
- const { provider, cfg, profileId } = params;
1157
- const store = params.store ?? ensureAuthProfileStore(params.agentDir);
1158
- if (profileId) {
1159
- const resolved = await resolveApiKeyForProfile({
1160
- cfg,
1161
- store,
1162
- profileId,
1163
- agentDir: params.agentDir
1164
- });
1165
- if (!resolved) throw new Error(`No credentials found for profile "${profileId}".`);
1166
- return {
1167
- apiKey: resolved.apiKey,
1168
- profileId,
1169
- source: `profile:${profileId}`,
1170
- mode: "api-key"
1171
- };
1172
- }
1173
- const profiles = listProfilesForProvider(store, provider);
1174
- const preferred = params.preferredProfile;
1175
- const candidates = preferred && profiles.includes(preferred) ? [preferred, ...profiles.filter((id) => id !== preferred)] : profiles;
1176
- for (const candidate of candidates) try {
1177
- const resolved = await resolveApiKeyForProfile({
1178
- cfg,
1179
- store,
1180
- profileId: candidate,
1181
- agentDir: params.agentDir
1182
- });
1183
- if (resolved) return {
1184
- apiKey: resolved.apiKey,
1185
- profileId: candidate,
1186
- source: `profile:${candidate}`,
1187
- mode: "api-key"
1188
- };
1189
- } catch {}
1190
- const envResolved = resolveEnvApiKey(provider);
1191
- if (envResolved) return {
1192
- apiKey: envResolved.apiKey,
1193
- source: envResolved.source,
1194
- mode: "api-key"
1195
- };
1196
- if (normalizeProviderId(provider) === "amazon-bedrock") return resolveAwsSdkAuthInfo();
1197
- if (provider === "openai") {
1198
- if (listProfilesForProvider(store, "openai-codex").length > 0) throw new Error("No API key found for provider \"openai\". You are authenticated with OpenAI Codex OAuth. Use openai-codex/gpt-5.3-codex (OAuth) or set OPENAI_API_KEY to use openai/gpt-5.1-codex.");
1199
- }
1200
- const authStorePath = resolveAuthStorePathForDisplay(params.agentDir);
1201
- const resolvedAgentDir = path.dirname(authStorePath);
1202
- throw new Error([
1203
- `No API key found for provider "${provider}".`,
1204
- `Auth store: ${authStorePath} (agentDir: ${resolvedAgentDir}).`,
1205
- `Configure auth for this agent (${formatCliCommand("remoteclaw agents add <id>")}) or copy auth-profiles.json from the main agentDir.`
1206
- ].join(" "));
1207
- }
1208
- function resolveEnvApiKey(provider) {
1209
- const normalized = normalizeProviderId(provider);
1210
- const applied = new Set(getShellEnvAppliedKeys());
1211
- const pick = (envVar) => {
1212
- const value = normalizeOptionalSecretInput(process.env[envVar]);
1213
- if (!value) return null;
1214
- return {
1215
- apiKey: value,
1216
- source: applied.has(envVar) ? `shell env: ${envVar}` : `env: ${envVar}`
1217
- };
1218
- };
1219
- if (normalized === "github-copilot") return pick("COPILOT_GITHUB_TOKEN") ?? pick("GH_TOKEN") ?? pick("GITHUB_TOKEN");
1220
- if (normalized === "anthropic") return pick("ANTHROPIC_OAUTH_TOKEN") ?? pick("ANTHROPIC_API_KEY");
1221
- if (normalized === "chutes") return pick("CHUTES_OAUTH_TOKEN") ?? pick("CHUTES_API_KEY");
1222
- if (normalized === "zai") return pick("ZAI_API_KEY") ?? pick("Z_AI_API_KEY");
1223
- if (normalized === "google-vertex") {
1224
- const hasCredentials = hasVertexAdcCredentials();
1225
- const hasProject = !!(process.env.GOOGLE_CLOUD_PROJECT || process.env.GCLOUD_PROJECT);
1226
- const hasLocation = !!process.env.GOOGLE_CLOUD_LOCATION;
1227
- if (hasCredentials && hasProject && hasLocation) return {
1228
- apiKey: "<authenticated>",
1229
- source: "gcloud adc"
1230
- };
1231
- return null;
1232
- }
1233
- if (normalized === "opencode") return pick("OPENCODE_API_KEY") ?? pick("OPENCODE_ZEN_API_KEY");
1234
- if (normalized === "qwen-portal") return pick("QWEN_OAUTH_TOKEN") ?? pick("QWEN_PORTAL_API_KEY");
1235
- if (normalized === "volcengine" || normalized === "volcengine-plan") return pick("VOLCANO_ENGINE_API_KEY");
1236
- if (normalized === "byteplus" || normalized === "byteplus-plan") return pick("BYTEPLUS_API_KEY");
1237
- if (normalized === "minimax-portal") return pick("MINIMAX_OAUTH_TOKEN") ?? pick("MINIMAX_API_KEY");
1238
- if (normalized === "kimi-coding") return pick("KIMI_API_KEY") ?? pick("KIMICODE_API_KEY");
1239
- if (normalized === "huggingface") return pick("HUGGINGFACE_HUB_TOKEN") ?? pick("HF_TOKEN");
1240
- const envVar = {
1241
- openai: "OPENAI_API_KEY",
1242
- google: "GEMINI_API_KEY",
1243
- voyage: "VOYAGE_API_KEY",
1244
- groq: "GROQ_API_KEY",
1245
- deepgram: "DEEPGRAM_API_KEY",
1246
- cerebras: "CEREBRAS_API_KEY",
1247
- xai: "XAI_API_KEY",
1248
- openrouter: "OPENROUTER_API_KEY",
1249
- litellm: "LITELLM_API_KEY",
1250
- "vercel-ai-gateway": "AI_GATEWAY_API_KEY",
1251
- "cloudflare-ai-gateway": "CLOUDFLARE_AI_GATEWAY_API_KEY",
1252
- moonshot: "MOONSHOT_API_KEY",
1253
- minimax: "MINIMAX_API_KEY",
1254
- nvidia: "NVIDIA_API_KEY",
1255
- xiaomi: "XIAOMI_API_KEY",
1256
- synthetic: "SYNTHETIC_API_KEY",
1257
- venice: "VENICE_API_KEY",
1258
- mistral: "MISTRAL_API_KEY",
1259
- opencode: "OPENCODE_API_KEY",
1260
- together: "TOGETHER_API_KEY",
1261
- qianfan: "QIANFAN_API_KEY",
1262
- ollama: "OLLAMA_API_KEY",
1263
- vllm: "VLLM_API_KEY",
1264
- kilocode: "KILOCODE_API_KEY"
1265
- }[normalized];
1266
- if (!envVar) return null;
1267
- return pick(envVar);
1268
- }
1269
- function resolveModelAuthMode(provider, cfg, store) {
1270
- const resolved = provider?.trim();
1271
- if (!resolved) return;
1272
- if (listProfilesForProvider(store ?? ensureAuthProfileStore(), resolved).length > 0) return "api-key";
1273
- if (normalizeProviderId(resolved) === "amazon-bedrock") return "api-key";
1274
- if (resolveEnvApiKey(resolved)?.apiKey) return "api-key";
1275
- return "unknown";
1276
- }
1277
- function requireApiKey(auth, provider) {
1278
- const key = normalizeSecretInput(auth.apiKey);
1279
- if (key) return key;
1280
- throw new Error(`No API key resolved for provider "${provider}" (auth mode: ${auth.mode}).`);
1281
- }
1282
- function formatApiKeySnippet(apiKey) {
1283
- const compact = apiKey.replace(/\s+/g, "");
1284
- if (!compact) return "unknown";
1285
- const edge = compact.length >= 12 ? 6 : 4;
1286
- return `${compact.slice(0, edge)}…${compact.slice(-edge)}`;
1287
- }
1288
- function resolveModelAuthLabel(params) {
1289
- const resolvedProvider = params.provider?.trim();
1290
- if (!resolvedProvider) return;
1291
- const providerKey = normalizeProviderId(resolvedProvider);
1292
- const store = ensureAuthProfileStore(params.agentDir, { allowKeychainPrompt: false });
1293
- const candidates = [params.sessionEntry?.authProfileOverride?.trim(), ...listProfilesForProvider(store, providerKey)].filter(Boolean);
1294
- for (const profileId of candidates) {
1295
- const profile = store.profiles[profileId];
1296
- if (!profile || normalizeProviderId(profile.provider) !== providerKey) continue;
1297
- const label = resolveAuthProfileDisplayLabel({
1298
- cfg: params.cfg,
1299
- store,
1300
- profileId
1301
- });
1302
- return `api-key ${formatApiKeySnippet(profile.key ?? "")}${label ? ` (${label})` : ""}`;
1303
- }
1304
- const envKey = resolveEnvApiKey(providerKey);
1305
- if (envKey?.apiKey) {
1306
- if (envKey.source.includes("OAUTH_TOKEN")) return `oauth (${envKey.source})`;
1307
- return `api-key ${formatApiKeySnippet(envKey.apiKey)} (${envKey.source})`;
1308
- }
1309
- return "unknown";
1310
- }
1311
-
1312
- //#endregion
1313
- //#region src/media-understanding/fs.ts
1314
- async function fileExists(filePath) {
1315
- if (!filePath) return false;
1316
- try {
1317
- await fsp.stat(filePath);
1318
- return true;
1319
- } catch {
1320
- return false;
1321
- }
1322
- }
1323
-
1324
- //#endregion
1325
- //#region src/media-understanding/output-extract.ts
1326
- function extractLastJsonObject(raw) {
1327
- const trimmed = raw.trim();
1328
- const start = trimmed.lastIndexOf("{");
1329
- if (start === -1) return null;
1330
- const slice = trimmed.slice(start);
1331
- try {
1332
- return JSON.parse(slice);
1333
- } catch {
1334
- return null;
1335
- }
1336
- }
1337
- function extractGeminiResponse(raw) {
1338
- const payload = extractLastJsonObject(raw);
1339
- if (!payload || typeof payload !== "object") return null;
1340
- const response = payload.response;
1341
- if (typeof response !== "string") return null;
1342
- return response.trim() || null;
1343
- }
1344
-
1345
- //#endregion
1346
- //#region src/agents/live-auth-keys.ts
1347
- const KEY_SPLIT_RE = /[\s,;]+/g;
1348
- const GOOGLE_LIVE_SINGLE_KEY = "REMOTECLAW_LIVE_GEMINI_KEY";
1349
- const PROVIDER_PREFIX_OVERRIDES = {
1350
- google: "GEMINI",
1351
- "google-vertex": "GEMINI"
1352
- };
1353
- const PROVIDER_API_KEY_CONFIG = {
1354
- anthropic: {
1355
- liveSingle: "REMOTECLAW_LIVE_ANTHROPIC_KEY",
1356
- listVar: "REMOTECLAW_LIVE_ANTHROPIC_KEYS",
1357
- primaryVar: "ANTHROPIC_API_KEY",
1358
- prefixedVar: "ANTHROPIC_API_KEY_"
1359
- },
1360
- google: {
1361
- liveSingle: GOOGLE_LIVE_SINGLE_KEY,
1362
- listVar: "GEMINI_API_KEYS",
1363
- primaryVar: "GEMINI_API_KEY",
1364
- prefixedVar: "GEMINI_API_KEY_"
1365
- },
1366
- "google-vertex": {
1367
- liveSingle: GOOGLE_LIVE_SINGLE_KEY,
1368
- listVar: "GEMINI_API_KEYS",
1369
- primaryVar: "GEMINI_API_KEY",
1370
- prefixedVar: "GEMINI_API_KEY_"
1371
- },
1372
- openai: {
1373
- liveSingle: "REMOTECLAW_LIVE_OPENAI_KEY",
1374
- listVar: "OPENAI_API_KEYS",
1375
- primaryVar: "OPENAI_API_KEY",
1376
- prefixedVar: "OPENAI_API_KEY_"
1377
- }
1378
- };
1379
- function parseKeyList(raw) {
1380
- if (!raw) return [];
1381
- return raw.split(KEY_SPLIT_RE).map((value) => value.trim()).filter(Boolean);
1382
- }
1383
- function collectEnvPrefixedKeys(prefix) {
1384
- const keys = [];
1385
- for (const [name, value] of Object.entries(process.env)) {
1386
- if (!name.startsWith(prefix)) continue;
1387
- const trimmed = value?.trim();
1388
- if (!trimmed) continue;
1389
- keys.push(trimmed);
1390
- }
1391
- return keys;
1392
- }
1393
- function resolveProviderApiKeyConfig(provider) {
1394
- const normalized = normalizeProviderId(provider);
1395
- const custom = PROVIDER_API_KEY_CONFIG[normalized];
1396
- const base = PROVIDER_PREFIX_OVERRIDES[normalized] ?? normalized.toUpperCase().replace(/-/g, "_");
1397
- const liveSingle = custom?.liveSingle ?? `REMOTECLAW_LIVE_${base}_KEY`;
1398
- const listVar = custom?.listVar ?? `${base}_API_KEYS`;
1399
- const primaryVar = custom?.primaryVar ?? `${base}_API_KEY`;
1400
- const prefixedVar = custom?.prefixedVar ?? `${base}_API_KEY_`;
1401
- if (normalized === "google" || normalized === "google-vertex") return {
1402
- liveSingle,
1403
- listVar,
1404
- primaryVar,
1405
- prefixedVar,
1406
- fallbackVars: ["GOOGLE_API_KEY"]
1407
- };
1408
- return {
1409
- liveSingle,
1410
- listVar,
1411
- primaryVar,
1412
- prefixedVar,
1413
- fallbackVars: []
1414
- };
1415
- }
1416
- function collectProviderApiKeys(provider) {
1417
- const config = resolveProviderApiKeyConfig(provider);
1418
- const forcedSingle = config.liveSingle ? process.env[config.liveSingle]?.trim() : void 0;
1419
- if (forcedSingle) return [forcedSingle];
1420
- const fromList = parseKeyList(config.listVar ? process.env[config.listVar] : void 0);
1421
- const primary = config.primaryVar ? process.env[config.primaryVar]?.trim() : void 0;
1422
- const fromPrefixed = config.prefixedVar ? collectEnvPrefixedKeys(config.prefixedVar) : [];
1423
- const fallback = config.fallbackVars.map((envVar) => process.env[envVar]?.trim()).filter(Boolean);
1424
- const seen = /* @__PURE__ */ new Set();
1425
- const add = (value) => {
1426
- if (!value) return;
1427
- if (seen.has(value)) return;
1428
- seen.add(value);
1429
- };
1430
- for (const value of fromList) add(value);
1431
- add(primary);
1432
- for (const value of fromPrefixed) add(value);
1433
- for (const value of fallback) add(value);
1434
- return Array.from(seen);
1435
- }
1436
- function isApiKeyRateLimitError(message) {
1437
- const lower = message.toLowerCase();
1438
- if (lower.includes("rate_limit")) return true;
1439
- if (lower.includes("rate limit")) return true;
1440
- if (lower.includes("429")) return true;
1441
- if (lower.includes("quota exceeded") || lower.includes("quota_exceeded")) return true;
1442
- if (lower.includes("resource exhausted") || lower.includes("resource_exhausted")) return true;
1443
- if (lower.includes("too many requests")) return true;
1444
- return false;
1445
- }
1446
-
1447
- //#endregion
1448
- //#region src/agents/api-key-rotation.ts
1449
- function dedupeApiKeys(raw) {
1450
- const seen = /* @__PURE__ */ new Set();
1451
- const keys = [];
1452
- for (const value of raw) {
1453
- const apiKey = value.trim();
1454
- if (!apiKey || seen.has(apiKey)) continue;
1455
- seen.add(apiKey);
1456
- keys.push(apiKey);
1457
- }
1458
- return keys;
1459
- }
1460
- function collectProviderApiKeysForExecution(params) {
1461
- const { primaryApiKey, provider } = params;
1462
- return dedupeApiKeys([primaryApiKey?.trim() ?? "", ...collectProviderApiKeys(provider)]);
1463
- }
1464
- async function executeWithApiKeyRotation(params) {
1465
- const keys = dedupeApiKeys(params.apiKeys);
1466
- if (keys.length === 0) throw new Error(`No API keys configured for provider "${params.provider}".`);
1467
- let lastError;
1468
- for (let attempt = 0; attempt < keys.length; attempt += 1) {
1469
- const apiKey = keys[attempt];
1470
- try {
1471
- return await params.execute(apiKey);
1472
- } catch (error) {
1473
- lastError = error;
1474
- const message = formatErrorMessage(error);
1475
- if (!(params.shouldRetry ? params.shouldRetry({
1476
- apiKey,
1477
- error,
1478
- attempt,
1479
- message
1480
- }) : isApiKeyRateLimitError(message)) || attempt + 1 >= keys.length) break;
1481
- params.onRetry?.({
1482
- apiKey,
1483
- error,
1484
- attempt,
1485
- message
1486
- });
1487
- }
1488
- }
1489
- if (lastError === void 0) throw new Error(`Failed to run API request for ${params.provider}.`);
1490
- throw lastError;
1491
- }
1492
-
1493
- //#endregion
1494
- //#region src/media-understanding/video.ts
1495
- function estimateBase64Size(bytes) {
1496
- return Math.ceil(bytes / 3) * 4;
1497
- }
1498
- function resolveVideoMaxBase64Bytes(maxBytes) {
1499
- const expanded = Math.floor(maxBytes * (4 / 3));
1500
- return Math.min(expanded, DEFAULT_VIDEO_MAX_BASE64_BYTES);
1501
- }
1502
-
1503
- //#endregion
1504
- //#region src/media-understanding/runner.entries.ts
1505
- function trimOutput(text, maxChars) {
1506
- const trimmed = text.trim();
1507
- if (!maxChars || trimmed.length <= maxChars) return trimmed;
1508
- return trimmed.slice(0, maxChars).trim();
1509
- }
1510
- function extractSherpaOnnxText(raw) {
1511
- const tryParse = (value) => {
1512
- const trimmed = value.trim();
1513
- if (!trimmed) return null;
1514
- const head = trimmed[0];
1515
- if (head !== "{" && head !== "\"") return null;
1516
- try {
1517
- const parsed = JSON.parse(trimmed);
1518
- if (typeof parsed === "string") return tryParse(parsed);
1519
- if (parsed && typeof parsed === "object") {
1520
- const text = parsed.text;
1521
- if (typeof text === "string" && text.trim()) return text.trim();
1522
- }
1523
- } catch {}
1524
- return null;
1525
- };
1526
- const direct = tryParse(raw);
1527
- if (direct) return direct;
1528
- const lines = raw.split("\n").map((line) => line.trim()).filter(Boolean);
1529
- for (let i = lines.length - 1; i >= 0; i -= 1) {
1530
- const parsed = tryParse(lines[i] ?? "");
1531
- if (parsed) return parsed;
1532
- }
1533
- return null;
1534
- }
1535
- function commandBase(command) {
1536
- return path.parse(command).name;
1537
- }
1538
- function findArgValue(args, keys) {
1539
- for (let i = 0; i < args.length; i += 1) if (keys.includes(args[i] ?? "")) {
1540
- const value = args[i + 1];
1541
- if (value) return value;
1542
- }
1543
- }
1544
- function hasArg(args, keys) {
1545
- return args.some((arg) => keys.includes(arg));
1546
- }
1547
- function resolveWhisperOutputPath(args, mediaPath) {
1548
- const outputDir = findArgValue(args, ["--output_dir", "-o"]);
1549
- const outputFormat = findArgValue(args, ["--output_format"]);
1550
- if (!outputDir || !outputFormat) return null;
1551
- if (!outputFormat.split(",").map((value) => value.trim()).includes("txt")) return null;
1552
- const base = path.parse(mediaPath).name;
1553
- return path.join(outputDir, `${base}.txt`);
1554
- }
1555
- function resolveWhisperCppOutputPath(args) {
1556
- if (!hasArg(args, ["-otxt", "--output-txt"])) return null;
1557
- const outputBase = findArgValue(args, ["-of", "--output-file"]);
1558
- if (!outputBase) return null;
1559
- return `${outputBase}.txt`;
1560
- }
1561
- async function resolveCliOutput(params) {
1562
- const commandId = commandBase(params.command);
1563
- const fileOutput = commandId === "whisper-cli" ? resolveWhisperCppOutputPath(params.args) : commandId === "whisper" ? resolveWhisperOutputPath(params.args, params.mediaPath) : null;
1564
- if (fileOutput && await fileExists(fileOutput)) try {
1565
- const content = await fsp.readFile(fileOutput, "utf8");
1566
- if (content.trim()) return content.trim();
1567
- } catch {}
1568
- if (commandId === "gemini") {
1569
- const response = extractGeminiResponse(params.stdout);
1570
- if (response) return response;
1571
- }
1572
- if (commandId === "sherpa-onnx-offline") {
1573
- const response = extractSherpaOnnxText(params.stdout);
1574
- if (response) return response;
1575
- }
1576
- return params.stdout.trim();
1577
- }
1578
- function normalizeProviderQuery(options) {
1579
- if (!options) return;
1580
- const query = {};
1581
- for (const [key, value] of Object.entries(options)) {
1582
- if (value === void 0) continue;
1583
- query[key] = value;
1584
- }
1585
- return Object.keys(query).length > 0 ? query : void 0;
1586
- }
1587
- function buildDeepgramCompatQuery(options) {
1588
- if (!options) return;
1589
- const query = {};
1590
- if (typeof options.detectLanguage === "boolean") query.detect_language = options.detectLanguage;
1591
- if (typeof options.punctuate === "boolean") query.punctuate = options.punctuate;
1592
- if (typeof options.smartFormat === "boolean") query.smart_format = options.smartFormat;
1593
- return Object.keys(query).length > 0 ? query : void 0;
1594
- }
1595
- function normalizeDeepgramQueryKeys(query) {
1596
- const normalized = { ...query };
1597
- if ("detectLanguage" in normalized) {
1598
- normalized.detect_language = normalized.detectLanguage;
1599
- delete normalized.detectLanguage;
1600
- }
1601
- if ("smartFormat" in normalized) {
1602
- normalized.smart_format = normalized.smartFormat;
1603
- delete normalized.smartFormat;
1604
- }
1605
- return normalized;
1606
- }
1607
- function resolveProviderQuery(params) {
1608
- const { providerId, config, entry } = params;
1609
- const mergedOptions = normalizeProviderQuery({
1610
- ...config?.providerOptions?.[providerId],
1611
- ...entry.providerOptions?.[providerId]
1612
- });
1613
- if (providerId !== "deepgram") return mergedOptions;
1614
- const query = normalizeDeepgramQueryKeys(mergedOptions ?? {});
1615
- const compat = buildDeepgramCompatQuery({
1616
- ...config?.deepgram,
1617
- ...entry.deepgram
1618
- });
1619
- for (const [key, value] of Object.entries(compat ?? {})) if (query[key] === void 0) query[key] = value;
1620
- return Object.keys(query).length > 0 ? query : void 0;
1621
- }
1622
- function buildModelDecision(params) {
1623
- if (params.entryType === "cli") {
1624
- const command = params.entry.command?.trim();
1625
- return {
1626
- type: "cli",
1627
- provider: command ?? "cli",
1628
- model: params.entry.model ?? command,
1629
- outcome: params.outcome,
1630
- reason: params.reason
1631
- };
1632
- }
1633
- const providerIdRaw = params.entry.provider?.trim();
1634
- return {
1635
- type: "provider",
1636
- provider: (providerIdRaw ? normalizeMediaProviderId(providerIdRaw) : void 0) ?? providerIdRaw,
1637
- model: params.entry.model,
1638
- outcome: params.outcome,
1639
- reason: params.reason
1640
- };
1641
- }
1642
- function resolveEntryRunOptions(params) {
1643
- const { capability, entry, cfg } = params;
1644
- const maxBytes = resolveMaxBytes({
1645
- capability,
1646
- entry,
1647
- cfg,
1648
- config: params.config
1649
- });
1650
- const maxChars = resolveMaxChars({
1651
- capability,
1652
- entry,
1653
- cfg,
1654
- config: params.config
1655
- });
1656
- return {
1657
- maxBytes,
1658
- maxChars,
1659
- timeoutMs: resolveTimeoutMs(entry.timeoutSeconds ?? params.config?.timeoutSeconds ?? cfg.tools?.media?.[capability]?.timeoutSeconds, DEFAULT_TIMEOUT_SECONDS[capability]),
1660
- prompt: resolvePrompt(capability, entry.prompt ?? params.config?.prompt ?? cfg.tools?.media?.[capability]?.prompt, maxChars)
1661
- };
1662
- }
1663
- async function resolveProviderExecutionAuth(params) {
1664
- const auth = await resolveApiKeyForProvider({
1665
- provider: params.providerId,
1666
- cfg: params.cfg,
1667
- profileId: params.entry.profile,
1668
- preferredProfile: params.entry.preferredProfile,
1669
- agentDir: params.agentDir
1670
- });
1671
- return { apiKeys: collectProviderApiKeysForExecution({
1672
- provider: params.providerId,
1673
- primaryApiKey: requireApiKey(auth, params.providerId)
1674
- }) };
1675
- }
1676
- async function resolveProviderExecutionContext(params) {
1677
- const { apiKeys } = await resolveProviderExecutionAuth({
1678
- providerId: params.providerId,
1679
- cfg: params.cfg,
1680
- entry: params.entry,
1681
- agentDir: params.agentDir
1682
- });
1683
- const baseUrl = params.entry.baseUrl ?? params.config?.baseUrl;
1684
- const mergedHeaders = {
1685
- ...params.config?.headers,
1686
- ...params.entry.headers
1687
- };
1688
- return {
1689
- apiKeys,
1690
- baseUrl,
1691
- headers: Object.keys(mergedHeaders).length > 0 ? mergedHeaders : void 0
1692
- };
1693
- }
1694
- function formatDecisionSummary(decision) {
1695
- const total = decision.attachments.length;
1696
- const success = decision.attachments.filter((entry) => entry.chosen?.outcome === "success").length;
1697
- const chosen = decision.attachments.find((entry) => entry.chosen)?.chosen;
1698
- const provider = chosen?.provider?.trim();
1699
- const model = chosen?.model?.trim();
1700
- const modelLabel = provider ? model ? `${provider}/${model}` : provider : void 0;
1701
- const reason = decision.attachments.flatMap((entry) => entry.attempts.map((attempt) => attempt.reason).filter(Boolean)).find(Boolean);
1702
- const shortReason = reason ? reason.split(":")[0]?.trim() : void 0;
1703
- const countLabel = total > 0 ? ` (${success}/${total})` : "";
1704
- const viaLabel = modelLabel ? ` via ${modelLabel}` : "";
1705
- const reasonLabel = shortReason ? ` reason=${shortReason}` : "";
1706
- return `${decision.capability}: ${decision.outcome}${countLabel}${viaLabel}${reasonLabel}`;
1707
- }
1708
- async function runProviderEntry(params) {
1709
- const { entry, capability, cfg } = params;
1710
- const providerIdRaw = entry.provider?.trim();
1711
- if (!providerIdRaw) throw new Error(`Provider entry missing provider for ${capability}`);
1712
- const providerId = normalizeMediaProviderId(providerIdRaw);
1713
- const { maxBytes, maxChars, timeoutMs, prompt } = resolveEntryRunOptions({
1714
- capability,
1715
- entry,
1716
- cfg,
1717
- config: params.config
1718
- });
1719
- const provider = getMediaUnderstandingProvider(providerId, params.providerRegistry);
1720
- if (!provider) throw new Error(`Media provider not available: ${providerId}`);
1721
- if (capability === "audio") {
1722
- if (!provider.transcribeAudio) throw new Error(`Audio transcription provider "${providerId}" not available.`);
1723
- const transcribeAudio = provider.transcribeAudio;
1724
- const media = await params.cache.getBuffer({
1725
- attachmentIndex: params.attachmentIndex,
1726
- maxBytes,
1727
- timeoutMs
1728
- });
1729
- const { apiKeys, baseUrl, headers } = await resolveProviderExecutionContext({
1730
- providerId,
1731
- cfg,
1732
- entry,
1733
- config: params.config,
1734
- agentDir: params.agentDir
1735
- });
1736
- const providerQuery = resolveProviderQuery({
1737
- providerId,
1738
- config: params.config,
1739
- entry
1740
- });
1741
- const model = entry.model?.trim() || DEFAULT_AUDIO_MODELS[providerId] || entry.model;
1742
- const result = await executeWithApiKeyRotation({
1743
- provider: providerId,
1744
- apiKeys,
1745
- execute: async (apiKey) => transcribeAudio({
1746
- buffer: media.buffer,
1747
- fileName: media.fileName,
1748
- mime: media.mime,
1749
- apiKey,
1750
- baseUrl,
1751
- headers,
1752
- model,
1753
- language: entry.language ?? params.config?.language ?? cfg.tools?.media?.audio?.language,
1754
- prompt,
1755
- query: providerQuery,
1756
- timeoutMs
1757
- })
1758
- });
1759
- return {
1760
- kind: "audio.transcription",
1761
- attachmentIndex: params.attachmentIndex,
1762
- text: trimOutput(result.text, maxChars),
1763
- provider: providerId,
1764
- model: result.model ?? model
1765
- };
1766
- }
1767
- if (!provider.describeVideo) throw new Error(`Video understanding provider "${providerId}" not available.`);
1768
- const describeVideo = provider.describeVideo;
1769
- const media = await params.cache.getBuffer({
1770
- attachmentIndex: params.attachmentIndex,
1771
- maxBytes,
1772
- timeoutMs
1773
- });
1774
- const estimatedBase64Bytes = estimateBase64Size(media.size);
1775
- const maxBase64Bytes = resolveVideoMaxBase64Bytes(maxBytes);
1776
- if (estimatedBase64Bytes > maxBase64Bytes) throw new MediaUnderstandingSkipError("maxBytes", `Video attachment ${params.attachmentIndex + 1} base64 payload ${estimatedBase64Bytes} exceeds ${maxBase64Bytes}`);
1777
- const { apiKeys, baseUrl, headers } = await resolveProviderExecutionContext({
1778
- providerId,
1779
- cfg,
1780
- entry,
1781
- config: params.config,
1782
- agentDir: params.agentDir
1783
- });
1784
- const result = await executeWithApiKeyRotation({
1785
- provider: providerId,
1786
- apiKeys,
1787
- execute: (apiKey) => describeVideo({
1788
- buffer: media.buffer,
1789
- fileName: media.fileName,
1790
- mime: media.mime,
1791
- apiKey,
1792
- baseUrl,
1793
- headers,
1794
- model: entry.model,
1795
- prompt,
1796
- timeoutMs
1797
- })
1798
- });
1799
- return {
1800
- kind: "video.description",
1801
- attachmentIndex: params.attachmentIndex,
1802
- text: trimOutput(result.text, maxChars),
1803
- provider: providerId,
1804
- model: result.model ?? entry.model
1805
- };
1806
- }
1807
- async function runCliEntry(params) {
1808
- const { entry, capability, cfg, ctx } = params;
1809
- const command = entry.command?.trim();
1810
- const args = entry.args ?? [];
1811
- if (!command) throw new Error(`CLI entry missing command for ${capability}`);
1812
- const { maxBytes, maxChars, timeoutMs, prompt } = resolveEntryRunOptions({
1813
- capability,
1814
- entry,
1815
- cfg,
1816
- config: params.config
1817
- });
1818
- const pathResult = await params.cache.getPath({
1819
- attachmentIndex: params.attachmentIndex,
1820
- maxBytes,
1821
- timeoutMs
1822
- });
1823
- const outputDir = await fsp.mkdtemp(path.join(resolvePreferredRemoteClawTmpDir(), "remoteclaw-media-cli-"));
1824
- const mediaPath = pathResult.path;
1825
- const outputBase = path.join(outputDir, path.parse(mediaPath).name);
1826
- const templCtx = {
1827
- ...ctx,
1828
- MediaPath: mediaPath,
1829
- MediaDir: path.dirname(mediaPath),
1830
- OutputDir: outputDir,
1831
- OutputBase: outputBase,
1832
- Prompt: prompt,
1833
- MaxChars: maxChars
1834
- };
1835
- const argv = [command, ...args].map((part, index) => index === 0 ? part : applyTemplate(part, templCtx));
1836
- try {
1837
- if (shouldLogVerbose()) logVerbose(`Media understanding via CLI: ${argv.join(" ")}`);
1838
- const { stdout } = await runExec(argv[0], argv.slice(1), {
1839
- timeoutMs,
1840
- maxBuffer: CLI_OUTPUT_MAX_BUFFER
1841
- });
1842
- const text = trimOutput(await resolveCliOutput({
1843
- command,
1844
- args: argv.slice(1),
1845
- stdout,
1846
- mediaPath
1847
- }), maxChars);
1848
- if (!text) return null;
1849
- return {
1850
- kind: capability === "audio" ? "audio.transcription" : `${capability}.description`,
1851
- attachmentIndex: params.attachmentIndex,
1852
- text,
1853
- provider: "cli",
1854
- model: command
1855
- };
1856
- } finally {
1857
- await fsp.rm(outputDir, {
1858
- recursive: true,
1859
- force: true
1860
- }).catch(() => {});
1861
- }
1862
- }
1863
-
1864
- //#endregion
1865
- //#region src/media-understanding/runner.ts
1866
- function buildProviderRegistry(overrides) {
1867
- return buildMediaUnderstandingRegistry(overrides);
1868
- }
1869
- function normalizeMediaAttachments(ctx) {
1870
- return normalizeAttachments(ctx);
1871
- }
1872
- function resolveMediaAttachmentLocalRoots(params) {
1873
- return mergeInboundPathRoots(getDefaultMediaLocalRoots(), resolveIMessageAttachmentRoots({
1874
- cfg: params.cfg,
1875
- accountId: params.ctx.AccountId
1876
- }));
1877
- }
1878
- function createMediaAttachmentCache(attachments, options) {
1879
- return new MediaAttachmentCache(attachments, options);
1880
- }
1881
- const binaryCache = /* @__PURE__ */ new Map();
1882
- const geminiProbeCache = /* @__PURE__ */ new Map();
1883
- function expandHomeDir(value) {
1884
- if (!value.startsWith("~")) return value;
1885
- const home = os.homedir();
1886
- if (value === "~") return home;
1887
- if (value.startsWith("~/")) return path.join(home, value.slice(2));
1888
- return value;
1889
- }
1890
- function hasPathSeparator(value) {
1891
- return value.includes("/") || value.includes("\\");
1892
- }
1893
- function candidateBinaryNames(name) {
1894
- if (process.platform !== "win32") return [name];
1895
- if (path.extname(name)) return [name];
1896
- const pathext = (process.env.PATHEXT ?? ".EXE;.CMD;.BAT;.COM").split(";").map((item) => item.trim()).filter(Boolean).map((item) => item.startsWith(".") ? item : `.${item}`);
1897
- return [name, ...Array.from(new Set(pathext)).map((item) => `${name}${item}`)];
1898
- }
1899
- async function isExecutable(filePath) {
1900
- try {
1901
- if (!(await fsp.stat(filePath)).isFile()) return false;
1902
- if (process.platform === "win32") return true;
1903
- await fsp.access(filePath, constants.X_OK);
1904
- return true;
1905
- } catch {
1906
- return false;
1907
- }
1908
- }
1909
- async function findBinary(name) {
1910
- const cached = binaryCache.get(name);
1911
- if (cached) return cached;
1912
- const resolved = (async () => {
1913
- const direct = expandHomeDir(name.trim());
1914
- if (direct && hasPathSeparator(direct)) {
1915
- for (const candidate of candidateBinaryNames(direct)) if (await isExecutable(candidate)) return candidate;
1916
- }
1917
- const searchName = name.trim();
1918
- if (!searchName) return null;
1919
- const pathEntries = (process.env.PATH ?? "").split(path.delimiter);
1920
- const candidates = candidateBinaryNames(searchName);
1921
- for (const entryRaw of pathEntries) {
1922
- const entry = expandHomeDir(entryRaw.trim().replace(/^"(.*)"$/, "$1"));
1923
- if (!entry) continue;
1924
- for (const candidate of candidates) {
1925
- const fullPath = path.join(entry, candidate);
1926
- if (await isExecutable(fullPath)) return fullPath;
1927
- }
1928
- }
1929
- return null;
1930
- })();
1931
- binaryCache.set(name, resolved);
1932
- return resolved;
1933
- }
1934
- async function hasBinary(name) {
1935
- return Boolean(await findBinary(name));
1936
- }
1937
- async function probeGeminiCli() {
1938
- const cached = geminiProbeCache.get("gemini");
1939
- if (cached) return cached;
1940
- const resolved = (async () => {
1941
- if (!await hasBinary("gemini")) return false;
1942
- try {
1943
- const { stdout } = await runExec("gemini", [
1944
- "--output-format",
1945
- "json",
1946
- "ok"
1947
- ], { timeoutMs: 8e3 });
1948
- return Boolean(extractGeminiResponse(stdout) ?? stdout.toLowerCase().includes("ok"));
1949
- } catch {
1950
- return false;
1951
- }
1952
- })();
1953
- geminiProbeCache.set("gemini", resolved);
1954
- return resolved;
1955
- }
1956
- async function resolveLocalWhisperCppEntry() {
1957
- if (!await hasBinary("whisper-cli")) return null;
1958
- const envModel = process.env.WHISPER_CPP_MODEL?.trim();
1959
- const modelPath = envModel && await fileExists(envModel) ? envModel : "/opt/homebrew/share/whisper-cpp/for-tests-ggml-tiny.bin";
1960
- if (!await fileExists(modelPath)) return null;
1961
- return {
1962
- type: "cli",
1963
- command: "whisper-cli",
1964
- args: [
1965
- "-m",
1966
- modelPath,
1967
- "-otxt",
1968
- "-of",
1969
- "{{OutputBase}}",
1970
- "-np",
1971
- "-nt",
1972
- "{{MediaPath}}"
1973
- ]
1974
- };
1975
- }
1976
- async function resolveLocalWhisperEntry() {
1977
- if (!await hasBinary("whisper")) return null;
1978
- return {
1979
- type: "cli",
1980
- command: "whisper",
1981
- args: [
1982
- "--model",
1983
- "turbo",
1984
- "--output_format",
1985
- "txt",
1986
- "--output_dir",
1987
- "{{OutputDir}}",
1988
- "--verbose",
1989
- "False",
1990
- "{{MediaPath}}"
1991
- ]
1992
- };
1993
- }
1994
- async function resolveSherpaOnnxEntry() {
1995
- if (!await hasBinary("sherpa-onnx-offline")) return null;
1996
- const modelDir = process.env.SHERPA_ONNX_MODEL_DIR?.trim();
1997
- if (!modelDir) return null;
1998
- const tokens = path.join(modelDir, "tokens.txt");
1999
- const encoder = path.join(modelDir, "encoder.onnx");
2000
- const decoder = path.join(modelDir, "decoder.onnx");
2001
- const joiner = path.join(modelDir, "joiner.onnx");
2002
- if (!await fileExists(tokens)) return null;
2003
- if (!await fileExists(encoder)) return null;
2004
- if (!await fileExists(decoder)) return null;
2005
- if (!await fileExists(joiner)) return null;
2006
- return {
2007
- type: "cli",
2008
- command: "sherpa-onnx-offline",
2009
- args: [
2010
- `--tokens=${tokens}`,
2011
- `--encoder=${encoder}`,
2012
- `--decoder=${decoder}`,
2013
- `--joiner=${joiner}`,
2014
- "{{MediaPath}}"
2015
- ]
2016
- };
2017
- }
2018
- async function resolveLocalAudioEntry() {
2019
- const sherpa = await resolveSherpaOnnxEntry();
2020
- if (sherpa) return sherpa;
2021
- const whisperCpp = await resolveLocalWhisperCppEntry();
2022
- if (whisperCpp) return whisperCpp;
2023
- return await resolveLocalWhisperEntry();
2024
- }
2025
- async function resolveGeminiCliEntry(_capability) {
2026
- if (!await probeGeminiCli()) return null;
2027
- return {
2028
- type: "cli",
2029
- command: "gemini",
2030
- args: [
2031
- "--output-format",
2032
- "json",
2033
- "--allowed-tools",
2034
- "read_many_files",
2035
- "--include-directories",
2036
- "{{MediaDir}}",
2037
- "{{Prompt}}",
2038
- "Use read_many_files to read {{MediaPath}} and respond with only the text output."
2039
- ]
2040
- };
2041
- }
2042
- async function resolveKeyEntry(params) {
2043
- const { cfg, agentDir, providerRegistry, capability } = params;
2044
- const checkProvider = async (providerId, model) => {
2045
- const provider = getMediaUnderstandingProvider(providerId, providerRegistry);
2046
- if (!provider) return null;
2047
- if (capability === "audio" && !provider.transcribeAudio) return null;
2048
- if (capability === "video" && !provider.describeVideo) return null;
2049
- try {
2050
- await resolveApiKeyForProvider({
2051
- provider: providerId,
2052
- cfg,
2053
- agentDir
2054
- });
2055
- return {
2056
- type: "provider",
2057
- provider: providerId,
2058
- model
2059
- };
2060
- } catch {
2061
- return null;
2062
- }
2063
- };
2064
- if (capability === "video") {
2065
- const activeProvider = params.activeModel?.provider?.trim();
2066
- if (activeProvider) {
2067
- const activeEntry = await checkProvider(activeProvider, params.activeModel?.model);
2068
- if (activeEntry) return activeEntry;
2069
- }
2070
- for (const providerId of AUTO_VIDEO_KEY_PROVIDERS) {
2071
- const entry = await checkProvider(providerId, void 0);
2072
- if (entry) return entry;
2073
- }
2074
- return null;
2075
- }
2076
- const activeProvider = params.activeModel?.provider?.trim();
2077
- if (activeProvider) {
2078
- const activeEntry = await checkProvider(activeProvider, params.activeModel?.model);
2079
- if (activeEntry) return activeEntry;
2080
- }
2081
- for (const providerId of AUTO_AUDIO_KEY_PROVIDERS) {
2082
- const entry = await checkProvider(providerId, void 0);
2083
- if (entry) return entry;
2084
- }
2085
- return null;
2086
- }
2087
- async function resolveAutoEntries(params) {
2088
- const activeEntry = await resolveActiveModelEntry(params);
2089
- if (activeEntry) return [activeEntry];
2090
- if (params.capability === "audio") {
2091
- const localAudio = await resolveLocalAudioEntry();
2092
- if (localAudio) return [localAudio];
2093
- }
2094
- const gemini = await resolveGeminiCliEntry(params.capability);
2095
- if (gemini) return [gemini];
2096
- const keys = await resolveKeyEntry(params);
2097
- if (keys) return [keys];
2098
- return [];
2099
- }
2100
- async function resolveActiveModelEntry(params) {
2101
- const activeProviderRaw = params.activeModel?.provider?.trim();
2102
- if (!activeProviderRaw) return null;
2103
- const providerId = normalizeMediaProviderId(activeProviderRaw);
2104
- if (!providerId) return null;
2105
- const provider = getMediaUnderstandingProvider(providerId, params.providerRegistry);
2106
- if (!provider) return null;
2107
- if (params.capability === "audio" && !provider.transcribeAudio) return null;
2108
- if (params.capability === "video" && !provider.describeVideo) return null;
2109
- try {
2110
- await resolveApiKeyForProvider({
2111
- provider: providerId,
2112
- cfg: params.cfg,
2113
- agentDir: params.agentDir
2114
- });
2115
- } catch {
2116
- return null;
2117
- }
2118
- return {
2119
- type: "provider",
2120
- provider: providerId,
2121
- model: params.activeModel?.model
2122
- };
2123
- }
2124
- async function runAttachmentEntries(params) {
2125
- const { entries, capability } = params;
2126
- const attempts = [];
2127
- for (const entry of entries) {
2128
- const entryType = entry.type ?? (entry.command ? "cli" : "provider");
2129
- try {
2130
- const result = entryType === "cli" ? await runCliEntry({
2131
- capability,
2132
- entry,
2133
- cfg: params.cfg,
2134
- ctx: params.ctx,
2135
- attachmentIndex: params.attachmentIndex,
2136
- cache: params.cache,
2137
- config: params.config
2138
- }) : await runProviderEntry({
2139
- capability,
2140
- entry,
2141
- cfg: params.cfg,
2142
- ctx: params.ctx,
2143
- attachmentIndex: params.attachmentIndex,
2144
- cache: params.cache,
2145
- agentDir: params.agentDir,
2146
- providerRegistry: params.providerRegistry,
2147
- config: params.config
2148
- });
2149
- if (result) {
2150
- const decision = buildModelDecision({
2151
- entry,
2152
- entryType,
2153
- outcome: "success"
2154
- });
2155
- if (result.provider) decision.provider = result.provider;
2156
- if (result.model) decision.model = result.model;
2157
- attempts.push(decision);
2158
- return {
2159
- output: result,
2160
- attempts
2161
- };
2162
- }
2163
- attempts.push(buildModelDecision({
2164
- entry,
2165
- entryType,
2166
- outcome: "skipped",
2167
- reason: "empty output"
2168
- }));
2169
- } catch (err) {
2170
- if (isMediaUnderstandingSkipError(err)) {
2171
- attempts.push(buildModelDecision({
2172
- entry,
2173
- entryType,
2174
- outcome: "skipped",
2175
- reason: `${err.reason}: ${err.message}`
2176
- }));
2177
- if (shouldLogVerbose()) logVerbose(`Skipping ${capability} model due to ${err.reason}: ${err.message}`);
2178
- continue;
2179
- }
2180
- attempts.push(buildModelDecision({
2181
- entry,
2182
- entryType,
2183
- outcome: "failed",
2184
- reason: String(err)
2185
- }));
2186
- if (shouldLogVerbose()) logVerbose(`${capability} understanding failed: ${String(err)}`);
2187
- }
2188
- }
2189
- return {
2190
- output: null,
2191
- attempts
2192
- };
2193
- }
2194
- async function runCapability(params) {
2195
- const { capability, cfg, ctx } = params;
2196
- const config = params.config ?? cfg.tools?.media?.[capability];
2197
- if (config?.enabled === false) return {
2198
- outputs: [],
2199
- decision: {
2200
- capability,
2201
- outcome: "disabled",
2202
- attachments: []
2203
- }
2204
- };
2205
- const attachmentPolicy = config?.attachments;
2206
- const selected = selectAttachments({
2207
- capability,
2208
- attachments: params.media,
2209
- policy: attachmentPolicy
2210
- });
2211
- if (selected.length === 0) return {
2212
- outputs: [],
2213
- decision: {
2214
- capability,
2215
- outcome: "no-attachment",
2216
- attachments: []
2217
- }
2218
- };
2219
- if (resolveScopeDecision({
2220
- scope: config?.scope,
2221
- ctx
2222
- }) === "deny") {
2223
- if (shouldLogVerbose()) logVerbose(`${capability} understanding disabled by scope policy.`);
2224
- return {
2225
- outputs: [],
2226
- decision: {
2227
- capability,
2228
- outcome: "scope-deny",
2229
- attachments: selected.map((item) => ({
2230
- attachmentIndex: item.index,
2231
- attempts: []
2232
- }))
2233
- }
2234
- };
2235
- }
2236
- let resolvedEntries = resolveModelEntries({
2237
- cfg,
2238
- capability,
2239
- config,
2240
- providerRegistry: params.providerRegistry
2241
- });
2242
- if (resolvedEntries.length === 0) resolvedEntries = await resolveAutoEntries({
2243
- cfg,
2244
- agentDir: params.agentDir,
2245
- providerRegistry: params.providerRegistry,
2246
- capability,
2247
- activeModel: params.activeModel
2248
- });
2249
- if (resolvedEntries.length === 0) return {
2250
- outputs: [],
2251
- decision: {
2252
- capability,
2253
- outcome: "skipped",
2254
- attachments: selected.map((item) => ({
2255
- attachmentIndex: item.index,
2256
- attempts: []
2257
- }))
2258
- }
2259
- };
2260
- const outputs = [];
2261
- const attachmentDecisions = [];
2262
- for (const attachment of selected) {
2263
- const { output, attempts } = await runAttachmentEntries({
2264
- capability,
2265
- cfg,
2266
- ctx,
2267
- attachmentIndex: attachment.index,
2268
- agentDir: params.agentDir,
2269
- providerRegistry: params.providerRegistry,
2270
- cache: params.attachments,
2271
- entries: resolvedEntries,
2272
- config
2273
- });
2274
- if (output) outputs.push(output);
2275
- attachmentDecisions.push({
2276
- attachmentIndex: attachment.index,
2277
- attempts,
2278
- chosen: attempts.find((attempt) => attempt.outcome === "success")
2279
- });
2280
- }
2281
- const decision = {
2282
- capability,
2283
- outcome: outputs.length > 0 ? "success" : "skipped",
2284
- attachments: attachmentDecisions
2285
- };
2286
- if (shouldLogVerbose()) logVerbose(`Media understanding ${formatDecisionSummary(decision)}`);
2287
- return {
2288
- outputs,
2289
- decision
2290
- };
2291
- }
2292
-
2293
- //#endregion
2294
- export { CLI_OUTPUT_MAX_BUFFER as _, runCapability as a, isAudioAttachment as c, installUnhandledRejectionHandler as d, registerUnhandledRejectionHandler as f, resolveMediaUnderstandingScope as g, normalizeMediaUnderstandingChatType as h, resolveMediaAttachmentLocalRoots as i, resolveAttachmentKind as l, resolveTimeoutMs as m, createMediaAttachmentCache as n, resolveModelAuthLabel as o, resolveConcurrency as p, normalizeMediaAttachments as r, resolveModelAuthMode as s, buildProviderRegistry as t, buildRandomTempFilePath as u, applyTemplate as v };