openclaw-multi-auto 1.4.4 → 1.4.5

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 (175) hide show
  1. package/dist/build-info.json +3 -3
  2. package/dist/canvas-host/a2ui/.bundle.hash +1 -1
  3. package/dist/plugin-sdk/{accounts-C3m65--E.js → accounts-BJAXxY46.js} +2 -2
  4. package/dist/plugin-sdk/{accounts-CNCCkdEF.js → accounts-C1j7HSL0.js} +3 -3
  5. package/dist/plugin-sdk/{accounts-BslAlVYS.js → accounts-DyFCXtHv.js} +2 -2
  6. package/dist/plugin-sdk/{active-listener-B_sLJTXM.js → active-listener-CftX5jLD.js} +2 -2
  7. package/dist/plugin-sdk/{api-key-rotation-BRE4X2tf.js → api-key-rotation-8nyyt1kx.js} +2 -2
  8. package/dist/plugin-sdk/{audio-preflight-CtO4fFvp.js → audio-preflight-C_aSAPR1.js} +26 -26
  9. package/dist/plugin-sdk/{audio-transcription-runner-DnxvOS1-.js → audio-transcription-runner-CB53F7_7.js} +11 -11
  10. package/dist/plugin-sdk/{audit-membership-runtime-BpfoSk8M.js → audit-membership-runtime-BXndI4LG.js} +2 -2
  11. package/dist/plugin-sdk/{channel-activity-WJYxcJ3S.js → channel-activity-C5y8AgAV.js} +3 -3
  12. package/dist/plugin-sdk/{channel-web-dO5k3ubM.js → channel-web-DBTRO03V.js} +18 -18
  13. package/dist/plugin-sdk/{chrome-CjNTuJML.js → chrome-f00sZkDX.js} +6 -6
  14. package/dist/plugin-sdk/{commands-registry-CdYjoI0i.js → commands-registry-BJ_NxG2F.js} +4 -4
  15. package/dist/plugin-sdk/{common-oYc5vPFl.js → common-Cf27Jwxu.js} +2 -2
  16. package/dist/plugin-sdk/{config-B1z-UxQ3.js → config-CHQrpx-Q.js} +7 -7
  17. package/dist/plugin-sdk/{deliver-D5_6T567.js → deliver-DNEuetST.js} +10 -10
  18. package/dist/plugin-sdk/deliver-runtime-BFdqklJM.js +32 -0
  19. package/dist/plugin-sdk/deps-send-discord.runtime-DuqpYwU0.js +23 -0
  20. package/dist/plugin-sdk/deps-send-imessage.runtime-CZ2rS8Lb.js +22 -0
  21. package/dist/plugin-sdk/deps-send-signal.runtime-BdqiWhIh.js +21 -0
  22. package/dist/plugin-sdk/deps-send-slack.runtime-04s36qiC.js +19 -0
  23. package/dist/plugin-sdk/deps-send-telegram.runtime-LE5tkPvr.js +24 -0
  24. package/dist/plugin-sdk/deps-send-whatsapp.runtime-Bz57lobC.js +57 -0
  25. package/dist/plugin-sdk/{diagnostic-Bxxu0ig-.js → diagnostic-LYUUmjJ5.js} +2 -2
  26. package/dist/plugin-sdk/{errors-B3cHyZZA.js → errors-CtMWwS2Z.js} +1 -1
  27. package/dist/plugin-sdk/{fetch-guard-Dcgod0tg.js → fetch-guard-CxYB5Kg6.js} +2 -2
  28. package/dist/plugin-sdk/{fs-safe-BaKqI3G4.js → fs-safe-DtfhxbrI.js} +3 -3
  29. package/dist/plugin-sdk/{image-B2mQW9Rb.js → image-BwjYjRHx.js} +6 -6
  30. package/dist/plugin-sdk/{image-ops-Cbzr4U9l.js → image-ops-BnZKcbd6.js} +2 -2
  31. package/dist/plugin-sdk/image-runtime-B8twoubs.js +25 -0
  32. package/dist/plugin-sdk/index.js +50 -50
  33. package/dist/plugin-sdk/{ir-ZEmrTr4J.js → ir-Z4hX67TJ.js} +7 -7
  34. package/dist/plugin-sdk/{local-roots-CIPRxA-4.js → local-roots-KhjQw04O.js} +4 -4
  35. package/dist/plugin-sdk/{logger-CvPFVOgT.js → logger-DHIIvMxj.js} +2 -2
  36. package/dist/plugin-sdk/{login-CCTew9bt.js → login-C31642Ld.js} +4 -4
  37. package/dist/plugin-sdk/{login-qr-BI3Vi_wJ.js → login-qr--y2SG_Ue.js} +5 -5
  38. package/dist/plugin-sdk/{manager-BEoYPn7R.js → manager-2UZBMCc7.js} +8 -8
  39. package/dist/plugin-sdk/manager-runtime-CMeLwose.js +15 -0
  40. package/dist/plugin-sdk/mattermost.js +3 -3
  41. package/dist/plugin-sdk/{outbound-ByOw1K6W.js → outbound-Ba0QUI5h.js} +5 -5
  42. package/dist/plugin-sdk/{outbound-attachment-BzVhxRRw.js → outbound-attachment-B1Laso-8.js} +2 -2
  43. package/dist/plugin-sdk/{path-alias-guards-DBjLbIX_.js → path-alias-guards-C7Vm5DZ1.js} +1 -1
  44. package/dist/plugin-sdk/{paths-Dpg3qxcl.js → paths-DopV9PQG.js} +1 -1
  45. package/dist/plugin-sdk/{pi-embedded-helpers-DIxXkGJf.js → pi-embedded-helpers-DnA_OCzP.js} +16 -16
  46. package/dist/plugin-sdk/{pi-model-discovery-DM_2uFtj.js → pi-model-discovery-DdPqXk8f.js} +1 -1
  47. package/dist/plugin-sdk/pi-model-discovery-runtime-D8CJhtJY.js +8 -0
  48. package/dist/plugin-sdk/{pi-tools.before-tool-call.runtime-w1dqL_ty.js → pi-tools.before-tool-call.runtime-DxFHiLUE.js} +4 -4
  49. package/dist/plugin-sdk/{plugins-C4USiH29.js → plugins-CbCt4osF.js} +4 -4
  50. package/dist/plugin-sdk/{proxy-env-ET-rp8eg.js → proxy-env-C63mMdas.js} +1 -1
  51. package/dist/plugin-sdk/{proxy-fetch-ChxOhWF4.js → proxy-fetch-Ch95c_Y2.js} +1 -1
  52. package/dist/plugin-sdk/{pw-ai-CyOt3RDA.js → pw-ai-DpJk62D4.js} +9 -9
  53. package/dist/plugin-sdk/{qmd-manager-BySdoVR7.js → qmd-manager-Ca-iSfEE.js} +7 -7
  54. package/dist/plugin-sdk/{query-expansion-C6uS-7lj.js → query-expansion-B_Xe41Ab.js} +4 -4
  55. package/dist/plugin-sdk/{redact-DjVX-1N3.js → redact-hp9TOulW.js} +1 -1
  56. package/dist/plugin-sdk/{reply-CTCSeQqW.js → reply-CovBlFea.js} +73 -73
  57. package/dist/plugin-sdk/{resolve-outbound-target-Bw8YNANu.js → resolve-outbound-target-BbrHgyUk.js} +2 -2
  58. package/dist/plugin-sdk/{run-with-concurrency-C_KCHwvf.js → run-with-concurrency-BR1DXa8T.js} +1 -1
  59. package/dist/plugin-sdk/runtime-whatsapp-login.runtime-SkO91TZH.js +10 -0
  60. package/dist/plugin-sdk/runtime-whatsapp-outbound.runtime-B0VWK5hm.js +19 -0
  61. package/dist/plugin-sdk/{send-C0w6xP2x.js → send-BTztm3D2.js} +6 -6
  62. package/dist/plugin-sdk/{send-qPyNGSe4.js → send-BXpXBwM_.js} +13 -13
  63. package/dist/plugin-sdk/{send-BZ6nYFZr.js → send-BvAtLLPl.js} +5 -5
  64. package/dist/plugin-sdk/{send-CFf-1V89.js → send-CWJUuG0i.js} +8 -8
  65. package/dist/plugin-sdk/{send-CY-Qfwia.js → send-EcglC4cG.js} +7 -7
  66. package/dist/plugin-sdk/{session-COrvpvUQ.js → session-k256LJZT.js} +3 -3
  67. package/dist/plugin-sdk/{skill-commands-DZqhtmiv.js → skill-commands-DoRqLzxm.js} +4 -4
  68. package/dist/plugin-sdk/{skills-Cw_vXEJb.js → skills-QudILG6e.js} +6 -6
  69. package/dist/plugin-sdk/slash-commands.runtime-DS6vCNSL.js +13 -0
  70. package/dist/plugin-sdk/slash-dispatch.runtime-BXrxb2wd.js +52 -0
  71. package/dist/plugin-sdk/slash-skill-commands.runtime-Bd6qQ2oT.js +16 -0
  72. package/dist/plugin-sdk/{store-CMHj6IIw.js → store-BbDQw3g6.js} +2 -2
  73. package/dist/plugin-sdk/subagent-registry-runtime-1uwQbuXj.js +52 -0
  74. package/dist/plugin-sdk/{tables-CSqrHsKL.js → tables-BhvloMKN.js} +1 -1
  75. package/dist/plugin-sdk/{thinking-DOnsR_A8.js → thinking-URzkT-3p.js} +7 -7
  76. package/dist/plugin-sdk/{tokens-DgNRBwIg.js → tokens-B1PW5Ayy.js} +1 -1
  77. package/dist/plugin-sdk/{tool-images-Gk_-0y2N.js → tool-images-xpqbP6RR.js} +2 -2
  78. package/dist/plugin-sdk/web-B74yhL2N.js +56 -0
  79. package/dist/plugin-sdk/{whatsapp-actions-xcleMoMv.js → whatsapp-actions-RcZ6vp61.js} +17 -17
  80. package/dist/plugin-sdk/whatsapp.js +50 -50
  81. package/package.json +1 -1
  82. package/scripts/create-instance.sh +6 -0
  83. package/scripts/install-maca.sh +78 -87
  84. package/dist/plugin-sdk/accounts-CJWOBzwB.js +0 -35
  85. package/dist/plugin-sdk/accounts-DP1-L-QS.js +0 -288
  86. package/dist/plugin-sdk/accounts-DZhWlEg3.js +0 -46
  87. package/dist/plugin-sdk/active-listener-CkPnMUkB.js +0 -50
  88. package/dist/plugin-sdk/api-key-rotation-BXnNsojA.js +0 -181
  89. package/dist/plugin-sdk/audio-preflight-DGEUDxxR.js +0 -69
  90. package/dist/plugin-sdk/audio-transcription-runner-DkoPNPYt.js +0 -2176
  91. package/dist/plugin-sdk/audit-membership-runtime-DSBHHw7o.js +0 -58
  92. package/dist/plugin-sdk/channel-activity-F3d0yUwy.js +0 -94
  93. package/dist/plugin-sdk/channel-web-QF7EpjeP.js +0 -2256
  94. package/dist/plugin-sdk/chrome-BXoCyCkY.js +0 -2415
  95. package/dist/plugin-sdk/commands-registry-t7cXBTfN.js +0 -1125
  96. package/dist/plugin-sdk/config-BkEnz2Po.js +0 -17913
  97. package/dist/plugin-sdk/deliver-B6AG_l67.js +0 -1694
  98. package/dist/plugin-sdk/deliver-runtime-C5dgvvga.js +0 -32
  99. package/dist/plugin-sdk/deliver-runtime-D585kJZc.js +0 -32
  100. package/dist/plugin-sdk/deps-send-discord.runtime-Dg4N7PHJ.js +0 -23
  101. package/dist/plugin-sdk/deps-send-discord.runtime-a_OKY2js.js +0 -23
  102. package/dist/plugin-sdk/deps-send-imessage.runtime-0OEwzMQm.js +0 -22
  103. package/dist/plugin-sdk/deps-send-imessage.runtime-Baxy9TD4.js +0 -22
  104. package/dist/plugin-sdk/deps-send-signal.runtime-BM1jRt3G.js +0 -21
  105. package/dist/plugin-sdk/deps-send-signal.runtime-BwXoCrFl.js +0 -21
  106. package/dist/plugin-sdk/deps-send-slack.runtime-1E3BYRdF.js +0 -19
  107. package/dist/plugin-sdk/deps-send-slack.runtime-CLmKjgso.js +0 -19
  108. package/dist/plugin-sdk/deps-send-telegram.runtime-BKfdBKnZ.js +0 -24
  109. package/dist/plugin-sdk/deps-send-telegram.runtime-DNCxIflA.js +0 -24
  110. package/dist/plugin-sdk/deps-send-whatsapp.runtime-BOTwkbx_.js +0 -57
  111. package/dist/plugin-sdk/deps-send-whatsapp.runtime-OLwr-9c8.js +0 -57
  112. package/dist/plugin-sdk/diagnostic-CsP-lEkI.js +0 -319
  113. package/dist/plugin-sdk/errors-DaiAM-yU.js +0 -54
  114. package/dist/plugin-sdk/fetch-guard-DETCcJzQ.js +0 -156
  115. package/dist/plugin-sdk/fs-safe-B8y811FR.js +0 -352
  116. package/dist/plugin-sdk/image-DjTEkYZE.js +0 -2310
  117. package/dist/plugin-sdk/image-ops-BSiMpAw4.js +0 -584
  118. package/dist/plugin-sdk/image-runtime-6xPp8m5a.js +0 -25
  119. package/dist/plugin-sdk/image-runtime-BFm45j49.js +0 -25
  120. package/dist/plugin-sdk/ir-DQ7_HbvK.js +0 -1296
  121. package/dist/plugin-sdk/local-roots-BUP4YBmR.js +0 -186
  122. package/dist/plugin-sdk/logger-CZY9KIoY.js +0 -1163
  123. package/dist/plugin-sdk/login-BxEKLlCo.js +0 -57
  124. package/dist/plugin-sdk/login-qr-BQIpMPr9.js +0 -320
  125. package/dist/plugin-sdk/manager-I6KbPihW.js +0 -3917
  126. package/dist/plugin-sdk/manager-runtime-CFfYYWIQ.js +0 -15
  127. package/dist/plugin-sdk/manager-runtime-DxclHQ4U.js +0 -15
  128. package/dist/plugin-sdk/outbound-NS6UHnB6.js +0 -212
  129. package/dist/plugin-sdk/outbound-attachment-Dy6fyf6H.js +0 -19
  130. package/dist/plugin-sdk/path-alias-guards-sWayacde.js +0 -43
  131. package/dist/plugin-sdk/paths-vTM3Lh3X.js +0 -166
  132. package/dist/plugin-sdk/pi-embedded-helpers-1R1gu7eX.js +0 -9627
  133. package/dist/plugin-sdk/pi-model-discovery-runtime-BuzvkvNR.js +0 -8
  134. package/dist/plugin-sdk/pi-model-discovery-runtime-Do9o-dUd.js +0 -8
  135. package/dist/plugin-sdk/pi-model-discovery-v-XPUOOf.js +0 -134
  136. package/dist/plugin-sdk/pi-tools.before-tool-call.runtime-D4sFsIks.js +0 -354
  137. package/dist/plugin-sdk/plugins-DeBZB9l_.js +0 -864
  138. package/dist/plugin-sdk/proxy-fetch-uDXGKG3Z.js +0 -38
  139. package/dist/plugin-sdk/pw-ai-DEOmCSSC.js +0 -1938
  140. package/dist/plugin-sdk/qmd-manager-HyYKoEch.js +0 -1448
  141. package/dist/plugin-sdk/query-expansion-CeyKUeDW.js +0 -1011
  142. package/dist/plugin-sdk/redact-Bvxt1T_Q.js +0 -319
  143. package/dist/plugin-sdk/reply-DAo_Jt8K.js +0 -97916
  144. package/dist/plugin-sdk/resolve-outbound-target-B42qgQS9.js +0 -40
  145. package/dist/plugin-sdk/run-with-concurrency-Bt_ks0Qa.js +0 -1994
  146. package/dist/plugin-sdk/runtime-whatsapp-login.runtime-B6W989eF.js +0 -10
  147. package/dist/plugin-sdk/runtime-whatsapp-login.runtime-BxgRDkhc.js +0 -10
  148. package/dist/plugin-sdk/runtime-whatsapp-outbound.runtime-c_GDFy37.js +0 -19
  149. package/dist/plugin-sdk/runtime-whatsapp-outbound.runtime-elOqrkfg.js +0 -19
  150. package/dist/plugin-sdk/send-CQpMudwO.js +0 -2587
  151. package/dist/plugin-sdk/send-DQHLzVyO.js +0 -414
  152. package/dist/plugin-sdk/send-DTB24bEF.js +0 -3135
  153. package/dist/plugin-sdk/send-DfHadjZ_.js +0 -503
  154. package/dist/plugin-sdk/send-XXlW2iny.js +0 -540
  155. package/dist/plugin-sdk/session-6TF6MyaC.js +0 -169
  156. package/dist/plugin-sdk/skill-commands-CkGeFUMl.js +0 -342
  157. package/dist/plugin-sdk/skills-CBkHBYPq.js +0 -1428
  158. package/dist/plugin-sdk/slash-commands.runtime-CxliuGaP.js +0 -13
  159. package/dist/plugin-sdk/slash-commands.runtime-D67JLweo.js +0 -13
  160. package/dist/plugin-sdk/slash-dispatch.runtime-DFaeYlJQ.js +0 -52
  161. package/dist/plugin-sdk/slash-dispatch.runtime-DvcpvCJ0.js +0 -52
  162. package/dist/plugin-sdk/slash-skill-commands.runtime-0M0OLCxq.js +0 -16
  163. package/dist/plugin-sdk/slash-skill-commands.runtime-BM1x3azR.js +0 -16
  164. package/dist/plugin-sdk/ssrf-cFtplYtS.js +0 -202
  165. package/dist/plugin-sdk/store-5nyxY3WU.js +0 -81
  166. package/dist/plugin-sdk/subagent-registry-runtime-1lbDyRzz.js +0 -52
  167. package/dist/plugin-sdk/subagent-registry-runtime-DCtmDwna.js +0 -52
  168. package/dist/plugin-sdk/tables-C47P4GTN.js +0 -55
  169. package/dist/plugin-sdk/target-errors-Blia4S69.js +0 -195
  170. package/dist/plugin-sdk/thinking-Bo2eosVa.js +0 -1206
  171. package/dist/plugin-sdk/tokens-BDr0Z9o3.js +0 -52
  172. package/dist/plugin-sdk/tool-images-eEfOVkzf.js +0 -274
  173. package/dist/plugin-sdk/web-BLyT64pW.js +0 -56
  174. package/dist/plugin-sdk/web-CVxZbXyH.js +0 -56
  175. package/dist/plugin-sdk/whatsapp-actions-Bw0H9g-n.js +0 -80
@@ -1,186 +0,0 @@
1
- import { c as resolveAgentWorkspaceDir } from "./run-with-concurrency-Bt_ks0Qa.js";
2
- import { c as resolveStateDir } from "./paths-MKyEVmEb.js";
3
- import { X as resolvePreferredOpenClawTmpDir } from "./logger-CZY9KIoY.js";
4
- import { c as detectMime, l as extensionForMime } from "./image-ops-BSiMpAw4.js";
5
- import { n as withStrictGuardedFetchMode, t as fetchWithSsrFGuard } from "./fetch-guard-DETCcJzQ.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 = resolvePreferredOpenClawTmpDir();
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 };