@openclaw/discord 2026.9.5 → 2026.9.6

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 (421) hide show
  1. package/dist/.setup/{activities-api-DBwRt5ES.mjs → activities-api-COU4-0nR.mjs} +4 -4
  2. package/dist/.setup/{approval-handler.runtime-Du3n5ypX.mjs → approval-handler.runtime-CbBktBb4.mjs} +5 -5
  3. package/dist/.setup/{approval-message-updates-BN7JtScm.mjs → approval-message-updates-jf9zMaIC.mjs} +1 -1
  4. package/dist/.setup/{audit-C8uaKoa9.mjs → audit-vKbh-LFR.mjs} +3 -3
  5. package/dist/.setup/{channel-ChKdlBgH.mjs → channel-Dv4e3Jpc.mjs} +19 -16
  6. package/dist/.setup/{channel-actions.runtime-CJmiFfps.mjs → channel-actions.runtime-leZuw01r.mjs} +13 -7
  7. package/dist/.setup/{channel.setup-BlC3-Kzz.mjs → channel.setup-0NX6FFwi.mjs} +1 -1
  8. package/dist/.setup/{components-MqMWUWnE.mjs → components-yBEb75bB.mjs} +1 -2
  9. package/dist/.setup/{conversation-binding-route-_rz33QHO.mjs → conversation-binding-route-B7qImK_b.mjs} +6 -3
  10. package/dist/.setup/{doctor-DxcdkXzz.mjs → doctor-D1R-uFIu.mjs} +2 -2
  11. package/dist/.setup/{handle-action.guild-admin-DAFyh_yV.mjs → handle-action.guild-admin-DcFa8NwA.mjs} +3 -3
  12. package/dist/.setup/{message-handler-DnUrDpaU.mjs → message-handler-X6ejmbtY.mjs} +6 -5
  13. package/dist/.setup/{message-handler.preflight-CtqaF_fb.mjs → message-handler.preflight-DE_POxFc.mjs} +14 -117
  14. package/dist/.setup/message-handler.preflight-pluralkit-8Xji34AF.mjs +143 -0
  15. package/dist/.setup/{message-handler.process-Dz1xvuQU.mjs → message-handler.process-CCmIVnxy.mjs} +387 -317
  16. package/dist/.setup/{outbound-adapter-C8v79z9Z.mjs → outbound-adapter-ClIgmu4F.mjs} +5 -5
  17. package/dist/.setup/{outbound-session-route-CqWbuMOm.mjs → outbound-session-route-VulUE0yV.mjs} +7 -6
  18. package/dist/.setup/{preflight-audio-DrnqFA8U.mjs → preflight-audio-DHGIHEpv.mjs} +2 -1
  19. package/dist/.setup/{provider-72zIvN-i.mjs → provider-iOf73HW-.mjs} +425 -286
  20. package/dist/.setup/{provider-session.runtime-BW7QrF5C.mjs → provider-session.runtime-DrGAYnZv.mjs} +3 -3
  21. package/dist/.setup/provider.runtime-BmjW_pIw.mjs +2 -0
  22. package/dist/.setup/{realtime-session.runtime-DTccTgTM.mjs → realtime-session.runtime-Dz8uVutq.mjs} +338 -297
  23. package/dist/.setup/receive-recovery-DHst8WRx.mjs +517 -0
  24. package/dist/.setup/{retry-DBfcEgmO.mjs → retry-BEYkDy0P.mjs} +78 -13
  25. package/dist/.setup/{runtime-SchNfUsQ.mjs → runtime-B8lJfyrA.mjs} +30 -11
  26. package/dist/.setup/{runtime-BVoa7hhx.mjs → runtime-DisDbixd.mjs} +1 -1
  27. package/dist/.setup/{send-CKDczUNL.mjs → send-CIBzvXjS.mjs} +23 -9
  28. package/dist/.setup/{send.components-DWQjXhPV.mjs → send.components-ChY21qr-.mjs} +4 -4
  29. package/dist/.setup/{send.outbound-D0hQ7s50.mjs → send.outbound-QTyuFupn.mjs} +15 -16
  30. package/dist/.setup/{send.shared-Zwx6BxQ5.mjs → send.shared-VNvWfX2T.mjs} +2 -2
  31. package/dist/.setup/setup-plugin-api-Dvr41dyx.mjs +3 -0
  32. package/dist/.setup/{shared-CaA3Vv4n.mjs → shared-DHPDaMSx.mjs} +1 -1
  33. package/dist/.setup/{subagent-hooks-Bired9q6.mjs → subagent-hooks-CjW7r8Pe.mjs} +1 -1
  34. package/dist/.setup/{target-resolver-B6MrxbYv.mjs → target-resolver-BXpy6VT8.mjs} +1 -1
  35. package/dist/.setup/targets-CvemhN3i.mjs +3 -0
  36. package/dist/.setup/{thread-bindings-CK5272V3.mjs → thread-bindings-CEh2dhqP.mjs} +3 -3
  37. package/dist/.setup/{thread-bindings.manager-eexkKyrG.mjs → thread-bindings.manager-ve-i6oqt.mjs} +94 -45
  38. package/dist/.setup/{transcripts-source-CuWYgayu.mjs → transcripts-source-DVegW0WI.mjs} +61 -7
  39. package/dist/.setup/{voice-runtime-DHVQ2mFz.mjs → voice-runtime-elTtjEIG.mjs} +553 -901
  40. package/dist/action-runtime-api.js +1 -1
  41. package/dist/activities-api.js +1 -1
  42. package/dist/api.js +10 -10
  43. package/dist/channel-plugin-api.js +1 -1
  44. package/dist/index.js +1 -1
  45. package/dist/runtime-api.js +12 -12
  46. package/dist/setup-entry.js +1 -1
  47. package/dist/setup-plugin-api.js +1 -1
  48. package/dist/src/voice/audio-worker.runtime.js +1065 -0
  49. package/dist/subagent-hooks-api.js +1 -1
  50. package/dist/transcripts-source-api.js +1 -1
  51. package/node_modules/@napi-rs/wasm-runtime/dist/emnapi-plugins.cjs +8 -4
  52. package/node_modules/@napi-rs/wasm-runtime/dist/emnapi-plugins.js +8 -4
  53. package/node_modules/@napi-rs/wasm-runtime/dist/fs-proxy.cjs +1 -1
  54. package/node_modules/@napi-rs/wasm-runtime/dist/fs.js +770 -695
  55. package/node_modules/@napi-rs/wasm-runtime/fs-proxy.js +3 -2
  56. package/node_modules/@napi-rs/wasm-runtime/package.json +1 -1
  57. package/node_modules/@tybys/wasm-util/LICENSE +21 -0
  58. package/node_modules/@tybys/wasm-util/package.json +1 -1
  59. package/node_modules/@types/node/README.md +1 -1
  60. package/node_modules/@types/node/package.json +2 -2
  61. package/node_modules/@types/node/web-globals/streams.d.ts +4 -0
  62. package/node_modules/zod/README.md +2 -2
  63. package/node_modules/zod/compile.cjs +19 -0
  64. package/node_modules/zod/index.cjs +19 -0
  65. package/node_modules/zod/locales/index.cjs +19 -0
  66. package/node_modules/zod/mini/index.cjs +19 -0
  67. package/node_modules/zod/package.json +8 -7
  68. package/node_modules/zod/src/v3/helpers/errorUtil.ts +1 -1
  69. package/node_modules/zod/src/v4/classic/external.ts +2 -0
  70. package/node_modules/zod/src/v4/classic/from-json-schema.ts +248 -25
  71. package/node_modules/zod/src/v4/classic/schemas.ts +243 -168
  72. package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +60 -9
  73. package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +6 -0
  74. package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +2 -2
  75. package/node_modules/zod/src/v4/classic/tests/cyclic-data.test.ts +265 -0
  76. package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +112 -6
  77. package/node_modules/zod/src/v4/classic/tests/enum.test.ts +9 -0
  78. package/node_modules/zod/src/v4/classic/tests/error.test.ts +130 -1
  79. package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +157 -0
  80. package/node_modules/zod/src/v4/classic/tests/iban.test.ts +81 -0
  81. package/node_modules/zod/src/v4/classic/tests/instance-footprint.test.ts +40 -2
  82. package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +27 -7
  83. package/node_modules/zod/src/v4/classic/tests/issue-schema.test.ts +88 -56
  84. package/node_modules/zod/src/v4/classic/tests/number.test.ts +39 -0
  85. package/node_modules/zod/src/v4/classic/tests/object.test.ts +56 -0
  86. package/node_modules/zod/src/v4/classic/tests/optin-ladder.test.ts +3 -2
  87. package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +70 -0
  88. package/node_modules/zod/src/v4/classic/tests/properties.test.ts +141 -0
  89. package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +46 -1
  90. package/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +19 -0
  91. package/node_modules/zod/src/v4/classic/tests/string.test.ts +95 -1
  92. package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +33 -1
  93. package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +234 -38
  94. package/node_modules/zod/src/v4/classic/tests/validate.test.ts +569 -0
  95. package/node_modules/zod/src/v4/core/api.ts +44 -28
  96. package/node_modules/zod/src/v4/core/checks.ts +62 -102
  97. package/node_modules/zod/src/v4/core/compile.ts +218 -93
  98. package/node_modules/zod/src/v4/core/core.ts +1 -3
  99. package/node_modules/zod/src/v4/core/doc.ts +6 -2
  100. package/node_modules/zod/src/v4/core/errors.ts +3 -6
  101. package/node_modules/zod/src/v4/core/json-schema-generator.ts +2 -2
  102. package/node_modules/zod/src/v4/core/json-schema-processors.ts +185 -81
  103. package/node_modules/zod/src/v4/core/memoizer.ts +75 -28
  104. package/node_modules/zod/src/v4/core/parse.ts +37 -16
  105. package/node_modules/zod/src/v4/core/regexes.ts +14 -4
  106. package/node_modules/zod/src/v4/core/schemas.ts +296 -132
  107. package/node_modules/zod/src/v4/core/tests/cached.test.ts +54 -0
  108. package/node_modules/zod/src/v4/core/tests/compile-differential.test.ts +35 -0
  109. package/node_modules/zod/src/v4/core/tests/compile-generative.test.ts +445 -0
  110. package/node_modules/zod/src/v4/core/tests/compile.test.ts +399 -2
  111. package/node_modules/zod/src/v4/core/tests/email-regex.test.ts +140 -0
  112. package/node_modules/zod/src/v4/core/tests/locales/tg.test.ts +85 -0
  113. package/node_modules/zod/src/v4/core/tests/polyfill-collision.test.ts +46 -0
  114. package/node_modules/zod/src/v4/core/tests/url-no-canparse.test.ts +118 -16
  115. package/node_modules/zod/src/v4/core/to-json-schema.ts +9 -7
  116. package/node_modules/zod/src/v4/core/util.ts +218 -147
  117. package/node_modules/zod/src/v4/core/versions.ts +2 -2
  118. package/node_modules/zod/src/v4/locales/ar.ts +2 -0
  119. package/node_modules/zod/src/v4/locales/az.ts +2 -0
  120. package/node_modules/zod/src/v4/locales/be.ts +2 -0
  121. package/node_modules/zod/src/v4/locales/bg.ts +2 -0
  122. package/node_modules/zod/src/v4/locales/bn.ts +2 -0
  123. package/node_modules/zod/src/v4/locales/ca.ts +2 -0
  124. package/node_modules/zod/src/v4/locales/ckb.ts +2 -0
  125. package/node_modules/zod/src/v4/locales/cs.ts +2 -0
  126. package/node_modules/zod/src/v4/locales/da.ts +2 -0
  127. package/node_modules/zod/src/v4/locales/de.ts +2 -0
  128. package/node_modules/zod/src/v4/locales/el.ts +2 -0
  129. package/node_modules/zod/src/v4/locales/en.ts +2 -0
  130. package/node_modules/zod/src/v4/locales/eo.ts +2 -0
  131. package/node_modules/zod/src/v4/locales/es.ts +2 -0
  132. package/node_modules/zod/src/v4/locales/fa.ts +2 -0
  133. package/node_modules/zod/src/v4/locales/fi.ts +2 -0
  134. package/node_modules/zod/src/v4/locales/fr-CA.ts +2 -0
  135. package/node_modules/zod/src/v4/locales/fr.ts +2 -0
  136. package/node_modules/zod/src/v4/locales/gu.ts +2 -0
  137. package/node_modules/zod/src/v4/locales/he.ts +2 -0
  138. package/node_modules/zod/src/v4/locales/hi.ts +2 -0
  139. package/node_modules/zod/src/v4/locales/hr.ts +2 -0
  140. package/node_modules/zod/src/v4/locales/hu.ts +2 -0
  141. package/node_modules/zod/src/v4/locales/hy.ts +2 -0
  142. package/node_modules/zod/src/v4/locales/id.ts +2 -0
  143. package/node_modules/zod/src/v4/locales/index.ts +1 -0
  144. package/node_modules/zod/src/v4/locales/is.ts +2 -0
  145. package/node_modules/zod/src/v4/locales/it.ts +2 -0
  146. package/node_modules/zod/src/v4/locales/ja.ts +2 -0
  147. package/node_modules/zod/src/v4/locales/ka.ts +2 -0
  148. package/node_modules/zod/src/v4/locales/km.ts +2 -0
  149. package/node_modules/zod/src/v4/locales/kn.ts +2 -0
  150. package/node_modules/zod/src/v4/locales/ko.ts +2 -0
  151. package/node_modules/zod/src/v4/locales/lt.ts +2 -0
  152. package/node_modules/zod/src/v4/locales/mk.ts +2 -0
  153. package/node_modules/zod/src/v4/locales/ms.ts +2 -0
  154. package/node_modules/zod/src/v4/locales/ne.ts +2 -0
  155. package/node_modules/zod/src/v4/locales/nl.ts +2 -0
  156. package/node_modules/zod/src/v4/locales/nn.ts +2 -0
  157. package/node_modules/zod/src/v4/locales/no.ts +2 -0
  158. package/node_modules/zod/src/v4/locales/ota.ts +2 -0
  159. package/node_modules/zod/src/v4/locales/pl.ts +2 -0
  160. package/node_modules/zod/src/v4/locales/ps.ts +2 -0
  161. package/node_modules/zod/src/v4/locales/pt-BR.ts +2 -0
  162. package/node_modules/zod/src/v4/locales/pt.ts +2 -0
  163. package/node_modules/zod/src/v4/locales/ro.ts +2 -0
  164. package/node_modules/zod/src/v4/locales/ru.ts +2 -0
  165. package/node_modules/zod/src/v4/locales/sk.ts +2 -0
  166. package/node_modules/zod/src/v4/locales/sl.ts +2 -0
  167. package/node_modules/zod/src/v4/locales/sv.ts +2 -0
  168. package/node_modules/zod/src/v4/locales/ta.ts +2 -0
  169. package/node_modules/zod/src/v4/locales/tg.ts +135 -0
  170. package/node_modules/zod/src/v4/locales/th.ts +2 -0
  171. package/node_modules/zod/src/v4/locales/tk.ts +2 -0
  172. package/node_modules/zod/src/v4/locales/tr.ts +2 -0
  173. package/node_modules/zod/src/v4/locales/uk.ts +2 -0
  174. package/node_modules/zod/src/v4/locales/ur.ts +2 -0
  175. package/node_modules/zod/src/v4/locales/uz.ts +2 -0
  176. package/node_modules/zod/src/v4/locales/vi.ts +2 -0
  177. package/node_modules/zod/src/v4/locales/yo.ts +2 -0
  178. package/node_modules/zod/src/v4/locales/zh-CN.ts +2 -0
  179. package/node_modules/zod/src/v4/locales/zh-TW.ts +2 -0
  180. package/node_modules/zod/src/v4/mini/external.ts +2 -0
  181. package/node_modules/zod/src/v4/mini/schemas.ts +32 -7
  182. package/node_modules/zod/src/v4/mini/tests/checks.test.ts +1 -1
  183. package/node_modules/zod/src/v4/mini/tests/computed.test.ts +11 -17
  184. package/node_modules/zod/src/v4/mini/tests/index.test.ts +86 -0
  185. package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +16 -0
  186. package/node_modules/zod/src/v4/mini/tests/string.test.ts +23 -0
  187. package/node_modules/zod/v3/ZodError.cjs +19 -0
  188. package/node_modules/zod/v3/errors.cjs +19 -0
  189. package/node_modules/zod/v3/external.cjs +19 -0
  190. package/node_modules/zod/v3/helpers/enumUtil.cjs +19 -0
  191. package/node_modules/zod/v3/helpers/errorUtil.cjs +20 -1
  192. package/node_modules/zod/v3/helpers/errorUtil.js +1 -1
  193. package/node_modules/zod/v3/helpers/parseUtil.cjs +19 -0
  194. package/node_modules/zod/v3/helpers/partialUtil.cjs +19 -0
  195. package/node_modules/zod/v3/helpers/typeAliases.cjs +19 -0
  196. package/node_modules/zod/v3/helpers/util.cjs +19 -0
  197. package/node_modules/zod/v3/index.cjs +19 -0
  198. package/node_modules/zod/v3/standard-schema.cjs +19 -0
  199. package/node_modules/zod/v3/types.cjs +19 -0
  200. package/node_modules/zod/v4/classic/checks.cjs +19 -0
  201. package/node_modules/zod/v4/classic/coerce.cjs +19 -0
  202. package/node_modules/zod/v4/classic/compat.cjs +19 -0
  203. package/node_modules/zod/v4/classic/deep-partial.cjs +19 -0
  204. package/node_modules/zod/v4/classic/errors.cjs +19 -0
  205. package/node_modules/zod/v4/classic/external.cjs +22 -1
  206. package/node_modules/zod/v4/classic/external.d.cts +1 -1
  207. package/node_modules/zod/v4/classic/external.d.ts +1 -1
  208. package/node_modules/zod/v4/classic/external.js +1 -1
  209. package/node_modules/zod/v4/classic/from-json-schema.cjs +264 -24
  210. package/node_modules/zod/v4/classic/from-json-schema.js +245 -24
  211. package/node_modules/zod/v4/classic/in-out.cjs +19 -0
  212. package/node_modules/zod/v4/classic/index.cjs +19 -0
  213. package/node_modules/zod/v4/classic/iso.cjs +19 -0
  214. package/node_modules/zod/v4/classic/parse.cjs +19 -0
  215. package/node_modules/zod/v4/classic/schemas.cjs +100 -35
  216. package/node_modules/zod/v4/classic/schemas.d.cts +15 -1
  217. package/node_modules/zod/v4/classic/schemas.d.ts +15 -1
  218. package/node_modules/zod/v4/classic/schemas.js +77 -33
  219. package/node_modules/zod/v4/core/api.cjs +45 -22
  220. package/node_modules/zod/v4/core/api.d.cts +12 -6
  221. package/node_modules/zod/v4/core/api.d.ts +12 -6
  222. package/node_modules/zod/v4/core/api.js +25 -22
  223. package/node_modules/zod/v4/core/checks.cjs +51 -97
  224. package/node_modules/zod/v4/core/checks.d.cts +17 -1
  225. package/node_modules/zod/v4/core/checks.d.ts +17 -1
  226. package/node_modules/zod/v4/core/checks.js +31 -96
  227. package/node_modules/zod/v4/core/compile.cjs +173 -78
  228. package/node_modules/zod/v4/core/compile.d.cts +18 -4
  229. package/node_modules/zod/v4/core/compile.d.ts +18 -4
  230. package/node_modules/zod/v4/core/compile.js +154 -79
  231. package/node_modules/zod/v4/core/core.cjs +20 -1
  232. package/node_modules/zod/v4/core/core.js +1 -1
  233. package/node_modules/zod/v4/core/doc.cjs +26 -2
  234. package/node_modules/zod/v4/core/doc.js +7 -2
  235. package/node_modules/zod/v4/core/errors.cjs +21 -5
  236. package/node_modules/zod/v4/core/errors.js +2 -5
  237. package/node_modules/zod/v4/core/index.cjs +19 -0
  238. package/node_modules/zod/v4/core/json-schema-generator.cjs +20 -1
  239. package/node_modules/zod/v4/core/json-schema-generator.js +2 -2
  240. package/node_modules/zod/v4/core/json-schema-processors.cjs +188 -72
  241. package/node_modules/zod/v4/core/json-schema-processors.d.cts +16 -0
  242. package/node_modules/zod/v4/core/json-schema-processors.d.ts +16 -0
  243. package/node_modules/zod/v4/core/json-schema-processors.js +170 -74
  244. package/node_modules/zod/v4/core/json-schema.cjs +19 -0
  245. package/node_modules/zod/v4/core/memoizer.cjs +111 -23
  246. package/node_modules/zod/v4/core/memoizer.js +69 -23
  247. package/node_modules/zod/v4/core/parse.cjs +56 -16
  248. package/node_modules/zod/v4/core/parse.js +37 -16
  249. package/node_modules/zod/v4/core/regexes.cjs +31 -6
  250. package/node_modules/zod/v4/core/regexes.d.cts +3 -0
  251. package/node_modules/zod/v4/core/regexes.d.ts +3 -0
  252. package/node_modules/zod/v4/core/regexes.js +10 -4
  253. package/node_modules/zod/v4/core/registries.cjs +19 -0
  254. package/node_modules/zod/v4/core/schemas.cjs +302 -114
  255. package/node_modules/zod/v4/core/schemas.d.cts +28 -8
  256. package/node_modules/zod/v4/core/schemas.d.ts +28 -8
  257. package/node_modules/zod/v4/core/schemas.js +279 -113
  258. package/node_modules/zod/v4/core/standard-schema.cjs +19 -0
  259. package/node_modules/zod/v4/core/to-json-schema.cjs +28 -7
  260. package/node_modules/zod/v4/core/to-json-schema.d.cts +4 -3
  261. package/node_modules/zod/v4/core/to-json-schema.d.ts +4 -3
  262. package/node_modules/zod/v4/core/to-json-schema.js +7 -6
  263. package/node_modules/zod/v4/core/util.cjs +177 -143
  264. package/node_modules/zod/v4/core/util.d.cts +25 -4
  265. package/node_modules/zod/v4/core/util.d.ts +25 -4
  266. package/node_modules/zod/v4/core/util.js +156 -143
  267. package/node_modules/zod/v4/core/versions.cjs +21 -2
  268. package/node_modules/zod/v4/core/versions.d.cts +1 -1
  269. package/node_modules/zod/v4/core/versions.d.ts +1 -1
  270. package/node_modules/zod/v4/core/versions.js +2 -2
  271. package/node_modules/zod/v4/core/visit.cjs +19 -0
  272. package/node_modules/zod/v4/index.cjs +19 -0
  273. package/node_modules/zod/v4/locales/ar.cjs +2 -0
  274. package/node_modules/zod/v4/locales/ar.js +2 -0
  275. package/node_modules/zod/v4/locales/az.cjs +2 -0
  276. package/node_modules/zod/v4/locales/az.js +2 -0
  277. package/node_modules/zod/v4/locales/be.cjs +2 -0
  278. package/node_modules/zod/v4/locales/be.js +2 -0
  279. package/node_modules/zod/v4/locales/bg.cjs +2 -0
  280. package/node_modules/zod/v4/locales/bg.js +2 -0
  281. package/node_modules/zod/v4/locales/bn.cjs +2 -0
  282. package/node_modules/zod/v4/locales/bn.js +2 -0
  283. package/node_modules/zod/v4/locales/ca.cjs +2 -0
  284. package/node_modules/zod/v4/locales/ca.js +2 -0
  285. package/node_modules/zod/v4/locales/ckb.cjs +2 -0
  286. package/node_modules/zod/v4/locales/ckb.js +2 -0
  287. package/node_modules/zod/v4/locales/cs.cjs +2 -0
  288. package/node_modules/zod/v4/locales/cs.js +2 -0
  289. package/node_modules/zod/v4/locales/da.cjs +2 -0
  290. package/node_modules/zod/v4/locales/da.js +2 -0
  291. package/node_modules/zod/v4/locales/de.cjs +2 -0
  292. package/node_modules/zod/v4/locales/de.js +2 -0
  293. package/node_modules/zod/v4/locales/el.cjs +2 -0
  294. package/node_modules/zod/v4/locales/el.js +2 -0
  295. package/node_modules/zod/v4/locales/en.cjs +2 -0
  296. package/node_modules/zod/v4/locales/en.js +2 -0
  297. package/node_modules/zod/v4/locales/eo.cjs +2 -0
  298. package/node_modules/zod/v4/locales/eo.js +2 -0
  299. package/node_modules/zod/v4/locales/es.cjs +2 -0
  300. package/node_modules/zod/v4/locales/es.js +2 -0
  301. package/node_modules/zod/v4/locales/fa.cjs +2 -0
  302. package/node_modules/zod/v4/locales/fa.js +2 -0
  303. package/node_modules/zod/v4/locales/fi.cjs +2 -0
  304. package/node_modules/zod/v4/locales/fi.js +2 -0
  305. package/node_modules/zod/v4/locales/fr-CA.cjs +2 -0
  306. package/node_modules/zod/v4/locales/fr-CA.js +2 -0
  307. package/node_modules/zod/v4/locales/fr.cjs +2 -0
  308. package/node_modules/zod/v4/locales/fr.js +2 -0
  309. package/node_modules/zod/v4/locales/gu.cjs +2 -0
  310. package/node_modules/zod/v4/locales/gu.js +2 -0
  311. package/node_modules/zod/v4/locales/he.cjs +2 -0
  312. package/node_modules/zod/v4/locales/he.js +2 -0
  313. package/node_modules/zod/v4/locales/hi.cjs +2 -0
  314. package/node_modules/zod/v4/locales/hi.js +2 -0
  315. package/node_modules/zod/v4/locales/hr.cjs +2 -0
  316. package/node_modules/zod/v4/locales/hr.js +2 -0
  317. package/node_modules/zod/v4/locales/hu.cjs +2 -0
  318. package/node_modules/zod/v4/locales/hu.js +2 -0
  319. package/node_modules/zod/v4/locales/hy.cjs +2 -0
  320. package/node_modules/zod/v4/locales/hy.js +2 -0
  321. package/node_modules/zod/v4/locales/id.cjs +2 -0
  322. package/node_modules/zod/v4/locales/id.js +2 -0
  323. package/node_modules/zod/v4/locales/index.cjs +22 -1
  324. package/node_modules/zod/v4/locales/index.d.cts +1 -0
  325. package/node_modules/zod/v4/locales/index.d.ts +1 -0
  326. package/node_modules/zod/v4/locales/index.js +1 -0
  327. package/node_modules/zod/v4/locales/is.cjs +2 -0
  328. package/node_modules/zod/v4/locales/is.js +2 -0
  329. package/node_modules/zod/v4/locales/it.cjs +2 -0
  330. package/node_modules/zod/v4/locales/it.js +2 -0
  331. package/node_modules/zod/v4/locales/ja.cjs +2 -0
  332. package/node_modules/zod/v4/locales/ja.js +2 -0
  333. package/node_modules/zod/v4/locales/ka.cjs +2 -0
  334. package/node_modules/zod/v4/locales/ka.js +2 -0
  335. package/node_modules/zod/v4/locales/km.cjs +2 -0
  336. package/node_modules/zod/v4/locales/km.js +2 -0
  337. package/node_modules/zod/v4/locales/kn.cjs +2 -0
  338. package/node_modules/zod/v4/locales/kn.js +2 -0
  339. package/node_modules/zod/v4/locales/ko.cjs +2 -0
  340. package/node_modules/zod/v4/locales/ko.js +2 -0
  341. package/node_modules/zod/v4/locales/lt.cjs +2 -0
  342. package/node_modules/zod/v4/locales/lt.js +2 -0
  343. package/node_modules/zod/v4/locales/mk.cjs +2 -0
  344. package/node_modules/zod/v4/locales/mk.js +2 -0
  345. package/node_modules/zod/v4/locales/ms.cjs +2 -0
  346. package/node_modules/zod/v4/locales/ms.js +2 -0
  347. package/node_modules/zod/v4/locales/ne.cjs +2 -0
  348. package/node_modules/zod/v4/locales/ne.js +2 -0
  349. package/node_modules/zod/v4/locales/nl.cjs +2 -0
  350. package/node_modules/zod/v4/locales/nl.js +2 -0
  351. package/node_modules/zod/v4/locales/nn.cjs +2 -0
  352. package/node_modules/zod/v4/locales/nn.js +2 -0
  353. package/node_modules/zod/v4/locales/no.cjs +2 -0
  354. package/node_modules/zod/v4/locales/no.js +2 -0
  355. package/node_modules/zod/v4/locales/ota.cjs +2 -0
  356. package/node_modules/zod/v4/locales/ota.js +2 -0
  357. package/node_modules/zod/v4/locales/pl.cjs +2 -0
  358. package/node_modules/zod/v4/locales/pl.js +2 -0
  359. package/node_modules/zod/v4/locales/ps.cjs +2 -0
  360. package/node_modules/zod/v4/locales/ps.js +2 -0
  361. package/node_modules/zod/v4/locales/pt-BR.cjs +2 -0
  362. package/node_modules/zod/v4/locales/pt-BR.js +2 -0
  363. package/node_modules/zod/v4/locales/pt.cjs +2 -0
  364. package/node_modules/zod/v4/locales/pt.js +2 -0
  365. package/node_modules/zod/v4/locales/ro.cjs +2 -0
  366. package/node_modules/zod/v4/locales/ro.js +2 -0
  367. package/node_modules/zod/v4/locales/ru.cjs +2 -0
  368. package/node_modules/zod/v4/locales/ru.js +2 -0
  369. package/node_modules/zod/v4/locales/sk.cjs +2 -0
  370. package/node_modules/zod/v4/locales/sk.js +2 -0
  371. package/node_modules/zod/v4/locales/sl.cjs +2 -0
  372. package/node_modules/zod/v4/locales/sl.js +2 -0
  373. package/node_modules/zod/v4/locales/sv.cjs +2 -0
  374. package/node_modules/zod/v4/locales/sv.js +2 -0
  375. package/node_modules/zod/v4/locales/ta.cjs +2 -0
  376. package/node_modules/zod/v4/locales/ta.js +2 -0
  377. package/node_modules/zod/v4/locales/tg.cjs +144 -0
  378. package/node_modules/zod/v4/locales/tg.d.cts +5 -0
  379. package/node_modules/zod/v4/locales/tg.d.ts +4 -0
  380. package/node_modules/zod/v4/locales/tg.js +117 -0
  381. package/node_modules/zod/v4/locales/th.cjs +2 -0
  382. package/node_modules/zod/v4/locales/th.js +2 -0
  383. package/node_modules/zod/v4/locales/tk.cjs +2 -0
  384. package/node_modules/zod/v4/locales/tk.js +2 -0
  385. package/node_modules/zod/v4/locales/tr.cjs +2 -0
  386. package/node_modules/zod/v4/locales/tr.js +2 -0
  387. package/node_modules/zod/v4/locales/uk.cjs +2 -0
  388. package/node_modules/zod/v4/locales/uk.js +2 -0
  389. package/node_modules/zod/v4/locales/ur.cjs +2 -0
  390. package/node_modules/zod/v4/locales/ur.js +2 -0
  391. package/node_modules/zod/v4/locales/uz.cjs +2 -0
  392. package/node_modules/zod/v4/locales/uz.js +2 -0
  393. package/node_modules/zod/v4/locales/vi.cjs +2 -0
  394. package/node_modules/zod/v4/locales/vi.js +2 -0
  395. package/node_modules/zod/v4/locales/yo.cjs +2 -0
  396. package/node_modules/zod/v4/locales/yo.js +2 -0
  397. package/node_modules/zod/v4/locales/zh-CN.cjs +2 -0
  398. package/node_modules/zod/v4/locales/zh-CN.js +2 -0
  399. package/node_modules/zod/v4/locales/zh-TW.cjs +2 -0
  400. package/node_modules/zod/v4/locales/zh-TW.js +2 -0
  401. package/node_modules/zod/v4/mini/checks.cjs +19 -0
  402. package/node_modules/zod/v4/mini/coerce.cjs +19 -0
  403. package/node_modules/zod/v4/mini/deep-partial.cjs +19 -0
  404. package/node_modules/zod/v4/mini/external.cjs +22 -1
  405. package/node_modules/zod/v4/mini/external.d.cts +1 -1
  406. package/node_modules/zod/v4/mini/external.d.ts +1 -1
  407. package/node_modules/zod/v4/mini/external.js +1 -1
  408. package/node_modules/zod/v4/mini/in-out.cjs +19 -0
  409. package/node_modules/zod/v4/mini/index.cjs +19 -0
  410. package/node_modules/zod/v4/mini/iso.cjs +19 -0
  411. package/node_modules/zod/v4/mini/parse.cjs +19 -0
  412. package/node_modules/zod/v4/mini/schemas.cjs +44 -8
  413. package/node_modules/zod/v4/mini/schemas.d.cts +6 -1
  414. package/node_modules/zod/v4/mini/schemas.d.ts +6 -1
  415. package/node_modules/zod/v4/mini/schemas.js +21 -6
  416. package/node_modules/zod/v4-mini/index.cjs +19 -0
  417. package/package.json +8 -5
  418. package/dist/.setup/message-handler.history-CJOsN9w5.mjs +0 -28
  419. package/dist/.setup/provider.runtime-DuhmKdDU.mjs +0 -2
  420. package/dist/.setup/setup-plugin-api-CINIEBLa.mjs +0 -3
  421. package/dist/.setup/targets-D1mAB5yO.mjs +0 -3
@@ -0,0 +1,517 @@
1
+ import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
2
+ import { logVerbose, shouldLogVerbose } from "openclaw/plugin-sdk/runtime-env";
3
+ import { Duplex } from "node:stream";
4
+ import { spawn } from "node:child_process";
5
+ import { StringDecoder } from "node:string_decoder";
6
+ import { Application, OpusError, createDecoder, createEncoder } from "libopus-wasm";
7
+ import { resolveFfmpegBin } from "openclaw/plugin-sdk/media-runtime";
8
+ import { createStreamingPcmResampler } from "openclaw/plugin-sdk/realtime-voice-provider";
9
+ import { resolvePreferredOpenClawTmpDir, tempWorkspace } from "openclaw/plugin-sdk/temp-path";
10
+ //#region extensions/discord/src/voice/audio-worker-protocol.ts
11
+ const DISCORD_AUDIO_OUTPUT_STATUS = 1;
12
+ const DiscordAudioOutputStatus = {
13
+ Buffering: 0n,
14
+ Playing: 1n,
15
+ Retiring: 2n,
16
+ Closed: 3n
17
+ };
18
+ const OUTPUT_STATUS_MASK = 3n;
19
+ const OUTPUT_INPUT_RESERVATION = 4n;
20
+ function getDiscordAudioOutputStatus(clock) {
21
+ return Atomics.load(clock, DISCORD_AUDIO_OUTPUT_STATUS) & OUTPUT_STATUS_MASK;
22
+ }
23
+ function setDiscordAudioOutputStatus(clock, status) {
24
+ for (;;) {
25
+ const current = Atomics.load(clock, DISCORD_AUDIO_OUTPUT_STATUS);
26
+ if ((current & OUTPUT_STATUS_MASK) >= status) return;
27
+ const next = current & -4n | status;
28
+ if (Atomics.compareExchange(clock, DISCORD_AUDIO_OUTPUT_STATUS, current, next) === current) return;
29
+ }
30
+ }
31
+ function admitDiscordAudioInput(clock) {
32
+ for (;;) {
33
+ const current = Atomics.load(clock, DISCORD_AUDIO_OUTPUT_STATUS);
34
+ if ((current & OUTPUT_STATUS_MASK) >= DiscordAudioOutputStatus.Retiring) return false;
35
+ if (Atomics.compareExchange(clock, DISCORD_AUDIO_OUTPUT_STATUS, current, current + OUTPUT_INPUT_RESERVATION) === current) return true;
36
+ }
37
+ }
38
+ function releaseDiscordAudioInput(clock) {
39
+ Atomics.sub(clock, DISCORD_AUDIO_OUTPUT_STATUS, OUTPUT_INPUT_RESERVATION);
40
+ }
41
+ function retireDiscordAudioOutput(clock) {
42
+ for (;;) {
43
+ const current = Atomics.load(clock, DISCORD_AUDIO_OUTPUT_STATUS);
44
+ if ((current & OUTPUT_STATUS_MASK) >= DiscordAudioOutputStatus.Retiring) return true;
45
+ if (current >= OUTPUT_INPUT_RESERVATION) return false;
46
+ if (Atomics.compareExchange(clock, DISCORD_AUDIO_OUTPUT_STATUS, current, DiscordAudioOutputStatus.Retiring) === current) return true;
47
+ }
48
+ }
49
+ function serializeDiscordAudioError(error) {
50
+ if (!(error instanceof Error)) return {
51
+ name: "Error",
52
+ message: String(error)
53
+ };
54
+ return {
55
+ name: error.name,
56
+ message: error.message,
57
+ ..."code" in error && typeof error.code === "number" ? { code: error.code } : {},
58
+ ..."codeName" in error && typeof error.codeName === "string" ? { codeName: error.codeName } : {},
59
+ ..."operation" in error && typeof error.operation === "string" ? { operation: error.operation } : {}
60
+ };
61
+ }
62
+ function restoreDiscordAudioError(error) {
63
+ return Object.assign(new Error(error.message), error);
64
+ }
65
+ //#endregion
66
+ //#region extensions/discord/src/voice/audio.ts
67
+ const SAMPLE_RATE = 48e3;
68
+ const CHANNELS = 2;
69
+ const BIT_DEPTH = 16;
70
+ const FFMPEG_ERROR_OUTPUT_BYTES = 8192;
71
+ const DISCORD_OPUS_FRAME_SIZE = 960;
72
+ const DISCORD_OPUS_MAX_DECODE_FRAME_SIZE = SAMPLE_RATE * 120 / 1e3;
73
+ const DISCORD_OPUS_ENCODE_BATCH_FRAMES = 8;
74
+ const DISCORD_OPUS_FRAME_BYTES = DISCORD_OPUS_FRAME_SIZE * CHANNELS * (BIT_DEPTH / 8);
75
+ const FFMPEG_PCM_ARGUMENTS = [
76
+ "-analyzeduration",
77
+ "0",
78
+ "-loglevel",
79
+ "error",
80
+ "-vn",
81
+ "-sn",
82
+ "-dn",
83
+ "-f",
84
+ "s16le",
85
+ "-ar",
86
+ String(SAMPLE_RATE),
87
+ "-ac",
88
+ String(CHANNELS)
89
+ ];
90
+ let warnedOpusMissing = false;
91
+ function buildWavBuffer(chunks) {
92
+ const pcmBytes = chunks.reduce((total, chunk) => total + chunk.length, 0);
93
+ const blockAlign = 4;
94
+ const byteRate = SAMPLE_RATE * blockAlign;
95
+ const wav = Buffer.allocUnsafe(44 + pcmBytes);
96
+ const header = wav.subarray(0, 44);
97
+ header.write("RIFF", 0);
98
+ header.writeUInt32LE(36 + pcmBytes, 4);
99
+ header.write("WAVE", 8);
100
+ header.write("fmt ", 12);
101
+ header.writeUInt32LE(16, 16);
102
+ header.writeUInt16LE(1, 20);
103
+ header.writeUInt16LE(CHANNELS, 22);
104
+ header.writeUInt32LE(SAMPLE_RATE, 24);
105
+ header.writeUInt32LE(byteRate, 28);
106
+ header.writeUInt16LE(blockAlign, 32);
107
+ header.writeUInt16LE(BIT_DEPTH, 34);
108
+ header.write("data", 36);
109
+ header.writeUInt32LE(pcmBytes, 40);
110
+ let offset = 44;
111
+ for (const chunk of chunks) offset += chunk.copy(wav, offset);
112
+ return wav;
113
+ }
114
+ function createDiscordOpusEncodeStream() {
115
+ return new DiscordOpusEncodeStream();
116
+ }
117
+ function createDiscordOpusPlaybackStream(input) {
118
+ const inputSource = typeof input === "string" ? input : "pipe:0";
119
+ const ffmpeg = spawn(resolveFfmpegBin(), [
120
+ "-i",
121
+ inputSource,
122
+ ...FFMPEG_PCM_ARGUMENTS,
123
+ "pipe:1"
124
+ ], {
125
+ stdio: [
126
+ "pipe",
127
+ "pipe",
128
+ "pipe"
129
+ ],
130
+ windowsHide: true
131
+ });
132
+ const opusStream = createDiscordOpusEncodeStream();
133
+ const stderr = Buffer.alloc(FFMPEG_ERROR_OUTPUT_BYTES);
134
+ let stderrBytes = 0;
135
+ let ffmpegClosed = false;
136
+ const killFfmpeg = (signal = "SIGTERM") => {
137
+ if (!ffmpegClosed && !ffmpeg.killed) ffmpeg.kill(signal);
138
+ };
139
+ ffmpeg.stderr.on("data", (chunk) => {
140
+ if (stderrBytes < FFMPEG_ERROR_OUTPUT_BYTES) stderrBytes += chunk.copy(stderr, stderrBytes, 0, FFMPEG_ERROR_OUTPUT_BYTES - stderrBytes);
141
+ });
142
+ ffmpeg.once("error", (err) => {
143
+ opusStream.destroy(err);
144
+ });
145
+ ffmpeg.once("close", (code, signal) => {
146
+ ffmpegClosed = true;
147
+ if (code && code !== 0) {
148
+ const stderrText = new StringDecoder("utf8").write(stderr.subarray(0, stderrBytes)).trim();
149
+ const suffix = stderrText ? `: ${stderrText}` : "";
150
+ opusStream.destroy(/* @__PURE__ */ new Error(`ffmpeg exited with code ${code}${suffix}`));
151
+ return;
152
+ }
153
+ if (signal) opusStream.destroy(/* @__PURE__ */ new Error(`ffmpeg exited with signal ${signal}`));
154
+ });
155
+ for (const readable of [ffmpeg.stdout, ffmpeg.stderr]) readable.on("error", (err) => {
156
+ killFfmpeg("SIGKILL");
157
+ opusStream.destroy(err);
158
+ });
159
+ ffmpeg.stdin.on("error", (err) => {
160
+ if (err.code !== "EPIPE") opusStream.destroy(err);
161
+ });
162
+ ffmpeg.stdout.pipe(opusStream);
163
+ opusStream.once("close", () => {
164
+ if (!opusStream.readableEnded) killFfmpeg();
165
+ });
166
+ if (typeof input !== "string") {
167
+ input.on("error", (err) => {
168
+ ffmpeg.stdin.destroy(err);
169
+ opusStream.destroy(err);
170
+ });
171
+ input.pipe(ffmpeg.stdin);
172
+ } else ffmpeg.stdin.end();
173
+ return opusStream;
174
+ }
175
+ var DiscordOpusEncodeStream = class extends Duplex {
176
+ #partialFrame = Buffer.alloc(DISCORD_OPUS_FRAME_BYTES);
177
+ #partialBytes = 0;
178
+ #pending;
179
+ #scheduled;
180
+ #readBlocked = false;
181
+ #partialFlushRequested = false;
182
+ #encoder;
183
+ #packetPcmBytes = /* @__PURE__ */ new WeakMap();
184
+ constructor() {
185
+ super({ readableObjectMode: true });
186
+ }
187
+ _construct(done) {
188
+ createEncoder({
189
+ application: Application.Audio,
190
+ channels: CHANNELS,
191
+ sampleRate: SAMPLE_RATE
192
+ }).then((encoder) => {
193
+ this.#encoder = encoder;
194
+ done();
195
+ }, (err) => done(err instanceof Error ? err : new Error(formatErrorMessage(err))));
196
+ }
197
+ _write(chunk, _encoding, done) {
198
+ this.#pending = {
199
+ chunk,
200
+ offset: 0,
201
+ done
202
+ };
203
+ this.#schedule();
204
+ }
205
+ _read() {
206
+ this.#readBlocked = false;
207
+ this.#schedule();
208
+ }
209
+ #schedule() {
210
+ if (this.destroyed || this.#scheduled || this.#readBlocked || !this.#pending) return;
211
+ this.#scheduled = setImmediate(() => {
212
+ this.#scheduled = void 0;
213
+ this.#encodeBatch();
214
+ });
215
+ }
216
+ #encodeBatch() {
217
+ const pending = this.#pending;
218
+ if (!pending || this.destroyed) return;
219
+ try {
220
+ for (let count = 0; count < DISCORD_OPUS_ENCODE_BATCH_FRAMES; count += 1) {
221
+ const remainingBytes = pending.chunk.length - pending.offset;
222
+ if (this.#partialBytes > 0 || remainingBytes < DISCORD_OPUS_FRAME_BYTES) {
223
+ const copied = pending.chunk.copy(this.#partialFrame, this.#partialBytes, pending.offset, pending.offset + DISCORD_OPUS_FRAME_BYTES - this.#partialBytes);
224
+ pending.offset += copied;
225
+ this.#partialBytes += copied;
226
+ if (this.#partialBytes < DISCORD_OPUS_FRAME_BYTES) {
227
+ this.#pending = void 0;
228
+ pending.done();
229
+ this.#flushRequestedPartialFrame();
230
+ return;
231
+ }
232
+ this.#partialBytes = 0;
233
+ this.#readBlocked = !this.#encodeFrame(this.#partialFrame);
234
+ } else {
235
+ const frame = pending.chunk.subarray(pending.offset, pending.offset + DISCORD_OPUS_FRAME_BYTES);
236
+ pending.offset += DISCORD_OPUS_FRAME_BYTES;
237
+ this.#readBlocked = !this.#encodeFrame(frame);
238
+ }
239
+ if (this.destroyed || this.#readBlocked) return;
240
+ }
241
+ this.#schedule();
242
+ } catch (err) {
243
+ this.#pending = void 0;
244
+ pending.done(err instanceof Error ? err : new Error(formatErrorMessage(err)));
245
+ }
246
+ }
247
+ _final(done) {
248
+ try {
249
+ this.flushPartialFrame();
250
+ this.push(null);
251
+ done();
252
+ } catch (err) {
253
+ done(err instanceof Error ? err : new Error(formatErrorMessage(err)));
254
+ }
255
+ }
256
+ flushPartialFrameWhenReady() {
257
+ this.#partialFlushRequested = true;
258
+ if (this.#partialBytes > 0) this.#flushRequestedPartialFrame();
259
+ }
260
+ #flushRequestedPartialFrame() {
261
+ if (!this.#partialFlushRequested || this.#pending || this.writableLength > 0) return;
262
+ this.#partialFlushRequested = false;
263
+ try {
264
+ this.flushPartialFrame();
265
+ } catch (error) {
266
+ this.destroy(error instanceof Error ? error : new Error(formatErrorMessage(error)));
267
+ }
268
+ }
269
+ flushPartialFrame() {
270
+ if (this.destroyed || this.#pending || this.#partialBytes === 0) return false;
271
+ const pcmBytes = this.#partialBytes;
272
+ this.#partialFrame.fill(0, pcmBytes);
273
+ this.#partialBytes = 0;
274
+ this.#readBlocked = !this.#encodeFrame(this.#partialFrame, pcmBytes);
275
+ return true;
276
+ }
277
+ takePcmBytes(packet) {
278
+ const bytes = this.#packetPcmBytes.get(packet) ?? 0;
279
+ this.#packetPcmBytes.delete(packet);
280
+ return bytes;
281
+ }
282
+ _destroy(err, done) {
283
+ this.#encoder?.free();
284
+ clearImmediate(this.#scheduled);
285
+ this.#scheduled = void 0;
286
+ this.#partialFlushRequested = false;
287
+ const pending = this.#pending;
288
+ this.#pending = void 0;
289
+ pending?.done(err ?? /* @__PURE__ */ new Error("Discord Opus encoder was destroyed"));
290
+ this.#partialBytes = 0;
291
+ this.#partialFrame = Buffer.alloc(0);
292
+ done(err);
293
+ }
294
+ #encodeFrame(frame, pcmBytes = frame.length) {
295
+ const packet = Buffer.from(this.#encoder.encode(frame, { frameSize: DISCORD_OPUS_FRAME_SIZE }));
296
+ this.#packetPcmBytes.set(packet, pcmBytes);
297
+ return this.push(packet);
298
+ }
299
+ };
300
+ function pcmInt16ToBuffer(pcm) {
301
+ return Buffer.from(pcm.buffer, pcm.byteOffset, pcm.byteLength);
302
+ }
303
+ async function decodeOpusStreamChunks(stream, params) {
304
+ try {
305
+ for await (const { pcm, packet } of decodeOpusFrames(stream, params)) await params.onChunk(pcm, packet);
306
+ } catch (err) {
307
+ params.onError?.(err);
308
+ }
309
+ }
310
+ async function* decodeOpusFrames(stream, params) {
311
+ let decoder;
312
+ try {
313
+ decoder = await createDecoder({
314
+ channels: CHANNELS,
315
+ sampleRate: SAMPLE_RATE
316
+ });
317
+ } catch (err) {
318
+ params.onError?.(err);
319
+ if (!warnedOpusMissing) {
320
+ warnedOpusMissing = true;
321
+ params.onWarn(`discord voice: no usable opus decoder available (libopus-wasm: ${formatErrorMessage(err)}); cannot decode voice audio`);
322
+ }
323
+ return;
324
+ }
325
+ params.onVerbose("opus decoder: libopus-wasm");
326
+ try {
327
+ for await (const chunk of stream) {
328
+ if (!chunk || !(chunk instanceof Buffer) || chunk.length === 0) continue;
329
+ const decoded = decoder.decode(chunk, { maxFrameSize: DISCORD_OPUS_MAX_DECODE_FRAME_SIZE });
330
+ if (decoded.length > 0) yield {
331
+ pcm: pcmInt16ToBuffer(decoded),
332
+ packet: chunk
333
+ };
334
+ }
335
+ } catch (err) {
336
+ params.onError?.(err);
337
+ if (shouldLogVerbose()) logVerbose(`discord voice: opus decode failed: ${formatErrorMessage(err)}`);
338
+ } finally {
339
+ decoder.free();
340
+ }
341
+ }
342
+ function createDiscordPcmToRealtimeConverter() {
343
+ const resampler = createStreamingPcmResampler(SAMPLE_RATE, 24e3);
344
+ let trailingFrame = Buffer.alloc(0);
345
+ return {
346
+ process(pcm) {
347
+ const input = trailingFrame.length > 0 ? Buffer.concat([trailingFrame, pcm]) : pcm;
348
+ const completeBytes = input.length - input.length % 4;
349
+ trailingFrame = Buffer.from(input.subarray(completeBytes));
350
+ const mono = Buffer.alloc(completeBytes / 2);
351
+ for (let offset = 0; offset < completeBytes; offset += 4) mono.writeInt16LE(Math.round((input.readInt16LE(offset) + input.readInt16LE(offset + 2)) / 2), offset / 2);
352
+ return resampler.process(mono);
353
+ },
354
+ flush() {
355
+ trailingFrame = Buffer.alloc(0);
356
+ return resampler.flush();
357
+ }
358
+ };
359
+ }
360
+ function duplicateMonoChannels(mono) {
361
+ const stereo = Buffer.alloc(mono.length * 2);
362
+ for (let offset = 0; offset < mono.length; offset += 2) {
363
+ const sample = mono.readInt16LE(offset);
364
+ stereo.writeInt16LE(sample, offset * 2);
365
+ stereo.writeInt16LE(sample, offset * 2 + 2);
366
+ }
367
+ return stereo;
368
+ }
369
+ function createRealtimePcmToDiscordConverter() {
370
+ let resampler = createStreamingPcmResampler(24e3, SAMPLE_RATE);
371
+ let history = Buffer.alloc(0);
372
+ let trailingByte = Buffer.alloc(0);
373
+ let replayBytes = 0;
374
+ let flushed = false;
375
+ const takeOutput = (pcm) => {
376
+ const skippedBytes = Math.min(replayBytes, pcm.length);
377
+ replayBytes -= skippedBytes;
378
+ return duplicateMonoChannels(pcm.subarray(skippedBytes));
379
+ };
380
+ return {
381
+ process(pcm) {
382
+ const input = trailingByte.length > 0 ? Buffer.concat([trailingByte, pcm]) : pcm;
383
+ const completeBytes = input.length - input.length % 2;
384
+ const completePcm = input.subarray(0, completeBytes);
385
+ trailingByte = Buffer.from(input.subarray(completeBytes));
386
+ history = Buffer.concat([history, completePcm.subarray(-64)]).subarray(-64);
387
+ return takeOutput(resampler.process(completePcm));
388
+ },
389
+ drain() {
390
+ if (flushed) return Buffer.alloc(0);
391
+ const output = takeOutput(resampler.flush());
392
+ resampler = createStreamingPcmResampler(24e3, SAMPLE_RATE);
393
+ replayBytes = history.length * 2 - resampler.process(history).length;
394
+ return output;
395
+ },
396
+ flush() {
397
+ flushed = true;
398
+ trailingByte = Buffer.alloc(0);
399
+ history = Buffer.alloc(0);
400
+ return takeOutput(resampler.flush());
401
+ }
402
+ };
403
+ }
404
+ async function writeVoiceWavFile(chunks) {
405
+ const wav = buildWavBuffer(chunks);
406
+ const workspace = await tempWorkspace({
407
+ rootDir: resolvePreferredOpenClawTmpDir(),
408
+ prefix: "discord-voice-"
409
+ });
410
+ try {
411
+ return {
412
+ path: await workspace.write("segment.wav", wav),
413
+ durationSeconds: (wav.length - 44) / (BIT_DEPTH / 8 * CHANNELS * SAMPLE_RATE),
414
+ cleanup: () => workspace[Symbol.asyncDispose]()
415
+ };
416
+ } catch (error) {
417
+ await workspace.cleanup();
418
+ throw error;
419
+ }
420
+ }
421
+ //#endregion
422
+ //#region extensions/discord/src/voice/receive-recovery.ts
423
+ const DECRYPT_FAILURE_WINDOW_MS = 3e4;
424
+ const DECRYPT_FAILURE_RECONNECT_THRESHOLD = 3;
425
+ const DECRYPT_FAILURE_MARKER = "DecryptionFailed(";
426
+ const DAVE_PASSTHROUGH_DISABLED_MARKER = "UnencryptedWhenPassthroughDisabled";
427
+ const WASM_MEMORY_ACCESS_MARKER = "memory access out of bounds";
428
+ const OPUS_INVALID_PACKET_CODE = -4;
429
+ function createVoiceReceiveRecoveryState() {
430
+ return {
431
+ decryptFailureCount: 0,
432
+ lastDecryptFailureAt: 0,
433
+ decryptRecoveryInFlight: false
434
+ };
435
+ }
436
+ function isAbortLikeReceiveError(err) {
437
+ if (!err || typeof err !== "object") return false;
438
+ const name = "name" in err && typeof err.name === "string" ? err.name : "";
439
+ const message = "message" in err && typeof err.message === "string" ? err.message : "";
440
+ return name === "AbortError" || message === "Premature close" || message.includes("The operation was aborted") || message.includes("aborted");
441
+ }
442
+ function isOpusDecodeInvalidPacketError(err) {
443
+ if (!err || typeof err !== "object") return false;
444
+ const maybeOpusError = err;
445
+ const isDecodeOperation = maybeOpusError.operation === "decode" || maybeOpusError.operation === "decodeFloat";
446
+ const isInvalidPacket = maybeOpusError.code === OPUS_INVALID_PACKET_CODE || maybeOpusError.codeName === "InvalidPacket";
447
+ return isDecodeOperation && isInvalidPacket && (err instanceof OpusError || maybeOpusError.name === "OpusError");
448
+ }
449
+ function analyzeVoiceReceiveError(err) {
450
+ const message = formatErrorMessage(err);
451
+ const normalizedMessage = message.toLowerCase();
452
+ const shouldAttemptPassthrough = message.includes(DAVE_PASSTHROUGH_DISABLED_MARKER);
453
+ const isWasmMemoryAccessFailure = normalizedMessage.includes(WASM_MEMORY_ACCESS_MARKER);
454
+ return {
455
+ message,
456
+ isAbortLike: isAbortLikeReceiveError(err),
457
+ isDecodeCorruption: isOpusDecodeInvalidPacketError(err),
458
+ shouldAttemptPassthrough,
459
+ countsAsDecryptFailure: message.includes(DECRYPT_FAILURE_MARKER) || shouldAttemptPassthrough || isWasmMemoryAccessFailure
460
+ };
461
+ }
462
+ function noteVoiceDecryptFailure(state, now = Date.now()) {
463
+ if (now - state.lastDecryptFailureAt > 3e4) state.decryptFailureCount = 0;
464
+ state.lastDecryptFailureAt = now;
465
+ state.decryptFailureCount += 1;
466
+ const firstFailure = state.decryptFailureCount === 1;
467
+ if (state.decryptFailureCount < DECRYPT_FAILURE_RECONNECT_THRESHOLD || state.decryptRecoveryInFlight) return {
468
+ firstFailure,
469
+ shouldRecover: false
470
+ };
471
+ state.decryptRecoveryInFlight = true;
472
+ resetVoiceReceiveRecoveryState(state);
473
+ return {
474
+ firstFailure,
475
+ shouldRecover: true
476
+ };
477
+ }
478
+ function resetVoiceReceiveRecoveryState(state) {
479
+ state.decryptFailureCount = 0;
480
+ state.lastDecryptFailureAt = 0;
481
+ }
482
+ function finishVoiceDecryptRecovery(state) {
483
+ state.decryptRecoveryInFlight = false;
484
+ }
485
+ function isDaveReinitializing(session) {
486
+ return session.reinitializing === true;
487
+ }
488
+ function recoverDaveZeroTransition(params) {
489
+ const { target, sdk, onWarn } = params;
490
+ const networkingState = target.connection.state.networking?.state;
491
+ const daveSession = networkingState?.dave;
492
+ if (target.connection.state.status !== sdk.VoiceConnectionStatus.Ready || networkingState?.code !== sdk.NetworkingStatusCode.Ready || daveSession?.lastTransitionId !== 0 || daveSession.reinitializing !== false || typeof daveSession.recoverFromInvalidTransition !== "function") return "not-attempted";
493
+ try {
494
+ daveSession.recoverFromInvalidTransition(0);
495
+ return "recovered";
496
+ } catch (err) {
497
+ onWarn(`discord voice: failed to recover DAVE transition 0 guild=${target.guildId} channel=${target.channelId}: ${formatErrorMessage(err)}`);
498
+ return isDaveReinitializing(daveSession) ? "failed" : "not-attempted";
499
+ }
500
+ }
501
+ function enableDaveReceivePassthrough(params) {
502
+ const { target, sdk, reason, expirySeconds, onVerbose, onWarn } = params;
503
+ const networkingState = target.connection.state.networking?.state;
504
+ if (target.connection.state.status !== sdk.VoiceConnectionStatus.Ready || !networkingState || networkingState.code !== sdk.NetworkingStatusCode.Ready && networkingState.code !== sdk.NetworkingStatusCode.Resuming) return false;
505
+ const daveSession = networkingState.dave?.session;
506
+ if (!daveSession) return false;
507
+ try {
508
+ daveSession.setPassthroughMode(true, expirySeconds);
509
+ onVerbose(`enabled DAVE receive passthrough: guild ${target.guildId} channel ${target.channelId} expiry=${expirySeconds}s reason=${reason}`);
510
+ return true;
511
+ } catch (err) {
512
+ onWarn(`discord voice: failed to enable DAVE passthrough guild=${target.guildId} channel=${target.channelId} reason=${reason}: ${formatErrorMessage(err)}`);
513
+ return false;
514
+ }
515
+ }
516
+ //#endregion
517
+ export { setDiscordAudioOutputStatus as S, getDiscordAudioOutputStatus as _, finishVoiceDecryptRecovery as a, retireDiscordAudioOutput as b, resetVoiceReceiveRecoveryState as c, createDiscordPcmToRealtimeConverter as d, createRealtimePcmToDiscordConverter as f, admitDiscordAudioInput as g, DiscordAudioOutputStatus as h, enableDaveReceivePassthrough as i, createDiscordOpusEncodeStream as l, writeVoiceWavFile as m, analyzeVoiceReceiveError as n, noteVoiceDecryptFailure as o, decodeOpusStreamChunks as p, createVoiceReceiveRecoveryState as r, recoverDaveZeroTransition as s, DECRYPT_FAILURE_WINDOW_MS as t, createDiscordOpusPlaybackStream as u, releaseDiscordAudioInput as v, serializeDiscordAudioError as x, restoreDiscordAudioError as y };
@@ -7,7 +7,7 @@ import { buildMessagingTarget, parseMentionPrefixOrAtUserTarget, requireTargetKi
7
7
  import { sleepWithAbort } from "openclaw/plugin-sdk/runtime-env";
8
8
  import { resolveAllowlistMatchByCandidates } from "openclaw/plugin-sdk/allow-from";
9
9
  import { chunkByParagraph } from "openclaw/plugin-sdk/reply-chunking";
10
- import { avoidTrailingHighSurrogateBreak, chunkTextForOutbound, findCodeRegions } from "openclaw/plugin-sdk/text-chunking";
10
+ import { chunkTextForOutbound, findCodeRegions } from "openclaw/plugin-sdk/text-chunking";
11
11
  import { isSingleUseReplyToMode } from "openclaw/plugin-sdk/reply-reference";
12
12
  import { createMessageReceiptFromOutboundResults } from "openclaw/plugin-sdk/channel-outbound";
13
13
  import { attachChannelToResults } from "openclaw/plugin-sdk/channel-send-result";
@@ -222,6 +222,42 @@ function createDiscordSendResult(params) {
222
222
  };
223
223
  }
224
224
  //#endregion
225
+ //#region packages/normalization-core/src/utf16-slice.ts
226
+ function isHighSurrogate(codeUnit) {
227
+ return codeUnit >= 55296 && codeUnit <= 56319;
228
+ }
229
+ function isLowSurrogate(codeUnit) {
230
+ return codeUnit >= 56320 && codeUnit <= 57343;
231
+ }
232
+ /** Moves a chunk boundary away from the middle of a UTF-16 surrogate pair. */
233
+ function avoidTrailingHighSurrogateBreak(text, start, end) {
234
+ if (end <= start || end >= text.length || !isHighSurrogate(text.charCodeAt(end - 1)) || !isLowSurrogate(text.charCodeAt(end))) return end;
235
+ const adjusted = end - 1;
236
+ return adjusted > start ? adjusted : end + 1;
237
+ }
238
+ //#endregion
239
+ //#region packages/normalization-core/src/grapheme.ts
240
+ let graphemeSegmenter;
241
+ function getGraphemeSegmenter() {
242
+ graphemeSegmenter ??= new Intl.Segmenter(void 0, { granularity: "grapheme" });
243
+ return graphemeSegmenter;
244
+ }
245
+ /**
246
+ * Chooses a whole-grapheme cut within the hard budget, honoring a usable preference.
247
+ * If no whole grapheme fits, allowPartial permits a surrogate-safe progress cut;
248
+ * a leading surrogate pair can exceed maxEnd by one code unit.
249
+ */
250
+ function findGraphemeChunkEnd(text, start, maxEnd, preferredEnd = maxEnd, allowPartial = true) {
251
+ const hardEnd = Math.min(maxEnd, text.length);
252
+ if (hardEnd <= start) return start;
253
+ const preferred = Number.isInteger(preferredEnd) && preferredEnd > start && preferredEnd <= hardEnd ? preferredEnd : hardEnd;
254
+ if (preferred === text.length) return preferred;
255
+ const segments = getGraphemeSegmenter().segment(text);
256
+ let end = segments.containing(preferred)?.index ?? preferred;
257
+ if (end <= start && preferred < hardEnd) end = hardEnd === text.length ? hardEnd : segments.containing(hardEnd)?.index ?? hardEnd;
258
+ return end > start ? end : allowPartial ? avoidTrailingHighSurrogateBreak(text, start, hardEnd) : start;
259
+ }
260
+ //#endregion
225
261
  //#region extensions/discord/src/chunk.ts
226
262
  const DEFAULT_MAX_CHARS = 2e3;
227
263
  const DEFAULT_MAX_LINES = 17;
@@ -453,24 +489,53 @@ function createDiscordRanges(source, maxChars, maxLines) {
453
489
  offset += line.length + 1;
454
490
  }
455
491
  if (!fence) collect(source.length);
456
- const overlaps = (start, end) => spans.some((span) => span.start < end && span.end > start);
457
- const joins = (end, start) => end <= start && spans.some((span) => span.start < end && end < span.end && start < span.end);
492
+ const firstSpanEndingAfter = (position) => {
493
+ let low = 0;
494
+ let high = spans.length;
495
+ while (low < high) {
496
+ const middle = low + Math.floor((high - low) / 2);
497
+ if (expectDefined(spans[middle], "Discord inline span").end <= position) low = middle + 1;
498
+ else high = middle;
499
+ }
500
+ return low;
501
+ };
502
+ const firstPrefixEndingAfter = (position) => {
503
+ let low = 0;
504
+ let high = spans.length;
505
+ while (low < high) {
506
+ const middle = low + Math.floor((high - low) / 2);
507
+ const span = expectDefined(spans[middle], "Discord inline span");
508
+ if (span.base + span.code.prefix.end <= position) low = middle + 1;
509
+ else high = middle;
510
+ }
511
+ return spans[low];
512
+ };
513
+ const overlaps = (start, end) => {
514
+ const span = spans[firstSpanEndingAfter(start)];
515
+ return Boolean(span && span.start < end);
516
+ };
517
+ const joins = (end, start) => {
518
+ if (end > start) return false;
519
+ const span = spans[firstSpanEndingAfter(end)];
520
+ return Boolean(span && span.start < end && start < span.end);
521
+ };
458
522
  const boundary = (start, end) => {
459
- let safe = avoidTrailingHighSurrogateBreak(source, start, end);
460
- for (const span of spans) {
461
- const prefix = span.code.prefix;
462
- if (span.base + prefix.start < safe && safe < span.base + prefix.end) return span.base + prefix.start;
463
- if (span.start < safe && safe < span.end) {
464
- if (source[safe - 1] === "\r" && source[safe] === "\n") safe -= 1;
465
- if (span.atomicTicks) while (source[safe - 1] === "`" && source[safe] === "`") safe -= 1;
466
- }
523
+ let safe = findGraphemeChunkEnd(source, start, end);
524
+ if (safe === end - 1 && source[end - 1] === "\r" && source[end] === "\n") safe = end;
525
+ const prefixSpan = firstPrefixEndingAfter(safe);
526
+ if (prefixSpan && prefixSpan.base + prefixSpan.code.prefix.start < safe) return prefixSpan.base + prefixSpan.code.prefix.start;
527
+ const span = spans[firstSpanEndingAfter(safe)];
528
+ if (span && span.start < safe) {
529
+ if (source[safe - 1] === "\r" && source[safe] === "\n") safe -= 1;
530
+ if (span.atomicTicks) while (source[safe - 1] === "`" && source[safe] === "`") safe -= 1;
467
531
  }
468
532
  return safe;
469
533
  };
470
534
  const render = (start, end) => {
471
535
  let cursor = start, text = "";
472
- for (const span of spans) {
473
- if (span.end <= start || span.start >= end) continue;
536
+ for (let index = firstSpanEndingAfter(start); index < spans.length; index += 1) {
537
+ const span = expectDefined(spans[index], "Discord inline span");
538
+ if (span.start >= end) break;
474
539
  const prefix = span.code.prefix;
475
540
  const prefixStart = span.base + prefix.start;
476
541
  if (start > span.base + prefix.ownerStart && cursor <= prefixStart) {