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,1785 @@
1
+ import { J as logVerbose, X as shouldLogVerbose, n as runExec } from "./exec-CJFFoM7H.js";
2
+ import { B as resolveOpenClawAgentDir, b as resolveApiKeyForProvider, f as normalizeGoogleModelId, o as normalizeProviderId, y as requireApiKey } from "./model-selection-C1GmkTAV.js";
3
+ import { Cn as getFileExtension, Dn as kindFromMime, Kn as normalizeChatType, Tn as isAudioFileName, xn as detectMime } from "./pi-embedded-helpers-CUzTc1v6.js";
4
+ import { t as loadConfig } from "./config-QYrbd7x7.js";
5
+ import { b as ensureOpenClawModelsJson, t as describeImageWithModel } from "./image-RKwc3fsL.js";
6
+ import { i as fetchWithSsrFGuard, n as MediaFetchError, r as fetchRemoteMedia, t as fetchWithTimeout } from "./fetch-timeout-DEoXG_SF.js";
7
+ import path from "node:path";
8
+ import { constants } from "node:fs";
9
+ import os from "node:os";
10
+ import fs$1 from "node:fs/promises";
11
+ import { fileURLToPath } from "node:url";
12
+ import crypto from "node:crypto";
13
+ import process$1 from "node:process";
14
+
15
+ //#region src/auto-reply/templating.ts
16
+ function formatTemplateValue(value) {
17
+ if (value == null) return "";
18
+ if (typeof value === "string") return value;
19
+ if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") return String(value);
20
+ if (typeof value === "symbol" || typeof value === "function") return value.toString();
21
+ if (Array.isArray(value)) return value.flatMap((entry) => {
22
+ if (entry == null) return [];
23
+ if (typeof entry === "string") return [entry];
24
+ if (typeof entry === "number" || typeof entry === "boolean" || typeof entry === "bigint") return [String(entry)];
25
+ return [];
26
+ }).join(",");
27
+ if (typeof value === "object") return "";
28
+ return "";
29
+ }
30
+ function applyTemplate(str, ctx) {
31
+ if (!str) return "";
32
+ return str.replace(/{{\s*(\w+)\s*}}/g, (_, key) => {
33
+ const value = ctx[key];
34
+ return formatTemplateValue(value);
35
+ });
36
+ }
37
+
38
+ //#endregion
39
+ //#region src/media-understanding/defaults.ts
40
+ const MB = 1024 * 1024;
41
+ const DEFAULT_MAX_CHARS = 500;
42
+ const DEFAULT_MAX_CHARS_BY_CAPABILITY = {
43
+ image: DEFAULT_MAX_CHARS,
44
+ audio: void 0,
45
+ video: DEFAULT_MAX_CHARS
46
+ };
47
+ const DEFAULT_MAX_BYTES = {
48
+ image: 10 * MB,
49
+ audio: 20 * MB,
50
+ video: 50 * MB
51
+ };
52
+ const DEFAULT_TIMEOUT_SECONDS = {
53
+ image: 60,
54
+ audio: 60,
55
+ video: 120
56
+ };
57
+ const DEFAULT_PROMPT = {
58
+ image: "Describe the image.",
59
+ audio: "Transcribe the audio.",
60
+ video: "Describe the video."
61
+ };
62
+ const DEFAULT_VIDEO_MAX_BASE64_BYTES = 70 * MB;
63
+ const DEFAULT_AUDIO_MODELS = {
64
+ groq: "whisper-large-v3-turbo",
65
+ openai: "gpt-4o-mini-transcribe",
66
+ deepgram: "nova-3"
67
+ };
68
+ const AUTO_AUDIO_KEY_PROVIDERS = [
69
+ "openai",
70
+ "groq",
71
+ "deepgram",
72
+ "google"
73
+ ];
74
+ const AUTO_IMAGE_KEY_PROVIDERS = [
75
+ "openai",
76
+ "anthropic",
77
+ "google",
78
+ "minimax",
79
+ "zai"
80
+ ];
81
+ const AUTO_VIDEO_KEY_PROVIDERS = ["google"];
82
+ const DEFAULT_IMAGE_MODELS = {
83
+ openai: "gpt-5-mini",
84
+ anthropic: "claude-opus-4-6",
85
+ google: "gemini-3-flash-preview",
86
+ minimax: "MiniMax-VL-01",
87
+ zai: "glm-4.6v"
88
+ };
89
+ const CLI_OUTPUT_MAX_BUFFER = 5 * MB;
90
+ const DEFAULT_MEDIA_CONCURRENCY = 2;
91
+
92
+ //#endregion
93
+ //#region src/media-understanding/providers/anthropic/index.ts
94
+ const anthropicProvider = {
95
+ id: "anthropic",
96
+ capabilities: ["image"],
97
+ describeImage: describeImageWithModel
98
+ };
99
+
100
+ //#endregion
101
+ //#region src/media-understanding/providers/shared.ts
102
+ const MAX_ERROR_CHARS = 300;
103
+ function normalizeBaseUrl(baseUrl, fallback) {
104
+ return (baseUrl?.trim() || fallback).replace(/\/+$/, "");
105
+ }
106
+ async function fetchWithTimeoutGuarded(url, init, timeoutMs, fetchFn, options) {
107
+ return await fetchWithSsrFGuard({
108
+ url,
109
+ fetchImpl: fetchFn,
110
+ init,
111
+ timeoutMs,
112
+ policy: options?.ssrfPolicy,
113
+ lookupFn: options?.lookupFn,
114
+ pinDns: options?.pinDns
115
+ });
116
+ }
117
+ async function readErrorResponse(res) {
118
+ try {
119
+ const collapsed = (await res.text()).replace(/\s+/g, " ").trim();
120
+ if (!collapsed) return;
121
+ if (collapsed.length <= MAX_ERROR_CHARS) return collapsed;
122
+ return `${collapsed.slice(0, MAX_ERROR_CHARS)}…`;
123
+ } catch {
124
+ return;
125
+ }
126
+ }
127
+
128
+ //#endregion
129
+ //#region src/media-understanding/providers/deepgram/audio.ts
130
+ const DEFAULT_DEEPGRAM_AUDIO_BASE_URL = "https://api.deepgram.com/v1";
131
+ const DEFAULT_DEEPGRAM_AUDIO_MODEL = "nova-3";
132
+ function resolveModel$3(model) {
133
+ return model?.trim() || DEFAULT_DEEPGRAM_AUDIO_MODEL;
134
+ }
135
+ async function transcribeDeepgramAudio(params) {
136
+ const fetchFn = params.fetchFn ?? fetch;
137
+ const baseUrl = normalizeBaseUrl(params.baseUrl, DEFAULT_DEEPGRAM_AUDIO_BASE_URL);
138
+ const allowPrivate = Boolean(params.baseUrl?.trim());
139
+ const model = resolveModel$3(params.model);
140
+ const url = new URL(`${baseUrl}/listen`);
141
+ url.searchParams.set("model", model);
142
+ if (params.language?.trim()) url.searchParams.set("language", params.language.trim());
143
+ if (params.query) for (const [key, value] of Object.entries(params.query)) {
144
+ if (value === void 0) continue;
145
+ url.searchParams.set(key, String(value));
146
+ }
147
+ const headers = new Headers(params.headers);
148
+ if (!headers.has("authorization")) headers.set("authorization", `Token ${params.apiKey}`);
149
+ if (!headers.has("content-type")) headers.set("content-type", params.mime ?? "application/octet-stream");
150
+ const body = new Uint8Array(params.buffer);
151
+ const { response: res, release } = await fetchWithTimeoutGuarded(url.toString(), {
152
+ method: "POST",
153
+ headers,
154
+ body
155
+ }, params.timeoutMs, fetchFn, allowPrivate ? { ssrfPolicy: { allowPrivateNetwork: true } } : void 0);
156
+ try {
157
+ if (!res.ok) {
158
+ const detail = await readErrorResponse(res);
159
+ const suffix = detail ? `: ${detail}` : "";
160
+ throw new Error(`Audio transcription failed (HTTP ${res.status})${suffix}`);
161
+ }
162
+ const transcript = (await res.json()).results?.channels?.[0]?.alternatives?.[0]?.transcript?.trim();
163
+ if (!transcript) throw new Error("Audio transcription response missing transcript");
164
+ return {
165
+ text: transcript,
166
+ model
167
+ };
168
+ } finally {
169
+ await release();
170
+ }
171
+ }
172
+
173
+ //#endregion
174
+ //#region src/media-understanding/providers/deepgram/index.ts
175
+ const deepgramProvider = {
176
+ id: "deepgram",
177
+ capabilities: ["audio"],
178
+ transcribeAudio: transcribeDeepgramAudio
179
+ };
180
+
181
+ //#endregion
182
+ //#region src/media-understanding/providers/google/audio.ts
183
+ const DEFAULT_GOOGLE_AUDIO_BASE_URL = "https://generativelanguage.googleapis.com/v1beta";
184
+ const DEFAULT_GOOGLE_AUDIO_MODEL = "gemini-3-flash-preview";
185
+ const DEFAULT_GOOGLE_AUDIO_PROMPT = "Transcribe the audio.";
186
+ function resolveModel$2(model) {
187
+ const trimmed = model?.trim();
188
+ if (!trimmed) return DEFAULT_GOOGLE_AUDIO_MODEL;
189
+ return normalizeGoogleModelId(trimmed);
190
+ }
191
+ function resolvePrompt$2(prompt) {
192
+ return prompt?.trim() || DEFAULT_GOOGLE_AUDIO_PROMPT;
193
+ }
194
+ async function transcribeGeminiAudio(params) {
195
+ const fetchFn = params.fetchFn ?? fetch;
196
+ const baseUrl = normalizeBaseUrl(params.baseUrl, DEFAULT_GOOGLE_AUDIO_BASE_URL);
197
+ const allowPrivate = Boolean(params.baseUrl?.trim());
198
+ const model = resolveModel$2(params.model);
199
+ const url = `${baseUrl}/models/${model}:generateContent`;
200
+ const headers = new Headers(params.headers);
201
+ if (!headers.has("content-type")) headers.set("content-type", "application/json");
202
+ if (!headers.has("x-goog-api-key")) headers.set("x-goog-api-key", params.apiKey);
203
+ const body = { contents: [{
204
+ role: "user",
205
+ parts: [{ text: resolvePrompt$2(params.prompt) }, { inline_data: {
206
+ mime_type: params.mime ?? "audio/wav",
207
+ data: params.buffer.toString("base64")
208
+ } }]
209
+ }] };
210
+ const { response: res, release } = await fetchWithTimeoutGuarded(url, {
211
+ method: "POST",
212
+ headers,
213
+ body: JSON.stringify(body)
214
+ }, params.timeoutMs, fetchFn, allowPrivate ? { ssrfPolicy: { allowPrivateNetwork: true } } : void 0);
215
+ try {
216
+ if (!res.ok) {
217
+ const detail = await readErrorResponse(res);
218
+ const suffix = detail ? `: ${detail}` : "";
219
+ throw new Error(`Audio transcription failed (HTTP ${res.status})${suffix}`);
220
+ }
221
+ const text = ((await res.json()).candidates?.[0]?.content?.parts ?? []).map((part) => part?.text?.trim()).filter(Boolean).join("\n");
222
+ if (!text) throw new Error("Audio transcription response missing text");
223
+ return {
224
+ text,
225
+ model
226
+ };
227
+ } finally {
228
+ await release();
229
+ }
230
+ }
231
+
232
+ //#endregion
233
+ //#region src/media-understanding/providers/google/video.ts
234
+ const DEFAULT_GOOGLE_VIDEO_BASE_URL = "https://generativelanguage.googleapis.com/v1beta";
235
+ const DEFAULT_GOOGLE_VIDEO_MODEL = "gemini-3-flash-preview";
236
+ const DEFAULT_GOOGLE_VIDEO_PROMPT = "Describe the video.";
237
+ function resolveModel$1(model) {
238
+ const trimmed = model?.trim();
239
+ if (!trimmed) return DEFAULT_GOOGLE_VIDEO_MODEL;
240
+ return normalizeGoogleModelId(trimmed);
241
+ }
242
+ function resolvePrompt$1(prompt) {
243
+ return prompt?.trim() || DEFAULT_GOOGLE_VIDEO_PROMPT;
244
+ }
245
+ async function describeGeminiVideo(params) {
246
+ const fetchFn = params.fetchFn ?? fetch;
247
+ const baseUrl = normalizeBaseUrl(params.baseUrl, DEFAULT_GOOGLE_VIDEO_BASE_URL);
248
+ const allowPrivate = Boolean(params.baseUrl?.trim());
249
+ const model = resolveModel$1(params.model);
250
+ const url = `${baseUrl}/models/${model}:generateContent`;
251
+ const headers = new Headers(params.headers);
252
+ if (!headers.has("content-type")) headers.set("content-type", "application/json");
253
+ if (!headers.has("x-goog-api-key")) headers.set("x-goog-api-key", params.apiKey);
254
+ const body = { contents: [{
255
+ role: "user",
256
+ parts: [{ text: resolvePrompt$1(params.prompt) }, { inline_data: {
257
+ mime_type: params.mime ?? "video/mp4",
258
+ data: params.buffer.toString("base64")
259
+ } }]
260
+ }] };
261
+ const { response: res, release } = await fetchWithTimeoutGuarded(url, {
262
+ method: "POST",
263
+ headers,
264
+ body: JSON.stringify(body)
265
+ }, params.timeoutMs, fetchFn, allowPrivate ? { ssrfPolicy: { allowPrivateNetwork: true } } : void 0);
266
+ try {
267
+ if (!res.ok) {
268
+ const detail = await readErrorResponse(res);
269
+ const suffix = detail ? `: ${detail}` : "";
270
+ throw new Error(`Video description failed (HTTP ${res.status})${suffix}`);
271
+ }
272
+ const text = ((await res.json()).candidates?.[0]?.content?.parts ?? []).map((part) => part?.text?.trim()).filter(Boolean).join("\n");
273
+ if (!text) throw new Error("Video description response missing text");
274
+ return {
275
+ text,
276
+ model
277
+ };
278
+ } finally {
279
+ await release();
280
+ }
281
+ }
282
+
283
+ //#endregion
284
+ //#region src/media-understanding/providers/google/index.ts
285
+ const googleProvider = {
286
+ id: "google",
287
+ capabilities: [
288
+ "image",
289
+ "audio",
290
+ "video"
291
+ ],
292
+ describeImage: describeImageWithModel,
293
+ transcribeAudio: transcribeGeminiAudio,
294
+ describeVideo: describeGeminiVideo
295
+ };
296
+
297
+ //#endregion
298
+ //#region src/media-understanding/providers/openai/audio.ts
299
+ const DEFAULT_OPENAI_AUDIO_BASE_URL = "https://api.openai.com/v1";
300
+ const DEFAULT_OPENAI_AUDIO_MODEL = "gpt-4o-mini-transcribe";
301
+ function resolveModel(model) {
302
+ return model?.trim() || DEFAULT_OPENAI_AUDIO_MODEL;
303
+ }
304
+ async function transcribeOpenAiCompatibleAudio(params) {
305
+ const fetchFn = params.fetchFn ?? fetch;
306
+ const baseUrl = normalizeBaseUrl(params.baseUrl, DEFAULT_OPENAI_AUDIO_BASE_URL);
307
+ const allowPrivate = Boolean(params.baseUrl?.trim());
308
+ const url = `${baseUrl}/audio/transcriptions`;
309
+ const model = resolveModel(params.model);
310
+ const form = new FormData();
311
+ const fileName = params.fileName?.trim() || path.basename(params.fileName) || "audio";
312
+ const bytes = new Uint8Array(params.buffer);
313
+ const blob = new Blob([bytes], { type: params.mime ?? "application/octet-stream" });
314
+ form.append("file", blob, fileName);
315
+ form.append("model", model);
316
+ if (params.language?.trim()) form.append("language", params.language.trim());
317
+ if (params.prompt?.trim()) form.append("prompt", params.prompt.trim());
318
+ const headers = new Headers(params.headers);
319
+ if (!headers.has("authorization")) headers.set("authorization", `Bearer ${params.apiKey}`);
320
+ const { response: res, release } = await fetchWithTimeoutGuarded(url, {
321
+ method: "POST",
322
+ headers,
323
+ body: form
324
+ }, params.timeoutMs, fetchFn, allowPrivate ? { ssrfPolicy: { allowPrivateNetwork: true } } : void 0);
325
+ try {
326
+ if (!res.ok) {
327
+ const detail = await readErrorResponse(res);
328
+ const suffix = detail ? `: ${detail}` : "";
329
+ throw new Error(`Audio transcription failed (HTTP ${res.status})${suffix}`);
330
+ }
331
+ const text = (await res.json()).text?.trim();
332
+ if (!text) throw new Error("Audio transcription response missing text");
333
+ return {
334
+ text,
335
+ model
336
+ };
337
+ } finally {
338
+ await release();
339
+ }
340
+ }
341
+
342
+ //#endregion
343
+ //#region src/media-understanding/providers/groq/index.ts
344
+ const DEFAULT_GROQ_AUDIO_BASE_URL = "https://api.groq.com/openai/v1";
345
+ const groqProvider = {
346
+ id: "groq",
347
+ capabilities: ["audio"],
348
+ transcribeAudio: (req) => transcribeOpenAiCompatibleAudio({
349
+ ...req,
350
+ baseUrl: req.baseUrl ?? DEFAULT_GROQ_AUDIO_BASE_URL
351
+ })
352
+ };
353
+
354
+ //#endregion
355
+ //#region src/media-understanding/providers/minimax/index.ts
356
+ const minimaxProvider = {
357
+ id: "minimax",
358
+ capabilities: ["image"],
359
+ describeImage: describeImageWithModel
360
+ };
361
+
362
+ //#endregion
363
+ //#region src/media-understanding/providers/openai/index.ts
364
+ const openaiProvider = {
365
+ id: "openai",
366
+ capabilities: ["image"],
367
+ describeImage: describeImageWithModel,
368
+ transcribeAudio: transcribeOpenAiCompatibleAudio
369
+ };
370
+
371
+ //#endregion
372
+ //#region src/media-understanding/providers/zai/index.ts
373
+ const zaiProvider = {
374
+ id: "zai",
375
+ capabilities: ["image"],
376
+ describeImage: describeImageWithModel
377
+ };
378
+
379
+ //#endregion
380
+ //#region src/media-understanding/providers/index.ts
381
+ const PROVIDERS = [
382
+ groqProvider,
383
+ openaiProvider,
384
+ googleProvider,
385
+ anthropicProvider,
386
+ minimaxProvider,
387
+ zaiProvider,
388
+ deepgramProvider
389
+ ];
390
+ function normalizeMediaProviderId(id) {
391
+ const normalized = normalizeProviderId(id);
392
+ if (normalized === "gemini") return "google";
393
+ return normalized;
394
+ }
395
+ function buildMediaUnderstandingRegistry(overrides) {
396
+ const registry = /* @__PURE__ */ new Map();
397
+ for (const provider of PROVIDERS) registry.set(normalizeMediaProviderId(provider.id), provider);
398
+ if (overrides) for (const [key, provider] of Object.entries(overrides)) {
399
+ const normalizedKey = normalizeMediaProviderId(key);
400
+ const existing = registry.get(normalizedKey);
401
+ const merged = existing ? {
402
+ ...existing,
403
+ ...provider,
404
+ capabilities: provider.capabilities ?? existing.capabilities
405
+ } : provider;
406
+ registry.set(normalizedKey, merged);
407
+ }
408
+ return registry;
409
+ }
410
+ function getMediaUnderstandingProvider(id, registry) {
411
+ return registry.get(normalizeMediaProviderId(id));
412
+ }
413
+
414
+ //#endregion
415
+ //#region src/media-understanding/scope.ts
416
+ function normalizeDecision(value) {
417
+ const normalized = value?.trim().toLowerCase();
418
+ if (normalized === "allow") return "allow";
419
+ if (normalized === "deny") return "deny";
420
+ }
421
+ function normalizeMatch(value) {
422
+ return value?.trim().toLowerCase() || void 0;
423
+ }
424
+ function normalizeMediaUnderstandingChatType(raw) {
425
+ return normalizeChatType(raw ?? void 0);
426
+ }
427
+ function resolveMediaUnderstandingScope(params) {
428
+ const scope = params.scope;
429
+ if (!scope) return "allow";
430
+ const channel = normalizeMatch(params.channel);
431
+ const chatType = normalizeMediaUnderstandingChatType(params.chatType);
432
+ const sessionKey = normalizeMatch(params.sessionKey) ?? "";
433
+ for (const rule of scope.rules ?? []) {
434
+ if (!rule) continue;
435
+ const action = normalizeDecision(rule.action) ?? "allow";
436
+ const match = rule.match ?? {};
437
+ const matchChannel = normalizeMatch(match.channel);
438
+ const matchChatType = normalizeMediaUnderstandingChatType(match.chatType);
439
+ const matchPrefix = normalizeMatch(match.keyPrefix);
440
+ if (matchChannel && matchChannel !== channel) continue;
441
+ if (matchChatType && matchChatType !== chatType) continue;
442
+ if (matchPrefix && !sessionKey.startsWith(matchPrefix)) continue;
443
+ return action;
444
+ }
445
+ return normalizeDecision(scope.default) ?? "allow";
446
+ }
447
+
448
+ //#endregion
449
+ //#region src/media-understanding/resolve.ts
450
+ function resolveTimeoutMs(seconds, fallbackSeconds) {
451
+ const value = typeof seconds === "number" && Number.isFinite(seconds) ? seconds : fallbackSeconds;
452
+ return Math.max(1e3, Math.floor(value * 1e3));
453
+ }
454
+ function resolvePrompt(capability, prompt, maxChars) {
455
+ const base = prompt?.trim() || DEFAULT_PROMPT[capability];
456
+ if (!maxChars || capability === "audio") return base;
457
+ return `${base} Respond in at most ${maxChars} characters.`;
458
+ }
459
+ function resolveMaxChars(params) {
460
+ const { capability, entry, cfg } = params;
461
+ const configured = entry.maxChars ?? params.config?.maxChars ?? cfg.tools?.media?.[capability]?.maxChars;
462
+ if (typeof configured === "number") return configured;
463
+ return DEFAULT_MAX_CHARS_BY_CAPABILITY[capability];
464
+ }
465
+ function resolveMaxBytes(params) {
466
+ const configured = params.entry.maxBytes ?? params.config?.maxBytes ?? params.cfg.tools?.media?.[params.capability]?.maxBytes;
467
+ if (typeof configured === "number") return configured;
468
+ return DEFAULT_MAX_BYTES[params.capability];
469
+ }
470
+ function resolveScopeDecision(params) {
471
+ return resolveMediaUnderstandingScope({
472
+ scope: params.scope,
473
+ sessionKey: params.ctx.SessionKey,
474
+ channel: params.ctx.Surface ?? params.ctx.Provider,
475
+ chatType: normalizeMediaUnderstandingChatType(params.ctx.ChatType)
476
+ });
477
+ }
478
+ function resolveEntryCapabilities(params) {
479
+ if ((params.entry.type ?? (params.entry.command ? "cli" : "provider")) === "cli") return;
480
+ const providerId = normalizeMediaProviderId(params.entry.provider ?? "");
481
+ if (!providerId) return;
482
+ return params.providerRegistry.get(providerId)?.capabilities;
483
+ }
484
+ function resolveModelEntries(params) {
485
+ const { cfg, capability, config } = params;
486
+ const sharedModels = cfg.tools?.media?.models ?? [];
487
+ const entries = [...(config?.models ?? []).map((entry) => ({
488
+ entry,
489
+ source: "capability"
490
+ })), ...sharedModels.map((entry) => ({
491
+ entry,
492
+ source: "shared"
493
+ }))];
494
+ if (entries.length === 0) return [];
495
+ return entries.filter(({ entry, source }) => {
496
+ const caps = entry.capabilities && entry.capabilities.length > 0 ? entry.capabilities : source === "shared" ? resolveEntryCapabilities({
497
+ entry,
498
+ providerRegistry: params.providerRegistry
499
+ }) : void 0;
500
+ if (!caps || caps.length === 0) {
501
+ if (source === "shared") {
502
+ if (shouldLogVerbose()) logVerbose(`Skipping shared media model without capabilities: ${entry.provider ?? entry.command ?? "unknown"}`);
503
+ return false;
504
+ }
505
+ return true;
506
+ }
507
+ return caps.includes(capability);
508
+ }).map(({ entry }) => entry);
509
+ }
510
+ function resolveConcurrency(cfg) {
511
+ const configured = cfg.tools?.media?.concurrency;
512
+ if (typeof configured === "number" && Number.isFinite(configured) && configured > 0) return Math.floor(configured);
513
+ return DEFAULT_MEDIA_CONCURRENCY;
514
+ }
515
+
516
+ //#endregion
517
+ //#region src/infra/unhandled-rejections.ts
518
+ const handlers = /* @__PURE__ */ new Set();
519
+ /**
520
+ * Checks if an error is an AbortError.
521
+ * These are typically intentional cancellations (e.g., during shutdown) and shouldn't crash.
522
+ */
523
+ function isAbortError(err) {
524
+ if (!err || typeof err !== "object") return false;
525
+ if (("name" in err ? String(err.name) : "") === "AbortError") return true;
526
+ if (("message" in err && typeof err.message === "string" ? err.message : "") === "This operation was aborted") return true;
527
+ return false;
528
+ }
529
+ function registerUnhandledRejectionHandler(handler) {
530
+ handlers.add(handler);
531
+ return () => {
532
+ handlers.delete(handler);
533
+ };
534
+ }
535
+
536
+ //#endregion
537
+ //#region src/media-understanding/errors.ts
538
+ var MediaUnderstandingSkipError = class extends Error {
539
+ constructor(reason, message) {
540
+ super(message);
541
+ this.reason = reason;
542
+ this.name = "MediaUnderstandingSkipError";
543
+ }
544
+ };
545
+ function isMediaUnderstandingSkipError(err) {
546
+ return err instanceof MediaUnderstandingSkipError;
547
+ }
548
+
549
+ //#endregion
550
+ //#region src/media-understanding/attachments.ts
551
+ const DEFAULT_MAX_ATTACHMENTS = 1;
552
+ function normalizeAttachmentPath(raw) {
553
+ const value = raw?.trim();
554
+ if (!value) return;
555
+ if (value.startsWith("file://")) try {
556
+ return fileURLToPath(value);
557
+ } catch {
558
+ return;
559
+ }
560
+ return value;
561
+ }
562
+ function normalizeAttachments(ctx) {
563
+ const pathsFromArray = Array.isArray(ctx.MediaPaths) ? ctx.MediaPaths : void 0;
564
+ const urlsFromArray = Array.isArray(ctx.MediaUrls) ? ctx.MediaUrls : void 0;
565
+ const typesFromArray = Array.isArray(ctx.MediaTypes) ? ctx.MediaTypes : void 0;
566
+ const resolveMime = (count, index) => {
567
+ const typeHint = typesFromArray?.[index];
568
+ const trimmed = typeof typeHint === "string" ? typeHint.trim() : "";
569
+ if (trimmed) return trimmed;
570
+ return count === 1 ? ctx.MediaType : void 0;
571
+ };
572
+ if (pathsFromArray && pathsFromArray.length > 0) {
573
+ const count = pathsFromArray.length;
574
+ const urls = urlsFromArray && urlsFromArray.length > 0 ? urlsFromArray : void 0;
575
+ return pathsFromArray.map((value, index) => ({
576
+ path: value?.trim() || void 0,
577
+ url: urls?.[index] ?? ctx.MediaUrl,
578
+ mime: resolveMime(count, index),
579
+ index
580
+ })).filter((entry) => Boolean(entry.path?.trim() || entry.url?.trim()));
581
+ }
582
+ if (urlsFromArray && urlsFromArray.length > 0) {
583
+ const count = urlsFromArray.length;
584
+ return urlsFromArray.map((value, index) => ({
585
+ path: void 0,
586
+ url: value?.trim() || void 0,
587
+ mime: resolveMime(count, index),
588
+ index
589
+ })).filter((entry) => Boolean(entry.url?.trim()));
590
+ }
591
+ const pathValue = ctx.MediaPath?.trim();
592
+ const url = ctx.MediaUrl?.trim();
593
+ if (!pathValue && !url) return [];
594
+ return [{
595
+ path: pathValue || void 0,
596
+ url: url || void 0,
597
+ mime: ctx.MediaType,
598
+ index: 0
599
+ }];
600
+ }
601
+ function resolveAttachmentKind(attachment) {
602
+ const kind = kindFromMime(attachment.mime);
603
+ if (kind === "image" || kind === "audio" || kind === "video") return kind;
604
+ const ext = getFileExtension(attachment.path ?? attachment.url);
605
+ if (!ext) return "unknown";
606
+ if ([
607
+ ".mp4",
608
+ ".mov",
609
+ ".mkv",
610
+ ".webm",
611
+ ".avi",
612
+ ".m4v"
613
+ ].includes(ext)) return "video";
614
+ if (isAudioFileName(attachment.path ?? attachment.url)) return "audio";
615
+ if ([
616
+ ".png",
617
+ ".jpg",
618
+ ".jpeg",
619
+ ".webp",
620
+ ".gif",
621
+ ".bmp",
622
+ ".tiff",
623
+ ".tif"
624
+ ].includes(ext)) return "image";
625
+ return "unknown";
626
+ }
627
+ function isVideoAttachment(attachment) {
628
+ return resolveAttachmentKind(attachment) === "video";
629
+ }
630
+ function isAudioAttachment(attachment) {
631
+ return resolveAttachmentKind(attachment) === "audio";
632
+ }
633
+ function isImageAttachment(attachment) {
634
+ return resolveAttachmentKind(attachment) === "image";
635
+ }
636
+ function resolveRequestUrl(input) {
637
+ if (typeof input === "string") return input;
638
+ if (input instanceof URL) return input.toString();
639
+ return input.url;
640
+ }
641
+ function orderAttachments(attachments, prefer) {
642
+ if (!prefer || prefer === "first") return attachments;
643
+ if (prefer === "last") return [...attachments].toReversed();
644
+ if (prefer === "path") {
645
+ const withPath = attachments.filter((item) => item.path);
646
+ const withoutPath = attachments.filter((item) => !item.path);
647
+ return [...withPath, ...withoutPath];
648
+ }
649
+ if (prefer === "url") {
650
+ const withUrl = attachments.filter((item) => item.url);
651
+ const withoutUrl = attachments.filter((item) => !item.url);
652
+ return [...withUrl, ...withoutUrl];
653
+ }
654
+ return attachments;
655
+ }
656
+ function selectAttachments(params) {
657
+ const { capability, attachments, policy } = params;
658
+ const matches = attachments.filter((item) => {
659
+ if (capability === "audio" && item.alreadyTranscribed) return false;
660
+ if (capability === "image") return isImageAttachment(item);
661
+ if (capability === "audio") return isAudioAttachment(item);
662
+ return isVideoAttachment(item);
663
+ });
664
+ if (matches.length === 0) return [];
665
+ const ordered = orderAttachments(matches, policy?.prefer);
666
+ const mode = policy?.mode ?? "first";
667
+ const maxAttachments = policy?.maxAttachments ?? DEFAULT_MAX_ATTACHMENTS;
668
+ if (mode === "all") return ordered.slice(0, Math.max(1, maxAttachments));
669
+ return ordered.slice(0, 1);
670
+ }
671
+ var MediaAttachmentCache = class {
672
+ constructor(attachments) {
673
+ this.entries = /* @__PURE__ */ new Map();
674
+ this.attachments = attachments;
675
+ for (const attachment of attachments) this.entries.set(attachment.index, { attachment });
676
+ }
677
+ async getBuffer(params) {
678
+ const entry = await this.ensureEntry(params.attachmentIndex);
679
+ if (entry.buffer) {
680
+ if (entry.buffer.length > params.maxBytes) throw new MediaUnderstandingSkipError("maxBytes", `Attachment ${params.attachmentIndex + 1} exceeds maxBytes ${params.maxBytes}`);
681
+ return {
682
+ buffer: entry.buffer,
683
+ mime: entry.bufferMime,
684
+ fileName: entry.bufferFileName ?? `media-${params.attachmentIndex + 1}`,
685
+ size: entry.buffer.length
686
+ };
687
+ }
688
+ if (entry.resolvedPath) {
689
+ const size = await this.ensureLocalStat(entry);
690
+ if (entry.resolvedPath) {
691
+ if (size !== void 0 && size > params.maxBytes) throw new MediaUnderstandingSkipError("maxBytes", `Attachment ${params.attachmentIndex + 1} exceeds maxBytes ${params.maxBytes}`);
692
+ const buffer = await fs$1.readFile(entry.resolvedPath);
693
+ entry.buffer = buffer;
694
+ entry.bufferMime = entry.bufferMime ?? entry.attachment.mime ?? await detectMime({
695
+ buffer,
696
+ filePath: entry.resolvedPath
697
+ });
698
+ entry.bufferFileName = path.basename(entry.resolvedPath) || `media-${params.attachmentIndex + 1}`;
699
+ return {
700
+ buffer,
701
+ mime: entry.bufferMime,
702
+ fileName: entry.bufferFileName,
703
+ size: buffer.length
704
+ };
705
+ }
706
+ }
707
+ const url = entry.attachment.url?.trim();
708
+ if (!url) throw new MediaUnderstandingSkipError("empty", `Attachment ${params.attachmentIndex + 1} has no path or URL.`);
709
+ try {
710
+ const fetchImpl = (input, init) => fetchWithTimeout(resolveRequestUrl(input), init ?? {}, params.timeoutMs, fetch);
711
+ const fetched = await fetchRemoteMedia({
712
+ url,
713
+ fetchImpl,
714
+ maxBytes: params.maxBytes
715
+ });
716
+ entry.buffer = fetched.buffer;
717
+ entry.bufferMime = entry.attachment.mime ?? fetched.contentType ?? await detectMime({
718
+ buffer: fetched.buffer,
719
+ filePath: fetched.fileName ?? url
720
+ });
721
+ entry.bufferFileName = fetched.fileName ?? `media-${params.attachmentIndex + 1}`;
722
+ return {
723
+ buffer: fetched.buffer,
724
+ mime: entry.bufferMime,
725
+ fileName: entry.bufferFileName,
726
+ size: fetched.buffer.length
727
+ };
728
+ } catch (err) {
729
+ if (err instanceof MediaFetchError && err.code === "max_bytes") throw new MediaUnderstandingSkipError("maxBytes", `Attachment ${params.attachmentIndex + 1} exceeds maxBytes ${params.maxBytes}`);
730
+ if (isAbortError(err)) throw new MediaUnderstandingSkipError("timeout", `Attachment ${params.attachmentIndex + 1} timed out while fetching.`);
731
+ throw err;
732
+ }
733
+ }
734
+ async getPath(params) {
735
+ const entry = await this.ensureEntry(params.attachmentIndex);
736
+ if (entry.resolvedPath) {
737
+ if (params.maxBytes) {
738
+ const size = await this.ensureLocalStat(entry);
739
+ if (entry.resolvedPath) {
740
+ if (size !== void 0 && size > params.maxBytes) throw new MediaUnderstandingSkipError("maxBytes", `Attachment ${params.attachmentIndex + 1} exceeds maxBytes ${params.maxBytes}`);
741
+ }
742
+ }
743
+ if (entry.resolvedPath) return { path: entry.resolvedPath };
744
+ }
745
+ if (entry.tempPath) {
746
+ if (params.maxBytes && entry.buffer && entry.buffer.length > params.maxBytes) throw new MediaUnderstandingSkipError("maxBytes", `Attachment ${params.attachmentIndex + 1} exceeds maxBytes ${params.maxBytes}`);
747
+ return {
748
+ path: entry.tempPath,
749
+ cleanup: entry.tempCleanup
750
+ };
751
+ }
752
+ const maxBytes = params.maxBytes ?? Number.POSITIVE_INFINITY;
753
+ const bufferResult = await this.getBuffer({
754
+ attachmentIndex: params.attachmentIndex,
755
+ maxBytes,
756
+ timeoutMs: params.timeoutMs
757
+ });
758
+ const extension = path.extname(bufferResult.fileName || "") || "";
759
+ const tmpPath = path.join(os.tmpdir(), `openclaw-media-${crypto.randomUUID()}${extension}`);
760
+ await fs$1.writeFile(tmpPath, bufferResult.buffer);
761
+ entry.tempPath = tmpPath;
762
+ entry.tempCleanup = async () => {
763
+ await fs$1.unlink(tmpPath).catch(() => {});
764
+ };
765
+ return {
766
+ path: tmpPath,
767
+ cleanup: entry.tempCleanup
768
+ };
769
+ }
770
+ async cleanup() {
771
+ const cleanups = [];
772
+ for (const entry of this.entries.values()) if (entry.tempCleanup) {
773
+ cleanups.push(Promise.resolve(entry.tempCleanup()));
774
+ entry.tempCleanup = void 0;
775
+ }
776
+ await Promise.all(cleanups);
777
+ }
778
+ async ensureEntry(attachmentIndex) {
779
+ const existing = this.entries.get(attachmentIndex);
780
+ if (existing) {
781
+ if (!existing.resolvedPath) existing.resolvedPath = this.resolveLocalPath(existing.attachment);
782
+ return existing;
783
+ }
784
+ const attachment = this.attachments.find((item) => item.index === attachmentIndex) ?? { index: attachmentIndex };
785
+ const entry = {
786
+ attachment,
787
+ resolvedPath: this.resolveLocalPath(attachment)
788
+ };
789
+ this.entries.set(attachmentIndex, entry);
790
+ return entry;
791
+ }
792
+ resolveLocalPath(attachment) {
793
+ const rawPath = normalizeAttachmentPath(attachment.path);
794
+ if (!rawPath) return;
795
+ return path.isAbsolute(rawPath) ? rawPath : path.resolve(rawPath);
796
+ }
797
+ async ensureLocalStat(entry) {
798
+ if (!entry.resolvedPath) return;
799
+ if (entry.statSize !== void 0) return entry.statSize;
800
+ try {
801
+ const stat = await fs$1.stat(entry.resolvedPath);
802
+ if (!stat.isFile()) {
803
+ entry.resolvedPath = void 0;
804
+ return;
805
+ }
806
+ entry.statSize = stat.size;
807
+ return stat.size;
808
+ } catch (err) {
809
+ entry.resolvedPath = void 0;
810
+ if (shouldLogVerbose()) logVerbose(`Failed to read attachment ${entry.attachment.index + 1}: ${String(err)}`);
811
+ return;
812
+ }
813
+ }
814
+ };
815
+
816
+ //#endregion
817
+ //#region src/agents/model-catalog.ts
818
+ let modelCatalogPromise = null;
819
+ let hasLoggedModelCatalogError = false;
820
+ const defaultImportPiSdk = () => import("./pi-model-discovery-EhM2JAQo.js").then((n) => n.r);
821
+ let importPiSdk = defaultImportPiSdk;
822
+ async function loadModelCatalog(params) {
823
+ if (params?.useCache === false) modelCatalogPromise = null;
824
+ if (modelCatalogPromise) return modelCatalogPromise;
825
+ modelCatalogPromise = (async () => {
826
+ const models = [];
827
+ const sortModels = (entries) => entries.sort((a, b) => {
828
+ const p = a.provider.localeCompare(b.provider);
829
+ if (p !== 0) return p;
830
+ return a.name.localeCompare(b.name);
831
+ });
832
+ try {
833
+ await ensureOpenClawModelsJson(params?.config ?? loadConfig());
834
+ const piSdk = await importPiSdk();
835
+ const agentDir = resolveOpenClawAgentDir();
836
+ const { join } = await import("node:path");
837
+ const authStorage = new piSdk.AuthStorage(join(agentDir, "auth.json"));
838
+ const registry = new piSdk.ModelRegistry(authStorage, join(agentDir, "models.json"));
839
+ const entries = Array.isArray(registry) ? registry : registry.getAll();
840
+ for (const entry of entries) {
841
+ const id = String(entry?.id ?? "").trim();
842
+ if (!id) continue;
843
+ const provider = String(entry?.provider ?? "").trim();
844
+ if (!provider) continue;
845
+ const name = String(entry?.name ?? id).trim() || id;
846
+ const contextWindow = typeof entry?.contextWindow === "number" && entry.contextWindow > 0 ? entry.contextWindow : void 0;
847
+ const reasoning = typeof entry?.reasoning === "boolean" ? entry.reasoning : void 0;
848
+ const input = Array.isArray(entry?.input) ? entry.input : void 0;
849
+ models.push({
850
+ id,
851
+ name,
852
+ provider,
853
+ contextWindow,
854
+ reasoning,
855
+ input
856
+ });
857
+ }
858
+ if (models.length === 0) modelCatalogPromise = null;
859
+ return sortModels(models);
860
+ } catch (error) {
861
+ if (!hasLoggedModelCatalogError) {
862
+ hasLoggedModelCatalogError = true;
863
+ console.warn(`[model-catalog] Failed to load model catalog: ${String(error)}`);
864
+ }
865
+ modelCatalogPromise = null;
866
+ if (models.length > 0) return sortModels(models);
867
+ return [];
868
+ }
869
+ })();
870
+ return modelCatalogPromise;
871
+ }
872
+ /**
873
+ * Check if a model supports image input based on its catalog entry.
874
+ */
875
+ function modelSupportsVision(entry) {
876
+ return entry?.input?.includes("image") ?? false;
877
+ }
878
+ /**
879
+ * Find a model in the catalog by provider and model ID.
880
+ */
881
+ function findModelInCatalog(catalog, provider, modelId) {
882
+ const normalizedProvider = provider.toLowerCase().trim();
883
+ const normalizedModelId = modelId.toLowerCase().trim();
884
+ return catalog.find((entry) => entry.provider.toLowerCase() === normalizedProvider && entry.id.toLowerCase() === normalizedModelId);
885
+ }
886
+
887
+ //#endregion
888
+ //#region src/media-understanding/video.ts
889
+ function estimateBase64Size(bytes) {
890
+ return Math.ceil(bytes / 3) * 4;
891
+ }
892
+ function resolveVideoMaxBase64Bytes(maxBytes) {
893
+ const expanded = Math.floor(maxBytes * (4 / 3));
894
+ return Math.min(expanded, DEFAULT_VIDEO_MAX_BASE64_BYTES);
895
+ }
896
+
897
+ //#endregion
898
+ //#region src/media-understanding/runner.ts
899
+ function buildProviderRegistry(overrides) {
900
+ return buildMediaUnderstandingRegistry(overrides);
901
+ }
902
+ function normalizeMediaAttachments(ctx) {
903
+ return normalizeAttachments(ctx);
904
+ }
905
+ function createMediaAttachmentCache(attachments) {
906
+ return new MediaAttachmentCache(attachments);
907
+ }
908
+ const binaryCache = /* @__PURE__ */ new Map();
909
+ const geminiProbeCache = /* @__PURE__ */ new Map();
910
+ function expandHomeDir(value) {
911
+ if (!value.startsWith("~")) return value;
912
+ const home = os.homedir();
913
+ if (value === "~") return home;
914
+ if (value.startsWith("~/")) return path.join(home, value.slice(2));
915
+ return value;
916
+ }
917
+ function hasPathSeparator(value) {
918
+ return value.includes("/") || value.includes("\\");
919
+ }
920
+ function candidateBinaryNames(name) {
921
+ if (process.platform !== "win32") return [name];
922
+ if (path.extname(name)) return [name];
923
+ const pathext = (process.env.PATHEXT ?? ".EXE;.CMD;.BAT;.COM").split(";").map((item) => item.trim()).filter(Boolean).map((item) => item.startsWith(".") ? item : `.${item}`);
924
+ return [name, ...Array.from(new Set(pathext)).map((item) => `${name}${item}`)];
925
+ }
926
+ async function isExecutable(filePath) {
927
+ try {
928
+ if (!(await fs$1.stat(filePath)).isFile()) return false;
929
+ if (process.platform === "win32") return true;
930
+ await fs$1.access(filePath, constants.X_OK);
931
+ return true;
932
+ } catch {
933
+ return false;
934
+ }
935
+ }
936
+ async function findBinary(name) {
937
+ const cached = binaryCache.get(name);
938
+ if (cached) return cached;
939
+ const resolved = (async () => {
940
+ const direct = expandHomeDir(name.trim());
941
+ if (direct && hasPathSeparator(direct)) {
942
+ for (const candidate of candidateBinaryNames(direct)) if (await isExecutable(candidate)) return candidate;
943
+ }
944
+ const searchName = name.trim();
945
+ if (!searchName) return null;
946
+ const pathEntries = (process.env.PATH ?? "").split(path.delimiter);
947
+ const candidates = candidateBinaryNames(searchName);
948
+ for (const entryRaw of pathEntries) {
949
+ const entry = expandHomeDir(entryRaw.trim().replace(/^"(.*)"$/, "$1"));
950
+ if (!entry) continue;
951
+ for (const candidate of candidates) {
952
+ const fullPath = path.join(entry, candidate);
953
+ if (await isExecutable(fullPath)) return fullPath;
954
+ }
955
+ }
956
+ return null;
957
+ })();
958
+ binaryCache.set(name, resolved);
959
+ return resolved;
960
+ }
961
+ async function hasBinary(name) {
962
+ return Boolean(await findBinary(name));
963
+ }
964
+ async function fileExists(filePath) {
965
+ if (!filePath) return false;
966
+ try {
967
+ await fs$1.stat(filePath);
968
+ return true;
969
+ } catch {
970
+ return false;
971
+ }
972
+ }
973
+ function extractLastJsonObject(raw) {
974
+ const trimmed = raw.trim();
975
+ const start = trimmed.lastIndexOf("{");
976
+ if (start === -1) return null;
977
+ const slice = trimmed.slice(start);
978
+ try {
979
+ return JSON.parse(slice);
980
+ } catch {
981
+ return null;
982
+ }
983
+ }
984
+ function extractGeminiResponse(raw) {
985
+ const payload = extractLastJsonObject(raw);
986
+ if (!payload || typeof payload !== "object") return null;
987
+ const response = payload.response;
988
+ if (typeof response !== "string") return null;
989
+ return response.trim() || null;
990
+ }
991
+ function extractSherpaOnnxText(raw) {
992
+ const tryParse = (value) => {
993
+ const trimmed = value.trim();
994
+ if (!trimmed) return null;
995
+ const head = trimmed[0];
996
+ if (head !== "{" && head !== "\"") return null;
997
+ try {
998
+ const parsed = JSON.parse(trimmed);
999
+ if (typeof parsed === "string") return tryParse(parsed);
1000
+ if (parsed && typeof parsed === "object") {
1001
+ const text = parsed.text;
1002
+ if (typeof text === "string" && text.trim()) return text.trim();
1003
+ }
1004
+ } catch {}
1005
+ return null;
1006
+ };
1007
+ const direct = tryParse(raw);
1008
+ if (direct) return direct;
1009
+ const lines = raw.split("\n").map((line) => line.trim()).filter(Boolean);
1010
+ for (let i = lines.length - 1; i >= 0; i -= 1) {
1011
+ const parsed = tryParse(lines[i] ?? "");
1012
+ if (parsed) return parsed;
1013
+ }
1014
+ return null;
1015
+ }
1016
+ async function probeGeminiCli() {
1017
+ const cached = geminiProbeCache.get("gemini");
1018
+ if (cached) return cached;
1019
+ const resolved = (async () => {
1020
+ if (!await hasBinary("gemini")) return false;
1021
+ try {
1022
+ const { stdout } = await runExec("gemini", [
1023
+ "--output-format",
1024
+ "json",
1025
+ "ok"
1026
+ ], { timeoutMs: 8e3 });
1027
+ return Boolean(extractGeminiResponse(stdout) ?? stdout.toLowerCase().includes("ok"));
1028
+ } catch {
1029
+ return false;
1030
+ }
1031
+ })();
1032
+ geminiProbeCache.set("gemini", resolved);
1033
+ return resolved;
1034
+ }
1035
+ async function resolveLocalWhisperCppEntry() {
1036
+ if (!await hasBinary("whisper-cli")) return null;
1037
+ const envModel = process.env.WHISPER_CPP_MODEL?.trim();
1038
+ const modelPath = envModel && await fileExists(envModel) ? envModel : "/opt/homebrew/share/whisper-cpp/for-tests-ggml-tiny.bin";
1039
+ if (!await fileExists(modelPath)) return null;
1040
+ return {
1041
+ type: "cli",
1042
+ command: "whisper-cli",
1043
+ args: [
1044
+ "-m",
1045
+ modelPath,
1046
+ "-otxt",
1047
+ "-of",
1048
+ "{{OutputBase}}",
1049
+ "-np",
1050
+ "-nt",
1051
+ "{{MediaPath}}"
1052
+ ]
1053
+ };
1054
+ }
1055
+ async function resolveLocalWhisperEntry() {
1056
+ if (!await hasBinary("whisper")) return null;
1057
+ return {
1058
+ type: "cli",
1059
+ command: "whisper",
1060
+ args: [
1061
+ "--model",
1062
+ "turbo",
1063
+ "--output_format",
1064
+ "txt",
1065
+ "--output_dir",
1066
+ "{{OutputDir}}",
1067
+ "--verbose",
1068
+ "False",
1069
+ "{{MediaPath}}"
1070
+ ]
1071
+ };
1072
+ }
1073
+ async function resolveSherpaOnnxEntry() {
1074
+ if (!await hasBinary("sherpa-onnx-offline")) return null;
1075
+ const modelDir = process.env.SHERPA_ONNX_MODEL_DIR?.trim();
1076
+ if (!modelDir) return null;
1077
+ const tokens = path.join(modelDir, "tokens.txt");
1078
+ const encoder = path.join(modelDir, "encoder.onnx");
1079
+ const decoder = path.join(modelDir, "decoder.onnx");
1080
+ const joiner = path.join(modelDir, "joiner.onnx");
1081
+ if (!await fileExists(tokens)) return null;
1082
+ if (!await fileExists(encoder)) return null;
1083
+ if (!await fileExists(decoder)) return null;
1084
+ if (!await fileExists(joiner)) return null;
1085
+ return {
1086
+ type: "cli",
1087
+ command: "sherpa-onnx-offline",
1088
+ args: [
1089
+ `--tokens=${tokens}`,
1090
+ `--encoder=${encoder}`,
1091
+ `--decoder=${decoder}`,
1092
+ `--joiner=${joiner}`,
1093
+ "{{MediaPath}}"
1094
+ ]
1095
+ };
1096
+ }
1097
+ async function resolveLocalAudioEntry() {
1098
+ const sherpa = await resolveSherpaOnnxEntry();
1099
+ if (sherpa) return sherpa;
1100
+ const whisperCpp = await resolveLocalWhisperCppEntry();
1101
+ if (whisperCpp) return whisperCpp;
1102
+ return await resolveLocalWhisperEntry();
1103
+ }
1104
+ async function resolveGeminiCliEntry(_capability) {
1105
+ if (!await probeGeminiCli()) return null;
1106
+ return {
1107
+ type: "cli",
1108
+ command: "gemini",
1109
+ args: [
1110
+ "--output-format",
1111
+ "json",
1112
+ "--allowed-tools",
1113
+ "read_many_files",
1114
+ "--include-directories",
1115
+ "{{MediaDir}}",
1116
+ "{{Prompt}}",
1117
+ "Use read_many_files to read {{MediaPath}} and respond with only the text output."
1118
+ ]
1119
+ };
1120
+ }
1121
+ async function resolveKeyEntry(params) {
1122
+ const { cfg, agentDir, providerRegistry, capability } = params;
1123
+ const checkProvider = async (providerId, model) => {
1124
+ const provider = getMediaUnderstandingProvider(providerId, providerRegistry);
1125
+ if (!provider) return null;
1126
+ if (capability === "audio" && !provider.transcribeAudio) return null;
1127
+ if (capability === "image" && !provider.describeImage) return null;
1128
+ if (capability === "video" && !provider.describeVideo) return null;
1129
+ try {
1130
+ await resolveApiKeyForProvider({
1131
+ provider: providerId,
1132
+ cfg,
1133
+ agentDir
1134
+ });
1135
+ return {
1136
+ type: "provider",
1137
+ provider: providerId,
1138
+ model
1139
+ };
1140
+ } catch {
1141
+ return null;
1142
+ }
1143
+ };
1144
+ if (capability === "image") {
1145
+ const activeProvider = params.activeModel?.provider?.trim();
1146
+ if (activeProvider) {
1147
+ const activeEntry = await checkProvider(activeProvider, params.activeModel?.model);
1148
+ if (activeEntry) return activeEntry;
1149
+ }
1150
+ for (const providerId of AUTO_IMAGE_KEY_PROVIDERS) {
1151
+ const model = DEFAULT_IMAGE_MODELS[providerId];
1152
+ const entry = await checkProvider(providerId, model);
1153
+ if (entry) return entry;
1154
+ }
1155
+ return null;
1156
+ }
1157
+ if (capability === "video") {
1158
+ const activeProvider = params.activeModel?.provider?.trim();
1159
+ if (activeProvider) {
1160
+ const activeEntry = await checkProvider(activeProvider, params.activeModel?.model);
1161
+ if (activeEntry) return activeEntry;
1162
+ }
1163
+ for (const providerId of AUTO_VIDEO_KEY_PROVIDERS) {
1164
+ const entry = await checkProvider(providerId, void 0);
1165
+ if (entry) return entry;
1166
+ }
1167
+ return null;
1168
+ }
1169
+ const activeProvider = params.activeModel?.provider?.trim();
1170
+ if (activeProvider) {
1171
+ const activeEntry = await checkProvider(activeProvider, params.activeModel?.model);
1172
+ if (activeEntry) return activeEntry;
1173
+ }
1174
+ for (const providerId of AUTO_AUDIO_KEY_PROVIDERS) {
1175
+ const entry = await checkProvider(providerId, void 0);
1176
+ if (entry) return entry;
1177
+ }
1178
+ return null;
1179
+ }
1180
+ async function resolveAutoEntries(params) {
1181
+ const activeEntry = await resolveActiveModelEntry(params);
1182
+ if (activeEntry) return [activeEntry];
1183
+ if (params.capability === "audio") {
1184
+ const localAudio = await resolveLocalAudioEntry();
1185
+ if (localAudio) return [localAudio];
1186
+ }
1187
+ const gemini = await resolveGeminiCliEntry(params.capability);
1188
+ if (gemini) return [gemini];
1189
+ const keys = await resolveKeyEntry(params);
1190
+ if (keys) return [keys];
1191
+ return [];
1192
+ }
1193
+ async function resolveAutoImageModel(params) {
1194
+ const providerRegistry = buildProviderRegistry();
1195
+ const toActive = (entry) => {
1196
+ if (!entry || entry.type === "cli") return null;
1197
+ const provider = entry.provider;
1198
+ if (!provider) return null;
1199
+ const model = entry.model ?? DEFAULT_IMAGE_MODELS[provider];
1200
+ if (!model) return null;
1201
+ return {
1202
+ provider,
1203
+ model
1204
+ };
1205
+ };
1206
+ const resolvedActive = toActive(await resolveActiveModelEntry({
1207
+ cfg: params.cfg,
1208
+ agentDir: params.agentDir,
1209
+ providerRegistry,
1210
+ capability: "image",
1211
+ activeModel: params.activeModel
1212
+ }));
1213
+ if (resolvedActive) return resolvedActive;
1214
+ return toActive(await resolveKeyEntry({
1215
+ cfg: params.cfg,
1216
+ agentDir: params.agentDir,
1217
+ providerRegistry,
1218
+ capability: "image",
1219
+ activeModel: params.activeModel
1220
+ }));
1221
+ }
1222
+ async function resolveActiveModelEntry(params) {
1223
+ const activeProviderRaw = params.activeModel?.provider?.trim();
1224
+ if (!activeProviderRaw) return null;
1225
+ const providerId = normalizeMediaProviderId(activeProviderRaw);
1226
+ if (!providerId) return null;
1227
+ const provider = getMediaUnderstandingProvider(providerId, params.providerRegistry);
1228
+ if (!provider) return null;
1229
+ if (params.capability === "audio" && !provider.transcribeAudio) return null;
1230
+ if (params.capability === "image" && !provider.describeImage) return null;
1231
+ if (params.capability === "video" && !provider.describeVideo) return null;
1232
+ try {
1233
+ await resolveApiKeyForProvider({
1234
+ provider: providerId,
1235
+ cfg: params.cfg,
1236
+ agentDir: params.agentDir
1237
+ });
1238
+ } catch {
1239
+ return null;
1240
+ }
1241
+ return {
1242
+ type: "provider",
1243
+ provider: providerId,
1244
+ model: params.activeModel?.model
1245
+ };
1246
+ }
1247
+ function trimOutput(text, maxChars) {
1248
+ const trimmed = text.trim();
1249
+ if (!maxChars || trimmed.length <= maxChars) return trimmed;
1250
+ return trimmed.slice(0, maxChars).trim();
1251
+ }
1252
+ function commandBase(command) {
1253
+ return path.parse(command).name;
1254
+ }
1255
+ function findArgValue(args, keys) {
1256
+ for (let i = 0; i < args.length; i += 1) if (keys.includes(args[i] ?? "")) {
1257
+ const value = args[i + 1];
1258
+ if (value) return value;
1259
+ }
1260
+ }
1261
+ function hasArg(args, keys) {
1262
+ return args.some((arg) => keys.includes(arg));
1263
+ }
1264
+ function resolveWhisperOutputPath(args, mediaPath) {
1265
+ const outputDir = findArgValue(args, ["--output_dir", "-o"]);
1266
+ const outputFormat = findArgValue(args, ["--output_format"]);
1267
+ if (!outputDir || !outputFormat) return null;
1268
+ if (!outputFormat.split(",").map((value) => value.trim()).includes("txt")) return null;
1269
+ const base = path.parse(mediaPath).name;
1270
+ return path.join(outputDir, `${base}.txt`);
1271
+ }
1272
+ function resolveWhisperCppOutputPath(args) {
1273
+ if (!hasArg(args, ["-otxt", "--output-txt"])) return null;
1274
+ const outputBase = findArgValue(args, ["-of", "--output-file"]);
1275
+ if (!outputBase) return null;
1276
+ return `${outputBase}.txt`;
1277
+ }
1278
+ async function resolveCliOutput(params) {
1279
+ const commandId = commandBase(params.command);
1280
+ const fileOutput = commandId === "whisper-cli" ? resolveWhisperCppOutputPath(params.args) : commandId === "whisper" ? resolveWhisperOutputPath(params.args, params.mediaPath) : null;
1281
+ if (fileOutput && await fileExists(fileOutput)) try {
1282
+ const content = await fs$1.readFile(fileOutput, "utf8");
1283
+ if (content.trim()) return content.trim();
1284
+ } catch {}
1285
+ if (commandId === "gemini") {
1286
+ const response = extractGeminiResponse(params.stdout);
1287
+ if (response) return response;
1288
+ }
1289
+ if (commandId === "sherpa-onnx-offline") {
1290
+ const response = extractSherpaOnnxText(params.stdout);
1291
+ if (response) return response;
1292
+ }
1293
+ return params.stdout.trim();
1294
+ }
1295
+ function normalizeProviderQuery(options) {
1296
+ if (!options) return;
1297
+ const query = {};
1298
+ for (const [key, value] of Object.entries(options)) {
1299
+ if (value === void 0) continue;
1300
+ query[key] = value;
1301
+ }
1302
+ return Object.keys(query).length > 0 ? query : void 0;
1303
+ }
1304
+ function buildDeepgramCompatQuery(options) {
1305
+ if (!options) return;
1306
+ const query = {};
1307
+ if (typeof options.detectLanguage === "boolean") query.detect_language = options.detectLanguage;
1308
+ if (typeof options.punctuate === "boolean") query.punctuate = options.punctuate;
1309
+ if (typeof options.smartFormat === "boolean") query.smart_format = options.smartFormat;
1310
+ return Object.keys(query).length > 0 ? query : void 0;
1311
+ }
1312
+ function normalizeDeepgramQueryKeys(query) {
1313
+ const normalized = { ...query };
1314
+ if ("detectLanguage" in normalized) {
1315
+ normalized.detect_language = normalized.detectLanguage;
1316
+ delete normalized.detectLanguage;
1317
+ }
1318
+ if ("smartFormat" in normalized) {
1319
+ normalized.smart_format = normalized.smartFormat;
1320
+ delete normalized.smartFormat;
1321
+ }
1322
+ return normalized;
1323
+ }
1324
+ function resolveProviderQuery(params) {
1325
+ const { providerId, config, entry } = params;
1326
+ const mergedOptions = normalizeProviderQuery({
1327
+ ...config?.providerOptions?.[providerId],
1328
+ ...entry.providerOptions?.[providerId]
1329
+ });
1330
+ if (providerId !== "deepgram") return mergedOptions;
1331
+ let query = normalizeDeepgramQueryKeys(mergedOptions ?? {});
1332
+ const compat = buildDeepgramCompatQuery({
1333
+ ...config?.deepgram,
1334
+ ...entry.deepgram
1335
+ });
1336
+ for (const [key, value] of Object.entries(compat ?? {})) if (query[key] === void 0) query[key] = value;
1337
+ return Object.keys(query).length > 0 ? query : void 0;
1338
+ }
1339
+ function buildModelDecision(params) {
1340
+ if (params.entryType === "cli") {
1341
+ const command = params.entry.command?.trim();
1342
+ return {
1343
+ type: "cli",
1344
+ provider: command ?? "cli",
1345
+ model: params.entry.model ?? command,
1346
+ outcome: params.outcome,
1347
+ reason: params.reason
1348
+ };
1349
+ }
1350
+ const providerIdRaw = params.entry.provider?.trim();
1351
+ return {
1352
+ type: "provider",
1353
+ provider: (providerIdRaw ? normalizeMediaProviderId(providerIdRaw) : void 0) ?? providerIdRaw,
1354
+ model: params.entry.model,
1355
+ outcome: params.outcome,
1356
+ reason: params.reason
1357
+ };
1358
+ }
1359
+ function formatDecisionSummary(decision) {
1360
+ const total = decision.attachments.length;
1361
+ const success = decision.attachments.filter((entry) => entry.chosen?.outcome === "success").length;
1362
+ const chosen = decision.attachments.find((entry) => entry.chosen)?.chosen;
1363
+ const provider = chosen?.provider?.trim();
1364
+ const model = chosen?.model?.trim();
1365
+ const modelLabel = provider ? model ? `${provider}/${model}` : provider : void 0;
1366
+ const reason = decision.attachments.flatMap((entry) => entry.attempts.map((attempt) => attempt.reason).filter(Boolean)).find(Boolean);
1367
+ const shortReason = reason ? reason.split(":")[0]?.trim() : void 0;
1368
+ const countLabel = total > 0 ? ` (${success}/${total})` : "";
1369
+ const viaLabel = modelLabel ? ` via ${modelLabel}` : "";
1370
+ const reasonLabel = shortReason ? ` reason=${shortReason}` : "";
1371
+ return `${decision.capability}: ${decision.outcome}${countLabel}${viaLabel}${reasonLabel}`;
1372
+ }
1373
+ async function runProviderEntry(params) {
1374
+ const { entry, capability, cfg } = params;
1375
+ const providerIdRaw = entry.provider?.trim();
1376
+ if (!providerIdRaw) throw new Error(`Provider entry missing provider for ${capability}`);
1377
+ const providerId = normalizeMediaProviderId(providerIdRaw);
1378
+ const maxBytes = resolveMaxBytes({
1379
+ capability,
1380
+ entry,
1381
+ cfg,
1382
+ config: params.config
1383
+ });
1384
+ const maxChars = resolveMaxChars({
1385
+ capability,
1386
+ entry,
1387
+ cfg,
1388
+ config: params.config
1389
+ });
1390
+ const timeoutMs = resolveTimeoutMs(entry.timeoutSeconds ?? params.config?.timeoutSeconds ?? cfg.tools?.media?.[capability]?.timeoutSeconds, DEFAULT_TIMEOUT_SECONDS[capability]);
1391
+ const prompt = resolvePrompt(capability, entry.prompt ?? params.config?.prompt ?? cfg.tools?.media?.[capability]?.prompt, maxChars);
1392
+ if (capability === "image") {
1393
+ if (!params.agentDir) throw new Error("Image understanding requires agentDir");
1394
+ const modelId = entry.model?.trim();
1395
+ if (!modelId) throw new Error("Image understanding requires model id");
1396
+ const media = await params.cache.getBuffer({
1397
+ attachmentIndex: params.attachmentIndex,
1398
+ maxBytes,
1399
+ timeoutMs
1400
+ });
1401
+ const provider = getMediaUnderstandingProvider(providerId, params.providerRegistry);
1402
+ const result = provider?.describeImage ? await provider.describeImage({
1403
+ buffer: media.buffer,
1404
+ fileName: media.fileName,
1405
+ mime: media.mime,
1406
+ model: modelId,
1407
+ provider: providerId,
1408
+ prompt,
1409
+ timeoutMs,
1410
+ profile: entry.profile,
1411
+ preferredProfile: entry.preferredProfile,
1412
+ agentDir: params.agentDir,
1413
+ cfg: params.cfg
1414
+ }) : await describeImageWithModel({
1415
+ buffer: media.buffer,
1416
+ fileName: media.fileName,
1417
+ mime: media.mime,
1418
+ model: modelId,
1419
+ provider: providerId,
1420
+ prompt,
1421
+ timeoutMs,
1422
+ profile: entry.profile,
1423
+ preferredProfile: entry.preferredProfile,
1424
+ agentDir: params.agentDir,
1425
+ cfg: params.cfg
1426
+ });
1427
+ return {
1428
+ kind: "image.description",
1429
+ attachmentIndex: params.attachmentIndex,
1430
+ text: trimOutput(result.text, maxChars),
1431
+ provider: providerId,
1432
+ model: result.model ?? modelId
1433
+ };
1434
+ }
1435
+ const provider = getMediaUnderstandingProvider(providerId, params.providerRegistry);
1436
+ if (!provider) throw new Error(`Media provider not available: ${providerId}`);
1437
+ if (capability === "audio") {
1438
+ if (!provider.transcribeAudio) throw new Error(`Audio transcription provider "${providerId}" not available.`);
1439
+ const media = await params.cache.getBuffer({
1440
+ attachmentIndex: params.attachmentIndex,
1441
+ maxBytes,
1442
+ timeoutMs
1443
+ });
1444
+ const apiKey = requireApiKey(await resolveApiKeyForProvider({
1445
+ provider: providerId,
1446
+ cfg,
1447
+ profileId: entry.profile,
1448
+ preferredProfile: entry.preferredProfile,
1449
+ agentDir: params.agentDir
1450
+ }), providerId);
1451
+ const providerConfig = cfg.models?.providers?.[providerId];
1452
+ const baseUrl = entry.baseUrl ?? params.config?.baseUrl ?? providerConfig?.baseUrl;
1453
+ const mergedHeaders = {
1454
+ ...providerConfig?.headers,
1455
+ ...params.config?.headers,
1456
+ ...entry.headers
1457
+ };
1458
+ const headers = Object.keys(mergedHeaders).length > 0 ? mergedHeaders : void 0;
1459
+ const providerQuery = resolveProviderQuery({
1460
+ providerId,
1461
+ config: params.config,
1462
+ entry
1463
+ });
1464
+ const model = entry.model?.trim() || DEFAULT_AUDIO_MODELS[providerId] || entry.model;
1465
+ const result = await provider.transcribeAudio({
1466
+ buffer: media.buffer,
1467
+ fileName: media.fileName,
1468
+ mime: media.mime,
1469
+ apiKey,
1470
+ baseUrl,
1471
+ headers,
1472
+ model,
1473
+ language: entry.language ?? params.config?.language ?? cfg.tools?.media?.audio?.language,
1474
+ prompt,
1475
+ query: providerQuery,
1476
+ timeoutMs
1477
+ });
1478
+ return {
1479
+ kind: "audio.transcription",
1480
+ attachmentIndex: params.attachmentIndex,
1481
+ text: trimOutput(result.text, maxChars),
1482
+ provider: providerId,
1483
+ model: result.model ?? model
1484
+ };
1485
+ }
1486
+ if (!provider.describeVideo) throw new Error(`Video understanding provider "${providerId}" not available.`);
1487
+ const media = await params.cache.getBuffer({
1488
+ attachmentIndex: params.attachmentIndex,
1489
+ maxBytes,
1490
+ timeoutMs
1491
+ });
1492
+ const estimatedBase64Bytes = estimateBase64Size(media.size);
1493
+ const maxBase64Bytes = resolveVideoMaxBase64Bytes(maxBytes);
1494
+ if (estimatedBase64Bytes > maxBase64Bytes) throw new MediaUnderstandingSkipError("maxBytes", `Video attachment ${params.attachmentIndex + 1} base64 payload ${estimatedBase64Bytes} exceeds ${maxBase64Bytes}`);
1495
+ const apiKey = requireApiKey(await resolveApiKeyForProvider({
1496
+ provider: providerId,
1497
+ cfg,
1498
+ profileId: entry.profile,
1499
+ preferredProfile: entry.preferredProfile,
1500
+ agentDir: params.agentDir
1501
+ }), providerId);
1502
+ const providerConfig = cfg.models?.providers?.[providerId];
1503
+ const result = await provider.describeVideo({
1504
+ buffer: media.buffer,
1505
+ fileName: media.fileName,
1506
+ mime: media.mime,
1507
+ apiKey,
1508
+ baseUrl: providerConfig?.baseUrl,
1509
+ headers: providerConfig?.headers,
1510
+ model: entry.model,
1511
+ prompt,
1512
+ timeoutMs
1513
+ });
1514
+ return {
1515
+ kind: "video.description",
1516
+ attachmentIndex: params.attachmentIndex,
1517
+ text: trimOutput(result.text, maxChars),
1518
+ provider: providerId,
1519
+ model: result.model ?? entry.model
1520
+ };
1521
+ }
1522
+ async function runCliEntry(params) {
1523
+ const { entry, capability, cfg, ctx } = params;
1524
+ const command = entry.command?.trim();
1525
+ const args = entry.args ?? [];
1526
+ if (!command) throw new Error(`CLI entry missing command for ${capability}`);
1527
+ const maxBytes = resolveMaxBytes({
1528
+ capability,
1529
+ entry,
1530
+ cfg,
1531
+ config: params.config
1532
+ });
1533
+ const maxChars = resolveMaxChars({
1534
+ capability,
1535
+ entry,
1536
+ cfg,
1537
+ config: params.config
1538
+ });
1539
+ const timeoutMs = resolveTimeoutMs(entry.timeoutSeconds ?? params.config?.timeoutSeconds ?? cfg.tools?.media?.[capability]?.timeoutSeconds, DEFAULT_TIMEOUT_SECONDS[capability]);
1540
+ const prompt = resolvePrompt(capability, entry.prompt ?? params.config?.prompt ?? cfg.tools?.media?.[capability]?.prompt, maxChars);
1541
+ const pathResult = await params.cache.getPath({
1542
+ attachmentIndex: params.attachmentIndex,
1543
+ maxBytes,
1544
+ timeoutMs
1545
+ });
1546
+ const outputDir = await fs$1.mkdtemp(path.join(os.tmpdir(), "openclaw-media-cli-"));
1547
+ const mediaPath = pathResult.path;
1548
+ const outputBase = path.join(outputDir, path.parse(mediaPath).name);
1549
+ const templCtx = {
1550
+ ...ctx,
1551
+ MediaPath: mediaPath,
1552
+ MediaDir: path.dirname(mediaPath),
1553
+ OutputDir: outputDir,
1554
+ OutputBase: outputBase,
1555
+ Prompt: prompt,
1556
+ MaxChars: maxChars
1557
+ };
1558
+ const argv = [command, ...args].map((part, index) => index === 0 ? part : applyTemplate(part, templCtx));
1559
+ try {
1560
+ if (shouldLogVerbose()) logVerbose(`Media understanding via CLI: ${argv.join(" ")}`);
1561
+ const { stdout } = await runExec(argv[0], argv.slice(1), {
1562
+ timeoutMs,
1563
+ maxBuffer: CLI_OUTPUT_MAX_BUFFER
1564
+ });
1565
+ const text = trimOutput(await resolveCliOutput({
1566
+ command,
1567
+ args: argv.slice(1),
1568
+ stdout,
1569
+ mediaPath
1570
+ }), maxChars);
1571
+ if (!text) return null;
1572
+ return {
1573
+ kind: capability === "audio" ? "audio.transcription" : `${capability}.description`,
1574
+ attachmentIndex: params.attachmentIndex,
1575
+ text,
1576
+ provider: "cli",
1577
+ model: command
1578
+ };
1579
+ } finally {
1580
+ await fs$1.rm(outputDir, {
1581
+ recursive: true,
1582
+ force: true
1583
+ }).catch(() => {});
1584
+ }
1585
+ }
1586
+ async function runAttachmentEntries(params) {
1587
+ const { entries, capability } = params;
1588
+ const attempts = [];
1589
+ for (const entry of entries) {
1590
+ const entryType = entry.type ?? (entry.command ? "cli" : "provider");
1591
+ try {
1592
+ const result = entryType === "cli" ? await runCliEntry({
1593
+ capability,
1594
+ entry,
1595
+ cfg: params.cfg,
1596
+ ctx: params.ctx,
1597
+ attachmentIndex: params.attachmentIndex,
1598
+ cache: params.cache,
1599
+ config: params.config
1600
+ }) : await runProviderEntry({
1601
+ capability,
1602
+ entry,
1603
+ cfg: params.cfg,
1604
+ ctx: params.ctx,
1605
+ attachmentIndex: params.attachmentIndex,
1606
+ cache: params.cache,
1607
+ agentDir: params.agentDir,
1608
+ providerRegistry: params.providerRegistry,
1609
+ config: params.config
1610
+ });
1611
+ if (result) {
1612
+ const decision = buildModelDecision({
1613
+ entry,
1614
+ entryType,
1615
+ outcome: "success"
1616
+ });
1617
+ if (result.provider) decision.provider = result.provider;
1618
+ if (result.model) decision.model = result.model;
1619
+ attempts.push(decision);
1620
+ return {
1621
+ output: result,
1622
+ attempts
1623
+ };
1624
+ }
1625
+ attempts.push(buildModelDecision({
1626
+ entry,
1627
+ entryType,
1628
+ outcome: "skipped",
1629
+ reason: "empty output"
1630
+ }));
1631
+ } catch (err) {
1632
+ if (isMediaUnderstandingSkipError(err)) {
1633
+ attempts.push(buildModelDecision({
1634
+ entry,
1635
+ entryType,
1636
+ outcome: "skipped",
1637
+ reason: `${err.reason}: ${err.message}`
1638
+ }));
1639
+ if (shouldLogVerbose()) logVerbose(`Skipping ${capability} model due to ${err.reason}: ${err.message}`);
1640
+ continue;
1641
+ }
1642
+ attempts.push(buildModelDecision({
1643
+ entry,
1644
+ entryType,
1645
+ outcome: "failed",
1646
+ reason: String(err)
1647
+ }));
1648
+ if (shouldLogVerbose()) logVerbose(`${capability} understanding failed: ${String(err)}`);
1649
+ }
1650
+ }
1651
+ return {
1652
+ output: null,
1653
+ attempts
1654
+ };
1655
+ }
1656
+ async function runCapability(params) {
1657
+ const { capability, cfg, ctx } = params;
1658
+ const config = params.config ?? cfg.tools?.media?.[capability];
1659
+ if (config?.enabled === false) return {
1660
+ outputs: [],
1661
+ decision: {
1662
+ capability,
1663
+ outcome: "disabled",
1664
+ attachments: []
1665
+ }
1666
+ };
1667
+ const attachmentPolicy = config?.attachments;
1668
+ const selected = selectAttachments({
1669
+ capability,
1670
+ attachments: params.media,
1671
+ policy: attachmentPolicy
1672
+ });
1673
+ if (selected.length === 0) return {
1674
+ outputs: [],
1675
+ decision: {
1676
+ capability,
1677
+ outcome: "no-attachment",
1678
+ attachments: []
1679
+ }
1680
+ };
1681
+ if (resolveScopeDecision({
1682
+ scope: config?.scope,
1683
+ ctx
1684
+ }) === "deny") {
1685
+ if (shouldLogVerbose()) logVerbose(`${capability} understanding disabled by scope policy.`);
1686
+ return {
1687
+ outputs: [],
1688
+ decision: {
1689
+ capability,
1690
+ outcome: "scope-deny",
1691
+ attachments: selected.map((item) => ({
1692
+ attachmentIndex: item.index,
1693
+ attempts: []
1694
+ }))
1695
+ }
1696
+ };
1697
+ }
1698
+ const activeProvider = params.activeModel?.provider?.trim();
1699
+ if (capability === "image" && activeProvider) {
1700
+ if (modelSupportsVision(findModelInCatalog(await loadModelCatalog({ config: cfg }), activeProvider, params.activeModel?.model ?? ""))) {
1701
+ if (shouldLogVerbose()) logVerbose("Skipping image understanding: primary model supports vision natively");
1702
+ const model = params.activeModel?.model?.trim();
1703
+ const reason = "primary model supports vision natively";
1704
+ return {
1705
+ outputs: [],
1706
+ decision: {
1707
+ capability,
1708
+ outcome: "skipped",
1709
+ attachments: selected.map((item) => {
1710
+ const attempt = {
1711
+ type: "provider",
1712
+ provider: activeProvider,
1713
+ model: model || void 0,
1714
+ outcome: "skipped",
1715
+ reason
1716
+ };
1717
+ return {
1718
+ attachmentIndex: item.index,
1719
+ attempts: [attempt],
1720
+ chosen: attempt
1721
+ };
1722
+ })
1723
+ }
1724
+ };
1725
+ }
1726
+ }
1727
+ let resolvedEntries = resolveModelEntries({
1728
+ cfg,
1729
+ capability,
1730
+ config,
1731
+ providerRegistry: params.providerRegistry
1732
+ });
1733
+ if (resolvedEntries.length === 0) resolvedEntries = await resolveAutoEntries({
1734
+ cfg,
1735
+ agentDir: params.agentDir,
1736
+ providerRegistry: params.providerRegistry,
1737
+ capability,
1738
+ activeModel: params.activeModel
1739
+ });
1740
+ if (resolvedEntries.length === 0) return {
1741
+ outputs: [],
1742
+ decision: {
1743
+ capability,
1744
+ outcome: "skipped",
1745
+ attachments: selected.map((item) => ({
1746
+ attachmentIndex: item.index,
1747
+ attempts: []
1748
+ }))
1749
+ }
1750
+ };
1751
+ const outputs = [];
1752
+ const attachmentDecisions = [];
1753
+ for (const attachment of selected) {
1754
+ const { output, attempts } = await runAttachmentEntries({
1755
+ capability,
1756
+ cfg,
1757
+ ctx,
1758
+ attachmentIndex: attachment.index,
1759
+ agentDir: params.agentDir,
1760
+ providerRegistry: params.providerRegistry,
1761
+ cache: params.attachments,
1762
+ entries: resolvedEntries,
1763
+ config
1764
+ });
1765
+ if (output) outputs.push(output);
1766
+ attachmentDecisions.push({
1767
+ attachmentIndex: attachment.index,
1768
+ attempts,
1769
+ chosen: attempts.find((attempt) => attempt.outcome === "success")
1770
+ });
1771
+ }
1772
+ const decision = {
1773
+ capability,
1774
+ outcome: outputs.length > 0 ? "success" : "skipped",
1775
+ attachments: attachmentDecisions
1776
+ };
1777
+ if (shouldLogVerbose()) logVerbose(`Media understanding ${formatDecisionSummary(decision)}`);
1778
+ return {
1779
+ outputs,
1780
+ decision
1781
+ };
1782
+ }
1783
+
1784
+ //#endregion
1785
+ export { applyTemplate as _, runCapability as a, modelSupportsVision as c, registerUnhandledRejectionHandler as d, resolveConcurrency as f, CLI_OUTPUT_MAX_BUFFER as g, resolveMediaUnderstandingScope as h, resolveAutoImageModel as i, isAudioAttachment as l, normalizeMediaUnderstandingChatType as m, createMediaAttachmentCache as n, findModelInCatalog as o, resolveTimeoutMs as p, normalizeMediaAttachments as r, loadModelCatalog as s, buildProviderRegistry as t, resolveAttachmentKind as u };