@openclaw/discord 2026.10.10 → 2026.11.5-beta.1

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 (217) hide show
  1. package/dist/.setup/{account-inspect-X_Xlr42B.mjs → account-inspect-CSz5Qodj.mjs} +1 -1
  2. package/dist/.setup/{accounts-C18HNgge.mjs → accounts-DtjvhJUj.mjs} +9 -6
  3. package/dist/.setup/{active-turn-thread-route-BAc_Xik-.mjs → active-turn-thread-route-DkPnk2x8.mjs} +1 -2
  4. package/dist/.setup/{allow-list-D1ZGfhXh.mjs → allow-list-DahA0Jxh.mjs} +3 -150
  5. package/dist/.setup/{api-Bth1wKF9.mjs → api-Bp0HI4q3.mjs} +10 -20
  6. package/dist/.setup/{approval-handler.runtime-BAoEELJJ.mjs → approval-handler.runtime-Cy53ugTf.mjs} +80 -61
  7. package/dist/.setup/{approval-message-updates-Cks-MSCJ.mjs → approval-message-updates-DqOXxPss.mjs} +2 -2
  8. package/dist/.setup/{audit-Dw_rAZIz.mjs → audit-DoPKOfQE.mjs} +4 -4
  9. package/dist/.setup/{channel-BMpMAeQL.mjs → channel-Ds6iuNdy.mjs} +134 -201
  10. package/dist/.setup/channel-access-DhJhVrdZ.mjs +23 -0
  11. package/dist/.setup/channel.setup-BLt9dkIG.mjs +235 -0
  12. package/dist/.setup/{components-BvOWSPxr.mjs → components-WTfUxead.mjs} +208 -426
  13. package/dist/.setup/components.base-C5sAPHe4.mjs +31 -0
  14. package/dist/.setup/{config-schema-Coyq5wOr.mjs → config-schema-GX2yDgIH.mjs} +6 -7
  15. package/dist/.setup/{conversation-binding-route-DOPUZNYo.mjs → conversation-binding-route-CZdm-X5A.mjs} +2 -2
  16. package/dist/.setup/{directory-config-CIqVnQtn.mjs → directory-config-BXJuh9-J.mjs} +1 -1
  17. package/dist/.setup/{directory-live-DUuPEWub.mjs → directory-live-CEopeb8Q.mjs} +55 -62
  18. package/dist/.setup/{discord-eFlHX1Gn.mjs → discord-r79VFjJp.mjs} +1087 -1664
  19. package/dist/.setup/{doctor-Dty_Ossy.mjs → doctor-UfLW8nye.mjs} +3 -5
  20. package/dist/.setup/endpoint-runtime-BM3x-m6O.mjs +138 -0
  21. package/dist/.setup/guilds-DQucP5Tn.mjs +21 -0
  22. package/dist/.setup/{handle-action-DXY91jF-.mjs → handle-action-BarHOi-v.mjs} +15 -15
  23. package/dist/.setup/{handle-action.guild-admin-BvBCfhXF.mjs → handle-action.guild-admin-oRUb8p_O.mjs} +5 -5
  24. package/dist/.setup/listeners-CHgTENFu.mjs +46 -0
  25. package/dist/.setup/{live-policy-config-DO1Fk2hp.mjs → live-policy-config-EKp4O6zx.mjs} +2 -3
  26. package/dist/.setup/{message-handler-fL1j1NiR.mjs → message-handler-DUeT8Asf.mjs} +154 -113
  27. package/dist/.setup/{message-handler.preflight-DkjwNZAd.mjs → message-handler.preflight-C6TNtKW0.mjs} +30 -104
  28. package/dist/.setup/{message-handler.preflight-pluralkit-DR4BnvMU.mjs → message-handler.preflight-pluralkit-6E9TFmmN.mjs} +9 -22
  29. package/dist/.setup/{message-handler.process-ClOwIPDK.mjs → message-handler.process-D8_oQ5Cp.mjs} +256 -367
  30. package/dist/.setup/outbound-payload-DUsrFICb.mjs +445 -0
  31. package/dist/.setup/{outbound-session-route-TFBPPkoz.mjs → outbound-session-route-Cb8cv4Oi.mjs} +138 -86
  32. package/dist/.setup/{preflight-audio-CwtPIsvk.mjs → preflight-audio-r4BbaJxh.mjs} +1 -5
  33. package/dist/.setup/{presence-cache-CgutE4NN.mjs → presence-cache-B3xj3b0l.mjs} +1 -6
  34. package/dist/.setup/{probe-DNge7OEP.mjs → probe-BUmJyH35.mjs} +5 -9
  35. package/dist/.setup/{provider-BBDuE14w.mjs → provider-Dm2ERSxe.mjs} +3600 -4454
  36. package/dist/.setup/{provider-session.runtime-D8hMXXqJ.mjs → provider-session.runtime-DCIqDsIg.mjs} +3 -3
  37. package/dist/.setup/provider.runtime-DmxPGoUg.mjs +1 -0
  38. package/dist/.setup/proxy-fetch-B8cK6FLQ.mjs +29 -0
  39. package/dist/.setup/{realtime-session.runtime-cetognkp.mjs → realtime-session.runtime-WJL6NdwK.mjs} +43 -81
  40. package/dist/.setup/{receive-recovery-C77CVdGM.mjs → receive-recovery-DV_v5ROf.mjs} +13 -27
  41. package/dist/.setup/{resolve-allowlist-common-CI77288n.mjs → resolve-allowlist-common-C37fgnYG.mjs} +3 -12
  42. package/dist/.setup/{resolve-channels-DYc6-xgV.mjs → resolve-channels-CwpnQ7C2.mjs} +5 -4
  43. package/dist/.setup/{resolve-users-BQT7XWF2.mjs → resolve-users-D6jSwe8R.mjs} +4 -7
  44. package/dist/.setup/{runtime-CcijhTJT.mjs → runtime-B-PgPsGR.mjs} +6 -6
  45. package/dist/.setup/{runtime-CI0UJqeS.mjs → runtime-DhOMlnYS.mjs} +196 -235
  46. package/dist/.setup/{secret-config-contract-BdbCvqnM.mjs → secret-config-contract-CP6teHec.mjs} +4 -9
  47. package/dist/.setup/{send-Cbq-IVsS.mjs → send-DnLL6XoO.mjs} +149 -174
  48. package/dist/.setup/{send.components-BV6ucNpJ.mjs → send.components-xB43CksK.mjs} +61 -71
  49. package/dist/.setup/{send.outbound-CGhBhzjQ.mjs → send.outbound-B11X6TOE.mjs} +75 -129
  50. package/dist/.setup/{send.receipt-Dw-_r5Bx.mjs → send.receipt-CMteCIZS.mjs} +29 -31
  51. package/dist/.setup/{send.shared-D4MioxW_.mjs → send.shared-BcLLZBul.mjs} +38 -112
  52. package/dist/.setup/{sender-identity-DrN5c4ec.mjs → sender-identity-CGNpdJmb.mjs} +3 -9
  53. package/dist/.setup/setup-plugin-api-C6AMx3hu.mjs +2 -0
  54. package/dist/.setup/{shared-Bp0sxD5R.mjs → shared-BEYw16he.mjs} +8 -10
  55. package/dist/.setup/shared-interactive-DKBw4SNV.mjs +311 -0
  56. package/dist/.setup/{subagent-hooks-mQbDkvuD.mjs → subagent-hooks-DlYElpXa.mjs} +1 -1
  57. package/dist/.setup/{system-events-2zc2eGfF.mjs → system-events--Pk6y9aP.mjs} +2 -2
  58. package/dist/.setup/{target-resolver-CAHeVfmZ.mjs → target-resolver-Bo9EpGp_.mjs} +3 -3
  59. package/dist/.setup/{thread-bindings-Dg7X_ZXP.mjs → thread-bindings-BF-hr-bg.mjs} +12 -20
  60. package/dist/.setup/{thread-bindings.manager-DCDYksah.mjs → thread-bindings.manager-CQCkha5r.mjs} +22 -42
  61. package/dist/.setup/{thread-bindings.session-updates-C76plLS3.mjs → thread-bindings.session-updates-C2gJAj_I.mjs} +11 -18
  62. package/dist/.setup/{threading-l0UfrE6x.mjs → threading-HA9C2wYR.mjs} +68 -104
  63. package/dist/.setup/{timeouts-DTrUsJ_W.mjs → timeouts-CT9hnmo4.mjs} +1 -1
  64. package/dist/.setup/{transcripts-source-CGgOaWcu.mjs → transcripts-source-DzpzETZR.mjs} +102 -172
  65. package/dist/.setup/{voice-runtime-DY1EwDfi.mjs → voice-runtime-Bo_nsVvX.mjs} +231 -448
  66. package/dist/.source-module-urls/d6c089460280c5a04184542d6712e04545caeb1ebb290d3504377b4cc5e22fea.json +1 -1
  67. package/dist/account-inspect-api.js +1 -1
  68. package/dist/action-runtime-api.js +1 -1
  69. package/dist/activities-api.js +285 -337
  70. package/dist/api.js +16 -16
  71. package/dist/assets/embedded-app-sdk.mjs +1 -1
  72. package/dist/channel-config-api.js +1 -1
  73. package/dist/channel-plugin-api.js +1 -1
  74. package/dist/directory-contract-api.js +1 -1
  75. package/dist/runtime-api.js +22 -22
  76. package/dist/secret-contract-api.js +1 -1
  77. package/dist/setup-entry.js +1 -1
  78. package/dist/setup-plugin-api.js +1 -1
  79. package/dist/src/voice/audio-worker.runtime.js +56 -68
  80. package/dist/subagent-hooks-api.js +1 -1
  81. package/dist/transcripts-source-api.js +1 -1
  82. package/node_modules/@discord/embedded-app-sdk/output/lib/zod/lib/index.cjs +2 -3
  83. package/node_modules/@discord/embedded-app-sdk/output/lib/zod/lib/index.mjs +2 -3
  84. package/node_modules/@napi-rs/wasm-runtime/dist/fs.js +3339 -4021
  85. package/node_modules/@napi-rs/wasm-runtime/package.json +1 -1
  86. package/node_modules/@types/lodash/README.md +1 -1
  87. package/node_modules/@types/lodash/common/function.d.ts +2 -2
  88. package/node_modules/@types/lodash/package.json +2 -2
  89. package/node_modules/@types/node/README.md +1 -1
  90. package/node_modules/@types/node/package.json +2 -2
  91. package/node_modules/@types/node/util.d.ts +6 -3
  92. package/node_modules/discord-api-types/package.json +4 -4
  93. package/node_modules/discord-api-types/rest/v10/index.d.ts +8 -0
  94. package/node_modules/discord-api-types/rest/v10/index.d.ts.map +1 -1
  95. package/node_modules/discord-api-types/rest/v10/index.js +8 -0
  96. package/node_modules/discord-api-types/rest/v10/index.js.map +1 -1
  97. package/node_modules/discord-api-types/rest/v10/oauth2.d.ts +26 -2
  98. package/node_modules/discord-api-types/rest/v10/oauth2.d.ts.map +1 -1
  99. package/node_modules/discord-api-types/rest/v9/index.d.ts +8 -0
  100. package/node_modules/discord-api-types/rest/v9/index.d.ts.map +1 -1
  101. package/node_modules/discord-api-types/rest/v9/index.js +8 -0
  102. package/node_modules/discord-api-types/rest/v9/index.js.map +1 -1
  103. package/node_modules/discord-api-types/rest/v9/oauth2.d.ts +26 -2
  104. package/node_modules/discord-api-types/rest/v9/oauth2.d.ts.map +1 -1
  105. package/node_modules/typebox/build/format/duration.d.mts +2 -2
  106. package/node_modules/typebox/build/format/duration.mjs +2 -2
  107. package/node_modules/typebox/build/format/idn_email.d.mts +1 -0
  108. package/node_modules/typebox/build/format/idn_email.mjs +1 -0
  109. package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -1
  110. package/node_modules/typebox/build/format/idn_hostname.mjs +1 -1
  111. package/node_modules/typebox/build/format/ipv4.d.mts +2 -2
  112. package/node_modules/typebox/build/format/ipv4.mjs +2 -2
  113. package/node_modules/typebox/build/format/ipv6.d.mts +1 -1
  114. package/node_modules/typebox/build/format/ipv6.mjs +1 -1
  115. package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
  116. package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
  117. package/node_modules/typebox/build/schema/build.mjs +1 -0
  118. package/node_modules/typebox/build/schema/engine/_unique.d.mts +4 -2
  119. package/node_modules/typebox/build/schema/engine/_unique.mjs +7 -3
  120. package/node_modules/typebox/build/schema/engine/additionalItems.mjs +3 -3
  121. package/node_modules/typebox/build/schema/engine/additionalProperties.d.mts +0 -3
  122. package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +15 -17
  123. package/node_modules/typebox/build/schema/engine/contains.mjs +3 -3
  124. package/node_modules/typebox/build/schema/engine/index.d.mts +1 -0
  125. package/node_modules/typebox/build/schema/engine/index.mjs +1 -0
  126. package/node_modules/typebox/build/schema/engine/items.mjs +7 -4
  127. package/node_modules/typebox/build/schema/engine/maxContains.mjs +2 -2
  128. package/node_modules/typebox/build/schema/engine/minContains.mjs +3 -3
  129. package/node_modules/typebox/build/schema/engine/oneOf.mjs +2 -2
  130. package/node_modules/typebox/build/schema/engine/patternProperties.mjs +2 -2
  131. package/node_modules/typebox/build/schema/engine/propertyNames.mjs +2 -2
  132. package/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs +2 -2
  133. package/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs +2 -2
  134. package/node_modules/typebox/build/system/hashing/hash.mjs +63 -34
  135. package/node_modules/typebox/build/system/locale/en_US.mjs +2 -1
  136. package/node_modules/typebox/build/system/memory/assign.d.mts +2 -8
  137. package/node_modules/typebox/build/system/memory/assign.mjs +13 -6
  138. package/node_modules/typebox/build/system/memory/clone.d.mts +4 -5
  139. package/node_modules/typebox/build/system/memory/clone.mjs +8 -96
  140. package/node_modules/typebox/build/system/memory/create.d.mts +1 -5
  141. package/node_modules/typebox/build/system/memory/create.mjs +18 -13
  142. package/node_modules/typebox/build/system/memory/deep.d.mts +2 -0
  143. package/node_modules/typebox/build/system/memory/deep.mjs +108 -0
  144. package/node_modules/typebox/build/system/memory/discard.d.mts +1 -1
  145. package/node_modules/typebox/build/system/memory/discard.mjs +9 -8
  146. package/node_modules/typebox/build/system/memory/finalize.d.mts +4 -0
  147. package/node_modules/typebox/build/system/memory/finalize.mjs +30 -0
  148. package/node_modules/typebox/build/system/memory/keys.d.mts +2 -0
  149. package/node_modules/typebox/build/system/memory/keys.mjs +8 -0
  150. package/node_modules/typebox/build/system/memory/update.d.mts +1 -4
  151. package/node_modules/typebox/build/system/memory/update.mjs +43 -16
  152. package/node_modules/typebox/build/type/engine/call/index.d.mts +1 -0
  153. package/node_modules/typebox/build/type/engine/call/index.mjs +1 -0
  154. package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +2 -24
  155. package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +2 -29
  156. package/node_modules/typebox/build/type/engine/evaluate/index.d.mts +1 -0
  157. package/node_modules/typebox/build/type/engine/evaluate/index.mjs +1 -0
  158. package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +5 -1
  159. package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +6 -1
  160. package/node_modules/typebox/build/type/engine/evaluate/property.d.mts +30 -0
  161. package/node_modules/typebox/build/type/engine/evaluate/property.mjs +29 -0
  162. package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +1 -3
  163. package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +1 -4
  164. package/node_modules/typebox/build/type/engine/object/from_intersect.d.mts +2 -2
  165. package/node_modules/typebox/build/type/engine/object/from_intersect.mjs +2 -2
  166. package/node_modules/typebox/build/type/engine/object/from_union.d.mts +2 -2
  167. package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
  168. package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +1 -3
  169. package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +1 -4
  170. package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +1 -3
  171. package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +1 -4
  172. package/node_modules/typebox/build/type/engine/this/index.d.mts +1 -0
  173. package/node_modules/typebox/build/type/engine/this/index.mjs +1 -0
  174. package/node_modules/typebox/build/value/clone/clone.d.mts +4 -3
  175. package/node_modules/typebox/build/value/clone/clone.mjs +5 -7
  176. package/node_modules/typebox/build/value/repair/from_cyclic.d.mts +2 -0
  177. package/node_modules/typebox/build/value/repair/from_cyclic.mjs +6 -0
  178. package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +25 -14
  179. package/node_modules/typebox/package.json +1 -1
  180. package/node_modules/typebox/readme.md +1 -1
  181. package/node_modules/undici/docs/docs/api/Interceptors.md +15 -2
  182. package/node_modules/undici/lib/dispatcher/client-h2.js +78 -3
  183. package/node_modules/undici/lib/dispatcher/pool-base.js +20 -3
  184. package/node_modules/undici/package.json +3 -3
  185. package/node_modules/undici/types/api.d.ts +1 -1
  186. package/node_modules/undici/types/utility.d.ts +4 -4
  187. package/node_modules/uuid/package.json +17 -17
  188. package/node_modules/zod/package.json +1 -1
  189. package/node_modules/zod/src/v4/classic/tests/array.test.ts +27 -0
  190. package/node_modules/zod/src/v4/classic/tests/map.test.ts +7 -0
  191. package/node_modules/zod/src/v4/classic/tests/set.test.ts +6 -0
  192. package/node_modules/zod/src/v4/core/compile.ts +9 -0
  193. package/node_modules/zod/src/v4/core/schemas.ts +35 -1
  194. package/node_modules/zod/src/v4/core/util.ts +13 -0
  195. package/node_modules/zod/src/v4/core/versions.ts +1 -1
  196. package/node_modules/zod/v4/core/compile.cjs +8 -0
  197. package/node_modules/zod/v4/core/compile.js +8 -0
  198. package/node_modules/zod/v4/core/schemas.cjs +30 -0
  199. package/node_modules/zod/v4/core/schemas.d.cts +3 -1
  200. package/node_modules/zod/v4/core/schemas.d.ts +3 -1
  201. package/node_modules/zod/v4/core/schemas.js +30 -0
  202. package/node_modules/zod/v4/core/util.cjs +15 -0
  203. package/node_modules/zod/v4/core/util.d.cts +2 -0
  204. package/node_modules/zod/v4/core/util.d.ts +2 -0
  205. package/node_modules/zod/v4/core/util.js +14 -0
  206. package/node_modules/zod/v4/core/versions.cjs +1 -1
  207. package/node_modules/zod/v4/core/versions.js +1 -1
  208. package/openclaw.plugin.json +1 -31
  209. package/package.json +8 -8
  210. package/dist/.setup/channel-access-BPrWoEXM.mjs +0 -47
  211. package/dist/.setup/channel.setup-DVe7Y3Jf.mjs +0 -245
  212. package/dist/.setup/outbound-adapter-DWyAWBFh.mjs +0 -537
  213. package/dist/.setup/provider.runtime-BQ1z4Aq1.mjs +0 -1
  214. package/dist/.setup/setup-plugin-api-B4J6wmL1.mjs +0 -2
  215. package/dist/.setup/targets-BaklhOqq.mjs +0 -3
  216. package/node_modules/typebox/build/system/memory/freeze.d.mts +0 -4
  217. package/node_modules/typebox/build/system/memory/freeze.mjs +0 -6
@@ -1,43 +1,41 @@
1
- import { m as resolveDiscordMaxLinesPerMessage } from "./accounts-C18HNgge.mjs";
2
- import { i as normalizeDiscordAllowList, o as normalizeDiscordSlug, w as resolveTimestampMs } from "./allow-list-D1ZGfhXh.mjs";
3
- import { F as createDiscordRuntimeAccountContext, O as resolveDiscordMessageFlags, P as createDiscordRestClient, u as resolveDiscordTargetChannelId } from "./send.shared-D4MioxW_.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-eFlHX1Gn.mjs";
5
- import { v as chunkDiscordTextWithMode } from "./send.receipt-Dw-_r5Bx.mjs";
1
+ import { m as resolveDiscordMaxLinesPerMessage } from "./accounts-DtjvhJUj.mjs";
2
+ import { N as createDiscordRestClient, O as resolveDiscordMessageFlags, P as createDiscordRuntimeAccountContext, u as resolveDiscordTargetChannelId } from "./send.shared-BcLLZBul.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-r79VFjJp.mjs";
4
+ import { i as normalizeDiscordAllowList, o as normalizeDiscordSlug } from "./allow-list-DahA0Jxh.mjs";
5
+ import { h as createDiscordRetryRunner, v as chunkDiscordTextWithMode } from "./send.receipt-CMteCIZS.mjs";
6
6
  import { n as resolveDiscordChannelId } from "./target-parsing-BiuhcK9Q.mjs";
7
- import { a as removeReactionDiscord, r as reactMessageDiscord } from "./send-Cbq-IVsS.mjs";
8
- import { o as discordTextHasBroadcastMention } from "./send.outbound-CGhBhzjQ.mjs";
9
- import { n as DISCORD_ATTACHMENT_TOTAL_TIMEOUT_MS, t as DISCORD_ATTACHMENT_IDLE_TIMEOUT_MS } from "./timeouts-DTrUsJ_W.mjs";
10
- import "./targets-BaklhOqq.mjs";
11
- import { C as discordInboundEventDelivery, p as buildDiscordRoutePeer, v as resolveDiscordConversationIdentity } from "./outbound-session-route-TFBPPkoz.mjs";
12
- import { t as DISCORD_TEXT_CHUNK_LIMIT } from "./outbound-adapter-DWyAWBFh.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-BBDuE14w.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-CGgOaWcu.mjs";
15
- import { n as resolveDiscordWebhookId, t as resolveDiscordSenderIdentity } from "./sender-identity-DrN5c4ec.mjs";
16
- import { n as resolveDiscordAutoThreadReplyPlan } from "./threading-l0UfrE6x.mjs";
17
- import { t as beginDiscordActiveTurnThreadRoute } from "./active-turn-thread-route-BAc_Xik-.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-DR4BnvMU.mjs";
7
+ import { a as removeReactionDiscord, r as reactMessageDiscord } from "./send-DnLL6XoO.mjs";
8
+ import { o as discordTextHasBroadcastMention } from "./send.outbound-B11X6TOE.mjs";
9
+ import { n as DISCORD_ATTACHMENT_TOTAL_TIMEOUT_MS, t as DISCORD_ATTACHMENT_IDLE_TIMEOUT_MS } from "./timeouts-CT9hnmo4.mjs";
10
+ import { S as discordInboundEventDelivery, _ as resolveDiscordConversationIdentity, p as buildDiscordRoutePeer } from "./outbound-session-route-Cb8cv4Oi.mjs";
11
+ import { t as DISCORD_TEXT_CHUNK_LIMIT } from "./outbound-payload-DUsrFICb.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-Dm2ERSxe.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-DzpzETZR.mjs";
14
+ import { n as resolveDiscordWebhookId, t as resolveDiscordSenderIdentity } from "./sender-identity-CGNpdJmb.mjs";
15
+ import { n as resolveDiscordAutoThreadReplyPlan } from "./threading-HA9C2wYR.mjs";
16
+ import { t as beginDiscordActiveTurnThreadRoute } from "./active-turn-thread-route-DkPnk2x8.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-6E9TFmmN.mjs";
19
18
  import { t as sendTyping } from "./typing-DAv4S2fI.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 [];
@@ -200,7 +198,10 @@ async function buildDiscordMessageProcessContext(params) {
200
198
  const groupChannel = isGuildMessage && displayChannelSlug ? `#${displayChannelSlug}` : void 0;
201
199
  const senderName = sender.isPluralKit ? sender.name ?? author.username : data.member?.nickname ?? author.globalName ?? author.username;
202
200
  const senderUsername = sender.isPluralKit ? sender.tag ?? sender.name ?? author.username : author.username;
203
- const { groupSystemPrompt, ownerAllowFrom, channelStructuredContext } = buildDiscordInboundAccessContext({
201
+ const { groupSystemPrompt, ownerAllowFrom, channelStructuredContext, toolPolicy } = buildDiscordInboundAccessContext({
202
+ cfg,
203
+ accountId,
204
+ parentId: threadParentId,
204
205
  channelConfig,
205
206
  guildInfo,
206
207
  sender: {
@@ -208,6 +209,8 @@ async function buildDiscordMessageProcessContext(params) {
208
209
  name: sender.name,
209
210
  tag: sender.tag
210
211
  },
212
+ senderName,
213
+ senderUsername,
211
214
  allowNameMatching: isDangerousNameMatchingEnabled(discordConfig),
212
215
  isGuild: isGuildMessage,
213
216
  channelTopic: channelInfo?.topic
@@ -260,7 +263,7 @@ async function buildDiscordMessageProcessContext(params) {
260
263
  let combinedBody = formatInboundEnvelope({
261
264
  channel: "Discord",
262
265
  from: fromLabel,
263
- timestamp: resolveTimestampMs(message.timestamp),
266
+ timestamp: parseDateStringTimestampMs(message.timestamp),
264
267
  body: bodyWithMediaNotice,
265
268
  chatType: isDirectMessage ? "direct" : "channel",
266
269
  senderLabel,
@@ -281,7 +284,7 @@ async function buildDiscordMessageProcessContext(params) {
281
284
  entries: guildHistories.get(messageChannelId) ?? [],
282
285
  mode: contextVisibilityMode,
283
286
  isSenderAllowed: isSupplementalContextSenderAllowed
284
- }).entries.slice(-historyLimit);
287
+ }).slice(-historyLimit);
285
288
  if (!isHistoryCurrent()) return null;
286
289
  combinedBody = buildHistoryContextFromEntries({
287
290
  entries: visibleChannelHistory,
@@ -320,7 +323,7 @@ async function buildDiscordMessageProcessContext(params) {
320
323
  accountId,
321
324
  parentId: threadParentId,
322
325
  parentType: threadParentType,
323
- resolveTimestampMs
326
+ resolveTimestampMs: parseDateStringTimestampMs
324
327
  });
325
328
  if (!isHistoryCurrent()) return null;
326
329
  if (starter?.text) {
@@ -383,7 +386,7 @@ async function buildDiscordMessageProcessContext(params) {
383
386
  threadParentInheritanceEnabled
384
387
  });
385
388
  if (!isHistoryCurrent()) return null;
386
- const { deliverTarget, replyTarget, autoThreadContext } = replyPlan;
389
+ const { replyTarget, autoThreadContext } = replyPlan;
387
390
  const conversationParentId = threadChannel ? threadParentId : autoThreadContext ? messageChannelId : void 0;
388
391
  const effectiveFrom = isDirectMessage ? `discord:${author.id}` : autoThreadContext?.From ?? `discord:channel:${messageChannelId}`;
389
392
  const dmConversationTarget = isDirectMessage ? resolveDiscordConversationIdentity({
@@ -426,7 +429,7 @@ async function buildDiscordMessageProcessContext(params) {
426
429
  accountId: route.accountId,
427
430
  messageId: canonicalMessageId ?? message.id,
428
431
  messageIdFull: canonicalMessageId && canonicalMessageId !== message.id ? message.id : void 0,
429
- timestamp: resolveTimestampMs(message.timestamp),
432
+ timestamp: parseDateStringTimestampMs(message.timestamp),
430
433
  from: effectiveFrom,
431
434
  sender: {
432
435
  id: sender.id,
@@ -478,6 +481,7 @@ async function buildDiscordMessageProcessContext(params) {
478
481
  historyKind: isGuildMessage ? "recent" : "pending"
479
482
  },
480
483
  access: {
484
+ toolPolicy,
481
485
  mentions: {
482
486
  canDetectMention: ctx.canDetectMention,
483
487
  wasMentioned: ctx.effectiveWasMentioned,
@@ -535,7 +539,7 @@ async function buildDiscordMessageProcessContext(params) {
535
539
  const persistedSessionKey = ctxPayload.SessionKey ?? route.sessionKey;
536
540
  if (ctx.inboundEventKind === "room_event" && shouldIncludeChannelHistory) {
537
541
  const historyText = [text, formatDiscordMediaText({
538
- attachments: message.attachments ?? void 0,
542
+ attachments: message.attachments,
539
543
  stickers: resolveDiscordMessageStickers(message)
540
544
  })].filter(Boolean).join("\n");
541
545
  await channelHistory.recordWithMedia({
@@ -544,7 +548,7 @@ async function buildDiscordMessageProcessContext(params) {
544
548
  entry: {
545
549
  sender: senderName,
546
550
  body: historyText,
547
- timestamp: resolveTimestampMs(message.timestamp),
551
+ timestamp: parseDateStringTimestampMs(message.timestamp),
548
552
  messageId: message.id,
549
553
  mediaIds: resolveDiscordHistoryMediaIds(message),
550
554
  senderProvenance: createDiscordHistorySenderProvenance({
@@ -556,10 +560,6 @@ async function buildDiscordMessageProcessContext(params) {
556
560
  messageId: message.id
557
561
  });
558
562
  }
559
- if (shouldLogVerbose()) {
560
- const preview = truncateUtf16Safe(combinedBody, 200).replace(/\n/g, "\\n");
561
- logVerbose(`discord inbound: channel=${messageChannelId} deliver=${deliverTarget} from=${ctxPayload.From} preview="${preview}"`);
562
- }
563
563
  return {
564
564
  ctxPayload,
565
565
  persistedSessionKey,
@@ -584,134 +584,6 @@ async function buildDiscordMessageProcessContext(params) {
584
584
  replyPlan
585
585
  };
586
586
  }
587
- // extensions/discord/src/monitor/message-handler.process-progress.ts
588
- async function createDiscordMessageProgressRuntime(params) {
589
- const { ctx, draftPreview } = params;
590
- const { cfg, route, abortSignal } = ctx;
591
- const reasoningLevel = await (async () => {
592
- const cfgDefault = resolveAgentConfig(cfg, route.agentId ?? "main")?.reasoningDefault ?? cfg.agents?.defaults?.reasoningDefault;
593
- const configDefault = cfgDefault === "on" || cfgDefault === "stream" ? cfgDefault : "off";
594
- if (!params.sessionKey) return configDefault;
595
- try {
596
- const storePath = resolveStorePath(cfg.session?.store, { agentId: route.agentId });
597
- const level = (await getSessionEntryAsync({
598
- agentId: route.agentId,
599
- sessionKey: params.sessionKey,
600
- storePath
601
- }))?.reasoningLevel;
602
- if (level === "on" || level === "stream" || level === "off") return level;
603
- } catch {
604
- return "off";
605
- }
606
- return configDefault;
607
- })();
608
- const reasoningDurableEnabled = reasoningLevel === "on";
609
- const reasoningWindowEnabled = reasoningLevel === "stream";
610
- let shouldYieldDraftCommentary = async () => false;
611
- let turnCommentaryVisible = false;
612
- return { replyOptions: {
613
- progressRequiresReply: draftPreview.isProgressMode ? true : void 0,
614
- onAssistantMessageStart: draftPreview.draftStream ? () => {
615
- if (draftPreview.handleAssistantMessageBoundary()) params.onTurnReset();
616
- return false;
617
- } : void 0,
618
- onReasoningEnd: draftPreview.draftStream ? () => {
619
- draftPreview.resetReasoningProgress();
620
- return false;
621
- } : void 0,
622
- onQueuedFollowupAdmitted: draftPreview.draftStream ? () => {
623
- if (draftPreview.handleQueuedFollowupAdmitted()) params.onTurnReset();
624
- } : void 0,
625
- onQueuedFollowupSettled: draftPreview.draftStream ? () => draftPreview.cleanup() : void 0,
626
- suppressDefaultToolProgressMessages: params.sourceRepliesAreToolOnly && params.reactions.statusReactionsExplicitlyEnabled || draftPreview.suppressDefaultToolProgressMessages ? true : void 0,
627
- allowToolLifecycleWhenProgressHidden: params.reactions.statusReactionsEnabled ? true : void 0,
628
- commentaryProgressEnabled: draftPreview.isProgressMode ? draftPreview.commentaryProgressEnabled : void 0,
629
- progressPreambleEnabled: draftPreview.draftStream && draftPreview.isProgressMode ? true : void 0,
630
- commentaryPayloadsEnabled: draftPreview.isProgressMode ? draftPreview.commentaryProgressEnabled : void 0,
631
- shouldDeliverCommentaryPayloads: draftPreview.isProgressMode && draftPreview.commentaryProgressEnabled ? () => turnCommentaryVisible : void 0,
632
- reasoningPayloadsEnabled: reasoningDurableEnabled,
633
- onVerboseProgressVisibilityAsync: async (isActive) => {
634
- shouldYieldDraftCommentary = isActive;
635
- turnCommentaryVisible = await isActive();
636
- },
637
- onNarrationUpdate: draftPreview.narrationProgressEnabled ? async (payload) => {
638
- if (await shouldYieldDraftCommentary() || abortSignal?.aborted) return;
639
- await draftPreview.pushNarrationProgress(payload.text);
640
- } : void 0,
641
- onProgressNarratorLifecycle: draftPreview.narrationProgressEnabled ? (lifecycle) => draftPreview.setProgressNarratorLifecycle(lifecycle) : void 0,
642
- isProgressDraftVisible: draftPreview.narrationProgressEnabled ? () => draftPreview.isProgressDraftVisible : void 0,
643
- narrationHideCommandText: draftPreview.narrationHideCommandText ? true : void 0,
644
- onReasoningStream: async (payload) => {
645
- if (payload?.requiresReasoningProgressOptIn === true && !reasoningWindowEnabled) return false;
646
- await params.reactions.controller.setThinking();
647
- return await draftPreview.pushReasoningProgress(payload?.text, { snapshot: payload?.isReasoningSnapshot === true });
648
- },
649
- streamReasoningInNonStreamModes: reasoningWindowEnabled,
650
- onToolStart: async (payload) => {
651
- if (abortSignal?.aborted) return false;
652
- await params.reactions.maybeBindToToolReaction(payload);
653
- await params.reactions.controller.setTool(payload.name);
654
- return await draftPreview.pushToolEvent(payload);
655
- },
656
- onItemEvent: async (payload) => {
657
- if (abortSignal?.aborted || payload.kind === "preamble" && await shouldYieldDraftCommentary()) return;
658
- return await draftPreview.pushItemEvent(payload);
659
- },
660
- onPlanUpdate: async (payload) => {
661
- if (payload.phase === "update") return await draftPreview.pushPlanProgress(payload.steps, {
662
- explanation: payload.explanation,
663
- explanationFormat: payload.explanationFormat
664
- });
665
- return false;
666
- },
667
- onApprovalEvent: async (payload) => {
668
- return await draftPreview.pushApprovalEvent(payload);
669
- },
670
- onCompactionStart: async () => {
671
- if (!abortSignal?.aborted) await params.reactions.controller.setCompacting();
672
- return false;
673
- },
674
- onCompactionEnd: async () => {
675
- if (!abortSignal?.aborted) {
676
- params.reactions.controller.cancelPending();
677
- await params.reactions.controller.setThinking();
678
- }
679
- return false;
680
- }
681
- } };
682
- }
683
- // extensions/discord/src/monitor/ack-reactions.ts
684
- function createDiscordAckReactionContext(params) {
685
- return {
686
- rest: params.rest,
687
- ...createDiscordRuntimeAccountContext(params)
688
- };
689
- }
690
- function createDiscordAckReactionAdapter(params) {
691
- return {
692
- setReaction: async (emoji) => {
693
- await reactMessageDiscord(params.channelId, params.messageId, emoji, params.reactionContext);
694
- },
695
- removeReaction: async (emoji) => {
696
- await removeReactionDiscord(params.channelId, params.messageId, emoji, params.reactionContext);
697
- }
698
- };
699
- }
700
- function queueInitialDiscordAckReaction(params) {
701
- if (params.enabled) {
702
- params.statusReactions.setQueued();
703
- return;
704
- }
705
- if (!params.shouldSendAckReaction || !params.ackReaction) return;
706
- params.reactionAdapter.setReaction(params.ackReaction).catch((err) => {
707
- logAckFailure({
708
- log: logVerbose,
709
- channel: "discord",
710
- target: params.target,
711
- error: err
712
- });
713
- });
714
- }
715
587
  // extensions/discord/src/monitor/message-handler.process-reactions.ts
716
588
  function createDiscordMessageReactionRuntime(params) {
717
589
  const { ctx } = params;
@@ -742,16 +614,22 @@ function createDiscordMessageReactionRuntime(params) {
742
614
  token,
743
615
  accountId
744
616
  }).rest;
745
- const ackReactionContext = createDiscordAckReactionContext({
617
+ const ackReactionContext = {
746
618
  rest: feedbackRest,
747
- cfg,
748
- accountId
749
- });
750
- const discordAdapter = createDiscordAckReactionAdapter({
751
- channelId: messageChannelId,
752
- messageId: message.id,
753
- reactionContext: ackReactionContext
619
+ ...createDiscordRuntimeAccountContext({
620
+ cfg,
621
+ accountId
622
+ })
623
+ };
624
+ const createReactionAdapter = (channelId, messageId) => ({
625
+ setReaction: async (emoji) => {
626
+ await reactMessageDiscord(channelId, messageId, emoji, ackReactionContext);
627
+ },
628
+ removeReaction: async (emoji) => {
629
+ await removeReactionDiscord(channelId, messageId, emoji, ackReactionContext);
630
+ }
754
631
  });
632
+ const discordAdapter = createReactionAdapter(messageChannelId, message.id);
755
633
  let statusReactionTarget = `${messageChannelId}/${message.id}`;
756
634
  let statusReactionsActive = statusReactionsEnabled;
757
635
  const logReactionFailure = (target, error) => logAckFailure({
@@ -798,11 +676,7 @@ function createDiscordMessageReactionRuntime(params) {
798
676
  }
799
677
  statusReactionTarget = `${trackedChannelId}/${trackedMessageId}`;
800
678
  if (statusReactionsActive) statusReactions.clear();
801
- statusReactions = createController(true, createDiscordAckReactionAdapter({
802
- channelId: trackedChannelId,
803
- messageId: trackedMessageId,
804
- reactionContext: ackReactionContext
805
- }), emoji);
679
+ statusReactions = createController(true, createReactionAdapter(trackedChannelId, trackedMessageId), emoji);
806
680
  statusReactionsActive = true;
807
681
  statusReactions.setQueued();
808
682
  };
@@ -810,13 +684,12 @@ function createDiscordMessageReactionRuntime(params) {
810
684
  const queueInitialAckReactionAfterRecord = () => {
811
685
  if (initialAckReactionQueued) return;
812
686
  initialAckReactionQueued = true;
813
- queueInitialDiscordAckReaction({
814
- enabled: statusReactionsEnabled,
815
- shouldSendAckReaction,
816
- ackReaction,
817
- statusReactions,
818
- reactionAdapter: discordAdapter,
819
- target: `${messageChannelId}/${message.id}`
687
+ if (statusReactionsEnabled) {
688
+ statusReactions.setQueued();
689
+ return;
690
+ }
691
+ if (shouldSendAckReaction && ackReaction) discordAdapter.setReaction(ackReaction).catch((err) => {
692
+ logReactionFailure(`${messageChannelId}/${message.id}`, err);
820
693
  });
821
694
  };
822
695
  const finish = async (result) => {
@@ -851,6 +724,7 @@ function createDiscordDraftStream(params) {
851
724
  const minInitialChars = params.minInitialChars;
852
725
  let channelId = params.channelId;
853
726
  const rest = params.rest;
727
+ const retryDelete = createDiscordRetryRunner({});
854
728
  const flags = resolveDiscordMessageFlags({ suppressEmbeds: params.suppressEmbeds });
855
729
  const streamState = {
856
730
  stopped: false,
@@ -925,7 +799,7 @@ function createDiscordDraftStream(params) {
925
799
  loop.resetThrottleWindow();
926
800
  },
927
801
  isValidMessageId: (value) => value !== void 0,
928
- deleteMessage: (message) => deleteChannelMessage(rest, message.channelId, message.messageId),
802
+ deleteMessage: (message) => retryDelete(() => deleteChannelMessage(rest, message.channelId, message.messageId)),
929
803
  warn: params.warn,
930
804
  warnPrefix: "discord stream preview cleanup failed"
931
805
  });
@@ -977,74 +851,11 @@ function createDiscordDraftStream(params) {
977
851
  forceNewMessage: lifecycle.reset
978
852
  };
979
853
  }
980
- // extensions/discord/src/preview-streaming.ts
981
- function resolveDiscordPreviewStreamMode(params = {}) {
982
- return resolveChannelPreviewStreamMode(params, "progress");
983
- }
984
- // extensions/discord/src/monitor/message-handler.progress-continuation.ts
985
- /** The registry owns task settlement; Discord keeps the confirmed transport and its cleanup. */
986
- function retainDiscordProgressDraft(params) {
987
- let retired = false;
988
- const assertChannelCurrent = () => {
989
- params.assertChannelAuthority?.();
990
- if (params.isPolicyCurrent?.() === false) throw new Error("Discord channel policy is no longer current");
991
- };
992
- const assertCurrent = () => {
993
- assertChannelCurrent();
994
- if (retired) throw new Error("Discord retained progress authority is no longer current");
995
- };
996
- const compositor = createChannelProgressDraftCompositor({
997
- preparedItems: true,
998
- showWorkStatus: true,
999
- entry: params.entry,
1000
- mode: "progress",
1001
- active: true,
1002
- seed: params.seed,
1003
- reasoningGate: false,
1004
- toolIcons: true,
1005
- initialSnapshot: params.snapshot,
1006
- update: async (text, options) => {
1007
- if (retired) return false;
1008
- params.stream.update(text, {
1009
- complete: true,
1010
- assertCurrent
1011
- });
1012
- if (options.flush) await params.stream.flush();
1013
- return params.stream.lastDeliveredText() === text;
1014
- }
1015
- });
1016
- let queue = Promise.resolve();
1017
- const enqueue = (work) => {
1018
- queue = params.runInChannelScope(() => queue.then(work).catch((error) => {
1019
- params.log("discord: retained progress failed (" + String(error) + ")");
1020
- }));
1021
- };
1022
- let started = false;
1023
- return {
1024
- push: (item) => enqueue(async () => {
1025
- if (retired) return;
1026
- if (!started) {
1027
- started = true;
1028
- await compositor.start();
1029
- }
1030
- await compositor.pushItemEvent(item);
1031
- }),
1032
- retire: () => {
1033
- if (retired) return;
1034
- retired = true;
1035
- compositor.markFinalReplyStarted();
1036
- enqueue(() => withDiscordRequestAuthority(assertChannelCurrent, async () => {
1037
- await params.stream.clear();
1038
- await params.stream.cleanupPendingMessages();
1039
- }));
1040
- }
1041
- };
1042
- }
1043
854
  // extensions/discord/src/monitor/message-handler.draft-preview.ts
1044
855
  function createDiscordDraftPreviewController(params) {
1045
856
  const runInChannelScope = AsyncLocalStorage.snapshot();
1046
857
  const assertChannelAuthority = captureDiscordRequestAuthority();
1047
- const discordStreamMode = resolveDiscordPreviewStreamMode(params.discordConfig);
858
+ const discordStreamMode = resolveChannelPreviewStreamMode(params.discordConfig, "progress");
1048
859
  const hookRunner = getGlobalHookRunner();
1049
860
  const allowProviderPreview = !params.groupThread && !params.isRoomEvent && !((hookRunner?.hasHooks("reply_payload_sending") ?? false) || (hookRunner?.hasHooks("message_sending") ?? false));
1050
861
  const draftMaxChars = Math.min(params.textLimit, 2e3);
@@ -1079,7 +890,6 @@ function createDiscordDraftPreviewController(params) {
1079
890
  const progressSeed = `${params.accountId}:${params.deliverChannelId}`;
1080
891
  const progressDraft = createChannelProgressDraftCompositor({
1081
892
  preparedItems: true,
1082
- showWorkStatus: true,
1083
893
  entry: params.discordConfig,
1084
894
  mode: discordStreamMode,
1085
895
  active: Boolean(draftStream),
@@ -1138,13 +948,9 @@ function createDiscordDraftPreviewController(params) {
1138
948
  } : void 0,
1139
949
  retainOnError: true,
1140
950
  cleanupUndelivered: true,
1141
- onFinalStarted: () => {
1142
- freezeProgress();
1143
- params.onFinalReplyStart?.();
1144
- },
951
+ onFinalStarted: freezeProgress,
1145
952
  onFinalDelivered: () => {
1146
953
  progressDraft.markFinalReplyDelivered();
1147
- params.onFinalReplyDelivered?.();
1148
954
  },
1149
955
  onCleanupFailure: (err) => params.log(`discord: draft cleanup failed: ${String(err)}`)
1150
956
  });
@@ -1212,16 +1018,63 @@ function createDiscordDraftPreviewController(params) {
1212
1018
  });
1213
1019
  if (!stream.messageId() || stream.isStopped() || stream.lastDeliveredText() !== text || draftStream !== stream) return false;
1214
1020
  assertCurrent();
1215
- if (!adopt(retainDiscordProgressDraft({
1216
- stream,
1217
- snapshot,
1218
- entry: params.discordConfig,
1021
+ const retainedEntry = params.discordConfig;
1022
+ const retainedLog = params.log;
1023
+ const retainedIsPolicyCurrent = params.isPolicyCurrent;
1024
+ let retired = false;
1025
+ const assertChannelCurrent = () => {
1026
+ assertChannelAuthority?.();
1027
+ if (retainedIsPolicyCurrent?.() === false) throw new Error("Discord channel policy is no longer current");
1028
+ };
1029
+ const assertRetainedCurrent = () => {
1030
+ assertChannelCurrent();
1031
+ if (retired) throw new Error("Discord retained progress authority is no longer current");
1032
+ };
1033
+ const retainedCompositor = createChannelProgressDraftCompositor({
1034
+ preparedItems: true,
1035
+ entry: retainedEntry,
1036
+ mode: "progress",
1037
+ active: true,
1219
1038
  seed: progressSeed,
1220
- log: params.log,
1221
- runInChannelScope,
1222
- assertChannelAuthority,
1223
- isPolicyCurrent: params.isPolicyCurrent
1224
- }))) return false;
1039
+ reasoningGate: false,
1040
+ toolIcons: true,
1041
+ initialSnapshot: snapshot,
1042
+ update: async (retainedText, options) => {
1043
+ if (retired) return false;
1044
+ stream.update(retainedText, {
1045
+ complete: true,
1046
+ assertCurrent: assertRetainedCurrent
1047
+ });
1048
+ if (options.flush) await stream.flush();
1049
+ return stream.lastDeliveredText() === retainedText;
1050
+ }
1051
+ });
1052
+ let queue = Promise.resolve();
1053
+ const enqueue = (work) => {
1054
+ queue = runInChannelScope(() => queue.then(work).catch((error) => {
1055
+ retainedLog("discord: retained progress failed (" + String(error) + ")");
1056
+ }));
1057
+ };
1058
+ let started = false;
1059
+ if (!adopt({
1060
+ push: (item) => enqueue(async () => {
1061
+ if (retired) return;
1062
+ if (!started) {
1063
+ started = true;
1064
+ await retainedCompositor.start();
1065
+ }
1066
+ await retainedCompositor.pushItemEvent(item);
1067
+ }),
1068
+ retire: () => {
1069
+ if (retired) return;
1070
+ retired = true;
1071
+ retainedCompositor.markFinalReplyStarted();
1072
+ enqueue(() => withDiscordRequestAuthority(assertChannelCurrent, async () => {
1073
+ await stream.clear();
1074
+ await stream.cleanupPendingMessages();
1075
+ }));
1076
+ }
1077
+ })) return false;
1225
1078
  lifecycle.retainPreview();
1226
1079
  draftStream = void 0;
1227
1080
  resetProgressState();
@@ -1312,27 +1165,6 @@ function isEmptyDiscordProgressLine(line) {
1312
1165
  function shouldStartDiscordProgressDraftNow(line) {
1313
1166
  return typeof line === "object" && line?.kind === "patch" && Boolean(line.detail);
1314
1167
  }
1315
- // extensions/discord/src/monitor/reply-typing-feedback.ts
1316
- const DISCORD_REPLY_TYPING_MAX_DURATION_MS = 12e5;
1317
- function createDiscordReplyTypingFeedback(params) {
1318
- const rest = params.rest ?? createDiscordRestClient(params).rest;
1319
- return createTypingCallbacks({
1320
- start: () => sendTyping({
1321
- rest,
1322
- channelId: params.channelId
1323
- }),
1324
- onStartError: (err) => {
1325
- logTypingFailure({
1326
- log: params.log,
1327
- channel: "discord",
1328
- target: params.channelId,
1329
- error: err
1330
- });
1331
- },
1332
- keepaliveIntervalMs: params.keepaliveIntervalMs,
1333
- maxDurationMs: params.maxDurationMs ?? DISCORD_REPLY_TYPING_MAX_DURATION_MS
1334
- });
1335
- }
1336
1168
  // extensions/discord/src/monitor/message-handler.process-reply-runtime.ts
1337
1169
  function formatDiscordGroupThreadReply(text, participant) {
1338
1170
  return `**${participant.name.replace(/[\\`*_{}[\]()<>#!|]/g, "\\$&").replace(/\s+/g, " ")}**\n${text}`;
@@ -1362,18 +1194,25 @@ function createDiscordBeforePayloadDelivery(params) {
1362
1194
  }
1363
1195
  function createDiscordMessageReplyRuntime(params) {
1364
1196
  const { ctx, processContext } = params;
1365
- const { cfg, discordConfig, accountId, token, guildHistories, historyLimit, textLimit, messageChannelId, isDirectMessage, route } = ctx;
1197
+ const { cfg, discordConfig, accountId, guildHistories, historyLimit, textLimit, messageChannelId, isDirectMessage, route } = ctx;
1366
1198
  const { ctxPayload, replyPlan } = processContext;
1367
1199
  const deliverChannelId = replyPlan.deliverTarget.startsWith("channel:") ? replyPlan.deliverTarget.slice(8) : messageChannelId;
1368
1200
  let typingFeedback;
1369
- const getTypingFeedback = () => typingFeedback ??= createDiscordReplyTypingFeedback({
1370
- cfg,
1371
- token,
1372
- accountId,
1373
- channelId: deliverChannelId,
1374
- rest: params.feedbackRest,
1375
- log: logVerbose,
1376
- keepaliveIntervalMs: params.shouldDisableCoreTypingKeepalive ? void 0 : 0
1201
+ const getTypingFeedback = () => typingFeedback ??= createTypingCallbacks({
1202
+ start: () => sendTyping({
1203
+ rest: params.feedbackRest,
1204
+ channelId: deliverChannelId
1205
+ }),
1206
+ onStartError: (error) => {
1207
+ logTypingFailure({
1208
+ log: logVerbose,
1209
+ channel: "discord",
1210
+ target: deliverChannelId,
1211
+ error
1212
+ });
1213
+ },
1214
+ keepaliveIntervalMs: params.shouldDisableCoreTypingKeepalive ? void 0 : 0,
1215
+ maxDurationMs: 12e5
1377
1216
  });
1378
1217
  const { onModelSelected, ...replyPipeline } = createChannelMessageReplyPipeline({
1379
1218
  cfg,
@@ -1456,55 +1295,18 @@ function createDiscordMessageReplyRuntime(params) {
1456
1295
  deliveryRest: params.deliveryRest,
1457
1296
  deliverChannelId,
1458
1297
  replyReference: params.replyReference,
1459
- onFinalReplyStart: params.onFinalReplyStart,
1460
- onFinalReplyDelivered: params.onFinalReplyDelivered,
1461
1298
  log: logVerbose
1462
1299
  }),
1463
1300
  resolvedBlockStreamingEnabled: resolveChannelStreamingBlockEnabled(discordConfig)
1464
1301
  };
1465
1302
  }
1466
- // extensions/discord/src/monitor/message-handler.process-thread-route.ts
1467
- function createDiscordMessageActiveThreadRoute(params) {
1468
- let adoptedThreadId;
1469
- let threadReplyDelivered = false;
1470
- let onThreadAdopted;
1471
- return {
1472
- replyReference: {
1473
- peek: () => adoptedThreadId ? void 0 : params.sourceReplyReference.peek(),
1474
- use: () => adoptedThreadId ? void 0 : params.sourceReplyReference.use(),
1475
- markSent: () => params.sourceReplyReference.markSent(),
1476
- hasReplied: () => Boolean(adoptedThreadId) || params.sourceReplyReference.hasReplied()
1477
- },
1478
- bindThreadAdoption(callback) {
1479
- onThreadAdopted = callback;
1480
- },
1481
- get threadReplyDelivered() {
1482
- return threadReplyDelivered;
1483
- },
1484
- end: beginDiscordActiveTurnThreadRoute(params.sessionKey, {
1485
- accountId: params.accountId,
1486
- sourceChannelId: params.sourceChannelId,
1487
- sourceMessageId: params.sourceMessageId,
1488
- onThreadAdopted: async (threadId) => {
1489
- adoptedThreadId = threadId;
1490
- await onThreadAdopted?.(threadId);
1491
- },
1492
- onThreadReplyDelivered: () => {
1493
- threadReplyDelivered = true;
1494
- },
1495
- onThreadAdoptionError: (error) => {
1496
- params.log(`discord: failed to move active progress into adopted thread (${String(error)})`);
1497
- }
1498
- })
1499
- };
1500
- }
1501
1303
  // extensions/discord/src/monitor/message-handler.process.ts
1502
1304
  const TARGETED_ONLY_ALLOWED_MENTIONS = { parse: [AllowedMentionsTypes.User, AllowedMentionsTypes.Role] };
1503
1305
  function isFallbackOnlyToolWarningFinal(payload) {
1504
1306
  if (payload.isError !== true || !isReplyPayloadNonTerminalToolErrorWarning(payload)) return false;
1505
1307
  return !resolveSendableOutboundReplyParts(payload).hasMedia;
1506
1308
  }
1507
- async function processDiscordMessage(ctx, observer) {
1309
+ async function processDiscordMessage(ctx) {
1508
1310
  const dispatchStartedAt = Date.now();
1509
1311
  const { cfg, accountId, token, runtime, textLimit, replyToMode, message, messageChannelId, isGuildMessage, isDirectMessage, isGroupDm, messageText: text, threadBindings, route, abortSignal, isPolicyCurrent, turnAdoptionLifecycle, preparedMedia: mediaList } = ctx;
1510
1312
  if (abortSignal?.aborted || isPolicyCurrent?.() === false) return;
@@ -1529,7 +1331,7 @@ async function processDiscordMessage(ctx, observer) {
1529
1331
  }
1530
1332
  });
1531
1333
  const sourceRepliesAreToolOnly = sourceReplyDeliveryMode === "message_tool_only";
1532
- const configuredTypingMode = resolveAgentConfig$1(cfg, route.agentId)?.typingMode ?? cfg.agents?.defaults?.typingMode;
1334
+ const configuredTypingMode = resolveAgentConfig(cfg, route.agentId)?.typingMode ?? cfg.agents?.defaults?.typingMode;
1533
1335
  const configuredTypingInterval = cfg.agents?.defaults?.typingIntervalSeconds;
1534
1336
  const shouldDisableCoreTypingKeepalive = sourceRepliesAreToolOnly && configuredTypingMode === void 0 && configuredTypingInterval === void 0;
1535
1337
  const mediaLocalRoots = getAgentScopedMediaLocalRoots(cfg, route.agentId);
@@ -1547,19 +1349,31 @@ async function processDiscordMessage(ctx, observer) {
1547
1349
  if (!processContext) return;
1548
1350
  const { ctxPayload, persistedSessionKey, record, replyPlan } = processContext;
1549
1351
  let deliverTarget = replyPlan.deliverTarget;
1550
- const activeThreadRoute = createDiscordMessageActiveThreadRoute({
1551
- sessionKey: ctxPayload.SessionKey,
1352
+ const sourceMessageId = ctx.canonicalMessageId ?? message.id;
1353
+ const sourceReplyReference = replyPlan.replyReference;
1354
+ let adoptedThreadId;
1355
+ let threadReplyDelivered = false;
1356
+ let onThreadAdopted = void 0;
1357
+ const endActiveThreadRoute = beginDiscordActiveTurnThreadRoute(ctxPayload.SessionKey, {
1552
1358
  accountId,
1553
1359
  sourceChannelId: messageChannelId,
1554
- sourceMessageId: ctx.canonicalMessageId ?? message.id,
1555
- sourceReplyReference: replyPlan.replyReference,
1556
- log: logVerbose
1557
- });
1558
- const replyReference = activeThreadRoute.replyReference;
1559
- observer?.onReplyPlanResolved?.({
1560
- createdThreadId: replyPlan.createdThreadId,
1561
- sessionKey: persistedSessionKey
1360
+ sourceMessageId,
1361
+ onThreadAdopted: async (threadId) => {
1362
+ adoptedThreadId = threadId;
1363
+ await onThreadAdopted?.(threadId);
1364
+ },
1365
+ onThreadReplyDelivered: () => {
1366
+ threadReplyDelivered = true;
1367
+ },
1368
+ onThreadAdoptionError: (error) => {
1369
+ logVerbose(`discord: failed to move active progress into adopted thread (${String(error)})`);
1370
+ }
1562
1371
  });
1372
+ const replyReference = {
1373
+ peek: () => adoptedThreadId ? void 0 : sourceReplyReference.peek(),
1374
+ use: () => adoptedThreadId ? void 0 : sourceReplyReference.use(),
1375
+ markSent: () => sourceReplyReference.markSent()
1376
+ };
1563
1377
  const { replyPipeline, onModelSelected, tableMode, maxLinesPerMessage, chunkMode, beginQueuedDeliveryCorrelation, endDeliveryCorrelation, resolveCurrentTurnTranscriptFinalText, draftPreview, resolvedBlockStreamingEnabled } = createDiscordMessageReplyRuntime({
1564
1378
  ctx,
1565
1379
  processContext,
@@ -1569,36 +1383,116 @@ async function processDiscordMessage(ctx, observer) {
1569
1383
  isRoomEvent,
1570
1384
  dispatchStartedAt,
1571
1385
  feedbackRest: reactions.feedbackRest,
1572
- deliveryRest: reactions.deliveryRest,
1573
- onFinalReplyStart: observer?.onFinalReplyStart,
1574
- onFinalReplyDelivered: observer?.onFinalReplyDelivered
1386
+ deliveryRest: reactions.deliveryRest
1575
1387
  });
1576
- activeThreadRoute.bindThreadAdoption(async (threadId) => {
1388
+ onThreadAdopted = async (threadId) => {
1577
1389
  deliverTarget = `channel:${threadId}`;
1578
1390
  await draftPreview.retarget(threadId);
1579
- });
1391
+ };
1580
1392
  const { lifecycle } = draftPreview;
1581
1393
  const hasCompletedFinalReply = () => lifecycle.finalSucceeded || lifecycle.previewFinalized;
1582
1394
  const observeFinalDelivery = async () => {
1583
1395
  if (lifecycle.finalSucceeded) return;
1584
1396
  draftPreview.freezeProgress();
1585
- const retainedProgress = activeThreadRoute.threadReplyDelivered && !lifecycle.previewFinalized ? draftPreview.finalizeProgressDraft().catch((error) => {
1397
+ const retainedProgress = threadReplyDelivered && !lifecycle.previewFinalized ? draftPreview.finalizeProgressDraft().catch((error) => {
1586
1398
  logVerbose(`discord: failed to finalize adopted thread progress (${String(error)})`);
1587
1399
  }) : void 0;
1588
1400
  await lifecycle.observeDelivery({ visibleReplySent: true });
1589
1401
  await retainedProgress;
1590
1402
  };
1591
1403
  let pendingToolWarningFinal;
1592
- const progress = await createDiscordMessageProgressRuntime({
1593
- ctx,
1594
- sessionKey: ctxPayload.SessionKey,
1595
- sourceRepliesAreToolOnly,
1596
- draftPreview,
1597
- reactions,
1598
- onTurnReset: () => {
1599
- pendingToolWarningFinal = void 0;
1404
+ const progressSessionKey = ctxPayload.SessionKey;
1405
+ const reasoningLevel = await (async () => {
1406
+ const cfgDefault = resolveAgentConfig(cfg, route.agentId ?? "main")?.reasoningDefault ?? cfg.agents?.defaults?.reasoningDefault;
1407
+ const configDefault = cfgDefault === "on" || cfgDefault === "stream" ? cfgDefault : "off";
1408
+ if (!progressSessionKey) return configDefault;
1409
+ try {
1410
+ const storePath = resolveStorePath(cfg.session?.store, { agentId: route.agentId });
1411
+ const level = (await getSessionEntryAsync({
1412
+ agentId: route.agentId,
1413
+ sessionKey: progressSessionKey,
1414
+ storePath
1415
+ }))?.reasoningLevel;
1416
+ if (level === "on" || level === "stream" || level === "off") return level;
1417
+ } catch {
1418
+ return "off";
1600
1419
  }
1601
- });
1420
+ return configDefault;
1421
+ })();
1422
+ const reasoningDurableEnabled = reasoningLevel === "on";
1423
+ const reasoningWindowEnabled = reasoningLevel === "stream";
1424
+ let shouldYieldDraftCommentary = async () => false;
1425
+ let turnCommentaryVisible = false;
1426
+ const progressReplyOptions = {
1427
+ progressRequiresReply: draftPreview.isProgressMode ? true : void 0,
1428
+ onAssistantMessageStart: draftPreview.draftStream ? () => {
1429
+ if (draftPreview.handleAssistantMessageBoundary()) pendingToolWarningFinal = void 0;
1430
+ return false;
1431
+ } : void 0,
1432
+ onReasoningEnd: draftPreview.draftStream ? () => {
1433
+ draftPreview.resetReasoningProgress();
1434
+ return false;
1435
+ } : void 0,
1436
+ onQueuedFollowupAdmitted: draftPreview.draftStream ? () => {
1437
+ if (draftPreview.handleQueuedFollowupAdmitted()) pendingToolWarningFinal = void 0;
1438
+ } : void 0,
1439
+ onQueuedFollowupSettled: draftPreview.draftStream ? () => draftPreview.cleanup() : void 0,
1440
+ suppressDefaultToolProgressMessages: sourceRepliesAreToolOnly && reactions.statusReactionsExplicitlyEnabled || draftPreview.suppressDefaultToolProgressMessages ? true : void 0,
1441
+ allowToolLifecycleWhenProgressHidden: reactions.statusReactionsEnabled ? true : void 0,
1442
+ commentaryProgressEnabled: draftPreview.isProgressMode ? draftPreview.commentaryProgressEnabled : void 0,
1443
+ progressPreambleEnabled: draftPreview.draftStream && draftPreview.isProgressMode ? true : void 0,
1444
+ commentaryPayloadsEnabled: draftPreview.isProgressMode ? draftPreview.commentaryProgressEnabled : void 0,
1445
+ shouldDeliverCommentaryPayloads: draftPreview.isProgressMode && draftPreview.commentaryProgressEnabled ? () => turnCommentaryVisible : void 0,
1446
+ reasoningPayloadsEnabled: reasoningDurableEnabled,
1447
+ onVerboseProgressVisibilityAsync: async (isActive) => {
1448
+ shouldYieldDraftCommentary = isActive;
1449
+ turnCommentaryVisible = await isActive();
1450
+ },
1451
+ onNarrationUpdate: draftPreview.narrationProgressEnabled ? async (payload) => {
1452
+ if (await shouldYieldDraftCommentary() || abortSignal?.aborted) return;
1453
+ await draftPreview.pushNarrationProgress(payload.text);
1454
+ } : void 0,
1455
+ onProgressNarratorLifecycle: draftPreview.narrationProgressEnabled ? (progressLifecycle) => draftPreview.setProgressNarratorLifecycle(progressLifecycle) : void 0,
1456
+ isProgressDraftVisible: draftPreview.narrationProgressEnabled ? () => draftPreview.isProgressDraftVisible : void 0,
1457
+ narrationHideCommandText: draftPreview.narrationHideCommandText ? true : void 0,
1458
+ onReasoningStream: async (payload) => {
1459
+ if (payload?.requiresReasoningProgressOptIn === true && !reasoningWindowEnabled) return false;
1460
+ await reactions.controller.setThinking();
1461
+ return await draftPreview.pushReasoningProgress(payload?.text, { snapshot: payload?.isReasoningSnapshot === true });
1462
+ },
1463
+ streamReasoningInNonStreamModes: reasoningWindowEnabled,
1464
+ onToolStart: async (payload) => {
1465
+ if (abortSignal?.aborted) return false;
1466
+ await reactions.maybeBindToToolReaction(payload);
1467
+ await reactions.controller.setTool(payload.name);
1468
+ return await draftPreview.pushToolEvent(payload);
1469
+ },
1470
+ onItemEvent: async (payload) => {
1471
+ if (abortSignal?.aborted || payload.kind === "preamble" && await shouldYieldDraftCommentary()) return;
1472
+ return await draftPreview.pushItemEvent(payload);
1473
+ },
1474
+ onPlanUpdate: async (payload) => {
1475
+ if (payload.phase === "update") return await draftPreview.pushPlanProgress(payload.steps, {
1476
+ explanation: payload.explanation,
1477
+ explanationFormat: payload.explanationFormat
1478
+ });
1479
+ return false;
1480
+ },
1481
+ onApprovalEvent: async (payload) => {
1482
+ return await draftPreview.pushApprovalEvent(payload);
1483
+ },
1484
+ onCompactionStart: async () => {
1485
+ if (!abortSignal?.aborted) await reactions.controller.setCompacting();
1486
+ return false;
1487
+ },
1488
+ onCompactionEnd: async () => {
1489
+ if (!abortSignal?.aborted) {
1490
+ reactions.controller.cancelPending();
1491
+ await reactions.controller.setThinking();
1492
+ }
1493
+ return false;
1494
+ }
1495
+ };
1602
1496
  let replyLifecycleStarted = false;
1603
1497
  const onDiscordReplyStart = async () => {
1604
1498
  if (abortSignal?.aborted) return;
@@ -1818,7 +1712,7 @@ async function processDiscordMessage(ctx, observer) {
1818
1712
  allowProgressCallbacksWhenSourceDeliverySuppressed: sourceRepliesAreToolOnly && draftPreview.draftStream && draftPreview.isProgressMode ? true : void 0,
1819
1713
  disableBlockStreaming: sourceRepliesAreToolOnly ? true : draftPreview.disableBlockStreamingForDraft ?? (typeof resolvedBlockStreamingEnabled === "boolean" ? !resolvedBlockStreamingEnabled : void 0),
1820
1714
  onPartialReply: draftPreview.draftStream && !draftPreview.isProgressMode ? (payload) => draftPreview.updateFromPartial(payload.text) : void 0,
1821
- ...progress.replyOptions,
1715
+ ...progressReplyOptions,
1822
1716
  onObservedReplyDelivery: observeFinalDelivery,
1823
1717
  onModelSelected
1824
1718
  }
@@ -1829,7 +1723,7 @@ async function processDiscordMessage(ctx, observer) {
1829
1723
  dispatchAborted = true;
1830
1724
  return;
1831
1725
  }
1832
- if (activeThreadRoute.threadReplyDelivered) await observeFinalDelivery();
1726
+ if (threadReplyDelivered) await observeFinalDelivery();
1833
1727
  } catch (err) {
1834
1728
  if (abortSignal?.aborted) {
1835
1729
  dispatchAborted = true;
@@ -1847,7 +1741,7 @@ async function processDiscordMessage(ctx, observer) {
1847
1741
  }
1848
1742
  throw err;
1849
1743
  } finally {
1850
- activeThreadRoute.end();
1744
+ endActiveThreadRoute();
1851
1745
  endDeliveryCorrelation();
1852
1746
  dispatchError ||= readAgentRunTerminalOutcome(dispatchResult) === "failed";
1853
1747
  const finalReceipt = dispatchResult?.settledReceipt?.counts.final;
@@ -1859,10 +1753,5 @@ async function processDiscordMessage(ctx, observer) {
1859
1753
  finalDeliveryFailed
1860
1754
  });
1861
1755
  }
1862
- if (!dispatchResult || !hasFinalInboundReplyDispatch(dispatchResult)) return;
1863
- if (shouldLogVerbose()) {
1864
- const finalCount = dispatchResult.settledReceipt?.counts.final.delivered ?? 0;
1865
- logVerbose(`discord: delivered ${finalCount} reply${finalCount === 1 ? "" : "ies"} to ${replyPlan.replyTarget}`);
1866
- }
1867
1756
  }
1868
1757
  export { processDiscordMessage };