@openclaw/discord 2026.10.2 → 2026.10.5-beta.2
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/dist/.setup/account-inspect-8cCu6uPG.mjs +31 -0
- package/dist/.setup/{accounts-HE9-mj1L.mjs → accounts-ljrzXBJi.mjs} +47 -45
- package/dist/.setup/{allow-list-vxkG9_JD.mjs → allow-list-B_ToXtew.mjs} +34 -101
- package/dist/.setup/{api-DlNUkDqj.mjs → api-CtmE1OUN.mjs} +25 -31
- package/dist/.setup/{approval-handler.runtime-DmnEa54W.mjs → approval-handler.runtime-D7FoZSn0.mjs} +30 -53
- package/dist/.setup/{approval-message-updates-B0jdSqOj.mjs → approval-message-updates-CIGByUcE.mjs} +2 -2
- package/dist/.setup/{audit-BpikUwN_.mjs → audit-zSawfbsN.mjs} +5 -8
- package/dist/.setup/{channel-Dr-AUnGt.mjs → channel-DI7DMzu0.mjs} +136 -215
- package/dist/.setup/{channel-access-BRp3Y-rF.mjs → channel-access-DasWY_OV.mjs} +6 -7
- package/dist/.setup/{channel.setup-BmNvkidb.mjs → channel.setup-DdFVN1mr.mjs} +35 -64
- package/dist/.setup/{components-DLJR0xU-.mjs → components-HN9052L1.mjs} +123 -146
- package/dist/.setup/{config-schema-BQWfnSCx.mjs → config-schema-_uBILpQf.mjs} +7 -3
- package/dist/.setup/{conversation-binding-route-DicJC1Lj.mjs → conversation-binding-route-DTjCBx-O.mjs} +1 -1
- package/dist/.setup/{directory-config-gqsdcplU.mjs → directory-config-3iVub-3m.mjs} +1 -1
- package/dist/.setup/{directory-live-Bipr0eUJ.mjs → directory-live-DLygQVtW.mjs} +18 -22
- package/dist/.setup/{discord-9gysrhzp.mjs → discord-BGqgx-yd.mjs} +686 -854
- package/dist/.setup/{doctor-B2bskDcF.mjs → doctor-DSrNJ7m2.mjs} +36 -47
- package/dist/.setup/{doctor-contract-Bg3NPAMw.mjs → doctor-contract-Bwv8EuQ_.mjs} +7 -16
- package/dist/.setup/{handle-action-UmkjXBfo.mjs → handle-action-CXH1h1tq.mjs} +25 -38
- package/dist/.setup/{handle-action.guild-admin-CB4sc9VV.mjs → handle-action.guild-admin-CHKW6PIs.mjs} +25 -31
- package/dist/.setup/{live-policy-config-VxexfRKo.mjs → live-policy-config-BPoB3eQi.mjs} +1 -1
- package/dist/.setup/{message-handler-BK69A-NB.mjs → message-handler-Ii_etru1.mjs} +9 -14
- package/dist/.setup/{message-handler.preflight-DFpsh90H.mjs → message-handler.preflight-C7YuSRl_.mjs} +79 -128
- package/dist/.setup/{message-handler.preflight-pluralkit-BXGGVmpe.mjs → message-handler.preflight-pluralkit-C3iAG--b.mjs} +6 -6
- package/dist/.setup/{message-handler.process-TKoqcqIP.mjs → message-handler.process-ClgWYH6o.mjs} +234 -206
- package/dist/.setup/{outbound-adapter-D4wRAb5S.mjs → outbound-adapter-D8OOIuKn.mjs} +73 -112
- package/dist/.setup/{outbound-session-route-BvBH4LC6.mjs → outbound-session-route-B0Hpwn3Q.mjs} +57 -115
- package/dist/.setup/output-activity-uBpMSX75.mjs +11 -0
- package/dist/.setup/{pluralkit-a6_NLfH9.mjs → pluralkit-B64dfq_j.mjs} +3 -1
- package/dist/.setup/{preflight-audio-DHGIHEpv.mjs → preflight-audio-wWgsZG5F.mjs} +1 -5
- package/dist/.setup/{presence-cache-Dg3_dADn.mjs → presence-cache-DCeTsL73.mjs} +3 -6
- package/dist/.setup/{probe-BwSKpnZf.mjs → probe-D3P1x4aN.mjs} +10 -18
- package/dist/.setup/{provider-YP8gN9_o.mjs → provider-D9EzOfG8.mjs} +2990 -3903
- package/dist/.setup/{provider-session.runtime-D1gkPxHT.mjs → provider-session.runtime-CsnRvddI.mjs} +5 -5
- package/dist/.setup/provider.runtime-BQVcM7Pg.mjs +2 -0
- package/dist/.setup/{realtime-session.runtime-BKUQBy1u.mjs → realtime-session.runtime-CxGBk8H-.mjs} +69 -98
- package/dist/.setup/{receive-recovery-DgkX7Qvi.mjs → receive-recovery-eVmK2_hl.mjs} +2 -12
- package/dist/.setup/resolve-allowlist-common-DNSsUQRF.mjs +66 -0
- package/dist/.setup/resolve-channels-UdT38DzU.mjs +173 -0
- package/dist/.setup/{resolve-users-DNrwvunm.mjs → resolve-users-DnCsrXZ_.mjs} +12 -41
- package/dist/.setup/{runtime-CESTexGn.mjs → runtime-CRTkKU1G.mjs} +202 -313
- package/dist/.setup/{runtime-DPcmPST9.mjs → runtime-DPm3gZXk.mjs} +2 -2
- package/dist/.setup/{secret-config-contract-uOE2J7yM.mjs → secret-config-contract-CIsH7R3B.mjs} +9 -18
- package/dist/.setup/{security-audit-D42cp5N7.mjs → security-audit-BFT84Uny.mjs} +1 -2
- package/dist/.setup/security-contract-DNyyjTZZ.mjs +19 -0
- package/dist/.setup/{send-CJk3VP5q.mjs → send-DbILKgcm.mjs} +184 -241
- package/dist/.setup/{send.components-dPljuV24.mjs → send.components-FxOS3CeP.mjs} +47 -63
- package/dist/.setup/{send.outbound-rOboMO_6.mjs → send.outbound-_jx4Xpd3.mjs} +178 -202
- package/dist/.setup/{send.receipt-DVOg2Oaw.mjs → send.receipt-BAlzXd8e.mjs} +33 -109
- package/dist/.setup/{send.shared-C4CN24D9.mjs → send.shared-CjQ4jbMA.mjs} +97 -153
- package/dist/.setup/{sender-identity-AHpUNr72.mjs → sender-identity-BNBvGt1l.mjs} +1 -1
- package/dist/.setup/setup-plugin-api-xfOFmxHP.mjs +3 -0
- package/dist/.setup/{shared-BoBnM5kM.mjs → shared-CestGDpq.mjs} +30 -20
- package/dist/.setup/{subagent-hooks-HH8Uy9cx.mjs → subagent-hooks-CME7dSGf.mjs} +5 -10
- package/dist/.setup/{system-events-Cwxaww8i.mjs → system-events-BwwSDCw4.mjs} +2 -2
- package/dist/.setup/target-parsing-C-HyNxcE.mjs +48 -0
- package/dist/.setup/{target-resolver-CSFoPQ12.mjs → target-resolver-Bse8fuTi.mjs} +11 -27
- package/dist/.setup/targets-DZJjkzwv.mjs +3 -0
- package/dist/.setup/{thread-bindings-DjQCkmsd.mjs → thread-bindings-0hPTSK14.mjs} +61 -52
- package/dist/.setup/{thread-bindings.manager-D2-GYZ5s.mjs → thread-bindings.manager-CdNa6UIs.mjs} +138 -211
- package/dist/.setup/{thread-bindings.session-updates-Bu_CGr_O.mjs → thread-bindings.session-updates-DGSljVf6.mjs} +60 -99
- package/dist/.setup/threading-BKe3E3tp.mjs +246 -0
- package/dist/.setup/{timeouts-pun7VJ02.mjs → timeouts-CuNARfyw.mjs} +10 -18
- package/dist/.setup/{transcripts-source-CaZQnGRH.mjs → transcripts-source-0qQYVu2H.mjs} +50 -368
- package/dist/.setup/{voice-runtime-DDymtIw8.mjs → voice-runtime-QlZJ4sHv.mjs} +166 -322
- package/dist/account-inspect-api.js +1 -1
- package/dist/action-runtime-api.js +1 -1
- package/dist/activities-api.js +77 -120
- package/dist/api.js +19 -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 +1 -1
- package/dist/runtime-api.js +21 -20
- 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/setup-entry.js +1 -1
- package/dist/setup-plugin-api.js +1 -1
- package/dist/src/voice/audio-worker.runtime.js +38 -57
- package/dist/subagent-hooks-api.js +1 -1
- package/dist/transcripts-source-api.js +1 -1
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/crypto.d.ts +2 -2
- package/node_modules/@types/node/dgram.d.ts +1 -1
- package/node_modules/@types/node/package.json +2 -2
- package/node_modules/@types/node/zlib.d.ts +6 -0
- package/node_modules/@types/ws/README.md +1 -1
- package/node_modules/@types/ws/index.d.mts +4 -0
- package/node_modules/@types/ws/index.d.ts +4 -0
- package/node_modules/@types/ws/package.json +3 -3
- package/node_modules/discord-api-types/_generated_/rest/v10/interfaces.d.ts +21 -0
- package/node_modules/discord-api-types/_generated_/rest/v10/interfaces.d.ts.map +1 -1
- package/node_modules/discord-api-types/_generated_/rest/v9/interfaces.d.ts +21 -0
- package/node_modules/discord-api-types/_generated_/rest/v9/interfaces.d.ts.map +1 -1
- package/node_modules/discord-api-types/globals.d.ts +6 -0
- package/node_modules/discord-api-types/globals.d.ts.map +1 -1
- package/node_modules/discord-api-types/globals.js +6 -0
- package/node_modules/discord-api-types/globals.js.map +1 -1
- package/node_modules/discord-api-types/package.json +3 -3
- package/node_modules/discord-api-types/payloads/index.mjs +1 -0
- package/node_modules/discord-api-types/payloads/v10/applicationIdentityProfile.d.ts +207 -0
- package/node_modules/discord-api-types/payloads/v10/applicationIdentityProfile.d.ts.map +1 -0
- package/node_modules/discord-api-types/payloads/v10/applicationIdentityProfile.js +25 -0
- package/node_modules/discord-api-types/payloads/v10/applicationIdentityProfile.js.map +1 -0
- package/node_modules/discord-api-types/payloads/v10/autoModeration.d.ts +1 -1
- package/node_modules/discord-api-types/payloads/v10/autoModeration.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v10/guild.d.ts +27 -23
- package/node_modules/discord-api-types/payloads/v10/guild.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v10/guild.js +26 -22
- package/node_modules/discord-api-types/payloads/v10/guild.js.map +1 -1
- package/node_modules/discord-api-types/payloads/v10/index.d.ts +1 -0
- package/node_modules/discord-api-types/payloads/v10/index.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v10/index.js +1 -0
- package/node_modules/discord-api-types/payloads/v10/index.js.map +1 -1
- package/node_modules/discord-api-types/payloads/v10/index.mjs +1 -0
- package/node_modules/discord-api-types/payloads/v9/applicationIdentityProfile.d.ts +207 -0
- package/node_modules/discord-api-types/payloads/v9/applicationIdentityProfile.d.ts.map +1 -0
- package/node_modules/discord-api-types/payloads/v9/applicationIdentityProfile.js +25 -0
- package/node_modules/discord-api-types/payloads/v9/applicationIdentityProfile.js.map +1 -0
- package/node_modules/discord-api-types/payloads/v9/autoModeration.d.ts +1 -1
- package/node_modules/discord-api-types/payloads/v9/autoModeration.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v9/guild.d.ts +27 -23
- package/node_modules/discord-api-types/payloads/v9/guild.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v9/guild.js +26 -22
- package/node_modules/discord-api-types/payloads/v9/guild.js.map +1 -1
- package/node_modules/discord-api-types/payloads/v9/index.d.ts +1 -0
- package/node_modules/discord-api-types/payloads/v9/index.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v9/index.js +1 -0
- package/node_modules/discord-api-types/payloads/v9/index.js.map +1 -1
- package/node_modules/discord-api-types/payloads/v9/index.mjs +1 -0
- package/node_modules/discord-api-types/rest/common.d.ts +2 -0
- package/node_modules/discord-api-types/rest/common.d.ts.map +1 -1
- package/node_modules/discord-api-types/rest/common.js +2 -0
- package/node_modules/discord-api-types/rest/common.js.map +1 -1
- package/node_modules/discord-api-types/rest/v10/applicationIdentityProfile.d.ts +70 -0
- package/node_modules/discord-api-types/rest/v10/applicationIdentityProfile.d.ts.map +1 -0
- package/node_modules/discord-api-types/rest/v10/applicationIdentityProfile.js +3 -0
- package/node_modules/discord-api-types/rest/v10/applicationIdentityProfile.js.map +1 -0
- package/node_modules/discord-api-types/rest/v10/index.d.ts +1 -0
- package/node_modules/discord-api-types/rest/v10/index.d.ts.map +1 -1
- package/node_modules/discord-api-types/rest/v10/index.js +29 -0
- package/node_modules/discord-api-types/rest/v10/index.js.map +1 -1
- package/node_modules/discord-api-types/rest/v10/interactions.d.ts +4 -2
- package/node_modules/discord-api-types/rest/v10/interactions.d.ts.map +1 -1
- package/node_modules/discord-api-types/rest/v10/user.d.ts +2 -2
- package/node_modules/discord-api-types/rest/v10/user.d.ts.map +1 -1
- package/node_modules/discord-api-types/rest/v9/applicationIdentityProfile.d.ts +70 -0
- package/node_modules/discord-api-types/rest/v9/applicationIdentityProfile.d.ts.map +1 -0
- package/node_modules/discord-api-types/rest/v9/applicationIdentityProfile.js +3 -0
- package/node_modules/discord-api-types/rest/v9/applicationIdentityProfile.js.map +1 -0
- package/node_modules/discord-api-types/rest/v9/index.d.ts +1 -0
- package/node_modules/discord-api-types/rest/v9/index.d.ts.map +1 -1
- package/node_modules/discord-api-types/rest/v9/index.js +29 -0
- package/node_modules/discord-api-types/rest/v9/index.js.map +1 -1
- package/node_modules/discord-api-types/rest/v9/interactions.d.ts +4 -2
- package/node_modules/discord-api-types/rest/v9/interactions.d.ts.map +1 -1
- package/node_modules/discord-api-types/rest/v9/user.d.ts +2 -2
- package/node_modules/discord-api-types/rest/v9/user.d.ts.map +1 -1
- package/node_modules/discord-api-types/v10.mjs +1 -0
- package/node_modules/discord-api-types/v9.mjs +1 -0
- package/node_modules/micromark/dev/lib/compile.d.ts.map +1 -1
- package/node_modules/micromark/dev/lib/compile.js +14 -4
- package/node_modules/micromark/dev/lib/create-tokenizer.d.ts.map +1 -1
- package/node_modules/micromark/dev/lib/create-tokenizer.js +7 -6
- package/node_modules/micromark/dev/lib/initialize/document.js +25 -21
- package/node_modules/micromark/dev/lib/initialize/text.d.ts.map +1 -1
- package/node_modules/micromark/dev/lib/initialize/text.js +10 -6
- package/node_modules/micromark/dev/lib/preprocess.d.ts.map +1 -1
- package/node_modules/micromark/dev/lib/preprocess.js +19 -21
- package/node_modules/micromark/lib/compile.d.ts.map +1 -1
- package/node_modules/micromark/lib/compile.js +37 -29
- package/node_modules/micromark/lib/create-tokenizer.d.ts.map +1 -1
- package/node_modules/micromark/lib/create-tokenizer.js +37 -35
- package/node_modules/micromark/lib/initialize/document.js +21 -13
- package/node_modules/micromark/lib/initialize/text.d.ts.map +1 -1
- package/node_modules/micromark/lib/initialize/text.js +7 -3
- package/node_modules/micromark/lib/preprocess.d.ts.map +1 -1
- package/node_modules/micromark/lib/preprocess.js +16 -19
- package/node_modules/micromark/package.json +2 -15
- package/node_modules/micromark-core-commonmark/dev/lib/attention.js +18 -24
- package/node_modules/micromark-core-commonmark/dev/lib/code-fenced.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/dev/lib/code-fenced.js +1 -43
- package/node_modules/micromark-core-commonmark/dev/lib/code-indented.js +19 -43
- package/node_modules/micromark-core-commonmark/dev/lib/heading-atx.js +2 -6
- package/node_modules/micromark-core-commonmark/dev/lib/html-flow.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/dev/lib/html-flow.js +2 -53
- package/node_modules/micromark-core-commonmark/dev/lib/label-end.js +14 -12
- package/node_modules/micromark-core-commonmark/dev/lib/label-start-image.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/dev/lib/label-start-image.js +14 -5
- package/node_modules/micromark-core-commonmark/dev/lib/label-start-link.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/dev/lib/label-start-link.js +14 -5
- package/node_modules/micromark-core-commonmark/dev/lib/partial-non-lazy-continuation.d.ts +4 -0
- package/node_modules/micromark-core-commonmark/dev/lib/partial-non-lazy-continuation.d.ts.map +1 -0
- package/node_modules/micromark-core-commonmark/dev/lib/partial-non-lazy-continuation.js +67 -0
- package/node_modules/micromark-core-commonmark/dev/lib/setext-underline.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/dev/lib/setext-underline.js +8 -5
- package/node_modules/micromark-core-commonmark/lib/attention.js +14 -24
- package/node_modules/micromark-core-commonmark/lib/code-fenced.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/lib/code-fenced.js +1 -39
- package/node_modules/micromark-core-commonmark/lib/code-indented.js +11 -29
- package/node_modules/micromark-core-commonmark/lib/heading-atx.js +2 -6
- package/node_modules/micromark-core-commonmark/lib/html-flow.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/lib/html-flow.js +2 -51
- package/node_modules/micromark-core-commonmark/lib/label-end.js +11 -10
- package/node_modules/micromark-core-commonmark/lib/label-start-image.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/lib/label-start-image.js +11 -3
- package/node_modules/micromark-core-commonmark/lib/label-start-link.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/lib/label-start-link.js +11 -3
- package/node_modules/micromark-core-commonmark/lib/partial-non-lazy-continuation.d.ts +4 -0
- package/node_modules/micromark-core-commonmark/lib/partial-non-lazy-continuation.d.ts.map +1 -0
- package/node_modules/micromark-core-commonmark/lib/partial-non-lazy-continuation.js +61 -0
- package/node_modules/micromark-core-commonmark/lib/setext-underline.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/lib/setext-underline.js +7 -5
- package/node_modules/micromark-core-commonmark/package.json +4 -16
- package/node_modules/micromark-factory-space/dev/index.d.ts +24 -1
- package/node_modules/micromark-factory-space/dev/index.d.ts.map +1 -1
- package/node_modules/micromark-factory-space/dev/index.js +58 -3
- package/node_modules/micromark-factory-space/index.d.ts +24 -1
- package/node_modules/micromark-factory-space/index.d.ts.map +1 -1
- package/node_modules/micromark-factory-space/index.js +55 -3
- package/node_modules/micromark-factory-space/package.json +1 -10
- package/node_modules/micromark-factory-space/readme.md +25 -25
- package/node_modules/micromark-util-edit-map/dev/index.d.ts +78 -0
- package/node_modules/micromark-util-edit-map/dev/index.d.ts.map +1 -0
- package/node_modules/micromark-util-edit-map/dev/index.js +237 -0
- package/node_modules/micromark-util-edit-map/index.d.ts +78 -0
- package/node_modules/micromark-util-edit-map/index.d.ts.map +1 -0
- package/node_modules/micromark-util-edit-map/index.js +225 -0
- package/node_modules/micromark-util-edit-map/license +22 -0
- package/node_modules/micromark-util-edit-map/package.json +48 -0
- package/node_modules/micromark-util-edit-map/readme.md +234 -0
- package/node_modules/micromark-util-types/index.d.ts +6 -3
- package/node_modules/micromark-util-types/package.json +2 -36
- package/node_modules/ws/lib/websocket.js +17 -3
- package/node_modules/ws/package.json +1 -1
- package/openclaw.plugin.json +3 -6
- package/package.json +7 -12
- package/dist/.setup/account-inspect-DsER5ILV.mjs +0 -45
- package/dist/.setup/provider.runtime-CZ51OIgD.mjs +0 -2
- package/dist/.setup/resolve-allowlist-common-BUyU3C-T.mjs +0 -27
- package/dist/.setup/resolve-channels-DA6QlhZN.mjs +0 -246
- package/dist/.setup/security-contract-DSHk7I2w.mjs +0 -26
- package/dist/.setup/setup-plugin-api-BVlCz3fm.mjs +0 -3
- package/dist/.setup/targets-bqXQENmX.mjs +0 -3
- package/dist/control-ui/2afbdab1d3aa65a789d8a3eba666f4b1ec5df07073538fe30d6cf32093a1fb2d/index.js +0 -1
package/dist/.setup/{thread-bindings.manager-D2-GYZ5s.mjs → thread-bindings.manager-CdNa6UIs.mjs}
RENAMED
|
@@ -1,34 +1,33 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.mjs";
|
|
2
|
-
import { A as isDiscordThreadChannelType } from "./allow-list-
|
|
3
|
-
import { P as createDiscordRestClient } from "./send.shared-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
2
|
+
import { A as isDiscordThreadChannelType } from "./allow-list-B_ToXtew.mjs";
|
|
3
|
+
import { P as createDiscordRestClient } from "./send.shared-CjQ4jbMA.mjs";
|
|
4
|
+
import { W as withDiscordRequestAuthority, dt as getChannel, tt as createChannelWebhook } from "./discord-BGqgx-yd.mjs";
|
|
5
|
+
import { p as canFallbackDiscordWebhookSend } from "./send.receipt-BAlzXd8e.mjs";
|
|
6
|
+
import { n as resolveDiscordChannelId } from "./target-parsing-C-HyNxcE.mjs";
|
|
7
|
+
import { c as sendWebhookMessageDiscord, u as createThreadDiscord } from "./send-DbILKgcm.mjs";
|
|
8
|
+
import { t as sendMessageDiscord } from "./send.outbound-_jx4Xpd3.mjs";
|
|
9
|
+
import { A as resolveBindingRecordKey, C as getThreadBindingToken, D as rememberReusableWebhook, E as refreshUnboundThreadWebhookIdentity, F as resolveThreadBindingMaxAgeMs$1, I as shouldDefaultPersist, L as toBindingRecordKey, M as resolveThreadBindingIdleTimeoutMs$1, O as rememberThreadBindingToken, R as toReusableWebhookKey, S as forgetThreadBindingToken, T as normalizeThreadBindingDurationMs, _ as MANAGERS_BY_ACCOUNT_ID, b as THREAD_BINDING_TOUCH_PERSIST_MIN_INTERVAL_MS, c as drainThreadBindingAccountOperations, d as runThreadBindingAccountOperation, f as runThreadBindingMutation, g as BINDINGS_BY_THREAD_ID, h as updateBindingRecordSync, j as resolvePreparedThreadBindingLifecycle, k as resolveBindingIdsForSession, l as drainThreadBindingMutations, m as snapshotThreadBindingMetadata, p as shouldPersistAnyBindingState, s as commitBindingRecord, v as PERSIST_BY_ACCOUNT_ID, w as normalizeTargetKind, x as ensureBindingsLoadedAsync, y as REUSABLE_WEBHOOKS_BY_ACCOUNT_CHANNEL } from "./thread-bindings.session-updates-DGSljVf6.mjs";
|
|
10
|
+
import { n as resolveDiscordChannelInfoSafe, t as resolveDiscordChannelIdSafe } from "./channel-access-DasWY_OV.mjs";
|
|
10
11
|
import { createSubsystemLogger, logVerbose } from "openclaw/plugin-sdk/runtime-env";
|
|
11
|
-
import { asOptionalObjectRecord, normalizeOptionalString, normalizeOptionalStringifiedId } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
12
12
|
import { normalizeAccountId } from "openclaw/plugin-sdk/routing";
|
|
13
|
+
import { normalizeOptionalString, normalizeOptionalStringifiedId } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
13
14
|
import { getRuntimeConfigSnapshot } from "openclaw/plugin-sdk/runtime-config-snapshot";
|
|
14
15
|
import { parseStrictNonNegativeInteger as parseStrictNonNegativeInteger$1 } from "openclaw/plugin-sdk/number-runtime";
|
|
15
16
|
import { SYSTEM_MARK } from "openclaw/plugin-sdk/text-chunking";
|
|
16
17
|
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
17
|
-
import { registerSessionBindingAdapter,
|
|
18
|
+
import { registerSessionBindingAdapter, resolveThreadBindingFarewellText, resolveThreadBindingThreadName, unregisterSessionBindingAdapter } from "openclaw/plugin-sdk/conversation-runtime";
|
|
19
|
+
import { createAccountScopedBindingAdapter, projectThreadBindingRecord } from "openclaw/plugin-sdk/thread-bindings-session-runtime";
|
|
18
20
|
import { resolveSessionAgentIdStrict } from "openclaw/plugin-sdk/agent-scope-runtime";
|
|
19
21
|
//#region extensions/discord/src/monitor/thread-bindings.persona.ts
|
|
20
22
|
const THREAD_BINDING_PERSONA_MAX_CHARS = 80;
|
|
21
23
|
function normalizePersonaLabel(value) {
|
|
22
|
-
|
|
23
|
-
return value.replace(/\s+/g, " ").trim() || void 0;
|
|
24
|
+
return value ? value.replace(/\s+/g, " ").trim() || void 0 : void 0;
|
|
24
25
|
}
|
|
25
26
|
function resolveThreadBindingPersona(params) {
|
|
26
27
|
const base = normalizePersonaLabel(params.label) || normalizePersonaLabel(params.agentId) || "agent";
|
|
27
28
|
return truncateUtf16Safe(`${SYSTEM_MARK} ${base}`, THREAD_BINDING_PERSONA_MAX_CHARS);
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
-
return resolveThreadBindingPersona(record);
|
|
31
|
-
}
|
|
30
|
+
const resolveThreadBindingPersonaFromRecord = resolveThreadBindingPersona;
|
|
32
31
|
//#endregion
|
|
33
32
|
//#region extensions/discord/src/monitor/thread-bindings.types.ts
|
|
34
33
|
const THREAD_BINDINGS_SWEEP_INTERVAL_MS = 12e4;
|
|
@@ -36,9 +35,6 @@ const DEFAULT_THREAD_BINDING_IDLE_TIMEOUT_MS = 864e5;
|
|
|
36
35
|
//#endregion
|
|
37
36
|
//#region extensions/discord/src/monitor/thread-bindings.discord-api.ts
|
|
38
37
|
const log = createSubsystemLogger("discord/thread-bindings");
|
|
39
|
-
function buildThreadTarget(threadId) {
|
|
40
|
-
return /^(channel:|user:)/i.test(threadId) ? threadId : `channel:${threadId}`;
|
|
41
|
-
}
|
|
42
38
|
function isThreadArchived(raw) {
|
|
43
39
|
if (!raw || typeof raw !== "object") return false;
|
|
44
40
|
const asRecord = raw;
|
|
@@ -55,23 +51,14 @@ function normalizeDiscordBindingChannelId(raw) {
|
|
|
55
51
|
}
|
|
56
52
|
function summarizeDiscordError(err) {
|
|
57
53
|
if (err instanceof Error) return err.message;
|
|
58
|
-
if (typeof err === "string") return err;
|
|
59
|
-
if (typeof err === "number" || typeof err === "boolean" || typeof err === "bigint" || typeof err === "symbol") return String(err);
|
|
54
|
+
if (typeof err === "string" || typeof err === "number" || typeof err === "boolean" || typeof err === "bigint" || typeof err === "symbol") return String(err);
|
|
60
55
|
return "error";
|
|
61
56
|
}
|
|
62
|
-
function extractDiscordErrorStatus(err) {
|
|
63
|
-
if (!err || typeof err !== "object") return;
|
|
64
|
-
const candidate = err;
|
|
65
|
-
return parseStrictNonNegativeInteger$1(candidate.status) ?? parseStrictNonNegativeInteger$1(candidate.statusCode) ?? parseStrictNonNegativeInteger$1(candidate.response?.status);
|
|
66
|
-
}
|
|
67
|
-
function extractDiscordErrorCode(err) {
|
|
68
|
-
if (!err || typeof err !== "object") return;
|
|
69
|
-
const candidate = err;
|
|
70
|
-
return parseStrictNonNegativeInteger$1(candidate.code) ?? parseStrictNonNegativeInteger$1(candidate.rawError?.code) ?? parseStrictNonNegativeInteger$1(candidate.body?.code) ?? parseStrictNonNegativeInteger$1(candidate.response?.body?.code) ?? parseStrictNonNegativeInteger$1(candidate.response?.data?.code);
|
|
71
|
-
}
|
|
72
57
|
function isDiscordThreadGoneError(err) {
|
|
73
|
-
if (
|
|
74
|
-
const
|
|
58
|
+
if (!err || typeof err !== "object") return false;
|
|
59
|
+
const candidate = err;
|
|
60
|
+
if ((parseStrictNonNegativeInteger$1(candidate.code) ?? parseStrictNonNegativeInteger$1(candidate.rawError?.code) ?? parseStrictNonNegativeInteger$1(candidate.body?.code) ?? parseStrictNonNegativeInteger$1(candidate.response?.body?.code) ?? parseStrictNonNegativeInteger$1(candidate.response?.data?.code)) === 10003) return true;
|
|
61
|
+
const status = parseStrictNonNegativeInteger$1(candidate.status) ?? parseStrictNonNegativeInteger$1(candidate.statusCode) ?? parseStrictNonNegativeInteger$1(candidate.response?.status);
|
|
75
62
|
return status === 404 || status === 403;
|
|
76
63
|
}
|
|
77
64
|
async function maybeSendBindingMessage(params) {
|
|
@@ -104,7 +91,9 @@ async function maybeSendBindingMessage(params) {
|
|
|
104
91
|
try {
|
|
105
92
|
await withDiscordRequestAuthority(assertCurrent, () => {
|
|
106
93
|
assertCurrent?.();
|
|
107
|
-
|
|
94
|
+
const threadId = record.threadId;
|
|
95
|
+
const target = /^(channel:|user:)/i.test(threadId) ? threadId : `channel:${threadId}`;
|
|
96
|
+
return sendMessageDiscord(target, text, {
|
|
108
97
|
cfg: params.cfg,
|
|
109
98
|
accountId: record.accountId
|
|
110
99
|
});
|
|
@@ -186,7 +175,7 @@ async function createThreadForBinding(params) {
|
|
|
186
175
|
token: params.token,
|
|
187
176
|
...assertCreateAllowed ? { assertCreateAllowed } : {}
|
|
188
177
|
});
|
|
189
|
-
return
|
|
178
|
+
return normalizeOptionalString(created?.id) ?? null;
|
|
190
179
|
} catch (err) {
|
|
191
180
|
logVerbose(`discord thread binding auto-thread create failed for ${params.channelId}: ${summarizeDiscordError(err)}`);
|
|
192
181
|
return null;
|
|
@@ -194,44 +183,32 @@ async function createThreadForBinding(params) {
|
|
|
194
183
|
}
|
|
195
184
|
//#endregion
|
|
196
185
|
//#region extensions/discord/src/monitor/thread-bindings.session-adapter.ts
|
|
197
|
-
function toSessionBindingRecord(record, defaults) {
|
|
198
|
-
const bindingId = resolveBindingRecordKey({
|
|
199
|
-
accountId: record.accountId,
|
|
200
|
-
threadId: record.threadId
|
|
201
|
-
}) ?? `${record.accountId}:${record.threadId}`;
|
|
202
|
-
const lifecycle = resolvePreparedThreadBindingLifecycle({
|
|
203
|
-
record,
|
|
204
|
-
...defaults
|
|
205
|
-
});
|
|
206
|
-
return {
|
|
207
|
-
bindingId,
|
|
208
|
-
targetSessionKey: record.targetSessionKey,
|
|
209
|
-
targetKind: record.targetKind === "subagent" ? "subagent" : "session",
|
|
210
|
-
conversation: {
|
|
211
|
-
channel: "discord",
|
|
212
|
-
accountId: record.accountId,
|
|
213
|
-
conversationId: record.threadId,
|
|
214
|
-
parentConversationId: record.channelId
|
|
215
|
-
},
|
|
216
|
-
status: "active",
|
|
217
|
-
boundAt: record.boundAt,
|
|
218
|
-
expiresAt: lifecycle.expiresAt,
|
|
219
|
-
metadata: {
|
|
220
|
-
agentId: record.agentId,
|
|
221
|
-
label: record.label,
|
|
222
|
-
webhookId: record.webhookId,
|
|
223
|
-
webhookToken: record.webhookToken,
|
|
224
|
-
boundBy: record.boundBy,
|
|
225
|
-
lastActivityAt: record.lastActivityAt,
|
|
226
|
-
idleTimeoutMs: lifecycle.idleTimeoutMs,
|
|
227
|
-
maxAgeMs: lifecycle.maxAgeMs,
|
|
228
|
-
...record.metadata
|
|
229
|
-
}
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
186
|
function createThreadBindingSessionAdapter(params) {
|
|
233
|
-
const serializeBinding = (
|
|
234
|
-
|
|
187
|
+
const serializeBinding = (record) => {
|
|
188
|
+
const defaults = params.defaults;
|
|
189
|
+
const bindingId = resolveBindingRecordKey(record) ?? `${record.accountId}:${record.threadId}`;
|
|
190
|
+
const lifecycle = resolvePreparedThreadBindingLifecycle({
|
|
191
|
+
record,
|
|
192
|
+
...defaults
|
|
193
|
+
});
|
|
194
|
+
return projectThreadBindingRecord(record, {
|
|
195
|
+
conversation: {
|
|
196
|
+
channel: "discord",
|
|
197
|
+
conversationId: record.threadId,
|
|
198
|
+
parentConversationId: record.channelId
|
|
199
|
+
},
|
|
200
|
+
bindingId,
|
|
201
|
+
targetKind: record.targetKind === "subagent" ? "subagent" : "session",
|
|
202
|
+
lifecycle,
|
|
203
|
+
metadata: (lifecycleMetadata) => ({
|
|
204
|
+
...lifecycleMetadata,
|
|
205
|
+
webhookId: record.webhookId,
|
|
206
|
+
webhookToken: record.webhookToken,
|
|
207
|
+
...record.metadata
|
|
208
|
+
})
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
return createAccountScopedBindingAdapter({
|
|
235
212
|
channel: "discord",
|
|
236
213
|
accountId: params.accountId,
|
|
237
214
|
capabilities: { placements: ["current", "child"] },
|
|
@@ -241,19 +218,12 @@ function createThreadBindingSessionAdapter(params) {
|
|
|
241
218
|
const targetSessionKey = input.targetSessionKey.trim();
|
|
242
219
|
if (!targetSessionKey) return null;
|
|
243
220
|
const conversationId = normalizeOptionalString(input.conversation.conversationId) ?? "";
|
|
244
|
-
const
|
|
245
|
-
const metadata =
|
|
221
|
+
const createThread = input.placement === "child";
|
|
222
|
+
const metadata = snapshotThreadBindingMetadata(input) ?? {};
|
|
246
223
|
const targetKind = input.targetKind === "subagent" ? "subagent" : "acp";
|
|
247
|
-
const
|
|
248
|
-
const threadName = normalizeOptionalString(metadata.threadName);
|
|
249
|
-
const introText = normalizeOptionalString(metadata.introText);
|
|
250
|
-
const boundBy = normalizeOptionalString(metadata.boundBy);
|
|
251
|
-
const agentId = normalizeOptionalString(metadata.agentId);
|
|
252
|
-
let threadId;
|
|
224
|
+
const threadId = createThread ? void 0 : conversationId || void 0;
|
|
253
225
|
let channelId;
|
|
254
|
-
|
|
255
|
-
if (placement === "child") {
|
|
256
|
-
createThread = true;
|
|
226
|
+
if (createThread) {
|
|
257
227
|
channelId = normalizeDiscordBindingChannelId(input.conversation.parentConversationId) ?? void 0;
|
|
258
228
|
if (!channelId && conversationId) channelId = await resolveChannelIdForBinding({
|
|
259
229
|
cfg: params.resolveCurrentCfg(),
|
|
@@ -261,69 +231,45 @@ function createThreadBindingSessionAdapter(params) {
|
|
|
261
231
|
token: params.resolveCurrentToken(),
|
|
262
232
|
threadId: conversationId
|
|
263
233
|
}) ?? void 0;
|
|
264
|
-
}
|
|
234
|
+
}
|
|
265
235
|
const bound = await params.manager.bindTarget({
|
|
266
236
|
threadId,
|
|
267
237
|
channelId,
|
|
268
238
|
createThread,
|
|
269
|
-
threadName,
|
|
239
|
+
threadName: normalizeOptionalString(metadata.threadName),
|
|
270
240
|
targetKind,
|
|
271
241
|
targetSessionKey,
|
|
272
|
-
agentId,
|
|
273
|
-
label,
|
|
274
|
-
boundBy,
|
|
275
|
-
introText,
|
|
242
|
+
agentId: normalizeOptionalString(metadata.agentId),
|
|
243
|
+
label: normalizeOptionalString(metadata.label),
|
|
244
|
+
boundBy: normalizeOptionalString(metadata.boundBy),
|
|
245
|
+
introText: normalizeOptionalString(metadata.introText),
|
|
276
246
|
metadata,
|
|
277
247
|
...assertCurrent ? { assertCurrent } : {}
|
|
278
248
|
});
|
|
279
249
|
return bound ? serializeBinding(bound) : null;
|
|
280
250
|
},
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
},
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
if (!threadId) return;
|
|
304
|
-
await params.manager.touchThread({
|
|
305
|
-
threadId,
|
|
306
|
-
at,
|
|
307
|
-
persist: true
|
|
308
|
-
});
|
|
309
|
-
},
|
|
310
|
-
unbind: async (input) => {
|
|
311
|
-
if (input.targetSessionKey?.trim()) return (await params.manager.unbindBySessionKey({
|
|
312
|
-
targetSessionKey: input.targetSessionKey,
|
|
313
|
-
reason: input.reason
|
|
314
|
-
})).map(serializeBinding);
|
|
315
|
-
const threadId = resolveThreadBindingConversationIdFromBindingId({
|
|
316
|
-
accountId: params.accountId,
|
|
317
|
-
bindingId: input.bindingId
|
|
318
|
-
});
|
|
319
|
-
if (!threadId) return [];
|
|
320
|
-
const removed = await params.manager.unbindThread({
|
|
321
|
-
threadId,
|
|
322
|
-
reason: input.reason
|
|
323
|
-
});
|
|
324
|
-
return removed ? [serializeBinding(removed)] : [];
|
|
325
|
-
}
|
|
326
|
-
};
|
|
251
|
+
project: serializeBinding,
|
|
252
|
+
listBySessionKey: params.manager.listBySessionKey,
|
|
253
|
+
getByConversation: (ref) => params.manager.getByThreadId(ref.conversationId),
|
|
254
|
+
touchConversation: (threadId, at) => params.manager.touchThreadSync({
|
|
255
|
+
threadId,
|
|
256
|
+
at,
|
|
257
|
+
persist: true
|
|
258
|
+
}),
|
|
259
|
+
touchConversationAsync: (threadId, at) => params.manager.touchThread({
|
|
260
|
+
threadId,
|
|
261
|
+
at,
|
|
262
|
+
persist: true
|
|
263
|
+
}),
|
|
264
|
+
unbindConversation: (threadId, reason) => params.manager.unbindThread({
|
|
265
|
+
threadId,
|
|
266
|
+
reason
|
|
267
|
+
}),
|
|
268
|
+
unbindBySessionKey: (targetSessionKey, reason) => params.manager.unbindBySessionKey({
|
|
269
|
+
targetSessionKey,
|
|
270
|
+
reason
|
|
271
|
+
})
|
|
272
|
+
});
|
|
327
273
|
}
|
|
328
274
|
/** Disabled bindings have a live empty owner; retirement still makes that owner unavailable. */
|
|
329
275
|
function createNoopThreadBindingManager(accountIdRaw) {
|
|
@@ -372,6 +318,15 @@ function isDirectConversationBindingId(value) {
|
|
|
372
318
|
const trimmed = normalizeOptionalString(value);
|
|
373
319
|
return Boolean(trimmed && /^(user:|channel:)/i.test(trimmed));
|
|
374
320
|
}
|
|
321
|
+
function normalizeTouchTimestamp(at) {
|
|
322
|
+
return typeof at === "number" && Number.isFinite(at) ? Math.max(0, Math.floor(at)) : Date.now();
|
|
323
|
+
}
|
|
324
|
+
function touchBindingRecord(record, at) {
|
|
325
|
+
return {
|
|
326
|
+
...record,
|
|
327
|
+
lastActivityAt: Math.max(record.lastActivityAt || 0, at)
|
|
328
|
+
};
|
|
329
|
+
}
|
|
375
330
|
async function createThreadBindingManager(input) {
|
|
376
331
|
const params = { ...input };
|
|
377
332
|
await ensureBindingsLoadedAsync();
|
|
@@ -385,17 +340,11 @@ async function createThreadBindingManager(input) {
|
|
|
385
340
|
function createLoadedThreadBindingManager(params) {
|
|
386
341
|
const accountId = normalizeAccountId(params.accountId);
|
|
387
342
|
const existing = MANAGERS_BY_ACCOUNT_ID.get(accountId);
|
|
388
|
-
if (existing) {
|
|
389
|
-
rememberThreadBindingToken({
|
|
390
|
-
accountId,
|
|
391
|
-
token: params.token
|
|
392
|
-
});
|
|
393
|
-
return existing;
|
|
394
|
-
}
|
|
395
343
|
rememberThreadBindingToken({
|
|
396
344
|
accountId,
|
|
397
345
|
token: params.token
|
|
398
346
|
});
|
|
347
|
+
if (existing) return existing;
|
|
399
348
|
const persist = params.persist ?? shouldDefaultPersist();
|
|
400
349
|
PERSIST_BY_ACCOUNT_ID.set(accountId, persist);
|
|
401
350
|
const idleTimeoutMs = normalizeThreadBindingDurationMs(params.idleTimeoutMs, DEFAULT_THREAD_BINDING_IDLE_TIMEOUT_MS);
|
|
@@ -403,6 +352,17 @@ function createLoadedThreadBindingManager(params) {
|
|
|
403
352
|
const resolveCurrentCfg = () => getRuntimeConfigSnapshot() ?? params.cfg;
|
|
404
353
|
const resolveCurrentToken = () => getThreadBindingToken(accountId) ?? params.token;
|
|
405
354
|
const getCurrentBinding = (threadId) => MANAGERS_BY_ACCOUNT_ID.get(accountId) === manager ? manager.getByThreadId(threadId) : void 0;
|
|
355
|
+
const getBinding = (threadId) => {
|
|
356
|
+
const bindingKey = resolveBindingRecordKey({
|
|
357
|
+
accountId,
|
|
358
|
+
threadId
|
|
359
|
+
});
|
|
360
|
+
const record = bindingKey ? BINDINGS_BY_THREAD_ID.get(bindingKey) : void 0;
|
|
361
|
+
return bindingKey && record?.accountId === accountId ? {
|
|
362
|
+
bindingKey,
|
|
363
|
+
record
|
|
364
|
+
} : void 0;
|
|
365
|
+
};
|
|
406
366
|
let stopping = false;
|
|
407
367
|
let stopPromise;
|
|
408
368
|
let sweepPromise;
|
|
@@ -423,7 +383,6 @@ function createLoadedThreadBindingManager(params) {
|
|
|
423
383
|
let sweepTimer = null;
|
|
424
384
|
const runSweepOnce = async () => {
|
|
425
385
|
const bindings = manager.listBindings();
|
|
426
|
-
if (bindings.length === 0) return;
|
|
427
386
|
let rest = null;
|
|
428
387
|
for (const snapshotBinding of bindings) {
|
|
429
388
|
const binding = getCurrentBinding(snapshotBinding.threadId);
|
|
@@ -451,9 +410,8 @@ function createLoadedThreadBindingManager(params) {
|
|
|
451
410
|
}
|
|
452
411
|
if (isDirectConversationBindingId(binding.threadId)) continue;
|
|
453
412
|
if (!rest) try {
|
|
454
|
-
const cfg = resolveCurrentCfg();
|
|
455
413
|
rest = createDiscordRestClient({
|
|
456
|
-
cfg,
|
|
414
|
+
cfg: resolveCurrentCfg(),
|
|
457
415
|
accountId,
|
|
458
416
|
token: resolveCurrentToken()
|
|
459
417
|
}).rest;
|
|
@@ -464,7 +422,7 @@ function createLoadedThreadBindingManager(params) {
|
|
|
464
422
|
const channel = await getChannel(rest, binding.threadId);
|
|
465
423
|
if (getCurrentBinding(binding.threadId) !== binding) continue;
|
|
466
424
|
if (!channel || typeof channel !== "object") {
|
|
467
|
-
logVerbose(`discord thread binding sweep
|
|
425
|
+
logVerbose(`discord thread binding sweep check returned invalid payload for ${binding.threadId}`);
|
|
468
426
|
continue;
|
|
469
427
|
}
|
|
470
428
|
if (isThreadArchived(channel)) await manager.unbindThread({
|
|
@@ -485,37 +443,36 @@ function createLoadedThreadBindingManager(params) {
|
|
|
485
443
|
});
|
|
486
444
|
continue;
|
|
487
445
|
}
|
|
488
|
-
logVerbose(`discord thread binding sweep
|
|
446
|
+
logVerbose(`discord thread binding sweep check failed for ${binding.threadId}: ${summarizeDiscordError(err)}`);
|
|
489
447
|
}
|
|
490
448
|
}
|
|
491
449
|
};
|
|
492
450
|
const unbindThread = async (unbindParams) => {
|
|
493
|
-
const
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
});
|
|
497
|
-
if (!bindingKey) return null;
|
|
498
|
-
const existingLocal = BINDINGS_BY_THREAD_ID.get(bindingKey);
|
|
499
|
-
if (!existingLocal || existingLocal.accountId !== accountId || unbindParams.expected && existingLocal !== unbindParams.expected) return null;
|
|
451
|
+
const binding = getBinding(unbindParams.threadId);
|
|
452
|
+
if (!binding || unbindParams.expected && binding.record !== unbindParams.expected) return null;
|
|
453
|
+
const { bindingKey, record: existingLocal } = binding;
|
|
500
454
|
await commitBindingRecord({
|
|
501
455
|
bindingKey,
|
|
502
456
|
previous: existingLocal,
|
|
503
457
|
next: null,
|
|
504
458
|
persist: unbindParams.persist ?? persist,
|
|
505
|
-
assertCurrent:
|
|
459
|
+
assertCurrent: () => {
|
|
460
|
+
assertManagerCurrent();
|
|
461
|
+
unbindParams.assertCurrent?.();
|
|
462
|
+
}
|
|
506
463
|
});
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
return removed;
|
|
464
|
+
manager.notifyUnbound(existingLocal, unbindParams);
|
|
465
|
+
return existingLocal;
|
|
510
466
|
};
|
|
511
467
|
const manager = {
|
|
512
468
|
accountId,
|
|
513
469
|
isStopping: () => stopping,
|
|
514
470
|
notifyUnbound: (removed, notification) => {
|
|
515
471
|
refreshUnboundThreadWebhookIdentity(removed);
|
|
516
|
-
if (notification.sendFarewell !== false) {
|
|
517
|
-
|
|
518
|
-
|
|
472
|
+
if (notification.sendFarewell !== false) maybeSendBindingMessage({
|
|
473
|
+
cfg: resolveCurrentCfg(),
|
|
474
|
+
record: removed,
|
|
475
|
+
text: resolveThreadBindingFarewellText({
|
|
519
476
|
reason: notification.reason,
|
|
520
477
|
farewellText: notification.farewellText,
|
|
521
478
|
idleTimeoutMs: resolveThreadBindingIdleTimeoutMs$1({
|
|
@@ -526,36 +483,18 @@ function createLoadedThreadBindingManager(params) {
|
|
|
526
483
|
record: removed,
|
|
527
484
|
defaultMaxAgeMs: maxAgeMs
|
|
528
485
|
})
|
|
529
|
-
})
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
record: removed,
|
|
533
|
-
text: farewell,
|
|
534
|
-
preferWebhook: false
|
|
535
|
-
});
|
|
536
|
-
}
|
|
486
|
+
}),
|
|
487
|
+
preferWebhook: false
|
|
488
|
+
});
|
|
537
489
|
},
|
|
538
490
|
getIdleTimeoutMs: () => idleTimeoutMs,
|
|
539
491
|
getMaxAgeMs: () => maxAgeMs,
|
|
540
|
-
getByThreadId: (threadId) =>
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
const entry = BINDINGS_BY_THREAD_ID.get(key);
|
|
547
|
-
if (!entry || entry.accountId !== accountId) return;
|
|
548
|
-
return entry;
|
|
549
|
-
},
|
|
550
|
-
getBySessionKey: (targetSessionKey) => {
|
|
551
|
-
return manager.listBySessionKey(targetSessionKey)[0];
|
|
552
|
-
},
|
|
553
|
-
listBySessionKey: (targetSessionKey) => {
|
|
554
|
-
return resolveBindingIdsForSession({
|
|
555
|
-
targetSessionKey,
|
|
556
|
-
accountId
|
|
557
|
-
}).map((bindingKey) => BINDINGS_BY_THREAD_ID.get(bindingKey)).filter((entry) => Boolean(entry));
|
|
558
|
-
},
|
|
492
|
+
getByThreadId: (threadId) => getBinding(threadId)?.record,
|
|
493
|
+
getBySessionKey: (targetSessionKey) => manager.listBySessionKey(targetSessionKey)[0],
|
|
494
|
+
listBySessionKey: (targetSessionKey) => resolveBindingIdsForSession({
|
|
495
|
+
targetSessionKey,
|
|
496
|
+
accountId
|
|
497
|
+
}).map((bindingKey) => BINDINGS_BY_THREAD_ID.get(bindingKey)).filter((entry) => Boolean(entry)),
|
|
559
498
|
listBindings: () => [...BINDINGS_BY_THREAD_ID.values()].filter((entry) => entry.accountId === accountId),
|
|
560
499
|
touchThreadSync: (input) => {
|
|
561
500
|
assertManagerCurrent();
|
|
@@ -565,13 +504,10 @@ function createLoadedThreadBindingManager(params) {
|
|
|
565
504
|
threadId: input.threadId
|
|
566
505
|
});
|
|
567
506
|
if (!key) return null;
|
|
568
|
-
const at =
|
|
507
|
+
const at = normalizeTouchTimestamp(input.at);
|
|
569
508
|
return updateBindingRecordSync({
|
|
570
509
|
bindingKey: key,
|
|
571
|
-
transform: (record) => (
|
|
572
|
-
...record,
|
|
573
|
-
lastActivityAt: Math.max(record.lastActivityAt || 0, at)
|
|
574
|
-
}),
|
|
510
|
+
transform: (record) => touchBindingRecord(record, at),
|
|
575
511
|
persist: (input.persist ?? persist) && shouldPersistAnyBindingState(),
|
|
576
512
|
minIntervalMs: THREAD_BINDING_TOUCH_PERSIST_MIN_INTERVAL_MS
|
|
577
513
|
});
|
|
@@ -579,22 +515,15 @@ function createLoadedThreadBindingManager(params) {
|
|
|
579
515
|
touchThread: (input) => {
|
|
580
516
|
const touchParams = {
|
|
581
517
|
...input,
|
|
582
|
-
at:
|
|
518
|
+
at: normalizeTouchTimestamp(input.at)
|
|
583
519
|
};
|
|
584
520
|
return mutate(async () => {
|
|
585
|
-
const
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
if (!key) return null;
|
|
590
|
-
const existingResult = BINDINGS_BY_THREAD_ID.get(key);
|
|
591
|
-
if (!existingResult || existingResult.accountId !== accountId) return null;
|
|
592
|
-
const nextRecord = {
|
|
593
|
-
...existingResult,
|
|
594
|
-
lastActivityAt: Math.max(existingResult.lastActivityAt || 0, touchParams.at)
|
|
595
|
-
};
|
|
521
|
+
const binding = getBinding(touchParams.threadId);
|
|
522
|
+
if (!binding) return null;
|
|
523
|
+
const { bindingKey, record: existingResult } = binding;
|
|
524
|
+
const nextRecord = touchBindingRecord(existingResult, touchParams.at);
|
|
596
525
|
await commitBindingRecord({
|
|
597
|
-
bindingKey
|
|
526
|
+
bindingKey,
|
|
598
527
|
previous: existingResult,
|
|
599
528
|
next: nextRecord,
|
|
600
529
|
persist: (touchParams.persist ?? persist) && shouldPersistAnyBindingState(),
|
|
@@ -607,7 +536,7 @@ function createLoadedThreadBindingManager(params) {
|
|
|
607
536
|
bindTarget: async (input) => {
|
|
608
537
|
const bindParams = {
|
|
609
538
|
...input,
|
|
610
|
-
metadata:
|
|
539
|
+
metadata: snapshotThreadBindingMetadata(input)
|
|
611
540
|
};
|
|
612
541
|
return runOwnedMutation(async () => {
|
|
613
542
|
const assertCurrent = bindParams.assertCurrent;
|
|
@@ -715,7 +644,7 @@ function createLoadedThreadBindingManager(params) {
|
|
|
715
644
|
}
|
|
716
645
|
}));
|
|
717
646
|
const introText = bindParams.introText?.trim();
|
|
718
|
-
if (introText
|
|
647
|
+
if (introText) maybeSendBindingMessage({
|
|
719
648
|
cfg,
|
|
720
649
|
record,
|
|
721
650
|
text: introText,
|
|
@@ -740,7 +669,6 @@ function createLoadedThreadBindingManager(params) {
|
|
|
740
669
|
accountId,
|
|
741
670
|
targetKind: unbindParams.targetKind
|
|
742
671
|
});
|
|
743
|
-
if (ids.length === 0) return [];
|
|
744
672
|
const removed = [];
|
|
745
673
|
for (const bindingKey of ids) {
|
|
746
674
|
const binding = BINDINGS_BY_THREAD_ID.get(bindingKey);
|
|
@@ -789,7 +717,7 @@ function createLoadedThreadBindingManager(params) {
|
|
|
789
717
|
sweepPromise = void 0;
|
|
790
718
|
});
|
|
791
719
|
}, THREAD_BINDINGS_SWEEP_INTERVAL_MS);
|
|
792
|
-
if (
|
|
720
|
+
if (shouldDefaultPersist()) sweepTimer.unref?.();
|
|
793
721
|
}
|
|
794
722
|
const sessionBindingAdapter = createThreadBindingSessionAdapter({
|
|
795
723
|
accountId,
|
|
@@ -806,8 +734,7 @@ function createLoadedThreadBindingManager(params) {
|
|
|
806
734
|
return manager;
|
|
807
735
|
}
|
|
808
736
|
function getThreadBindingManager(accountId) {
|
|
809
|
-
|
|
810
|
-
return MANAGERS_BY_ACCOUNT_ID.get(normalized) ?? null;
|
|
737
|
+
return MANAGERS_BY_ACCOUNT_ID.get(normalizeAccountId(accountId)) ?? null;
|
|
811
738
|
}
|
|
812
739
|
//#endregion
|
|
813
740
|
export { isThreadArchived as a, resolveThreadBindingPersonaFromRecord as c, createNoopThreadBindingManager as i, getThreadBindingManager as n, resolveChannelIdForBinding as o, thread_bindings_manager_exports as r, resolveThreadBindingPersona as s, createThreadBindingManager as t };
|