@openclaw/discord 2026.11.3 → 2026.11.5-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (220) hide show
  1. package/dist/.setup/{account-inspect-8cCu6uPG.mjs → account-inspect-DGkdWwix.mjs} +1 -1
  2. package/dist/.setup/{accounts-ljrzXBJi.mjs → accounts-C_25wyxC.mjs} +9 -6
  3. package/dist/.setup/{active-turn-thread-route-C4tp9noA.mjs → active-turn-thread-route-KvRTAVE3.mjs} +1 -2
  4. package/dist/.setup/{allow-list-BKqOldGy.mjs → allow-list-BXrS8-R9.mjs} +4 -152
  5. package/dist/.setup/{api-DqmMUZau.mjs → api-BlBD4ism.mjs} +10 -20
  6. package/dist/.setup/{approval-handler.runtime-D0qu1um7.mjs → approval-handler.runtime-BGYjX1t9.mjs} +80 -61
  7. package/dist/.setup/{approval-message-updates-CdurC9Ej.mjs → approval-message-updates-DKsCfxSW.mjs} +2 -2
  8. package/dist/.setup/{audit-ChorIwio.mjs → audit-5b-FXj9R.mjs} +4 -4
  9. package/dist/.setup/{channel-ZilgdF5e.mjs → channel-CWwTHWFo.mjs} +134 -202
  10. package/dist/.setup/channel-access-9cyzozUP.mjs +24 -0
  11. package/dist/.setup/channel.setup-B3MtmBQG.mjs +238 -0
  12. package/dist/.setup/{components-Du9NhD8h.mjs → components-YCvQ6YLS.mjs} +209 -430
  13. package/dist/.setup/components.base-CiS0h_XP.mjs +32 -0
  14. package/dist/.setup/{config-schema-_uBILpQf.mjs → config-schema-BNKN1cu5.mjs} +6 -7
  15. package/dist/.setup/{conversation-binding-route-8Ul1KpGF.mjs → conversation-binding-route-kCTw8cij.mjs} +2 -2
  16. package/dist/.setup/{directory-config-3iVub-3m.mjs → directory-config-Ble81PWH.mjs} +1 -1
  17. package/dist/.setup/{directory-live-BDVl2DoC.mjs → directory-live-DH3tpS3x.mjs} +52 -57
  18. package/dist/.setup/{discord-BMD-JiVS.mjs → discord-DGVSguhx.mjs} +1124 -1710
  19. package/dist/.setup/{doctor-hQKbkNKq.mjs → doctor-eujgbnpZ.mjs} +3 -5
  20. package/dist/.setup/endpoint-runtime-lf4DeLas.mjs +139 -0
  21. package/dist/.setup/guilds-eDq22iSM.mjs +22 -0
  22. package/dist/.setup/{handle-action-B1lmt4ms.mjs → handle-action-CktwmzMz.mjs} +15 -15
  23. package/dist/.setup/{handle-action.guild-admin-B6g31cwt.mjs → handle-action.guild-admin-WLQ7fRqI.mjs} +5 -5
  24. package/dist/.setup/listeners-Df8lx3vK.mjs +47 -0
  25. package/dist/.setup/{live-policy-config-C_Q966Wh.mjs → live-policy-config-DiBVuaU6.mjs} +2 -3
  26. package/dist/.setup/{message-handler-CkI3yMjL.mjs → message-handler-hhNSioxo.mjs} +154 -115
  27. package/dist/.setup/{message-handler.preflight-CEfkFV9U.mjs → message-handler.preflight-BZcZE1o-.mjs} +30 -105
  28. package/dist/.setup/{message-handler.preflight-pluralkit-D5si80_L.mjs → message-handler.preflight-pluralkit-CYZfXXb6.mjs} +9 -22
  29. package/dist/.setup/{message-handler.process-DsMtetRf.mjs → message-handler.process-B0n-mQ99.mjs} +256 -373
  30. package/dist/.setup/outbound-payload-BaZmjewa.mjs +447 -0
  31. package/dist/.setup/{outbound-session-route-BtUpGBTb.mjs → outbound-session-route-Cgx4i9cS.mjs} +139 -86
  32. package/dist/.setup/{preflight-audio-wWgsZG5F.mjs → preflight-audio-C6QtD6HX.mjs} +1 -5
  33. package/dist/.setup/{presence-cache-DCeTsL73.mjs → presence-cache-Dq-3nH7R.mjs} +1 -6
  34. package/dist/.setup/{probe-CBaoCs-c.mjs → probe-DezB-6xz.mjs} +5 -9
  35. package/dist/.setup/{provider-CI_OLfvz.mjs → provider-BN2bCIUp.mjs} +3440 -4308
  36. package/dist/.setup/{provider-session.runtime-TWOo_JZx.mjs → provider-session.runtime-Dr_5X43t.mjs} +3 -3
  37. package/dist/.setup/provider.runtime-BuJpl0Pv.mjs +1 -0
  38. package/dist/.setup/proxy-fetch-BzXwBAXt.mjs +30 -0
  39. package/dist/.setup/{realtime-session.runtime-DvfS4vJj.mjs → realtime-session.runtime-BTDWsV4d.mjs} +44 -81
  40. package/dist/.setup/{receive-recovery-CKvaG2Hf.mjs → receive-recovery-C3Ks4wAQ.mjs} +13 -27
  41. package/dist/.setup/{resolve-allowlist-common-cIjtqh2F.mjs → resolve-allowlist-common-Bk8Fj6Ik.mjs} +3 -13
  42. package/dist/.setup/{resolve-channels-Cj5i7hzj.mjs → resolve-channels-Bp8frXvc.mjs} +7 -8
  43. package/dist/.setup/{resolve-users-BQLbysRB.mjs → resolve-users-Cvcj22sG.mjs} +4 -7
  44. package/dist/.setup/{runtime-RWnuJgWB.mjs → runtime-BJaCvlmq.mjs} +196 -239
  45. package/dist/.setup/{runtime-plifsKg9.mjs → runtime-BMgTyuwg.mjs} +6 -6
  46. package/dist/.setup/{secret-config-contract-z6FhbT8E.mjs → secret-config-contract-B1kE4sDv.mjs} +4 -9
  47. package/dist/.setup/{send-da6ENJ9f.mjs → send-CVW7V-VZ.mjs} +149 -175
  48. package/dist/.setup/{send.components-CWZUuGvA.mjs → send.components-C8YXdnO_.mjs} +59 -71
  49. package/dist/.setup/{send.outbound-qZ3iK3Vq.mjs → send.outbound-Uzcmh3Yd.mjs} +76 -129
  50. package/dist/.setup/{send.receipt-C18khRYH.mjs → send.receipt-NZDOTZBU.mjs} +30 -32
  51. package/dist/.setup/{send.shared-CnlMgoqQ.mjs → send.shared-a_6Oeyg1.mjs} +38 -115
  52. package/dist/.setup/{sender-identity-DgbJykq0.mjs → sender-identity-76HFb8eK.mjs} +3 -9
  53. package/dist/.setup/setup-plugin-api-BExhGEhL.mjs +2 -0
  54. package/dist/.setup/shared-interactive-DmzaoKOM.mjs +316 -0
  55. package/dist/.setup/{shared-CY5vJM48.mjs → shared-yDUSExm2.mjs} +8 -11
  56. package/dist/.setup/{subagent-hooks-CIu2TFz3.mjs → subagent-hooks-CDkdHQyy.mjs} +1 -1
  57. package/dist/.setup/{system-events-DCOLXkwS.mjs → system-events-yfWz150v.mjs} +2 -2
  58. package/dist/.setup/{target-resolver-CApivu3G.mjs → target-resolver-BOOzqxxM.mjs} +3 -3
  59. package/dist/.setup/{thread-bindings-DcvT_JgI.mjs → thread-bindings-zce4cpu_.mjs} +12 -20
  60. package/dist/.setup/{thread-bindings.manager-5Sh7yedN.mjs → thread-bindings.manager-NywKzUtc.mjs} +22 -42
  61. package/dist/.setup/{thread-bindings.session-updates-BMdJeJMc.mjs → thread-bindings.session-updates-D0j7oh8S.mjs} +11 -18
  62. package/dist/.setup/{threading-CzjFeUSe.mjs → threading-DodLYDt-.mjs} +68 -105
  63. package/dist/.setup/{timeouts-CuNARfyw.mjs → timeouts-cIxzatmv.mjs} +1 -1
  64. package/dist/.setup/{transcripts-source-8RDQrSVb.mjs → transcripts-source-ie9GBWaU.mjs} +110 -179
  65. package/dist/.setup/{voice-runtime-BsDILmAv.mjs → voice-runtime-B7V_LTdX.mjs} +231 -452
  66. package/dist/.source-module-urls/d6c089460280c5a04184542d6712e04545caeb1ebb290d3504377b4cc5e22fea.json +1 -0
  67. package/dist/account-inspect-api.js +1 -1
  68. package/dist/action-runtime-api.js +1 -2
  69. package/dist/activities-api.js +286 -341
  70. package/dist/api.js +16 -16
  71. package/dist/channel-config-api.js +1 -2
  72. package/dist/channel-plugin-api.js +1 -2
  73. package/dist/contract-api.js +1 -2
  74. package/dist/directory-contract-api.js +1 -1
  75. package/dist/runtime-api.js +22 -22
  76. package/dist/runtime-setter-api.js +1 -2
  77. package/dist/secret-contract-api.js +1 -2
  78. package/dist/security-audit-contract-api.js +1 -2
  79. package/dist/security-contract-api.js +1 -2
  80. package/dist/session-key-api.js +1 -2
  81. package/dist/setup-entry.js +1 -1
  82. package/dist/setup-plugin-api.js +1 -2
  83. package/dist/src/voice/audio-worker.runtime.js +56 -68
  84. package/dist/subagent-hooks-api.js +1 -1
  85. package/dist/thread-binding-api.js +1 -2
  86. package/dist/transcripts-source-api.js +1 -1
  87. package/node_modules/@napi-rs/wasm-runtime/dist/fs.js +3339 -4021
  88. package/node_modules/@napi-rs/wasm-runtime/package.json +1 -1
  89. package/node_modules/@types/lodash/README.md +1 -1
  90. package/node_modules/@types/lodash/common/function.d.ts +2 -2
  91. package/node_modules/@types/lodash/package.json +2 -2
  92. package/node_modules/@types/node/README.md +1 -1
  93. package/node_modules/@types/node/package.json +2 -2
  94. package/node_modules/@types/node/util.d.ts +6 -3
  95. package/node_modules/discord-api-types/package.json +4 -4
  96. package/node_modules/discord-api-types/rest/v10/index.d.ts +8 -0
  97. package/node_modules/discord-api-types/rest/v10/index.d.ts.map +1 -1
  98. package/node_modules/discord-api-types/rest/v10/index.js +8 -0
  99. package/node_modules/discord-api-types/rest/v10/index.js.map +1 -1
  100. package/node_modules/discord-api-types/rest/v10/oauth2.d.ts +26 -2
  101. package/node_modules/discord-api-types/rest/v10/oauth2.d.ts.map +1 -1
  102. package/node_modules/discord-api-types/rest/v9/index.d.ts +8 -0
  103. package/node_modules/discord-api-types/rest/v9/index.d.ts.map +1 -1
  104. package/node_modules/discord-api-types/rest/v9/index.js +8 -0
  105. package/node_modules/discord-api-types/rest/v9/index.js.map +1 -1
  106. package/node_modules/discord-api-types/rest/v9/oauth2.d.ts +26 -2
  107. package/node_modules/discord-api-types/rest/v9/oauth2.d.ts.map +1 -1
  108. package/node_modules/typebox/build/format/duration.d.mts +2 -2
  109. package/node_modules/typebox/build/format/duration.mjs +2 -2
  110. package/node_modules/typebox/build/format/idn_email.d.mts +1 -0
  111. package/node_modules/typebox/build/format/idn_email.mjs +1 -0
  112. package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -1
  113. package/node_modules/typebox/build/format/idn_hostname.mjs +1 -1
  114. package/node_modules/typebox/build/format/ipv4.d.mts +2 -2
  115. package/node_modules/typebox/build/format/ipv4.mjs +2 -2
  116. package/node_modules/typebox/build/format/ipv6.d.mts +1 -1
  117. package/node_modules/typebox/build/format/ipv6.mjs +1 -1
  118. package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
  119. package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
  120. package/node_modules/typebox/build/schema/build.mjs +1 -0
  121. package/node_modules/typebox/build/schema/engine/_unique.d.mts +4 -2
  122. package/node_modules/typebox/build/schema/engine/_unique.mjs +7 -3
  123. package/node_modules/typebox/build/schema/engine/additionalItems.mjs +3 -3
  124. package/node_modules/typebox/build/schema/engine/additionalProperties.d.mts +0 -3
  125. package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +15 -17
  126. package/node_modules/typebox/build/schema/engine/contains.mjs +3 -3
  127. package/node_modules/typebox/build/schema/engine/index.d.mts +1 -0
  128. package/node_modules/typebox/build/schema/engine/index.mjs +1 -0
  129. package/node_modules/typebox/build/schema/engine/items.mjs +7 -4
  130. package/node_modules/typebox/build/schema/engine/maxContains.mjs +2 -2
  131. package/node_modules/typebox/build/schema/engine/minContains.mjs +3 -3
  132. package/node_modules/typebox/build/schema/engine/oneOf.mjs +2 -2
  133. package/node_modules/typebox/build/schema/engine/patternProperties.mjs +2 -2
  134. package/node_modules/typebox/build/schema/engine/propertyNames.mjs +2 -2
  135. package/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs +2 -2
  136. package/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs +2 -2
  137. package/node_modules/typebox/build/system/hashing/hash.mjs +63 -34
  138. package/node_modules/typebox/build/system/locale/en_US.mjs +2 -1
  139. package/node_modules/typebox/build/system/memory/assign.d.mts +2 -8
  140. package/node_modules/typebox/build/system/memory/assign.mjs +13 -6
  141. package/node_modules/typebox/build/system/memory/clone.d.mts +4 -5
  142. package/node_modules/typebox/build/system/memory/clone.mjs +8 -96
  143. package/node_modules/typebox/build/system/memory/create.d.mts +1 -5
  144. package/node_modules/typebox/build/system/memory/create.mjs +18 -13
  145. package/node_modules/typebox/build/system/memory/deep.d.mts +2 -0
  146. package/node_modules/typebox/build/system/memory/deep.mjs +108 -0
  147. package/node_modules/typebox/build/system/memory/discard.d.mts +1 -1
  148. package/node_modules/typebox/build/system/memory/discard.mjs +9 -8
  149. package/node_modules/typebox/build/system/memory/finalize.d.mts +4 -0
  150. package/node_modules/typebox/build/system/memory/finalize.mjs +30 -0
  151. package/node_modules/typebox/build/system/memory/keys.d.mts +2 -0
  152. package/node_modules/typebox/build/system/memory/keys.mjs +8 -0
  153. package/node_modules/typebox/build/system/memory/update.d.mts +1 -4
  154. package/node_modules/typebox/build/system/memory/update.mjs +43 -16
  155. package/node_modules/typebox/build/type/engine/call/index.d.mts +1 -0
  156. package/node_modules/typebox/build/type/engine/call/index.mjs +1 -0
  157. package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +2 -24
  158. package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +2 -29
  159. package/node_modules/typebox/build/type/engine/evaluate/index.d.mts +1 -0
  160. package/node_modules/typebox/build/type/engine/evaluate/index.mjs +1 -0
  161. package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +5 -1
  162. package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +6 -1
  163. package/node_modules/typebox/build/type/engine/evaluate/property.d.mts +30 -0
  164. package/node_modules/typebox/build/type/engine/evaluate/property.mjs +29 -0
  165. package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +1 -3
  166. package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +1 -4
  167. package/node_modules/typebox/build/type/engine/object/from_intersect.d.mts +2 -2
  168. package/node_modules/typebox/build/type/engine/object/from_intersect.mjs +2 -2
  169. package/node_modules/typebox/build/type/engine/object/from_union.d.mts +2 -2
  170. package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
  171. package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +1 -3
  172. package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +1 -4
  173. package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +1 -3
  174. package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +1 -4
  175. package/node_modules/typebox/build/type/engine/this/index.d.mts +1 -0
  176. package/node_modules/typebox/build/type/engine/this/index.mjs +1 -0
  177. package/node_modules/typebox/build/value/clone/clone.d.mts +4 -3
  178. package/node_modules/typebox/build/value/clone/clone.mjs +5 -7
  179. package/node_modules/typebox/build/value/repair/from_cyclic.d.mts +2 -0
  180. package/node_modules/typebox/build/value/repair/from_cyclic.mjs +6 -0
  181. package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +25 -14
  182. package/node_modules/typebox/package.json +1 -1
  183. package/node_modules/typebox/readme.md +1 -1
  184. package/node_modules/undici/docs/docs/api/Interceptors.md +15 -2
  185. package/node_modules/undici/lib/dispatcher/client-h2.js +78 -3
  186. package/node_modules/undici/lib/dispatcher/pool-base.js +20 -3
  187. package/node_modules/undici/package.json +3 -3
  188. package/node_modules/undici/types/api.d.ts +1 -1
  189. package/node_modules/undici/types/utility.d.ts +4 -4
  190. package/node_modules/uuid/package.json +17 -17
  191. package/node_modules/zod/package.json +1 -1
  192. package/node_modules/zod/src/v4/classic/tests/array.test.ts +27 -0
  193. package/node_modules/zod/src/v4/classic/tests/map.test.ts +7 -0
  194. package/node_modules/zod/src/v4/classic/tests/set.test.ts +6 -0
  195. package/node_modules/zod/src/v4/core/compile.ts +9 -0
  196. package/node_modules/zod/src/v4/core/schemas.ts +35 -1
  197. package/node_modules/zod/src/v4/core/util.ts +13 -0
  198. package/node_modules/zod/src/v4/core/versions.ts +1 -1
  199. package/node_modules/zod/v4/core/compile.cjs +8 -0
  200. package/node_modules/zod/v4/core/compile.js +8 -0
  201. package/node_modules/zod/v4/core/schemas.cjs +30 -0
  202. package/node_modules/zod/v4/core/schemas.d.cts +3 -1
  203. package/node_modules/zod/v4/core/schemas.d.ts +3 -1
  204. package/node_modules/zod/v4/core/schemas.js +30 -0
  205. package/node_modules/zod/v4/core/util.cjs +15 -0
  206. package/node_modules/zod/v4/core/util.d.cts +2 -0
  207. package/node_modules/zod/v4/core/util.d.ts +2 -0
  208. package/node_modules/zod/v4/core/util.js +14 -0
  209. package/node_modules/zod/v4/core/versions.cjs +1 -1
  210. package/node_modules/zod/v4/core/versions.js +1 -1
  211. package/openclaw.plugin.json +1 -31
  212. package/package.json +8 -8
  213. package/dist/.setup/channel-access-DasWY_OV.mjs +0 -48
  214. package/dist/.setup/channel.setup-DaDQdctj.mjs +0 -249
  215. package/dist/.setup/outbound-adapter-DfAanoCO.mjs +0 -543
  216. package/dist/.setup/provider.runtime-DnionCyo.mjs +0 -2
  217. package/dist/.setup/setup-plugin-api-D1QuM187.mjs +0 -3
  218. package/dist/.setup/targets-UWWZ6gF7.mjs +0 -3
  219. package/node_modules/typebox/build/system/memory/freeze.d.mts +0 -4
  220. package/node_modules/typebox/build/system/memory/freeze.mjs +0 -6
@@ -1,8 +1,9 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.mjs";
2
- import { A as resolveDiscordSendEmbeds, D as createDiscordMessageNonce, E as buildDiscordMessageRequest, M as parseAndResolveChannelRecipient, N as createDiscordClient, O as resolveDiscordMessageFlags, c as resolveChannelId, d as sendDiscordChunks, f as sendDiscordMedia, i as normalizeDiscordPollInput, j as resolveDiscordSuppressEmbeds, k as resolveDiscordSendComponents, l as resolveDiscordChannel, n as buildDiscordTextChunks, s as normalizeStickerIds, t as buildDiscordSendError } from "./send.shared-CnlMgoqQ.mjs";
3
- import { G as withDiscordRequestAuthority, ct as createChannelMessage, lt as createThread } from "./discord-BMD-JiVS.mjs";
4
- import { a as createReusableDiscordReplyReference, n as createDiscordSendReceiptFromResults, r as createDiscordSendResult } from "./send.receipt-C18khRYH.mjs";
5
- import { a as normalizeDiscordSnowflake, i as normalizeDiscordHandleKey, s as resolveDiscordDirectoryUserId } from "./directory-live-BDVl2DoC.mjs";
2
+ import { A as resolveDiscordSendEmbeds, D as createDiscordMessageNonce, E as buildDiscordMessageRequest, M as createDiscordClient, O as resolveDiscordMessageFlags, c as resolveChannelId, d as sendDiscordChunks, f as sendDiscordMedia, i as normalizeDiscordPollInput, j as resolveDiscordSuppressEmbeds, k as resolveDiscordSendComponents, l as resolveDiscordChannel, n as buildDiscordTextChunks, s as normalizeStickerIds, t as buildDiscordSendError } from "./send.shared-a_6Oeyg1.mjs";
3
+ import { T as createThread, q as withDiscordRequestAuthority, w as createChannelMessage } from "./discord-DGVSguhx.mjs";
4
+ import { n as createDiscordSendReceiptFromResults, r as createDiscordSendResult, u as createReusableDiscordReplyReference } from "./send.receipt-NZDOTZBU.mjs";
5
+ import { a as normalizeDiscordSnowflake, i as normalizeDiscordHandleKey, s as resolveDiscordDirectoryUserId } from "./directory-live-DH3tpS3x.mjs";
6
+ import { t as parseAndResolveDiscordTarget } from "./target-resolver-BOOzqxxM.mjs";
6
7
  import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
7
8
  import { ChannelType } from "discord-api-types/v10";
8
9
  import { requireRuntimeConfig } from "openclaw/plugin-sdk/plugin-config-runtime";
@@ -13,6 +14,35 @@ import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
13
14
  import { recordChannelActivity } from "openclaw/plugin-sdk/channel-activity-runtime";
14
15
  import { resolveMarkdownTableMode } from "openclaw/plugin-sdk/markdown-table-runtime";
15
16
  import { fromMarkdown } from "mdast-util-from-markdown";
17
+ //#region extensions/discord/src/url-ranges.ts
18
+ const DISCORD_URL_START_RE = /(?:[A-Za-z][A-Za-z0-9+.-]*:\/\/|www\.|\/\/|mailto:)/giu;
19
+ function findDiscordUrlRanges(markdown) {
20
+ const ranges = [];
21
+ for (const match of markdown.matchAll(DISCORD_URL_START_RE)) {
22
+ const start = match.index;
23
+ const preceding = markdown[start - 1] ?? "";
24
+ if (/[\p{L}\p{N}]/u.test(preceding) || preceding === "_" && markdown[start - 2] !== "_") continue;
25
+ let end = start + match[0].length;
26
+ let parenthesisDepth = 0;
27
+ while (end < markdown.length) {
28
+ const char = markdown[end];
29
+ if (!char || /[\s<>]/u.test(char)) break;
30
+ if (char === "(") parenthesisDepth += 1;
31
+ else if (char === ")") {
32
+ if (parenthesisDepth === 0) break;
33
+ parenthesisDepth -= 1;
34
+ }
35
+ end += 1;
36
+ }
37
+ while (/[.,!?;:'"]/u.test(markdown[end - 1] ?? "")) end -= 1;
38
+ ranges.push({
39
+ start,
40
+ end
41
+ });
42
+ }
43
+ return ranges;
44
+ }
45
+ //#endregion
16
46
  //#region extensions/discord/src/mentions.ts
17
47
  const MENTION_CANDIDATE_PATTERN = /(^|[\s([{"'.,;:!?])@([a-z0-9_.-]{2,32}(?:#[0-9]{4})?)/gi;
18
48
  const DISCORD_RESERVED_MENTIONS = /* @__PURE__ */ new Set(["everyone", "here"]);
@@ -20,14 +50,9 @@ const DISCORD_DISCRIMINATOR_SUFFIX = /#\d{4}$/;
20
50
  const DISCORD_BROADCAST_MENTION_PATTERN = /@(everyone|here)\b/;
21
51
  function formatMention(params) {
22
52
  const userId = params.userId == null ? null : normalizeDiscordSnowflake(params.userId);
23
- const roleId = params.roleId == null ? null : normalizeDiscordSnowflake(params.roleId);
24
53
  const channelId = params.channelId == null ? null : normalizeDiscordSnowflake(params.channelId);
25
- const mentions = [
26
- userId ? `<@${userId}>` : null,
27
- roleId ? `<@&${roleId}>` : null,
28
- channelId ? `<#${channelId}>` : null
29
- ].filter((entry) => Boolean(entry));
30
- if (mentions.length !== 1) throw new Error("formatMention requires exactly one of userId, roleId, or channelId");
54
+ const mentions = [userId ? `<@${userId}>` : null, channelId ? `<#${channelId}>` : null].filter((entry) => Boolean(entry));
55
+ if (mentions.length !== 1) throw new Error("formatMention requires exactly one of userId or channelId");
31
56
  return expectDefined(mentions.at(0), "single Discord mention target");
32
57
  }
33
58
  function resolveConfiguredMentionAlias(handle, mentionAliases) {
@@ -45,15 +70,20 @@ function resolveConfiguredMentionAlias(handle, mentionAliases) {
45
70
  }
46
71
  }
47
72
  function rewritePlainTextMentions(text, params) {
48
- return text.replace(MENTION_CANDIDATE_PATTERN, (match, prefix, handle) => {
49
- const lookup = handle.toLowerCase();
50
- if (DISCORD_RESERVED_MENTIONS.has(lookup)) return match;
51
- const userId = resolveConfiguredMentionAlias(handle, params.mentionAliases) ?? resolveDiscordDirectoryUserId({
52
- accountId: params.accountId,
53
- handle
54
- });
55
- if (!userId) return match;
56
- return `${prefix}${formatMention({ userId })}`;
73
+ const urlRanges = findDiscordUrlRanges(text);
74
+ return text.replace(MENTION_CANDIDATE_PATTERN, (match, prefix, handle, offset) => {
75
+ const mentionStart = offset + prefix.length;
76
+ if (urlRanges.some(({ start, end }) => start <= mentionStart && mentionStart < end)) return match;
77
+ for (let candidate = handle; candidate.length >= 2; candidate = candidate.slice(0, -1)) {
78
+ if (DISCORD_RESERVED_MENTIONS.has(candidate.toLowerCase())) return match;
79
+ const userId = resolveConfiguredMentionAlias(candidate, params.mentionAliases) ?? resolveDiscordDirectoryUserId({
80
+ accountId: params.accountId,
81
+ handle: candidate
82
+ });
83
+ if (userId) return `${prefix}${formatMention({ userId })}${handle.slice(candidate.length)}`;
84
+ if (!candidate.endsWith(".")) return match;
85
+ }
86
+ return match;
57
87
  });
58
88
  }
59
89
  function countBacktickRun(text, index) {
@@ -111,80 +141,14 @@ function discordTextHasBroadcastMention(text) {
111
141
  //#endregion
112
142
  //#region extensions/discord/src/markdown.ts
113
143
  const DISCORD_NATIVE_TOKEN_RE = /<a?:[A-Za-z0-9_]+:\d+>|<\/[^>]+:\d+>/giu;
114
- const DISCORD_URL_START_RE = /(?:[A-Za-z][A-Za-z0-9+.-]*:\/\/|www\.)/giu;
115
- function findDiscordUrlRanges(markdown) {
116
- const ranges = [];
117
- for (const match of markdown.matchAll(DISCORD_URL_START_RE)) {
118
- const start = match.index;
119
- const preceding = markdown[start - 1] ?? "";
120
- if (/[\p{L}\p{N}]/u.test(preceding) || preceding === "_" && markdown[start - 2] !== "_") continue;
121
- let end = start + match[0].length;
122
- let parenthesisDepth = 0;
123
- while (end < markdown.length) {
124
- const char = markdown[end];
125
- if (!char || /[\s<>]/u.test(char)) break;
126
- if (char === "(") parenthesisDepth += 1;
127
- else if (char === ")") {
128
- if (parenthesisDepth === 0) break;
129
- parenthesisDepth -= 1;
130
- }
131
- end += 1;
132
- }
133
- ranges.push({
134
- start,
135
- end
136
- });
137
- }
138
- return ranges;
139
- }
140
- function markdownSemanticSignature(root) {
141
- const parts = [];
142
- const pending = [{
143
- node: root,
144
- parentStrong: false
145
- }];
146
- for (let event = pending.pop(); event; event = pending.pop()) {
147
- if (event.exiting) {
148
- parts.push(")");
149
- continue;
150
- }
151
- const { node } = event;
152
- const redundantStrong = event.parentStrong && node.type === "strong";
153
- const { children: childNodes, position: _position, ...fields } = node;
154
- const children = childNodes ?? [];
155
- if (!redundantStrong) {
156
- parts.push(`(${JSON.stringify(fields)}`);
157
- pending.push({
158
- node,
159
- parentStrong: event.parentStrong,
160
- exiting: true
161
- });
162
- }
163
- const parentStrong = event.parentStrong || node.type === "strong";
164
- for (let index = children.length - 1; index >= 0; index -= 1) {
165
- const child = children[index];
166
- if (child) pending.push({
167
- node: child,
168
- parentStrong
169
- });
170
- }
171
- }
172
- return parts.join("\n");
173
- }
174
144
  function normalizeDiscordBold(markdown) {
175
145
  if (!markdown.includes("__")) return markdown;
176
146
  const spans = [];
177
147
  const contentEdits = [];
178
148
  const starEmphasisDelimiters = /* @__PURE__ */ new Set();
179
149
  const astLinkRanges = [];
180
- const sourceTree = fromMarkdown(markdown);
181
- const activeSpanIds = [];
182
- const pending = [{ node: sourceTree }];
150
+ const pending = [{ node: fromMarkdown(markdown) }];
183
151
  for (let event = pending.pop(); event; event = pending.pop()) {
184
- if (event.exiting !== void 0) {
185
- activeSpanIds.pop();
186
- continue;
187
- }
188
152
  const { node } = event;
189
153
  const start = node.position?.start.offset;
190
154
  const end = node.position?.end.offset;
@@ -192,18 +156,18 @@ function normalizeDiscordBold(markdown) {
192
156
  start,
193
157
  end
194
158
  });
195
- let enteredSpanId;
159
+ let spanId = event.spanId;
160
+ let enteredSpan = false;
196
161
  if (node.type === "strong" && start !== void 0 && end !== void 0 && markdown.startsWith("__", start) && markdown.slice(end - 2, end) === "__") {
197
- enteredSpanId = spans.length;
162
+ spanId = spans.length;
198
163
  spans.push({
199
164
  start,
200
165
  end
201
166
  });
202
- activeSpanIds.push(enteredSpanId);
167
+ enteredSpan = true;
203
168
  }
204
- const spanId = activeSpanIds.at(-1);
205
169
  if (spanId !== void 0 && start !== void 0 && end !== void 0) {
206
- if (node.type === "strong" && enteredSpanId === void 0 && markdown.startsWith("**", start) && markdown.slice(end - 2, end) === "**") contentEdits.push({
170
+ if (node.type === "strong" && !enteredSpan && markdown.startsWith("**", start) && markdown.slice(end - 2, end) === "**") contentEdits.push({
207
171
  spanId,
208
172
  start,
209
173
  marker: "****",
@@ -245,14 +209,13 @@ function normalizeDiscordBold(markdown) {
245
209
  });
246
210
  }
247
211
  }
248
- if (enteredSpanId !== void 0) pending.push({
249
- node,
250
- exiting: enteredSpanId
251
- });
252
212
  const children = node.children ?? [];
253
213
  for (let index = children.length - 1; index >= 0; index -= 1) {
254
214
  const child = children[index];
255
- if (child) pending.push({ node: child });
215
+ if (child) pending.push({
216
+ node: child,
217
+ spanId
218
+ });
256
219
  }
257
220
  }
258
221
  if (spans.length === 0) return markdown;
@@ -269,7 +232,7 @@ function normalizeDiscordBold(markdown) {
269
232
  ...findDiscordUrlRanges(markdown),
270
233
  ...astLinkRanges,
271
234
  ...nativeTokenRanges
272
- ].toSorted((left, right) => left.start - right.start).map(({ start, end: rawEnd }) => {
235
+ ].sort((left, right) => left.start - right.start).map(({ start, end: rawEnd }) => {
273
236
  let end = rawEnd;
274
237
  while (/[.,!?;:'"]/u.test(markdown[end - 1] ?? "")) end -= 1;
275
238
  let previousEnd = -1;
@@ -293,55 +256,34 @@ function normalizeDiscordBold(markdown) {
293
256
  marker: "**",
294
257
  consume: 2,
295
258
  delimiter: true
296
- }))), ...contentEdits].toSorted((left, right) => left.start - right.start);
297
- const editsBySpan = /* @__PURE__ */ new Map();
298
- for (const edit of edits) {
299
- const spanEdits = editsBySpan.get(edit.spanId) ?? [];
300
- spanEdits.push(edit);
301
- editsBySpan.set(edit.spanId, spanEdits);
302
- }
303
- const renderEdits = (selectedEdits, start = 0, end = markdown.length) => {
304
- let cursor = start;
259
+ }))), ...contentEdits].sort((left, right) => left.start - right.start);
260
+ const renderEdits = (selectedEdits) => {
261
+ let cursor = 0;
305
262
  let rendered = "";
306
263
  for (const edit of selectedEdits) {
307
264
  rendered += `${markdown.slice(cursor, edit.start)}${edit.marker}`;
308
265
  cursor = edit.start + edit.consume;
309
266
  }
310
- return rendered + markdown.slice(cursor, end);
267
+ return rendered + markdown.slice(cursor);
311
268
  };
312
269
  const protectedSpanIds = /* @__PURE__ */ new Set();
313
270
  const protectedEditKeys = /* @__PURE__ */ new Set();
314
- const spansWithProtectedContent = /* @__PURE__ */ new Set();
315
271
  let rangeIndex = 0;
316
272
  for (const edit of edits) {
317
273
  while ((protectedRanges[rangeIndex]?.end ?? Number.POSITIVE_INFINITY) <= edit.start) rangeIndex += 1;
318
274
  const range = protectedRanges[rangeIndex];
319
275
  if (range && (edit.consume === 0 ? edit.start >= range.start && edit.start < range.end : edit.start < range.end && edit.start + edit.consume > range.start)) {
320
- if (edit.delimiter) protectedSpanIds.add(edit.spanId);
321
- else {
322
- protectedEditKeys.add(`${edit.start}:${edit.consume}:${edit.marker}`);
323
- spansWithProtectedContent.add(edit.spanId);
324
- }
276
+ if (edit.delimiter || !astLinkRanges.some(({ start, end }) => edit.start >= start && edit.start + edit.consume <= end)) protectedSpanIds.add(edit.spanId);
277
+ else protectedEditKeys.add(`${edit.start}:${edit.consume}:${edit.marker}`);
325
278
  }
326
279
  }
327
- for (const spanId of spansWithProtectedContent) {
328
- const span = spans[spanId];
329
- if (!span) continue;
330
- const localRendered = renderEdits((editsBySpan.get(spanId) ?? []).filter((edit) => {
331
- const key = `${edit.start}:${edit.consume}:${edit.marker}`;
332
- return !protectedEditKeys.has(key);
333
- }), span.start, span.end);
334
- const localSource = markdown.slice(span.start, span.end);
335
- if (markdownSemanticSignature(fromMarkdown(localRendered)) !== markdownSemanticSignature(fromMarkdown(localSource))) protectedSpanIds.add(spanId);
336
- }
337
280
  const seenEdits = /* @__PURE__ */ new Set();
338
- const rendered = renderEdits(edits.filter((edit) => {
281
+ return renderEdits(edits.filter((edit) => {
339
282
  const key = `${edit.start}:${edit.consume}:${edit.marker}`;
340
283
  if (protectedSpanIds.has(edit.spanId) || protectedEditKeys.has(key) || seenEdits.has(key)) return false;
341
284
  seenEdits.add(key);
342
285
  return true;
343
286
  }));
344
- return markdownSemanticSignature(fromMarkdown(rendered)) === markdownSemanticSignature(sourceTree) ? rendered : markdown;
345
287
  }
346
288
  function renderDiscordMarkdown(markdown, tableMode) {
347
289
  return normalizeDiscordBold(convertMarkdownTables(markdown, tableMode));
@@ -376,7 +318,6 @@ const DEFAULT_DISCORD_MEDIA_MAX_MB = 100;
376
318
  const DISCORD_FORUM_REQUIRE_TAG_FLAG = 16;
377
319
  /** Discord thread names are capped at 100 characters. */
378
320
  const DISCORD_THREAD_NAME_LIMIT = 100;
379
- /** Derive a thread title from the first non-empty line of the message text. */
380
321
  function deriveForumThreadName(text) {
381
322
  const firstLine = normalizeOptionalString(text.split("\n").find((line) => normalizeOptionalString(line))) ?? "";
382
323
  return truncateUtf16Safe(firstLine, DISCORD_THREAD_NAME_LIMIT) || (/* @__PURE__ */ new Date()).toISOString().slice(0, 16);
@@ -405,7 +346,10 @@ async function sendMessageDiscord(to, text, opts) {
405
346
  tableMode: opts.tableMode,
406
347
  textLimit: opts.textLimit
407
348
  });
408
- const recipient = await parseAndResolveChannelRecipient(to, cfg, accountInfo.accountId);
349
+ const recipient = await parseAndResolveDiscordTarget(to, {
350
+ cfg,
351
+ accountId: accountInfo.accountId
352
+ }, { defaultKind: "channel" });
409
353
  const { channelId } = await resolveChannelId(rest, recipient, request);
410
354
  const channel = await resolveDiscordChannel(rest, channelId);
411
355
  const deliveredResults = [];
@@ -587,7 +531,10 @@ async function sendDiscordStructuredMessage(to, opts, kind, buildPayload) {
587
531
  ...opts,
588
532
  cfg
589
533
  });
590
- const recipient = await parseAndResolveChannelRecipient(to, cfg, account.accountId);
534
+ const recipient = await parseAndResolveDiscordTarget(to, {
535
+ cfg,
536
+ accountId: account.accountId
537
+ }, { defaultKind: "channel" });
591
538
  const { channelId } = await resolveChannelId(rest, recipient, request);
592
539
  const content = opts.content?.trim() ? rewriteDiscordKnownMentions(opts.content, {
593
540
  accountId: account.accountId,
@@ -1,4 +1,4 @@
1
- import { R as RateLimitError } from "./discord-BMD-JiVS.mjs";
1
+ import { B as RateLimitError } from "./discord-DGVSguhx.mjs";
2
2
  import { t as parseDiscordTarget } from "./target-parsing-C-HyNxcE.mjs";
3
3
  import { collectErrorGraphCandidates, extractErrorCode, formatErrorMessage, readErrorName } from "openclaw/plugin-sdk/error-runtime";
4
4
  import { sleepWithAbort } from "openclaw/plugin-sdk/runtime-env";
@@ -430,7 +430,7 @@ function createDiscordRetryRunner(params) {
430
430
  throw err;
431
431
  }
432
432
  };
433
- const shouldRetry = (err, attempt) => isRetryableDiscordError(err, safety) && (attempt < retryConfig.attempts || observedGatewayDisconnect && isRetryableDiscordError(err) && !(err instanceof RateLimitError) && !collectDiscordErrorCandidates(err).some((candidate) => readDiscordErrorStatus(candidate) !== void 0));
433
+ const shouldRetry = (err, attempt) => isRetryableDiscordError(err, safety) && (attempt < retryConfig.attempts || observedGatewayDisconnect && !(err instanceof RateLimitError) && !collectDiscordErrorCandidates(err).some((candidate) => readDiscordErrorStatus(candidate) !== void 0));
434
434
  const retryAfterMs = (err) => err instanceof RateLimitError ? err.retryAfter * 1e3 : void 0;
435
435
  const signal = params.signal;
436
436
  if (signal) return retryAsync(runRequest, {
@@ -460,6 +460,25 @@ function createDiscordRetryRunner(params) {
460
460
  };
461
461
  }
462
462
  //#endregion
463
+ //#region extensions/discord/src/reply-reference.ts
464
+ function resolveDiscordReplyReference(params) {
465
+ if (!params.replyToId) return;
466
+ const singleUse = params.replyToIdSource !== "explicit" && params.replyToMode !== void 0 && isSingleUseReplyToMode(params.replyToMode);
467
+ return {
468
+ messageId: params.replyToId,
469
+ scope: singleUse ? "first" : "all"
470
+ };
471
+ }
472
+ function createReusableDiscordReplyReference(messageId) {
473
+ return messageId ? {
474
+ messageId,
475
+ scope: "all"
476
+ } : void 0;
477
+ }
478
+ function resolveDiscordReplyMessageId(reply, isFirst) {
479
+ return reply && (isFirst || reply.scope === "all") ? reply.messageId : void 0;
480
+ }
481
+ //#endregion
463
482
  //#region extensions/discord/src/normalize.ts
464
483
  function normalizeDiscordMessagingTarget(raw) {
465
484
  return parseDiscordTarget(raw, { defaultKind: "channel" })?.normalized;
@@ -506,25 +525,6 @@ function looksLikeDiscordTargetId(raw) {
506
525
  return /^<@!?\d+>$/.test(trimmed) || /^(?:(?:user|channel|discord):\d+|discord:(?:user|channel):\d+)$/i.test(trimmed) || /^\d{6,}$/.test(trimmed);
507
526
  }
508
527
  //#endregion
509
- //#region extensions/discord/src/reply-reference.ts
510
- function resolveDiscordReplyReference(params) {
511
- if (!params.replyToId) return;
512
- const singleUse = params.replyToIdSource !== "explicit" && params.replyToMode !== void 0 && isSingleUseReplyToMode(params.replyToMode);
513
- return {
514
- messageId: params.replyToId,
515
- scope: singleUse ? "first" : "all"
516
- };
517
- }
518
- function createReusableDiscordReplyReference(messageId) {
519
- return messageId ? {
520
- messageId,
521
- scope: "all"
522
- } : void 0;
523
- }
524
- function resolveDiscordReplyMessageId(reply, isFirst) {
525
- return reply && (isFirst || reply.scope === "all") ? reply.messageId : void 0;
526
- }
527
- //#endregion
528
528
  //#region extensions/discord/src/send.receipt.ts
529
529
  function toDiscordOutboundDeliveryResult(result) {
530
530
  const { channelId, ...delivery } = result;
@@ -541,17 +541,15 @@ function createDiscordSendReceiptFromResults(params) {
541
541
  results: attachChannelToResults("discord", params.results),
542
542
  threadId: params.threadId
543
543
  });
544
- return {
545
- ...receipt,
546
- parts: receipt.parts.map(({ platformMessageId, kind, threadId, replyToId, raw }, index) => ({
547
- platformMessageId,
548
- kind,
544
+ receipt.parts.forEach((part, index) => {
545
+ Object.assign(part, {
549
546
  index,
550
- threadId,
551
- replyToId,
552
- raw
553
- }))
554
- };
547
+ threadId: part.threadId,
548
+ replyToId: part.replyToId,
549
+ raw: part.raw
550
+ });
551
+ });
552
+ return receipt;
555
553
  }
556
554
  function createDiscordSendReceipt(params) {
557
555
  const results = params.platformMessageIds.map((messageId) => messageId.trim()).filter(Boolean).map((messageId, index) => {
@@ -591,4 +589,4 @@ function createDiscordSendResult(params) {
591
589
  };
592
590
  }
593
591
  //#endregion
594
- export { recordDiscordMessageCreateAmbiguity as _, createReusableDiscordReplyReference as a, allowFromContainsDiscordUserId as c, normalizeDiscordMessagingTarget as d, normalizeDiscordOutboundTarget as f, hasDiscordMessageCreateAmbiguity as g, createDiscordRetryRunner as h, toDiscordOutboundDeliveryResult as i, looksLikeDiscordTargetId as l, classifyDiscordDeliveryFailure as m, createDiscordSendReceiptFromResults as n, resolveDiscordReplyMessageId as o, canFallbackDiscordWebhookSend as p, createDiscordSendResult as r, resolveDiscordReplyReference as s, createDiscordSendReceipt as t, matchesDiscordToolContextTarget as u, chunkDiscordTextWithMode as v, findGraphemeChunkEnd as y };
592
+ export { recordDiscordMessageCreateAmbiguity as _, allowFromContainsDiscordUserId as a, normalizeDiscordMessagingTarget as c, resolveDiscordReplyMessageId as d, resolveDiscordReplyReference as f, hasDiscordMessageCreateAmbiguity as g, createDiscordRetryRunner as h, toDiscordOutboundDeliveryResult as i, normalizeDiscordOutboundTarget as l, classifyDiscordDeliveryFailure as m, createDiscordSendReceiptFromResults as n, looksLikeDiscordTargetId as o, canFallbackDiscordWebhookSend as p, createDiscordSendResult as r, matchesDiscordToolContextTarget as s, createDiscordSendReceipt as t, createReusableDiscordReplyReference as u, chunkDiscordTextWithMode as v, findGraphemeChunkEnd as y };