activeclaw 2026.2.11 → 2026.2.13

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 (531) hide show
  1. package/CHANGELOG.md +106 -0
  2. package/dist/{accounts-DbzMEfKN.js → accounts-DCDeFTra.js} +2 -2
  3. package/dist/{accounts-C2elk6PC.js → accounts-DeqIQjo1.js} +2 -2
  4. package/dist/{acp-cli-CVFTdsQY.js → acp-cli-CeYI4XRd.js} +15 -16
  5. package/dist/{acp-cli-BpJwIyLl.js → acp-cli-rNbGXICg.js} +14 -15
  6. package/dist/{agent-Bz1r5O8q.js → agent-BvNJF5QL.js} +19 -15
  7. package/dist/{agent-22-R4bNS.js → agent-CyMxTyrG.js} +20 -16
  8. package/dist/{agent-scope-D8miw9q_.js → agent-scope-BIEhVP4_.js} +172 -4
  9. package/dist/{agent-scope-CGmuusG9.js → agent-scope-CQCus0rI.js} +3 -3
  10. package/dist/{agent-scope-DQuy3dwI.js → agent-scope-CsRbLH4l.js} +4 -4
  11. package/dist/{agent-scope-BEf5crnU.js → agent-scope-DPIFau3f.js} +5 -1
  12. package/dist/audio-preflight-BU8W7uxc.js +60 -0
  13. package/dist/audio-preflight-CGsumMzb.js +60 -0
  14. package/dist/audio-preflight-SLmkJI6-.js +74 -0
  15. package/dist/audio-preflight-jZc5mFCZ.js +71 -0
  16. package/dist/{audit-C4wLaF0D.js → audit-Dmww_503.js} +71 -19
  17. package/dist/{audit-CY-yopxa.js → audit-wPu26VMb.js} +72 -20
  18. package/dist/{tailscale-DU6DgqVy.js → auth-9x3lqfIY.js} +208 -3
  19. package/dist/{tailscale-Cu-2HNvU.js → auth-CQNl_IaI.js} +190 -3
  20. package/dist/{auth-health-BFKUoCwJ.js → auth-health-C4L4FGBA.js} +1 -1
  21. package/dist/{auth-health-d7BMZlWG.js → auth-health-j6epgQbq.js} +1 -1
  22. package/dist/{auth-profiles-Bv1AEm-Y.js → auth-profiles-ByNs3eEm.js} +87 -31
  23. package/dist/build-info.json +3 -3
  24. package/dist/bundled/boot-md/handler.js +28 -22
  25. package/dist/bundled/session-memory/handler.js +33 -22
  26. package/dist/{call-7yrB6v4I.js → call-DVYCIV8m.js} +5 -5
  27. package/dist/{call-Bek1xlgk.js → call-SolyGS1r.js} +6 -6
  28. package/dist/canvas-host/a2ui/.bundle.hash +1 -1
  29. package/dist/{channel-options-3mdYN0C_.js → channel-options-BwC2yQcR.js} +4 -4
  30. package/dist/{channel-options-DJ0b1m7B.js → channel-options-Cq9BVDkP.js} +12 -7
  31. package/dist/{channel-selection-RZimme3j.js → channel-selection-D4D6ImhN.js} +2 -2
  32. package/dist/{channel-selection-B9b7Kuit.js → channel-selection-MZAHm4U8.js} +2 -2
  33. package/dist/{channels-cli-CYbK2Dku.js → channels-cli-9Dsk9Qm7.js} +57 -53
  34. package/dist/{channels-cli-BFznbGOs.js → channels-cli-BJUppQll.js} +59 -55
  35. package/dist/{channels-status-issues-B3KkflfR.js → channels-status-issues-D7GSV1GS.js} +1 -1
  36. package/dist/{channels-status-issues-DQkRaZts.js → channels-status-issues-DDAWeT-6.js} +1 -1
  37. package/dist/{chrome-Db7w64LF.js → chrome-BfB6JdKF.js} +4 -4
  38. package/dist/{chrome-Dm-EgOjJ.js → chrome-Cvr-57lg.js} +6 -5
  39. package/dist/{chrome-CF16STk9.js → chrome-DL0avO8n.js} +2 -1
  40. package/dist/{chrome-yIKmOzCO.js → chrome-foEwx3lN.js} +5 -4
  41. package/dist/{clack-prompter-BCiBkJVr.js → clack-prompter-Bz3Mmcl-.js} +5 -5
  42. package/dist/{clack-prompter-DuBVnTKy.js → clack-prompter-ChCGXfyt.js} +4 -4
  43. package/dist/cli/daemon-cli.js +1 -1
  44. package/dist/{cli-Cl3PdJei.js → cli-ZR9ugUBX.js} +42 -38
  45. package/dist/cli-miPe4Ujz.js +93 -0
  46. package/dist/{client-6xKrRC-1.js → client-BrYfyoDK.js} +54 -5
  47. package/dist/{client-DMloFP_O.js → client-CTwXnRl7.js} +54 -5
  48. package/dist/{command-format-ayFsmwwz.js → command-format-Bxe0mWee.js} +1 -1
  49. package/dist/{command-options-BTAzyqqb.js → command-options-BvgxzPbK.js} +9 -4
  50. package/dist/{commands-CjEGXOZ_.js → commands-BX_OIIVR.js} +4 -4
  51. package/dist/{completion-cli-DrJGfJGl.js → completion-cli-CR77-jyv.js} +3 -3
  52. package/dist/{completion-cli-DOec3E2Z.js → completion-cli-DnjpxAag.js} +30 -30
  53. package/dist/{config-B00lvFac.js → config-Bdhomfei.js} +21 -7
  54. package/dist/{config-XBdA0ciN.js → config-BvMsmctM.js} +83 -9
  55. package/dist/{config-BqGVMf1y.js → config-QYrbd7x7.js} +60 -6
  56. package/dist/{config--NUdpACy.js → config-aFQssWKX.js} +21 -7
  57. package/dist/{config-guard-4kCO_rnQ.js → config-guard-CljaSxJd.js} +160 -51
  58. package/dist/{configure-B69emwZv.js → configure-BXLiucXo.js} +28 -25
  59. package/dist/{configure-sMhpLzFf.js → configure-BYPqXzGZ.js} +28 -25
  60. package/dist/control-auth-8Cf4WXpR.js +54 -0
  61. package/dist/control-auth-DBCu3qyv.js +54 -0
  62. package/dist/{control-service-Db_1V-KY.js → control-service-B5KnPqGP.js} +11 -5
  63. package/dist/{control-service-IRAmbcbN.js → control-service-DKnttEus.js} +10 -4
  64. package/dist/control-ui/assets/{index-CnB9IO4a.js → index-B4LPvte9.js} +369 -369
  65. package/dist/control-ui/assets/index-B4LPvte9.js.map +1 -0
  66. package/dist/control-ui/index.html +1 -1
  67. package/dist/{cron-cli-Cum2324v.js → cron-cli-D7BRjDv2.js} +20 -20
  68. package/dist/{cron-cli-DhUWcYdk.js → cron-cli-z1zk_FXQ.js} +19 -19
  69. package/dist/{daemon-cli-q7nkEF5-.js → daemon-cli-BDkU2ocb.js} +60 -21
  70. package/dist/{daemon-cli-CTC2CHci.js → daemon-cli-cNSF93-v.js} +59 -20
  71. package/dist/{daemon-runtime-c0uXH4Dl.js → daemon-runtime-B0tg_LsX.js} +3 -3
  72. package/dist/{daemon-runtime-UsK-tOty.js → daemon-runtime-Bsjeut6m.js} +3 -3
  73. package/dist/{deliver-hf-WKyWd.js → deliver-CIU9Npgs.js} +373 -281
  74. package/dist/{deliver-CT6KiDqO.js → deliver-DYYCo1G7.js} +369 -278
  75. package/dist/{deliver-T9d44OpZ.js → deliver-LsxKETro.js} +371 -279
  76. package/dist/{deliver-CPy8jYj9.js → deliver-xUU3mGHo.js} +369 -277
  77. package/dist/{deps-Bv1kLtwo.js → deps-QSwGcoNZ.js} +2 -2
  78. package/dist/{deps-DFQdAWQc.js → deps-lAAA2zYI.js} +2 -2
  79. package/dist/{devices-cli-Cm7U1py9.js → devices-cli-BG3-2oqt.js} +14 -14
  80. package/dist/{devices-cli-ZpjlfK-e.js → devices-cli-VIQtOvt_.js} +14 -14
  81. package/dist/{directory-cli-B14TUSJA.js → directory-cli-BCJwjVC0.js} +16 -16
  82. package/dist/{directory-cli-67kzd4I5.js → directory-cli-jYzZ02gk.js} +14 -14
  83. package/dist/{dispatcher-3ElQWGVI.js → dispatcher-DY51b-Zc.js} +2 -2
  84. package/dist/{dns-cli-CU-xfhTN.js → dns-cli-DHIiMJjS.js} +12 -12
  85. package/dist/{dns-cli-Dqj7O6Q_.js → dns-cli-pZlv87Ib.js} +11 -11
  86. package/dist/{docs-cli-CamBqzb5.js → docs-cli-2JDiwfzP.js} +8 -8
  87. package/dist/{docs-cli-Cj3L5oqB.js → docs-cli-BhkYqoIQ.js} +7 -7
  88. package/dist/{doctor-BV1kvbMm.js → doctor-Bf8EhNtA.js} +36 -35
  89. package/dist/{doctor-BJirShBi.js → doctor-sYG5V4Co.js} +34 -33
  90. package/dist/entry.js +56 -18
  91. package/dist/{env-BxRc6wWv.js → env-ONzUVAG2.js} +1 -1
  92. package/dist/{exec-CijMSZd9.js → exec-B8lXct-k.js} +503 -14
  93. package/dist/{exec-B8JKbXKW.js → exec-CACT5OAW.js} +1 -1
  94. package/dist/{exec-57A8Rlc8.js → exec-CJFFoM7H.js} +32 -13
  95. package/dist/{exec-Cv_Ofd1m.js → exec-YIosokWE.js} +1 -1
  96. package/dist/{exec-approvals-cli-DEzz9Iai.js → exec-approvals-cli-7LH0lwhO.js} +21 -21
  97. package/dist/{exec-approvals-cli-DhXj3hQX.js → exec-approvals-cli-apGnQbpj.js} +21 -21
  98. package/dist/extensionAPI.js +7733 -8746
  99. package/dist/fetch-DmiOpALK.js +274 -0
  100. package/dist/fetch-timeout-BEtUjM1S.js +274 -0
  101. package/dist/fetch-timeout-DEoXG_SF.js +274 -0
  102. package/dist/fetch-timeout-DTK9vxex.js +274 -0
  103. package/dist/{gateway-cli-D1EdIq8I.js → gateway-cli-DUdYxlZS.js} +491 -136
  104. package/dist/{gateway-cli-B_xDUDy2.js → gateway-cli-DbvWmE-9.js} +495 -140
  105. package/dist/{gateway-rpc-3B5y445n.js → gateway-rpc-BByb2Snz.js} +3 -3
  106. package/dist/{gateway-rpc-BoL2vinh.js → gateway-rpc-wXSCUZXj.js} +3 -3
  107. package/dist/{github-copilot-auth-Omqrto0J.js → github-copilot-auth-D7ewvpMd.js} +205 -17
  108. package/dist/{github-copilot-auth-CZxurvdz.js → github-copilot-auth-DDispnyz.js} +205 -17
  109. package/dist/{github-copilot-token-SLWintYd.js → github-copilot-token-Cfs0Wxr8.js} +1 -1
  110. package/dist/{gmail-setup-utils-BXQKsLtI.js → gmail-setup-utils-Cfns8TQx.js} +3 -3
  111. package/dist/{gmail-setup-utils-CHcssBOA.js → gmail-setup-utils-DJb-_5kO.js} +4 -4
  112. package/dist/{health-format-Dy1caGsq.js → health-format-KGPokKJH.js} +97 -42
  113. package/dist/{health-format-DrGFg8bx.js → health-format-LZDxu3rv.js} +95 -40
  114. package/dist/{help-format-DAj7l5uV.js → help-format-C48TXngO.js} +1 -1
  115. package/dist/{help-format-CUnac_bT.js → help-format-R5fLToDw.js} +1 -1
  116. package/dist/{hooks-cli-ptEf6TIM.js → hooks-cli-CT8JCRkH.js} +51 -46
  117. package/dist/{hooks-cli-Bhf5VRp1.js → hooks-cli-S1MKumJO.js} +49 -44
  118. package/dist/{hooks-status-Br-2bK2G.js → hooks-status-Cw0xD8Lt.js} +3 -3
  119. package/dist/{hooks-status-DNQJSa4B.js → hooks-status-D9MhwHRp.js} +3 -3
  120. package/dist/{image-rOFfK3PJ.js → image-Brk1sJbw.js} +10 -7
  121. package/dist/{image-fUwR7slg.js → image-C4Nn2p3e.js} +10 -7
  122. package/dist/{image-Ds4NLGPR.js → image-DgtfXMcX.js} +9 -6
  123. package/dist/{image-Dnnxt82I.js → image-RKwc3fsL.js} +8 -5
  124. package/dist/index.js +208 -97
  125. package/dist/{installs-CRSjQxbR.js → installs-CrLcWYHe.js} +8 -7
  126. package/dist/{installs-89zeUsVn.js → installs-DscWb9b9.js} +8 -7
  127. package/dist/{links-7M-j83As.js → links-B8LAzWwg.js} +1 -1
  128. package/dist/{links-C591fM9M.js → links-Eax1UO3w.js} +1 -1
  129. package/dist/llm-slug-generator.js +18 -19
  130. package/dist/{loader-wXwp4rZJ.js → loader-KjT074JR.js} +5722 -6888
  131. package/dist/{logging-MMRGFxGI.js → logging-BAyPwvdH.js} +1 -1
  132. package/dist/{logging-DuK6YXuK.js → logging-CRq4h04P.js} +2 -2
  133. package/dist/{login-qr-wM8BnKJh.js → login-qr-B6ZgAuIf.js} +5 -5
  134. package/dist/{login-qr-CPEsT6dN.js → login-qr-Bua-p0nG.js} +3 -4
  135. package/dist/{login-qr-CGEu5TU-.js → login-qr-CuvemJj4.js} +6 -6
  136. package/dist/{login-qr-DH150tTp.js → login-qr-Djr1JfIf.js} +2 -2
  137. package/dist/{logs-cli-ClgkHnfT.js → logs-cli-9IAV7rWY.js} +38 -22
  138. package/dist/{logs-cli-CmfINsOj.js → logs-cli-EiKzUFPa.js} +37 -21
  139. package/dist/{manager-DYo4PlVM.js → manager-BIMh_eSm.js} +7 -8
  140. package/dist/{manager-D6EbxDV4.js → manager-CwinWQoz.js} +5 -5
  141. package/dist/{manager-BbnHek5T.js → manager-DkqF1GiK.js} +9 -9
  142. package/dist/{manager-CcVYv0N5.js → manager-T1XfGchB.js} +8 -8
  143. package/dist/{manifest-registry-3It8Z8yN.js → manifest-registry-CQhdnDBZ.js} +40 -2
  144. package/dist/{manifest-registry-D5SiA3xq.js → manifest-registry-u0okVSkU.js} +40 -2
  145. package/dist/{message-channel-Cu61-7H6.js → message-channel-BLi2a6Yw.js} +1 -1
  146. package/dist/{message-channel-BlgPSDAh.js → message-channel-C_MmebBt.js} +1 -1
  147. package/dist/{model-auth-ioeR_zLX.js → model-auth-CabXIF6O.js} +116 -34
  148. package/dist/{model-selection-BK7DuyH8.js → model-selection-BLuqsGVB.js} +86 -30
  149. package/dist/{model-selection-CezC36lH.js → model-selection-C1GmkTAV.js} +84 -28
  150. package/dist/{models-cli-C3uGdOrd.js → models-cli-9jmDv-h3.js} +52 -48
  151. package/dist/{models-cli-CUIVPgXE.js → models-cli-zS9rtWz8.js} +53 -49
  152. package/dist/{node-cli-BxBGSuPE.js → node-cli-CrpTxTTs.js} +28 -26
  153. package/dist/{node-cli-CdYAsuQQ.js → node-cli-wemUMCg-.js} +28 -26
  154. package/dist/{node-service-u8g85nD3.js → node-service-C8DTHTMg.js} +2 -2
  155. package/dist/{node-service-CM5vkdIo.js → node-service-WQuEKz6W.js} +2 -2
  156. package/dist/{nodes-cli-By6yeCTB.js → nodes-cli-BaU2SIFw.js} +20 -20
  157. package/dist/{nodes-cli-BaVMTAPc.js → nodes-cli-Dx23D72n.js} +20 -20
  158. package/dist/{nodes-screen-Dvl_ohUY.js → nodes-screen-C0IuBqUL.js} +1 -1
  159. package/dist/{note-5WqioBRA.js → note-BhRSeNeu.js} +2 -2
  160. package/dist/{note-Ci08TSbV.js → note-hhtubr2j.js} +1 -1
  161. package/dist/{onboard-channels-DxXvp8og.js → onboard-channels-C501x8GI.js} +8 -8
  162. package/dist/{onboard-channels-CXhnVy4E.js → onboard-channels-Dxzroasd.js} +8 -8
  163. package/dist/{onboard-skills-CBxsRGyf.js → onboard-skills-DV0Qzvjj.js} +440 -136
  164. package/dist/{onboard-skills-DQwOQ6Ry.js → onboard-skills-rlBHcu3Q.js} +439 -135
  165. package/dist/{onboarding-Du_7qEng.js → onboarding-CN-EDLjd.js} +38 -38
  166. package/dist/{openclaw-root-JLDMp6ux.js → openclaw-root-1VeFrph_.js} +4 -0
  167. package/dist/{openclaw-root-Dw6gumSU.js → openclaw-root-BNlEap4i.js} +4 -0
  168. package/dist/{pairing-cli-CRQDpj8f.js → pairing-cli-CDHG4xuI.js} +15 -15
  169. package/dist/{pairing-cli-Cng1KFWw.js → pairing-cli-CQP34Dlx.js} +15 -15
  170. package/dist/{pairing-labels-Ciu3Zoxj.js → pairing-labels-B6CN0SNH.js} +1 -1
  171. package/dist/{pairing-labels-CWFEtSc3.js → pairing-labels-CgNHnjzT.js} +1 -1
  172. package/dist/{pairing-store-c-QQ2u8p.js → pairing-store-CmlRVqOz.js} +2 -2
  173. package/dist/{pairing-store-CgXR3ZWJ.js → pairing-store-Dp5_JGnG.js} +3 -3
  174. package/dist/{path-env-CXWUFfFv.js → path-env-CLvYNwtL.js} +1 -1
  175. package/dist/{path-env-BgLvMbz_.js → path-env-CaYUVIML.js} +2 -2
  176. package/dist/{paths-MnZaxqPw.js → paths-B0a4ywSO.js} +30 -5
  177. package/dist/{paths-Bkhd_qY8.js → paths-B49s6UZQ.js} +30 -5
  178. package/dist/{paths-DL6EIRTw.js → paths-D0O87MfH.js} +30 -5
  179. package/dist/{paths-IivnSNkP.js → paths-DLINmNFQ.js} +31 -6
  180. package/dist/{pi-embedded-CgPTEqlB.js → pi-embedded-Ctrt2kz0.js} +8759 -9600
  181. package/dist/{pi-embedded-helpers-DYH6OWft.js → pi-embedded-helpers-CMKLjW6X.js} +68 -9
  182. package/dist/{pi-embedded-helpers-y1_Se0yq.js → pi-embedded-helpers-CUzTc1v6.js} +241 -24
  183. package/dist/{pi-embedded-helpers-Bkpd4fTr.js → pi-embedded-helpers-DfwkwPYD.js} +67 -8
  184. package/dist/{pi-embedded-helpers-BbWRSUnc.js → pi-embedded-helpers-WDwx99UA.js} +347 -32
  185. package/dist/{pi-tools.policy-akYsGFiA.js → pi-tools.policy-BpsROZbz.js} +4 -4
  186. package/dist/{plugin-auto-enable-lZwe2yX5.js → plugin-auto-enable-Bqhc3w5n.js} +5 -5
  187. package/dist/{plugin-auto-enable-AOSOJ-v1.js → plugin-auto-enable-PW76g_PJ.js} +5 -5
  188. package/dist/plugin-sdk/agents/bash-process-registry.d.ts +1 -0
  189. package/dist/plugin-sdk/agents/models-config.providers.d.ts +10 -0
  190. package/dist/plugin-sdk/agents/pi-embedded-helpers/errors.d.ts +5 -1
  191. package/dist/plugin-sdk/agents/pi-embedded-helpers.d.ts +1 -1
  192. package/dist/plugin-sdk/agents/pi-embedded-runner/google.d.ts +1 -0
  193. package/dist/plugin-sdk/agents/pi-embedded-runner/run/params.d.ts +2 -0
  194. package/dist/plugin-sdk/agents/pi-embedded-runner/run/payloads.d.ts +1 -0
  195. package/dist/plugin-sdk/agents/pi-embedded-runner/run/types.d.ts +2 -0
  196. package/dist/plugin-sdk/agents/pi-embedded-runner/types.d.ts +15 -0
  197. package/dist/plugin-sdk/agents/pi-embedded-subscribe.handlers.tools.d.ts +1 -1
  198. package/dist/plugin-sdk/agents/pi-embedded-subscribe.handlers.types.d.ts +2 -0
  199. package/dist/plugin-sdk/agents/pi-embedded-subscribe.types.d.ts +2 -0
  200. package/dist/plugin-sdk/agents/session-tool-result-guard-wrapper.d.ts +2 -0
  201. package/dist/plugin-sdk/agents/session-tool-result-guard.d.ts +4 -0
  202. package/dist/plugin-sdk/agents/tools/agent-step.d.ts +3 -0
  203. package/dist/plugin-sdk/agents/tools/browser-tool.schema.d.ts +1 -1
  204. package/dist/plugin-sdk/agents/tools/web-search.d.ts +10 -1
  205. package/dist/plugin-sdk/agents/usage.d.ts +1 -0
  206. package/dist/plugin-sdk/auto-reply/heartbeat.d.ts +1 -1
  207. package/dist/plugin-sdk/auto-reply/reply/get-reply-directives.d.ts +1 -0
  208. package/dist/plugin-sdk/auto-reply/reply/mentions.d.ts +1 -0
  209. package/dist/plugin-sdk/auto-reply/reply/model-selection.d.ts +3 -0
  210. package/dist/plugin-sdk/auto-reply/reply/reply-reference.d.ts +1 -1
  211. package/dist/plugin-sdk/auto-reply/reply/session-run-accounting.d.ts +11 -0
  212. package/dist/plugin-sdk/auto-reply/reply/session-usage.d.ts +8 -0
  213. package/dist/plugin-sdk/auto-reply/types.d.ts +2 -0
  214. package/dist/plugin-sdk/browser/control-auth.d.ts +13 -0
  215. package/dist/plugin-sdk/channels/plugins/onboarding/signal.d.ts +1 -0
  216. package/dist/plugin-sdk/cli/prompt.d.ts +1 -0
  217. package/dist/plugin-sdk/commands/agent/types.d.ts +2 -0
  218. package/dist/plugin-sdk/commands/onboard-types.d.ts +7 -1
  219. package/dist/plugin-sdk/config/sessions/paths.d.ts +7 -2
  220. package/dist/plugin-sdk/config/types.agents.d.ts +2 -0
  221. package/dist/plugin-sdk/config/types.discord.d.ts +5 -0
  222. package/dist/plugin-sdk/config/types.gateway.d.ts +15 -0
  223. package/dist/plugin-sdk/config/types.hooks.d.ts +15 -0
  224. package/dist/plugin-sdk/config/types.memory.d.ts +2 -0
  225. package/dist/plugin-sdk/config/zod-schema.agents.d.ts +1 -0
  226. package/dist/plugin-sdk/config/zod-schema.d.ts +13 -1
  227. package/dist/plugin-sdk/config/zod-schema.hooks.d.ts +1 -1
  228. package/dist/plugin-sdk/config/zod-schema.providers-core.d.ts +9 -0
  229. package/dist/plugin-sdk/config/zod-schema.providers.d.ts +4 -0
  230. package/dist/plugin-sdk/cron/service/jobs.d.ts +8 -0
  231. package/dist/plugin-sdk/cron/service/state.d.ts +1 -0
  232. package/dist/plugin-sdk/cron/types.d.ts +2 -0
  233. package/dist/plugin-sdk/discord/monitor/allow-list.d.ts +15 -0
  234. package/dist/plugin-sdk/discord/send.types.d.ts +5 -0
  235. package/dist/plugin-sdk/gateway/auth.d.ts +36 -0
  236. package/dist/plugin-sdk/gateway/protocol/index.d.ts +0 -3
  237. package/dist/plugin-sdk/gateway/protocol/schema/agent.d.ts +7 -1
  238. package/dist/plugin-sdk/gateway/session-utils.fs.d.ts +3 -1
  239. package/dist/plugin-sdk/index.js +935 -660
  240. package/dist/plugin-sdk/infra/binaries.d.ts +3 -0
  241. package/dist/plugin-sdk/infra/heartbeat-active-hours.d.ts +5 -0
  242. package/dist/plugin-sdk/infra/heartbeat-runner.d.ts +1 -0
  243. package/dist/plugin-sdk/infra/net/fetch-guard.d.ts +1 -0
  244. package/dist/plugin-sdk/infra/net/ssrf.d.ts +1 -0
  245. package/dist/plugin-sdk/infra/tailscale.d.ts +34 -0
  246. package/dist/plugin-sdk/infra/tmp-openclaw-dir.d.ts +10 -0
  247. package/dist/plugin-sdk/logging/console.d.ts +1 -0
  248. package/dist/plugin-sdk/logging/logger.d.ts +1 -1
  249. package/dist/plugin-sdk/logging/state.d.ts +1 -0
  250. package/dist/plugin-sdk/markdown/ir.d.ts +1 -1
  251. package/dist/plugin-sdk/markdown/whatsapp.d.ts +14 -0
  252. package/dist/plugin-sdk/media/input-files.d.ts +5 -0
  253. package/dist/plugin-sdk/media-understanding/audio-preflight.d.ts +16 -0
  254. package/dist/plugin-sdk/media-understanding/types.d.ts +1 -0
  255. package/dist/plugin-sdk/memory/backend-config.d.ts +2 -1
  256. package/dist/plugin-sdk/memory/qmd-manager.d.ts +2 -0
  257. package/dist/plugin-sdk/memory/qmd-query-parser.d.ts +8 -0
  258. package/dist/plugin-sdk/process/command-queue.d.ts +16 -0
  259. package/dist/plugin-sdk/routing/resolve-route.d.ts +3 -1
  260. package/dist/plugin-sdk/security/external-content.d.ts +1 -1
  261. package/dist/plugin-sdk/security/secret-equal.d.ts +1 -0
  262. package/dist/plugin-sdk/sessions/input-provenance.d.ts +16 -0
  263. package/dist/plugin-sdk/signal/monitor/event-handler.types.d.ts +8 -0
  264. package/dist/plugin-sdk/signal/monitor/mentions.d.ts +2 -0
  265. package/dist/plugin-sdk/slack/monitor/commands.d.ts +5 -0
  266. package/dist/plugin-sdk/telegram/bot-message-context.d.ts +2 -1
  267. package/dist/plugin-sdk/telegram/send.d.ts +3 -0
  268. package/dist/plugin-sdk/web/media.d.ts +2 -0
  269. package/dist/{plugins-Db5BiELK.js → plugins-4Hqd1WGf.js} +3 -3
  270. package/dist/{plugins-CNaHNND_.js → plugins-X7d_tfTE.js} +4 -4
  271. package/dist/{plugins-cli-8G-hQPCu.js → plugins-cli-Bgku3EGj.js} +253 -44
  272. package/dist/{plugins-cli-CDiocaDE.js → plugins-cli-CVToH3if.js} +257 -48
  273. package/dist/{ports-BeebfNCb.js → ports-qkt29rdC.js} +2 -2
  274. package/dist/{program-0Cj9YxRN.js → program-Cf7lkBur.js} +82 -80
  275. package/dist/{progress-DIQJt9Va.js → progress-C9kngsTD.js} +1 -1
  276. package/dist/{progress-Da1ehW-x.js → progress-DWqhRakV.js} +1 -1
  277. package/dist/{prompt-style-Dc0C5HC9.js → prompt-style-BFH5D5LN.js} +1 -1
  278. package/dist/{prompt-style-CjQRlDx4.js → prompt-style-CIbmaxSa.js} +1 -1
  279. package/dist/{pw-ai-C43wv1ZF.js → pw-ai-8mdv3h-d.js} +7 -6
  280. package/dist/{pw-ai-COWYvUfG.js → pw-ai-CM1IsSgZ.js} +6 -6
  281. package/dist/{pw-ai-BxJ-KCIy.js → pw-ai-FGoRVblI.js} +5 -6
  282. package/dist/{pw-ai-CsvaObGM.js → pw-ai-sS1fRKW_.js} +3 -3
  283. package/dist/{qmd-manager-CpsjQyaZ.js → qmd-manager-C67Fc8aN.js} +79 -26
  284. package/dist/{qmd-manager-C9YWFeG6.js → qmd-manager-CXVbfg99.js} +81 -26
  285. package/dist/{qmd-manager-C02E8ixK.js → qmd-manager-RMRE8Tqt.js} +81 -26
  286. package/dist/{qmd-manager-BzY2LQTT.js → qmd-manager-pyc_MTIe.js} +78 -23
  287. package/dist/{register.subclis-DUkirdHn.js → register.subclis-C02e4zuJ.js} +29 -29
  288. package/dist/{reply--b7BsXGP.js → reply-DICXkh_C.js} +7289 -8455
  289. package/dist/{routes-DUkEKAc1.js → routes-CmOI1hIH.js} +29 -11
  290. package/dist/{routes-B4QQiFju.js → routes-DewK5tq2.js} +29 -12
  291. package/dist/{rpc-CuMtxrRT.js → rpc-DHr30euf.js} +3 -3
  292. package/dist/{rpc-Blt6MJ4F.js → rpc-T300F8zI.js} +3 -3
  293. package/dist/{run-main-XZcPA23b.js → run-main-C5wpthq1.js} +84 -82
  294. package/dist/runner-CY0nmVme.js +1886 -0
  295. package/dist/runner-Cfm5nTMc.js +1785 -0
  296. package/dist/runner-D_dujMod.js +1886 -0
  297. package/dist/runner-DrGYLH5K.js +1785 -0
  298. package/dist/{sandbox-Aks-9EcZ.js → sandbox-BKYnhYQH.js} +24 -17
  299. package/dist/{sandbox-DqUO2K83.js → sandbox-Bhjnh1Xg.js} +23 -16
  300. package/dist/{sandbox-cli-C99Thxi8.js → sandbox-cli-DBsAjZJN.js} +21 -21
  301. package/dist/{sandbox-cli-CJqRM4V6.js → sandbox-cli-rV9LtFeu.js} +21 -21
  302. package/dist/{security-cli-iqYLMOz3.js → security-cli-BIwJM_rs.js} +27 -27
  303. package/dist/{security-cli-DW3lCz-o.js → security-cli-BRjny8Yu.js} +27 -27
  304. package/dist/{server-context-fX4xiYRh.js → server-context-BGpGs3qd.js} +7 -7
  305. package/dist/{server-context-8Qt35QdF.js → server-context-Cl0U0vE3.js} +7 -7
  306. package/dist/{server-node-events-CHWXfb_T.js → server-node-events-CBfTbiTA.js} +48 -44
  307. package/dist/{server-node-events-BzrEnKLX.js → server-node-events-QCvh8EgI.js} +45 -41
  308. package/dist/{service-Cd4BxKuo.js → service--nPk7DvT.js} +8 -4
  309. package/dist/{service-DDPRbf8a.js → service-99RDXwX4.js} +8 -4
  310. package/dist/{service-audit-CCFxuvKs.js → service-audit-DnLmRGQt.js} +4 -4
  311. package/dist/{service-audit-x6jCN-6a.js → service-audit-ckBaRCVC.js} +4 -4
  312. package/dist/{session-cost-usage-CcCEQNuc.js → session-cost-usage-D7HuoSSD.js} +12 -10
  313. package/dist/{session-cost-usage-PvyVZz-g.js → session-cost-usage-D9hHANWI.js} +12 -10
  314. package/dist/{shared-ILguacOr.js → shared-Bs4vduG4.js} +3 -3
  315. package/dist/{shared-CagUDdmp.js → shared-CEY5IkwG.js} +3 -3
  316. package/dist/{shared-gOyV38rM.js → shared-DRohONn_.js} +4 -4
  317. package/dist/{shared-BDk_zC9p.js → shared-ICqOZibV.js} +4 -4
  318. package/dist/{skill-scanner-C_fQzVDu.js → skill-scanner-CucvxYhu.js} +1 -1
  319. package/dist/{skill-scanner-DrVEHfC6.js → skill-scanner-rHMtUHtP.js} +1 -1
  320. package/dist/{skills-D5UZZZSY.js → skills-DRjfSQT3.js} +141 -6
  321. package/dist/{skills-ccAgQ3Ad.js → skills-DprQj9X2.js} +142 -7
  322. package/dist/{skills-cli-DQilTG3n.js → skills-cli-9WO-C55s.js} +12 -12
  323. package/dist/{skills-cli-ggyLBtAY.js → skills-cli-B9eej-EW.js} +13 -13
  324. package/dist/{skills-status-BosMnzIs.js → skills-status-5U3P3YfJ.js} +3 -3
  325. package/dist/{skills-status-DjtPPMnY.js → skills-status-TDIgVd1K.js} +2 -2
  326. package/dist/{sqlite-B7FPASCO.js → sqlite-BINzs1U0.js} +2 -2
  327. package/dist/{sqlite-Btrgi7-j.js → sqlite-D4w5TejA.js} +3 -3
  328. package/dist/{sqlite-BrQ9tw8B.js → sqlite-DRRHmlug.js} +3 -3
  329. package/dist/{sqlite-HepBVDoX.js → sqlite-F6PGkEm1.js} +2 -2
  330. package/dist/{status-BByCntWS.js → status-BKGkKC_v.js} +3 -3
  331. package/dist/{status-Dt7RE_Yy.js → status-CiHtHdaa.js} +4 -4
  332. package/dist/{status-zfL4Yej7.js → status-DDWoOpeB.js} +37 -37
  333. package/dist/{subsystem-Bh1Y_6Uv.js → subsystem-BoExtIHo.js} +52 -17
  334. package/dist/{system-cli-DwuUkdkH.js → system-cli-B6lr60Io.js} +14 -14
  335. package/dist/{system-cli-Clqsx8U5.js → system-cli-CprW9G3h.js} +14 -14
  336. package/dist/{systemd-BEWwfwn0.js → systemd-C0VZriGM.js} +3 -3
  337. package/dist/{systemd-D6wTPnHi.js → systemd-DrmBtJ5T.js} +3 -3
  338. package/dist/{systemd-hints-zi4ohCOY.js → systemd-hints-DZtXiVHa.js} +1 -1
  339. package/dist/{systemd-linger-CDo2UbHM.js → systemd-linger-NC2kl1SC.js} +2 -2
  340. package/dist/{systemd-linger-BxjTrgoH.js → systemd-linger-xdn3BdPh.js} +2 -2
  341. package/dist/{table-DEnmtvl5.js → table-B8dx3v4v.js} +2 -2
  342. package/dist/{table-cCoGqLsk.js → table-CwulTLQp.js} +1 -1
  343. package/dist/{tool-display-DskiU8Kt.js → tool-display-CZRIDMRm.js} +2 -2
  344. package/dist/{tool-display-o-dDAlqF.js → tool-display-ClRud3pg.js} +2 -2
  345. package/dist/{tui-BdJWZdto.js → tui-CVTQn-dC.js} +14 -13
  346. package/dist/{tui-Bc7XUQGP.js → tui-Lu8FdrlK.js} +13 -14
  347. package/dist/{tui-cli-BGYh0UL0.js → tui-cli-BLpTj1X9.js} +27 -27
  348. package/dist/{tui-cli-D3n-O9zB.js → tui-cli-BLx5kL2I.js} +26 -26
  349. package/dist/{tui-formatters-CA85v4U2.js → tui-formatters-CNySEfJN.js} +6 -6
  350. package/dist/{tui-formatters-C3NarH24.js → tui-formatters-DePhZK3J.js} +6 -6
  351. package/dist/{update-JB16aPIY.js → update-DHVxMTpQ.js} +3 -3
  352. package/dist/{update-Ct9sqJC_.js → update-DU1geolI.js} +3 -3
  353. package/dist/{update-cli-wWKDS3cm.js → update-cli-C0hUvJWK.js} +89 -71
  354. package/dist/{update-cli-DDXp_N9B.js → update-cli-Wb1GB3rL.js} +88 -70
  355. package/dist/{update-runner-ChTf6O6p.js → update-runner--ixK4J3W.js} +11 -11
  356. package/dist/{update-runner-CmE6cHdn.js → update-runner-7Qa1T9y6.js} +10 -10
  357. package/dist/{utils-Dk86IbEs.js → utils-BLJAc3ZV.js} +1 -1
  358. package/dist/{utils-es4ygvQ-.js → utils-Cd9QdCHh.js} +1 -1
  359. package/dist/{webhooks-cli-CVIE9TtX.js → webhooks-cli-DgcMy7RG.js} +12 -12
  360. package/dist/{webhooks-cli-BmKSiQQC.js → webhooks-cli-aVzUcJY9.js} +11 -11
  361. package/dist/{widearea-dns-2ah0bkAj.js → widearea-dns-BaIgNEhY.js} +3 -3
  362. package/dist/{widearea-dns-CMIG6-74.js → widearea-dns-DzuRdwk5.js} +3 -3
  363. package/dist/{ws-DtDKpbLR.js → ws-CHCQHs0F.js} +1 -1
  364. package/dist/{ws-log-BP3z_g6Z.js → ws-log-CIXbLCka.js} +1 -1
  365. package/dist/{ws-log-D7MkvKhg.js → ws-log-DcQFZByi.js} +2 -2
  366. package/dist/{wsl-Cwo7X0Un.js → wsl-BUOkxKJu.js} +2 -2
  367. package/docs/assets/install-script.svg +1 -0
  368. package/docs/automation/hooks.md +1 -38
  369. package/docs/automation/webhook.md +43 -2
  370. package/docs/channels/discord.md +389 -381
  371. package/docs/channels/imessage.md +229 -218
  372. package/docs/channels/slack.md +294 -415
  373. package/docs/channels/telegram.md +401 -505
  374. package/docs/channels/whatsapp.md +338 -310
  375. package/docs/ci.md +0 -12
  376. package/docs/cli/hooks.md +1 -14
  377. package/docs/cli/index.md +6 -1
  378. package/docs/cli/logs.md +4 -0
  379. package/docs/cli/onboard.md +30 -0
  380. package/docs/cli/plugins.md +20 -1
  381. package/docs/cli/security.md +1 -0
  382. package/docs/concepts/memory.md +7 -4
  383. package/docs/concepts/session-tool.md +1 -0
  384. package/docs/docs.json +11 -11
  385. package/docs/gateway/configuration-examples.md +9 -2
  386. package/docs/gateway/configuration-reference.md +2329 -0
  387. package/docs/gateway/configuration.md +338 -3304
  388. package/docs/gateway/index.md +162 -238
  389. package/docs/gateway/openresponses-http-api.md +15 -0
  390. package/docs/gateway/security/index.md +3 -0
  391. package/docs/help/faq.md +9 -0
  392. package/docs/install/hetzner.md +21 -0
  393. package/docs/install/installer.md +20 -0
  394. package/docs/nodes/audio.md +19 -0
  395. package/docs/platforms/mac/release.md +7 -7
  396. package/docs/providers/glm.md +3 -3
  397. package/docs/providers/index.md +1 -0
  398. package/docs/providers/litellm.md +153 -0
  399. package/docs/providers/zai.md +2 -2
  400. package/docs/reference/templates/AGENTS.md +26 -26
  401. package/docs/reference/templates/HEARTBEAT.md +31 -2
  402. package/docs/reference/templates/SOUL.md +14 -8
  403. package/docs/reference/transcript-hygiene.md +18 -0
  404. package/docs/start/getting-started.md +5 -0
  405. package/docs/start/wizard-cli-automation.md +17 -0
  406. package/docs/start/wizard-cli-reference.md +12 -0
  407. package/docs/tools/browser.md +6 -0
  408. package/docs/zh-CN/automation/hooks.md +1 -38
  409. package/docs/zh-CN/cli/hooks.md +1 -14
  410. package/extensions/bluebubbles/package.json +1 -1
  411. package/extensions/bluebubbles/src/monitor.test.ts +40 -28
  412. package/extensions/bluebubbles/src/monitor.ts +0 -4
  413. package/extensions/copilot-proxy/package.json +1 -1
  414. package/extensions/diagnostics-otel/package.json +10 -10
  415. package/extensions/discord/package.json +1 -1
  416. package/extensions/feishu/package.json +2 -5
  417. package/extensions/feishu/src/bot.checkBotMentioned.test.ts +64 -0
  418. package/extensions/feishu/src/bot.ts +1 -1
  419. package/extensions/feishu/src/channel.test.ts +48 -0
  420. package/extensions/feishu/src/channel.ts +1 -3
  421. package/extensions/feishu/src/config-schema.ts +6 -0
  422. package/extensions/feishu/src/docx.ts +14 -4
  423. package/extensions/feishu/src/media.test.ts +151 -0
  424. package/extensions/feishu/src/media.ts +27 -13
  425. package/extensions/feishu/src/reply-dispatcher.test.ts +116 -0
  426. package/extensions/feishu/src/reply-dispatcher.ts +124 -67
  427. package/extensions/feishu/src/streaming-card.ts +223 -0
  428. package/extensions/feishu/src/targets.test.ts +16 -0
  429. package/extensions/feishu/src/targets.ts +1 -1
  430. package/extensions/google-antigravity-auth/package.json +1 -1
  431. package/extensions/google-gemini-cli-auth/package.json +1 -1
  432. package/extensions/googlechat/package.json +1 -1
  433. package/extensions/imessage/package.json +1 -1
  434. package/extensions/irc/package.json +1 -1
  435. package/extensions/irc/src/client.ts +1 -1
  436. package/extensions/line/package.json +1 -1
  437. package/extensions/llm-task/package.json +1 -1
  438. package/extensions/lobster/package.json +1 -1
  439. package/extensions/matrix/CHANGELOG.md +6 -0
  440. package/extensions/matrix/package.json +2 -2
  441. package/extensions/mattermost/package.json +1 -1
  442. package/extensions/memory-core/package.json +1 -1
  443. package/extensions/memory-lancedb/index.ts +6 -2
  444. package/extensions/memory-lancedb/package.json +2 -2
  445. package/extensions/minimax-portal-auth/index.ts +7 -5
  446. package/extensions/minimax-portal-auth/package.json +1 -1
  447. package/extensions/msteams/CHANGELOG.md +6 -0
  448. package/extensions/msteams/package.json +1 -1
  449. package/extensions/nextcloud-talk/package.json +1 -1
  450. package/extensions/nostr/CHANGELOG.md +6 -0
  451. package/extensions/nostr/package.json +2 -2
  452. package/extensions/open-prose/package.json +1 -1
  453. package/extensions/signal/package.json +1 -1
  454. package/extensions/slack/package.json +1 -1
  455. package/extensions/telegram/package.json +1 -1
  456. package/extensions/tlon/package.json +1 -1
  457. package/extensions/twitch/CHANGELOG.md +6 -0
  458. package/extensions/twitch/package.json +1 -1
  459. package/extensions/voice-call/CHANGELOG.md +6 -0
  460. package/extensions/voice-call/package.json +1 -1
  461. package/extensions/voice-call/src/media-stream.ts +7 -1
  462. package/extensions/voice-call/src/providers/twilio.test.ts +5 -3
  463. package/extensions/voice-call/src/providers/twilio.ts +12 -1
  464. package/extensions/whatsapp/package.json +1 -1
  465. package/extensions/zalo/CHANGELOG.md +6 -0
  466. package/extensions/zalo/package.json +1 -1
  467. package/extensions/zalouser/CHANGELOG.md +6 -0
  468. package/extensions/zalouser/package.json +1 -1
  469. package/package.json +26 -22
  470. package/dist/auth-BcNHFK-i.js +0 -184
  471. package/dist/auth-BvIPpm7G.js +0 -184
  472. package/dist/boolean-M-esQJt6.js +0 -30
  473. package/dist/bundled/soul-evil/HOOK.md +0 -71
  474. package/dist/bundled/soul-evil/handler.js +0 -194
  475. package/dist/cli-DJbWJ9aB.js +0 -89
  476. package/dist/config-CI7EpvlP.js +0 -15
  477. package/dist/control-ui/assets/index-CnB9IO4a.js.map +0 -1
  478. package/dist/date-time-c6HTX6IW.js +0 -187
  479. package/dist/frontmatter-xwTm0734.js +0 -105
  480. package/dist/parse-duration-De_tAQSe.js +0 -24
  481. package/dist/session-key-nXYQSv-a.js +0 -167
  482. package/dist/utils-dp_OM900.js +0 -476
  483. package/docs/hooks/soul-evil.md +0 -69
  484. package/docs/zh-CN/hooks/soul-evil.md +0 -72
  485. /package/dist/{archive-CXhvR9nU.js → archive-beaSfAzA.js} +0 -0
  486. /package/dist/{brew-BIrWdDps.js → brew-BUIxHEkn.js} +0 -0
  487. /package/dist/{brew-B7YK4ZoL.js → brew-ROHf0-Xp.js} +0 -0
  488. /package/dist/{cli-utils-PlLcDZlM.js → cli-utils-CRhVAaLV.js} +0 -0
  489. /package/dist/{cli-utils-R-ECs5cY.js → cli-utils-LcHOt63h.js} +0 -0
  490. /package/dist/{command-format-BUxhT1xL.js → command-format-qUVxzqYm.js} +0 -0
  491. /package/dist/{constants-CNTiY-ZN.js → constants-BvQ6S8j5.js} +0 -0
  492. /package/dist/{constants-DuoCkWRh.js → constants-JPeoOZnw.js} +0 -0
  493. /package/dist/{errors-D3tYRJWG.js → errors-B91HIDPD.js} +0 -0
  494. /package/dist/{errors-B0eT3jVv.js → errors-Bv81hF2P.js} +0 -0
  495. /package/dist/{errors-x4NYs-1P.js → errors-DjZBTJJ3.js} +0 -0
  496. /package/dist/{exec-approvals-DGPTjO0N.js → exec-approvals-Cb4ZLukq.js} +0 -0
  497. /package/dist/{exec-approvals-DhmKpiIo.js → exec-approvals-DQ8TVVmj.js} +0 -0
  498. /package/dist/{format-CaxeRcue.js → format-CNU-Zkrz.js} +0 -0
  499. /package/dist/{format-DLOJPZmo.js → format-DcfK-dwd.js} +0 -0
  500. /package/dist/{format-duration-Be5Z7JdJ.js → format-duration-84n6_DgO.js} +0 -0
  501. /package/dist/{format-duration-CEmFWLyX.js → format-duration-Bo9zNKwO.js} +0 -0
  502. /package/dist/{format-relative-79_Y1n2Y.js → format-relative-CZOlQ2pA.js} +0 -0
  503. /package/dist/{format-relative-Db7eqEu8.js → format-relative-cegC_FF5.js} +0 -0
  504. /package/dist/{github-copilot-token-C9IJh2Pn.js → github-copilot-token-DkiRbJdR.js} +0 -0
  505. /package/dist/{helpers-CQI-5xS9.js → helpers-8O7IVGO-.js} +0 -0
  506. /package/dist/{helpers-CRzoyyXS.js → helpers-D_jqdWkd.js} +0 -0
  507. /package/dist/{helpers-C89IG08W.js → helpers-HyeZXsnu.js} +0 -0
  508. /package/dist/{is-main-WWuz28Ip.js → is-main-BWoXGz7p.js} +0 -0
  509. /package/dist/{logging-BzvBIA3Y.js → logging-fywhKCmE.js} +0 -0
  510. /package/dist/{nodes-screen-lykd2cny.js → nodes-screen-CdCWeiwy.js} +0 -0
  511. /package/dist/{parse-Cjiudy6x.js → parse-Bw0oH-rT.js} +0 -0
  512. /package/dist/{parse-DqAvJRIf.js → parse-ioZhOtha.js} +0 -0
  513. /package/dist/{parse-log-line-CUrpqe1w.js → parse-log-line-BoDqomM4.js} +0 -0
  514. /package/dist/{parse-log-line-D2UGw0wR.js → parse-log-line-DPxH1XZx.js} +0 -0
  515. /package/dist/{parse-timeout-DFSPLxpY.js → parse-timeout-D1XX_zN_.js} +0 -0
  516. /package/dist/{parse-timeout-DV8NQQWk.js → parse-timeout-DMW-z4Iz.js} +0 -0
  517. /package/dist/{pi-model-discovery-CV2V1HHz.js → pi-model-discovery-DqgqUyAv.js} +0 -0
  518. /package/dist/{pi-model-discovery-DzFOAbQt.js → pi-model-discovery-EwKVHlZB.js} +0 -0
  519. /package/dist/{prompts--d-6l5Ln.js → prompts-Bg96reub.js} +0 -0
  520. /package/dist/{redact-DAKeu7PA.js → redact-BRsnXqwD.js} +0 -0
  521. /package/dist/{redact-DuEEf1p1.js → redact-Br9GfacZ.js} +0 -0
  522. /package/dist/{redact-BOIof271.js → redact-BrXLgslJ.js} +0 -0
  523. /package/dist/{status-Cv36yYdi.js → status-BRZfQbJ2.js} +0 -0
  524. /package/dist/{status-Drziap9H.js → status-CoAy6bEC.js} +0 -0
  525. /package/dist/{systemd-hints-CH4pbCFD.js → systemd-hints-CXNtLw9Q.js} +0 -0
  526. /package/dist/{tailnet-DGRSvYuQ.js → tailnet-DATIFSsY.js} +0 -0
  527. /package/dist/{transcript-events-BlIONGVn.js → transcript-events-BHS7QoRl.js} +0 -0
  528. /package/dist/{transcript-events-C1hdue6u.js → transcript-events-Bp7fGnwv.js} +0 -0
  529. /package/dist/{transcript-events-CZ8CG4ht.js → transcript-events-BtNd-j6q.js} +0 -0
  530. /package/dist/{usage-format-6Uar63S0.js → usage-format-C4JfTbSp.js} +0 -0
  531. /package/dist/{usage-format-hd37en6b.js → usage-format-CpORtVCG.js} +0 -0
@@ -0,0 +1,1886 @@
1
+ import { A as logVerbose, N as shouldLogVerbose } from "./subsystem-BoExtIHo.js";
2
+ import { n as runExec } from "./exec-YIosokWE.js";
3
+ import { B as resolveApiKeyForProvider, bt as resolveOpenClawAgentDir, s as normalizeProviderId, x as normalizeGoogleModelId, z as requireApiKey } from "./model-selection-BLuqsGVB.js";
4
+ import { i as loadConfig } from "./config-aFQssWKX.js";
5
+ import { b as normalizeChatType } from "./plugins-X7d_tfTE.js";
6
+ import { t as describeImageWithModel, v as ensureOpenClawModelsJson } from "./image-C4Nn2p3e.js";
7
+ import { d as getFileExtension, h as kindFromMime, l as detectMime, p as isAudioFileName } from "./routes-CmOI1hIH.js";
8
+ import { r as formatUncaughtError, t as extractErrorCode } from "./errors-Bv81hF2P.js";
9
+ import { i as fetchWithSsrFGuard, n as fetchRemoteMedia, r as fetchWithTimeout, t as MediaFetchError } from "./fetch-DmiOpALK.js";
10
+ import process$1 from "node:process";
11
+ import { fileURLToPath } from "node:url";
12
+ import { constants } from "node:fs";
13
+ import os from "node:os";
14
+ import path from "node:path";
15
+ import fs$1 from "node:fs/promises";
16
+ import crypto from "node:crypto";
17
+
18
+ //#region src/auto-reply/templating.ts
19
+ function formatTemplateValue(value) {
20
+ if (value == null) return "";
21
+ if (typeof value === "string") return value;
22
+ if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") return String(value);
23
+ if (typeof value === "symbol" || typeof value === "function") return value.toString();
24
+ if (Array.isArray(value)) return value.flatMap((entry) => {
25
+ if (entry == null) return [];
26
+ if (typeof entry === "string") return [entry];
27
+ if (typeof entry === "number" || typeof entry === "boolean" || typeof entry === "bigint") return [String(entry)];
28
+ return [];
29
+ }).join(",");
30
+ if (typeof value === "object") return "";
31
+ return "";
32
+ }
33
+ function applyTemplate(str, ctx) {
34
+ if (!str) return "";
35
+ return str.replace(/{{\s*(\w+)\s*}}/g, (_, key) => {
36
+ const value = ctx[key];
37
+ return formatTemplateValue(value);
38
+ });
39
+ }
40
+
41
+ //#endregion
42
+ //#region src/media-understanding/defaults.ts
43
+ const MB = 1024 * 1024;
44
+ const DEFAULT_MAX_CHARS = 500;
45
+ const DEFAULT_MAX_CHARS_BY_CAPABILITY = {
46
+ image: DEFAULT_MAX_CHARS,
47
+ audio: void 0,
48
+ video: DEFAULT_MAX_CHARS
49
+ };
50
+ const DEFAULT_MAX_BYTES = {
51
+ image: 10 * MB,
52
+ audio: 20 * MB,
53
+ video: 50 * MB
54
+ };
55
+ const DEFAULT_TIMEOUT_SECONDS = {
56
+ image: 60,
57
+ audio: 60,
58
+ video: 120
59
+ };
60
+ const DEFAULT_PROMPT = {
61
+ image: "Describe the image.",
62
+ audio: "Transcribe the audio.",
63
+ video: "Describe the video."
64
+ };
65
+ const DEFAULT_VIDEO_MAX_BASE64_BYTES = 70 * MB;
66
+ const DEFAULT_AUDIO_MODELS = {
67
+ groq: "whisper-large-v3-turbo",
68
+ openai: "gpt-4o-mini-transcribe",
69
+ deepgram: "nova-3"
70
+ };
71
+ const AUTO_AUDIO_KEY_PROVIDERS = [
72
+ "openai",
73
+ "groq",
74
+ "deepgram",
75
+ "google"
76
+ ];
77
+ const AUTO_IMAGE_KEY_PROVIDERS = [
78
+ "openai",
79
+ "anthropic",
80
+ "google",
81
+ "minimax",
82
+ "zai"
83
+ ];
84
+ const AUTO_VIDEO_KEY_PROVIDERS = ["google"];
85
+ const DEFAULT_IMAGE_MODELS = {
86
+ openai: "gpt-5-mini",
87
+ anthropic: "claude-opus-4-6",
88
+ google: "gemini-3-flash-preview",
89
+ minimax: "MiniMax-VL-01",
90
+ zai: "glm-4.6v"
91
+ };
92
+ const CLI_OUTPUT_MAX_BUFFER = 5 * MB;
93
+ const DEFAULT_MEDIA_CONCURRENCY = 2;
94
+
95
+ //#endregion
96
+ //#region src/media-understanding/providers/anthropic/index.ts
97
+ const anthropicProvider = {
98
+ id: "anthropic",
99
+ capabilities: ["image"],
100
+ describeImage: describeImageWithModel
101
+ };
102
+
103
+ //#endregion
104
+ //#region src/media-understanding/providers/shared.ts
105
+ const MAX_ERROR_CHARS = 300;
106
+ function normalizeBaseUrl(baseUrl, fallback) {
107
+ return (baseUrl?.trim() || fallback).replace(/\/+$/, "");
108
+ }
109
+ async function fetchWithTimeoutGuarded(url, init, timeoutMs, fetchFn, options) {
110
+ return await fetchWithSsrFGuard({
111
+ url,
112
+ fetchImpl: fetchFn,
113
+ init,
114
+ timeoutMs,
115
+ policy: options?.ssrfPolicy,
116
+ lookupFn: options?.lookupFn,
117
+ pinDns: options?.pinDns
118
+ });
119
+ }
120
+ async function readErrorResponse(res) {
121
+ try {
122
+ const collapsed = (await res.text()).replace(/\s+/g, " ").trim();
123
+ if (!collapsed) return;
124
+ if (collapsed.length <= MAX_ERROR_CHARS) return collapsed;
125
+ return `${collapsed.slice(0, MAX_ERROR_CHARS)}…`;
126
+ } catch {
127
+ return;
128
+ }
129
+ }
130
+
131
+ //#endregion
132
+ //#region src/media-understanding/providers/deepgram/audio.ts
133
+ const DEFAULT_DEEPGRAM_AUDIO_BASE_URL = "https://api.deepgram.com/v1";
134
+ const DEFAULT_DEEPGRAM_AUDIO_MODEL = "nova-3";
135
+ function resolveModel$3(model) {
136
+ return model?.trim() || DEFAULT_DEEPGRAM_AUDIO_MODEL;
137
+ }
138
+ async function transcribeDeepgramAudio(params) {
139
+ const fetchFn = params.fetchFn ?? fetch;
140
+ const baseUrl = normalizeBaseUrl(params.baseUrl, DEFAULT_DEEPGRAM_AUDIO_BASE_URL);
141
+ const allowPrivate = Boolean(params.baseUrl?.trim());
142
+ const model = resolveModel$3(params.model);
143
+ const url = new URL(`${baseUrl}/listen`);
144
+ url.searchParams.set("model", model);
145
+ if (params.language?.trim()) url.searchParams.set("language", params.language.trim());
146
+ if (params.query) for (const [key, value] of Object.entries(params.query)) {
147
+ if (value === void 0) continue;
148
+ url.searchParams.set(key, String(value));
149
+ }
150
+ const headers = new Headers(params.headers);
151
+ if (!headers.has("authorization")) headers.set("authorization", `Token ${params.apiKey}`);
152
+ if (!headers.has("content-type")) headers.set("content-type", params.mime ?? "application/octet-stream");
153
+ const body = new Uint8Array(params.buffer);
154
+ const { response: res, release } = await fetchWithTimeoutGuarded(url.toString(), {
155
+ method: "POST",
156
+ headers,
157
+ body
158
+ }, params.timeoutMs, fetchFn, allowPrivate ? { ssrfPolicy: { allowPrivateNetwork: true } } : void 0);
159
+ try {
160
+ if (!res.ok) {
161
+ const detail = await readErrorResponse(res);
162
+ const suffix = detail ? `: ${detail}` : "";
163
+ throw new Error(`Audio transcription failed (HTTP ${res.status})${suffix}`);
164
+ }
165
+ const transcript = (await res.json()).results?.channels?.[0]?.alternatives?.[0]?.transcript?.trim();
166
+ if (!transcript) throw new Error("Audio transcription response missing transcript");
167
+ return {
168
+ text: transcript,
169
+ model
170
+ };
171
+ } finally {
172
+ await release();
173
+ }
174
+ }
175
+
176
+ //#endregion
177
+ //#region src/media-understanding/providers/deepgram/index.ts
178
+ const deepgramProvider = {
179
+ id: "deepgram",
180
+ capabilities: ["audio"],
181
+ transcribeAudio: transcribeDeepgramAudio
182
+ };
183
+
184
+ //#endregion
185
+ //#region src/media-understanding/providers/google/audio.ts
186
+ const DEFAULT_GOOGLE_AUDIO_BASE_URL = "https://generativelanguage.googleapis.com/v1beta";
187
+ const DEFAULT_GOOGLE_AUDIO_MODEL = "gemini-3-flash-preview";
188
+ const DEFAULT_GOOGLE_AUDIO_PROMPT = "Transcribe the audio.";
189
+ function resolveModel$2(model) {
190
+ const trimmed = model?.trim();
191
+ if (!trimmed) return DEFAULT_GOOGLE_AUDIO_MODEL;
192
+ return normalizeGoogleModelId(trimmed);
193
+ }
194
+ function resolvePrompt$2(prompt) {
195
+ return prompt?.trim() || DEFAULT_GOOGLE_AUDIO_PROMPT;
196
+ }
197
+ async function transcribeGeminiAudio(params) {
198
+ const fetchFn = params.fetchFn ?? fetch;
199
+ const baseUrl = normalizeBaseUrl(params.baseUrl, DEFAULT_GOOGLE_AUDIO_BASE_URL);
200
+ const allowPrivate = Boolean(params.baseUrl?.trim());
201
+ const model = resolveModel$2(params.model);
202
+ const url = `${baseUrl}/models/${model}:generateContent`;
203
+ const headers = new Headers(params.headers);
204
+ if (!headers.has("content-type")) headers.set("content-type", "application/json");
205
+ if (!headers.has("x-goog-api-key")) headers.set("x-goog-api-key", params.apiKey);
206
+ const body = { contents: [{
207
+ role: "user",
208
+ parts: [{ text: resolvePrompt$2(params.prompt) }, { inline_data: {
209
+ mime_type: params.mime ?? "audio/wav",
210
+ data: params.buffer.toString("base64")
211
+ } }]
212
+ }] };
213
+ const { response: res, release } = await fetchWithTimeoutGuarded(url, {
214
+ method: "POST",
215
+ headers,
216
+ body: JSON.stringify(body)
217
+ }, params.timeoutMs, fetchFn, allowPrivate ? { ssrfPolicy: { allowPrivateNetwork: true } } : void 0);
218
+ try {
219
+ if (!res.ok) {
220
+ const detail = await readErrorResponse(res);
221
+ const suffix = detail ? `: ${detail}` : "";
222
+ throw new Error(`Audio transcription failed (HTTP ${res.status})${suffix}`);
223
+ }
224
+ const text = ((await res.json()).candidates?.[0]?.content?.parts ?? []).map((part) => part?.text?.trim()).filter(Boolean).join("\n");
225
+ if (!text) throw new Error("Audio transcription response missing text");
226
+ return {
227
+ text,
228
+ model
229
+ };
230
+ } finally {
231
+ await release();
232
+ }
233
+ }
234
+
235
+ //#endregion
236
+ //#region src/media-understanding/providers/google/video.ts
237
+ const DEFAULT_GOOGLE_VIDEO_BASE_URL = "https://generativelanguage.googleapis.com/v1beta";
238
+ const DEFAULT_GOOGLE_VIDEO_MODEL = "gemini-3-flash-preview";
239
+ const DEFAULT_GOOGLE_VIDEO_PROMPT = "Describe the video.";
240
+ function resolveModel$1(model) {
241
+ const trimmed = model?.trim();
242
+ if (!trimmed) return DEFAULT_GOOGLE_VIDEO_MODEL;
243
+ return normalizeGoogleModelId(trimmed);
244
+ }
245
+ function resolvePrompt$1(prompt) {
246
+ return prompt?.trim() || DEFAULT_GOOGLE_VIDEO_PROMPT;
247
+ }
248
+ async function describeGeminiVideo(params) {
249
+ const fetchFn = params.fetchFn ?? fetch;
250
+ const baseUrl = normalizeBaseUrl(params.baseUrl, DEFAULT_GOOGLE_VIDEO_BASE_URL);
251
+ const allowPrivate = Boolean(params.baseUrl?.trim());
252
+ const model = resolveModel$1(params.model);
253
+ const url = `${baseUrl}/models/${model}:generateContent`;
254
+ const headers = new Headers(params.headers);
255
+ if (!headers.has("content-type")) headers.set("content-type", "application/json");
256
+ if (!headers.has("x-goog-api-key")) headers.set("x-goog-api-key", params.apiKey);
257
+ const body = { contents: [{
258
+ role: "user",
259
+ parts: [{ text: resolvePrompt$1(params.prompt) }, { inline_data: {
260
+ mime_type: params.mime ?? "video/mp4",
261
+ data: params.buffer.toString("base64")
262
+ } }]
263
+ }] };
264
+ const { response: res, release } = await fetchWithTimeoutGuarded(url, {
265
+ method: "POST",
266
+ headers,
267
+ body: JSON.stringify(body)
268
+ }, params.timeoutMs, fetchFn, allowPrivate ? { ssrfPolicy: { allowPrivateNetwork: true } } : void 0);
269
+ try {
270
+ if (!res.ok) {
271
+ const detail = await readErrorResponse(res);
272
+ const suffix = detail ? `: ${detail}` : "";
273
+ throw new Error(`Video description failed (HTTP ${res.status})${suffix}`);
274
+ }
275
+ const text = ((await res.json()).candidates?.[0]?.content?.parts ?? []).map((part) => part?.text?.trim()).filter(Boolean).join("\n");
276
+ if (!text) throw new Error("Video description response missing text");
277
+ return {
278
+ text,
279
+ model
280
+ };
281
+ } finally {
282
+ await release();
283
+ }
284
+ }
285
+
286
+ //#endregion
287
+ //#region src/media-understanding/providers/google/index.ts
288
+ const googleProvider = {
289
+ id: "google",
290
+ capabilities: [
291
+ "image",
292
+ "audio",
293
+ "video"
294
+ ],
295
+ describeImage: describeImageWithModel,
296
+ transcribeAudio: transcribeGeminiAudio,
297
+ describeVideo: describeGeminiVideo
298
+ };
299
+
300
+ //#endregion
301
+ //#region src/media-understanding/providers/openai/audio.ts
302
+ const DEFAULT_OPENAI_AUDIO_BASE_URL = "https://api.openai.com/v1";
303
+ const DEFAULT_OPENAI_AUDIO_MODEL = "gpt-4o-mini-transcribe";
304
+ function resolveModel(model) {
305
+ return model?.trim() || DEFAULT_OPENAI_AUDIO_MODEL;
306
+ }
307
+ async function transcribeOpenAiCompatibleAudio(params) {
308
+ const fetchFn = params.fetchFn ?? fetch;
309
+ const baseUrl = normalizeBaseUrl(params.baseUrl, DEFAULT_OPENAI_AUDIO_BASE_URL);
310
+ const allowPrivate = Boolean(params.baseUrl?.trim());
311
+ const url = `${baseUrl}/audio/transcriptions`;
312
+ const model = resolveModel(params.model);
313
+ const form = new FormData();
314
+ const fileName = params.fileName?.trim() || path.basename(params.fileName) || "audio";
315
+ const bytes = new Uint8Array(params.buffer);
316
+ const blob = new Blob([bytes], { type: params.mime ?? "application/octet-stream" });
317
+ form.append("file", blob, fileName);
318
+ form.append("model", model);
319
+ if (params.language?.trim()) form.append("language", params.language.trim());
320
+ if (params.prompt?.trim()) form.append("prompt", params.prompt.trim());
321
+ const headers = new Headers(params.headers);
322
+ if (!headers.has("authorization")) headers.set("authorization", `Bearer ${params.apiKey}`);
323
+ const { response: res, release } = await fetchWithTimeoutGuarded(url, {
324
+ method: "POST",
325
+ headers,
326
+ body: form
327
+ }, params.timeoutMs, fetchFn, allowPrivate ? { ssrfPolicy: { allowPrivateNetwork: true } } : void 0);
328
+ try {
329
+ if (!res.ok) {
330
+ const detail = await readErrorResponse(res);
331
+ const suffix = detail ? `: ${detail}` : "";
332
+ throw new Error(`Audio transcription failed (HTTP ${res.status})${suffix}`);
333
+ }
334
+ const text = (await res.json()).text?.trim();
335
+ if (!text) throw new Error("Audio transcription response missing text");
336
+ return {
337
+ text,
338
+ model
339
+ };
340
+ } finally {
341
+ await release();
342
+ }
343
+ }
344
+
345
+ //#endregion
346
+ //#region src/media-understanding/providers/groq/index.ts
347
+ const DEFAULT_GROQ_AUDIO_BASE_URL = "https://api.groq.com/openai/v1";
348
+ const groqProvider = {
349
+ id: "groq",
350
+ capabilities: ["audio"],
351
+ transcribeAudio: (req) => transcribeOpenAiCompatibleAudio({
352
+ ...req,
353
+ baseUrl: req.baseUrl ?? DEFAULT_GROQ_AUDIO_BASE_URL
354
+ })
355
+ };
356
+
357
+ //#endregion
358
+ //#region src/media-understanding/providers/minimax/index.ts
359
+ const minimaxProvider = {
360
+ id: "minimax",
361
+ capabilities: ["image"],
362
+ describeImage: describeImageWithModel
363
+ };
364
+
365
+ //#endregion
366
+ //#region src/media-understanding/providers/openai/index.ts
367
+ const openaiProvider = {
368
+ id: "openai",
369
+ capabilities: ["image"],
370
+ describeImage: describeImageWithModel,
371
+ transcribeAudio: transcribeOpenAiCompatibleAudio
372
+ };
373
+
374
+ //#endregion
375
+ //#region src/media-understanding/providers/zai/index.ts
376
+ const zaiProvider = {
377
+ id: "zai",
378
+ capabilities: ["image"],
379
+ describeImage: describeImageWithModel
380
+ };
381
+
382
+ //#endregion
383
+ //#region src/media-understanding/providers/index.ts
384
+ const PROVIDERS = [
385
+ groqProvider,
386
+ openaiProvider,
387
+ googleProvider,
388
+ anthropicProvider,
389
+ minimaxProvider,
390
+ zaiProvider,
391
+ deepgramProvider
392
+ ];
393
+ function normalizeMediaProviderId(id) {
394
+ const normalized = normalizeProviderId(id);
395
+ if (normalized === "gemini") return "google";
396
+ return normalized;
397
+ }
398
+ function buildMediaUnderstandingRegistry(overrides) {
399
+ const registry = /* @__PURE__ */ new Map();
400
+ for (const provider of PROVIDERS) registry.set(normalizeMediaProviderId(provider.id), provider);
401
+ if (overrides) for (const [key, provider] of Object.entries(overrides)) {
402
+ const normalizedKey = normalizeMediaProviderId(key);
403
+ const existing = registry.get(normalizedKey);
404
+ const merged = existing ? {
405
+ ...existing,
406
+ ...provider,
407
+ capabilities: provider.capabilities ?? existing.capabilities
408
+ } : provider;
409
+ registry.set(normalizedKey, merged);
410
+ }
411
+ return registry;
412
+ }
413
+ function getMediaUnderstandingProvider(id, registry) {
414
+ return registry.get(normalizeMediaProviderId(id));
415
+ }
416
+
417
+ //#endregion
418
+ //#region src/media-understanding/scope.ts
419
+ function normalizeDecision(value) {
420
+ const normalized = value?.trim().toLowerCase();
421
+ if (normalized === "allow") return "allow";
422
+ if (normalized === "deny") return "deny";
423
+ }
424
+ function normalizeMatch(value) {
425
+ return value?.trim().toLowerCase() || void 0;
426
+ }
427
+ function normalizeMediaUnderstandingChatType(raw) {
428
+ return normalizeChatType(raw ?? void 0);
429
+ }
430
+ function resolveMediaUnderstandingScope(params) {
431
+ const scope = params.scope;
432
+ if (!scope) return "allow";
433
+ const channel = normalizeMatch(params.channel);
434
+ const chatType = normalizeMediaUnderstandingChatType(params.chatType);
435
+ const sessionKey = normalizeMatch(params.sessionKey) ?? "";
436
+ for (const rule of scope.rules ?? []) {
437
+ if (!rule) continue;
438
+ const action = normalizeDecision(rule.action) ?? "allow";
439
+ const match = rule.match ?? {};
440
+ const matchChannel = normalizeMatch(match.channel);
441
+ const matchChatType = normalizeMediaUnderstandingChatType(match.chatType);
442
+ const matchPrefix = normalizeMatch(match.keyPrefix);
443
+ if (matchChannel && matchChannel !== channel) continue;
444
+ if (matchChatType && matchChatType !== chatType) continue;
445
+ if (matchPrefix && !sessionKey.startsWith(matchPrefix)) continue;
446
+ return action;
447
+ }
448
+ return normalizeDecision(scope.default) ?? "allow";
449
+ }
450
+
451
+ //#endregion
452
+ //#region src/media-understanding/resolve.ts
453
+ function resolveTimeoutMs(seconds, fallbackSeconds) {
454
+ const value = typeof seconds === "number" && Number.isFinite(seconds) ? seconds : fallbackSeconds;
455
+ return Math.max(1e3, Math.floor(value * 1e3));
456
+ }
457
+ function resolvePrompt(capability, prompt, maxChars) {
458
+ const base = prompt?.trim() || DEFAULT_PROMPT[capability];
459
+ if (!maxChars || capability === "audio") return base;
460
+ return `${base} Respond in at most ${maxChars} characters.`;
461
+ }
462
+ function resolveMaxChars(params) {
463
+ const { capability, entry, cfg } = params;
464
+ const configured = entry.maxChars ?? params.config?.maxChars ?? cfg.tools?.media?.[capability]?.maxChars;
465
+ if (typeof configured === "number") return configured;
466
+ return DEFAULT_MAX_CHARS_BY_CAPABILITY[capability];
467
+ }
468
+ function resolveMaxBytes(params) {
469
+ const configured = params.entry.maxBytes ?? params.config?.maxBytes ?? params.cfg.tools?.media?.[params.capability]?.maxBytes;
470
+ if (typeof configured === "number") return configured;
471
+ return DEFAULT_MAX_BYTES[params.capability];
472
+ }
473
+ function resolveScopeDecision(params) {
474
+ return resolveMediaUnderstandingScope({
475
+ scope: params.scope,
476
+ sessionKey: params.ctx.SessionKey,
477
+ channel: params.ctx.Surface ?? params.ctx.Provider,
478
+ chatType: normalizeMediaUnderstandingChatType(params.ctx.ChatType)
479
+ });
480
+ }
481
+ function resolveEntryCapabilities(params) {
482
+ if ((params.entry.type ?? (params.entry.command ? "cli" : "provider")) === "cli") return;
483
+ const providerId = normalizeMediaProviderId(params.entry.provider ?? "");
484
+ if (!providerId) return;
485
+ return params.providerRegistry.get(providerId)?.capabilities;
486
+ }
487
+ function resolveModelEntries(params) {
488
+ const { cfg, capability, config } = params;
489
+ const sharedModels = cfg.tools?.media?.models ?? [];
490
+ const entries = [...(config?.models ?? []).map((entry) => ({
491
+ entry,
492
+ source: "capability"
493
+ })), ...sharedModels.map((entry) => ({
494
+ entry,
495
+ source: "shared"
496
+ }))];
497
+ if (entries.length === 0) return [];
498
+ return entries.filter(({ entry, source }) => {
499
+ const caps = entry.capabilities && entry.capabilities.length > 0 ? entry.capabilities : source === "shared" ? resolveEntryCapabilities({
500
+ entry,
501
+ providerRegistry: params.providerRegistry
502
+ }) : void 0;
503
+ if (!caps || caps.length === 0) {
504
+ if (source === "shared") {
505
+ if (shouldLogVerbose()) logVerbose(`Skipping shared media model without capabilities: ${entry.provider ?? entry.command ?? "unknown"}`);
506
+ return false;
507
+ }
508
+ return true;
509
+ }
510
+ return caps.includes(capability);
511
+ }).map(({ entry }) => entry);
512
+ }
513
+ function resolveConcurrency(cfg) {
514
+ const configured = cfg.tools?.media?.concurrency;
515
+ if (typeof configured === "number" && Number.isFinite(configured) && configured > 0) return Math.floor(configured);
516
+ return DEFAULT_MEDIA_CONCURRENCY;
517
+ }
518
+
519
+ //#endregion
520
+ //#region src/infra/unhandled-rejections.ts
521
+ const handlers = /* @__PURE__ */ new Set();
522
+ const FATAL_ERROR_CODES = new Set([
523
+ "ERR_OUT_OF_MEMORY",
524
+ "ERR_SCRIPT_EXECUTION_TIMEOUT",
525
+ "ERR_WORKER_OUT_OF_MEMORY",
526
+ "ERR_WORKER_UNCAUGHT_EXCEPTION",
527
+ "ERR_WORKER_INITIALIZATION_FAILED"
528
+ ]);
529
+ const CONFIG_ERROR_CODES = new Set([
530
+ "INVALID_CONFIG",
531
+ "MISSING_API_KEY",
532
+ "MISSING_CREDENTIALS"
533
+ ]);
534
+ const TRANSIENT_NETWORK_CODES = new Set([
535
+ "ECONNRESET",
536
+ "ECONNREFUSED",
537
+ "ENOTFOUND",
538
+ "ETIMEDOUT",
539
+ "ESOCKETTIMEDOUT",
540
+ "ECONNABORTED",
541
+ "EPIPE",
542
+ "EHOSTUNREACH",
543
+ "ENETUNREACH",
544
+ "EAI_AGAIN",
545
+ "UND_ERR_CONNECT_TIMEOUT",
546
+ "UND_ERR_DNS_RESOLVE_FAILED",
547
+ "UND_ERR_CONNECT",
548
+ "UND_ERR_SOCKET",
549
+ "UND_ERR_HEADERS_TIMEOUT",
550
+ "UND_ERR_BODY_TIMEOUT"
551
+ ]);
552
+ function getErrorCause(err) {
553
+ if (!err || typeof err !== "object") return;
554
+ return err.cause;
555
+ }
556
+ function extractErrorCodeWithCause(err) {
557
+ const direct = extractErrorCode(err);
558
+ if (direct) return direct;
559
+ return extractErrorCode(getErrorCause(err));
560
+ }
561
+ /**
562
+ * Checks if an error is an AbortError.
563
+ * These are typically intentional cancellations (e.g., during shutdown) and shouldn't crash.
564
+ */
565
+ function isAbortError(err) {
566
+ if (!err || typeof err !== "object") return false;
567
+ if (("name" in err ? String(err.name) : "") === "AbortError") return true;
568
+ if (("message" in err && typeof err.message === "string" ? err.message : "") === "This operation was aborted") return true;
569
+ return false;
570
+ }
571
+ function isFatalError(err) {
572
+ const code = extractErrorCodeWithCause(err);
573
+ return code !== void 0 && FATAL_ERROR_CODES.has(code);
574
+ }
575
+ function isConfigError(err) {
576
+ const code = extractErrorCodeWithCause(err);
577
+ return code !== void 0 && CONFIG_ERROR_CODES.has(code);
578
+ }
579
+ /**
580
+ * Checks if an error is a transient network error that shouldn't crash the gateway.
581
+ * These are typically temporary connectivity issues that will resolve on their own.
582
+ */
583
+ function isTransientNetworkError(err) {
584
+ if (!err) return false;
585
+ const code = extractErrorCodeWithCause(err);
586
+ if (code && TRANSIENT_NETWORK_CODES.has(code)) return true;
587
+ if (err instanceof TypeError && err.message === "fetch failed") {
588
+ const cause = getErrorCause(err);
589
+ if (cause) return isTransientNetworkError(cause);
590
+ return true;
591
+ }
592
+ const cause = getErrorCause(err);
593
+ if (cause && cause !== err) return isTransientNetworkError(cause);
594
+ if (err instanceof AggregateError && err.errors?.length) return err.errors.some((e) => isTransientNetworkError(e));
595
+ return false;
596
+ }
597
+ function registerUnhandledRejectionHandler(handler) {
598
+ handlers.add(handler);
599
+ return () => {
600
+ handlers.delete(handler);
601
+ };
602
+ }
603
+ function isUnhandledRejectionHandled(reason) {
604
+ for (const handler of handlers) try {
605
+ if (handler(reason)) return true;
606
+ } catch (err) {
607
+ console.error("[openclaw] Unhandled rejection handler failed:", err instanceof Error ? err.stack ?? err.message : err);
608
+ }
609
+ return false;
610
+ }
611
+ function installUnhandledRejectionHandler() {
612
+ process$1.on("unhandledRejection", (reason, _promise) => {
613
+ if (isUnhandledRejectionHandled(reason)) return;
614
+ if (isAbortError(reason)) {
615
+ console.warn("[openclaw] Suppressed AbortError:", formatUncaughtError(reason));
616
+ return;
617
+ }
618
+ if (isFatalError(reason)) {
619
+ console.error("[openclaw] FATAL unhandled rejection:", formatUncaughtError(reason));
620
+ process$1.exit(1);
621
+ return;
622
+ }
623
+ if (isConfigError(reason)) {
624
+ console.error("[openclaw] CONFIGURATION ERROR - requires fix:", formatUncaughtError(reason));
625
+ process$1.exit(1);
626
+ return;
627
+ }
628
+ if (isTransientNetworkError(reason)) {
629
+ console.warn("[openclaw] Non-fatal unhandled rejection (continuing):", formatUncaughtError(reason));
630
+ return;
631
+ }
632
+ console.error("[openclaw] Unhandled promise rejection:", formatUncaughtError(reason));
633
+ process$1.exit(1);
634
+ });
635
+ }
636
+
637
+ //#endregion
638
+ //#region src/media-understanding/errors.ts
639
+ var MediaUnderstandingSkipError = class extends Error {
640
+ constructor(reason, message) {
641
+ super(message);
642
+ this.reason = reason;
643
+ this.name = "MediaUnderstandingSkipError";
644
+ }
645
+ };
646
+ function isMediaUnderstandingSkipError(err) {
647
+ return err instanceof MediaUnderstandingSkipError;
648
+ }
649
+
650
+ //#endregion
651
+ //#region src/media-understanding/attachments.ts
652
+ const DEFAULT_MAX_ATTACHMENTS = 1;
653
+ function normalizeAttachmentPath(raw) {
654
+ const value = raw?.trim();
655
+ if (!value) return;
656
+ if (value.startsWith("file://")) try {
657
+ return fileURLToPath(value);
658
+ } catch {
659
+ return;
660
+ }
661
+ return value;
662
+ }
663
+ function normalizeAttachments(ctx) {
664
+ const pathsFromArray = Array.isArray(ctx.MediaPaths) ? ctx.MediaPaths : void 0;
665
+ const urlsFromArray = Array.isArray(ctx.MediaUrls) ? ctx.MediaUrls : void 0;
666
+ const typesFromArray = Array.isArray(ctx.MediaTypes) ? ctx.MediaTypes : void 0;
667
+ const resolveMime = (count, index) => {
668
+ const typeHint = typesFromArray?.[index];
669
+ const trimmed = typeof typeHint === "string" ? typeHint.trim() : "";
670
+ if (trimmed) return trimmed;
671
+ return count === 1 ? ctx.MediaType : void 0;
672
+ };
673
+ if (pathsFromArray && pathsFromArray.length > 0) {
674
+ const count = pathsFromArray.length;
675
+ const urls = urlsFromArray && urlsFromArray.length > 0 ? urlsFromArray : void 0;
676
+ return pathsFromArray.map((value, index) => ({
677
+ path: value?.trim() || void 0,
678
+ url: urls?.[index] ?? ctx.MediaUrl,
679
+ mime: resolveMime(count, index),
680
+ index
681
+ })).filter((entry) => Boolean(entry.path?.trim() || entry.url?.trim()));
682
+ }
683
+ if (urlsFromArray && urlsFromArray.length > 0) {
684
+ const count = urlsFromArray.length;
685
+ return urlsFromArray.map((value, index) => ({
686
+ path: void 0,
687
+ url: value?.trim() || void 0,
688
+ mime: resolveMime(count, index),
689
+ index
690
+ })).filter((entry) => Boolean(entry.url?.trim()));
691
+ }
692
+ const pathValue = ctx.MediaPath?.trim();
693
+ const url = ctx.MediaUrl?.trim();
694
+ if (!pathValue && !url) return [];
695
+ return [{
696
+ path: pathValue || void 0,
697
+ url: url || void 0,
698
+ mime: ctx.MediaType,
699
+ index: 0
700
+ }];
701
+ }
702
+ function resolveAttachmentKind(attachment) {
703
+ const kind = kindFromMime(attachment.mime);
704
+ if (kind === "image" || kind === "audio" || kind === "video") return kind;
705
+ const ext = getFileExtension(attachment.path ?? attachment.url);
706
+ if (!ext) return "unknown";
707
+ if ([
708
+ ".mp4",
709
+ ".mov",
710
+ ".mkv",
711
+ ".webm",
712
+ ".avi",
713
+ ".m4v"
714
+ ].includes(ext)) return "video";
715
+ if (isAudioFileName(attachment.path ?? attachment.url)) return "audio";
716
+ if ([
717
+ ".png",
718
+ ".jpg",
719
+ ".jpeg",
720
+ ".webp",
721
+ ".gif",
722
+ ".bmp",
723
+ ".tiff",
724
+ ".tif"
725
+ ].includes(ext)) return "image";
726
+ return "unknown";
727
+ }
728
+ function isVideoAttachment(attachment) {
729
+ return resolveAttachmentKind(attachment) === "video";
730
+ }
731
+ function isAudioAttachment(attachment) {
732
+ return resolveAttachmentKind(attachment) === "audio";
733
+ }
734
+ function isImageAttachment(attachment) {
735
+ return resolveAttachmentKind(attachment) === "image";
736
+ }
737
+ function resolveRequestUrl(input) {
738
+ if (typeof input === "string") return input;
739
+ if (input instanceof URL) return input.toString();
740
+ return input.url;
741
+ }
742
+ function orderAttachments(attachments, prefer) {
743
+ if (!prefer || prefer === "first") return attachments;
744
+ if (prefer === "last") return [...attachments].toReversed();
745
+ if (prefer === "path") {
746
+ const withPath = attachments.filter((item) => item.path);
747
+ const withoutPath = attachments.filter((item) => !item.path);
748
+ return [...withPath, ...withoutPath];
749
+ }
750
+ if (prefer === "url") {
751
+ const withUrl = attachments.filter((item) => item.url);
752
+ const withoutUrl = attachments.filter((item) => !item.url);
753
+ return [...withUrl, ...withoutUrl];
754
+ }
755
+ return attachments;
756
+ }
757
+ function selectAttachments(params) {
758
+ const { capability, attachments, policy } = params;
759
+ const matches = attachments.filter((item) => {
760
+ if (capability === "audio" && item.alreadyTranscribed) return false;
761
+ if (capability === "image") return isImageAttachment(item);
762
+ if (capability === "audio") return isAudioAttachment(item);
763
+ return isVideoAttachment(item);
764
+ });
765
+ if (matches.length === 0) return [];
766
+ const ordered = orderAttachments(matches, policy?.prefer);
767
+ const mode = policy?.mode ?? "first";
768
+ const maxAttachments = policy?.maxAttachments ?? DEFAULT_MAX_ATTACHMENTS;
769
+ if (mode === "all") return ordered.slice(0, Math.max(1, maxAttachments));
770
+ return ordered.slice(0, 1);
771
+ }
772
+ var MediaAttachmentCache = class {
773
+ constructor(attachments) {
774
+ this.entries = /* @__PURE__ */ new Map();
775
+ this.attachments = attachments;
776
+ for (const attachment of attachments) this.entries.set(attachment.index, { attachment });
777
+ }
778
+ async getBuffer(params) {
779
+ const entry = await this.ensureEntry(params.attachmentIndex);
780
+ if (entry.buffer) {
781
+ if (entry.buffer.length > params.maxBytes) throw new MediaUnderstandingSkipError("maxBytes", `Attachment ${params.attachmentIndex + 1} exceeds maxBytes ${params.maxBytes}`);
782
+ return {
783
+ buffer: entry.buffer,
784
+ mime: entry.bufferMime,
785
+ fileName: entry.bufferFileName ?? `media-${params.attachmentIndex + 1}`,
786
+ size: entry.buffer.length
787
+ };
788
+ }
789
+ if (entry.resolvedPath) {
790
+ const size = await this.ensureLocalStat(entry);
791
+ if (entry.resolvedPath) {
792
+ if (size !== void 0 && size > params.maxBytes) throw new MediaUnderstandingSkipError("maxBytes", `Attachment ${params.attachmentIndex + 1} exceeds maxBytes ${params.maxBytes}`);
793
+ const buffer = await fs$1.readFile(entry.resolvedPath);
794
+ entry.buffer = buffer;
795
+ entry.bufferMime = entry.bufferMime ?? entry.attachment.mime ?? await detectMime({
796
+ buffer,
797
+ filePath: entry.resolvedPath
798
+ });
799
+ entry.bufferFileName = path.basename(entry.resolvedPath) || `media-${params.attachmentIndex + 1}`;
800
+ return {
801
+ buffer,
802
+ mime: entry.bufferMime,
803
+ fileName: entry.bufferFileName,
804
+ size: buffer.length
805
+ };
806
+ }
807
+ }
808
+ const url = entry.attachment.url?.trim();
809
+ if (!url) throw new MediaUnderstandingSkipError("empty", `Attachment ${params.attachmentIndex + 1} has no path or URL.`);
810
+ try {
811
+ const fetchImpl = (input, init) => fetchWithTimeout(resolveRequestUrl(input), init ?? {}, params.timeoutMs, fetch);
812
+ const fetched = await fetchRemoteMedia({
813
+ url,
814
+ fetchImpl,
815
+ maxBytes: params.maxBytes
816
+ });
817
+ entry.buffer = fetched.buffer;
818
+ entry.bufferMime = entry.attachment.mime ?? fetched.contentType ?? await detectMime({
819
+ buffer: fetched.buffer,
820
+ filePath: fetched.fileName ?? url
821
+ });
822
+ entry.bufferFileName = fetched.fileName ?? `media-${params.attachmentIndex + 1}`;
823
+ return {
824
+ buffer: fetched.buffer,
825
+ mime: entry.bufferMime,
826
+ fileName: entry.bufferFileName,
827
+ size: fetched.buffer.length
828
+ };
829
+ } catch (err) {
830
+ if (err instanceof MediaFetchError && err.code === "max_bytes") throw new MediaUnderstandingSkipError("maxBytes", `Attachment ${params.attachmentIndex + 1} exceeds maxBytes ${params.maxBytes}`);
831
+ if (isAbortError(err)) throw new MediaUnderstandingSkipError("timeout", `Attachment ${params.attachmentIndex + 1} timed out while fetching.`);
832
+ throw err;
833
+ }
834
+ }
835
+ async getPath(params) {
836
+ const entry = await this.ensureEntry(params.attachmentIndex);
837
+ if (entry.resolvedPath) {
838
+ if (params.maxBytes) {
839
+ const size = await this.ensureLocalStat(entry);
840
+ if (entry.resolvedPath) {
841
+ if (size !== void 0 && size > params.maxBytes) throw new MediaUnderstandingSkipError("maxBytes", `Attachment ${params.attachmentIndex + 1} exceeds maxBytes ${params.maxBytes}`);
842
+ }
843
+ }
844
+ if (entry.resolvedPath) return { path: entry.resolvedPath };
845
+ }
846
+ if (entry.tempPath) {
847
+ if (params.maxBytes && entry.buffer && entry.buffer.length > params.maxBytes) throw new MediaUnderstandingSkipError("maxBytes", `Attachment ${params.attachmentIndex + 1} exceeds maxBytes ${params.maxBytes}`);
848
+ return {
849
+ path: entry.tempPath,
850
+ cleanup: entry.tempCleanup
851
+ };
852
+ }
853
+ const maxBytes = params.maxBytes ?? Number.POSITIVE_INFINITY;
854
+ const bufferResult = await this.getBuffer({
855
+ attachmentIndex: params.attachmentIndex,
856
+ maxBytes,
857
+ timeoutMs: params.timeoutMs
858
+ });
859
+ const extension = path.extname(bufferResult.fileName || "") || "";
860
+ const tmpPath = path.join(os.tmpdir(), `openclaw-media-${crypto.randomUUID()}${extension}`);
861
+ await fs$1.writeFile(tmpPath, bufferResult.buffer);
862
+ entry.tempPath = tmpPath;
863
+ entry.tempCleanup = async () => {
864
+ await fs$1.unlink(tmpPath).catch(() => {});
865
+ };
866
+ return {
867
+ path: tmpPath,
868
+ cleanup: entry.tempCleanup
869
+ };
870
+ }
871
+ async cleanup() {
872
+ const cleanups = [];
873
+ for (const entry of this.entries.values()) if (entry.tempCleanup) {
874
+ cleanups.push(Promise.resolve(entry.tempCleanup()));
875
+ entry.tempCleanup = void 0;
876
+ }
877
+ await Promise.all(cleanups);
878
+ }
879
+ async ensureEntry(attachmentIndex) {
880
+ const existing = this.entries.get(attachmentIndex);
881
+ if (existing) {
882
+ if (!existing.resolvedPath) existing.resolvedPath = this.resolveLocalPath(existing.attachment);
883
+ return existing;
884
+ }
885
+ const attachment = this.attachments.find((item) => item.index === attachmentIndex) ?? { index: attachmentIndex };
886
+ const entry = {
887
+ attachment,
888
+ resolvedPath: this.resolveLocalPath(attachment)
889
+ };
890
+ this.entries.set(attachmentIndex, entry);
891
+ return entry;
892
+ }
893
+ resolveLocalPath(attachment) {
894
+ const rawPath = normalizeAttachmentPath(attachment.path);
895
+ if (!rawPath) return;
896
+ return path.isAbsolute(rawPath) ? rawPath : path.resolve(rawPath);
897
+ }
898
+ async ensureLocalStat(entry) {
899
+ if (!entry.resolvedPath) return;
900
+ if (entry.statSize !== void 0) return entry.statSize;
901
+ try {
902
+ const stat = await fs$1.stat(entry.resolvedPath);
903
+ if (!stat.isFile()) {
904
+ entry.resolvedPath = void 0;
905
+ return;
906
+ }
907
+ entry.statSize = stat.size;
908
+ return stat.size;
909
+ } catch (err) {
910
+ entry.resolvedPath = void 0;
911
+ if (shouldLogVerbose()) logVerbose(`Failed to read attachment ${entry.attachment.index + 1}: ${String(err)}`);
912
+ return;
913
+ }
914
+ }
915
+ };
916
+
917
+ //#endregion
918
+ //#region src/agents/model-catalog.ts
919
+ let modelCatalogPromise = null;
920
+ let hasLoggedModelCatalogError = false;
921
+ const defaultImportPiSdk = () => import("./pi-model-discovery-EwKVHlZB.js").then((n) => n.r);
922
+ let importPiSdk = defaultImportPiSdk;
923
+ async function loadModelCatalog(params) {
924
+ if (params?.useCache === false) modelCatalogPromise = null;
925
+ if (modelCatalogPromise) return modelCatalogPromise;
926
+ modelCatalogPromise = (async () => {
927
+ const models = [];
928
+ const sortModels = (entries) => entries.sort((a, b) => {
929
+ const p = a.provider.localeCompare(b.provider);
930
+ if (p !== 0) return p;
931
+ return a.name.localeCompare(b.name);
932
+ });
933
+ try {
934
+ await ensureOpenClawModelsJson(params?.config ?? loadConfig());
935
+ const piSdk = await importPiSdk();
936
+ const agentDir = resolveOpenClawAgentDir();
937
+ const { join } = await import("node:path");
938
+ const authStorage = new piSdk.AuthStorage(join(agentDir, "auth.json"));
939
+ const registry = new piSdk.ModelRegistry(authStorage, join(agentDir, "models.json"));
940
+ const entries = Array.isArray(registry) ? registry : registry.getAll();
941
+ for (const entry of entries) {
942
+ const id = String(entry?.id ?? "").trim();
943
+ if (!id) continue;
944
+ const provider = String(entry?.provider ?? "").trim();
945
+ if (!provider) continue;
946
+ const name = String(entry?.name ?? id).trim() || id;
947
+ const contextWindow = typeof entry?.contextWindow === "number" && entry.contextWindow > 0 ? entry.contextWindow : void 0;
948
+ const reasoning = typeof entry?.reasoning === "boolean" ? entry.reasoning : void 0;
949
+ const input = Array.isArray(entry?.input) ? entry.input : void 0;
950
+ models.push({
951
+ id,
952
+ name,
953
+ provider,
954
+ contextWindow,
955
+ reasoning,
956
+ input
957
+ });
958
+ }
959
+ if (models.length === 0) modelCatalogPromise = null;
960
+ return sortModels(models);
961
+ } catch (error) {
962
+ if (!hasLoggedModelCatalogError) {
963
+ hasLoggedModelCatalogError = true;
964
+ console.warn(`[model-catalog] Failed to load model catalog: ${String(error)}`);
965
+ }
966
+ modelCatalogPromise = null;
967
+ if (models.length > 0) return sortModels(models);
968
+ return [];
969
+ }
970
+ })();
971
+ return modelCatalogPromise;
972
+ }
973
+ /**
974
+ * Check if a model supports image input based on its catalog entry.
975
+ */
976
+ function modelSupportsVision(entry) {
977
+ return entry?.input?.includes("image") ?? false;
978
+ }
979
+ /**
980
+ * Find a model in the catalog by provider and model ID.
981
+ */
982
+ function findModelInCatalog(catalog, provider, modelId) {
983
+ const normalizedProvider = provider.toLowerCase().trim();
984
+ const normalizedModelId = modelId.toLowerCase().trim();
985
+ return catalog.find((entry) => entry.provider.toLowerCase() === normalizedProvider && entry.id.toLowerCase() === normalizedModelId);
986
+ }
987
+
988
+ //#endregion
989
+ //#region src/media-understanding/video.ts
990
+ function estimateBase64Size(bytes) {
991
+ return Math.ceil(bytes / 3) * 4;
992
+ }
993
+ function resolveVideoMaxBase64Bytes(maxBytes) {
994
+ const expanded = Math.floor(maxBytes * (4 / 3));
995
+ return Math.min(expanded, DEFAULT_VIDEO_MAX_BASE64_BYTES);
996
+ }
997
+
998
+ //#endregion
999
+ //#region src/media-understanding/runner.ts
1000
+ function buildProviderRegistry(overrides) {
1001
+ return buildMediaUnderstandingRegistry(overrides);
1002
+ }
1003
+ function normalizeMediaAttachments(ctx) {
1004
+ return normalizeAttachments(ctx);
1005
+ }
1006
+ function createMediaAttachmentCache(attachments) {
1007
+ return new MediaAttachmentCache(attachments);
1008
+ }
1009
+ const binaryCache = /* @__PURE__ */ new Map();
1010
+ const geminiProbeCache = /* @__PURE__ */ new Map();
1011
+ function expandHomeDir(value) {
1012
+ if (!value.startsWith("~")) return value;
1013
+ const home = os.homedir();
1014
+ if (value === "~") return home;
1015
+ if (value.startsWith("~/")) return path.join(home, value.slice(2));
1016
+ return value;
1017
+ }
1018
+ function hasPathSeparator(value) {
1019
+ return value.includes("/") || value.includes("\\");
1020
+ }
1021
+ function candidateBinaryNames(name) {
1022
+ if (process.platform !== "win32") return [name];
1023
+ if (path.extname(name)) return [name];
1024
+ const pathext = (process.env.PATHEXT ?? ".EXE;.CMD;.BAT;.COM").split(";").map((item) => item.trim()).filter(Boolean).map((item) => item.startsWith(".") ? item : `.${item}`);
1025
+ return [name, ...Array.from(new Set(pathext)).map((item) => `${name}${item}`)];
1026
+ }
1027
+ async function isExecutable(filePath) {
1028
+ try {
1029
+ if (!(await fs$1.stat(filePath)).isFile()) return false;
1030
+ if (process.platform === "win32") return true;
1031
+ await fs$1.access(filePath, constants.X_OK);
1032
+ return true;
1033
+ } catch {
1034
+ return false;
1035
+ }
1036
+ }
1037
+ async function findBinary(name) {
1038
+ const cached = binaryCache.get(name);
1039
+ if (cached) return cached;
1040
+ const resolved = (async () => {
1041
+ const direct = expandHomeDir(name.trim());
1042
+ if (direct && hasPathSeparator(direct)) {
1043
+ for (const candidate of candidateBinaryNames(direct)) if (await isExecutable(candidate)) return candidate;
1044
+ }
1045
+ const searchName = name.trim();
1046
+ if (!searchName) return null;
1047
+ const pathEntries = (process.env.PATH ?? "").split(path.delimiter);
1048
+ const candidates = candidateBinaryNames(searchName);
1049
+ for (const entryRaw of pathEntries) {
1050
+ const entry = expandHomeDir(entryRaw.trim().replace(/^"(.*)"$/, "$1"));
1051
+ if (!entry) continue;
1052
+ for (const candidate of candidates) {
1053
+ const fullPath = path.join(entry, candidate);
1054
+ if (await isExecutable(fullPath)) return fullPath;
1055
+ }
1056
+ }
1057
+ return null;
1058
+ })();
1059
+ binaryCache.set(name, resolved);
1060
+ return resolved;
1061
+ }
1062
+ async function hasBinary(name) {
1063
+ return Boolean(await findBinary(name));
1064
+ }
1065
+ async function fileExists(filePath) {
1066
+ if (!filePath) return false;
1067
+ try {
1068
+ await fs$1.stat(filePath);
1069
+ return true;
1070
+ } catch {
1071
+ return false;
1072
+ }
1073
+ }
1074
+ function extractLastJsonObject(raw) {
1075
+ const trimmed = raw.trim();
1076
+ const start = trimmed.lastIndexOf("{");
1077
+ if (start === -1) return null;
1078
+ const slice = trimmed.slice(start);
1079
+ try {
1080
+ return JSON.parse(slice);
1081
+ } catch {
1082
+ return null;
1083
+ }
1084
+ }
1085
+ function extractGeminiResponse(raw) {
1086
+ const payload = extractLastJsonObject(raw);
1087
+ if (!payload || typeof payload !== "object") return null;
1088
+ const response = payload.response;
1089
+ if (typeof response !== "string") return null;
1090
+ return response.trim() || null;
1091
+ }
1092
+ function extractSherpaOnnxText(raw) {
1093
+ const tryParse = (value) => {
1094
+ const trimmed = value.trim();
1095
+ if (!trimmed) return null;
1096
+ const head = trimmed[0];
1097
+ if (head !== "{" && head !== "\"") return null;
1098
+ try {
1099
+ const parsed = JSON.parse(trimmed);
1100
+ if (typeof parsed === "string") return tryParse(parsed);
1101
+ if (parsed && typeof parsed === "object") {
1102
+ const text = parsed.text;
1103
+ if (typeof text === "string" && text.trim()) return text.trim();
1104
+ }
1105
+ } catch {}
1106
+ return null;
1107
+ };
1108
+ const direct = tryParse(raw);
1109
+ if (direct) return direct;
1110
+ const lines = raw.split("\n").map((line) => line.trim()).filter(Boolean);
1111
+ for (let i = lines.length - 1; i >= 0; i -= 1) {
1112
+ const parsed = tryParse(lines[i] ?? "");
1113
+ if (parsed) return parsed;
1114
+ }
1115
+ return null;
1116
+ }
1117
+ async function probeGeminiCli() {
1118
+ const cached = geminiProbeCache.get("gemini");
1119
+ if (cached) return cached;
1120
+ const resolved = (async () => {
1121
+ if (!await hasBinary("gemini")) return false;
1122
+ try {
1123
+ const { stdout } = await runExec("gemini", [
1124
+ "--output-format",
1125
+ "json",
1126
+ "ok"
1127
+ ], { timeoutMs: 8e3 });
1128
+ return Boolean(extractGeminiResponse(stdout) ?? stdout.toLowerCase().includes("ok"));
1129
+ } catch {
1130
+ return false;
1131
+ }
1132
+ })();
1133
+ geminiProbeCache.set("gemini", resolved);
1134
+ return resolved;
1135
+ }
1136
+ async function resolveLocalWhisperCppEntry() {
1137
+ if (!await hasBinary("whisper-cli")) return null;
1138
+ const envModel = process.env.WHISPER_CPP_MODEL?.trim();
1139
+ const modelPath = envModel && await fileExists(envModel) ? envModel : "/opt/homebrew/share/whisper-cpp/for-tests-ggml-tiny.bin";
1140
+ if (!await fileExists(modelPath)) return null;
1141
+ return {
1142
+ type: "cli",
1143
+ command: "whisper-cli",
1144
+ args: [
1145
+ "-m",
1146
+ modelPath,
1147
+ "-otxt",
1148
+ "-of",
1149
+ "{{OutputBase}}",
1150
+ "-np",
1151
+ "-nt",
1152
+ "{{MediaPath}}"
1153
+ ]
1154
+ };
1155
+ }
1156
+ async function resolveLocalWhisperEntry() {
1157
+ if (!await hasBinary("whisper")) return null;
1158
+ return {
1159
+ type: "cli",
1160
+ command: "whisper",
1161
+ args: [
1162
+ "--model",
1163
+ "turbo",
1164
+ "--output_format",
1165
+ "txt",
1166
+ "--output_dir",
1167
+ "{{OutputDir}}",
1168
+ "--verbose",
1169
+ "False",
1170
+ "{{MediaPath}}"
1171
+ ]
1172
+ };
1173
+ }
1174
+ async function resolveSherpaOnnxEntry() {
1175
+ if (!await hasBinary("sherpa-onnx-offline")) return null;
1176
+ const modelDir = process.env.SHERPA_ONNX_MODEL_DIR?.trim();
1177
+ if (!modelDir) return null;
1178
+ const tokens = path.join(modelDir, "tokens.txt");
1179
+ const encoder = path.join(modelDir, "encoder.onnx");
1180
+ const decoder = path.join(modelDir, "decoder.onnx");
1181
+ const joiner = path.join(modelDir, "joiner.onnx");
1182
+ if (!await fileExists(tokens)) return null;
1183
+ if (!await fileExists(encoder)) return null;
1184
+ if (!await fileExists(decoder)) return null;
1185
+ if (!await fileExists(joiner)) return null;
1186
+ return {
1187
+ type: "cli",
1188
+ command: "sherpa-onnx-offline",
1189
+ args: [
1190
+ `--tokens=${tokens}`,
1191
+ `--encoder=${encoder}`,
1192
+ `--decoder=${decoder}`,
1193
+ `--joiner=${joiner}`,
1194
+ "{{MediaPath}}"
1195
+ ]
1196
+ };
1197
+ }
1198
+ async function resolveLocalAudioEntry() {
1199
+ const sherpa = await resolveSherpaOnnxEntry();
1200
+ if (sherpa) return sherpa;
1201
+ const whisperCpp = await resolveLocalWhisperCppEntry();
1202
+ if (whisperCpp) return whisperCpp;
1203
+ return await resolveLocalWhisperEntry();
1204
+ }
1205
+ async function resolveGeminiCliEntry(_capability) {
1206
+ if (!await probeGeminiCli()) return null;
1207
+ return {
1208
+ type: "cli",
1209
+ command: "gemini",
1210
+ args: [
1211
+ "--output-format",
1212
+ "json",
1213
+ "--allowed-tools",
1214
+ "read_many_files",
1215
+ "--include-directories",
1216
+ "{{MediaDir}}",
1217
+ "{{Prompt}}",
1218
+ "Use read_many_files to read {{MediaPath}} and respond with only the text output."
1219
+ ]
1220
+ };
1221
+ }
1222
+ async function resolveKeyEntry(params) {
1223
+ const { cfg, agentDir, providerRegistry, capability } = params;
1224
+ const checkProvider = async (providerId, model) => {
1225
+ const provider = getMediaUnderstandingProvider(providerId, providerRegistry);
1226
+ if (!provider) return null;
1227
+ if (capability === "audio" && !provider.transcribeAudio) return null;
1228
+ if (capability === "image" && !provider.describeImage) return null;
1229
+ if (capability === "video" && !provider.describeVideo) return null;
1230
+ try {
1231
+ await resolveApiKeyForProvider({
1232
+ provider: providerId,
1233
+ cfg,
1234
+ agentDir
1235
+ });
1236
+ return {
1237
+ type: "provider",
1238
+ provider: providerId,
1239
+ model
1240
+ };
1241
+ } catch {
1242
+ return null;
1243
+ }
1244
+ };
1245
+ if (capability === "image") {
1246
+ const activeProvider = params.activeModel?.provider?.trim();
1247
+ if (activeProvider) {
1248
+ const activeEntry = await checkProvider(activeProvider, params.activeModel?.model);
1249
+ if (activeEntry) return activeEntry;
1250
+ }
1251
+ for (const providerId of AUTO_IMAGE_KEY_PROVIDERS) {
1252
+ const model = DEFAULT_IMAGE_MODELS[providerId];
1253
+ const entry = await checkProvider(providerId, model);
1254
+ if (entry) return entry;
1255
+ }
1256
+ return null;
1257
+ }
1258
+ if (capability === "video") {
1259
+ const activeProvider = params.activeModel?.provider?.trim();
1260
+ if (activeProvider) {
1261
+ const activeEntry = await checkProvider(activeProvider, params.activeModel?.model);
1262
+ if (activeEntry) return activeEntry;
1263
+ }
1264
+ for (const providerId of AUTO_VIDEO_KEY_PROVIDERS) {
1265
+ const entry = await checkProvider(providerId, void 0);
1266
+ if (entry) return entry;
1267
+ }
1268
+ return null;
1269
+ }
1270
+ const activeProvider = params.activeModel?.provider?.trim();
1271
+ if (activeProvider) {
1272
+ const activeEntry = await checkProvider(activeProvider, params.activeModel?.model);
1273
+ if (activeEntry) return activeEntry;
1274
+ }
1275
+ for (const providerId of AUTO_AUDIO_KEY_PROVIDERS) {
1276
+ const entry = await checkProvider(providerId, void 0);
1277
+ if (entry) return entry;
1278
+ }
1279
+ return null;
1280
+ }
1281
+ async function resolveAutoEntries(params) {
1282
+ const activeEntry = await resolveActiveModelEntry(params);
1283
+ if (activeEntry) return [activeEntry];
1284
+ if (params.capability === "audio") {
1285
+ const localAudio = await resolveLocalAudioEntry();
1286
+ if (localAudio) return [localAudio];
1287
+ }
1288
+ const gemini = await resolveGeminiCliEntry(params.capability);
1289
+ if (gemini) return [gemini];
1290
+ const keys = await resolveKeyEntry(params);
1291
+ if (keys) return [keys];
1292
+ return [];
1293
+ }
1294
+ async function resolveAutoImageModel(params) {
1295
+ const providerRegistry = buildProviderRegistry();
1296
+ const toActive = (entry) => {
1297
+ if (!entry || entry.type === "cli") return null;
1298
+ const provider = entry.provider;
1299
+ if (!provider) return null;
1300
+ const model = entry.model ?? DEFAULT_IMAGE_MODELS[provider];
1301
+ if (!model) return null;
1302
+ return {
1303
+ provider,
1304
+ model
1305
+ };
1306
+ };
1307
+ const resolvedActive = toActive(await resolveActiveModelEntry({
1308
+ cfg: params.cfg,
1309
+ agentDir: params.agentDir,
1310
+ providerRegistry,
1311
+ capability: "image",
1312
+ activeModel: params.activeModel
1313
+ }));
1314
+ if (resolvedActive) return resolvedActive;
1315
+ return toActive(await resolveKeyEntry({
1316
+ cfg: params.cfg,
1317
+ agentDir: params.agentDir,
1318
+ providerRegistry,
1319
+ capability: "image",
1320
+ activeModel: params.activeModel
1321
+ }));
1322
+ }
1323
+ async function resolveActiveModelEntry(params) {
1324
+ const activeProviderRaw = params.activeModel?.provider?.trim();
1325
+ if (!activeProviderRaw) return null;
1326
+ const providerId = normalizeMediaProviderId(activeProviderRaw);
1327
+ if (!providerId) return null;
1328
+ const provider = getMediaUnderstandingProvider(providerId, params.providerRegistry);
1329
+ if (!provider) return null;
1330
+ if (params.capability === "audio" && !provider.transcribeAudio) return null;
1331
+ if (params.capability === "image" && !provider.describeImage) return null;
1332
+ if (params.capability === "video" && !provider.describeVideo) return null;
1333
+ try {
1334
+ await resolveApiKeyForProvider({
1335
+ provider: providerId,
1336
+ cfg: params.cfg,
1337
+ agentDir: params.agentDir
1338
+ });
1339
+ } catch {
1340
+ return null;
1341
+ }
1342
+ return {
1343
+ type: "provider",
1344
+ provider: providerId,
1345
+ model: params.activeModel?.model
1346
+ };
1347
+ }
1348
+ function trimOutput(text, maxChars) {
1349
+ const trimmed = text.trim();
1350
+ if (!maxChars || trimmed.length <= maxChars) return trimmed;
1351
+ return trimmed.slice(0, maxChars).trim();
1352
+ }
1353
+ function commandBase(command) {
1354
+ return path.parse(command).name;
1355
+ }
1356
+ function findArgValue(args, keys) {
1357
+ for (let i = 0; i < args.length; i += 1) if (keys.includes(args[i] ?? "")) {
1358
+ const value = args[i + 1];
1359
+ if (value) return value;
1360
+ }
1361
+ }
1362
+ function hasArg(args, keys) {
1363
+ return args.some((arg) => keys.includes(arg));
1364
+ }
1365
+ function resolveWhisperOutputPath(args, mediaPath) {
1366
+ const outputDir = findArgValue(args, ["--output_dir", "-o"]);
1367
+ const outputFormat = findArgValue(args, ["--output_format"]);
1368
+ if (!outputDir || !outputFormat) return null;
1369
+ if (!outputFormat.split(",").map((value) => value.trim()).includes("txt")) return null;
1370
+ const base = path.parse(mediaPath).name;
1371
+ return path.join(outputDir, `${base}.txt`);
1372
+ }
1373
+ function resolveWhisperCppOutputPath(args) {
1374
+ if (!hasArg(args, ["-otxt", "--output-txt"])) return null;
1375
+ const outputBase = findArgValue(args, ["-of", "--output-file"]);
1376
+ if (!outputBase) return null;
1377
+ return `${outputBase}.txt`;
1378
+ }
1379
+ async function resolveCliOutput(params) {
1380
+ const commandId = commandBase(params.command);
1381
+ const fileOutput = commandId === "whisper-cli" ? resolveWhisperCppOutputPath(params.args) : commandId === "whisper" ? resolveWhisperOutputPath(params.args, params.mediaPath) : null;
1382
+ if (fileOutput && await fileExists(fileOutput)) try {
1383
+ const content = await fs$1.readFile(fileOutput, "utf8");
1384
+ if (content.trim()) return content.trim();
1385
+ } catch {}
1386
+ if (commandId === "gemini") {
1387
+ const response = extractGeminiResponse(params.stdout);
1388
+ if (response) return response;
1389
+ }
1390
+ if (commandId === "sherpa-onnx-offline") {
1391
+ const response = extractSherpaOnnxText(params.stdout);
1392
+ if (response) return response;
1393
+ }
1394
+ return params.stdout.trim();
1395
+ }
1396
+ function normalizeProviderQuery(options) {
1397
+ if (!options) return;
1398
+ const query = {};
1399
+ for (const [key, value] of Object.entries(options)) {
1400
+ if (value === void 0) continue;
1401
+ query[key] = value;
1402
+ }
1403
+ return Object.keys(query).length > 0 ? query : void 0;
1404
+ }
1405
+ function buildDeepgramCompatQuery(options) {
1406
+ if (!options) return;
1407
+ const query = {};
1408
+ if (typeof options.detectLanguage === "boolean") query.detect_language = options.detectLanguage;
1409
+ if (typeof options.punctuate === "boolean") query.punctuate = options.punctuate;
1410
+ if (typeof options.smartFormat === "boolean") query.smart_format = options.smartFormat;
1411
+ return Object.keys(query).length > 0 ? query : void 0;
1412
+ }
1413
+ function normalizeDeepgramQueryKeys(query) {
1414
+ const normalized = { ...query };
1415
+ if ("detectLanguage" in normalized) {
1416
+ normalized.detect_language = normalized.detectLanguage;
1417
+ delete normalized.detectLanguage;
1418
+ }
1419
+ if ("smartFormat" in normalized) {
1420
+ normalized.smart_format = normalized.smartFormat;
1421
+ delete normalized.smartFormat;
1422
+ }
1423
+ return normalized;
1424
+ }
1425
+ function resolveProviderQuery(params) {
1426
+ const { providerId, config, entry } = params;
1427
+ const mergedOptions = normalizeProviderQuery({
1428
+ ...config?.providerOptions?.[providerId],
1429
+ ...entry.providerOptions?.[providerId]
1430
+ });
1431
+ if (providerId !== "deepgram") return mergedOptions;
1432
+ let query = normalizeDeepgramQueryKeys(mergedOptions ?? {});
1433
+ const compat = buildDeepgramCompatQuery({
1434
+ ...config?.deepgram,
1435
+ ...entry.deepgram
1436
+ });
1437
+ for (const [key, value] of Object.entries(compat ?? {})) if (query[key] === void 0) query[key] = value;
1438
+ return Object.keys(query).length > 0 ? query : void 0;
1439
+ }
1440
+ function buildModelDecision(params) {
1441
+ if (params.entryType === "cli") {
1442
+ const command = params.entry.command?.trim();
1443
+ return {
1444
+ type: "cli",
1445
+ provider: command ?? "cli",
1446
+ model: params.entry.model ?? command,
1447
+ outcome: params.outcome,
1448
+ reason: params.reason
1449
+ };
1450
+ }
1451
+ const providerIdRaw = params.entry.provider?.trim();
1452
+ return {
1453
+ type: "provider",
1454
+ provider: (providerIdRaw ? normalizeMediaProviderId(providerIdRaw) : void 0) ?? providerIdRaw,
1455
+ model: params.entry.model,
1456
+ outcome: params.outcome,
1457
+ reason: params.reason
1458
+ };
1459
+ }
1460
+ function formatDecisionSummary(decision) {
1461
+ const total = decision.attachments.length;
1462
+ const success = decision.attachments.filter((entry) => entry.chosen?.outcome === "success").length;
1463
+ const chosen = decision.attachments.find((entry) => entry.chosen)?.chosen;
1464
+ const provider = chosen?.provider?.trim();
1465
+ const model = chosen?.model?.trim();
1466
+ const modelLabel = provider ? model ? `${provider}/${model}` : provider : void 0;
1467
+ const reason = decision.attachments.flatMap((entry) => entry.attempts.map((attempt) => attempt.reason).filter(Boolean)).find(Boolean);
1468
+ const shortReason = reason ? reason.split(":")[0]?.trim() : void 0;
1469
+ const countLabel = total > 0 ? ` (${success}/${total})` : "";
1470
+ const viaLabel = modelLabel ? ` via ${modelLabel}` : "";
1471
+ const reasonLabel = shortReason ? ` reason=${shortReason}` : "";
1472
+ return `${decision.capability}: ${decision.outcome}${countLabel}${viaLabel}${reasonLabel}`;
1473
+ }
1474
+ async function runProviderEntry(params) {
1475
+ const { entry, capability, cfg } = params;
1476
+ const providerIdRaw = entry.provider?.trim();
1477
+ if (!providerIdRaw) throw new Error(`Provider entry missing provider for ${capability}`);
1478
+ const providerId = normalizeMediaProviderId(providerIdRaw);
1479
+ const maxBytes = resolveMaxBytes({
1480
+ capability,
1481
+ entry,
1482
+ cfg,
1483
+ config: params.config
1484
+ });
1485
+ const maxChars = resolveMaxChars({
1486
+ capability,
1487
+ entry,
1488
+ cfg,
1489
+ config: params.config
1490
+ });
1491
+ const timeoutMs = resolveTimeoutMs(entry.timeoutSeconds ?? params.config?.timeoutSeconds ?? cfg.tools?.media?.[capability]?.timeoutSeconds, DEFAULT_TIMEOUT_SECONDS[capability]);
1492
+ const prompt = resolvePrompt(capability, entry.prompt ?? params.config?.prompt ?? cfg.tools?.media?.[capability]?.prompt, maxChars);
1493
+ if (capability === "image") {
1494
+ if (!params.agentDir) throw new Error("Image understanding requires agentDir");
1495
+ const modelId = entry.model?.trim();
1496
+ if (!modelId) throw new Error("Image understanding requires model id");
1497
+ const media = await params.cache.getBuffer({
1498
+ attachmentIndex: params.attachmentIndex,
1499
+ maxBytes,
1500
+ timeoutMs
1501
+ });
1502
+ const provider = getMediaUnderstandingProvider(providerId, params.providerRegistry);
1503
+ const result = provider?.describeImage ? await provider.describeImage({
1504
+ buffer: media.buffer,
1505
+ fileName: media.fileName,
1506
+ mime: media.mime,
1507
+ model: modelId,
1508
+ provider: providerId,
1509
+ prompt,
1510
+ timeoutMs,
1511
+ profile: entry.profile,
1512
+ preferredProfile: entry.preferredProfile,
1513
+ agentDir: params.agentDir,
1514
+ cfg: params.cfg
1515
+ }) : await describeImageWithModel({
1516
+ buffer: media.buffer,
1517
+ fileName: media.fileName,
1518
+ mime: media.mime,
1519
+ model: modelId,
1520
+ provider: providerId,
1521
+ prompt,
1522
+ timeoutMs,
1523
+ profile: entry.profile,
1524
+ preferredProfile: entry.preferredProfile,
1525
+ agentDir: params.agentDir,
1526
+ cfg: params.cfg
1527
+ });
1528
+ return {
1529
+ kind: "image.description",
1530
+ attachmentIndex: params.attachmentIndex,
1531
+ text: trimOutput(result.text, maxChars),
1532
+ provider: providerId,
1533
+ model: result.model ?? modelId
1534
+ };
1535
+ }
1536
+ const provider = getMediaUnderstandingProvider(providerId, params.providerRegistry);
1537
+ if (!provider) throw new Error(`Media provider not available: ${providerId}`);
1538
+ if (capability === "audio") {
1539
+ if (!provider.transcribeAudio) throw new Error(`Audio transcription provider "${providerId}" not available.`);
1540
+ const media = await params.cache.getBuffer({
1541
+ attachmentIndex: params.attachmentIndex,
1542
+ maxBytes,
1543
+ timeoutMs
1544
+ });
1545
+ const apiKey = requireApiKey(await resolveApiKeyForProvider({
1546
+ provider: providerId,
1547
+ cfg,
1548
+ profileId: entry.profile,
1549
+ preferredProfile: entry.preferredProfile,
1550
+ agentDir: params.agentDir
1551
+ }), providerId);
1552
+ const providerConfig = cfg.models?.providers?.[providerId];
1553
+ const baseUrl = entry.baseUrl ?? params.config?.baseUrl ?? providerConfig?.baseUrl;
1554
+ const mergedHeaders = {
1555
+ ...providerConfig?.headers,
1556
+ ...params.config?.headers,
1557
+ ...entry.headers
1558
+ };
1559
+ const headers = Object.keys(mergedHeaders).length > 0 ? mergedHeaders : void 0;
1560
+ const providerQuery = resolveProviderQuery({
1561
+ providerId,
1562
+ config: params.config,
1563
+ entry
1564
+ });
1565
+ const model = entry.model?.trim() || DEFAULT_AUDIO_MODELS[providerId] || entry.model;
1566
+ const result = await provider.transcribeAudio({
1567
+ buffer: media.buffer,
1568
+ fileName: media.fileName,
1569
+ mime: media.mime,
1570
+ apiKey,
1571
+ baseUrl,
1572
+ headers,
1573
+ model,
1574
+ language: entry.language ?? params.config?.language ?? cfg.tools?.media?.audio?.language,
1575
+ prompt,
1576
+ query: providerQuery,
1577
+ timeoutMs
1578
+ });
1579
+ return {
1580
+ kind: "audio.transcription",
1581
+ attachmentIndex: params.attachmentIndex,
1582
+ text: trimOutput(result.text, maxChars),
1583
+ provider: providerId,
1584
+ model: result.model ?? model
1585
+ };
1586
+ }
1587
+ if (!provider.describeVideo) throw new Error(`Video understanding provider "${providerId}" not available.`);
1588
+ const media = await params.cache.getBuffer({
1589
+ attachmentIndex: params.attachmentIndex,
1590
+ maxBytes,
1591
+ timeoutMs
1592
+ });
1593
+ const estimatedBase64Bytes = estimateBase64Size(media.size);
1594
+ const maxBase64Bytes = resolveVideoMaxBase64Bytes(maxBytes);
1595
+ if (estimatedBase64Bytes > maxBase64Bytes) throw new MediaUnderstandingSkipError("maxBytes", `Video attachment ${params.attachmentIndex + 1} base64 payload ${estimatedBase64Bytes} exceeds ${maxBase64Bytes}`);
1596
+ const apiKey = requireApiKey(await resolveApiKeyForProvider({
1597
+ provider: providerId,
1598
+ cfg,
1599
+ profileId: entry.profile,
1600
+ preferredProfile: entry.preferredProfile,
1601
+ agentDir: params.agentDir
1602
+ }), providerId);
1603
+ const providerConfig = cfg.models?.providers?.[providerId];
1604
+ const result = await provider.describeVideo({
1605
+ buffer: media.buffer,
1606
+ fileName: media.fileName,
1607
+ mime: media.mime,
1608
+ apiKey,
1609
+ baseUrl: providerConfig?.baseUrl,
1610
+ headers: providerConfig?.headers,
1611
+ model: entry.model,
1612
+ prompt,
1613
+ timeoutMs
1614
+ });
1615
+ return {
1616
+ kind: "video.description",
1617
+ attachmentIndex: params.attachmentIndex,
1618
+ text: trimOutput(result.text, maxChars),
1619
+ provider: providerId,
1620
+ model: result.model ?? entry.model
1621
+ };
1622
+ }
1623
+ async function runCliEntry(params) {
1624
+ const { entry, capability, cfg, ctx } = params;
1625
+ const command = entry.command?.trim();
1626
+ const args = entry.args ?? [];
1627
+ if (!command) throw new Error(`CLI entry missing command for ${capability}`);
1628
+ const maxBytes = resolveMaxBytes({
1629
+ capability,
1630
+ entry,
1631
+ cfg,
1632
+ config: params.config
1633
+ });
1634
+ const maxChars = resolveMaxChars({
1635
+ capability,
1636
+ entry,
1637
+ cfg,
1638
+ config: params.config
1639
+ });
1640
+ const timeoutMs = resolveTimeoutMs(entry.timeoutSeconds ?? params.config?.timeoutSeconds ?? cfg.tools?.media?.[capability]?.timeoutSeconds, DEFAULT_TIMEOUT_SECONDS[capability]);
1641
+ const prompt = resolvePrompt(capability, entry.prompt ?? params.config?.prompt ?? cfg.tools?.media?.[capability]?.prompt, maxChars);
1642
+ const pathResult = await params.cache.getPath({
1643
+ attachmentIndex: params.attachmentIndex,
1644
+ maxBytes,
1645
+ timeoutMs
1646
+ });
1647
+ const outputDir = await fs$1.mkdtemp(path.join(os.tmpdir(), "openclaw-media-cli-"));
1648
+ const mediaPath = pathResult.path;
1649
+ const outputBase = path.join(outputDir, path.parse(mediaPath).name);
1650
+ const templCtx = {
1651
+ ...ctx,
1652
+ MediaPath: mediaPath,
1653
+ MediaDir: path.dirname(mediaPath),
1654
+ OutputDir: outputDir,
1655
+ OutputBase: outputBase,
1656
+ Prompt: prompt,
1657
+ MaxChars: maxChars
1658
+ };
1659
+ const argv = [command, ...args].map((part, index) => index === 0 ? part : applyTemplate(part, templCtx));
1660
+ try {
1661
+ if (shouldLogVerbose()) logVerbose(`Media understanding via CLI: ${argv.join(" ")}`);
1662
+ const { stdout } = await runExec(argv[0], argv.slice(1), {
1663
+ timeoutMs,
1664
+ maxBuffer: CLI_OUTPUT_MAX_BUFFER
1665
+ });
1666
+ const text = trimOutput(await resolveCliOutput({
1667
+ command,
1668
+ args: argv.slice(1),
1669
+ stdout,
1670
+ mediaPath
1671
+ }), maxChars);
1672
+ if (!text) return null;
1673
+ return {
1674
+ kind: capability === "audio" ? "audio.transcription" : `${capability}.description`,
1675
+ attachmentIndex: params.attachmentIndex,
1676
+ text,
1677
+ provider: "cli",
1678
+ model: command
1679
+ };
1680
+ } finally {
1681
+ await fs$1.rm(outputDir, {
1682
+ recursive: true,
1683
+ force: true
1684
+ }).catch(() => {});
1685
+ }
1686
+ }
1687
+ async function runAttachmentEntries(params) {
1688
+ const { entries, capability } = params;
1689
+ const attempts = [];
1690
+ for (const entry of entries) {
1691
+ const entryType = entry.type ?? (entry.command ? "cli" : "provider");
1692
+ try {
1693
+ const result = entryType === "cli" ? await runCliEntry({
1694
+ capability,
1695
+ entry,
1696
+ cfg: params.cfg,
1697
+ ctx: params.ctx,
1698
+ attachmentIndex: params.attachmentIndex,
1699
+ cache: params.cache,
1700
+ config: params.config
1701
+ }) : await runProviderEntry({
1702
+ capability,
1703
+ entry,
1704
+ cfg: params.cfg,
1705
+ ctx: params.ctx,
1706
+ attachmentIndex: params.attachmentIndex,
1707
+ cache: params.cache,
1708
+ agentDir: params.agentDir,
1709
+ providerRegistry: params.providerRegistry,
1710
+ config: params.config
1711
+ });
1712
+ if (result) {
1713
+ const decision = buildModelDecision({
1714
+ entry,
1715
+ entryType,
1716
+ outcome: "success"
1717
+ });
1718
+ if (result.provider) decision.provider = result.provider;
1719
+ if (result.model) decision.model = result.model;
1720
+ attempts.push(decision);
1721
+ return {
1722
+ output: result,
1723
+ attempts
1724
+ };
1725
+ }
1726
+ attempts.push(buildModelDecision({
1727
+ entry,
1728
+ entryType,
1729
+ outcome: "skipped",
1730
+ reason: "empty output"
1731
+ }));
1732
+ } catch (err) {
1733
+ if (isMediaUnderstandingSkipError(err)) {
1734
+ attempts.push(buildModelDecision({
1735
+ entry,
1736
+ entryType,
1737
+ outcome: "skipped",
1738
+ reason: `${err.reason}: ${err.message}`
1739
+ }));
1740
+ if (shouldLogVerbose()) logVerbose(`Skipping ${capability} model due to ${err.reason}: ${err.message}`);
1741
+ continue;
1742
+ }
1743
+ attempts.push(buildModelDecision({
1744
+ entry,
1745
+ entryType,
1746
+ outcome: "failed",
1747
+ reason: String(err)
1748
+ }));
1749
+ if (shouldLogVerbose()) logVerbose(`${capability} understanding failed: ${String(err)}`);
1750
+ }
1751
+ }
1752
+ return {
1753
+ output: null,
1754
+ attempts
1755
+ };
1756
+ }
1757
+ async function runCapability(params) {
1758
+ const { capability, cfg, ctx } = params;
1759
+ const config = params.config ?? cfg.tools?.media?.[capability];
1760
+ if (config?.enabled === false) return {
1761
+ outputs: [],
1762
+ decision: {
1763
+ capability,
1764
+ outcome: "disabled",
1765
+ attachments: []
1766
+ }
1767
+ };
1768
+ const attachmentPolicy = config?.attachments;
1769
+ const selected = selectAttachments({
1770
+ capability,
1771
+ attachments: params.media,
1772
+ policy: attachmentPolicy
1773
+ });
1774
+ if (selected.length === 0) return {
1775
+ outputs: [],
1776
+ decision: {
1777
+ capability,
1778
+ outcome: "no-attachment",
1779
+ attachments: []
1780
+ }
1781
+ };
1782
+ if (resolveScopeDecision({
1783
+ scope: config?.scope,
1784
+ ctx
1785
+ }) === "deny") {
1786
+ if (shouldLogVerbose()) logVerbose(`${capability} understanding disabled by scope policy.`);
1787
+ return {
1788
+ outputs: [],
1789
+ decision: {
1790
+ capability,
1791
+ outcome: "scope-deny",
1792
+ attachments: selected.map((item) => ({
1793
+ attachmentIndex: item.index,
1794
+ attempts: []
1795
+ }))
1796
+ }
1797
+ };
1798
+ }
1799
+ const activeProvider = params.activeModel?.provider?.trim();
1800
+ if (capability === "image" && activeProvider) {
1801
+ if (modelSupportsVision(findModelInCatalog(await loadModelCatalog({ config: cfg }), activeProvider, params.activeModel?.model ?? ""))) {
1802
+ if (shouldLogVerbose()) logVerbose("Skipping image understanding: primary model supports vision natively");
1803
+ const model = params.activeModel?.model?.trim();
1804
+ const reason = "primary model supports vision natively";
1805
+ return {
1806
+ outputs: [],
1807
+ decision: {
1808
+ capability,
1809
+ outcome: "skipped",
1810
+ attachments: selected.map((item) => {
1811
+ const attempt = {
1812
+ type: "provider",
1813
+ provider: activeProvider,
1814
+ model: model || void 0,
1815
+ outcome: "skipped",
1816
+ reason
1817
+ };
1818
+ return {
1819
+ attachmentIndex: item.index,
1820
+ attempts: [attempt],
1821
+ chosen: attempt
1822
+ };
1823
+ })
1824
+ }
1825
+ };
1826
+ }
1827
+ }
1828
+ let resolvedEntries = resolveModelEntries({
1829
+ cfg,
1830
+ capability,
1831
+ config,
1832
+ providerRegistry: params.providerRegistry
1833
+ });
1834
+ if (resolvedEntries.length === 0) resolvedEntries = await resolveAutoEntries({
1835
+ cfg,
1836
+ agentDir: params.agentDir,
1837
+ providerRegistry: params.providerRegistry,
1838
+ capability,
1839
+ activeModel: params.activeModel
1840
+ });
1841
+ if (resolvedEntries.length === 0) return {
1842
+ outputs: [],
1843
+ decision: {
1844
+ capability,
1845
+ outcome: "skipped",
1846
+ attachments: selected.map((item) => ({
1847
+ attachmentIndex: item.index,
1848
+ attempts: []
1849
+ }))
1850
+ }
1851
+ };
1852
+ const outputs = [];
1853
+ const attachmentDecisions = [];
1854
+ for (const attachment of selected) {
1855
+ const { output, attempts } = await runAttachmentEntries({
1856
+ capability,
1857
+ cfg,
1858
+ ctx,
1859
+ attachmentIndex: attachment.index,
1860
+ agentDir: params.agentDir,
1861
+ providerRegistry: params.providerRegistry,
1862
+ cache: params.attachments,
1863
+ entries: resolvedEntries,
1864
+ config
1865
+ });
1866
+ if (output) outputs.push(output);
1867
+ attachmentDecisions.push({
1868
+ attachmentIndex: attachment.index,
1869
+ attempts,
1870
+ chosen: attempts.find((attempt) => attempt.outcome === "success")
1871
+ });
1872
+ }
1873
+ const decision = {
1874
+ capability,
1875
+ outcome: outputs.length > 0 ? "success" : "skipped",
1876
+ attachments: attachmentDecisions
1877
+ };
1878
+ if (shouldLogVerbose()) logVerbose(`Media understanding ${formatDecisionSummary(decision)}`);
1879
+ return {
1880
+ outputs,
1881
+ decision
1882
+ };
1883
+ }
1884
+
1885
+ //#endregion
1886
+ export { CLI_OUTPUT_MAX_BUFFER as _, runCapability as a, modelSupportsVision as c, installUnhandledRejectionHandler as d, registerUnhandledRejectionHandler as f, resolveMediaUnderstandingScope as g, normalizeMediaUnderstandingChatType as h, resolveAutoImageModel as i, isAudioAttachment as l, resolveTimeoutMs as m, createMediaAttachmentCache as n, findModelInCatalog as o, resolveConcurrency as p, normalizeMediaAttachments as r, loadModelCatalog as s, buildProviderRegistry as t, resolveAttachmentKind as u, applyTemplate as v };