@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,4 +1,4 @@
1
- import { i as listDiscordAccountIds, n as inspectDiscordAccountConfig, v as resolveDiscordAccountAvailability } from "./accounts-C18HNgge.mjs";
1
+ import { i as listDiscordAccountIds, n as inspectDiscordAccountConfig, v as resolveDiscordAccountAvailability } from "./accounts-DtjvhJUj.mjs";
2
2
  import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
3
3
  import { normalizeSecretInputString } from "openclaw/plugin-sdk/secret-input";
4
4
  // extensions/discord/src/account-inspect.ts
@@ -1,5 +1,5 @@
1
1
  import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
2
- import { hasConfiguredSecretInput, normalizeResolvedSecretInputString, normalizeSecretInputString, resolveSecretInputString } from "openclaw/plugin-sdk/secret-input";
2
+ import { normalizeResolvedSecretInputString, resolveSecretInputString } from "openclaw/plugin-sdk/secret-input";
3
3
  import { createAccountActionGate, createAccountListHelpers } from "openclaw/plugin-sdk/account-helpers";
4
4
  import { mapAllowFromEntries, normalizeChannelDmPolicy } from "openclaw/plugin-sdk/channel-config-helpers";
5
5
  import { resolveConfiguredFromCredentialStatuses } from "openclaw/plugin-sdk/channel-status";
@@ -8,13 +8,16 @@ import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runti
8
8
  import { getRuntimeConfigSnapshot, getRuntimeConfigSourceSnapshot, selectApplicableRuntimeConfig } from "openclaw/plugin-sdk/runtime-config-snapshot";
9
9
  // extensions/discord/src/account-token-inspect.ts
10
10
  function inspectDiscordConfiguredToken(value) {
11
- const normalized = normalizeSecretInputString(value);
12
- if (normalized || hasConfiguredSecretInput(value)) return {
13
- token: normalized ? normalized.replace(/^Bot\s+/i, "") : "",
11
+ const credential = resolveSecretInputString({
12
+ value,
13
+ path: "Discord token",
14
+ mode: "inspect"
15
+ });
16
+ return credential.status === "missing" ? null : {
17
+ token: credential.value?.replace(/^Bot\s+/i, "") ?? "",
14
18
  tokenSource: "config",
15
- tokenStatus: normalized ? "available" : "configured_unavailable"
19
+ tokenStatus: credential.status
16
20
  };
17
- return null;
18
21
  }
19
22
  function inspectDiscordAccountTokenState(params) {
20
23
  const configuredToken = inspectDiscordConfiguredToken(params.accountToken) ?? (params.hasAccountToken ? null : inspectDiscordConfiguredToken(params.channelToken));
@@ -18,14 +18,13 @@ async function notifyDiscordActiveTurnThreadCreated(params) {
18
18
  const sourceChannelId = normalizeOptionalString(params.sourceChannelId);
19
19
  const sourceMessageId = normalizeOptionalString(params.sourceMessageId);
20
20
  const route = key ? Array.from(activeRoutes.get(key) ?? []).find((candidate) => sourceChannelId === candidate.sourceChannelId && sourceMessageId === candidate.sourceMessageId && (!candidate.accountId || !params.accountId || candidate.accountId === params.accountId)) : void 0;
21
- if (!route || !threadId) return false;
21
+ if (!route || !threadId) return;
22
22
  route.adoptedThreadId = threadId;
23
23
  try {
24
24
  await route.onThreadAdopted(threadId);
25
25
  } catch (error) {
26
26
  route.onThreadAdoptionError?.(error);
27
27
  }
28
- return true;
29
28
  }
30
29
  function notifyDiscordActiveTurnThreadReplyDelivered(params) {
31
30
  const key = normalizeOptionalString(params.sessionKey ?? void 0);
@@ -1,149 +1,12 @@
1
1
  import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
2
2
  import { ChannelType } from "discord-api-types/v10";
3
- import { asFiniteNumberInRange, parseDateStringTimestampMs, parseStrictFiniteNumber } from "openclaw/plugin-sdk/number-runtime";
4
- import { readResponseWithLimit } from "openclaw/plugin-sdk/response-limit-runtime";
5
- import { fetchWithSsrFGuard, isBlockedHostnameOrIp, isLoopbackHost } from "openclaw/plugin-sdk/ssrf-runtime";
3
+ import { asFiniteNumberInRange, parseStrictFiniteNumber } from "openclaw/plugin-sdk/number-runtime";
6
4
  import { buildChannelKeyCandidates, normalizeChannelSlug, resolveChannelEntryMatchWithFallback, resolveChannelMatchConfig } from "openclaw/plugin-sdk/channel-targets";
7
5
  import { resolveAllowlistMatchByCandidates } from "openclaw/plugin-sdk/allow-from";
8
6
  // extensions/discord/src/channel-type.ts
9
7
  function isDiscordThreadChannelType(channelType) {
10
8
  return channelType === ChannelType.AnnouncementThread || channelType === ChannelType.PublicThread || channelType === ChannelType.PrivateThread;
11
9
  }
12
- // extensions/discord/src/endpoint-runtime.ts
13
- const DISCORD_ENDPOINT_RESPONSE_MAX_BYTES = 8388608;
14
- const DISCORD_API_URL_ENV = "DISCORD_API_URL";
15
- function parseHttpAnchor(value, label) {
16
- let url;
17
- try {
18
- url = new URL(value);
19
- } catch {
20
- throw new Error(`${label} must be a valid URL`);
21
- }
22
- if (url.protocol !== "https:" && !(url.protocol === "http:" && isLoopbackHost(url.hostname))) throw new Error(`${label} must use HTTPS or loopback HTTP`);
23
- if (url.username || url.password || url.hash) throw new Error(`${label} must not contain credentials or a fragment`);
24
- return url;
25
- }
26
- function normalizeRestApiBaseUrl(value) {
27
- const url = parseHttpAnchor(value, "Discord endpoint REST API base URL");
28
- if (url.search) throw new Error("Discord endpoint REST API base URL must not contain a query");
29
- url.pathname = url.pathname.replace(/\/+$/u, "") || "/";
30
- return url;
31
- }
32
- function resolveDescriptor(apiUrl) {
33
- const restApiBaseUrl = normalizeRestApiBaseUrl(apiUrl);
34
- const gatewayBotUrl = new URL(`${restApiBaseUrl.pathname.replace(/\/+$/u, "")}/gateway/bot`, restApiBaseUrl.origin);
35
- const gatewayOriginUrl = new URL(restApiBaseUrl.origin);
36
- gatewayOriginUrl.protocol = gatewayOriginUrl.protocol === "https:" ? "wss:" : "ws:";
37
- if (gatewayOriginUrl.protocol === "wss:" && isBlockedHostnameOrIp(gatewayOriginUrl.hostname)) throw new Error("Discord endpoint Gateway origin must not target a private/internal/special-use hostname or IP address");
38
- return Object.freeze({
39
- restApiBaseUrl: restApiBaseUrl.toString().replace(/\/$/u, ""),
40
- gatewayBotUrl: gatewayBotUrl.toString(),
41
- gatewayOrigin: gatewayOriginUrl.origin
42
- });
43
- }
44
- function isWithinRestApiBase(target, restApiBaseUrl) {
45
- if (target.origin !== restApiBaseUrl.origin) return false;
46
- const basePath = restApiBaseUrl.pathname.replace(/\/+$/u, "");
47
- return basePath === "" || target.pathname === basePath || target.pathname.startsWith(`${basePath}/`);
48
- }
49
- function assertEndpointHttpTarget(target, descriptor) {
50
- const restApiBaseUrl = new URL(descriptor.restApiBaseUrl);
51
- const gatewayBotUrl = new URL(descriptor.gatewayBotUrl);
52
- if (!isWithinRestApiBase(target, restApiBaseUrl) && target.toString() !== gatewayBotUrl.toString()) throw new Error("Discord endpoint request is outside the configured boundaries");
53
- }
54
- function requestInitFromRequest(request, signal) {
55
- return {
56
- method: request.method,
57
- headers: request.headers,
58
- ...request.body ? {
59
- body: request.body,
60
- duplex: "half"
61
- } : {},
62
- signal,
63
- cache: request.cache,
64
- credentials: request.credentials,
65
- integrity: request.integrity,
66
- keepalive: request.keepalive,
67
- mode: request.mode,
68
- referrer: request.referrer,
69
- referrerPolicy: request.referrerPolicy
70
- };
71
- }
72
- function createEndpointFetch(descriptor) {
73
- const allowedOrigins = Array.from(/* @__PURE__ */ new Set([new URL(descriptor.restApiBaseUrl).origin, new URL(descriptor.gatewayBotUrl).origin]));
74
- return async (input, init, beforeRequest) => {
75
- const request = new Request(input, init);
76
- const target = new URL(request.url);
77
- assertEndpointHttpTarget(target, descriptor);
78
- const guarded = await fetchWithSsrFGuard({
79
- url: target.toString(),
80
- init: requestInitFromRequest(request, request.signal),
81
- signal: request.signal,
82
- requireHttps: target.protocol === "https:",
83
- policy: { allowedOrigins },
84
- maxRedirects: 0,
85
- capture: false,
86
- auditContext: "discord.endpoint-runtime",
87
- beforeRequest
88
- });
89
- try {
90
- const body = await readResponseWithLimit(guarded.response, DISCORD_ENDPOINT_RESPONSE_MAX_BYTES, { onOverflow: ({ size, maxBytes }) => /* @__PURE__ */ new Error(`Discord endpoint response too large: ${size} bytes (limit: ${maxBytes} bytes)`) });
91
- return new Response(body.byteLength > 0 ? new Uint8Array(body) : null, {
92
- status: guarded.response.status,
93
- statusText: guarded.response.statusText,
94
- headers: guarded.response.headers
95
- });
96
- } finally {
97
- await guarded.release();
98
- }
99
- };
100
- }
101
- /** Resolve the process-wide Discord API override using the same env convention as sibling channels. */
102
- function getDiscordEndpointRuntime(env = process.env) {
103
- const apiUrl = env[DISCORD_API_URL_ENV]?.trim();
104
- if (!apiUrl) return;
105
- const descriptor = resolveDescriptor(apiUrl);
106
- return Object.freeze({
107
- descriptor,
108
- fetch: createEndpointFetch(descriptor)
109
- });
110
- }
111
- function resolveDiscordEndpointMediaGuard(url, retainedRuntime) {
112
- const guard = resolveEndpointResourceGuard(url, "media", retainedRuntime);
113
- return guard ? {
114
- maxRedirects: guard.maxRedirects,
115
- ssrfPolicy: guard.policy
116
- } : void 0;
117
- }
118
- function resolveDiscordEndpointAttachmentGuard(url, retainedRuntime) {
119
- return resolveEndpointResourceGuard(url, "attachment upload", retainedRuntime);
120
- }
121
- function resolveEndpointResourceGuard(url, kind, retainedRuntime) {
122
- if (retainedRuntime === null) return;
123
- const runtime = retainedRuntime ?? getDiscordEndpointRuntime();
124
- if (!runtime) return;
125
- const target = parseHttpAnchor(url, `Discord endpoint ${kind} URL`);
126
- const restOrigin = new URL(runtime.descriptor.restApiBaseUrl).origin;
127
- if (target.origin !== restOrigin) throw new Error(`Discord endpoint ${kind} URL is outside the configured REST origin`);
128
- return {
129
- maxRedirects: 0,
130
- policy: {
131
- allowedOrigins: [restOrigin],
132
- hostnameAllowlist: [target.hostname]
133
- },
134
- requireHttps: target.protocol === "https:"
135
- };
136
- }
137
- function assertDiscordEndpointGatewayUrl(url, gatewayOrigin) {
138
- if (!gatewayOrigin) return;
139
- let parsed;
140
- try {
141
- parsed = new URL(url);
142
- } catch {
143
- throw new Error("Discord endpoint returned an invalid Gateway WebSocket URL");
144
- }
145
- if (parsed.origin !== gatewayOrigin || parsed.username || parsed.password || parsed.hash) throw new Error("Discord endpoint Gateway URL is outside the configured WebSocket origin");
146
- }
147
10
  // extensions/discord/src/retry-after.ts
148
11
  const RETRY_AFTER_BODY_SECONDS_RE = /^(?:\d+\.?\d*|\.\d+)$/;
149
12
  const MAX_SAFE_RETRY_AFTER_SECONDS = Number.MAX_SAFE_INTEGER / 1e3;
@@ -155,12 +18,6 @@ function parseDiscordRetryAfterBodySeconds(value) {
155
18
  });
156
19
  }
157
20
  // extensions/discord/src/monitor/format.ts
158
- function resolveDiscordSystemLocation(params) {
159
- const { isDirectMessage, isGroupDm, guild, channelName } = params;
160
- if (isDirectMessage) return "DM";
161
- if (isGroupDm) return `Group DM #${channelName}`;
162
- return guild?.name ? `${guild.name} #${channelName}` : `#${channelName}`;
163
- }
164
21
  function formatDiscordReactionEmoji(emoji) {
165
22
  if (emoji.id && emoji.name) return `<:${emoji.name}:${emoji.id}>`;
166
23
  if (emoji.id) return `emoji:${emoji.id}`;
@@ -171,9 +28,6 @@ function formatDiscordUserTag(user) {
171
28
  if (discriminator && discriminator !== "0") return `${user.username}#${discriminator}`;
172
29
  return user.username ?? user.id;
173
30
  }
174
- function resolveTimestampMs(timestamp) {
175
- return parseDateStringTimestampMs(timestamp);
176
- }
177
31
  // extensions/discord/src/monitor/allow-list.ts
178
32
  const DISCORD_OWNER_ALLOWLIST_PREFIXES = [
179
33
  "discord:",
@@ -437,10 +291,9 @@ function resolveGroupDmAllow(params) {
437
291
  function shouldEmitDiscordReactionNotification(params) {
438
292
  const mode = params.mode ?? "own";
439
293
  if (mode === "off") return false;
440
- const accessGuildInfo = params.guildInfo ?? (params.allowlist ? { users: params.allowlist } : null);
441
294
  const { hasAccessRestrictions, memberAllowed } = resolveDiscordMemberAccessState({
442
295
  channelConfig: params.channelConfig,
443
- guildInfo: accessGuildInfo,
296
+ guildInfo: params.guildInfo,
444
297
  memberRoleIds: params.memberRoleIds ?? [],
445
298
  sender: {
446
299
  id: params.userId,
@@ -455,4 +308,4 @@ function shouldEmitDiscordReactionNotification(params) {
455
308
  if (mode === "own") return Boolean(params.botId && params.messageAuthorId === params.botId);
456
309
  return false;
457
310
  }
458
- export { isDiscordThreadChannelType as A, resolveDiscordSystemLocation as C, getDiscordEndpointRuntime as D, assertDiscordEndpointGatewayUrl as E, resolveDiscordEndpointAttachmentGuard as O, formatDiscordUserTag as S, parseDiscordRetryAfterBodySeconds as T, resolveDiscordOwnerAllowFrom as _, normalizeDiscordDisplaySlug as a, shouldEmitDiscordReactionNotification as b, resolveDiscordChannelConfig as c, resolveDiscordCommandAuthorized as d, resolveDiscordGuildEntry as f, resolveDiscordOwnerAccess as g, resolveDiscordMentionPolicy as h, normalizeDiscordAllowList as i, resolveDiscordEndpointMediaGuard as k, resolveDiscordChannelConfigWithFallback as l, resolveDiscordMemberAllowed as m, hasConfiguredDiscordChannels as n, normalizeDiscordSlug as o, resolveDiscordMemberAccessState as p, isDiscordGroupAllowedByPolicy as r, resolveDiscordAllowListMatch as s, allowListMatches as t, resolveDiscordChannelPolicyCommandAuthorizer as u, resolveDiscordShouldRequireMention as v, resolveTimestampMs as w, formatDiscordReactionEmoji as x, resolveGroupDmAllow as y };
311
+ export { parseDiscordRetryAfterBodySeconds as C, formatDiscordUserTag as S, resolveDiscordOwnerAllowFrom as _, normalizeDiscordDisplaySlug as a, shouldEmitDiscordReactionNotification as b, resolveDiscordChannelConfig as c, resolveDiscordCommandAuthorized as d, resolveDiscordGuildEntry as f, resolveDiscordOwnerAccess as g, resolveDiscordMentionPolicy as h, normalizeDiscordAllowList as i, resolveDiscordChannelConfigWithFallback as l, resolveDiscordMemberAllowed as m, hasConfiguredDiscordChannels as n, normalizeDiscordSlug as o, resolveDiscordMemberAccessState as p, isDiscordGroupAllowedByPolicy as r, resolveDiscordAllowListMatch as s, allowListMatches as t, resolveDiscordChannelPolicyCommandAuthorizer as u, resolveDiscordShouldRequireMention as v, isDiscordThreadChannelType as w, formatDiscordReactionEmoji as x, resolveGroupDmAllow as y };
@@ -1,4 +1,5 @@
1
- import { D as getDiscordEndpointRuntime, T as parseDiscordRetryAfterBodySeconds } from "./allow-list-D1ZGfhXh.mjs";
1
+ import { C as parseDiscordRetryAfterBodySeconds } from "./allow-list-DahA0Jxh.mjs";
2
+ import { n as getDiscordEndpointRuntime } from "./endpoint-runtime-BM3x-m6O.mjs";
2
3
  import { sleepWithAbort } from "openclaw/plugin-sdk/runtime-env";
3
4
  import { resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
4
5
  import { captureChannelReadAuthority, captureEffectAuthority, resolveFetch } from "openclaw/plugin-sdk/fetch-runtime";
@@ -49,22 +50,9 @@ function parseDiscordApiErrorPayload(text) {
49
50
  return null;
50
51
  }
51
52
  }
52
- function parseRetryAfterSeconds(text, response) {
53
- const payload = parseDiscordApiErrorPayload(text);
54
- const retryAfter = parseDiscordRetryAfterBodySeconds(payload?.retry_after);
55
- if (retryAfter !== void 0) return retryAfter;
56
- const header = response.headers.get("Retry-After");
57
- return header ? parseRetryAfterHeaderSeconds(header) : void 0;
58
- }
59
- function formatRetryAfterSeconds(raw) {
60
- const value = parseDiscordRetryAfterBodySeconds(raw);
61
- if (value === void 0) return;
62
- return `${value < 10 ? value.toFixed(1) : Math.round(value).toString()}s`;
63
- }
64
- function formatDiscordApiErrorTextUntrusted(text, response) {
53
+ function formatDiscordApiErrorTextUntrusted(text, response, payload, retryAfter) {
65
54
  const trimmed = text.trim();
66
55
  if (!trimmed) return;
67
- const payload = parseDiscordApiErrorPayload(trimmed);
68
56
  if (!payload) {
69
57
  if (trimmed.startsWith("{") && trimmed.endsWith("}")) return "unknown error";
70
58
  const summary = summarizeDiscordResponseBody(trimmed);
@@ -75,8 +63,8 @@ function formatDiscordApiErrorTextUntrusted(text, response) {
75
63
  return summary;
76
64
  }
77
65
  const message = typeof payload.message === "string" && payload.message.trim() ? payload.message.trim() : "unknown error";
78
- const retryAfter = formatRetryAfterSeconds(payload.retry_after);
79
- return retryAfter ? `${message} (retry after ${retryAfter})` : message;
66
+ if (retryAfter === void 0) return message;
67
+ return `${message} (retry after ${retryAfter < 10 ? retryAfter.toFixed(1) : Math.round(retryAfter).toString()}s)`;
80
68
  }
81
69
  var DiscordApiError = class extends Error {
82
70
  constructor(message, status, retryAfter) {
@@ -97,7 +85,7 @@ function createDiscordRequestSignal(options) {
97
85
  };
98
86
  const controller = new AbortController();
99
87
  const timeout = setTimeout(() => controller.abort(), resolveTimerTimeoutMs(options.timeoutMs, 1));
100
- timeout.unref?.();
88
+ timeout.unref();
101
89
  return {
102
90
  signal: options.signal ? AbortSignal.any([options.signal, controller.signal]) : controller.signal,
103
91
  cleanup: () => clearTimeout(timeout)
@@ -129,10 +117,12 @@ async function requestDiscord(path, token, options) {
129
117
  const res = endpoint ? await effect.run(request) : await effect.initiate(request);
130
118
  if (!res.ok) {
131
119
  const text = await readResponseTextLimited(res, DISCORD_API_ERROR_BODY_LIMIT_BYTES).catch(() => "");
132
- const untrustedDetail = formatDiscordApiErrorTextUntrusted(text, res);
120
+ const errorPayload = parseDiscordApiErrorPayload(text);
121
+ const bodyRetryAfter = parseDiscordRetryAfterBodySeconds(errorPayload?.retry_after);
122
+ const untrustedDetail = formatDiscordApiErrorTextUntrusted(text, res, errorPayload, bodyRetryAfter);
133
123
  const detail = untrustedDetail ? redactToolPayloadText(untrustedDetail) : untrustedDetail;
134
124
  const suffix = detail ? `: ${detail}` : "";
135
- const retryAfter = res.status === 429 ? parseRetryAfterSeconds(text, res) ?? DISCORD_API_429_FALLBACK_RETRY_AFTER_SECONDS : void 0;
125
+ const retryAfter = res.status === 429 ? bodyRetryAfter ?? parseRetryAfterHeaderSeconds(res.headers.get("Retry-After")) ?? DISCORD_API_429_FALLBACK_RETRY_AFTER_SECONDS : void 0;
136
126
  throw new DiscordApiError(`Discord API ${path} failed (${res.status})${suffix}`, res.status, retryAfter);
137
127
  }
138
128
  const responseBody = await readResponseWithLimit(res, DISCORD_API_RESPONSE_BODY_LIMIT_BYTES, { onOverflow: ({ size, maxBytes }) => /* @__PURE__ */ new Error(`Discord API ${path} response body too large: ${size} bytes (limit: ${maxBytes} bytes)`) });
@@ -1,15 +1,16 @@
1
- import { D as createDiscordMessageNonce, N as createDiscordClient } from "./send.shared-D4MioxW_.mjs";
2
- import { D as Row, ct as createChannelMessage, dt as editChannelMessage, j as TextDisplay, k as Separator, q as serializePayload, rt as createUserDmChannel, ut as deleteChannelMessage, x as Container, xt as stripUndefinedFields, y as Button } from "./discord-eFlHX1Gn.mjs";
3
- import { y as findGraphemeChunkEnd } from "./send.receipt-Dw-_r5Bx.mjs";
4
- import { s as buildExecApprovalCustomId } from "./components-BvOWSPxr.mjs";
5
- import { A as isDiscordExecApprovalClientEnabled, c as formatDiscordApprovalDisplayValue, s as DISCORD_APPROVAL_ALLOWED_MENTIONS } from "./outbound-session-route-TFBPPkoz.mjs";
6
- import { a as shouldHandleDiscordApprovalRequest } from "./channel-BMpMAeQL.mjs";
7
- import { t as discordApprovalMessageUpdates } from "./approval-message-updates-Cks-MSCJ.mjs";
1
+ import { D as createDiscordMessageNonce, M as createDiscordClient } from "./send.shared-BcLLZBul.mjs";
2
+ import { D as editChannelMessage, E as deleteChannelMessage, J as stripUndefinedFields, f as serializePayload, w as createChannelMessage, y as createUserDmChannel } from "./discord-r79VFjJp.mjs";
3
+ import { y as findGraphemeChunkEnd } from "./send.receipt-CMteCIZS.mjs";
4
+ import { r as colorToNumber } from "./components.base-C5sAPHe4.mjs";
5
+ import { a as DISCORD_APPROVAL_DECISIONS, o as buildExecApprovalCustomId } from "./shared-interactive-DKBw4SNV.mjs";
6
+ import { c as formatDiscordApprovalDisplayValue, k as isDiscordExecApprovalClientEnabled, s as DISCORD_APPROVAL_ALLOWED_MENTIONS } from "./outbound-session-route-Cb8cv4Oi.mjs";
7
+ import { r as shouldHandleDiscordApprovalRequest } from "./channel-Ds6iuNdy.mjs";
8
+ import { t as discordApprovalMessageUpdates } from "./approval-message-updates-DqOXxPss.mjs";
8
9
  import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
9
- import { ButtonStyle } from "discord-api-types/v10";
10
+ import { ButtonStyle, ComponentType } from "discord-api-types/v10";
10
11
  import { logDebug, logError } from "openclaw/plugin-sdk/logging-core";
11
- import { createChannelApprovalNativeRuntimeAdapterAsync } from "openclaw/plugin-sdk/approval-handler-runtime";
12
12
  import { formatChannelApprovalResolvedLabel } from "openclaw/plugin-sdk/approval-runtime";
13
+ import { createChannelApprovalNativeRuntimeAdapterAsync } from "openclaw/plugin-sdk/approval-handler-runtime";
13
14
  // extensions/discord/src/approval-handler.runtime.ts
14
15
  function resolveHandlerContext(params) {
15
16
  const context = params.context;
@@ -20,14 +21,14 @@ function resolveHandlerContext(params) {
20
21
  context
21
22
  };
22
23
  }
23
- var ExecApprovalActionButton = class extends Button {
24
- constructor(view, descriptor) {
25
- super();
26
- this.customId = buildExecApprovalCustomId(view.approvalId, view.approvalKind, descriptor.decision);
27
- this.label = descriptor.label;
28
- this.style = descriptor.style === "success" ? ButtonStyle.Success : descriptor.style === "primary" ? ButtonStyle.Primary : descriptor.style === "danger" ? ButtonStyle.Danger : ButtonStyle.Secondary;
29
- }
30
- };
24
+ function createApprovalActionButton(view, descriptor) {
25
+ return {
26
+ type: ComponentType.Button,
27
+ custom_id: buildExecApprovalCustomId(view.approvalId, view.approvalKind, descriptor.decision),
28
+ label: descriptor.label,
29
+ style: descriptor.style === "success" ? ButtonStyle.Success : descriptor.style === "primary" ? ButtonStyle.Primary : descriptor.style === "danger" ? ButtonStyle.Danger : ButtonStyle.Secondary
30
+ };
31
+ }
31
32
  function buildExecApprovalPayload(container) {
32
33
  return {
33
34
  components: [container],
@@ -46,49 +47,56 @@ function createApprovalContainer(view) {
46
47
  const commandPreview = formatCommandPreview(plugin ? view.title : view.commandText, plugin ? 700 : pending ? 1e3 : 500);
47
48
  const secondaryText = plugin ? view.description : view.commandPreview;
48
49
  const commandSecondaryPreview = secondaryText ? formatCommandPreview(secondaryText, plugin ? 1e3 : pending ? 500 : 300) : null;
49
- const decisionLabel = view.phase === "resolved" ? formatChannelApprovalResolvedLabel(view, (decision) => decision === "allow-once" ? "Allowed (once)" : decision === "allow-always" ? "Allowed (always)" : "Denied") : void 0;
50
+ const decisionLabel = view.phase === "resolved" ? formatChannelApprovalResolvedLabel(view, (decision) => DISCORD_APPROVAL_DECISIONS[decision].label) : void 0;
50
51
  const title = pending ? `${approvalLabel} Approval Required` : `${approvalLabel} Approval: ${view.phase === "expired" ? "Expired" : decisionLabel}`;
51
52
  const description = pending ? plugin ? "A plugin action needs your approval." : systemAgent ? "An OpenClaw change needs your approval." : "A command needs your approval." : view.phase === "expired" ? "This approval request has expired." : view.resolvedBy ? `Resolved by ${formatDiscordApprovalDisplayValue(view.resolvedBy)}` : "Resolved";
52
- const accentColor = view.phase === "expired" ? "#99AAB5" : view.phase === "resolved" ? view.decision === "deny" ? "#ED4245" : view.decision === "allow-always" ? "#5865F2" : "#57F287" : plugin ? view.severity === "critical" ? "#ED4245" : view.severity === "info" ? "#5865F2" : "#FAA61A" : "#FFA500";
53
+ const accentColor = view.phase === "expired" ? "#99AAB5" : view.phase === "resolved" ? DISCORD_APPROVAL_DECISIONS[view.decision].color : plugin ? view.severity === "critical" ? "#ED4245" : view.severity === "info" ? "#5865F2" : "#FAA61A" : "#FFA500";
53
54
  const approvalId = formatDiscordApprovalDisplayValue(view.approvalId);
54
55
  const footer = pending ? `Expires <t:${Math.max(0, Math.floor(view.expiresAtMs / 1e3))}:R> · ID: ${approvalId}` : `ID: ${approvalId}`;
55
56
  const components = [
56
- new TextDisplay(`## ${title}`),
57
- new TextDisplay(description),
58
- new Separator({
57
+ {
58
+ type: ComponentType.TextDisplay,
59
+ content: `## ${title}`
60
+ },
61
+ {
62
+ type: ComponentType.TextDisplay,
63
+ content: description
64
+ },
65
+ {
66
+ type: ComponentType.Separator,
59
67
  divider: true,
60
- spacing: "small"
61
- }),
62
- new TextDisplay(`### ${systemAgent ? "Change" : "Command"}\n\`\`\`\n${commandPreview}\n\`\`\``)
68
+ spacing: 1
69
+ },
70
+ {
71
+ type: ComponentType.TextDisplay,
72
+ content: `### ${systemAgent ? "Change" : "Command"}\n\`\`\`\n${commandPreview}\n\`\`\``
73
+ }
63
74
  ];
64
- if (commandSecondaryPreview) components.push(new TextDisplay(`### Shell Preview\n\`\`\`\n${commandSecondaryPreview}\n\`\`\``));
65
- if (view.metadata.length) components.push(new TextDisplay(view.metadata.map((item) => `- ${item.label}: ${item.value}`).join("\n")));
66
- if (pending) components.push(new Row(view.actions.map((descriptor) => new ExecApprovalActionButton(view, descriptor))));
67
- components.push(new Separator({
75
+ if (commandSecondaryPreview) components.push({
76
+ type: ComponentType.TextDisplay,
77
+ content: `### Shell Preview\n\`\`\`\n${commandSecondaryPreview}\n\`\`\``
78
+ });
79
+ if (view.metadata.length) components.push({
80
+ type: ComponentType.TextDisplay,
81
+ content: view.metadata.map((item) => `- ${item.label}: ${item.value}`).join("\n")
82
+ });
83
+ if (pending) components.push({
84
+ type: ComponentType.ActionRow,
85
+ components: view.actions.map((descriptor) => createApprovalActionButton(view, descriptor))
86
+ });
87
+ components.push({
88
+ type: ComponentType.Separator,
68
89
  divider: false,
69
- spacing: "small"
70
- }), new TextDisplay(`-# ${footer}`));
71
- return new Container(components, { accentColor });
72
- }
73
- async function finalizeMessage(params) {
74
- const operations = params.cleanupAfterResolve ? ["delete", "update"] : ["update"];
75
- for (const operation of operations) try {
76
- const { rest, request: discordRequest } = createDiscordClient({
77
- cfg: params.cfg,
78
- token: params.token,
79
- accountId: params.accountId
80
- });
81
- let request;
82
- if (operation === "delete") request = () => deleteChannelMessage(rest, params.channelId, params.messageId);
83
- else {
84
- const payload = buildExecApprovalPayload(params.container);
85
- request = () => editChannelMessage(rest, params.channelId, params.messageId, { body: stripUndefinedFields(serializePayload(payload)) });
86
- }
87
- await discordApprovalMessageUpdates.enqueue(params.messageId, () => discordRequest(request, `${operation}-approval`));
88
- return;
89
- } catch (err) {
90
- logError(`discord approvals: failed to ${operation} message: ${String(err)}`);
91
- }
90
+ spacing: 1
91
+ }, {
92
+ type: ComponentType.TextDisplay,
93
+ content: `-# ${footer}`
94
+ });
95
+ return {
96
+ type: ComponentType.Container,
97
+ components,
98
+ accent_color: colorToNumber(accentColor)
99
+ };
92
100
  }
93
101
  function buildTerminalApprovalResult(params) {
94
102
  if (!resolveHandlerContext(params)) return { kind: "delete" };
@@ -205,15 +213,26 @@ const discordApprovalNativeRuntime = createChannelApprovalNativeRuntimeAdapterAs
205
213
  });
206
214
  if (!resolved) return;
207
215
  const container = payload;
208
- await finalizeMessage({
209
- cfg,
210
- accountId: resolved.accountId,
211
- token: resolved.context.token,
212
- cleanupAfterResolve: phase === "resolved" ? resolved.context.config.cleanupAfterResolve : false,
213
- channelId: entry.discordChannelId,
214
- messageId: entry.discordMessageId,
215
- container
216
- });
216
+ const { token } = resolved.context;
217
+ const { discordChannelId, discordMessageId } = entry;
218
+ const operations = phase === "resolved" && resolved.context.config.cleanupAfterResolve ? ["delete", "update"] : ["update"];
219
+ for (const operation of operations) try {
220
+ const { rest, request: discordRequest } = createDiscordClient({
221
+ cfg,
222
+ token,
223
+ accountId: resolved.accountId
224
+ });
225
+ let request;
226
+ if (operation === "delete") request = () => deleteChannelMessage(rest, discordChannelId, discordMessageId);
227
+ else {
228
+ const messagePayload = buildExecApprovalPayload(container);
229
+ request = () => editChannelMessage(rest, discordChannelId, discordMessageId, { body: stripUndefinedFields(serializePayload(messagePayload)) });
230
+ }
231
+ await discordApprovalMessageUpdates.enqueue(discordMessageId, () => discordRequest(request, `${operation}-approval`));
232
+ return;
233
+ } catch (err) {
234
+ logError(`discord approvals: failed to ${operation} message: ${String(err)}`);
235
+ }
217
236
  }
218
237
  },
219
238
  observe: {
@@ -1,5 +1,5 @@
1
- import { tt as parseCustomId } from "./discord-eFlHX1Gn.mjs";
2
- import { c as parseExecApprovalData } from "./components-BvOWSPxr.mjs";
1
+ import { i as parseCustomId } from "./components.base-C5sAPHe4.mjs";
2
+ import { s as parseExecApprovalData } from "./shared-interactive-DKBw4SNV.mjs";
3
3
  import { KeyedAsyncQueue } from "openclaw/plugin-sdk/keyed-async-queue";
4
4
  // extensions/discord/src/approval-message-updates.ts
5
5
  const discordApprovalMessageUpdates = new KeyedAsyncQueue();
@@ -1,8 +1,8 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.mjs";
2
- import { t as inspectDiscordAccount } from "./account-inspect-X_Xlr42B.mjs";
3
- import { b as fetchChannelPermissionsDiscord } from "./send.shared-D4MioxW_.mjs";
4
- import "./send-Cbq-IVsS.mjs";
5
- import { E as collectDiscordAuditChannelIdsForAccount, T as auditDiscordChannelPermissionsWithFetcher } from "./outbound-session-route-TFBPPkoz.mjs";
2
+ import { t as inspectDiscordAccount } from "./account-inspect-CSz5Qodj.mjs";
3
+ import { b as fetchChannelPermissionsDiscord } from "./send.shared-BcLLZBul.mjs";
4
+ import "./send-DnLL6XoO.mjs";
5
+ import { T as collectDiscordAuditChannelIdsForAccount, w as auditDiscordChannelPermissionsWithFetcher } from "./outbound-session-route-Cb8cv4Oi.mjs";
6
6
  // extensions/discord/src/audit.ts
7
7
  var audit_exports = /* @__PURE__ */ __exportAll({
8
8
  auditDiscordChannelPermissions: () => auditDiscordChannelPermissions,