@openclaw/discord 2026.8.1-beta.2 → 2026.8.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 (289) hide show
  1. package/dist/{account-inspect-CqzrH14k.js → account-inspect-BDfKyuvL.js} +1 -1
  2. package/dist/account-inspect-api.js +1 -1
  3. package/dist/{accounts-DJTf1LtA.js → accounts-CfQ-vSyf.js} +34 -1
  4. package/dist/action-runtime-api.js +1 -1
  5. package/dist/{activities-api-DS7vpdtp.js → activities-api-Dl-TOyOX.js} +134 -175
  6. package/dist/activities-api.js +1 -1
  7. package/dist/api.js +17 -17
  8. package/dist/{approval-handler.runtime-B6yEV79q.js → approval-handler.runtime-q4Zqo44V.js} +29 -106
  9. package/dist/{audit-Db-rlntl.js → audit-DgrvFPGt.js} +5 -5
  10. package/dist/{channel-CnnbJSt5.js → channel-BsQUalPw.js} +72 -50
  11. package/dist/{channel-actions.runtime-CLKrx6tr.js → channel-actions.runtime-UMGGIfSy.js} +31 -45
  12. package/dist/channel-config-api.js +1 -1
  13. package/dist/channel-plugin-api.js +1 -1
  14. package/dist/channel-type-CVLZyGYS.js +7 -0
  15. package/dist/{channel.setup-BFAO-V1P.js → channel.setup-rPs4dsk_.js} +5 -5
  16. package/dist/{outbound-session-route-DxLkrgKQ.js → components-Dk35LTf_.js} +34 -76
  17. package/dist/{config-schema-BgEskFAs.js → config-schema-CxPqtVI1.js} +46 -14
  18. package/dist/conversation-binding-route-BjvX4e35.js +43 -0
  19. package/dist/{directory-config-BVX7Cflc.js → directory-config-B7DY_pNG.js} +2 -2
  20. package/dist/directory-contract-api.js +1 -1
  21. package/dist/{directory-live-DGIGxpIo.js → directory-live-DuAXKkan.js} +3 -3
  22. package/dist/doctor-contract-api.js +2 -2
  23. package/dist/{doctor-BzC-TLnB.js → doctor-zQTtn6hm.js} +33 -12
  24. package/dist/{handle-action.guild-admin-BNVTUISF.js → handle-action.guild-admin-DZewwLr1.js} +9 -5
  25. package/dist/index.js +3 -4
  26. package/dist/ingress-identity-CzZKcPK8.js +60 -0
  27. package/dist/{message-handler-Unk_f10F.js → message-handler-C5By3yl5.js} +82 -6
  28. package/dist/{message-handler.preflight-C9zecxR9.js → message-handler.preflight-DrszWuHw.js} +44 -118
  29. package/dist/{message-handler.process-DWQ6UHHu.js → message-handler.process-DyFPDLCt.js} +205 -235
  30. package/dist/{message-utils-BSCPVgy0.js → message-text-Ca8M6TU8.js} +43 -42
  31. package/dist/{outbound-adapter-D9nRivT1.js → outbound-adapter-Dif8p481.js} +118 -91
  32. package/dist/{outbound-components-cTzwBJ60.js → outbound-components-wjv7yyAj.js} +5 -4
  33. package/dist/outbound-session-route-Bn4uXaoE.js +665 -0
  34. package/dist/owner-access-UlYi9t0M.js +107 -0
  35. package/dist/{pluralkit-DdiJ9KMK.js → pluralkit-9EuEN4UD.js} +1 -1
  36. package/dist/{probe-Bl-k5_Ku.js → probe-n6ZXxK8V.js} +1 -1
  37. package/dist/{probe.runtime-M9fREKvp.js → probe.runtime-CN4bdPfZ.js} +1 -1
  38. package/dist/{provider-DvSNb-2v.js → provider-LXiOcJrH.js} +887 -1350
  39. package/dist/{provider-session.runtime-BUEqD0rA.js → provider-session.runtime-DSNe7r2W.js} +3 -3
  40. package/dist/provider.runtime-DiInaDXO.js +2 -0
  41. package/dist/{realtime-session.runtime-C7wen-aF.js → realtime-session.runtime-DOViOIjY.js} +129 -134
  42. package/dist/{resolve-allowlist-common-D04lpEzb.js → resolve-allowlist-common-BLoYaxEG.js} +2 -2
  43. package/dist/{resolve-channels-Dm7jEeg6.js → resolve-channels-D2yl_2CN.js} +5 -4
  44. package/dist/{resolve-users-bktrCUUU.js → resolve-users-BLxfqajZ.js} +2 -2
  45. package/dist/{retry-CLpJcXXf.js → retry-DqHCW6PV.js} +187 -19
  46. package/dist/{runtime-DGsSyDTS.js → runtime-BYamRVPN.js} +89 -86
  47. package/dist/{runtime-DoHjckYm.js → runtime-DrxVBTtp.js} +9 -10
  48. package/dist/runtime-api.js +19 -25
  49. package/dist/{sdk-runtime-QpY8PvCh.js → sdk-runtime-6tfgYDjY.js} +57 -89
  50. package/dist/{secret-config-contract-B1akrlyY.js → secret-config-contract-B3i6WxV5.js} +53 -25
  51. package/dist/secret-contract-api.js +1 -1
  52. package/dist/{security-audit-jGnJF__m.js → security-audit-DKfK-iPY.js} +11 -12
  53. package/dist/security-audit-contract-api.js +1 -1
  54. package/dist/{security-audit.runtime-CPN0xFYz.js → security-audit.runtime-sKZyKgpx.js} +1 -1
  55. package/dist/{send-B7Q6Oc1I.js → send-UJHiAm4C.js} +82 -19
  56. package/dist/{send.components-iJyFXw9L.js → send.components-CrBJpGT_.js} +22 -39
  57. package/dist/{send.outbound-DS5tHwfR.js → send.outbound-D7JYmfm9.js} +77 -78
  58. package/dist/{send.shared-BmwFjW6T.js → send.shared-DZJ1akvQ.js} +136 -121
  59. package/dist/{sender-identity-QtalnCYv.js → sender-identity-BJtfyise.js} +1 -1
  60. package/dist/setup-plugin-api.js +1 -1
  61. package/dist/{shared-BIXIX6uJ.js → shared-Dii2HTn7.js} +41 -14
  62. package/dist/subagent-hooks-JyGrtQIl.js +49 -0
  63. package/dist/subagent-hooks-api.js +1 -6
  64. package/dist/{system-events-CTqDf6_s.js → system-events-BEmcj4xJ.js} +2 -2
  65. package/dist/{target-resolver-maOKSqO0.js → target-resolver-V-IYae6s.js} +3 -3
  66. package/dist/targets-CQp53cGj.js +3 -0
  67. package/dist/{thread-bindings-3L8p82GV.js → thread-bindings-DvYP79fy.js} +28 -26
  68. package/dist/{thread-bindings.manager-DCIH6WDC.js → thread-bindings.manager-Clm77DBM.js} +11 -14
  69. package/dist/{thread-bindings.session-updates-bJ2KQFY6.js → thread-bindings.session-updates-CJb-BpPL.js} +1 -1
  70. package/dist/{thread-bindings.state-aeV8HNgV.js → thread-bindings.state-D8OMdk4O.js} +1 -1
  71. package/dist/threading-CXuu_7o9.js +478 -0
  72. package/dist/transcripts-source-BLEMH_yi.js +270 -0
  73. package/dist/transcripts-source-api.js +7 -2
  74. package/dist/{typing-CS-nNVoe.js → typing-B9snnwMe.js} +1 -1
  75. package/dist/{voice-runtime-BEdqNcST.js → voice-runtime-DY6_o73o.js} +250 -150
  76. package/node_modules/@discord/embedded-app-sdk/node_modules/uuid/README.md +19 -19
  77. package/node_modules/@discord/embedded-app-sdk/node_modules/uuid/dist/v1.js +7 -3
  78. package/node_modules/@discord/embedded-app-sdk/node_modules/uuid/dist/v7.js +5 -2
  79. package/node_modules/@discord/embedded-app-sdk/node_modules/uuid/dist-node/v1.js +7 -3
  80. package/node_modules/@discord/embedded-app-sdk/node_modules/uuid/dist-node/v7.js +5 -2
  81. package/node_modules/@discord/embedded-app-sdk/node_modules/uuid/package.json +4 -3
  82. package/node_modules/@discordjs/voice/node_modules/@types/node/README.md +1 -1
  83. package/node_modules/@discordjs/voice/node_modules/@types/node/child_process.d.ts +0 -1
  84. package/node_modules/@discordjs/voice/node_modules/@types/node/crypto.d.ts +6 -6
  85. package/node_modules/@discordjs/voice/node_modules/@types/node/dns/promises.d.ts +5 -5
  86. package/node_modules/@discordjs/voice/node_modules/@types/node/dns.d.ts +5 -5
  87. package/node_modules/@discordjs/voice/node_modules/@types/node/fs.d.ts +7 -0
  88. package/node_modules/@discordjs/voice/node_modules/@types/node/http.d.ts +30 -0
  89. package/node_modules/@discordjs/voice/node_modules/@types/node/http2.d.ts +4 -4
  90. package/node_modules/@discordjs/voice/node_modules/@types/node/os.d.ts +30 -30
  91. package/node_modules/@discordjs/voice/node_modules/@types/node/package.json +2 -2
  92. package/node_modules/@discordjs/voice/node_modules/@types/node/perf_hooks.d.ts +2 -1
  93. package/node_modules/@discordjs/voice/node_modules/@types/node/process.d.ts +42 -43
  94. package/node_modules/@discordjs/voice/node_modules/@types/node/quic.d.ts +1049 -84
  95. package/node_modules/@discordjs/voice/node_modules/@types/node/sqlite.d.ts +14 -1
  96. package/node_modules/@discordjs/voice/node_modules/@types/node/stream/iter.d.ts +3 -2
  97. package/node_modules/@discordjs/voice/node_modules/@types/node/test.d.ts +61 -0
  98. package/node_modules/@discordjs/voice/node_modules/@types/node/v8.d.ts +20 -23
  99. package/node_modules/discord-api-types/CHANGELOG.md +8 -0
  100. package/node_modules/discord-api-types/package.json +4 -4
  101. package/node_modules/discord-api-types/payloads/v10/channel.d.ts +2 -2
  102. package/node_modules/discord-api-types/payloads/v10/channel.d.ts.map +1 -1
  103. package/node_modules/discord-api-types/payloads/v10/gateway.d.ts +4 -0
  104. package/node_modules/discord-api-types/payloads/v10/gateway.d.ts.map +1 -1
  105. package/node_modules/discord-api-types/payloads/v10/gateway.js.map +1 -1
  106. package/node_modules/discord-api-types/payloads/v10/message.d.ts +4 -1
  107. package/node_modules/discord-api-types/payloads/v10/message.d.ts.map +1 -1
  108. package/node_modules/discord-api-types/payloads/v10/message.js +1 -0
  109. package/node_modules/discord-api-types/payloads/v10/message.js.map +1 -1
  110. package/node_modules/discord-api-types/payloads/v9/channel.d.ts +2 -2
  111. package/node_modules/discord-api-types/payloads/v9/channel.d.ts.map +1 -1
  112. package/node_modules/discord-api-types/payloads/v9/gateway.d.ts +4 -0
  113. package/node_modules/discord-api-types/payloads/v9/gateway.d.ts.map +1 -1
  114. package/node_modules/discord-api-types/payloads/v9/gateway.js.map +1 -1
  115. package/node_modules/discord-api-types/payloads/v9/message.d.ts +4 -1
  116. package/node_modules/discord-api-types/payloads/v9/message.d.ts.map +1 -1
  117. package/node_modules/discord-api-types/payloads/v9/message.js +1 -0
  118. package/node_modules/discord-api-types/payloads/v9/message.js.map +1 -1
  119. package/node_modules/typebox/build/format/date.d.mts +1 -1
  120. package/node_modules/typebox/build/format/date.mjs +1 -1
  121. package/node_modules/typebox/build/format/date_time.d.mts +2 -2
  122. package/node_modules/typebox/build/format/date_time.mjs +3 -3
  123. package/node_modules/typebox/build/format/email.d.mts +1 -1
  124. package/node_modules/typebox/build/format/email.mjs +2 -2
  125. package/node_modules/typebox/build/format/hostname.mjs +2 -10
  126. package/node_modules/typebox/build/format/idn_email.d.mts +1 -1
  127. package/node_modules/typebox/build/format/idn_email.mjs +3 -3
  128. package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -0
  129. package/node_modules/typebox/build/format/idn_hostname.mjs +3 -11
  130. package/node_modules/typebox/build/format/idna/format/bidi.d.mts +3 -0
  131. package/node_modules/typebox/build/format/idna/format/bidi.mjs +98 -0
  132. package/node_modules/typebox/build/format/idna/format/puny.d.mts +3 -0
  133. package/node_modules/typebox/build/format/idna/format/puny.mjs +144 -0
  134. package/node_modules/typebox/build/format/idna/hostname.d.mts +1 -0
  135. package/node_modules/typebox/build/format/idna/hostname.mjs +16 -0
  136. package/node_modules/typebox/build/format/idna/idn-hostname.d.mts +1 -0
  137. package/node_modules/typebox/build/format/idna/idn-hostname.mjs +23 -0
  138. package/node_modules/typebox/build/format/idna/index.d.mts +2 -0
  139. package/node_modules/typebox/build/format/idna/index.mjs +2 -0
  140. package/node_modules/typebox/build/format/idna/label/ascii.d.mts +1 -0
  141. package/node_modules/typebox/build/format/idna/label/ascii.mjs +9 -0
  142. package/node_modules/typebox/build/format/idna/label/puny.d.mts +1 -0
  143. package/node_modules/typebox/build/format/idna/label/puny.mjs +28 -0
  144. package/node_modules/typebox/build/format/idna/label/unicode.d.mts +1 -0
  145. package/node_modules/typebox/build/format/idna/label/unicode.mjs +106 -0
  146. package/node_modules/typebox/build/format/idna/pattern/pattern.d.mts +30 -0
  147. package/node_modules/typebox/build/format/idna/pattern/pattern.mjs +70 -0
  148. package/node_modules/typebox/build/format/ipv4.d.mts +0 -1
  149. package/node_modules/typebox/build/format/ipv4.mjs +2 -32
  150. package/node_modules/typebox/build/format/ipv6.mjs +2 -61
  151. package/node_modules/typebox/build/format/iri.d.mts +2 -2
  152. package/node_modules/typebox/build/format/iri.mjs +26 -8
  153. package/node_modules/typebox/build/format/iri_reference.d.mts +2 -2
  154. package/node_modules/typebox/build/format/iri_reference.mjs +9 -55
  155. package/node_modules/typebox/build/format/regex.d.mts +1 -2
  156. package/node_modules/typebox/build/format/regex.mjs +2 -6
  157. package/node_modules/typebox/build/format/time.d.mts +2 -2
  158. package/node_modules/typebox/build/format/time.mjs +19 -14
  159. package/node_modules/typebox/build/format/uri.d.mts +1 -1
  160. package/node_modules/typebox/build/format/uri.mjs +3 -130
  161. package/node_modules/typebox/build/format/uri_reference.d.mts +1 -1
  162. package/node_modules/typebox/build/format/uri_reference.mjs +2 -3
  163. package/node_modules/typebox/build/format/uri_template.d.mts +2 -3
  164. package/node_modules/typebox/build/format/uri_template.mjs +4 -5
  165. package/node_modules/typebox/build/format/url.d.mts +3 -3
  166. package/node_modules/typebox/build/format/url.mjs +4 -5
  167. package/node_modules/typebox/build/guard/emit.d.mts +3 -1
  168. package/node_modules/typebox/build/guard/emit.mjs +12 -5
  169. package/node_modules/typebox/build/guard/guard.d.mts +8 -2
  170. package/node_modules/typebox/build/guard/guard.mjs +25 -4
  171. package/node_modules/typebox/build/guard/string.d.mts +2 -2
  172. package/node_modules/typebox/build/guard/string.mjs +7 -7
  173. package/node_modules/typebox/build/schema/engine/_context.mjs +3 -3
  174. package/node_modules/typebox/build/schema/engine/_functions.mjs +1 -2
  175. package/node_modules/typebox/build/schema/engine/_regexp.d.mts +2 -0
  176. package/node_modules/typebox/build/schema/engine/_regexp.mjs +4 -0
  177. package/node_modules/typebox/build/schema/engine/_stack.mjs +12 -13
  178. package/node_modules/typebox/build/schema/engine/additionalItems.mjs +17 -7
  179. package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +4 -3
  180. package/node_modules/typebox/build/schema/engine/contains.mjs +18 -6
  181. package/node_modules/typebox/build/schema/engine/enum.mjs +1 -1
  182. package/node_modules/typebox/build/schema/engine/items.mjs +26 -6
  183. package/node_modules/typebox/build/schema/engine/maxContains.mjs +3 -3
  184. package/node_modules/typebox/build/schema/engine/minContains.mjs +14 -4
  185. package/node_modules/typebox/build/schema/engine/not.mjs +4 -2
  186. package/node_modules/typebox/build/schema/engine/oneOf.mjs +7 -6
  187. package/node_modules/typebox/build/schema/engine/pattern.mjs +3 -2
  188. package/node_modules/typebox/build/schema/engine/patternProperties.mjs +4 -3
  189. package/node_modules/typebox/build/schema/engine/ref.mjs +1 -7
  190. package/node_modules/typebox/build/schema/engine/schema.mjs +13 -4
  191. package/node_modules/typebox/build/schema/engine/type.mjs +1 -1
  192. package/node_modules/typebox/build/schema/resolve/resolve.d.mts +4 -1
  193. package/node_modules/typebox/build/schema/resolve/resolve.mjs +202 -1
  194. package/node_modules/typebox/build/schema/static/propertyNames.d.mts +5 -0
  195. package/node_modules/typebox/build/schema/static/propertyNames.mjs +3 -0
  196. package/node_modules/typebox/build/schema/static/schema.d.mts +3 -0
  197. package/node_modules/typebox/build/schema/types/index.d.mts +0 -2
  198. package/node_modules/typebox/build/schema/types/index.mjs +0 -2
  199. package/node_modules/typebox/build/system/memory/clone.mjs +14 -11
  200. package/node_modules/typebox/build/system/memory/discard.mjs +6 -5
  201. package/node_modules/typebox/build/system/settings/settings.d.mts +9 -0
  202. package/node_modules/typebox/build/system/settings/settings.mjs +2 -0
  203. package/node_modules/typebox/build/type/engine/call/distribute_arguments.d.mts +6 -1
  204. package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +16 -3
  205. package/node_modules/typebox/build/type/engine/call/instantiate.mjs +34 -4
  206. package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +5 -5
  207. package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +20 -26
  208. package/node_modules/typebox/build/type/engine/evaluate/compare.d.mts +6 -10
  209. package/node_modules/typebox/build/type/engine/evaluate/compare.mjs +9 -13
  210. package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +7 -4
  211. package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +12 -19
  212. package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +4 -20
  213. package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +8 -20
  214. package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +4 -4
  215. package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +11 -8
  216. package/node_modules/typebox/build/type/engine/evaluate/flatten.d.mts +1 -1
  217. package/node_modules/typebox/build/type/engine/evaluate/flatten.mjs +3 -4
  218. package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +17 -2
  219. package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +26 -6
  220. package/node_modules/typebox/build/type/engine/exclude/operation.mjs +3 -4
  221. package/node_modules/typebox/build/type/engine/extract/operation.d.mts +1 -1
  222. package/node_modules/typebox/build/type/engine/extract/operation.mjs +3 -4
  223. package/node_modules/typebox/build/type/engine/priority/priority.d.mts +2 -2
  224. package/node_modules/typebox/build/type/engine/priority/priority.mjs +3 -4
  225. package/node_modules/typebox/build/type/script/mapping.d.mts +32 -29
  226. package/node_modules/typebox/build/type/script/mapping.mjs +18 -25
  227. package/node_modules/typebox/build/type/script/parser.d.mts +19 -25
  228. package/node_modules/typebox/build/type/script/parser.mjs +27 -23
  229. package/node_modules/typebox/build/value/errors/errors.d.mts +2 -2
  230. package/node_modules/typebox/build/value/errors/errors.mjs +1 -1
  231. package/node_modules/typebox/package.json +27 -27
  232. package/node_modules/typebox/readme.md +79 -82
  233. package/node_modules/undici/docs/docs/api/Client.md +21 -8
  234. package/node_modules/undici/lib/api/readable.js +33 -43
  235. package/node_modules/undici/lib/core/connect.js +16 -2
  236. package/node_modules/undici/lib/core/symbols.js +1 -0
  237. package/node_modules/undici/lib/dispatcher/client-h1.js +3 -3
  238. package/node_modules/undici/lib/dispatcher/client-h2.js +179 -10
  239. package/node_modules/undici/lib/dispatcher/client.js +74 -29
  240. package/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +28 -6
  241. package/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +15 -1
  242. package/node_modules/undici/lib/handler/retry-handler.js +7 -2
  243. package/node_modules/undici/lib/interceptor/cache.js +5 -2
  244. package/node_modules/undici/lib/interceptor/deduplicate.js +1 -1
  245. package/node_modules/undici/lib/mock/mock-utils.js +213 -24
  246. package/node_modules/undici/lib/util/cache.js +2 -4
  247. package/node_modules/undici/lib/web/websocket/websocket.js +22 -0
  248. package/node_modules/undici/package.json +1 -1
  249. package/node_modules/undici/types/client.d.ts +40 -0
  250. package/node_modules/ws/lib/permessage-deflate.js +3 -1
  251. package/node_modules/ws/package.json +1 -1
  252. package/openclaw.plugin.json +24 -10
  253. package/package.json +8 -10
  254. package/skills/discord/SKILL.md +1 -1
  255. package/dist/approval-message-safety-AcIxvrf3.js +0 -140
  256. package/dist/audit-core-xwjIczO0.js +0 -105
  257. package/dist/channel-actions-5s_hjYKd.js +0 -208
  258. package/dist/channel-api-CAJ0wMoV.js +0 -21
  259. package/dist/inbound-event-delivery-De2qxTrP.js +0 -39
  260. package/dist/provider.runtime-C9PnJZbZ.js +0 -2
  261. package/dist/runtime-api.actions.js +0 -3
  262. package/dist/runtime-api.lookup.js +0 -7
  263. package/dist/runtime-api.monitor-CHxrFPnW.js +0 -5
  264. package/dist/runtime-api.monitor.js +0 -8
  265. package/dist/runtime-api.send.js +0 -7
  266. package/dist/runtime-api.threads.js +0 -5
  267. package/dist/send.reactions-BAn0iiVQ.js +0 -78
  268. package/dist/send.receipt-IPI1p-SP.js +0 -66
  269. package/dist/subagent-hooks-CTt5KCJr.js +0 -120
  270. package/dist/subagent-progress-DhaE_h8a.js +0 -109
  271. package/dist/targets-yUFTHoAx.js +0 -3
  272. package/dist/transcripts-source-CfFMexGt.js +0 -123
  273. package/node_modules/p-map/index.d.ts +0 -155
  274. package/node_modules/p-map/index.js +0 -285
  275. package/node_modules/p-map/license +0 -9
  276. package/node_modules/p-map/package.json +0 -57
  277. package/node_modules/p-map/readme.md +0 -190
  278. package/node_modules/typebox/build/format/_idna.d.mts +0 -2
  279. package/node_modules/typebox/build/format/_idna.mjs +0 -246
  280. package/node_modules/typebox/build/format/_puny.d.mts +0 -1
  281. package/node_modules/typebox/build/format/_puny.mjs +0 -77
  282. package/node_modules/typebox/build/schema/resolve/ref.d.mts +0 -3
  283. package/node_modules/typebox/build/schema/resolve/ref.mjs +0 -146
  284. package/node_modules/typebox/build/schema/types/contentEncoding.d.mts +0 -9
  285. package/node_modules/typebox/build/schema/types/contentEncoding.mjs +0 -13
  286. package/node_modules/typebox/build/schema/types/contentMediaType.d.mts +0 -9
  287. package/node_modules/typebox/build/schema/types/contentMediaType.mjs +0 -13
  288. package/dist/{allow-list-DnxIlPP2.js → allow-list-BDMimASD.js} +1 -1
  289. package/dist/{doctor-contract-DLa-BTiU.js → doctor-contract-DsWvKIXF.js} +1 -1
@@ -1,41 +1,42 @@
1
- import { St as deleteChannelMessage, a as chunkDiscordTextWithMode, h as discord_exports, m as resolveDiscordChannelId, wt as editChannelMessage, yt as createChannelMessage } from "./retry-CLpJcXXf.js";
2
- import { f as resolveDiscordMaxLinesPerMessage } from "./accounts-DJTf1LtA.js";
3
- import { F as createDiscordRestClient, I as createDiscordRuntimeAccountContext, _ as resolveDiscordMessageFlags, d as resolveDiscordTargetChannelId } from "./send.shared-BmwFjW6T.js";
4
- import { C as resolveTimestampMs, a as normalizeDiscordSlug, r as normalizeDiscordAllowList } from "./allow-list-DnxIlPP2.js";
5
- import { i as discordTextHasBroadcastMention } from "./send.outbound-DS5tHwfR.js";
6
- import { c as editMessageDiscord } from "./send-B7Q6Oc1I.js";
1
+ import { Dt as deleteChannelMessage, a as chunkDiscordTextWithMode, kt as editChannelMessage, v as resolveDiscordChannelId, wt as createChannelMessage, y as discord_exports } from "./retry-DqHCW6PV.js";
2
+ import { p as resolveDiscordMaxLinesPerMessage } from "./accounts-CfQ-vSyf.js";
3
+ import { C as resolveTimestampMs, a as normalizeDiscordSlug, r as normalizeDiscordAllowList } from "./allow-list-BDMimASD.js";
4
+ import { F as createDiscordRuntimeAccountContext, P as createDiscordRestClient, d as resolveDiscordTargetChannelId, k as resolveDiscordMessageFlags } from "./send.shared-DZJ1akvQ.js";
5
+ import { i as discordTextHasBroadcastMention } from "./send.outbound-D7JYmfm9.js";
6
+ import { a as removeReactionDiscord, f as editMessageDiscord, r as reactMessageDiscord } from "./send-UJHiAm4C.js";
7
7
  import { n as DISCORD_ATTACHMENT_TOTAL_TIMEOUT_MS, t as DISCORD_ATTACHMENT_IDLE_TIMEOUT_MS } from "./timeouts-B9cy6RvQ.js";
8
- import { i as removeReactionDiscord, n as reactMessageDiscord } from "./send.reactions-BAn0iiVQ.js";
9
- import "./targets-yUFTHoAx.js";
10
- import { r as resolveDiscordConversationIdentity } from "./approval-message-safety-AcIxvrf3.js";
11
- import { t as discordInboundEventDelivery } from "./inbound-event-delivery-De2qxTrP.js";
12
- import { t as DISCORD_TEXT_CHUNK_LIMIT } from "./outbound-adapter-D9nRivT1.js";
13
- import { D as resolveDiscordAutoThreadReplyPlan, _ as buildDiscordInboundAccessContext, a as sanitizeDiscordFrontChannelReplyPayloads, c as resolveReplyContext, i as formatDiscordReplySkip, k as resolveDiscordThreadStarter, n as deliverDiscordReply, o as buildDirectLabel, r as formatDiscordReplyDeliveryFailure, s as buildGuildLabel, v as createDiscordSupplementalContextAccessChecker } from "./provider-DvSNb-2v.js";
14
- import { a as formatDiscordMediaText, c as resolveReferencedReplyMediaList, i as resolveDiscordMessageText, u as resolveDiscordMessageStickers } from "./message-utils-BSCPVgy0.js";
15
- import { n as resolveDiscordWebhookId } from "./sender-identity-QtalnCYv.js";
8
+ import "./targets-CQp53cGj.js";
9
+ import { a as buildDiscordRoutePeer, h as discordInboundEventDelivery, u as resolveDiscordConversationIdentity } from "./outbound-session-route-Bn4uXaoE.js";
10
+ import { t as DISCORD_TEXT_CHUNK_LIMIT } from "./outbound-adapter-Dif8p481.js";
11
+ import { a as formatDiscordReplySkip, c as buildGuildLabel, g as createDiscordSupplementalContextAccessChecker, h as buildDiscordInboundAccessContext, i as formatDiscordReplyDeliveryFailure, l as resolveReplyContext, o as sanitizeDiscordFrontChannelReplyPayloads, r as deliverDiscordReply, s as buildDirectLabel } from "./provider-LXiOcJrH.js";
12
+ import { a as formatDiscordMediaText, c as resolveReferencedReplyMediaList, i as resolveDiscordMessageText, u as resolveDiscordMessageStickers } from "./message-text-Ca8M6TU8.js";
13
+ import { a as resolveDiscordThreadStarter, n as resolveDiscordAutoThreadReplyPlan } from "./threading-CXuu_7o9.js";
14
+ import { n as resolveDiscordWebhookId } from "./sender-identity-BJtfyise.js";
16
15
  import { t as beginDiscordActiveTurnThreadRoute } from "./active-turn-thread-route-fmHl1HNd.js";
17
16
  import { n as filterDiscordHistoryEntriesForContext, t as createDiscordHistorySenderProvenance } from "./message-handler.history-CJOsN9w5.js";
18
- import { t as sendTyping } from "./typing-CS-nNVoe.js";
19
- import { buildAgentSessionKey, resolveThreadSessionKeys } from "openclaw/plugin-sdk/routing";
17
+ import { t as sendTyping } from "./typing-B9snnwMe.js";
20
18
  import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
21
19
  import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
20
+ import { buildAgentSessionKey, resolveThreadSessionKeys } from "openclaw/plugin-sdk/routing";
21
+ import { getReplyPayloadTtsSupplement, isReplyPayloadNonTerminalToolErrorWarning, resolveSendableOutboundReplyParts } from "openclaw/plugin-sdk/reply-payload";
22
22
  import { danger, logVerbose, shouldLogVerbose, sleepWithAbort } from "openclaw/plugin-sdk/runtime-env";
23
23
  import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
24
24
  import { resolveMarkdownTableMode } from "openclaw/plugin-sdk/markdown-table-runtime";
25
25
  import { resolveChunkMode } from "openclaw/plugin-sdk/reply-chunking";
26
26
  import { convertMarkdownTables, stripInlineDirectiveTagsForDelivery, stripReasoningTagsFromText } from "openclaw/plugin-sdk/text-chunking";
27
- import { bindIngressLifecycleToReplyOptions, buildChannelProgressDraftLine, buildChannelProgressDraftLineForEntry, createChannelMessageReplyPipeline, createChannelProgressDraftCompositor, createChannelProgressReceiptTracker, createFinalizableDraftLifecycle, createTypingCallbacks, defineFinalizableLivePreviewAdapter, deliverWithFinalizableLivePreviewAdapter, resolveChannelDraftStreamingChunking, resolveChannelMessageSourceReplyDeliveryMode, resolveChannelPreviewStreamMode, resolveChannelStreamingBlockEnabled, resolveChannelStreamingPreviewCommandText, resolveChannelStreamingPreviewToolProgress, resolveChannelStreamingProgressNarration, resolveChannelStreamingSuppressDefaultToolProgressMessages, resolveTranscriptBackedChannelFinalText } from "openclaw/plugin-sdk/channel-outbound";
27
+ import { bindIngressLifecycleToReplyOptions, buildChannelProgressDraftLine, buildChannelProgressDraftLineForEntry, createChannelMessageReplyPipeline, createChannelProgressDraftCompositor, createFinalizableDraftStreamControlsForState, createTypingCallbacks, defineFinalizableLivePreviewAdapter, deliverWithFinalizableLivePreviewAdapter, resolveChannelDraftStreamingChunking, resolveChannelMessageSourceReplyDeliveryMode, resolveChannelPreviewStreamMode, resolveChannelStreamingBlockEnabled, resolveChannelStreamingPreviewCommandText, resolveChannelStreamingPreviewToolProgress, resolveChannelStreamingProgressNarration, resolveChannelStreamingSuppressDefaultToolProgressMessages, resolveTranscriptBackedChannelFinalText } from "openclaw/plugin-sdk/channel-outbound";
28
28
  import { getAgentScopedMediaLocalRoots } from "openclaw/plugin-sdk/media-runtime";
29
- import { getReplyPayloadTtsSupplement, isReplyPayloadNonTerminalToolErrorWarning, resolveSendableOutboundReplyParts } from "openclaw/plugin-sdk/reply-payload";
30
29
  import { evaluateSupplementalContextVisibility } from "openclaw/plugin-sdk/security-runtime";
31
30
  import { resolvePinnedMainDmOwnerFromAllowlist } from "openclaw/plugin-sdk/conversation-runtime";
32
- import { EmbeddedBlockChunker, resolveAckReaction, resolveAgentConfig, resolveHumanDelayConfig } from "openclaw/plugin-sdk/agent-runtime";
31
+ import { resolveAgentConfig } from "openclaw/plugin-sdk/agent-scope-runtime";
32
+ import { EmbeddedBlockChunker, resolveAckReaction, resolveAgentConfig as resolveAgentConfig$1, resolveHumanDelayConfig } from "openclaw/plugin-sdk/agent-runtime";
33
33
  import { isDangerousNameMatchingEnabled } from "openclaw/plugin-sdk/dangerous-name-runtime";
34
- import { buildChannelInboundEventContext, dispatchChannelInboundTurn, formatInboundEnvelope, formatInboundMediaUnavailableText, hasFinalInboundReplyDispatch, readAgentRunTerminalOutcome, resolveEnvelopeFormatOptions, toHistoryMediaEntries, toInboundMediaFactsWithMetadata } from "openclaw/plugin-sdk/channel-inbound";
35
34
  import { getSessionEntry, readSessionUpdatedAt, resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
35
+ import { buildChannelInboundEventContext, createCommandTurnContext, dispatchChannelInboundTurn, formatInboundEnvelope, formatInboundMediaUnavailableText, hasFinalInboundReplyDispatch, readAgentRunTerminalOutcome, resolveEnvelopeFormatOptions, toHistoryMediaEntries, toInboundMediaFactsWithMetadata } from "openclaw/plugin-sdk/channel-inbound";
36
36
  import { getGlobalHookRunner } from "openclaw/plugin-sdk/plugin-runtime";
37
37
  import { buildHistoryContextFromEntries, buildInboundHistoryFromEntries, createChannelHistoryWindow } from "openclaw/plugin-sdk/reply-history";
38
38
  import { resolveChannelContextVisibilityMode } from "openclaw/plugin-sdk/context-visibility-runtime";
39
+ import { formatAudioTranscriptForAgent } from "openclaw/plugin-sdk/media-understanding-runtime";
39
40
  import { DEFAULT_TIMING, createStatusReactionController, logAckFailure, logTypingFailure, shouldAckReaction } from "openclaw/plugin-sdk/channel-feedback";
40
41
  import { readLatestAssistantTextByIdentity } from "openclaw/plugin-sdk/session-transcript-runtime";
41
42
  //#region extensions/discord/src/monitor/message-handler.retry.ts
@@ -78,7 +79,7 @@ function isContextAborted(abortSignal) {
78
79
  }
79
80
  async function buildDiscordMessageProcessContext(params) {
80
81
  const { ctx, text, mediaList } = params;
81
- const { cfg, discordConfig, accountId, runtime, botUserId, mediaMaxBytes, discordRestFetch, abortSignal, guildHistories, historyLimit, replyToMode, message, author, sender, canonicalMessageId, data, client, channelInfo, channelName, messageChannelId, isGuildMessage, isDirectMessage, baseText, preflightAudioTranscript, threadChannel, threadParentId, threadParentName, threadParentType, threadName, displayChannelSlug, guildInfo, guildSlug, memberRoleIds, channelConfig, baseSessionKey, boundSessionKey, route, commandAuthorized, resolveChannelIngress } = ctx;
82
+ const { cfg, discordConfig, accountId, runtime, botUserId, mediaMaxBytes, discordRestFetch, abortSignal, guildHistories, historyLimit, replyToMode, message, author, sender, canonicalMessageId, data, client, channelInfo, channelName, messageChannelId, isGuildMessage, isDirectMessage, isGroupDm, baseText, preflightAudioTranscript, threadChannel, threadParentId, threadParentName, threadParentType, threadName, displayChannelSlug, guildInfo, guildSlug, memberRoleIds, channelConfig, baseSessionKey, boundSessionKey, route, commandAuthorized, hasControlCommand, resolveChannelIngress } = ctx;
82
83
  const fromLabel = isDirectMessage ? buildDirectLabel(author) : buildGuildLabel({
83
84
  guild: data.guild ?? void 0,
84
85
  channelName: channelName ?? messageChannelId,
@@ -135,6 +136,7 @@ async function buildDiscordMessageProcessContext(params) {
135
136
  notice: `[discord ${unavailableMediaCount > 1 ? `${unavailableMediaCount} attachments` : "attachment"} unavailable]`
136
137
  }) : body;
137
138
  const bodyWithMediaNotice = appendMediaUnavailableNotice(text) ?? text;
139
+ const agentFacingBody = preflightAudioTranscript !== void 0 ? formatAudioTranscriptForAgent(preflightAudioTranscript) : baseText ?? text;
138
140
  let combinedBody = formatInboundEnvelope({
139
141
  channel: "Discord",
140
142
  from: fromLabel,
@@ -195,6 +197,7 @@ async function buildDiscordMessageProcessContext(params) {
195
197
  const starter = await resolveDiscordThreadStarter({
196
198
  channel: threadChannel,
197
199
  client,
200
+ accountId,
198
201
  parentId: threadParentId,
199
202
  parentType: threadParentType,
200
203
  resolveTimestampMs
@@ -216,15 +219,17 @@ async function buildDiscordMessageProcessContext(params) {
216
219
  if (threadParentId) {
217
220
  parentSessionKey = buildAgentSessionKey({
218
221
  agentId: route.agentId,
222
+ mainKey: cfg.session?.mainKey,
219
223
  channel: route.channel,
220
224
  peer: {
221
225
  kind: "channel",
222
226
  id: threadParentId
223
- }
227
+ },
228
+ groupScope: route.groupScope
224
229
  });
225
- modelParentSessionKey = parentSessionKey;
230
+ modelParentSessionKey = parentSessionKey === baseSessionKey ? void 0 : parentSessionKey;
226
231
  }
227
- if (!threadParentInheritanceEnabled) parentSessionKey = void 0;
232
+ parentSessionKey = threadParentInheritanceEnabled ? modelParentSessionKey : void 0;
228
233
  }
229
234
  const preflightAudioIndex = preflightAudioTranscript === void 0 ? -1 : mediaList.findIndex((media) => media.contentType?.startsWith("audio/"));
230
235
  const threadKeys = resolveThreadSessionKeys({
@@ -249,12 +254,15 @@ async function buildDiscordMessageProcessContext(params) {
249
254
  agentId: route.agentId,
250
255
  channel: route.channel,
251
256
  cfg,
257
+ parentSessionKey: route.sessionKey,
258
+ groupScope: route.groupScope,
252
259
  threadParentInheritanceEnabled
253
260
  });
254
261
  const deliverTarget = replyPlan.deliverTarget;
255
262
  const replyTarget = replyPlan.replyTarget;
256
263
  const replyReference = replyPlan.replyReference;
257
264
  const autoThreadContext = replyPlan.autoThreadContext;
265
+ const conversationParentId = threadChannel ? threadParentId : autoThreadContext ? messageChannelId : void 0;
258
266
  const effectiveFrom = isDirectMessage ? `discord:${author.id}` : autoThreadContext?.From ?? `discord:channel:${messageChannelId}`;
259
267
  const dmConversationTarget = isDirectMessage ? resolveDiscordConversationIdentity({
260
268
  isDirectMessage,
@@ -282,7 +290,7 @@ async function buildDiscordMessageProcessContext(params) {
282
290
  messageId: canonicalMessageId ?? message.id,
283
291
  inboundEventKind: ctx.inboundEventKind
284
292
  }, {
285
- parentId: threadChannel ? threadParentId : void 0,
293
+ parentId: conversationParentId,
286
294
  threadId: threadChannel?.id ?? autoThreadContext?.createdThreadId ?? void 0
287
295
  });
288
296
  const ctxPayload = await (ctx.buildContext ?? buildChannelInboundEventContext)({
@@ -305,12 +313,19 @@ async function buildDiscordMessageProcessContext(params) {
305
313
  isBot: author.bot && !sender.isPluralKit ? true : void 0
306
314
  },
307
315
  conversation: {
308
- kind: isDirectMessage ? "direct" : "channel",
316
+ kind: isGroupDm ? "group" : isDirectMessage ? "direct" : "channel",
309
317
  id: messageChannelId,
318
+ routePeer: buildDiscordRoutePeer({
319
+ isDirectMessage,
320
+ isGroupDm,
321
+ directUserId: author.id,
322
+ conversationId: messageChannelId
323
+ }),
310
324
  nativeChannelId: messageChannelId,
325
+ avatar: ctx.conversationAvatar,
311
326
  label: fromLabel,
312
- spaceId: isGuildMessage ? (guildInfo?.id ?? guildSlug) || void 0 : void 0,
313
- parentId: threadChannel ? threadParentId : void 0,
327
+ spaceId: isGuildMessage ? (guildInfo?.id ?? data.guild?.id ?? data.guild_id ?? guildSlug) || void 0 : void 0,
328
+ parentId: conversationParentId,
314
329
  threadId: threadChannel?.id ?? autoThreadContext?.createdThreadId ?? void 0
315
330
  },
316
331
  route: {
@@ -329,9 +344,9 @@ async function buildDiscordMessageProcessContext(params) {
329
344
  message: {
330
345
  inboundEventKind: ctx.inboundEventKind,
331
346
  body: combinedBody,
332
- rawBody: preflightAudioTranscript ?? baseText,
333
- bodyForAgent: appendMediaUnavailableNotice(preflightAudioTranscript ?? baseText ?? text),
334
- commandBody: preflightAudioTranscript ?? baseText,
347
+ rawBody: baseText,
348
+ bodyForAgent: appendMediaUnavailableNotice(agentFacingBody),
349
+ commandBody: baseText,
335
350
  inboundHistory
336
351
  },
337
352
  sessionTranscript: { historyLimit: shouldIncludeChannelHistory ? historyLimit : 0 },
@@ -345,12 +360,10 @@ async function buildDiscordMessageProcessContext(params) {
345
360
  },
346
361
  commands: { authorized: commandAuthorized }
347
362
  },
348
- commandTurn: {
349
- kind: "text-slash",
350
- source: "text",
363
+ commandTurn: createCommandTurnContext(hasControlCommand ? "text" : "message", {
351
364
  authorized: commandAuthorized,
352
- body: preflightAudioTranscript ?? baseText
353
- },
365
+ body: baseText
366
+ }),
354
367
  media: await toInboundMediaFactsWithMetadata(mediaList, { transcribed: (_media, index) => index === preflightAudioIndex }),
355
368
  supplemental: {
356
369
  quote: replyContext && replyVisible ? {
@@ -367,7 +380,7 @@ async function buildDiscordMessageProcessContext(params) {
367
380
  totalTimeoutMs: DISCORD_ATTACHMENT_TOTAL_TIMEOUT_MS,
368
381
  abortSignal
369
382
  });
370
- return isContextAborted(abortSignal) ? [] : await toInboundMediaFactsWithMetadata(referencedReplyMediaList);
383
+ return isContextAborted(abortSignal) ? [] : await toInboundMediaFactsWithMetadata(referencedReplyMediaList, { messageId: replyContext.id });
371
384
  }
372
385
  } : void 0,
373
386
  thread: {
@@ -455,8 +468,7 @@ function createDiscordMessageProgressRuntime(params) {
455
468
  const { ctx, draftPreview } = params;
456
469
  const { cfg, route, abortSignal } = ctx;
457
470
  const reasoningLevel = (() => {
458
- const normalizedAgentId = (route.agentId ?? "").trim().toLowerCase() || "main";
459
- const cfgDefault = cfg.agents?.list?.find((entry) => ((entry?.id ?? "").trim().toLowerCase() || "main") === normalizedAgentId)?.reasoningDefault ?? cfg.agents?.defaults?.reasoningDefault;
471
+ const cfgDefault = resolveAgentConfig(cfg, route.agentId ?? "main")?.reasoningDefault ?? cfg.agents?.defaults?.reasoningDefault;
460
472
  const configDefault = cfgDefault === "on" || cfgDefault === "stream" ? cfgDefault : "off";
461
473
  if (!params.sessionKey) return configDefault;
462
474
  try {
@@ -475,103 +487,84 @@ function createDiscordMessageProgressRuntime(params) {
475
487
  const reasoningDurableEnabled = reasoningLevel === "on";
476
488
  const reasoningWindowEnabled = reasoningLevel === "stream";
477
489
  let shouldYieldDraftCommentary = () => false;
478
- const progressReceipt = createChannelProgressReceiptTracker();
479
- const resetTurnState = () => {
480
- progressReceipt.reset();
481
- };
482
490
  const handleAssistantMessageBoundary = () => {
483
- if (draftPreview.handleAssistantMessageBoundary()) {
484
- resetTurnState();
485
- params.onTurnReset();
486
- }
491
+ if (draftPreview.handleAssistantMessageBoundary()) params.onTurnReset();
487
492
  };
488
- const buildProgressSummaryLine = () => `-# ${progressReceipt.buildSummaryLine()}`;
489
- return {
490
- replyOptions: {
491
- onAssistantMessageStart: draftPreview.draftStream ? () => {
492
- handleAssistantMessageBoundary();
493
- return false;
494
- } : void 0,
495
- onReasoningEnd: draftPreview.draftStream ? () => {
496
- progressReceipt.closeReasoning();
497
- handleAssistantMessageBoundary();
498
- return false;
499
- } : void 0,
500
- onQueuedFollowupAdmitted: draftPreview.draftStream ? () => {
501
- if (draftPreview.handleQueuedFollowupAdmitted()) {
502
- resetTurnState();
503
- params.onTurnReset();
504
- }
505
- } : void 0,
506
- suppressDefaultToolProgressMessages: params.sourceRepliesAreToolOnly && params.reactions.statusReactionsExplicitlyEnabled || draftPreview.suppressDefaultToolProgressMessages ? true : void 0,
507
- allowToolLifecycleWhenProgressHidden: params.reactions.statusReactionsEnabled ? true : void 0,
508
- commentaryProgressEnabled: draftPreview.isProgressMode ? draftPreview.commentaryProgressEnabled : void 0,
509
- progressPreambleEnabled: draftPreview.draftStream && draftPreview.isProgressMode ? true : void 0,
510
- commentaryPayloadsEnabled: draftPreview.isProgressMode ? draftPreview.commentaryProgressEnabled : void 0,
511
- shouldDeliverCommentaryPayloads: draftPreview.isProgressMode && draftPreview.commentaryProgressEnabled ? () => shouldYieldDraftCommentary() : void 0,
512
- reasoningPayloadsEnabled: reasoningDurableEnabled,
513
- onVerboseProgressVisibility: (isActive) => {
514
- shouldYieldDraftCommentary = isActive;
515
- },
516
- onNarrationUpdate: draftPreview.narrationProgressEnabled ? async (payload) => {
517
- if (isProcessAborted$1(abortSignal) || shouldYieldDraftCommentary()) return;
518
- await draftPreview.pushNarrationProgress(payload.text);
519
- } : void 0,
520
- onProgressNarratorLifecycle: draftPreview.narrationProgressEnabled ? (lifecycle) => draftPreview.setProgressNarratorLifecycle(lifecycle) : void 0,
521
- isProgressDraftVisible: draftPreview.narrationProgressEnabled ? () => draftPreview.isProgressDraftVisible : void 0,
522
- narrationHideCommandText: draftPreview.narrationHideCommandText ? true : void 0,
523
- onReasoningStream: async (payload) => {
524
- if (payload?.requiresReasoningProgressOptIn === true && !reasoningWindowEnabled) return false;
525
- if (payload?.text) progressReceipt.noteReasoning();
526
- await params.reactions.controller.setThinking();
527
- return await draftPreview.pushReasoningProgress(payload?.text, { snapshot: payload?.isReasoningSnapshot === true });
528
- },
529
- streamReasoningInNonStreamModes: reasoningWindowEnabled,
530
- onToolStart: async (payload) => {
531
- if (isProcessAborted$1(abortSignal)) return false;
532
- await params.reactions.maybeBindToToolReaction(payload);
533
- await params.reactions.controller.setTool(payload.name);
534
- if (payload.phase === "start") progressReceipt.noteToolCall(payload.name);
535
- return await draftPreview.pushToolEvent(payload);
536
- },
537
- onItemEvent: async (payload) => {
538
- if (isFailedProgress(payload)) return false;
539
- if (payload.kind === "preamble") {
540
- if (shouldYieldDraftCommentary()) return;
541
- return await draftPreview.pushPreambleItemEvent(payload, (itemId, text) => {
542
- progressReceipt.noteCommentary(itemId, text);
543
- });
544
- }
545
- return await draftPreview.pushItemEvent(payload);
546
- },
547
- onPlanUpdate: async (payload) => {
548
- if (payload.phase === "update") return await draftPreview.pushPlanProgress(payload.steps, { explanation: payload.explanation });
549
- return false;
550
- },
551
- onApprovalEvent: async (payload) => {
552
- return await draftPreview.pushApprovalEvent(payload);
553
- },
554
- onCommandOutput: async (payload) => {
555
- if (isFailedProgress(payload)) return false;
556
- return await draftPreview.pushCommandOutputEvent(payload);
557
- },
558
- onPatchSummary: async (payload) => {
559
- return await draftPreview.pushPatchEvent(payload);
560
- },
561
- onCompactionStart: async () => {
562
- if (!isProcessAborted$1(abortSignal)) await params.reactions.controller.setCompacting();
563
- return false;
564
- },
565
- onCompactionEnd: async () => {
566
- if (!isProcessAborted$1(abortSignal)) {
567
- params.reactions.controller.cancelPending();
568
- await params.reactions.controller.setThinking();
569
- }
570
- return false;
493
+ return { replyOptions: {
494
+ onAssistantMessageStart: draftPreview.draftStream ? () => {
495
+ handleAssistantMessageBoundary();
496
+ return false;
497
+ } : void 0,
498
+ onReasoningEnd: draftPreview.draftStream ? () => {
499
+ handleAssistantMessageBoundary();
500
+ return false;
501
+ } : void 0,
502
+ onQueuedFollowupAdmitted: draftPreview.draftStream ? () => {
503
+ if (draftPreview.handleQueuedFollowupAdmitted()) params.onTurnReset();
504
+ } : void 0,
505
+ suppressDefaultToolProgressMessages: params.sourceRepliesAreToolOnly && params.reactions.statusReactionsExplicitlyEnabled || draftPreview.suppressDefaultToolProgressMessages ? true : void 0,
506
+ allowToolLifecycleWhenProgressHidden: params.reactions.statusReactionsEnabled ? true : void 0,
507
+ commentaryProgressEnabled: draftPreview.isProgressMode ? draftPreview.commentaryProgressEnabled : void 0,
508
+ progressPreambleEnabled: draftPreview.draftStream && draftPreview.isProgressMode ? true : void 0,
509
+ commentaryPayloadsEnabled: draftPreview.isProgressMode ? draftPreview.commentaryProgressEnabled : void 0,
510
+ shouldDeliverCommentaryPayloads: draftPreview.isProgressMode && draftPreview.commentaryProgressEnabled ? () => shouldYieldDraftCommentary() : void 0,
511
+ reasoningPayloadsEnabled: reasoningDurableEnabled,
512
+ onVerboseProgressVisibility: (isActive) => {
513
+ shouldYieldDraftCommentary = isActive;
514
+ },
515
+ onNarrationUpdate: draftPreview.narrationProgressEnabled ? async (payload) => {
516
+ if (isProcessAborted$1(abortSignal) || shouldYieldDraftCommentary()) return;
517
+ await draftPreview.pushNarrationProgress(payload.text);
518
+ } : void 0,
519
+ onProgressNarratorLifecycle: draftPreview.narrationProgressEnabled ? (lifecycle) => draftPreview.setProgressNarratorLifecycle(lifecycle) : void 0,
520
+ isProgressDraftVisible: draftPreview.narrationProgressEnabled ? () => draftPreview.isProgressDraftVisible : void 0,
521
+ narrationHideCommandText: draftPreview.narrationHideCommandText ? true : void 0,
522
+ onReasoningStream: async (payload) => {
523
+ if (payload?.requiresReasoningProgressOptIn === true && !reasoningWindowEnabled) return false;
524
+ await params.reactions.controller.setThinking();
525
+ return await draftPreview.pushReasoningProgress(payload?.text, { snapshot: payload?.isReasoningSnapshot === true });
526
+ },
527
+ streamReasoningInNonStreamModes: reasoningWindowEnabled,
528
+ onToolStart: async (payload) => {
529
+ if (isProcessAborted$1(abortSignal)) return false;
530
+ await params.reactions.maybeBindToToolReaction(payload);
531
+ await params.reactions.controller.setTool(payload.name);
532
+ return await draftPreview.pushToolEvent(payload);
533
+ },
534
+ onItemEvent: async (payload) => {
535
+ if (isFailedProgress(payload)) return false;
536
+ if (payload.kind === "preamble") {
537
+ if (shouldYieldDraftCommentary()) return;
538
+ return await draftPreview.pushPreambleItemEvent(payload);
571
539
  }
540
+ return await draftPreview.pushItemEvent(payload);
572
541
  },
573
- buildProgressSummaryLine
574
- };
542
+ onPlanUpdate: async (payload) => {
543
+ if (payload.phase === "update") return await draftPreview.pushPlanProgress(payload.steps, { explanation: payload.explanation });
544
+ return false;
545
+ },
546
+ onApprovalEvent: async (payload) => {
547
+ return await draftPreview.pushApprovalEvent(payload);
548
+ },
549
+ onCommandOutput: async (payload) => {
550
+ if (isFailedProgress(payload)) return false;
551
+ return await draftPreview.pushCommandOutputEvent(payload);
552
+ },
553
+ onPatchSummary: async (payload) => {
554
+ return await draftPreview.pushPatchEvent(payload);
555
+ },
556
+ onCompactionStart: async () => {
557
+ if (!isProcessAborted$1(abortSignal)) await params.reactions.controller.setCompacting();
558
+ return false;
559
+ },
560
+ onCompactionEnd: async () => {
561
+ if (!isProcessAborted$1(abortSignal)) {
562
+ params.reactions.controller.cancelPending();
563
+ await params.reactions.controller.setThinking();
564
+ }
565
+ return false;
566
+ }
567
+ } };
575
568
  }
576
569
  //#endregion
577
570
  //#region extensions/discord/src/monitor/ack-reactions.ts
@@ -798,7 +791,7 @@ function createDiscordDraftStream(params) {
798
791
  let streamGeneration = 0;
799
792
  let activeCreateGeneration;
800
793
  let discardActiveCreate = false;
801
- let retargetedCleanup = [];
794
+ let pendingCleanupMessages = [];
802
795
  const sendOrEditStreamMessage = async (text) => {
803
796
  const generation = streamGeneration;
804
797
  if (streamState.stopped && !streamState.final) return false;
@@ -839,11 +832,11 @@ function createDiscordDraftStream(params) {
839
832
  activeCreateGeneration = void 0;
840
833
  discardActiveCreate = false;
841
834
  if (generation !== streamGeneration) {
842
- if (shouldDiscardStaleCreate && typeof sentMessageId === "string" && sentMessageId) try {
843
- await deleteChannelMessage(rest, channelId, sentMessageId);
844
- } catch (err) {
845
- params.warn?.(`discord stale stream preview cleanup failed: ${formatErrorMessage(err)}`);
846
- }
835
+ if (shouldDiscardStaleCreate && typeof sentMessageId === "string" && sentMessageId) await deleteCleanupMessage({
836
+ channelId,
837
+ messageId: sentMessageId,
838
+ warnPrefix: "discord stale stream preview cleanup failed"
839
+ });
847
840
  return true;
848
841
  }
849
842
  if (typeof sentMessageId !== "string" || !sentMessageId) {
@@ -864,24 +857,10 @@ function createDiscordDraftStream(params) {
864
857
  return false;
865
858
  }
866
859
  };
867
- const readMessageId = () => streamMessageId;
868
- const clearMessageId = () => {
869
- streamMessageId = void 0;
870
- };
871
- const isValidStreamMessageId = (value) => typeof value === "string";
872
- const deleteStreamMessage = async (messageId) => {
873
- await deleteChannelMessage(rest, channelId, messageId);
874
- };
875
- const { loop, update, stop, clear, discardPending, seal } = createFinalizableDraftLifecycle({
860
+ const { loop, update, stop, discardPending, seal } = createFinalizableDraftStreamControlsForState({
876
861
  throttleMs,
877
862
  state: streamState,
878
- sendOrEditStreamMessage,
879
- readMessageId,
880
- clearMessageId,
881
- isValidMessageId: isValidStreamMessageId,
882
- deleteMessage: deleteStreamMessage,
883
- warn: params.warn,
884
- warnPrefix: "discord stream preview cleanup failed"
863
+ sendOrEditStreamMessage
885
864
  });
886
865
  const forceNewMessage = (mode = "preserve") => {
887
866
  if (mode === "discard" && activeCreateGeneration !== void 0) discardActiveCreate = true;
@@ -893,16 +872,19 @@ function createDiscordDraftStream(params) {
893
872
  loop.resetPending();
894
873
  loop.resetThrottleWindow();
895
874
  };
896
- const cleanupRetargeted = async () => {
897
- const pending = retargetedCleanup;
898
- retargetedCleanup = [];
899
- for (const stale of pending) try {
900
- await deleteChannelMessage(rest, stale.channelId, stale.messageId);
875
+ const deleteCleanupMessage = async (message) => {
876
+ try {
877
+ await deleteChannelMessage(rest, message.channelId, message.messageId);
901
878
  } catch (err) {
902
- retargetedCleanup.push(stale);
903
- params.warn?.(`discord stream preview retarget cleanup failed: ${formatErrorMessage(err)}`);
879
+ pendingCleanupMessages.push(message);
880
+ params.warn?.(`${message.warnPrefix}: ${formatErrorMessage(err)}`);
904
881
  }
905
882
  };
883
+ const cleanupPendingMessages = async () => {
884
+ const pending = pendingCleanupMessages;
885
+ pendingCleanupMessages = [];
886
+ for (const message of pending) await deleteCleanupMessage(message);
887
+ };
906
888
  const retarget = async (nextChannelId) => {
907
889
  const normalized = nextChannelId.trim();
908
890
  if (!normalized || normalized === channelId) return;
@@ -925,33 +907,33 @@ function createDiscordDraftStream(params) {
925
907
  if (previousMessageId) {
926
908
  const stale = {
927
909
  channelId: previousChannelId,
928
- messageId: previousMessageId
910
+ messageId: previousMessageId,
911
+ warnPrefix: "discord stream preview retarget cleanup failed"
929
912
  };
930
913
  if (!streamMessageId) {
931
- retargetedCleanup.push(stale);
914
+ pendingCleanupMessages.push(stale);
932
915
  throw new Error("discord stream preview retarget replacement failed");
933
916
  }
934
- try {
935
- await deleteChannelMessage(rest, previousChannelId, previousMessageId);
936
- } catch (err) {
937
- retargetedCleanup.push(stale);
938
- params.warn?.(`discord stream preview retarget cleanup failed: ${formatErrorMessage(err)}`);
939
- }
917
+ await deleteCleanupMessage(stale);
940
918
  }
941
919
  };
942
920
  const deleteCurrentMessage = async () => {
943
921
  loop.resetPending();
944
922
  await loop.waitForInFlight();
945
- const messageId = streamMessageId;
923
+ const currentMessage = streamMessageId ? {
924
+ channelId,
925
+ messageId: streamMessageId,
926
+ warnPrefix: "discord stream preview cleanup failed"
927
+ } : void 0;
946
928
  streamMessageId = void 0;
947
929
  lastSentText = "";
948
930
  loop.resetThrottleWindow();
949
- if (!isValidStreamMessageId(messageId)) return;
950
- try {
951
- await deleteStreamMessage(messageId);
952
- } catch (err) {
953
- params.warn?.(`discord stream preview cleanup failed: ${formatErrorMessage(err)}`);
954
- }
931
+ if (!currentMessage) return;
932
+ await deleteCleanupMessage(currentMessage);
933
+ };
934
+ const clear = async () => {
935
+ await discardPending();
936
+ await deleteCurrentMessage();
955
937
  };
956
938
  params.log?.(`discord stream preview ready (maxChars=${maxChars}, throttleMs=${throttleMs})`);
957
939
  return {
@@ -964,7 +946,7 @@ function createDiscordDraftStream(params) {
964
946
  seal,
965
947
  stop,
966
948
  retarget,
967
- cleanupRetargeted,
949
+ cleanupPendingMessages,
968
950
  forceNewMessage
969
951
  };
970
952
  }
@@ -1004,7 +986,7 @@ function createDiscordDraftPreviewController(params) {
1004
986
  let draftText = "";
1005
987
  let hasStreamedMessage = false;
1006
988
  let finalizedViaPreviewMessage = false;
1007
- let finalReplyDelivered = false;
989
+ let finalReplyError;
1008
990
  let progressDraftStartedBeforeFinal = false;
1009
991
  let progressDraftCollapsed = false;
1010
992
  let progressNarratorLifecycle;
@@ -1067,7 +1049,7 @@ function createDiscordDraftPreviewController(params) {
1067
1049
  if (beganNewTurn) {
1068
1050
  progressDraftCollapsed = false;
1069
1051
  progressDraftStartedBeforeFinal = false;
1070
- finalReplyDelivered = false;
1052
+ finalReplyError = void 0;
1071
1053
  finalizedViaPreviewMessage = false;
1072
1054
  progressNarratorLifecycle?.beginTurn();
1073
1055
  }
@@ -1110,8 +1092,8 @@ function createDiscordDraftPreviewController(params) {
1110
1092
  progressDraft.markFinalReplyStarted();
1111
1093
  progressNarratorLifecycle?.stopTurn();
1112
1094
  },
1113
- markFinalReplyDelivered() {
1114
- finalReplyDelivered = true;
1095
+ markFinalReplyDelivered(isError = false) {
1096
+ finalReplyError = isError;
1115
1097
  progressDraft.markFinalReplyDelivered();
1116
1098
  },
1117
1099
  markPreviewFinalized() {
@@ -1120,14 +1102,11 @@ function createDiscordDraftPreviewController(params) {
1120
1102
  async retarget(channelId) {
1121
1103
  await draftStream?.retarget(channelId);
1122
1104
  },
1123
- async finalizeProgressReceipt(receiptLine) {
1105
+ async finalizeProgressDraft() {
1124
1106
  if (!draftStream || discordStreamMode !== "progress") return false;
1125
- const receipt = receiptLine.trim();
1126
- if (!receipt) return false;
1127
1107
  const progressText = lastPartialText.trimEnd();
1128
- const maxProgressChars = Math.max(0, draftMaxChars - receipt.length - 1);
1129
- const fittedProgressText = progressText.length > maxProgressChars ? progressText.slice(progressText.length - maxProgressChars).trimStart() : progressText;
1130
- draftStream.update(fittedProgressText ? `${fittedProgressText}\n${receipt}` : receipt);
1108
+ if (!progressText) return false;
1109
+ draftStream.update(progressText);
1131
1110
  await draftStream.stop();
1132
1111
  if (!draftStream.messageId()) return false;
1133
1112
  finalizedViaPreviewMessage = true;
@@ -1152,11 +1131,10 @@ function createDiscordDraftPreviewController(params) {
1152
1131
  return await progressDraft.pushNarrationProgress(text);
1153
1132
  },
1154
1133
  pushPreambleHeadline,
1155
- async pushPreambleItemEvent(payload, noteCommentary) {
1134
+ async pushPreambleItemEvent(payload) {
1156
1135
  const headlineAccepted = await pushPreambleHeadline(payload.progressText, { itemId: payload.itemId });
1157
1136
  if (!progressDraft.commentaryProgressEnabled) return headlineAccepted;
1158
1137
  const commentaryAccepted = await progressDraft.pushCommentaryProgress(payload.progressText, { itemId: payload.itemId });
1159
- if (commentaryAccepted) noteCommentary(payload.itemId, payload.progressText);
1160
1138
  return headlineAccepted || commentaryAccepted;
1161
1139
  },
1162
1140
  async pushCommentaryProgress(text, options) {
@@ -1240,9 +1218,9 @@ function createDiscordDraftPreviewController(params) {
1240
1218
  async cleanup() {
1241
1219
  try {
1242
1220
  progressDraft.cancel();
1243
- if (!finalReplyDelivered) await draftStream?.discardPending();
1244
- if (!finalizedViaPreviewMessage && draftStream?.messageId()) await draftStream.clear();
1245
- await draftStream?.cleanupRetargeted();
1221
+ if (finalReplyError !== false) await draftStream?.discardPending();
1222
+ if (finalReplyError !== true && !finalizedViaPreviewMessage && draftStream?.messageId()) await draftStream.clear();
1223
+ await draftStream?.cleanupPendingMessages();
1246
1224
  } catch (err) {
1247
1225
  params.log(`discord: draft cleanup failed: ${String(err)}`);
1248
1226
  }
@@ -1411,16 +1389,6 @@ function createDiscordMessageReplyRuntime(params) {
1411
1389
  }
1412
1390
  //#endregion
1413
1391
  //#region extensions/discord/src/monitor/message-handler.process-thread-route.ts
1414
- async function finalizeDiscordAdoptedThreadProgressReceipt(hasProgressDraft, receipt, finalizeDraft, deliverReceipt, onFinalizeError) {
1415
- const receiptLine = receipt.trim();
1416
- if (!hasProgressDraft || !receiptLine) return;
1417
- try {
1418
- if (await finalizeDraft(receiptLine)) return;
1419
- } catch (error) {
1420
- onFinalizeError?.(error);
1421
- }
1422
- await deliverReceipt(receiptLine);
1423
- }
1424
1392
  function createDiscordMessageActiveThreadRoute(params) {
1425
1393
  let adoptedThreadId;
1426
1394
  let threadReplyDelivered = false;
@@ -1487,7 +1455,7 @@ async function processDiscordMessageInner(ctx, observer) {
1487
1455
  }
1488
1456
  });
1489
1457
  const sourceRepliesAreToolOnly = sourceReplyDeliveryMode === "message_tool_only";
1490
- const configuredTypingMode = resolveAgentConfig(cfg, route.agentId)?.typingMode ?? cfg.agents?.defaults?.typingMode;
1458
+ const configuredTypingMode = resolveAgentConfig$1(cfg, route.agentId)?.typingMode ?? cfg.agents?.defaults?.typingMode;
1491
1459
  const configuredTypingInterval = cfg.agents?.defaults?.typingIntervalSeconds;
1492
1460
  const shouldDisableCoreTypingKeepalive = sourceRepliesAreToolOnly && configuredTypingMode === void 0 && configuredTypingInterval === void 0;
1493
1461
  const mediaLocalRoots = getAgentScopedMediaLocalRoots(cfg, route.agentId);
@@ -1547,21 +1515,21 @@ async function processDiscordMessageInner(ctx, observer) {
1547
1515
  let userFacingFinalDelivered = false;
1548
1516
  let userFacingFinalDeliveryFailed = false;
1549
1517
  let pendingToolWarningFinal;
1550
- const markUserFacingFinalDelivered = () => {
1551
- userFacingFinalDelivered = true;
1552
- userFacingFinalDeliveryFailed = false;
1553
- pendingToolWarningFinal = void 0;
1554
- draftPreview.markFinalReplyDelivered();
1555
- observer?.onFinalReplyDelivered?.();
1518
+ const markFinalReplyDelivered = (isError = false) => {
1519
+ draftPreview.markFinalReplyDelivered(isError);
1520
+ if (!isError) {
1521
+ userFacingFinalDelivered = true;
1522
+ userFacingFinalDeliveryFailed = false;
1523
+ pendingToolWarningFinal = void 0;
1524
+ observer?.onFinalReplyDelivered?.();
1525
+ }
1556
1526
  };
1557
- let progressReceiptLine;
1558
1527
  let clearProgressDraftAfterFinalDelivery = false;
1559
1528
  const resetDeliveryState = () => {
1560
1529
  finalReplyStartNotified = false;
1561
1530
  userFacingFinalDelivered = false;
1562
1531
  userFacingFinalDeliveryFailed = false;
1563
1532
  pendingToolWarningFinal = void 0;
1564
- progressReceiptLine = void 0;
1565
1533
  clearProgressDraftAfterFinalDelivery = false;
1566
1534
  };
1567
1535
  const progress = createDiscordMessageProgressRuntime({
@@ -1629,7 +1597,8 @@ async function processDiscordMessageInner(ctx, observer) {
1629
1597
  threadBindings,
1630
1598
  mediaLocalRoots,
1631
1599
  kind: "block",
1632
- bindPendingFinalDelivery: info.bindPendingFinalDelivery
1600
+ bindPendingFinalDelivery: info.bindPendingFinalDelivery,
1601
+ onPlatformSendDispatch: info.onPlatformSendDispatch
1633
1602
  });
1634
1603
  if (result.visibleReplySent) replyReference.markSent();
1635
1604
  return result;
@@ -1666,7 +1635,6 @@ async function processDiscordMessageInner(ctx, observer) {
1666
1635
  }
1667
1636
  if (draftStream && isFinal && draftPreview.isProgressMode && !deliverablePayload.isError && draftPreview.hasProgressDraftToCollapse && draftStream) {
1668
1637
  await draftPreview.flush();
1669
- progressReceiptLine = progress.buildProgressSummaryLine();
1670
1638
  clearProgressDraftAfterFinalDelivery = true;
1671
1639
  }
1672
1640
  if (draftStream && isFinal && !draftPreview.isProgressMode && !deliverablePayload.isError) {
@@ -1693,7 +1661,7 @@ async function processDiscordMessageInner(ctx, observer) {
1693
1661
  });
1694
1662
  },
1695
1663
  onPreviewFinalized: () => {
1696
- markUserFacingFinalDelivered();
1664
+ markFinalReplyDelivered();
1697
1665
  draftPreview.markPreviewFinalized();
1698
1666
  replyReference.markSent();
1699
1667
  },
@@ -1729,11 +1697,12 @@ async function processDiscordMessageInner(ctx, observer) {
1729
1697
  mediaLocalRoots,
1730
1698
  allowedMentions,
1731
1699
  kind: info.kind,
1732
- bindPendingFinalDelivery: info.bindPendingFinalDelivery
1700
+ bindPendingFinalDelivery: info.bindPendingFinalDelivery,
1701
+ onPlatformSendDispatch: info.onPlatformSendDispatch
1733
1702
  })).visibleReplySent;
1734
1703
  },
1735
1704
  onNormalDelivered: () => {
1736
- markUserFacingFinalDelivered();
1705
+ markFinalReplyDelivered();
1737
1706
  replyReference.markSent();
1738
1707
  }
1739
1708
  })).kind !== "normal-skipped") return { visibleReplySent: true };
@@ -1749,14 +1718,9 @@ async function processDiscordMessageInner(ctx, observer) {
1749
1718
  }
1750
1719
  const replyToId = replyReference.use();
1751
1720
  if (isFinal) notifyFinalReplyStart();
1752
- const receiptLine = isFinal && deliverablePayload.isError !== true ? progressReceiptLine : void 0;
1753
- const payloadForDelivery = receiptLine ? {
1754
- ...deliverablePayload,
1755
- text: deliverablePayload.text?.trim() ? `${deliverablePayload.text.trimEnd()}\n${receiptLine}` : receiptLine
1756
- } : deliverablePayload;
1757
1721
  const result = await deliverDiscordReply({
1758
1722
  cfg,
1759
- replies: [payloadForDelivery],
1723
+ replies: [deliverablePayload],
1760
1724
  target: deliverTarget,
1761
1725
  token,
1762
1726
  accountId,
@@ -1772,18 +1736,16 @@ async function processDiscordMessageInner(ctx, observer) {
1772
1736
  threadBindings,
1773
1737
  mediaLocalRoots,
1774
1738
  kind: info.kind,
1775
- bindPendingFinalDelivery: info.bindPendingFinalDelivery
1739
+ bindPendingFinalDelivery: info.bindPendingFinalDelivery,
1740
+ onPlatformSendDispatch: info.onPlatformSendDispatch
1776
1741
  });
1777
1742
  if (!result.visibleReplySent) return result;
1778
1743
  replyReference.markSent();
1779
- if (isFinal && deliverablePayload.isError !== true) {
1780
- if (receiptLine) {
1781
- progressReceiptLine = void 0;
1782
- draftPreview.markProgressDraftCollapsed();
1783
- }
1784
- markUserFacingFinalDelivered();
1785
- if (clearProgressDraftAfterFinalDelivery) {
1744
+ if (isFinal) {
1745
+ markFinalReplyDelivered(deliverablePayload.isError === true);
1746
+ if (deliverablePayload.isError !== true && clearProgressDraftAfterFinalDelivery) {
1786
1747
  clearProgressDraftAfterFinalDelivery = false;
1748
+ draftPreview.markProgressDraftCollapsed();
1787
1749
  await draftStream?.discardPending();
1788
1750
  await draftStream?.clear();
1789
1751
  }
@@ -1880,8 +1842,12 @@ async function processDiscordMessageInner(ctx, observer) {
1880
1842
  }
1881
1843
  if (activeThreadRoute.threadReplyDelivered && !userFacingFinalDelivered) {
1882
1844
  draftPreview.markFinalReplyStarted();
1883
- await finalizeDiscordAdoptedThreadProgressReceipt(draftPreview.hasProgressDraftToCollapse, progress.buildProgressSummaryLine(), (receiptLine) => draftPreview.finalizeProgressReceipt(receiptLine), (receiptText) => deliverDiscordPayload({ text: receiptText }, { kind: "block" }, { allowProgressBlock: true }), (error) => logVerbose(`discord: failed to finalize adopted thread progress (${String(error)})`));
1884
- markUserFacingFinalDelivered();
1845
+ if (draftPreview.hasProgressDraftToCollapse) try {
1846
+ await draftPreview.finalizeProgressDraft();
1847
+ } catch (error) {
1848
+ logVerbose(`discord: failed to finalize adopted thread progress (${String(error)})`);
1849
+ }
1850
+ markFinalReplyDelivered();
1885
1851
  }
1886
1852
  } catch (err) {
1887
1853
  if (isProcessAborted(abortSignal)) {
@@ -1889,14 +1855,18 @@ async function processDiscordMessageInner(ctx, observer) {
1889
1855
  return;
1890
1856
  }
1891
1857
  dispatchError = true;
1892
- if (await completeDiscordSessionConflict(err, deliverDiscordPayload, onDiscordDeliveryError)) return;
1858
+ if (await completeDiscordSessionConflict(err, (payload, info) => deliverDiscordPayload(payload, {
1859
+ ...info,
1860
+ onPlatformSendDispatch: () => Promise.resolve()
1861
+ }), onDiscordDeliveryError)) return;
1893
1862
  throw err;
1894
1863
  } finally {
1895
1864
  activeThreadRoute.end();
1896
1865
  endDeliveryCorrelation();
1897
1866
  await draftPreview.cleanup();
1898
1867
  dispatchError ||= readAgentRunTerminalOutcome(dispatchResult) === "failed";
1899
- const finalDeliveryFailed = (dispatchResult?.failedCounts?.final ?? 0) > 0;
1868
+ const finalReceipt = dispatchResult?.settledReceipt?.counts.final;
1869
+ const finalDeliveryFailed = (finalReceipt?.failedBeforeSend ?? 0) + (finalReceipt?.failedAfterSend ?? 0) > 0;
1900
1870
  await reactions.finish({
1901
1871
  dispatchAborted,
1902
1872
  dispatchError,
@@ -1907,7 +1877,7 @@ async function processDiscordMessageInner(ctx, observer) {
1907
1877
  const finalDispatchResult = dispatchResult;
1908
1878
  if (!finalDispatchResult || !hasFinalInboundReplyDispatch(finalDispatchResult)) return;
1909
1879
  if (shouldLogVerbose()) {
1910
- const finalCount = finalDispatchResult.counts.final;
1880
+ const finalCount = finalDispatchResult.settledReceipt?.counts.final.delivered ?? 0;
1911
1881
  logVerbose(`discord: delivered ${finalCount} reply${finalCount === 1 ? "" : "ies"} to ${replyTarget}`);
1912
1882
  }
1913
1883
  }