@openclaw/discord 2026.9.4 → 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.
- package/assets/activity.svg +40 -0
- package/assets/icon.png +0 -0
- package/dist/{account-inspect-BY-ve3yH.js → .setup/account-inspect-BwQj24ht.mjs} +1 -1
- package/dist/{activities-api-w8j7Elou.js → .setup/activities-api-COU4-0nR.mjs} +93 -31
- package/dist/{api-LIV--eMq.js → .setup/api-CBK9zcq5.mjs} +7 -4
- package/dist/{approval-handler.runtime-BnPUU5NK.js → .setup/approval-handler.runtime-CbBktBb4.mjs} +8 -7
- package/dist/.setup/approval-message-updates-jf9zMaIC.mjs +17 -0
- package/dist/{audit-BgAgIzwo.js → .setup/audit-vKbh-LFR.mjs} +5 -5
- package/dist/{channel-C_OFFR5Y.js → .setup/channel-Dv4e3Jpc.mjs} +34 -29
- package/dist/{channel-actions.runtime-tShzmemq.js → .setup/channel-actions.runtime-leZuw01r.mjs} +25 -12
- package/dist/{allow-list-DWEio925.js → .setup/channel-type-DKnjV1XW.mjs} +161 -1
- package/dist/{channel.setup-CpAwAiS0.js → .setup/channel.setup-0NX6FFwi.mjs} +4 -4
- package/dist/{components-DBFTIN6P.js → .setup/components-yBEb75bB.mjs} +4 -5
- package/dist/{config-schema-r38UkM_J.js → .setup/config-schema-CiZz-mtA.mjs} +1 -1
- package/dist/{conversation-binding-route-CB9PRqgi.js → .setup/conversation-binding-route-B7qImK_b.mjs} +6 -3
- package/dist/{directory-config-D1uDGbWh.js → .setup/directory-config-BytTftz-.mjs} +2 -2
- package/dist/{directory-live-C5o1uKlw.js → .setup/directory-live--EGTH0DC.mjs} +4 -4
- package/dist/{discord-CmL3ati-.js → .setup/discord-BXpHW-cu.mjs} +89 -39
- package/dist/{doctor-DgKMH6N7.js → .setup/doctor-D1R-uFIu.mjs} +6 -6
- package/dist/{handle-action.guild-admin-CpEwox_X.js → .setup/handle-action.guild-admin-DcFa8NwA.mjs} +10 -5
- package/dist/{live-policy-config-BblutQAq.js → .setup/live-policy-config-eKQ-PLdy.mjs} +1 -1
- package/dist/{message-handler-C7FZGKa8.js → .setup/message-handler-X6ejmbtY.mjs} +25 -14
- package/dist/{message-handler.preflight-DFpwDW2W.js → .setup/message-handler.preflight-DE_POxFc.mjs} +35 -125
- package/dist/.setup/message-handler.preflight-pluralkit-8Xji34AF.mjs +143 -0
- package/dist/{message-handler.process-ZKrmmA9D.js → .setup/message-handler.process-CCmIVnxy.mjs} +438 -378
- package/dist/{outbound-adapter-C8PTt7_p.js → .setup/outbound-adapter-ClIgmu4F.mjs} +13 -9
- package/dist/{outbound-session-route-B0N6os97.js → .setup/outbound-session-route-VulUE0yV.mjs} +138 -11
- package/dist/{pluralkit-BiUW53Yn.js → .setup/pluralkit-CdAt1G0P.mjs} +2 -2
- package/dist/{preflight-audio-DrnqFA8U.js → .setup/preflight-audio-DHGIHEpv.mjs} +2 -1
- package/dist/{probe-BcoN44eK.js → .setup/probe-CupW4we4.mjs} +14 -10
- package/dist/{probe.runtime-BnuED0fI.js → .setup/probe.runtime-DBQ_AGPe.mjs} +1 -1
- package/dist/{provider-DmRHCZ_K.js → .setup/provider-iOf73HW-.mjs} +885 -557
- package/dist/{provider-session.runtime-U1M8_EYY.js → .setup/provider-session.runtime-DrGAYnZv.mjs} +4 -4
- package/dist/.setup/provider.runtime-BmjW_pIw.mjs +2 -0
- package/dist/{realtime-session.runtime-Bjsk9Q5t.js → .setup/realtime-session.runtime-Dz8uVutq.mjs} +977 -514
- package/dist/.setup/receive-recovery-DHst8WRx.mjs +517 -0
- package/dist/{resolve-allowlist-common-ChPf0Qy7.js → .setup/resolve-allowlist-common-CwMBzbx9.mjs} +3 -3
- package/dist/{resolve-channels-VbpLmUS8.js → .setup/resolve-channels-BbvsLQOZ.mjs} +4 -5
- package/dist/{resolve-users-D-wRFsd5.js → .setup/resolve-users-ByFlR7LQ.mjs} +3 -3
- package/dist/{retry-DKeoT7UO.js → .setup/retry-BEYkDy0P.mjs} +106 -19
- package/dist/{runtime-Dxl-ZOvg.js → .setup/runtime-B8lJfyrA.mjs} +113 -141
- package/dist/{runtime-CbknwoBH.js → .setup/runtime-DisDbixd.mjs} +2 -2
- package/dist/{security-audit-DKfK-iPY.js → .setup/security-audit-s5w50-Ly.mjs} +1 -1
- package/dist/{security-audit.runtime-sKZyKgpx.js → .setup/security-audit.runtime-DHtYenx9.mjs} +1 -1
- package/dist/{send-CLpzfzJe.js → .setup/send-CIBzvXjS.mjs} +80 -37
- package/dist/{send.components-BWnkX4QN.js → .setup/send.components-ChY21qr-.mjs} +87 -65
- package/dist/{send.outbound-BVTWrl_4.js → .setup/send.outbound-QTyuFupn.mjs} +30 -21
- package/dist/{send.shared-BHPM3CSl.js → .setup/send.shared-VNvWfX2T.mjs} +15 -12
- package/dist/{sender-identity-f3l5OYgV.js → .setup/sender-identity-0Ymgvmaj.mjs} +1 -1
- package/dist/.setup/setup-plugin-api-Dvr41dyx.mjs +3 -0
- package/dist/{shared-CPPR0Xo4.js → .setup/shared-DHPDaMSx.mjs} +11 -11
- package/dist/{subagent-hooks-DfsiwCec.js → .setup/subagent-hooks-CjW7r8Pe.mjs} +16 -4
- package/dist/{system-events-B6HkUhF_.js → .setup/system-events-B2YEEMbS.mjs} +2 -2
- package/dist/{target-resolver-CoFQ7iSX.js → .setup/target-resolver-BXpy6VT8.mjs} +4 -4
- package/dist/.setup/targets-CvemhN3i.mjs +3 -0
- package/dist/{thread-bindings-uudC_0TY.js → .setup/thread-bindings-CEh2dhqP.mjs} +6 -6
- package/dist/{thread-bindings.manager-BeUxc8nr.js → .setup/thread-bindings.manager-ve-i6oqt.mjs} +100 -46
- package/dist/{thread-bindings.session-updates-BwkXpcy0.js → .setup/thread-bindings.session-updates-DCQq1WZ5.mjs} +1 -1
- package/dist/{thread-bindings.state-dDn-dwBw.js → .setup/thread-bindings.state-BThFQEga.mjs} +46 -14
- package/dist/{transcripts-source-VkgenQv-.js → .setup/transcripts-source-DVegW0WI.mjs} +121 -30
- package/dist/{typing-DuBg1U8Q.js → .setup/typing-BKZL5fGj.mjs} +2 -2
- package/dist/{voice-runtime-DMYDMkJx.js → .setup/voice-runtime-elTtjEIG.mjs} +773 -773
- package/dist/account-inspect-api.js +1 -1
- package/dist/action-runtime-api.js +1 -1
- package/dist/activities-api.js +1 -1
- package/dist/api.js +19 -19
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/contract-api.js +1 -1
- package/dist/directory-contract-api.js +1 -1
- package/dist/doctor-contract-api.js +4 -4
- package/dist/index.js +1 -1
- package/dist/runtime-api.js +22 -22
- package/dist/runtime-setter-api.js +1 -1
- package/dist/secret-contract-api.js +1 -1
- package/dist/security-audit-contract-api.js +1 -1
- package/dist/security-contract-api.js +1 -1
- package/dist/session-key-api.js +1 -1
- package/dist/setup-entry.js +2 -1
- package/dist/setup-plugin-api.js +1 -1
- package/dist/src/voice/audio-worker.runtime.js +1065 -0
- package/dist/subagent-hooks-api.js +5 -4
- package/dist/thread-binding-api.js +1 -1
- package/dist/transcripts-source-api.js +1 -1
- package/node_modules/@napi-rs/wasm-runtime/dist/emnapi-plugins.cjs +8 -4
- package/node_modules/@napi-rs/wasm-runtime/dist/emnapi-plugins.js +8 -4
- package/node_modules/@napi-rs/wasm-runtime/dist/fs-proxy.cjs +1 -1
- package/node_modules/@napi-rs/wasm-runtime/dist/fs.js +770 -695
- package/node_modules/@napi-rs/wasm-runtime/fs-proxy.js +3 -2
- package/node_modules/@napi-rs/wasm-runtime/package.json +1 -1
- package/node_modules/@tybys/wasm-util/LICENSE +21 -0
- package/node_modules/@tybys/wasm-util/package.json +1 -1
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/buffer.d.ts +1 -0
- package/node_modules/@types/node/diagnostics_channel.d.ts +4 -4
- package/node_modules/@types/node/ffi.d.ts +1 -1
- package/node_modules/@types/node/http.d.ts +1 -1
- package/node_modules/@types/node/package.json +3 -3
- package/node_modules/@types/node/perf_hooks.d.ts +31 -19
- package/node_modules/@types/node/quic.d.ts +6 -4
- package/node_modules/@types/node/stream/web.d.ts +20 -0
- package/node_modules/@types/node/tls.d.ts +26 -15
- package/node_modules/@types/node/vfs.d.ts +7 -6
- package/node_modules/@types/node/web-globals/streams.d.ts +4 -0
- package/node_modules/@types/node/zlib.d.ts +17 -0
- package/node_modules/discord-api-types/README.md +3 -2
- package/node_modules/discord-api-types/package.json +46 -46
- package/node_modules/discord-api-types/rest/v10/interactions.d.ts +1 -0
- package/node_modules/discord-api-types/rest/v10/interactions.d.ts.map +1 -1
- package/node_modules/discord-api-types/rest/v9/interactions.d.ts +1 -0
- package/node_modules/discord-api-types/rest/v9/interactions.d.ts.map +1 -1
- package/node_modules/libopus-wasm/CHANGELOG.md +15 -0
- package/node_modules/libopus-wasm/README.md +1 -1
- package/node_modules/libopus-wasm/dist/discordjs.d.ts.map +1 -1
- package/node_modules/libopus-wasm/dist/generated/libopus.generated.mjs +0 -0
- package/node_modules/libopus-wasm/dist/index.d.ts.map +1 -1
- package/node_modules/libopus-wasm/dist/index.js +37 -18
- package/node_modules/libopus-wasm/package.json +13 -13
- package/node_modules/typebox/build/compile/validator.d.mts +1 -1
- package/node_modules/typebox/build/compile/validator.mjs +1 -1
- package/node_modules/typebox/build/format/idna/idn-hostname.mjs +7 -5
- package/node_modules/typebox/build/format/iri.mjs +5 -1
- package/node_modules/typebox/build/guard/emit.mjs +2 -4
- package/node_modules/typebox/build/guard/guard.mjs +6 -18
- package/node_modules/typebox/build/guard/string.mjs +16 -24
- package/node_modules/typebox/build/schema/build.mjs +2 -2
- package/node_modules/typebox/build/schema/check.mjs +1 -1
- package/node_modules/typebox/build/schema/compile.d.mts +3 -2
- package/node_modules/typebox/build/schema/compile.mjs +8 -8
- package/node_modules/typebox/build/schema/engine/_context.d.mts +6 -7
- package/node_modules/typebox/build/schema/engine/_context.mjs +23 -15
- package/node_modules/typebox/build/schema/engine/_functions.d.mts +2 -2
- package/node_modules/typebox/build/schema/engine/_functions.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/_reducer.d.mts +3 -3
- package/node_modules/typebox/build/schema/engine/_refine.d.mts +5 -5
- package/node_modules/typebox/build/schema/engine/_refine.mjs +4 -7
- package/node_modules/typebox/build/schema/engine/_stack.d.mts +34 -16
- package/node_modules/typebox/build/schema/engine/_stack.mjs +148 -104
- package/node_modules/typebox/build/schema/engine/additionalItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/additionalProperties.d.mts +8 -8
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +26 -18
- package/node_modules/typebox/build/schema/engine/allOf.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/allOf.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/anyOf.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/anyOf.mjs +5 -10
- package/node_modules/typebox/build/schema/engine/boolean.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/boolean.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/const.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/const.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/contains.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/contains.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/dependencies.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/dependencies.mjs +3 -6
- package/node_modules/typebox/build/schema/engine/dependentRequired.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/dependentRequired.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/dependentSchemas.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/dynamicRef.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/dynamicRef.mjs +11 -7
- package/node_modules/typebox/build/schema/engine/enum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/enum.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/exclusiveMaximum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/exclusiveMaximum.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/exclusiveMinimum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/exclusiveMinimum.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/format.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/format.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/if.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/if.mjs +7 -15
- package/node_modules/typebox/build/schema/engine/items.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/items.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/maxContains.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maxContains.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/maxItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maxItems.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/maxLength.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maxLength.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/maxProperties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maxProperties.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/maximum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maximum.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/minContains.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/minContains.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/minItems.d.mts +5 -5
- package/node_modules/typebox/build/schema/engine/minItems.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/minLength.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/minLength.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/minProperties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/minProperties.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/minimum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/minimum.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/multipleOf.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/multipleOf.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/not.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/not.mjs +4 -8
- package/node_modules/typebox/build/schema/engine/oneOf.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/oneOf.mjs +6 -11
- package/node_modules/typebox/build/schema/engine/pattern.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/pattern.mjs +3 -7
- package/node_modules/typebox/build/schema/engine/patternProperties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/prefixItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/prefixItems.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/properties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/properties.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/propertyNames.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/propertyNames.mjs +4 -10
- package/node_modules/typebox/build/schema/engine/recursiveRef.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/recursiveRef.mjs +11 -7
- package/node_modules/typebox/build/schema/engine/ref.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/ref.mjs +19 -15
- package/node_modules/typebox/build/schema/engine/required.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/required.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/schema.d.mts +7 -7
- package/node_modules/typebox/build/schema/engine/schema.mjs +137 -133
- package/node_modules/typebox/build/schema/engine/type.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/type.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/unevaluatedItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs +5 -9
- package/node_modules/typebox/build/schema/engine/unevaluatedProperties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs +5 -9
- package/node_modules/typebox/build/schema/engine/uniqueItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/uniqueItems.mjs +2 -6
- package/node_modules/typebox/build/schema/errors.d.mts +2 -2
- package/node_modules/typebox/build/schema/errors.mjs +8 -14
- package/node_modules/typebox/build/schema/intern/index.d.mts +1 -0
- package/node_modules/typebox/build/schema/intern/index.mjs +1 -0
- package/node_modules/typebox/build/schema/intern/intern.d.mts +11 -0
- package/node_modules/typebox/build/schema/intern/intern.mjs +293 -0
- package/node_modules/typebox/build/schema/meta/draft_2019_09.d.mts +2 -0
- package/node_modules/typebox/build/schema/meta/draft_2019_09.mjs +288 -0
- package/node_modules/typebox/build/schema/meta/draft_2020_12.d.mts +2 -0
- package/node_modules/typebox/build/schema/meta/draft_2020_12.mjs +300 -0
- package/node_modules/typebox/build/schema/meta/draft_3.d.mts +2 -0
- package/node_modules/typebox/build/schema/meta/draft_3.mjs +143 -0
- package/node_modules/typebox/build/schema/meta/draft_4.d.mts +2 -0
- package/node_modules/typebox/build/schema/meta/draft_4.mjs +149 -0
- package/node_modules/typebox/build/schema/meta/draft_6.d.mts +2 -0
- package/node_modules/typebox/build/schema/meta/draft_6.mjs +155 -0
- package/node_modules/typebox/build/schema/meta/draft_7.d.mts +2 -0
- package/node_modules/typebox/build/schema/meta/draft_7.mjs +172 -0
- package/node_modules/typebox/build/schema/meta/index.d.mts +2 -0
- package/node_modules/typebox/build/schema/meta/index.mjs +2 -0
- package/node_modules/typebox/build/schema/meta/meta.d.mts +9 -0
- package/node_modules/typebox/build/schema/meta/meta.mjs +15 -0
- package/node_modules/typebox/build/schema/meta/schema.d.mts +6 -0
- package/node_modules/typebox/build/schema/meta/schema.mjs +1 -0
- package/node_modules/typebox/build/schema/parse.d.mts +1 -0
- package/node_modules/typebox/build/schema/parse.mjs +10 -5
- package/node_modules/typebox/build/schema/resolve/resolve.d.mts +8 -3
- package/node_modules/typebox/build/schema/resolve/resolve.mjs +268 -139
- package/node_modules/typebox/build/schema/schema.d.mts +2 -0
- package/node_modules/typebox/build/schema/schema.mjs +2 -0
- package/node_modules/typebox/build/value/errors/errors.d.mts +2 -12
- package/node_modules/typebox/build/value/errors/errors.mjs +2 -7
- package/node_modules/typebox/package.json +1 -1
- package/node_modules/typebox/readme.md +59 -89
- package/node_modules/undici-types/client.d.ts +8 -3
- package/node_modules/undici-types/connector.d.ts +1 -0
- package/node_modules/undici-types/cookies.d.ts +1 -1
- package/node_modules/undici-types/dispatcher.d.ts +3 -3
- package/node_modules/undici-types/errors.d.ts +10 -0
- package/node_modules/undici-types/fetch.d.ts +5 -1
- package/node_modules/undici-types/handlers.d.ts +2 -0
- package/node_modules/undici-types/interceptors.d.ts +1 -1
- package/node_modules/undici-types/mock-interceptor.d.ts +5 -1
- package/node_modules/undici-types/package.json +1 -1
- package/node_modules/undici-types/proxy-agent.d.ts +7 -0
- package/node_modules/zod/README.md +29 -2
- package/node_modules/zod/compile.cjs +96 -0
- package/node_modules/zod/compile.d.cts +1 -0
- package/node_modules/zod/compile.d.ts +1 -0
- package/node_modules/zod/compile.js +52 -0
- package/node_modules/zod/index.cjs +21 -2
- package/node_modules/zod/index.d.cts +1 -2
- package/node_modules/zod/index.d.ts +1 -2
- package/node_modules/zod/index.js +5 -2
- package/node_modules/zod/locales/index.cjs +19 -0
- package/node_modules/zod/mini/index.cjs +19 -0
- package/node_modules/zod/package.json +20 -8
- package/node_modules/zod/src/compile.ts +56 -0
- package/node_modules/zod/src/index.ts +5 -2
- package/node_modules/zod/src/v3/ZodError.ts +22 -12
- package/node_modules/zod/src/v3/helpers/errorUtil.ts +1 -1
- package/node_modules/zod/src/v3/tests/error.test.ts +35 -0
- package/node_modules/zod/src/v3/tests/intersection.test.ts +18 -0
- package/node_modules/zod/src/v3/tests/language-server.test.ts +1 -2
- package/node_modules/zod/src/v3/tests/object.test.ts +3 -6
- package/node_modules/zod/src/v3/tests/readonly.test.ts +0 -80
- package/node_modules/zod/src/v3/tests/string.test.ts +6 -0
- package/node_modules/zod/src/v3/types.ts +5 -5
- package/node_modules/zod/src/v4/classic/checks.ts +1 -0
- package/node_modules/zod/src/v4/classic/compat.ts +26 -18
- package/node_modules/zod/src/v4/classic/deep-partial.ts +76 -0
- package/node_modules/zod/src/v4/classic/errors.ts +59 -44
- package/node_modules/zod/src/v4/classic/external.ts +14 -9
- package/node_modules/zod/src/v4/classic/from-json-schema.ts +363 -78
- package/node_modules/zod/src/v4/classic/in-out.ts +45 -0
- package/node_modules/zod/src/v4/classic/index.ts +2 -2
- package/node_modules/zod/src/v4/classic/iso.ts +2 -72
- package/node_modules/zod/src/v4/classic/parse.ts +10 -4
- package/node_modules/zod/src/v4/classic/schemas.ts +640 -375
- package/node_modules/zod/src/v4/classic/tests/apply.test.ts +27 -0
- package/node_modules/zod/src/v4/classic/tests/array.test.ts +2 -2
- package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +186 -0
- package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +36 -1
- package/node_modules/zod/src/v4/classic/tests/catch.test.ts +278 -0
- package/node_modules/zod/src/v4/classic/tests/codec-examples.test.ts +1 -2
- package/node_modules/zod/src/v4/classic/tests/codec.test.ts +2 -1
- package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +3 -3
- package/node_modules/zod/src/v4/classic/tests/credit-card.test.ts +76 -0
- package/node_modules/zod/src/v4/classic/tests/cyclic-data.test.ts +985 -0
- package/node_modules/zod/src/v4/classic/tests/date.test.ts +30 -0
- package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +32 -18
- package/node_modules/zod/src/v4/classic/tests/deep-partial.test.ts +380 -0
- package/node_modules/zod/src/v4/classic/tests/default-locale.test.ts +32 -0
- package/node_modules/zod/src/v4/classic/tests/default.test.ts +46 -0
- package/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +31 -7
- package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +261 -13
- package/node_modules/zod/src/v4/classic/tests/enum.test.ts +20 -0
- package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +112 -2
- package/node_modules/zod/src/v4/classic/tests/error.test.ts +403 -6
- package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +582 -10
- package/node_modules/zod/src/v4/classic/tests/function.test.ts +31 -0
- package/node_modules/zod/src/v4/classic/tests/global-config.test.ts +2 -9
- package/node_modules/zod/src/v4/classic/tests/hash.test.ts +1 -2
- package/node_modules/zod/src/v4/classic/tests/iban.test.ts +81 -0
- package/node_modules/zod/src/v4/classic/tests/in-out.test.ts +159 -0
- package/node_modules/zod/src/v4/classic/tests/index.test.ts +21 -2
- package/node_modules/zod/src/v4/classic/tests/instance-footprint.test.ts +319 -0
- package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +67 -0
- package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +136 -0
- package/node_modules/zod/src/v4/classic/tests/issue-schema.test.ts +215 -0
- package/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +3 -10
- package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +36 -1
- package/node_modules/zod/src/v4/classic/tests/literal.test.ts +12 -1
- package/node_modules/zod/src/v4/classic/tests/map.test.ts +12 -0
- package/node_modules/zod/src/v4/classic/tests/number.test.ts +85 -9
- package/node_modules/zod/src/v4/classic/tests/object.test.ts +301 -12
- package/node_modules/zod/src/v4/classic/tests/optin-ladder.test.ts +235 -0
- package/node_modules/zod/src/v4/classic/tests/optional.test.ts +49 -16
- package/node_modules/zod/src/v4/classic/tests/partial.test.ts +51 -4
- package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +70 -0
- package/node_modules/zod/src/v4/classic/tests/preprocess-types.test.ts +20 -2
- package/node_modules/zod/src/v4/classic/tests/properties.test.ts +141 -0
- package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +0 -68
- package/node_modules/zod/src/v4/classic/tests/record.test.ts +186 -18
- package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +79 -3
- package/node_modules/zod/src/v4/classic/tests/redos.test.ts +68 -0
- package/node_modules/zod/src/v4/classic/tests/refine.test.ts +60 -0
- package/node_modules/zod/src/v4/classic/tests/set.test.ts +9 -0
- package/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +19 -0
- package/node_modules/zod/src/v4/classic/tests/string.test.ts +222 -6
- package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +18 -0
- package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +44 -3
- package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +1812 -204
- package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +45 -30
- package/node_modules/zod/src/v4/classic/tests/union.test.ts +39 -2
- package/node_modules/zod/src/v4/classic/tests/validate.test.ts +645 -0
- package/node_modules/zod/src/v4/classic/tests/validations.test.ts +2 -2
- package/node_modules/zod/src/v4/core/api.ts +87 -35
- package/node_modules/zod/src/v4/core/checks.ts +119 -146
- package/node_modules/zod/src/v4/core/compile.ts +2313 -0
- package/node_modules/zod/src/v4/core/core.ts +99 -22
- package/node_modules/zod/src/v4/core/doc.ts +17 -9
- package/node_modules/zod/src/v4/core/errors.ts +113 -25
- package/node_modules/zod/src/v4/core/index.ts +3 -0
- package/node_modules/zod/src/v4/core/json-schema-generator.ts +8 -3
- package/node_modules/zod/src/v4/core/json-schema-processors.ts +424 -156
- package/node_modules/zod/src/v4/core/json-schema.ts +2 -1
- package/node_modules/zod/src/v4/core/memoizer.ts +331 -0
- package/node_modules/zod/src/v4/core/parse.ts +164 -50
- package/node_modules/zod/src/v4/core/regexes.ts +42 -15
- package/node_modules/zod/src/v4/core/registries.ts +2 -2
- package/node_modules/zod/src/v4/core/schemas.ts +1000 -538
- package/node_modules/zod/src/v4/core/tests/cached.test.ts +54 -0
- package/node_modules/zod/src/v4/core/tests/compile-differential.test.ts +1004 -0
- package/node_modules/zod/src/v4/core/tests/compile-generative.test.ts +445 -0
- package/node_modules/zod/src/v4/core/tests/compile-global.test.ts +89 -0
- package/node_modules/zod/src/v4/core/tests/compile-off-by-default.test.ts +26 -0
- package/node_modules/zod/src/v4/core/tests/compile-stats.test.ts +34 -0
- package/node_modules/zod/src/v4/core/tests/compile.test.ts +2036 -0
- package/node_modules/zod/src/v4/core/tests/email-regex.test.ts +140 -0
- package/node_modules/zod/src/v4/core/tests/locales/el.test.ts +1 -2
- package/node_modules/zod/src/v4/core/tests/locales/es.test.ts +1 -2
- package/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +3 -3
- package/node_modules/zod/src/v4/core/tests/locales/parity.test.ts +42 -0
- package/node_modules/zod/src/v4/core/tests/locales/tg.test.ts +85 -0
- package/node_modules/zod/src/v4/core/tests/locales/tk.test.ts +69 -0
- package/node_modules/zod/src/v4/core/tests/polyfill-collision.test.ts +46 -0
- package/node_modules/zod/src/v4/core/tests/treeshake.test.ts +51 -0
- package/node_modules/zod/src/v4/core/tests/url-no-canparse.test.ts +133 -0
- package/node_modules/zod/src/v4/core/to-json-schema.ts +283 -48
- package/node_modules/zod/src/v4/core/util.ts +454 -157
- package/node_modules/zod/src/v4/core/versions.ts +2 -2
- package/node_modules/zod/src/v4/core/visit.ts +193 -0
- package/node_modules/zod/src/v4/index.ts +3 -3
- package/node_modules/zod/src/v4/locales/ar.ts +5 -0
- package/node_modules/zod/src/v4/locales/az.ts +5 -0
- package/node_modules/zod/src/v4/locales/be.ts +12 -0
- package/node_modules/zod/src/v4/locales/bg.ts +5 -0
- package/node_modules/zod/src/v4/locales/bn.ts +123 -0
- package/node_modules/zod/src/v4/locales/ca.ts +5 -0
- package/node_modules/zod/src/v4/locales/ckb.ts +140 -0
- package/node_modules/zod/src/v4/locales/cs.ts +5 -0
- package/node_modules/zod/src/v4/locales/da.ts +7 -2
- package/node_modules/zod/src/v4/locales/de.ts +5 -0
- package/node_modules/zod/src/v4/locales/el.ts +3 -0
- package/node_modules/zod/src/v4/locales/en.ts +17 -4
- package/node_modules/zod/src/v4/locales/eo.ts +5 -0
- package/node_modules/zod/src/v4/locales/es.ts +4 -0
- package/node_modules/zod/src/v4/locales/fa.ts +5 -0
- package/node_modules/zod/src/v4/locales/fi.ts +5 -0
- package/node_modules/zod/src/v4/locales/fr-CA.ts +5 -0
- package/node_modules/zod/src/v4/locales/fr.ts +21 -14
- package/node_modules/zod/src/v4/locales/gu.ts +123 -0
- package/node_modules/zod/src/v4/locales/he.ts +8 -1
- package/node_modules/zod/src/v4/locales/hi.ts +126 -0
- package/node_modules/zod/src/v4/locales/hr.ts +4 -0
- package/node_modules/zod/src/v4/locales/hu.ts +5 -0
- package/node_modules/zod/src/v4/locales/hy.ts +11 -0
- package/node_modules/zod/src/v4/locales/id.ts +5 -0
- package/node_modules/zod/src/v4/locales/index.ts +11 -0
- package/node_modules/zod/src/v4/locales/is.ts +5 -0
- package/node_modules/zod/src/v4/locales/it.ts +5 -0
- package/node_modules/zod/src/v4/locales/ja.ts +5 -0
- package/node_modules/zod/src/v4/locales/ka.ts +5 -0
- package/node_modules/zod/src/v4/locales/km.ts +5 -0
- package/node_modules/zod/src/v4/locales/kn.ts +126 -0
- package/node_modules/zod/src/v4/locales/ko.ts +5 -0
- package/node_modules/zod/src/v4/locales/lt.ts +4 -0
- package/node_modules/zod/src/v4/locales/mk.ts +5 -0
- package/node_modules/zod/src/v4/locales/ms.ts +5 -0
- package/node_modules/zod/src/v4/locales/ne.ts +128 -0
- package/node_modules/zod/src/v4/locales/nl.ts +5 -0
- package/node_modules/zod/src/v4/locales/nn.ts +121 -0
- package/node_modules/zod/src/v4/locales/no.ts +7 -2
- package/node_modules/zod/src/v4/locales/ota.ts +5 -0
- package/node_modules/zod/src/v4/locales/pl.ts +5 -0
- package/node_modules/zod/src/v4/locales/ps.ts +5 -0
- package/node_modules/zod/src/v4/locales/pt-BR.ts +161 -0
- package/node_modules/zod/src/v4/locales/pt.ts +101 -58
- package/node_modules/zod/src/v4/locales/ro.ts +3 -0
- package/node_modules/zod/src/v4/locales/ru.ts +12 -0
- package/node_modules/zod/src/v4/locales/sk.ts +123 -0
- package/node_modules/zod/src/v4/locales/sl.ts +5 -0
- package/node_modules/zod/src/v4/locales/sv.ts +7 -2
- package/node_modules/zod/src/v4/locales/ta.ts +5 -0
- package/node_modules/zod/src/v4/locales/tg.ts +135 -0
- package/node_modules/zod/src/v4/locales/th.ts +5 -0
- package/node_modules/zod/src/v4/locales/tk.ts +113 -0
- package/node_modules/zod/src/v4/locales/tr.ts +5 -0
- package/node_modules/zod/src/v4/locales/uk.ts +5 -0
- package/node_modules/zod/src/v4/locales/ur.ts +5 -0
- package/node_modules/zod/src/v4/locales/uz.ts +3 -0
- package/node_modules/zod/src/v4/locales/vi.ts +5 -0
- package/node_modules/zod/src/v4/locales/yo.ts +5 -0
- package/node_modules/zod/src/v4/locales/zh-CN.ts +5 -0
- package/node_modules/zod/src/v4/locales/zh-TW.ts +5 -0
- package/node_modules/zod/src/v4/mini/checks.ts +1 -0
- package/node_modules/zod/src/v4/mini/deep-partial.ts +73 -0
- package/node_modules/zod/src/v4/mini/external.ts +12 -1
- package/node_modules/zod/src/v4/mini/in-out.ts +45 -0
- package/node_modules/zod/src/v4/mini/parse.ts +2 -0
- package/node_modules/zod/src/v4/mini/schemas.ts +167 -63
- package/node_modules/zod/src/v4/mini/tests/apply.test.ts +33 -0
- package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +62 -1
- package/node_modules/zod/src/v4/mini/tests/checks.test.ts +14 -0
- package/node_modules/zod/src/v4/mini/tests/codec.test.ts +35 -1
- package/node_modules/zod/src/v4/mini/tests/computed.test.ts +11 -17
- package/node_modules/zod/src/v4/mini/tests/cyclic-data.test.ts +84 -0
- package/node_modules/zod/src/v4/mini/tests/deep-partial.test.ts +54 -0
- package/node_modules/zod/src/v4/mini/tests/error.test.ts +23 -4
- package/node_modules/zod/src/v4/mini/tests/functions.test.ts +9 -0
- package/node_modules/zod/src/v4/mini/tests/index.test.ts +158 -5
- package/node_modules/zod/src/v4/mini/tests/number.test.ts +14 -0
- package/node_modules/zod/src/v4/mini/tests/object.test.ts +65 -0
- package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +16 -0
- package/node_modules/zod/src/v4/mini/tests/string.test.ts +44 -0
- package/node_modules/zod/v3/ZodError.cjs +41 -12
- package/node_modules/zod/v3/ZodError.d.cts +1 -1
- package/node_modules/zod/v3/ZodError.d.ts +1 -1
- package/node_modules/zod/v3/ZodError.js +22 -12
- package/node_modules/zod/v3/errors.cjs +19 -0
- package/node_modules/zod/v3/external.cjs +19 -0
- package/node_modules/zod/v3/helpers/enumUtil.cjs +19 -0
- package/node_modules/zod/v3/helpers/errorUtil.cjs +20 -1
- package/node_modules/zod/v3/helpers/errorUtil.js +1 -1
- package/node_modules/zod/v3/helpers/parseUtil.cjs +19 -0
- package/node_modules/zod/v3/helpers/partialUtil.cjs +19 -0
- package/node_modules/zod/v3/helpers/typeAliases.cjs +19 -0
- package/node_modules/zod/v3/helpers/util.cjs +19 -0
- package/node_modules/zod/v3/index.cjs +19 -0
- package/node_modules/zod/v3/standard-schema.cjs +19 -0
- package/node_modules/zod/v3/types.cjs +26 -5
- package/node_modules/zod/v3/types.js +7 -5
- package/node_modules/zod/v4/classic/checks.cjs +21 -1
- package/node_modules/zod/v4/classic/checks.d.cts +1 -1
- package/node_modules/zod/v4/classic/checks.d.ts +1 -1
- package/node_modules/zod/v4/classic/checks.js +1 -1
- package/node_modules/zod/v4/classic/coerce.cjs +19 -0
- package/node_modules/zod/v4/classic/compat.cjs +19 -0
- package/node_modules/zod/v4/classic/compat.d.cts +9 -11
- package/node_modules/zod/v4/classic/compat.d.ts +9 -11
- package/node_modules/zod/v4/classic/deep-partial.cjs +58 -0
- package/node_modules/zod/v4/classic/deep-partial.d.cts +14 -0
- package/node_modules/zod/v4/classic/deep-partial.d.ts +14 -0
- package/node_modules/zod/v4/classic/deep-partial.js +13 -0
- package/node_modules/zod/v4/classic/errors.cjs +62 -34
- package/node_modules/zod/v4/classic/errors.d.cts +3 -4
- package/node_modules/zod/v4/classic/errors.d.ts +3 -4
- package/node_modules/zod/v4/classic/errors.js +43 -34
- package/node_modules/zod/v4/classic/external.cjs +51 -27
- package/node_modules/zod/v4/classic/external.d.cts +5 -2
- package/node_modules/zod/v4/classic/external.d.ts +5 -2
- package/node_modules/zod/v4/classic/external.js +5 -8
- package/node_modules/zod/v4/classic/from-json-schema.cjs +376 -75
- package/node_modules/zod/v4/classic/from-json-schema.js +357 -75
- package/node_modules/zod/v4/classic/in-out.cjs +82 -0
- package/node_modules/zod/v4/classic/in-out.d.cts +8 -0
- package/node_modules/zod/v4/classic/in-out.d.ts +8 -0
- package/node_modules/zod/v4/classic/in-out.js +36 -0
- package/node_modules/zod/v4/classic/index.cjs +21 -2
- package/node_modules/zod/v4/classic/index.d.cts +1 -2
- package/node_modules/zod/v4/classic/index.d.ts +1 -2
- package/node_modules/zod/v4/classic/index.js +2 -2
- package/node_modules/zod/v4/classic/iso.cjs +30 -22
- package/node_modules/zod/v4/classic/iso.d.cts +2 -17
- package/node_modules/zod/v4/classic/iso.d.ts +2 -17
- package/node_modules/zod/v4/classic/iso.js +2 -17
- package/node_modules/zod/v4/classic/parse.cjs +23 -1
- package/node_modules/zod/v4/classic/parse.d.cts +17 -4
- package/node_modules/zod/v4/classic/parse.d.ts +17 -4
- package/node_modules/zod/v4/classic/parse.js +1 -0
- package/node_modules/zod/v4/classic/schemas.cjs +591 -426
- package/node_modules/zod/v4/classic/schemas.d.cts +68 -19
- package/node_modules/zod/v4/classic/schemas.d.ts +68 -19
- package/node_modules/zod/v4/classic/schemas.js +564 -424
- package/node_modules/zod/v4/core/api.cjs +66 -24
- package/node_modules/zod/v4/core/api.d.cts +22 -12
- package/node_modules/zod/v4/core/api.d.ts +22 -12
- package/node_modules/zod/v4/core/api.js +44 -24
- package/node_modules/zod/v4/core/checks.cjs +88 -128
- package/node_modules/zod/v4/core/checks.d.cts +29 -13
- package/node_modules/zod/v4/core/checks.d.ts +29 -13
- package/node_modules/zod/v4/core/checks.js +68 -127
- package/node_modules/zod/v4/core/compile.cjs +1908 -0
- package/node_modules/zod/v4/core/compile.d.cts +65 -0
- package/node_modules/zod/v4/core/compile.d.ts +65 -0
- package/node_modules/zod/v4/core/compile.js +1858 -0
- package/node_modules/zod/v4/core/core.cjs +101 -19
- package/node_modules/zod/v4/core/core.d.cts +16 -4
- package/node_modules/zod/v4/core/core.d.ts +16 -4
- package/node_modules/zod/v4/core/core.js +83 -20
- package/node_modules/zod/v4/core/doc.cjs +31 -9
- package/node_modules/zod/v4/core/doc.d.cts +3 -1
- package/node_modules/zod/v4/core/doc.d.ts +3 -1
- package/node_modules/zod/v4/core/doc.js +12 -9
- package/node_modules/zod/v4/core/errors.cjs +126 -25
- package/node_modules/zod/v4/core/errors.d.cts +4 -0
- package/node_modules/zod/v4/core/errors.d.ts +4 -0
- package/node_modules/zod/v4/core/errors.js +107 -25
- package/node_modules/zod/v4/core/index.cjs +24 -1
- package/node_modules/zod/v4/core/index.d.cts +3 -0
- package/node_modules/zod/v4/core/index.d.ts +3 -0
- package/node_modules/zod/v4/core/index.js +3 -0
- package/node_modules/zod/v4/core/json-schema-generator.cjs +24 -1
- package/node_modules/zod/v4/core/json-schema-generator.d.cts +2 -2
- package/node_modules/zod/v4/core/json-schema-generator.d.ts +2 -2
- package/node_modules/zod/v4/core/json-schema-generator.js +6 -2
- package/node_modules/zod/v4/core/json-schema-processors.cjs +441 -156
- package/node_modules/zod/v4/core/json-schema-processors.d.cts +16 -0
- package/node_modules/zod/v4/core/json-schema-processors.d.ts +16 -0
- package/node_modules/zod/v4/core/json-schema-processors.js +400 -158
- package/node_modules/zod/v4/core/json-schema.cjs +19 -0
- package/node_modules/zod/v4/core/json-schema.d.cts +2 -1
- package/node_modules/zod/v4/core/json-schema.d.ts +2 -1
- package/node_modules/zod/v4/core/memoizer.cjs +360 -0
- package/node_modules/zod/v4/core/memoizer.d.cts +15 -0
- package/node_modules/zod/v4/core/memoizer.d.ts +15 -0
- package/node_modules/zod/v4/core/memoizer.js +311 -0
- package/node_modules/zod/v4/core/parse.cjs +148 -46
- package/node_modules/zod/v4/core/parse.d.cts +14 -11
- package/node_modules/zod/v4/core/parse.d.ts +14 -11
- package/node_modules/zod/v4/core/parse.js +127 -45
- package/node_modules/zod/v4/core/regexes.cjs +54 -17
- package/node_modules/zod/v4/core/regexes.d.cts +5 -0
- package/node_modules/zod/v4/core/regexes.d.ts +5 -0
- package/node_modules/zod/v4/core/regexes.js +32 -15
- package/node_modules/zod/v4/core/registries.cjs +19 -0
- package/node_modules/zod/v4/core/registries.js +2 -2
- package/node_modules/zod/v4/core/schemas.cjs +785 -386
- package/node_modules/zod/v4/core/schemas.d.cts +123 -34
- package/node_modules/zod/v4/core/schemas.d.ts +123 -34
- package/node_modules/zod/v4/core/schemas.js +753 -386
- package/node_modules/zod/v4/core/standard-schema.cjs +19 -0
- package/node_modules/zod/v4/core/to-json-schema.cjs +269 -45
- package/node_modules/zod/v4/core/to-json-schema.d.cts +45 -5
- package/node_modules/zod/v4/core/to-json-schema.d.ts +45 -5
- package/node_modules/zod/v4/core/to-json-schema.js +247 -44
- package/node_modules/zod/v4/core/util.cjs +372 -157
- package/node_modules/zod/v4/core/util.d.cts +79 -1
- package/node_modules/zod/v4/core/util.d.ts +79 -1
- package/node_modules/zod/v4/core/util.js +341 -156
- package/node_modules/zod/v4/core/versions.cjs +21 -2
- package/node_modules/zod/v4/core/versions.d.cts +1 -1
- package/node_modules/zod/v4/core/versions.d.ts +1 -1
- package/node_modules/zod/v4/core/versions.js +2 -2
- package/node_modules/zod/v4/core/visit.cjs +214 -0
- package/node_modules/zod/v4/core/visit.d.cts +30 -0
- package/node_modules/zod/v4/core/visit.d.ts +30 -0
- package/node_modules/zod/v4/core/visit.js +169 -0
- package/node_modules/zod/v4/index.cjs +34 -5
- package/node_modules/zod/v4/index.d.cts +2 -2
- package/node_modules/zod/v4/index.d.ts +2 -2
- package/node_modules/zod/v4/index.js +3 -2
- package/node_modules/zod/v4/locales/ar.cjs +5 -0
- package/node_modules/zod/v4/locales/ar.js +5 -0
- package/node_modules/zod/v4/locales/az.cjs +5 -0
- package/node_modules/zod/v4/locales/az.js +5 -0
- package/node_modules/zod/v4/locales/be.cjs +12 -0
- package/node_modules/zod/v4/locales/be.js +12 -0
- package/node_modules/zod/v4/locales/bg.cjs +5 -0
- package/node_modules/zod/v4/locales/bg.js +5 -0
- package/node_modules/zod/v4/locales/bn.cjs +140 -0
- package/node_modules/zod/v4/locales/bn.d.cts +5 -0
- package/node_modules/zod/v4/locales/bn.d.ts +4 -0
- package/node_modules/zod/v4/locales/bn.js +113 -0
- package/node_modules/zod/v4/locales/ca.cjs +5 -0
- package/node_modules/zod/v4/locales/ca.js +5 -0
- package/node_modules/zod/v4/locales/ckb.cjs +160 -0
- package/node_modules/zod/v4/locales/ckb.d.cts +5 -0
- package/node_modules/zod/v4/locales/ckb.d.ts +4 -0
- package/node_modules/zod/v4/locales/ckb.js +133 -0
- package/node_modules/zod/v4/locales/cs.cjs +5 -0
- package/node_modules/zod/v4/locales/cs.js +5 -0
- package/node_modules/zod/v4/locales/da.cjs +7 -2
- package/node_modules/zod/v4/locales/da.js +7 -2
- package/node_modules/zod/v4/locales/de.cjs +5 -0
- package/node_modules/zod/v4/locales/de.js +5 -0
- package/node_modules/zod/v4/locales/el.cjs +3 -0
- package/node_modules/zod/v4/locales/el.js +3 -0
- package/node_modules/zod/v4/locales/en.cjs +16 -4
- package/node_modules/zod/v4/locales/en.js +16 -4
- package/node_modules/zod/v4/locales/eo.cjs +5 -0
- package/node_modules/zod/v4/locales/eo.js +5 -0
- package/node_modules/zod/v4/locales/es.cjs +4 -0
- package/node_modules/zod/v4/locales/es.js +4 -0
- package/node_modules/zod/v4/locales/fa.cjs +5 -0
- package/node_modules/zod/v4/locales/fa.js +5 -0
- package/node_modules/zod/v4/locales/fi.cjs +5 -0
- package/node_modules/zod/v4/locales/fi.js +5 -0
- package/node_modules/zod/v4/locales/fr-CA.cjs +5 -0
- package/node_modules/zod/v4/locales/fr-CA.js +5 -0
- package/node_modules/zod/v4/locales/fr.cjs +18 -14
- package/node_modules/zod/v4/locales/fr.js +18 -14
- package/node_modules/zod/v4/locales/gu.cjs +140 -0
- package/node_modules/zod/v4/locales/gu.d.cts +5 -0
- package/node_modules/zod/v4/locales/gu.d.ts +4 -0
- package/node_modules/zod/v4/locales/gu.js +113 -0
- package/node_modules/zod/v4/locales/he.cjs +7 -0
- package/node_modules/zod/v4/locales/he.js +7 -0
- package/node_modules/zod/v4/locales/hi.cjs +138 -0
- package/node_modules/zod/v4/locales/hi.d.cts +5 -0
- package/node_modules/zod/v4/locales/hi.d.ts +4 -0
- package/node_modules/zod/v4/locales/hi.js +111 -0
- package/node_modules/zod/v4/locales/hr.cjs +4 -0
- package/node_modules/zod/v4/locales/hr.js +4 -0
- package/node_modules/zod/v4/locales/hu.cjs +5 -0
- package/node_modules/zod/v4/locales/hu.js +5 -0
- package/node_modules/zod/v4/locales/hy.cjs +11 -0
- package/node_modules/zod/v4/locales/hy.js +11 -0
- package/node_modules/zod/v4/locales/id.cjs +5 -0
- package/node_modules/zod/v4/locales/id.js +5 -0
- package/node_modules/zod/v4/locales/index.cjs +43 -2
- package/node_modules/zod/v4/locales/index.d.cts +11 -0
- package/node_modules/zod/v4/locales/index.d.ts +11 -0
- package/node_modules/zod/v4/locales/index.js +11 -0
- package/node_modules/zod/v4/locales/is.cjs +5 -0
- package/node_modules/zod/v4/locales/is.js +5 -0
- package/node_modules/zod/v4/locales/it.cjs +5 -0
- package/node_modules/zod/v4/locales/it.js +5 -0
- package/node_modules/zod/v4/locales/ja.cjs +5 -0
- package/node_modules/zod/v4/locales/ja.js +5 -0
- package/node_modules/zod/v4/locales/ka.cjs +5 -0
- package/node_modules/zod/v4/locales/ka.js +5 -0
- package/node_modules/zod/v4/locales/km.cjs +5 -0
- package/node_modules/zod/v4/locales/km.js +5 -0
- package/node_modules/zod/v4/locales/kn.cjs +143 -0
- package/node_modules/zod/v4/locales/kn.d.cts +5 -0
- package/node_modules/zod/v4/locales/kn.d.ts +4 -0
- package/node_modules/zod/v4/locales/kn.js +116 -0
- package/node_modules/zod/v4/locales/ko.cjs +5 -0
- package/node_modules/zod/v4/locales/ko.js +5 -0
- package/node_modules/zod/v4/locales/lt.cjs +4 -0
- package/node_modules/zod/v4/locales/lt.js +4 -0
- package/node_modules/zod/v4/locales/mk.cjs +5 -0
- package/node_modules/zod/v4/locales/mk.js +5 -0
- package/node_modules/zod/v4/locales/ms.cjs +5 -0
- package/node_modules/zod/v4/locales/ms.js +5 -0
- package/node_modules/zod/v4/locales/ne.cjs +138 -0
- package/node_modules/zod/v4/locales/ne.d.cts +5 -0
- package/node_modules/zod/v4/locales/ne.d.ts +4 -0
- package/node_modules/zod/v4/locales/ne.js +111 -0
- package/node_modules/zod/v4/locales/nl.cjs +5 -0
- package/node_modules/zod/v4/locales/nl.js +5 -0
- package/node_modules/zod/v4/locales/nn.cjs +140 -0
- package/node_modules/zod/v4/locales/nn.d.cts +5 -0
- package/node_modules/zod/v4/locales/nn.d.ts +4 -0
- package/node_modules/zod/v4/locales/nn.js +113 -0
- package/node_modules/zod/v4/locales/no.cjs +7 -2
- package/node_modules/zod/v4/locales/no.js +7 -2
- package/node_modules/zod/v4/locales/ota.cjs +5 -0
- package/node_modules/zod/v4/locales/ota.js +5 -0
- package/node_modules/zod/v4/locales/pl.cjs +5 -0
- package/node_modules/zod/v4/locales/pl.js +5 -0
- package/node_modules/zod/v4/locales/ps.cjs +5 -0
- package/node_modules/zod/v4/locales/ps.js +5 -0
- package/node_modules/zod/v4/locales/pt-BR.cjs +170 -0
- package/node_modules/zod/v4/locales/pt-BR.d.cts +5 -0
- package/node_modules/zod/v4/locales/pt-BR.d.ts +4 -0
- package/node_modules/zod/v4/locales/pt-BR.js +143 -0
- package/node_modules/zod/v4/locales/pt.cjs +89 -55
- package/node_modules/zod/v4/locales/pt.js +89 -55
- package/node_modules/zod/v4/locales/ro.cjs +3 -0
- package/node_modules/zod/v4/locales/ro.js +3 -0
- package/node_modules/zod/v4/locales/ru.cjs +12 -0
- package/node_modules/zod/v4/locales/ru.js +12 -0
- package/node_modules/zod/v4/locales/sk.cjs +143 -0
- package/node_modules/zod/v4/locales/sk.d.cts +5 -0
- package/node_modules/zod/v4/locales/sk.d.ts +4 -0
- package/node_modules/zod/v4/locales/sk.js +116 -0
- package/node_modules/zod/v4/locales/sl.cjs +5 -0
- package/node_modules/zod/v4/locales/sl.js +5 -0
- package/node_modules/zod/v4/locales/sv.cjs +7 -2
- package/node_modules/zod/v4/locales/sv.js +7 -2
- package/node_modules/zod/v4/locales/ta.cjs +5 -0
- package/node_modules/zod/v4/locales/ta.js +5 -0
- package/node_modules/zod/v4/locales/tg.cjs +144 -0
- package/node_modules/zod/v4/locales/tg.d.cts +5 -0
- package/node_modules/zod/v4/locales/tg.d.ts +4 -0
- package/node_modules/zod/v4/locales/tg.js +117 -0
- package/node_modules/zod/v4/locales/th.cjs +5 -0
- package/node_modules/zod/v4/locales/th.js +5 -0
- package/node_modules/zod/v4/locales/tk.cjs +134 -0
- package/node_modules/zod/v4/locales/tk.d.cts +5 -0
- package/node_modules/zod/v4/locales/tk.d.ts +4 -0
- package/node_modules/zod/v4/locales/tk.js +107 -0
- package/node_modules/zod/v4/locales/tr.cjs +5 -0
- package/node_modules/zod/v4/locales/tr.js +5 -0
- package/node_modules/zod/v4/locales/uk.cjs +5 -0
- package/node_modules/zod/v4/locales/uk.js +5 -0
- package/node_modules/zod/v4/locales/ur.cjs +5 -0
- package/node_modules/zod/v4/locales/ur.js +5 -0
- package/node_modules/zod/v4/locales/uz.cjs +3 -0
- package/node_modules/zod/v4/locales/uz.js +3 -0
- package/node_modules/zod/v4/locales/vi.cjs +5 -0
- package/node_modules/zod/v4/locales/vi.js +5 -0
- package/node_modules/zod/v4/locales/yo.cjs +5 -0
- package/node_modules/zod/v4/locales/yo.js +5 -0
- package/node_modules/zod/v4/locales/zh-CN.cjs +5 -0
- package/node_modules/zod/v4/locales/zh-CN.js +5 -0
- package/node_modules/zod/v4/locales/zh-TW.cjs +5 -0
- package/node_modules/zod/v4/locales/zh-TW.js +5 -0
- package/node_modules/zod/v4/mini/checks.cjs +21 -1
- package/node_modules/zod/v4/mini/checks.d.cts +1 -1
- package/node_modules/zod/v4/mini/checks.d.ts +1 -1
- package/node_modules/zod/v4/mini/checks.js +1 -1
- package/node_modules/zod/v4/mini/coerce.cjs +19 -0
- package/node_modules/zod/v4/mini/deep-partial.cjs +58 -0
- package/node_modules/zod/v4/mini/deep-partial.d.cts +14 -0
- package/node_modules/zod/v4/mini/deep-partial.d.ts +14 -0
- package/node_modules/zod/v4/mini/deep-partial.js +13 -0
- package/node_modules/zod/v4/mini/external.cjs +33 -1
- package/node_modules/zod/v4/mini/external.d.cts +5 -2
- package/node_modules/zod/v4/mini/external.d.ts +5 -2
- package/node_modules/zod/v4/mini/external.js +3 -1
- package/node_modules/zod/v4/mini/in-out.cjs +82 -0
- package/node_modules/zod/v4/mini/in-out.d.cts +8 -0
- package/node_modules/zod/v4/mini/in-out.d.ts +8 -0
- package/node_modules/zod/v4/mini/in-out.js +36 -0
- package/node_modules/zod/v4/mini/index.cjs +19 -0
- package/node_modules/zod/v4/mini/iso.cjs +19 -0
- package/node_modules/zod/v4/mini/parse.cjs +22 -1
- package/node_modules/zod/v4/mini/parse.d.cts +1 -1
- package/node_modules/zod/v4/mini/parse.d.ts +1 -1
- package/node_modules/zod/v4/mini/parse.js +1 -1
- package/node_modules/zod/v4/mini/schemas.cjs +117 -53
- package/node_modules/zod/v4/mini/schemas.d.cts +49 -14
- package/node_modules/zod/v4/mini/schemas.d.ts +49 -14
- package/node_modules/zod/v4/mini/schemas.js +92 -51
- package/node_modules/zod/v4-mini/index.cjs +19 -0
- package/openclaw.plugin.json +3 -4
- package/package.json +13 -8
- package/dist/channel-type-CVLZyGYS.js +0 -7
- package/dist/message-handler.history-CJOsN9w5.js +0 -28
- package/dist/outbound-components-DrlHcWfM.js +0 -100
- package/dist/provider.runtime-CqfE-RvC.js +0 -2
- package/dist/targets-Cm6aV9nJ.js +0 -3
- package/node_modules/discord-api-types/CHANGELOG.md +0 -2514
- package/node_modules/discord-api-types/scripts/versions.mjs +0 -46
- package/node_modules/zod/src/v4/core/config.ts +0 -15
- /package/dist/{accounts-CwJQoLjM.js → .setup/accounts-CwJQoLjM.mjs} +0 -0
- /package/dist/{active-turn-thread-route-fmHl1HNd.js → .setup/active-turn-thread-route-fmHl1HNd.mjs} +0 -0
- /package/dist/{agent-components.runtime-CEPrf2SY.js → .setup/agent-components.runtime-CEPrf2SY.mjs} +0 -0
- /package/dist/{channel-access-C12aDZ0p.js → .setup/channel-access-C12aDZ0p.mjs} +0 -0
- /package/dist/{command-deploy-store-DFkBTViB.js → .setup/command-deploy-store-DFkBTViB.mjs} +0 -0
- /package/dist/{command-owners-D78sAoOz.js → .setup/command-owners-D78sAoOz.mjs} +0 -0
- /package/dist/{doctor-contract-Co5vRCZ6.js → .setup/doctor-contract-Co5vRCZ6.mjs} +0 -0
- /package/dist/{model-picker-preference-primitives-BHT1LkR_.js → .setup/model-picker-preference-primitives-BHT1LkR_.mjs} +0 -0
- /package/dist/{presence-cache-dYSHPWMx.js → .setup/presence-cache-dYSHPWMx.mjs} +0 -0
- /package/dist/{runtime-DgnVQ7zW.js → .setup/runtime-DgnVQ7zW.mjs} +0 -0
- /package/dist/{secret-config-contract-DFu9hfU8.js → .setup/secret-config-contract-DFu9hfU8.mjs} +0 -0
- /package/dist/{security-contract-DSHk7I2w.js → .setup/security-contract-DSHk7I2w.mjs} +0 -0
- /package/dist/{security-doctor-nGgPm65L.js → .setup/security-doctor-nGgPm65L.mjs} +0 -0
- /package/dist/{session-contract-BO5tlIdl.js → .setup/session-contract-BO5tlIdl.mjs} +0 -0
- /package/dist/{session-key-normalization-wJgsKPNF.js → .setup/session-key-normalization-wJgsKPNF.mjs} +0 -0
- /package/dist/{thread-binding-api-BDZJD4na.js → .setup/thread-binding-api-BDZJD4na.mjs} +0 -0
- /package/dist/{timeouts-D86uWLt_.js → .setup/timeouts-D86uWLt_.mjs} +0 -0
|
@@ -0,0 +1,1065 @@
|
|
|
1
|
+
import { S as setDiscordAudioOutputStatus, _ as getDiscordAudioOutputStatus, b as retireDiscordAudioOutput, f as createRealtimePcmToDiscordConverter, h as DiscordAudioOutputStatus, i as enableDaveReceivePassthrough, l as createDiscordOpusEncodeStream, n as analyzeVoiceReceiveError, p as decodeOpusStreamChunks, s as recoverDaveZeroTransition, u as createDiscordOpusPlaybackStream, v as releaseDiscordAudioInput, x as serializeDiscordAudioError } from "../../.setup/receive-recovery-DHst8WRx.mjs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
4
|
+
import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env";
|
|
5
|
+
import { parentPort, workerData } from "node:worker_threads";
|
|
6
|
+
import { PassThrough, pipeline } from "node:stream";
|
|
7
|
+
import { REALTIME_VOICE_AUDIO_FORMAT_PCM16_24KHZ } from "openclaw/plugin-sdk/realtime-voice-provider";
|
|
8
|
+
import { createRealtimeVoiceOutputActivityTracker, isRealtimeVoiceAudioAudible } from "openclaw/plugin-sdk/realtime-voice";
|
|
9
|
+
//#region extensions/discord/src/voice/sdk-runtime.ts
|
|
10
|
+
let cachedDiscordVoiceSdk = null;
|
|
11
|
+
function loadDiscordVoiceSdk() {
|
|
12
|
+
if (cachedDiscordVoiceSdk) return cachedDiscordVoiceSdk;
|
|
13
|
+
cachedDiscordVoiceSdk = createRequire(import.meta.url)("@discordjs/voice");
|
|
14
|
+
return cachedDiscordVoiceSdk;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region extensions/discord/src/voice/realtime-player.runtime.ts
|
|
18
|
+
const DISCORD_REALTIME_PLAYBACK_IDLE_MS = 2e3;
|
|
19
|
+
/** One physical player serves every speaker lane in the room. */
|
|
20
|
+
var DiscordRealtimePlayer = class {
|
|
21
|
+
hold(hold) {
|
|
22
|
+
this.holds = Math.max(0, this.holds + (hold ? 1 : -1));
|
|
23
|
+
this.drain();
|
|
24
|
+
}
|
|
25
|
+
constructor(player) {
|
|
26
|
+
this.player = player;
|
|
27
|
+
this.queue = [];
|
|
28
|
+
this.changing = false;
|
|
29
|
+
this.closed = false;
|
|
30
|
+
this.holds = 0;
|
|
31
|
+
this.onIdle = () => {
|
|
32
|
+
const request = this.current;
|
|
33
|
+
this.current = void 0;
|
|
34
|
+
if (request) this.transition(() => request.onIdle());
|
|
35
|
+
};
|
|
36
|
+
const stop = player.stop.bind(player);
|
|
37
|
+
player.stop = (force) => {
|
|
38
|
+
const request = this.current;
|
|
39
|
+
if (request && !force && !request.onRetiring()) return false;
|
|
40
|
+
return stop(force);
|
|
41
|
+
};
|
|
42
|
+
player.on(loadDiscordVoiceSdk().AudioPlayerStatus.Idle, this.onIdle);
|
|
43
|
+
}
|
|
44
|
+
enqueue(request) {
|
|
45
|
+
if (this.closed || this.current === request) return;
|
|
46
|
+
if (!this.queue.includes(request)) this.queue.push(request);
|
|
47
|
+
this.drain();
|
|
48
|
+
}
|
|
49
|
+
isRetiring(request) {
|
|
50
|
+
if (this.current !== request) return false;
|
|
51
|
+
const state = this.player.state;
|
|
52
|
+
return state.status !== loadDiscordVoiceSdk().AudioPlayerStatus.Idle && state.resource.silenceRemaining >= 0;
|
|
53
|
+
}
|
|
54
|
+
cancel(request) {
|
|
55
|
+
this.queue = this.queue.filter((queued) => queued !== request);
|
|
56
|
+
if (this.current !== request) {
|
|
57
|
+
this.drain();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
this.current = void 0;
|
|
61
|
+
this.transition(() => this.player.stop(true));
|
|
62
|
+
}
|
|
63
|
+
close() {
|
|
64
|
+
if (this.closed) return;
|
|
65
|
+
this.closed = true;
|
|
66
|
+
this.queue = [];
|
|
67
|
+
this.current = void 0;
|
|
68
|
+
this.player.off(loadDiscordVoiceSdk().AudioPlayerStatus.Idle, this.onIdle);
|
|
69
|
+
this.player.stop(true);
|
|
70
|
+
}
|
|
71
|
+
/** Prevent retiring one lane from granting playback to a sibling that is also retiring. */
|
|
72
|
+
transition(action) {
|
|
73
|
+
const wasChanging = this.changing;
|
|
74
|
+
this.changing = true;
|
|
75
|
+
try {
|
|
76
|
+
action();
|
|
77
|
+
} finally {
|
|
78
|
+
this.changing = wasChanging;
|
|
79
|
+
this.drain();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
drain() {
|
|
83
|
+
if (this.closed || this.changing || this.current || this.holds > 0) return;
|
|
84
|
+
const next = this.queue[0];
|
|
85
|
+
if (!next?.isReady()) return;
|
|
86
|
+
this.queue.shift();
|
|
87
|
+
this.current = next;
|
|
88
|
+
this.transition(() => {
|
|
89
|
+
try {
|
|
90
|
+
this.player.play(next.createResource());
|
|
91
|
+
next.onStart();
|
|
92
|
+
} catch (error) {
|
|
93
|
+
this.current = void 0;
|
|
94
|
+
this.player.stop(true);
|
|
95
|
+
next.onError(error);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region extensions/discord/src/voice/realtime-output.runtime.ts
|
|
102
|
+
const logger = createSubsystemLogger("discord/voice");
|
|
103
|
+
const DISCORD_RAW_PCM_FRAME_BYTES = 3840;
|
|
104
|
+
const DISCORD_RAW_PCM_BYTES_PER_MS = 192;
|
|
105
|
+
const DISCORD_REALTIME_OUTPUT_PREROLL_FRAMES = 25;
|
|
106
|
+
const DISCORD_CONTINUOUS_PREROLL_FRAMES = 6;
|
|
107
|
+
const DISCORD_CONTINUOUS_START_DEADLINE_MS = 120;
|
|
108
|
+
const DISCORD_REALTIME_OUTPUT_PLAYBACK_WATCHDOG_MARGIN_MS = 3e3;
|
|
109
|
+
/** One output stream retains ownership through queued and audible playback. */
|
|
110
|
+
var DiscordRealtimeOutput = class {
|
|
111
|
+
constructor(params) {
|
|
112
|
+
this.params = params;
|
|
113
|
+
this.activity = createRealtimeVoiceOutputActivityTracker();
|
|
114
|
+
this.converter = createRealtimePcmToDiscordConverter();
|
|
115
|
+
this.stream = new PassThrough({ highWaterMark: DISCORD_RAW_PCM_FRAME_BYTES * 128 });
|
|
116
|
+
this.ready = false;
|
|
117
|
+
this.playbackMarks = [];
|
|
118
|
+
this.playedPcmBytes = 0;
|
|
119
|
+
this.lastAudiblePcmEndBytes = 0;
|
|
120
|
+
this.buffers = [];
|
|
121
|
+
this.bufferedBytes = 0;
|
|
122
|
+
this.closed = false;
|
|
123
|
+
this.failed = false;
|
|
124
|
+
this.stream.once("close", () => {
|
|
125
|
+
if (!this.activity.snapshot().playbackStarted) this.close("stream-close");
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
pendingBytes() {
|
|
129
|
+
return this.closed ? 0 : Math.max(0, this.activity.snapshot().sourceAudioBytes * 4 - this.playedPcmBytes);
|
|
130
|
+
}
|
|
131
|
+
isAcceptingAudio() {
|
|
132
|
+
return !this.closed && getDiscordAudioOutputStatus(this.params.clock) < DiscordAudioOutputStatus.Retiring && !this.activity.snapshot().streamEnding && (!this.request || !this.params.player.isRetiring(this.request));
|
|
133
|
+
}
|
|
134
|
+
hasUnplayedAudibleAudio() {
|
|
135
|
+
return !this.closed && this.playedPcmBytes < this.lastAudiblePcmEndBytes;
|
|
136
|
+
}
|
|
137
|
+
markPlayback(acknowledge) {
|
|
138
|
+
if (!this.closed) this.playbackMarks.push({
|
|
139
|
+
endBytes: this.activity.snapshot().sinkAudioBytes,
|
|
140
|
+
acknowledge
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
append(sourcePcm, audible) {
|
|
144
|
+
if (!this.isAcceptingAudio()) return;
|
|
145
|
+
const previous = this.activity.snapshot();
|
|
146
|
+
const sinkBytes = Math.floor((previous.sourceAudioBytes + sourcePcm.length) / 2) * 8;
|
|
147
|
+
const audioMs = (sinkBytes - previous.sinkAudioBytes) / DISCORD_RAW_PCM_BYTES_PER_MS;
|
|
148
|
+
this.activity.markAudio({
|
|
149
|
+
audioMs,
|
|
150
|
+
sourceAudioBytes: sourcePcm.length,
|
|
151
|
+
sinkAudioBytes: sinkBytes - previous.sinkAudioBytes
|
|
152
|
+
});
|
|
153
|
+
if (audible) {
|
|
154
|
+
this.clearSilenceTimer();
|
|
155
|
+
this.silentSince = void 0;
|
|
156
|
+
this.lastAudiblePcmEndBytes = this.activity.snapshot().sinkAudioBytes;
|
|
157
|
+
}
|
|
158
|
+
this.writeConverted(this.converter.process(sourcePcm));
|
|
159
|
+
this.scheduleSilenceRetirement();
|
|
160
|
+
if (this.params.continuous) this.enqueuePlayback();
|
|
161
|
+
const prerollFrames = this.params.continuous ? DISCORD_CONTINUOUS_PREROLL_FRAMES : DISCORD_REALTIME_OUTPUT_PREROLL_FRAMES;
|
|
162
|
+
if (this.activity.snapshot().sinkAudioBytes >= DISCORD_RAW_PCM_FRAME_BYTES * prerollFrames) this.startPlayback();
|
|
163
|
+
else if (this.params.continuous && !this.ready && !this.startupTimer) {
|
|
164
|
+
this.startupTimer = setTimeout(() => {
|
|
165
|
+
this.startupTimer = void 0;
|
|
166
|
+
this.startPlayback();
|
|
167
|
+
}, DISCORD_CONTINUOUS_START_DEADLINE_MS);
|
|
168
|
+
this.startupTimer.unref?.();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
appendAdmitted(sourcePcm, audible) {
|
|
172
|
+
try {
|
|
173
|
+
this.append(sourcePcm, audible);
|
|
174
|
+
} finally {
|
|
175
|
+
releaseDiscordAudioInput(this.params.clock);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
writeConverted(pcm) {
|
|
179
|
+
if (pcm.length === 0 || this.closed) return;
|
|
180
|
+
if (this.activity.snapshot().playbackStarted && !this.drainHandler) {
|
|
181
|
+
if (!this.stream.write(pcm)) this.waitForDrain();
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
this.buffers.push(pcm);
|
|
185
|
+
this.bufferedBytes += pcm.length;
|
|
186
|
+
}
|
|
187
|
+
finish(reason, playBuffered) {
|
|
188
|
+
if (this.closed) return;
|
|
189
|
+
this.publishRetiring();
|
|
190
|
+
this.clearSilenceTimer();
|
|
191
|
+
if (playBuffered) this.writeConverted(this.converter.flush());
|
|
192
|
+
this.activity.markStreamEnding();
|
|
193
|
+
const activity = this.activity.snapshot();
|
|
194
|
+
logger.info(`discord voice: realtime audio playback finishing reason=${reason} ${this.params.logContext} audioMs=${Math.floor(activity.audioMs)} chunks=${activity.chunks}`);
|
|
195
|
+
if (!playBuffered) {
|
|
196
|
+
this.close(reason);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
this.startPlayback();
|
|
200
|
+
if (this.activity.snapshot().playbackStarted) {
|
|
201
|
+
this.scheduleWatchdog(reason);
|
|
202
|
+
if (!this.drainHandler) this.stream.end();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
close(reason) {
|
|
206
|
+
if (this.closed) return;
|
|
207
|
+
const playbackRetirement = reason === "player-idle" || reason === "output-pipeline-error" || reason === "playback-watchdog";
|
|
208
|
+
const heardMarks = playbackRetirement ? this.playbackMarks.filter((mark) => mark.endBytes <= this.playedPcmBytes) : [];
|
|
209
|
+
const lostPlaybackMarks = playbackRetirement && this.playbackMarks.some((mark) => mark.endBytes > this.playedPcmBytes);
|
|
210
|
+
this.closed = true;
|
|
211
|
+
setDiscordAudioOutputStatus(this.params.clock, DiscordAudioOutputStatus.Closed);
|
|
212
|
+
this.clearSilenceTimer();
|
|
213
|
+
clearTimeout(this.startupTimer);
|
|
214
|
+
this.startupTimer = void 0;
|
|
215
|
+
this.playbackMarks = [];
|
|
216
|
+
this.clearWatchdog();
|
|
217
|
+
const activity = this.activity.snapshot();
|
|
218
|
+
logger.info(`discord voice: realtime audio playback stopped reason=${reason} ${this.params.logContext} audioMs=${Math.floor(activity.audioMs)} elapsedMs=${this.activity.elapsedPlaybackMs()} chunks=${activity.chunks} discordBytes=${activity.sinkAudioBytes} realtimeBytes=${activity.sourceAudioBytes}`);
|
|
219
|
+
this.buffers = [];
|
|
220
|
+
this.bufferedBytes = 0;
|
|
221
|
+
if (this.drainHandler) {
|
|
222
|
+
this.stream.off("drain", this.drainHandler);
|
|
223
|
+
this.drainHandler = void 0;
|
|
224
|
+
}
|
|
225
|
+
this.stream.end();
|
|
226
|
+
this.stream.destroy();
|
|
227
|
+
if (lostPlaybackMarks) this.params.onError(/* @__PURE__ */ new Error(`Discord realtime audio stopped before playback completed: ${reason}`));
|
|
228
|
+
this.params.onClose(this, reason);
|
|
229
|
+
if (this.request) {
|
|
230
|
+
this.params.player.cancel(this.request);
|
|
231
|
+
this.request = void 0;
|
|
232
|
+
}
|
|
233
|
+
try {
|
|
234
|
+
for (const mark of heardMarks) mark.acknowledge();
|
|
235
|
+
} catch (error) {
|
|
236
|
+
this.params.onError(error);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
startPlayback() {
|
|
240
|
+
if (this.closed || this.ready) return;
|
|
241
|
+
clearTimeout(this.startupTimer);
|
|
242
|
+
this.startupTimer = void 0;
|
|
243
|
+
if (this.bufferedBytes < DISCORD_RAW_PCM_FRAME_BYTES) this.writeConverted(this.converter.drain());
|
|
244
|
+
this.ready = true;
|
|
245
|
+
this.enqueuePlayback();
|
|
246
|
+
}
|
|
247
|
+
publishRetiring() {
|
|
248
|
+
if (!this.closed) setDiscordAudioOutputStatus(this.params.clock, DiscordAudioOutputStatus.Retiring);
|
|
249
|
+
}
|
|
250
|
+
enqueuePlayback() {
|
|
251
|
+
this.request ??= {
|
|
252
|
+
isReady: () => this.ready,
|
|
253
|
+
createResource: () => this.createResource(),
|
|
254
|
+
onStart: () => {
|
|
255
|
+
this.activity.markPlaybackStarted();
|
|
256
|
+
setDiscordAudioOutputStatus(this.params.clock, this.activity.snapshot().streamEnding ? DiscordAudioOutputStatus.Retiring : DiscordAudioOutputStatus.Playing);
|
|
257
|
+
Atomics.store(this.params.clock, 2, 1n);
|
|
258
|
+
this.params.onStart();
|
|
259
|
+
if (this.activity.snapshot().streamEnding) {
|
|
260
|
+
this.scheduleWatchdog("player-start");
|
|
261
|
+
if (!this.drainHandler) this.stream.end();
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
onRetiring: () => this.activity.snapshot().sinkAudioBytes <= this.playedPcmBytes && retireDiscordAudioOutput(this.params.clock),
|
|
265
|
+
onIdle: () => this.close(this.failed ? "output-pipeline-error" : "player-idle"),
|
|
266
|
+
onError: this.params.onError
|
|
267
|
+
};
|
|
268
|
+
this.params.player.enqueue(this.request);
|
|
269
|
+
}
|
|
270
|
+
createResource() {
|
|
271
|
+
const voiceSdk = loadDiscordVoiceSdk();
|
|
272
|
+
const opusStream = createDiscordOpusEncodeStream();
|
|
273
|
+
opusStream.once("error", () => {
|
|
274
|
+
this.failed = true;
|
|
275
|
+
});
|
|
276
|
+
pipeline(this.stream, opusStream, (error) => {
|
|
277
|
+
if (!error || this.closed) return;
|
|
278
|
+
logger.warn(`discord voice: realtime output pipeline failed ${this.params.logContext}: ${formatErrorMessage(error)}`);
|
|
279
|
+
this.close("output-pipeline-error");
|
|
280
|
+
});
|
|
281
|
+
const buffered = Buffer.concat(this.buffers, this.bufferedBytes);
|
|
282
|
+
this.buffers = [];
|
|
283
|
+
this.bufferedBytes = 0;
|
|
284
|
+
if (buffered.length > 0 && !this.stream.write(buffered)) this.waitForDrain();
|
|
285
|
+
if (this.params.continuous && buffered.length > 0 && buffered.length < DISCORD_RAW_PCM_FRAME_BYTES) opusStream.flushPartialFrameWhenReady();
|
|
286
|
+
const resource = voiceSdk.createAudioResource(opusStream, { inputType: voiceSdk.StreamType.Opus });
|
|
287
|
+
const read = resource.read.bind(resource);
|
|
288
|
+
resource.read = () => {
|
|
289
|
+
if (this.params.isOpen?.() === false || getDiscordAudioOutputStatus(this.params.clock) === DiscordAudioOutputStatus.Closed) {
|
|
290
|
+
this.close("port-closed");
|
|
291
|
+
return null;
|
|
292
|
+
}
|
|
293
|
+
let packet;
|
|
294
|
+
try {
|
|
295
|
+
packet = read();
|
|
296
|
+
if (!packet && opusStream.flushPartialFrame()) packet = read();
|
|
297
|
+
if (packet) {
|
|
298
|
+
this.playedPcmBytes += opusStream.takePcmBytes(packet);
|
|
299
|
+
Atomics.store(this.params.clock, 0, BigInt(this.playedPcmBytes));
|
|
300
|
+
if (resource.silenceRemaining >= 0) this.publishRetiring();
|
|
301
|
+
const remaining = this.activity.snapshot().sinkAudioBytes - this.playedPcmBytes;
|
|
302
|
+
if (remaining > 0 && remaining <= DISCORD_RAW_PCM_FRAME_BYTES) this.writeConverted(this.converter.drain());
|
|
303
|
+
this.scheduleSilenceRetirement();
|
|
304
|
+
}
|
|
305
|
+
} catch (error) {
|
|
306
|
+
opusStream.destroy(error instanceof Error ? error : new Error(formatErrorMessage(error)));
|
|
307
|
+
return null;
|
|
308
|
+
}
|
|
309
|
+
if (this.playbackMarks.length > 0) queueMicrotask(() => this.acknowledgePlayedMarks());
|
|
310
|
+
return packet;
|
|
311
|
+
};
|
|
312
|
+
return resource;
|
|
313
|
+
}
|
|
314
|
+
acknowledgePlayedMarks() {
|
|
315
|
+
try {
|
|
316
|
+
while (!this.closed) {
|
|
317
|
+
const mark = this.playbackMarks[0];
|
|
318
|
+
if (!mark || mark.endBytes > this.playedPcmBytes) return;
|
|
319
|
+
this.playbackMarks.shift();
|
|
320
|
+
mark.acknowledge();
|
|
321
|
+
}
|
|
322
|
+
} catch (error) {
|
|
323
|
+
this.params.onError(error);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
scheduleSilenceRetirement() {
|
|
327
|
+
const activity = this.activity.snapshot();
|
|
328
|
+
if (!this.params.continuous || this.closed || activity.streamEnding || !activity.playbackStarted || this.hasUnplayedAudibleAudio()) return;
|
|
329
|
+
this.silentSince ??= performance.now();
|
|
330
|
+
if (activity.sinkAudioBytes <= this.lastAudiblePcmEndBytes || this.silenceTimer) return;
|
|
331
|
+
this.silenceTimer = setTimeout(() => {
|
|
332
|
+
this.silenceTimer = void 0;
|
|
333
|
+
if (!this.closed && !this.activity.snapshot().streamEnding && !this.hasUnplayedAudibleAudio() && retireDiscordAudioOutput(this.params.clock)) this.finish("continuous-idle", true);
|
|
334
|
+
}, Math.max(0, DISCORD_REALTIME_PLAYBACK_IDLE_MS - (performance.now() - this.silentSince)));
|
|
335
|
+
this.silenceTimer.unref?.();
|
|
336
|
+
}
|
|
337
|
+
clearSilenceTimer() {
|
|
338
|
+
clearTimeout(this.silenceTimer);
|
|
339
|
+
this.silenceTimer = void 0;
|
|
340
|
+
}
|
|
341
|
+
waitForDrain() {
|
|
342
|
+
if (this.drainHandler || this.closed) return;
|
|
343
|
+
logger.info(`discord voice: realtime audio playback buffering ${this.params.logContext} bufferedBytes=${this.stream.writableLength + this.stream.readableLength}`);
|
|
344
|
+
this.drainHandler = () => {
|
|
345
|
+
this.drainHandler = void 0;
|
|
346
|
+
if (this.closed) return;
|
|
347
|
+
let refreshWatchdog = this.activity.snapshot().streamEnding;
|
|
348
|
+
while (this.buffers.length > 0) {
|
|
349
|
+
const buffered = this.buffers.shift();
|
|
350
|
+
if (!buffered) break;
|
|
351
|
+
this.bufferedBytes -= buffered.length;
|
|
352
|
+
const writable = this.stream.write(buffered);
|
|
353
|
+
if (refreshWatchdog) {
|
|
354
|
+
this.scheduleWatchdog("output-drain");
|
|
355
|
+
refreshWatchdog = false;
|
|
356
|
+
}
|
|
357
|
+
if (!writable) {
|
|
358
|
+
this.waitForDrain();
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
if (this.activity.snapshot().streamEnding) this.stream.end();
|
|
363
|
+
};
|
|
364
|
+
this.stream.once("drain", this.drainHandler);
|
|
365
|
+
}
|
|
366
|
+
scheduleWatchdog(reason) {
|
|
367
|
+
this.clearWatchdog();
|
|
368
|
+
const timeoutMs = this.activity.playbackWatchdogDelayMs({
|
|
369
|
+
marginMs: DISCORD_REALTIME_OUTPUT_PLAYBACK_WATCHDOG_MARGIN_MS,
|
|
370
|
+
minMs: DISCORD_REALTIME_OUTPUT_PLAYBACK_WATCHDOG_MARGIN_MS
|
|
371
|
+
});
|
|
372
|
+
if (timeoutMs === void 0) return;
|
|
373
|
+
this.watchdog = setTimeout(() => {
|
|
374
|
+
this.watchdog = void 0;
|
|
375
|
+
logger.warn(`discord voice: realtime audio playback watchdog fired reason=${reason} ${this.params.logContext} audioMs=${Math.floor(this.activity.snapshot().audioMs)} elapsedMs=${this.activity.elapsedPlaybackMs()}`);
|
|
376
|
+
this.close("playback-watchdog");
|
|
377
|
+
}, timeoutMs);
|
|
378
|
+
}
|
|
379
|
+
clearWatchdog() {
|
|
380
|
+
clearTimeout(this.watchdog);
|
|
381
|
+
this.watchdog = void 0;
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
//#endregion
|
|
385
|
+
//#region extensions/discord/src/voice/continuous-output.runtime.ts
|
|
386
|
+
/** A transferred endpoint is owned by one already-admitted provider generation.
|
|
387
|
+
* No socket, response policy, credential, or speaker admission crosses this port. */
|
|
388
|
+
var DiscordContinuousOutput = class {
|
|
389
|
+
constructor(params) {
|
|
390
|
+
this.params = params;
|
|
391
|
+
this.outputs = /* @__PURE__ */ new Set();
|
|
392
|
+
this.closed = false;
|
|
393
|
+
this.enabled = params.enabled;
|
|
394
|
+
params.port.on("message", (message) => {
|
|
395
|
+
try {
|
|
396
|
+
if (this.closed || Atomics.load(params.state, 0) !== 0) return;
|
|
397
|
+
if (message.type === "flushed") {
|
|
398
|
+
params.post({
|
|
399
|
+
type: "continuous-flushed",
|
|
400
|
+
id: params.id,
|
|
401
|
+
marker: message.marker
|
|
402
|
+
});
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
if (!this.enabled) return;
|
|
406
|
+
if (message.type === "audio") this.append(Buffer.from(message.audio));
|
|
407
|
+
else if (message.type === "clear") this.clear();
|
|
408
|
+
} catch (error) {
|
|
409
|
+
this.fail(error);
|
|
410
|
+
} finally {
|
|
411
|
+
if (message.type === "audio") params.port.postMessage({ type: "ack" }, []);
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
params.port.on("messageerror", (error) => this.fail(error));
|
|
415
|
+
params.port.on("close", () => this.close());
|
|
416
|
+
}
|
|
417
|
+
append(audio) {
|
|
418
|
+
if (!audio.length) return;
|
|
419
|
+
if (this.generating && !this.generating.isAcceptingAudio()) this.generating = void 0;
|
|
420
|
+
const audible = isRealtimeVoiceAudioAudible(audio, REALTIME_VOICE_AUDIO_FORMAT_PCM16_24KHZ);
|
|
421
|
+
if (!audible && !this.generating) return;
|
|
422
|
+
if ([...this.outputs].reduce((total, output) => total + output.pendingBytes(), 0) + audio.length * 4 > 2304e4 || !this.generating && this.outputs.size >= 32) throw new Error("Discord realtime direct audio backlog exceeded.");
|
|
423
|
+
if (!this.generating) {
|
|
424
|
+
const latch = Atomics.load(this.params.clock, 2);
|
|
425
|
+
const speechEpoch = latch < 0n ? -latch : latch;
|
|
426
|
+
const output = new DiscordRealtimeOutput({
|
|
427
|
+
player: this.params.player,
|
|
428
|
+
clock: new BigInt64Array(new SharedArrayBuffer(24)),
|
|
429
|
+
continuous: true,
|
|
430
|
+
logContext: this.params.logContext,
|
|
431
|
+
isOpen: () => {
|
|
432
|
+
const current = Atomics.load(this.params.clock, 2);
|
|
433
|
+
return !this.closed && this.enabled && Atomics.load(this.params.state, 0) === 0 && (current === speechEpoch || current === -speechEpoch);
|
|
434
|
+
},
|
|
435
|
+
onStart: () => {
|
|
436
|
+
const current = Atomics.compareExchange(this.params.clock, 2, speechEpoch, -speechEpoch);
|
|
437
|
+
if (current !== speechEpoch && current !== -speechEpoch) {
|
|
438
|
+
output.close("exact-speech-retired");
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
this.params.post({
|
|
442
|
+
type: "continuous-start",
|
|
443
|
+
id: this.params.id,
|
|
444
|
+
speechEpoch
|
|
445
|
+
});
|
|
446
|
+
},
|
|
447
|
+
onClose: (closed) => {
|
|
448
|
+
this.outputs.delete(closed);
|
|
449
|
+
if (this.generating === closed) this.generating = void 0;
|
|
450
|
+
Atomics.store(this.params.clock, 0, BigInt(this.outputs.size));
|
|
451
|
+
if (this.outputs.size === 0) {
|
|
452
|
+
Atomics.store(this.params.clock, 1, 0n);
|
|
453
|
+
this.params.post({
|
|
454
|
+
type: "continuous-idle",
|
|
455
|
+
id: this.params.id,
|
|
456
|
+
speechEpoch
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
},
|
|
460
|
+
onError: (error) => this.fail(error)
|
|
461
|
+
});
|
|
462
|
+
this.outputs.add(output);
|
|
463
|
+
this.generating = output;
|
|
464
|
+
Atomics.store(this.params.clock, 0, BigInt(this.outputs.size));
|
|
465
|
+
}
|
|
466
|
+
Atomics.add(this.params.clock, 1, BigInt(audio.length));
|
|
467
|
+
this.generating.append(audio, audible);
|
|
468
|
+
}
|
|
469
|
+
activate() {
|
|
470
|
+
this.enabled = true;
|
|
471
|
+
}
|
|
472
|
+
flush(marker) {
|
|
473
|
+
if (!this.closed) this.params.port.postMessage({
|
|
474
|
+
type: "flush",
|
|
475
|
+
marker
|
|
476
|
+
}, []);
|
|
477
|
+
}
|
|
478
|
+
clear() {
|
|
479
|
+
this.generating = void 0;
|
|
480
|
+
this.params.player.transition(() => {
|
|
481
|
+
for (const output of [...this.outputs].toReversed()) output.close("provider-clear");
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
close() {
|
|
485
|
+
if (this.closed) return;
|
|
486
|
+
this.closed = true;
|
|
487
|
+
Atomics.store(this.params.state, 0, 1);
|
|
488
|
+
this.clear();
|
|
489
|
+
this.params.port.close();
|
|
490
|
+
}
|
|
491
|
+
fail(error) {
|
|
492
|
+
if (this.closed) return;
|
|
493
|
+
this.params.post({
|
|
494
|
+
type: "continuous-error",
|
|
495
|
+
id: this.params.id,
|
|
496
|
+
error: serializeDiscordAudioError(error)
|
|
497
|
+
});
|
|
498
|
+
this.close();
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
//#endregion
|
|
502
|
+
//#region extensions/discord/src/voice/audio-worker.ts
|
|
503
|
+
const PLAYBACK_READY_TIMEOUT_MS = 6e4;
|
|
504
|
+
const MAX_CAPTURE_PACKETS = 1e3;
|
|
505
|
+
const MAX_CAPTURE_BYTES = 1048576;
|
|
506
|
+
/** Owns every Discord socket, codec, resource and packet deadline in one isolate. */
|
|
507
|
+
var DiscordAudioWorker = class {
|
|
508
|
+
constructor(options, post) {
|
|
509
|
+
this.options = options;
|
|
510
|
+
this.post = post;
|
|
511
|
+
this.sdk = loadDiscordVoiceSdk();
|
|
512
|
+
this.captures = /* @__PURE__ */ new Map();
|
|
513
|
+
this.outputs = /* @__PURE__ */ new Map();
|
|
514
|
+
this.continuous = /* @__PURE__ */ new Map();
|
|
515
|
+
this.stopped = false;
|
|
516
|
+
this.stopAbort = new AbortController();
|
|
517
|
+
this.tasks = /* @__PURE__ */ new Set();
|
|
518
|
+
this.onPlayerError = (error) => this.post({
|
|
519
|
+
type: "error",
|
|
520
|
+
error: serializeDiscordAudioError(error)
|
|
521
|
+
});
|
|
522
|
+
this.onDisconnected = () => {
|
|
523
|
+
if (!this.stopped && this.connection) this.recoverConnection(this.connection);
|
|
524
|
+
};
|
|
525
|
+
this.onDestroyed = () => {
|
|
526
|
+
this.stop();
|
|
527
|
+
};
|
|
528
|
+
this.onSpeakingStart = (userId) => {
|
|
529
|
+
if (this.stopped) return;
|
|
530
|
+
for (const capture of this.captures.values()) if (capture.userId === userId) {
|
|
531
|
+
clearTimeout(capture.timer);
|
|
532
|
+
capture.timer = void 0;
|
|
533
|
+
}
|
|
534
|
+
this.post({
|
|
535
|
+
type: "speaking",
|
|
536
|
+
userId,
|
|
537
|
+
speaking: true
|
|
538
|
+
});
|
|
539
|
+
};
|
|
540
|
+
this.onSpeakingEnd = (userId) => {
|
|
541
|
+
if (this.stopped) return;
|
|
542
|
+
for (const [id, capture] of this.captures) if (capture.userId === userId) this.finalizeLater(id, capture);
|
|
543
|
+
this.post({
|
|
544
|
+
type: "speaking",
|
|
545
|
+
userId,
|
|
546
|
+
speaking: false
|
|
547
|
+
});
|
|
548
|
+
};
|
|
549
|
+
this.player = options.realtime ? this.sdk.createAudioPlayer({ behaviors: { maxMissedFrames: DISCORD_REALTIME_PLAYBACK_IDLE_MS / 20 } }) : this.sdk.createAudioPlayer();
|
|
550
|
+
this.roomPlayer = new DiscordRealtimePlayer(this.player);
|
|
551
|
+
this.player.on("stateChange", (_old, state) => this.post({
|
|
552
|
+
type: "player",
|
|
553
|
+
status: state.status
|
|
554
|
+
}));
|
|
555
|
+
this.player.on("error", this.onPlayerError);
|
|
556
|
+
}
|
|
557
|
+
async connect() {
|
|
558
|
+
const deadline = Date.now() + this.options.connectTimeoutMs;
|
|
559
|
+
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
560
|
+
if (this.stopped) return;
|
|
561
|
+
const connection = this.sdk.joinVoiceChannel({
|
|
562
|
+
guildId: this.options.guildId,
|
|
563
|
+
channelId: this.options.channelId,
|
|
564
|
+
group: this.options.group,
|
|
565
|
+
selfDeaf: this.options.selfDeaf,
|
|
566
|
+
selfMute: this.options.selfMute,
|
|
567
|
+
daveEncryption: this.options.daveEncryption,
|
|
568
|
+
decryptionFailureTolerance: this.options.decryptionFailureTolerance,
|
|
569
|
+
adapterCreator: (methods) => {
|
|
570
|
+
this.adapter = methods;
|
|
571
|
+
return {
|
|
572
|
+
sendPayload: (payload) => {
|
|
573
|
+
this.post({
|
|
574
|
+
type: "gateway-send",
|
|
575
|
+
payload
|
|
576
|
+
});
|
|
577
|
+
return true;
|
|
578
|
+
},
|
|
579
|
+
destroy: () => {}
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
});
|
|
583
|
+
this.connection = connection;
|
|
584
|
+
connection.on("error", (error) => this.post({
|
|
585
|
+
type: "error",
|
|
586
|
+
error: serializeDiscordAudioError(error)
|
|
587
|
+
}));
|
|
588
|
+
try {
|
|
589
|
+
await this.sdk.entersState(connection, this.sdk.VoiceConnectionStatus.Ready, AbortSignal.any([this.stopAbort.signal, AbortSignal.timeout(Math.max(1, deadline - Date.now()))]));
|
|
590
|
+
if (this.stopped) return;
|
|
591
|
+
connection.subscribe(this.player);
|
|
592
|
+
connection.on("stateChange", (_old, state) => {
|
|
593
|
+
this.post({
|
|
594
|
+
type: "connection",
|
|
595
|
+
status: state.status
|
|
596
|
+
});
|
|
597
|
+
});
|
|
598
|
+
connection.on(this.sdk.VoiceConnectionStatus.Destroyed, this.onDestroyed);
|
|
599
|
+
connection.on(this.sdk.VoiceConnectionStatus.Disconnected, this.onDisconnected);
|
|
600
|
+
connection.receiver.speaking.on("start", this.onSpeakingStart);
|
|
601
|
+
connection.receiver.speaking.on("end", this.onSpeakingEnd);
|
|
602
|
+
for (const userId of connection.receiver.speaking.users.keys()) this.post({
|
|
603
|
+
type: "speaking",
|
|
604
|
+
userId,
|
|
605
|
+
speaking: true
|
|
606
|
+
});
|
|
607
|
+
this.post({
|
|
608
|
+
type: "connection",
|
|
609
|
+
status: connection.state.status
|
|
610
|
+
});
|
|
611
|
+
this.post({ type: "ready" });
|
|
612
|
+
return;
|
|
613
|
+
} catch (error) {
|
|
614
|
+
if (this.stopped) return;
|
|
615
|
+
if (connection.state.status !== this.sdk.VoiceConnectionStatus.Destroyed) connection.destroy();
|
|
616
|
+
if (attempt === 0 && !this.stopped && Date.now() < deadline && error instanceof Error && error.message.toLowerCase().includes("operation was aborted")) continue;
|
|
617
|
+
throw error;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
receive(command) {
|
|
622
|
+
if (this.stopped) return;
|
|
623
|
+
switch (command.type) {
|
|
624
|
+
case "gateway-server":
|
|
625
|
+
this.adapter?.onVoiceServerUpdate(command.data);
|
|
626
|
+
break;
|
|
627
|
+
case "gateway-state":
|
|
628
|
+
this.adapter?.onVoiceStateUpdate(command.data);
|
|
629
|
+
break;
|
|
630
|
+
case "gateway-failed":
|
|
631
|
+
this.post({
|
|
632
|
+
type: "error",
|
|
633
|
+
error: {
|
|
634
|
+
name: "Error",
|
|
635
|
+
message: "Discord main gateway could not send voice signalling."
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
this.adapter?.destroy();
|
|
639
|
+
this.stop();
|
|
640
|
+
break;
|
|
641
|
+
case "stop":
|
|
642
|
+
this.stop();
|
|
643
|
+
break;
|
|
644
|
+
case "continuous-port": {
|
|
645
|
+
const lane = new DiscordContinuousOutput({
|
|
646
|
+
id: command.id,
|
|
647
|
+
enabled: command.enabled,
|
|
648
|
+
port: command.port,
|
|
649
|
+
state: new Int32Array(command.state),
|
|
650
|
+
clock: new BigInt64Array(command.clock),
|
|
651
|
+
player: this.roomPlayer,
|
|
652
|
+
post: this.post,
|
|
653
|
+
logContext: "guild=" + this.options.guildId + " channel=" + this.options.channelId
|
|
654
|
+
});
|
|
655
|
+
this.continuous.set(command.id, lane);
|
|
656
|
+
command.port.once("close", () => this.continuous.delete(command.id));
|
|
657
|
+
break;
|
|
658
|
+
}
|
|
659
|
+
case "continuous-activate":
|
|
660
|
+
this.continuous.get(command.id)?.activate();
|
|
661
|
+
break;
|
|
662
|
+
case "continuous-clear":
|
|
663
|
+
this.continuous.get(command.id)?.clear();
|
|
664
|
+
break;
|
|
665
|
+
case "continuous-flush":
|
|
666
|
+
this.continuous.get(command.id)?.flush(command.marker);
|
|
667
|
+
break;
|
|
668
|
+
case "continuous-close":
|
|
669
|
+
this.continuous.get(command.id)?.close();
|
|
670
|
+
this.continuous.delete(command.id);
|
|
671
|
+
break;
|
|
672
|
+
case "capture":
|
|
673
|
+
this.track(this.capture(command.id, command.userId, command.recordingEpoch));
|
|
674
|
+
break;
|
|
675
|
+
case "capture-stop": {
|
|
676
|
+
const capture = this.captures.get(command.id);
|
|
677
|
+
if (capture) this.stopCapture(capture);
|
|
678
|
+
break;
|
|
679
|
+
}
|
|
680
|
+
case "capture-ack": {
|
|
681
|
+
const capture = this.captures.get(command.id);
|
|
682
|
+
if (capture) {
|
|
683
|
+
capture.pendingPackets = Math.max(0, capture.pendingPackets - 1);
|
|
684
|
+
capture.pendingBytes = Math.max(0, capture.pendingBytes - command.bytes);
|
|
685
|
+
}
|
|
686
|
+
break;
|
|
687
|
+
}
|
|
688
|
+
case "passthrough":
|
|
689
|
+
this.enablePassthrough(command.reason, command.expirySeconds);
|
|
690
|
+
break;
|
|
691
|
+
case "output-create": {
|
|
692
|
+
const output = new DiscordRealtimeOutput({
|
|
693
|
+
player: this.roomPlayer,
|
|
694
|
+
clock: new BigInt64Array(command.clock),
|
|
695
|
+
logContext: "guild=" + this.options.guildId + " channel=" + this.options.channelId,
|
|
696
|
+
continuous: command.continuous,
|
|
697
|
+
onStart: () => this.post({
|
|
698
|
+
type: "output-start",
|
|
699
|
+
id: command.id
|
|
700
|
+
}),
|
|
701
|
+
onClose: (_output, reason) => {
|
|
702
|
+
this.outputs.delete(command.id);
|
|
703
|
+
queueMicrotask(() => this.post({
|
|
704
|
+
type: "output-close",
|
|
705
|
+
id: command.id,
|
|
706
|
+
reason
|
|
707
|
+
}));
|
|
708
|
+
},
|
|
709
|
+
onError: (error) => this.post({
|
|
710
|
+
type: "output-error",
|
|
711
|
+
id: command.id,
|
|
712
|
+
error: serializeDiscordAudioError(error)
|
|
713
|
+
})
|
|
714
|
+
});
|
|
715
|
+
this.outputs.set(command.id, output);
|
|
716
|
+
break;
|
|
717
|
+
}
|
|
718
|
+
case "output-audio":
|
|
719
|
+
this.outputs.get(command.id)?.appendAdmitted(Buffer.from(command.audio), command.audible);
|
|
720
|
+
break;
|
|
721
|
+
case "output-mark":
|
|
722
|
+
this.outputs.get(command.id)?.markPlayback(() => this.post({
|
|
723
|
+
type: "output-mark",
|
|
724
|
+
id: command.id,
|
|
725
|
+
markId: command.markId
|
|
726
|
+
}));
|
|
727
|
+
break;
|
|
728
|
+
case "output-finish":
|
|
729
|
+
this.outputs.get(command.id)?.finish(command.reason, command.playBuffered);
|
|
730
|
+
break;
|
|
731
|
+
case "output-close":
|
|
732
|
+
this.outputs.get(command.id)?.close(command.reason);
|
|
733
|
+
break;
|
|
734
|
+
case "output-hold":
|
|
735
|
+
this.roomPlayer.hold(command.hold);
|
|
736
|
+
break;
|
|
737
|
+
case "output-shutdown":
|
|
738
|
+
this.retireOutputs();
|
|
739
|
+
break;
|
|
740
|
+
case "player-stop":
|
|
741
|
+
this.fileAbort?.abort();
|
|
742
|
+
this.player.stop(true);
|
|
743
|
+
break;
|
|
744
|
+
case "file-play":
|
|
745
|
+
this.track(this.playFile(command.id, command.path));
|
|
746
|
+
break;
|
|
747
|
+
case "stream-play": {
|
|
748
|
+
const stream = new PassThrough();
|
|
749
|
+
this.fileInput = {
|
|
750
|
+
id: command.id,
|
|
751
|
+
stream
|
|
752
|
+
};
|
|
753
|
+
this.track(this.playFile(command.id, stream));
|
|
754
|
+
break;
|
|
755
|
+
}
|
|
756
|
+
case "stream-chunk":
|
|
757
|
+
if (this.fileInput?.id !== command.id) break;
|
|
758
|
+
if (this.fileInput.stream.write(Buffer.from(command.audio))) this.post({
|
|
759
|
+
type: "stream-drain",
|
|
760
|
+
id: command.id
|
|
761
|
+
});
|
|
762
|
+
else this.fileInput.stream.once("drain", () => this.post({
|
|
763
|
+
type: "stream-drain",
|
|
764
|
+
id: command.id
|
|
765
|
+
}));
|
|
766
|
+
break;
|
|
767
|
+
case "stream-end": if (this.fileInput?.id === command.id) this.fileInput.stream.end();
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
retireOutputs() {
|
|
771
|
+
this.roomPlayer.transition(() => {
|
|
772
|
+
for (const lane of this.continuous.values()) lane.close();
|
|
773
|
+
this.continuous.clear();
|
|
774
|
+
const retiring = [...this.outputs.values()];
|
|
775
|
+
for (const output of retiring) output.close("session-close");
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
async recoverConnection(connection) {
|
|
779
|
+
const recovery = new AbortController();
|
|
780
|
+
const signal = AbortSignal.any([
|
|
781
|
+
this.stopAbort.signal,
|
|
782
|
+
recovery.signal,
|
|
783
|
+
AbortSignal.timeout(this.options.reconnectGraceMs)
|
|
784
|
+
]);
|
|
785
|
+
try {
|
|
786
|
+
await Promise.race([this.sdk.entersState(connection, this.sdk.VoiceConnectionStatus.Signalling, signal), this.sdk.entersState(connection, this.sdk.VoiceConnectionStatus.Connecting, signal)]);
|
|
787
|
+
} catch (error) {
|
|
788
|
+
if (!this.stopped) {
|
|
789
|
+
this.post({
|
|
790
|
+
type: "error",
|
|
791
|
+
error: serializeDiscordAudioError(error)
|
|
792
|
+
});
|
|
793
|
+
await this.stop();
|
|
794
|
+
}
|
|
795
|
+
} finally {
|
|
796
|
+
recovery.abort();
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
enablePassthrough(reason, expirySeconds) {
|
|
800
|
+
if (!this.connection) return;
|
|
801
|
+
enableDaveReceivePassthrough({
|
|
802
|
+
target: {
|
|
803
|
+
guildId: this.options.guildId,
|
|
804
|
+
channelId: this.options.channelId,
|
|
805
|
+
connection: this.connection
|
|
806
|
+
},
|
|
807
|
+
sdk: this.sdk,
|
|
808
|
+
reason,
|
|
809
|
+
expirySeconds,
|
|
810
|
+
onVerbose: (message) => this.post({
|
|
811
|
+
type: "log",
|
|
812
|
+
level: "verbose",
|
|
813
|
+
message
|
|
814
|
+
}),
|
|
815
|
+
onWarn: (message) => this.post({
|
|
816
|
+
type: "log",
|
|
817
|
+
level: "warn",
|
|
818
|
+
message
|
|
819
|
+
})
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
stopCapture(capture) {
|
|
823
|
+
if (capture.closed) return;
|
|
824
|
+
capture.closed = true;
|
|
825
|
+
clearTimeout(capture.timer);
|
|
826
|
+
if (!capture.stream.destroyed) capture.stream.destroy();
|
|
827
|
+
}
|
|
828
|
+
finalizeLater(id, capture) {
|
|
829
|
+
clearTimeout(capture.timer);
|
|
830
|
+
capture.timer = setTimeout(() => {
|
|
831
|
+
if (this.captures.get(id) === capture) this.stopCapture(capture);
|
|
832
|
+
}, this.options.captureSilenceGraceMs);
|
|
833
|
+
}
|
|
834
|
+
async capture(id, userId, recordingEpoch) {
|
|
835
|
+
const connection = this.connection;
|
|
836
|
+
if (!connection || this.captures.has(id)) return;
|
|
837
|
+
const stream = connection.receiver.subscribe(userId, { end: { behavior: this.sdk.EndBehaviorType.Manual } });
|
|
838
|
+
const capture = {
|
|
839
|
+
userId,
|
|
840
|
+
stream,
|
|
841
|
+
pendingPackets: 0,
|
|
842
|
+
pendingBytes: 0,
|
|
843
|
+
closed: false
|
|
844
|
+
};
|
|
845
|
+
this.captures.set(id, capture);
|
|
846
|
+
const input = new PassThrough({ objectMode: true });
|
|
847
|
+
const recordingClock = new BigInt64Array(recordingEpoch);
|
|
848
|
+
const receipts = /* @__PURE__ */ new WeakMap();
|
|
849
|
+
let failed = false;
|
|
850
|
+
let abortReported = false;
|
|
851
|
+
let decodedFrames = 0;
|
|
852
|
+
const onError = (error) => {
|
|
853
|
+
if (failed) return;
|
|
854
|
+
const analysis = analyzeVoiceReceiveError(error);
|
|
855
|
+
if (analysis.isAbortLike && !analysis.countsAsDecryptFailure) {
|
|
856
|
+
if (!abortReported) this.post({
|
|
857
|
+
type: "capture-error",
|
|
858
|
+
id,
|
|
859
|
+
error: serializeDiscordAudioError(error)
|
|
860
|
+
});
|
|
861
|
+
abortReported = true;
|
|
862
|
+
return;
|
|
863
|
+
}
|
|
864
|
+
failed = true;
|
|
865
|
+
let recovery = "not-attempted";
|
|
866
|
+
if (analysis.shouldAttemptPassthrough) {
|
|
867
|
+
recovery = recoverDaveZeroTransition({
|
|
868
|
+
target: {
|
|
869
|
+
guildId: this.options.guildId,
|
|
870
|
+
channelId: this.options.channelId,
|
|
871
|
+
connection
|
|
872
|
+
},
|
|
873
|
+
sdk: this.sdk,
|
|
874
|
+
onWarn: (message) => this.post({
|
|
875
|
+
type: "log",
|
|
876
|
+
level: "warn",
|
|
877
|
+
message
|
|
878
|
+
})
|
|
879
|
+
});
|
|
880
|
+
if (recovery !== "failed") this.enablePassthrough("receive decrypt error", 15);
|
|
881
|
+
}
|
|
882
|
+
this.post({
|
|
883
|
+
type: "capture-error",
|
|
884
|
+
id,
|
|
885
|
+
error: {
|
|
886
|
+
...serializeDiscordAudioError(error),
|
|
887
|
+
...recovery === "failed" ? { daveRecoveryFailed: true } : {}
|
|
888
|
+
}
|
|
889
|
+
});
|
|
890
|
+
};
|
|
891
|
+
const accept = (packet) => {
|
|
892
|
+
if (failed || capture.closed || !packet.length) return;
|
|
893
|
+
if (capture.pendingPackets >= MAX_CAPTURE_PACKETS || capture.pendingBytes + packet.length > MAX_CAPTURE_BYTES) {
|
|
894
|
+
onError(/* @__PURE__ */ new Error("Discord voice receive backlog exceeded; try speaking again."));
|
|
895
|
+
this.stopCapture(capture);
|
|
896
|
+
input.destroy();
|
|
897
|
+
return;
|
|
898
|
+
}
|
|
899
|
+
capture.pendingPackets += 1;
|
|
900
|
+
capture.pendingBytes += packet.length;
|
|
901
|
+
const owned = Buffer.from(packet);
|
|
902
|
+
receipts.set(owned, {
|
|
903
|
+
receivedAt: Date.now(),
|
|
904
|
+
recordingEpoch: Atomics.load(recordingClock, 0)
|
|
905
|
+
});
|
|
906
|
+
input.write(owned);
|
|
907
|
+
};
|
|
908
|
+
const end = () => input.end();
|
|
909
|
+
const finalized = () => {
|
|
910
|
+
clearTimeout(capture.timer);
|
|
911
|
+
capture.closed = true;
|
|
912
|
+
this.post({
|
|
913
|
+
type: "capture-finalized",
|
|
914
|
+
id
|
|
915
|
+
});
|
|
916
|
+
input.end();
|
|
917
|
+
};
|
|
918
|
+
stream.on("data", accept);
|
|
919
|
+
stream.on("end", end);
|
|
920
|
+
stream.once("close", finalized);
|
|
921
|
+
stream.on("error", onError);
|
|
922
|
+
if (!connection.receiver.speaking.users.has(userId)) this.finalizeLater(id, capture);
|
|
923
|
+
try {
|
|
924
|
+
await decodeOpusStreamChunks(input, {
|
|
925
|
+
onChunk: async (pcm, packet) => {
|
|
926
|
+
const receipt = receipts.get(packet);
|
|
927
|
+
if (!failed && receipt) this.post({
|
|
928
|
+
type: "capture-frame",
|
|
929
|
+
id,
|
|
930
|
+
frame: {
|
|
931
|
+
pcm,
|
|
932
|
+
packet,
|
|
933
|
+
...receipt
|
|
934
|
+
}
|
|
935
|
+
});
|
|
936
|
+
if (++decodedFrames % 8 === 0) await new Promise((resolve) => {
|
|
937
|
+
setImmediate(resolve);
|
|
938
|
+
});
|
|
939
|
+
},
|
|
940
|
+
onError,
|
|
941
|
+
onVerbose: (message) => this.post({
|
|
942
|
+
type: "log",
|
|
943
|
+
level: "verbose",
|
|
944
|
+
message
|
|
945
|
+
}),
|
|
946
|
+
onWarn: (message) => this.post({
|
|
947
|
+
type: "log",
|
|
948
|
+
level: "warn",
|
|
949
|
+
message
|
|
950
|
+
})
|
|
951
|
+
});
|
|
952
|
+
} finally {
|
|
953
|
+
clearTimeout(capture.timer);
|
|
954
|
+
this.captures.delete(id);
|
|
955
|
+
stream.off("data", accept);
|
|
956
|
+
stream.off("end", end);
|
|
957
|
+
stream.off("error", onError);
|
|
958
|
+
this.stopCapture(capture);
|
|
959
|
+
input.destroy();
|
|
960
|
+
this.post({
|
|
961
|
+
type: "capture-end",
|
|
962
|
+
id
|
|
963
|
+
});
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
async playFile(id, input) {
|
|
967
|
+
const abort = new AbortController();
|
|
968
|
+
this.fileAbort?.abort();
|
|
969
|
+
this.fileAbort = abort;
|
|
970
|
+
let error;
|
|
971
|
+
const onError = (cause) => {
|
|
972
|
+
error = serializeDiscordAudioError(cause);
|
|
973
|
+
abort.abort();
|
|
974
|
+
};
|
|
975
|
+
let playbackStarted = false;
|
|
976
|
+
const onIdle = () => {
|
|
977
|
+
if (!playbackStarted) abort.abort();
|
|
978
|
+
};
|
|
979
|
+
this.player.on("error", onError);
|
|
980
|
+
this.player.on(this.sdk.AudioPlayerStatus.Idle, onIdle);
|
|
981
|
+
try {
|
|
982
|
+
this.player.play(this.sdk.createAudioResource(createDiscordOpusPlaybackStream(input), { inputType: this.sdk.StreamType.Opus }));
|
|
983
|
+
await this.sdk.entersState(this.player, this.sdk.AudioPlayerStatus.Playing, AbortSignal.any([AbortSignal.timeout(PLAYBACK_READY_TIMEOUT_MS), abort.signal]));
|
|
984
|
+
playbackStarted = true;
|
|
985
|
+
await this.sdk.entersState(this.player, this.sdk.AudioPlayerStatus.Idle, abort.signal);
|
|
986
|
+
} catch (cause) {
|
|
987
|
+
error ??= serializeDiscordAudioError(cause);
|
|
988
|
+
} finally {
|
|
989
|
+
this.player.off("error", onError);
|
|
990
|
+
this.player.off(this.sdk.AudioPlayerStatus.Idle, onIdle);
|
|
991
|
+
if (this.fileAbort === abort) this.fileAbort = void 0;
|
|
992
|
+
if (this.fileInput?.id === id) {
|
|
993
|
+
this.fileInput.stream.destroy();
|
|
994
|
+
this.fileInput = void 0;
|
|
995
|
+
}
|
|
996
|
+
this.post({
|
|
997
|
+
type: "file-end",
|
|
998
|
+
id,
|
|
999
|
+
...error ? { error } : {}
|
|
1000
|
+
});
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
track(task) {
|
|
1004
|
+
this.tasks.add(task);
|
|
1005
|
+
task.catch((error) => this.post({
|
|
1006
|
+
type: "error",
|
|
1007
|
+
error: serializeDiscordAudioError(error)
|
|
1008
|
+
})).finally(() => this.tasks.delete(task));
|
|
1009
|
+
}
|
|
1010
|
+
async stop() {
|
|
1011
|
+
if (this.stopped) return;
|
|
1012
|
+
this.stopped = true;
|
|
1013
|
+
this.stopAbort.abort();
|
|
1014
|
+
this.post({
|
|
1015
|
+
type: "connection",
|
|
1016
|
+
status: this.sdk.VoiceConnectionStatus.Destroyed
|
|
1017
|
+
});
|
|
1018
|
+
this.retireOutputs();
|
|
1019
|
+
this.roomPlayer.close();
|
|
1020
|
+
this.fileAbort?.abort();
|
|
1021
|
+
this.fileInput?.stream.destroy();
|
|
1022
|
+
for (const capture of this.captures.values()) this.stopCapture(capture);
|
|
1023
|
+
const connection = this.connection;
|
|
1024
|
+
connection?.receiver.speaking.off("start", this.onSpeakingStart);
|
|
1025
|
+
connection?.receiver.speaking.off("end", this.onSpeakingEnd);
|
|
1026
|
+
connection?.off(this.sdk.VoiceConnectionStatus.Disconnected, this.onDisconnected);
|
|
1027
|
+
connection?.off(this.sdk.VoiceConnectionStatus.Destroyed, this.onDestroyed);
|
|
1028
|
+
this.player.off("error", this.onPlayerError);
|
|
1029
|
+
if (connection && connection.state.status !== this.sdk.VoiceConnectionStatus.Destroyed) connection.destroy();
|
|
1030
|
+
this.post({ type: "gateway-destroy" });
|
|
1031
|
+
await Promise.allSettled(this.tasks);
|
|
1032
|
+
this.post({ type: "stopped" });
|
|
1033
|
+
}
|
|
1034
|
+
};
|
|
1035
|
+
//#endregion
|
|
1036
|
+
//#region extensions/discord/src/voice/audio-worker.runtime.ts
|
|
1037
|
+
const port = parentPort;
|
|
1038
|
+
if (!port) throw new Error("Discord audio runtime requires a worker MessagePort.");
|
|
1039
|
+
const media = new DiscordAudioWorker(workerData, (event) => {
|
|
1040
|
+
port.postMessage(event);
|
|
1041
|
+
if (event.type === "stopped") port.close();
|
|
1042
|
+
});
|
|
1043
|
+
port.on("message", (command) => {
|
|
1044
|
+
try {
|
|
1045
|
+
media.receive(command);
|
|
1046
|
+
} catch (error) {
|
|
1047
|
+
port.postMessage({
|
|
1048
|
+
type: "error",
|
|
1049
|
+
error: serializeDiscordAudioError(error)
|
|
1050
|
+
});
|
|
1051
|
+
media.stop();
|
|
1052
|
+
}
|
|
1053
|
+
});
|
|
1054
|
+
port.on("close", () => {
|
|
1055
|
+
media.stop();
|
|
1056
|
+
});
|
|
1057
|
+
media.connect().catch((error) => {
|
|
1058
|
+
port.postMessage({
|
|
1059
|
+
type: "error",
|
|
1060
|
+
error: serializeDiscordAudioError(error)
|
|
1061
|
+
});
|
|
1062
|
+
media.stop();
|
|
1063
|
+
});
|
|
1064
|
+
//#endregion
|
|
1065
|
+
export {};
|