@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
@@ -0,0 +1,447 @@
1
+ import { t as createDiscordActionGate } from "./accounts-C_25wyxC.mjs";
2
+ import { c as normalizeDiscordMessagingTarget, f as resolveDiscordReplyReference, g as hasDiscordMessageCreateAmbiguity, i as toDiscordOutboundDeliveryResult, l as normalizeDiscordOutboundTarget, n as createDiscordSendReceiptFromResults, p as canFallbackDiscordWebhookSend, t as createDiscordSendReceipt, v as chunkDiscordTextWithMode } from "./send.receipt-NZDOTZBU.mjs";
3
+ import { t as parseDiscordTarget } from "./target-parsing-C-HyNxcE.mjs";
4
+ import { C as notifyDiscordInboundEventOutboundPayloadSuccess, S as discordInboundEventDelivery, a as resolveDiscordComponentSpec, c as formatDiscordApprovalDisplayValue, n as DISCORD_PRESENTATION_CAPABILITIES, o as sendDiscordComponentMessageLazy, r as buildDiscordPresentationPayload, v as resolveDiscordCurrentConversationIdentity } from "./outbound-session-route-Cgx4i9cS.mjs";
5
+ import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
6
+ import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env";
7
+ import { asOptionalRecord, normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeOptionalStringifiedId } from "openclaw/plugin-sdk/string-coerce-runtime";
8
+ import { getReplyPayloadTtsSupplement, resolvePayloadMediaUrls, sendPayloadMediaSequenceOrFallback, sendTextMediaPayload } from "openclaw/plugin-sdk/reply-payload";
9
+ import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
10
+ import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
11
+ import { createReplyToFanout, resolveOutboundSendDep } from "openclaw/plugin-sdk/channel-outbound";
12
+ import { attachChannelToResult, createAttachedChannelResultAdapter } from "openclaw/plugin-sdk/channel-send-result";
13
+ import { questionGatewayRuntime } from "openclaw/plugin-sdk/question-gateway-runtime";
14
+ //#region extensions/discord/src/channel.conversation.ts
15
+ function resolveDiscordAttachedOutboundTarget(params) {
16
+ if (params.threadId == null) return params.to;
17
+ const threadId = normalizeOptionalStringifiedId(params.threadId) ?? "";
18
+ return threadId ? `channel:${threadId}` : params.to;
19
+ }
20
+ function resolveDiscordConversationIdFromTargets(targets) {
21
+ for (const raw of targets) {
22
+ if (!raw) continue;
23
+ try {
24
+ const target = parseDiscordTarget(raw, { defaultKind: "channel" });
25
+ if (target?.normalized) return target.normalized;
26
+ } catch {}
27
+ }
28
+ }
29
+ function parseDiscordParentChannelFromSessionKey(raw) {
30
+ const match = normalizeLowercaseStringOrEmpty(raw).match(/(?:^|:)channel:([^:]+)$/);
31
+ return match?.[1] ? `channel:${match[1]}` : void 0;
32
+ }
33
+ function resolveDiscordCommandConversation(params) {
34
+ const threadConversation = resolveDiscordThreadConversationRef(params);
35
+ if (threadConversation) return threadConversation;
36
+ const conversationId = resolveDiscordCurrentConversationIdentity({
37
+ from: params.from,
38
+ chatType: params.chatType,
39
+ originatingTo: params.originatingTo,
40
+ commandTo: params.commandTo,
41
+ fallbackTo: params.fallbackTo
42
+ });
43
+ return conversationId ? { conversationId } : null;
44
+ }
45
+ function resolveDiscordThreadConversationRef(params) {
46
+ const threadId = normalizeOptionalStringifiedId(params.threadId);
47
+ if (!threadId) return null;
48
+ const targets = [
49
+ params.originatingTo ?? params.to,
50
+ params.commandTo,
51
+ params.fallbackTo ?? params.conversationId
52
+ ];
53
+ const parentConversationId = normalizeDiscordMessagingTarget(normalizeOptionalStringifiedId(params.threadParentId) ?? "") || parseDiscordParentChannelFromSessionKey(params.parentSessionKey) || resolveDiscordConversationIdFromTargets(targets);
54
+ return {
55
+ conversationId: threadId,
56
+ ...parentConversationId && parentConversationId !== threadId ? { parentConversationId } : {}
57
+ };
58
+ }
59
+ function resolveDiscordInboundConversation(params) {
60
+ const threadConversation = resolveDiscordThreadConversationRef({
61
+ to: params.to,
62
+ conversationId: params.conversationId,
63
+ threadId: params.threadId,
64
+ threadParentId: params.threadParentId
65
+ });
66
+ if (threadConversation) return threadConversation;
67
+ const conversationId = resolveDiscordCurrentConversationIdentity({
68
+ from: params.from,
69
+ chatType: params.isGroup ? "group" : "direct",
70
+ originatingTo: params.to,
71
+ fallbackTo: params.conversationId
72
+ });
73
+ return conversationId ? { conversationId } : null;
74
+ }
75
+ //#endregion
76
+ //#region extensions/discord/src/outbound-payload.ts
77
+ const loadDiscordSendRuntime = createLazyRuntimeModule(() => import("./send-CVW7V-VZ.mjs").then((n) => n.t));
78
+ function resolveDiscordDeliveryOptions(ctx) {
79
+ return {
80
+ onPlatformSendDispatch: ctx.onPlatformSendDispatch,
81
+ assertPlatformSendAuthorized: ctx.assertDirectAdapterHandoff,
82
+ onDeliveryResult: ctx.onDeliveryResult ? async (result) => ctx.onDeliveryResult?.(attachChannelToResult("discord", toDiscordOutboundDeliveryResult(result))) : void 0
83
+ };
84
+ }
85
+ async function createDiscordOutboundSendContext(ctx) {
86
+ const nextReplyToId = createReplyToFanout(ctx);
87
+ const resolveReply = () => resolveDiscordReplyReference({
88
+ replyToId: nextReplyToId(),
89
+ replyToIdSource: ctx.replyToIdSource,
90
+ replyToMode: ctx.replyToMode
91
+ });
92
+ const delivery = resolveDiscordDeliveryOptions(ctx);
93
+ const common = {
94
+ accountId: ctx.accountId ?? void 0,
95
+ silent: ctx.silent ?? void 0,
96
+ cfg: ctx.cfg,
97
+ signal: ctx.signal,
98
+ onPlatformSendDispatch: delivery.onPlatformSendDispatch,
99
+ assertPlatformSendAuthorized: delivery.assertPlatformSendAuthorized
100
+ };
101
+ const media = {
102
+ mediaAccess: ctx.mediaAccess,
103
+ mediaLocalRoots: ctx.mediaLocalRoots,
104
+ mediaReadFile: ctx.mediaReadFile
105
+ };
106
+ const options = (reply = resolveReply()) => ({
107
+ ...common,
108
+ verbose: false,
109
+ reply,
110
+ textLimit: ctx.formatting?.textLimit,
111
+ maxLinesPerMessage: ctx.formatting?.maxLinesPerMessage,
112
+ tableMode: ctx.formatting?.tableMode,
113
+ chunkMode: ctx.formatting?.chunkMode,
114
+ onDeliveryResult: delivery.onDeliveryResult
115
+ });
116
+ return {
117
+ target: resolveDiscordAttachedOutboundTarget(ctx),
118
+ resolveReply,
119
+ options,
120
+ mediaOptions: (mediaUrl, reply = resolveReply()) => ({
121
+ ...options(reply),
122
+ mediaUrl,
123
+ ...media
124
+ }),
125
+ voiceOptions: (reply = resolveReply()) => ({
126
+ ...common,
127
+ reply,
128
+ ...media
129
+ }),
130
+ onDeliveryResult: delivery.onDeliveryResult,
131
+ send: resolveOutboundSendDep(ctx.deps, "discord") ?? (await loadDiscordSendRuntime()).sendMessageDiscord,
132
+ sendVoice: async (...args) => await (resolveOutboundSendDep(ctx.deps, "discordVoice") ?? (await loadDiscordSendRuntime()).sendVoiceMessageDiscord)(...args)
133
+ };
134
+ }
135
+ function normalizeDiscordApprovalPayload(payload) {
136
+ if (!asOptionalRecord(payload.channelData)?.execApproval || !payload.text) return payload;
137
+ return {
138
+ ...payload,
139
+ text: payload.text.replace(/@everyone/gi, "@​everyone").replace(/@here/gi, "@​here").replace(/<@/g, "<@​").replace(/<#/g, "<#​")
140
+ };
141
+ }
142
+ const payloadLog = createSubsystemLogger("discord/outbound");
143
+ function createDiscordUnknownPayloadResult(target) {
144
+ return {
145
+ messageId: "",
146
+ channelId: target,
147
+ receipt: createDiscordSendReceipt({
148
+ platformMessageIds: [],
149
+ channelId: target,
150
+ kind: "unknown"
151
+ })
152
+ };
153
+ }
154
+ const DISCORD_TEXT_CHUNK_LIMIT = 2e3;
155
+ const DISCORD_PRECHUNK_MAX_LINES = Number.MAX_SAFE_INTEGER;
156
+ const DISCORD_VIDEO_MEDIA_EXTENSIONS = [
157
+ ".avi",
158
+ ".m4v",
159
+ ".mkv",
160
+ ".mov",
161
+ ".mp4",
162
+ ".webm"
163
+ ];
164
+ const log = createSubsystemLogger("discord/outbound");
165
+ const loadDiscordThreadBindings = createLazyRuntimeModule(() => import("./thread-bindings-zce4cpu_.mjs").then((n) => n.i));
166
+ const loadDiscordComponentSendRuntime = createLazyRuntimeModule(() => import("./send.components-C8YXdnO_.mjs").then((n) => n.i));
167
+ const discordOutbound = {
168
+ deliveryMode: "direct",
169
+ chunker: (text, limit, ctx) => chunkDiscordTextWithMode(text, {
170
+ maxChars: limit,
171
+ maxLines: ctx?.formatting?.maxLinesPerMessage ?? DISCORD_PRECHUNK_MAX_LINES
172
+ }),
173
+ textChunkLimit: DISCORD_TEXT_CHUNK_LIMIT,
174
+ pollMaxOptions: 10,
175
+ normalizePayload: ({ payload }) => normalizeDiscordApprovalPayload(payload),
176
+ presentationCapabilities: DISCORD_PRESENTATION_CAPABILITIES,
177
+ deliveryCapabilities: { durableFinal: {
178
+ text: true,
179
+ media: true,
180
+ poll: true,
181
+ payload: true,
182
+ silent: true,
183
+ replyTo: true,
184
+ thread: true,
185
+ messageSendingHooks: true
186
+ } },
187
+ renderPresentation: buildDiscordPresentationPayload,
188
+ resolveTarget: ({ to, allowFrom }) => normalizeDiscordOutboundTarget(to, allowFrom),
189
+ sendPayload: async (ctx) => {
190
+ const payload = normalizeDiscordApprovalPayload({
191
+ ...ctx.payload,
192
+ text: ctx.payload.text ?? ""
193
+ });
194
+ const mediaUrls = resolvePayloadMediaUrls(payload);
195
+ const payloadContext = {
196
+ ...ctx,
197
+ payload
198
+ };
199
+ const deliveredResults = [];
200
+ let createdThreadId;
201
+ payloadContext.onDeliveryResult = async (result) => {
202
+ await ctx.onDeliveryResult?.(result);
203
+ const threadId = result.receipt?.threadId;
204
+ if (threadId && payloadContext.threadId == null) {
205
+ payloadContext.threadId = threadId;
206
+ sendContext.target = `channel:${threadId}`;
207
+ createdThreadId = threadId;
208
+ }
209
+ if (createdThreadId && result.target?.kind === "channel" && result.receipt) deliveredResults.push({
210
+ messageId: result.messageId,
211
+ channelId: result.target.id,
212
+ receipt: result.receipt
213
+ });
214
+ };
215
+ const sendContext = await createDiscordOutboundSendContext(payloadContext);
216
+ const completeResult = (result) => createdThreadId ? {
217
+ ...result,
218
+ receipt: createDiscordSendReceiptFromResults({
219
+ results: deliveredResults,
220
+ threadId: createdThreadId
221
+ })
222
+ } : result;
223
+ const completeDelivery = (result) => attachChannelToResult("discord", toDiscordOutboundDeliveryResult(completeResult(result)));
224
+ if (payload.audioAsVoice && mediaUrls.length > 0) {
225
+ const voiceReply = sendContext.resolveReply();
226
+ let voiceFailure;
227
+ let lastResult = createDiscordUnknownPayloadResult(sendContext.target);
228
+ try {
229
+ const voiceUrl = expectDefined(mediaUrls.at(0), "non-empty Discord voice media URLs");
230
+ lastResult = await sendContext.sendVoice(sendContext.target, voiceUrl, sendContext.voiceOptions(voiceReply));
231
+ } catch (err) {
232
+ if (hasDiscordMessageCreateAmbiguity(err)) throw err;
233
+ const supplement = getReplyPayloadTtsSupplement(payload);
234
+ const visibleFallbackText = payload.text?.trim() ? payload.text : void 0;
235
+ const hiddenFallbackText = supplement?.visibleTextAlreadyDelivered ? void 0 : supplement?.spokenText;
236
+ const fallbackText = visibleFallbackText ?? hiddenFallbackText;
237
+ if (!fallbackText && !supplement?.visibleTextAlreadyDelivered) throw err;
238
+ payloadLog.warn("discord voice send failed; continuing without voice", { error: err });
239
+ if (fallbackText) await sendContext.send(sendContext.target, fallbackText, sendContext.options(voiceReply));
240
+ voiceFailure = { error: err };
241
+ }
242
+ if (!voiceFailure) {
243
+ await sendContext.onDeliveryResult?.(lastResult);
244
+ if (payload.text?.trim()) lastResult = await sendContext.send(sendContext.target, payload.text, sendContext.options());
245
+ }
246
+ for (const mediaUrl of mediaUrls.slice(1)) try {
247
+ lastResult = await sendContext.send(sendContext.target, "", sendContext.mediaOptions(mediaUrl));
248
+ } catch (err) {
249
+ if (!voiceFailure) throw err;
250
+ payloadLog.warn("discord remaining media send failed after voice failure", { error: err });
251
+ }
252
+ if (voiceFailure) throw voiceFailure.error;
253
+ return completeDelivery(lastResult);
254
+ }
255
+ const discordData = asOptionalRecord(payload.channelData?.discord) ?? {};
256
+ const filename = normalizeOptionalString(discordData.filename);
257
+ const componentSpec = await resolveDiscordComponentSpec(payload);
258
+ const nativeComponents = !componentSpec && Array.isArray(discordData.components) ? discordData.components : void 0;
259
+ const embeds = !componentSpec && Array.isArray(discordData.embeds) ? discordData.embeds : void 0;
260
+ if (!componentSpec && !nativeComponents && !embeds?.length && !filename) return completeResult(await sendTextMediaPayload({
261
+ channel: "discord",
262
+ ctx: payloadContext,
263
+ adapter: discordOutbound
264
+ }));
265
+ return completeDelivery(await sendPayloadMediaSequenceOrFallback({
266
+ text: payload.text ?? "",
267
+ mediaUrls,
268
+ fallbackResult: createDiscordUnknownPayloadResult(sendContext.target),
269
+ sendNoMedia: async () => componentSpec ? await sendDiscordComponentMessageLazy(sendContext.target, componentSpec, {
270
+ ...sendContext.options(),
271
+ filename
272
+ }) : await sendContext.send(sendContext.target, payload.text ?? "", {
273
+ components: nativeComponents,
274
+ embeds,
275
+ filename,
276
+ ...sendContext.options()
277
+ }),
278
+ send: async ({ text, mediaUrl, isFirst }) => {
279
+ if (componentSpec && isFirst) return await sendDiscordComponentMessageLazy(sendContext.target, componentSpec, {
280
+ ...sendContext.mediaOptions(mediaUrl),
281
+ filename
282
+ });
283
+ return await sendContext.send(sendContext.target, text, {
284
+ ...sendContext.mediaOptions(mediaUrl),
285
+ ...!componentSpec ? {
286
+ components: isFirst ? nativeComponents : void 0,
287
+ embeds: isFirst ? embeds : void 0,
288
+ filename: isFirst ? filename : void 0
289
+ } : {}
290
+ });
291
+ }
292
+ }));
293
+ },
294
+ ...createAttachedChannelResultAdapter({
295
+ channel: "discord",
296
+ sendText: async (ctx) => {
297
+ if (!ctx.silent && !resolveDiscordReplyReference(ctx)) try {
298
+ const threadId = normalizeOptionalStringifiedId(ctx.threadId) ?? "";
299
+ if (threadId) {
300
+ const { getThreadBindingManager } = await loadDiscordThreadBindings();
301
+ const binding = getThreadBindingManager(ctx.accountId ?? void 0)?.getByThreadId(threadId);
302
+ if (binding?.webhookId && binding.webhookToken) {
303
+ const username = normalizeOptionalString(ctx.identity?.name) || normalizeOptionalString(binding.label) || binding.agentId || "";
304
+ const { sendWebhookMessageDiscord } = await loadDiscordSendRuntime();
305
+ const webhookResult = await sendWebhookMessageDiscord(ctx.text, {
306
+ webhookId: binding.webhookId,
307
+ webhookToken: binding.webhookToken,
308
+ accountId: binding.accountId,
309
+ threadId: binding.threadId,
310
+ cfg: ctx.cfg,
311
+ signal: ctx.signal,
312
+ username: truncateUtf16Safe(username, 80) || void 0,
313
+ avatarUrl: normalizeOptionalString(ctx.identity?.avatarUrl),
314
+ tableMode: ctx.formatting?.tableMode,
315
+ chunking: {
316
+ maxChars: ctx.formatting?.textLimit,
317
+ maxLines: ctx.formatting?.maxLinesPerMessage
318
+ },
319
+ ...resolveDiscordDeliveryOptions(ctx)
320
+ });
321
+ if (webhookResult) return toDiscordOutboundDeliveryResult(webhookResult);
322
+ }
323
+ }
324
+ } catch (error) {
325
+ if (!canFallbackDiscordWebhookSend(error)) throw error;
326
+ log.warn("discord webhook persona send failed; falling back to bot send", { error });
327
+ }
328
+ const prepared = await createDiscordOutboundSendContext(ctx);
329
+ return toDiscordOutboundDeliveryResult(await prepared.send(prepared.target, ctx.text, prepared.options()));
330
+ },
331
+ sendMedia: async (ctx) => {
332
+ const prepared = await createDiscordOutboundSendContext(ctx);
333
+ const { send, target } = prepared;
334
+ const reply = prepared.resolveReply();
335
+ if (ctx.audioAsVoice && ctx.mediaUrl) return toDiscordOutboundDeliveryResult(await prepared.sendVoice(target, ctx.mediaUrl, prepared.voiceOptions(reply)));
336
+ const options = prepared.options(reply);
337
+ const mediaOptions = prepared.mediaOptions(ctx.mediaUrl, reply);
338
+ const trimmed = ctx.text.trim() && ctx.mediaUrl?.trim();
339
+ if (trimmed) {
340
+ let path;
341
+ try {
342
+ const { pathname } = new URL(trimmed);
343
+ path = pathname.slice(pathname.lastIndexOf("/") + 1);
344
+ try {
345
+ path = decodeURIComponent(path);
346
+ } catch {}
347
+ } catch {
348
+ path = trimmed.split(/[?#]/, 1)[0] ?? trimmed;
349
+ }
350
+ const normalized = normalizeLowercaseStringOrEmpty(path);
351
+ if (DISCORD_VIDEO_MEDIA_EXTENSIONS.some((ext) => normalized.endsWith(ext))) {
352
+ const captionResult = await send(target, ctx.text, options);
353
+ const mediaResult = await send(captionResult.receipt?.threadId ? `channel:${captionResult.receipt.threadId}` : target, "", {
354
+ ...mediaOptions,
355
+ reply: options.reply?.scope === "all" ? options.reply : void 0
356
+ });
357
+ const threadId = captionResult.receipt?.threadId;
358
+ return toDiscordOutboundDeliveryResult({
359
+ ...threadId ? captionResult : mediaResult,
360
+ receipt: createDiscordSendReceiptFromResults({
361
+ results: [captionResult, mediaResult],
362
+ threadId
363
+ })
364
+ });
365
+ }
366
+ }
367
+ return toDiscordOutboundDeliveryResult(await send(target, ctx.text, mediaOptions));
368
+ },
369
+ sendPoll: async ({ cfg, to, poll, content, accountId, threadId, silent, signal, sessionKey, inboundEventKind, onPlatformSendDispatch, assertDirectAdapterHandoff }) => {
370
+ if (!createDiscordActionGate({
371
+ cfg,
372
+ accountId
373
+ })("polls")) throw new Error("Discord polls are disabled.");
374
+ const outboundTo = resolveDiscordAttachedOutboundTarget({
375
+ to,
376
+ threadId
377
+ });
378
+ const result = await (await loadDiscordSendRuntime()).sendPollDiscord(outboundTo, poll, {
379
+ accountId: accountId ?? void 0,
380
+ content,
381
+ threadId: threadId ?? void 0,
382
+ silent: silent ?? void 0,
383
+ cfg,
384
+ signal,
385
+ onPlatformSendDispatch,
386
+ assertPlatformSendAuthorized: assertDirectAdapterHandoff
387
+ });
388
+ discordInboundEventDelivery.notify({
389
+ sessionKey,
390
+ inboundEventKind,
391
+ to: outboundTo,
392
+ accountId
393
+ });
394
+ return result;
395
+ }
396
+ }),
397
+ adoptTargetFromDelivery: ({ result }) => {
398
+ const threadId = normalizeOptionalStringifiedId(result.receipt?.threadId);
399
+ return threadId ? { threadId } : null;
400
+ },
401
+ afterDeliverPayload: async ({ cfg, target, payload, results }) => {
402
+ notifyDiscordInboundEventOutboundPayloadSuccess({
403
+ payload,
404
+ to: resolveDiscordAttachedOutboundTarget({
405
+ to: target.to,
406
+ threadId: target.threadId
407
+ }),
408
+ accountId: target.accountId
409
+ });
410
+ const questionId = questionGatewayRuntime.readAskUserQuestionId(payload);
411
+ const result = results.find((candidate) => candidate.channel === "discord" && candidate.messageId);
412
+ const componentSpec = questionId ? await resolveDiscordComponentSpec(payload) : void 0;
413
+ if (questionId && result && componentSpec) {
414
+ const to = resolveDiscordAttachedOutboundTarget({
415
+ to: target.to,
416
+ threadId: target.threadId
417
+ });
418
+ const channelId = result.target?.kind === "channel" ? result.target.id : to;
419
+ questionGatewayRuntime.registerChannelDelivery({
420
+ questionId,
421
+ deliveryId: `discord:${target.accountId ?? "default"}:${channelId}:${result.messageId}`,
422
+ finalize: async (statusLine) => {
423
+ const { editDiscordComponentMessage } = await loadDiscordComponentSendRuntime();
424
+ await editDiscordComponentMessage(to, result.messageId, {
425
+ ...componentSpec,
426
+ blocks: [...(componentSpec.blocks ?? []).filter((block) => block.type !== "actions"), {
427
+ type: "text",
428
+ text: `-# ${formatDiscordApprovalDisplayValue(statusLine)}`
429
+ }],
430
+ modal: void 0
431
+ }, {
432
+ cfg,
433
+ accountId: target.accountId ?? void 0
434
+ });
435
+ }
436
+ });
437
+ }
438
+ const threadId = normalizeOptionalStringifiedId(target.threadId);
439
+ if (!threadId) return;
440
+ const { getThreadBindingManager } = await loadDiscordThreadBindings();
441
+ const manager = getThreadBindingManager(target.accountId ?? void 0);
442
+ if (!manager?.getByThreadId(threadId)) return;
443
+ await manager.touchThread({ threadId });
444
+ }
445
+ };
446
+ //#endregion
447
+ export { resolveDiscordInboundConversation as a, resolveDiscordCommandConversation as i, discordOutbound as n, resolveDiscordAttachedOutboundTarget as r, DISCORD_TEXT_CHUNK_LIMIT as t };