@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
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { l as withAbortTimeout } from "./timeouts-pun7VJ02.mjs";
|
|
1
|
+
import { l as resolveDiscordAccount, o as listEnabledDiscordAccounts, u as resolveDiscordAccountAllowFrom } from "./accounts-ljrzXBJi.mjs";
|
|
2
|
+
import { A as isDiscordThreadChannelType, D as getDiscordEndpointRuntime, f as resolveDiscordGuildEntry, i as normalizeDiscordAllowList, k as resolveDiscordEndpointMediaGuard, l as resolveDiscordChannelConfigWithFallback, n as hasConfiguredDiscordChannels, o as normalizeDiscordSlug, p as resolveDiscordMemberAccessState, r as isDiscordGroupAllowedByPolicy, t as allowListMatches } from "./allow-list-B_ToXtew.mjs";
|
|
3
|
+
import { L as DiscordError, ft as getChannelMessage, t as discord_exports } from "./discord-BGqgx-yd.mjs";
|
|
4
|
+
import { l as withAbortTimeout } from "./timeouts-CuNARfyw.mjs";
|
|
6
5
|
import { t as resolveDiscordCommandOwnerAllowFrom } from "./command-owners-D78sAoOz.mjs";
|
|
7
|
-
import { a as resolveDiscordChannelParentSafe, i as resolveDiscordChannelParentIdSafe, n as resolveDiscordChannelInfoSafe, r as resolveDiscordChannelNameSafe, t as resolveDiscordChannelIdSafe } from "./channel-access-
|
|
6
|
+
import { a as resolveDiscordChannelParentSafe, i as resolveDiscordChannelParentIdSafe, n as resolveDiscordChannelInfoSafe, r as resolveDiscordChannelNameSafe, t as resolveDiscordChannelIdSafe } from "./channel-access-DasWY_OV.mjs";
|
|
8
7
|
import { createSubsystemLogger, getChildLogger, logVerbose } from "openclaw/plugin-sdk/runtime-env";
|
|
9
8
|
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
10
9
|
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeOptionalStringifiedId, summarizeStringEntries, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
11
|
-
import {
|
|
12
|
-
import { ComponentType, Routes, StickerFormatType } from "discord-api-types/v10";
|
|
10
|
+
import { ComponentType, StickerFormatType } from "discord-api-types/v10";
|
|
13
11
|
import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
|
|
14
12
|
import { saveRemoteMedia } from "openclaw/plugin-sdk/media-runtime";
|
|
15
13
|
import { asDateTimestampMs, resolveExpiresAtMsFromDurationMs } from "openclaw/plugin-sdk/number-runtime";
|
|
@@ -19,8 +17,6 @@ import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
|
19
17
|
import { createReplyReferencePlanner } from "openclaw/plugin-sdk/reply-reference";
|
|
20
18
|
import { resolveOpenProviderRuntimeGroupPolicy } from "openclaw/plugin-sdk/runtime-group-policy";
|
|
21
19
|
import { getFileExtension, normalizeMimeType } from "openclaw/plugin-sdk/media-mime";
|
|
22
|
-
import { resolveChannelModelOverride } from "openclaw/plugin-sdk/model-session-runtime";
|
|
23
|
-
import { generateConversationLabel } from "openclaw/plugin-sdk/reply-dispatch-runtime";
|
|
24
20
|
import { formatMediaPlaceholderText } from "openclaw/plugin-sdk/channel-inbound";
|
|
25
21
|
import { resolveCommandAuthorizedFromAuthorizers } from "openclaw/plugin-sdk/command-auth-native";
|
|
26
22
|
//#region extensions/discord/src/monitor/message-channel-info-state.ts
|
|
@@ -47,6 +43,17 @@ function resolveDiscordMessageChannelId(params) {
|
|
|
47
43
|
const message = params.message;
|
|
48
44
|
return normalizeDiscordChannelId(message.channelId) || normalizeDiscordChannelId(message.channel_id) || normalizeDiscordChannelId(message.rawData?.channel_id) || normalizeDiscordChannelId(params.eventChannelId);
|
|
49
45
|
}
|
|
46
|
+
function buildDiscordChannelInfo(channel, options) {
|
|
47
|
+
const info = resolveDiscordChannelInfoSafe(channel);
|
|
48
|
+
const type = info.type ?? (options?.rawTypeFallback ? channel.type : void 0);
|
|
49
|
+
return type === void 0 ? null : {
|
|
50
|
+
type,
|
|
51
|
+
name: info.name,
|
|
52
|
+
topic: info.topic,
|
|
53
|
+
parentId: info.parentId,
|
|
54
|
+
ownerId: info.ownerId
|
|
55
|
+
};
|
|
56
|
+
}
|
|
50
57
|
async function resolveDiscordChannelInfo(client, channelId) {
|
|
51
58
|
const rawNow = Date.now();
|
|
52
59
|
const now = asDateTimestampMs(rawNow);
|
|
@@ -61,17 +68,8 @@ async function resolveDiscordChannelInfo(client, channelId) {
|
|
|
61
68
|
cacheDiscordChannelInfo(channelId, null, DISCORD_CHANNEL_INFO_NEGATIVE_CACHE_TTL_MS, rawNow);
|
|
62
69
|
return null;
|
|
63
70
|
}
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
const type = channelInfo.type ?? rawChannel.type;
|
|
67
|
-
if (type === void 0) return null;
|
|
68
|
-
const payload = {
|
|
69
|
-
type,
|
|
70
|
-
name: channelInfo.name,
|
|
71
|
-
topic: channelInfo.topic,
|
|
72
|
-
parentId: channelInfo.parentId,
|
|
73
|
-
ownerId: channelInfo.ownerId
|
|
74
|
-
};
|
|
71
|
+
const payload = buildDiscordChannelInfo(channel, { rawTypeFallback: true });
|
|
72
|
+
if (!payload) return null;
|
|
75
73
|
cacheDiscordChannelInfo(channelId, payload, DISCORD_CHANNEL_INFO_CACHE_TTL_MS, rawNow);
|
|
76
74
|
return payload;
|
|
77
75
|
} catch (err) {
|
|
@@ -81,80 +79,6 @@ async function resolveDiscordChannelInfo(client, channelId) {
|
|
|
81
79
|
}
|
|
82
80
|
}
|
|
83
81
|
//#endregion
|
|
84
|
-
//#region extensions/discord/src/monitor/thread-title.ts
|
|
85
|
-
const DEFAULT_THREAD_TITLE_TIMEOUT_MS = 6e4;
|
|
86
|
-
const MAX_THREAD_TITLE_SOURCE_CHARS = 600;
|
|
87
|
-
const MAX_THREAD_TITLE_CHANNEL_NAME_CHARS = 120;
|
|
88
|
-
const MAX_THREAD_TITLE_CHANNEL_DESCRIPTION_CHARS = 320;
|
|
89
|
-
const DISCORD_THREAD_TITLE_SYSTEM_PROMPT = "Generate a concise Discord thread title (3-6 words) in sentence case: capitalize only the first word and words that are always capitalized. Return only the title. Use channel context when provided and avoid redundant channel-name words unless needed for clarity.";
|
|
90
|
-
async function generateThreadTitle(params) {
|
|
91
|
-
const sourceText = params.messageText.trim();
|
|
92
|
-
if (!sourceText) return null;
|
|
93
|
-
try {
|
|
94
|
-
const userMessage = buildThreadTitleCompletionUserMessage({
|
|
95
|
-
sourceText,
|
|
96
|
-
channelName: params.channelName,
|
|
97
|
-
channelDescription: params.channelDescription
|
|
98
|
-
});
|
|
99
|
-
const generated = await generateConversationLabel({
|
|
100
|
-
cfg: params.cfg,
|
|
101
|
-
agentId: params.agentId,
|
|
102
|
-
userMessage,
|
|
103
|
-
prompt: DISCORD_THREAD_TITLE_SYSTEM_PROMPT,
|
|
104
|
-
...params.modelRef ? { modelRef: params.modelRef } : {},
|
|
105
|
-
timeoutMs: Math.max(100, Math.floor(params.timeoutMs ?? DEFAULT_THREAD_TITLE_TIMEOUT_MS)),
|
|
106
|
-
maxLength: MAX_THREAD_TITLE_SOURCE_CHARS
|
|
107
|
-
});
|
|
108
|
-
return generated ? normalizeGeneratedThreadTitle(generated) : null;
|
|
109
|
-
} catch (err) {
|
|
110
|
-
logVerbose(`thread-title: title generation failed for agent ${params.agentId}: ${String(err)}`);
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
function buildThreadTitleCompletionUserMessage(params) {
|
|
115
|
-
const sourceText = truncateThreadTitleSourceText(params.sourceText);
|
|
116
|
-
const channelName = normalizeTitleContextField(params.channelName, MAX_THREAD_TITLE_CHANNEL_NAME_CHARS);
|
|
117
|
-
const channelDescription = normalizeTitleContextField(params.channelDescription, MAX_THREAD_TITLE_CHANNEL_DESCRIPTION_CHARS);
|
|
118
|
-
const messageLines = [];
|
|
119
|
-
if (channelName) messageLines.push(`Channel: ${channelName}`);
|
|
120
|
-
if (channelDescription) messageLines.push(`Channel description: ${channelDescription}`);
|
|
121
|
-
messageLines.push(`Message:\n${sourceText}`);
|
|
122
|
-
return messageLines.join("\n\n");
|
|
123
|
-
}
|
|
124
|
-
function truncateThreadTitleSourceText(sourceText) {
|
|
125
|
-
if (sourceText.length <= MAX_THREAD_TITLE_SOURCE_CHARS) return sourceText;
|
|
126
|
-
return `${truncateUtf16Safe(sourceText, MAX_THREAD_TITLE_SOURCE_CHARS)}...`;
|
|
127
|
-
}
|
|
128
|
-
function normalizeGeneratedThreadTitle(raw) {
|
|
129
|
-
return stripThreadTitleWrappers(raw.replace(/\r/g, "").split("\n").find((line) => line.trim() && !line.trim().startsWith("```")) ?? "");
|
|
130
|
-
}
|
|
131
|
-
function stripThreadTitleWrappers(raw) {
|
|
132
|
-
let current = raw.trim();
|
|
133
|
-
let previous = "";
|
|
134
|
-
while (current && current !== previous) {
|
|
135
|
-
previous = current;
|
|
136
|
-
current = current.replace(/^["'`]+|["'`]+$/g, "").trim();
|
|
137
|
-
current = stripBalancedWrapper(current, "**");
|
|
138
|
-
current = stripBalancedWrapper(current, "__");
|
|
139
|
-
current = stripBalancedWrapper(current, "*");
|
|
140
|
-
current = stripBalancedWrapper(current, "_");
|
|
141
|
-
current = stripBalancedWrapper(current, "~~");
|
|
142
|
-
}
|
|
143
|
-
return current;
|
|
144
|
-
}
|
|
145
|
-
function stripBalancedWrapper(text, marker) {
|
|
146
|
-
if (text.length < marker.length * 2 + 1 || !text.startsWith(marker) || !text.endsWith(marker)) return text;
|
|
147
|
-
const inner = text.slice(marker.length, text.length - marker.length);
|
|
148
|
-
return inner.includes(marker) ? text : inner;
|
|
149
|
-
}
|
|
150
|
-
function normalizeTitleContextField(raw, maxChars) {
|
|
151
|
-
const value = raw?.trim();
|
|
152
|
-
if (!value) return;
|
|
153
|
-
const singleLine = value.replace(/\s+/g, " ");
|
|
154
|
-
if (singleLine.length <= maxChars) return singleLine;
|
|
155
|
-
return `${truncateUtf16Safe(singleLine, maxChars)}...`;
|
|
156
|
-
}
|
|
157
|
-
//#endregion
|
|
158
82
|
//#region extensions/discord/src/monitor/message-forwarded.ts
|
|
159
83
|
const FORWARD_MESSAGE_REFERENCE_TYPE = 1;
|
|
160
84
|
function normalizeDiscordStickerItems(value) {
|
|
@@ -202,10 +126,9 @@ function formatDiscordSnapshotAuthor(author) {
|
|
|
202
126
|
const username = normalizeOptionalString(author.username) ?? void 0;
|
|
203
127
|
const name = normalizeOptionalString(author.name) ?? void 0;
|
|
204
128
|
const discriminator = normalizeOptionalString(author.discriminator) ?? void 0;
|
|
205
|
-
const base = globalName || username || name;
|
|
129
|
+
const base = globalName || username || name || author.id;
|
|
206
130
|
if (username && discriminator && discriminator !== "0") return `@${username}#${discriminator}`;
|
|
207
|
-
|
|
208
|
-
if (author.id) return `@${author.id}`;
|
|
131
|
+
return base ? `@${base}` : void 0;
|
|
209
132
|
}
|
|
210
133
|
//#endregion
|
|
211
134
|
//#region extensions/discord/src/monitor/media-ssrf-policy.ts
|
|
@@ -258,16 +181,6 @@ function createDiscordMediaOperation(maxBytes, options) {
|
|
|
258
181
|
out: []
|
|
259
182
|
};
|
|
260
183
|
}
|
|
261
|
-
function isDiscordAudioAttachmentFileName(fileName) {
|
|
262
|
-
const ext = getFileExtension(fileName);
|
|
263
|
-
return Boolean(ext && AUDIO_ATTACHMENT_EXTENSIONS.has(ext));
|
|
264
|
-
}
|
|
265
|
-
function isDiscordVoiceWaveform(attachment) {
|
|
266
|
-
return typeof attachment.waveform === "string";
|
|
267
|
-
}
|
|
268
|
-
function isDiscordVoiceDurationOnly(attachment) {
|
|
269
|
-
return typeof attachment.duration_secs === "number" && !isDiscordVoiceWaveform(attachment);
|
|
270
|
-
}
|
|
271
184
|
const NON_DEFINITIVE_MEDIA_TYPES = /* @__PURE__ */ new Set([
|
|
272
185
|
"application/octet-stream",
|
|
273
186
|
"binary/octet-stream",
|
|
@@ -277,22 +190,15 @@ function isDefinitiveMediaType(contentType) {
|
|
|
277
190
|
const normalized = normalizeMimeType(contentType);
|
|
278
191
|
return Boolean(normalized && !NON_DEFINITIVE_MEDIA_TYPES.has(normalized));
|
|
279
192
|
}
|
|
280
|
-
function resolveEffectiveMediaType(params) {
|
|
281
|
-
if (isDefinitiveMediaType(params.fetchedContentType)) return params.fetchedContentType ?? void 0;
|
|
282
|
-
if (isDefinitiveMediaType(params.declaredContentType)) return params.declaredContentType ?? void 0;
|
|
283
|
-
return params.fetchedContentType ?? params.declaredContentType ?? void 0;
|
|
284
|
-
}
|
|
285
193
|
function resolveDiscordMediaClassification(params) {
|
|
286
|
-
const contentType =
|
|
287
|
-
declaredContentType: params.attachment.content_type,
|
|
288
|
-
fetchedContentType: params.fetchedContentType
|
|
289
|
-
});
|
|
194
|
+
const contentType = [params.fetchedContentType, params.attachment.content_type].find(isDefinitiveMediaType) ?? params.fetchedContentType ?? params.attachment.content_type ?? void 0;
|
|
290
195
|
const mime = normalizeMimeType(contentType);
|
|
196
|
+
const definitive = isDefinitiveMediaType(contentType);
|
|
291
197
|
const definitiveVisual = mime?.startsWith("video/") === true || mime?.startsWith("image/") === true;
|
|
292
|
-
const audioKind = mime?.startsWith("audio/") ||
|
|
293
|
-
const kind = audioKind ?? (!
|
|
198
|
+
const audioKind = mime?.startsWith("audio/") || typeof params.attachment.waveform === "string" || !definitiveVisual && (typeof params.attachment.duration_secs === "number" || AUDIO_ATTACHMENT_EXTENSIONS.has(getFileExtension(params.attachment.filename ?? params.attachment.url) ?? "") && !definitive) ? "audio" : void 0;
|
|
199
|
+
const kind = audioKind ?? (!definitive ? isImageAttachment(params.attachment) ? "image" : "document" : void 0);
|
|
294
200
|
return {
|
|
295
|
-
contentType: audioKind && !mime?.startsWith("audio/") || kind && !
|
|
201
|
+
contentType: audioKind && !mime?.startsWith("audio/") || kind && !definitive ? void 0 : contentType,
|
|
296
202
|
...kind ? { kind } : {}
|
|
297
203
|
};
|
|
298
204
|
}
|
|
@@ -355,9 +261,7 @@ async function fetchDiscordMedia(operation, params) {
|
|
|
355
261
|
}) : save(operation.abortSignal);
|
|
356
262
|
}
|
|
357
263
|
async function appendResolvedMediaFromAttachments(params) {
|
|
358
|
-
const
|
|
359
|
-
if (!attachments || attachments.length === 0) return;
|
|
360
|
-
for (const attachment of attachments) {
|
|
264
|
+
for (const attachment of params.attachments ?? []) {
|
|
361
265
|
const attachmentUrl = normalizeOptionalString(attachment.url);
|
|
362
266
|
if (!attachmentUrl) {
|
|
363
267
|
logVerbose(`${params.errorPrefix} ${attachment.id ?? attachment.filename ?? "attachment"}: missing url`);
|
|
@@ -389,23 +293,11 @@ async function appendResolvedMediaFromAttachments(params) {
|
|
|
389
293
|
}
|
|
390
294
|
function resolveStickerAssetCandidates(sticker) {
|
|
391
295
|
const baseName = sticker.name?.trim() || `sticker-${sticker.id}`;
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
case StickerFormatType.Lottie: return [{
|
|
398
|
-
url: `${DISCORD_STICKER_ASSET_BASE_URL}/${sticker.id}.png?size=160`,
|
|
399
|
-
fileName: `${baseName}.png`
|
|
400
|
-
}, {
|
|
401
|
-
url: `${DISCORD_STICKER_ASSET_BASE_URL}/${sticker.id}.json`,
|
|
402
|
-
fileName: `${baseName}.json`
|
|
403
|
-
}];
|
|
404
|
-
default: return [{
|
|
405
|
-
url: `${DISCORD_STICKER_ASSET_BASE_URL}/${sticker.id}.png`,
|
|
406
|
-
fileName: `${baseName}.png`
|
|
407
|
-
}];
|
|
408
|
-
}
|
|
296
|
+
const isLottie = sticker.format_type === StickerFormatType.Lottie;
|
|
297
|
+
return (isLottie ? ["png", "json"] : [sticker.format_type === StickerFormatType.GIF ? "gif" : "png"]).map((extension) => ({
|
|
298
|
+
url: `${DISCORD_STICKER_ASSET_BASE_URL}/${sticker.id}.${extension}${isLottie && extension === "png" ? "?size=160" : ""}`,
|
|
299
|
+
fileName: `${baseName}.${extension}`
|
|
300
|
+
}));
|
|
409
301
|
}
|
|
410
302
|
function formatStickerError(err) {
|
|
411
303
|
if (err instanceof Error) return err.message;
|
|
@@ -426,9 +318,7 @@ function inferStickerContentType(sticker) {
|
|
|
426
318
|
}
|
|
427
319
|
}
|
|
428
320
|
async function appendResolvedMediaFromStickers(params) {
|
|
429
|
-
const
|
|
430
|
-
if (!stickers || stickers.length === 0) return;
|
|
431
|
-
for (const sticker of stickers) {
|
|
321
|
+
for (const sticker of params.stickers ?? []) {
|
|
432
322
|
const candidates = resolveStickerAssetCandidates(sticker);
|
|
433
323
|
let lastError;
|
|
434
324
|
for (const candidate of candidates) try {
|
|
@@ -474,7 +364,7 @@ function resolveDiscordEmbedText(embeds) {
|
|
|
474
364
|
return (embeds ?? []).flatMap(({ title, description }) => [normalizeOptionalString(title), normalizeOptionalString(description)]).filter(Boolean).join("\n");
|
|
475
365
|
}
|
|
476
366
|
function resolveDiscordMessageText(message, options) {
|
|
477
|
-
const baseText = resolveDiscordMentions(resolveDiscordMessageMentionDocuments(message).map((text) =>
|
|
367
|
+
const baseText = resolveDiscordMentions(resolveDiscordMessageMentionDocuments(message).map((text) => text.trim()).join("\n") || normalizeOptionalString(options?.fallbackText) || "", message);
|
|
478
368
|
if (!options?.includeForwarded) return baseText;
|
|
479
369
|
return [baseText, resolveDiscordForwardedMessagesText(message)].filter(Boolean).join("\n");
|
|
480
370
|
}
|
|
@@ -556,7 +446,7 @@ function resolveDiscordMessageComponents(message) {
|
|
|
556
446
|
function extractDiscordComponentsV2Text(components) {
|
|
557
447
|
const parts = [];
|
|
558
448
|
collectDiscordTextDisplayDocuments(components, parts);
|
|
559
|
-
return parts.map((part) =>
|
|
449
|
+
return parts.map((part) => part.trim()).join("\n");
|
|
560
450
|
}
|
|
561
451
|
function collectDiscordTextDisplayDocuments(value, parts) {
|
|
562
452
|
if (Array.isArray(value)) {
|
|
@@ -669,14 +559,10 @@ async function resolveDiscordThreadStarterUncached(params, cacheKey, messageChan
|
|
|
669
559
|
};
|
|
670
560
|
try {
|
|
671
561
|
const starter = await getChannelMessage(params.client.rest, messageChannelId, params.channel.id);
|
|
672
|
-
|
|
673
|
-
cacheMiss();
|
|
674
|
-
return null;
|
|
675
|
-
}
|
|
676
|
-
const payload = buildDiscordThreadStarterPayload({
|
|
562
|
+
const payload = starter ? buildDiscordThreadStarterPayload({
|
|
677
563
|
starter,
|
|
678
564
|
resolveTimestampMs: params.resolveTimestampMs
|
|
679
|
-
});
|
|
565
|
+
}) : null;
|
|
680
566
|
if (!payload) {
|
|
681
567
|
cacheMiss();
|
|
682
568
|
return null;
|
|
@@ -737,188 +623,7 @@ function resolveDiscordReplyDeliveryPlan(params) {
|
|
|
737
623
|
};
|
|
738
624
|
}
|
|
739
625
|
//#endregion
|
|
740
|
-
//#region extensions/discord/src/monitor/threading.auto-thread.ts
|
|
741
|
-
function resolveTrimmedDiscordMessageChannelId(params) {
|
|
742
|
-
return (params.messageChannelId || resolveDiscordMessageChannelId({ message: params.message })).trim();
|
|
743
|
-
}
|
|
744
|
-
function resolveDiscordAutoThreadContext(params) {
|
|
745
|
-
const createdThreadId = normalizeOptionalStringifiedId(params.createdThreadId) ?? "";
|
|
746
|
-
if (!createdThreadId) return null;
|
|
747
|
-
const parentSessionKey = normalizeOptionalString(params.parentSessionKey) ?? "";
|
|
748
|
-
if (!parentSessionKey) return null;
|
|
749
|
-
const threadSessionKey = params.groupScope === "main" ? parentSessionKey : buildAgentSessionKey({
|
|
750
|
-
agentId: params.agentId,
|
|
751
|
-
channel: params.channel,
|
|
752
|
-
peer: {
|
|
753
|
-
kind: "channel",
|
|
754
|
-
id: createdThreadId
|
|
755
|
-
}
|
|
756
|
-
});
|
|
757
|
-
const inheritsDistinctParent = threadSessionKey !== parentSessionKey;
|
|
758
|
-
return {
|
|
759
|
-
createdThreadId,
|
|
760
|
-
From: `${params.channel}:channel:${createdThreadId}`,
|
|
761
|
-
To: `channel:${createdThreadId}`,
|
|
762
|
-
OriginatingTo: `channel:${createdThreadId}`,
|
|
763
|
-
SessionKey: threadSessionKey,
|
|
764
|
-
...inheritsDistinctParent ? { ModelParentSessionKey: parentSessionKey } : {},
|
|
765
|
-
...inheritsDistinctParent && params.parentInheritanceEnabled === true ? { ParentSessionKey: parentSessionKey } : {}
|
|
766
|
-
};
|
|
767
|
-
}
|
|
768
|
-
async function resolveDiscordAutoThreadReplyPlan(params) {
|
|
769
|
-
const messageChannelId = resolveTrimmedDiscordMessageChannelId(params);
|
|
770
|
-
const originalReplyTarget = `channel:${params.threadChannel?.id ?? (messageChannelId || "unknown")}`;
|
|
771
|
-
const createdThreadId = await maybeCreateDiscordAutoThread({
|
|
772
|
-
...params,
|
|
773
|
-
messageChannelId: messageChannelId || void 0
|
|
774
|
-
});
|
|
775
|
-
const deliveryPlan = resolveDiscordReplyDeliveryPlan({
|
|
776
|
-
replyTarget: originalReplyTarget,
|
|
777
|
-
replyToMode: params.replyToMode,
|
|
778
|
-
messageId: params.message.id,
|
|
779
|
-
threadChannel: params.threadChannel,
|
|
780
|
-
createdThreadId
|
|
781
|
-
});
|
|
782
|
-
const autoThreadContext = params.isGuildMessage ? resolveDiscordAutoThreadContext({
|
|
783
|
-
agentId: params.agentId,
|
|
784
|
-
channel: params.channel,
|
|
785
|
-
parentSessionKey: params.parentSessionKey,
|
|
786
|
-
createdThreadId,
|
|
787
|
-
groupScope: params.groupScope,
|
|
788
|
-
parentInheritanceEnabled: params.threadParentInheritanceEnabled
|
|
789
|
-
}) : null;
|
|
790
|
-
return {
|
|
791
|
-
...deliveryPlan,
|
|
792
|
-
createdThreadId,
|
|
793
|
-
autoThreadContext
|
|
794
|
-
};
|
|
795
|
-
}
|
|
796
|
-
async function maybeCreateDiscordAutoThread(params) {
|
|
797
|
-
if (!params.isGuildMessage) return;
|
|
798
|
-
if (!params.channelConfig?.autoThread) return;
|
|
799
|
-
if (params.threadChannel) return;
|
|
800
|
-
if (params.channelType === discord_exports.ChannelType.GuildForum || params.channelType === discord_exports.ChannelType.GuildMedia || params.channelType === discord_exports.ChannelType.GuildVoice || params.channelType === discord_exports.ChannelType.GuildStageVoice) return;
|
|
801
|
-
const messageChannelId = resolveTrimmedDiscordMessageChannelId(params);
|
|
802
|
-
if (!messageChannelId) return;
|
|
803
|
-
const findExistingThread = async () => {
|
|
804
|
-
try {
|
|
805
|
-
const existingThreadId = (await getChannelMessage(params.client.rest, messageChannelId, params.message.id))?.thread?.id;
|
|
806
|
-
if (existingThreadId) {
|
|
807
|
-
logVerbose(`discord: autoThread reusing existing thread ${existingThreadId} on ${messageChannelId}/${params.message.id}`);
|
|
808
|
-
return existingThreadId;
|
|
809
|
-
}
|
|
810
|
-
} catch {}
|
|
811
|
-
};
|
|
812
|
-
try {
|
|
813
|
-
const existingThreadId = await findExistingThread();
|
|
814
|
-
if (existingThreadId) return existingThreadId;
|
|
815
|
-
if (params.message.author?.bot) {
|
|
816
|
-
logVerbose(`discord: autoThread skipped for bot-authored message ${messageChannelId}/${params.message.id}`);
|
|
817
|
-
return;
|
|
818
|
-
}
|
|
819
|
-
const rawThreadSource = params.baseText || params.combinedBody || "Thread";
|
|
820
|
-
const threadName = sanitizeDiscordThreadName(rawThreadSource, params.message.id);
|
|
821
|
-
const archiveDuration = params.channelConfig?.autoArchiveDuration ? Number(params.channelConfig.autoArchiveDuration) : 60;
|
|
822
|
-
const createdId = (await createThread(params.client.rest, messageChannelId, { body: {
|
|
823
|
-
name: threadName,
|
|
824
|
-
auto_archive_duration: archiveDuration
|
|
825
|
-
} }, params.message.id))?.id || "";
|
|
826
|
-
if (createdId && params.channelConfig?.autoThreadName === "generated" && params.cfg && params.agentId) {
|
|
827
|
-
const modelRef = resolveDiscordThreadTitleModelRef({
|
|
828
|
-
cfg: params.cfg,
|
|
829
|
-
channel: params.channel,
|
|
830
|
-
agentId: params.agentId,
|
|
831
|
-
threadId: createdId,
|
|
832
|
-
messageChannelId,
|
|
833
|
-
channelName: params.channelName
|
|
834
|
-
});
|
|
835
|
-
maybeRenameDiscordAutoThread({
|
|
836
|
-
client: params.client,
|
|
837
|
-
threadId: createdId,
|
|
838
|
-
currentName: threadName,
|
|
839
|
-
fallbackId: params.message.id,
|
|
840
|
-
sourceText: rawThreadSource,
|
|
841
|
-
modelRef,
|
|
842
|
-
channelName: params.channelName,
|
|
843
|
-
channelDescription: params.channelDescription,
|
|
844
|
-
cfg: params.cfg,
|
|
845
|
-
agentId: params.agentId
|
|
846
|
-
});
|
|
847
|
-
}
|
|
848
|
-
return createdId || void 0;
|
|
849
|
-
} catch (err) {
|
|
850
|
-
logVerbose(`discord: autoThread creation failed for ${messageChannelId}/${params.message.id}: ${String(err)}`);
|
|
851
|
-
return findExistingThread();
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
function resolveDiscordThreadTitleModelRef(params) {
|
|
855
|
-
const channel = params.channel?.trim();
|
|
856
|
-
if (!channel) return;
|
|
857
|
-
const parentSessionKey = buildAgentSessionKey({
|
|
858
|
-
agentId: params.agentId,
|
|
859
|
-
channel,
|
|
860
|
-
peer: {
|
|
861
|
-
kind: "channel",
|
|
862
|
-
id: params.messageChannelId
|
|
863
|
-
}
|
|
864
|
-
});
|
|
865
|
-
const channelLabel = params.channelName?.trim();
|
|
866
|
-
const groupChannel = channelLabel ? `#${channelLabel}` : void 0;
|
|
867
|
-
return resolveChannelModelOverride({
|
|
868
|
-
cfg: params.cfg,
|
|
869
|
-
channel,
|
|
870
|
-
groupId: params.threadId,
|
|
871
|
-
groupChatType: "channel",
|
|
872
|
-
groupChannel,
|
|
873
|
-
groupSubject: groupChannel,
|
|
874
|
-
parentSessionKey
|
|
875
|
-
})?.model;
|
|
876
|
-
}
|
|
877
|
-
async function maybeRenameDiscordAutoThread(params) {
|
|
878
|
-
try {
|
|
879
|
-
const fallbackName = sanitizeDiscordThreadName("", params.fallbackId);
|
|
880
|
-
const generated = await generateThreadTitle({
|
|
881
|
-
cfg: params.cfg,
|
|
882
|
-
agentId: params.agentId,
|
|
883
|
-
messageText: params.sourceText,
|
|
884
|
-
modelRef: params.modelRef,
|
|
885
|
-
channelName: params.channelName,
|
|
886
|
-
channelDescription: params.channelDescription
|
|
887
|
-
});
|
|
888
|
-
if (!generated) return;
|
|
889
|
-
const nextName = sanitizeDiscordThreadName(generated, params.fallbackId);
|
|
890
|
-
if (!nextName || nextName === params.currentName || nextName === fallbackName) return;
|
|
891
|
-
await params.client.rest.patch(Routes.channel(params.threadId), { body: { name: nextName } });
|
|
892
|
-
} catch (err) {
|
|
893
|
-
logVerbose(`discord: autoThread rename failed for ${params.threadId}: ${String(err)}`);
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
//#endregion
|
|
897
|
-
//#region extensions/discord/src/monitor/threading.ts
|
|
898
|
-
var threading_exports = /* @__PURE__ */ __exportAll({
|
|
899
|
-
maybeCreateDiscordAutoThread: () => maybeCreateDiscordAutoThread,
|
|
900
|
-
resolveDiscordAutoThreadContext: () => resolveDiscordAutoThreadContext,
|
|
901
|
-
resolveDiscordAutoThreadReplyPlan: () => resolveDiscordAutoThreadReplyPlan,
|
|
902
|
-
resolveDiscordReplyDeliveryPlan: () => resolveDiscordReplyDeliveryPlan,
|
|
903
|
-
resolveDiscordReplyTarget: () => resolveDiscordReplyTarget,
|
|
904
|
-
resolveDiscordThreadChannel: () => resolveDiscordThreadChannel,
|
|
905
|
-
resolveDiscordThreadParentInfo: () => resolveDiscordThreadParentInfo,
|
|
906
|
-
resolveDiscordThreadStarter: () => resolveDiscordThreadStarter,
|
|
907
|
-
sanitizeDiscordThreadName: () => sanitizeDiscordThreadName
|
|
908
|
-
});
|
|
909
|
-
//#endregion
|
|
910
626
|
//#region extensions/discord/src/monitor/thread-channel-context.ts
|
|
911
|
-
function buildFetchedChannelInfo(channel) {
|
|
912
|
-
const channelInfo = resolveDiscordChannelInfoSafe(channel);
|
|
913
|
-
if (channelInfo.type === void 0) return null;
|
|
914
|
-
return {
|
|
915
|
-
type: channelInfo.type,
|
|
916
|
-
name: channelInfo.name,
|
|
917
|
-
topic: channelInfo.topic,
|
|
918
|
-
parentId: channelInfo.parentId,
|
|
919
|
-
ownerId: channelInfo.ownerId
|
|
920
|
-
};
|
|
921
|
-
}
|
|
922
627
|
async function resolveDiscordThreadLikeChannelContext(params) {
|
|
923
628
|
const safeChannelInfo = resolveDiscordChannelInfoSafe(params.channel);
|
|
924
629
|
const channelId = resolveDiscordChannelIdSafe(params.channel) ?? params.channelIdFallback ?? "";
|
|
@@ -962,7 +667,7 @@ async function resolveDiscordThreadLikeChannelContext(params) {
|
|
|
962
667
|
async function resolveFetchedDiscordThreadLikeChannelContext(params) {
|
|
963
668
|
return await resolveDiscordThreadLikeChannelContext({
|
|
964
669
|
...params,
|
|
965
|
-
channelInfo:
|
|
670
|
+
channelInfo: buildDiscordChannelInfo(params.channel)
|
|
966
671
|
});
|
|
967
672
|
}
|
|
968
673
|
//#endregion
|
|
@@ -993,16 +698,12 @@ async function resolveDiscordVoiceAccessTarget(params) {
|
|
|
993
698
|
}
|
|
994
699
|
function resolveDiscordVoiceAccess(params) {
|
|
995
700
|
const commandOwnerAllowFrom = resolveDiscordCommandOwnerAllowFrom(params.cfg);
|
|
996
|
-
if (commandOwnerAllowFrom) return {
|
|
997
|
-
admissionAllowFrom: commandOwnerAllowFrom,
|
|
998
|
-
ownerAllowFrom: commandOwnerAllowFrom
|
|
999
|
-
};
|
|
1000
701
|
return {
|
|
1001
|
-
admissionAllowFrom: resolveDiscordAccountAllowFrom({
|
|
702
|
+
admissionAllowFrom: commandOwnerAllowFrom ?? resolveDiscordAccountAllowFrom({
|
|
1002
703
|
cfg: params.cfg,
|
|
1003
704
|
accountId: params.accountId
|
|
1004
705
|
}) ?? params.discordConfig.allowFrom ?? [],
|
|
1005
|
-
ownerAllowFrom: []
|
|
706
|
+
ownerAllowFrom: commandOwnerAllowFrom ?? []
|
|
1006
707
|
};
|
|
1007
708
|
}
|
|
1008
709
|
//#endregion
|
|
@@ -1033,26 +734,16 @@ async function authorizeDiscordVoiceIngress(initialParams) {
|
|
|
1033
734
|
guildEntries: params.discordConfig.guilds
|
|
1034
735
|
});
|
|
1035
736
|
const channelConfig = params.channelId ? resolveDiscordChannelConfigWithFallback({
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
channelName: params.channelName,
|
|
1039
|
-
channelSlug: params.channelSlug,
|
|
1040
|
-
parentId: params.parentId,
|
|
1041
|
-
parentName: params.parentName,
|
|
1042
|
-
parentSlug: params.parentSlug,
|
|
1043
|
-
scope: params.scope
|
|
737
|
+
...params,
|
|
738
|
+
guildInfo
|
|
1044
739
|
}) : null;
|
|
1045
740
|
if (channelConfig?.enabled === false) return {
|
|
1046
741
|
ok: false,
|
|
1047
742
|
message: "This channel is disabled."
|
|
1048
743
|
};
|
|
1049
744
|
const channelAllowlistConfigured = hasConfiguredDiscordChannels(guildInfo?.channels);
|
|
1050
|
-
if (!params.channelId && groupPolicy === "allowlist" && channelAllowlistConfigured) return {
|
|
1051
|
-
ok: false,
|
|
1052
|
-
message: `${params.channelLabel ?? "This channel"} is not allowlisted for voice commands.`
|
|
1053
|
-
};
|
|
1054
745
|
const channelAllowed = channelConfig ? channelConfig.allowed : !channelAllowlistConfigured;
|
|
1055
|
-
if (!isDiscordGroupAllowedByPolicy({
|
|
746
|
+
if (!params.channelId && groupPolicy === "allowlist" && channelAllowlistConfigured || !isDiscordGroupAllowedByPolicy({
|
|
1056
747
|
groupPolicy,
|
|
1057
748
|
guildAllowlisted: Boolean(guildInfo),
|
|
1058
749
|
channelAllowlistConfigured,
|
|
@@ -1074,18 +765,14 @@ async function authorizeDiscordVoiceIngress(initialParams) {
|
|
|
1074
765
|
"pk:"
|
|
1075
766
|
]);
|
|
1076
767
|
const admissionAllowed = admissionAllowList ? allowListMatches(admissionAllowList, params.sender, { allowNameMatching: false }) : false;
|
|
1077
|
-
const useAccessGroups = params.useAccessGroups ?? true;
|
|
1078
768
|
return resolveCommandAuthorizedFromAuthorizers({
|
|
1079
|
-
useAccessGroups,
|
|
1080
|
-
authorizers:
|
|
769
|
+
useAccessGroups: true,
|
|
770
|
+
authorizers: [{
|
|
1081
771
|
configured: admissionAllowList != null,
|
|
1082
772
|
allowed: admissionAllowed
|
|
1083
773
|
}, {
|
|
1084
774
|
configured: hasAccessRestrictions,
|
|
1085
775
|
allowed: memberAllowed
|
|
1086
|
-
}] : [{
|
|
1087
|
-
configured: hasAccessRestrictions,
|
|
1088
|
-
allowed: memberAllowed
|
|
1089
776
|
}],
|
|
1090
777
|
modeWhenAccessGroupsOff: "configured"
|
|
1091
778
|
}) ? {
|
|
@@ -1160,6 +847,7 @@ function bindDiscordCaptureReceipts(source, manager) {
|
|
|
1160
847
|
}
|
|
1161
848
|
function notifyCaptureRetired(capture) {
|
|
1162
849
|
if (!capture?.onStatus) return;
|
|
850
|
+
const warn = (error) => logger.warn(`discord voice: transcripts terminal notification failed: ${formatErrorMessage(error)}`);
|
|
1163
851
|
try {
|
|
1164
852
|
Promise.resolve(capture.onStatus({
|
|
1165
853
|
active: false,
|
|
@@ -1168,9 +856,9 @@ function notifyCaptureRetired(capture) {
|
|
|
1168
856
|
providerId: "discord-voice",
|
|
1169
857
|
...capture.source
|
|
1170
858
|
}
|
|
1171
|
-
})).catch(
|
|
859
|
+
})).catch(warn);
|
|
1172
860
|
} catch (error) {
|
|
1173
|
-
|
|
861
|
+
warn(error);
|
|
1174
862
|
}
|
|
1175
863
|
}
|
|
1176
864
|
function resolveDiscordTranscriptsCapture(source, manager) {
|
|
@@ -1333,19 +1021,13 @@ const discordVoiceTranscriptsSourceProvider = {
|
|
|
1333
1021
|
accountId: callerAccountId
|
|
1334
1022
|
});
|
|
1335
1023
|
const access = await authorizeDiscordVoiceIngress({
|
|
1024
|
+
...target,
|
|
1336
1025
|
readPolicy: manager?.readPolicy,
|
|
1337
1026
|
cfg,
|
|
1338
1027
|
discordConfig: account.config,
|
|
1339
1028
|
accountId: account.accountId,
|
|
1340
|
-
guild: target.guild,
|
|
1341
1029
|
guildId,
|
|
1342
1030
|
channelId,
|
|
1343
|
-
...target.channelName ? { channelName: target.channelName } : {},
|
|
1344
|
-
channelSlug: target.channelSlug,
|
|
1345
|
-
...target.parentId ? { parentId: target.parentId } : {},
|
|
1346
|
-
...target.parentName ? { parentName: target.parentName } : {},
|
|
1347
|
-
...target.parentSlug ? { parentSlug: target.parentSlug } : {},
|
|
1348
|
-
scope: target.scope,
|
|
1349
1031
|
memberRoleIds: [...caller.roleIds],
|
|
1350
1032
|
admissionAllowFrom: resolveDiscordVoiceAccess({
|
|
1351
1033
|
cfg,
|
|
@@ -1570,4 +1252,4 @@ const discordVoiceTranscriptsSourceProvider = {
|
|
|
1570
1252
|
}
|
|
1571
1253
|
};
|
|
1572
1254
|
//#endregion
|
|
1573
|
-
export {
|
|
1255
|
+
export { resolveDiscordChannelInfo as A, resolveMediaList as C, resolveDiscordMessageStickers as D, hasDiscordMessageStickers as E, resolveDiscordReferencedReplyMessage as O, resolveForwardedMediaList as S, resolveDiscordCdnPolicy as T, resolveDiscordMessageBatch as _, authorizeDiscordVoiceIngress as a, resolveDiscordMessageText as b, resolveDiscordVoiceEnabled as c, resolveDiscordReplyDeliveryPlan as d, resolveDiscordReplyTarget as f, sanitizeDiscordThreadName as g, resolveDiscordThreadStarter as h, setDiscordTranscriptsVoiceManager as i, resolveDiscordMessageChannelId as j, resolveDiscordReferencedReplyMessageId as k, resolveDiscordThreadLikeChannelContext as l, resolveDiscordThreadParentInfo as m, discordVoiceTranscriptsSourceProvider as n, resolveDiscordVoiceAccess as o, resolveDiscordThreadChannel as p, resolveDiscordTranscriptsCapture as r, resolveDiscordVoiceAccessTarget as s, bindDiscordCaptureReceipts as t, resolveFetchedDiscordThreadLikeChannelContext as u, resolveDiscordMessageHistoryText as v, resolveReferencedReplyMediaList as w, formatDiscordMediaText as x, resolveDiscordMessageMentionDocuments as y };
|