@openclaw/discord 2026.9.6 → 2026.9.8

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 (150) hide show
  1. package/assets/icon.png +0 -0
  2. package/dist/.setup/{account-inspect-BwQj24ht.mjs → account-inspect-De8hOUxG.mjs} +1 -1
  3. package/dist/.setup/{accounts-CwJQoLjM.mjs → accounts-ChaMcixG.mjs} +1 -4
  4. package/dist/.setup/{activities-api-COU4-0nR.mjs → activities-api-tvbsU2e3.mjs} +38 -66
  5. package/dist/.setup/{api-CBK9zcq5.mjs → api-DVbJwZVt.mjs} +10 -2
  6. package/dist/.setup/{approval-handler.runtime-CbBktBb4.mjs → approval-handler.runtime-DxCK2Rux.mjs} +49 -125
  7. package/dist/.setup/{approval-message-updates-jf9zMaIC.mjs → approval-message-updates-BKFqavHZ.mjs} +2 -2
  8. package/dist/.setup/{audit-vKbh-LFR.mjs → audit-CLg9I71N.mjs} +5 -5
  9. package/dist/.setup/{channel-Dv4e3Jpc.mjs → channel-DxlUVU9t.mjs} +121 -227
  10. package/dist/.setup/{channel-type-DKnjV1XW.mjs → channel-type-DRCrEMss.mjs} +22 -22
  11. package/dist/.setup/{channel.setup-0NX6FFwi.mjs → channel.setup-CRo1GjV7.mjs} +6 -9
  12. package/dist/.setup/{components-yBEb75bB.mjs → components-Cq1PvIpN.mjs} +41 -69
  13. package/dist/.setup/{config-schema-CiZz-mtA.mjs → config-schema-oxELUSDx.mjs} +19 -44
  14. package/dist/.setup/{conversation-binding-route-B7qImK_b.mjs → conversation-binding-route-Caz_XuFH.mjs} +10 -5
  15. package/dist/.setup/{directory-config-BytTftz-.mjs → directory-config-esqNn0Eo.mjs} +6 -9
  16. package/dist/.setup/{directory-live--EGTH0DC.mjs → directory-live-DtKRHuGV.mjs} +6 -12
  17. package/dist/.setup/{discord-BXpHW-cu.mjs → discord-0xJYfdDD.mjs} +82 -386
  18. package/dist/.setup/{doctor-D1R-uFIu.mjs → doctor-BCl1H5tl.mjs} +21 -36
  19. package/dist/.setup/{doctor-contract-Co5vRCZ6.mjs → doctor-contract-CvvgwrrG.mjs} +41 -50
  20. package/dist/.setup/{channel-actions.runtime-leZuw01r.mjs → handle-action-CUvQWnE7.mjs} +67 -104
  21. package/dist/.setup/{handle-action.guild-admin-DcFa8NwA.mjs → handle-action.guild-admin-Df-8gVle.mjs} +62 -120
  22. package/dist/.setup/{live-policy-config-eKQ-PLdy.mjs → live-policy-config-8Pv20CHc.mjs} +2 -3
  23. package/dist/.setup/{message-handler-X6ejmbtY.mjs → message-handler-B-Jk4oDk.mjs} +18 -94
  24. package/dist/.setup/{message-handler.preflight-pluralkit-8Xji34AF.mjs → message-handler.preflight-pluralkit-CWLUBVcx.mjs} +8 -10
  25. package/dist/.setup/{message-handler.preflight-DE_POxFc.mjs → message-handler.preflight-v-__NSDq.mjs} +69 -180
  26. package/dist/.setup/{message-handler.process-CCmIVnxy.mjs → message-handler.process-BNFFuChn.mjs} +65 -86
  27. package/dist/.setup/{outbound-adapter-ClIgmu4F.mjs → outbound-adapter-BobT-kse.mjs} +105 -19
  28. package/dist/.setup/{outbound-session-route-VulUE0yV.mjs → outbound-session-route-zVGxxceg.mjs} +140 -108
  29. package/dist/.setup/{pluralkit-CdAt1G0P.mjs → pluralkit-a6_NLfH9.mjs} +1 -1
  30. package/dist/.setup/{presence-cache-dYSHPWMx.mjs → presence-cache-Di3H3DIU.mjs} +0 -4
  31. package/dist/.setup/{probe-CupW4we4.mjs → probe-LYrIHlBF.mjs} +13 -4
  32. package/dist/.setup/{provider-iOf73HW-.mjs → provider-B_G5hASF.mjs} +721 -1416
  33. package/dist/.setup/provider-session.runtime-BYlTBFD2.mjs +6 -0
  34. package/dist/.setup/provider.runtime-CUE3UxER.mjs +2 -0
  35. package/dist/.setup/{realtime-session.runtime-Dz8uVutq.mjs → realtime-session.runtime-oUd9DOcz.mjs} +41 -55
  36. package/dist/.setup/{receive-recovery-DHst8WRx.mjs → receive-recovery-CHPOsnLc.mjs} +1 -4
  37. package/dist/.setup/{resolve-allowlist-common-CwMBzbx9.mjs → resolve-allowlist-common-DPdRggu5.mjs} +4 -7
  38. package/dist/.setup/{resolve-channels-BbvsLQOZ.mjs → resolve-channels-BFPNRmVv.mjs} +21 -40
  39. package/dist/.setup/{resolve-users-ByFlR7LQ.mjs → resolve-users-0-aBuCy3.mjs} +4 -4
  40. package/dist/.setup/{retry-BEYkDy0P.mjs → retry-pz_cSha2.mjs} +3 -3
  41. package/dist/.setup/rolldown-runtime-B4FMCO8f.mjs +28 -0
  42. package/dist/.setup/{runtime-B8lJfyrA.mjs → runtime-FN000lxA.mjs} +60 -162
  43. package/dist/.setup/runtime-doctor-migrations-CshUGl36.mjs +159 -0
  44. package/dist/.setup/{runtime-DisDbixd.mjs → runtime-sUksZ--Q.mjs} +2 -5
  45. package/dist/.setup/{secret-config-contract-DFu9hfU8.mjs → secret-config-contract-uOE2J7yM.mjs} +15 -85
  46. package/dist/.setup/{security-audit-s5w50-Ly.mjs → security-audit-Cdaegq7C.mjs} +3 -1
  47. package/dist/.setup/{send-CIBzvXjS.mjs → send-CrfEI6Bs.mjs} +53 -108
  48. package/dist/.setup/{send.components-ChY21qr-.mjs → send.components-DxQAMfES.mjs} +62 -107
  49. package/dist/.setup/{send.outbound-QTyuFupn.mjs → send.outbound-BISKnb-a.mjs} +66 -140
  50. package/dist/.setup/{send.shared-VNvWfX2T.mjs → send.shared-DGFkbkQR.mjs} +10 -25
  51. package/dist/.setup/{sender-identity-0Ymgvmaj.mjs → sender-identity-B9X5Vb9R.mjs} +2 -3
  52. package/dist/.setup/setup-plugin-api-BQUBxbhe.mjs +3 -0
  53. package/dist/.setup/{shared-DHPDaMSx.mjs → shared-B3wZ4hN-.mjs} +25 -32
  54. package/dist/.setup/{subagent-hooks-CjW7r8Pe.mjs → subagent-hooks-nlUE9ow7.mjs} +5 -6
  55. package/dist/.setup/system-events-CdeZnvPV.mjs +33 -0
  56. package/dist/.setup/{target-resolver-BXpy6VT8.mjs → target-resolver-BuLapkhy.mjs} +9 -12
  57. package/dist/.setup/targets-0KUcEIYx.mjs +3 -0
  58. package/dist/.setup/{thread-bindings-CEh2dhqP.mjs → thread-bindings-D7TfgjR_.mjs} +33 -35
  59. package/dist/.setup/{thread-bindings.manager-ve-i6oqt.mjs → thread-bindings.manager-DN-NissX.mjs} +325 -233
  60. package/dist/.setup/thread-bindings.session-updates-CshfKghV.mjs +359 -0
  61. package/dist/.setup/{thread-bindings.state-BThFQEga.mjs → thread-bindings.state-g6v9zAym.mjs} +21 -62
  62. package/dist/.setup/{transcripts-source-DVegW0WI.mjs → transcripts-source-p8EV179h.mjs} +76 -235
  63. package/dist/.setup/{typing-BKZL5fGj.mjs → typing-BiHCzBRu.mjs} +2 -1
  64. package/dist/.setup/{voice-runtime-elTtjEIG.mjs → voice-runtime-B46rcwrG.mjs} +140 -244
  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/directory-contract-api.js +1 -1
  72. package/dist/doctor-contract-api.js +4 -4
  73. package/dist/index.js +1 -1
  74. package/dist/runtime-api.js +20 -20
  75. package/dist/secret-contract-api.js +1 -1
  76. package/dist/security-audit-contract-api.js +1 -1
  77. package/dist/setup-entry.js +1 -1
  78. package/dist/setup-plugin-api.js +1 -1
  79. package/dist/src/voice/audio-worker.runtime.js +15 -24
  80. package/dist/subagent-hooks-api.js +3 -4
  81. package/dist/transcripts-source-api.js +1 -1
  82. package/node_modules/@types/node/README.md +2 -2
  83. package/node_modules/@types/node/child_process.d.ts +1 -1
  84. package/node_modules/@types/node/crypto.d.ts +20 -8
  85. package/node_modules/@types/node/ffi.d.ts +14 -0
  86. package/node_modules/@types/node/http2.d.ts +3 -2
  87. package/node_modules/@types/node/net.d.ts +16 -4
  88. package/node_modules/@types/node/package.json +2 -17
  89. package/node_modules/@types/node/process.d.ts +1 -0
  90. package/node_modules/@types/node/quic.d.ts +39 -1
  91. package/node_modules/@types/node/stream/iter.d.ts +9 -12
  92. package/node_modules/@types/node/test/reporters.d.ts +1 -0
  93. package/node_modules/@types/node/test.d.ts +72 -0
  94. package/node_modules/@types/node/tls.d.ts +14 -10
  95. package/node_modules/@types/node/vm.d.ts +2 -1
  96. package/node_modules/@types/node/worker_threads.d.ts +4 -1
  97. package/node_modules/typebox/build/compile/code.mjs +1 -2
  98. package/node_modules/typebox/build/compile/validator.mjs +5 -1
  99. package/node_modules/typebox/build/format/iri.mjs +16 -9
  100. package/node_modules/typebox/build/guard/emit.mjs +2 -2
  101. package/node_modules/typebox/build/guard/guard.d.mts +7 -5
  102. package/node_modules/typebox/build/guard/guard.mjs +14 -9
  103. package/node_modules/typebox/build/guard/index.mjs +6 -0
  104. package/node_modules/typebox/build/guard/unicode/unicode.d.mts +6 -0
  105. package/node_modules/typebox/build/guard/unicode/unicode.mjs +35 -0
  106. package/node_modules/typebox/build/guard/{string.mjs → unicode/unicode_segment.mjs} +16 -19
  107. package/node_modules/typebox/build/schema/build.mjs +2 -3
  108. package/node_modules/typebox/build/schema/engine/_pathing.d.mts +1 -0
  109. package/node_modules/typebox/build/schema/engine/_pathing.mjs +11 -0
  110. package/node_modules/typebox/build/schema/engine/_refine.mjs +13 -5
  111. package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +2 -1
  112. package/node_modules/typebox/build/schema/engine/dependencies.mjs +2 -1
  113. package/node_modules/typebox/build/schema/engine/dependentSchemas.mjs +2 -1
  114. package/node_modules/typebox/build/schema/engine/dynamicRef.d.mts +1 -1
  115. package/node_modules/typebox/build/schema/engine/dynamicRef.mjs +2 -2
  116. package/node_modules/typebox/build/schema/engine/format.mjs +9 -2
  117. package/node_modules/typebox/build/schema/engine/patternProperties.mjs +3 -2
  118. package/node_modules/typebox/build/schema/engine/properties.mjs +3 -2
  119. package/node_modules/typebox/build/schema/engine/propertyNames.mjs +2 -1
  120. package/node_modules/typebox/build/schema/engine/recursiveRef.d.mts +1 -1
  121. package/node_modules/typebox/build/schema/engine/recursiveRef.mjs +2 -2
  122. package/node_modules/typebox/build/schema/engine/ref.d.mts +1 -1
  123. package/node_modules/typebox/build/schema/engine/ref.mjs +2 -2
  124. package/node_modules/typebox/build/schema/engine/schema.mjs +24 -24
  125. package/node_modules/typebox/build/schema/parse.mjs +3 -0
  126. package/node_modules/typebox/build/schema/pointer/pointer.d.mts +1 -6
  127. package/node_modules/typebox/build/schema/pointer/pointer.mjs +47 -64
  128. package/node_modules/typebox/build/system/settings/internal.d.mts +2 -0
  129. package/node_modules/typebox/build/system/settings/internal.mjs +20 -0
  130. package/node_modules/typebox/build/system/settings/settings.d.mts +11 -0
  131. package/node_modules/typebox/build/system/settings/settings.mjs +14 -0
  132. package/node_modules/typebox/build/type/extends/inference.d.mts +1 -1
  133. package/node_modules/typebox/build/type/extends/inference.mjs +15 -2
  134. package/node_modules/typebox/build/type/extends/tuple.d.mts +2 -1
  135. package/node_modules/typebox/build/type/extends/tuple.mjs +21 -1
  136. package/node_modules/typebox/build/value/parse/parse.mjs +10 -4
  137. package/node_modules/typebox/package.json +1 -1
  138. package/node_modules/typebox/readme.md +3 -1
  139. package/openclaw.plugin.json +21 -1
  140. package/package.json +5 -5
  141. package/dist/.setup/agent-components.runtime-CEPrf2SY.mjs +0 -4
  142. package/dist/.setup/probe.runtime-DBQ_AGPe.mjs +0 -2
  143. package/dist/.setup/provider-session.runtime-DrGAYnZv.mjs +0 -6
  144. package/dist/.setup/provider.runtime-BmjW_pIw.mjs +0 -2
  145. package/dist/.setup/security-audit.runtime-DHtYenx9.mjs +0 -2
  146. package/dist/.setup/setup-plugin-api-Dvr41dyx.mjs +0 -3
  147. package/dist/.setup/system-events-B2YEEMbS.mjs +0 -34
  148. package/dist/.setup/targets-CvemhN3i.mjs +0 -3
  149. package/dist/.setup/thread-bindings.session-updates-DCQq1WZ5.mjs +0 -55
  150. /package/node_modules/typebox/build/guard/{string.d.mts → unicode/unicode_segment.d.mts} +0 -0
@@ -1,17 +1,16 @@
1
- import { D as Message, mt as getChannelMessage, t as discord_exports } from "./discord-BXpHW-cu.mjs";
2
- import { C as resolveTimestampMs, S as resolveDiscordSystemLocation, _ as resolveDiscordShouldRequireMention, a as normalizeDiscordDisplaySlug, f as resolveDiscordGuildEntry, l as resolveDiscordChannelConfigWithFallback, o as normalizeDiscordSlug, p as resolveDiscordMemberAccessState, x as formatDiscordUserTag } from "./channel-type-DKnjV1XW.mjs";
3
- import { s as resolveDefaultDiscordAccountId } from "./accounts-CwJQoLjM.mjs";
1
+ import { D as Message, ht as getChannelMessage, t as discord_exports } from "./discord-0xJYfdDD.mjs";
2
+ import { C as resolveDiscordSystemLocation, S as formatDiscordUserTag, a as normalizeDiscordDisplaySlug, f as resolveDiscordGuildEntry, h as resolveDiscordMentionPolicy, l as resolveDiscordChannelConfigWithFallback, o as normalizeDiscordSlug, p as resolveDiscordMemberAccessState, w as resolveTimestampMs } from "./channel-type-DRCrEMss.mjs";
3
+ import { s as resolveDefaultDiscordAccountId } from "./accounts-ChaMcixG.mjs";
4
4
  import { n as resolveDiscordChannelInfoSafe, r as resolveDiscordChannelNameSafe } from "./channel-access-C12aDZ0p.mjs";
5
- import { C as resolveForwardedMediaList, M as resolveDiscordMessageChannelId, O as resolveDiscordMessageStickers, b as resolveDiscordMessageMentionDocuments, j as resolveDiscordChannelInfo, k as resolveDiscordReferencedReplyMessage, v as resolveDiscordMessageBatch, w as resolveMediaList, x as resolveDiscordMessageText, y as resolveDiscordMessageHistoryText } from "./transcripts-source-DVegW0WI.mjs";
5
+ import { A as resolveDiscordMessageChannelId, D as resolveDiscordReferencedReplyMessage, E as resolveDiscordMessageStickers, S as resolveMediaList, _ as resolveDiscordMessageHistoryText, g as resolveDiscordMessageBatch, k as resolveDiscordChannelInfo, v as resolveDiscordMessageMentionDocuments, x as resolveForwardedMediaList, y as resolveDiscordMessageText } from "./transcripts-source-p8EV179h.mjs";
6
6
  import { n as DISCORD_ATTACHMENT_TOTAL_TIMEOUT_MS, t as DISCORD_ATTACHMENT_IDLE_TIMEOUT_MS } from "./timeouts-D86uWLt_.mjs";
7
- import { _ as resolveDiscordRuntimeBindingConversationId, f as resolveDiscordConversationRoute, h as resolveDiscordConversationIdentity, p as resolveDiscordEffectiveRoute, u as buildDiscordRoutePeer } from "./outbound-session-route-VulUE0yV.mjs";
8
- import { t as resolveDiscordConversationBindingRoute } from "./conversation-binding-route-B7qImK_b.mjs";
9
- import { S as resolveDiscordTextCommandAccess, _ as handleDiscordDmCommandDecision, n as resolveDiscordPreflightChannelAccess, x as resolveDiscordDmCommandAccess } from "./provider-iOf73HW-.mjs";
10
- import { n as resolveDiscordWebhookId, t as resolveDiscordSenderIdentity } from "./sender-identity-0Ymgvmaj.mjs";
11
- import { a as createDiscordHistorySenderProvenance, c as hasRawDiscordUserMention, d as matchesActiveDiscordMentionPatterns, f as resolveDiscordMentionState, h as shouldIgnoreBoundThreadWebhookMessage, i as loadSystemEventsRuntime, l as isBoundThreadBotSystemMessage, m as resolvePreflightMentionRequirement, n as loadDiscordThreadingRuntime, p as resolveInjectedBoundThreadLookupRecord, r as loadPreflightAudioRuntime, s as resolveDiscordHistoryMediaIds, t as resolveDiscordPreflightPluralKitInfo, u as isDiscordThreadChannelMessage } from "./message-handler.preflight-pluralkit-8Xji34AF.mjs";
7
+ import { _ as resolveDiscordRuntimeBindingConversationId, f as resolveDiscordConversationRoute, h as resolveDiscordConversationIdentity, p as resolveDiscordEffectiveRoute, u as buildDiscordRoutePeer } from "./outbound-session-route-zVGxxceg.mjs";
8
+ import { t as resolveDiscordConversationBindingRoute } from "./conversation-binding-route-Caz_XuFH.mjs";
9
+ import { A as resolveDiscordDmCommandAccess, E as handleDiscordDmCommandDecision, j as resolveDiscordTextCommandAccess, n as resolveDiscordPreflightChannelAccess } from "./provider-B_G5hASF.mjs";
10
+ import { n as resolveDiscordWebhookId, t as resolveDiscordSenderIdentity } from "./sender-identity-B9X5Vb9R.mjs";
11
+ import { a as createDiscordHistorySenderProvenance, c as hasRawDiscordUserMention, d as matchesActiveDiscordMentionPatterns, f as resolveDiscordMentionState, h as shouldIgnoreBoundThreadWebhookMessage, i as loadSystemEventsRuntime, l as isBoundThreadBotSystemMessage, m as resolvePreflightMentionRequirement, n as loadDiscordThreadingRuntime, p as resolveInjectedBoundThreadLookupRecord, r as loadPreflightAudioRuntime, s as resolveDiscordHistoryMediaIds, t as resolveDiscordPreflightPluralKitInfo, u as isDiscordThreadChannelMessage } from "./message-handler.preflight-pluralkit-CWLUBVcx.mjs";
12
12
  import { logDebug } from "openclaw/plugin-sdk/logging-core";
13
13
  import { MessageReferenceType, MessageType } from "discord-api-types/v10";
14
- import { readStringValue } from "openclaw/plugin-sdk/string-coerce-runtime";
15
14
  import { recordChannelActivity } from "openclaw/plugin-sdk/channel-activity-runtime";
16
15
  import { mimeTypeFromFilePath } from "openclaw/plugin-sdk/media-mime";
17
16
  import { getChildLogger, logVerbose, shouldLogVerbose } from "openclaw/plugin-sdk/runtime-env";
@@ -27,10 +26,7 @@ import { shouldHandleTextCommands } from "openclaw/plugin-sdk/command-surface";
27
26
  import { createChannelHistoryWindow } from "openclaw/plugin-sdk/reply-history";
28
27
  //#region extensions/discord/src/monitor/message-handler.dm-preflight.ts
29
28
  const loadConversationRuntime$1 = createLazyRuntimeModule(() => import("openclaw/plugin-sdk/conversation-binding-runtime"));
30
- const loadDiscordSendRuntime = createLazyRuntimeModule(() => import("./send-CIBzvXjS.mjs").then((n) => n.t));
31
- function resolveDiscordDmPairingSenderId(sender) {
32
- return sender.isPluralKit ? `pk:${sender.id}` : sender.id;
33
- }
29
+ const loadDiscordSendRuntime = createLazyRuntimeModule(() => import("./send-CrfEI6Bs.mjs").then((n) => n.t));
34
30
  async function resolveDiscordDmPreflightAccess(params) {
35
31
  if (params.dmPolicy === "disabled") {
36
32
  logVerbose("discord: drop dm (dmPolicy: disabled)");
@@ -70,14 +66,12 @@ async function resolveDiscordDmPreflightAccess(params) {
70
66
  const commandAuthorized = dmAccess.senderAccess.allowed && dmAccess.commandAccess.authorized || directBindingRecord != null;
71
67
  if (dmAccess.senderAccess.decision === "allow") return {
72
68
  commandAuthorized,
73
- channelIngress: dmAccess,
74
69
  resolveChannelIngress
75
70
  };
76
71
  if (directBindingRecord) {
77
72
  logVerbose(`discord: allow bound DM conversation ${directBindingConversationId} despite dmPolicy=${params.dmPolicy}`);
78
73
  return {
79
74
  commandAuthorized,
80
- channelIngress: dmAccess,
81
75
  resolveChannelIngress
82
76
  };
83
77
  }
@@ -85,7 +79,7 @@ async function resolveDiscordDmPreflightAccess(params) {
85
79
  senderAccess: dmAccess.senderAccess,
86
80
  accountId: params.resolvedAccountId,
87
81
  sender: {
88
- id: resolveDiscordDmPairingSenderId(params.sender),
82
+ id: params.sender.isPluralKit ? `pk:${params.sender.id}` : params.sender.id,
89
83
  tag: params.sender.tag ?? formatDiscordUserTag(params.author),
90
84
  name: params.sender.name ?? params.author.username ?? void 0
91
85
  },
@@ -116,100 +110,15 @@ async function resolveDiscordDmPreflightAccess(params) {
116
110
  }
117
111
  //#endregion
118
112
  //#region extensions/discord/src/monitor/message-handler.hydration.ts
119
- function mergeFetchedDiscordMessage(base, fetched) {
120
- const baseRawData = readMessageRawData(base);
121
- const baseFallback = readMessageFallback(base);
122
- const rawData = {
123
- ...baseRawData,
124
- ...fetched,
125
- id: fetched.id ?? baseRawData.id ?? baseFallback.id,
126
- channel_id: fetched.channel_id ?? baseRawData.channel_id ?? baseFallback.channel_id,
127
- content: fetched.content ?? baseRawData.content ?? baseFallback.content,
128
- author: fetched.author ?? baseRawData.author ?? baseFallback.author,
129
- attachments: fetched.attachments ?? baseRawData.attachments ?? baseFallback.attachments,
130
- embeds: fetched.embeds ?? baseRawData.embeds ?? baseFallback.embeds,
131
- mentions: fetched.mentions ?? baseRawData.mentions ?? baseFallback.mentions,
132
- mention_roles: fetched.mention_roles ?? baseRawData.mention_roles ?? baseFallback.mention_roles,
133
- mention_everyone: fetched.mention_everyone ?? baseRawData.mention_everyone ?? baseFallback.mention_everyone,
134
- timestamp: fetched.timestamp ?? baseRawData.timestamp ?? baseFallback.timestamp,
135
- tts: fetched.tts ?? baseRawData.tts ?? false,
136
- pinned: fetched.pinned ?? baseRawData.pinned ?? false,
137
- type: fetched.type ?? baseRawData.type ?? 0,
138
- message_snapshots: fetched.message_snapshots ?? baseRawData.message_snapshots ?? baseFallback.message_snapshots,
139
- sticker_items: fetched.sticker_items ?? baseRawData.sticker_items ?? baseFallback.sticker_items
140
- };
141
- const hydrated = new Message(readMessageClient(base), rawData);
142
- copyRuntimeMessageFields(base, hydrated);
143
- return hydrated;
144
- }
145
- function readMessageClient(message) {
146
- return message.client;
147
- }
148
- function readMessageRawData(message) {
149
- try {
150
- const rawData = message.rawData;
151
- return rawData && typeof rawData === "object" ? rawData : {};
152
- } catch {
153
- return {};
154
- }
155
- }
156
- function readMessageFallback(message) {
157
- const value = message;
158
- return {
159
- id: typeof value.id === "string" ? value.id : "",
160
- channel_id: readStringValue(value.channel_id) ?? readStringValue(value.channelId) ?? "",
161
- content: typeof value.content === "string" ? value.content : "",
162
- author: normalizeApiUser(value.author),
163
- attachments: Array.isArray(value.attachments) ? value.attachments : [],
164
- embeds: Array.isArray(value.embeds) ? value.embeds : [],
165
- mentions: normalizeApiUsers(value.mentionedUsers),
166
- mention_roles: normalizeStringArray(value.mentionedRoles),
167
- mention_everyone: value.mentionedEveryone === true,
168
- timestamp: readStringValue(value.timestamp) ?? "1970-01-01T00:00:00.000Z",
169
- sticker_items: Array.isArray(value.sticker_items) ? value.sticker_items : Array.isArray(value.stickers) ? value.stickers : void 0,
170
- message_snapshots: Array.isArray(value.message_snapshots) ? value.message_snapshots : void 0
171
- };
172
- }
173
- function normalizeStringArray(value) {
174
- return Array.isArray(value) ? value.flatMap((entry) => typeof entry === "string" ? [entry] : []) : [];
175
- }
176
- function normalizeApiUsers(value) {
177
- return Array.isArray(value) ? value.flatMap((entry) => {
178
- const user = normalizeApiUser(entry);
179
- return user.id ? [user] : [];
180
- }) : [];
181
- }
182
- function normalizeApiUser(value) {
183
- if (!value || typeof value !== "object") return {
184
- id: "",
185
- username: "",
186
- discriminator: "0",
187
- global_name: null,
188
- avatar: null
189
- };
190
- const input = value;
191
- return {
192
- id: readStringValue(input.id) ?? "",
193
- username: readStringValue(input.username) ?? "",
194
- discriminator: readStringValue(input.discriminator) ?? "0",
195
- global_name: readStringValue(input.global_name) ?? readStringValue(input.globalName) ?? null,
196
- avatar: input.avatar === null ? null : readStringValue(input.avatar) ?? null,
197
- ...typeof input.bot === "boolean" ? { bot: input.bot } : {}
198
- };
199
- }
200
- function copyRuntimeMessageFields(source, target) {
201
- const channelDescriptor = Object.getOwnPropertyDescriptor(source, "channel");
202
- if (channelDescriptor) Object.defineProperty(target, "channel", channelDescriptor);
203
- }
204
- function shouldHydrateDiscordMessagePayload(params) {
113
+ function shouldHydrateDiscordMessagePayload(message) {
205
114
  let currentText;
206
115
  try {
207
- currentText = resolveDiscordMessageText(params.message, { includeForwarded: true });
116
+ currentText = resolveDiscordMessageText(message, { includeForwarded: true });
208
117
  } catch {
209
118
  return true;
210
119
  }
211
120
  if (!currentText) return true;
212
- if ((params.message.mentionedUsers?.length ?? 0) > 0 || (params.message.mentionedRoles?.length ?? 0) > 0 || params.message.mentionedEveryone) return false;
121
+ if ((message.mentionedUsers?.length ?? 0) > 0 || (message.mentionedRoles?.length ?? 0) > 0 || message.mentionedEveryone) return false;
213
122
  return /<@!?\d+>|<@&\d+>|@everyone|@here/u.test(currentText);
214
123
  }
215
124
  function resolveReferencedMessagePayloadState(message) {
@@ -217,11 +126,13 @@ function resolveReferencedMessagePayloadState(message) {
217
126
  if (!reference?.message_id) return "complete";
218
127
  if (reference.type != null && reference.type !== MessageReferenceType.Default) return "complete";
219
128
  if (message.type != null && message.type !== MessageType.Reply) return "complete";
220
- const rawData = readMessageRawData(message);
129
+ const rawData = message.rawData;
221
130
  if (!Object.hasOwn(rawData, "referenced_message")) return "missing";
222
131
  const referenced = rawData.referenced_message;
223
132
  if (referenced == null) return "complete";
224
- return typeof referenced === "object" && typeof referenced.id === "string" && referenced.id === reference.message_id ? "complete" : "invalid";
133
+ if (typeof referenced !== "object" || referenced.id !== reference.message_id) return "invalid";
134
+ const reply = message.referencedMessage;
135
+ return reply?.author && (resolveDiscordMessageText(reply, { includeForwarded: true }) || reply.attachments.length > 0 || resolveDiscordMessageStickers(reply).length > 0) ? "complete" : "missing";
225
136
  }
226
137
  async function hydrateDiscordReplyReference(params) {
227
138
  const payloadState = resolveReferencedMessagePayloadState(params.message);
@@ -232,26 +143,28 @@ async function hydrateDiscordReplyReference(params) {
232
143
  const referencedChannelId = reference.channel_id ?? params.messageChannelId;
233
144
  try {
234
145
  const referenced = await getChannelMessage(params.client.rest, referencedChannelId, referencedMessageId);
235
- return mergeFetchedDiscordMessage(params.message, {
236
- ...readMessageRawData(params.message),
146
+ return new Message(params.client, {
147
+ ...params.message.rawData,
237
148
  referenced_message: referenced
238
149
  });
239
150
  } catch (err) {
240
151
  logVerbose(`discord: failed to hydrate referenced message ${referencedMessageId}: ${String(err)}`);
241
- if (payloadState === "invalid") return mergeFetchedDiscordMessage(params.message, {
242
- ...readMessageRawData(params.message),
152
+ if (payloadState === "invalid") return new Message(params.client, {
153
+ ...params.message.rawData,
243
154
  referenced_message: null
244
155
  });
245
156
  return params.message;
246
157
  }
247
158
  }
248
159
  async function hydrateDiscordMessageIfNeeded(params) {
249
- params.channelInfo;
250
160
  let hydrated = params.message;
251
- if (shouldHydrateDiscordMessagePayload({ message: params.message })) try {
161
+ if (shouldHydrateDiscordMessagePayload(params.message)) try {
252
162
  const fetched = await getChannelMessage(params.client.rest, params.messageChannelId, params.message.id);
253
163
  logVerbose(`discord: hydrated inbound payload via REST for ${params.message.id}`);
254
- hydrated = mergeFetchedDiscordMessage(params.message, fetched);
164
+ hydrated = new Message(params.client, {
165
+ ...params.message.partial ? {} : params.message.rawData,
166
+ ...fetched
167
+ });
255
168
  } catch (err) {
256
169
  logVerbose(`discord: failed to hydrate message ${params.message.id}: ${String(err)}`);
257
170
  return {
@@ -301,33 +214,6 @@ function resolveDiscordPreflightChannelContext(params) {
301
214
  };
302
215
  }
303
216
  //#endregion
304
- //#region extensions/discord/src/monitor/message-handler.preflight-context.ts
305
- function buildDiscordMessagePreflightContext({ preflightParams, ...fields }) {
306
- return {
307
- cfg: preflightParams.cfg,
308
- client: preflightParams.client,
309
- discordConfig: preflightParams.discordConfig,
310
- accountId: preflightParams.accountId,
311
- token: preflightParams.token,
312
- runtime: preflightParams.runtime,
313
- buildContext: preflightParams.buildContext,
314
- botUserId: preflightParams.botUserId,
315
- abortSignal: preflightParams.abortSignal,
316
- isPolicyCurrent: preflightParams.isPolicyCurrent,
317
- guildHistories: preflightParams.guildHistories,
318
- historyLimit: preflightParams.historyLimit,
319
- mediaMaxBytes: preflightParams.mediaMaxBytes,
320
- textLimit: preflightParams.textLimit,
321
- replyToMode: preflightParams.replyToMode,
322
- ackReactionScope: preflightParams.ackReactionScope,
323
- groupPolicy: preflightParams.groupPolicy,
324
- turnAdoptionLifecycle: preflightParams.turnAdoptionLifecycle,
325
- ...fields,
326
- threadBindings: preflightParams.threadBindings,
327
- discordRestFetch: preflightParams.discordRestFetch
328
- };
329
- }
330
- //#endregion
331
217
  //#region extensions/discord/src/monitor/message-handler.preflight-history.ts
332
218
  function buildDiscordPreflightHistoryEntry(params) {
333
219
  const textForHistory = resolveDiscordMessageHistoryText(params.message, { includeForwarded: true });
@@ -383,8 +269,9 @@ async function resolveDiscordPreflightThreadContext(params) {
383
269
  const loadConversationRuntime = createLazyRuntimeModule(() => import("openclaw/plugin-sdk/conversation-binding-runtime"));
384
270
  async function resolveDiscordPreflightRoute(params) {
385
271
  const conversationRuntime = await loadConversationRuntime();
386
- const route = resolveDiscordConversationRoute({
272
+ const route = ({ boundAgentId }) => resolveDiscordConversationRoute({
387
273
  cfg: params.preflight.cfg,
274
+ defaultAgentId: boundAgentId,
388
275
  accountId: params.preflight.accountId,
389
276
  guildId: params.preflight.data.guild_id ?? void 0,
390
277
  memberRoleIds: params.memberRoleIds,
@@ -404,7 +291,7 @@ async function resolveDiscordPreflightRoute(params) {
404
291
  });
405
292
  const { runtimeRoute, configuredRoute } = resolveDiscordConversationBindingRoute({
406
293
  cfg: params.preflight.cfg,
407
- route,
294
+ resolveRoute: route,
408
295
  accountId: params.preflight.accountId,
409
296
  runtimeConversationId: bindingConversationId,
410
297
  configuredConversationId: params.messageChannelId,
@@ -518,8 +405,8 @@ async function preflightDiscordMessage(params) {
518
405
  logVerbose(`discord: drop message ${message.id} (missing channel id)`);
519
406
  return null;
520
407
  }
521
- const allowBotsSetting = params.discordConfig?.allowBots;
522
- const allowBotsMode = allowBotsSetting === "mentions" ? "mentions" : allowBotsSetting === true ? "all" : "off";
408
+ const allowBotsSetting = params.discordConfig?.allowBots ?? true;
409
+ const allowBotsMode = allowBotsSetting === "mentions" ? "mentions" : allowBotsSetting ? "all" : "off";
523
410
  if (params.botUserId && author.id === params.botUserId) return null;
524
411
  const hydratedSources = [];
525
412
  for (const source of [...params.precedingMessages ?? [], message]) {
@@ -610,7 +497,6 @@ async function preflightDiscordMessage(params) {
610
497
  const resolvedAccountId = params.accountId ?? resolveDefaultDiscordAccountId(params.cfg);
611
498
  const allowNameMatching = isDangerousNameMatchingEnabled(params.discordConfig);
612
499
  let commandAuthorized = true;
613
- let channelIngress;
614
500
  let resolveChannelIngress;
615
501
  if (isDirectMessage) {
616
502
  const access = await resolveDiscordDmPreflightAccess({
@@ -625,7 +511,6 @@ async function preflightDiscordMessage(params) {
625
511
  if (params.abortSignal?.aborted || params.isPolicyCurrent?.() === false) return null;
626
512
  if (!access) return null;
627
513
  commandAuthorized = access.commandAuthorized;
628
- channelIngress = access.channelIngress;
629
514
  resolveChannelIngress = access.resolveChannelIngress;
630
515
  }
631
516
  const botId = params.botUserId;
@@ -645,7 +530,7 @@ async function preflightDiscordMessage(params) {
645
530
  abortSignal: params.abortSignal
646
531
  });
647
532
  if (!threadContext || params.isPolicyCurrent?.() === false) return null;
648
- const { earlyThreadChannel, earlyThreadParentId, earlyThreadParentName, earlyThreadParentType } = threadContext;
533
+ const { earlyThreadChannel: threadChannel, earlyThreadParentId: threadParentId, earlyThreadParentName: threadParentName, earlyThreadParentType: threadParentType } = threadContext;
649
534
  const memberRoleIds = Array.isArray(params.data.rawMember?.roles) ? params.data.rawMember.roles : [];
650
535
  const routeState = await resolveDiscordPreflightRoute({
651
536
  preflight: params,
@@ -654,7 +539,7 @@ async function preflightDiscordMessage(params) {
654
539
  isGroupDm,
655
540
  messageChannelId,
656
541
  memberRoleIds,
657
- earlyThreadParentId
542
+ earlyThreadParentId: threadParentId
658
543
  });
659
544
  if (params.isPolicyCurrent?.() === false) return null;
660
545
  const { conversationRuntime, threadBinding, configuredBinding, boundSessionKey, effectiveRoute, boundAgentId, baseSessionKey } = routeState;
@@ -666,7 +551,7 @@ async function preflightDiscordMessage(params) {
666
551
  logVerbose(`discord: drop bound-thread webhook echo message ${message.id}`);
667
552
  return null;
668
553
  }
669
- const isBoundThreadSession = Boolean(threadBinding && earlyThreadChannel);
554
+ const isBoundThreadSession = Boolean(threadBinding && threadChannel);
670
555
  const bypassMentionRequirement = isBoundThreadSession;
671
556
  if (isBoundThreadBotSystemMessage({
672
557
  isBoundThreadSession,
@@ -710,11 +595,7 @@ async function preflightDiscordMessage(params) {
710
595
  logVerbose(`Blocked discord guild ${params.data.guild_id ?? "unknown"} (not in discord.guilds)`);
711
596
  return null;
712
597
  }
713
- const threadChannel = earlyThreadChannel;
714
- const threadParentId = earlyThreadParentId;
715
- const threadParentName = earlyThreadParentName;
716
- const threadParentType = earlyThreadParentType;
717
- const { threadName, configChannelName, configChannelSlug, displayChannelName, displayChannelSlug, guildSlug, channelConfig } = resolveDiscordPreflightChannelContext({
598
+ const { threadName, displayChannelName, displayChannelSlug, guildSlug, channelConfig } = resolveDiscordPreflightChannelContext({
718
599
  isGuildMessage,
719
600
  messageChannelId,
720
601
  channelName,
@@ -730,7 +611,7 @@ async function preflightDiscordMessage(params) {
730
611
  channelMatchMeta,
731
612
  channelId: messageChannelId
732
613
  });
733
- const channelAccess = resolveDiscordPreflightChannelAccess({
614
+ if (!resolveDiscordPreflightChannelAccess({
734
615
  isGuildMessage,
735
616
  isGroupDm,
736
617
  groupPolicy: params.groupPolicy,
@@ -741,9 +622,7 @@ async function preflightDiscordMessage(params) {
741
622
  guildInfo,
742
623
  channelConfig,
743
624
  channelMatchMeta
744
- });
745
- if (!channelAccess.allowed) return null;
746
- const { channelAllowlistConfigured, channelAllowed } = channelAccess;
625
+ })) return null;
747
626
  const historyEntry = buildDiscordPreflightHistoryEntry({
748
627
  isGuildMessage,
749
628
  historyLimit: params.historyLimit,
@@ -752,15 +631,15 @@ async function preflightDiscordMessage(params) {
752
631
  sender,
753
632
  memberRoleIds
754
633
  });
755
- const threadOwnerId = threadChannel ? resolveDiscordChannelInfoSafe(threadChannel).ownerId ?? channelInfo?.ownerId : void 0;
756
- const shouldRequireMentionByConfig = resolveDiscordShouldRequireMention({
634
+ const mentionPolicy = resolveDiscordMentionPolicy({
757
635
  isGuildMessage,
758
636
  isThread: Boolean(threadChannel),
759
637
  botId,
760
- threadOwnerId,
638
+ threadOwnerId: threadChannel ? resolveDiscordChannelInfoSafe(threadChannel).ownerId ?? channelInfo?.ownerId : void 0,
761
639
  channelConfig,
762
640
  guildInfo
763
641
  });
642
+ const shouldRequireMentionByConfig = mentionPolicy.requireMention;
764
643
  const shouldRequireMention = resolvePreflightMentionRequirement({
765
644
  shouldRequireMention: shouldRequireMentionByConfig,
766
645
  bypassMentionRequirement
@@ -788,15 +667,14 @@ async function preflightDiscordMessage(params) {
788
667
  abortSignal: params.abortSignal
789
668
  });
790
669
  if (params.abortSignal?.aborted || params.isPolicyCurrent?.() === false) return null;
791
- const mentionText = hasTypedText ? baseText : "";
792
670
  const { implicitMentionKinds, wasMentioned: wasNormallyMentioned } = resolveDiscordMentionState({
793
- authorIsBot: Boolean(author.bot),
794
671
  botId,
672
+ authorIsBot: Boolean(author.bot),
795
673
  hasAnyMention,
796
674
  isDirectMessage,
797
675
  isExplicitlyMentioned: explicitlyMentioned,
798
676
  mentionRegexes,
799
- mentionText,
677
+ mentionText: hasTypedText ? baseText : "",
800
678
  mentionedEveryone: message.mentionedEveryone,
801
679
  referencedAuthorId: message.referencedMessage?.author?.id,
802
680
  senderIsPluralKit: sender.isPluralKit,
@@ -812,7 +690,7 @@ async function preflightDiscordMessage(params) {
812
690
  directUserId: author.id,
813
691
  conversationId: messageChannelId
814
692
  }).id : params.cfg.broadcast?.[`discord:${messageChannelId}`] !== void 0 ? messageChannelId : threadParentId ?? messageChannelId,
815
- text: mentionText || preflightTranscript || "",
693
+ text: (hasTypedText ? baseText : "") || preflightTranscript || "",
816
694
  sessionKey: boundSessionKey || effectiveRoute.sessionKey,
817
695
  acpBinding: Boolean(configuredBinding)
818
696
  });
@@ -857,7 +735,6 @@ async function preflightDiscordMessage(params) {
857
735
  const commandAccess = await resolveCommandIngress();
858
736
  if (params.isPolicyCurrent?.() === false) return null;
859
737
  commandAuthorized = commandAccess.commandAccess.authorized;
860
- channelIngress = commandAccess;
861
738
  resolveChannelIngress = resolveCommandIngress;
862
739
  if (commandAccess.commandAccess.shouldBlockControlCommand) {
863
740
  logInboundDrop({
@@ -880,6 +757,7 @@ async function preflightDiscordMessage(params) {
880
757
  policy: {
881
758
  isGroup: isGuildMessage,
882
759
  requireMention: shouldRequireMention,
760
+ allowedImplicitMentionKinds: mentionPolicy.allowedImplicitMentionKinds,
883
761
  allowTextCommands,
884
762
  hasControlCommand: hasControlCommandInMessage,
885
763
  commandAuthorized
@@ -1005,8 +883,27 @@ async function preflightDiscordMessage(params) {
1005
883
  if (params.abortSignal?.aborted) return null;
1006
884
  preparedMedia.push(...forwardedMedia);
1007
885
  logDebug(`[discord-preflight] success: route=${effectiveRoute.agentId} sessionKey=${effectiveRoute.sessionKey}`);
1008
- return buildDiscordMessagePreflightContext({
1009
- preflightParams: params,
886
+ return {
887
+ cfg: params.cfg,
888
+ client: params.client,
889
+ discordConfig: params.discordConfig,
890
+ accountId: params.accountId,
891
+ token: params.token,
892
+ runtime: params.runtime,
893
+ buildContext: params.buildContext,
894
+ botUserId: params.botUserId,
895
+ abortSignal: params.abortSignal,
896
+ isPolicyCurrent: params.isPolicyCurrent,
897
+ guildHistories: params.guildHistories,
898
+ historyLimit: params.historyLimit,
899
+ mediaMaxBytes: params.mediaMaxBytes,
900
+ textLimit: params.textLimit,
901
+ replyToMode: params.replyToMode,
902
+ ackReactionScope: params.ackReactionScope,
903
+ groupPolicy: params.groupPolicy,
904
+ turnAdoptionLifecycle: params.turnAdoptionLifecycle,
905
+ threadBindings: params.threadBindings,
906
+ discordRestFetch: params.discordRestFetch,
1010
907
  groupThread,
1011
908
  data,
1012
909
  message,
@@ -1022,7 +919,6 @@ async function preflightDiscordMessage(params) {
1022
919
  isDirectMessage,
1023
920
  isGroupDm,
1024
921
  commandAuthorized,
1025
- channelIngress,
1026
922
  resolveChannelIngress,
1027
923
  baseText,
1028
924
  messageText,
@@ -1041,25 +937,18 @@ async function preflightDiscordMessage(params) {
1041
937
  threadParentName,
1042
938
  threadParentType,
1043
939
  threadName,
1044
- configChannelName,
1045
- configChannelSlug,
1046
- displayChannelName,
1047
940
  displayChannelSlug,
1048
941
  baseSessionKey,
1049
942
  channelConfig,
1050
- channelAllowlistConfigured,
1051
- channelAllowed,
1052
943
  shouldRequireMention,
1053
944
  groupRequireMention: shouldRequireMentionByConfig,
1054
945
  hasAnyMention,
1055
946
  hasControlCommand: hasControlCommandInMessage,
1056
- allowTextCommands,
1057
947
  shouldBypassMention: mentionDecision.shouldBypassMention,
1058
948
  effectiveWasMentioned,
1059
949
  inboundEventKind,
1060
- canDetectMention,
1061
- historyEntry
1062
- });
950
+ canDetectMention
951
+ };
1063
952
  }
1064
953
  //#endregion
1065
- export { preflightDiscordMessage, resolvePreflightMentionRequirement, shouldIgnoreBoundThreadWebhookMessage };
954
+ export { preflightDiscordMessage, shouldIgnoreBoundThreadWebhookMessage };