@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,43 +1,41 @@
1
- import { m as resolveDiscordMaxLinesPerMessage } from "./accounts-ljrzXBJi.mjs";
2
- import { i as normalizeDiscordAllowList, o as normalizeDiscordSlug, w as resolveTimestampMs } from "./allow-list-BKqOldGy.mjs";
3
- import { F as createDiscordRuntimeAccountContext, O as resolveDiscordMessageFlags, P as createDiscordRestClient, u as resolveDiscordTargetChannelId } from "./send.shared-CnlMgoqQ.mjs";
4
- import { G as withDiscordRequestAuthority, Q as Message, W as captureDiscordRequestAuthority, dt as editChannelMessage, t as discord_exports, ut as deleteChannelMessage, vt as getGuildMember } from "./discord-BMD-JiVS.mjs";
5
- import { v as chunkDiscordTextWithMode } from "./send.receipt-C18khRYH.mjs";
1
+ import { m as resolveDiscordMaxLinesPerMessage } from "./accounts-C_25wyxC.mjs";
2
+ import { N as createDiscordRestClient, O as resolveDiscordMessageFlags, P as createDiscordRuntimeAccountContext, u as resolveDiscordTargetChannelId } from "./send.shared-a_6Oeyg1.mjs";
3
+ import { D as editChannelMessage, E as deleteChannelMessage, K as captureDiscordRequestAuthority, P as getGuildMember, h as Message, q as withDiscordRequestAuthority, t as discord_exports } from "./discord-DGVSguhx.mjs";
4
+ import { i as normalizeDiscordAllowList, o as normalizeDiscordSlug } from "./allow-list-BXrS8-R9.mjs";
5
+ import { h as createDiscordRetryRunner, v as chunkDiscordTextWithMode } from "./send.receipt-NZDOTZBU.mjs";
6
6
  import { n as resolveDiscordChannelId } from "./target-parsing-C-HyNxcE.mjs";
7
- import { a as removeReactionDiscord, r as reactMessageDiscord } from "./send-da6ENJ9f.mjs";
8
- import { o as discordTextHasBroadcastMention } from "./send.outbound-qZ3iK3Vq.mjs";
9
- import { n as DISCORD_ATTACHMENT_TOTAL_TIMEOUT_MS, t as DISCORD_ATTACHMENT_IDLE_TIMEOUT_MS } from "./timeouts-CuNARfyw.mjs";
10
- import "./targets-UWWZ6gF7.mjs";
11
- import { C as discordInboundEventDelivery, p as buildDiscordRoutePeer, v as resolveDiscordConversationIdentity } from "./outbound-session-route-BtUpGBTb.mjs";
12
- import { t as DISCORD_TEXT_CHUNK_LIMIT } from "./outbound-adapter-DfAanoCO.mjs";
13
- import { T as createDiscordSupplementalContextAccessChecker, c as formatDiscordReplySkip, d as buildGuildLabel, f as resolveReplyContext, l as sanitizeDiscordFrontChannelReplyPayloads, o as deliverDiscordReply, s as formatDiscordReplyDeliveryFailure, u as buildDirectLabel, w as buildDiscordInboundAccessContext } from "./provider-CI_OLfvz.mjs";
14
- import { D as resolveDiscordMessageStickers, b as resolveDiscordMessageText, h as resolveDiscordThreadStarter, k as resolveDiscordReferencedReplyMessageId, v as resolveDiscordMessageHistoryText, w as resolveReferencedReplyMediaList, x as formatDiscordMediaText } from "./transcripts-source-8RDQrSVb.mjs";
15
- import { n as resolveDiscordWebhookId, t as resolveDiscordSenderIdentity } from "./sender-identity-DgbJykq0.mjs";
16
- import { n as resolveDiscordAutoThreadReplyPlan } from "./threading-CzjFeUSe.mjs";
17
- import { t as beginDiscordActiveTurnThreadRoute } from "./active-turn-thread-route-C4tp9noA.mjs";
18
- import { a as createDiscordHistorySenderProvenance, l as isBoundThreadBotSystemMessage, m as shouldIgnoreBoundThreadWebhookMessage, o as filterDiscordHistoryEntriesForContext, s as resolveDiscordHistoryMediaIds, t as resolveDiscordPreflightPluralKitInfo } from "./message-handler.preflight-pluralkit-D5si80_L.mjs";
7
+ import { a as removeReactionDiscord, r as reactMessageDiscord } from "./send-CVW7V-VZ.mjs";
8
+ import { o as discordTextHasBroadcastMention } from "./send.outbound-Uzcmh3Yd.mjs";
9
+ import { n as DISCORD_ATTACHMENT_TOTAL_TIMEOUT_MS, t as DISCORD_ATTACHMENT_IDLE_TIMEOUT_MS } from "./timeouts-cIxzatmv.mjs";
10
+ import { S as discordInboundEventDelivery, _ as resolveDiscordConversationIdentity, p as buildDiscordRoutePeer } from "./outbound-session-route-Cgx4i9cS.mjs";
11
+ import { t as DISCORD_TEXT_CHUNK_LIMIT } from "./outbound-payload-BaZmjewa.mjs";
12
+ import { C as buildDiscordInboundAccessContext, c as formatDiscordReplySkip, d as buildGuildLabel, f as resolveReplyContext, l as sanitizeDiscordFrontChannelReplyPayloads, o as deliverDiscordReply, s as formatDiscordReplyDeliveryFailure, u as buildDirectLabel, w as createDiscordSupplementalContextAccessChecker } from "./provider-BN2bCIUp.mjs";
13
+ import { D as resolveDiscordMessageStickers, b as resolveDiscordMessageText, h as resolveDiscordThreadStarter, k as resolveDiscordReferencedReplyMessageId, v as resolveDiscordMessageHistoryText, w as resolveReferencedReplyMediaList, x as formatDiscordMediaText } from "./transcripts-source-ie9GBWaU.mjs";
14
+ import { n as resolveDiscordWebhookId, t as resolveDiscordSenderIdentity } from "./sender-identity-76HFb8eK.mjs";
15
+ import { n as resolveDiscordAutoThreadReplyPlan } from "./threading-DodLYDt-.mjs";
16
+ import { t as beginDiscordActiveTurnThreadRoute } from "./active-turn-thread-route-KvRTAVE3.mjs";
17
+ import { a as createDiscordHistorySenderProvenance, l as isBoundThreadBotSystemMessage, o as filterDiscordHistoryEntriesForContext, p as shouldIgnoreBoundThreadWebhookMessage, s as resolveDiscordHistoryMediaIds, t as resolveDiscordPreflightPluralKitInfo } from "./message-handler.preflight-pluralkit-CYZfXXb6.mjs";
19
18
  import { t as sendTyping } from "./typing-CNlSKY5S.mjs";
20
19
  import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
21
- import { danger, logVerbose, shouldLogVerbose, sleepWithAbort } from "openclaw/plugin-sdk/runtime-env";
20
+ import { danger, logVerbose, sleepWithAbort } from "openclaw/plugin-sdk/runtime-env";
22
21
  import { buildAgentSessionKey, resolveThreadSessionKeys } from "openclaw/plugin-sdk/routing";
23
22
  import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
24
23
  import { AllowedMentionsTypes, Routes } from "discord-api-types/v10";
25
24
  import { getAgentScopedMediaLocalRoots } from "openclaw/plugin-sdk/media-runtime";
26
25
  import { getReplyPayloadTtsSupplement, isReplyPayloadNonTerminalToolErrorWarning, resolveSendableOutboundReplyParts } from "openclaw/plugin-sdk/reply-payload";
26
+ import { parseDateStringTimestampMs } from "openclaw/plugin-sdk/number-runtime";
27
27
  import { resolveChunkMode } from "openclaw/plugin-sdk/reply-chunking";
28
28
  import { stripInlineDirectiveTagsForDelivery, stripReasoningTagsFromText } from "openclaw/plugin-sdk/text-chunking";
29
29
  import { AsyncLocalStorage } from "node:async_hooks";
30
- import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
31
30
  import { resolveBatchedReplyThreadingPolicy } from "openclaw/plugin-sdk/reply-reference";
32
31
  import { resolveMarkdownTableMode } from "openclaw/plugin-sdk/markdown-table-runtime";
33
32
  import { bindIngressLifecycleToReplyOptions, createChannelMessageReplyPipeline, createChannelProgressDraftCompositor, createFinalizableDraftLifecycle, createLivePreviewLifecycle, createTypingCallbacks, isRecentOutboundMessageIdentity, resolveChannelDraftStreamingChunking, resolveChannelMessageSourceReplyDeliveryMode, resolveChannelPreviewStreamMode, resolveChannelStreamingBlockEnabled, resolveChannelStreamingPreviewCommandText, resolveChannelStreamingProgressNarration, resolveTranscriptBackedChannelFinalText } from "openclaw/plugin-sdk/channel-outbound";
34
33
  import { evaluateSupplementalContextVisibility } from "openclaw/plugin-sdk/security-runtime";
35
34
  import { resolvePinnedMainDmOwnerFromAllowlist as resolvePinnedMainDmOwnerFromAllowlist$1 } from "openclaw/plugin-sdk/conversation-runtime";
36
- import { resolveAgentConfig } from "openclaw/plugin-sdk/agent-scope-runtime";
37
35
  import { isDangerousNameMatchingEnabled } from "openclaw/plugin-sdk/dangerous-name-runtime";
38
- import { EmbeddedBlockChunker, resolveAckReaction, resolveAgentConfig as resolveAgentConfig$1, resolveHumanDelayConfig } from "openclaw/plugin-sdk/agent-runtime";
36
+ import { EmbeddedBlockChunker, resolveAckReaction, resolveAgentConfig, resolveHumanDelayConfig } from "openclaw/plugin-sdk/agent-runtime";
39
37
  import { getSessionEntryAsync, readSessionUpdatedAtAsync, resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
40
- import { buildChannelInboundEventContext, createCommandTurnContext, dispatchChannelInboundTurn, formatInboundEnvelope, formatInboundMediaUnavailableText, getGroupThreadDeliverySession, hasFinalInboundReplyDispatch, readAgentRunTerminalOutcome, resolveEnvelopeFormatOptions, toHistoryMediaEntries, toInboundMediaFactsWithMetadata } from "openclaw/plugin-sdk/channel-inbound";
38
+ import { buildChannelInboundEventContext, createCommandTurnContext, dispatchChannelInboundTurn, formatInboundEnvelope, formatInboundMediaUnavailableText, getGroupThreadDeliverySession, readAgentRunTerminalOutcome, resolveEnvelopeFormatOptions, toHistoryMediaEntries, toInboundMediaFactsWithMetadata } from "openclaw/plugin-sdk/channel-inbound";
41
39
  import { readLatestAssistantTextByIdentity } from "openclaw/plugin-sdk/session-transcript-runtime";
42
40
  import { getGlobalHookRunner } from "openclaw/plugin-sdk/plugin-runtime";
43
41
  import { buildHistoryContextFromEntries, buildInboundHistoryFromEntries, createChannelHistoryWindow } from "openclaw/plugin-sdk/reply-history";
@@ -53,7 +51,7 @@ async function recoverDiscordChannelHistory(params) {
53
51
  if (ctx.canonicalMessageId) excludedIds.add(ctx.canonicalMessageId);
54
52
  let remaining = ctx.historyLimit + excludedIds.size - 1;
55
53
  let before = ctx.message.id;
56
- const triggerTimestamp = resolveTimestampMs(ctx.message.timestamp);
54
+ const triggerTimestamp = parseDateStringTimestampMs(ctx.message.timestamp);
57
55
  const guildId = ctx.data.guild?.id ?? ctx.data.guild_id;
58
56
  const cachedMedia = new Map((ctx.guildHistories.get(ctx.messageChannelId) ?? []).map((entry) => [entry.messageId, entry]));
59
57
  const members = /* @__PURE__ */ new Map();
@@ -71,7 +69,7 @@ async function recoverDiscordChannelHistory(params) {
71
69
  remaining -= window.length;
72
70
  for (const raw of window) {
73
71
  const row = raw;
74
- const timestamp = resolveTimestampMs(row.timestamp);
72
+ const timestamp = parseDateStringTimestampMs(row.timestamp);
75
73
  if (row.channel_id !== ctx.messageChannelId || row.guild_id && row.guild_id !== guildId || excludedIds.has(row.id) || /^\d+$/u.test(row.id) && /^\d+$/u.test(ctx.message.id) && BigInt(row.id) >= BigInt(ctx.message.id) || timestamp === void 0 || triggerTimestamp !== void 0 && timestamp > triggerTimestamp || params.sessionStartedAt !== void 0 && timestamp < params.sessionStartedAt || row.type === discord_exports.MessageType.ChatInputCommand || row.type === discord_exports.MessageType.ContextMenuCommand || row.author.id === ctx.botUserId) continue;
76
74
  excludedIds.add(row.id);
77
75
  const message = new Message(ctx.client, row);
@@ -145,7 +143,7 @@ async function recoverDiscordChannelHistory(params) {
145
143
  entries: entries.toReversed(),
146
144
  mode: params.mode,
147
145
  isSenderAllowed: params.isSenderAllowed
148
- }).entries.slice(-ctx.historyLimit);
146
+ }).slice(-ctx.historyLimit);
149
147
  } catch (error) {
150
148
  ctx.runtime.error(danger(`discord: recent history omitted for ${ctx.messageChannelId}: ${String(error)}`));
151
149
  return [];
@@ -202,7 +200,10 @@ async function buildDiscordMessageProcessContext(params) {
202
200
  const groupChannel = isGuildMessage && displayChannelSlug ? `#${displayChannelSlug}` : void 0;
203
201
  const senderName = sender.isPluralKit ? sender.name ?? author.username : data.member?.nickname ?? author.globalName ?? author.username;
204
202
  const senderUsername = sender.isPluralKit ? sender.tag ?? sender.name ?? author.username : author.username;
205
- const { groupSystemPrompt, ownerAllowFrom, channelStructuredContext } = buildDiscordInboundAccessContext({
203
+ const { groupSystemPrompt, ownerAllowFrom, channelStructuredContext, toolPolicy } = buildDiscordInboundAccessContext({
204
+ cfg,
205
+ accountId,
206
+ parentId: threadParentId,
206
207
  channelConfig,
207
208
  guildInfo,
208
209
  sender: {
@@ -210,6 +211,8 @@ async function buildDiscordMessageProcessContext(params) {
210
211
  name: sender.name,
211
212
  tag: sender.tag
212
213
  },
214
+ senderName,
215
+ senderUsername,
213
216
  allowNameMatching: isDangerousNameMatchingEnabled(discordConfig),
214
217
  isGuild: isGuildMessage,
215
218
  channelTopic: channelInfo?.topic
@@ -262,7 +265,7 @@ async function buildDiscordMessageProcessContext(params) {
262
265
  let combinedBody = formatInboundEnvelope({
263
266
  channel: "Discord",
264
267
  from: fromLabel,
265
- timestamp: resolveTimestampMs(message.timestamp),
268
+ timestamp: parseDateStringTimestampMs(message.timestamp),
266
269
  body: bodyWithMediaNotice,
267
270
  chatType: isDirectMessage ? "direct" : "channel",
268
271
  senderLabel,
@@ -283,7 +286,7 @@ async function buildDiscordMessageProcessContext(params) {
283
286
  entries: guildHistories.get(messageChannelId) ?? [],
284
287
  mode: contextVisibilityMode,
285
288
  isSenderAllowed: isSupplementalContextSenderAllowed
286
- }).entries.slice(-historyLimit);
289
+ }).slice(-historyLimit);
287
290
  if (!isHistoryCurrent()) return null;
288
291
  combinedBody = buildHistoryContextFromEntries({
289
292
  entries: visibleChannelHistory,
@@ -322,7 +325,7 @@ async function buildDiscordMessageProcessContext(params) {
322
325
  accountId,
323
326
  parentId: threadParentId,
324
327
  parentType: threadParentType,
325
- resolveTimestampMs
328
+ resolveTimestampMs: parseDateStringTimestampMs
326
329
  });
327
330
  if (!isHistoryCurrent()) return null;
328
331
  if (starter?.text) {
@@ -385,7 +388,7 @@ async function buildDiscordMessageProcessContext(params) {
385
388
  threadParentInheritanceEnabled
386
389
  });
387
390
  if (!isHistoryCurrent()) return null;
388
- const { deliverTarget, replyTarget, autoThreadContext } = replyPlan;
391
+ const { replyTarget, autoThreadContext } = replyPlan;
389
392
  const conversationParentId = threadChannel ? threadParentId : autoThreadContext ? messageChannelId : void 0;
390
393
  const effectiveFrom = isDirectMessage ? `discord:${author.id}` : autoThreadContext?.From ?? `discord:channel:${messageChannelId}`;
391
394
  const dmConversationTarget = isDirectMessage ? resolveDiscordConversationIdentity({
@@ -428,7 +431,7 @@ async function buildDiscordMessageProcessContext(params) {
428
431
  accountId: route.accountId,
429
432
  messageId: canonicalMessageId ?? message.id,
430
433
  messageIdFull: canonicalMessageId && canonicalMessageId !== message.id ? message.id : void 0,
431
- timestamp: resolveTimestampMs(message.timestamp),
434
+ timestamp: parseDateStringTimestampMs(message.timestamp),
432
435
  from: effectiveFrom,
433
436
  sender: {
434
437
  id: sender.id,
@@ -480,6 +483,7 @@ async function buildDiscordMessageProcessContext(params) {
480
483
  historyKind: isGuildMessage ? "recent" : "pending"
481
484
  },
482
485
  access: {
486
+ toolPolicy,
483
487
  mentions: {
484
488
  canDetectMention: ctx.canDetectMention,
485
489
  wasMentioned: ctx.effectiveWasMentioned,
@@ -537,7 +541,7 @@ async function buildDiscordMessageProcessContext(params) {
537
541
  const persistedSessionKey = ctxPayload.SessionKey ?? route.sessionKey;
538
542
  if (ctx.inboundEventKind === "room_event" && shouldIncludeChannelHistory) {
539
543
  const historyText = [text, formatDiscordMediaText({
540
- attachments: message.attachments ?? void 0,
544
+ attachments: message.attachments,
541
545
  stickers: resolveDiscordMessageStickers(message)
542
546
  })].filter(Boolean).join("\n");
543
547
  await channelHistory.recordWithMedia({
@@ -546,7 +550,7 @@ async function buildDiscordMessageProcessContext(params) {
546
550
  entry: {
547
551
  sender: senderName,
548
552
  body: historyText,
549
- timestamp: resolveTimestampMs(message.timestamp),
553
+ timestamp: parseDateStringTimestampMs(message.timestamp),
550
554
  messageId: message.id,
551
555
  mediaIds: resolveDiscordHistoryMediaIds(message),
552
556
  senderProvenance: createDiscordHistorySenderProvenance({
@@ -558,10 +562,6 @@ async function buildDiscordMessageProcessContext(params) {
558
562
  messageId: message.id
559
563
  });
560
564
  }
561
- if (shouldLogVerbose()) {
562
- const preview = truncateUtf16Safe(combinedBody, 200).replace(/\n/g, "\\n");
563
- logVerbose(`discord inbound: channel=${messageChannelId} deliver=${deliverTarget} from=${ctxPayload.From} preview="${preview}"`);
564
- }
565
565
  return {
566
566
  ctxPayload,
567
567
  persistedSessionKey,
@@ -587,136 +587,6 @@ async function buildDiscordMessageProcessContext(params) {
587
587
  };
588
588
  }
589
589
  //#endregion
590
- //#region extensions/discord/src/monitor/message-handler.process-progress.ts
591
- async function createDiscordMessageProgressRuntime(params) {
592
- const { ctx, draftPreview } = params;
593
- const { cfg, route, abortSignal } = ctx;
594
- const reasoningLevel = await (async () => {
595
- const cfgDefault = resolveAgentConfig(cfg, route.agentId ?? "main")?.reasoningDefault ?? cfg.agents?.defaults?.reasoningDefault;
596
- const configDefault = cfgDefault === "on" || cfgDefault === "stream" ? cfgDefault : "off";
597
- if (!params.sessionKey) return configDefault;
598
- try {
599
- const storePath = resolveStorePath(cfg.session?.store, { agentId: route.agentId });
600
- const level = (await getSessionEntryAsync({
601
- agentId: route.agentId,
602
- sessionKey: params.sessionKey,
603
- storePath
604
- }))?.reasoningLevel;
605
- if (level === "on" || level === "stream" || level === "off") return level;
606
- } catch {
607
- return "off";
608
- }
609
- return configDefault;
610
- })();
611
- const reasoningDurableEnabled = reasoningLevel === "on";
612
- const reasoningWindowEnabled = reasoningLevel === "stream";
613
- let shouldYieldDraftCommentary = async () => false;
614
- let turnCommentaryVisible = false;
615
- return { replyOptions: {
616
- progressRequiresReply: draftPreview.isProgressMode ? true : void 0,
617
- onAssistantMessageStart: draftPreview.draftStream ? () => {
618
- if (draftPreview.handleAssistantMessageBoundary()) params.onTurnReset();
619
- return false;
620
- } : void 0,
621
- onReasoningEnd: draftPreview.draftStream ? () => {
622
- draftPreview.resetReasoningProgress();
623
- return false;
624
- } : void 0,
625
- onQueuedFollowupAdmitted: draftPreview.draftStream ? () => {
626
- if (draftPreview.handleQueuedFollowupAdmitted()) params.onTurnReset();
627
- } : void 0,
628
- onQueuedFollowupSettled: draftPreview.draftStream ? () => draftPreview.cleanup() : void 0,
629
- suppressDefaultToolProgressMessages: params.sourceRepliesAreToolOnly && params.reactions.statusReactionsExplicitlyEnabled || draftPreview.suppressDefaultToolProgressMessages ? true : void 0,
630
- allowToolLifecycleWhenProgressHidden: params.reactions.statusReactionsEnabled ? true : void 0,
631
- commentaryProgressEnabled: draftPreview.isProgressMode ? draftPreview.commentaryProgressEnabled : void 0,
632
- progressPreambleEnabled: draftPreview.draftStream && draftPreview.isProgressMode ? true : void 0,
633
- commentaryPayloadsEnabled: draftPreview.isProgressMode ? draftPreview.commentaryProgressEnabled : void 0,
634
- shouldDeliverCommentaryPayloads: draftPreview.isProgressMode && draftPreview.commentaryProgressEnabled ? () => turnCommentaryVisible : void 0,
635
- reasoningPayloadsEnabled: reasoningDurableEnabled,
636
- onVerboseProgressVisibilityAsync: async (isActive) => {
637
- shouldYieldDraftCommentary = isActive;
638
- turnCommentaryVisible = await isActive();
639
- },
640
- onNarrationUpdate: draftPreview.narrationProgressEnabled ? async (payload) => {
641
- if (await shouldYieldDraftCommentary() || abortSignal?.aborted) return;
642
- await draftPreview.pushNarrationProgress(payload.text);
643
- } : void 0,
644
- onProgressNarratorLifecycle: draftPreview.narrationProgressEnabled ? (lifecycle) => draftPreview.setProgressNarratorLifecycle(lifecycle) : void 0,
645
- isProgressDraftVisible: draftPreview.narrationProgressEnabled ? () => draftPreview.isProgressDraftVisible : void 0,
646
- narrationHideCommandText: draftPreview.narrationHideCommandText ? true : void 0,
647
- onReasoningStream: async (payload) => {
648
- if (payload?.requiresReasoningProgressOptIn === true && !reasoningWindowEnabled) return false;
649
- await params.reactions.controller.setThinking();
650
- return await draftPreview.pushReasoningProgress(payload?.text, { snapshot: payload?.isReasoningSnapshot === true });
651
- },
652
- streamReasoningInNonStreamModes: reasoningWindowEnabled,
653
- onToolStart: async (payload) => {
654
- if (abortSignal?.aborted) return false;
655
- await params.reactions.maybeBindToToolReaction(payload);
656
- await params.reactions.controller.setTool(payload.name);
657
- return await draftPreview.pushToolEvent(payload);
658
- },
659
- onItemEvent: async (payload) => {
660
- if (abortSignal?.aborted || payload.kind === "preamble" && await shouldYieldDraftCommentary()) return;
661
- return await draftPreview.pushItemEvent(payload);
662
- },
663
- onPlanUpdate: async (payload) => {
664
- if (payload.phase === "update") return await draftPreview.pushPlanProgress(payload.steps, {
665
- explanation: payload.explanation,
666
- explanationFormat: payload.explanationFormat
667
- });
668
- return false;
669
- },
670
- onApprovalEvent: async (payload) => {
671
- return await draftPreview.pushApprovalEvent(payload);
672
- },
673
- onCompactionStart: async () => {
674
- if (!abortSignal?.aborted) await params.reactions.controller.setCompacting();
675
- return false;
676
- },
677
- onCompactionEnd: async () => {
678
- if (!abortSignal?.aborted) {
679
- params.reactions.controller.cancelPending();
680
- await params.reactions.controller.setThinking();
681
- }
682
- return false;
683
- }
684
- } };
685
- }
686
- //#endregion
687
- //#region extensions/discord/src/monitor/ack-reactions.ts
688
- function createDiscordAckReactionContext(params) {
689
- return {
690
- rest: params.rest,
691
- ...createDiscordRuntimeAccountContext(params)
692
- };
693
- }
694
- function createDiscordAckReactionAdapter(params) {
695
- return {
696
- setReaction: async (emoji) => {
697
- await reactMessageDiscord(params.channelId, params.messageId, emoji, params.reactionContext);
698
- },
699
- removeReaction: async (emoji) => {
700
- await removeReactionDiscord(params.channelId, params.messageId, emoji, params.reactionContext);
701
- }
702
- };
703
- }
704
- function queueInitialDiscordAckReaction(params) {
705
- if (params.enabled) {
706
- params.statusReactions.setQueued();
707
- return;
708
- }
709
- if (!params.shouldSendAckReaction || !params.ackReaction) return;
710
- params.reactionAdapter.setReaction(params.ackReaction).catch((err) => {
711
- logAckFailure({
712
- log: logVerbose,
713
- channel: "discord",
714
- target: params.target,
715
- error: err
716
- });
717
- });
718
- }
719
- //#endregion
720
590
  //#region extensions/discord/src/monitor/message-handler.process-reactions.ts
721
591
  function createDiscordMessageReactionRuntime(params) {
722
592
  const { ctx } = params;
@@ -747,16 +617,22 @@ function createDiscordMessageReactionRuntime(params) {
747
617
  token,
748
618
  accountId
749
619
  }).rest;
750
- const ackReactionContext = createDiscordAckReactionContext({
620
+ const ackReactionContext = {
751
621
  rest: feedbackRest,
752
- cfg,
753
- accountId
754
- });
755
- const discordAdapter = createDiscordAckReactionAdapter({
756
- channelId: messageChannelId,
757
- messageId: message.id,
758
- reactionContext: ackReactionContext
622
+ ...createDiscordRuntimeAccountContext({
623
+ cfg,
624
+ accountId
625
+ })
626
+ };
627
+ const createReactionAdapter = (channelId, messageId) => ({
628
+ setReaction: async (emoji) => {
629
+ await reactMessageDiscord(channelId, messageId, emoji, ackReactionContext);
630
+ },
631
+ removeReaction: async (emoji) => {
632
+ await removeReactionDiscord(channelId, messageId, emoji, ackReactionContext);
633
+ }
759
634
  });
635
+ const discordAdapter = createReactionAdapter(messageChannelId, message.id);
760
636
  let statusReactionTarget = `${messageChannelId}/${message.id}`;
761
637
  let statusReactionsActive = statusReactionsEnabled;
762
638
  const logReactionFailure = (target, error) => logAckFailure({
@@ -803,11 +679,7 @@ function createDiscordMessageReactionRuntime(params) {
803
679
  }
804
680
  statusReactionTarget = `${trackedChannelId}/${trackedMessageId}`;
805
681
  if (statusReactionsActive) statusReactions.clear();
806
- statusReactions = createController(true, createDiscordAckReactionAdapter({
807
- channelId: trackedChannelId,
808
- messageId: trackedMessageId,
809
- reactionContext: ackReactionContext
810
- }), emoji);
682
+ statusReactions = createController(true, createReactionAdapter(trackedChannelId, trackedMessageId), emoji);
811
683
  statusReactionsActive = true;
812
684
  statusReactions.setQueued();
813
685
  };
@@ -815,13 +687,12 @@ function createDiscordMessageReactionRuntime(params) {
815
687
  const queueInitialAckReactionAfterRecord = () => {
816
688
  if (initialAckReactionQueued) return;
817
689
  initialAckReactionQueued = true;
818
- queueInitialDiscordAckReaction({
819
- enabled: statusReactionsEnabled,
820
- shouldSendAckReaction,
821
- ackReaction,
822
- statusReactions,
823
- reactionAdapter: discordAdapter,
824
- target: `${messageChannelId}/${message.id}`
690
+ if (statusReactionsEnabled) {
691
+ statusReactions.setQueued();
692
+ return;
693
+ }
694
+ if (shouldSendAckReaction && ackReaction) discordAdapter.setReaction(ackReaction).catch((err) => {
695
+ logReactionFailure(`${messageChannelId}/${message.id}`, err);
825
696
  });
826
697
  };
827
698
  const finish = async (result) => {
@@ -857,6 +728,7 @@ function createDiscordDraftStream(params) {
857
728
  const minInitialChars = params.minInitialChars;
858
729
  let channelId = params.channelId;
859
730
  const rest = params.rest;
731
+ const retryDelete = createDiscordRetryRunner({});
860
732
  const flags = resolveDiscordMessageFlags({ suppressEmbeds: params.suppressEmbeds });
861
733
  const streamState = {
862
734
  stopped: false,
@@ -931,7 +803,7 @@ function createDiscordDraftStream(params) {
931
803
  loop.resetThrottleWindow();
932
804
  },
933
805
  isValidMessageId: (value) => value !== void 0,
934
- deleteMessage: (message) => deleteChannelMessage(rest, message.channelId, message.messageId),
806
+ deleteMessage: (message) => retryDelete(() => deleteChannelMessage(rest, message.channelId, message.messageId)),
935
807
  warn: params.warn,
936
808
  warnPrefix: "discord stream preview cleanup failed"
937
809
  });
@@ -984,76 +856,11 @@ function createDiscordDraftStream(params) {
984
856
  };
985
857
  }
986
858
  //#endregion
987
- //#region extensions/discord/src/preview-streaming.ts
988
- function resolveDiscordPreviewStreamMode(params = {}) {
989
- return resolveChannelPreviewStreamMode(params, "progress");
990
- }
991
- //#endregion
992
- //#region extensions/discord/src/monitor/message-handler.progress-continuation.ts
993
- /** The registry owns task settlement; Discord keeps the confirmed transport and its cleanup. */
994
- function retainDiscordProgressDraft(params) {
995
- let retired = false;
996
- const assertChannelCurrent = () => {
997
- params.assertChannelAuthority?.();
998
- if (params.isPolicyCurrent?.() === false) throw new Error("Discord channel policy is no longer current");
999
- };
1000
- const assertCurrent = () => {
1001
- assertChannelCurrent();
1002
- if (retired) throw new Error("Discord retained progress authority is no longer current");
1003
- };
1004
- const compositor = createChannelProgressDraftCompositor({
1005
- preparedItems: true,
1006
- showWorkStatus: true,
1007
- entry: params.entry,
1008
- mode: "progress",
1009
- active: true,
1010
- seed: params.seed,
1011
- reasoningGate: false,
1012
- toolIcons: true,
1013
- initialSnapshot: params.snapshot,
1014
- update: async (text, options) => {
1015
- if (retired) return false;
1016
- params.stream.update(text, {
1017
- complete: true,
1018
- assertCurrent
1019
- });
1020
- if (options.flush) await params.stream.flush();
1021
- return params.stream.lastDeliveredText() === text;
1022
- }
1023
- });
1024
- let queue = Promise.resolve();
1025
- const enqueue = (work) => {
1026
- queue = params.runInChannelScope(() => queue.then(work).catch((error) => {
1027
- params.log("discord: retained progress failed (" + String(error) + ")");
1028
- }));
1029
- };
1030
- let started = false;
1031
- return {
1032
- push: (item) => enqueue(async () => {
1033
- if (retired) return;
1034
- if (!started) {
1035
- started = true;
1036
- await compositor.start();
1037
- }
1038
- await compositor.pushItemEvent(item);
1039
- }),
1040
- retire: () => {
1041
- if (retired) return;
1042
- retired = true;
1043
- compositor.markFinalReplyStarted();
1044
- enqueue(() => withDiscordRequestAuthority(assertChannelCurrent, async () => {
1045
- await params.stream.clear();
1046
- await params.stream.cleanupPendingMessages();
1047
- }));
1048
- }
1049
- };
1050
- }
1051
- //#endregion
1052
859
  //#region extensions/discord/src/monitor/message-handler.draft-preview.ts
1053
860
  function createDiscordDraftPreviewController(params) {
1054
861
  const runInChannelScope = AsyncLocalStorage.snapshot();
1055
862
  const assertChannelAuthority = captureDiscordRequestAuthority();
1056
- const discordStreamMode = resolveDiscordPreviewStreamMode(params.discordConfig);
863
+ const discordStreamMode = resolveChannelPreviewStreamMode(params.discordConfig, "progress");
1057
864
  const hookRunner = getGlobalHookRunner();
1058
865
  const allowProviderPreview = !params.groupThread && !params.isRoomEvent && !((hookRunner?.hasHooks("reply_payload_sending") ?? false) || (hookRunner?.hasHooks("message_sending") ?? false));
1059
866
  const draftMaxChars = Math.min(params.textLimit, 2e3);
@@ -1088,7 +895,6 @@ function createDiscordDraftPreviewController(params) {
1088
895
  const progressSeed = `${params.accountId}:${params.deliverChannelId}`;
1089
896
  const progressDraft = createChannelProgressDraftCompositor({
1090
897
  preparedItems: true,
1091
- showWorkStatus: true,
1092
898
  entry: params.discordConfig,
1093
899
  mode: discordStreamMode,
1094
900
  active: Boolean(draftStream),
@@ -1147,13 +953,9 @@ function createDiscordDraftPreviewController(params) {
1147
953
  } : void 0,
1148
954
  retainOnError: true,
1149
955
  cleanupUndelivered: true,
1150
- onFinalStarted: () => {
1151
- freezeProgress();
1152
- params.onFinalReplyStart?.();
1153
- },
956
+ onFinalStarted: freezeProgress,
1154
957
  onFinalDelivered: () => {
1155
958
  progressDraft.markFinalReplyDelivered();
1156
- params.onFinalReplyDelivered?.();
1157
959
  },
1158
960
  onCleanupFailure: (err) => params.log(`discord: draft cleanup failed: ${String(err)}`)
1159
961
  });
@@ -1221,16 +1023,63 @@ function createDiscordDraftPreviewController(params) {
1221
1023
  });
1222
1024
  if (!stream.messageId() || stream.isStopped() || stream.lastDeliveredText() !== text || draftStream !== stream) return false;
1223
1025
  assertCurrent();
1224
- if (!adopt(retainDiscordProgressDraft({
1225
- stream,
1226
- snapshot,
1227
- entry: params.discordConfig,
1026
+ const retainedEntry = params.discordConfig;
1027
+ const retainedLog = params.log;
1028
+ const retainedIsPolicyCurrent = params.isPolicyCurrent;
1029
+ let retired = false;
1030
+ const assertChannelCurrent = () => {
1031
+ assertChannelAuthority?.();
1032
+ if (retainedIsPolicyCurrent?.() === false) throw new Error("Discord channel policy is no longer current");
1033
+ };
1034
+ const assertRetainedCurrent = () => {
1035
+ assertChannelCurrent();
1036
+ if (retired) throw new Error("Discord retained progress authority is no longer current");
1037
+ };
1038
+ const retainedCompositor = createChannelProgressDraftCompositor({
1039
+ preparedItems: true,
1040
+ entry: retainedEntry,
1041
+ mode: "progress",
1042
+ active: true,
1228
1043
  seed: progressSeed,
1229
- log: params.log,
1230
- runInChannelScope,
1231
- assertChannelAuthority,
1232
- isPolicyCurrent: params.isPolicyCurrent
1233
- }))) return false;
1044
+ reasoningGate: false,
1045
+ toolIcons: true,
1046
+ initialSnapshot: snapshot,
1047
+ update: async (retainedText, options) => {
1048
+ if (retired) return false;
1049
+ stream.update(retainedText, {
1050
+ complete: true,
1051
+ assertCurrent: assertRetainedCurrent
1052
+ });
1053
+ if (options.flush) await stream.flush();
1054
+ return stream.lastDeliveredText() === retainedText;
1055
+ }
1056
+ });
1057
+ let queue = Promise.resolve();
1058
+ const enqueue = (work) => {
1059
+ queue = runInChannelScope(() => queue.then(work).catch((error) => {
1060
+ retainedLog("discord: retained progress failed (" + String(error) + ")");
1061
+ }));
1062
+ };
1063
+ let started = false;
1064
+ if (!adopt({
1065
+ push: (item) => enqueue(async () => {
1066
+ if (retired) return;
1067
+ if (!started) {
1068
+ started = true;
1069
+ await retainedCompositor.start();
1070
+ }
1071
+ await retainedCompositor.pushItemEvent(item);
1072
+ }),
1073
+ retire: () => {
1074
+ if (retired) return;
1075
+ retired = true;
1076
+ retainedCompositor.markFinalReplyStarted();
1077
+ enqueue(() => withDiscordRequestAuthority(assertChannelCurrent, async () => {
1078
+ await stream.clear();
1079
+ await stream.cleanupPendingMessages();
1080
+ }));
1081
+ }
1082
+ })) return false;
1234
1083
  lifecycle.retainPreview();
1235
1084
  draftStream = void 0;
1236
1085
  resetProgressState();
@@ -1322,28 +1171,6 @@ function shouldStartDiscordProgressDraftNow(line) {
1322
1171
  return typeof line === "object" && line?.kind === "patch" && Boolean(line.detail);
1323
1172
  }
1324
1173
  //#endregion
1325
- //#region extensions/discord/src/monitor/reply-typing-feedback.ts
1326
- const DISCORD_REPLY_TYPING_MAX_DURATION_MS = 12e5;
1327
- function createDiscordReplyTypingFeedback(params) {
1328
- const rest = params.rest ?? createDiscordRestClient(params).rest;
1329
- return createTypingCallbacks({
1330
- start: () => sendTyping({
1331
- rest,
1332
- channelId: params.channelId
1333
- }),
1334
- onStartError: (err) => {
1335
- logTypingFailure({
1336
- log: params.log,
1337
- channel: "discord",
1338
- target: params.channelId,
1339
- error: err
1340
- });
1341
- },
1342
- keepaliveIntervalMs: params.keepaliveIntervalMs,
1343
- maxDurationMs: params.maxDurationMs ?? DISCORD_REPLY_TYPING_MAX_DURATION_MS
1344
- });
1345
- }
1346
- //#endregion
1347
1174
  //#region extensions/discord/src/monitor/message-handler.process-reply-runtime.ts
1348
1175
  function formatDiscordGroupThreadReply(text, participant) {
1349
1176
  return `**${participant.name.replace(/[\\`*_{}[\]()<>#!|]/g, "\\$&").replace(/\s+/g, " ")}**\n${text}`;
@@ -1373,18 +1200,25 @@ function createDiscordBeforePayloadDelivery(params) {
1373
1200
  }
1374
1201
  function createDiscordMessageReplyRuntime(params) {
1375
1202
  const { ctx, processContext } = params;
1376
- const { cfg, discordConfig, accountId, token, guildHistories, historyLimit, textLimit, messageChannelId, isDirectMessage, route } = ctx;
1203
+ const { cfg, discordConfig, accountId, guildHistories, historyLimit, textLimit, messageChannelId, isDirectMessage, route } = ctx;
1377
1204
  const { ctxPayload, replyPlan } = processContext;
1378
1205
  const deliverChannelId = replyPlan.deliverTarget.startsWith("channel:") ? replyPlan.deliverTarget.slice(8) : messageChannelId;
1379
1206
  let typingFeedback;
1380
- const getTypingFeedback = () => typingFeedback ??= createDiscordReplyTypingFeedback({
1381
- cfg,
1382
- token,
1383
- accountId,
1384
- channelId: deliverChannelId,
1385
- rest: params.feedbackRest,
1386
- log: logVerbose,
1387
- keepaliveIntervalMs: params.shouldDisableCoreTypingKeepalive ? void 0 : 0
1207
+ const getTypingFeedback = () => typingFeedback ??= createTypingCallbacks({
1208
+ start: () => sendTyping({
1209
+ rest: params.feedbackRest,
1210
+ channelId: deliverChannelId
1211
+ }),
1212
+ onStartError: (error) => {
1213
+ logTypingFailure({
1214
+ log: logVerbose,
1215
+ channel: "discord",
1216
+ target: deliverChannelId,
1217
+ error
1218
+ });
1219
+ },
1220
+ keepaliveIntervalMs: params.shouldDisableCoreTypingKeepalive ? void 0 : 0,
1221
+ maxDurationMs: 12e5
1388
1222
  });
1389
1223
  const { onModelSelected, ...replyPipeline } = createChannelMessageReplyPipeline({
1390
1224
  cfg,
@@ -1467,57 +1301,19 @@ function createDiscordMessageReplyRuntime(params) {
1467
1301
  deliveryRest: params.deliveryRest,
1468
1302
  deliverChannelId,
1469
1303
  replyReference: params.replyReference,
1470
- onFinalReplyStart: params.onFinalReplyStart,
1471
- onFinalReplyDelivered: params.onFinalReplyDelivered,
1472
1304
  log: logVerbose
1473
1305
  }),
1474
1306
  resolvedBlockStreamingEnabled: resolveChannelStreamingBlockEnabled(discordConfig)
1475
1307
  };
1476
1308
  }
1477
1309
  //#endregion
1478
- //#region extensions/discord/src/monitor/message-handler.process-thread-route.ts
1479
- function createDiscordMessageActiveThreadRoute(params) {
1480
- let adoptedThreadId;
1481
- let threadReplyDelivered = false;
1482
- let onThreadAdopted;
1483
- return {
1484
- replyReference: {
1485
- peek: () => adoptedThreadId ? void 0 : params.sourceReplyReference.peek(),
1486
- use: () => adoptedThreadId ? void 0 : params.sourceReplyReference.use(),
1487
- markSent: () => params.sourceReplyReference.markSent(),
1488
- hasReplied: () => Boolean(adoptedThreadId) || params.sourceReplyReference.hasReplied()
1489
- },
1490
- bindThreadAdoption(callback) {
1491
- onThreadAdopted = callback;
1492
- },
1493
- get threadReplyDelivered() {
1494
- return threadReplyDelivered;
1495
- },
1496
- end: beginDiscordActiveTurnThreadRoute(params.sessionKey, {
1497
- accountId: params.accountId,
1498
- sourceChannelId: params.sourceChannelId,
1499
- sourceMessageId: params.sourceMessageId,
1500
- onThreadAdopted: async (threadId) => {
1501
- adoptedThreadId = threadId;
1502
- await onThreadAdopted?.(threadId);
1503
- },
1504
- onThreadReplyDelivered: () => {
1505
- threadReplyDelivered = true;
1506
- },
1507
- onThreadAdoptionError: (error) => {
1508
- params.log(`discord: failed to move active progress into adopted thread (${String(error)})`);
1509
- }
1510
- })
1511
- };
1512
- }
1513
- //#endregion
1514
1310
  //#region extensions/discord/src/monitor/message-handler.process.ts
1515
1311
  const TARGETED_ONLY_ALLOWED_MENTIONS = { parse: [AllowedMentionsTypes.User, AllowedMentionsTypes.Role] };
1516
1312
  function isFallbackOnlyToolWarningFinal(payload) {
1517
1313
  if (payload.isError !== true || !isReplyPayloadNonTerminalToolErrorWarning(payload)) return false;
1518
1314
  return !resolveSendableOutboundReplyParts(payload).hasMedia;
1519
1315
  }
1520
- async function processDiscordMessage(ctx, observer) {
1316
+ async function processDiscordMessage(ctx) {
1521
1317
  const dispatchStartedAt = Date.now();
1522
1318
  const { cfg, accountId, token, runtime, textLimit, replyToMode, message, messageChannelId, isGuildMessage, isDirectMessage, isGroupDm, messageText: text, threadBindings, route, abortSignal, isPolicyCurrent, turnAdoptionLifecycle, preparedMedia: mediaList } = ctx;
1523
1319
  if (abortSignal?.aborted || isPolicyCurrent?.() === false) return;
@@ -1542,7 +1338,7 @@ async function processDiscordMessage(ctx, observer) {
1542
1338
  }
1543
1339
  });
1544
1340
  const sourceRepliesAreToolOnly = sourceReplyDeliveryMode === "message_tool_only";
1545
- const configuredTypingMode = resolveAgentConfig$1(cfg, route.agentId)?.typingMode ?? cfg.agents?.defaults?.typingMode;
1341
+ const configuredTypingMode = resolveAgentConfig(cfg, route.agentId)?.typingMode ?? cfg.agents?.defaults?.typingMode;
1546
1342
  const configuredTypingInterval = cfg.agents?.defaults?.typingIntervalSeconds;
1547
1343
  const shouldDisableCoreTypingKeepalive = sourceRepliesAreToolOnly && configuredTypingMode === void 0 && configuredTypingInterval === void 0;
1548
1344
  const mediaLocalRoots = getAgentScopedMediaLocalRoots(cfg, route.agentId);
@@ -1560,19 +1356,31 @@ async function processDiscordMessage(ctx, observer) {
1560
1356
  if (!processContext) return;
1561
1357
  const { ctxPayload, persistedSessionKey, record, replyPlan } = processContext;
1562
1358
  let deliverTarget = replyPlan.deliverTarget;
1563
- const activeThreadRoute = createDiscordMessageActiveThreadRoute({
1564
- sessionKey: ctxPayload.SessionKey,
1359
+ const sourceMessageId = ctx.canonicalMessageId ?? message.id;
1360
+ const sourceReplyReference = replyPlan.replyReference;
1361
+ let adoptedThreadId;
1362
+ let threadReplyDelivered = false;
1363
+ let onThreadAdopted = void 0;
1364
+ const endActiveThreadRoute = beginDiscordActiveTurnThreadRoute(ctxPayload.SessionKey, {
1565
1365
  accountId,
1566
1366
  sourceChannelId: messageChannelId,
1567
- sourceMessageId: ctx.canonicalMessageId ?? message.id,
1568
- sourceReplyReference: replyPlan.replyReference,
1569
- log: logVerbose
1570
- });
1571
- const replyReference = activeThreadRoute.replyReference;
1572
- observer?.onReplyPlanResolved?.({
1573
- createdThreadId: replyPlan.createdThreadId,
1574
- sessionKey: persistedSessionKey
1367
+ sourceMessageId,
1368
+ onThreadAdopted: async (threadId) => {
1369
+ adoptedThreadId = threadId;
1370
+ await onThreadAdopted?.(threadId);
1371
+ },
1372
+ onThreadReplyDelivered: () => {
1373
+ threadReplyDelivered = true;
1374
+ },
1375
+ onThreadAdoptionError: (error) => {
1376
+ logVerbose(`discord: failed to move active progress into adopted thread (${String(error)})`);
1377
+ }
1575
1378
  });
1379
+ const replyReference = {
1380
+ peek: () => adoptedThreadId ? void 0 : sourceReplyReference.peek(),
1381
+ use: () => adoptedThreadId ? void 0 : sourceReplyReference.use(),
1382
+ markSent: () => sourceReplyReference.markSent()
1383
+ };
1576
1384
  const { replyPipeline, onModelSelected, tableMode, maxLinesPerMessage, chunkMode, beginQueuedDeliveryCorrelation, endDeliveryCorrelation, resolveCurrentTurnTranscriptFinalText, draftPreview, resolvedBlockStreamingEnabled } = createDiscordMessageReplyRuntime({
1577
1385
  ctx,
1578
1386
  processContext,
@@ -1582,36 +1390,116 @@ async function processDiscordMessage(ctx, observer) {
1582
1390
  isRoomEvent,
1583
1391
  dispatchStartedAt,
1584
1392
  feedbackRest: reactions.feedbackRest,
1585
- deliveryRest: reactions.deliveryRest,
1586
- onFinalReplyStart: observer?.onFinalReplyStart,
1587
- onFinalReplyDelivered: observer?.onFinalReplyDelivered
1393
+ deliveryRest: reactions.deliveryRest
1588
1394
  });
1589
- activeThreadRoute.bindThreadAdoption(async (threadId) => {
1395
+ onThreadAdopted = async (threadId) => {
1590
1396
  deliverTarget = `channel:${threadId}`;
1591
1397
  await draftPreview.retarget(threadId);
1592
- });
1398
+ };
1593
1399
  const { lifecycle } = draftPreview;
1594
1400
  const hasCompletedFinalReply = () => lifecycle.finalSucceeded || lifecycle.previewFinalized;
1595
1401
  const observeFinalDelivery = async () => {
1596
1402
  if (lifecycle.finalSucceeded) return;
1597
1403
  draftPreview.freezeProgress();
1598
- const retainedProgress = activeThreadRoute.threadReplyDelivered && !lifecycle.previewFinalized ? draftPreview.finalizeProgressDraft().catch((error) => {
1404
+ const retainedProgress = threadReplyDelivered && !lifecycle.previewFinalized ? draftPreview.finalizeProgressDraft().catch((error) => {
1599
1405
  logVerbose(`discord: failed to finalize adopted thread progress (${String(error)})`);
1600
1406
  }) : void 0;
1601
1407
  await lifecycle.observeDelivery({ visibleReplySent: true });
1602
1408
  await retainedProgress;
1603
1409
  };
1604
1410
  let pendingToolWarningFinal;
1605
- const progress = await createDiscordMessageProgressRuntime({
1606
- ctx,
1607
- sessionKey: ctxPayload.SessionKey,
1608
- sourceRepliesAreToolOnly,
1609
- draftPreview,
1610
- reactions,
1611
- onTurnReset: () => {
1612
- pendingToolWarningFinal = void 0;
1411
+ const progressSessionKey = ctxPayload.SessionKey;
1412
+ const reasoningLevel = await (async () => {
1413
+ const cfgDefault = resolveAgentConfig(cfg, route.agentId ?? "main")?.reasoningDefault ?? cfg.agents?.defaults?.reasoningDefault;
1414
+ const configDefault = cfgDefault === "on" || cfgDefault === "stream" ? cfgDefault : "off";
1415
+ if (!progressSessionKey) return configDefault;
1416
+ try {
1417
+ const storePath = resolveStorePath(cfg.session?.store, { agentId: route.agentId });
1418
+ const level = (await getSessionEntryAsync({
1419
+ agentId: route.agentId,
1420
+ sessionKey: progressSessionKey,
1421
+ storePath
1422
+ }))?.reasoningLevel;
1423
+ if (level === "on" || level === "stream" || level === "off") return level;
1424
+ } catch {
1425
+ return "off";
1613
1426
  }
1614
- });
1427
+ return configDefault;
1428
+ })();
1429
+ const reasoningDurableEnabled = reasoningLevel === "on";
1430
+ const reasoningWindowEnabled = reasoningLevel === "stream";
1431
+ let shouldYieldDraftCommentary = async () => false;
1432
+ let turnCommentaryVisible = false;
1433
+ const progressReplyOptions = {
1434
+ progressRequiresReply: draftPreview.isProgressMode ? true : void 0,
1435
+ onAssistantMessageStart: draftPreview.draftStream ? () => {
1436
+ if (draftPreview.handleAssistantMessageBoundary()) pendingToolWarningFinal = void 0;
1437
+ return false;
1438
+ } : void 0,
1439
+ onReasoningEnd: draftPreview.draftStream ? () => {
1440
+ draftPreview.resetReasoningProgress();
1441
+ return false;
1442
+ } : void 0,
1443
+ onQueuedFollowupAdmitted: draftPreview.draftStream ? () => {
1444
+ if (draftPreview.handleQueuedFollowupAdmitted()) pendingToolWarningFinal = void 0;
1445
+ } : void 0,
1446
+ onQueuedFollowupSettled: draftPreview.draftStream ? () => draftPreview.cleanup() : void 0,
1447
+ suppressDefaultToolProgressMessages: sourceRepliesAreToolOnly && reactions.statusReactionsExplicitlyEnabled || draftPreview.suppressDefaultToolProgressMessages ? true : void 0,
1448
+ allowToolLifecycleWhenProgressHidden: reactions.statusReactionsEnabled ? true : void 0,
1449
+ commentaryProgressEnabled: draftPreview.isProgressMode ? draftPreview.commentaryProgressEnabled : void 0,
1450
+ progressPreambleEnabled: draftPreview.draftStream && draftPreview.isProgressMode ? true : void 0,
1451
+ commentaryPayloadsEnabled: draftPreview.isProgressMode ? draftPreview.commentaryProgressEnabled : void 0,
1452
+ shouldDeliverCommentaryPayloads: draftPreview.isProgressMode && draftPreview.commentaryProgressEnabled ? () => turnCommentaryVisible : void 0,
1453
+ reasoningPayloadsEnabled: reasoningDurableEnabled,
1454
+ onVerboseProgressVisibilityAsync: async (isActive) => {
1455
+ shouldYieldDraftCommentary = isActive;
1456
+ turnCommentaryVisible = await isActive();
1457
+ },
1458
+ onNarrationUpdate: draftPreview.narrationProgressEnabled ? async (payload) => {
1459
+ if (await shouldYieldDraftCommentary() || abortSignal?.aborted) return;
1460
+ await draftPreview.pushNarrationProgress(payload.text);
1461
+ } : void 0,
1462
+ onProgressNarratorLifecycle: draftPreview.narrationProgressEnabled ? (progressLifecycle) => draftPreview.setProgressNarratorLifecycle(progressLifecycle) : void 0,
1463
+ isProgressDraftVisible: draftPreview.narrationProgressEnabled ? () => draftPreview.isProgressDraftVisible : void 0,
1464
+ narrationHideCommandText: draftPreview.narrationHideCommandText ? true : void 0,
1465
+ onReasoningStream: async (payload) => {
1466
+ if (payload?.requiresReasoningProgressOptIn === true && !reasoningWindowEnabled) return false;
1467
+ await reactions.controller.setThinking();
1468
+ return await draftPreview.pushReasoningProgress(payload?.text, { snapshot: payload?.isReasoningSnapshot === true });
1469
+ },
1470
+ streamReasoningInNonStreamModes: reasoningWindowEnabled,
1471
+ onToolStart: async (payload) => {
1472
+ if (abortSignal?.aborted) return false;
1473
+ await reactions.maybeBindToToolReaction(payload);
1474
+ await reactions.controller.setTool(payload.name);
1475
+ return await draftPreview.pushToolEvent(payload);
1476
+ },
1477
+ onItemEvent: async (payload) => {
1478
+ if (abortSignal?.aborted || payload.kind === "preamble" && await shouldYieldDraftCommentary()) return;
1479
+ return await draftPreview.pushItemEvent(payload);
1480
+ },
1481
+ onPlanUpdate: async (payload) => {
1482
+ if (payload.phase === "update") return await draftPreview.pushPlanProgress(payload.steps, {
1483
+ explanation: payload.explanation,
1484
+ explanationFormat: payload.explanationFormat
1485
+ });
1486
+ return false;
1487
+ },
1488
+ onApprovalEvent: async (payload) => {
1489
+ return await draftPreview.pushApprovalEvent(payload);
1490
+ },
1491
+ onCompactionStart: async () => {
1492
+ if (!abortSignal?.aborted) await reactions.controller.setCompacting();
1493
+ return false;
1494
+ },
1495
+ onCompactionEnd: async () => {
1496
+ if (!abortSignal?.aborted) {
1497
+ reactions.controller.cancelPending();
1498
+ await reactions.controller.setThinking();
1499
+ }
1500
+ return false;
1501
+ }
1502
+ };
1615
1503
  let replyLifecycleStarted = false;
1616
1504
  const onDiscordReplyStart = async () => {
1617
1505
  if (abortSignal?.aborted) return;
@@ -1831,7 +1719,7 @@ async function processDiscordMessage(ctx, observer) {
1831
1719
  allowProgressCallbacksWhenSourceDeliverySuppressed: sourceRepliesAreToolOnly && draftPreview.draftStream && draftPreview.isProgressMode ? true : void 0,
1832
1720
  disableBlockStreaming: sourceRepliesAreToolOnly ? true : draftPreview.disableBlockStreamingForDraft ?? (typeof resolvedBlockStreamingEnabled === "boolean" ? !resolvedBlockStreamingEnabled : void 0),
1833
1721
  onPartialReply: draftPreview.draftStream && !draftPreview.isProgressMode ? (payload) => draftPreview.updateFromPartial(payload.text) : void 0,
1834
- ...progress.replyOptions,
1722
+ ...progressReplyOptions,
1835
1723
  onObservedReplyDelivery: observeFinalDelivery,
1836
1724
  onModelSelected
1837
1725
  }
@@ -1842,7 +1730,7 @@ async function processDiscordMessage(ctx, observer) {
1842
1730
  dispatchAborted = true;
1843
1731
  return;
1844
1732
  }
1845
- if (activeThreadRoute.threadReplyDelivered) await observeFinalDelivery();
1733
+ if (threadReplyDelivered) await observeFinalDelivery();
1846
1734
  } catch (err) {
1847
1735
  if (abortSignal?.aborted) {
1848
1736
  dispatchAborted = true;
@@ -1860,7 +1748,7 @@ async function processDiscordMessage(ctx, observer) {
1860
1748
  }
1861
1749
  throw err;
1862
1750
  } finally {
1863
- activeThreadRoute.end();
1751
+ endActiveThreadRoute();
1864
1752
  endDeliveryCorrelation();
1865
1753
  dispatchError ||= readAgentRunTerminalOutcome(dispatchResult) === "failed";
1866
1754
  const finalReceipt = dispatchResult?.settledReceipt?.counts.final;
@@ -1872,11 +1760,6 @@ async function processDiscordMessage(ctx, observer) {
1872
1760
  finalDeliveryFailed
1873
1761
  });
1874
1762
  }
1875
- if (!dispatchResult || !hasFinalInboundReplyDispatch(dispatchResult)) return;
1876
- if (shouldLogVerbose()) {
1877
- const finalCount = dispatchResult.settledReceipt?.counts.final.delivered ?? 0;
1878
- logVerbose(`discord: delivered ${finalCount} reply${finalCount === 1 ? "" : "ies"} to ${replyPlan.replyTarget}`);
1879
- }
1880
1763
  }
1881
1764
  //#endregion
1882
1765
  export { processDiscordMessage };