@openclaw/discord 2026.9.1-beta.1 → 2026.9.2

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 (165) hide show
  1. package/dist/account-inspect-BY-ve3yH.js +45 -0
  2. package/dist/account-inspect-api.js +1 -1
  3. package/dist/{accounts-CfQ-vSyf.js → accounts-CwJQoLjM.js} +89 -45
  4. package/dist/action-runtime-api.js +1 -1
  5. package/dist/{activities-api-q-9PaaHH.js → activities-api-CTcGq3Hf.js} +30 -17
  6. package/dist/activities-api.js +1 -1
  7. package/dist/{allow-list-BDMimASD.js → allow-list-DBTtR2dz.js} +13 -35
  8. package/dist/{api-DNVbJyEy.js → api-BfmEP6wp.js} +6 -5
  9. package/dist/api.js +18 -18
  10. package/dist/{approval-handler.runtime-B7qhK3fR.js → approval-handler.runtime-DUSe5fyH.js} +19 -12
  11. package/dist/{audit-CBEv_ERu.js → audit-DpPfwoJM.js} +8 -7
  12. package/dist/{channel-Dx1tMTfx.js → channel-BHajPgwR.js} +29 -23
  13. package/dist/{channel-actions.runtime-CLWWu9nC.js → channel-actions.runtime-DS8pXo0S.js} +38 -38
  14. package/dist/channel-config-api.js +1 -1
  15. package/dist/channel-plugin-api.js +1 -1
  16. package/dist/{channel.setup-DOzXS2Pk.js → channel.setup-BWmMe1tT.js} +18 -18
  17. package/dist/command-owners-D78sAoOz.js +10 -0
  18. package/dist/{components-B9V5o361.js → components-BimX47Mq.js} +111 -149
  19. package/dist/{config-schema-BR13IAx6.js → config-schema-B797-Spt.js} +19 -12
  20. package/dist/{conversation-binding-route-DJYrY2TQ.js → conversation-binding-route-DuR5NGIx.js} +1 -1
  21. package/dist/{directory-config-BK6eqekJ.js → directory-config-CD2v2Szs.js} +2 -2
  22. package/dist/directory-contract-api.js +1 -1
  23. package/dist/{directory-live-DSAJSrJk.js → directory-live-DaJzWJ2N.js} +4 -4
  24. package/dist/{doctor-Cm7Y1pJ2.js → doctor-D4HH1inA.js} +9 -6
  25. package/dist/{doctor-contract-DsWvKIXF.js → doctor-contract-Co5vRCZ6.js} +9 -6
  26. package/dist/doctor-contract-api.js +31 -28
  27. package/dist/{handle-action.guild-admin-BdwCRHmm.js → handle-action.guild-admin-4We6wWQU.js} +6 -3
  28. package/dist/index.js +1 -1
  29. package/dist/ingress-identity-XNmW-mZS.js +60 -0
  30. package/dist/{message-handler-BXpWZyni.js → message-handler-DhgBabyU.js} +61 -70
  31. package/dist/{message-handler.preflight-Ba5LAY_X.js → message-handler.preflight-oZ7dQCd0.js} +41 -101
  32. package/dist/{message-handler.process-3HEzmemS.js → message-handler.process-BzCYf1pa.js} +82 -108
  33. package/dist/{message-text-aiwO5R2F.js → message-text-DK4NnBg-.js} +11 -6
  34. package/dist/{outbound-adapter-BE4jSq2d.js → outbound-adapter-CtggmGh9.js} +52 -67
  35. package/dist/{outbound-components-oLpg8Qzb.js → outbound-components-Dn8SJWMS.js} +5 -4
  36. package/dist/{outbound-session-route-Cg15ZFJd.js → outbound-session-route-Q_HEusBQ.js} +57 -15
  37. package/dist/{owner-access-UlYi9t0M.js → owner-access-Cp8r6Ipf.js} +9 -7
  38. package/dist/{pluralkit-Tiyl70dx.js → pluralkit-BY75YcK0.js} +2 -2
  39. package/dist/{probe-n6ZXxK8V.js → probe-3ovFAp3b.js} +3 -3
  40. package/dist/{probe.runtime-CN4bdPfZ.js → probe.runtime-BckHn3cJ.js} +1 -1
  41. package/dist/{provider-session.runtime-B9xe-Qaf.js → provider-session.runtime-BL2lHBH7.js} +3 -3
  42. package/dist/{provider-B11xwilq.js → provider-uKmmrDM4.js} +299 -136
  43. package/dist/provider.runtime-C-IkWF2w.js +2 -0
  44. package/dist/{realtime-session.runtime-CU8IQUS-.js → realtime-session.runtime-CGYm1t_0.js} +798 -448
  45. package/dist/{resolve-allowlist-common-BLoYaxEG.js → resolve-allowlist-common-sKIKy-cF.js} +3 -3
  46. package/dist/{resolve-channels-C2sT_n67.js → resolve-channels-CoiMlWy0.js} +4 -4
  47. package/dist/{resolve-users-CzpjLwjy.js → resolve-users-DJpiokfW.js} +5 -4
  48. package/dist/{retry-Cv4jCU5Z.js → retry-DQt1zDgH.js} +356 -214
  49. package/dist/{retry-after-DdLPmPoa.js → retry-after-BrLjLUJi.js} +2 -1
  50. package/dist/{runtime-CY4PRMF-.js → runtime-BHsdEdr5.js} +2 -2
  51. package/dist/{runtime-BHrTlFkf.js → runtime-Ghtfh5ZA.js} +151 -109
  52. package/dist/runtime-api.js +20 -20
  53. package/dist/{secret-config-contract-B3i6WxV5.js → secret-config-contract-DFu9hfU8.js} +14 -6
  54. package/dist/secret-contract-api.js +1 -1
  55. package/dist/{security-audit-BfJhAXZp.js → security-audit-DKfK-iPY.js} +10 -11
  56. package/dist/security-audit-contract-api.js +1 -1
  57. package/dist/{security-audit.runtime-BVKF9VtY.js → security-audit.runtime-sKZyKgpx.js} +1 -1
  58. package/dist/{send-C49MFF9j.js → send-CZeWKUiA.js} +132 -100
  59. package/dist/{send.components-DKKAw5VX.js → send.components-BG5IDABj.js} +21 -15
  60. package/dist/{send.outbound-zam0TrZx.js → send.outbound-DHuFUL6W.js} +42 -63
  61. package/dist/{send.shared-JjljcV4O.js → send.shared-B0n_fWzu.js} +77 -149
  62. package/dist/{sender-identity-BJtfyise.js → sender-identity-B8Ncfi63.js} +1 -1
  63. package/dist/setup-plugin-api.js +1 -1
  64. package/dist/{shared-_5EcP4jW.js → shared-C3dKun_X.js} +24 -15
  65. package/dist/{subagent-hooks-DQzvOptn.js → subagent-hooks-ZoQXEI1E.js} +2 -2
  66. package/dist/subagent-hooks-api.js +1 -1
  67. package/dist/{system-events-C7yxaHWP.js → system-events-DFF_awl7.js} +2 -2
  68. package/dist/{target-resolver-vxIh6O3-.js → target-resolver-DLtHDwMK.js} +6 -5
  69. package/dist/targets-BObRyaKX.js +3 -0
  70. package/dist/{thread-bindings-DW5F9vat.js → thread-bindings-DKvsNjQR.js} +7 -6
  71. package/dist/{thread-bindings.manager-ByOtwjo_.js → thread-bindings.manager-pbbRT5gb.js} +38 -29
  72. package/dist/{thread-bindings.session-updates-CJb-BpPL.js → thread-bindings.session-updates-t6jeFB1-.js} +3 -2
  73. package/dist/{thread-bindings.state-D8OMdk4O.js → thread-bindings.state-DtgOqsbX.js} +34 -1
  74. package/dist/{threading-agH1T_6s.js → threading-BCx49X-6.js} +8 -6
  75. package/dist/{timeouts-B9cy6RvQ.js → timeouts-D86uWLt_.js} +1 -1
  76. package/dist/{transcripts-source-BR11iHA4.js → transcripts-source-Dc6Nnli5.js} +55 -7
  77. package/dist/transcripts-source-api.js +1 -1
  78. package/dist/{typing-Dc_YMY2e.js → typing-CuopV-Hi.js} +2 -2
  79. package/dist/{voice-runtime-DIeaa8fJ.js → voice-runtime-BQnILUbG.js} +492 -105
  80. package/node_modules/@discord/embedded-app-sdk/node_modules/@types/lodash/README.md +1 -1
  81. package/node_modules/@discord/embedded-app-sdk/node_modules/@types/lodash/conforms.d.ts +2 -0
  82. package/node_modules/@discord/embedded-app-sdk/node_modules/@types/lodash/package.json +3 -3
  83. package/node_modules/@discord/embedded-app-sdk/node_modules/@types/lodash/stubArray.d.ts +2 -0
  84. package/node_modules/@discord/embedded-app-sdk/node_modules/@types/lodash/stubObject.d.ts +2 -0
  85. package/node_modules/@discord/embedded-app-sdk/node_modules/@types/lodash/stubString.d.ts +2 -0
  86. package/node_modules/@discordjs/voice/node_modules/@types/node/README.md +1 -1
  87. package/node_modules/@discordjs/voice/node_modules/@types/node/buffer.buffer.d.ts +5 -5
  88. package/node_modules/@discordjs/voice/node_modules/@types/node/crypto.d.ts +2 -2
  89. package/node_modules/@discordjs/voice/node_modules/@types/node/http.d.ts +16 -0
  90. package/node_modules/@discordjs/voice/node_modules/@types/node/http2.d.ts +10 -2
  91. package/node_modules/@discordjs/voice/node_modules/@types/node/package.json +2 -2
  92. package/node_modules/@discordjs/voice/node_modules/@types/node/process.d.ts +52 -0
  93. package/node_modules/@discordjs/voice/node_modules/@types/node/quic.d.ts +210 -28
  94. package/node_modules/@discordjs/voice/node_modules/@types/node/sqlite.d.ts +6 -2
  95. package/node_modules/@discordjs/voice/node_modules/@types/node/test.d.ts +36 -0
  96. package/node_modules/typebox/build/format/email.mjs +1 -1
  97. package/node_modules/typebox/build/format/idna/idn-hostname.mjs +19 -1
  98. package/node_modules/typebox/build/format/json_pointer.d.mts +2 -2
  99. package/node_modules/typebox/build/format/json_pointer.mjs +2 -2
  100. package/node_modules/typebox/build/format/json_pointer_uri_fragment.d.mts +2 -2
  101. package/node_modules/typebox/build/format/json_pointer_uri_fragment.mjs +2 -2
  102. package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
  103. package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
  104. package/node_modules/typebox/build/system/memory/assign.mjs +2 -1
  105. package/node_modules/typebox/build/system/memory/create.mjs +3 -4
  106. package/node_modules/typebox/build/system/memory/discard.mjs +2 -2
  107. package/node_modules/typebox/build/system/memory/freeze.d.mts +4 -0
  108. package/node_modules/typebox/build/system/memory/freeze.mjs +6 -0
  109. package/node_modules/typebox/build/system/memory/update.mjs +3 -2
  110. package/node_modules/typebox/package.json +1 -1
  111. package/node_modules/undici/docs/docs/api/Client.md +4 -0
  112. package/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +3 -2
  113. package/node_modules/undici/docs/docs/api/EventSource.md +4 -0
  114. package/node_modules/undici/docs/docs/api/Interceptors.md +7 -3
  115. package/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +7 -1
  116. package/node_modules/undici/lib/cache/memory-cache-store.js +2 -2
  117. package/node_modules/undici/lib/core/symbols.js +2 -0
  118. package/node_modules/undici/lib/dispatcher/agent.js +7 -2
  119. package/node_modules/undici/lib/dispatcher/balanced-pool.js +7 -4
  120. package/node_modules/undici/lib/dispatcher/client-h1.js +12 -4
  121. package/node_modules/undici/lib/dispatcher/client-h2.js +43 -3
  122. package/node_modules/undici/lib/dispatcher/client.js +3 -2
  123. package/node_modules/undici/lib/dispatcher/dispatcher-base.js +13 -1
  124. package/node_modules/undici/lib/dispatcher/dispatcher.js +15 -1
  125. package/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +3 -0
  126. package/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +10 -3
  127. package/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -1
  128. package/node_modules/undici/lib/dispatcher/retry-agent.js +3 -0
  129. package/node_modules/undici/lib/dispatcher/round-robin-pool.js +1 -1
  130. package/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +91 -21
  131. package/node_modules/undici/lib/handler/cache-handler.js +29 -5
  132. package/node_modules/undici/lib/handler/decorator-handler.js +7 -1
  133. package/node_modules/undici/lib/handler/deduplication-handler.js +12 -6
  134. package/node_modules/undici/lib/handler/redirect-handler.js +21 -4
  135. package/node_modules/undici/lib/handler/retry-handler.js +148 -30
  136. package/node_modules/undici/lib/interceptor/cache.js +65 -12
  137. package/node_modules/undici/lib/interceptor/decompress.js +115 -13
  138. package/node_modules/undici/lib/interceptor/deduplicate.js +5 -4
  139. package/node_modules/undici/lib/interceptor/dns.js +7 -0
  140. package/node_modules/undici/lib/interceptor/dump.js +10 -23
  141. package/node_modules/undici/lib/mock/mock-agent.js +13 -1
  142. package/node_modules/undici/lib/mock/mock-utils.js +11 -10
  143. package/node_modules/undici/lib/util/cache.js +45 -3
  144. package/node_modules/undici/lib/web/cookies/parse.js +150 -147
  145. package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +28 -1
  146. package/node_modules/undici/lib/web/eventsource/eventsource.js +13 -3
  147. package/node_modules/undici/lib/web/fetch/index.js +6 -0
  148. package/node_modules/undici/lib/web/fetch/request.js +2 -3
  149. package/node_modules/undici/lib/web/fetch/util.js +6 -1
  150. package/node_modules/undici/lib/web/webidl/index.js +3 -3
  151. package/node_modules/undici/lib/web/websocket/connection.js +1 -1
  152. package/node_modules/undici/lib/web/websocket/permessage-deflate.js +5 -0
  153. package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +8 -10
  154. package/node_modules/undici/package.json +3 -3
  155. package/node_modules/undici/types/client.d.ts +10 -0
  156. package/node_modules/undici/types/interceptors.d.ts +2 -0
  157. package/node_modules/undici/types/mock-agent.d.ts +11 -10
  158. package/node_modules/undici/types/socks5-proxy-agent.d.ts +2 -0
  159. package/openclaw.plugin.json +15 -8
  160. package/package.json +7 -6
  161. package/skills/discord/SKILL.md +1 -1
  162. package/dist/account-inspect-BDfKyuvL.js +0 -89
  163. package/dist/provider.runtime-DiYaHvOz.js +0 -2
  164. package/dist/sdk-runtime-4geQHtXc.js +0 -338
  165. package/dist/targets-CtTKvntJ.js +0 -3
@@ -1,8 +1,8 @@
1
- import { c as createDiscordSendResult, kt as editChannelMessage, on as __exportAll, q as serializePayload, wt as createChannelMessage } from "./retry-Cv4jCU5Z.js";
2
- import { d as buildDiscordComponentMessage, f as buildDiscordComponentMessageFlags, h as resolveDiscordComponentAttachmentName } from "./components-B9V5o361.js";
1
+ import { At as editChannelMessage, J as serializePayload, Tt as createChannelMessage, l as createDiscordSendResult, sn as __exportAll } from "./retry-DQt1zDgH.js";
2
+ import { d as buildDiscordComponentMessage, f as buildDiscordComponentMessageFlags, g as resolveDiscordComponentAttachmentName } from "./components-BimX47Mq.js";
3
3
  import { n as getOptionalDiscordRuntime } from "./runtime-DgnVQ7zW.js";
4
- import { E as SUPPRESS_NOTIFICATIONS_FLAG, K as parseAndResolveChannelRecipient, N as createDiscordClient, O as createDiscordMessageNonce, l as resolveChannelId, t as buildDiscordSendError, u as resolveDiscordChannel } from "./send.shared-JjljcV4O.js";
5
- import { t as sendMessageDiscord } from "./send.outbound-zam0TrZx.js";
4
+ import { E as SUPPRESS_NOTIFICATIONS_FLAG, K as parseAndResolveChannelRecipient, N as createDiscordClient, O as createDiscordMessageNonce, l as resolveChannelId, t as buildDiscordSendError, u as resolveDiscordChannel } from "./send.shared-B0n_fWzu.js";
5
+ import { t as sendMessageDiscord } from "./send.outbound-DHuFUL6W.js";
6
6
  import { ChannelType } from "discord-api-types/v10";
7
7
  import { asDateTimestampMs, isFutureDateTimestampMs, resolveDateTimestampMs, resolveExpiresAtMsFromDurationMs } from "openclaw/plugin-sdk/number-runtime";
8
8
  import { uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
@@ -28,7 +28,7 @@ const discordComponentRegistryState = resolveGlobalSingleton(Symbol.for("opencla
28
28
  });
29
29
  //#endregion
30
30
  //#region extensions/discord/src/components-registry.ts
31
- const DEFAULT_COMPONENT_TTL_MS = 1800 * 1e3;
31
+ const DEFAULT_COMPONENT_TTL_MS = 18e5;
32
32
  const PERSISTENT_COMPONENT_NAMESPACE = "discord.components";
33
33
  const PERSISTENT_MODAL_NAMESPACE = "discord.modals";
34
34
  const PERSISTENT_COMPONENT_MAX_ENTRIES = 500;
@@ -371,7 +371,8 @@ async function buildDiscordComponentPayload(params) {
371
371
  contentType: media.contentType
372
372
  }];
373
373
  }
374
- const uniqueAttachmentNames = uniqueStrings(extractComponentAttachmentNames(spec));
374
+ const attachmentNames = extractComponentAttachmentNames(spec);
375
+ const uniqueAttachmentNames = uniqueStrings(attachmentNames);
375
376
  if (uniqueAttachmentNames.length > 1) throw new Error("Discord component attachments currently support a single file. Use media-gallery for multiple files.");
376
377
  const expectedAttachmentName = uniqueAttachmentNames[0];
377
378
  if (expectedAttachmentName && resolvedFileName && expectedAttachmentName !== resolvedFileName) throw new Error(`Component file block expects attachment "${expectedAttachmentName}", but the uploaded file is "${resolvedFileName}". Update components.blocks[].file or provide a matching filename.`);
@@ -384,14 +385,15 @@ async function buildDiscordComponentPayload(params) {
384
385
  });
385
386
  const flags = buildDiscordComponentMessageFlags(buildResult.components);
386
387
  const finalFlags = params.opts.silent ? (flags ?? 0) | SUPPRESS_NOTIFICATIONS_FLAG : flags ?? void 0;
388
+ const payload = {
389
+ components: buildResult.components,
390
+ allowed_mentions: params.opts.allowedMentions,
391
+ ...finalFlags ? { flags: finalFlags } : {},
392
+ ...files ? { files } : {}
393
+ };
387
394
  return {
388
395
  body: {
389
- ...serializePayload({
390
- components: buildResult.components,
391
- allowed_mentions: params.opts.allowedMentions,
392
- ...finalFlags ? { flags: finalFlags } : {},
393
- ...files ? { files } : {}
394
- }),
396
+ ...serializePayload(payload),
395
397
  ...messageReference ? { message_reference: messageReference } : {}
396
398
  },
397
399
  buildResult
@@ -405,7 +407,7 @@ async function sendDiscordComponentMessage(to, spec, opts) {
405
407
  token: opts.token,
406
408
  rest: opts.rest,
407
409
  mediaUrl: opts.mediaUrl,
408
- filename: opts.filename,
410
+ filename: opts.filename?.trim() || extractComponentAttachmentNames(spec)[0],
409
411
  mediaLocalRoots: opts.mediaLocalRoots,
410
412
  mediaReadFile: opts.mediaReadFile,
411
413
  mediaAccess: opts.mediaAccess,
@@ -417,6 +419,7 @@ async function sendDiscordComponentMessage(to, spec, opts) {
417
419
  chunkMode: opts.chunkMode,
418
420
  onDeliveryResult: opts.onDeliveryResult,
419
421
  onPlatformSendDispatch: opts.onPlatformSendDispatch,
422
+ assertPlatformSendAuthorized: opts.assertPlatformSendAuthorized,
420
423
  ...opts.suppressEmbeds === void 0 ? {} : { suppressEmbeds: opts.suppressEmbeds }
421
424
  });
422
425
  const cfg = requireRuntimeConfig(opts.cfg, "Discord component send");
@@ -424,7 +427,8 @@ async function sendDiscordComponentMessage(to, spec, opts) {
424
427
  ...opts,
425
428
  cfg
426
429
  });
427
- const { channelId } = await resolveChannelId(rest, await parseAndResolveChannelRecipient(to, cfg, accountInfo.accountId), request);
430
+ const recipient = await parseAndResolveChannelRecipient(to, cfg, accountInfo.accountId);
431
+ const { channelId } = await resolveChannelId(rest, recipient, request);
428
432
  const channel = await resolveDiscordChannel(rest, channelId);
429
433
  if (channel && DISCORD_FORUM_LIKE_TYPES.has(channel.type)) throw new Error("Discord components are not supported in forum-style channels");
430
434
  const { body: componentBody, buildResult } = await buildDiscordComponentPayload({
@@ -441,6 +445,7 @@ async function sendDiscordComponentMessage(to, spec, opts) {
441
445
  try {
442
446
  result = await request(async () => {
443
447
  await opts.onPlatformSendDispatch?.();
448
+ opts.assertPlatformSendAuthorized?.();
444
449
  return createChannelMessage(rest, channelId, { body });
445
450
  }, "components", { safety: "nonce-protected-create" });
446
451
  } catch (err) {
@@ -477,7 +482,8 @@ async function editDiscordComponentMessage(to, messageId, spec, opts) {
477
482
  ...opts,
478
483
  cfg
479
484
  });
480
- const { channelId } = await resolveChannelId(rest, await parseAndResolveChannelRecipient(to, cfg, accountInfo.accountId), request);
485
+ const recipient = await parseAndResolveChannelRecipient(to, cfg, accountInfo.accountId);
486
+ const { channelId } = await resolveChannelId(rest, recipient, request);
481
487
  const { body, buildResult } = await buildDiscordComponentPayload({
482
488
  spec,
483
489
  opts,
@@ -1,6 +1,6 @@
1
- import { Tt as createThread, c as createDiscordSendResult, s as createDiscordSendReceiptFromResults, u as createReusableDiscordReplyReference, wt as createChannelMessage } from "./retry-Cv4jCU5Z.js";
2
- import { i as normalizeDiscordHandleKey, o as resolveDiscordDirectoryUserId } from "./directory-live-DSAJSrJk.js";
3
- import { A as resolveDiscordSendComponents, D as buildDiscordMessageRequest, K as parseAndResolveChannelRecipient, M as resolveDiscordSuppressEmbeds, N as createDiscordClient, O as createDiscordMessageNonce, a as normalizeDiscordPollInput, c as normalizeStickerIds, f as sendDiscordMedia, j as resolveDiscordSendEmbeds, k as resolveDiscordMessageFlags, l as resolveChannelId, n as buildDiscordTextChunks, p as sendDiscordText, t as buildDiscordSendError, u as resolveDiscordChannel } from "./send.shared-JjljcV4O.js";
1
+ import { Et as createThread, Tt as createChannelMessage, c as createDiscordSendReceiptFromResults, d as createReusableDiscordReplyReference, l as createDiscordSendResult } from "./retry-DQt1zDgH.js";
2
+ import { i as normalizeDiscordHandleKey, o as resolveDiscordDirectoryUserId } from "./directory-live-DaJzWJ2N.js";
3
+ import { A as resolveDiscordSendComponents, D as buildDiscordMessageRequest, K as parseAndResolveChannelRecipient, M as resolveDiscordSuppressEmbeds, N as createDiscordClient, O as createDiscordMessageNonce, a as normalizeDiscordPollInput, c as normalizeStickerIds, f as sendDiscordMedia, j as resolveDiscordSendEmbeds, k as resolveDiscordMessageFlags, l as resolveChannelId, n as buildDiscordTextChunks, p as sendDiscordText, t as buildDiscordSendError, u as resolveDiscordChannel } from "./send.shared-B0n_fWzu.js";
4
4
  import { ChannelType } from "discord-api-types/v10";
5
5
  import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
6
6
  import { normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeOptionalStringifiedId } from "openclaw/plugin-sdk/string-coerce-runtime";
@@ -10,36 +10,8 @@ import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
10
10
  import { resolveMarkdownTableMode } from "openclaw/plugin-sdk/markdown-table-runtime";
11
11
  import { resolveChunkMode } from "openclaw/plugin-sdk/reply-chunking";
12
12
  import { fromMarkdown } from "mdast-util-from-markdown";
13
- import { FormatCapabilityProfile, convertMarkdownTables, renderMarkdownWithMarkers } from "openclaw/plugin-sdk/text-chunking";
13
+ import { convertMarkdownTables } from "openclaw/plugin-sdk/text-chunking";
14
14
  //#region extensions/discord/src/markdown.ts
15
- const DISCORD_FORMAT_PROFILE = FormatCapabilityProfile.define({
16
- mechanism: "markdown",
17
- constructs: { table: "fallback" },
18
- chunk: {
19
- limit: 2e3,
20
- unit: "utf16"
21
- }
22
- });
23
- const DISCORD_BOLD_PROBE_TEXT = "openclaw-discord-bold";
24
- const DISCORD_BOLD_PROBE = renderMarkdownWithMarkers({
25
- text: DISCORD_BOLD_PROBE_TEXT,
26
- styles: [{
27
- start: 0,
28
- end: 21,
29
- style: "bold"
30
- }],
31
- links: []
32
- }, {
33
- styleMarkers: { bold: {
34
- open: "**",
35
- close: "**"
36
- } },
37
- escapeText: (value) => value
38
- }, DISCORD_FORMAT_PROFILE);
39
- const DISCORD_BOLD_MARKERS = {
40
- open: DISCORD_BOLD_PROBE.slice(0, DISCORD_BOLD_PROBE.indexOf(DISCORD_BOLD_PROBE_TEXT)),
41
- close: DISCORD_BOLD_PROBE.slice(DISCORD_BOLD_PROBE.indexOf(DISCORD_BOLD_PROBE_TEXT) + 21)
42
- };
43
15
  const DISCORD_NATIVE_TOKEN_RE = /<a?:[A-Za-z0-9_]+:\d+>|<\/[^>]+:\d+>/giu;
44
16
  const DISCORD_URL_START_RE = /(?:[A-Za-z][A-Za-z0-9+.-]*:\/\/|www\.)/giu;
45
17
  function findDiscordUrlRanges(markdown) {
@@ -221,19 +193,13 @@ function normalizeDiscordBold(markdown) {
221
193
  end
222
194
  };
223
195
  });
224
- const edits = [...spans.flatMap((span, spanId) => [{
225
- spanId,
226
- start: span.start,
227
- marker: DISCORD_BOLD_MARKERS.open,
228
- consume: 2,
229
- delimiter: true
230
- }, {
196
+ const edits = [...spans.flatMap((span, spanId) => [span.start, span.end - 2].map((start) => ({
231
197
  spanId,
232
- start: span.end - 2,
233
- marker: DISCORD_BOLD_MARKERS.close,
198
+ start,
199
+ marker: "**",
234
200
  consume: 2,
235
201
  delimiter: true
236
- }]), ...contentEdits].toSorted((left, right) => left.start - right.start);
202
+ }))), ...contentEdits].toSorted((left, right) => left.start - right.start);
237
203
  const editsBySpan = /* @__PURE__ */ new Map();
238
204
  for (const edit of edits) {
239
205
  const spanEdits = editsBySpan.get(edit.spanId);
@@ -247,10 +213,12 @@ function normalizeDiscordBold(markdown) {
247
213
  for (const edit of edits) {
248
214
  while ((protectedRanges[rangeIndex]?.end ?? Number.POSITIVE_INFINITY) <= edit.start) rangeIndex += 1;
249
215
  const range = protectedRanges[rangeIndex];
250
- if (range && (edit.consume === 0 ? edit.start >= range.start && edit.start < range.end : edit.start < range.end && edit.start + edit.consume > range.start)) if (edit.delimiter) protectedSpanIds.add(edit.spanId);
251
- else {
252
- protectedEditKeys.add(`${edit.start}:${edit.consume}:${edit.marker}`);
253
- spansWithProtectedContent.add(edit.spanId);
216
+ if (range && (edit.consume === 0 ? edit.start >= range.start && edit.start < range.end : edit.start < range.end && edit.start + edit.consume > range.start)) {
217
+ if (edit.delimiter) protectedSpanIds.add(edit.spanId);
218
+ else {
219
+ protectedEditKeys.add(`${edit.start}:${edit.consume}:${edit.marker}`);
220
+ spansWithProtectedContent.add(edit.spanId);
221
+ }
254
222
  }
255
223
  }
256
224
  for (const spanId of spansWithProtectedContent) {
@@ -420,14 +388,16 @@ async function sendDiscordThreadTextChunks(params) {
420
388
  allowedMentions: params.allowedMentions,
421
389
  maxChars: params.maxChars,
422
390
  onResult: params.onResult,
423
- onPlatformSendDispatch: params.onPlatformSendDispatch
391
+ onPlatformSendDispatch: params.onPlatformSendDispatch,
392
+ assertPlatformSendAuthorized: params.assertPlatformSendAuthorized
424
393
  });
425
394
  }
426
395
  /** Discord thread names are capped at 100 characters. */
427
396
  const DISCORD_THREAD_NAME_LIMIT = 100;
428
397
  /** Derive a thread title from the first non-empty line of the message text. */
429
398
  function deriveForumThreadName(text) {
430
- return truncateUtf16Safe(normalizeOptionalString(text.split("\n").find((line) => normalizeOptionalString(line))) ?? "", DISCORD_THREAD_NAME_LIMIT) || (/* @__PURE__ */ new Date()).toISOString().slice(0, 16);
399
+ const firstLine = normalizeOptionalString(text.split("\n").find((line) => normalizeOptionalString(line))) ?? "";
400
+ return truncateUtf16Safe(firstLine, DISCORD_THREAD_NAME_LIMIT) || (/* @__PURE__ */ new Date()).toISOString().slice(0, 16);
431
401
  }
432
402
  /** Forum/Media channels cannot receive regular messages; detect them here. */
433
403
  function isForumLikeChannel(channel) {
@@ -449,7 +419,8 @@ async function resolveDiscordSendTarget(to, opts) {
449
419
  ...opts,
450
420
  cfg
451
421
  });
452
- const { channelId } = await resolveChannelId(rest, await parseAndResolveChannelRecipient(to, cfg, account.accountId), request);
422
+ const recipient = await parseAndResolveChannelRecipient(to, cfg, account.accountId);
423
+ const { channelId } = await resolveChannelId(rest, recipient, request);
453
424
  return {
454
425
  rest,
455
426
  request,
@@ -482,7 +453,8 @@ async function sendMessageDiscord(to, text, opts) {
482
453
  accountId: accountInfo.accountId,
483
454
  mentionAliases: accountInfo.config.mentionAliases
484
455
  });
485
- const { channelId } = await resolveChannelId(rest, await parseAndResolveChannelRecipient(to, cfg, accountInfo.accountId), request);
456
+ const recipient = await parseAndResolveChannelRecipient(to, cfg, accountInfo.accountId);
457
+ const { channelId } = await resolveChannelId(rest, recipient, request);
486
458
  const channel = await resolveDiscordChannel(rest, channelId);
487
459
  const deliveredResults = [];
488
460
  let deliveryThreadId;
@@ -513,21 +485,23 @@ async function sendMessageDiscord(to, text, opts) {
513
485
  embeds: opts.embeds,
514
486
  isFirst: true
515
487
  });
488
+ const starterFlags = resolveDiscordMessageFlags({
489
+ silent: opts.silent,
490
+ suppressEmbeds: suppressEmbeds && !starterEmbeds?.length
491
+ });
516
492
  const starterBody = buildDiscordMessageRequest({
517
493
  endpoint: "forum-thread",
518
494
  text: starterContent,
519
495
  components: starterComponents,
520
496
  embeds: starterEmbeds,
521
- flags: resolveDiscordMessageFlags({
522
- silent: opts.silent,
523
- suppressEmbeds: suppressEmbeds && !starterEmbeds?.length
524
- }),
497
+ flags: starterFlags,
525
498
  allowedMentions: opts.allowedMentions
526
499
  });
527
500
  let threadRes;
528
501
  try {
529
502
  threadRes = await request(async () => {
530
503
  await opts.onPlatformSendDispatch?.();
504
+ opts.assertPlatformSendAuthorized?.();
531
505
  return createThread(rest, channelId, { body: {
532
506
  name: threadName,
533
507
  ...channel.default_auto_archive_duration === void 0 ? {} : { auto_archive_duration: channel.default_auto_archive_duration },
@@ -578,7 +552,8 @@ async function sendMessageDiscord(to, text, opts) {
578
552
  allowedMentions: opts.allowedMentions,
579
553
  maxChars: textLimit,
580
554
  onResult: reportResult,
581
- onPlatformSendDispatch: opts.onPlatformSendDispatch
555
+ onPlatformSendDispatch: opts.onPlatformSendDispatch,
556
+ assertPlatformSendAuthorized: opts.assertPlatformSendAuthorized
582
557
  });
583
558
  await sendDiscordThreadTextChunks({
584
559
  rest,
@@ -592,7 +567,8 @@ async function sendMessageDiscord(to, text, opts) {
592
567
  suppressEmbeds,
593
568
  allowedMentions: opts.allowedMentions,
594
569
  onResult: reportResult,
595
- onPlatformSendDispatch: opts.onPlatformSendDispatch
570
+ onPlatformSendDispatch: opts.onPlatformSendDispatch,
571
+ assertPlatformSendAuthorized: opts.assertPlatformSendAuthorized
596
572
  });
597
573
  } else await sendDiscordThreadTextChunks({
598
574
  rest,
@@ -606,7 +582,8 @@ async function sendMessageDiscord(to, text, opts) {
606
582
  suppressEmbeds,
607
583
  allowedMentions: opts.allowedMentions,
608
584
  onResult: reportResult,
609
- onPlatformSendDispatch: opts.onPlatformSendDispatch
585
+ onPlatformSendDispatch: opts.onPlatformSendDispatch,
586
+ assertPlatformSendAuthorized: opts.assertPlatformSendAuthorized
610
587
  });
611
588
  } catch (err) {
612
589
  throw await buildDiscordSendError(err, {
@@ -653,7 +630,8 @@ async function sendMessageDiscord(to, text, opts) {
653
630
  allowedMentions: opts.allowedMentions,
654
631
  maxChars: textLimit,
655
632
  onResult: reportResult,
656
- onPlatformSendDispatch: opts.onPlatformSendDispatch
633
+ onPlatformSendDispatch: opts.onPlatformSendDispatch,
634
+ assertPlatformSendAuthorized: opts.assertPlatformSendAuthorized
657
635
  });
658
636
  else result = await sendDiscordText({
659
637
  rest,
@@ -670,7 +648,8 @@ async function sendMessageDiscord(to, text, opts) {
670
648
  allowedMentions: opts.allowedMentions,
671
649
  maxChars: textLimit,
672
650
  onResult: reportResult,
673
- onPlatformSendDispatch: opts.onPlatformSendDispatch
651
+ onPlatformSendDispatch: opts.onPlatformSendDispatch,
652
+ assertPlatformSendAuthorized: opts.assertPlatformSendAuthorized
674
653
  });
675
654
  } catch (err) {
676
655
  throw await buildDiscordSendError(err, {
@@ -687,8 +666,7 @@ async function sendMessageDiscord(to, text, opts) {
687
666
  direction: "outbound"
688
667
  });
689
668
  return {
690
- messageId: result.id || "unknown",
691
- channelId: result.channel_id ?? channelId,
669
+ ...toDiscordSendResult(result, channelId),
692
670
  receipt: createDiscordSendReceiptFromResults({ results: deliveredResults })
693
671
  };
694
672
  }
@@ -730,11 +708,12 @@ async function sendPollDiscord(to, poll, opts) {
730
708
  async function resolveDiscordStructuredSendContext(to, opts) {
731
709
  requireRuntimeConfig(opts.cfg, "Discord structured send");
732
710
  const { rest, request, channelId, account: accountInfo } = await resolveDiscordSendTarget(to, opts);
733
- const content = opts.content?.trim();
711
+ const content = opts.content;
734
712
  return {
735
713
  send: async (kind, body) => {
736
714
  const result = await request(async () => {
737
715
  await opts.onPlatformSendDispatch?.();
716
+ opts.assertPlatformSendAuthorized?.();
738
717
  return createChannelMessage(rest, channelId, { body });
739
718
  }, kind, { safety: "nonce-protected-create" });
740
719
  recordChannelActivity({
@@ -747,7 +726,7 @@ async function resolveDiscordStructuredSendContext(to, opts) {
747
726
  threadId: kind === "poll" ? opts.threadId : void 0
748
727
  });
749
728
  },
750
- rewrittenContent: content ? rewriteDiscordKnownMentions(content, {
729
+ rewrittenContent: content?.trim() ? rewriteDiscordKnownMentions(content, {
751
730
  accountId: accountInfo.accountId,
752
731
  mentionAliases: accountInfo.config.mentionAliases
753
732
  }) : void 0,
@@ -1,29 +1,29 @@
1
- import { At as getChannel, J as Embed, Jt as getGuildMember, K as hasDiscordV2Components, Mt as getThreadMember, P as RequestClient, a as chunkDiscordTextWithMode, bt as getCurrentUser, d as resolveDiscordReplyMessageId, n as createDiscordRetryRunner, q as serializePayload, qt as getGuild, wt as createChannelMessage, yt as createUserDmChannel } from "./retry-Cv4jCU5Z.js";
2
- import { c as resolveDiscordAccount, m as normalizeDiscordToken, o as mergeDiscordAccountConfig } from "./accounts-CfQ-vSyf.js";
3
- import { t as parseAndResolveDiscordTarget } from "./target-resolver-vxIh6O3-.js";
1
+ import { F as RequestClient, J as serializePayload, Jt as getGuild, Nt as getThreadMember, Tt as createChannelMessage, Y as Embed, Yt as getGuildMember, bt as createUserDmChannel, f as resolveDiscordReplyMessageId, jt as getChannel, o as chunkDiscordTextWithMode, q as hasDiscordV2Components, r as createDiscordRetryRunner, xt as getCurrentUser } from "./retry-DQt1zDgH.js";
2
+ import { c as resolveDiscordAccount, m as normalizeDiscordToken, o as mergeDiscordAccountConfig } from "./accounts-CwJQoLjM.js";
3
+ import { t as parseAndResolveDiscordTarget } from "./target-resolver-DLtHDwMK.js";
4
4
  import { t as isDiscordThreadChannelType } from "./channel-type-CVLZyGYS.js";
5
5
  import { ChannelType, MessageFlags, PermissionFlagsBits } from "discord-api-types/v10";
6
6
  import { randomBytes } from "node:crypto";
7
- import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
8
7
  import { normalizeAccountId } from "openclaw/plugin-sdk/routing";
9
8
  import { normalizeOptionalString, normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
10
9
  import { requireRuntimeConfig } from "openclaw/plugin-sdk/plugin-config-runtime";
10
+ import { resolveTextChunksWithFallback } from "openclaw/plugin-sdk/reply-payload";
11
11
  import { makeProxyFetch } from "openclaw/plugin-sdk/fetch-runtime";
12
12
  import { danger } from "openclaw/plugin-sdk/runtime-env";
13
13
  import { PollLayoutType } from "discord-api-types/payloads/v10";
14
14
  import { buildOutboundMediaLoadOptions, extensionForMime, normalizePollDurationHours, normalizePollInput } from "openclaw/plugin-sdk/media-runtime";
15
- import { resolveTextChunksWithFallback } from "openclaw/plugin-sdk/reply-payload";
16
15
  import { loadWebMedia } from "openclaw/plugin-sdk/web-media";
17
16
  //#region extensions/discord/src/recipient-resolution.ts
18
17
  async function parseAndResolveRecipient(raw, cfg, accountId, parseOptions = {}) {
19
18
  if (!cfg) throw new Error("Discord recipient resolution requires a resolved runtime config. Load and resolve config at the command or gateway boundary, then pass cfg through the runtime path.");
20
19
  const resolvedCfg = requireRuntimeConfig(cfg, "Discord recipient resolution");
20
+ const accountInfo = resolveDiscordAccount({
21
+ cfg: resolvedCfg,
22
+ accountId
23
+ });
21
24
  const resolved = await parseAndResolveDiscordTarget(raw, {
22
25
  cfg: resolvedCfg,
23
- accountId: resolveDiscordAccount({
24
- cfg: resolvedCfg,
25
- accountId
26
- }).accountId
26
+ accountId: accountInfo.accountId
27
27
  }, parseOptions);
28
28
  return {
29
29
  kind: resolved.kind,
@@ -31,8 +31,9 @@ async function parseAndResolveRecipient(raw, cfg, accountId, parseOptions = {})
31
31
  };
32
32
  }
33
33
  async function parseAndResolveChannelRecipient(raw, cfg, accountId) {
34
+ const resolvedCfg = requireRuntimeConfig(cfg, "Discord recipient resolution");
34
35
  const resolved = await parseAndResolveDiscordTarget(raw, {
35
- cfg: requireRuntimeConfig(cfg, "Discord recipient resolution"),
36
+ cfg: resolvedCfg,
36
37
  accountId
37
38
  }, { defaultKind: "channel" });
38
39
  return {
@@ -512,9 +513,9 @@ var DiscordSendError = class extends Error {
512
513
  return this.message;
513
514
  }
514
515
  };
515
- const DISCORD_MAX_EMOJI_BYTES = 256 * 1024;
516
- const DISCORD_MAX_STICKER_BYTES = 512 * 1024;
517
- const DISCORD_MAX_EVENT_COVER_BYTES = 8 * 1024 * 1024;
516
+ const DISCORD_MAX_EMOJI_BYTES = 262144;
517
+ const DISCORD_MAX_STICKER_BYTES = 524288;
518
+ const DISCORD_MAX_EVENT_COVER_BYTES = 8388608;
518
519
  //#endregion
519
520
  //#region extensions/discord/src/send.shared.ts
520
521
  const DISCORD_TEXT_LIMIT = 2e3;
@@ -637,168 +638,95 @@ async function resolveDiscordChannel(rest, channelId) {
637
638
  }
638
639
  function buildDiscordTextChunks(text, opts = {}) {
639
640
  if (!text) return [];
640
- return resolveTextChunksWithFallback(text, chunkDiscordTextWithMode(text, {
641
+ const chunks = chunkDiscordTextWithMode(text, {
641
642
  maxChars: opts.maxChars ?? DISCORD_TEXT_LIMIT,
642
643
  maxLines: opts.maxLinesPerMessage,
643
644
  chunkMode: opts.chunkMode
644
- }));
645
- }
646
- async function sendDiscordText(params) {
647
- const { rest, channelId, text, request, reply, maxLinesPerMessage, components, embeds, allowedMentions, chunkMode, silent, suppressEmbeds, maxChars, onResult, onPlatformSendDispatch } = params;
648
- const chunks = buildDiscordTextChunks(text, {
649
- maxLinesPerMessage,
650
- chunkMode,
651
- maxChars
652
645
  });
646
+ return resolveTextChunksWithFallback(text, chunks);
647
+ }
648
+ async function sendDiscordChunks(params, upload) {
649
+ const chunks = buildDiscordTextChunks(params.text, params);
653
650
  if (!chunks.length) chunks.push("");
654
- const sendChunk = async (chunk, isFirst) => {
655
- const chunkComponents = resolveDiscordSendComponents({
656
- components,
651
+ const platformMessageIds = [];
652
+ let primary;
653
+ for (const [index, chunk] of chunks.entries()) {
654
+ const isFirst = index === 0;
655
+ if (upload && !isFirst && !chunk.trim()) continue;
656
+ const files = isFirst ? upload?.files : void 0;
657
+ const components = resolveDiscordSendComponents({
658
+ ...params,
657
659
  text: chunk,
658
660
  isFirst
659
661
  });
660
- const chunkEmbeds = resolveDiscordSendEmbeds({
661
- embeds,
662
+ const embeds = resolveDiscordSendEmbeds({
663
+ ...params,
662
664
  isFirst
663
665
  });
664
- if (!chunk.trim() && !chunkComponents?.length && !chunkEmbeds?.length) throw new Error("Message must be non-empty for Discord sends");
665
- const chunkReplyTo = resolveDiscordReplyMessageId(reply, isFirst);
666
- const kind = chunkComponents?.length || chunkEmbeds?.length ? "card" : "text";
667
- const flags = resolveDiscordMessageFlags({
668
- silent,
669
- suppressEmbeds: suppressEmbeds && !chunkEmbeds?.length
670
- });
666
+ if (!chunk.trim() && !components?.length && !embeds?.length && !files?.length) throw new Error("Message must be non-empty for Discord sends");
667
+ const replyToId = resolveDiscordReplyMessageId(params.reply, isFirst);
668
+ const kind = files ? "media" : components?.length || embeds?.length ? "card" : "text";
671
669
  const body = buildDiscordMessageRequest({
672
670
  endpoint: "create-message",
673
671
  text: chunk,
674
- components: chunkComponents,
675
- embeds: chunkEmbeds,
676
- allowedMentions,
677
- flags,
678
- replyTo: chunkReplyTo
672
+ components,
673
+ embeds,
674
+ files,
675
+ allowedMentions: params.allowedMentions,
676
+ flags: resolveDiscordMessageFlags({
677
+ silent: params.silent,
678
+ suppressEmbeds: params.suppressEmbeds && !embeds?.length
679
+ }),
680
+ replyTo: replyToId
679
681
  });
680
- return {
681
- result: await request(async () => {
682
- await onPlatformSendDispatch?.();
683
- return createChannelMessage(rest, channelId, { body });
684
- }, "text", { safety: "nonce-protected-create" }),
685
- replyToId: chunkReplyTo,
686
- kind
687
- };
688
- };
689
- if (chunks.length === 1) {
690
- const { result, replyToId, kind } = await sendChunk(expectDefined(chunks.at(0), "single Discord text chunk"), true);
691
- await onResult?.(result, kind, replyToId);
692
- return {
693
- ...result,
694
- platformMessageIds: result.id ? [result.id] : []
695
- };
696
- }
697
- const platformMessageIds = [];
698
- let last = null;
699
- for (const [index, chunk] of chunks.entries()) {
700
- const sent = await sendChunk(chunk, index === 0);
701
- last = sent.result;
702
- await onResult?.(last, sent.kind, sent.replyToId);
703
- if (last.id) platformMessageIds.push(last.id);
682
+ let result;
683
+ try {
684
+ result = await params.request(async () => {
685
+ await params.onPlatformSendDispatch?.();
686
+ params.assertPlatformSendAuthorized?.();
687
+ return createChannelMessage(params.rest, params.channelId, { body });
688
+ }, files ? "media" : "text", { safety: "nonce-protected-create" });
689
+ } catch (error) {
690
+ if (files && upload) return upload.onRejected(error);
691
+ throw error;
692
+ }
693
+ await params.onResult?.(result, kind, replyToId);
694
+ if (result.id) platformMessageIds.push(result.id);
695
+ primary = upload ? primary ?? result : result;
704
696
  }
705
- if (!last) throw new Error("Discord send failed (empty chunk result)");
697
+ if (!primary) throw new Error("Discord send failed (empty chunk result)");
706
698
  return {
707
- ...last,
699
+ ...primary,
708
700
  platformMessageIds
709
701
  };
710
702
  }
703
+ async function sendDiscordText(params) {
704
+ return sendDiscordChunks(params);
705
+ }
711
706
  async function sendDiscordMedia(params) {
712
- const { rest, channelId, text, mediaUrl, filename, mediaAccess, mediaLocalRoots, mediaReadFile, maxBytes, reply, request, maxLinesPerMessage, components, embeds, allowedMentions, chunkMode, silent, suppressEmbeds, maxChars, onResult, onPlatformSendDispatch } = params;
713
- const media = await loadWebMedia(mediaUrl, buildOutboundMediaLoadOptions({
714
- maxBytes,
715
- mediaAccess,
716
- mediaLocalRoots,
717
- mediaReadFile
707
+ const media = await loadWebMedia(params.mediaUrl, buildOutboundMediaLoadOptions({
708
+ maxBytes: params.maxBytes,
709
+ mediaAccess: params.mediaAccess,
710
+ mediaLocalRoots: params.mediaLocalRoots,
711
+ mediaReadFile: params.mediaReadFile
718
712
  }));
719
- const resolvedFileName = filename?.trim() || media.fileName || (media.contentType ? `upload${extensionForMime(media.contentType) ?? ""}` : "") || "upload";
720
- const chunks = text ? buildDiscordTextChunks(text, {
721
- maxLinesPerMessage,
722
- chunkMode,
723
- maxChars
724
- }) : [];
725
- const caption = chunks[0] ?? "";
726
- const captionComponents = resolveDiscordSendComponents({
727
- components,
728
- text: caption,
729
- isFirst: true
730
- });
731
- const captionEmbeds = resolveDiscordSendEmbeds({
732
- embeds,
733
- isFirst: true
734
- });
735
- const body = buildDiscordMessageRequest({
736
- endpoint: "create-message",
737
- text: caption,
738
- components: captionComponents,
739
- embeds: captionEmbeds,
740
- allowedMentions,
741
- flags: resolveDiscordMessageFlags({
742
- silent,
743
- suppressEmbeds: suppressEmbeds && !captionEmbeds?.length
744
- }),
745
- replyTo: resolveDiscordReplyMessageId(reply, true),
713
+ const resolvedFileName = params.filename?.trim() || media.fileName || (media.contentType ? `upload${extensionForMime(media.contentType) ?? ""}` : "") || "upload";
714
+ return sendDiscordChunks(params, {
746
715
  files: [{
747
716
  data: media.buffer,
748
717
  name: resolvedFileName,
749
718
  contentType: media.contentType
750
- }]
719
+ }],
720
+ onRejected(error) {
721
+ if (!isDiscordUploadTooLargeError(error)) throw error;
722
+ return sendDiscordText({
723
+ ...params,
724
+ text: buildDiscordUploadTooLargeFallbackText(params.text),
725
+ components: void 0,
726
+ embeds: void 0
727
+ });
728
+ }
751
729
  });
752
- let res;
753
- try {
754
- res = await request(async () => {
755
- await onPlatformSendDispatch?.();
756
- return createChannelMessage(rest, channelId, { body });
757
- }, "media", { safety: "nonce-protected-create" });
758
- } catch (err) {
759
- if (!isDiscordUploadTooLargeError(err)) throw err;
760
- return sendDiscordText({
761
- rest,
762
- channelId,
763
- text: buildDiscordUploadTooLargeFallbackText(text),
764
- reply,
765
- request,
766
- maxLinesPerMessage,
767
- chunkMode,
768
- silent,
769
- suppressEmbeds,
770
- allowedMentions,
771
- maxChars,
772
- onResult,
773
- onPlatformSendDispatch
774
- });
775
- }
776
- await onResult?.(res, "media", reply?.messageId);
777
- const platformMessageIds = res.id ? [res.id] : [];
778
- const followupReply = reply?.scope === "all" ? reply : void 0;
779
- for (const chunk of chunks.slice(1)) {
780
- if (!chunk.trim()) continue;
781
- const followup = await sendDiscordText({
782
- rest,
783
- channelId,
784
- text: chunk,
785
- reply: followupReply,
786
- request,
787
- maxLinesPerMessage,
788
- chunkMode,
789
- silent,
790
- suppressEmbeds,
791
- allowedMentions,
792
- maxChars,
793
- onResult,
794
- onPlatformSendDispatch
795
- });
796
- for (const id of followup.platformMessageIds) if (id) platformMessageIds.push(id);
797
- }
798
- return {
799
- ...res,
800
- platformMessageIds
801
- };
802
730
  }
803
731
  function buildReactionIdentifier(emoji) {
804
732
  if (emoji.id && emoji.name) return `${emoji.name}:${emoji.id}`;
@@ -1,4 +1,4 @@
1
- import { x as formatDiscordUserTag } from "./allow-list-BDMimASD.js";
1
+ import { b as formatDiscordUserTag } from "./allow-list-DBTtR2dz.js";
2
2
  import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
3
3
  //#region extensions/discord/src/monitor/sender-identity.ts
4
4
  function resolveDiscordWebhookId(message) {
@@ -1,2 +1,2 @@
1
- import { t as discordSetupPlugin } from "./channel.setup-DOzXS2Pk.js";
1
+ import { t as discordSetupPlugin } from "./channel.setup-BWmMe1tT.js";
2
2
  export { discordSetupPlugin };