@openclaw/discord 2026.11.3 → 2026.11.5-beta.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 (220) hide show
  1. package/dist/.setup/{account-inspect-8cCu6uPG.mjs → account-inspect-DGkdWwix.mjs} +1 -1
  2. package/dist/.setup/{accounts-ljrzXBJi.mjs → accounts-C_25wyxC.mjs} +9 -6
  3. package/dist/.setup/{active-turn-thread-route-C4tp9noA.mjs → active-turn-thread-route-KvRTAVE3.mjs} +1 -2
  4. package/dist/.setup/{allow-list-BKqOldGy.mjs → allow-list-BXrS8-R9.mjs} +4 -152
  5. package/dist/.setup/{api-DqmMUZau.mjs → api-BlBD4ism.mjs} +10 -20
  6. package/dist/.setup/{approval-handler.runtime-D0qu1um7.mjs → approval-handler.runtime-BGYjX1t9.mjs} +80 -61
  7. package/dist/.setup/{approval-message-updates-CdurC9Ej.mjs → approval-message-updates-DKsCfxSW.mjs} +2 -2
  8. package/dist/.setup/{audit-ChorIwio.mjs → audit-5b-FXj9R.mjs} +4 -4
  9. package/dist/.setup/{channel-ZilgdF5e.mjs → channel-CWwTHWFo.mjs} +134 -202
  10. package/dist/.setup/channel-access-9cyzozUP.mjs +24 -0
  11. package/dist/.setup/channel.setup-B3MtmBQG.mjs +238 -0
  12. package/dist/.setup/{components-Du9NhD8h.mjs → components-YCvQ6YLS.mjs} +209 -430
  13. package/dist/.setup/components.base-CiS0h_XP.mjs +32 -0
  14. package/dist/.setup/{config-schema-_uBILpQf.mjs → config-schema-BNKN1cu5.mjs} +6 -7
  15. package/dist/.setup/{conversation-binding-route-8Ul1KpGF.mjs → conversation-binding-route-kCTw8cij.mjs} +2 -2
  16. package/dist/.setup/{directory-config-3iVub-3m.mjs → directory-config-Ble81PWH.mjs} +1 -1
  17. package/dist/.setup/{directory-live-BDVl2DoC.mjs → directory-live-DH3tpS3x.mjs} +52 -57
  18. package/dist/.setup/{discord-BMD-JiVS.mjs → discord-DGVSguhx.mjs} +1124 -1710
  19. package/dist/.setup/{doctor-hQKbkNKq.mjs → doctor-eujgbnpZ.mjs} +3 -5
  20. package/dist/.setup/endpoint-runtime-lf4DeLas.mjs +139 -0
  21. package/dist/.setup/guilds-eDq22iSM.mjs +22 -0
  22. package/dist/.setup/{handle-action-B1lmt4ms.mjs → handle-action-CktwmzMz.mjs} +15 -15
  23. package/dist/.setup/{handle-action.guild-admin-B6g31cwt.mjs → handle-action.guild-admin-WLQ7fRqI.mjs} +5 -5
  24. package/dist/.setup/listeners-Df8lx3vK.mjs +47 -0
  25. package/dist/.setup/{live-policy-config-C_Q966Wh.mjs → live-policy-config-DiBVuaU6.mjs} +2 -3
  26. package/dist/.setup/{message-handler-CkI3yMjL.mjs → message-handler-hhNSioxo.mjs} +154 -115
  27. package/dist/.setup/{message-handler.preflight-CEfkFV9U.mjs → message-handler.preflight-BZcZE1o-.mjs} +30 -105
  28. package/dist/.setup/{message-handler.preflight-pluralkit-D5si80_L.mjs → message-handler.preflight-pluralkit-CYZfXXb6.mjs} +9 -22
  29. package/dist/.setup/{message-handler.process-DsMtetRf.mjs → message-handler.process-B0n-mQ99.mjs} +256 -373
  30. package/dist/.setup/outbound-payload-BaZmjewa.mjs +447 -0
  31. package/dist/.setup/{outbound-session-route-BtUpGBTb.mjs → outbound-session-route-Cgx4i9cS.mjs} +139 -86
  32. package/dist/.setup/{preflight-audio-wWgsZG5F.mjs → preflight-audio-C6QtD6HX.mjs} +1 -5
  33. package/dist/.setup/{presence-cache-DCeTsL73.mjs → presence-cache-Dq-3nH7R.mjs} +1 -6
  34. package/dist/.setup/{probe-CBaoCs-c.mjs → probe-DezB-6xz.mjs} +5 -9
  35. package/dist/.setup/{provider-CI_OLfvz.mjs → provider-BN2bCIUp.mjs} +3440 -4308
  36. package/dist/.setup/{provider-session.runtime-TWOo_JZx.mjs → provider-session.runtime-Dr_5X43t.mjs} +3 -3
  37. package/dist/.setup/provider.runtime-BuJpl0Pv.mjs +1 -0
  38. package/dist/.setup/proxy-fetch-BzXwBAXt.mjs +30 -0
  39. package/dist/.setup/{realtime-session.runtime-DvfS4vJj.mjs → realtime-session.runtime-BTDWsV4d.mjs} +44 -81
  40. package/dist/.setup/{receive-recovery-CKvaG2Hf.mjs → receive-recovery-C3Ks4wAQ.mjs} +13 -27
  41. package/dist/.setup/{resolve-allowlist-common-cIjtqh2F.mjs → resolve-allowlist-common-Bk8Fj6Ik.mjs} +3 -13
  42. package/dist/.setup/{resolve-channels-Cj5i7hzj.mjs → resolve-channels-Bp8frXvc.mjs} +7 -8
  43. package/dist/.setup/{resolve-users-BQLbysRB.mjs → resolve-users-Cvcj22sG.mjs} +4 -7
  44. package/dist/.setup/{runtime-RWnuJgWB.mjs → runtime-BJaCvlmq.mjs} +196 -239
  45. package/dist/.setup/{runtime-plifsKg9.mjs → runtime-BMgTyuwg.mjs} +6 -6
  46. package/dist/.setup/{secret-config-contract-z6FhbT8E.mjs → secret-config-contract-B1kE4sDv.mjs} +4 -9
  47. package/dist/.setup/{send-da6ENJ9f.mjs → send-CVW7V-VZ.mjs} +149 -175
  48. package/dist/.setup/{send.components-CWZUuGvA.mjs → send.components-C8YXdnO_.mjs} +59 -71
  49. package/dist/.setup/{send.outbound-qZ3iK3Vq.mjs → send.outbound-Uzcmh3Yd.mjs} +76 -129
  50. package/dist/.setup/{send.receipt-C18khRYH.mjs → send.receipt-NZDOTZBU.mjs} +30 -32
  51. package/dist/.setup/{send.shared-CnlMgoqQ.mjs → send.shared-a_6Oeyg1.mjs} +38 -115
  52. package/dist/.setup/{sender-identity-DgbJykq0.mjs → sender-identity-76HFb8eK.mjs} +3 -9
  53. package/dist/.setup/setup-plugin-api-BExhGEhL.mjs +2 -0
  54. package/dist/.setup/shared-interactive-DmzaoKOM.mjs +316 -0
  55. package/dist/.setup/{shared-CY5vJM48.mjs → shared-yDUSExm2.mjs} +8 -11
  56. package/dist/.setup/{subagent-hooks-CIu2TFz3.mjs → subagent-hooks-CDkdHQyy.mjs} +1 -1
  57. package/dist/.setup/{system-events-DCOLXkwS.mjs → system-events-yfWz150v.mjs} +2 -2
  58. package/dist/.setup/{target-resolver-CApivu3G.mjs → target-resolver-BOOzqxxM.mjs} +3 -3
  59. package/dist/.setup/{thread-bindings-DcvT_JgI.mjs → thread-bindings-zce4cpu_.mjs} +12 -20
  60. package/dist/.setup/{thread-bindings.manager-5Sh7yedN.mjs → thread-bindings.manager-NywKzUtc.mjs} +22 -42
  61. package/dist/.setup/{thread-bindings.session-updates-BMdJeJMc.mjs → thread-bindings.session-updates-D0j7oh8S.mjs} +11 -18
  62. package/dist/.setup/{threading-CzjFeUSe.mjs → threading-DodLYDt-.mjs} +68 -105
  63. package/dist/.setup/{timeouts-CuNARfyw.mjs → timeouts-cIxzatmv.mjs} +1 -1
  64. package/dist/.setup/{transcripts-source-8RDQrSVb.mjs → transcripts-source-ie9GBWaU.mjs} +110 -179
  65. package/dist/.setup/{voice-runtime-BsDILmAv.mjs → voice-runtime-B7V_LTdX.mjs} +231 -452
  66. package/dist/.source-module-urls/d6c089460280c5a04184542d6712e04545caeb1ebb290d3504377b4cc5e22fea.json +1 -0
  67. package/dist/account-inspect-api.js +1 -1
  68. package/dist/action-runtime-api.js +1 -2
  69. package/dist/activities-api.js +286 -341
  70. package/dist/api.js +16 -16
  71. package/dist/channel-config-api.js +1 -2
  72. package/dist/channel-plugin-api.js +1 -2
  73. package/dist/contract-api.js +1 -2
  74. package/dist/directory-contract-api.js +1 -1
  75. package/dist/runtime-api.js +22 -22
  76. package/dist/runtime-setter-api.js +1 -2
  77. package/dist/secret-contract-api.js +1 -2
  78. package/dist/security-audit-contract-api.js +1 -2
  79. package/dist/security-contract-api.js +1 -2
  80. package/dist/session-key-api.js +1 -2
  81. package/dist/setup-entry.js +1 -1
  82. package/dist/setup-plugin-api.js +1 -2
  83. package/dist/src/voice/audio-worker.runtime.js +56 -68
  84. package/dist/subagent-hooks-api.js +1 -1
  85. package/dist/thread-binding-api.js +1 -2
  86. package/dist/transcripts-source-api.js +1 -1
  87. package/node_modules/@napi-rs/wasm-runtime/dist/fs.js +3339 -4021
  88. package/node_modules/@napi-rs/wasm-runtime/package.json +1 -1
  89. package/node_modules/@types/lodash/README.md +1 -1
  90. package/node_modules/@types/lodash/common/function.d.ts +2 -2
  91. package/node_modules/@types/lodash/package.json +2 -2
  92. package/node_modules/@types/node/README.md +1 -1
  93. package/node_modules/@types/node/package.json +2 -2
  94. package/node_modules/@types/node/util.d.ts +6 -3
  95. package/node_modules/discord-api-types/package.json +4 -4
  96. package/node_modules/discord-api-types/rest/v10/index.d.ts +8 -0
  97. package/node_modules/discord-api-types/rest/v10/index.d.ts.map +1 -1
  98. package/node_modules/discord-api-types/rest/v10/index.js +8 -0
  99. package/node_modules/discord-api-types/rest/v10/index.js.map +1 -1
  100. package/node_modules/discord-api-types/rest/v10/oauth2.d.ts +26 -2
  101. package/node_modules/discord-api-types/rest/v10/oauth2.d.ts.map +1 -1
  102. package/node_modules/discord-api-types/rest/v9/index.d.ts +8 -0
  103. package/node_modules/discord-api-types/rest/v9/index.d.ts.map +1 -1
  104. package/node_modules/discord-api-types/rest/v9/index.js +8 -0
  105. package/node_modules/discord-api-types/rest/v9/index.js.map +1 -1
  106. package/node_modules/discord-api-types/rest/v9/oauth2.d.ts +26 -2
  107. package/node_modules/discord-api-types/rest/v9/oauth2.d.ts.map +1 -1
  108. package/node_modules/typebox/build/format/duration.d.mts +2 -2
  109. package/node_modules/typebox/build/format/duration.mjs +2 -2
  110. package/node_modules/typebox/build/format/idn_email.d.mts +1 -0
  111. package/node_modules/typebox/build/format/idn_email.mjs +1 -0
  112. package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -1
  113. package/node_modules/typebox/build/format/idn_hostname.mjs +1 -1
  114. package/node_modules/typebox/build/format/ipv4.d.mts +2 -2
  115. package/node_modules/typebox/build/format/ipv4.mjs +2 -2
  116. package/node_modules/typebox/build/format/ipv6.d.mts +1 -1
  117. package/node_modules/typebox/build/format/ipv6.mjs +1 -1
  118. package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
  119. package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
  120. package/node_modules/typebox/build/schema/build.mjs +1 -0
  121. package/node_modules/typebox/build/schema/engine/_unique.d.mts +4 -2
  122. package/node_modules/typebox/build/schema/engine/_unique.mjs +7 -3
  123. package/node_modules/typebox/build/schema/engine/additionalItems.mjs +3 -3
  124. package/node_modules/typebox/build/schema/engine/additionalProperties.d.mts +0 -3
  125. package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +15 -17
  126. package/node_modules/typebox/build/schema/engine/contains.mjs +3 -3
  127. package/node_modules/typebox/build/schema/engine/index.d.mts +1 -0
  128. package/node_modules/typebox/build/schema/engine/index.mjs +1 -0
  129. package/node_modules/typebox/build/schema/engine/items.mjs +7 -4
  130. package/node_modules/typebox/build/schema/engine/maxContains.mjs +2 -2
  131. package/node_modules/typebox/build/schema/engine/minContains.mjs +3 -3
  132. package/node_modules/typebox/build/schema/engine/oneOf.mjs +2 -2
  133. package/node_modules/typebox/build/schema/engine/patternProperties.mjs +2 -2
  134. package/node_modules/typebox/build/schema/engine/propertyNames.mjs +2 -2
  135. package/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs +2 -2
  136. package/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs +2 -2
  137. package/node_modules/typebox/build/system/hashing/hash.mjs +63 -34
  138. package/node_modules/typebox/build/system/locale/en_US.mjs +2 -1
  139. package/node_modules/typebox/build/system/memory/assign.d.mts +2 -8
  140. package/node_modules/typebox/build/system/memory/assign.mjs +13 -6
  141. package/node_modules/typebox/build/system/memory/clone.d.mts +4 -5
  142. package/node_modules/typebox/build/system/memory/clone.mjs +8 -96
  143. package/node_modules/typebox/build/system/memory/create.d.mts +1 -5
  144. package/node_modules/typebox/build/system/memory/create.mjs +18 -13
  145. package/node_modules/typebox/build/system/memory/deep.d.mts +2 -0
  146. package/node_modules/typebox/build/system/memory/deep.mjs +108 -0
  147. package/node_modules/typebox/build/system/memory/discard.d.mts +1 -1
  148. package/node_modules/typebox/build/system/memory/discard.mjs +9 -8
  149. package/node_modules/typebox/build/system/memory/finalize.d.mts +4 -0
  150. package/node_modules/typebox/build/system/memory/finalize.mjs +30 -0
  151. package/node_modules/typebox/build/system/memory/keys.d.mts +2 -0
  152. package/node_modules/typebox/build/system/memory/keys.mjs +8 -0
  153. package/node_modules/typebox/build/system/memory/update.d.mts +1 -4
  154. package/node_modules/typebox/build/system/memory/update.mjs +43 -16
  155. package/node_modules/typebox/build/type/engine/call/index.d.mts +1 -0
  156. package/node_modules/typebox/build/type/engine/call/index.mjs +1 -0
  157. package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +2 -24
  158. package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +2 -29
  159. package/node_modules/typebox/build/type/engine/evaluate/index.d.mts +1 -0
  160. package/node_modules/typebox/build/type/engine/evaluate/index.mjs +1 -0
  161. package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +5 -1
  162. package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +6 -1
  163. package/node_modules/typebox/build/type/engine/evaluate/property.d.mts +30 -0
  164. package/node_modules/typebox/build/type/engine/evaluate/property.mjs +29 -0
  165. package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +1 -3
  166. package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +1 -4
  167. package/node_modules/typebox/build/type/engine/object/from_intersect.d.mts +2 -2
  168. package/node_modules/typebox/build/type/engine/object/from_intersect.mjs +2 -2
  169. package/node_modules/typebox/build/type/engine/object/from_union.d.mts +2 -2
  170. package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
  171. package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +1 -3
  172. package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +1 -4
  173. package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +1 -3
  174. package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +1 -4
  175. package/node_modules/typebox/build/type/engine/this/index.d.mts +1 -0
  176. package/node_modules/typebox/build/type/engine/this/index.mjs +1 -0
  177. package/node_modules/typebox/build/value/clone/clone.d.mts +4 -3
  178. package/node_modules/typebox/build/value/clone/clone.mjs +5 -7
  179. package/node_modules/typebox/build/value/repair/from_cyclic.d.mts +2 -0
  180. package/node_modules/typebox/build/value/repair/from_cyclic.mjs +6 -0
  181. package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +25 -14
  182. package/node_modules/typebox/package.json +1 -1
  183. package/node_modules/typebox/readme.md +1 -1
  184. package/node_modules/undici/docs/docs/api/Interceptors.md +15 -2
  185. package/node_modules/undici/lib/dispatcher/client-h2.js +78 -3
  186. package/node_modules/undici/lib/dispatcher/pool-base.js +20 -3
  187. package/node_modules/undici/package.json +3 -3
  188. package/node_modules/undici/types/api.d.ts +1 -1
  189. package/node_modules/undici/types/utility.d.ts +4 -4
  190. package/node_modules/uuid/package.json +17 -17
  191. package/node_modules/zod/package.json +1 -1
  192. package/node_modules/zod/src/v4/classic/tests/array.test.ts +27 -0
  193. package/node_modules/zod/src/v4/classic/tests/map.test.ts +7 -0
  194. package/node_modules/zod/src/v4/classic/tests/set.test.ts +6 -0
  195. package/node_modules/zod/src/v4/core/compile.ts +9 -0
  196. package/node_modules/zod/src/v4/core/schemas.ts +35 -1
  197. package/node_modules/zod/src/v4/core/util.ts +13 -0
  198. package/node_modules/zod/src/v4/core/versions.ts +1 -1
  199. package/node_modules/zod/v4/core/compile.cjs +8 -0
  200. package/node_modules/zod/v4/core/compile.js +8 -0
  201. package/node_modules/zod/v4/core/schemas.cjs +30 -0
  202. package/node_modules/zod/v4/core/schemas.d.cts +3 -1
  203. package/node_modules/zod/v4/core/schemas.d.ts +3 -1
  204. package/node_modules/zod/v4/core/schemas.js +30 -0
  205. package/node_modules/zod/v4/core/util.cjs +15 -0
  206. package/node_modules/zod/v4/core/util.d.cts +2 -0
  207. package/node_modules/zod/v4/core/util.d.ts +2 -0
  208. package/node_modules/zod/v4/core/util.js +14 -0
  209. package/node_modules/zod/v4/core/versions.cjs +1 -1
  210. package/node_modules/zod/v4/core/versions.js +1 -1
  211. package/openclaw.plugin.json +1 -31
  212. package/package.json +8 -8
  213. package/dist/.setup/channel-access-DasWY_OV.mjs +0 -48
  214. package/dist/.setup/channel.setup-DaDQdctj.mjs +0 -249
  215. package/dist/.setup/outbound-adapter-DfAanoCO.mjs +0 -543
  216. package/dist/.setup/provider.runtime-DnionCyo.mjs +0 -2
  217. package/dist/.setup/setup-plugin-api-D1QuM187.mjs +0 -3
  218. package/dist/.setup/targets-UWWZ6gF7.mjs +0 -3
  219. package/node_modules/typebox/build/system/memory/freeze.d.mts +0 -4
  220. package/node_modules/typebox/build/system/memory/freeze.mjs +0 -6
@@ -1,11 +1,13 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.mjs";
2
- import { D as getDiscordEndpointRuntime, O as resolveDiscordEndpointAttachmentGuard, T as parseDiscordRetryAfterBodySeconds } from "./allow-list-BKqOldGy.mjs";
3
- import { C as hasAnyChannelPermissionDiscord, D as createDiscordMessageNonce, I as resolveDiscordClientAccountContext, L as resolveDiscordRest, M as parseAndResolveChannelRecipient, N as createDiscordClient, O as resolveDiscordMessageFlags, R as DISCORD_REST_TIMEOUT_MS, S as hasAllGuildPermissionsDiscord, _ as canManageGuildMemberRoleDiscord, a as normalizeEmojiName, b as fetchChannelPermissionsDiscord, c as resolveChannelId, d as sendDiscordChunks, g as DiscordSendError, h as DISCORD_MAX_STICKER_BYTES, j as resolveDiscordSuppressEmbeds, m as DISCORD_MAX_EVENT_COVER_BYTES, n as buildDiscordTextChunks, o as normalizeReactionEmoji, p as DISCORD_MAX_EMOJI_BYTES, r as buildReactionIdentifier, t as buildDiscordSendError, v as canManageGuildRoleDiscord, w as hasAnyGuildPermissionDiscord, x as fetchMemberGuildPermissionsDiscord, y as canViewDiscordGuildChannel } from "./send.shared-CnlMgoqQ.mjs";
4
- import { B as isUnknownDiscordVoiceStateError, G as withDiscordRequestAuthority, H as readDiscordMessage, L as DiscordError, R as RateLimitError, U as readRetryAfter, V as readDiscordCode, _t as getGuild, at as createOwnMessageReaction, bt as listGuildEmojis, dt as editChannelMessage, ft as getChannel, gt as unpinChannelMessage, ht as pinChannelMessage, lt as createThread, ot as deleteOwnMessageReaction, pt as getChannelMessage, st as listMessageReactionUsers, ut as deleteChannelMessage, vt as getGuildMember, xt as stripUndefinedFields, yt as getGuildVoiceState, z as isUnknownDiscordMessageError } from "./discord-BMD-JiVS.mjs";
5
- import { _ as recordDiscordMessageCreateAmbiguity, a as createReusableDiscordReplyReference, h as createDiscordRetryRunner, m as classifyDiscordDeliveryFailure, n as createDiscordSendReceiptFromResults, o as resolveDiscordReplyMessageId, r as createDiscordSendResult, v as chunkDiscordTextWithMode } from "./send.receipt-C18khRYH.mjs";
6
- import { o as parseDiscordHttpErrorBody } from "./api-DqmMUZau.mjs";
7
- import { a as prepareDiscordOutboundText, n as sendPollDiscord, r as sendStickerDiscord, t as sendMessageDiscord } from "./send.outbound-qZ3iK3Vq.mjs";
8
- import { n as DISCORD_ATTACHMENT_TOTAL_TIMEOUT_MS } from "./timeouts-CuNARfyw.mjs";
2
+ import { C as hasAnyChannelPermissionDiscord, D as createDiscordMessageNonce, F as resolveDiscordClientAccountContext, I as resolveDiscordRest, M as createDiscordClient, O as resolveDiscordMessageFlags, S as hasAllGuildPermissionsDiscord, _ as canManageGuildMemberRoleDiscord, a as normalizeEmojiName, b as fetchChannelPermissionsDiscord, c as resolveChannelId, d as sendDiscordChunks, g as DiscordSendError, h as DISCORD_MAX_STICKER_BYTES, j as resolveDiscordSuppressEmbeds, m as DISCORD_MAX_EVENT_COVER_BYTES, n as buildDiscordTextChunks, o as normalizeReactionEmoji, p as DISCORD_MAX_EMOJI_BYTES, r as buildReactionIdentifier, t as buildDiscordSendError, v as canManageGuildRoleDiscord, w as hasAnyGuildPermissionDiscord, x as fetchMemberGuildPermissionsDiscord, y as canViewDiscordGuildChannel } from "./send.shared-a_6Oeyg1.mjs";
3
+ import { B as RateLimitError, C as listMessageReactionUsers, D as editChannelMessage, E as deleteChannelMessage, F as getGuildVoiceState, G as readRetryAfter, H as isUnknownDiscordVoiceStateError, I as listGuildEmojis, J as stripUndefinedFields, L as DISCORD_REST_TIMEOUT_MS, M as unpinChannelMessage, N as getGuild, O as getChannel, P as getGuildMember, S as deleteOwnMessageReaction, T as createThread, U as readDiscordCode, V as isUnknownDiscordMessageError, W as readDiscordMessage, j as pinChannelMessage, k as getChannelMessage, q as withDiscordRequestAuthority, w as createChannelMessage, x as createOwnMessageReaction, z as DiscordError } from "./discord-DGVSguhx.mjs";
4
+ import { C as parseDiscordRetryAfterBodySeconds } from "./allow-list-BXrS8-R9.mjs";
5
+ import { _ as recordDiscordMessageCreateAmbiguity, h as createDiscordRetryRunner, m as classifyDiscordDeliveryFailure, n as createDiscordSendReceiptFromResults, r as createDiscordSendResult, v as chunkDiscordTextWithMode } from "./send.receipt-NZDOTZBU.mjs";
6
+ import { n as getDiscordEndpointRuntime, r as resolveDiscordEndpointAttachmentGuard } from "./endpoint-runtime-lf4DeLas.mjs";
7
+ import { o as parseDiscordHttpErrorBody } from "./api-BlBD4ism.mjs";
8
+ import { t as parseAndResolveDiscordTarget } from "./target-resolver-BOOzqxxM.mjs";
9
+ import { a as prepareDiscordOutboundText, n as sendPollDiscord, r as sendStickerDiscord, t as sendMessageDiscord } from "./send.outbound-Uzcmh3Yd.mjs";
10
+ import { n as DISCORD_ATTACHMENT_TOTAL_TIMEOUT_MS } from "./timeouts-cIxzatmv.mjs";
9
11
  import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
10
12
  import { resolvePreferredOpenClawTmpDir, withTempWorkspace } from "openclaw/plugin-sdk/temp-path";
11
13
  import { normalizeLowercaseStringOrEmpty, normalizeOptionalLowercaseString, normalizeOptionalString, normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
@@ -14,8 +16,8 @@ import { MEDIA_FFMPEG_MAX_AUDIO_DURATION_SECS, buildOutboundMediaLoadOptions, ex
14
16
  import { requireRuntimeConfig } from "openclaw/plugin-sdk/plugin-config-runtime";
15
17
  import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
16
18
  import { parseStrictFiniteNumber, resolveExpiresAtMsFromDurationMs, timestampMsToIsoString } from "openclaw/plugin-sdk/number-runtime";
17
- import crypto from "node:crypto";
18
19
  import { fetchWithSsrFGuard } from "openclaw/plugin-sdk/ssrf-runtime";
20
+ import crypto from "node:crypto";
19
21
  import { readProviderJsonResponse, readResponseTextLimited } from "openclaw/plugin-sdk/provider-http";
20
22
  import { loadWebMediaRaw } from "openclaw/plugin-sdk/web-media";
21
23
  import { recordChannelActivity } from "openclaw/plugin-sdk/channel-activity-runtime";
@@ -49,13 +51,7 @@ async function editChannelDiscord(payload, opts) {
49
51
  archived: payload.archived,
50
52
  locked: payload.locked,
51
53
  auto_archive_duration: payload.autoArchiveDuration,
52
- available_tags: payload.availableTags === void 0 ? void 0 : payload.availableTags.map((tag) => stripUndefinedFields({
53
- id: tag.id,
54
- name: tag.name,
55
- moderated: tag.moderated,
56
- emoji_id: tag.emoji_id,
57
- emoji_name: tag.emoji_name
58
- }))
54
+ available_tags: payload.availableTags
59
55
  });
60
56
  return await rest.patch(Routes.channel(payload.channelId), { body });
61
57
  }
@@ -241,9 +237,16 @@ function assertDiscordResponseArray(value, label) {
241
237
  if (!Array.isArray(value)) throw new Error(`Unexpected Discord response for ${label}: expected array.`);
242
238
  return value;
243
239
  }
244
- function assertDiscordResponseObject(value, label) {
245
- if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`Unexpected Discord response for ${label}: expected object.`);
246
- return value;
240
+ function assertDiscordSearchResponse(value) {
241
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("Unexpected Discord response for message search: expected object.");
242
+ const result = value;
243
+ if (result.code === 11e4) {
244
+ const message = typeof result.message === "string" && result.message.trim() ? result.message.trim() : "Discord search index is not yet available";
245
+ const retryAfter = parseDiscordRetryAfterBodySeconds(result.retry_after);
246
+ const retryHint = retryAfter === void 0 ? "" : ` (retry after ${retryAfter}s)`;
247
+ throw new Error(`Discord message search unavailable: ${message}${retryHint}`);
248
+ }
249
+ if (!Array.isArray(result.messages)) throw new Error("Unexpected Discord response for message search: expected messages array.");
247
250
  }
248
251
  function describeDiscordThreadInitialMessageFailure(delivery) {
249
252
  if (delivery?.failedChunkDelivery === "unknown") return delivery.deliveredChunkCount > 0 ? "Discord thread was created, but delivery of the remaining initial content could not be confirmed" : "Discord thread was created, but initial message delivery could not be confirmed";
@@ -255,10 +258,7 @@ var DiscordThreadInitialMessageError = class extends Error {
255
258
  const initialMessageWarning = describeDiscordThreadInitialMessageFailure(initialMessageDelivery);
256
259
  super(`${initialMessageWarning}: ${initialMessageError}`, { cause: error });
257
260
  this.name = "DiscordThreadInitialMessageError";
258
- this.initialMessageDelivery = initialMessageDelivery ? {
259
- ...initialMessageDelivery,
260
- deliveredMessageIds: [...initialMessageDelivery.deliveredMessageIds]
261
- } : void 0;
261
+ this.initialMessageDelivery = initialMessageDelivery;
262
262
  this.initialMessageError = initialMessageError;
263
263
  this.initialMessageWarning = initialMessageWarning;
264
264
  this.thread = thread;
@@ -316,7 +316,20 @@ async function deleteMessageDiscord(channelId, messageId, opts) {
316
316
  return { ok: true };
317
317
  }
318
318
  async function listPinsDiscord(channelId, opts) {
319
- return await resolveDiscordRest(opts).get(Routes.channelPins(channelId));
319
+ const rest = resolveDiscordRest(opts);
320
+ const messages = [];
321
+ let before;
322
+ while (true) {
323
+ const page = await rest.get(Routes.channelMessagesPins(channelId), {
324
+ limit: 50,
325
+ ...before ? { before } : {}
326
+ });
327
+ messages.push(...page.items.map((pin) => pin.message));
328
+ if (!page.has_more) return messages;
329
+ const nextBefore = page.items.at(-1)?.pinned_at;
330
+ if (!nextBefore || nextBefore === before) throw new Error("Discord pin pagination did not advance.");
331
+ before = nextBefore;
332
+ }
320
333
  }
321
334
  async function createThreadDiscord(channelId, payload, opts) {
322
335
  const assertCreateAllowed = opts.assertCreateAllowed;
@@ -411,14 +424,8 @@ async function searchMessagesDiscord(query, opts) {
411
424
  const limit = Math.min(Math.max(Math.floor(query.limit), 1), 25);
412
425
  params.set("limit", String(limit));
413
426
  }
414
- const result = assertDiscordResponseObject(await rest.get(`/guilds/${query.guildId}/messages/search?${params.toString()}`), "message search");
415
- if (result.code === 11e4) {
416
- const message = typeof result.message === "string" && result.message.trim() ? result.message.trim() : "Discord search index is not yet available";
417
- const retryAfter = parseDiscordRetryAfterBodySeconds(result.retry_after);
418
- const retryHint = retryAfter === void 0 ? "" : ` (retry after ${retryAfter}s)`;
419
- throw new Error(`Discord message search unavailable: ${message}${retryHint}`);
420
- }
421
- if (!Array.isArray(result.messages)) throw new Error("Unexpected Discord response for message search: expected messages array.");
427
+ const result = await rest.get(`/guilds/${query.guildId}/messages/search?${params.toString()}`);
428
+ assertDiscordSearchResponse(result);
422
429
  return result;
423
430
  }
424
431
  //#endregion
@@ -437,7 +444,7 @@ async function throwWebhookResponseError(response, signal) {
437
444
  const parsed = parseDiscordHttpErrorBody(raw);
438
445
  if (response.status === 429) throw new RateLimitError(response, {
439
446
  message: readDiscordMessage(parsed, "Rate limited"),
440
- retry_after: readRetryAfter(parsed, response, 1),
447
+ retry_after: readRetryAfter(parsed, response),
441
448
  code: readDiscordCode(parsed),
442
449
  global: parsed && typeof parsed === "object" && "global" in parsed ? Boolean(parsed.global) : false
443
450
  });
@@ -447,7 +454,6 @@ async function sendWebhookMessageDiscord(text, opts) {
447
454
  const webhookId = normalizeOptionalString(opts.webhookId) ?? "";
448
455
  const webhookToken = normalizeOptionalString(opts.webhookToken) ?? "";
449
456
  if (!webhookId || !webhookToken) throw new Error("Discord webhook id/token are required");
450
- const reply = typeof opts.replyTo === "string" ? createReusableDiscordReplyReference(normalizeOptionalString(opts.replyTo)) : opts.replyTo;
451
457
  const { account, proxyFetch } = resolveDiscordClientAccountContext({
452
458
  cfg: opts.cfg,
453
459
  accountId: opts.accountId
@@ -473,6 +479,7 @@ async function sendWebhookMessageDiscord(text, opts) {
473
479
  if (opts.threadId != null && opts.threadId !== "") url.searchParams.set("thread_id", String(opts.threadId));
474
480
  const deadline = buildTimeoutAbortSignal({
475
481
  timeoutMs: DISCORD_WEBHOOK_TIMEOUT_MS,
482
+ signal: opts.signal,
476
483
  operation: "discord.webhook.send"
477
484
  });
478
485
  const request = createDiscordRetryRunner({ signal: deadline.signal });
@@ -483,11 +490,6 @@ async function sendWebhookMessageDiscord(text, opts) {
483
490
  const results = [];
484
491
  try {
485
492
  for (const content of chunks.length ? chunks : [""]) {
486
- const replyTo = resolveDiscordReplyMessageId(reply, results.length === 0);
487
- const messageReference = replyTo ? {
488
- message_id: replyTo,
489
- fail_if_not_exists: false
490
- } : void 0;
491
493
  const response = await request(async () => {
492
494
  await opts.onPlatformSendDispatch?.();
493
495
  opts.assertPlatformSendAuthorized?.();
@@ -498,8 +500,7 @@ async function sendWebhookMessageDiscord(text, opts) {
498
500
  content,
499
501
  username: normalizeOptionalString(opts.username),
500
502
  avatar_url: normalizeOptionalString(opts.avatarUrl),
501
- ...flags ? { flags } : {},
502
- ...messageReference ? { message_reference: messageReference } : {}
503
+ ...flags ? { flags } : {}
503
504
  }),
504
505
  signal: deadline.signal
505
506
  });
@@ -521,8 +522,7 @@ async function sendWebhookMessageDiscord(text, opts) {
521
522
  result: payload,
522
523
  fallbackChannelId: opts.threadId ? String(opts.threadId) : "",
523
524
  kind: "text",
524
- ...opts.threadId != null ? { threadId: opts.threadId } : {},
525
- reply: createReusableDiscordReplyReference(replyTo)
525
+ ...opts.threadId != null ? { threadId: opts.threadId } : {}
526
526
  });
527
527
  const resultConversationId = result.channelId.trim();
528
528
  if (result.messageId && resultConversationId) recordOutboundMessageIdentity({
@@ -548,7 +548,7 @@ async function sendWebhookMessageDiscord(text, opts) {
548
548
  }
549
549
  }
550
550
  //#endregion
551
- //#region extensions/discord/src/voice-message.ts
551
+ //#region extensions/discord/src/send.voice.ts
552
552
  const WAVEFORM_SAMPLES = 256;
553
553
  const DISCORD_OPUS_SAMPLE_RATE_HZ = 48e3;
554
554
  const DISCORD_VOICE_ERROR_BODY_LIMIT_BYTES = 8192;
@@ -697,128 +697,11 @@ async function createVoiceRequestError(response, fallbackMessage) {
697
697
  const parsed = parseDiscordHttpErrorBody(raw);
698
698
  if (response.status === 429) throw new RateLimitError(response, {
699
699
  message: readDiscordMessage(parsed, "You are being rate limited."),
700
- retry_after: readRetryAfter(parsed, response, 1),
700
+ retry_after: readRetryAfter(parsed, response),
701
701
  global: parsed && typeof parsed === "object" && "global" in parsed ? Boolean(parsed.global) : false
702
702
  });
703
703
  return new DiscordError(response, parsed ?? { message: fallbackMessage });
704
704
  }
705
- async function requestVoiceUploadUrl(params) {
706
- const endpoint = params.endpointRuntime;
707
- const url = `${endpoint?.descriptor.restApiBaseUrl ?? params.rest.options?.baseUrl ?? "https://discord.com/api"}/channels/${params.channelId}/attachments`;
708
- const uploadUrlInit = {
709
- method: "POST",
710
- headers: {
711
- Authorization: `Bot ${params.botToken}`,
712
- "Content-Type": "application/json"
713
- },
714
- body: JSON.stringify({ files: [{
715
- filename: params.filename,
716
- file_size: params.fileSize,
717
- id: "0"
718
- }] })
719
- };
720
- const { response: res, release } = endpoint ? {
721
- response: await endpoint.fetch(url, {
722
- ...uploadUrlInit,
723
- signal: AbortSignal.timeout(params.rest.options.timeout)
724
- }),
725
- release: async () => {}
726
- } : await fetchWithSsrFGuard({
727
- url,
728
- init: uploadUrlInit,
729
- timeoutMs: params.rest.options.timeout,
730
- policy: DISCORD_VOICE_UPLOAD_SSRF_POLICY,
731
- auditContext: "discord.voice.upload-url"
732
- });
733
- try {
734
- if (!res.ok) throw await createVoiceRequestError(res, "Upload URL request failed");
735
- return await readProviderJsonResponse(res, "discord.voice.upload-url");
736
- } finally {
737
- await release();
738
- }
739
- }
740
- async function uploadVoiceAttachment(params) {
741
- const endpointGuard = resolveDiscordEndpointAttachmentGuard(params.uploadUrl, params.endpointRuntime);
742
- const { response: uploadResponse, release } = await fetchWithSsrFGuard({
743
- url: params.uploadUrl,
744
- init: {
745
- method: "PUT",
746
- headers: { "Content-Type": "audio/ogg" },
747
- body: new Uint8Array(params.audioBuffer)
748
- },
749
- timeoutMs: DISCORD_ATTACHMENT_TOTAL_TIMEOUT_MS,
750
- policy: endpointGuard?.policy ?? DISCORD_VOICE_UPLOAD_SSRF_POLICY,
751
- ...endpointGuard ? {
752
- maxRedirects: endpointGuard.maxRedirects,
753
- requireHttps: endpointGuard.requireHttps
754
- } : {},
755
- auditContext: "discord.voice.attachment-upload"
756
- });
757
- try {
758
- if (!uploadResponse.ok) throw await createVoiceRequestError(uploadResponse, "Failed to upload voice message");
759
- await uploadResponse.body?.cancel().catch(() => void 0);
760
- } finally {
761
- await release();
762
- }
763
- }
764
- async function sendDiscordVoiceMessage(rest, channelId, audioBuffer, metadata, replyTo, request, silent, token, onPlatformSendDispatch, assertPlatformSendAuthorized) {
765
- const filename = "voice-message.ogg";
766
- const fileSize = audioBuffer.byteLength;
767
- const endpointRuntime = getDiscordEndpointRuntime() ?? null;
768
- if (!token) throw new Error("Discord bot token is required for voice message upload");
769
- const { upload_filename } = await request(async () => {
770
- const uploadUrlResponse = await requestVoiceUploadUrl({
771
- rest,
772
- endpointRuntime,
773
- channelId,
774
- botToken: token,
775
- filename,
776
- fileSize
777
- });
778
- if (!uploadUrlResponse.attachments?.[0]) throw new Error("Failed to get upload URL for voice message");
779
- const attachment = uploadUrlResponse.attachments[0];
780
- await uploadVoiceAttachment({
781
- uploadUrl: attachment.upload_url,
782
- audioBuffer,
783
- endpointRuntime
784
- });
785
- return attachment;
786
- }, "voice-upload");
787
- const messagePayload = {
788
- flags: MessageFlags.IsVoiceMessage | (silent ? MessageFlags.SuppressNotifications : 0),
789
- nonce: createDiscordMessageNonce(),
790
- enforce_nonce: true,
791
- attachments: [{
792
- id: "0",
793
- filename,
794
- uploaded_filename: upload_filename,
795
- duration_secs: metadata.durationSecs,
796
- waveform: metadata.waveform
797
- }],
798
- ...replyTo ? { message_reference: {
799
- message_id: replyTo,
800
- fail_if_not_exists: false
801
- } } : {}
802
- };
803
- let messageCreateMayHaveCommitted = false;
804
- try {
805
- return await request(async () => {
806
- await onPlatformSendDispatch?.();
807
- assertPlatformSendAuthorized?.();
808
- try {
809
- return await rest.post(`/channels/${channelId}/messages`, { body: messagePayload });
810
- } catch (error) {
811
- messageCreateMayHaveCommitted ||= classifyDiscordDeliveryFailure(error) === "ambiguous";
812
- throw error;
813
- }
814
- }, "voice-message", { safety: "nonce-protected-create" });
815
- } catch (error) {
816
- if (messageCreateMayHaveCommitted) recordDiscordMessageCreateAmbiguity(error);
817
- throw error;
818
- }
819
- }
820
- //#endregion
821
- //#region extensions/discord/src/send.voice.ts
822
705
  /** Discord voice messages require OGG/Opus audio with a waveform and cannot include text. */
823
706
  async function sendVoiceMessageDiscord(to, audioPath, opts) {
824
707
  return await withDiscordRequestAuthority(opts.assertPlatformSendAuthorized, async () => {
@@ -846,12 +729,111 @@ async function sendVoiceMessageDiscord(to, audioPath, opts) {
846
729
  cfg
847
730
  });
848
731
  const { token, rest, request, account: accountInfo } = client;
849
- const recipient = await parseAndResolveChannelRecipient(to, cfg, accountInfo.accountId);
850
- channelId = (await resolveChannelId(rest, recipient, request)).channelId;
732
+ const recipient = await parseAndResolveDiscordTarget(to, {
733
+ cfg,
734
+ accountId: accountInfo.accountId
735
+ }, { defaultKind: "channel" });
736
+ const resolvedChannelId = (await resolveChannelId(rest, recipient, request)).channelId;
737
+ channelId = resolvedChannelId;
851
738
  ogg = await ensureOggOpus(localInputPath);
852
739
  const metadata = await getVoiceMessageMetadata(ogg.path);
853
740
  const audioBuffer = await fs.readFile(ogg.path);
854
- const result = await sendDiscordVoiceMessage(rest, channelId, audioBuffer, metadata, opts.reply?.messageId, request, opts.silent, token, opts.onPlatformSendDispatch, opts.assertPlatformSendAuthorized);
741
+ const filename = "voice-message.ogg";
742
+ const endpointRuntime = getDiscordEndpointRuntime() ?? null;
743
+ if (!token) throw new Error("Discord bot token is required for voice message upload");
744
+ const { upload_filename } = await request(async () => {
745
+ let uploadUrlResponse;
746
+ const url = `${endpointRuntime?.descriptor.restApiBaseUrl ?? rest.options?.baseUrl ?? "https://discord.com/api"}/channels/${channelId}/attachments`;
747
+ const uploadUrlInit = {
748
+ method: "POST",
749
+ headers: {
750
+ Authorization: `Bot ${token}`,
751
+ "Content-Type": "application/json"
752
+ },
753
+ body: JSON.stringify({ files: [{
754
+ filename,
755
+ file_size: audioBuffer.byteLength,
756
+ id: "0"
757
+ }] })
758
+ };
759
+ const { response: res, release: releaseNegotiation } = endpointRuntime ? {
760
+ response: await endpointRuntime.fetch(url, {
761
+ ...uploadUrlInit,
762
+ signal: AbortSignal.timeout(rest.options.timeout)
763
+ }),
764
+ release: async () => {}
765
+ } : await fetchWithSsrFGuard({
766
+ url,
767
+ init: uploadUrlInit,
768
+ timeoutMs: rest.options.timeout,
769
+ policy: DISCORD_VOICE_UPLOAD_SSRF_POLICY,
770
+ auditContext: "discord.voice.upload-url"
771
+ });
772
+ try {
773
+ if (!res.ok) throw await createVoiceRequestError(res, "Upload URL request failed");
774
+ uploadUrlResponse = await readProviderJsonResponse(res, "discord.voice.upload-url");
775
+ } finally {
776
+ await releaseNegotiation();
777
+ }
778
+ if (!uploadUrlResponse.attachments?.[0]) throw new Error("Failed to get upload URL for voice message");
779
+ const attachment = uploadUrlResponse.attachments[0];
780
+ const endpointGuard = resolveDiscordEndpointAttachmentGuard(attachment.upload_url, endpointRuntime);
781
+ const { response: uploadResponse, release: releaseUpload } = await fetchWithSsrFGuard({
782
+ url: attachment.upload_url,
783
+ init: {
784
+ method: "PUT",
785
+ headers: { "Content-Type": "audio/ogg" },
786
+ body: new Uint8Array(audioBuffer)
787
+ },
788
+ timeoutMs: DISCORD_ATTACHMENT_TOTAL_TIMEOUT_MS,
789
+ policy: endpointGuard?.policy ?? DISCORD_VOICE_UPLOAD_SSRF_POLICY,
790
+ ...endpointGuard ? {
791
+ maxRedirects: endpointGuard.maxRedirects,
792
+ requireHttps: endpointGuard.requireHttps
793
+ } : {},
794
+ auditContext: "discord.voice.attachment-upload"
795
+ });
796
+ try {
797
+ if (!uploadResponse.ok) throw await createVoiceRequestError(uploadResponse, "Failed to upload voice message");
798
+ await uploadResponse.body?.cancel().catch(() => void 0);
799
+ } finally {
800
+ await releaseUpload();
801
+ }
802
+ return attachment;
803
+ }, "voice-upload");
804
+ const messagePayload = {
805
+ flags: MessageFlags.IsVoiceMessage | (opts.silent ? MessageFlags.SuppressNotifications : 0),
806
+ nonce: createDiscordMessageNonce(),
807
+ enforce_nonce: true,
808
+ attachments: [{
809
+ id: "0",
810
+ filename,
811
+ uploaded_filename: upload_filename,
812
+ duration_secs: metadata.durationSecs,
813
+ waveform: metadata.waveform
814
+ }],
815
+ ...opts.reply?.messageId ? { message_reference: {
816
+ message_id: opts.reply.messageId,
817
+ fail_if_not_exists: false
818
+ } } : {}
819
+ };
820
+ let result;
821
+ let messageCreateMayHaveCommitted = false;
822
+ try {
823
+ result = await request(async () => {
824
+ await opts.onPlatformSendDispatch?.();
825
+ opts.assertPlatformSendAuthorized?.();
826
+ try {
827
+ return await createChannelMessage(rest, resolvedChannelId, { body: messagePayload });
828
+ } catch (error) {
829
+ messageCreateMayHaveCommitted ||= classifyDiscordDeliveryFailure(error) === "ambiguous";
830
+ throw error;
831
+ }
832
+ }, "voice-message", { safety: "nonce-protected-create" });
833
+ } catch (error) {
834
+ if (messageCreateMayHaveCommitted) recordDiscordMessageCreateAmbiguity(error);
835
+ throw error;
836
+ }
855
837
  recordChannelActivity({
856
838
  channel: "discord",
857
839
  accountId: accountInfo.accountId,
@@ -889,17 +871,9 @@ async function sendTypingDiscord(channelId, opts) {
889
871
  }
890
872
  //#endregion
891
873
  //#region extensions/discord/src/send.reactions.ts
892
- function resolveDiscordReactionClient(opts) {
893
- if (opts.rest && opts.cfg && opts.accountId) return createDiscordClient(opts);
894
- const cfg = requireRuntimeConfig(opts.cfg, "Discord reactions");
895
- return createDiscordClient({
896
- ...opts,
897
- cfg
898
- });
899
- }
900
874
  function reactionMutation(operation, label) {
901
875
  return async (channelId, messageId, emoji, opts) => {
902
- const { rest, request } = resolveDiscordReactionClient(opts);
876
+ const { rest, request } = createDiscordClient(opts);
903
877
  const encoded = normalizeReactionEmoji(emoji);
904
878
  await request(() => operation(rest, channelId, messageId, encoded), label);
905
879
  return { ok: true };
@@ -908,7 +882,7 @@ function reactionMutation(operation, label) {
908
882
  const reactMessageDiscord = reactionMutation(createOwnMessageReaction, "react");
909
883
  const removeReactionDiscord = reactionMutation(deleteOwnMessageReaction, "reaction-remove");
910
884
  async function removeOwnReactionsDiscord(channelId, messageId, opts) {
911
- const { rest, request } = resolveDiscordReactionClient(opts);
885
+ const { rest, request } = createDiscordClient(opts);
912
886
  const message = await request(() => getChannelMessage(rest, channelId, messageId), "reaction-list");
913
887
  const identifiers = /* @__PURE__ */ new Set();
914
888
  for (const reaction of message.reactions ?? []) {
@@ -927,7 +901,7 @@ async function removeOwnReactionsDiscord(channelId, messageId, opts) {
927
901
  };
928
902
  }
929
903
  async function fetchReactionsDiscord(channelId, messageId, opts) {
930
- const { rest, request } = resolveDiscordReactionClient(opts);
904
+ const { rest, request } = createDiscordClient(opts);
931
905
  const reactions = (await request(() => getChannelMessage(rest, channelId, messageId), "reaction-list")).reactions ?? [];
932
906
  const limit = typeof opts.limit === "number" && Number.isFinite(opts.limit) ? Math.min(Math.max(Math.floor(opts.limit), 1), 100) : 100;
933
907
  const summaries = [];
@@ -1,9 +1,10 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.mjs";
2
- import { D as createDiscordMessageNonce, M as parseAndResolveChannelRecipient, N as createDiscordClient, T as SUPPRESS_NOTIFICATIONS_FLAG, c as resolveChannelId, l as resolveDiscordChannel, t as buildDiscordSendError } from "./send.shared-CnlMgoqQ.mjs";
3
- import { G as withDiscordRequestAuthority, ct as createChannelMessage, dt as editChannelMessage, q as serializePayload } from "./discord-BMD-JiVS.mjs";
4
- import { r as createDiscordSendResult } from "./send.receipt-C18khRYH.mjs";
5
- import { t as sendMessageDiscord } from "./send.outbound-qZ3iK3Vq.mjs";
6
- import { d as buildDiscordComponentMessage, f as buildDiscordComponentMessageFlags, g as resolveDiscordComponentAttachmentName } from "./components-Du9NhD8h.mjs";
2
+ import { D as createDiscordMessageNonce, M as createDiscordClient, T as SUPPRESS_NOTIFICATIONS_FLAG, c as resolveChannelId, l as resolveDiscordChannel, t as buildDiscordSendError } from "./send.shared-a_6Oeyg1.mjs";
3
+ import { D as editChannelMessage, f as serializePayload, q as withDiscordRequestAuthority, w as createChannelMessage } from "./discord-DGVSguhx.mjs";
4
+ import { r as createDiscordSendResult } from "./send.receipt-NZDOTZBU.mjs";
5
+ import { t as parseAndResolveDiscordTarget } from "./target-resolver-BOOzqxxM.mjs";
6
+ import { t as sendMessageDiscord } from "./send.outbound-Uzcmh3Yd.mjs";
7
+ import { a as buildDiscordComponentMessage, u as resolveDiscordComponentAttachmentName } from "./components-YCvQ6YLS.mjs";
7
8
  import { n as getOptionalDiscordRuntime } from "./runtime-DgnVQ7zW.mjs";
8
9
  import { hasNonEmptyString, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
9
10
  import { ChannelType } from "discord-api-types/v10";
@@ -263,34 +264,58 @@ function registerBuiltDiscordComponentMessage(params) {
263
264
  ttlMs: params.ttlMs
264
265
  });
265
266
  }
266
- function resolveDiscordComponentRegistryTtlMs(accountConfig) {
267
- const ttlMs = accountConfig?.agentComponents?.ttlMs;
268
- return typeof ttlMs === "number" && Number.isFinite(ttlMs) && ttlMs > 0 ? Math.floor(ttlMs) : void 0;
267
+ async function sendDiscordComponentMessage(to, spec, opts) {
268
+ return await withDiscordRequestAuthority(opts.assertPlatformSendAuthorized, async () => {
269
+ const classicMessage = opts.mediaUrl ? resolveClassicDiscordMessage(spec) : void 0;
270
+ if (classicMessage) return await sendMessageDiscord(to, classicMessage.text, {
271
+ ...opts,
272
+ filename: opts.filename?.trim() || classicMessage.filename
273
+ });
274
+ return await writeDiscordComponentMessage(to, spec, opts);
275
+ });
269
276
  }
270
- async function buildDiscordComponentPayload(params) {
271
- const messageReference = params.opts.reply ? {
272
- message_id: params.opts.reply.messageId,
277
+ async function editDiscordComponentMessage(to, messageId, spec, opts) {
278
+ return await writeDiscordComponentMessage(to, spec, opts, messageId);
279
+ }
280
+ async function writeDiscordComponentMessage(to, spec, opts, messageId) {
281
+ const creating = messageId === void 0;
282
+ const cfg = requireRuntimeConfig(opts.cfg, creating ? "Discord component send" : "Discord component edit");
283
+ const { token, rest, request, account: accountInfo } = createDiscordClient({
284
+ ...opts,
285
+ cfg
286
+ });
287
+ const recipient = await parseAndResolveDiscordTarget(to, {
288
+ cfg,
289
+ accountId: accountInfo.accountId
290
+ }, { defaultKind: "channel" });
291
+ const { channelId } = await resolveChannelId(rest, recipient, request);
292
+ if (creating) {
293
+ const channel = await resolveDiscordChannel(rest, channelId);
294
+ if (channel && DISCORD_FORUM_LIKE_TYPES.has(channel.type)) throw new Error("Discord components are not supported in forum-style channels");
295
+ }
296
+ const messageReference = opts.reply ? {
297
+ message_id: opts.reply.messageId,
273
298
  fail_if_not_exists: false
274
299
  } : void 0;
275
- let spec = params.spec;
300
+ let componentSpec = spec;
276
301
  let resolvedFileName;
277
302
  let files;
278
303
  let attachmentNames;
279
- if (params.opts.mediaUrl) {
280
- const media = await loadOutboundMediaFromUrl(params.opts.mediaUrl, {
281
- mediaAccess: params.opts.mediaAccess,
282
- mediaLocalRoots: params.opts.mediaLocalRoots,
283
- mediaReadFile: params.opts.mediaReadFile
304
+ if (opts.mediaUrl) {
305
+ const media = await loadOutboundMediaFromUrl(opts.mediaUrl, {
306
+ mediaAccess: opts.mediaAccess,
307
+ mediaLocalRoots: opts.mediaLocalRoots,
308
+ mediaReadFile: opts.mediaReadFile
284
309
  });
285
- const filenameOverride = params.opts.filename?.trim();
286
- attachmentNames = extractComponentAttachmentNames(spec);
310
+ const filenameOverride = opts.filename?.trim();
311
+ attachmentNames = extractComponentAttachmentNames(componentSpec);
287
312
  const explicitAttachmentName = attachmentNames[0];
288
313
  resolvedFileName = filenameOverride || explicitAttachmentName || media.fileName || `upload${extensionForMime(media.contentType) ?? ""}`;
289
314
  if (attachmentNames.length === 0) {
290
315
  const file = `attachment://${resolvedFileName}`;
291
- spec = {
292
- ...spec,
293
- blocks: [...spec.blocks ?? [], {
316
+ componentSpec = {
317
+ ...componentSpec,
318
+ blocks: [...componentSpec.blocks ?? [], {
294
319
  type: "file",
295
320
  file
296
321
  }]
@@ -303,64 +328,27 @@ async function buildDiscordComponentPayload(params) {
303
328
  contentType: media.contentType
304
329
  }];
305
330
  }
306
- const uniqueAttachmentNames = uniqueStrings(attachmentNames ?? extractComponentAttachmentNames(spec));
331
+ const uniqueAttachmentNames = uniqueStrings(attachmentNames ?? extractComponentAttachmentNames(componentSpec));
307
332
  if (uniqueAttachmentNames.length > 1) throw new Error("Discord component attachments currently support a single file. Use media-gallery for multiple files.");
308
333
  const expectedAttachmentName = uniqueAttachmentNames[0];
309
334
  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.`);
310
- if (!params.opts.mediaUrl && expectedAttachmentName) throw new Error("Discord component file blocks require a media attachment (media/path/filePath).");
335
+ if (!opts.mediaUrl && expectedAttachmentName) throw new Error("Discord component file blocks require a media attachment (media/path/filePath).");
311
336
  const buildResult = buildDiscordComponentMessage({
312
- spec,
313
- sessionKey: params.opts.sessionKey,
314
- agentId: params.opts.agentId,
315
- accountId: params.accountId
337
+ spec: componentSpec,
338
+ sessionKey: opts.sessionKey,
339
+ agentId: opts.agentId,
340
+ accountId: accountInfo.accountId
316
341
  });
317
- const flags = buildDiscordComponentMessageFlags(buildResult.components);
318
- const finalFlags = params.opts.silent ? (flags ?? 0) | SUPPRESS_NOTIFICATIONS_FLAG : flags ?? void 0;
319
342
  const payload = {
320
343
  components: buildResult.components,
321
- allowed_mentions: params.opts.allowedMentions,
322
- ...finalFlags ? { flags: finalFlags } : {},
344
+ allowed_mentions: opts.allowedMentions,
345
+ ...opts.silent ? { flags: SUPPRESS_NOTIFICATIONS_FLAG } : {},
323
346
  ...files ? { files } : {}
324
347
  };
325
- return {
326
- body: {
327
- ...serializePayload(payload),
328
- ...messageReference ? { message_reference: messageReference } : {}
329
- },
330
- buildResult
348
+ const componentBody = {
349
+ ...serializePayload(payload),
350
+ ...messageReference ? { message_reference: messageReference } : {}
331
351
  };
332
- }
333
- async function sendDiscordComponentMessage(to, spec, opts) {
334
- return await withDiscordRequestAuthority(opts.assertPlatformSendAuthorized, async () => {
335
- const classicMessage = opts.mediaUrl ? resolveClassicDiscordMessage(spec) : void 0;
336
- if (classicMessage) return await sendMessageDiscord(to, classicMessage.text, {
337
- ...opts,
338
- filename: opts.filename?.trim() || classicMessage.filename
339
- });
340
- return await writeDiscordComponentMessage(to, spec, opts);
341
- });
342
- }
343
- async function editDiscordComponentMessage(to, messageId, spec, opts) {
344
- return await writeDiscordComponentMessage(to, spec, opts, messageId);
345
- }
346
- async function writeDiscordComponentMessage(to, spec, opts, messageId) {
347
- const creating = messageId === void 0;
348
- const cfg = requireRuntimeConfig(opts.cfg, creating ? "Discord component send" : "Discord component edit");
349
- const { token, rest, request, account: accountInfo } = createDiscordClient({
350
- ...opts,
351
- cfg
352
- });
353
- const recipient = await parseAndResolveChannelRecipient(to, cfg, accountInfo.accountId);
354
- const { channelId } = await resolveChannelId(rest, recipient, request);
355
- if (creating) {
356
- const channel = await resolveDiscordChannel(rest, channelId);
357
- if (channel && DISCORD_FORUM_LIKE_TYPES.has(channel.type)) throw new Error("Discord components are not supported in forum-style channels");
358
- }
359
- const { body: componentBody, buildResult } = await buildDiscordComponentPayload({
360
- spec,
361
- opts,
362
- accountId: accountInfo.accountId
363
- });
364
352
  const body = creating ? {
365
353
  ...componentBody,
366
354
  nonce: createDiscordMessageNonce(),
@@ -397,7 +385,7 @@ async function writeDiscordComponentMessage(to, spec, opts, messageId) {
397
385
  await registerBuiltDiscordComponentMessage({
398
386
  buildResult,
399
387
  messageId: result.id ?? messageId,
400
- ttlMs: resolveDiscordComponentRegistryTtlMs(accountInfo.config)
388
+ ttlMs: accountInfo.config.agentComponents?.ttlMs
401
389
  });
402
390
  recordChannelActivity({
403
391
  channel: "discord",