@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,9 +1,9 @@
1
- import { h as normalizeDiscordToken, l as resolveDiscordAccount, s as mergeDiscordAccountConfig } from "./accounts-ljrzXBJi.mjs";
2
- import { A as isDiscordThreadChannelType } from "./allow-list-BKqOldGy.mjs";
3
- import { I as RequestClient, J as Embed, K as hasDiscordV2Components, _t as getGuild, ct as createChannelMessage, ft as getChannel, it as getCurrentUser, mt as getThreadMember, q as serializePayload, rt as createUserDmChannel, vt as getGuildMember } from "./discord-BMD-JiVS.mjs";
4
- import { h as createDiscordRetryRunner, o as resolveDiscordReplyMessageId, v as chunkDiscordTextWithMode } from "./send.receipt-C18khRYH.mjs";
5
- import { t as parseAndResolveDiscordTarget } from "./target-resolver-CApivu3G.mjs";
6
- import { danger } from "openclaw/plugin-sdk/runtime-env";
1
+ import { h as normalizeDiscordToken, l as resolveDiscordAccount, s as mergeDiscordAccountConfig } from "./accounts-C_25wyxC.mjs";
2
+ import { A as getThreadMember, N as getGuild, O as getChannel, P as getGuildMember, R as RequestClient, b as getCurrentUser, d as hasDiscordV2Components, f as serializePayload, p as Embed, w as createChannelMessage, y as createUserDmChannel, z as DiscordError } from "./discord-DGVSguhx.mjs";
3
+ import { w as isDiscordThreadChannelType } from "./allow-list-BXrS8-R9.mjs";
4
+ import { d as resolveDiscordReplyMessageId, h as createDiscordRetryRunner, v as chunkDiscordTextWithMode } from "./send.receipt-NZDOTZBU.mjs";
5
+ import { t as resolveDiscordProxyFetchForAccount } from "./proxy-fetch-BzXwBAXt.mjs";
6
+ import { t as parseAndResolveDiscordTarget } from "./target-resolver-BOOzqxxM.mjs";
7
7
  import { normalizeAccountId } from "openclaw/plugin-sdk/routing";
8
8
  import { normalizeOptionalString, normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
9
9
  import { ChannelType, MessageFlags, PermissionFlagsBits } from "discord-api-types/v10";
@@ -12,7 +12,6 @@ import { extensionForMime, normalizePollDurationHours, normalizePollInput } from
12
12
  import { loadOutboundMediaFromUrl } from "openclaw/plugin-sdk/outbound-media";
13
13
  import { requireRuntimeConfig } from "openclaw/plugin-sdk/plugin-config-runtime";
14
14
  import { resolveTextChunksWithFallback } from "openclaw/plugin-sdk/reply-payload";
15
- import { makeProxyFetch } from "openclaw/plugin-sdk/fetch-runtime";
16
15
  import { randomBytes } from "node:crypto";
17
16
  //#region extensions/discord/src/monitor/gateway-registry.ts
18
17
  /**
@@ -36,39 +35,6 @@ function clearGateways() {
36
35
  gatewayRegistry.clear();
37
36
  }
38
37
  //#endregion
39
- //#region extensions/discord/src/proxy-fetch.ts
40
- function resolveDiscordProxyFetchForAccount(account, cfg, runtime) {
41
- return withValidatedDiscordProxy(normalizeOptionalString(account.config.proxy) ?? normalizeOptionalString(cfg?.channels?.discord?.proxy), runtime, makeProxyFetch);
42
- }
43
- function withValidatedDiscordProxy(proxyUrl, runtime, createValue) {
44
- const proxy = proxyUrl?.trim();
45
- if (!proxy) return;
46
- try {
47
- validateDiscordProxyUrl(proxy);
48
- return createValue(proxy);
49
- } catch (err) {
50
- runtime?.error?.(danger(`discord: invalid rest proxy: ${String(err)}`));
51
- return;
52
- }
53
- }
54
- function validateDiscordProxyUrl(proxyUrl) {
55
- let parsed;
56
- try {
57
- parsed = new URL(proxyUrl);
58
- } catch {
59
- throw new Error("Proxy URL must be a valid http or https URL");
60
- }
61
- if (!["http:", "https:"].includes(parsed.protocol)) throw new Error("Proxy URL must use http or https");
62
- if (!parsed.hostname) throw new Error("Proxy URL must include a host");
63
- return proxyUrl;
64
- }
65
- //#endregion
66
- //#region extensions/discord/src/proxy-request-client.ts
67
- const DISCORD_REST_TIMEOUT_MS = 15e3;
68
- function createDiscordRequestClient(token, options) {
69
- return new RequestClient(token, options);
70
- }
71
- //#endregion
72
38
  //#region extensions/discord/src/client.ts
73
39
  function createDiscordRuntimeAccountContext(params) {
74
40
  return {
@@ -76,7 +42,7 @@ function createDiscordRuntimeAccountContext(params) {
76
42
  accountId: normalizeAccountId(params.accountId)
77
43
  };
78
44
  }
79
- function resolveDiscordClientAccountContext(opts, runtime) {
45
+ function resolveDiscordClientAccountContext(opts) {
80
46
  const resolvedCfg = requireRuntimeConfig(opts.cfg, "Discord client");
81
47
  const accountId = normalizeAccountId(opts.accountId);
82
48
  const config = mergeDiscordAccountConfig(resolvedCfg, accountId);
@@ -92,7 +58,7 @@ function resolveDiscordClientAccountContext(opts, runtime) {
92
58
  return {
93
59
  cfg: resolvedCfg,
94
60
  account,
95
- proxyFetch: resolveDiscordProxyFetchForAccount(account, resolvedCfg, runtime)
61
+ proxyFetch: resolveDiscordProxyFetchForAccount(account, resolvedCfg)
96
62
  };
97
63
  }
98
64
  function resolveToken(account) {
@@ -121,7 +87,7 @@ function createDiscordRestClient(opts) {
121
87
  const proxyFetch = proxyContext.proxyFetch ?? resolveDiscordProxyFetchForAccount(account, resolvedCfg);
122
88
  return {
123
89
  token,
124
- rest: createDiscordRequestClient(token, {
90
+ rest: new RequestClient(token, {
125
91
  ...proxyFetch ? { fetch: proxyFetch } : {},
126
92
  ...signal ? { signal } : {},
127
93
  ...timeoutMs !== void 0 ? { timeout: timeoutMs } : {}
@@ -154,34 +120,6 @@ function resolveDiscordRest(opts) {
154
120
  return createDiscordRestClient(opts).rest;
155
121
  }
156
122
  //#endregion
157
- //#region extensions/discord/src/recipient-resolution.ts
158
- async function parseAndResolveRecipient(raw, cfg, accountId, parseOptions = {}) {
159
- const resolvedCfg = requireRuntimeConfig(cfg, "Discord recipient resolution");
160
- const accountInfo = resolveDiscordAccount({
161
- cfg: resolvedCfg,
162
- accountId
163
- });
164
- const resolved = await parseAndResolveDiscordTarget(raw, {
165
- cfg: resolvedCfg,
166
- accountId: accountInfo.accountId
167
- }, parseOptions);
168
- return {
169
- kind: resolved.kind,
170
- id: resolved.id
171
- };
172
- }
173
- async function parseAndResolveChannelRecipient(raw, cfg, accountId) {
174
- const resolvedCfg = requireRuntimeConfig(cfg, "Discord recipient resolution");
175
- const resolved = await parseAndResolveDiscordTarget(raw, {
176
- cfg: resolvedCfg,
177
- accountId
178
- }, { defaultKind: "channel" });
179
- return {
180
- kind: resolved.kind,
181
- id: resolved.id
182
- };
183
- }
184
- //#endregion
185
123
  //#region extensions/discord/src/send.message-request.ts
186
124
  const SUPPRESS_EMBEDS_FLAG = MessageFlags.SuppressEmbeds;
187
125
  const SUPPRESS_NOTIFICATIONS_FLAG = MessageFlags.SuppressNotifications;
@@ -250,9 +188,8 @@ async function fetchBotUserId(rest) {
250
188
  return me.id;
251
189
  }
252
190
  function resolveMemberGuildPermissionBits(params) {
253
- const rolesByIdLocal = rolesById(params.guild);
254
- let permissions = addPermissionBits(0n, rolesByIdLocal.get(params.guild.id)?.permissions);
255
- for (const roleId of params.member.roles ?? []) permissions = addPermissionBits(permissions, rolesByIdLocal.get(roleId)?.permissions);
191
+ let permissions = addPermissionBits(0n, params.roles.get(params.guildId)?.permissions);
192
+ for (const roleId of params.member.roles ?? []) permissions = addPermissionBits(permissions, params.roles.get(roleId)?.permissions);
256
193
  return permissions;
257
194
  }
258
195
  function rolesById(guild) {
@@ -261,13 +198,13 @@ function rolesById(guild) {
261
198
  function rolePosition(role) {
262
199
  return typeof role?.position === "number" ? role.position : -1;
263
200
  }
264
- function highestMemberRolePosition(guild, member) {
265
- const roles = rolesById(guild);
201
+ function highestMemberRolePosition(roles, member) {
266
202
  return Math.max(...(member.roles ?? []).map((roleId) => rolePosition(roles.get(roleId))), 0);
267
203
  }
268
204
  function resolveMemberChannelPermissionBits(params) {
269
205
  let permissions = resolveMemberGuildPermissionBits({
270
- guild: params.guild,
206
+ guildId: params.guildId,
207
+ roles: rolesById(params.guild),
271
208
  member: params.member
272
209
  });
273
210
  if (hasAdministrator(permissions)) return ALL_PERMISSIONS;
@@ -304,7 +241,8 @@ async function fetchMemberGuildPermissionsDiscord(guildId, userId, opts) {
304
241
  const [guild, member] = await Promise.all([getGuild(rest, guildId), getGuildMember(rest, guildId, userId)]);
305
242
  if (guild.owner_id === userId) return ALL_PERMISSIONS;
306
243
  return resolveMemberGuildPermissionBits({
307
- guild,
244
+ guildId,
245
+ roles: rolesById(guild),
308
246
  member
309
247
  });
310
248
  } catch {
@@ -357,17 +295,19 @@ async function canManageGuildMemberRoleDiscord(guildId, senderUserId, targetUser
357
295
  ]);
358
296
  if (guild.owner_id === senderUserId) return true;
359
297
  if (guild.owner_id === targetUserId) return false;
360
- const targetRole = rolesById(guild).get(roleId);
298
+ const roles = rolesById(guild);
299
+ const targetRole = roles.get(roleId);
361
300
  const targetRolePosition = rolePosition(targetRole);
362
301
  if (targetRolePosition < 0) return false;
363
302
  const senderPermissions = resolveMemberGuildPermissionBits({
364
- guild,
303
+ guildId,
304
+ roles,
365
305
  member: senderMember
366
306
  });
367
307
  if (requirements?.assignablePermissionCeiling && !hasAdministrator(senderPermissions) && (BigInt(targetRole?.permissions ?? "0") & ~senderPermissions) !== 0n) return false;
368
- const senderHighestRolePosition = highestMemberRolePosition(guild, senderMember);
308
+ const senderHighestRolePosition = highestMemberRolePosition(roles, senderMember);
369
309
  if (senderHighestRolePosition <= targetRolePosition) return false;
370
- return senderHighestRolePosition > highestMemberRolePosition(guild, targetMember);
310
+ return senderHighestRolePosition > highestMemberRolePosition(roles, targetMember);
371
311
  } catch {
372
312
  return false;
373
313
  }
@@ -376,10 +316,11 @@ async function canManageGuildRoleDiscord(guildId, senderUserId, roleId, opts) {
376
316
  const rest = resolveDiscordRest(opts);
377
317
  try {
378
318
  const [guild, senderMember] = await Promise.all([getGuild(rest, guildId), getGuildMember(rest, guildId, senderUserId)]);
379
- const targetRole = rolesById(guild).get(roleId);
319
+ const roles = rolesById(guild);
320
+ const targetRole = roles.get(roleId);
380
321
  if (!targetRole) return null;
381
322
  if (guild.owner_id === senderUserId) return true;
382
- return highestMemberRolePosition(guild, senderMember) > rolePosition(targetRole);
323
+ return highestMemberRolePosition(roles, senderMember) > rolePosition(targetRole);
383
324
  } catch {
384
325
  return false;
385
326
  }
@@ -502,32 +443,16 @@ function normalizeDiscordPollInput(input) {
502
443
  layout_type: PollLayoutType.Default
503
444
  };
504
445
  }
505
- function readDiscordErrorNumber(value, finiteNumbers = false) {
506
- if (typeof value === "number") return !finiteNumbers || Number.isFinite(value) ? value : void 0;
507
- return typeof value === "string" && /^\d+$/.test(value) ? Number(value) : void 0;
508
- }
509
- function getDiscordErrorCode(err) {
510
- if (!err || typeof err !== "object") return;
511
- return readDiscordErrorNumber("code" in err && err.code !== void 0 ? err.code : "rawError" in err && err.rawError && typeof err.rawError === "object" ? err.rawError.code : void 0);
512
- }
513
- function getDiscordErrorStatus(err) {
514
- if (!err || typeof err !== "object") return;
515
- return readDiscordErrorNumber("status" in err && err.status !== void 0 ? err.status : "statusCode" in err && err.statusCode !== void 0 ? err.statusCode : void 0, true);
516
- }
517
446
  function isDiscordUploadTooLargeError(err) {
518
- return getDiscordErrorCode(err) === DISCORD_UPLOAD_TOO_LARGE || getDiscordErrorStatus(err) === DISCORD_UPLOAD_TOO_LARGE_STATUS;
447
+ return err instanceof DiscordError && (err.discordCode === DISCORD_UPLOAD_TOO_LARGE || err.status === DISCORD_UPLOAD_TOO_LARGE_STATUS);
519
448
  }
520
449
  function buildDiscordUploadTooLargeFallbackText(text) {
521
450
  return text.trim() ? `${text}\n\n[${DISCORD_UPLOAD_TOO_LARGE_NOTICE}]` : DISCORD_UPLOAD_TOO_LARGE_NOTICE;
522
451
  }
523
452
  async function buildDiscordSendError(err, ctx) {
524
- if (err instanceof DiscordSendError) return err;
525
- const code = getDiscordErrorCode(err);
526
- if (code === DISCORD_CANNOT_DM) return new DiscordSendError(`discord dm failed: user blocks dms or privacy settings disallow it (code=${code})`, {
527
- kind: "dm-blocked",
528
- discordCode: code,
529
- status: getDiscordErrorStatus(err)
530
- });
453
+ if (!(err instanceof DiscordError)) return err;
454
+ const code = err.discordCode;
455
+ if (code === DISCORD_CANNOT_DM) return new DiscordSendError(`discord dm failed: user blocks dms or privacy settings disallow it (code=${code})`, { status: err.status });
531
456
  if (code !== DISCORD_MISSING_PERMISSIONS) return err;
532
457
  let missing = [];
533
458
  let probedChannelType;
@@ -541,16 +466,10 @@ async function buildDiscordSendError(err, ctx) {
541
466
  const current = new Set(permissions.permissions);
542
467
  missing = resolveRequiredDiscordSendPermissions(probedChannelType, ctx.hasMedia).filter((permission) => !current.has(permission));
543
468
  } catch {}
544
- const status = getDiscordErrorStatus(err);
545
- const apiDetails = [`code=${code}`, status != null ? `status=${status}` : void 0].filter(Boolean).join(" ");
469
+ const status = err.status;
470
+ const apiDetails = `code=${code} status=${status}`;
546
471
  const probeSummary = resolveRequiredDiscordSendPermissions(probedChannelType, ctx.hasMedia).join("/");
547
- return new DiscordSendError(`${missing.length ? `discord missing permissions in channel ${ctx.channelId}: ${missing.join(", ")}` : `discord missing permissions in channel ${ctx.channelId}; permission check did not identify missing ${probeSummary}`} (${apiDetails}). bot might be blocked by channel/thread overrides, archived thread state, reply target visibility, or app-role position`, {
548
- kind: "missing-permissions",
549
- channelId: ctx.channelId,
550
- missingPermissions: missing,
551
- discordCode: code,
552
- status
553
- });
472
+ return new DiscordSendError(`${missing.length ? `discord missing permissions in channel ${ctx.channelId}: ${missing.join(", ")}` : `discord missing permissions in channel ${ctx.channelId}; permission check did not identify missing ${probeSummary}`} (${apiDetails}). bot might be blocked by channel/thread overrides, archived thread state, reply target visibility, or app-role position`, { status });
554
473
  }
555
474
  async function resolveChannelId(rest, recipient, request) {
556
475
  if (recipient.kind === "channel") return { channelId: recipient.id };
@@ -562,7 +481,11 @@ async function resolveChannelId(rest, recipient, request) {
562
481
  };
563
482
  }
564
483
  async function resolveDiscordTargetChannelId(raw, opts) {
565
- const recipient = await parseAndResolveRecipient(raw, requireRuntimeConfig(opts.cfg, "Discord target channel resolution"), opts.accountId, { defaultKind: "channel" });
484
+ const cfg = requireRuntimeConfig(opts.cfg, "Discord target channel resolution");
485
+ const recipient = await parseAndResolveDiscordTarget(raw, {
486
+ cfg,
487
+ accountId: opts.accountId
488
+ }, { defaultKind: "channel" });
566
489
  const { rest, request } = createDiscordClient(opts);
567
490
  return await resolveChannelId(rest, recipient, request);
568
491
  }
@@ -663,4 +586,4 @@ function buildReactionIdentifier(emoji) {
663
586
  return emoji.name ?? "";
664
587
  }
665
588
  //#endregion
666
- export { resolveDiscordSendEmbeds as A, validateDiscordProxyUrl as B, hasAnyChannelPermissionDiscord as C, createDiscordMessageNonce as D, buildDiscordMessageRequest as E, createDiscordRuntimeAccountContext as F, unregisterGateway as G, clearGateways as H, resolveDiscordClientAccountContext as I, resolveDiscordRest as L, parseAndResolveChannelRecipient as M, createDiscordClient as N, resolveDiscordMessageFlags as O, createDiscordRestClient as P, DISCORD_REST_TIMEOUT_MS as R, hasAllGuildPermissionsDiscord as S, SUPPRESS_NOTIFICATIONS_FLAG as T, getGateway as U, withValidatedDiscordProxy as V, registerGateway as W, canManageGuildMemberRoleDiscord as _, normalizeEmojiName as a, fetchChannelPermissionsDiscord as b, resolveChannelId as c, sendDiscordChunks as d, sendDiscordMedia as f, DiscordSendError as g, DISCORD_MAX_STICKER_BYTES as h, normalizeDiscordPollInput as i, resolveDiscordSuppressEmbeds as j, resolveDiscordSendComponents as k, resolveDiscordChannel as l, DISCORD_MAX_EVENT_COVER_BYTES as m, buildDiscordTextChunks as n, normalizeReactionEmoji as o, DISCORD_MAX_EMOJI_BYTES as p, buildReactionIdentifier as r, normalizeStickerIds as s, buildDiscordSendError as t, resolveDiscordTargetChannelId as u, canManageGuildRoleDiscord as v, hasAnyGuildPermissionDiscord as w, fetchMemberGuildPermissionsDiscord as x, canViewDiscordGuildChannel as y, resolveDiscordProxyFetchForAccount as z };
589
+ export { resolveDiscordSendEmbeds as A, unregisterGateway as B, hasAnyChannelPermissionDiscord as C, createDiscordMessageNonce as D, buildDiscordMessageRequest as E, resolveDiscordClientAccountContext as F, resolveDiscordRest as I, clearGateways as L, createDiscordClient as M, createDiscordRestClient as N, resolveDiscordMessageFlags as O, createDiscordRuntimeAccountContext as P, getGateway as R, hasAllGuildPermissionsDiscord as S, SUPPRESS_NOTIFICATIONS_FLAG as T, canManageGuildMemberRoleDiscord as _, normalizeEmojiName as a, fetchChannelPermissionsDiscord as b, resolveChannelId as c, sendDiscordChunks as d, sendDiscordMedia as f, DiscordSendError as g, DISCORD_MAX_STICKER_BYTES as h, normalizeDiscordPollInput as i, resolveDiscordSuppressEmbeds as j, resolveDiscordSendComponents as k, resolveDiscordChannel as l, DISCORD_MAX_EVENT_COVER_BYTES as m, buildDiscordTextChunks as n, normalizeReactionEmoji as o, DISCORD_MAX_EMOJI_BYTES as p, buildReactionIdentifier as r, normalizeStickerIds as s, buildDiscordSendError as t, resolveDiscordTargetChannelId as u, canManageGuildRoleDiscord as v, hasAnyGuildPermissionDiscord as w, fetchMemberGuildPermissionsDiscord as x, canViewDiscordGuildChannel as y, registerGateway as z };
@@ -1,4 +1,4 @@
1
- import { S as formatDiscordUserTag } from "./allow-list-BKqOldGy.mjs";
1
+ import { S as formatDiscordUserTag } from "./allow-list-BXrS8-R9.mjs";
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) {
@@ -18,13 +18,7 @@ function resolveDiscordSenderIdentity(params) {
18
18
  name: memberName,
19
19
  tag: normalizeOptionalString(pkMember?.name),
20
20
  label,
21
- isPluralKit: true,
22
- pluralkit: {
23
- memberId,
24
- memberName,
25
- systemId: normalizeOptionalString(pkSystem?.id),
26
- systemName
27
- }
21
+ isPluralKit: true
28
22
  };
29
23
  }
30
24
  const senderTag = formatDiscordUserTag(params.author);
@@ -32,7 +26,7 @@ function resolveDiscordSenderIdentity(params) {
32
26
  const senderLabel = senderDisplay && senderTag && senderDisplay !== senderTag ? `${senderDisplay} (${senderTag})` : senderDisplay ?? senderTag ?? params.author.id;
33
27
  return {
34
28
  id: params.author.id,
35
- name: params.author.username ?? void 0,
29
+ name: params.author.username,
36
30
  tag: senderTag,
37
31
  label: senderLabel,
38
32
  isPluralKit: false
@@ -0,0 +1,2 @@
1
+ export { t as discordSetupPlugin } from "./channel.setup-B3MtmBQG.mjs";
2
+ import "../setup-plugin-api.js";
@@ -0,0 +1,316 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.mjs";
2
+ import { i as parseCustomId } from "./components.base-CiS0h_XP.mjs";
3
+ import { readNonBlankString } from "openclaw/plugin-sdk/string-coerce-runtime";
4
+ import { resolveAskUserQuestionOptionIndex } from "openclaw/plugin-sdk/reply-payload";
5
+ import { legacyInteractiveReplyToPresentation, resolveMessagePresentationActionValue, resolveMessagePresentationButtonAction, resolveMessagePresentationOptionAction } from "openclaw/plugin-sdk/interactive-runtime";
6
+ import { buildApprovalResolutionRef } from "openclaw/plugin-sdk/approval-reference-runtime";
7
+ //#region extensions/discord/src/custom-id-codec.ts
8
+ /**
9
+ * URI-component codec for values embedded in `k=v;` custom-id grammars
10
+ * (exec approvals, model picker, command args, agent components).
11
+ * Decode falls back to the raw value: Discord redelivers old component ids
12
+ * indefinitely and historical values may predate strict encoding.
13
+ */
14
+ const encodeCustomIdComponent = encodeURIComponent;
15
+ function decodeCustomIdComponent(value) {
16
+ try {
17
+ return decodeURIComponent(value);
18
+ } catch {
19
+ return value;
20
+ }
21
+ }
22
+ /**
23
+ * Minimal field escape for the versioned `occomp`/`ocmodal` grammar: only `%`
24
+ * and the `;` field separator are escaped to preserve the 100-char custom-id
25
+ * budget. The wire format is versioned (`e=1`); do not swap this for the URI
26
+ * codec — in-flight component ids must keep decoding byte-exactly.
27
+ */
28
+ function escapeCustomIdFieldValue(value) {
29
+ return value.replace(/%/g, "%25").replace(/;/g, "%3B");
30
+ }
31
+ function needsCustomIdFieldEscaping(value) {
32
+ return /[%;]/.test(value);
33
+ }
34
+ function unescapeCustomIdFieldValue(value) {
35
+ return value.replace(/%(25|3B)/gi, (match) => match.toLowerCase() === "%25" ? "%" : ";");
36
+ }
37
+ //#endregion
38
+ //#region extensions/discord/src/component-custom-id.ts
39
+ const DISCORD_COMPONENT_CUSTOM_ID_KEY = "occomp";
40
+ const DISCORD_MODAL_CUSTOM_ID_KEY = "ocmodal";
41
+ const DISCORD_ACTIVITY_CUSTOM_ID_KEY = "ocactivity";
42
+ const ENCODED_CUSTOM_ID_VERSION = "1";
43
+ const DISCORD_ACTIVITY_CUSTOM_ID_PREFIX = `${DISCORD_ACTIVITY_CUSTOM_ID_KEY}${ENCODED_CUSTOM_ID_VERSION}_`;
44
+ function isValidDiscordActivityWidgetId(widgetId) {
45
+ return /^[A-Za-z0-9_-]{22}$/.test(widgetId);
46
+ }
47
+ function buildDiscordActivityCustomId(widgetId) {
48
+ return `${DISCORD_ACTIVITY_CUSTOM_ID_PREFIX}${widgetId}`;
49
+ }
50
+ function parseDiscordActivityCustomId(id) {
51
+ if (id.startsWith(DISCORD_ACTIVITY_CUSTOM_ID_PREFIX)) {
52
+ const widgetId = id.slice(DISCORD_ACTIVITY_CUSTOM_ID_PREFIX.length);
53
+ return isValidDiscordActivityWidgetId(widgetId) ? { widgetId } : null;
54
+ }
55
+ const parsed = parseCustomId(id);
56
+ if (parsed.key !== DISCORD_ACTIVITY_CUSTOM_ID_KEY || parsed.data.v !== ENCODED_CUSTOM_ID_VERSION || typeof parsed.data.wid !== "string" || !isValidDiscordActivityWidgetId(parsed.data.wid)) return null;
57
+ return { widgetId: parsed.data.wid };
58
+ }
59
+ function parseDiscordActivityCustomIdForInteraction(id) {
60
+ const parsed = parseDiscordActivityCustomId(id);
61
+ return parsed ? {
62
+ key: DISCORD_ACTIVITY_CUSTOM_ID_KEY,
63
+ data: { widgetId: parsed.widgetId }
64
+ } : parseCustomId(id);
65
+ }
66
+ function decodeParsedCustomIdData(data) {
67
+ if (data.e !== ENCODED_CUSTOM_ID_VERSION) return data;
68
+ return Object.fromEntries(Object.entries(data).map(([key, value]) => [key, typeof value === "string" ? unescapeCustomIdFieldValue(value) : value]));
69
+ }
70
+ function buildDiscordFieldCustomId(key, fields) {
71
+ const encoded = Object.values(fields).some(needsCustomIdFieldEscaping);
72
+ const parts = Object.entries(fields).map(([name, value]) => `${name}=${encoded ? escapeCustomIdFieldValue(value) : value}`);
73
+ return (encoded ? `${key}:e=${ENCODED_CUSTOM_ID_VERSION};` : `${key}:`) + parts.join(";");
74
+ }
75
+ function buildDiscordComponentCustomId(params) {
76
+ return buildDiscordFieldCustomId(DISCORD_COMPONENT_CUSTOM_ID_KEY, {
77
+ cid: params.componentId,
78
+ ...params.modalId ? { mid: params.modalId } : {}
79
+ });
80
+ }
81
+ function buildDiscordModalCustomId(modalId) {
82
+ return buildDiscordFieldCustomId(DISCORD_MODAL_CUSTOM_ID_KEY, { mid: modalId });
83
+ }
84
+ function parseDiscordComponentCustomId(id) {
85
+ const parsed = parseCustomId(id);
86
+ if (parsed.key !== "occomp") return null;
87
+ const data = decodeParsedCustomIdData(parsed.data);
88
+ const componentId = readNonBlankString(data.cid);
89
+ if (!componentId) return null;
90
+ return {
91
+ componentId,
92
+ modalId: readNonBlankString(data.mid)
93
+ };
94
+ }
95
+ function parseDiscordModalCustomId(id) {
96
+ const parsed = parseCustomId(id);
97
+ if (parsed.key !== "ocmodal") return null;
98
+ return readNonBlankString(decodeParsedCustomIdData(parsed.data).mid) ?? null;
99
+ }
100
+ function parseDiscordCustomIdForInteraction(id, key) {
101
+ if (id === "*" || /^__openclaw_discord_component_[a-z_]+_wildcard__$/.test(id)) return {
102
+ key: "*",
103
+ data: {}
104
+ };
105
+ const parsed = parseCustomId(id);
106
+ if (parsed.key !== key) return parsed;
107
+ return {
108
+ key: "*",
109
+ data: decodeParsedCustomIdData(parsed.data)
110
+ };
111
+ }
112
+ function parseDiscordComponentCustomIdForInteraction(id) {
113
+ return parseDiscordCustomIdForInteraction(id, DISCORD_COMPONENT_CUSTOM_ID_KEY);
114
+ }
115
+ function parseDiscordModalCustomIdForInteraction(id) {
116
+ return parseDiscordCustomIdForInteraction(id, DISCORD_MODAL_CUSTOM_ID_KEY);
117
+ }
118
+ //#endregion
119
+ //#region extensions/discord/src/approval-custom-id.ts
120
+ const DISCORD_APPROVAL_DECISIONS = {
121
+ "allow-once": {
122
+ label: "Allowed (once)",
123
+ color: "#57F287"
124
+ },
125
+ "allow-always": {
126
+ label: "Allowed (always)",
127
+ color: "#5865F2"
128
+ },
129
+ deny: {
130
+ label: "Denied",
131
+ color: "#ED4245"
132
+ }
133
+ };
134
+ const DISCORD_APPROVAL_CUSTOM_ID_MAX_CHARS = 100;
135
+ function encodeDiscordApprovalCustomId(action) {
136
+ return `execapproval:kind=${action.approvalKind};id=${encodeURIComponent(action.approvalId)};action=${action.decision}`;
137
+ }
138
+ function encodeBoundedDiscordApprovalCustomId(action) {
139
+ const exact = encodeDiscordApprovalCustomId(action);
140
+ if (exact.length <= DISCORD_APPROVAL_CUSTOM_ID_MAX_CHARS) return exact;
141
+ return encodeDiscordApprovalCustomId({
142
+ ...action,
143
+ approvalId: buildApprovalResolutionRef({
144
+ approvalId: action.approvalId,
145
+ approvalKind: action.approvalKind
146
+ })
147
+ });
148
+ }
149
+ function buildDiscordApprovalCustomId(action) {
150
+ if (!action.approvalId || action.approvalKind !== "exec" && action.approvalKind !== "plugin" && action.approvalKind !== "system-agent" || action.decision !== "allow-once" && action.decision !== "allow-always" && action.decision !== "deny") return;
151
+ return encodeBoundedDiscordApprovalCustomId(action);
152
+ }
153
+ function buildExecApprovalCustomId(approvalId, approvalKind, decision) {
154
+ return encodeBoundedDiscordApprovalCustomId({
155
+ type: "approval",
156
+ approvalId,
157
+ approvalKind,
158
+ decision
159
+ });
160
+ }
161
+ function parseExecApprovalData(data) {
162
+ if (!data || typeof data !== "object") return null;
163
+ const coerce = (value) => typeof value === "string" || typeof value === "number" ? String(value) : "";
164
+ const rawId = coerce(data.id);
165
+ const rawKind = coerce(data.kind);
166
+ const rawAction = coerce(data.action);
167
+ if (!rawId || rawKind !== "exec" && rawKind !== "plugin" && rawKind !== "system-agent") return null;
168
+ if (rawAction !== "allow-once" && rawAction !== "allow-always" && rawAction !== "deny") return null;
169
+ let approvalId;
170
+ try {
171
+ approvalId = decodeURIComponent(rawId);
172
+ } catch {
173
+ return null;
174
+ }
175
+ if (!approvalId) return null;
176
+ return {
177
+ approvalId,
178
+ approvalKind: rawKind,
179
+ action: rawAction
180
+ };
181
+ }
182
+ //#endregion
183
+ //#region extensions/discord/src/question-custom-id.ts
184
+ const QUESTION_RECORD_ID_PATTERN = /^ask_[a-f0-9]{32}$/u;
185
+ function buildDiscordQuestionCustomId(callback) {
186
+ if (!QUESTION_RECORD_ID_PATTERN.test(callback.questionId) || !Number.isInteger(callback.optionIndex) || callback.optionIndex < 0 || callback.optionIndex > 3) return;
187
+ return `ocq:id=${callback.questionId};i=${callback.optionIndex}`;
188
+ }
189
+ function parseDiscordQuestionData(data) {
190
+ const questionId = typeof data.id === "string" ? data.id : "";
191
+ const rawIndex = typeof data.i === "string" ? data.i : typeof data.i === "number" ? String(data.i) : "";
192
+ if (!QUESTION_RECORD_ID_PATTERN.test(questionId) || !/^[0-3]$/u.test(rawIndex)) return null;
193
+ return {
194
+ questionId,
195
+ optionIndex: Number(rawIndex)
196
+ };
197
+ }
198
+ //#endregion
199
+ //#region extensions/discord/src/shared-interactive.ts
200
+ var shared_interactive_exports = /* @__PURE__ */ __exportAll({
201
+ buildDiscordInteractiveComponents: () => buildDiscordInteractiveComponents,
202
+ buildDiscordPresentationComponents: () => buildDiscordPresentationComponents
203
+ });
204
+ const DISCORD_INTERACTIVE_BUTTON_ROW_SIZE = 5;
205
+ function buildDiscordButtonComponent(button, options) {
206
+ const action = resolveMessagePresentationButtonAction(button);
207
+ if (!action) return;
208
+ const component = {
209
+ label: button.label,
210
+ style: button.style ?? "secondary",
211
+ ...button.disabled === true ? { disabled: true } : {}
212
+ };
213
+ if (action.type === "approval") {
214
+ const internalCustomId = buildDiscordApprovalCustomId(action);
215
+ return internalCustomId ? {
216
+ ...component,
217
+ internalCustomId
218
+ } : void 0;
219
+ }
220
+ if (action.type === "question") {
221
+ if ("intent" in action) return;
222
+ const optionIndex = resolveAskUserQuestionOptionIndex({
223
+ questionOptionIndices: options.questionOptionIndices,
224
+ questionId: action.questionId,
225
+ optionValue: action.optionValue
226
+ });
227
+ if (optionIndex === void 0) return;
228
+ const internalCustomId = buildDiscordQuestionCustomId({
229
+ questionId: action.questionId,
230
+ optionIndex
231
+ });
232
+ return internalCustomId ? {
233
+ ...component,
234
+ internalCustomId
235
+ } : void 0;
236
+ }
237
+ if (action.type === "web-app" && action.widgetId && isValidDiscordActivityWidgetId(action.widgetId)) component.internalCustomId = buildDiscordActivityCustomId(action.widgetId);
238
+ else if (action.type === "url" || action.type === "web-app") {
239
+ if (action.type === "web-app" && !action.url) return;
240
+ component.style = "link";
241
+ component.url = action.url;
242
+ } else {
243
+ component.callbackData = action.type === "command" ? action.command : action.value;
244
+ if (button.action?.type === "command" || button.action?.type === "callback") component.callbackDataKind = button.action.type;
245
+ }
246
+ if (button.reusable === true) component.reusable = true;
247
+ return component;
248
+ }
249
+ function appendDiscordSelectBlock(blocks, block) {
250
+ const options = [];
251
+ let callbackDataKind;
252
+ for (const option of block.options) {
253
+ const value = resolveMessagePresentationActionValue(resolveMessagePresentationOptionAction(option));
254
+ if (!value) continue;
255
+ const kind = option.action?.type;
256
+ if (kind !== void 0 && kind !== "command" && kind !== "callback" || options.length > 0 && callbackDataKind !== kind) return;
257
+ callbackDataKind = kind;
258
+ options.push({
259
+ label: option.label,
260
+ value
261
+ });
262
+ }
263
+ if (options.length === 0) return;
264
+ blocks.push({
265
+ type: "actions",
266
+ select: {
267
+ type: "string",
268
+ placeholder: block.placeholder,
269
+ options,
270
+ callbackDataKind
271
+ }
272
+ });
273
+ }
274
+ /**
275
+ * @deprecated Use buildDiscordPresentationComponents with MessagePresentation.
276
+ */
277
+ function buildDiscordInteractiveComponents(interactive, options = {}) {
278
+ return buildDiscordPresentationComponents(interactive ? legacyInteractiveReplyToPresentation(interactive) : void 0, options);
279
+ }
280
+ function buildDiscordPresentationComponents(presentation, options = {}) {
281
+ if (!presentation) return;
282
+ const blocks = [];
283
+ if (presentation.title) blocks.push({
284
+ type: "text",
285
+ text: presentation.title
286
+ });
287
+ for (const block of presentation.blocks) {
288
+ if (block.type === "text" || block.type === "context") {
289
+ const text = block.text;
290
+ if (text) blocks.push({
291
+ type: "text",
292
+ text: block.type === "context" ? `-# ${text}` : text
293
+ });
294
+ continue;
295
+ }
296
+ if (block.type === "divider") {
297
+ blocks.push({ type: "separator" });
298
+ continue;
299
+ }
300
+ if (block.type === "buttons") {
301
+ const components = block.buttons.flatMap((button) => {
302
+ const component = buildDiscordButtonComponent(button, options);
303
+ return component ? [component] : [];
304
+ });
305
+ for (let index = 0; index < components.length; index += DISCORD_INTERACTIVE_BUTTON_ROW_SIZE) blocks.push({
306
+ type: "actions",
307
+ buttons: components.slice(index, index + DISCORD_INTERACTIVE_BUTTON_ROW_SIZE)
308
+ });
309
+ continue;
310
+ }
311
+ if (block.type === "select") appendDiscordSelectBlock(blocks, block);
312
+ }
313
+ return blocks.length ? { blocks } : void 0;
314
+ }
315
+ //#endregion
316
+ export { parseDiscordModalCustomId as _, DISCORD_APPROVAL_DECISIONS as a, encodeCustomIdComponent as b, DISCORD_COMPONENT_CUSTOM_ID_KEY as c, buildDiscordComponentCustomId as d, buildDiscordModalCustomId as f, parseDiscordComponentCustomIdForInteraction as g, parseDiscordComponentCustomId as h, parseDiscordQuestionData as i, DISCORD_MODAL_CUSTOM_ID_KEY as l, parseDiscordActivityCustomIdForInteraction as m, buildDiscordPresentationComponents as n, buildExecApprovalCustomId as o, parseDiscordActivityCustomId as p, shared_interactive_exports as r, parseExecApprovalData as s, buildDiscordInteractiveComponents as t, buildDiscordActivityCustomId as u, parseDiscordModalCustomIdForInteraction as v, decodeCustomIdComponent as y };