@openclaw/discord 2026.8.1-beta.2 → 2026.9.1-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 (287) 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-q-9PaaHH.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-B7qhK3fR.js} +29 -106
  9. package/dist/{audit-Db-rlntl.js → audit-CBEv_ERu.js} +5 -5
  10. package/dist/{channel-CnnbJSt5.js → channel-Dx1tMTfx.js} +72 -50
  11. package/dist/{channel-actions.runtime-CLKrx6tr.js → channel-actions.runtime-CLWWu9nC.js} +28 -43
  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-DOzXS2Pk.js} +5 -5
  16. package/dist/{outbound-session-route-DxLkrgKQ.js → components-B9V5o361.js} +8 -70
  17. package/dist/{config-schema-BgEskFAs.js → config-schema-BR13IAx6.js} +33 -7
  18. package/dist/conversation-binding-route-DJYrY2TQ.js +43 -0
  19. package/dist/{directory-config-BVX7Cflc.js → directory-config-BK6eqekJ.js} +2 -2
  20. package/dist/directory-contract-api.js +1 -1
  21. package/dist/{directory-live-DGIGxpIo.js → directory-live-DSAJSrJk.js} +3 -3
  22. package/dist/{doctor-BzC-TLnB.js → doctor-Cm7Y1pJ2.js} +33 -12
  23. package/dist/doctor-contract-api.js +2 -2
  24. package/dist/{handle-action.guild-admin-BNVTUISF.js → handle-action.guild-admin-BdwCRHmm.js} +9 -5
  25. package/dist/index.js +3 -4
  26. package/dist/{message-handler-Unk_f10F.js → message-handler-BXpWZyni.js} +82 -6
  27. package/dist/{message-handler.preflight-C9zecxR9.js → message-handler.preflight-Ba5LAY_X.js} +38 -50
  28. package/dist/{message-handler.process-DWQ6UHHu.js → message-handler.process-3HEzmemS.js} +204 -234
  29. package/dist/{message-utils-BSCPVgy0.js → message-text-aiwO5R2F.js} +41 -40
  30. package/dist/{outbound-adapter-D9nRivT1.js → outbound-adapter-BE4jSq2d.js} +113 -88
  31. package/dist/{outbound-components-cTzwBJ60.js → outbound-components-oLpg8Qzb.js} +3 -3
  32. package/dist/outbound-session-route-Cg15ZFJd.js +625 -0
  33. package/dist/owner-access-UlYi9t0M.js +107 -0
  34. package/dist/{pluralkit-DdiJ9KMK.js → pluralkit-Tiyl70dx.js} +1 -1
  35. package/dist/{probe-Bl-k5_Ku.js → probe-n6ZXxK8V.js} +1 -1
  36. package/dist/{probe.runtime-M9fREKvp.js → probe.runtime-CN4bdPfZ.js} +1 -1
  37. package/dist/{provider-DvSNb-2v.js → provider-B11xwilq.js} +720 -1325
  38. package/dist/{provider-session.runtime-BUEqD0rA.js → provider-session.runtime-B9xe-Qaf.js} +3 -3
  39. package/dist/provider.runtime-DiYaHvOz.js +2 -0
  40. package/dist/{realtime-session.runtime-C7wen-aF.js → realtime-session.runtime-CU8IQUS-.js} +97 -98
  41. package/dist/{resolve-allowlist-common-D04lpEzb.js → resolve-allowlist-common-BLoYaxEG.js} +2 -2
  42. package/dist/{resolve-channels-Dm7jEeg6.js → resolve-channels-C2sT_n67.js} +5 -4
  43. package/dist/{resolve-users-bktrCUUU.js → resolve-users-CzpjLwjy.js} +2 -2
  44. package/dist/{retry-CLpJcXXf.js → retry-Cv4jCU5Z.js} +111 -18
  45. package/dist/{runtime-DGsSyDTS.js → runtime-BHrTlFkf.js} +88 -85
  46. package/dist/{runtime-DoHjckYm.js → runtime-CY4PRMF-.js} +9 -10
  47. package/dist/runtime-api.js +19 -25
  48. package/dist/{sdk-runtime-QpY8PvCh.js → sdk-runtime-4geQHtXc.js} +57 -89
  49. package/dist/{secret-config-contract-B1akrlyY.js → secret-config-contract-B3i6WxV5.js} +53 -25
  50. package/dist/secret-contract-api.js +1 -1
  51. package/dist/security-audit-contract-api.js +1 -1
  52. package/dist/{security-audit.runtime-CPN0xFYz.js → security-audit.runtime-BVKF9VtY.js} +1 -1
  53. package/dist/{send-B7Q6Oc1I.js → send-C49MFF9j.js} +82 -19
  54. package/dist/{send.components-iJyFXw9L.js → send.components-DKKAw5VX.js} +21 -38
  55. package/dist/{send.outbound-DS5tHwfR.js → send.outbound-zam0TrZx.js} +77 -78
  56. package/dist/{send.shared-BmwFjW6T.js → send.shared-JjljcV4O.js} +135 -120
  57. package/dist/{sender-identity-QtalnCYv.js → sender-identity-BJtfyise.js} +1 -1
  58. package/dist/setup-plugin-api.js +1 -1
  59. package/dist/{shared-BIXIX6uJ.js → shared-_5EcP4jW.js} +38 -14
  60. package/dist/subagent-hooks-DQzvOptn.js +49 -0
  61. package/dist/subagent-hooks-api.js +1 -6
  62. package/dist/{system-events-CTqDf6_s.js → system-events-C7yxaHWP.js} +2 -2
  63. package/dist/{target-resolver-maOKSqO0.js → target-resolver-vxIh6O3-.js} +3 -3
  64. package/dist/targets-CtTKvntJ.js +3 -0
  65. package/dist/{thread-bindings-3L8p82GV.js → thread-bindings-DW5F9vat.js} +28 -26
  66. package/dist/{thread-bindings.manager-DCIH6WDC.js → thread-bindings.manager-ByOtwjo_.js} +9 -12
  67. package/dist/{thread-bindings.session-updates-bJ2KQFY6.js → thread-bindings.session-updates-CJb-BpPL.js} +1 -1
  68. package/dist/{thread-bindings.state-aeV8HNgV.js → thread-bindings.state-D8OMdk4O.js} +1 -1
  69. package/dist/threading-agH1T_6s.js +478 -0
  70. package/dist/transcripts-source-BR11iHA4.js +265 -0
  71. package/dist/transcripts-source-api.js +7 -2
  72. package/dist/{typing-CS-nNVoe.js → typing-Dc_YMY2e.js} +1 -1
  73. package/dist/{voice-runtime-BEdqNcST.js → voice-runtime-DIeaa8fJ.js} +230 -148
  74. package/node_modules/@discord/embedded-app-sdk/node_modules/uuid/README.md +19 -19
  75. package/node_modules/@discord/embedded-app-sdk/node_modules/uuid/dist/v1.js +7 -3
  76. package/node_modules/@discord/embedded-app-sdk/node_modules/uuid/dist/v7.js +5 -2
  77. package/node_modules/@discord/embedded-app-sdk/node_modules/uuid/dist-node/v1.js +7 -3
  78. package/node_modules/@discord/embedded-app-sdk/node_modules/uuid/dist-node/v7.js +5 -2
  79. package/node_modules/@discord/embedded-app-sdk/node_modules/uuid/package.json +4 -3
  80. package/node_modules/@discordjs/voice/node_modules/@types/node/README.md +1 -1
  81. package/node_modules/@discordjs/voice/node_modules/@types/node/child_process.d.ts +0 -1
  82. package/node_modules/@discordjs/voice/node_modules/@types/node/crypto.d.ts +6 -6
  83. package/node_modules/@discordjs/voice/node_modules/@types/node/dns/promises.d.ts +5 -5
  84. package/node_modules/@discordjs/voice/node_modules/@types/node/dns.d.ts +5 -5
  85. package/node_modules/@discordjs/voice/node_modules/@types/node/fs.d.ts +7 -0
  86. package/node_modules/@discordjs/voice/node_modules/@types/node/http.d.ts +30 -0
  87. package/node_modules/@discordjs/voice/node_modules/@types/node/http2.d.ts +4 -4
  88. package/node_modules/@discordjs/voice/node_modules/@types/node/os.d.ts +30 -30
  89. package/node_modules/@discordjs/voice/node_modules/@types/node/package.json +2 -2
  90. package/node_modules/@discordjs/voice/node_modules/@types/node/perf_hooks.d.ts +2 -1
  91. package/node_modules/@discordjs/voice/node_modules/@types/node/process.d.ts +42 -43
  92. package/node_modules/@discordjs/voice/node_modules/@types/node/quic.d.ts +1049 -84
  93. package/node_modules/@discordjs/voice/node_modules/@types/node/sqlite.d.ts +14 -1
  94. package/node_modules/@discordjs/voice/node_modules/@types/node/stream/iter.d.ts +3 -2
  95. package/node_modules/@discordjs/voice/node_modules/@types/node/test.d.ts +61 -0
  96. package/node_modules/@discordjs/voice/node_modules/@types/node/v8.d.ts +20 -23
  97. package/node_modules/discord-api-types/CHANGELOG.md +8 -0
  98. package/node_modules/discord-api-types/package.json +4 -4
  99. package/node_modules/discord-api-types/payloads/v10/channel.d.ts +2 -2
  100. package/node_modules/discord-api-types/payloads/v10/channel.d.ts.map +1 -1
  101. package/node_modules/discord-api-types/payloads/v10/gateway.d.ts +4 -0
  102. package/node_modules/discord-api-types/payloads/v10/gateway.d.ts.map +1 -1
  103. package/node_modules/discord-api-types/payloads/v10/gateway.js.map +1 -1
  104. package/node_modules/discord-api-types/payloads/v10/message.d.ts +4 -1
  105. package/node_modules/discord-api-types/payloads/v10/message.d.ts.map +1 -1
  106. package/node_modules/discord-api-types/payloads/v10/message.js +1 -0
  107. package/node_modules/discord-api-types/payloads/v10/message.js.map +1 -1
  108. package/node_modules/discord-api-types/payloads/v9/channel.d.ts +2 -2
  109. package/node_modules/discord-api-types/payloads/v9/channel.d.ts.map +1 -1
  110. package/node_modules/discord-api-types/payloads/v9/gateway.d.ts +4 -0
  111. package/node_modules/discord-api-types/payloads/v9/gateway.d.ts.map +1 -1
  112. package/node_modules/discord-api-types/payloads/v9/gateway.js.map +1 -1
  113. package/node_modules/discord-api-types/payloads/v9/message.d.ts +4 -1
  114. package/node_modules/discord-api-types/payloads/v9/message.d.ts.map +1 -1
  115. package/node_modules/discord-api-types/payloads/v9/message.js +1 -0
  116. package/node_modules/discord-api-types/payloads/v9/message.js.map +1 -1
  117. package/node_modules/typebox/build/format/date.d.mts +1 -1
  118. package/node_modules/typebox/build/format/date.mjs +1 -1
  119. package/node_modules/typebox/build/format/date_time.d.mts +2 -2
  120. package/node_modules/typebox/build/format/date_time.mjs +3 -3
  121. package/node_modules/typebox/build/format/email.d.mts +1 -1
  122. package/node_modules/typebox/build/format/email.mjs +2 -2
  123. package/node_modules/typebox/build/format/hostname.mjs +2 -10
  124. package/node_modules/typebox/build/format/idn_email.d.mts +1 -1
  125. package/node_modules/typebox/build/format/idn_email.mjs +3 -3
  126. package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -0
  127. package/node_modules/typebox/build/format/idn_hostname.mjs +3 -11
  128. package/node_modules/typebox/build/format/idna/format/bidi.d.mts +3 -0
  129. package/node_modules/typebox/build/format/idna/format/bidi.mjs +98 -0
  130. package/node_modules/typebox/build/format/idna/format/puny.d.mts +3 -0
  131. package/node_modules/typebox/build/format/idna/format/puny.mjs +144 -0
  132. package/node_modules/typebox/build/format/idna/hostname.d.mts +1 -0
  133. package/node_modules/typebox/build/format/idna/hostname.mjs +16 -0
  134. package/node_modules/typebox/build/format/idna/idn-hostname.d.mts +1 -0
  135. package/node_modules/typebox/build/format/idna/idn-hostname.mjs +23 -0
  136. package/node_modules/typebox/build/format/idna/index.d.mts +2 -0
  137. package/node_modules/typebox/build/format/idna/index.mjs +2 -0
  138. package/node_modules/typebox/build/format/idna/label/ascii.d.mts +1 -0
  139. package/node_modules/typebox/build/format/idna/label/ascii.mjs +9 -0
  140. package/node_modules/typebox/build/format/idna/label/puny.d.mts +1 -0
  141. package/node_modules/typebox/build/format/idna/label/puny.mjs +28 -0
  142. package/node_modules/typebox/build/format/idna/label/unicode.d.mts +1 -0
  143. package/node_modules/typebox/build/format/idna/label/unicode.mjs +106 -0
  144. package/node_modules/typebox/build/format/idna/pattern/pattern.d.mts +30 -0
  145. package/node_modules/typebox/build/format/idna/pattern/pattern.mjs +70 -0
  146. package/node_modules/typebox/build/format/ipv4.d.mts +0 -1
  147. package/node_modules/typebox/build/format/ipv4.mjs +2 -32
  148. package/node_modules/typebox/build/format/ipv6.mjs +2 -61
  149. package/node_modules/typebox/build/format/iri.d.mts +2 -2
  150. package/node_modules/typebox/build/format/iri.mjs +26 -8
  151. package/node_modules/typebox/build/format/iri_reference.d.mts +2 -2
  152. package/node_modules/typebox/build/format/iri_reference.mjs +9 -55
  153. package/node_modules/typebox/build/format/regex.d.mts +1 -2
  154. package/node_modules/typebox/build/format/regex.mjs +2 -6
  155. package/node_modules/typebox/build/format/time.d.mts +2 -2
  156. package/node_modules/typebox/build/format/time.mjs +19 -14
  157. package/node_modules/typebox/build/format/uri.d.mts +1 -1
  158. package/node_modules/typebox/build/format/uri.mjs +3 -130
  159. package/node_modules/typebox/build/format/uri_reference.d.mts +1 -1
  160. package/node_modules/typebox/build/format/uri_reference.mjs +2 -3
  161. package/node_modules/typebox/build/format/uri_template.d.mts +2 -3
  162. package/node_modules/typebox/build/format/uri_template.mjs +4 -5
  163. package/node_modules/typebox/build/format/url.d.mts +3 -3
  164. package/node_modules/typebox/build/format/url.mjs +4 -5
  165. package/node_modules/typebox/build/guard/emit.d.mts +3 -1
  166. package/node_modules/typebox/build/guard/emit.mjs +12 -5
  167. package/node_modules/typebox/build/guard/guard.d.mts +8 -2
  168. package/node_modules/typebox/build/guard/guard.mjs +25 -4
  169. package/node_modules/typebox/build/guard/string.d.mts +2 -2
  170. package/node_modules/typebox/build/guard/string.mjs +7 -7
  171. package/node_modules/typebox/build/schema/engine/_context.mjs +3 -3
  172. package/node_modules/typebox/build/schema/engine/_functions.mjs +1 -2
  173. package/node_modules/typebox/build/schema/engine/_regexp.d.mts +2 -0
  174. package/node_modules/typebox/build/schema/engine/_regexp.mjs +4 -0
  175. package/node_modules/typebox/build/schema/engine/_stack.mjs +12 -13
  176. package/node_modules/typebox/build/schema/engine/additionalItems.mjs +17 -7
  177. package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +4 -3
  178. package/node_modules/typebox/build/schema/engine/contains.mjs +18 -6
  179. package/node_modules/typebox/build/schema/engine/enum.mjs +1 -1
  180. package/node_modules/typebox/build/schema/engine/items.mjs +26 -6
  181. package/node_modules/typebox/build/schema/engine/maxContains.mjs +3 -3
  182. package/node_modules/typebox/build/schema/engine/minContains.mjs +14 -4
  183. package/node_modules/typebox/build/schema/engine/not.mjs +4 -2
  184. package/node_modules/typebox/build/schema/engine/oneOf.mjs +7 -6
  185. package/node_modules/typebox/build/schema/engine/pattern.mjs +3 -2
  186. package/node_modules/typebox/build/schema/engine/patternProperties.mjs +4 -3
  187. package/node_modules/typebox/build/schema/engine/ref.mjs +1 -7
  188. package/node_modules/typebox/build/schema/engine/schema.mjs +13 -4
  189. package/node_modules/typebox/build/schema/engine/type.mjs +1 -1
  190. package/node_modules/typebox/build/schema/resolve/resolve.d.mts +4 -1
  191. package/node_modules/typebox/build/schema/resolve/resolve.mjs +202 -1
  192. package/node_modules/typebox/build/schema/static/propertyNames.d.mts +5 -0
  193. package/node_modules/typebox/build/schema/static/propertyNames.mjs +3 -0
  194. package/node_modules/typebox/build/schema/static/schema.d.mts +3 -0
  195. package/node_modules/typebox/build/schema/types/index.d.mts +0 -2
  196. package/node_modules/typebox/build/schema/types/index.mjs +0 -2
  197. package/node_modules/typebox/build/system/memory/clone.mjs +14 -11
  198. package/node_modules/typebox/build/system/memory/discard.mjs +6 -5
  199. package/node_modules/typebox/build/system/settings/settings.d.mts +9 -0
  200. package/node_modules/typebox/build/system/settings/settings.mjs +2 -0
  201. package/node_modules/typebox/build/type/engine/call/distribute_arguments.d.mts +6 -1
  202. package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +16 -3
  203. package/node_modules/typebox/build/type/engine/call/instantiate.mjs +34 -4
  204. package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +5 -5
  205. package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +20 -26
  206. package/node_modules/typebox/build/type/engine/evaluate/compare.d.mts +6 -10
  207. package/node_modules/typebox/build/type/engine/evaluate/compare.mjs +9 -13
  208. package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +7 -4
  209. package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +12 -19
  210. package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +4 -20
  211. package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +8 -20
  212. package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +4 -4
  213. package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +11 -8
  214. package/node_modules/typebox/build/type/engine/evaluate/flatten.d.mts +1 -1
  215. package/node_modules/typebox/build/type/engine/evaluate/flatten.mjs +3 -4
  216. package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +17 -2
  217. package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +26 -6
  218. package/node_modules/typebox/build/type/engine/exclude/operation.mjs +3 -4
  219. package/node_modules/typebox/build/type/engine/extract/operation.d.mts +1 -1
  220. package/node_modules/typebox/build/type/engine/extract/operation.mjs +3 -4
  221. package/node_modules/typebox/build/type/engine/priority/priority.d.mts +2 -2
  222. package/node_modules/typebox/build/type/engine/priority/priority.mjs +3 -4
  223. package/node_modules/typebox/build/type/script/mapping.d.mts +32 -29
  224. package/node_modules/typebox/build/type/script/mapping.mjs +18 -25
  225. package/node_modules/typebox/build/type/script/parser.d.mts +19 -25
  226. package/node_modules/typebox/build/type/script/parser.mjs +27 -23
  227. package/node_modules/typebox/build/value/errors/errors.d.mts +2 -2
  228. package/node_modules/typebox/build/value/errors/errors.mjs +1 -1
  229. package/node_modules/typebox/package.json +27 -27
  230. package/node_modules/typebox/readme.md +79 -82
  231. package/node_modules/undici/docs/docs/api/Client.md +21 -8
  232. package/node_modules/undici/lib/api/readable.js +33 -43
  233. package/node_modules/undici/lib/core/connect.js +16 -2
  234. package/node_modules/undici/lib/core/symbols.js +1 -0
  235. package/node_modules/undici/lib/dispatcher/client-h1.js +3 -3
  236. package/node_modules/undici/lib/dispatcher/client-h2.js +179 -10
  237. package/node_modules/undici/lib/dispatcher/client.js +74 -29
  238. package/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +28 -6
  239. package/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +15 -1
  240. package/node_modules/undici/lib/handler/retry-handler.js +7 -2
  241. package/node_modules/undici/lib/interceptor/cache.js +5 -2
  242. package/node_modules/undici/lib/interceptor/deduplicate.js +1 -1
  243. package/node_modules/undici/lib/mock/mock-utils.js +213 -24
  244. package/node_modules/undici/lib/util/cache.js +2 -4
  245. package/node_modules/undici/lib/web/websocket/websocket.js +22 -0
  246. package/node_modules/undici/package.json +1 -1
  247. package/node_modules/undici/types/client.d.ts +40 -0
  248. package/node_modules/ws/lib/permessage-deflate.js +3 -1
  249. package/node_modules/ws/package.json +1 -1
  250. package/openclaw.plugin.json +12 -6
  251. package/package.json +8 -10
  252. package/dist/approval-message-safety-AcIxvrf3.js +0 -140
  253. package/dist/audit-core-xwjIczO0.js +0 -105
  254. package/dist/channel-actions-5s_hjYKd.js +0 -208
  255. package/dist/channel-api-CAJ0wMoV.js +0 -21
  256. package/dist/inbound-event-delivery-De2qxTrP.js +0 -39
  257. package/dist/provider.runtime-C9PnJZbZ.js +0 -2
  258. package/dist/runtime-api.actions.js +0 -3
  259. package/dist/runtime-api.lookup.js +0 -7
  260. package/dist/runtime-api.monitor-CHxrFPnW.js +0 -5
  261. package/dist/runtime-api.monitor.js +0 -8
  262. package/dist/runtime-api.send.js +0 -7
  263. package/dist/runtime-api.threads.js +0 -5
  264. package/dist/send.reactions-BAn0iiVQ.js +0 -78
  265. package/dist/send.receipt-IPI1p-SP.js +0 -66
  266. package/dist/subagent-hooks-CTt5KCJr.js +0 -120
  267. package/dist/subagent-progress-DhaE_h8a.js +0 -109
  268. package/dist/targets-yUFTHoAx.js +0 -3
  269. package/dist/transcripts-source-CfFMexGt.js +0 -123
  270. package/node_modules/p-map/index.d.ts +0 -155
  271. package/node_modules/p-map/index.js +0 -285
  272. package/node_modules/p-map/license +0 -9
  273. package/node_modules/p-map/package.json +0 -57
  274. package/node_modules/p-map/readme.md +0 -190
  275. package/node_modules/typebox/build/format/_idna.d.mts +0 -2
  276. package/node_modules/typebox/build/format/_idna.mjs +0 -246
  277. package/node_modules/typebox/build/format/_puny.d.mts +0 -1
  278. package/node_modules/typebox/build/format/_puny.mjs +0 -77
  279. package/node_modules/typebox/build/schema/resolve/ref.d.mts +0 -3
  280. package/node_modules/typebox/build/schema/resolve/ref.mjs +0 -146
  281. package/node_modules/typebox/build/schema/types/contentEncoding.d.mts +0 -9
  282. package/node_modules/typebox/build/schema/types/contentEncoding.mjs +0 -13
  283. package/node_modules/typebox/build/schema/types/contentMediaType.d.mts +0 -9
  284. package/node_modules/typebox/build/schema/types/contentMediaType.mjs +0 -13
  285. package/dist/{allow-list-DnxIlPP2.js → allow-list-BDMimASD.js} +1 -1
  286. package/dist/{doctor-contract-DLa-BTiU.js → doctor-contract-DsWvKIXF.js} +1 -1
  287. package/dist/{security-audit-jGnJF__m.js → security-audit-BfJhAXZp.js} +1 -1
@@ -1,19 +1,20 @@
1
- import { C as ReadyListener, D as VoiceStateUpdateListener, N as isUnknownDiscordVoiceStateError, Wt as getGuildVoiceState, h as discord_exports, p as parseDiscordTarget, w as ResumedListener } from "./retry-CLpJcXXf.js";
1
+ import { D as ReadyListener, L as isUnknownDiscordVoiceStateError, O as ResumedListener, Yt as getGuildVoiceState, _ as parseDiscordTarget, j as VoiceStateUpdateListener, y as discord_exports } from "./retry-Cv4jCU5Z.js";
2
2
  import { t as getDiscordRuntime } from "./runtime-DgnVQ7zW.js";
3
- import { a as normalizeDiscordSlug, h as resolveDiscordOwnerAccess, x as formatDiscordUserTag } from "./allow-list-DnxIlPP2.js";
4
- import { a as formatMention } from "./send.outbound-DS5tHwfR.js";
5
- import { g as buildDiscordGroupSystemPrompt, l as resolveDiscordVoiceAccess, m as resolveDiscordVoiceEnabled, u as authorizeDiscordVoiceIngress } from "./provider-DvSNb-2v.js";
6
- import { S as formatVoiceLogPreview, _ as decodeOpusStream, a as SPEAKING_READY_TIMEOUT_MS, b as formatVoiceIngressPrompt, c as isDiscordRealtimeVoiceMode, d as resolveDiscordVoiceMode, f as resolveVoiceTimeoutMs, g as createDiscordOpusPlaybackStream, i as PLAYBACK_READY_TIMEOUT_MS, l as isVoiceChannel, n as CAPTURE_FINALIZE_GRACE_MS, o as VOICE_CONNECT_READY_TIMEOUT_MS, s as VOICE_RECONNECT_GRACE_MS, t as loadDiscordVoiceSdk, u as logVoiceVerbose, v as decodeOpusStreamChunks, x as maybeControlDiscordVoiceAgentRun, y as writeVoiceWavFile } from "./sdk-runtime-QpY8PvCh.js";
7
- import { resolveAgentRoute } from "openclaw/plugin-sdk/routing";
8
- import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
3
+ import { a as normalizeDiscordSlug, h as resolveDiscordOwnerAccess, x as formatDiscordUserTag } from "./allow-list-BDMimASD.js";
4
+ import { a as formatMention } from "./send.outbound-zam0TrZx.js";
5
+ import { n as resolveDiscordVoiceEnabled, r as authorizeDiscordVoiceIngress, t as resolveDiscordVoiceAccess } from "./owner-access-UlYi9t0M.js";
6
+ import { p as buildDiscordGroupSystemPrompt, y as resolveFetchedDiscordThreadLikeChannelContext } from "./provider-B11xwilq.js";
7
+ import { _ as decodeOpusStreamChunks, a as VOICE_CONNECT_READY_TIMEOUT_MS, b as maybeControlDiscordVoiceAgentRun, c as isVoiceChannel, d as resolveVoiceTimeoutMs, g as decodeOpusStream, h as createDiscordOpusPlaybackStream, i as PLAYBACK_READY_TIMEOUT_MS, l as logVoiceVerbose, n as CAPTURE_FINALIZE_GRACE_MS, o as VOICE_RECONNECT_GRACE_MS, s as isDiscordRealtimeVoiceMode, t as loadDiscordVoiceSdk, u as resolveDiscordVoiceMode, v as writeVoiceWavFile, x as formatVoiceLogPreview, y as formatVoiceIngressPrompt } from "./sdk-runtime-4geQHtXc.js";
9
8
  import { asDateTimestampMs, resolveExpiresAtMsFromDurationMs } from "openclaw/plugin-sdk/number-runtime";
10
9
  import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
11
10
  import { formatErrorMessage } from "openclaw/plugin-sdk/ssrf-runtime";
11
+ import { resolveAgentRoute } from "openclaw/plugin-sdk/routing";
12
+ import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
12
13
  import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env";
13
14
  import { escapeRegExp, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
14
15
  import { stripInlineDirectiveTagsForDisplay } from "openclaw/plugin-sdk/text-chunking";
15
- import path from "node:path";
16
- import { agentCommandFromIngress, resolveAgentDir } from "openclaw/plugin-sdk/agent-runtime";
16
+ import { unlinkIfExists } from "openclaw/plugin-sdk/media-runtime";
17
+ import { resolveAgentDir } from "openclaw/plugin-sdk/agent-runtime";
17
18
  import { enqueueRoutedSystemEvent } from "openclaw/plugin-sdk/system-event-runtime";
18
19
  import { Readable } from "node:stream";
19
20
  import { OpusError } from "libopus-wasm";
@@ -82,12 +83,13 @@ async function runDiscordVoiceAgentTurn(params) {
82
83
  });
83
84
  if (!context) return null;
84
85
  const voiceModel = normalizeOptionalString(params.discordConfig.voice?.model);
85
- const payloads = (await agentCommandFromIngress({
86
+ const payloads = (await getDiscordRuntime().agent.runCommandFromIngress({
86
87
  message: params.message,
87
88
  sessionKey: params.entry.route.sessionKey,
88
89
  agentId: params.entry.route.agentId,
89
90
  messageChannel: "discord",
90
91
  messageProvider: DISCORD_VOICE_MESSAGE_PROVIDER,
92
+ accountId: params.accountId,
91
93
  extraSystemPrompt: context.extraSystemPrompt,
92
94
  senderIsOwner: context.senderIsOwner,
93
95
  allowModelOverride: Boolean(voiceModel),
@@ -193,7 +195,7 @@ function countDiscordVoiceHumanParticipants(params) {
193
195
  const userId = state.user_id?.trim();
194
196
  if (!userId || userId === params.botUserId || knownUserIds.has(userId)) continue;
195
197
  knownUserIds.add(userId);
196
- if (state.member?.user?.bot !== true) count += 1;
198
+ if (state.member?.user && state.member.user.bot !== true) count += 1;
197
199
  }
198
200
  for (const rawUserId of params.additionalUserIds ?? []) {
199
201
  const userId = rawUserId.trim();
@@ -654,7 +656,8 @@ function normalizeVoiceChannelResidencies(entries) {
654
656
  const channelId = entry.channelId?.trim();
655
657
  if (guildId && channelId) normalized.push({
656
658
  guildId,
657
- channelId
659
+ channelId,
660
+ ...entry.whenOccupied === true ? { whenOccupied: true } : {}
658
661
  });
659
662
  }
660
663
  return normalized;
@@ -1017,6 +1020,7 @@ var DiscordVoiceFollowing = class {
1017
1020
  }
1018
1021
  resolveVoiceResidencyTarget(guildId) {
1019
1022
  const autoJoinTarget = this.params.autoJoinChannels.toReversed().find((entry) => entry.guildId === guildId);
1023
+ if (autoJoinTarget?.whenOccupied) return null;
1020
1024
  if (autoJoinTarget && this.params.isAllowedVoiceChannel(autoJoinTarget)) return autoJoinTarget;
1021
1025
  if (this.params.allowedChannels === null) return null;
1022
1026
  const guildAllowed = this.params.allowedChannels.filter((entry) => entry.guildId === guildId);
@@ -1142,6 +1146,7 @@ async function synthesizeVoiceReplyAudio(params) {
1142
1146
  release: streamResult.release,
1143
1147
  speakText
1144
1148
  };
1149
+ const streamFailure = streamResult && !streamResult.success ? streamResult.attempts?.findLast((attempt) => attempt.outcome === "failed") : void 0;
1145
1150
  const result = await runtime.tts.textToSpeech({
1146
1151
  text: speakText,
1147
1152
  cfg: prepared.cfg,
@@ -1156,7 +1161,11 @@ async function synthesizeVoiceReplyAudio(params) {
1156
1161
  status: "ok",
1157
1162
  mode: "file",
1158
1163
  audioPath: result.audioPath,
1159
- speakText
1164
+ speakText,
1165
+ ...streamFailure ? { streamFailure: {
1166
+ provider: streamFailure.provider,
1167
+ reasonCode: streamFailure.reasonCode
1168
+ } } : {}
1160
1169
  };
1161
1170
  }
1162
1171
  //#endregion
@@ -1219,10 +1228,12 @@ async function processDiscordVoiceSegment(params) {
1219
1228
  logger$4.info(`discord voice: active-run control handled mode=${control.result.mode} ok=${control.result.ok} active=${control.result.active} reason=${control.result.reason ?? "none"} session=${entry.route.sessionKey}`);
1220
1229
  replyText = control.speakText ?? "";
1221
1230
  } else {
1231
+ const prompt = formatVoiceIngressPrompt(transcript, ingress.speakerLabel);
1222
1232
  const turn = await runDiscordVoiceAgentTurn({
1223
1233
  entry,
1234
+ accountId: params.accountId,
1224
1235
  userId,
1225
- message: formatVoiceIngressPrompt(transcript, ingress.speakerLabel),
1236
+ message: prompt,
1226
1237
  cfg: params.cfg,
1227
1238
  discordConfig: params.discordConfig,
1228
1239
  runtime: params.runtime,
@@ -1256,26 +1267,38 @@ async function processDiscordVoiceSegment(params) {
1256
1267
  logger$4.warn(`discord voice: TTS failed: ${voiceReplyAudio.error ?? "unknown error"}`);
1257
1268
  return;
1258
1269
  }
1270
+ const streamFailure = voiceReplyAudio.mode === "file" ? voiceReplyAudio.streamFailure : void 0;
1271
+ if (streamFailure && !entry.ttsStreamFallbackWarned) {
1272
+ entry.ttsStreamFallbackWarned = true;
1273
+ logger$4.warn(`discord voice: streaming TTS failed provider=${streamFailure.provider} reasonCode=${streamFailure.reasonCode}; using file fallback`);
1274
+ }
1259
1275
  logVoiceVerbose(`tts ok (${voiceReplyAudio.speakText.length} chars): guild ${entry.guildId} channel ${entry.channelId}`);
1276
+ const releaseAudio = voiceReplyAudio.mode === "stream" ? voiceReplyAudio.release : () => unlinkIfExists(voiceReplyAudio.audioPath);
1277
+ if (entry.sessionLifecycle.status === "stopped") {
1278
+ await releaseAudio?.();
1279
+ return;
1280
+ }
1260
1281
  params.enqueuePlayback(entry, async () => {
1261
1282
  const voiceSdk = loadDiscordVoiceSdk();
1262
- const releaseAudioStream = voiceReplyAudio.mode === "stream" ? voiceReplyAudio.release : void 0;
1283
+ const playbackLifecycle = new AbortController();
1284
+ let playbackStarted = false;
1285
+ const cancelStoppedPlayback = () => (!playbackStarted || entry.sessionLifecycle.status === "stopped") && playbackLifecycle.abort();
1263
1286
  try {
1264
- if (voiceReplyAudio.mode === "stream") {
1265
- logVoiceVerbose(`playback start: guild ${entry.guildId} channel ${entry.channelId} stream`);
1266
- const nodeStream = Readable.fromWeb(voiceReplyAudio.audioStream);
1267
- const resource = voiceSdk.createAudioResource(createDiscordOpusPlaybackStream(nodeStream), { inputType: voiceSdk.StreamType.Opus });
1268
- entry.player.play(resource);
1269
- } else {
1270
- logVoiceVerbose(`playback start: guild ${entry.guildId} channel ${entry.channelId} file ${path.basename(voiceReplyAudio.audioPath)}`);
1271
- const resource = voiceSdk.createAudioResource(createDiscordOpusPlaybackStream(voiceReplyAudio.audioPath), { inputType: voiceSdk.StreamType.Opus });
1272
- entry.player.play(resource);
1273
- }
1274
- await voiceSdk.entersState(entry.player, voiceSdk.AudioPlayerStatus.Playing, PLAYBACK_READY_TIMEOUT_MS).catch(() => void 0);
1275
- await voiceSdk.entersState(entry.player, voiceSdk.AudioPlayerStatus.Idle, SPEAKING_READY_TIMEOUT_MS).catch(() => void 0);
1287
+ if (entry.sessionLifecycle.status === "stopped") return;
1288
+ entry.player.on(voiceSdk.AudioPlayerStatus.Idle, cancelStoppedPlayback);
1289
+ const input = voiceReplyAudio.mode === "stream" ? Readable.fromWeb(voiceReplyAudio.audioStream) : voiceReplyAudio.audioPath;
1290
+ logVoiceVerbose(`playback start: guild ${entry.guildId} channel ${entry.channelId} ${voiceReplyAudio.mode}`);
1291
+ const resource = voiceSdk.createAudioResource(createDiscordOpusPlaybackStream(input), { inputType: voiceSdk.StreamType.Opus });
1292
+ entry.player.play(resource);
1293
+ await voiceSdk.entersState(entry.player, voiceSdk.AudioPlayerStatus.Playing, AbortSignal.any([AbortSignal.timeout(PLAYBACK_READY_TIMEOUT_MS), playbackLifecycle.signal]));
1294
+ playbackStarted = true;
1295
+ await voiceSdk.entersState(entry.player, voiceSdk.AudioPlayerStatus.Idle, playbackLifecycle.signal);
1276
1296
  logVoiceVerbose(`playback done: guild ${entry.guildId} channel ${entry.channelId}`);
1297
+ } catch (error) {
1298
+ if (entry.sessionLifecycle.status !== "stopped") throw error;
1277
1299
  } finally {
1278
- await releaseAudioStream?.();
1300
+ entry.player.off(voiceSdk.AudioPlayerStatus.Idle, cancelStoppedPlayback);
1301
+ await releaseAudio?.();
1279
1302
  }
1280
1303
  });
1281
1304
  }
@@ -1415,6 +1438,7 @@ var DiscordVoiceReceive = class {
1415
1438
  async processSegment(params) {
1416
1439
  await processDiscordVoiceSegment({
1417
1440
  ...params,
1441
+ accountId: this.params.accountId,
1418
1442
  cfg: this.params.cfg,
1419
1443
  discordConfig: this.params.discordConfig,
1420
1444
  admissionAllowFrom: this.params.admissionAllowFrom,
@@ -1515,6 +1539,7 @@ var DiscordVoiceReceive = class {
1515
1539
  logger$3.info(`discord voice: agent turn start guild=${entry.guildId} channel=${entry.channelId} voiceSession=${entry.voiceSessionKey} supervisorSession=${entry.route.sessionKey} agent=${entry.route.agentId} user=${userId} speaker=${context.speakerLabel} owner=${context.senderIsOwner} model=${this.params.discordConfig.voice?.model ?? "route-default"} message=${formatVoiceLogPreview(message)}`);
1516
1540
  const turn = await runDiscordVoiceAgentTurn({
1517
1541
  entry,
1542
+ accountId: this.params.accountId,
1518
1543
  userId,
1519
1544
  message,
1520
1545
  cfg: this.params.cfg,
@@ -1574,13 +1599,17 @@ var DiscordVoiceReceive = class {
1574
1599
  const result = await this.params.join({
1575
1600
  guildId: entry.guildId,
1576
1601
  channelId: entry.channelId
1577
- }, { preserveFollowState });
1602
+ }, {
1603
+ preserveFollowState,
1604
+ autoJoinWhenOccupied: entry.autoJoinWhenOccupied
1605
+ });
1578
1606
  if (!result.ok) logger$3.warn(`discord voice: rejoin after decrypt failures failed: ${result.message}`);
1579
1607
  }
1580
1608
  };
1581
1609
  //#endregion
1582
1610
  //#region extensions/discord/src/voice/voice-session.ts
1583
1611
  const logger$2 = createSubsystemLogger("discord/voice");
1612
+ const REALTIME_PLAYBACK_MAX_MISSED_FRAMES = 100;
1584
1613
  function isVoiceSessionStopped(entry) {
1585
1614
  return entry.sessionLifecycle.status === "stopped";
1586
1615
  }
@@ -1660,8 +1689,15 @@ var DiscordVoiceSessions = class {
1660
1689
  const { guildId, channelId } = params;
1661
1690
  const voiceConfig = this.params.discordConfig.voice;
1662
1691
  const voiceMode = resolveDiscordVoiceMode(voiceConfig);
1692
+ const cancelledJoinResult = () => ({
1693
+ ok: false,
1694
+ message: "Discord voice join was cancelled.",
1695
+ guildId,
1696
+ channelId
1697
+ });
1663
1698
  const existing = this.params.sessions.get(guildId);
1664
1699
  if (existing && existing.channelId === channelId) {
1700
+ existing.autoJoinWhenOccupied = options?.autoJoinWhenOccupied === true;
1665
1701
  if (authority) existing.generation = authority.generation;
1666
1702
  if (options?.transcripts) existing.transcripts = options.transcripts;
1667
1703
  if (!options?.transcripts && isDiscordRealtimeVoiceMode(voiceMode) && existing.realtimeLifecycle.status !== "active" && existing.realtimeLifecycle.status !== "starting") {
@@ -1688,14 +1724,20 @@ var DiscordVoiceSessions = class {
1688
1724
  logVoiceVerbose(`join: replacing existing session for guild ${guildId}`);
1689
1725
  await this.leave({ guildId }, { preserveFollowState: options?.preserveFollowState });
1690
1726
  }
1691
- const channelInfo = await this.params.client.fetchChannel(channelId).catch(() => null);
1692
- if (authority && !authority.isCurrent()) return {
1693
- ok: false,
1694
- message: "Discord voice join was cancelled.",
1695
- guildId,
1696
- channelId
1697
- };
1698
- if (!channelInfo || "type" in channelInfo && !isVoiceChannel(channelInfo.type)) return {
1727
+ let channelInfo;
1728
+ try {
1729
+ channelInfo = await this.params.client.fetchChannel(channelId);
1730
+ } catch (err) {
1731
+ if (authority && !authority.isCurrent()) return cancelledJoinResult();
1732
+ return {
1733
+ ok: false,
1734
+ message: `Failed to resolve Discord channel ${channelId}: ${formatErrorMessage(err)}`,
1735
+ guildId,
1736
+ channelId
1737
+ };
1738
+ }
1739
+ if (authority && !authority.isCurrent()) return cancelledJoinResult();
1740
+ if (!isVoiceChannel(channelInfo.type)) return {
1699
1741
  ok: false,
1700
1742
  message: `Channel ${channelId} is not a voice channel.`
1701
1743
  };
@@ -1717,10 +1759,7 @@ var DiscordVoiceSessions = class {
1717
1759
  logVoiceVerbose(`join: DAVE settings encryption=${daveEncryption === false ? "off" : "on"} tolerance=${decryptionFailureTolerance ?? "default"} connectTimeout=${connectReadyTimeoutMs}ms reconnectGrace=${reconnectGraceMs}ms`);
1718
1760
  const voiceSdk = loadDiscordVoiceSdk();
1719
1761
  const existingEntry = this.params.sessions.get(guildId);
1720
- if (existingEntry) {
1721
- existingEntry.stop();
1722
- this.params.sessions.delete(guildId);
1723
- }
1762
+ if (existingEntry) existingEntry.stop();
1724
1763
  const voiceConnectionGroup = resolveVoiceConnectionGroup(this.params.accountId);
1725
1764
  const staleConnection = voiceSdk.getVoiceConnection(guildId, voiceConnectionGroup);
1726
1765
  if (staleConnection) destroyVoiceConnectionSafely({
@@ -1774,12 +1813,7 @@ var DiscordVoiceSessions = class {
1774
1813
  voiceSdk,
1775
1814
  reason: `cancelled join guild ${guildId} channel ${channelId}`
1776
1815
  });
1777
- return {
1778
- ok: false,
1779
- message: "Discord voice join was cancelled.",
1780
- guildId,
1781
- channelId
1782
- };
1816
+ return cancelledJoinResult();
1783
1817
  }
1784
1818
  if (this.params.destroyed()) {
1785
1819
  destroyVoiceConnectionSafely({
@@ -1820,24 +1854,22 @@ var DiscordVoiceSessions = class {
1820
1854
  }
1821
1855
  const { route, voiceRoute, agentSessionMode, agentSessionTarget } = routeInfo;
1822
1856
  logger$2.info(`discord voice: joining guild=${guildId} channel=${channelId} mode=${voiceMode} agent=${route.agentId} voiceSession=${voiceRoute.sessionKey} supervisorSession=${route.sessionKey} agentSessionMode=${agentSessionMode}${agentSessionTarget ? ` agentSessionTarget=${agentSessionTarget}` : ""} voiceModel=${voiceConfig?.model ?? "route-default"} realtimeProvider=${voiceConfig?.realtime?.provider ?? "auto"} realtimeModel=${voiceConfig?.realtime?.model ?? "provider-default"} realtimeVoice=${voiceConfig?.realtime?.speakerVoice ?? voiceConfig?.realtime?.speakerVoiceId ?? "provider-default"}`);
1823
- const player = voiceSdk.createAudioPlayer();
1857
+ const player = isDiscordRealtimeVoiceMode(voiceMode) ? voiceSdk.createAudioPlayer({ behaviors: { maxMissedFrames: REALTIME_PLAYBACK_MAX_MISSED_FRAMES } }) : voiceSdk.createAudioPlayer();
1824
1858
  connection.subscribe(player);
1825
- const clearSessionIfCurrent = () => {
1826
- if (this.params.sessions.get(guildId)?.connection === connection) this.params.sessions.delete(guildId);
1827
- };
1828
- const stopEntry = (entry, optionsLocal) => {
1859
+ const stopEntry = (optionsLocal) => {
1829
1860
  if (entry.sessionLifecycle.status === "stopped") return;
1830
1861
  entry.sessionLifecycle = {
1831
1862
  status: "stopped",
1832
1863
  reason: optionsLocal.reason
1833
1864
  };
1865
+ if (this.params.sessions.get(guildId) === entry) this.params.sessions.delete(guildId);
1834
1866
  this.params.membership.deactivate(entry);
1835
- if (speakingHandler) connection.receiver.speaking.off("start", speakingHandler);
1836
- if (speakingEndHandler) connection.receiver.speaking.off("end", speakingEndHandler);
1867
+ connection.receiver.speaking.off("start", speakingHandler);
1868
+ connection.receiver.speaking.off("end", speakingEndHandler);
1837
1869
  stopVoiceCaptureState(entry.capture);
1838
- if (disconnectedHandler) connection.off(voiceSdk.VoiceConnectionStatus.Disconnected, disconnectedHandler);
1839
- if (destroyedHandler) connection.off(voiceSdk.VoiceConnectionStatus.Destroyed, destroyedHandler);
1840
- if (playerErrorHandler) player.off("error", playerErrorHandler);
1870
+ connection.off(voiceSdk.VoiceConnectionStatus.Disconnected, disconnectedHandler);
1871
+ connection.off(voiceSdk.VoiceConnectionStatus.Destroyed, destroyedHandler);
1872
+ player.off("error", playerErrorHandler);
1841
1873
  const realtimeLifecycle = entry.realtimeLifecycle;
1842
1874
  if (realtimeLifecycle.status === "starting" || realtimeLifecycle.status === "active") realtimeLifecycle.instance.close();
1843
1875
  entry.realtimeLifecycle = {
@@ -1845,7 +1877,7 @@ var DiscordVoiceSessions = class {
1845
1877
  generation: realtimeLifecycle.generation,
1846
1878
  reason: optionsLocal.reason
1847
1879
  };
1848
- player.stop();
1880
+ player.stop(true);
1849
1881
  if (optionsLocal.destroyConnection) destroyVoiceConnectionSafely({
1850
1882
  connection,
1851
1883
  voiceSdk,
@@ -1855,6 +1887,7 @@ var DiscordVoiceSessions = class {
1855
1887
  };
1856
1888
  const entry = {
1857
1889
  generation: authority?.generation ?? 0,
1890
+ autoJoinWhenOccupied: options?.autoJoinWhenOccupied === true,
1858
1891
  sessionLifecycle: { status: "active" },
1859
1892
  guildId,
1860
1893
  guildName: channelInfo && "guild" in channelInfo && channelInfo.guild && typeof channelInfo.guild.name === "string" ? channelInfo.guild.name : void 0,
@@ -1867,6 +1900,7 @@ var DiscordVoiceSessions = class {
1867
1900
  player,
1868
1901
  playbackQueue: Promise.resolve(),
1869
1902
  processingQueue: Promise.resolve(),
1903
+ ttsStreamFallbackWarned: false,
1870
1904
  capture: createVoiceCaptureState(),
1871
1905
  transcripts: options?.transcripts,
1872
1906
  receiveRecovery: createVoiceReceiveRecoveryState(),
@@ -1875,41 +1909,12 @@ var DiscordVoiceSessions = class {
1875
1909
  generation: 0
1876
1910
  },
1877
1911
  stop(reason) {
1878
- clearSessionIfCurrent();
1879
- stopEntry(entry, {
1912
+ stopEntry({
1880
1913
  destroyConnection: true,
1881
1914
  reason: reason ?? `stop guild ${guildId} channel ${channelId}`
1882
1915
  });
1883
1916
  }
1884
1917
  };
1885
- if (!options?.transcripts && isDiscordRealtimeVoiceMode(voiceMode)) {
1886
- const realtimeResult = await this.attachRealtimeSession(entry, voiceMode, { isCurrent: authority?.isCurrent });
1887
- if (!realtimeResult.ok) {
1888
- destroyVoiceConnectionSafely({
1889
- connection,
1890
- voiceSdk,
1891
- reason: `realtime setup failed guild ${guildId} channel ${channelId}`
1892
- });
1893
- return {
1894
- ok: false,
1895
- message: realtimeResult.message,
1896
- guildId,
1897
- channelId
1898
- };
1899
- }
1900
- }
1901
- if (this.params.destroyed() || authority && !authority.isCurrent()) {
1902
- stopEntry(entry, {
1903
- destroyConnection: true,
1904
- reason: `${this.params.destroyed() ? "manager stopped" : "join cancelled"} during setup guild ${guildId} channel ${channelId}`
1905
- });
1906
- return {
1907
- ok: false,
1908
- message: this.params.destroyed() ? "Discord voice manager is stopped." : "Discord voice join was cancelled.",
1909
- guildId,
1910
- channelId
1911
- };
1912
- }
1913
1918
  const speakingHandler = (userId) => {
1914
1919
  this.params.receive.handleSpeakingStart(entry, userId).catch((err) => {
1915
1920
  logger$2.warn(`discord voice: capture failed: ${formatErrorMessage(err)}`);
@@ -1926,8 +1931,7 @@ var DiscordVoiceSessions = class {
1926
1931
  logVoiceVerbose(`disconnected: recovery started guild ${guildId} channel ${channelId}`);
1927
1932
  } catch (err) {
1928
1933
  logger$2.warn(`discord voice: disconnect recovery failed: guild ${guildId} channel ${channelId} timeout=${reconnectGraceMs}ms error=${formatErrorMessage(err)}; destroying connection`);
1929
- clearSessionIfCurrent();
1930
- stopEntry(entry, {
1934
+ stopEntry({
1931
1935
  destroyConnection: true,
1932
1936
  reason: `disconnect recovery failed guild ${guildId} channel ${channelId}`
1933
1937
  });
@@ -1935,8 +1939,7 @@ var DiscordVoiceSessions = class {
1935
1939
  })();
1936
1940
  };
1937
1941
  const destroyedHandler = () => {
1938
- clearSessionIfCurrent();
1939
- stopEntry(entry, {
1942
+ stopEntry({
1940
1943
  destroyConnection: false,
1941
1944
  reason: `destroyed guild ${guildId} channel ${channelId}`
1942
1945
  });
@@ -1944,12 +1947,33 @@ var DiscordVoiceSessions = class {
1944
1947
  const playerErrorHandler = (err) => {
1945
1948
  logger$2.warn(`discord voice: playback error: ${formatErrorMessage(err)}`);
1946
1949
  };
1947
- this.params.receive.enableDaveReceivePassthrough(entry, "post-join warmup", 30);
1948
- connection.receiver.speaking.on("start", speakingHandler);
1949
- connection.receiver.speaking.on("end", speakingEndHandler);
1950
1950
  connection.on(voiceSdk.VoiceConnectionStatus.Disconnected, disconnectedHandler);
1951
1951
  connection.on(voiceSdk.VoiceConnectionStatus.Destroyed, destroyedHandler);
1952
1952
  player.on("error", playerErrorHandler);
1953
+ if (!options?.transcripts && isDiscordRealtimeVoiceMode(voiceMode)) {
1954
+ const realtimeResult = await this.attachRealtimeSession(entry, voiceMode, { isCurrent: authority?.isCurrent });
1955
+ if (!realtimeResult.ok) {
1956
+ entry.stop(`realtime setup failed guild ${guildId} channel ${channelId}`);
1957
+ return {
1958
+ ok: false,
1959
+ message: realtimeResult.message,
1960
+ guildId,
1961
+ channelId
1962
+ };
1963
+ }
1964
+ }
1965
+ if (isVoiceSessionStopped(entry) || this.params.destroyed() || authority && !authority.isCurrent()) {
1966
+ entry.stop(`${this.params.destroyed() ? "manager stopped" : "join cancelled"} during setup guild ${guildId} channel ${channelId}`);
1967
+ return {
1968
+ ok: false,
1969
+ message: this.params.destroyed() ? "Discord voice manager is stopped." : "Discord voice join was cancelled.",
1970
+ guildId,
1971
+ channelId
1972
+ };
1973
+ }
1974
+ this.params.receive.enableDaveReceivePassthrough(entry, "post-join warmup", 30);
1975
+ connection.receiver.speaking.on("start", speakingHandler);
1976
+ connection.receiver.speaking.on("end", speakingEndHandler);
1953
1977
  this.params.sessions.set(guildId, entry);
1954
1978
  this.params.membership.activate(entry, this.params.botUserId());
1955
1979
  logger$2.info(`discord voice: joined guild=${guildId} channel=${channelId} mode=${voiceMode} agent=${route.agentId} voiceSession=${voiceRoute.sessionKey} supervisorSession=${route.sessionKey} voiceModel=${voiceConfig?.model ?? "route-default"}`);
@@ -1990,7 +2014,6 @@ var DiscordVoiceSessions = class {
1990
2014
  }
1991
2015
  }
1992
2016
  entry.stop();
1993
- this.params.sessions.delete(guildId);
1994
2017
  if (!entry.receiveRecovery.decryptRecoveryInFlight) this.params.receive.deleteRecoveryAttempt(guildId);
1995
2018
  if (!options?.preserveFollowState) this.params.onLeaveFollowState(guildId);
1996
2019
  logVoiceVerbose(`leave: disconnected from guild ${guildId} channel ${entry.channelId}`);
@@ -2011,8 +2034,9 @@ var DiscordVoiceSessions = class {
2011
2034
  ok: false,
2012
2035
  message: "Discord realtime voice session stopped before startup completed."
2013
2036
  };
2014
- const { DiscordRealtimeVoiceSession } = await import("./realtime-session.runtime-C7wen-aF.js");
2037
+ const { DiscordRealtimeVoiceSession } = await import("./realtime-session.runtime-CU8IQUS-.js");
2015
2038
  const realtime = new DiscordRealtimeVoiceSession({
2039
+ accountId: this.params.accountId,
2016
2040
  bootstrapContextInstructions,
2017
2041
  cfg: this.params.cfg,
2018
2042
  discordConfig: this.params.discordConfig,
@@ -2069,8 +2093,8 @@ var DiscordVoiceSessions = class {
2069
2093
  //#endregion
2070
2094
  //#region extensions/discord/src/voice/listeners.ts
2071
2095
  const logger$1 = createSubsystemLogger("discord/voice");
2072
- function startAutoJoin(manager) {
2073
- manager.autoJoin().catch((err) => logger$1.warn(`discord voice: autoJoin failed: ${formatErrorMessage(err)}`));
2096
+ function startAutoJoin(operation, context = "") {
2097
+ operation().catch((err) => logger$1.warn(`discord voice: autoJoin${context} failed: ${formatErrorMessage(err)}`));
2074
2098
  }
2075
2099
  var DiscordVoiceReadyListener = class extends ReadyListener {
2076
2100
  constructor(manager) {
@@ -2078,7 +2102,7 @@ var DiscordVoiceReadyListener = class extends ReadyListener {
2078
2102
  this.manager = manager;
2079
2103
  }
2080
2104
  async handle(_data, _client) {
2081
- startAutoJoin(this.manager);
2105
+ startAutoJoin(() => this.manager.autoJoin());
2082
2106
  }
2083
2107
  };
2084
2108
  var DiscordVoiceResumedListener = class extends ResumedListener {
@@ -2087,7 +2111,7 @@ var DiscordVoiceResumedListener = class extends ResumedListener {
2087
2111
  this.manager = manager;
2088
2112
  }
2089
2113
  async handle(_data, _client) {
2090
- startAutoJoin(this.manager);
2114
+ startAutoJoin(() => this.manager.autoJoin());
2091
2115
  }
2092
2116
  };
2093
2117
  var DiscordVoiceGuildCreateListener = class {
@@ -2096,7 +2120,10 @@ var DiscordVoiceGuildCreateListener = class {
2096
2120
  this.type = discord_exports.GatewayDispatchEvents.GuildCreate;
2097
2121
  }
2098
2122
  async handle(data, _client) {
2099
- if (!data.unavailable) this.manager.refreshGuildRoster(data.id);
2123
+ if (!data.unavailable) {
2124
+ this.manager.refreshGuildRoster(data.id);
2125
+ startAutoJoin(() => this.manager.reconcileAutoJoinGuild(data.id), ` occupancy reconciliation guild=${data.id}`);
2126
+ }
2100
2127
  }
2101
2128
  };
2102
2129
  var DiscordVoiceStateUpdateListener = class extends VoiceStateUpdateListener {
@@ -2137,9 +2164,10 @@ var DiscordVoiceManager = class {
2137
2164
  this.guildLifecycles = /* @__PURE__ */ new Map();
2138
2165
  this.nextGuildGeneration = 0;
2139
2166
  this.joinTasks = /* @__PURE__ */ new Map();
2140
- this.autoJoinTask = null;
2167
+ this.autoJoinTasks = /* @__PURE__ */ new Map();
2141
2168
  this.fatalAutoJoinFailures = /* @__PURE__ */ new Map();
2142
2169
  this.destroyed = false;
2170
+ this.client = params.client;
2143
2171
  this.botUserId = params.botUserId;
2144
2172
  this.voiceEnabled = resolveDiscordVoiceEnabled(params.discordConfig.voice);
2145
2173
  const voiceAccess = resolveDiscordVoiceAccess(params);
@@ -2153,6 +2181,7 @@ var DiscordVoiceManager = class {
2153
2181
  });
2154
2182
  this.membership = new DiscordVoiceMembershipTracker(params.client, this.speakerContext, params.accountId);
2155
2183
  this.receive = new DiscordVoiceReceive({
2184
+ accountId: params.accountId,
2156
2185
  admissionAllowFrom: this.admissionAllowFrom,
2157
2186
  botUserId: () => this.botUserId,
2158
2187
  cfg: params.cfg,
@@ -2218,51 +2247,24 @@ var DiscordVoiceManager = class {
2218
2247
  }
2219
2248
  async autoJoin() {
2220
2249
  if (!this.voiceEnabled || this.destroyed) return;
2221
- if (this.autoJoinTask) return this.autoJoinTask;
2222
- this.autoJoinTask = (async () => {
2223
- const entries = this.autoJoinChannels;
2224
- const entriesByGuild = /* @__PURE__ */ new Map();
2225
- const duplicateGuilds = /* @__PURE__ */ new Set();
2226
- for (const entry of entries) {
2227
- const guildId = entry.guildId.trim();
2228
- const channelId = entry.channelId.trim();
2229
- if (!guildId || !channelId) continue;
2230
- if (entriesByGuild.has(guildId)) duplicateGuilds.add(guildId);
2231
- entriesByGuild.set(guildId, {
2232
- guildId,
2233
- channelId
2234
- });
2235
- }
2236
- logVoiceVerbose(`autoJoin: ${entries.length} entries, ${entriesByGuild.size} guilds`);
2237
- for (const guildId of duplicateGuilds) {
2238
- const selected = entriesByGuild.get(guildId);
2239
- if (selected) logger.warn(`discord voice: autoJoin has multiple entries for guild ${guildId}; using channel ${selected.channelId}`);
2240
- }
2241
- for (const entry of entriesByGuild.values()) {
2242
- const failureKey = formatAutoJoinFailureKey(entry);
2243
- const fatalFailure = this.fatalAutoJoinFailures.get(failureKey);
2244
- if (fatalFailure) {
2245
- if (!fatalFailure.skipLogged) {
2246
- logger.warn(`discord voice: autoJoin suppressed guild=${entry.guildId} channel=${entry.channelId} after fatal startup failure; retry with /vc join or reload config after fixing credentials: ${fatalFailure.message}`);
2247
- fatalFailure.skipLogged = true;
2248
- }
2249
- continue;
2250
- }
2251
- logVoiceVerbose(`autoJoin: joining guild ${entry.guildId} channel ${entry.channelId}`);
2252
- const result = await this.join(entry);
2253
- if (!result.ok) {
2254
- logger.warn(`discord voice: autoJoin skipped guild=${entry.guildId} channel=${entry.channelId}: ${result.message}`);
2255
- if (isFatalAutoJoinFailure(result.message)) this.fatalAutoJoinFailures.set(failureKey, {
2256
- message: result.message,
2257
- skipLogged: false
2258
- });
2259
- }
2260
- }
2261
- await this.following.startReconciliation();
2262
- })().finally(() => {
2263
- this.autoJoinTask = null;
2264
- });
2265
- return this.autoJoinTask;
2250
+ const entriesByGuild = /* @__PURE__ */ new Map();
2251
+ const duplicateGuilds = /* @__PURE__ */ new Set();
2252
+ for (const entry of this.autoJoinChannels) {
2253
+ if (entriesByGuild.has(entry.guildId)) duplicateGuilds.add(entry.guildId);
2254
+ entriesByGuild.set(entry.guildId, entry);
2255
+ }
2256
+ logVoiceVerbose(`autoJoin: ${this.autoJoinChannels.length} entries, ${entriesByGuild.size} guilds`);
2257
+ for (const guildId of duplicateGuilds) {
2258
+ const selected = entriesByGuild.get(guildId);
2259
+ if (selected) logger.warn(`discord voice: autoJoin has multiple entries for guild ${guildId}; using channel ${selected.channelId}`);
2260
+ }
2261
+ for (const entry of entriesByGuild.values()) await this.enqueueAutoJoin(entry);
2262
+ await this.following.startReconciliation();
2263
+ }
2264
+ async reconcileAutoJoinGuild(guildId) {
2265
+ const entry = this.resolveAutoJoinTarget(guildId);
2266
+ if (!entry?.whenOccupied || !this.voiceEnabled || this.destroyed) return;
2267
+ await this.enqueueAutoJoin(entry);
2266
2268
  }
2267
2269
  status() {
2268
2270
  return Array.from(this.guildLifecycles.values()).filter((lifecycle) => lifecycle.status === "active").map(({ instance: session }) => ({
@@ -2279,6 +2281,24 @@ var DiscordVoiceManager = class {
2279
2281
  channelId: params.channelId.trim()
2280
2282
  });
2281
2283
  }
2284
+ async resolveAccessTarget(params) {
2285
+ const [guild, channel] = await Promise.all([this.client.fetchGuild(params.guildId).catch(() => null), this.client.fetchChannel(params.channelId).catch(() => null)]);
2286
+ if (!guild || !channel) return;
2287
+ const context = await resolveFetchedDiscordThreadLikeChannelContext({
2288
+ client: this.client,
2289
+ channel,
2290
+ channelIdFallback: params.channelId
2291
+ });
2292
+ return {
2293
+ guild,
2294
+ ...context.channelName ? { channelName: context.channelName } : {},
2295
+ channelSlug: context.channelSlug,
2296
+ ...context.parentId ? { parentId: context.parentId } : {},
2297
+ ...context.threadParentName ? { parentName: context.threadParentName } : {},
2298
+ ...context.threadParentSlug ? { parentSlug: context.threadParentSlug } : {},
2299
+ scope: context.isThreadChannel ? "thread" : "channel"
2300
+ };
2301
+ }
2282
2302
  async join(params, options) {
2283
2303
  if (this.destroyed) return {
2284
2304
  ok: false,
@@ -2429,6 +2449,7 @@ var DiscordVoiceManager = class {
2429
2449
  guildId,
2430
2450
  channelId
2431
2451
  });
2452
+ await this.reconcileAutoJoinGuild(guildId);
2432
2453
  return;
2433
2454
  }
2434
2455
  this.membership.track(this.sessions.get(guildId), data, previousVoiceState);
@@ -2437,6 +2458,8 @@ var DiscordVoiceManager = class {
2437
2458
  channelId,
2438
2459
  userId
2439
2460
  });
2461
+ const autoJoinTarget = this.resolveAutoJoinTarget(guildId);
2462
+ if (autoJoinTarget?.whenOccupied) await this.enqueueAutoJoin(autoJoinTarget);
2440
2463
  }
2441
2464
  async destroy() {
2442
2465
  this.destroyed = true;
@@ -2454,6 +2477,65 @@ var DiscordVoiceManager = class {
2454
2477
  const lifecycle = this.guildLifecycles.get(entry.guildId);
2455
2478
  return lifecycle?.status === "active" && lifecycle.generation === entry.generation && lifecycle.instance === entry && entry.sessionLifecycle.status === "active";
2456
2479
  }
2480
+ resolveAutoJoinTarget(guildId) {
2481
+ return this.autoJoinChannels.toReversed().find((entry) => entry.guildId === guildId.trim());
2482
+ }
2483
+ enqueueAutoJoin(entry) {
2484
+ const task = (this.autoJoinTasks.get(entry.guildId) ?? Promise.resolve()).catch(() => void 0).then(async () => await this.reconcileAutoJoinEntry(entry)).finally(() => {
2485
+ if (this.autoJoinTasks.get(entry.guildId) === task) this.autoJoinTasks.delete(entry.guildId);
2486
+ });
2487
+ this.autoJoinTasks.set(entry.guildId, task);
2488
+ return task;
2489
+ }
2490
+ async reconcileAutoJoinEntry(entry) {
2491
+ if (this.destroyed) return;
2492
+ const failureKey = formatAutoJoinFailureKey(entry);
2493
+ const fatalFailure = this.fatalAutoJoinFailures.get(failureKey);
2494
+ if (fatalFailure) {
2495
+ if (!fatalFailure.skipLogged) {
2496
+ logger.warn(`discord voice: autoJoin suppressed guild=${entry.guildId} channel=${entry.channelId} after fatal startup failure; retry with /vc join or reload config after fixing credentials: ${fatalFailure.message}`);
2497
+ fatalFailure.skipLogged = true;
2498
+ }
2499
+ return;
2500
+ }
2501
+ if (entry.whenOccupied) {
2502
+ const states = listDiscordVoiceParticipantStates({
2503
+ client: this.client,
2504
+ guildId: entry.guildId,
2505
+ channelId: entry.channelId
2506
+ });
2507
+ if (states === null) {
2508
+ logVoiceVerbose(`autoJoin waiting for guild voice snapshot guild=${entry.guildId} channel=${entry.channelId}`);
2509
+ return;
2510
+ }
2511
+ const humanCount = countDiscordVoiceHumanParticipants({
2512
+ states,
2513
+ botUserId: this.botUserId
2514
+ });
2515
+ const existing = this.sessions.get(entry.guildId);
2516
+ if (humanCount === 0) {
2517
+ if (!existing?.autoJoinWhenOccupied || existing.channelId !== entry.channelId) return;
2518
+ logger.info(`discord voice: occupied autoJoin leaving empty channel guild=${entry.guildId} channel=${entry.channelId}`);
2519
+ const result = await this.leave({
2520
+ guildId: entry.guildId,
2521
+ channelId: entry.channelId
2522
+ });
2523
+ if (!result.ok) logger.warn(`discord voice: occupied autoJoin failed to leave guild=${entry.guildId} channel=${entry.channelId}: ${result.message}`);
2524
+ return;
2525
+ }
2526
+ const lifecycle = this.guildLifecycles.get(entry.guildId);
2527
+ if (existing || lifecycle?.status === "starting" || lifecycle?.status === "active") return;
2528
+ logger.info(`discord voice: occupied autoJoin joining guild=${entry.guildId} channel=${entry.channelId} humans=${humanCount}`);
2529
+ } else logVoiceVerbose(`autoJoin: joining guild ${entry.guildId} channel ${entry.channelId}`);
2530
+ const result = await this.join(entry, { autoJoinWhenOccupied: entry.whenOccupied === true });
2531
+ if (!result.ok) {
2532
+ logger.warn(`discord voice: autoJoin skipped guild=${entry.guildId} channel=${entry.channelId}: ${result.message}`);
2533
+ if (isFatalAutoJoinFailure(result.message)) this.fatalAutoJoinFailures.set(failureKey, {
2534
+ message: result.message,
2535
+ skipLogged: false
2536
+ });
2537
+ }
2538
+ }
2457
2539
  };
2458
2540
  //#endregion
2459
2541
  export { DiscordVoiceGuildCreateListener, DiscordVoiceManager, DiscordVoiceReadyListener, DiscordVoiceResumedListener, DiscordVoiceStateUpdateListener };