@openclaw/discord 2026.9.5 → 2026.9.7
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/icon.png +0 -0
- package/dist/.setup/{account-inspect-BwQj24ht.mjs → account-inspect-De8hOUxG.mjs} +1 -1
- package/dist/.setup/{accounts-CwJQoLjM.mjs → accounts-ChaMcixG.mjs} +1 -4
- package/dist/.setup/{activities-api-DBwRt5ES.mjs → activities-api-tvbsU2e3.mjs} +38 -66
- package/dist/.setup/{api-CBK9zcq5.mjs → api-DVbJwZVt.mjs} +10 -2
- package/dist/.setup/{approval-handler.runtime-Du3n5ypX.mjs → approval-handler.runtime-DxCK2Rux.mjs} +49 -125
- package/dist/.setup/{approval-message-updates-BN7JtScm.mjs → approval-message-updates-BKFqavHZ.mjs} +2 -2
- package/dist/.setup/{audit-C8uaKoa9.mjs → audit-CLg9I71N.mjs} +5 -5
- package/dist/.setup/{channel-ChKdlBgH.mjs → channel-DxlUVU9t.mjs} +125 -228
- package/dist/.setup/{channel-type-DKnjV1XW.mjs → channel-type-DRCrEMss.mjs} +22 -22
- package/dist/.setup/{channel.setup-BlC3-Kzz.mjs → channel.setup-CRo1GjV7.mjs} +6 -9
- package/dist/.setup/{components-MqMWUWnE.mjs → components-Cq1PvIpN.mjs} +42 -71
- package/dist/.setup/{config-schema-CiZz-mtA.mjs → config-schema-oxELUSDx.mjs} +19 -44
- package/dist/.setup/{conversation-binding-route-_rz33QHO.mjs → conversation-binding-route-Caz_XuFH.mjs} +14 -6
- package/dist/.setup/{directory-config-BytTftz-.mjs → directory-config-esqNn0Eo.mjs} +6 -9
- package/dist/.setup/{directory-live--EGTH0DC.mjs → directory-live-DtKRHuGV.mjs} +6 -12
- package/dist/.setup/{discord-BXpHW-cu.mjs → discord-0xJYfdDD.mjs} +82 -386
- package/dist/.setup/{doctor-DxcdkXzz.mjs → doctor-BCl1H5tl.mjs} +21 -36
- package/dist/.setup/{doctor-contract-Co5vRCZ6.mjs → doctor-contract-CvvgwrrG.mjs} +41 -50
- package/dist/.setup/{channel-actions.runtime-CJmiFfps.mjs → handle-action-CUvQWnE7.mjs} +74 -105
- package/dist/.setup/{handle-action.guild-admin-DAFyh_yV.mjs → handle-action.guild-admin-Df-8gVle.mjs} +63 -121
- package/dist/.setup/{live-policy-config-eKQ-PLdy.mjs → live-policy-config-8Pv20CHc.mjs} +2 -3
- package/dist/.setup/{message-handler-DnUrDpaU.mjs → message-handler-B-Jk4oDk.mjs} +18 -93
- package/dist/.setup/message-handler.preflight-pluralkit-CWLUBVcx.mjs +141 -0
- package/dist/.setup/{message-handler.preflight-CtqaF_fb.mjs → message-handler.preflight-v-__NSDq.mjs} +73 -287
- package/dist/.setup/{message-handler.process-Dz1xvuQU.mjs → message-handler.process-BNFFuChn.mjs} +423 -374
- package/dist/.setup/{outbound-adapter-C8v79z9Z.mjs → outbound-adapter-BobT-kse.mjs} +105 -19
- package/dist/.setup/{outbound-session-route-CqWbuMOm.mjs → outbound-session-route-zVGxxceg.mjs} +142 -109
- package/dist/.setup/{pluralkit-CdAt1G0P.mjs → pluralkit-a6_NLfH9.mjs} +1 -1
- package/dist/.setup/{preflight-audio-DrnqFA8U.mjs → preflight-audio-DHGIHEpv.mjs} +2 -1
- package/dist/.setup/{presence-cache-dYSHPWMx.mjs → presence-cache-Di3H3DIU.mjs} +0 -4
- package/dist/.setup/{probe-CupW4we4.mjs → probe-LYrIHlBF.mjs} +13 -4
- package/dist/.setup/{provider-72zIvN-i.mjs → provider-B_G5hASF.mjs} +1112 -1668
- package/dist/.setup/provider-session.runtime-BYlTBFD2.mjs +6 -0
- package/dist/.setup/provider.runtime-CUE3UxER.mjs +2 -0
- package/dist/.setup/{realtime-session.runtime-DTccTgTM.mjs → realtime-session.runtime-oUd9DOcz.mjs} +372 -345
- package/dist/.setup/receive-recovery-CHPOsnLc.mjs +514 -0
- package/dist/.setup/{resolve-allowlist-common-CwMBzbx9.mjs → resolve-allowlist-common-DPdRggu5.mjs} +4 -7
- package/dist/.setup/{resolve-channels-BbvsLQOZ.mjs → resolve-channels-BFPNRmVv.mjs} +21 -40
- package/dist/.setup/{resolve-users-ByFlR7LQ.mjs → resolve-users-0-aBuCy3.mjs} +4 -4
- package/dist/.setup/{retry-DBfcEgmO.mjs → retry-pz_cSha2.mjs} +81 -16
- package/dist/.setup/rolldown-runtime-B4FMCO8f.mjs +28 -0
- package/dist/.setup/{runtime-SchNfUsQ.mjs → runtime-FN000lxA.mjs} +83 -166
- package/dist/.setup/runtime-doctor-migrations-CshUGl36.mjs +159 -0
- package/dist/.setup/{runtime-BVoa7hhx.mjs → runtime-sUksZ--Q.mjs} +2 -5
- package/dist/.setup/{secret-config-contract-DFu9hfU8.mjs → secret-config-contract-uOE2J7yM.mjs} +15 -85
- package/dist/.setup/{security-audit-s5w50-Ly.mjs → security-audit-Cdaegq7C.mjs} +3 -1
- package/dist/.setup/{send-CKDczUNL.mjs → send-CrfEI6Bs.mjs} +73 -114
- package/dist/.setup/{send.components-DWQjXhPV.mjs → send.components-DxQAMfES.mjs} +62 -107
- package/dist/.setup/{send.outbound-D0hQ7s50.mjs → send.outbound-BISKnb-a.mjs} +79 -154
- package/dist/.setup/{send.shared-Zwx6BxQ5.mjs → send.shared-DGFkbkQR.mjs} +10 -25
- package/dist/.setup/{sender-identity-0Ymgvmaj.mjs → sender-identity-B9X5Vb9R.mjs} +2 -3
- package/dist/.setup/setup-plugin-api-BQUBxbhe.mjs +3 -0
- package/dist/.setup/{shared-CaA3Vv4n.mjs → shared-B3wZ4hN-.mjs} +25 -32
- package/dist/.setup/{subagent-hooks-Bired9q6.mjs → subagent-hooks-nlUE9ow7.mjs} +5 -6
- package/dist/.setup/system-events-CdeZnvPV.mjs +33 -0
- package/dist/.setup/{target-resolver-B6MrxbYv.mjs → target-resolver-BuLapkhy.mjs} +9 -12
- package/dist/.setup/targets-0KUcEIYx.mjs +3 -0
- package/dist/.setup/{thread-bindings-CK5272V3.mjs → thread-bindings-D7TfgjR_.mjs} +33 -35
- package/dist/.setup/thread-bindings.manager-DN-NissX.mjs +819 -0
- package/dist/.setup/thread-bindings.session-updates-CshfKghV.mjs +359 -0
- package/dist/.setup/{thread-bindings.state-BThFQEga.mjs → thread-bindings.state-g6v9zAym.mjs} +21 -62
- package/dist/.setup/{transcripts-source-CuWYgayu.mjs → transcripts-source-p8EV179h.mjs} +133 -238
- package/dist/.setup/{typing-BKZL5fGj.mjs → typing-BiHCzBRu.mjs} +2 -1
- package/dist/.setup/{voice-runtime-DHVQ2mFz.mjs → voice-runtime-B46rcwrG.mjs} +633 -1085
- 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 +18 -18
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-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 +20 -20
- package/dist/secret-contract-api.js +1 -1
- package/dist/security-audit-contract-api.js +1 -1
- package/dist/setup-entry.js +1 -1
- package/dist/setup-plugin-api.js +1 -1
- package/dist/src/voice/audio-worker.runtime.js +1056 -0
- package/dist/subagent-hooks-api.js +3 -4
- 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 +2 -2
- package/node_modules/@types/node/child_process.d.ts +1 -1
- package/node_modules/@types/node/crypto.d.ts +20 -8
- package/node_modules/@types/node/ffi.d.ts +14 -0
- package/node_modules/@types/node/http2.d.ts +3 -2
- package/node_modules/@types/node/net.d.ts +16 -4
- package/node_modules/@types/node/package.json +2 -17
- package/node_modules/@types/node/process.d.ts +1 -0
- package/node_modules/@types/node/quic.d.ts +39 -1
- package/node_modules/@types/node/stream/iter.d.ts +9 -12
- package/node_modules/@types/node/test/reporters.d.ts +1 -0
- package/node_modules/@types/node/test.d.ts +72 -0
- package/node_modules/@types/node/tls.d.ts +14 -10
- package/node_modules/@types/node/vm.d.ts +2 -1
- package/node_modules/@types/node/web-globals/streams.d.ts +4 -0
- package/node_modules/@types/node/worker_threads.d.ts +4 -1
- package/node_modules/typebox/build/compile/code.mjs +1 -2
- package/node_modules/typebox/build/compile/validator.mjs +5 -1
- package/node_modules/typebox/build/format/iri.mjs +16 -9
- package/node_modules/typebox/build/guard/emit.mjs +2 -2
- package/node_modules/typebox/build/guard/guard.d.mts +7 -5
- package/node_modules/typebox/build/guard/guard.mjs +14 -9
- package/node_modules/typebox/build/guard/index.mjs +6 -0
- package/node_modules/typebox/build/guard/unicode/unicode.d.mts +6 -0
- package/node_modules/typebox/build/guard/unicode/unicode.mjs +35 -0
- package/node_modules/typebox/build/guard/{string.mjs → unicode/unicode_segment.mjs} +16 -19
- package/node_modules/typebox/build/schema/build.mjs +2 -3
- package/node_modules/typebox/build/schema/engine/_pathing.d.mts +1 -0
- package/node_modules/typebox/build/schema/engine/_pathing.mjs +11 -0
- package/node_modules/typebox/build/schema/engine/_refine.mjs +13 -5
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +2 -1
- package/node_modules/typebox/build/schema/engine/dependencies.mjs +2 -1
- package/node_modules/typebox/build/schema/engine/dependentSchemas.mjs +2 -1
- package/node_modules/typebox/build/schema/engine/dynamicRef.d.mts +1 -1
- package/node_modules/typebox/build/schema/engine/dynamicRef.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/format.mjs +9 -2
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +3 -2
- package/node_modules/typebox/build/schema/engine/properties.mjs +3 -2
- package/node_modules/typebox/build/schema/engine/propertyNames.mjs +2 -1
- package/node_modules/typebox/build/schema/engine/recursiveRef.d.mts +1 -1
- package/node_modules/typebox/build/schema/engine/recursiveRef.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/ref.d.mts +1 -1
- package/node_modules/typebox/build/schema/engine/ref.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/schema.mjs +24 -24
- package/node_modules/typebox/build/schema/parse.mjs +3 -0
- package/node_modules/typebox/build/schema/pointer/pointer.d.mts +1 -6
- package/node_modules/typebox/build/schema/pointer/pointer.mjs +47 -64
- package/node_modules/typebox/build/system/settings/internal.d.mts +2 -0
- package/node_modules/typebox/build/system/settings/internal.mjs +20 -0
- package/node_modules/typebox/build/system/settings/settings.d.mts +11 -0
- package/node_modules/typebox/build/system/settings/settings.mjs +14 -0
- package/node_modules/typebox/build/type/extends/inference.d.mts +1 -1
- package/node_modules/typebox/build/type/extends/inference.mjs +15 -2
- package/node_modules/typebox/build/type/extends/tuple.d.mts +2 -1
- package/node_modules/typebox/build/type/extends/tuple.mjs +21 -1
- package/node_modules/typebox/build/value/parse/parse.mjs +10 -4
- package/node_modules/typebox/package.json +1 -1
- package/node_modules/typebox/readme.md +3 -1
- package/node_modules/zod/README.md +2 -2
- package/node_modules/zod/compile.cjs +19 -0
- package/node_modules/zod/index.cjs +19 -0
- package/node_modules/zod/locales/index.cjs +19 -0
- package/node_modules/zod/mini/index.cjs +19 -0
- package/node_modules/zod/package.json +8 -7
- package/node_modules/zod/src/v3/helpers/errorUtil.ts +1 -1
- package/node_modules/zod/src/v4/classic/external.ts +2 -0
- package/node_modules/zod/src/v4/classic/from-json-schema.ts +248 -25
- package/node_modules/zod/src/v4/classic/schemas.ts +243 -168
- package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +60 -9
- package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +6 -0
- package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +2 -2
- package/node_modules/zod/src/v4/classic/tests/cyclic-data.test.ts +265 -0
- package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +112 -6
- package/node_modules/zod/src/v4/classic/tests/enum.test.ts +9 -0
- package/node_modules/zod/src/v4/classic/tests/error.test.ts +130 -1
- package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +157 -0
- package/node_modules/zod/src/v4/classic/tests/iban.test.ts +81 -0
- package/node_modules/zod/src/v4/classic/tests/instance-footprint.test.ts +40 -2
- package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +27 -7
- package/node_modules/zod/src/v4/classic/tests/issue-schema.test.ts +88 -56
- package/node_modules/zod/src/v4/classic/tests/number.test.ts +39 -0
- package/node_modules/zod/src/v4/classic/tests/object.test.ts +56 -0
- package/node_modules/zod/src/v4/classic/tests/optin-ladder.test.ts +3 -2
- package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +70 -0
- package/node_modules/zod/src/v4/classic/tests/properties.test.ts +141 -0
- package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +46 -1
- 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 +95 -1
- package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +33 -1
- package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +234 -38
- package/node_modules/zod/src/v4/classic/tests/validate.test.ts +569 -0
- package/node_modules/zod/src/v4/core/api.ts +44 -28
- package/node_modules/zod/src/v4/core/checks.ts +62 -102
- package/node_modules/zod/src/v4/core/compile.ts +218 -93
- package/node_modules/zod/src/v4/core/core.ts +1 -3
- package/node_modules/zod/src/v4/core/doc.ts +6 -2
- package/node_modules/zod/src/v4/core/errors.ts +3 -6
- package/node_modules/zod/src/v4/core/json-schema-generator.ts +2 -2
- package/node_modules/zod/src/v4/core/json-schema-processors.ts +185 -81
- package/node_modules/zod/src/v4/core/memoizer.ts +75 -28
- package/node_modules/zod/src/v4/core/parse.ts +37 -16
- package/node_modules/zod/src/v4/core/regexes.ts +14 -4
- package/node_modules/zod/src/v4/core/schemas.ts +296 -132
- 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 +35 -0
- package/node_modules/zod/src/v4/core/tests/compile-generative.test.ts +445 -0
- package/node_modules/zod/src/v4/core/tests/compile.test.ts +399 -2
- package/node_modules/zod/src/v4/core/tests/email-regex.test.ts +140 -0
- package/node_modules/zod/src/v4/core/tests/locales/tg.test.ts +85 -0
- package/node_modules/zod/src/v4/core/tests/polyfill-collision.test.ts +46 -0
- package/node_modules/zod/src/v4/core/tests/url-no-canparse.test.ts +118 -16
- package/node_modules/zod/src/v4/core/to-json-schema.ts +9 -7
- package/node_modules/zod/src/v4/core/util.ts +218 -147
- package/node_modules/zod/src/v4/core/versions.ts +2 -2
- package/node_modules/zod/src/v4/locales/ar.ts +2 -0
- package/node_modules/zod/src/v4/locales/az.ts +2 -0
- package/node_modules/zod/src/v4/locales/be.ts +2 -0
- package/node_modules/zod/src/v4/locales/bg.ts +2 -0
- package/node_modules/zod/src/v4/locales/bn.ts +2 -0
- package/node_modules/zod/src/v4/locales/ca.ts +2 -0
- package/node_modules/zod/src/v4/locales/ckb.ts +2 -0
- package/node_modules/zod/src/v4/locales/cs.ts +2 -0
- package/node_modules/zod/src/v4/locales/da.ts +2 -0
- package/node_modules/zod/src/v4/locales/de.ts +2 -0
- package/node_modules/zod/src/v4/locales/el.ts +2 -0
- package/node_modules/zod/src/v4/locales/en.ts +2 -0
- package/node_modules/zod/src/v4/locales/eo.ts +2 -0
- package/node_modules/zod/src/v4/locales/es.ts +2 -0
- package/node_modules/zod/src/v4/locales/fa.ts +2 -0
- package/node_modules/zod/src/v4/locales/fi.ts +2 -0
- package/node_modules/zod/src/v4/locales/fr-CA.ts +2 -0
- package/node_modules/zod/src/v4/locales/fr.ts +2 -0
- package/node_modules/zod/src/v4/locales/gu.ts +2 -0
- package/node_modules/zod/src/v4/locales/he.ts +2 -0
- package/node_modules/zod/src/v4/locales/hi.ts +2 -0
- package/node_modules/zod/src/v4/locales/hr.ts +2 -0
- package/node_modules/zod/src/v4/locales/hu.ts +2 -0
- package/node_modules/zod/src/v4/locales/hy.ts +2 -0
- package/node_modules/zod/src/v4/locales/id.ts +2 -0
- package/node_modules/zod/src/v4/locales/index.ts +1 -0
- package/node_modules/zod/src/v4/locales/is.ts +2 -0
- package/node_modules/zod/src/v4/locales/it.ts +2 -0
- package/node_modules/zod/src/v4/locales/ja.ts +2 -0
- package/node_modules/zod/src/v4/locales/ka.ts +2 -0
- package/node_modules/zod/src/v4/locales/km.ts +2 -0
- package/node_modules/zod/src/v4/locales/kn.ts +2 -0
- package/node_modules/zod/src/v4/locales/ko.ts +2 -0
- package/node_modules/zod/src/v4/locales/lt.ts +2 -0
- package/node_modules/zod/src/v4/locales/mk.ts +2 -0
- package/node_modules/zod/src/v4/locales/ms.ts +2 -0
- package/node_modules/zod/src/v4/locales/ne.ts +2 -0
- package/node_modules/zod/src/v4/locales/nl.ts +2 -0
- package/node_modules/zod/src/v4/locales/nn.ts +2 -0
- package/node_modules/zod/src/v4/locales/no.ts +2 -0
- package/node_modules/zod/src/v4/locales/ota.ts +2 -0
- package/node_modules/zod/src/v4/locales/pl.ts +2 -0
- package/node_modules/zod/src/v4/locales/ps.ts +2 -0
- package/node_modules/zod/src/v4/locales/pt-BR.ts +2 -0
- package/node_modules/zod/src/v4/locales/pt.ts +2 -0
- package/node_modules/zod/src/v4/locales/ro.ts +2 -0
- package/node_modules/zod/src/v4/locales/ru.ts +2 -0
- package/node_modules/zod/src/v4/locales/sk.ts +2 -0
- package/node_modules/zod/src/v4/locales/sl.ts +2 -0
- package/node_modules/zod/src/v4/locales/sv.ts +2 -0
- package/node_modules/zod/src/v4/locales/ta.ts +2 -0
- package/node_modules/zod/src/v4/locales/tg.ts +135 -0
- package/node_modules/zod/src/v4/locales/th.ts +2 -0
- package/node_modules/zod/src/v4/locales/tk.ts +2 -0
- package/node_modules/zod/src/v4/locales/tr.ts +2 -0
- package/node_modules/zod/src/v4/locales/uk.ts +2 -0
- package/node_modules/zod/src/v4/locales/ur.ts +2 -0
- package/node_modules/zod/src/v4/locales/uz.ts +2 -0
- package/node_modules/zod/src/v4/locales/vi.ts +2 -0
- package/node_modules/zod/src/v4/locales/yo.ts +2 -0
- package/node_modules/zod/src/v4/locales/zh-CN.ts +2 -0
- package/node_modules/zod/src/v4/locales/zh-TW.ts +2 -0
- package/node_modules/zod/src/v4/mini/external.ts +2 -0
- package/node_modules/zod/src/v4/mini/schemas.ts +32 -7
- package/node_modules/zod/src/v4/mini/tests/checks.test.ts +1 -1
- package/node_modules/zod/src/v4/mini/tests/computed.test.ts +11 -17
- package/node_modules/zod/src/v4/mini/tests/index.test.ts +86 -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 +23 -0
- package/node_modules/zod/v3/ZodError.cjs +19 -0
- 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 +19 -0
- package/node_modules/zod/v4/classic/checks.cjs +19 -0
- 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/deep-partial.cjs +19 -0
- package/node_modules/zod/v4/classic/errors.cjs +19 -0
- package/node_modules/zod/v4/classic/external.cjs +22 -1
- package/node_modules/zod/v4/classic/external.d.cts +1 -1
- package/node_modules/zod/v4/classic/external.d.ts +1 -1
- package/node_modules/zod/v4/classic/external.js +1 -1
- package/node_modules/zod/v4/classic/from-json-schema.cjs +264 -24
- package/node_modules/zod/v4/classic/from-json-schema.js +245 -24
- package/node_modules/zod/v4/classic/in-out.cjs +19 -0
- package/node_modules/zod/v4/classic/index.cjs +19 -0
- package/node_modules/zod/v4/classic/iso.cjs +19 -0
- package/node_modules/zod/v4/classic/parse.cjs +19 -0
- package/node_modules/zod/v4/classic/schemas.cjs +100 -35
- package/node_modules/zod/v4/classic/schemas.d.cts +15 -1
- package/node_modules/zod/v4/classic/schemas.d.ts +15 -1
- package/node_modules/zod/v4/classic/schemas.js +77 -33
- package/node_modules/zod/v4/core/api.cjs +45 -22
- package/node_modules/zod/v4/core/api.d.cts +12 -6
- package/node_modules/zod/v4/core/api.d.ts +12 -6
- package/node_modules/zod/v4/core/api.js +25 -22
- package/node_modules/zod/v4/core/checks.cjs +51 -97
- package/node_modules/zod/v4/core/checks.d.cts +17 -1
- package/node_modules/zod/v4/core/checks.d.ts +17 -1
- package/node_modules/zod/v4/core/checks.js +31 -96
- package/node_modules/zod/v4/core/compile.cjs +173 -78
- package/node_modules/zod/v4/core/compile.d.cts +18 -4
- package/node_modules/zod/v4/core/compile.d.ts +18 -4
- package/node_modules/zod/v4/core/compile.js +154 -79
- package/node_modules/zod/v4/core/core.cjs +20 -1
- package/node_modules/zod/v4/core/core.js +1 -1
- package/node_modules/zod/v4/core/doc.cjs +26 -2
- package/node_modules/zod/v4/core/doc.js +7 -2
- package/node_modules/zod/v4/core/errors.cjs +21 -5
- package/node_modules/zod/v4/core/errors.js +2 -5
- package/node_modules/zod/v4/core/index.cjs +19 -0
- package/node_modules/zod/v4/core/json-schema-generator.cjs +20 -1
- package/node_modules/zod/v4/core/json-schema-generator.js +2 -2
- package/node_modules/zod/v4/core/json-schema-processors.cjs +188 -72
- 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 +170 -74
- package/node_modules/zod/v4/core/json-schema.cjs +19 -0
- package/node_modules/zod/v4/core/memoizer.cjs +111 -23
- package/node_modules/zod/v4/core/memoizer.js +69 -23
- package/node_modules/zod/v4/core/parse.cjs +56 -16
- package/node_modules/zod/v4/core/parse.js +37 -16
- package/node_modules/zod/v4/core/regexes.cjs +31 -6
- package/node_modules/zod/v4/core/regexes.d.cts +3 -0
- package/node_modules/zod/v4/core/regexes.d.ts +3 -0
- package/node_modules/zod/v4/core/regexes.js +10 -4
- package/node_modules/zod/v4/core/registries.cjs +19 -0
- package/node_modules/zod/v4/core/schemas.cjs +302 -114
- package/node_modules/zod/v4/core/schemas.d.cts +28 -8
- package/node_modules/zod/v4/core/schemas.d.ts +28 -8
- package/node_modules/zod/v4/core/schemas.js +279 -113
- package/node_modules/zod/v4/core/standard-schema.cjs +19 -0
- package/node_modules/zod/v4/core/to-json-schema.cjs +28 -7
- package/node_modules/zod/v4/core/to-json-schema.d.cts +4 -3
- package/node_modules/zod/v4/core/to-json-schema.d.ts +4 -3
- package/node_modules/zod/v4/core/to-json-schema.js +7 -6
- package/node_modules/zod/v4/core/util.cjs +177 -143
- package/node_modules/zod/v4/core/util.d.cts +25 -4
- package/node_modules/zod/v4/core/util.d.ts +25 -4
- package/node_modules/zod/v4/core/util.js +156 -143
- 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 +19 -0
- package/node_modules/zod/v4/index.cjs +19 -0
- package/node_modules/zod/v4/locales/ar.cjs +2 -0
- package/node_modules/zod/v4/locales/ar.js +2 -0
- package/node_modules/zod/v4/locales/az.cjs +2 -0
- package/node_modules/zod/v4/locales/az.js +2 -0
- package/node_modules/zod/v4/locales/be.cjs +2 -0
- package/node_modules/zod/v4/locales/be.js +2 -0
- package/node_modules/zod/v4/locales/bg.cjs +2 -0
- package/node_modules/zod/v4/locales/bg.js +2 -0
- package/node_modules/zod/v4/locales/bn.cjs +2 -0
- package/node_modules/zod/v4/locales/bn.js +2 -0
- package/node_modules/zod/v4/locales/ca.cjs +2 -0
- package/node_modules/zod/v4/locales/ca.js +2 -0
- package/node_modules/zod/v4/locales/ckb.cjs +2 -0
- package/node_modules/zod/v4/locales/ckb.js +2 -0
- package/node_modules/zod/v4/locales/cs.cjs +2 -0
- package/node_modules/zod/v4/locales/cs.js +2 -0
- package/node_modules/zod/v4/locales/da.cjs +2 -0
- package/node_modules/zod/v4/locales/da.js +2 -0
- package/node_modules/zod/v4/locales/de.cjs +2 -0
- package/node_modules/zod/v4/locales/de.js +2 -0
- package/node_modules/zod/v4/locales/el.cjs +2 -0
- package/node_modules/zod/v4/locales/el.js +2 -0
- package/node_modules/zod/v4/locales/en.cjs +2 -0
- package/node_modules/zod/v4/locales/en.js +2 -0
- package/node_modules/zod/v4/locales/eo.cjs +2 -0
- package/node_modules/zod/v4/locales/eo.js +2 -0
- package/node_modules/zod/v4/locales/es.cjs +2 -0
- package/node_modules/zod/v4/locales/es.js +2 -0
- package/node_modules/zod/v4/locales/fa.cjs +2 -0
- package/node_modules/zod/v4/locales/fa.js +2 -0
- package/node_modules/zod/v4/locales/fi.cjs +2 -0
- package/node_modules/zod/v4/locales/fi.js +2 -0
- package/node_modules/zod/v4/locales/fr-CA.cjs +2 -0
- package/node_modules/zod/v4/locales/fr-CA.js +2 -0
- package/node_modules/zod/v4/locales/fr.cjs +2 -0
- package/node_modules/zod/v4/locales/fr.js +2 -0
- package/node_modules/zod/v4/locales/gu.cjs +2 -0
- package/node_modules/zod/v4/locales/gu.js +2 -0
- package/node_modules/zod/v4/locales/he.cjs +2 -0
- package/node_modules/zod/v4/locales/he.js +2 -0
- package/node_modules/zod/v4/locales/hi.cjs +2 -0
- package/node_modules/zod/v4/locales/hi.js +2 -0
- package/node_modules/zod/v4/locales/hr.cjs +2 -0
- package/node_modules/zod/v4/locales/hr.js +2 -0
- package/node_modules/zod/v4/locales/hu.cjs +2 -0
- package/node_modules/zod/v4/locales/hu.js +2 -0
- package/node_modules/zod/v4/locales/hy.cjs +2 -0
- package/node_modules/zod/v4/locales/hy.js +2 -0
- package/node_modules/zod/v4/locales/id.cjs +2 -0
- package/node_modules/zod/v4/locales/id.js +2 -0
- package/node_modules/zod/v4/locales/index.cjs +22 -1
- package/node_modules/zod/v4/locales/index.d.cts +1 -0
- package/node_modules/zod/v4/locales/index.d.ts +1 -0
- package/node_modules/zod/v4/locales/index.js +1 -0
- package/node_modules/zod/v4/locales/is.cjs +2 -0
- package/node_modules/zod/v4/locales/is.js +2 -0
- package/node_modules/zod/v4/locales/it.cjs +2 -0
- package/node_modules/zod/v4/locales/it.js +2 -0
- package/node_modules/zod/v4/locales/ja.cjs +2 -0
- package/node_modules/zod/v4/locales/ja.js +2 -0
- package/node_modules/zod/v4/locales/ka.cjs +2 -0
- package/node_modules/zod/v4/locales/ka.js +2 -0
- package/node_modules/zod/v4/locales/km.cjs +2 -0
- package/node_modules/zod/v4/locales/km.js +2 -0
- package/node_modules/zod/v4/locales/kn.cjs +2 -0
- package/node_modules/zod/v4/locales/kn.js +2 -0
- package/node_modules/zod/v4/locales/ko.cjs +2 -0
- package/node_modules/zod/v4/locales/ko.js +2 -0
- package/node_modules/zod/v4/locales/lt.cjs +2 -0
- package/node_modules/zod/v4/locales/lt.js +2 -0
- package/node_modules/zod/v4/locales/mk.cjs +2 -0
- package/node_modules/zod/v4/locales/mk.js +2 -0
- package/node_modules/zod/v4/locales/ms.cjs +2 -0
- package/node_modules/zod/v4/locales/ms.js +2 -0
- package/node_modules/zod/v4/locales/ne.cjs +2 -0
- package/node_modules/zod/v4/locales/ne.js +2 -0
- package/node_modules/zod/v4/locales/nl.cjs +2 -0
- package/node_modules/zod/v4/locales/nl.js +2 -0
- package/node_modules/zod/v4/locales/nn.cjs +2 -0
- package/node_modules/zod/v4/locales/nn.js +2 -0
- package/node_modules/zod/v4/locales/no.cjs +2 -0
- package/node_modules/zod/v4/locales/no.js +2 -0
- package/node_modules/zod/v4/locales/ota.cjs +2 -0
- package/node_modules/zod/v4/locales/ota.js +2 -0
- package/node_modules/zod/v4/locales/pl.cjs +2 -0
- package/node_modules/zod/v4/locales/pl.js +2 -0
- package/node_modules/zod/v4/locales/ps.cjs +2 -0
- package/node_modules/zod/v4/locales/ps.js +2 -0
- package/node_modules/zod/v4/locales/pt-BR.cjs +2 -0
- package/node_modules/zod/v4/locales/pt-BR.js +2 -0
- package/node_modules/zod/v4/locales/pt.cjs +2 -0
- package/node_modules/zod/v4/locales/pt.js +2 -0
- package/node_modules/zod/v4/locales/ro.cjs +2 -0
- package/node_modules/zod/v4/locales/ro.js +2 -0
- package/node_modules/zod/v4/locales/ru.cjs +2 -0
- package/node_modules/zod/v4/locales/ru.js +2 -0
- package/node_modules/zod/v4/locales/sk.cjs +2 -0
- package/node_modules/zod/v4/locales/sk.js +2 -0
- package/node_modules/zod/v4/locales/sl.cjs +2 -0
- package/node_modules/zod/v4/locales/sl.js +2 -0
- package/node_modules/zod/v4/locales/sv.cjs +2 -0
- package/node_modules/zod/v4/locales/sv.js +2 -0
- package/node_modules/zod/v4/locales/ta.cjs +2 -0
- package/node_modules/zod/v4/locales/ta.js +2 -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 +2 -0
- package/node_modules/zod/v4/locales/th.js +2 -0
- package/node_modules/zod/v4/locales/tk.cjs +2 -0
- package/node_modules/zod/v4/locales/tk.js +2 -0
- package/node_modules/zod/v4/locales/tr.cjs +2 -0
- package/node_modules/zod/v4/locales/tr.js +2 -0
- package/node_modules/zod/v4/locales/uk.cjs +2 -0
- package/node_modules/zod/v4/locales/uk.js +2 -0
- package/node_modules/zod/v4/locales/ur.cjs +2 -0
- package/node_modules/zod/v4/locales/ur.js +2 -0
- package/node_modules/zod/v4/locales/uz.cjs +2 -0
- package/node_modules/zod/v4/locales/uz.js +2 -0
- package/node_modules/zod/v4/locales/vi.cjs +2 -0
- package/node_modules/zod/v4/locales/vi.js +2 -0
- package/node_modules/zod/v4/locales/yo.cjs +2 -0
- package/node_modules/zod/v4/locales/yo.js +2 -0
- package/node_modules/zod/v4/locales/zh-CN.cjs +2 -0
- package/node_modules/zod/v4/locales/zh-CN.js +2 -0
- package/node_modules/zod/v4/locales/zh-TW.cjs +2 -0
- package/node_modules/zod/v4/locales/zh-TW.js +2 -0
- package/node_modules/zod/v4/mini/checks.cjs +19 -0
- package/node_modules/zod/v4/mini/coerce.cjs +19 -0
- package/node_modules/zod/v4/mini/deep-partial.cjs +19 -0
- package/node_modules/zod/v4/mini/external.cjs +22 -1
- package/node_modules/zod/v4/mini/external.d.cts +1 -1
- package/node_modules/zod/v4/mini/external.d.ts +1 -1
- package/node_modules/zod/v4/mini/external.js +1 -1
- package/node_modules/zod/v4/mini/in-out.cjs +19 -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 +19 -0
- package/node_modules/zod/v4/mini/schemas.cjs +44 -8
- package/node_modules/zod/v4/mini/schemas.d.cts +6 -1
- package/node_modules/zod/v4/mini/schemas.d.ts +6 -1
- package/node_modules/zod/v4/mini/schemas.js +21 -6
- package/node_modules/zod/v4-mini/index.cjs +19 -0
- package/openclaw.plugin.json +21 -1
- package/package.json +9 -6
- package/dist/.setup/agent-components.runtime-CEPrf2SY.mjs +0 -4
- package/dist/.setup/message-handler.history-CJOsN9w5.mjs +0 -28
- package/dist/.setup/probe.runtime-DBQ_AGPe.mjs +0 -2
- package/dist/.setup/provider-session.runtime-BW7QrF5C.mjs +0 -6
- package/dist/.setup/provider.runtime-DuhmKdDU.mjs +0 -2
- package/dist/.setup/security-audit.runtime-DHtYenx9.mjs +0 -2
- package/dist/.setup/setup-plugin-api-CINIEBLa.mjs +0 -3
- package/dist/.setup/system-events-B2YEEMbS.mjs +0 -34
- package/dist/.setup/targets-D1mAB5yO.mjs +0 -3
- package/dist/.setup/thread-bindings.manager-eexkKyrG.mjs +0 -678
- package/dist/.setup/thread-bindings.session-updates-DCQq1WZ5.mjs +0 -55
- /package/node_modules/typebox/build/guard/{string.d.mts → unicode/unicode_segment.d.mts} +0 -0
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
import { t as getDiscordRuntime } from "./runtime-DgnVQ7zW.mjs";
|
|
2
|
+
import { O as setBindingRecord, a as THREAD_BINDINGS_MAX_ENTRIES, b as removeBindingRecord, g as openThreadBindingsStore, l as ensureBindingsLoaded, n as MANAGERS_BY_ACCOUNT_ID, o as THREAD_BINDINGS_NAMESPACE, p as normalizePersistedBinding, r as PERSIST_BY_ACCOUNT_ID, s as THREAD_BINDINGS_STATE, t as BINDINGS_BY_THREAD_ID, u as ensureBindingsLoadedAsync, x as resolveBindingIdsForSession } from "./thread-bindings.state-g6v9zAym.mjs";
|
|
3
|
+
import { normalizeAccountId } from "openclaw/plugin-sdk/routing";
|
|
4
|
+
import { createPluginStateErrorReporter } from "openclaw/plugin-sdk/plugin-state-runtime";
|
|
5
|
+
import { logVerbose } from "openclaw/plugin-sdk/runtime-env";
|
|
6
|
+
//#region extensions/discord/src/monitor/thread-bindings.persistence.ts
|
|
7
|
+
function shouldPersistAnyBindingState() {
|
|
8
|
+
for (const value of PERSIST_BY_ACCOUNT_ID.values()) if (value) return true;
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
function shouldPersistBindingMutations() {
|
|
12
|
+
if (shouldPersistAnyBindingState()) return true;
|
|
13
|
+
return THREAD_BINDINGS_STATE.loadedPersistentBindings;
|
|
14
|
+
}
|
|
15
|
+
function snapshotThreadBindingJson(value) {
|
|
16
|
+
const serialized = JSON.stringify(value);
|
|
17
|
+
return serialized ? JSON.parse(serialized) : void 0;
|
|
18
|
+
}
|
|
19
|
+
function toPersistedBindingRecord(record) {
|
|
20
|
+
return normalizePersistedBinding(record.threadId, snapshotThreadBindingJson(record)) ?? { ...record };
|
|
21
|
+
}
|
|
22
|
+
function runThreadBindingAccountOperation(managers, operation) {
|
|
23
|
+
if (managers.length === 0) return operation();
|
|
24
|
+
const tails = THREAD_BINDINGS_STATE.accountOperationTails;
|
|
25
|
+
const predecessors = managers.map((manager) => tails.get(manager) ?? Promise.resolve());
|
|
26
|
+
const result = Promise.all(predecessors).then(operation);
|
|
27
|
+
const settled = result.then(() => {}, () => {});
|
|
28
|
+
for (const manager of managers) tails.set(manager, settled);
|
|
29
|
+
settled.then(() => {
|
|
30
|
+
for (const manager of managers) if (tails.get(manager) === settled) tails.delete(manager);
|
|
31
|
+
});
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
function drainThreadBindingAccountOperations(manager) {
|
|
35
|
+
return THREAD_BINDINGS_STATE.accountOperationTails.get(manager) ?? Promise.resolve();
|
|
36
|
+
}
|
|
37
|
+
function runThreadBindingMutation(operation) {
|
|
38
|
+
const result = THREAD_BINDINGS_STATE.mutationTail.then(operation);
|
|
39
|
+
THREAD_BINDINGS_STATE.mutationTail = result.then(() => {}, () => {});
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
function drainThreadBindingMutations() {
|
|
43
|
+
return THREAD_BINDINGS_STATE.mutationTail;
|
|
44
|
+
}
|
|
45
|
+
async function commitBindingRecord(params) {
|
|
46
|
+
const revision = THREAD_BINDINGS_STATE.revision;
|
|
47
|
+
let authorityRefused = false;
|
|
48
|
+
let targetCommitted = false;
|
|
49
|
+
let committedWrites = 0;
|
|
50
|
+
const assertCurrent = () => {
|
|
51
|
+
try {
|
|
52
|
+
params.assertCurrent?.();
|
|
53
|
+
if (THREAD_BINDINGS_STATE.revision !== revision || BINDINGS_BY_THREAD_ID.get(params.bindingKey) !== params.previous) throw new Error("Discord thread binding changed during persistence");
|
|
54
|
+
} catch (error) {
|
|
55
|
+
authorityRefused = true;
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
assertCurrent();
|
|
60
|
+
const now = Date.now();
|
|
61
|
+
if (params.persist && THREAD_BINDINGS_STATE.persistenceAvailable && !(params.minIntervalMs && THREAD_BINDINGS_STATE.lastPersistedAtMs > 0 && now - THREAD_BINDINGS_STATE.lastPersistedAtMs < params.minIntervalMs)) {
|
|
62
|
+
const records = new Map(BINDINGS_BY_THREAD_ID);
|
|
63
|
+
if (params.next) records.set(params.bindingKey, params.next);
|
|
64
|
+
else records.delete(params.bindingKey);
|
|
65
|
+
const active = {
|
|
66
|
+
targetKey: params.bindingKey,
|
|
67
|
+
deletingTarget: params.next === null,
|
|
68
|
+
nextRecord: params.next,
|
|
69
|
+
writingKey: void 0,
|
|
70
|
+
committedKeys: /* @__PURE__ */ new Set()
|
|
71
|
+
};
|
|
72
|
+
THREAD_BINDINGS_STATE.activePersistence = active;
|
|
73
|
+
try {
|
|
74
|
+
const store = getDiscordRuntime().state.openKeyedStore({
|
|
75
|
+
namespace: THREAD_BINDINGS_NAMESPACE,
|
|
76
|
+
maxEntries: THREAD_BINDINGS_MAX_ENTRIES
|
|
77
|
+
});
|
|
78
|
+
for (const [key, record] of records) {
|
|
79
|
+
assertCurrent();
|
|
80
|
+
const persisted = toPersistedBindingRecord(record);
|
|
81
|
+
if (key === params.bindingKey) active.nextRecord = persisted;
|
|
82
|
+
active.writingKey = key;
|
|
83
|
+
await store.register(key, persisted, { assertCurrent });
|
|
84
|
+
active.writingKey = void 0;
|
|
85
|
+
active.committedKeys.add(key);
|
|
86
|
+
committedWrites += 1;
|
|
87
|
+
targetCommitted ||= key === params.bindingKey;
|
|
88
|
+
}
|
|
89
|
+
assertCurrent();
|
|
90
|
+
const entries = await store.entries();
|
|
91
|
+
assertCurrent();
|
|
92
|
+
for (const entry of entries) if (!records.has(entry.key)) {
|
|
93
|
+
active.writingKey = entry.key;
|
|
94
|
+
await store.delete(entry.key, { assertCurrent });
|
|
95
|
+
active.writingKey = void 0;
|
|
96
|
+
active.committedKeys.add(entry.key);
|
|
97
|
+
committedWrites += 1;
|
|
98
|
+
targetCommitted ||= entry.key === params.bindingKey;
|
|
99
|
+
}
|
|
100
|
+
if (!params.next) targetCommitted = true;
|
|
101
|
+
assertCurrent();
|
|
102
|
+
THREAD_BINDINGS_STATE.loadedPersistentBindings = records.size > 0;
|
|
103
|
+
THREAD_BINDINGS_STATE.lastPersistedAtMs = now;
|
|
104
|
+
} catch (error) {
|
|
105
|
+
let failure = error;
|
|
106
|
+
if (!authorityRefused) try {
|
|
107
|
+
assertCurrent();
|
|
108
|
+
} catch (interruption) {
|
|
109
|
+
failure = interruption;
|
|
110
|
+
}
|
|
111
|
+
if (authorityRefused) {
|
|
112
|
+
createPluginStateErrorReporter(getDiscordRuntime, "discord", "thread-bindings", "Discord thread binding save interrupted; acknowledged writes were retained.", () => ({
|
|
113
|
+
committedWrites,
|
|
114
|
+
targetCommitted
|
|
115
|
+
}))(failure);
|
|
116
|
+
if (!targetCommitted) {
|
|
117
|
+
if (committedWrites === 0) throw failure;
|
|
118
|
+
throw new Error(`Discord thread binding changed during persistence after ${committedWrites} acknowledged writes`, { cause: error });
|
|
119
|
+
}
|
|
120
|
+
} else {
|
|
121
|
+
THREAD_BINDINGS_STATE.persistenceAvailable = false;
|
|
122
|
+
logVerbose("discord thread binding persistence unavailable; keeping bindings in memory");
|
|
123
|
+
}
|
|
124
|
+
} finally {
|
|
125
|
+
delete THREAD_BINDINGS_STATE.activePersistence;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (!targetCommitted) assertCurrent();
|
|
129
|
+
if (BINDINGS_BY_THREAD_ID.get(params.bindingKey) !== params.previous) return;
|
|
130
|
+
if (params.next) setBindingRecord(params.next);
|
|
131
|
+
else removeBindingRecord(params.bindingKey);
|
|
132
|
+
}
|
|
133
|
+
function persistBindingsSync(update, removedKey) {
|
|
134
|
+
const store = openThreadBindingsStore();
|
|
135
|
+
const active = THREAD_BINDINGS_STATE.activePersistence;
|
|
136
|
+
let updatedRecord;
|
|
137
|
+
for (const [key, record] of BINDINGS_BY_THREAD_ID) if (key === update?.bindingKey || active?.targetKey === key && active.deletingTarget || active?.writingKey === key || active?.committedKeys.has(key)) {
|
|
138
|
+
if (!store.update) throw new Error("Discord synchronous compatibility requires atomic state update");
|
|
139
|
+
let next;
|
|
140
|
+
store.update(key, (current) => {
|
|
141
|
+
let base = record;
|
|
142
|
+
if (active?.targetKey === key) {
|
|
143
|
+
if (!current && active.deletingTarget) base = void 0;
|
|
144
|
+
else if (current && active.nextRecord && (active.writingKey === key || active.committedKeys.has(key)) && JSON.stringify(toPersistedBindingRecord(current)) === JSON.stringify(toPersistedBindingRecord(active.nextRecord))) base = normalizePersistedBinding(key, current) ?? record;
|
|
145
|
+
}
|
|
146
|
+
if (key === update?.bindingKey) update.observe?.(current && normalizePersistedBinding(key, current) ? base : void 0);
|
|
147
|
+
next = base ? key === update?.bindingKey ? update.transform(base) : base : void 0;
|
|
148
|
+
return next ? toPersistedBindingRecord(next) : void 0;
|
|
149
|
+
});
|
|
150
|
+
if (key === update?.bindingKey) updatedRecord = next;
|
|
151
|
+
if (next) {
|
|
152
|
+
if (next !== record) setBindingRecord(next);
|
|
153
|
+
} else if (!(active?.targetKey === key && active.deletingTarget)) removeBindingRecord(key);
|
|
154
|
+
} else store.register(key, toPersistedBindingRecord(record));
|
|
155
|
+
for (const entry of store.entries()) if (!BINDINGS_BY_THREAD_ID.has(entry.key)) {
|
|
156
|
+
if (entry.key !== removedKey && active?.targetKey === entry.key && !active.deletingTarget) {
|
|
157
|
+
const committed = normalizePersistedBinding(entry.key, entry.value);
|
|
158
|
+
if (committed) {
|
|
159
|
+
setBindingRecord(committed);
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
store.delete(entry.key);
|
|
164
|
+
}
|
|
165
|
+
THREAD_BINDINGS_STATE.loadedPersistentBindings = BINDINGS_BY_THREAD_ID.size > 0;
|
|
166
|
+
THREAD_BINDINGS_STATE.lastPersistedAtMs = Date.now();
|
|
167
|
+
return updatedRecord;
|
|
168
|
+
}
|
|
169
|
+
/** Public SDK compatibility only; bundled callers await worker mutations. */
|
|
170
|
+
function updateBindingRecordSync(params) {
|
|
171
|
+
const record = BINDINGS_BY_THREAD_ID.get(params.bindingKey);
|
|
172
|
+
if (!record) return null;
|
|
173
|
+
const now = Date.now();
|
|
174
|
+
const persist = params.persist && THREAD_BINDINGS_STATE.persistenceAvailable && (THREAD_BINDINGS_STATE.activePersistence || !params.minIntervalMs || now - THREAD_BINDINGS_STATE.lastPersistedAtMs >= params.minIntervalMs);
|
|
175
|
+
let observed;
|
|
176
|
+
if (persist) try {
|
|
177
|
+
return persistBindingsSync({
|
|
178
|
+
...params,
|
|
179
|
+
observe: (current) => {
|
|
180
|
+
observed = current;
|
|
181
|
+
}
|
|
182
|
+
}) ?? null;
|
|
183
|
+
} catch {
|
|
184
|
+
THREAD_BINDINGS_STATE.persistenceAvailable = false;
|
|
185
|
+
logVerbose("discord thread binding persistence unavailable; keeping bindings in memory");
|
|
186
|
+
}
|
|
187
|
+
const current = BINDINGS_BY_THREAD_ID.get(params.bindingKey);
|
|
188
|
+
if (current !== record) return current ?? null;
|
|
189
|
+
if (THREAD_BINDINGS_STATE.activePersistence?.targetKey === params.bindingKey && !observed) {
|
|
190
|
+
logVerbose("discord synchronous binding update skipped: pending target read unavailable");
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
const next = params.transform(observed ?? record);
|
|
194
|
+
setBindingRecord(next);
|
|
195
|
+
return next;
|
|
196
|
+
}
|
|
197
|
+
/** Public SDK compatibility only; bundled callers await worker mutations. */
|
|
198
|
+
function removeBindingRecordSync(bindingKey) {
|
|
199
|
+
const record = BINDINGS_BY_THREAD_ID.get(bindingKey);
|
|
200
|
+
if (!record) return null;
|
|
201
|
+
if (!shouldPersistBindingMutations() || !THREAD_BINDINGS_STATE.persistenceAvailable) return THREAD_BINDINGS_STATE.activePersistence?.targetKey === bindingKey ? null : removeBindingRecord(bindingKey);
|
|
202
|
+
let removed = null;
|
|
203
|
+
let observed = null;
|
|
204
|
+
let replacement;
|
|
205
|
+
try {
|
|
206
|
+
const store = openThreadBindingsStore();
|
|
207
|
+
if (!store.deleteIf) throw new Error("Discord synchronous compatibility requires atomic state deletion");
|
|
208
|
+
const deleted = store.deleteIf(bindingKey, (current) => {
|
|
209
|
+
const normalized = normalizePersistedBinding(bindingKey, current);
|
|
210
|
+
observed = normalized;
|
|
211
|
+
const pending = THREAD_BINDINGS_STATE.activePersistence;
|
|
212
|
+
if (normalized && pending?.targetKey === bindingKey && pending.nextRecord && (pending.writingKey === bindingKey || pending.committedKeys.has(bindingKey)) && JSON.stringify(toPersistedBindingRecord(normalized)) === JSON.stringify(toPersistedBindingRecord(pending.nextRecord)) && (normalized.targetSessionKey !== record.targetSessionKey || normalized.targetKind !== record.targetKind)) {
|
|
213
|
+
replacement = normalized;
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
return true;
|
|
217
|
+
});
|
|
218
|
+
if (replacement) {
|
|
219
|
+
setBindingRecord(replacement);
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
const pending = THREAD_BINDINGS_STATE.activePersistence;
|
|
223
|
+
if (!deleted && pending?.targetKey === bindingKey && pending.deletingTarget) return null;
|
|
224
|
+
removed = removeBindingRecord(bindingKey);
|
|
225
|
+
persistBindingsSync(void 0, bindingKey);
|
|
226
|
+
return removed;
|
|
227
|
+
} catch {
|
|
228
|
+
THREAD_BINDINGS_STATE.persistenceAvailable = false;
|
|
229
|
+
if (replacement) {
|
|
230
|
+
setBindingRecord(replacement);
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
if (THREAD_BINDINGS_STATE.activePersistence?.targetKey === bindingKey && !observed && !removed) {
|
|
234
|
+
logVerbose("discord synchronous binding removal skipped: pending target read unavailable");
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
return removed ?? removeBindingRecord(bindingKey);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
//#endregion
|
|
241
|
+
//#region extensions/discord/src/monitor/thread-bindings.session-shared.ts
|
|
242
|
+
function normalizeNonNegativeMs(raw) {
|
|
243
|
+
if (!Number.isFinite(raw)) return 0;
|
|
244
|
+
return Math.max(0, Math.floor(raw));
|
|
245
|
+
}
|
|
246
|
+
function resolveBindingIdsForTargetSession(params) {
|
|
247
|
+
ensureBindingsLoaded();
|
|
248
|
+
const targetSessionKey = params.targetSessionKey.trim();
|
|
249
|
+
if (!targetSessionKey) return [];
|
|
250
|
+
const accountId = params.accountId ? normalizeAccountId(params.accountId) : void 0;
|
|
251
|
+
return resolveBindingIdsForSession({
|
|
252
|
+
targetSessionKey,
|
|
253
|
+
accountId,
|
|
254
|
+
targetKind: params.targetKind
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
function mutateBindingsForTargetSession(params, update, onRemoved) {
|
|
258
|
+
const accountId = params.accountId ? normalizeAccountId(params.accountId) : void 0;
|
|
259
|
+
const admittedOwners = new Map([...MANAGERS_BY_ACCOUNT_ID].filter(([ownerAccountId]) => accountId === void 0 || ownerAccountId === accountId).map(([ownerAccountId, manager]) => [ownerAccountId, {
|
|
260
|
+
manager,
|
|
261
|
+
stopping: manager.isStopping()
|
|
262
|
+
}]));
|
|
263
|
+
return runThreadBindingAccountOperation([...admittedOwners.values()].map(({ manager }) => manager), () => runThreadBindingMutation(async () => {
|
|
264
|
+
await ensureBindingsLoadedAsync();
|
|
265
|
+
const ids = resolveBindingIdsForTargetSession(params);
|
|
266
|
+
const owners = /* @__PURE__ */ new Map();
|
|
267
|
+
for (const bindingKey of ids) {
|
|
268
|
+
const existing = BINDINGS_BY_THREAD_ID.get(bindingKey);
|
|
269
|
+
if (!existing) continue;
|
|
270
|
+
const manager = MANAGERS_BY_ACCOUNT_ID.get(existing.accountId);
|
|
271
|
+
const admitted = admittedOwners.get(existing.accountId);
|
|
272
|
+
if (admitted?.stopping || !admitted && manager?.isStopping()) throw new Error("Discord thread binding manager is stopping");
|
|
273
|
+
if (admitted?.manager !== manager) throw new Error("Discord thread binding manager changed");
|
|
274
|
+
owners.set(existing.accountId, manager);
|
|
275
|
+
}
|
|
276
|
+
const now = Date.now();
|
|
277
|
+
const updated = [];
|
|
278
|
+
for (const bindingKey of ids) {
|
|
279
|
+
const existing = BINDINGS_BY_THREAD_ID.get(bindingKey);
|
|
280
|
+
if (!existing) continue;
|
|
281
|
+
const manager = owners.get(existing.accountId);
|
|
282
|
+
const assertCurrent = () => {
|
|
283
|
+
if (MANAGERS_BY_ACCOUNT_ID.get(existing.accountId) !== manager) throw new Error("Discord thread binding manager changed");
|
|
284
|
+
};
|
|
285
|
+
const nextRecord = update(existing, now);
|
|
286
|
+
await commitBindingRecord({
|
|
287
|
+
bindingKey,
|
|
288
|
+
previous: existing,
|
|
289
|
+
next: nextRecord,
|
|
290
|
+
persist: shouldPersistBindingMutations(),
|
|
291
|
+
assertCurrent
|
|
292
|
+
});
|
|
293
|
+
if (!nextRecord) onRemoved?.(existing, manager);
|
|
294
|
+
updated.push(nextRecord ?? existing);
|
|
295
|
+
}
|
|
296
|
+
return updated;
|
|
297
|
+
}));
|
|
298
|
+
}
|
|
299
|
+
/** @deprecated Generic SDK synchronous lifecycle compatibility. */
|
|
300
|
+
function updateBindingsForTargetSessionSync(ids, update) {
|
|
301
|
+
const now = Date.now();
|
|
302
|
+
const updated = [];
|
|
303
|
+
for (const bindingKey of ids) {
|
|
304
|
+
const existing = BINDINGS_BY_THREAD_ID.get(bindingKey);
|
|
305
|
+
if (!existing) continue;
|
|
306
|
+
if (MANAGERS_BY_ACCOUNT_ID.get(existing.accountId)?.isStopping()) throw new Error("Discord thread binding manager is stopping");
|
|
307
|
+
const next = updateBindingRecordSync({
|
|
308
|
+
bindingKey,
|
|
309
|
+
transform: (record) => record.targetSessionKey === existing.targetSessionKey ? update(record, now) : record,
|
|
310
|
+
persist: shouldPersistBindingMutations()
|
|
311
|
+
});
|
|
312
|
+
if (next?.targetSessionKey === existing.targetSessionKey) updated.push(next);
|
|
313
|
+
}
|
|
314
|
+
return updated;
|
|
315
|
+
}
|
|
316
|
+
//#endregion
|
|
317
|
+
//#region extensions/discord/src/monitor/thread-bindings.session-updates.ts
|
|
318
|
+
async function setThreadBindingIdleTimeoutBySessionKeyAsync(input) {
|
|
319
|
+
const params = { ...input };
|
|
320
|
+
const idleTimeoutMs = normalizeNonNegativeMs(params.idleTimeoutMs);
|
|
321
|
+
return mutateBindingsForTargetSession(params, (existing, now) => ({
|
|
322
|
+
...existing,
|
|
323
|
+
idleTimeoutMs,
|
|
324
|
+
lastActivityAt: now
|
|
325
|
+
}));
|
|
326
|
+
}
|
|
327
|
+
async function setThreadBindingMaxAgeBySessionKeyAsync(input) {
|
|
328
|
+
const params = { ...input };
|
|
329
|
+
const maxAgeMs = normalizeNonNegativeMs(params.maxAgeMs);
|
|
330
|
+
return mutateBindingsForTargetSession(params, (existing, now) => ({
|
|
331
|
+
...existing,
|
|
332
|
+
maxAgeMs,
|
|
333
|
+
boundAt: now,
|
|
334
|
+
lastActivityAt: now
|
|
335
|
+
}));
|
|
336
|
+
}
|
|
337
|
+
/** @deprecated Use the awaited lifecycle setter; retained for the generic SDK contract. */
|
|
338
|
+
function setThreadBindingIdleTimeoutBySessionKey(params) {
|
|
339
|
+
const ids = resolveBindingIdsForTargetSession(params);
|
|
340
|
+
const idleTimeoutMs = normalizeNonNegativeMs(params.idleTimeoutMs);
|
|
341
|
+
return updateBindingsForTargetSessionSync(ids, (existing, now) => ({
|
|
342
|
+
...existing,
|
|
343
|
+
idleTimeoutMs,
|
|
344
|
+
lastActivityAt: now
|
|
345
|
+
}));
|
|
346
|
+
}
|
|
347
|
+
/** @deprecated Use the awaited lifecycle setter; retained for the generic SDK contract. */
|
|
348
|
+
function setThreadBindingMaxAgeBySessionKey(params) {
|
|
349
|
+
const ids = resolveBindingIdsForTargetSession(params);
|
|
350
|
+
const maxAgeMs = normalizeNonNegativeMs(params.maxAgeMs);
|
|
351
|
+
return updateBindingsForTargetSessionSync(ids, (existing, now) => ({
|
|
352
|
+
...existing,
|
|
353
|
+
maxAgeMs,
|
|
354
|
+
boundAt: now,
|
|
355
|
+
lastActivityAt: now
|
|
356
|
+
}));
|
|
357
|
+
}
|
|
358
|
+
//#endregion
|
|
359
|
+
export { mutateBindingsForTargetSession as a, drainThreadBindingAccountOperations as c, runThreadBindingAccountOperation as d, runThreadBindingMutation as f, updateBindingRecordSync as h, setThreadBindingMaxAgeBySessionKeyAsync as i, drainThreadBindingMutations as l, snapshotThreadBindingJson as m, setThreadBindingIdleTimeoutBySessionKeyAsync as n, resolveBindingIdsForTargetSession as o, shouldPersistAnyBindingState as p, setThreadBindingMaxAgeBySessionKey as r, commitBindingRecord as s, setThreadBindingIdleTimeoutBySessionKey as t, removeBindingRecordSync as u };
|
package/dist/.setup/{thread-bindings.state-BThFQEga.mjs → thread-bindings.state-g6v9zAym.mjs}
RENAMED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.mjs";
|
|
2
2
|
import { t as getDiscordRuntime } from "./runtime-DgnVQ7zW.mjs";
|
|
3
|
+
import { resolveGlobalSingleton } from "openclaw/plugin-sdk/global-singleton";
|
|
3
4
|
import { normalizeAccountId, resolveAgentIdFromSessionKey } from "openclaw/plugin-sdk/routing";
|
|
4
|
-
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeOptionalStringifiedId } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
5
|
+
import { asFiniteNumber, normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeOptionalStringifiedId } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
6
|
+
import { logVerbose } from "openclaw/plugin-sdk/runtime-env";
|
|
5
7
|
import { recordOutboundMessageIdentity } from "openclaw/plugin-sdk/outbound-echo-runtime";
|
|
6
8
|
import { resolveThreadBindingExpiry } from "openclaw/plugin-sdk/thread-bindings-session-runtime";
|
|
7
9
|
//#region extensions/discord/src/monitor/thread-bindings.state.ts
|
|
@@ -12,6 +14,7 @@ var thread_bindings_state_exports = /* @__PURE__ */ __exportAll({
|
|
|
12
14
|
REUSABLE_WEBHOOKS_BY_ACCOUNT_CHANNEL: () => REUSABLE_WEBHOOKS_BY_ACCOUNT_CHANNEL,
|
|
13
15
|
THREAD_BINDINGS_MAX_ENTRIES: () => THREAD_BINDINGS_MAX_ENTRIES,
|
|
14
16
|
THREAD_BINDINGS_NAMESPACE: () => THREAD_BINDINGS_NAMESPACE,
|
|
17
|
+
THREAD_BINDINGS_STATE: () => THREAD_BINDINGS_STATE,
|
|
15
18
|
THREAD_BINDING_TOUCH_PERSIST_MIN_INTERVAL_MS: () => THREAD_BINDING_TOUCH_PERSIST_MIN_INTERVAL_MS,
|
|
16
19
|
ensureBindingsLoaded: () => ensureBindingsLoaded,
|
|
17
20
|
ensureBindingsLoadedAsync: () => ensureBindingsLoadedAsync,
|
|
@@ -20,7 +23,7 @@ var thread_bindings_state_exports = /* @__PURE__ */ __exportAll({
|
|
|
20
23
|
normalizePersistedBinding: () => normalizePersistedBinding,
|
|
21
24
|
normalizeTargetKind: () => normalizeTargetKind,
|
|
22
25
|
normalizeThreadBindingDurationMs: () => normalizeThreadBindingDurationMs,
|
|
23
|
-
|
|
26
|
+
openThreadBindingsStore: () => openThreadBindingsStore,
|
|
24
27
|
refreshUnboundThreadWebhookIdentity: () => refreshUnboundThreadWebhookIdentity,
|
|
25
28
|
rememberReusableWebhook: () => rememberReusableWebhook,
|
|
26
29
|
rememberThreadBindingToken: () => rememberThreadBindingToken,
|
|
@@ -32,15 +35,12 @@ var thread_bindings_state_exports = /* @__PURE__ */ __exportAll({
|
|
|
32
35
|
resolveThreadBindingInactivityExpiresAt: () => resolveThreadBindingInactivityExpiresAt,
|
|
33
36
|
resolveThreadBindingMaxAgeExpiresAt: () => resolveThreadBindingMaxAgeExpiresAt,
|
|
34
37
|
resolveThreadBindingMaxAgeMs: () => resolveThreadBindingMaxAgeMs,
|
|
35
|
-
saveBindingsToDisk: () => saveBindingsToDisk,
|
|
36
38
|
setBindingRecord: () => setBindingRecord,
|
|
37
39
|
shouldDefaultPersist: () => shouldDefaultPersist,
|
|
38
|
-
shouldPersistBindingMutations: () => shouldPersistBindingMutations,
|
|
39
40
|
toBindingRecordKey: () => toBindingRecordKey,
|
|
40
41
|
toReusableWebhookKey: () => toReusableWebhookKey
|
|
41
42
|
});
|
|
42
43
|
const THREAD_BINDINGS_STATE_KEY = Symbol.for("openclaw.discordThreadBindingsState");
|
|
43
|
-
let threadBindingsState;
|
|
44
44
|
function createThreadBindingsGlobalState() {
|
|
45
45
|
return {
|
|
46
46
|
managersByAccountId: /* @__PURE__ */ new Map(),
|
|
@@ -52,18 +52,14 @@ function createThreadBindingsGlobalState() {
|
|
|
52
52
|
loadedBindings: false,
|
|
53
53
|
loadedPersistentBindings: false,
|
|
54
54
|
persistenceAvailable: true,
|
|
55
|
-
lastPersistedAtMs: 0
|
|
55
|
+
lastPersistedAtMs: 0,
|
|
56
|
+
revision: 0,
|
|
57
|
+
mutationTail: Promise.resolve(),
|
|
58
|
+
accountOperationTails: /* @__PURE__ */ new WeakMap()
|
|
56
59
|
};
|
|
57
60
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const globalStore = globalThis;
|
|
61
|
-
threadBindingsState = globalStore[THREAD_BINDINGS_STATE_KEY] ?? createThreadBindingsGlobalState();
|
|
62
|
-
globalStore[THREAD_BINDINGS_STATE_KEY] = threadBindingsState;
|
|
63
|
-
}
|
|
64
|
-
return threadBindingsState;
|
|
65
|
-
}
|
|
66
|
-
const THREAD_BINDINGS_STATE = resolveThreadBindingsGlobalState();
|
|
61
|
+
const THREAD_BINDINGS_STATE = resolveGlobalSingleton(THREAD_BINDINGS_STATE_KEY, createThreadBindingsGlobalState);
|
|
62
|
+
THREAD_BINDINGS_STATE.accountOperationTails ??= /* @__PURE__ */ new WeakMap();
|
|
67
63
|
const MANAGERS_BY_ACCOUNT_ID = THREAD_BINDINGS_STATE.managersByAccountId;
|
|
68
64
|
const BINDINGS_BY_THREAD_ID = THREAD_BINDINGS_STATE.bindingsByThreadId;
|
|
69
65
|
const BINDINGS_BY_SESSION_KEY = THREAD_BINDINGS_STATE.bindingsBySessionKey;
|
|
@@ -98,14 +94,11 @@ function normalizeTargetKind(raw, targetSessionKey) {
|
|
|
98
94
|
if (raw === "subagent" || raw === "acp") return raw;
|
|
99
95
|
return targetSessionKey.includes(":subagent:") ? "subagent" : "acp";
|
|
100
96
|
}
|
|
101
|
-
function normalizeThreadId(raw) {
|
|
102
|
-
return normalizeOptionalStringifiedId(raw);
|
|
103
|
-
}
|
|
104
97
|
function toBindingRecordKey(params) {
|
|
105
98
|
return `${normalizeAccountId(params.accountId)}:${params.threadId.trim()}`;
|
|
106
99
|
}
|
|
107
100
|
function resolveBindingRecordKey(params) {
|
|
108
|
-
const threadId =
|
|
101
|
+
const threadId = normalizeOptionalStringifiedId(params.threadId);
|
|
109
102
|
if (!threadId) return;
|
|
110
103
|
return toBindingRecordKey({
|
|
111
104
|
accountId: normalizeAccountId(params.accountId),
|
|
@@ -115,7 +108,7 @@ function resolveBindingRecordKey(params) {
|
|
|
115
108
|
function normalizePersistedBinding(threadIdKey, raw) {
|
|
116
109
|
if (!raw || typeof raw !== "object") return null;
|
|
117
110
|
const value = raw;
|
|
118
|
-
const threadId =
|
|
111
|
+
const threadId = normalizeOptionalStringifiedId(value.threadId ?? threadIdKey);
|
|
119
112
|
const channelId = normalizeOptionalString(value.channelId) ?? "";
|
|
120
113
|
const targetSessionKey = normalizeOptionalString(value.targetSessionKey) ?? "";
|
|
121
114
|
if (!threadId || !channelId || !targetSessionKey) return null;
|
|
@@ -157,14 +150,10 @@ function normalizeThreadBindingDurationMs(raw, defaultsTo) {
|
|
|
157
150
|
return durationMs;
|
|
158
151
|
}
|
|
159
152
|
function resolveThreadBindingIdleTimeoutMs(params) {
|
|
160
|
-
|
|
161
|
-
if (typeof explicit === "number" && Number.isFinite(explicit)) return Math.max(0, Math.floor(explicit));
|
|
162
|
-
return Math.max(0, Math.floor(params.defaultIdleTimeoutMs));
|
|
153
|
+
return Math.max(0, Math.floor(asFiniteNumber(params.record.idleTimeoutMs) ?? params.defaultIdleTimeoutMs));
|
|
163
154
|
}
|
|
164
155
|
function resolveThreadBindingMaxAgeMs(params) {
|
|
165
|
-
|
|
166
|
-
if (typeof explicit === "number" && Number.isFinite(explicit)) return Math.max(0, Math.floor(explicit));
|
|
167
|
-
return Math.max(0, Math.floor(params.defaultMaxAgeMs));
|
|
156
|
+
return Math.max(0, Math.floor(asFiniteNumber(params.record.maxAgeMs) ?? params.defaultMaxAgeMs));
|
|
168
157
|
}
|
|
169
158
|
function resolveTimestampExpiry(timestamp, durationMs) {
|
|
170
159
|
if (durationMs <= 0) return;
|
|
@@ -252,6 +241,7 @@ function setBindingRecord(record) {
|
|
|
252
241
|
const existing = BINDINGS_BY_THREAD_ID.get(bindingKey);
|
|
253
242
|
if (existing) unlinkSessionBinding(existing.targetSessionKey, bindingKey);
|
|
254
243
|
BINDINGS_BY_THREAD_ID.set(bindingKey, record);
|
|
244
|
+
THREAD_BINDINGS_STATE.revision += 1;
|
|
255
245
|
linkSessionBinding(record.targetSessionKey, bindingKey);
|
|
256
246
|
rememberReusableWebhook(record);
|
|
257
247
|
}
|
|
@@ -261,46 +251,14 @@ function removeBindingRecord(bindingKeyRaw) {
|
|
|
261
251
|
const existing = BINDINGS_BY_THREAD_ID.get(key);
|
|
262
252
|
if (!existing) return null;
|
|
263
253
|
BINDINGS_BY_THREAD_ID.delete(key);
|
|
254
|
+
THREAD_BINDINGS_STATE.revision += 1;
|
|
264
255
|
unlinkSessionBinding(existing.targetSessionKey, key);
|
|
265
256
|
return existing;
|
|
266
257
|
}
|
|
267
|
-
function shouldPersistAnyBindingState() {
|
|
268
|
-
for (const value of PERSIST_BY_ACCOUNT_ID.values()) if (value) return true;
|
|
269
|
-
return false;
|
|
270
|
-
}
|
|
271
|
-
function shouldPersistBindingMutations() {
|
|
272
|
-
if (!THREAD_BINDINGS_STATE.persistenceAvailable) return false;
|
|
273
|
-
if (shouldPersistAnyBindingState()) return true;
|
|
274
|
-
return THREAD_BINDINGS_STATE.loadedPersistentBindings;
|
|
275
|
-
}
|
|
276
|
-
function toPersistedBindingRecord(record) {
|
|
277
|
-
const serialized = JSON.stringify(record);
|
|
278
|
-
if (!serialized) return { ...record };
|
|
279
|
-
return normalizePersistedBinding(record.threadId, JSON.parse(serialized)) ?? { ...record };
|
|
280
|
-
}
|
|
281
|
-
function saveBindingsToDisk(params = {}) {
|
|
282
|
-
if (!params.force && !shouldPersistAnyBindingState()) return;
|
|
283
|
-
if (!THREAD_BINDINGS_STATE.persistenceAvailable) return;
|
|
284
|
-
const minIntervalMs = typeof params.minIntervalMs === "number" && Number.isFinite(params.minIntervalMs) ? Math.max(0, Math.floor(params.minIntervalMs)) : 0;
|
|
285
|
-
const now = Date.now();
|
|
286
|
-
if (!params.force && minIntervalMs > 0 && THREAD_BINDINGS_STATE.lastPersistedAtMs > 0 && now - THREAD_BINDINGS_STATE.lastPersistedAtMs < minIntervalMs) return;
|
|
287
|
-
try {
|
|
288
|
-
const store = openThreadBindingsStore();
|
|
289
|
-
const persistedKeys = /* @__PURE__ */ new Set();
|
|
290
|
-
for (const [bindingKey, record] of BINDINGS_BY_THREAD_ID.entries()) {
|
|
291
|
-
store.register(bindingKey, toPersistedBindingRecord(record));
|
|
292
|
-
persistedKeys.add(bindingKey);
|
|
293
|
-
}
|
|
294
|
-
for (const entry of store.entries()) if (!persistedKeys.has(entry.key)) store.delete(entry.key);
|
|
295
|
-
THREAD_BINDINGS_STATE.loadedPersistentBindings = persistedKeys.size > 0;
|
|
296
|
-
THREAD_BINDINGS_STATE.lastPersistedAtMs = now;
|
|
297
|
-
} catch {
|
|
298
|
-
THREAD_BINDINGS_STATE.persistenceAvailable = false;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
258
|
function beginBindingsLoad() {
|
|
302
259
|
THREAD_BINDINGS_STATE.loadedBindings = true;
|
|
303
260
|
BINDINGS_BY_THREAD_ID.clear();
|
|
261
|
+
THREAD_BINDINGS_STATE.revision += 1;
|
|
304
262
|
BINDINGS_BY_SESSION_KEY.clear();
|
|
305
263
|
REUSABLE_WEBHOOKS_BY_ACCOUNT_CHANNEL.clear();
|
|
306
264
|
THREAD_BINDINGS_STATE.loadedPersistentBindings = false;
|
|
@@ -337,6 +295,7 @@ async function loadBindingsAsync() {
|
|
|
337
295
|
if (!THREAD_BINDINGS_STATE.loadedBindings) {
|
|
338
296
|
beginBindingsLoad();
|
|
339
297
|
THREAD_BINDINGS_STATE.persistenceAvailable = false;
|
|
298
|
+
logVerbose("discord thread binding persistence unavailable; keeping bindings in memory");
|
|
340
299
|
}
|
|
341
300
|
return;
|
|
342
301
|
}
|
|
@@ -369,4 +328,4 @@ function resolveBindingIdsForSession(params) {
|
|
|
369
328
|
return out;
|
|
370
329
|
}
|
|
371
330
|
//#endregion
|
|
372
|
-
export {
|
|
331
|
+
export { thread_bindings_state_exports as A, resolvePreparedThreadBindingLifecycle as C, resolveThreadBindingMaxAgeMs as D, resolveThreadBindingMaxAgeExpiresAt as E, toReusableWebhookKey as M, setBindingRecord as O, resolveBindingRecordKey as S, resolveThreadBindingInactivityExpiresAt as T, refreshUnboundThreadWebhookIdentity as _, THREAD_BINDINGS_MAX_ENTRIES as a, removeBindingRecord as b, THREAD_BINDING_TOUCH_PERSIST_MIN_INTERVAL_MS as c, forgetThreadBindingToken as d, getThreadBindingToken as f, openThreadBindingsStore as g, normalizeThreadBindingDurationMs as h, REUSABLE_WEBHOOKS_BY_ACCOUNT_CHANNEL as i, toBindingRecordKey as j, shouldDefaultPersist as k, ensureBindingsLoaded as l, normalizeTargetKind as m, MANAGERS_BY_ACCOUNT_ID as n, THREAD_BINDINGS_NAMESPACE as o, normalizePersistedBinding as p, PERSIST_BY_ACCOUNT_ID as r, THREAD_BINDINGS_STATE as s, BINDINGS_BY_THREAD_ID as t, ensureBindingsLoadedAsync as u, rememberReusableWebhook as v, resolveThreadBindingIdleTimeoutMs as w, resolveBindingIdsForSession as x, rememberThreadBindingToken as y };
|