squidclaw 3.0.19 → 3.0.20

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 (209) hide show
  1. package/dist/{agents-DL8uYsUq.js → agents-BOS_wASV.js} +4 -4
  2. package/dist/{agents.config-B4KAAVvR.js → agents.config-ChUZBohP.js} +1 -1
  3. package/dist/{agents.config-D93fF1eJ.js → agents.config-Dfsl4jNF.js} +1 -1
  4. package/dist/{audio-preflight-Bzo_zN4j.js → audio-preflight-lT9iRnYi.js} +4 -4
  5. package/dist/{audio-transcription-runner-Cp_lkLCv.js → audio-transcription-runner-YiR1ym3a.js} +1 -1
  6. package/dist/{auth-choice-Ba4AEm_k.js → auth-choice-B_pvWO2S.js} +1 -1
  7. package/dist/{auth-choice-ziFj5bXd.js → auth-choice-kUm2JAky.js} +1 -1
  8. package/dist/{banner-DDih2slD.js → banner-4LItBqCV.js} +1 -1
  9. package/dist/build-info.json +2 -2
  10. package/dist/bundled/boot-md/handler.js +1 -1
  11. package/dist/bundled/session-memory/handler.js +1 -1
  12. package/dist/canvas-host/a2ui/.bundle.hash +1 -1
  13. package/dist/{channel-options-DTDfU0R6.js → channel-options-DA-4IR6h.js} +1 -1
  14. package/dist/{channel-options-BBSsevyl.js → channel-options-DQeQl3Rk.js} +1 -1
  15. package/dist/{channel-web-BXl9jCKV.js → channel-web--dAjVoio.js} +1 -1
  16. package/dist/{channel-web-SF18oYqo.js → channel-web-DJ21CAFF.js} +1 -1
  17. package/dist/{channels-cli-BDLabpWH.js → channels-cli-DviJtKuS.js} +6 -6
  18. package/dist/{channels-cli-BiuWJpJu.js → channels-cli-QvrLGt6C.js} +6 -6
  19. package/dist/{chrome-CZQnp4VH.js → chrome-CuBHInKC.js} +8 -8
  20. package/dist/{cli-CfgDCCuC.js → cli-aCubMdJg.js} +1 -1
  21. package/dist/{cli-DAZ1MKrJ.js → cli-q7seQ2Xx.js} +1 -1
  22. package/dist/{command-registry-DkjNuW8w.js → command-registry-C_YMaVul.js} +9 -9
  23. package/dist/{completion-cli-DbNma3J9.js → completion-cli-CyKEJDPO.js} +1 -1
  24. package/dist/{completion-cli-Du8H92bM.js → completion-cli-w4XQjhDI.js} +2 -2
  25. package/dist/{config-cli-D16tlTWa.js → config-cli-BfhjWCvB.js} +1 -1
  26. package/dist/{config-cli-CQhQ8Bcc.js → config-cli-BhQXEuBv.js} +1 -1
  27. package/dist/{configure-B4TiK50K.js → configure-0xkYrQ0e.js} +3 -3
  28. package/dist/{configure-B9b3cQTC.js → configure-Dsg_0ymU.js} +3 -3
  29. package/dist/{deliver-B4WWPQvt.js → deliver-6zfT7daI.js} +1 -1
  30. package/dist/{deliver-runtime-CeE1X9si.js → deliver-runtime-MBexxUuG.js} +3 -3
  31. package/dist/{deps-send-whatsapp.runtime-Cw7U9orE.js → deps-send-whatsapp.runtime-B7GC68Cu.js} +2 -2
  32. package/dist/{deps-send-whatsapp.runtime-CFnZsKW0.js → deps-send-whatsapp.runtime-BGDIgEzh.js} +3 -3
  33. package/dist/{deps-send-whatsapp.runtime-B9uivfkM.js → deps-send-whatsapp.runtime-BNAJe11S.js} +3 -3
  34. package/dist/{deps-send-whatsapp.runtime-miTfQkK9.js → deps-send-whatsapp.runtime-qBpqM2k9.js} +7 -7
  35. package/dist/{doctor-completion-CEiVFPte.js → doctor-completion-BCQdm02b.js} +1 -1
  36. package/dist/{doctor-completion-ujZ_JdIz.js → doctor-completion-BlkbgU5h.js} +1 -1
  37. package/dist/entry.js +2 -2
  38. package/dist/extensionAPI.js +6 -6
  39. package/dist/{gateway-cli-NXeo-J8r.js → gateway-cli-tFwyE4a3.js} +8 -8
  40. package/dist/{gateway-cli-2jaWM_Ci.js → gateway-cli-uWj08vdf.js} +8 -8
  41. package/dist/{health-BPZALM__.js → health-BwC4Qe5W.js} +1 -1
  42. package/dist/{health-DFZKMrW2.js → health-DS3reqch.js} +1 -1
  43. package/dist/{hooks-cli-B3rkhWcT.js → hooks-cli-oei5kRQM.js} +2 -2
  44. package/dist/{hooks-cli-BO_gZJVD.js → hooks-cli-tp5LchRL.js} +2 -2
  45. package/dist/{image-DKkuLtZ4.js → image-VgwN31FZ.js} +1 -1
  46. package/dist/{image-runtime-BMavqm9n.js → image-runtime-CwMuTYvd.js} +3 -3
  47. package/dist/index.js +6 -6
  48. package/dist/llm-slug-generator.js +1 -1
  49. package/dist/{models-Bb-GYqHr.js → models-D9X4EUlY.js} +2 -2
  50. package/dist/{models-cli-CAIJM1Wh.js → models-cli-C1PLBYF7.js} +2 -2
  51. package/dist/{models-cli-DffAz0ji.js → models-cli-LGp-Tok9.js} +3 -3
  52. package/dist/{npm-resolution-D2_zGJM-.js → npm-resolution-BUvQm-e-.js} +1 -1
  53. package/dist/{npm-resolution-D5pBCkUw.js → npm-resolution-Dtkh26DG.js} +1 -1
  54. package/dist/{onboard-dhG2YBez.js → onboard-B0padonr.js} +2 -2
  55. package/dist/{onboard-DcVsL9Jx.js → onboard-DDD6GX8E.js} +2 -2
  56. package/dist/{onboard-channels-mNXKTvFs.js → onboard-channels-9My16AOy.js} +1 -1
  57. package/dist/{onboard-channels-C-cQFUBH.js → onboard-channels-Bm_NXV3z.js} +1 -1
  58. package/dist/{onboarding-B3-IwkNi.js → onboarding-dES4q9RV.js} +3 -3
  59. package/dist/{onboarding-Cl6kW_iq.js → onboarding-o-id7p0-.js} +3 -3
  60. package/dist/{onboarding.finalize-BZqsNG2H.js → onboarding.finalize-BFtOLT7n.js} +6 -6
  61. package/dist/{onboarding.finalize-CCU-ykTR.js → onboarding.finalize-dpgNgUt5.js} +5 -5
  62. package/dist/{pi-embedded-C5U8Qxn6.js → pi-embedded-B_4NAHxA.js} +4 -40
  63. package/dist/{pi-embedded-B79nZERv.js → pi-embedded-BpHQIzjg.js} +24 -60
  64. package/dist/{pi-embedded-helpers-CEHpGDRs.js → pi-embedded-helpers-A9VYPVCH.js} +3 -3
  65. package/dist/{plugin-registry-CB47SSz1.js → plugin-registry-CCeUDvxY.js} +1 -1
  66. package/dist/{plugin-registry-Gy_VByyf.js → plugin-registry-CCkpP8-I.js} +1 -1
  67. package/dist/plugin-sdk/{channel-web-vB3Dcd8-.js → channel-web-BQE2gJ5U.js} +1 -1
  68. package/dist/plugin-sdk/{channel-web-BrhP6FQO.js → channel-web-BtNgAS1G.js} +1 -1
  69. package/dist/plugin-sdk/compat.js +50 -50
  70. package/dist/plugin-sdk/{deps-send-whatsapp.runtime-CuxKhIE0.js → deps-send-whatsapp.runtime-DPZSTh1j.js} +3 -3
  71. package/dist/plugin-sdk/{deps-send-whatsapp.runtime-Ce4Gzz-J.js → deps-send-whatsapp.runtime-V0Jfat5S.js} +3 -3
  72. package/dist/plugin-sdk/index.js +2 -2
  73. package/dist/plugin-sdk/mattermost.js +3 -3
  74. package/dist/plugin-sdk/nextcloud-talk.js +2 -2
  75. package/dist/plugin-sdk/{reply-DxvpiQBp.js → reply-DJYA4ZNu.js} +4 -40
  76. package/dist/plugin-sdk/{reply-sFKB3ofA.js → reply-DeKKmUDh.js} +4 -40
  77. package/dist/plugin-sdk/{slash-dispatch.runtime-C7u7mlny.js → slash-dispatch.runtime-E6j8gkO2.js} +1 -1
  78. package/dist/plugin-sdk/{slash-dispatch.runtime-Dyb_EkUt.js → slash-dispatch.runtime-k8xSVYOI.js} +1 -1
  79. package/dist/plugin-sdk/{subagent-registry-runtime-B6l6PxqP.js → subagent-registry-runtime-Cca50Qld.js} +1 -1
  80. package/dist/plugin-sdk/{subagent-registry-runtime-hdnabonI.js → subagent-registry-runtime-D6cTAG2k.js} +1 -1
  81. package/dist/plugin-sdk/{web-Bnn82S4u.js → web-Be4JS3z8.js} +2 -2
  82. package/dist/plugin-sdk/{web-D9LAdsuU.js → web-DkbCMgLG.js} +2 -2
  83. package/dist/plugin-sdk/whatsapp.js +2 -2
  84. package/dist/{plugins-cli-gtgkmDcv.js → plugins-cli-CZCadI9y.js} +2 -2
  85. package/dist/{plugins-cli-BYnoJwF1.js → plugins-cli-DFpHU_xo.js} +2 -2
  86. package/dist/{program-BGlgDpHI.js → program-B4_o5EDH.js} +7 -7
  87. package/dist/{program-context-M4FTWqqg.js → program-context-CkfdLtpp.js} +17 -17
  88. package/dist/{prompt-select-styled-AL5Tm3yO.js → prompt-select-styled-C1DFrYuk.js} +4 -4
  89. package/dist/{prompt-select-styled-BVC2byQV.js → prompt-select-styled-CZJJ2rPA.js} +4 -4
  90. package/dist/{provider-auth-helpers-DDgrFku5.js → provider-auth-helpers-BlYwNWkq.js} +1 -1
  91. package/dist/{provider-auth-helpers-Q7aIhDgv.js → provider-auth-helpers-C5taJG0R.js} +1 -1
  92. package/dist/{push-apns-FyGbUyh2.js → push-apns-Bhk1_5ut.js} +1 -1
  93. package/dist/{push-apns-Ga8xvhkh.js → push-apns-Dkjfalec.js} +1 -1
  94. package/dist/{pw-ai-Du22SYoO.js → pw-ai-CM87tQwG.js} +1 -1
  95. package/dist/{register.agent-zP8a-sNB.js → register.agent-DOp4lbyc.js} +7 -7
  96. package/dist/{register.agent-koAXw1ay.js → register.agent-s2PqcoIS.js} +6 -6
  97. package/dist/{register.configure-CYrmyjlf.js → register.configure-BGfourxZ.js} +7 -7
  98. package/dist/{register.configure-CUuP5J8W.js → register.configure-DABoMBBf.js} +7 -7
  99. package/dist/{register.maintenance-BZuEljPU.js → register.maintenance-Bdr3bSAF.js} +8 -8
  100. package/dist/{register.maintenance-ByEQ2CVH.js → register.maintenance-DmP8sVxb.js} +7 -7
  101. package/dist/{register.message-BkSXhv9I.js → register.message-DF0InVCv.js} +2 -2
  102. package/dist/{register.message-CgHfmDHm.js → register.message-gz8DaAc1.js} +2 -2
  103. package/dist/{register.onboard-HcQwPAEK.js → register.onboard-Do14cwDQ.js} +2 -2
  104. package/dist/{register.onboard-4ke40MNP.js → register.onboard-auVLfmF3.js} +2 -2
  105. package/dist/{register.setup-xAb7Cvzy.js → register.setup-B3aVuPyo.js} +2 -2
  106. package/dist/{register.setup-B41xZb1r.js → register.setup-ZyGJlYOD.js} +2 -2
  107. package/dist/{register.status-health-sessions-CcOVL0x8.js → register.status-health-sessions-C-1HE5oP.js} +3 -3
  108. package/dist/{register.status-health-sessions-BbHAAKwv.js → register.status-health-sessions-vFpvdVS1.js} +3 -3
  109. package/dist/{register.subclis-_uSASnfC.js → register.subclis-BYiAuTiK.js} +9 -9
  110. package/dist/{reply-BFTOdZcK.js → reply-BaVB3YlN.js} +4 -40
  111. package/dist/{run-main-C1eZrW-5.js → run-main-DW-JR8hB.js} +14 -14
  112. package/dist/{server-node-events-DbS1jJ5j.js → server-node-events-D-EmiDyc.js} +2 -2
  113. package/dist/{server-node-events-pYrJmi9w.js → server-node-events-rumcq7j0.js} +2 -2
  114. package/dist/{slash-dispatch.runtime-BGXbtMX6.js → slash-dispatch.runtime-BeltKAMm.js} +6 -6
  115. package/dist/{slash-dispatch.runtime-DqZVfX4H.js → slash-dispatch.runtime-C7rHRQFg.js} +1 -1
  116. package/dist/{slash-dispatch.runtime-DmFVOi3w.js → slash-dispatch.runtime-DPRwMKXk.js} +1 -1
  117. package/dist/{slash-dispatch.runtime-PX9_08Hm.js → slash-dispatch.runtime-sVHNrSL1.js} +1 -1
  118. package/dist/{status-DtiapFqq.js → status-BeSD1NDD.js} +2 -2
  119. package/dist/{status-B4eVRJcO.js → status-DGF_ROMC.js} +2 -2
  120. package/dist/{subagent-registry-Ctrhw4X-.js → subagent-registry-CgUBOyi3.js} +4 -40
  121. package/dist/{subagent-registry-runtime-Cy7dsGqF.js → subagent-registry-runtime-BYpjZwjA.js} +1 -1
  122. package/dist/{subagent-registry-runtime-BIKGAzgI.js → subagent-registry-runtime-Bm5UEB8c.js} +1 -1
  123. package/dist/{subagent-registry-runtime-CezPaX9P.js → subagent-registry-runtime-Bxc5DYZt.js} +6 -6
  124. package/dist/{subagent-registry-runtime-CTjx4TK5.js → subagent-registry-runtime-Cx5vPpG8.js} +1 -1
  125. package/dist/{update-cli-DLOWRdjv.js → update-cli-BSIF-OEa.js} +8 -8
  126. package/dist/{update-cli-_FsTRdQZ.js → update-cli-Duy8S3Bj.js} +7 -7
  127. package/dist/{update-runner-BY3l7ytB.js → update-runner-CMpruPN8.js} +1 -1
  128. package/dist/{update-runner-BKWHnVYI.js → update-runner-D_nDdx7d.js} +1 -1
  129. package/dist/{web-BNfDYvlW.js → web-Bnr4YuWJ.js} +2 -2
  130. package/dist/{web-BdZ3mX3p.js → web-C-5RPkV9.js} +2 -2
  131. package/dist/{web-1D0d1RHD.js → web-C0xcHURK.js} +1 -1
  132. package/dist/{web-B46aOGK0.js → web-CKY0tK0k.js} +6 -6
  133. package/package.json +1 -1
  134. package/dist/plugin-sdk/accounts-CUEuUR3C.js +0 -46
  135. package/dist/plugin-sdk/accounts-D0W2pELU.js +0 -288
  136. package/dist/plugin-sdk/accounts-ucj0odJq.js +0 -35
  137. package/dist/plugin-sdk/active-listener-BO7eBEG_.js +0 -50
  138. package/dist/plugin-sdk/agents/agent-tier.d.ts +0 -13
  139. package/dist/plugin-sdk/api-key-rotation-C4C_mDsg.js +0 -181
  140. package/dist/plugin-sdk/audio-preflight-Cqdo0JKm.js +0 -69
  141. package/dist/plugin-sdk/audio-transcription-runner-DnEooIyE.js +0 -2176
  142. package/dist/plugin-sdk/audit-membership-runtime-B9b-zRwg.js +0 -58
  143. package/dist/plugin-sdk/channel-activity-BMWLw4o2.js +0 -94
  144. package/dist/plugin-sdk/channel-web-D9WdAFlv.js +0 -2256
  145. package/dist/plugin-sdk/chrome-CV-q0Lmc.js +0 -2415
  146. package/dist/plugin-sdk/commands-registry-e7YoqrbP.js +0 -1125
  147. package/dist/plugin-sdk/config-B2B64aX0.js +0 -17911
  148. package/dist/plugin-sdk/deliver-BkyBtcLR.js +0 -1694
  149. package/dist/plugin-sdk/deliver-runtime-O4lwAWMw.js +0 -32
  150. package/dist/plugin-sdk/deps-send-discord.runtime-BAeeBldY.js +0 -23
  151. package/dist/plugin-sdk/deps-send-imessage.runtime-EL-CfikZ.js +0 -22
  152. package/dist/plugin-sdk/deps-send-signal.runtime-BeemHeUu.js +0 -21
  153. package/dist/plugin-sdk/deps-send-slack.runtime-DTttkC0N.js +0 -19
  154. package/dist/plugin-sdk/deps-send-telegram.runtime-Dsf9Cnka.js +0 -24
  155. package/dist/plugin-sdk/deps-send-whatsapp.runtime-CCS71r77.js +0 -57
  156. package/dist/plugin-sdk/diagnostic-DPRVoKTk.js +0 -319
  157. package/dist/plugin-sdk/errors-B8oJXuCF.js +0 -54
  158. package/dist/plugin-sdk/fetch-guard-F0Fnqisy.js +0 -156
  159. package/dist/plugin-sdk/fs-safe-Dqmpk-Fr.js +0 -352
  160. package/dist/plugin-sdk/image-cBW8L8pp.js +0 -2310
  161. package/dist/plugin-sdk/image-ops-BP8ix1GC.js +0 -584
  162. package/dist/plugin-sdk/image-runtime-9xkgSlNz.js +0 -25
  163. package/dist/plugin-sdk/ir-DWEc6zOp.js +0 -1296
  164. package/dist/plugin-sdk/local-roots-BIPT8uAO.js +0 -186
  165. package/dist/plugin-sdk/logger-DDdrdbDu.js +0 -1163
  166. package/dist/plugin-sdk/login-BMTiGutN.js +0 -57
  167. package/dist/plugin-sdk/login-qr-BFxqYUkc.js +0 -320
  168. package/dist/plugin-sdk/manager-BD-aYaZ8.js +0 -3917
  169. package/dist/plugin-sdk/manager-runtime-C5bRwUlz.js +0 -15
  170. package/dist/plugin-sdk/outbound-Bm07xvO6.js +0 -212
  171. package/dist/plugin-sdk/outbound-attachment-DLsaxDsc.js +0 -19
  172. package/dist/plugin-sdk/path-alias-guards-gBhrAn14.js +0 -43
  173. package/dist/plugin-sdk/paths-C6W4VHoa.js +0 -166
  174. package/dist/plugin-sdk/pi-embedded-helpers-BExwPvTh.js +0 -9627
  175. package/dist/plugin-sdk/pi-model-discovery-DdctvBeX.js +0 -134
  176. package/dist/plugin-sdk/pi-model-discovery-runtime-DrtpLJjk.js +0 -8
  177. package/dist/plugin-sdk/pi-tools.before-tool-call.runtime-rgTz3FBl.js +0 -354
  178. package/dist/plugin-sdk/plugins-BN64HHZA.js +0 -864
  179. package/dist/plugin-sdk/proxy-fetch-ZPEvp58f.js +0 -38
  180. package/dist/plugin-sdk/pw-ai-DBm3RdBK.js +0 -1938
  181. package/dist/plugin-sdk/qmd-manager-6bozlfFg.js +0 -1448
  182. package/dist/plugin-sdk/query-expansion-eeVz_aEm.js +0 -1011
  183. package/dist/plugin-sdk/redact-BoNEjbpF.js +0 -319
  184. package/dist/plugin-sdk/reply-CqXMy3Yd.js +0 -98731
  185. package/dist/plugin-sdk/resolve-outbound-target-DXfjGlZQ.js +0 -40
  186. package/dist/plugin-sdk/run-with-concurrency-5DMu9szx.js +0 -1994
  187. package/dist/plugin-sdk/runtime-whatsapp-login.runtime-D2hkJBa-.js +0 -10
  188. package/dist/plugin-sdk/runtime-whatsapp-outbound.runtime-C06I4adi.js +0 -19
  189. package/dist/plugin-sdk/send-B9xnwtQ-.js +0 -540
  190. package/dist/plugin-sdk/send-BxySs-Cu.js +0 -2587
  191. package/dist/plugin-sdk/send-D9THKp_J.js +0 -414
  192. package/dist/plugin-sdk/send-DCuaaP2w.js +0 -503
  193. package/dist/plugin-sdk/send-Dm_-_xje.js +0 -3135
  194. package/dist/plugin-sdk/session-DDzIZHxt.js +0 -169
  195. package/dist/plugin-sdk/skill-commands-DRvqtuFC.js +0 -342
  196. package/dist/plugin-sdk/skills-BWwlfbVj.js +0 -1428
  197. package/dist/plugin-sdk/slash-commands.runtime-BzYsaTST.js +0 -13
  198. package/dist/plugin-sdk/slash-dispatch.runtime-BC3IAF-I.js +0 -52
  199. package/dist/plugin-sdk/slash-skill-commands.runtime-sg98L8BK.js +0 -16
  200. package/dist/plugin-sdk/ssrf-DOBwjFow.js +0 -202
  201. package/dist/plugin-sdk/store-BKDR_-Qk.js +0 -81
  202. package/dist/plugin-sdk/subagent-registry-runtime-Ceu7AzWi.js +0 -52
  203. package/dist/plugin-sdk/tables-GIj79us5.js +0 -55
  204. package/dist/plugin-sdk/target-errors-jlLHihbX.js +0 -195
  205. package/dist/plugin-sdk/thinking-BgdUnMZ2.js +0 -1206
  206. package/dist/plugin-sdk/tokens-CTIYTLWu.js +0 -52
  207. package/dist/plugin-sdk/tool-images-GSlvf6RP.js +0 -274
  208. package/dist/plugin-sdk/web-BK2-uaOo.js +0 -56
  209. package/dist/plugin-sdk/whatsapp-actions-DQpK_5Ds.js +0 -80
@@ -1,186 +0,0 @@
1
- import { c as resolveAgentWorkspaceDir } from "./run-with-concurrency-5DMu9szx.js";
2
- import { c as resolveStateDir } from "./paths-8xF5kDne.js";
3
- import { X as resolvePreferredSquidClawTmpDir } from "./logger-DDdrdbDu.js";
4
- import { c as detectMime, l as extensionForMime } from "./image-ops-BP8ix1GC.js";
5
- import { n as withStrictGuardedFetchMode, t as fetchWithSsrFGuard } from "./fetch-guard-F0Fnqisy.js";
6
- import path from "node:path";
7
-
8
- //#region src/media/read-response-with-limit.ts
9
- async function readResponseWithLimit(res, maxBytes, opts) {
10
- const onOverflow = opts?.onOverflow ?? ((params) => /* @__PURE__ */ new Error(`Content too large: ${params.size} bytes (limit: ${params.maxBytes} bytes)`));
11
- const body = res.body;
12
- if (!body || typeof body.getReader !== "function") {
13
- const fallback = Buffer.from(await res.arrayBuffer());
14
- if (fallback.length > maxBytes) throw onOverflow({
15
- size: fallback.length,
16
- maxBytes,
17
- res
18
- });
19
- return fallback;
20
- }
21
- const reader = body.getReader();
22
- const chunks = [];
23
- let total = 0;
24
- try {
25
- while (true) {
26
- const { done, value } = await reader.read();
27
- if (done) break;
28
- if (value?.length) {
29
- total += value.length;
30
- if (total > maxBytes) {
31
- try {
32
- await reader.cancel();
33
- } catch {}
34
- throw onOverflow({
35
- size: total,
36
- maxBytes,
37
- res
38
- });
39
- }
40
- chunks.push(value);
41
- }
42
- }
43
- } finally {
44
- try {
45
- reader.releaseLock();
46
- } catch {}
47
- }
48
- return Buffer.concat(chunks.map((chunk) => Buffer.from(chunk)), total);
49
- }
50
-
51
- //#endregion
52
- //#region src/media/fetch.ts
53
- var MediaFetchError = class extends Error {
54
- constructor(code, message) {
55
- super(message);
56
- this.code = code;
57
- this.name = "MediaFetchError";
58
- }
59
- };
60
- function stripQuotes(value) {
61
- return value.replace(/^["']|["']$/g, "");
62
- }
63
- function parseContentDispositionFileName(header) {
64
- if (!header) return;
65
- const starMatch = /filename\*\s*=\s*([^;]+)/i.exec(header);
66
- if (starMatch?.[1]) {
67
- const cleaned = stripQuotes(starMatch[1].trim());
68
- const encoded = cleaned.split("''").slice(1).join("''") || cleaned;
69
- try {
70
- return path.basename(decodeURIComponent(encoded));
71
- } catch {
72
- return path.basename(encoded);
73
- }
74
- }
75
- const match = /filename\s*=\s*([^;]+)/i.exec(header);
76
- if (match?.[1]) return path.basename(stripQuotes(match[1].trim()));
77
- }
78
- async function readErrorBodySnippet(res, maxChars = 200) {
79
- try {
80
- const text = await res.text();
81
- if (!text) return;
82
- const collapsed = text.replace(/\s+/g, " ").trim();
83
- if (!collapsed) return;
84
- if (collapsed.length <= maxChars) return collapsed;
85
- return `${collapsed.slice(0, maxChars)}…`;
86
- } catch {
87
- return;
88
- }
89
- }
90
- async function fetchRemoteMedia(options) {
91
- const { url, fetchImpl, requestInit, filePathHint, maxBytes, maxRedirects, ssrfPolicy, lookupFn } = options;
92
- let res;
93
- let finalUrl = url;
94
- let release = null;
95
- try {
96
- const result = await fetchWithSsrFGuard(withStrictGuardedFetchMode({
97
- url,
98
- fetchImpl,
99
- init: requestInit,
100
- maxRedirects,
101
- policy: ssrfPolicy,
102
- lookupFn
103
- }));
104
- res = result.response;
105
- finalUrl = result.finalUrl;
106
- release = result.release;
107
- } catch (err) {
108
- throw new MediaFetchError("fetch_failed", `Failed to fetch media from ${url}: ${String(err)}`);
109
- }
110
- try {
111
- if (!res.ok) {
112
- const statusText = res.statusText ? ` ${res.statusText}` : "";
113
- const redirected = finalUrl !== url ? ` (redirected to ${finalUrl})` : "";
114
- let detail = `HTTP ${res.status}${statusText}`;
115
- if (!res.body) detail = `HTTP ${res.status}${statusText}; empty response body`;
116
- else {
117
- const snippet = await readErrorBodySnippet(res);
118
- if (snippet) detail += `; body: ${snippet}`;
119
- }
120
- throw new MediaFetchError("http_error", `Failed to fetch media from ${url}${redirected}: ${detail}`);
121
- }
122
- const contentLength = res.headers.get("content-length");
123
- if (maxBytes && contentLength) {
124
- const length = Number(contentLength);
125
- if (Number.isFinite(length) && length > maxBytes) throw new MediaFetchError("max_bytes", `Failed to fetch media from ${url}: content length ${length} exceeds maxBytes ${maxBytes}`);
126
- }
127
- const buffer = maxBytes ? await readResponseWithLimit(res, maxBytes, { onOverflow: ({ maxBytes, res }) => new MediaFetchError("max_bytes", `Failed to fetch media from ${res.url || url}: payload exceeds maxBytes ${maxBytes}`) }) : Buffer.from(await res.arrayBuffer());
128
- let fileNameFromUrl;
129
- try {
130
- const parsed = new URL(finalUrl);
131
- fileNameFromUrl = path.basename(parsed.pathname) || void 0;
132
- } catch {}
133
- const headerFileName = parseContentDispositionFileName(res.headers.get("content-disposition"));
134
- let fileName = headerFileName || fileNameFromUrl || (filePathHint ? path.basename(filePathHint) : void 0);
135
- const filePathForMime = headerFileName && path.extname(headerFileName) ? headerFileName : filePathHint ?? finalUrl;
136
- const contentType = await detectMime({
137
- buffer,
138
- headerMime: res.headers.get("content-type"),
139
- filePath: filePathForMime
140
- });
141
- if (fileName && !path.extname(fileName) && contentType) {
142
- const ext = extensionForMime(contentType);
143
- if (ext) fileName = `${fileName}${ext}`;
144
- }
145
- return {
146
- buffer,
147
- contentType: contentType ?? void 0,
148
- fileName
149
- };
150
- } finally {
151
- if (release) await release();
152
- }
153
- }
154
-
155
- //#endregion
156
- //#region src/media/local-roots.ts
157
- let cachedPreferredTmpDir;
158
- function resolveCachedPreferredTmpDir() {
159
- if (!cachedPreferredTmpDir) cachedPreferredTmpDir = resolvePreferredSquidClawTmpDir();
160
- return cachedPreferredTmpDir;
161
- }
162
- function buildMediaLocalRoots(stateDir, options = {}) {
163
- const resolvedStateDir = path.resolve(stateDir);
164
- return [
165
- options.preferredTmpDir ?? resolveCachedPreferredTmpDir(),
166
- path.join(resolvedStateDir, "media"),
167
- path.join(resolvedStateDir, "agents"),
168
- path.join(resolvedStateDir, "workspace"),
169
- path.join(resolvedStateDir, "sandboxes")
170
- ];
171
- }
172
- function getDefaultMediaLocalRoots() {
173
- return buildMediaLocalRoots(resolveStateDir());
174
- }
175
- function getAgentScopedMediaLocalRoots(cfg, agentId) {
176
- const roots = buildMediaLocalRoots(resolveStateDir());
177
- if (!agentId?.trim()) return roots;
178
- const workspaceDir = resolveAgentWorkspaceDir(cfg, agentId);
179
- if (!workspaceDir) return roots;
180
- const normalizedWorkspaceDir = path.resolve(workspaceDir);
181
- if (!roots.includes(normalizedWorkspaceDir)) roots.push(normalizedWorkspaceDir);
182
- return roots;
183
- }
184
-
185
- //#endregion
186
- export { readResponseWithLimit as a, fetchRemoteMedia as i, getDefaultMediaLocalRoots as n, MediaFetchError as r, getAgentScopedMediaLocalRoots as t };