@openclaw/discord 2026.9.8 → 2026.10.1-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/README.md +7 -0
  2. package/dist/.setup/{account-inspect-De8hOUxG.mjs → account-inspect-CjKqkDnH.mjs} +2 -2
  3. package/dist/.setup/{accounts-ChaMcixG.mjs → accounts-DXHCL8Zm.mjs} +9 -32
  4. package/dist/.setup/{active-turn-thread-route-fmHl1HNd.mjs → active-turn-thread-route-C4tp9noA.mjs} +5 -9
  5. package/dist/.setup/{activities-api-tvbsU2e3.mjs → activities-api-BL_hJ0JQ.mjs} +15 -18
  6. package/dist/.setup/{api-DVbJwZVt.mjs → api-_oznjffB.mjs} +1 -1
  7. package/dist/.setup/{approval-handler.runtime-DxCK2Rux.mjs → approval-handler.runtime-BilYSrRF.mjs} +22 -61
  8. package/dist/.setup/{approval-message-updates-BKFqavHZ.mjs → approval-message-updates-CgRwc2_Q.mjs} +2 -2
  9. package/dist/.setup/{audit-CLg9I71N.mjs → audit-DtvzxONM.mjs} +4 -4
  10. package/dist/.setup/{channel-access-C12aDZ0p.mjs → channel-access-BRp3Y-rF.mjs} +4 -17
  11. package/dist/.setup/{channel-type-DRCrEMss.mjs → channel-type-D1_b5UhU.mjs} +12 -16
  12. package/dist/.setup/{channel-DxlUVU9t.mjs → channel-z5lQMS_9.mjs} +79 -75
  13. package/dist/.setup/{channel.setup-CRo1GjV7.mjs → channel.setup-DBJtugJO.mjs} +14 -34
  14. package/dist/.setup/{components-Cq1PvIpN.mjs → components-CzXLR3QH.mjs} +56 -72
  15. package/dist/.setup/{config-schema-oxELUSDx.mjs → config-schema-CsemBDpS.mjs} +6 -17
  16. package/dist/.setup/{conversation-binding-route-Caz_XuFH.mjs → conversation-binding-route-Bi62ApSt.mjs} +1 -1
  17. package/dist/.setup/{directory-config-esqNn0Eo.mjs → directory-config-BH1LA-gi.mjs} +1 -1
  18. package/dist/.setup/{directory-live-DtKRHuGV.mjs → directory-live-C9xz7IPm.mjs} +10 -13
  19. package/dist/.setup/{discord-0xJYfdDD.mjs → discord-J7aRzq2Q.mjs} +101 -381
  20. package/dist/.setup/{doctor-BCl1H5tl.mjs → doctor-DxSAngJq.mjs} +31 -70
  21. package/dist/.setup/doctor-contract-Bg3NPAMw.mjs +137 -0
  22. package/dist/.setup/{handle-action-CUvQWnE7.mjs → handle-action-DlmFX-_G.mjs} +10 -11
  23. package/dist/.setup/{handle-action.guild-admin-Df-8gVle.mjs → handle-action.guild-admin-BnyqTczR.mjs} +67 -129
  24. package/dist/.setup/{live-policy-config-8Pv20CHc.mjs → live-policy-config-emmPNyh4.mjs} +1 -1
  25. package/dist/.setup/{message-handler-B-Jk4oDk.mjs → message-handler-BNToPZrx.mjs} +7 -6
  26. package/dist/.setup/{message-handler.preflight-v-__NSDq.mjs → message-handler.preflight-D0BcCyI7.mjs} +13 -23
  27. package/dist/.setup/{message-handler.preflight-pluralkit-CWLUBVcx.mjs → message-handler.preflight-pluralkit-D1g3eq0B.mjs} +5 -8
  28. package/dist/.setup/{message-handler.process-BNFFuChn.mjs → message-handler.process-CThRmCWK.mjs} +57 -96
  29. package/dist/.setup/{outbound-adapter-BobT-kse.mjs → outbound-adapter-BPq0c2wY.mjs} +11 -17
  30. package/dist/.setup/{outbound-session-route-zVGxxceg.mjs → outbound-session-route-DGPPKA0z.mjs} +21 -46
  31. package/dist/.setup/{presence-cache-Di3H3DIU.mjs → presence-cache-Dg3_dADn.mjs} +2 -4
  32. package/dist/.setup/{probe-LYrIHlBF.mjs → probe-DIRY8vh7.mjs} +17 -27
  33. package/dist/.setup/{provider-B_G5hASF.mjs → provider-D2OKMo0f.mjs} +273 -446
  34. package/dist/.setup/{provider-session.runtime-BYlTBFD2.mjs → provider-session.runtime-BupCTZQv.mjs} +3 -3
  35. package/dist/.setup/provider.runtime-BaW_JnfU.mjs +2 -0
  36. package/dist/.setup/{realtime-session.runtime-oUd9DOcz.mjs → realtime-session.runtime-D5RSC8Mm.mjs} +6 -8
  37. package/dist/.setup/{receive-recovery-CHPOsnLc.mjs → receive-recovery-GqF2PUN_.mjs} +1 -4
  38. package/dist/.setup/{resolve-allowlist-common-DPdRggu5.mjs → resolve-allowlist-common-DUYRrrVB.mjs} +5 -9
  39. package/dist/.setup/{resolve-channels-BFPNRmVv.mjs → resolve-channels--MUatisx.mjs} +3 -3
  40. package/dist/.setup/{resolve-users-0-aBuCy3.mjs → resolve-users-CxLcDmM0.mjs} +6 -9
  41. package/dist/.setup/{retry-pz_cSha2.mjs → retry-BKzO25k4.mjs} +27 -51
  42. package/dist/.setup/{runtime-sUksZ--Q.mjs → runtime-CerRBfaa.mjs} +2 -2
  43. package/dist/.setup/{runtime-FN000lxA.mjs → runtime-CwUA0RLr.mjs} +228 -255
  44. package/dist/.setup/{runtime-doctor-migrations-CshUGl36.mjs → runtime-doctor-migrations-BPV-R4G9.mjs} +6 -0
  45. package/dist/.setup/{security-audit-Cdaegq7C.mjs → security-audit-D42cp5N7.mjs} +21 -48
  46. package/dist/.setup/{send-CrfEI6Bs.mjs → send-2X7m2Zmw.mjs} +45 -58
  47. package/dist/.setup/{send.components-DxQAMfES.mjs → send.components-RqvgmCs3.mjs} +44 -90
  48. package/dist/.setup/{send.outbound-BISKnb-a.mjs → send.outbound-B4QHSEzm.mjs} +60 -98
  49. package/dist/.setup/{send.shared-DGFkbkQR.mjs → send.shared-BQIUh6Vn.mjs} +13 -20
  50. package/dist/.setup/{sender-identity-B9X5Vb9R.mjs → sender-identity-CooeYfAn.mjs} +1 -1
  51. package/dist/.setup/{session-key-normalization-wJgsKPNF.mjs → session-key-normalization-CCHGNSQw.mjs} +3 -9
  52. package/dist/.setup/setup-plugin-api-nn_giXvZ.mjs +3 -0
  53. package/dist/.setup/{shared-B3wZ4hN-.mjs → shared-CIJn6AEC.mjs} +7 -7
  54. package/dist/.setup/{subagent-hooks-nlUE9ow7.mjs → subagent-hooks-BYlVnxzy.mjs} +4 -9
  55. package/dist/.setup/{system-events-CdeZnvPV.mjs → system-events-CQ3if_pS.mjs} +2 -2
  56. package/dist/.setup/{target-resolver-BuLapkhy.mjs → target-resolver-Dzxf80Y3.mjs} +5 -13
  57. package/dist/.setup/targets-Lf8D55w-.mjs +3 -0
  58. package/dist/.setup/{thread-bindings-D7TfgjR_.mjs → thread-bindings-yNNlcUWE.mjs} +5 -6
  59. package/dist/.setup/{thread-bindings.manager-DN-NissX.mjs → thread-bindings.manager-plk0zJAW.mjs} +14 -20
  60. package/dist/.setup/{thread-bindings.session-updates-CshfKghV.mjs → thread-bindings.session-updates-C9aKtVs6.mjs} +295 -5
  61. package/dist/.setup/{timeouts-D86uWLt_.mjs → timeouts-pun7VJ02.mjs} +2 -15
  62. package/dist/.setup/{transcripts-source-p8EV179h.mjs → transcripts-source-CNWswry-.mjs} +31 -79
  63. package/dist/.setup/typing-CNlSKY5S.mjs +11 -0
  64. package/dist/.setup/{voice-runtime-B46rcwrG.mjs → voice-runtime-Bc75quiH.mjs} +62 -110
  65. package/dist/account-inspect-api.js +1 -1
  66. package/dist/action-runtime-api.js +1 -1
  67. package/dist/activities-api.js +1 -1
  68. package/dist/api.js +18 -18
  69. package/dist/channel-config-api.js +1 -1
  70. package/dist/channel-plugin-api.js +1 -1
  71. package/dist/control-ui/2afbdab1d3aa65a789d8a3eba666f4b1ec5df07073538fe30d6cf32093a1fb2d/index.js +1 -0
  72. package/dist/directory-contract-api.js +1 -1
  73. package/dist/doctor-contract-api.js +19 -128
  74. package/dist/index.js +1 -1
  75. package/dist/runtime-api.js +20 -21
  76. package/dist/security-audit-contract-api.js +1 -1
  77. package/dist/session-key-api.js +1 -1
  78. package/dist/setup-entry.js +1 -1
  79. package/dist/setup-plugin-api.js +1 -1
  80. package/dist/src/voice/audio-worker.runtime.js +6 -8
  81. package/dist/subagent-hooks-api.js +1 -1
  82. package/dist/transcripts-source-api.js +1 -1
  83. package/node_modules/libopus-wasm/CHANGELOG.md +8 -0
  84. package/node_modules/libopus-wasm/dist/discordjs.d.ts.map +1 -1
  85. package/node_modules/libopus-wasm/dist/discordjs.js +14 -2
  86. package/node_modules/libopus-wasm/dist/generated/libopus.generated.mjs +0 -0
  87. package/node_modules/libopus-wasm/dist/index.d.ts.map +1 -1
  88. package/node_modules/libopus-wasm/dist/index.js +55 -100
  89. package/node_modules/libopus-wasm/package.json +5 -5
  90. package/node_modules/undici/README.md +10 -1
  91. package/node_modules/undici/docs/docs/api/Agent.md +8 -8
  92. package/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +9 -6
  93. package/node_modules/undici/docs/docs/api/Dispatcher.md +9 -0
  94. package/node_modules/undici/docs/docs/api/Errors.md +25 -0
  95. package/node_modules/undici/docs/docs/api/Fetch.md +10 -0
  96. package/node_modules/undici/docs/docs/api/Interceptors.md +4 -3
  97. package/node_modules/undici/docs/docs/api/Pool.md +5 -6
  98. package/node_modules/undici/docs/docs/index.md +10 -1
  99. package/node_modules/undici/lib/api/readable.js +1 -2
  100. package/node_modules/undici/lib/core/request.js +23 -2
  101. package/node_modules/undici/lib/core/util.js +0 -39
  102. package/node_modules/undici/lib/dispatcher/client-h1.js +11 -4
  103. package/node_modules/undici/lib/dispatcher/client-h2.js +52 -8
  104. package/node_modules/undici/lib/dispatcher/client.js +6 -1
  105. package/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +21 -6
  106. package/node_modules/undici/lib/dispatcher/pool-base.js +63 -2
  107. package/node_modules/undici/lib/dispatcher/pool.js +90 -7
  108. package/node_modules/undici/lib/dispatcher/proxy-agent.js +16 -3
  109. package/node_modules/undici/lib/handler/deduplication-handler.js +24 -11
  110. package/node_modules/undici/lib/handler/redirect-handler.js +5 -0
  111. package/node_modules/undici/lib/handler/retry-handler.js +72 -13
  112. package/node_modules/undici/lib/interceptor/cache.js +4 -1
  113. package/node_modules/undici/lib/interceptor/decompress.js +236 -69
  114. package/node_modules/undici/lib/web/cache/cache.js +17 -8
  115. package/node_modules/undici/lib/web/cache/cachestorage.js +11 -5
  116. package/node_modules/undici/lib/web/cookies/index.js +19 -7
  117. package/node_modules/undici/lib/web/cookies/util.js +3 -1
  118. package/node_modules/undici/lib/web/eventsource/eventsource.js +25 -1
  119. package/node_modules/undici/lib/web/fetch/body.js +22 -15
  120. package/node_modules/undici/lib/web/fetch/data-url.js +6 -6
  121. package/node_modules/undici/lib/web/fetch/formdata.js +30 -36
  122. package/node_modules/undici/lib/web/fetch/headers.js +34 -31
  123. package/node_modules/undici/lib/web/fetch/index.js +46 -25
  124. package/node_modules/undici/lib/web/fetch/request.js +74 -79
  125. package/node_modules/undici/lib/web/fetch/response.js +43 -44
  126. package/node_modules/undici/lib/web/fetch/util.js +7 -7
  127. package/node_modules/undici/lib/web/infra/index.js +16 -1
  128. package/node_modules/undici/lib/web/webidl/index.js +2 -14
  129. package/node_modules/undici/lib/web/websocket/connection.js +33 -12
  130. package/node_modules/undici/lib/web/websocket/events.js +43 -26
  131. package/node_modules/undici/lib/web/websocket/receiver.js +2 -0
  132. package/node_modules/undici/lib/web/websocket/stream/websocketerror.js +13 -10
  133. package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +19 -4
  134. package/node_modules/undici/lib/web/websocket/websocket.js +44 -41
  135. package/node_modules/undici/package.json +1 -1
  136. package/node_modules/undici/types/diagnostics-channel.d.ts +2 -1
  137. package/node_modules/undici/types/interceptors.d.ts +1 -1
  138. package/node_modules/undici/types/webidl.d.ts +13 -7
  139. package/openclaw.plugin.json +6 -0
  140. package/package.json +12 -7
  141. package/dist/.setup/doctor-contract-CvvgwrrG.mjs +0 -409
  142. package/dist/.setup/model-picker-preference-primitives-BHT1LkR_.mjs +0 -37
  143. package/dist/.setup/provider.runtime-CUE3UxER.mjs +0 -2
  144. package/dist/.setup/setup-plugin-api-BQUBxbhe.mjs +0 -3
  145. package/dist/.setup/targets-0KUcEIYx.mjs +0 -3
  146. package/dist/.setup/thread-bindings.state-g6v9zAym.mjs +0 -331
  147. package/dist/.setup/typing-BiHCzBRu.mjs +0 -15
@@ -1,37 +1,37 @@
1
- import { C as parseDiscordActivityCustomIdForInteraction, D as parseDiscordModalCustomIdForInteraction, E as parseDiscordModalCustomId, O as decodeCustomIdComponent, T as parseDiscordComponentCustomIdForInteraction, c as parseExecApprovalData, d as buildDiscordComponentMessage, k as encodeCustomIdComponent, o as parseDiscordQuestionData, w as parseDiscordComponentCustomId, y as buildDiscordActivityCustomId } from "./components-Cq1PvIpN.mjs";
2
- import { $ as BaseMessageInteractiveComponent, B as Container, D as Message, E as Guild, J as Separator, K as Row, O as User, P as Modal, R as Button, T as CommandWithSubcommands, X as TextDisplay, Y as StringSelectMenu, a as MessageCreateListener, c as PresenceUpdateListener, d as ThreadDeleteListener, f as ThreadUpdateListener, h as Plugin, i as InteractionCreateListener, k as hasDiscordV2Components, l as ReadyListener, m as Client, n as GuildCreateListener, o as MessageReactionAddListener, r as GuildDeleteListener, s as MessageReactionRemoveListener, t as discord_exports, v as RateLimitError, w as Command } from "./discord-0xJYfdDD.mjs";
3
- import { D as getDiscordEndpointRuntime, E as assertDiscordEndpointGatewayUrl, S as formatDiscordUserTag, _ as resolveDiscordOwnerAllowFrom, a as normalizeDiscordDisplaySlug, b as shouldEmitDiscordReactionNotification, c as resolveDiscordChannelConfig, f as resolveDiscordGuildEntry, g as resolveDiscordOwnerAccess, i as normalizeDiscordAllowList, l as resolveDiscordChannelConfigWithFallback, m as resolveDiscordMemberAllowed, o as normalizeDiscordSlug, p as resolveDiscordMemberAccessState, r as isDiscordGroupAllowedByPolicy, s as resolveDiscordAllowListMatch, t as isDiscordThreadChannelType, u as resolveDiscordChannelPolicyCommandAuthorizer, w as resolveTimestampMs, x as formatDiscordReactionEmoji, y as resolveGroupDmAllow } from "./channel-type-DRCrEMss.mjs";
4
- import { c as resolveDiscordAccount, f as resolveDiscordAccountDmPolicy, h as resolveDiscordToken, l as resolveDiscordAccountAllowFrom, m as normalizeDiscordToken, o as mergeDiscordAccountConfig, p as resolveDiscordMaxLinesPerMessage } from "./accounts-ChaMcixG.mjs";
5
- import { a as registerDiscordComponentEntries, o as resolveDiscordComponentEntryWithPersistence, s as resolveDiscordModalEntryWithPersistence, t as editDiscordComponentMessage } from "./send.components-DxQAMfES.mjs";
1
+ import { C as parseDiscordActivityCustomIdForInteraction, D as parseDiscordModalCustomIdForInteraction, E as parseDiscordModalCustomId, O as decodeCustomIdComponent, T as parseDiscordComponentCustomIdForInteraction, c as parseExecApprovalData, d as buildDiscordComponentMessage, k as encodeCustomIdComponent, o as parseDiscordQuestionData, w as parseDiscordComponentCustomId, y as buildDiscordActivityCustomId } from "./components-CzXLR3QH.mjs";
2
+ import { $ as BaseMessageInteractiveComponent, B as Container, D as Message, E as Guild, J as Separator, K as Row, O as User, P as Modal, R as Button, T as CommandWithSubcommands, X as TextDisplay, Y as StringSelectMenu, a as MessageCreateListener, c as PresenceUpdateListener, d as ThreadDeleteListener, f as ThreadUpdateListener, h as Plugin, i as InteractionCreateListener, k as hasDiscordV2Components, l as ReadyListener, m as Client, n as GuildCreateListener, o as MessageReactionAddListener, r as GuildDeleteListener, s as MessageReactionRemoveListener, t as discord_exports, v as RateLimitError, w as Command } from "./discord-J7aRzq2Q.mjs";
3
+ import { C as formatDiscordUserTag, D as assertDiscordEndpointGatewayUrl, O as getDiscordEndpointRuntime, S as formatDiscordReactionEmoji, T as resolveTimestampMs, _ as resolveDiscordOwnerAccess, a as normalizeDiscordAllowList, b as resolveGroupDmAllow, c as resolveDiscordAllowListMatch, d as resolveDiscordChannelPolicyCommandAuthorizer, h as resolveDiscordMemberAllowed, i as isDiscordGroupAllowedByPolicy, l as resolveDiscordChannelConfig, m as resolveDiscordMemberAccessState, o as normalizeDiscordDisplaySlug, p as resolveDiscordGuildEntry, r as hasConfiguredDiscordChannels, s as normalizeDiscordSlug, t as isDiscordThreadChannelType, u as resolveDiscordChannelConfigWithFallback, v as resolveDiscordOwnerAllowFrom, x as shouldEmitDiscordReactionNotification } from "./channel-type-D1_b5UhU.mjs";
4
+ import { c as resolveDiscordAccount, f as resolveDiscordAccountDmPolicy, h as resolveDiscordToken, l as resolveDiscordAccountAllowFrom, m as normalizeDiscordToken, o as mergeDiscordAccountConfig, p as resolveDiscordMaxLinesPerMessage } from "./accounts-DXHCL8Zm.mjs";
5
+ import { a as registerDiscordComponentEntries, o as resolveDiscordComponentEntryWithPersistence, s as resolveDiscordModalEntryWithPersistence, t as editDiscordComponentMessage } from "./send.components-RqvgmCs3.mjs";
6
6
  import { t as getDiscordRuntime } from "./runtime-DgnVQ7zW.mjs";
7
- import { a as isDiscordRateLimitResponseBody, s as summarizeDiscordResponseBody } from "./api-DVbJwZVt.mjs";
8
- import { o as chunkDiscordTextWithMode } from "./retry-pz_cSha2.mjs";
9
- import { B as withValidatedDiscordProxy, C as hasAnyChannelPermissionDiscord, L as DISCORD_REST_TIMEOUT_MS, N as createDiscordRestClient, U as registerGateway, W as unregisterGateway, y as canViewDiscordGuildChannel, z as validateDiscordProxyUrl } from "./send.shared-DGFkbkQR.mjs";
10
- import { o as formatMention, t as sendMessageDiscord } from "./send.outbound-BISKnb-a.mjs";
11
- import { n as getDiscordActivitiesRuntime } from "./runtime-sUksZ--Q.mjs";
7
+ import { a as isDiscordRateLimitResponseBody, s as summarizeDiscordResponseBody } from "./api-_oznjffB.mjs";
8
+ import { o as chunkDiscordTextWithMode } from "./retry-BKzO25k4.mjs";
9
+ import { B as withValidatedDiscordProxy, C as hasAnyChannelPermissionDiscord, L as DISCORD_REST_TIMEOUT_MS, N as createDiscordRestClient, U as registerGateway, W as unregisterGateway, y as canViewDiscordGuildChannel, z as validateDiscordProxyUrl } from "./send.shared-BQIUh6Vn.mjs";
10
+ import { o as formatMention, t as sendMessageDiscord } from "./send.outbound-B4QHSEzm.mjs";
11
+ import { n as getDiscordActivitiesRuntime } from "./runtime-CerRBfaa.mjs";
12
12
  import { t as resolveDiscordCommandOwnerAllowFrom } from "./command-owners-D78sAoOz.mjs";
13
- import { n as resolveDiscordChannelInfoSafe, o as resolveDiscordChannelTopicSafe, r as resolveDiscordChannelNameSafe } from "./channel-access-C12aDZ0p.mjs";
14
- import { D as resolveDiscordReferencedReplyMessage, O as resolveDiscordReferencedReplyMessageId, a as resolveDiscordVoiceEnabled, i as setDiscordTranscriptsVoiceManager, l as resolveDiscordThreadLikeChannelContext, o as authorizeDiscordVoiceIngress, s as resolveDiscordVoiceAccess, u as resolveFetchedDiscordThreadLikeChannelContext } from "./transcripts-source-p8EV179h.mjs";
15
- import { i as setPresence, t as clearPresences } from "./presence-cache-Di3H3DIU.mjs";
16
- import { _ as readMessagesDiscord, s as sendVoiceMessageDiscord } from "./send-CrfEI6Bs.mjs";
17
- import { c as raceWithTimeout, u as withAbortTimeout } from "./timeouts-D86uWLt_.mjs";
18
- import { D as isDiscordExecApprovalClientEnabled, T as getDiscordExecApprovalApprovers, a as resolveDiscordComponentSpec, c as formatDiscordApprovalDisplayValue, d as resolveDiscordBoundConversationRoute, h as resolveDiscordConversationIdentity, l as buildDiscordConversationRouteContext, n as DISCORD_PRESENTATION_CAPABILITIES, p as resolveDiscordEffectiveRoute, r as buildDiscordPresentationPayload, s as DISCORD_APPROVAL_ALLOWED_MENTIONS, u as buildDiscordRoutePeer } from "./outbound-session-route-zVGxxceg.mjs";
19
- import { n as discordIngressIdentity, t as selectDiscordLivePolicyConfig } from "./live-policy-config-8Pv20CHc.mjs";
20
- import { t as resolveDiscordChannelAllowlist } from "./resolve-channels-BFPNRmVv.mjs";
21
- import { t as resolveDiscordUserAllowlist } from "./resolve-users-0-aBuCy3.mjs";
22
- import { a as isThreadArchived, n as getThreadBindingManager } from "./thread-bindings.manager-DN-NissX.mjs";
23
- import { a as probeDiscordApplicationId, r as parseApplicationIdFromToken } from "./probe-LYrIHlBF.mjs";
24
- import { i as sanitizeRecentModels, n as normalizeModelRef, r as preferenceTimestampMs, t as buildPreferenceModelKey } from "./model-picker-preference-primitives-BHT1LkR_.mjs";
25
- import { t as resolveDiscordSenderIdentity } from "./sender-identity-B9X5Vb9R.mjs";
26
- import { n as hasDiscordApprovalControl, t as discordApprovalMessageUpdates } from "./approval-message-updates-BKFqavHZ.mjs";
13
+ import { n as resolveDiscordChannelInfoSafe, o as resolveDiscordChannelTopicSafe, r as resolveDiscordChannelNameSafe } from "./channel-access-BRp3Y-rF.mjs";
14
+ import { D as resolveDiscordReferencedReplyMessage, O as resolveDiscordReferencedReplyMessageId, a as resolveDiscordVoiceEnabled, i as setDiscordTranscriptsVoiceManager, l as resolveDiscordThreadLikeChannelContext, o as authorizeDiscordVoiceIngress, s as resolveDiscordVoiceAccess, u as resolveFetchedDiscordThreadLikeChannelContext } from "./transcripts-source-CNWswry-.mjs";
15
+ import { l as withAbortTimeout } from "./timeouts-pun7VJ02.mjs";
16
+ import { i as setPresence, t as clearPresences } from "./presence-cache-Dg3_dADn.mjs";
17
+ import { _ as readMessagesDiscord, s as sendVoiceMessageDiscord } from "./send-2X7m2Zmw.mjs";
18
+ import { D as isDiscordExecApprovalClientEnabled, T as getDiscordExecApprovalApprovers, a as resolveDiscordComponentSpec, c as formatDiscordApprovalDisplayValue, d as resolveDiscordBoundConversationRoute, h as resolveDiscordConversationIdentity, l as buildDiscordConversationRouteContext, n as DISCORD_PRESENTATION_CAPABILITIES, p as resolveDiscordEffectiveRoute, r as buildDiscordPresentationPayload, s as DISCORD_APPROVAL_ALLOWED_MENTIONS, u as buildDiscordRoutePeer } from "./outbound-session-route-DGPPKA0z.mjs";
19
+ import { n as discordIngressIdentity, t as selectDiscordLivePolicyConfig } from "./live-policy-config-emmPNyh4.mjs";
20
+ import { t as resolveDiscordChannelAllowlist } from "./resolve-channels--MUatisx.mjs";
21
+ import { t as resolveDiscordUserAllowlist } from "./resolve-users-CxLcDmM0.mjs";
22
+ import { a as isThreadArchived, n as getThreadBindingManager } from "./thread-bindings.manager-plk0zJAW.mjs";
23
+ import { a as probeDiscordApplicationId, r as parseApplicationIdFromToken } from "./probe-DIRY8vh7.mjs";
24
+ import { t as resolveDiscordSenderIdentity } from "./sender-identity-CooeYfAn.mjs";
25
+ import { n as hasDiscordApprovalControl, t as discordApprovalMessageUpdates } from "./approval-message-updates-CgRwc2_Q.mjs";
27
26
  import { createRequire } from "node:module";
28
27
  import { logDebug, logError } from "openclaw/plugin-sdk/logging-core";
28
+ import { asFiniteNumber, asOptionalRecord, normalizeLowercaseStringOrEmpty, normalizeOptionalLowercaseString, normalizeOptionalString, normalizeStringEntries, parseFiniteNumber, parseStrictNonNegativeInteger, readNonBlankString, summarizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
29
29
  import { ApplicationCommandOptionType, ButtonStyle, ChannelType, ComponentType, GatewayCloseCodes, GatewayCloseCodes as GatewayCloseCodes$1, GatewayDispatchEvents, GatewayIntentBits, GatewayOpcodes, PermissionFlagsBits } from "discord-api-types/v10";
30
30
  import { Type } from "typebox";
31
31
  import { Check, Errors } from "typebox/value";
32
32
  import { createHash, randomUUID } from "node:crypto";
33
- import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
34
- import { MAX_DATE_TIMESTAMP_MS, MAX_TIMER_TIMEOUT_MS, asDateTimestampMs, asSafeIntegerInRange, parseFiniteNumber, parseStrictInteger, parseStrictPositiveInteger, resolveDateTimestampMs, resolvePromptHistoryLimit, resolveTimestampMsToIsoString } from "openclaw/plugin-sdk/number-runtime";
33
+ import { MAX_DATE_TIMESTAMP_MS, MAX_TIMER_TIMEOUT_MS, asDateTimestampMs, asSafeIntegerInRange, parseFiniteNumber as parseFiniteNumber$1, parseStrictInteger, parseStrictPositiveInteger, resolveDateTimestampMs, resolvePromptHistoryLimit, resolveTimestampMsToIsoString } from "openclaw/plugin-sdk/number-runtime";
34
+ import { raceWithTimeout } from "openclaw/plugin-sdk/time-runtime";
35
35
  import { inspect } from "node:util";
36
36
  import * as fetchRuntimeSdk from "openclaw/plugin-sdk/fetch-runtime";
37
37
  import { createHttp1EnvHttpProxyAgent, createHttp1ProxyAgent, createNodeProxyAgent, resolveEnvHttpProxyAgentOptions, wrapFetchWithAbortSignal } from "openclaw/plugin-sdk/fetch-runtime";
@@ -40,24 +40,24 @@ import { fetchWithSsrFGuard, formatErrorMessage, resolvePinnedHostnameWithPolicy
40
40
  import { PlatformMessageNotDispatchedError, formatErrorMessage as formatErrorMessage$1, toErrorObject } from "openclaw/plugin-sdk/error-runtime";
41
41
  import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
42
42
  import { resolveAgentRoute } from "openclaw/plugin-sdk/routing";
43
- import { asFiniteNumber, asOptionalRecord, normalizeLowercaseStringOrEmpty, normalizeOptionalLowercaseString, normalizeOptionalString, normalizeStringEntries, parseFiniteNumber as parseFiniteNumber$1, parseStrictNonNegativeInteger as parseStrictNonNegativeInteger$1, summarizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
44
43
  import { createRuntimeConfigReader, getRuntimeConfig, getRuntimeConfigSnapshot } from "openclaw/plugin-sdk/runtime-config-snapshot";
45
44
  import { renderPresentationForDelivery } from "openclaw/plugin-sdk/interactive-runtime";
46
45
  import { hasOutboundReplyContent, resolveSendableOutboundReplyParts, resolveTextChunksWithFallback } from "openclaw/plugin-sdk/reply-payload";
47
46
  import { createNonExitingRuntime, createSubsystemLogger, danger, formatDurationSeconds, isVerbose, logVerbose, shouldLogVerbose, sleepWithAbort, warn } from "openclaw/plugin-sdk/runtime-env";
48
- import { sliceUtf16Safe, truncateUtf16Safe, withTimeout } from "openclaw/plugin-sdk/text-utility-runtime";
47
+ import { sliceUtf16Safe, truncateCodePoints, truncateUtf16Safe, withTimeout } from "openclaw/plugin-sdk/text-utility-runtime";
49
48
  import { addAllowlistUserEntriesFromConfigEntry, buildAllowlistResolutionSummary, canonicalizeAllowlistWithResolvedIds, patchAllowlistUsersInConfigEntries, summarizeMapping } from "openclaw/plugin-sdk/allow-from";
50
49
  import { resolveChunkMode, resolveTextChunkLimit } from "openclaw/plugin-sdk/reply-chunking";
50
+ import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
51
51
  import { resolveMarkdownTableMode } from "openclaw/plugin-sdk/markdown-table-runtime";
52
52
  import { chunkItems, findCodeRegions, sanitizeAssistantVisibleText, sanitizeAssistantVisibleTextWithProfile } from "openclaw/plugin-sdk/text-chunking";
53
53
  import { buildOutboundSessionContext, listMessageReceiptPlatformIds, resolveChannelStreamingBlockEnabled, sendDurableMessageBatch } from "openclaw/plugin-sdk/channel-outbound";
54
54
  import { getAgentScopedMediaLocalRoots } from "openclaw/plugin-sdk/media-runtime";
55
- import { loadWebMedia } from "openclaw/plugin-sdk/web-media";
56
55
  import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
57
56
  import { buildCommandTextFromArgs, findCommandByNativeName, formatCommandArgMenuTitle, listChatCommands, listNativeCommandSpecsForConfig, listSkillCommandsForAgents, resolveCommandAuthorization, resolveCommandAuthorizedFromAuthorizers, resolveEffectiveAgentRuntime, resolveNativeCommandSessionTargets, resolveStoredModelOverride, serializeCommandArgs } from "openclaw/plugin-sdk/command-auth-native";
58
57
  import { GROUP_POLICY_BLOCKED_LABEL, resolveDefaultGroupPolicy, resolveOpenProviderRuntimeGroupPolicy, warnMissingProviderGroupPolicyFallbackOnce } from "openclaw/plugin-sdk/runtime-group-policy";
59
58
  import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
60
59
  import { buildChannelInboundEventContext, createChannelPartialDeliveryError, createCommandTurnContext, dispatchChannelInboundTurn, formatInboundEnvelope, hasVisibleInboundReplyDispatch, isChannelPartialDeliveryError, resolveEnvelopeFormatOptions, resolveInboundSupplementalSenderAllowed, runChannelInboundEvent } from "openclaw/plugin-sdk/channel-inbound";
60
+ import { loadWebMedia } from "openclaw/plugin-sdk/web-media";
61
61
  import path from "node:path";
62
62
  import { resolvePinnedMainDmOwnerFromAllowlist } from "openclaw/plugin-sdk/security-runtime";
63
63
  import { createChannelPairingChallengeIssuer } from "openclaw/plugin-sdk/channel-pairing";
@@ -80,8 +80,9 @@ import * as dns from "node:dns";
80
80
  import { buildCommandTextFromArgs as buildCommandTextFromArgs$1, findCommandByNativeName as findCommandByNativeName$1, mergeNativeCommandSpecs, parseCommandArgs, resolveCommandArgChoices, resolveCommandArgMenu, serializeCommandArgs as serializeCommandArgs$1 } from "openclaw/plugin-sdk/native-command-registry";
81
81
  import { PLUGIN_COMMAND_DISPATCH } from "openclaw/plugin-sdk/plugin-command-runtime";
82
82
  import { resolveDirectStatusReplyForSession } from "openclaw/plugin-sdk/command-status-runtime";
83
+ import { normalizeProviderId } from "openclaw/plugin-sdk/model-ref-parse";
83
84
  import * as modelsProviderRuntime from "openclaw/plugin-sdk/models-provider-runtime";
84
- import { normalizeProviderId } from "openclaw/plugin-sdk/provider-model-shared";
85
+ import { normalizeProviderId as normalizeProviderId$1 } from "openclaw/plugin-sdk/provider-model-shared";
85
86
  import { EventEmitter } from "node:events";
86
87
  import { Agent } from "node:https";
87
88
  import { channelReadyPatch, createTransportActivityStatusPatch } from "openclaw/plugin-sdk/gateway-runtime";
@@ -410,11 +411,7 @@ function syntheticAccessGroupMembership(groupName, allowed) {
410
411
  }
411
412
  async function resolveDiscordDmCommandAccess(params) {
412
413
  return await createDiscordIngressResolver({
413
- accountId: params.accountId,
414
- cfg: params.cfg,
415
- token: params.token,
416
- rest: params.rest,
417
- readStoreAllowFrom: params.readStoreAllowFrom,
414
+ ...params,
418
415
  useDefaultPairingStore: params.readStoreAllowFrom == null
419
416
  }).message({
420
417
  subject: createDiscordDmIngressSubject(params.sender),
@@ -448,12 +445,7 @@ async function resolveDiscordTextCommandAccess(params) {
448
445
  const memberAccessGroup = "discord-member-access";
449
446
  const commandGroup = params.memberAccessConfigured ? [`accessGroup:${memberAccessGroup}`] : [];
450
447
  const accessGroupMembership = params.memberAccessConfigured ? [syntheticAccessGroupMembership(memberAccessGroup, params.memberAllowed)] : [];
451
- return await createDiscordIngressResolver({
452
- accountId: params.accountId,
453
- cfg: params.cfg,
454
- token: params.token,
455
- rest: params.rest
456
- }).command({
448
+ return await createDiscordIngressResolver(params).command({
457
449
  subject: createDiscordDmIngressSubject(params.sender),
458
450
  conversation: {
459
451
  kind: "channel",
@@ -582,7 +574,7 @@ async function authorizeDiscordReactionIngress(params) {
582
574
  reason: "group-dm-not-allowlisted"
583
575
  };
584
576
  if (!params.isGuildMessage) return { allowed: true };
585
- const channelAllowlistConfigured = Boolean(params.guildInfo?.channels) && Object.keys(params.guildInfo?.channels ?? {}).length > 0;
577
+ const channelAllowlistConfigured = hasConfiguredDiscordChannels(params.guildInfo?.channels);
586
578
  const channelAllowed = params.channelConfig?.allowed !== false;
587
579
  if (!isDiscordGroupAllowedByPolicy({
588
580
  groupPolicy: params.groupPolicy,
@@ -614,13 +606,10 @@ async function authorizeDiscordReactionIngress(params) {
614
606
  };
615
607
  return { allowed: true };
616
608
  }
617
- function hasDiscordGuildChannelOverrides(guildInfo) {
618
- return Boolean(guildInfo?.channels && Object.keys(guildInfo.channels).length > 0);
619
- }
620
609
  function shouldSkipGuildReactionBeforeChannelFetch(params) {
621
610
  if (params.reactionMode === "off" || params.groupPolicy === "disabled") return true;
622
611
  if (params.reactionMode !== "allowlist") return false;
623
- if (hasDiscordGuildChannelOverrides(params.guildInfo)) return false;
612
+ if (hasConfiguredDiscordChannels(params.guildInfo?.channels)) return false;
624
613
  return !shouldEmitDiscordReactionNotification({
625
614
  mode: params.reactionMode,
626
615
  botId: params.botUserId,
@@ -1177,11 +1166,8 @@ function dispatchVoiceGatewayEvent(client, payload) {
1177
1166
  if (payload.t === GatewayDispatchEvents.VoiceStateUpdate) adapter?.onVoiceStateUpdate?.(payload.d);
1178
1167
  }
1179
1168
  function mapGatewayDispatchData(client, type, data) {
1180
- const messageCreate = GatewayDispatchEvents.MessageCreate;
1181
- const reactionAdd = GatewayDispatchEvents.MessageReactionAdd;
1182
- const reactionRemove = GatewayDispatchEvents.MessageReactionRemove;
1183
- if (type === messageCreate) return createMessageDispatchData(client, data);
1184
- if (type === reactionAdd || type === reactionRemove) return createReactionDispatchData(client, data);
1169
+ if (type === GatewayDispatchEvents.MessageCreate) return createMessageDispatchData(client, data);
1170
+ if (type === GatewayDispatchEvents.MessageReactionAdd || type === GatewayDispatchEvents.MessageReactionRemove) return createReactionDispatchData(client, data);
1185
1171
  return data;
1186
1172
  }
1187
1173
  function createMessageDispatchData(client, data) {
@@ -1492,8 +1478,6 @@ function reorderLookupAddresses(addresses) {
1492
1478
  if (addresses.length < 2) return addresses;
1493
1479
  const ipv4 = addresses.filter((entry) => entry.family === 4);
1494
1480
  const ipv6 = addresses.filter((entry) => entry.family === 6);
1495
- if (ipv4.length === 0) return ipv6;
1496
- if (ipv6.length === 0) return ipv4;
1497
1481
  return [...ipv4, ...ipv6];
1498
1482
  }
1499
1483
  function createDiscordDnsLookup() {
@@ -1748,8 +1732,7 @@ function isDiscordUnknownInteraction(error) {
1748
1732
  const err = error;
1749
1733
  if (err.discordCode === 10062 || err.rawBody?.code === 10062) return true;
1750
1734
  if (err.status === 404 && /Unknown interaction/i.test(err.message ?? "")) return true;
1751
- if (/Unknown interaction/i.test(err.rawBody?.message ?? "")) return true;
1752
- return false;
1735
+ return /Unknown interaction/i.test(err.rawBody?.message ?? "");
1753
1736
  }
1754
1737
  function resolveDiscordInteractionMessageParts(payload) {
1755
1738
  const { components, embeds } = payload.channelData?.discord ?? {};
@@ -2416,22 +2399,16 @@ function resolveDiscordNativeCommandChannelAccessContext(params) {
2416
2399
  guildId: guild?.id ?? void 0,
2417
2400
  guildEntries: params.discordConfig?.guilds
2418
2401
  });
2419
- return {
2420
- commandsAllowFromAccess,
2402
+ const channelConfig = guild ? resolveDiscordChannelConfigWithFallback({
2421
2403
  guildInfo,
2422
- channelConfig: guild ? resolveDiscordChannelConfigWithFallback({
2423
- guildInfo,
2424
- channelId: params.rawChannelId,
2425
- channelName: params.channelName,
2426
- channelSlug: params.channelSlug,
2427
- parentId: params.threadParentId,
2428
- parentName: params.threadParentName,
2429
- parentSlug: params.threadParentSlug,
2430
- scope: params.isThreadChannel ? "thread" : "channel"
2431
- }) : null
2432
- };
2433
- }
2434
- async function resolveDiscordGuildNativeCommandAuthorized(params) {
2404
+ channelId: params.rawChannelId,
2405
+ channelName: params.channelName,
2406
+ channelSlug: params.channelSlug,
2407
+ parentId: params.threadParentId,
2408
+ parentName: params.threadParentName,
2409
+ parentSlug: params.threadParentSlug,
2410
+ scope: params.isThreadChannel ? "thread" : "channel"
2411
+ }) : null;
2435
2412
  const { groupPolicy } = resolveOpenProviderRuntimeGroupPolicy({
2436
2413
  providerConfigPresent: params.cfg.channels?.discord !== void 0,
2437
2414
  groupPolicy: params.discordConfig?.groupPolicy,
@@ -2439,9 +2416,19 @@ async function resolveDiscordGuildNativeCommandAuthorized(params) {
2439
2416
  });
2440
2417
  const policyAuthorizer = resolveDiscordChannelPolicyCommandAuthorizer({
2441
2418
  groupPolicy,
2442
- guildInfo: params.guildInfo,
2443
- channelConfig: params.channelConfig
2419
+ guildInfo,
2420
+ channelConfig
2444
2421
  });
2422
+ return {
2423
+ commandsAllowFromAccess,
2424
+ guildInfo,
2425
+ channelConfig,
2426
+ policyAuthorizer,
2427
+ channelDenial: channelConfig?.enabled === false ? "disabled" : guild && (channelConfig?.allowed === false || !policyAuthorizer.allowed) ? "not-allowed" : void 0
2428
+ };
2429
+ }
2430
+ async function resolveDiscordGuildNativeCommandAuthorized(params) {
2431
+ const { policyAuthorizer } = params;
2445
2432
  if (!policyAuthorizer.allowed) return false;
2446
2433
  const { hasAccessRestrictions, memberAllowed } = resolveDiscordMemberAccessState({
2447
2434
  channelConfig: params.channelConfig,
@@ -2518,27 +2505,15 @@ async function resolveDiscordNativeAutocompleteAuthorized(params) {
2518
2505
  sender,
2519
2506
  allowNameMatching
2520
2507
  });
2521
- const { commandsAllowFromAccess, guildInfo, channelConfig } = resolveDiscordNativeCommandChannelAccessContext({
2508
+ const channelAccess = resolveDiscordNativeCommandChannelAccessContext({
2522
2509
  cfg,
2523
2510
  discordConfig,
2524
2511
  sender,
2525
2512
  ...channelContext,
2526
2513
  guild: interaction.guild ?? null
2527
2514
  });
2528
- if (channelConfig?.enabled === false) return false;
2529
- if (interaction.guild && channelConfig?.allowed === false) return false;
2530
- if (interaction.guild) {
2531
- const { groupPolicy } = resolveOpenProviderRuntimeGroupPolicy({
2532
- providerConfigPresent: cfg.channels?.discord !== void 0,
2533
- groupPolicy: discordConfig?.groupPolicy,
2534
- defaultGroupPolicy: cfg.channels?.defaults?.groupPolicy
2535
- });
2536
- if (!resolveDiscordChannelPolicyCommandAuthorizer({
2537
- groupPolicy,
2538
- guildInfo,
2539
- channelConfig
2540
- }).allowed) return false;
2541
- }
2515
+ const { commandsAllowFromAccess, guildInfo, channelConfig } = channelAccess;
2516
+ if (channelAccess.channelDenial) return false;
2542
2517
  const dmEnabled = discordConfig?.dm?.enabled ?? true;
2543
2518
  const dmPolicy = resolveDiscordAccountDmPolicy({
2544
2519
  cfg,
@@ -2567,11 +2542,7 @@ async function resolveDiscordNativeAutocompleteAuthorized(params) {
2567
2542
  }).allowed) return false;
2568
2543
  if (!isDirectMessage) {
2569
2544
  if (!await resolveDiscordGuildNativeCommandAuthorized({
2570
- cfg,
2571
- discordConfig,
2572
- commandsAllowFromAccess,
2573
- guildInfo,
2574
- channelConfig,
2545
+ ...channelAccess,
2575
2546
  memberRoleIds,
2576
2547
  sender,
2577
2548
  allowNameMatching,
@@ -2632,6 +2603,40 @@ function shouldBypassConfiguredAcpGuildGuards(commandName) {
2632
2603
  return command === "new" || command === "reset";
2633
2604
  }
2634
2605
  //#endregion
2606
+ //#region extensions/discord/src/monitor/model-picker-preference-primitives.ts
2607
+ function normalizeModelRef(raw) {
2608
+ const value = raw?.trim();
2609
+ if (!value) return null;
2610
+ const slashIndex = value.indexOf("/");
2611
+ if (slashIndex <= 0 || slashIndex >= value.length - 1) return null;
2612
+ const provider = normalizeProviderId(value.slice(0, slashIndex));
2613
+ const model = value.slice(slashIndex + 1).trim();
2614
+ return provider && model ? `${provider}/${model}` : null;
2615
+ }
2616
+ function sanitizeRecentModels(models, limit) {
2617
+ const deduped = [];
2618
+ const seen = /* @__PURE__ */ new Set();
2619
+ if (!Array.isArray(models)) return deduped;
2620
+ for (const item of models) {
2621
+ const normalized = normalizeModelRef(typeof item === "string" ? item : void 0);
2622
+ if (!normalized || seen.has(normalized)) continue;
2623
+ seen.add(normalized);
2624
+ deduped.push(normalized);
2625
+ if (deduped.length >= limit) break;
2626
+ }
2627
+ return deduped;
2628
+ }
2629
+ function hashSegment(value, length) {
2630
+ return createHash("sha256").update(value, "utf8").digest("hex").slice(0, length);
2631
+ }
2632
+ function buildPreferenceModelKey(scopeKey, modelRef) {
2633
+ return `v1:${hashSegment(scopeKey, 32)}:${hashSegment(modelRef, 24)}`;
2634
+ }
2635
+ function preferenceTimestampMs(value) {
2636
+ const parsed = typeof value === "string" ? Date.parse(value) : NaN;
2637
+ return Number.isFinite(parsed) ? parsed : 0;
2638
+ }
2639
+ //#endregion
2635
2640
  //#region extensions/discord/src/monitor/model-picker-preferences.ts
2636
2641
  const DEFAULT_RECENT_LIMIT = 5;
2637
2642
  const PREFERENCE_MAX_ENTRIES = 2e3;
@@ -2740,6 +2745,7 @@ const PICKER_ACTIONS = [
2740
2745
  "open",
2741
2746
  "provider",
2742
2747
  "model",
2748
+ "pick",
2743
2749
  "runtime",
2744
2750
  "submit",
2745
2751
  "quick",
@@ -2760,7 +2766,7 @@ const DISCORD_MODEL_PICKER_BUCKET_THRESHOLD = DISCORD_COMPONENT_MAX_SELECT_OPTIO
2760
2766
  const DISCORD_MODEL_PICKER_BUCKET_TARGET_SIZE = 20;
2761
2767
  const DISCORD_MODEL_PICKER_TOKEN_PATTERN = /^[A-Za-z0-9_-]{8}$/u;
2762
2768
  function createDiscordModelPickerModelToken(provider, model) {
2763
- return createHash("sha256").update(JSON.stringify([normalizeProviderId(provider), model]), "utf8").digest("base64url").slice(0, 8);
2769
+ return createHash("sha256").update(JSON.stringify([normalizeProviderId$1(provider), model]), "utf8").digest("base64url").slice(0, 8);
2764
2770
  }
2765
2771
  function createDiscordModelPickerRuntimeToken(runtime) {
2766
2772
  return createHash("sha256").update(runtime, "utf8").digest("base64url").slice(0, 8);
@@ -2821,7 +2827,7 @@ function buildDiscordModelPickerCustomId(params) {
2821
2827
  if (!userId) throw new Error("Discord model picker custom_id requires userId");
2822
2828
  const page = normalizeModelPickerPage(params.page);
2823
2829
  const providerPage = normalizeOptionalModelPickerIndex(params.providerPage);
2824
- const normalizedProvider = params.provider ? normalizeProviderId(params.provider) : void 0;
2830
+ const normalizedProvider = params.provider ? normalizeProviderId$1(params.provider) : void 0;
2825
2831
  const modelIndex = normalizeOptionalModelPickerIndex(params.modelIndex);
2826
2832
  const recentSlot = normalizeOptionalModelPickerIndex(params.recentSlot);
2827
2833
  const modelToken = params.modelToken?.trim();
@@ -2894,7 +2900,7 @@ function parseDiscordModelPickerData(data) {
2894
2900
  action,
2895
2901
  view,
2896
2902
  userId: trimmedUserId,
2897
- provider: providerRaw ? normalizeProviderId(providerRaw) : void 0,
2903
+ provider: providerRaw ? normalizeProviderId$1(providerRaw) : void 0,
2898
2904
  runtime: runtimeRaw.trim() || void 0,
2899
2905
  ...runtimeTokenRaw ? { runtimeToken: runtimeTokenRaw } : {},
2900
2906
  ...typeof runtimeIndex === "number" ? { runtimeIndex } : {},
@@ -2965,10 +2971,10 @@ function findProviderBucketId(data, provider) {
2965
2971
  return findProviderBucketLocation(data, provider)?.bucket;
2966
2972
  }
2967
2973
  function findProviderBucketLocation(data, provider) {
2968
- return findModelPickerBucketLocation([...data.providers].toSorted(), normalizeProviderId(provider));
2974
+ return findModelPickerBucketLocation([...data.providers].toSorted(), normalizeProviderId$1(provider));
2969
2975
  }
2970
2976
  function findModelBucketId(data, provider, model) {
2971
- const modelSet = data.byProvider.get(normalizeProviderId(provider));
2977
+ const modelSet = data.byProvider.get(normalizeProviderId$1(provider));
2972
2978
  return modelSet ? findModelPickerBucketLocation([...modelSet].toSorted(compareBucketItems), model)?.bucket : void 0;
2973
2979
  }
2974
2980
  function findModelPickerBucketLocation(sortedItems, item, pageSize = DISCORD_COMPONENT_MAX_SELECT_OPTIONS) {
@@ -3006,7 +3012,7 @@ function getDiscordModelPickerProviderPage(params) {
3006
3012
  });
3007
3013
  }
3008
3014
  function getDiscordModelPickerModelPage(params) {
3009
- const provider = normalizeProviderId(params.provider);
3015
+ const provider = normalizeProviderId$1(params.provider);
3010
3016
  const modelSet = params.data.byProvider.get(provider);
3011
3017
  if (!modelSet) return null;
3012
3018
  const allModels = [...modelSet].toSorted(compareBucketItems);
@@ -3020,7 +3026,7 @@ function getDiscordModelPickerModelPage(params) {
3020
3026
  };
3021
3027
  }
3022
3028
  function resolveDiscordModelPickerPageForModel(params) {
3023
- const provider = normalizeProviderId(params.provider);
3029
+ const provider = normalizeProviderId$1(params.provider);
3024
3030
  const modelSet = params.data.byProvider.get(provider);
3025
3031
  if (!modelSet) return { page: 1 };
3026
3032
  const sorted = [...modelSet].toSorted(compareBucketItems);
@@ -3036,7 +3042,7 @@ function parseCurrentModelRef(raw) {
3036
3042
  const providerText = match[1];
3037
3043
  const model = match[2];
3038
3044
  if (providerText === void 0 || model === void 0) return null;
3039
- const provider = normalizeProviderId(providerText);
3045
+ const provider = normalizeProviderId$1(providerText);
3040
3046
  if (!provider || !model) return null;
3041
3047
  return {
3042
3048
  provider,
@@ -3101,7 +3107,7 @@ function buildBucketSelectRow(params) {
3101
3107
  }
3102
3108
  function getRuntimeChoices(params) {
3103
3109
  const model = parseCurrentModelRef(params.modelRef);
3104
- return getDiscordModelPickerRuntimeChoices(params.data, params.provider, model?.provider === normalizeProviderId(params.provider) ? model.model : void 0);
3110
+ return getDiscordModelPickerRuntimeChoices(params.data, params.provider, model?.provider === normalizeProviderId$1(params.provider) ? model.model : void 0);
3105
3111
  }
3106
3112
  function resolveExplicitRuntimeState(params) {
3107
3113
  const runtime = params.pendingRuntime?.trim() || params.currentRuntime?.trim();
@@ -3222,18 +3228,21 @@ function buildModelRows(params) {
3222
3228
  currentRuntime,
3223
3229
  pendingRuntime: params.pendingRuntime
3224
3230
  });
3231
+ const modelViewState = {
3232
+ command: params.command,
3233
+ userId: params.userId,
3234
+ view: "models",
3235
+ provider: params.modelPage.provider,
3236
+ page: params.modelPage.page,
3237
+ providerPage: providerPage.page
3238
+ };
3225
3239
  if (runtimeChoices && (runtimeChoices.length > 1 || runtimeChoices.length === 1 && selectedRuntime === void 0)) rows.push(new Row([createModelSelect({
3226
3240
  customId: buildDiscordModelPickerCustomId({
3227
- command: params.command,
3241
+ ...modelViewState,
3228
3242
  action: "runtime",
3229
- view: "models",
3230
- provider: params.modelPage.provider,
3231
- page: params.modelPage.page,
3232
- providerPage: providerPage.page,
3233
3243
  modelIndex: params.pendingModelIndex,
3234
3244
  modelToken: pendingModelToken,
3235
- ...params.pendingModelIndex === void 0 && activeModelBucket ? { modelBucket: activeModelBucket } : {},
3236
- userId: params.userId
3245
+ ...params.pendingModelIndex === void 0 && activeModelBucket ? { modelBucket: activeModelBucket } : {}
3237
3246
  }),
3238
3247
  options: runtimeChoices.map((choice) => {
3239
3248
  const option = {
@@ -3248,35 +3257,25 @@ function buildModelRows(params) {
3248
3257
  })]));
3249
3258
  const selectedModelRef = parsedPendingModel ?? parsedCurrentModel;
3250
3259
  const modelOptions = params.modelPage.items.map((model) => ({
3251
- label: model,
3252
- value: model,
3260
+ label: truncateCodePoints(model, 100),
3261
+ value: createDiscordModelPickerModelToken(params.modelPage.provider, model),
3253
3262
  default: selectedModelRef ? selectedModelRef.provider === params.modelPage.provider && selectedModelRef.model === model : false
3254
3263
  }));
3255
3264
  rows.push(new Row([createModelSelect({
3256
3265
  customId: buildDiscordModelPickerCustomId({
3257
- command: params.command,
3258
- action: "model",
3259
- view: "models",
3260
- provider: params.modelPage.provider,
3266
+ ...modelViewState,
3261
3267
  ...compactRuntime,
3262
- page: params.modelPage.page,
3263
- providerPage: providerPage.page,
3264
- userId: params.userId
3268
+ action: "pick"
3265
3269
  }),
3266
3270
  options: modelOptions,
3267
3271
  placeholder: `Select ${params.modelPage.provider} model`
3268
3272
  })]));
3269
3273
  const modelNavRow = buildPaginationRow({
3270
- command: params.command,
3271
- userId: params.userId,
3272
- view: "models",
3273
- page: params.modelPage.page,
3274
+ ...modelViewState,
3274
3275
  totalPages: params.modelPage.totalPages,
3275
3276
  hasPrev: params.modelPage.hasPrev,
3276
3277
  hasNext: params.modelPage.hasNext,
3277
- provider: params.modelPage.provider,
3278
3278
  ...compactRuntime,
3279
- providerPage: providerPage.page,
3280
3279
  modelIndex: params.pendingModelIndex,
3281
3280
  modelToken: pendingModelToken,
3282
3281
  modelBucket: activeModelBucket
@@ -3286,12 +3285,8 @@ function buildModelRows(params) {
3286
3285
  const shouldDisableReset = Boolean(parsedCurrentModel) && parsedCurrentModel?.provider === resolvedDefault.provider && parsedCurrentModel?.model === resolvedDefault.model;
3287
3286
  const hasPendingSelection = Boolean(parsedPendingModel) && parsedPendingModel?.provider === params.modelPage.provider && typeof params.pendingModelIndex === "number" && params.pendingModelIndex > 0;
3288
3287
  const modelActionState = {
3289
- command: params.command,
3290
- provider: params.modelPage.provider,
3291
- ...compactRuntime,
3292
- page: params.modelPage.page,
3293
- providerPage: providerPage.page,
3294
- userId: params.userId
3288
+ ...modelViewState,
3289
+ ...compactRuntime
3295
3290
  };
3296
3291
  const buttonRowItems = [
3297
3292
  createModelPickerButton({
@@ -3309,8 +3304,7 @@ function buildModelRows(params) {
3309
3304
  label: "Cancel",
3310
3305
  customId: buildDiscordModelPickerCustomId({
3311
3306
  ...modelActionState,
3312
- action: "cancel",
3313
- view: "models"
3307
+ action: "cancel"
3314
3308
  })
3315
3309
  }),
3316
3310
  createModelPickerButton({
@@ -3318,8 +3312,7 @@ function buildModelRows(params) {
3318
3312
  disabled: shouldDisableReset,
3319
3313
  customId: buildDiscordModelPickerCustomId({
3320
3314
  ...modelActionState,
3321
- action: "reset",
3322
- view: "models"
3315
+ action: "reset"
3323
3316
  })
3324
3317
  })
3325
3318
  ];
@@ -3339,7 +3332,6 @@ function buildModelRows(params) {
3339
3332
  customId: buildDiscordModelPickerCustomId({
3340
3333
  ...modelActionState,
3341
3334
  action: "submit",
3342
- view: "models",
3343
3335
  modelIndex: params.pendingModelIndex,
3344
3336
  modelToken: pendingModelToken
3345
3337
  })
@@ -3420,7 +3412,7 @@ function renderDiscordModelPickerModelsView(params) {
3420
3412
  return buildRenderedShell({
3421
3413
  title: "Model Picker",
3422
3414
  refreshWarning: params.data.refreshWarning,
3423
- detailLines: [formatCurrentModelLine(params.currentModel), `Provider not found: ${normalizeProviderId(params.provider)}`],
3415
+ detailLines: [formatCurrentModelLine(params.currentModel), `Provider not found: ${normalizeProviderId$1(params.provider)}`],
3424
3416
  rows,
3425
3417
  footer: "Choose a different provider."
3426
3418
  });
@@ -4045,9 +4037,15 @@ async function handleDiscordModelPickerInteraction(params) {
4045
4037
  });
4046
4038
  return;
4047
4039
  }
4048
- if (parsed.action === "model") {
4049
- const selectedModel = resolveModelPickerSelectionValue(interaction);
4040
+ if (parsed.action === "model" || parsed.action === "pick") {
4041
+ const selectedValue = resolveModelPickerSelectionValue(interaction);
4050
4042
  const provider = parsedProvider;
4043
+ const selectedModel = parsed.action === "pick" ? resolveDiscordModelPickerModelSelection({
4044
+ data: pickerData,
4045
+ provider: provider ?? "",
4046
+ modelToken: selectedValue ?? void 0,
4047
+ requireModelToken: true
4048
+ }) : selectedValue;
4051
4049
  if (!provider || !selectedModel) {
4052
4050
  await showNotice(MODEL_PICKER_CHANGED_MESSAGE);
4053
4051
  return;
@@ -4516,13 +4514,14 @@ async function dispatchDiscordCommandInteraction(params) {
4516
4514
  sender,
4517
4515
  allowNameMatching
4518
4516
  });
4519
- const { commandsAllowFromAccess, guildInfo, channelConfig } = resolveDiscordNativeCommandChannelAccessContext({
4517
+ const channelAccess = resolveDiscordNativeCommandChannelAccessContext({
4520
4518
  cfg,
4521
4519
  discordConfig,
4522
4520
  sender,
4523
4521
  ...channelContext,
4524
4522
  guild: interaction.guild ?? null
4525
4523
  });
4524
+ const { guildInfo, channelConfig } = channelAccess;
4526
4525
  let nativeRouteState;
4527
4526
  const getNativeRouteState = () => nativeRouteState ??= nativeCommandRuntime.resolveDiscordNativeInteractionRouteState({
4528
4527
  cfg,
@@ -4541,29 +4540,10 @@ async function dispatchDiscordCommandInteraction(params) {
4541
4540
  const routeState = getNativeRouteState();
4542
4541
  return routeState.effectiveRoute.matchedBy === "binding.channel" || routeState.boundSessionKey != null || routeState.configuredBinding != null;
4543
4542
  };
4544
- if (channelConfig?.enabled === false && !canBypassConfiguredAcpGuildGuards()) {
4545
- await respond("This channel is disabled.");
4546
- return { accepted: false };
4547
- }
4548
- if (interaction.guild && channelConfig?.allowed === false && !canBypassConfiguredAcpGuildGuards()) {
4549
- await respond("This channel is not allowed.");
4543
+ if (channelAccess.channelDenial && !canBypassConfiguredAcpGuildGuards()) {
4544
+ await respond(channelAccess.channelDenial === "disabled" ? "This channel is disabled." : "This channel is not allowed.");
4550
4545
  return { accepted: false };
4551
4546
  }
4552
- if (interaction.guild) {
4553
- const { groupPolicy } = resolveOpenProviderRuntimeGroupPolicy({
4554
- providerConfigPresent: cfg.channels?.discord !== void 0,
4555
- groupPolicy: discordConfig?.groupPolicy,
4556
- defaultGroupPolicy: cfg.channels?.defaults?.groupPolicy
4557
- });
4558
- if (!resolveDiscordChannelPolicyCommandAuthorizer({
4559
- groupPolicy,
4560
- guildInfo,
4561
- channelConfig
4562
- }).allowed && !canBypassConfiguredAcpGuildGuards()) {
4563
- await respond("This channel is not allowed.");
4564
- return { accepted: false };
4565
- }
4566
- }
4567
4547
  if (policy?.isCurrent() === false) {
4568
4548
  await respond("Access policy changed. Try this interaction again.", { ephemeral: true });
4569
4549
  return { accepted: false };
@@ -4630,11 +4610,7 @@ async function dispatchDiscordCommandInteraction(params) {
4630
4610
  }
4631
4611
  if (!isDirectMessage) {
4632
4612
  commandAuthorized = await resolveDiscordGuildNativeCommandAuthorized({
4633
- cfg,
4634
- discordConfig,
4635
- commandsAllowFromAccess,
4636
- guildInfo,
4637
- channelConfig,
4613
+ ...channelAccess,
4638
4614
  memberRoleIds,
4639
4615
  sender,
4640
4616
  allowNameMatching,
@@ -4886,28 +4862,8 @@ async function dispatchDiscordCommandInteraction(params) {
4886
4862
  hiddenFinalReply
4887
4863
  };
4888
4864
  }
4889
- function createDiscordCommandArgFallbackButton(params) {
4890
- return createDiscordCommandArgFallbackButton$1({
4891
- ctx: {
4892
- ...params,
4893
- readPolicy: resolveDiscordNativePolicyReader(params)
4894
- },
4895
- safeInteractionCall: safeDiscordInteractionCall,
4896
- dispatchCommandInteraction: dispatchDiscordCommandInteraction
4897
- });
4898
- }
4899
- function createDiscordModelPickerFallbackButton(params) {
4900
- return createDiscordModelPickerFallbackButton$1({
4901
- ctx: {
4902
- ...params,
4903
- readPolicy: resolveDiscordNativePolicyReader(params)
4904
- },
4905
- safeInteractionCall: safeDiscordInteractionCall,
4906
- dispatchCommandInteraction: dispatchDiscordCommandInteraction
4907
- });
4908
- }
4909
- function createDiscordModelPickerFallbackSelect(params) {
4910
- return createDiscordModelPickerFallbackSelect$1({
4865
+ function bindDiscordCommandControl(createControl) {
4866
+ return (params) => createControl({
4911
4867
  ctx: {
4912
4868
  ...params,
4913
4869
  readPolicy: resolveDiscordNativePolicyReader(params)
@@ -4916,6 +4872,9 @@ function createDiscordModelPickerFallbackSelect(params) {
4916
4872
  dispatchCommandInteraction: dispatchDiscordCommandInteraction
4917
4873
  });
4918
4874
  }
4875
+ const createDiscordCommandArgFallbackButton = bindDiscordCommandControl(createDiscordCommandArgFallbackButton$1);
4876
+ const createDiscordModelPickerFallbackButton = bindDiscordCommandControl(createDiscordModelPickerFallbackButton$1);
4877
+ const createDiscordModelPickerFallbackSelect = bindDiscordCommandControl(createDiscordModelPickerFallbackSelect$1);
4919
4878
  //#endregion
4920
4879
  //#region extensions/discord/src/internal/gateway-close-codes.ts
4921
4880
  const fatalGatewayCloseCodes = /* @__PURE__ */ new Set([
@@ -4942,7 +4901,7 @@ function canResumeAfterGatewayClose(code) {
4942
4901
  //#region extensions/discord/src/internal/gateway-identify-limiter.ts
4943
4902
  const IDENTIFY_WINDOW_MS = 5e3;
4944
4903
  function normalizeMaxConcurrency(value) {
4945
- const parsed = parseFiniteNumber(value);
4904
+ const parsed = parseFiniteNumber$1(value);
4946
4905
  return parsed === void 0 ? 1 : Math.max(1, Math.floor(parsed));
4947
4906
  }
4948
4907
  var GatewayIdentifyLimiter = class {
@@ -5256,7 +5215,6 @@ var GatewayPlugin = class extends Plugin {
5256
5215
  maxAttempts: 50,
5257
5216
  ...options.reconnect
5258
5217
  },
5259
- autoInteractions: options.autoInteractions ?? true,
5260
5218
  intents: options.intents ?? 0
5261
5219
  };
5262
5220
  this.gatewayInfo = gatewayInfo;
@@ -5270,18 +5228,6 @@ var GatewayPlugin = class extends Plugin {
5270
5228
  takeVoiceStateTransition(state) {
5271
5229
  return this.voiceStateCache.takeTransition(state);
5272
5230
  }
5273
- get heartbeatInterval() {
5274
- return this.heartbeatTimers.heartbeatInterval;
5275
- }
5276
- set heartbeatInterval(timer) {
5277
- this.heartbeatTimers.heartbeatInterval = timer;
5278
- }
5279
- get firstHeartbeatTimeout() {
5280
- return this.heartbeatTimers.firstHeartbeatTimeout;
5281
- }
5282
- set firstHeartbeatTimeout(timer) {
5283
- this.heartbeatTimers.firstHeartbeatTimeout = timer;
5284
- }
5285
5231
  async registerClient(client) {
5286
5232
  this.client = client;
5287
5233
  if (this.options.shard) {
@@ -5495,7 +5441,6 @@ var GatewayPlugin = class extends Plugin {
5495
5441
  dispatchVoiceGatewayEvent(this.client, payload);
5496
5442
  const data = payload.t === GatewayDispatchEvents.MessageCreate ? payload.d : mapGatewayDispatchData(this.client, payload.t, payload.d);
5497
5443
  await this.client.dispatchGatewayEvent(payload.t, data);
5498
- if (payload.t === GatewayDispatchEvents.InteractionCreate && this.options.autoInteractions) await this.client.handleInteraction(payload.d);
5499
5444
  }
5500
5445
  resetSessionState() {
5501
5446
  this.sessionId = null;
@@ -5622,12 +5567,10 @@ function resolveAuthAvailability(params) {
5622
5567
  })) ? "exhausted" : "degraded";
5623
5568
  }
5624
5569
  function resolveDiscordAutoPresenceUpdate(params) {
5625
- if (!resolveAutoPresenceConfig(params.discordConfig.autoPresence).enabled) return null;
5626
- const now = params.now ?? Date.now();
5627
5570
  const basePresence = resolveDiscordPresenceUpdate(params.discordConfig);
5628
5571
  const availability = resolveAuthAvailability({
5629
5572
  store: params.authStore,
5630
- now
5573
+ now: params.now
5631
5574
  });
5632
5575
  const state = params.gatewayConnected ? availability : "degraded";
5633
5576
  return state === "healthy" ? {
@@ -5655,19 +5598,14 @@ function stablePresenceSignature(payload) {
5655
5598
  }
5656
5599
  function createDiscordAutoPresenceController(params) {
5657
5600
  const autoCfg = resolveAutoPresenceConfig(params.discordConfig.autoPresence);
5658
- if (!autoCfg.enabled) return {
5659
- enabled: false,
5660
- start: () => void 0,
5661
- stop: () => void 0,
5662
- refresh: () => void 0,
5663
- runNow: () => void 0
5664
- };
5665
5601
  const loadAuthStore = params.loadAuthStore ?? (() => ensureAuthProfileStore());
5666
- const now = params.now ?? (() => Date.now());
5667
- let timer;
5602
+ const now = params.scheduler.now;
5603
+ const scheduler = params.scheduler.scope();
5604
+ let started = false;
5668
5605
  let lastAppliedSignature = null;
5669
5606
  let lastAppliedAt = 0;
5670
5607
  const runEvaluation = (options) => {
5608
+ if (!autoCfg.enabled || scheduler.signal.aborted) return;
5671
5609
  let presence;
5672
5610
  try {
5673
5611
  presence = resolveDiscordAutoPresenceUpdate({
@@ -5680,7 +5618,7 @@ function createDiscordAutoPresenceController(params) {
5680
5618
  params.log?.(warn(`discord: auto-presence evaluation failed for account ${params.accountId}: ${String(err)}`));
5681
5619
  return;
5682
5620
  }
5683
- if (!presence || !params.gateway.isConnected) return;
5621
+ if (!params.gateway.isConnected) return;
5684
5622
  const forceApply = options?.force === true;
5685
5623
  const ts = now();
5686
5624
  const signature = stablePresenceSignature(presence);
@@ -5691,19 +5629,20 @@ function createDiscordAutoPresenceController(params) {
5691
5629
  lastAppliedAt = ts;
5692
5630
  };
5693
5631
  return {
5694
- enabled: true,
5695
- runNow: () => runEvaluation(),
5632
+ enabled: autoCfg.enabled,
5696
5633
  refresh: () => runEvaluation({ force: true }),
5697
5634
  start: () => {
5698
- if (timer) return;
5635
+ if (!autoCfg.enabled || started || scheduler.signal.aborted) return;
5636
+ started = true;
5699
5637
  runEvaluation({ force: true });
5700
- timer = setInterval(() => runEvaluation(), autoCfg.intervalMs);
5638
+ scheduler.schedule({
5639
+ id: "presence",
5640
+ delayMs: autoCfg.intervalMs,
5641
+ everyMs: autoCfg.intervalMs,
5642
+ run: () => runEvaluation()
5643
+ });
5701
5644
  },
5702
- stop: () => {
5703
- if (!timer) return;
5704
- clearInterval(timer);
5705
- timer = void 0;
5706
- }
5645
+ stop: () => scheduler.stop()
5707
5646
  };
5708
5647
  }
5709
5648
  //#endregion
@@ -6136,8 +6075,7 @@ function createDiscordGatewayPlugin(params) {
6136
6075
  return createGatewayPlugin({
6137
6076
  options: {
6138
6077
  reconnect: { maxAttempts: 50 },
6139
- intents,
6140
- autoInteractions: false
6078
+ intents
6141
6079
  },
6142
6080
  gatewayInfoTimeoutMs,
6143
6081
  ...endpoint ? { endpoint } : {},
@@ -6329,42 +6267,32 @@ async function waitForDiscordGatewayStop(params) {
6329
6267
  abortSignal?.removeEventListener("abort", onAbort);
6330
6268
  params.gatewaySupervisor?.detachLifecycle();
6331
6269
  };
6332
- const finishResolve = () => {
6270
+ const finish = (settle) => {
6333
6271
  if (settled) return;
6334
6272
  settled = true;
6335
6273
  try {
6336
6274
  gateway?.disconnect?.();
6337
6275
  } finally {
6338
6276
  cleanup();
6339
- resolve();
6277
+ settle();
6340
6278
  }
6341
6279
  };
6342
6280
  const finishReject = (err) => {
6343
- if (settled) return;
6344
- settled = true;
6345
- try {
6346
- gateway?.disconnect?.();
6347
- } finally {
6348
- cleanup();
6349
- reject(toErrorObject(err, "Non-Error rejection"));
6350
- }
6281
+ finish(() => reject(toErrorObject(err, "Non-Error rejection")));
6351
6282
  };
6352
6283
  const onAbort = () => {
6353
- finishResolve();
6284
+ finish(resolve);
6354
6285
  };
6355
6286
  const onGatewayEvent = (event) => {
6356
6287
  if ((params.onGatewayEvent?.(event) ?? "stop") === "stop") finishReject(new DiscordGatewayLifecycleError(event));
6357
6288
  };
6358
- const onForceStop = (err) => {
6359
- finishReject(err);
6360
- };
6361
6289
  if (abortSignal?.aborted) {
6362
6290
  onAbort();
6363
6291
  return;
6364
6292
  }
6365
6293
  abortSignal?.addEventListener("abort", onAbort, { once: true });
6366
6294
  params.gatewaySupervisor?.attachLifecycle(onGatewayEvent);
6367
- params.registerForceStop?.(onForceStop);
6295
+ params.registerForceStop?.(finishReject);
6368
6296
  });
6369
6297
  }
6370
6298
  //#endregion
@@ -6457,8 +6385,7 @@ async function restartGatewayAfterReadyTimeout(params) {
6457
6385
  function parseGatewayCloseCode(message) {
6458
6386
  const match = /Gateway websocket closed:\s*(\d{3,5})/.exec(message);
6459
6387
  if (!match?.[1]) return;
6460
- const code = Number.parseInt(match[1], 10);
6461
- return Number.isFinite(code) ? code : void 0;
6388
+ return Number.parseInt(match[1], 10);
6462
6389
  }
6463
6390
  function resolveTransportActivityAt(event) {
6464
6391
  const at = event?.at;
@@ -6703,7 +6630,7 @@ async function runDiscordGatewayLifecycle(params) {
6703
6630
  });
6704
6631
  if (drainPendingGatewayErrors() === "stop") return;
6705
6632
  await waitForDiscordGatewayStop({
6706
- gateway: gateway ? { disconnect: () => gateway.disconnect() } : void 0,
6633
+ gateway,
6707
6634
  abortSignal: params.abortSignal,
6708
6635
  gatewaySupervisor: params.gatewaySupervisor,
6709
6636
  onGatewayEvent: handleGatewayEvent,
@@ -6736,34 +6663,20 @@ async function runDiscordGatewayLifecycle(params) {
6736
6663
  }
6737
6664
  //#endregion
6738
6665
  //#region extensions/discord/src/monitor/provider-runtime.ts
6739
- let discordVoiceRuntimePromise;
6740
- let discordProviderSessionRuntimePromise;
6741
- async function loadDiscordVoiceRuntime() {
6742
- const promise = discordVoiceRuntimePromise ?? import("./voice-runtime-B46rcwrG.mjs").then((n) => n.t);
6743
- discordVoiceRuntimePromise = promise;
6744
- try {
6745
- return await promise;
6746
- } catch (error) {
6747
- if (discordVoiceRuntimePromise === promise) discordVoiceRuntimePromise = void 0;
6748
- throw error;
6749
- }
6750
- }
6751
- async function loadDiscordProviderSessionRuntime() {
6752
- const promise = discordProviderSessionRuntimePromise ?? import("./provider-session.runtime-BYlTBFD2.mjs");
6753
- discordProviderSessionRuntimePromise = promise;
6754
- try {
6755
- return await promise;
6756
- } catch (error) {
6757
- if (discordProviderSessionRuntimePromise === promise) discordProviderSessionRuntimePromise = void 0;
6758
- throw error;
6759
- }
6760
- }
6666
+ const discordVoiceRuntime = createLazyRuntimeModule(() => import("./voice-runtime-Bc75quiH.mjs").then((n) => n.t).catch((error) => {
6667
+ discordVoiceRuntime.clear();
6668
+ throw error;
6669
+ }));
6670
+ const discordProviderSessionRuntime = createLazyRuntimeModule(() => import("./provider-session.runtime-BupCTZQv.mjs").catch((error) => {
6671
+ discordProviderSessionRuntime.clear();
6672
+ throw error;
6673
+ }));
6761
6674
  const discordProviderRuntime = {
6762
6675
  probeDiscordApplicationId,
6763
6676
  createDiscordNativeCommand,
6764
6677
  runDiscordGatewayLifecycle,
6765
- loadDiscordVoiceRuntime,
6766
- loadDiscordProviderSessionRuntime,
6678
+ loadDiscordVoiceRuntime: () => discordVoiceRuntime(),
6679
+ loadDiscordProviderSessionRuntime: () => discordProviderSessionRuntime(),
6767
6680
  createClient: (...args) => new Client(...args),
6768
6681
  resolveDiscordAccount,
6769
6682
  resolveNativeCommandsEnabled,
@@ -6824,11 +6737,7 @@ async function probeDiscordAcpBindingHealth(params) {
6824
6737
  kind: "error",
6825
6738
  error
6826
6739
  }));
6827
- const result = await raceWithTimeout({
6828
- promise: statusPromise,
6829
- timeoutMs: DISCORD_ACP_STATUS_PROBE_TIMEOUT_MS,
6830
- onTimeout: () => ({ kind: "timeout" })
6831
- });
6740
+ const result = await raceWithTimeout(statusPromise, DISCORD_ACP_STATUS_PROBE_TIMEOUT_MS, () => ({ kind: "timeout" }), { ref: false });
6832
6741
  if (result.kind === "timeout") statusProbeAbortController.abort();
6833
6742
  const runningForMs = resolveRunningActivityAgeMs(params);
6834
6743
  const isStaleRunning = params.storedState === "running" && runningForMs >= DISCORD_ACP_STALE_RUNNING_ACTIVITY_MS;
@@ -6860,7 +6769,7 @@ async function cleanupDiscordProviderStartup(params) {
6860
6769
  } finally {
6861
6770
  await listenersStopped;
6862
6771
  }
6863
- params.autoPresenceController?.stop();
6772
+ await params.autoPresenceController?.stop();
6864
6773
  params.setStatus?.({ connected: false });
6865
6774
  if (params.onEarlyGatewayDebug) params.earlyGatewayEmitter?.removeListener("debug", params.onEarlyGatewayDebug);
6866
6775
  if (!params.lifecycleStarted) try {
@@ -7017,7 +6926,7 @@ function createDiscordVoiceCommand(startupParams) {
7017
6926
  } });
7018
6927
  if (!access.ok) {
7019
6928
  await interaction.reply({
7020
- content: access.message ?? "Not authorized.",
6929
+ content: access.message,
7021
6930
  ephemeral: true
7022
6931
  });
7023
6932
  return;
@@ -7029,14 +6938,6 @@ function createDiscordVoiceCommand(startupParams) {
7029
6938
  });
7030
6939
  return;
7031
6940
  }
7032
- const guildId = access.guildId ?? ("guildId" in channel ? channel.guildId : void 0);
7033
- if (!guildId) {
7034
- await interaction.reply({
7035
- content: "Unable to resolve guild for this voice channel.",
7036
- ephemeral: true
7037
- });
7038
- return;
7039
- }
7040
6941
  const manager = params.getManager();
7041
6942
  if (!manager) {
7042
6943
  await interaction.reply({
@@ -7046,7 +6947,7 @@ function createDiscordVoiceCommand(startupParams) {
7046
6947
  return;
7047
6948
  }
7048
6949
  const result = await manager.join({
7049
- guildId,
6950
+ guildId: access.guildId,
7050
6951
  channelId: channel.id
7051
6952
  });
7052
6953
  await interaction.reply({
@@ -7085,7 +6986,7 @@ function createDiscordVoiceCommand(startupParams) {
7085
6986
  const access = await authorizeVoiceCommand(interaction, params, { channelOverride: sessionChannelId ? { id: sessionChannelId } : void 0 });
7086
6987
  if (!access.ok) {
7087
6988
  await interaction.reply({
7088
- content: access.message ?? "Not authorized.",
6989
+ content: access.message,
7089
6990
  ephemeral: true
7090
6991
  });
7091
6992
  return;
@@ -7166,30 +7067,6 @@ async function resolveDiscordProviderCommandSpecs(params) {
7166
7067
  };
7167
7068
  }
7168
7069
  //#endregion
7169
- //#region extensions/discord/src/monitor/provider.config-log.ts
7170
- function formatThreadBindingDurationForConfigLabel(durationMs) {
7171
- const label = formatThreadBindingDurationLabel(durationMs);
7172
- return label === "disabled" ? "off" : label;
7173
- }
7174
- function logDiscordResolvedConfig(params) {
7175
- const allowFromSummary = summarizeStringEntries({
7176
- entries: params.allowFrom ?? [],
7177
- limit: 4,
7178
- emptyText: "any"
7179
- });
7180
- const groupDmChannelSummary = summarizeStringEntries({
7181
- entries: params.groupDmChannels ?? [],
7182
- limit: 4,
7183
- emptyText: "any"
7184
- });
7185
- const guildSummary = summarizeStringEntries({
7186
- entries: Object.keys(params.guildEntries ?? {}),
7187
- limit: 4,
7188
- emptyText: "any"
7189
- });
7190
- logVerbose(`discord: config dm=${params.dmEnabled ? "on" : "off"} dmPolicy=${params.dmPolicy} allowFrom=${allowFromSummary} groupDm=${params.groupDmEnabled ? "on" : "off"} groupDmChannels=${groupDmChannelSummary} groupPolicy=${params.groupPolicy} guilds=${guildSummary} historyLimit=${params.historyLimit} mediaMaxMb=${Math.round(params.mediaMaxBytes / 1048576)} native=${params.nativeEnabled ? "on" : "off"} nativeSkills=${params.nativeSkillsEnabled ? "on" : "off"} accessGroups=${params.useAccessGroups ? "on" : "off"} threadBindings=${params.threadBindingsEnabled ? "on" : "off"} threadIdleTimeout=${formatThreadBindingDurationForConfigLabel(params.threadBindingIdleTimeoutMs)} threadMaxAge=${formatThreadBindingDurationForConfigLabel(params.threadBindingMaxAgeMs)}`);
7191
- }
7192
- //#endregion
7193
7070
  //#region extensions/discord/src/monitor/provider.deploy-errors.ts
7194
7071
  const DISCORD_DEPLOY_REJECTED_ENTRY_LIMIT = 3;
7195
7072
  function attachDiscordDeployRequestBody(err, body) {
@@ -7235,16 +7112,16 @@ function isAbortLikeError(err) {
7235
7112
  return name === "AbortError" || message === "This operation was aborted" || message === "The operation was aborted" || /\boperation was aborted\b/i.test(message);
7236
7113
  }
7237
7114
  function formatDiscordDeployRestOperation(err) {
7238
- const method = typeof err.deployRestMethod === "string" && err.deployRestMethod.trim().length > 0 ? err.deployRestMethod.toUpperCase() : void 0;
7239
- const path = typeof err.deployRestPath === "string" && err.deployRestPath.trim().length > 0 ? err.deployRestPath : void 0;
7115
+ const method = readNonBlankString(err.deployRestMethod)?.toUpperCase();
7116
+ const path = readNonBlankString(err.deployRestPath);
7240
7117
  if (method && path) return `${method} ${path}`;
7241
7118
  return method ?? path ?? "request";
7242
7119
  }
7243
7120
  function formatDiscordDeployErrorMessage(err) {
7244
7121
  if (!isAbortLikeError(err)) return formatErrorMessage(err);
7245
7122
  const deployErr = err && typeof err === "object" ? err : {};
7246
- const requestMs = parseFiniteNumber$1(deployErr.deployRequestMs);
7247
- const timeoutMs = parseFiniteNumber$1(deployErr.deployTimeoutMs);
7123
+ const requestMs = parseFiniteNumber(deployErr.deployRequestMs);
7124
+ const timeoutMs = parseFiniteNumber(deployErr.deployTimeoutMs);
7248
7125
  const operation = formatDiscordDeployRestOperation(deployErr);
7249
7126
  if (!(requestMs !== void 0 || timeoutMs !== void 0 || deployErr.deployRestMethod !== void 0 || deployErr.deployRestPath !== void 0)) return "Discord REST request was aborted";
7250
7127
  const timing = [];
@@ -7257,11 +7134,11 @@ function formatDiscordDeployErrorMessage(err) {
7257
7134
  function resolveDiscordDeployRateLimitDetails(err) {
7258
7135
  if (!err || typeof err !== "object") return;
7259
7136
  const deployErr = err;
7260
- const status = parseStrictNonNegativeInteger$1(deployErr.status) ?? parseStrictNonNegativeInteger$1(deployErr.statusCode);
7261
- const retryAfterSeconds = parseFiniteNumber$1(deployErr.retryAfter) ?? parseFiniteNumber$1(readDiscordDeployObjectField(deployErr.rawBody, "retry_after"));
7137
+ const status = parseStrictNonNegativeInteger(deployErr.status) ?? parseStrictNonNegativeInteger(deployErr.statusCode);
7138
+ const retryAfterSeconds = parseFiniteNumber(deployErr.retryAfter) ?? parseFiniteNumber(readDiscordDeployObjectField(deployErr.rawBody, "retry_after"));
7262
7139
  if (!(err instanceof RateLimitError || status === 429 || retryAfterSeconds !== void 0)) return;
7263
7140
  const rawGlobal = readDiscordDeployObjectField(deployErr.rawBody, "global");
7264
- const scope = typeof deployErr.scope === "string" && deployErr.scope.trim().length > 0 ? deployErr.scope : rawGlobal === true ? "global" : rawGlobal === false ? "route" : void 0;
7141
+ const scope = readNonBlankString(deployErr.scope) ?? (rawGlobal === true ? "global" : rawGlobal === false ? "route" : void 0);
7265
7142
  const discordCode = typeof deployErr.discordCode === "number" || typeof deployErr.discordCode === "string" ? deployErr.discordCode : void 0;
7266
7143
  return {
7267
7144
  status,
@@ -7345,8 +7222,8 @@ function formatDiscordDeployErrorDetails(err) {
7345
7222
  function isDiscordDeployDailyCreateLimit(err) {
7346
7223
  if (!err || typeof err !== "object") return false;
7347
7224
  const deployErr = err;
7348
- const discordCode = parseStrictNonNegativeInteger$1(deployErr.discordCode);
7349
- const rawCode = parseStrictNonNegativeInteger$1(readDiscordDeployObjectField(deployErr.rawBody, "code"));
7225
+ const discordCode = parseStrictNonNegativeInteger(deployErr.discordCode);
7226
+ const rawCode = parseStrictNonNegativeInteger(readDiscordDeployObjectField(deployErr.rawBody, "code"));
7350
7227
  return (discordCode === 30034 || rawCode === 30034) && /daily application command creates/i.test(formatErrorMessage(err));
7351
7228
  }
7352
7229
  //#endregion
@@ -7423,11 +7300,7 @@ function installDeployRestLogging(params) {
7423
7300
  });
7424
7301
  }
7425
7302
  return () => {
7426
- params.rest.get = original.get;
7427
- params.rest.post = original.post;
7428
- params.rest.put = original.put;
7429
- params.rest.patch = original.patch;
7430
- params.rest.delete = original.delete;
7303
+ Object.assign(params.rest, original);
7431
7304
  };
7432
7305
  }
7433
7306
  async function deployDiscordCommands(params) {
@@ -7443,7 +7316,7 @@ async function deployDiscordCommands(params) {
7443
7316
  });
7444
7317
  try {
7445
7318
  try {
7446
- await params.client.deployCommands({ mode: "reconcile" });
7319
+ await params.client.deployCommands();
7447
7320
  } catch (err) {
7448
7321
  if (isDiscordDeployDailyCreateLimit(err)) {
7449
7322
  params.runtime.log?.(warn(`[${accountId}] slash command deploy skipped: daily application command create limit reached. Existing slash commands stay active until Discord resets the quota; message send/receive is unaffected.`));
@@ -7534,16 +7407,7 @@ var DiscordActivityButton = class extends Button {
7534
7407
  this.logPendingLaunchFailure(error);
7535
7408
  return "failed";
7536
7409
  });
7537
- let timer;
7538
- const timeout = new Promise((resolve) => {
7539
- timer = setTimeout(() => resolve("timeout"), PENDING_LAUNCH_WRITE_BUDGET_MS);
7540
- timer.unref?.();
7541
- });
7542
- try {
7543
- if (await Promise.race([write, timeout]) === "timeout") this.logPendingLaunchFailure(/* @__PURE__ */ new Error(`pending launch write exceeded ${PENDING_LAUNCH_WRITE_BUDGET_MS}ms`));
7544
- } finally {
7545
- if (timer) clearTimeout(timer);
7546
- }
7410
+ if (await raceWithTimeout(write, PENDING_LAUNCH_WRITE_BUDGET_MS, () => "timeout", { ref: false }) === "timeout") this.logPendingLaunchFailure(/* @__PURE__ */ new Error(`pending launch write exceeded ${PENDING_LAUNCH_WRITE_BUDGET_MS}ms`));
7547
7411
  }
7548
7412
  await interaction.launchActivity();
7549
7413
  }
@@ -7592,12 +7456,10 @@ async function ackComponentInteraction(params) {
7592
7456
  }
7593
7457
  }
7594
7458
  async function replyUnavailableComponentInteraction(interaction, content) {
7595
- try {
7596
- await interaction.reply({
7597
- content,
7598
- ephemeral: true
7599
- });
7600
- } catch {}
7459
+ await replySilently(interaction, {
7460
+ content,
7461
+ ephemeral: true
7462
+ });
7601
7463
  }
7602
7464
  function resolveDiscordChannelContext(interaction) {
7603
7465
  const channel = interaction.channel;
@@ -7931,8 +7793,8 @@ function resolveComponentRuntimeGroupPolicy(ctx) {
7931
7793
  }).groupPolicy;
7932
7794
  }
7933
7795
  async function ensureGuildComponentMemberAllowed(params) {
7934
- const { interaction, guildInfo, channelId, rawGuildId, channelCtx, memberRoleIds, user, replyOpts, componentLabel, unauthorizedReply } = params;
7935
- if (!rawGuildId) return true;
7796
+ const { interaction, guildInfo, user, replyOpts, componentLabel, unauthorizedReply } = params;
7797
+ if (!params.rawGuildId) return true;
7936
7798
  const replyUnauthorized = async () => {
7937
7799
  await replySilently(interaction, {
7938
7800
  content: unauthorizedReply,
@@ -7941,37 +7803,26 @@ async function ensureGuildComponentMemberAllowed(params) {
7941
7803
  };
7942
7804
  const channelConfig = resolveDiscordChannelConfigWithFallback({
7943
7805
  guildInfo,
7944
- channelId,
7945
- channelName: channelCtx.channelName,
7946
- channelSlug: channelCtx.channelSlug,
7947
- parentId: channelCtx.parentId,
7948
- parentName: channelCtx.parentName,
7949
- parentSlug: channelCtx.parentSlug,
7950
- scope: channelCtx.isThread ? "thread" : "channel"
7951
- });
7952
- if (channelConfig?.enabled === false) {
7953
- await replyUnauthorized();
7954
- return false;
7955
- }
7956
- const channelAllowlistConfigured = Boolean(guildInfo?.channels) && Object.keys(guildInfo?.channels ?? {}).length > 0;
7957
- const channelAllowed = channelConfig?.allowed !== false;
7958
- if (!isDiscordGroupAllowedByPolicy({
7806
+ channelId: params.channelId,
7807
+ channelName: params.channelCtx.channelName,
7808
+ channelSlug: params.channelCtx.channelSlug,
7809
+ parentId: params.channelCtx.parentId,
7810
+ parentName: params.channelCtx.parentName,
7811
+ parentSlug: params.channelCtx.parentSlug,
7812
+ scope: params.channelCtx.isThread ? "thread" : "channel"
7813
+ });
7814
+ if (channelConfig?.enabled === false || !resolveDiscordChannelPolicyCommandAuthorizer({
7959
7815
  groupPolicy: params.groupPolicy,
7960
- guildAllowlisted: Boolean(guildInfo),
7961
- channelAllowlistConfigured,
7962
- channelAllowed
7963
- })) {
7964
- await replyUnauthorized();
7965
- return false;
7966
- }
7967
- if (channelConfig?.allowed === false) {
7816
+ guildInfo,
7817
+ channelConfig
7818
+ }).allowed || channelConfig?.allowed === false) {
7968
7819
  await replyUnauthorized();
7969
7820
  return false;
7970
7821
  }
7971
7822
  const { memberAllowed } = resolveDiscordMemberAccessState({
7972
7823
  channelConfig,
7973
7824
  guildInfo,
7974
- memberRoleIds,
7825
+ memberRoleIds: params.memberRoleIds,
7975
7826
  sender: {
7976
7827
  id: user.id,
7977
7828
  name: user.username,
@@ -8017,16 +7868,9 @@ async function ensureAgentComponentInteractionAllowed(params) {
8017
7868
  });
8018
7869
  const channelCtx = resolveDiscordChannelContext(params.interaction);
8019
7870
  if (!await ensureGuildComponentMemberAllowed({
8020
- interaction: params.interaction,
7871
+ ...params,
8021
7872
  guildInfo,
8022
- channelId: params.channelId,
8023
- rawGuildId: params.rawGuildId,
8024
7873
  channelCtx,
8025
- memberRoleIds: params.memberRoleIds,
8026
- user: params.user,
8027
- replyOpts: params.replyOpts,
8028
- componentLabel: params.componentLabel,
8029
- unauthorizedReply: params.unauthorizedReply,
8030
7874
  allowNameMatching: isDangerousNameMatchingEnabled(ctx.discordConfig),
8031
7875
  groupPolicy: resolveComponentRuntimeGroupPolicy(ctx)
8032
7876
  })) return null;
@@ -8050,7 +7894,7 @@ async function resolveAuthorizedComponentInteraction(params) {
8050
7894
  defer: params.defer
8051
7895
  });
8052
7896
  if (!interactionCtx) return null;
8053
- const { channelId, user, replyOpts, rawGuildId, memberRoleIds } = interactionCtx;
7897
+ const { channelId, user, replyOpts, rawGuildId } = interactionCtx;
8054
7898
  const guildInfo = resolveDiscordGuildEntry({
8055
7899
  guild: params.interaction.guild ?? void 0,
8056
7900
  guildId: rawGuildId,
@@ -8069,16 +7913,10 @@ async function resolveAuthorizedComponentInteraction(params) {
8069
7913
  scope: channelCtx.isThread ? "thread" : "channel"
8070
7914
  });
8071
7915
  if (!await ensureGuildComponentMemberAllowed({
8072
- interaction: params.interaction,
7916
+ ...params,
7917
+ ...interactionCtx,
8073
7918
  guildInfo,
8074
- channelId,
8075
- rawGuildId,
8076
7919
  channelCtx,
8077
- memberRoleIds,
8078
- user,
8079
- replyOpts,
8080
- componentLabel: params.componentLabel,
8081
- unauthorizedReply: params.unauthorizedReply,
8082
7920
  allowNameMatching,
8083
7921
  groupPolicy: resolveComponentRuntimeGroupPolicy(ctx)
8084
7922
  })) return null;
@@ -8118,24 +7956,21 @@ async function resolveAuthorizedComponentInteraction(params) {
8118
7956
  async function resolveComponentCommandAuthorized(params) {
8119
7957
  const { ctx, interactionCtx, channelConfig, guildInfo } = params;
8120
7958
  if (interactionCtx.isDirectMessage) return true;
7959
+ const sender = {
7960
+ id: interactionCtx.user.id,
7961
+ name: interactionCtx.user.username,
7962
+ tag: formatDiscordUserTag(interactionCtx.user)
7963
+ };
8121
7964
  const { ownerAllowList, ownerAllowed: ownerOk } = resolveDiscordOwnerAccess({
8122
7965
  allowFrom: ctx.allowFrom,
8123
- sender: {
8124
- id: interactionCtx.user.id,
8125
- name: interactionCtx.user.username,
8126
- tag: formatDiscordUserTag(interactionCtx.user)
8127
- },
7966
+ sender,
8128
7967
  allowNameMatching: params.allowNameMatching
8129
7968
  });
8130
7969
  const { hasAccessRestrictions, memberAllowed } = resolveDiscordMemberAccessState({
8131
7970
  channelConfig,
8132
7971
  guildInfo,
8133
7972
  memberRoleIds: interactionCtx.memberRoleIds,
8134
- sender: {
8135
- id: interactionCtx.user.id,
8136
- name: interactionCtx.user.username,
8137
- tag: formatDiscordUserTag(interactionCtx.user)
8138
- },
7973
+ sender,
8139
7974
  allowNameMatching: params.allowNameMatching
8140
7975
  });
8141
7976
  return resolveCommandAuthorizedFromAuthorizers({
@@ -8357,7 +8192,7 @@ async function deliverDiscordReply(params) {
8357
8192
  //#endregion
8358
8193
  //#region extensions/discord/src/monitor/agent-components.dispatch.ts
8359
8194
  const loadReplyRuntime = createLazyRuntimeModule(() => import("openclaw/plugin-sdk/reply-runtime"));
8360
- const loadTypingRuntime = createLazyRuntimeModule(() => import("./typing-BiHCzBRu.mjs").then((n) => n.n));
8195
+ const loadTypingRuntime = createLazyRuntimeModule(() => import("./typing-CNlSKY5S.mjs").then((n) => n.n));
8361
8196
  function buildDiscordComponentConversationLabel(params) {
8362
8197
  if (params.interactionCtx.isDirectMessage) return buildDirectLabel(params.interactionCtx.user);
8363
8198
  if (params.interactionCtx.isGroupDm) return `Group DM #${params.channelCtx.channelName ?? params.interactionCtx.channelId} channel id:${params.interactionCtx.channelId}`;
@@ -8752,7 +8587,7 @@ async function dispatchPluginDiscordInteractiveEvent(params) {
8752
8587
  }
8753
8588
  //#endregion
8754
8589
  //#region extensions/discord/src/monitor/agent-components.handlers.ts
8755
- const loadComponentsRuntime = createLazyRuntimeModule(() => import("./components-Cq1PvIpN.mjs").then((n) => n.t));
8590
+ const loadComponentsRuntime = createLazyRuntimeModule(() => import("./components-CzXLR3QH.mjs").then((n) => n.t));
8756
8591
  async function handleDiscordComponentEvent(params) {
8757
8592
  const parsed = parseDiscordComponentData(params.data, resolveInteractionCustomId(params.interaction));
8758
8593
  if (!parsed) {
@@ -9183,28 +9018,11 @@ var DiscordComponentButton = class extends Button {
9183
9018
  });
9184
9019
  }
9185
9020
  };
9186
- function bindSelectControl(spec) {
9187
- return (ctx, handlers) => new DiscordComponentSelectControl(spec, ctx, handlers);
9188
- }
9189
- function createDiscordComponentButtonControl(ctx, handlers) {
9190
- return new DiscordComponentButton(ctx, handlers);
9191
- }
9192
- const createDiscordComponentStringSelectControl = bindSelectControl(SELECT_CONTROLS.string);
9193
- const createDiscordComponentUserSelectControl = bindSelectControl(SELECT_CONTROLS.user);
9194
- const createDiscordComponentRoleSelectControl = bindSelectControl(SELECT_CONTROLS.role);
9195
- const createDiscordComponentMentionableSelectControl = bindSelectControl(SELECT_CONTROLS.mentionable);
9196
- const createDiscordComponentChannelSelectControl = bindSelectControl(SELECT_CONTROLS.channel);
9021
+ const discordComponentControlFactories = [(ctx, handlers) => new DiscordComponentButton(ctx, handlers), ...Object.values(SELECT_CONTROLS).map((spec) => (ctx, handlers) => new DiscordComponentSelectControl(spec, ctx, handlers))];
9197
9022
  //#endregion
9198
9023
  //#region extensions/discord/src/monitor/agent-components.ts
9199
9024
  const createAgentComponentControls = [createAgentComponentButton, createAgentSelectMenu];
9200
- const createDiscordComponentControls = [
9201
- createDiscordComponentButtonControl,
9202
- createDiscordComponentStringSelectControl,
9203
- createDiscordComponentUserSelectControl,
9204
- createDiscordComponentRoleSelectControl,
9205
- createDiscordComponentMentionableSelectControl,
9206
- createDiscordComponentChannelSelectControl
9207
- ].map((createControl) => (ctx) => createControl(ctx, discordComponentControlHandlers));
9025
+ const createDiscordComponentControls = discordComponentControlFactories.map((createControl) => (ctx) => createControl(ctx, discordComponentControlHandlers));
9208
9026
  function createDiscordComponentModal(ctx) {
9209
9027
  return new DiscordComponentModal(ctx);
9210
9028
  }
@@ -9499,7 +9317,6 @@ var VoicePlugin = class extends Plugin {
9499
9317
  this.adapters = /* @__PURE__ */ new Map();
9500
9318
  }
9501
9319
  registerClient(client) {
9502
- this.client = client;
9503
9320
  this.gatewayPlugin = client.getPlugin("gateway");
9504
9321
  if (!this.gatewayPlugin) throw new Error("Discord voice cannot be used without a gateway connection.");
9505
9322
  }
@@ -9542,7 +9359,7 @@ function resolveDiscordPreflightChannelAccess(params) {
9542
9359
  channelSlug: params.displayChannelSlug
9543
9360
  });
9544
9361
  if (params.isGroupDm && !groupDmAllowed) return false;
9545
- const channelAllowlistConfigured = Boolean(params.guildInfo?.channels) && Object.keys(params.guildInfo?.channels ?? {}).length > 0;
9362
+ const channelAllowlistConfigured = hasConfiguredDiscordChannels(params.guildInfo?.channels);
9546
9363
  const channelAllowed = params.channelConfig?.allowed !== false;
9547
9364
  if (params.isGuildMessage && !isDiscordGroupAllowedByPolicy({
9548
9365
  groupPolicy: params.groupPolicy,
@@ -9739,7 +9556,6 @@ async function createDiscordMonitorClient(params) {
9739
9556
  commandDeployHashStore: params.commandDeployHashStore,
9740
9557
  requestOptions: {
9741
9558
  timeout: DISCORD_REST_TIMEOUT_MS,
9742
- maxQueueSize: 1e3,
9743
9559
  ...params.restFetch ? { fetch: params.restFetch } : {}
9744
9560
  },
9745
9561
  eventQueue: eventQueueOpts
@@ -9759,6 +9575,7 @@ async function createDiscordMonitorClient(params) {
9759
9575
  });
9760
9576
  if (gateway) {
9761
9577
  autoPresenceController = params.createAutoPresenceController({
9578
+ scheduler: params.scheduler,
9762
9579
  accountId: params.accountId,
9763
9580
  discordConfig: params.discordConfig,
9764
9581
  gateway,
@@ -9807,8 +9624,7 @@ async function fetchDiscordBotIdentity(params) {
9807
9624
  };
9808
9625
  }
9809
9626
  function registerDiscordMonitorListeners(params) {
9810
- registerDiscordListener(params.client.listeners, new DiscordInteractionListener(params.logger, params.trackInboundEvent));
9811
- registerDiscordListener(params.client.listeners, new DiscordMessageListener(params.messageHandler, params.logger, params.trackInboundEvent));
9627
+ for (const listener of [new DiscordInteractionListener(params.logger, params.trackInboundEvent), new DiscordMessageListener(params.messageHandler, params.logger, params.trackInboundEvent)]) registerDiscordListener(params.client.listeners, listener);
9812
9628
  const guildJoinListener = new DiscordGuildJoinIntroductionListener({
9813
9629
  readPolicy: params.readPolicy,
9814
9630
  cfg: params.cfg,
@@ -9836,12 +9652,13 @@ function registerDiscordMonitorListeners(params) {
9836
9652
  logger: params.logger,
9837
9653
  onEvent: params.trackInboundEvent
9838
9654
  };
9839
- registerDiscordListener(params.client.listeners, new DiscordReactionListener(reactionListenerOptions));
9840
- registerDiscordListener(params.client.listeners, new DiscordReactionRemoveListener(reactionListenerOptions));
9655
+ for (const listener of [new DiscordReactionListener(reactionListenerOptions), new DiscordReactionRemoveListener(reactionListenerOptions)]) registerDiscordListener(params.client.listeners, listener);
9841
9656
  const threadUpdateListener = new DiscordThreadUpdateListener(params.cfg, params.logger);
9842
- registerDiscordListener(params.client.listeners, threadUpdateListener);
9843
- registerDiscordListener(params.client.listeners, new DiscordThreadReadyListener(threadUpdateListener));
9844
- registerDiscordListener(params.client.listeners, new DiscordThreadDeleteListener(params.cfg, params.accountId, params.logger));
9657
+ for (const listener of [
9658
+ threadUpdateListener,
9659
+ new DiscordThreadReadyListener(threadUpdateListener),
9660
+ new DiscordThreadDeleteListener(params.cfg, params.accountId, params.logger)
9661
+ ]) registerDiscordListener(params.client.listeners, listener);
9845
9662
  let presenceListener;
9846
9663
  if (params.discordConfig.intents?.presence) {
9847
9664
  presenceListener = new DiscordPresenceListener({
@@ -9852,10 +9669,12 @@ function registerDiscordMonitorListeners(params) {
9852
9669
  botUserId: params.botUserId,
9853
9670
  guildEntries: params.guildEntries
9854
9671
  });
9855
- registerDiscordListener(params.client.listeners, presenceListener);
9856
- registerDiscordListener(params.client.listeners, new DiscordPresenceGuildCreateListener(presenceListener));
9857
- registerDiscordListener(params.client.listeners, new DiscordPresenceGuildDeleteListener(presenceListener));
9858
- registerDiscordListener(params.client.listeners, new DiscordPresenceReadyListener(presenceListener));
9672
+ for (const listener of [
9673
+ presenceListener,
9674
+ new DiscordPresenceGuildCreateListener(presenceListener),
9675
+ new DiscordPresenceGuildDeleteListener(presenceListener),
9676
+ new DiscordPresenceReadyListener(presenceListener)
9677
+ ]) registerDiscordListener(params.client.listeners, listener);
9859
9678
  params.runtime.log?.("discord: GuildPresences intent enabled — presence listener registered");
9860
9679
  }
9861
9680
  return async () => {
@@ -9878,11 +9697,16 @@ function formatDiscordStartupStatusMessage(params) {
9878
9697
  //#region extensions/discord/src/monitor/provider.ts
9879
9698
  const DEFAULT_DISCORD_MEDIA_MAX_MB = 100;
9880
9699
  const DISCORD_DISALLOWED_INTENTS_CODE = GatewayCloseCodes$1.DisallowedIntents;
9700
+ function formatThreadBindingDurationForConfigLabel(durationMs) {
9701
+ const label = formatThreadBindingDurationLabel(durationMs);
9702
+ return label === "disabled" ? "off" : label;
9703
+ }
9881
9704
  function isDiscordDisallowedIntentsError(err) {
9882
9705
  if (!err) return false;
9883
9706
  return formatErrorMessage(err).includes(String(DISCORD_DISALLOWED_INTENTS_CODE));
9884
9707
  }
9885
- async function monitorDiscordProvider(opts = {}) {
9708
+ async function monitorDiscordProvider(opts) {
9709
+ const { scheduler } = opts;
9886
9710
  const startupStartedAt = Date.now();
9887
9711
  const cfg = opts.config ?? getRuntimeConfig();
9888
9712
  const readConfig = opts.readConfig ?? createRuntimeConfigReader(cfg);
@@ -9991,25 +9815,26 @@ async function monitorDiscordProvider(opts = {}) {
9991
9815
  abortSignal: opts.abortSignal,
9992
9816
  resolvedAllowlist: allowlistResolved
9993
9817
  });
9994
- if (discordProviderRuntime.shouldLogVerbose()) logDiscordResolvedConfig({
9995
- dmEnabled,
9996
- dmPolicy,
9997
- allowFrom,
9998
- groupDmEnabled,
9999
- groupDmChannels,
10000
- groupPolicy,
10001
- guildEntries,
10002
- historyLimit,
10003
- mediaMaxBytes,
10004
- nativeEnabled,
10005
- nativeSkillsEnabled,
10006
- useAccessGroups,
10007
- threadBindingsEnabled,
10008
- threadBindingIdleTimeoutMs,
10009
- threadBindingMaxAgeMs
10010
- });
9818
+ if (discordProviderRuntime.shouldLogVerbose()) {
9819
+ const allowFromSummary = summarizeStringEntries({
9820
+ entries: allowFrom,
9821
+ limit: 4,
9822
+ emptyText: "any"
9823
+ });
9824
+ const groupDmChannelSummary = summarizeStringEntries({
9825
+ entries: groupDmChannels ?? [],
9826
+ limit: 4,
9827
+ emptyText: "any"
9828
+ });
9829
+ const guildSummary = summarizeStringEntries({
9830
+ entries: Object.keys(guildEntries ?? {}),
9831
+ limit: 4,
9832
+ emptyText: "any"
9833
+ });
9834
+ logVerbose(`discord: config dm=${dmEnabled ? "on" : "off"} dmPolicy=${dmPolicy} allowFrom=${allowFromSummary} groupDm=${groupDmEnabled ? "on" : "off"} groupDmChannels=${groupDmChannelSummary} groupPolicy=${groupPolicy} guilds=${guildSummary} historyLimit=${historyLimit} mediaMaxMb=${Math.round(mediaMaxBytes / 1048576)} native=${nativeEnabled ? "on" : "off"} nativeSkills=${nativeSkillsEnabled ? "on" : "off"} accessGroups=on threadBindings=${threadBindingsEnabled ? "on" : "off"} threadIdleTimeout=${formatThreadBindingDurationForConfigLabel(threadBindingIdleTimeoutMs)} threadMaxAge=${formatThreadBindingDurationForConfigLabel(threadBindingMaxAgeMs)}`);
9835
+ }
10011
9836
  logStartupPhase("fetch-application-id:start");
10012
- const parsedApplicationId = (typeof discordCfg.applicationId === "string" && discordCfg.applicationId.trim() ? discordCfg.applicationId.trim() : void 0) ?? parseApplicationIdFromToken(token);
9837
+ const parsedApplicationId = normalizeOptionalString(discordCfg.applicationId) ?? parseApplicationIdFromToken(token);
10013
9838
  const applicationIdProbe = parsedApplicationId ? {
10014
9839
  kind: "resolved",
10015
9840
  applicationId: parsedApplicationId
@@ -10110,6 +9935,7 @@ async function monitorDiscordProvider(opts = {}) {
10110
9935
  createNativeCommand: discordProviderRuntime.createDiscordNativeCommand
10111
9936
  });
10112
9937
  const { client, gateway, gatewaySupervisor: createdGatewaySupervisor, autoPresenceController: createdAutoPresenceController } = await createDiscordMonitorClient({
9938
+ scheduler,
10113
9939
  accountId: account.accountId,
10114
9940
  applicationId,
10115
9941
  token,
@@ -10158,6 +9984,7 @@ async function monitorDiscordProvider(opts = {}) {
10158
9984
  if (voiceEnabled) {
10159
9985
  const { DiscordVoiceGuildCreateListener, DiscordVoiceManager, DiscordVoiceReadyListener, DiscordVoiceResumedListener, DiscordVoiceStateUpdateListener } = await discordProviderRuntime.loadDiscordVoiceRuntime();
10160
9986
  voiceManager = new DiscordVoiceManager({
9987
+ scheduler,
10161
9988
  readPolicy,
10162
9989
  client,
10163
9990
  cfg,