@openclaw/discord 2026.10.10 → 2026.11.5-beta.1

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 (217) hide show
  1. package/dist/.setup/{account-inspect-X_Xlr42B.mjs → account-inspect-CSz5Qodj.mjs} +1 -1
  2. package/dist/.setup/{accounts-C18HNgge.mjs → accounts-DtjvhJUj.mjs} +9 -6
  3. package/dist/.setup/{active-turn-thread-route-BAc_Xik-.mjs → active-turn-thread-route-DkPnk2x8.mjs} +1 -2
  4. package/dist/.setup/{allow-list-D1ZGfhXh.mjs → allow-list-DahA0Jxh.mjs} +3 -150
  5. package/dist/.setup/{api-Bth1wKF9.mjs → api-Bp0HI4q3.mjs} +10 -20
  6. package/dist/.setup/{approval-handler.runtime-BAoEELJJ.mjs → approval-handler.runtime-Cy53ugTf.mjs} +80 -61
  7. package/dist/.setup/{approval-message-updates-Cks-MSCJ.mjs → approval-message-updates-DqOXxPss.mjs} +2 -2
  8. package/dist/.setup/{audit-Dw_rAZIz.mjs → audit-DoPKOfQE.mjs} +4 -4
  9. package/dist/.setup/{channel-BMpMAeQL.mjs → channel-Ds6iuNdy.mjs} +134 -201
  10. package/dist/.setup/channel-access-DhJhVrdZ.mjs +23 -0
  11. package/dist/.setup/channel.setup-BLt9dkIG.mjs +235 -0
  12. package/dist/.setup/{components-BvOWSPxr.mjs → components-WTfUxead.mjs} +208 -426
  13. package/dist/.setup/components.base-C5sAPHe4.mjs +31 -0
  14. package/dist/.setup/{config-schema-Coyq5wOr.mjs → config-schema-GX2yDgIH.mjs} +6 -7
  15. package/dist/.setup/{conversation-binding-route-DOPUZNYo.mjs → conversation-binding-route-CZdm-X5A.mjs} +2 -2
  16. package/dist/.setup/{directory-config-CIqVnQtn.mjs → directory-config-BXJuh9-J.mjs} +1 -1
  17. package/dist/.setup/{directory-live-DUuPEWub.mjs → directory-live-CEopeb8Q.mjs} +55 -62
  18. package/dist/.setup/{discord-eFlHX1Gn.mjs → discord-r79VFjJp.mjs} +1087 -1664
  19. package/dist/.setup/{doctor-Dty_Ossy.mjs → doctor-UfLW8nye.mjs} +3 -5
  20. package/dist/.setup/endpoint-runtime-BM3x-m6O.mjs +138 -0
  21. package/dist/.setup/guilds-DQucP5Tn.mjs +21 -0
  22. package/dist/.setup/{handle-action-DXY91jF-.mjs → handle-action-BarHOi-v.mjs} +15 -15
  23. package/dist/.setup/{handle-action.guild-admin-BvBCfhXF.mjs → handle-action.guild-admin-oRUb8p_O.mjs} +5 -5
  24. package/dist/.setup/listeners-CHgTENFu.mjs +46 -0
  25. package/dist/.setup/{live-policy-config-DO1Fk2hp.mjs → live-policy-config-EKp4O6zx.mjs} +2 -3
  26. package/dist/.setup/{message-handler-fL1j1NiR.mjs → message-handler-DUeT8Asf.mjs} +154 -113
  27. package/dist/.setup/{message-handler.preflight-DkjwNZAd.mjs → message-handler.preflight-C6TNtKW0.mjs} +30 -104
  28. package/dist/.setup/{message-handler.preflight-pluralkit-DR4BnvMU.mjs → message-handler.preflight-pluralkit-6E9TFmmN.mjs} +9 -22
  29. package/dist/.setup/{message-handler.process-ClOwIPDK.mjs → message-handler.process-D8_oQ5Cp.mjs} +256 -367
  30. package/dist/.setup/outbound-payload-DUsrFICb.mjs +445 -0
  31. package/dist/.setup/{outbound-session-route-TFBPPkoz.mjs → outbound-session-route-Cb8cv4Oi.mjs} +138 -86
  32. package/dist/.setup/{preflight-audio-CwtPIsvk.mjs → preflight-audio-r4BbaJxh.mjs} +1 -5
  33. package/dist/.setup/{presence-cache-CgutE4NN.mjs → presence-cache-B3xj3b0l.mjs} +1 -6
  34. package/dist/.setup/{probe-DNge7OEP.mjs → probe-BUmJyH35.mjs} +5 -9
  35. package/dist/.setup/{provider-BBDuE14w.mjs → provider-Dm2ERSxe.mjs} +3600 -4454
  36. package/dist/.setup/{provider-session.runtime-D8hMXXqJ.mjs → provider-session.runtime-DCIqDsIg.mjs} +3 -3
  37. package/dist/.setup/provider.runtime-DmxPGoUg.mjs +1 -0
  38. package/dist/.setup/proxy-fetch-B8cK6FLQ.mjs +29 -0
  39. package/dist/.setup/{realtime-session.runtime-cetognkp.mjs → realtime-session.runtime-WJL6NdwK.mjs} +43 -81
  40. package/dist/.setup/{receive-recovery-C77CVdGM.mjs → receive-recovery-DV_v5ROf.mjs} +13 -27
  41. package/dist/.setup/{resolve-allowlist-common-CI77288n.mjs → resolve-allowlist-common-C37fgnYG.mjs} +3 -12
  42. package/dist/.setup/{resolve-channels-DYc6-xgV.mjs → resolve-channels-CwpnQ7C2.mjs} +5 -4
  43. package/dist/.setup/{resolve-users-BQT7XWF2.mjs → resolve-users-D6jSwe8R.mjs} +4 -7
  44. package/dist/.setup/{runtime-CcijhTJT.mjs → runtime-B-PgPsGR.mjs} +6 -6
  45. package/dist/.setup/{runtime-CI0UJqeS.mjs → runtime-DhOMlnYS.mjs} +196 -235
  46. package/dist/.setup/{secret-config-contract-BdbCvqnM.mjs → secret-config-contract-CP6teHec.mjs} +4 -9
  47. package/dist/.setup/{send-Cbq-IVsS.mjs → send-DnLL6XoO.mjs} +149 -174
  48. package/dist/.setup/{send.components-BV6ucNpJ.mjs → send.components-xB43CksK.mjs} +61 -71
  49. package/dist/.setup/{send.outbound-CGhBhzjQ.mjs → send.outbound-B11X6TOE.mjs} +75 -129
  50. package/dist/.setup/{send.receipt-Dw-_r5Bx.mjs → send.receipt-CMteCIZS.mjs} +29 -31
  51. package/dist/.setup/{send.shared-D4MioxW_.mjs → send.shared-BcLLZBul.mjs} +38 -112
  52. package/dist/.setup/{sender-identity-DrN5c4ec.mjs → sender-identity-CGNpdJmb.mjs} +3 -9
  53. package/dist/.setup/setup-plugin-api-C6AMx3hu.mjs +2 -0
  54. package/dist/.setup/{shared-Bp0sxD5R.mjs → shared-BEYw16he.mjs} +8 -10
  55. package/dist/.setup/shared-interactive-DKBw4SNV.mjs +311 -0
  56. package/dist/.setup/{subagent-hooks-mQbDkvuD.mjs → subagent-hooks-DlYElpXa.mjs} +1 -1
  57. package/dist/.setup/{system-events-2zc2eGfF.mjs → system-events--Pk6y9aP.mjs} +2 -2
  58. package/dist/.setup/{target-resolver-CAHeVfmZ.mjs → target-resolver-Bo9EpGp_.mjs} +3 -3
  59. package/dist/.setup/{thread-bindings-Dg7X_ZXP.mjs → thread-bindings-BF-hr-bg.mjs} +12 -20
  60. package/dist/.setup/{thread-bindings.manager-DCDYksah.mjs → thread-bindings.manager-CQCkha5r.mjs} +22 -42
  61. package/dist/.setup/{thread-bindings.session-updates-C76plLS3.mjs → thread-bindings.session-updates-C2gJAj_I.mjs} +11 -18
  62. package/dist/.setup/{threading-l0UfrE6x.mjs → threading-HA9C2wYR.mjs} +68 -104
  63. package/dist/.setup/{timeouts-DTrUsJ_W.mjs → timeouts-CT9hnmo4.mjs} +1 -1
  64. package/dist/.setup/{transcripts-source-CGgOaWcu.mjs → transcripts-source-DzpzETZR.mjs} +102 -172
  65. package/dist/.setup/{voice-runtime-DY1EwDfi.mjs → voice-runtime-Bo_nsVvX.mjs} +231 -448
  66. package/dist/.source-module-urls/d6c089460280c5a04184542d6712e04545caeb1ebb290d3504377b4cc5e22fea.json +1 -1
  67. package/dist/account-inspect-api.js +1 -1
  68. package/dist/action-runtime-api.js +1 -1
  69. package/dist/activities-api.js +285 -337
  70. package/dist/api.js +16 -16
  71. package/dist/assets/embedded-app-sdk.mjs +1 -1
  72. package/dist/channel-config-api.js +1 -1
  73. package/dist/channel-plugin-api.js +1 -1
  74. package/dist/directory-contract-api.js +1 -1
  75. package/dist/runtime-api.js +22 -22
  76. package/dist/secret-contract-api.js +1 -1
  77. package/dist/setup-entry.js +1 -1
  78. package/dist/setup-plugin-api.js +1 -1
  79. package/dist/src/voice/audio-worker.runtime.js +56 -68
  80. package/dist/subagent-hooks-api.js +1 -1
  81. package/dist/transcripts-source-api.js +1 -1
  82. package/node_modules/@discord/embedded-app-sdk/output/lib/zod/lib/index.cjs +2 -3
  83. package/node_modules/@discord/embedded-app-sdk/output/lib/zod/lib/index.mjs +2 -3
  84. package/node_modules/@napi-rs/wasm-runtime/dist/fs.js +3339 -4021
  85. package/node_modules/@napi-rs/wasm-runtime/package.json +1 -1
  86. package/node_modules/@types/lodash/README.md +1 -1
  87. package/node_modules/@types/lodash/common/function.d.ts +2 -2
  88. package/node_modules/@types/lodash/package.json +2 -2
  89. package/node_modules/@types/node/README.md +1 -1
  90. package/node_modules/@types/node/package.json +2 -2
  91. package/node_modules/@types/node/util.d.ts +6 -3
  92. package/node_modules/discord-api-types/package.json +4 -4
  93. package/node_modules/discord-api-types/rest/v10/index.d.ts +8 -0
  94. package/node_modules/discord-api-types/rest/v10/index.d.ts.map +1 -1
  95. package/node_modules/discord-api-types/rest/v10/index.js +8 -0
  96. package/node_modules/discord-api-types/rest/v10/index.js.map +1 -1
  97. package/node_modules/discord-api-types/rest/v10/oauth2.d.ts +26 -2
  98. package/node_modules/discord-api-types/rest/v10/oauth2.d.ts.map +1 -1
  99. package/node_modules/discord-api-types/rest/v9/index.d.ts +8 -0
  100. package/node_modules/discord-api-types/rest/v9/index.d.ts.map +1 -1
  101. package/node_modules/discord-api-types/rest/v9/index.js +8 -0
  102. package/node_modules/discord-api-types/rest/v9/index.js.map +1 -1
  103. package/node_modules/discord-api-types/rest/v9/oauth2.d.ts +26 -2
  104. package/node_modules/discord-api-types/rest/v9/oauth2.d.ts.map +1 -1
  105. package/node_modules/typebox/build/format/duration.d.mts +2 -2
  106. package/node_modules/typebox/build/format/duration.mjs +2 -2
  107. package/node_modules/typebox/build/format/idn_email.d.mts +1 -0
  108. package/node_modules/typebox/build/format/idn_email.mjs +1 -0
  109. package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -1
  110. package/node_modules/typebox/build/format/idn_hostname.mjs +1 -1
  111. package/node_modules/typebox/build/format/ipv4.d.mts +2 -2
  112. package/node_modules/typebox/build/format/ipv4.mjs +2 -2
  113. package/node_modules/typebox/build/format/ipv6.d.mts +1 -1
  114. package/node_modules/typebox/build/format/ipv6.mjs +1 -1
  115. package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
  116. package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
  117. package/node_modules/typebox/build/schema/build.mjs +1 -0
  118. package/node_modules/typebox/build/schema/engine/_unique.d.mts +4 -2
  119. package/node_modules/typebox/build/schema/engine/_unique.mjs +7 -3
  120. package/node_modules/typebox/build/schema/engine/additionalItems.mjs +3 -3
  121. package/node_modules/typebox/build/schema/engine/additionalProperties.d.mts +0 -3
  122. package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +15 -17
  123. package/node_modules/typebox/build/schema/engine/contains.mjs +3 -3
  124. package/node_modules/typebox/build/schema/engine/index.d.mts +1 -0
  125. package/node_modules/typebox/build/schema/engine/index.mjs +1 -0
  126. package/node_modules/typebox/build/schema/engine/items.mjs +7 -4
  127. package/node_modules/typebox/build/schema/engine/maxContains.mjs +2 -2
  128. package/node_modules/typebox/build/schema/engine/minContains.mjs +3 -3
  129. package/node_modules/typebox/build/schema/engine/oneOf.mjs +2 -2
  130. package/node_modules/typebox/build/schema/engine/patternProperties.mjs +2 -2
  131. package/node_modules/typebox/build/schema/engine/propertyNames.mjs +2 -2
  132. package/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs +2 -2
  133. package/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs +2 -2
  134. package/node_modules/typebox/build/system/hashing/hash.mjs +63 -34
  135. package/node_modules/typebox/build/system/locale/en_US.mjs +2 -1
  136. package/node_modules/typebox/build/system/memory/assign.d.mts +2 -8
  137. package/node_modules/typebox/build/system/memory/assign.mjs +13 -6
  138. package/node_modules/typebox/build/system/memory/clone.d.mts +4 -5
  139. package/node_modules/typebox/build/system/memory/clone.mjs +8 -96
  140. package/node_modules/typebox/build/system/memory/create.d.mts +1 -5
  141. package/node_modules/typebox/build/system/memory/create.mjs +18 -13
  142. package/node_modules/typebox/build/system/memory/deep.d.mts +2 -0
  143. package/node_modules/typebox/build/system/memory/deep.mjs +108 -0
  144. package/node_modules/typebox/build/system/memory/discard.d.mts +1 -1
  145. package/node_modules/typebox/build/system/memory/discard.mjs +9 -8
  146. package/node_modules/typebox/build/system/memory/finalize.d.mts +4 -0
  147. package/node_modules/typebox/build/system/memory/finalize.mjs +30 -0
  148. package/node_modules/typebox/build/system/memory/keys.d.mts +2 -0
  149. package/node_modules/typebox/build/system/memory/keys.mjs +8 -0
  150. package/node_modules/typebox/build/system/memory/update.d.mts +1 -4
  151. package/node_modules/typebox/build/system/memory/update.mjs +43 -16
  152. package/node_modules/typebox/build/type/engine/call/index.d.mts +1 -0
  153. package/node_modules/typebox/build/type/engine/call/index.mjs +1 -0
  154. package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +2 -24
  155. package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +2 -29
  156. package/node_modules/typebox/build/type/engine/evaluate/index.d.mts +1 -0
  157. package/node_modules/typebox/build/type/engine/evaluate/index.mjs +1 -0
  158. package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +5 -1
  159. package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +6 -1
  160. package/node_modules/typebox/build/type/engine/evaluate/property.d.mts +30 -0
  161. package/node_modules/typebox/build/type/engine/evaluate/property.mjs +29 -0
  162. package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +1 -3
  163. package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +1 -4
  164. package/node_modules/typebox/build/type/engine/object/from_intersect.d.mts +2 -2
  165. package/node_modules/typebox/build/type/engine/object/from_intersect.mjs +2 -2
  166. package/node_modules/typebox/build/type/engine/object/from_union.d.mts +2 -2
  167. package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
  168. package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +1 -3
  169. package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +1 -4
  170. package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +1 -3
  171. package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +1 -4
  172. package/node_modules/typebox/build/type/engine/this/index.d.mts +1 -0
  173. package/node_modules/typebox/build/type/engine/this/index.mjs +1 -0
  174. package/node_modules/typebox/build/value/clone/clone.d.mts +4 -3
  175. package/node_modules/typebox/build/value/clone/clone.mjs +5 -7
  176. package/node_modules/typebox/build/value/repair/from_cyclic.d.mts +2 -0
  177. package/node_modules/typebox/build/value/repair/from_cyclic.mjs +6 -0
  178. package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +25 -14
  179. package/node_modules/typebox/package.json +1 -1
  180. package/node_modules/typebox/readme.md +1 -1
  181. package/node_modules/undici/docs/docs/api/Interceptors.md +15 -2
  182. package/node_modules/undici/lib/dispatcher/client-h2.js +78 -3
  183. package/node_modules/undici/lib/dispatcher/pool-base.js +20 -3
  184. package/node_modules/undici/package.json +3 -3
  185. package/node_modules/undici/types/api.d.ts +1 -1
  186. package/node_modules/undici/types/utility.d.ts +4 -4
  187. package/node_modules/uuid/package.json +17 -17
  188. package/node_modules/zod/package.json +1 -1
  189. package/node_modules/zod/src/v4/classic/tests/array.test.ts +27 -0
  190. package/node_modules/zod/src/v4/classic/tests/map.test.ts +7 -0
  191. package/node_modules/zod/src/v4/classic/tests/set.test.ts +6 -0
  192. package/node_modules/zod/src/v4/core/compile.ts +9 -0
  193. package/node_modules/zod/src/v4/core/schemas.ts +35 -1
  194. package/node_modules/zod/src/v4/core/util.ts +13 -0
  195. package/node_modules/zod/src/v4/core/versions.ts +1 -1
  196. package/node_modules/zod/v4/core/compile.cjs +8 -0
  197. package/node_modules/zod/v4/core/compile.js +8 -0
  198. package/node_modules/zod/v4/core/schemas.cjs +30 -0
  199. package/node_modules/zod/v4/core/schemas.d.cts +3 -1
  200. package/node_modules/zod/v4/core/schemas.d.ts +3 -1
  201. package/node_modules/zod/v4/core/schemas.js +30 -0
  202. package/node_modules/zod/v4/core/util.cjs +15 -0
  203. package/node_modules/zod/v4/core/util.d.cts +2 -0
  204. package/node_modules/zod/v4/core/util.d.ts +2 -0
  205. package/node_modules/zod/v4/core/util.js +14 -0
  206. package/node_modules/zod/v4/core/versions.cjs +1 -1
  207. package/node_modules/zod/v4/core/versions.js +1 -1
  208. package/openclaw.plugin.json +1 -31
  209. package/package.json +8 -8
  210. package/dist/.setup/channel-access-BPrWoEXM.mjs +0 -47
  211. package/dist/.setup/channel.setup-DVe7Y3Jf.mjs +0 -245
  212. package/dist/.setup/outbound-adapter-DWyAWBFh.mjs +0 -537
  213. package/dist/.setup/provider.runtime-BQ1z4Aq1.mjs +0 -1
  214. package/dist/.setup/setup-plugin-api-B4J6wmL1.mjs +0 -2
  215. package/dist/.setup/targets-BaklhOqq.mjs +0 -3
  216. package/node_modules/typebox/build/system/memory/freeze.d.mts +0 -4
  217. 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-C18HNgge.mjs";
2
- import { A as isDiscordThreadChannelType } from "./allow-list-D1ZGfhXh.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-eFlHX1Gn.mjs";
4
- import { h as createDiscordRetryRunner, o as resolveDiscordReplyMessageId, v as chunkDiscordTextWithMode } from "./send.receipt-Dw-_r5Bx.mjs";
5
- import { t as parseAndResolveDiscordTarget } from "./target-resolver-CAHeVfmZ.mjs";
6
- import { danger } from "openclaw/plugin-sdk/runtime-env";
1
+ import { h as normalizeDiscordToken, l as resolveDiscordAccount, s as mergeDiscordAccountConfig } from "./accounts-DtjvhJUj.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-r79VFjJp.mjs";
3
+ import { w as isDiscordThreadChannelType } from "./allow-list-DahA0Jxh.mjs";
4
+ import { d as resolveDiscordReplyMessageId, h as createDiscordRetryRunner, v as chunkDiscordTextWithMode } from "./send.receipt-CMteCIZS.mjs";
5
+ import { t as resolveDiscordProxyFetchForAccount } from "./proxy-fetch-B8cK6FLQ.mjs";
6
+ import { t as parseAndResolveDiscordTarget } from "./target-resolver-Bo9EpGp_.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
  // extensions/discord/src/monitor/gateway-registry.ts
18
17
  /**
@@ -35,37 +34,6 @@ function getGateway(accountId) {
35
34
  function clearGateways() {
36
35
  gatewayRegistry.clear();
37
36
  }
38
- // extensions/discord/src/proxy-fetch.ts
39
- function resolveDiscordProxyFetchForAccount(account, cfg, runtime) {
40
- return withValidatedDiscordProxy(normalizeOptionalString(account.config.proxy) ?? normalizeOptionalString(cfg?.channels?.discord?.proxy), runtime, makeProxyFetch);
41
- }
42
- function withValidatedDiscordProxy(proxyUrl, runtime, createValue) {
43
- const proxy = proxyUrl?.trim();
44
- if (!proxy) return;
45
- try {
46
- validateDiscordProxyUrl(proxy);
47
- return createValue(proxy);
48
- } catch (err) {
49
- runtime?.error?.(danger(`discord: invalid rest proxy: ${String(err)}`));
50
- return;
51
- }
52
- }
53
- function validateDiscordProxyUrl(proxyUrl) {
54
- let parsed;
55
- try {
56
- parsed = new URL(proxyUrl);
57
- } catch {
58
- throw new Error("Proxy URL must be a valid http or https URL");
59
- }
60
- if (!["http:", "https:"].includes(parsed.protocol)) throw new Error("Proxy URL must use http or https");
61
- if (!parsed.hostname) throw new Error("Proxy URL must include a host");
62
- return proxyUrl;
63
- }
64
- // extensions/discord/src/proxy-request-client.ts
65
- const DISCORD_REST_TIMEOUT_MS = 15e3;
66
- function createDiscordRequestClient(token, options) {
67
- return new RequestClient(token, options);
68
- }
69
37
  // extensions/discord/src/client.ts
70
38
  function createDiscordRuntimeAccountContext(params) {
71
39
  return {
@@ -73,7 +41,7 @@ function createDiscordRuntimeAccountContext(params) {
73
41
  accountId: normalizeAccountId(params.accountId)
74
42
  };
75
43
  }
76
- function resolveDiscordClientAccountContext(opts, runtime) {
44
+ function resolveDiscordClientAccountContext(opts) {
77
45
  const resolvedCfg = requireRuntimeConfig(opts.cfg, "Discord client");
78
46
  const accountId = normalizeAccountId(opts.accountId);
79
47
  const config = mergeDiscordAccountConfig(resolvedCfg, accountId);
@@ -89,7 +57,7 @@ function resolveDiscordClientAccountContext(opts, runtime) {
89
57
  return {
90
58
  cfg: resolvedCfg,
91
59
  account,
92
- proxyFetch: resolveDiscordProxyFetchForAccount(account, resolvedCfg, runtime)
60
+ proxyFetch: resolveDiscordProxyFetchForAccount(account, resolvedCfg)
93
61
  };
94
62
  }
95
63
  function resolveToken(account) {
@@ -118,7 +86,7 @@ function createDiscordRestClient(opts) {
118
86
  const proxyFetch = proxyContext.proxyFetch ?? resolveDiscordProxyFetchForAccount(account, resolvedCfg);
119
87
  return {
120
88
  token,
121
- rest: createDiscordRequestClient(token, {
89
+ rest: new RequestClient(token, {
122
90
  ...proxyFetch ? { fetch: proxyFetch } : {},
123
91
  ...signal ? { signal } : {},
124
92
  ...timeoutMs !== void 0 ? { timeout: timeoutMs } : {}
@@ -150,33 +118,6 @@ function createDiscordClient(opts) {
150
118
  function resolveDiscordRest(opts) {
151
119
  return createDiscordRestClient(opts).rest;
152
120
  }
153
- // extensions/discord/src/recipient-resolution.ts
154
- async function parseAndResolveRecipient(raw, cfg, accountId, parseOptions = {}) {
155
- const resolvedCfg = requireRuntimeConfig(cfg, "Discord recipient resolution");
156
- const accountInfo = resolveDiscordAccount({
157
- cfg: resolvedCfg,
158
- accountId
159
- });
160
- const resolved = await parseAndResolveDiscordTarget(raw, {
161
- cfg: resolvedCfg,
162
- accountId: accountInfo.accountId
163
- }, parseOptions);
164
- return {
165
- kind: resolved.kind,
166
- id: resolved.id
167
- };
168
- }
169
- async function parseAndResolveChannelRecipient(raw, cfg, accountId) {
170
- const resolvedCfg = requireRuntimeConfig(cfg, "Discord recipient resolution");
171
- const resolved = await parseAndResolveDiscordTarget(raw, {
172
- cfg: resolvedCfg,
173
- accountId
174
- }, { defaultKind: "channel" });
175
- return {
176
- kind: resolved.kind,
177
- id: resolved.id
178
- };
179
- }
180
121
  // extensions/discord/src/send.message-request.ts
181
122
  const SUPPRESS_EMBEDS_FLAG = MessageFlags.SuppressEmbeds;
182
123
  const SUPPRESS_NOTIFICATIONS_FLAG = MessageFlags.SuppressNotifications;
@@ -244,9 +185,8 @@ async function fetchBotUserId(rest) {
244
185
  return me.id;
245
186
  }
246
187
  function resolveMemberGuildPermissionBits(params) {
247
- const rolesByIdLocal = rolesById(params.guild);
248
- let permissions = addPermissionBits(0n, rolesByIdLocal.get(params.guild.id)?.permissions);
249
- for (const roleId of params.member.roles ?? []) permissions = addPermissionBits(permissions, rolesByIdLocal.get(roleId)?.permissions);
188
+ let permissions = addPermissionBits(0n, params.roles.get(params.guildId)?.permissions);
189
+ for (const roleId of params.member.roles ?? []) permissions = addPermissionBits(permissions, params.roles.get(roleId)?.permissions);
250
190
  return permissions;
251
191
  }
252
192
  function rolesById(guild) {
@@ -255,13 +195,13 @@ function rolesById(guild) {
255
195
  function rolePosition(role) {
256
196
  return typeof role?.position === "number" ? role.position : -1;
257
197
  }
258
- function highestMemberRolePosition(guild, member) {
259
- const roles = rolesById(guild);
198
+ function highestMemberRolePosition(roles, member) {
260
199
  return Math.max(...(member.roles ?? []).map((roleId) => rolePosition(roles.get(roleId))), 0);
261
200
  }
262
201
  function resolveMemberChannelPermissionBits(params) {
263
202
  let permissions = resolveMemberGuildPermissionBits({
264
- guild: params.guild,
203
+ guildId: params.guildId,
204
+ roles: rolesById(params.guild),
265
205
  member: params.member
266
206
  });
267
207
  if (hasAdministrator(permissions)) return ALL_PERMISSIONS;
@@ -298,7 +238,8 @@ async function fetchMemberGuildPermissionsDiscord(guildId, userId, opts) {
298
238
  const [guild, member] = await Promise.all([getGuild(rest, guildId), getGuildMember(rest, guildId, userId)]);
299
239
  if (guild.owner_id === userId) return ALL_PERMISSIONS;
300
240
  return resolveMemberGuildPermissionBits({
301
- guild,
241
+ guildId,
242
+ roles: rolesById(guild),
302
243
  member
303
244
  });
304
245
  } catch {
@@ -351,17 +292,19 @@ async function canManageGuildMemberRoleDiscord(guildId, senderUserId, targetUser
351
292
  ]);
352
293
  if (guild.owner_id === senderUserId) return true;
353
294
  if (guild.owner_id === targetUserId) return false;
354
- const targetRole = rolesById(guild).get(roleId);
295
+ const roles = rolesById(guild);
296
+ const targetRole = roles.get(roleId);
355
297
  const targetRolePosition = rolePosition(targetRole);
356
298
  if (targetRolePosition < 0) return false;
357
299
  const senderPermissions = resolveMemberGuildPermissionBits({
358
- guild,
300
+ guildId,
301
+ roles,
359
302
  member: senderMember
360
303
  });
361
304
  if (requirements?.assignablePermissionCeiling && !hasAdministrator(senderPermissions) && (BigInt(targetRole?.permissions ?? "0") & ~senderPermissions) !== 0n) return false;
362
- const senderHighestRolePosition = highestMemberRolePosition(guild, senderMember);
305
+ const senderHighestRolePosition = highestMemberRolePosition(roles, senderMember);
363
306
  if (senderHighestRolePosition <= targetRolePosition) return false;
364
- return senderHighestRolePosition > highestMemberRolePosition(guild, targetMember);
307
+ return senderHighestRolePosition > highestMemberRolePosition(roles, targetMember);
365
308
  } catch {
366
309
  return false;
367
310
  }
@@ -370,10 +313,11 @@ async function canManageGuildRoleDiscord(guildId, senderUserId, roleId, opts) {
370
313
  const rest = resolveDiscordRest(opts);
371
314
  try {
372
315
  const [guild, senderMember] = await Promise.all([getGuild(rest, guildId), getGuildMember(rest, guildId, senderUserId)]);
373
- const targetRole = rolesById(guild).get(roleId);
316
+ const roles = rolesById(guild);
317
+ const targetRole = roles.get(roleId);
374
318
  if (!targetRole) return null;
375
319
  if (guild.owner_id === senderUserId) return true;
376
- return highestMemberRolePosition(guild, senderMember) > rolePosition(targetRole);
320
+ return highestMemberRolePosition(roles, senderMember) > rolePosition(targetRole);
377
321
  } catch {
378
322
  return false;
379
323
  }
@@ -494,32 +438,16 @@ function normalizeDiscordPollInput(input) {
494
438
  layout_type: PollLayoutType.Default
495
439
  };
496
440
  }
497
- function readDiscordErrorNumber(value, finiteNumbers = false) {
498
- if (typeof value === "number") return !finiteNumbers || Number.isFinite(value) ? value : void 0;
499
- return typeof value === "string" && /^\d+$/.test(value) ? Number(value) : void 0;
500
- }
501
- function getDiscordErrorCode(err) {
502
- if (!err || typeof err !== "object") return;
503
- 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);
504
- }
505
- function getDiscordErrorStatus(err) {
506
- if (!err || typeof err !== "object") return;
507
- return readDiscordErrorNumber("status" in err && err.status !== void 0 ? err.status : "statusCode" in err && err.statusCode !== void 0 ? err.statusCode : void 0, true);
508
- }
509
441
  function isDiscordUploadTooLargeError(err) {
510
- return getDiscordErrorCode(err) === DISCORD_UPLOAD_TOO_LARGE || getDiscordErrorStatus(err) === DISCORD_UPLOAD_TOO_LARGE_STATUS;
442
+ return err instanceof DiscordError && (err.discordCode === DISCORD_UPLOAD_TOO_LARGE || err.status === DISCORD_UPLOAD_TOO_LARGE_STATUS);
511
443
  }
512
444
  function buildDiscordUploadTooLargeFallbackText(text) {
513
445
  return text.trim() ? `${text}\n\n[${DISCORD_UPLOAD_TOO_LARGE_NOTICE}]` : DISCORD_UPLOAD_TOO_LARGE_NOTICE;
514
446
  }
515
447
  async function buildDiscordSendError(err, ctx) {
516
- if (err instanceof DiscordSendError) return err;
517
- const code = getDiscordErrorCode(err);
518
- if (code === DISCORD_CANNOT_DM) return new DiscordSendError(`discord dm failed: user blocks dms or privacy settings disallow it (code=${code})`, {
519
- kind: "dm-blocked",
520
- discordCode: code,
521
- status: getDiscordErrorStatus(err)
522
- });
448
+ if (!(err instanceof DiscordError)) return err;
449
+ const code = err.discordCode;
450
+ if (code === DISCORD_CANNOT_DM) return new DiscordSendError(`discord dm failed: user blocks dms or privacy settings disallow it (code=${code})`, { status: err.status });
523
451
  if (code !== DISCORD_MISSING_PERMISSIONS) return err;
524
452
  let missing = [];
525
453
  let probedChannelType;
@@ -533,16 +461,10 @@ async function buildDiscordSendError(err, ctx) {
533
461
  const current = new Set(permissions.permissions);
534
462
  missing = resolveRequiredDiscordSendPermissions(probedChannelType, ctx.hasMedia).filter((permission) => !current.has(permission));
535
463
  } catch {}
536
- const status = getDiscordErrorStatus(err);
537
- const apiDetails = [`code=${code}`, status != null ? `status=${status}` : void 0].filter(Boolean).join(" ");
464
+ const status = err.status;
465
+ const apiDetails = `code=${code} status=${status}`;
538
466
  const probeSummary = resolveRequiredDiscordSendPermissions(probedChannelType, ctx.hasMedia).join("/");
539
- 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`, {
540
- kind: "missing-permissions",
541
- channelId: ctx.channelId,
542
- missingPermissions: missing,
543
- discordCode: code,
544
- status
545
- });
467
+ 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 });
546
468
  }
547
469
  async function resolveChannelId(rest, recipient, request) {
548
470
  if (recipient.kind === "channel") return { channelId: recipient.id };
@@ -554,7 +476,11 @@ async function resolveChannelId(rest, recipient, request) {
554
476
  };
555
477
  }
556
478
  async function resolveDiscordTargetChannelId(raw, opts) {
557
- const recipient = await parseAndResolveRecipient(raw, requireRuntimeConfig(opts.cfg, "Discord target channel resolution"), opts.accountId, { defaultKind: "channel" });
479
+ const cfg = requireRuntimeConfig(opts.cfg, "Discord target channel resolution");
480
+ const recipient = await parseAndResolveDiscordTarget(raw, {
481
+ cfg,
482
+ accountId: opts.accountId
483
+ }, { defaultKind: "channel" });
558
484
  const { rest, request } = createDiscordClient(opts);
559
485
  return await resolveChannelId(rest, recipient, request);
560
486
  }
@@ -654,4 +580,4 @@ function buildReactionIdentifier(emoji) {
654
580
  if (emoji.id && emoji.name) return `${emoji.name}:${emoji.id}`;
655
581
  return emoji.name ?? "";
656
582
  }
657
- 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 };
583
+ 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-D1ZGfhXh.mjs";
1
+ import { S as formatDiscordUserTag } from "./allow-list-DahA0Jxh.mjs";
2
2
  import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
3
3
  // 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-BLt9dkIG.mjs";
2
+ import "../setup-plugin-api.js";
@@ -1,10 +1,10 @@
1
- import { c as resolveDefaultDiscordAccountId, f as resolveDiscordAccountDisabledReason, i as listDiscordAccountIds, l as resolveDiscordAccount, p as resolveDiscordAccountDmPolicy, r as isDiscordAccountEnabledForRuntime, s as mergeDiscordAccountConfig, u as resolveDiscordAccountAllowFrom } from "./accounts-C18HNgge.mjs";
2
- import { t as inspectDiscordAccount } from "./account-inspect-X_Xlr42B.mjs";
1
+ import { c as resolveDefaultDiscordAccountId, f as resolveDiscordAccountDisabledReason, i as listDiscordAccountIds, l as resolveDiscordAccount, p as resolveDiscordAccountDmPolicy, r as isDiscordAccountEnabledForRuntime, s as mergeDiscordAccountConfig, u as resolveDiscordAccountAllowFrom } from "./accounts-DtjvhJUj.mjs";
2
+ import { t as inspectDiscordAccount } from "./account-inspect-CSz5Qodj.mjs";
3
3
  import { t as parseDiscordTarget } from "./target-parsing-BiuhcK9Q.mjs";
4
- import { n as discordIngressIdentity, t as selectDiscordLivePolicyConfig } from "./live-policy-config-DO1Fk2hp.mjs";
5
- import { t as DiscordChannelConfigSchema } from "./config-schema-Coyq5wOr.mjs";
4
+ import { n as discordIngressIdentity, t as selectDiscordLivePolicyConfig } from "./live-policy-config-EKp4O6zx.mjs";
5
+ import { t as DiscordChannelConfigSchema } from "./config-schema-GX2yDgIH.mjs";
6
6
  import { n as normalizeCompatibilityConfig } from "./doctor-contract-Dstl3cMg.mjs";
7
- import { r as secretTargetRegistryEntries, t as collectRuntimeConfigAssignments } from "./secret-config-contract-BdbCvqnM.mjs";
7
+ import { r as secretTargetRegistryEntries, t as collectRuntimeConfigAssignments } from "./secret-config-contract-CP6teHec.mjs";
8
8
  import { n as unsupportedSecretRefSurfacePatterns, t as collectUnsupportedSecretRefConfigCandidates } from "./security-contract-D-o0iWDk.mjs";
9
9
  import { t as deriveLegacySessionChatType } from "./session-contract-Bq71MS78.mjs";
10
10
  import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
@@ -92,18 +92,16 @@ const discordSetupContract = defineChannelSetupContract({
92
92
  },
93
93
  legacyAdapter: discordSetupAdapter
94
94
  });
95
- // extensions/discord/src/doctor-shared.ts
96
- const DISCORD_LEGACY_CONFIG_RULES = [];
97
95
  // extensions/discord/src/shared.ts
98
96
  const DISCORD_CHANNEL = "discord";
99
97
  const livePolicyConfigPrefixes = Object.keys(selectDiscordLivePolicyConfig({})).flatMap((key) => [`channels.discord.${key}`, `channels.discord.accounts.*.${key}`]);
100
- const loadDiscordDoctorModule = createLazyRuntimeModule(() => import("./doctor-Dty_Ossy.mjs"));
98
+ const loadDiscordDoctorModule = createLazyRuntimeModule(() => import("./doctor-UfLW8nye.mjs"));
101
99
  const discordDoctor = {
102
100
  dmAllowFromMode: "topOnly",
103
101
  groupModel: "route",
104
102
  groupAllowFromFallbackToAllowFrom: false,
105
103
  warnOnEmptyGroupSenderAllowlist: false,
106
- legacyConfigRules: DISCORD_LEGACY_CONFIG_RULES,
104
+ legacyConfigRules: [],
107
105
  normalizeCompatibilityConfig,
108
106
  collectPreviewWarnings: async (params) => (await loadDiscordDoctorModule()).discordDoctor.collectPreviewWarnings?.(params) ?? [],
109
107
  collectMutableAllowlistWarnings: async (params) => (await loadDiscordDoctorModule()).discordDoctor.collectMutableAllowlistWarnings?.(params) ?? [],
@@ -223,4 +221,4 @@ function createDiscordPluginBase(params) {
223
221
  }
224
222
  };
225
223
  }
226
- export { discordSecurityAdapter as a, discordSetupContract as i, discordConfigAdapter as n, DISCORD_LEGACY_CONFIG_RULES as r, createDiscordPluginBase as t };
224
+ export { discordSecurityAdapter as i, discordConfigAdapter as n, discordSetupContract as r, createDiscordPluginBase as t };
@@ -0,0 +1,311 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.mjs";
2
+ import { i as parseCustomId } from "./components.base-C5sAPHe4.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
+ // 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
+ // extensions/discord/src/component-custom-id.ts
38
+ const DISCORD_COMPONENT_CUSTOM_ID_KEY = "occomp";
39
+ const DISCORD_MODAL_CUSTOM_ID_KEY = "ocmodal";
40
+ const DISCORD_ACTIVITY_CUSTOM_ID_KEY = "ocactivity";
41
+ const ENCODED_CUSTOM_ID_VERSION = "1";
42
+ const DISCORD_ACTIVITY_CUSTOM_ID_PREFIX = `${DISCORD_ACTIVITY_CUSTOM_ID_KEY}${ENCODED_CUSTOM_ID_VERSION}_`;
43
+ function isValidDiscordActivityWidgetId(widgetId) {
44
+ return /^[A-Za-z0-9_-]{22}$/.test(widgetId);
45
+ }
46
+ function buildDiscordActivityCustomId(widgetId) {
47
+ return `${DISCORD_ACTIVITY_CUSTOM_ID_PREFIX}${widgetId}`;
48
+ }
49
+ function parseDiscordActivityCustomId(id) {
50
+ if (id.startsWith(DISCORD_ACTIVITY_CUSTOM_ID_PREFIX)) {
51
+ const widgetId = id.slice(DISCORD_ACTIVITY_CUSTOM_ID_PREFIX.length);
52
+ return isValidDiscordActivityWidgetId(widgetId) ? { widgetId } : null;
53
+ }
54
+ const parsed = parseCustomId(id);
55
+ 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;
56
+ return { widgetId: parsed.data.wid };
57
+ }
58
+ function parseDiscordActivityCustomIdForInteraction(id) {
59
+ const parsed = parseDiscordActivityCustomId(id);
60
+ return parsed ? {
61
+ key: DISCORD_ACTIVITY_CUSTOM_ID_KEY,
62
+ data: { widgetId: parsed.widgetId }
63
+ } : parseCustomId(id);
64
+ }
65
+ function decodeParsedCustomIdData(data) {
66
+ if (data.e !== ENCODED_CUSTOM_ID_VERSION) return data;
67
+ return Object.fromEntries(Object.entries(data).map(([key, value]) => [key, typeof value === "string" ? unescapeCustomIdFieldValue(value) : value]));
68
+ }
69
+ function buildDiscordFieldCustomId(key, fields) {
70
+ const encoded = Object.values(fields).some(needsCustomIdFieldEscaping);
71
+ const parts = Object.entries(fields).map(([name, value]) => `${name}=${encoded ? escapeCustomIdFieldValue(value) : value}`);
72
+ return (encoded ? `${key}:e=${ENCODED_CUSTOM_ID_VERSION};` : `${key}:`) + parts.join(";");
73
+ }
74
+ function buildDiscordComponentCustomId(params) {
75
+ return buildDiscordFieldCustomId(DISCORD_COMPONENT_CUSTOM_ID_KEY, {
76
+ cid: params.componentId,
77
+ ...params.modalId ? { mid: params.modalId } : {}
78
+ });
79
+ }
80
+ function buildDiscordModalCustomId(modalId) {
81
+ return buildDiscordFieldCustomId(DISCORD_MODAL_CUSTOM_ID_KEY, { mid: modalId });
82
+ }
83
+ function parseDiscordComponentCustomId(id) {
84
+ const parsed = parseCustomId(id);
85
+ if (parsed.key !== "occomp") return null;
86
+ const data = decodeParsedCustomIdData(parsed.data);
87
+ const componentId = readNonBlankString(data.cid);
88
+ if (!componentId) return null;
89
+ return {
90
+ componentId,
91
+ modalId: readNonBlankString(data.mid)
92
+ };
93
+ }
94
+ function parseDiscordModalCustomId(id) {
95
+ const parsed = parseCustomId(id);
96
+ if (parsed.key !== "ocmodal") return null;
97
+ return readNonBlankString(decodeParsedCustomIdData(parsed.data).mid) ?? null;
98
+ }
99
+ function parseDiscordCustomIdForInteraction(id, key) {
100
+ if (id === "*" || /^__openclaw_discord_component_[a-z_]+_wildcard__$/.test(id)) return {
101
+ key: "*",
102
+ data: {}
103
+ };
104
+ const parsed = parseCustomId(id);
105
+ if (parsed.key !== key) return parsed;
106
+ return {
107
+ key: "*",
108
+ data: decodeParsedCustomIdData(parsed.data)
109
+ };
110
+ }
111
+ function parseDiscordComponentCustomIdForInteraction(id) {
112
+ return parseDiscordCustomIdForInteraction(id, DISCORD_COMPONENT_CUSTOM_ID_KEY);
113
+ }
114
+ function parseDiscordModalCustomIdForInteraction(id) {
115
+ return parseDiscordCustomIdForInteraction(id, DISCORD_MODAL_CUSTOM_ID_KEY);
116
+ }
117
+ // extensions/discord/src/approval-custom-id.ts
118
+ const DISCORD_APPROVAL_DECISIONS = {
119
+ "allow-once": {
120
+ label: "Allowed (once)",
121
+ color: "#57F287"
122
+ },
123
+ "allow-always": {
124
+ label: "Allowed (always)",
125
+ color: "#5865F2"
126
+ },
127
+ deny: {
128
+ label: "Denied",
129
+ color: "#ED4245"
130
+ }
131
+ };
132
+ const DISCORD_APPROVAL_CUSTOM_ID_MAX_CHARS = 100;
133
+ function encodeDiscordApprovalCustomId(action) {
134
+ return `execapproval:kind=${action.approvalKind};id=${encodeURIComponent(action.approvalId)};action=${action.decision}`;
135
+ }
136
+ function encodeBoundedDiscordApprovalCustomId(action) {
137
+ const exact = encodeDiscordApprovalCustomId(action);
138
+ if (exact.length <= DISCORD_APPROVAL_CUSTOM_ID_MAX_CHARS) return exact;
139
+ return encodeDiscordApprovalCustomId({
140
+ ...action,
141
+ approvalId: buildApprovalResolutionRef({
142
+ approvalId: action.approvalId,
143
+ approvalKind: action.approvalKind
144
+ })
145
+ });
146
+ }
147
+ function buildDiscordApprovalCustomId(action) {
148
+ 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;
149
+ return encodeBoundedDiscordApprovalCustomId(action);
150
+ }
151
+ function buildExecApprovalCustomId(approvalId, approvalKind, decision) {
152
+ return encodeBoundedDiscordApprovalCustomId({
153
+ type: "approval",
154
+ approvalId,
155
+ approvalKind,
156
+ decision
157
+ });
158
+ }
159
+ function parseExecApprovalData(data) {
160
+ if (!data || typeof data !== "object") return null;
161
+ const coerce = (value) => typeof value === "string" || typeof value === "number" ? String(value) : "";
162
+ const rawId = coerce(data.id);
163
+ const rawKind = coerce(data.kind);
164
+ const rawAction = coerce(data.action);
165
+ if (!rawId || rawKind !== "exec" && rawKind !== "plugin" && rawKind !== "system-agent") return null;
166
+ if (rawAction !== "allow-once" && rawAction !== "allow-always" && rawAction !== "deny") return null;
167
+ let approvalId;
168
+ try {
169
+ approvalId = decodeURIComponent(rawId);
170
+ } catch {
171
+ return null;
172
+ }
173
+ if (!approvalId) return null;
174
+ return {
175
+ approvalId,
176
+ approvalKind: rawKind,
177
+ action: rawAction
178
+ };
179
+ }
180
+ // extensions/discord/src/question-custom-id.ts
181
+ const QUESTION_RECORD_ID_PATTERN = /^ask_[a-f0-9]{32}$/u;
182
+ function buildDiscordQuestionCustomId(callback) {
183
+ if (!QUESTION_RECORD_ID_PATTERN.test(callback.questionId) || !Number.isInteger(callback.optionIndex) || callback.optionIndex < 0 || callback.optionIndex > 3) return;
184
+ return `ocq:id=${callback.questionId};i=${callback.optionIndex}`;
185
+ }
186
+ function parseDiscordQuestionData(data) {
187
+ const questionId = typeof data.id === "string" ? data.id : "";
188
+ const rawIndex = typeof data.i === "string" ? data.i : typeof data.i === "number" ? String(data.i) : "";
189
+ if (!QUESTION_RECORD_ID_PATTERN.test(questionId) || !/^[0-3]$/u.test(rawIndex)) return null;
190
+ return {
191
+ questionId,
192
+ optionIndex: Number(rawIndex)
193
+ };
194
+ }
195
+ // extensions/discord/src/shared-interactive.ts
196
+ var shared_interactive_exports = /* @__PURE__ */ __exportAll({
197
+ buildDiscordInteractiveComponents: () => buildDiscordInteractiveComponents,
198
+ buildDiscordPresentationComponents: () => buildDiscordPresentationComponents
199
+ });
200
+ const DISCORD_INTERACTIVE_BUTTON_ROW_SIZE = 5;
201
+ function buildDiscordButtonComponent(button, options) {
202
+ const action = resolveMessagePresentationButtonAction(button);
203
+ if (!action) return;
204
+ const component = {
205
+ label: button.label,
206
+ style: button.style ?? "secondary",
207
+ ...button.disabled === true ? { disabled: true } : {}
208
+ };
209
+ if (action.type === "approval") {
210
+ const internalCustomId = buildDiscordApprovalCustomId(action);
211
+ return internalCustomId ? {
212
+ ...component,
213
+ internalCustomId
214
+ } : void 0;
215
+ }
216
+ if (action.type === "question") {
217
+ if ("intent" in action) return;
218
+ const optionIndex = resolveAskUserQuestionOptionIndex({
219
+ questionOptionIndices: options.questionOptionIndices,
220
+ questionId: action.questionId,
221
+ optionValue: action.optionValue
222
+ });
223
+ if (optionIndex === void 0) return;
224
+ const internalCustomId = buildDiscordQuestionCustomId({
225
+ questionId: action.questionId,
226
+ optionIndex
227
+ });
228
+ return internalCustomId ? {
229
+ ...component,
230
+ internalCustomId
231
+ } : void 0;
232
+ }
233
+ if (action.type === "web-app" && action.widgetId && isValidDiscordActivityWidgetId(action.widgetId)) component.internalCustomId = buildDiscordActivityCustomId(action.widgetId);
234
+ else if (action.type === "url" || action.type === "web-app") {
235
+ if (action.type === "web-app" && !action.url) return;
236
+ component.style = "link";
237
+ component.url = action.url;
238
+ } else {
239
+ component.callbackData = action.type === "command" ? action.command : action.value;
240
+ if (button.action?.type === "command" || button.action?.type === "callback") component.callbackDataKind = button.action.type;
241
+ }
242
+ if (button.reusable === true) component.reusable = true;
243
+ return component;
244
+ }
245
+ function appendDiscordSelectBlock(blocks, block) {
246
+ const options = [];
247
+ let callbackDataKind;
248
+ for (const option of block.options) {
249
+ const value = resolveMessagePresentationActionValue(resolveMessagePresentationOptionAction(option));
250
+ if (!value) continue;
251
+ const kind = option.action?.type;
252
+ if (kind !== void 0 && kind !== "command" && kind !== "callback" || options.length > 0 && callbackDataKind !== kind) return;
253
+ callbackDataKind = kind;
254
+ options.push({
255
+ label: option.label,
256
+ value
257
+ });
258
+ }
259
+ if (options.length === 0) return;
260
+ blocks.push({
261
+ type: "actions",
262
+ select: {
263
+ type: "string",
264
+ placeholder: block.placeholder,
265
+ options,
266
+ callbackDataKind
267
+ }
268
+ });
269
+ }
270
+ /**
271
+ * @deprecated Use buildDiscordPresentationComponents with MessagePresentation.
272
+ */
273
+ function buildDiscordInteractiveComponents(interactive, options = {}) {
274
+ return buildDiscordPresentationComponents(interactive ? legacyInteractiveReplyToPresentation(interactive) : void 0, options);
275
+ }
276
+ function buildDiscordPresentationComponents(presentation, options = {}) {
277
+ if (!presentation) return;
278
+ const blocks = [];
279
+ if (presentation.title) blocks.push({
280
+ type: "text",
281
+ text: presentation.title
282
+ });
283
+ for (const block of presentation.blocks) {
284
+ if (block.type === "text" || block.type === "context") {
285
+ const text = block.text;
286
+ if (text) blocks.push({
287
+ type: "text",
288
+ text: block.type === "context" ? `-# ${text}` : text
289
+ });
290
+ continue;
291
+ }
292
+ if (block.type === "divider") {
293
+ blocks.push({ type: "separator" });
294
+ continue;
295
+ }
296
+ if (block.type === "buttons") {
297
+ const components = block.buttons.flatMap((button) => {
298
+ const component = buildDiscordButtonComponent(button, options);
299
+ return component ? [component] : [];
300
+ });
301
+ for (let index = 0; index < components.length; index += DISCORD_INTERACTIVE_BUTTON_ROW_SIZE) blocks.push({
302
+ type: "actions",
303
+ buttons: components.slice(index, index + DISCORD_INTERACTIVE_BUTTON_ROW_SIZE)
304
+ });
305
+ continue;
306
+ }
307
+ if (block.type === "select") appendDiscordSelectBlock(blocks, block);
308
+ }
309
+ return blocks.length ? { blocks } : void 0;
310
+ }
311
+ 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 };