@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,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { A as isDiscordThreadChannelType } from "./allow-list-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { t as parseAndResolveDiscordTarget } from "./target-resolver-
|
|
1
|
+
import { h as normalizeDiscordToken, l as resolveDiscordAccount, s as mergeDiscordAccountConfig } from "./accounts-ljrzXBJi.mjs";
|
|
2
|
+
import { A as isDiscordThreadChannelType } from "./allow-list-B_ToXtew.mjs";
|
|
3
|
+
import { G as hasDiscordV2Components, I as RequestClient, K as serializePayload, _t as getGuildMember, dt as getChannel, gt as getGuild, nt as createUserDmChannel, pt as getThreadMember, q as Embed, rt as getCurrentUser, st as createChannelMessage } from "./discord-BGqgx-yd.mjs";
|
|
4
|
+
import { h as createDiscordRetryRunner, o as resolveDiscordReplyMessageId, v as chunkDiscordTextWithMode } from "./send.receipt-BAlzXd8e.mjs";
|
|
5
|
+
import { t as parseAndResolveDiscordTarget } from "./target-resolver-Bse8fuTi.mjs";
|
|
6
6
|
import { danger } from "openclaw/plugin-sdk/runtime-env";
|
|
7
|
-
import { normalizeOptionalString, normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
8
7
|
import { normalizeAccountId } from "openclaw/plugin-sdk/routing";
|
|
9
|
-
import {
|
|
8
|
+
import { normalizeOptionalString, normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
9
|
+
import { ChannelType, MessageFlags, PermissionFlagsBits } from "discord-api-types/v10";
|
|
10
10
|
import { PollLayoutType } from "discord-api-types/payloads/v10";
|
|
11
11
|
import { extensionForMime, normalizePollDurationHours, normalizePollInput } from "openclaw/plugin-sdk/media-runtime";
|
|
12
12
|
import { loadOutboundMediaFromUrl } from "openclaw/plugin-sdk/outbound-media";
|
|
13
13
|
import { requireRuntimeConfig } from "openclaw/plugin-sdk/plugin-config-runtime";
|
|
14
14
|
import { resolveTextChunksWithFallback } from "openclaw/plugin-sdk/reply-payload";
|
|
15
|
-
import { randomBytes } from "node:crypto";
|
|
16
15
|
import { makeProxyFetch } from "openclaw/plugin-sdk/fetch-runtime";
|
|
16
|
+
import { randomBytes } from "node:crypto";
|
|
17
17
|
//#region extensions/discord/src/monitor/gateway-registry.ts
|
|
18
18
|
/**
|
|
19
19
|
* Module-level registry of active Discord GatewayPlugin instances.
|
|
@@ -23,30 +23,22 @@ import { makeProxyFetch } from "openclaw/plugin-sdk/fetch-runtime";
|
|
|
23
23
|
*/
|
|
24
24
|
const gatewayRegistry = /* @__PURE__ */ new Map();
|
|
25
25
|
const DEFAULT_ACCOUNT_KEY = "\0__default__";
|
|
26
|
-
function resolveAccountKey(accountId) {
|
|
27
|
-
return accountId ?? DEFAULT_ACCOUNT_KEY;
|
|
28
|
-
}
|
|
29
26
|
function registerGateway(accountId, gateway) {
|
|
30
|
-
gatewayRegistry.set(
|
|
27
|
+
gatewayRegistry.set(accountId ?? DEFAULT_ACCOUNT_KEY, gateway);
|
|
31
28
|
}
|
|
32
29
|
function unregisterGateway(accountId) {
|
|
33
|
-
gatewayRegistry.delete(
|
|
30
|
+
gatewayRegistry.delete(accountId ?? DEFAULT_ACCOUNT_KEY);
|
|
34
31
|
}
|
|
35
32
|
function getGateway(accountId) {
|
|
36
|
-
return gatewayRegistry.get(
|
|
33
|
+
return gatewayRegistry.get(accountId ?? DEFAULT_ACCOUNT_KEY);
|
|
37
34
|
}
|
|
38
35
|
function clearGateways() {
|
|
39
36
|
gatewayRegistry.clear();
|
|
40
37
|
}
|
|
41
38
|
//#endregion
|
|
42
39
|
//#region extensions/discord/src/proxy-fetch.ts
|
|
43
|
-
function resolveDiscordProxyUrl(account, cfg) {
|
|
44
|
-
const accountProxy = normalizeOptionalString(account.config.proxy);
|
|
45
|
-
if (accountProxy) return accountProxy;
|
|
46
|
-
return normalizeOptionalString(cfg?.channels?.discord?.proxy);
|
|
47
|
-
}
|
|
48
40
|
function resolveDiscordProxyFetchForAccount(account, cfg, runtime) {
|
|
49
|
-
return withValidatedDiscordProxy(
|
|
41
|
+
return withValidatedDiscordProxy(normalizeOptionalString(account.config.proxy) ?? normalizeOptionalString(cfg?.channels?.discord?.proxy), runtime, makeProxyFetch);
|
|
50
42
|
}
|
|
51
43
|
function withValidatedDiscordProxy(proxyUrl, runtime, createValue) {
|
|
52
44
|
const proxy = proxyUrl?.trim();
|
|
@@ -86,48 +78,31 @@ function createDiscordRuntimeAccountContext(params) {
|
|
|
86
78
|
}
|
|
87
79
|
function resolveDiscordClientAccountContext(opts, runtime) {
|
|
88
80
|
const resolvedCfg = requireRuntimeConfig(opts.cfg, "Discord client");
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
81
|
+
const accountId = normalizeAccountId(opts.accountId);
|
|
82
|
+
const config = mergeDiscordAccountConfig(resolvedCfg, accountId);
|
|
83
|
+
const account = {
|
|
84
|
+
accountId,
|
|
85
|
+
enabled: resolvedCfg.channels?.discord?.enabled !== false && config.enabled !== false,
|
|
86
|
+
name: normalizeOptionalString(config.name),
|
|
87
|
+
token: "",
|
|
88
|
+
tokenSource: "none",
|
|
89
|
+
tokenStatus: "missing",
|
|
90
|
+
config
|
|
91
|
+
};
|
|
93
92
|
return {
|
|
94
93
|
cfg: resolvedCfg,
|
|
95
94
|
account,
|
|
96
95
|
proxyFetch: resolveDiscordProxyFetchForAccount(account, resolvedCfg, runtime)
|
|
97
96
|
};
|
|
98
97
|
}
|
|
99
|
-
function resolveToken(
|
|
100
|
-
const fallback = normalizeDiscordToken(
|
|
98
|
+
function resolveToken(account) {
|
|
99
|
+
const fallback = normalizeDiscordToken(account.token, "channels.discord.token");
|
|
101
100
|
if (!fallback) {
|
|
102
|
-
if (
|
|
103
|
-
throw new Error(`Discord bot token missing for account "${
|
|
101
|
+
if (account.tokenStatus === "configured_unavailable") throw new Error(`Discord bot token configured for account "${account.accountId}" is unavailable; resolve SecretRefs against the active runtime snapshot before using this account.`);
|
|
102
|
+
throw new Error(`Discord bot token missing for account "${account.accountId}" (set discord.accounts.${account.accountId}.token or DISCORD_BOT_TOKEN for default).`);
|
|
104
103
|
}
|
|
105
104
|
return fallback;
|
|
106
105
|
}
|
|
107
|
-
function resolveRest(token, account, cfg, rest, proxyFetch, signal, timeoutMs) {
|
|
108
|
-
if (rest) return rest;
|
|
109
|
-
const resolvedProxyFetch = proxyFetch ?? resolveDiscordProxyFetchForAccount(account, cfg);
|
|
110
|
-
return createDiscordRequestClient(token, {
|
|
111
|
-
...resolvedProxyFetch ? { fetch: resolvedProxyFetch } : {},
|
|
112
|
-
...signal ? { signal } : {},
|
|
113
|
-
...timeoutMs !== void 0 ? { timeout: timeoutMs } : {}
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
function resolveAccountWithoutToken(params) {
|
|
117
|
-
const accountId = normalizeAccountId(params.accountId);
|
|
118
|
-
const merged = mergeDiscordAccountConfig(params.cfg, accountId);
|
|
119
|
-
const baseEnabled = params.cfg.channels?.discord?.enabled !== false;
|
|
120
|
-
const accountEnabled = merged.enabled !== false;
|
|
121
|
-
return {
|
|
122
|
-
accountId,
|
|
123
|
-
enabled: baseEnabled && accountEnabled,
|
|
124
|
-
name: normalizeOptionalString(merged.name),
|
|
125
|
-
token: "",
|
|
126
|
-
tokenSource: "none",
|
|
127
|
-
tokenStatus: "missing",
|
|
128
|
-
config: merged
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
106
|
function createDiscordRestClient(opts) {
|
|
132
107
|
const explicitToken = normalizeDiscordToken(opts.token, "channels.discord.token");
|
|
133
108
|
const proxyContext = resolveDiscordClientAccountContext(opts);
|
|
@@ -136,14 +111,21 @@ function createDiscordRestClient(opts) {
|
|
|
136
111
|
cfg: resolvedCfg,
|
|
137
112
|
accountId: opts.accountId
|
|
138
113
|
});
|
|
139
|
-
const token = explicitToken ?? resolveToken(
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
114
|
+
const token = explicitToken ?? resolveToken(account);
|
|
115
|
+
const { rest, signal, timeoutMs } = opts;
|
|
116
|
+
if (rest) return {
|
|
117
|
+
token,
|
|
118
|
+
rest,
|
|
119
|
+
account
|
|
120
|
+
};
|
|
121
|
+
const proxyFetch = proxyContext.proxyFetch ?? resolveDiscordProxyFetchForAccount(account, resolvedCfg);
|
|
144
122
|
return {
|
|
145
123
|
token,
|
|
146
|
-
rest:
|
|
124
|
+
rest: createDiscordRequestClient(token, {
|
|
125
|
+
...proxyFetch ? { fetch: proxyFetch } : {},
|
|
126
|
+
...signal ? { signal } : {},
|
|
127
|
+
...timeoutMs !== void 0 ? { timeout: timeoutMs } : {}
|
|
128
|
+
}),
|
|
147
129
|
account
|
|
148
130
|
};
|
|
149
131
|
}
|
|
@@ -213,29 +195,23 @@ function resolveDiscordSendEmbeds(params) {
|
|
|
213
195
|
if (!params.embeds?.length || !params.isFirst) return;
|
|
214
196
|
return params.embeds.map((embed) => embed instanceof Embed ? embed : new Embed(embed));
|
|
215
197
|
}
|
|
216
|
-
function buildDiscordMessagePayload(params) {
|
|
217
|
-
const payload = {};
|
|
218
|
-
const hasV2 = hasDiscordV2Components(params.components);
|
|
219
|
-
const trimmed = params.text.trim();
|
|
220
|
-
if (!hasV2 && trimmed) payload.content = params.text;
|
|
221
|
-
if (params.components?.length) payload.components = params.components;
|
|
222
|
-
if (!hasV2 && params.embeds?.length) payload.embeds = params.embeds;
|
|
223
|
-
if (params.allowedMentions) payload.allowed_mentions = params.allowedMentions;
|
|
224
|
-
if (params.flags !== void 0) payload.flags = params.flags;
|
|
225
|
-
if (params.files?.length) payload.files = params.files;
|
|
226
|
-
return payload;
|
|
227
|
-
}
|
|
228
198
|
function resolveDiscordMessageFlags(params) {
|
|
229
|
-
|
|
230
|
-
if (params.suppressEmbeds) flags |= SUPPRESS_EMBEDS_FLAG;
|
|
231
|
-
if (params.silent) flags |= SUPPRESS_NOTIFICATIONS_FLAG;
|
|
232
|
-
return flags || void 0;
|
|
199
|
+
return (params.suppressEmbeds ? SUPPRESS_EMBEDS_FLAG : 0) | (params.silent ? SUPPRESS_NOTIFICATIONS_FLAG : 0) || void 0;
|
|
233
200
|
}
|
|
234
201
|
function resolveDiscordSuppressEmbeds(params) {
|
|
235
202
|
return params.override ?? params.configured ?? true;
|
|
236
203
|
}
|
|
237
204
|
function buildDiscordMessageRequest(params) {
|
|
238
|
-
const
|
|
205
|
+
const hasV2 = hasDiscordV2Components(params.components);
|
|
206
|
+
const trimmed = params.text.trim();
|
|
207
|
+
const payload = {
|
|
208
|
+
content: !hasV2 && trimmed ? params.text : void 0,
|
|
209
|
+
components: params.components?.length ? params.components : void 0,
|
|
210
|
+
embeds: !hasV2 && params.embeds?.length ? params.embeds : void 0,
|
|
211
|
+
allowed_mentions: params.allowedMentions || void 0,
|
|
212
|
+
flags: params.flags,
|
|
213
|
+
files: params.files?.length ? params.files : void 0
|
|
214
|
+
};
|
|
239
215
|
const nonce = params.endpoint === "create-message" ? params.nonce ?? createDiscordMessageNonce() : void 0;
|
|
240
216
|
return {
|
|
241
217
|
...serializePayload(payload),
|
|
@@ -253,12 +229,10 @@ const PERMISSION_ENTRIES = Object.entries(PermissionFlagsBits).filter(([, value]
|
|
|
253
229
|
const ALL_PERMISSIONS = PERMISSION_ENTRIES.reduce((acc, [, value]) => acc | value, 0n);
|
|
254
230
|
const ADMINISTRATOR_BIT = PermissionFlagsBits.Administrator;
|
|
255
231
|
function addPermissionBits(base, add) {
|
|
256
|
-
|
|
257
|
-
return base | BigInt(add);
|
|
232
|
+
return base | BigInt(add || "0");
|
|
258
233
|
}
|
|
259
234
|
function removePermissionBits(base, deny) {
|
|
260
|
-
|
|
261
|
-
return base & ~BigInt(deny);
|
|
235
|
+
return base & ~BigInt(deny || "0");
|
|
262
236
|
}
|
|
263
237
|
function bitfieldToPermissions(bitfield) {
|
|
264
238
|
return PERMISSION_ENTRIES.filter(([, value]) => (bitfield & value) === value).map(([name]) => name).toSorted();
|
|
@@ -276,13 +250,8 @@ async function fetchBotUserId(rest) {
|
|
|
276
250
|
}
|
|
277
251
|
function resolveMemberGuildPermissionBits(params) {
|
|
278
252
|
const rolesByIdLocal = rolesById(params.guild);
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
if (everyoneRole?.permissions) permissions = addPermissionBits(permissions, everyoneRole.permissions);
|
|
282
|
-
for (const roleId of params.member.roles ?? []) {
|
|
283
|
-
const role = rolesByIdLocal.get(roleId);
|
|
284
|
-
if (role?.permissions) permissions = addPermissionBits(permissions, role.permissions);
|
|
285
|
-
}
|
|
253
|
+
let permissions = addPermissionBits(0n, rolesByIdLocal.get(params.guild.id)?.permissions);
|
|
254
|
+
for (const roleId of params.member.roles ?? []) permissions = addPermissionBits(permissions, rolesByIdLocal.get(roleId)?.permissions);
|
|
286
255
|
return permissions;
|
|
287
256
|
}
|
|
288
257
|
function rolesById(guild) {
|
|
@@ -303,20 +272,19 @@ function resolveMemberChannelPermissionBits(params) {
|
|
|
303
272
|
if (hasAdministrator(permissions)) return ALL_PERMISSIONS;
|
|
304
273
|
const overwrites = "permission_overwrites" in params.channel ? params.channel.permission_overwrites ?? [] : [];
|
|
305
274
|
for (const overwrite of overwrites) if (overwrite.id === params.guildId) {
|
|
306
|
-
permissions = removePermissionBits(permissions, overwrite.deny
|
|
307
|
-
permissions = addPermissionBits(permissions, overwrite.allow
|
|
275
|
+
permissions = removePermissionBits(permissions, overwrite.deny);
|
|
276
|
+
permissions = addPermissionBits(permissions, overwrite.allow);
|
|
308
277
|
}
|
|
309
278
|
let roleDeny = 0n;
|
|
310
279
|
let roleAllow = 0n;
|
|
311
280
|
for (const overwrite of overwrites) if (params.member.roles?.includes(overwrite.id)) {
|
|
312
|
-
roleDeny = addPermissionBits(roleDeny, overwrite.deny
|
|
313
|
-
roleAllow = addPermissionBits(roleAllow, overwrite.allow
|
|
281
|
+
roleDeny = addPermissionBits(roleDeny, overwrite.deny);
|
|
282
|
+
roleAllow = addPermissionBits(roleAllow, overwrite.allow);
|
|
314
283
|
}
|
|
315
|
-
permissions = permissions & ~roleDeny;
|
|
316
|
-
permissions = permissions | roleAllow;
|
|
284
|
+
permissions = permissions & ~roleDeny | roleAllow;
|
|
317
285
|
for (const overwrite of overwrites) if (overwrite.id === params.userId) {
|
|
318
|
-
permissions = removePermissionBits(permissions, overwrite.deny
|
|
319
|
-
permissions = addPermissionBits(permissions, overwrite.allow
|
|
286
|
+
permissions = removePermissionBits(permissions, overwrite.deny);
|
|
287
|
+
permissions = addPermissionBits(permissions, overwrite.allow);
|
|
320
288
|
}
|
|
321
289
|
return permissions;
|
|
322
290
|
}
|
|
@@ -342,53 +310,41 @@ async function fetchMemberGuildPermissionsDiscord(guildId, userId, opts) {
|
|
|
342
310
|
return null;
|
|
343
311
|
}
|
|
344
312
|
}
|
|
345
|
-
async function
|
|
313
|
+
async function checkMemberChannelPermissions(guildId, channelId, userId, opts, check) {
|
|
346
314
|
const rest = resolveDiscordRest(opts);
|
|
347
315
|
try {
|
|
348
316
|
const channel = await getChannel(rest, channelId);
|
|
349
317
|
const permissionChannel = await resolveChannelPermissionSubject(rest, channel);
|
|
350
|
-
if (("guild_id" in permissionChannel
|
|
318
|
+
if (!("guild_id" in permissionChannel) || permissionChannel.guild_id !== guildId) return false;
|
|
351
319
|
const [guild, member] = await Promise.all([getGuild(rest, guildId), getGuildMember(rest, guildId, userId)]);
|
|
352
320
|
if (guild.owner_id === userId) return true;
|
|
353
|
-
|
|
321
|
+
return await check(resolveMemberChannelPermissionBits({
|
|
354
322
|
guildId,
|
|
355
323
|
userId,
|
|
356
324
|
guild,
|
|
357
325
|
member,
|
|
358
326
|
channel: permissionChannel
|
|
359
|
-
});
|
|
327
|
+
}), channel, rest);
|
|
328
|
+
} catch {
|
|
329
|
+
return false;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
async function canViewDiscordGuildChannel(guildId, channelId, userId, opts) {
|
|
333
|
+
return checkMemberChannelPermissions(guildId, channelId, userId, opts, async (permissions, channel, rest) => {
|
|
360
334
|
if (!hasPermissionBit(permissions, PermissionFlagsBits.ViewChannel)) return false;
|
|
361
335
|
if ("type" in channel && channel.type === ChannelType.PrivateThread) {
|
|
362
336
|
if (hasPermissionBit(permissions, PermissionFlagsBits.ManageThreads)) return true;
|
|
363
337
|
await getThreadMember(rest, channel.id, userId);
|
|
364
338
|
}
|
|
365
339
|
return true;
|
|
366
|
-
}
|
|
367
|
-
return false;
|
|
368
|
-
}
|
|
340
|
+
});
|
|
369
341
|
}
|
|
370
342
|
/**
|
|
371
343
|
* Returns true when the user has ADMINISTRATOR or any required permission bit
|
|
372
344
|
* after applying channel/category overwrites.
|
|
373
345
|
*/
|
|
374
346
|
async function hasAnyChannelPermissionDiscord(guildId, channelId, userId, requiredPermissions, opts) {
|
|
375
|
-
|
|
376
|
-
try {
|
|
377
|
-
const permissionChannel = await resolveChannelPermissionSubject(rest, await getChannel(rest, channelId));
|
|
378
|
-
if (("guild_id" in permissionChannel ? permissionChannel.guild_id : void 0) !== guildId) return false;
|
|
379
|
-
const [guild, member] = await Promise.all([getGuild(rest, guildId), getGuildMember(rest, guildId, userId)]);
|
|
380
|
-
if (guild.owner_id === userId) return true;
|
|
381
|
-
const permissions = resolveMemberChannelPermissionBits({
|
|
382
|
-
guildId,
|
|
383
|
-
userId,
|
|
384
|
-
guild,
|
|
385
|
-
member,
|
|
386
|
-
channel: permissionChannel
|
|
387
|
-
});
|
|
388
|
-
return requiredPermissions.some((permission) => hasPermissionBit(permissions, permission));
|
|
389
|
-
} catch {
|
|
390
|
-
return false;
|
|
391
|
-
}
|
|
347
|
+
return checkMemberChannelPermissions(guildId, channelId, userId, opts, (permissions) => requiredPermissions.some((permission) => hasPermissionBit(permissions, permission)));
|
|
392
348
|
}
|
|
393
349
|
async function canManageGuildMemberRoleDiscord(guildId, senderUserId, targetUserId, roleId, opts, requirements) {
|
|
394
350
|
const rest = resolveDiscordRest(opts);
|
|
@@ -428,26 +384,23 @@ async function canManageGuildRoleDiscord(guildId, senderUserId, roleId, opts) {
|
|
|
428
384
|
}
|
|
429
385
|
}
|
|
430
386
|
/**
|
|
431
|
-
* Returns true when the user has ADMINISTRATOR or required permission bits
|
|
432
|
-
* matching the provided predicate.
|
|
387
|
+
* Returns true when the user has ADMINISTRATOR or the required permission bits.
|
|
433
388
|
*/
|
|
434
|
-
async function hasGuildPermissionsDiscord(guildId, userId, requiredPermissions,
|
|
389
|
+
async function hasGuildPermissionsDiscord(guildId, userId, requiredPermissions, match, opts) {
|
|
435
390
|
const permissions = await fetchMemberGuildPermissionsDiscord(guildId, userId, opts);
|
|
436
|
-
|
|
437
|
-
if (hasAdministrator(permissions)) return true;
|
|
438
|
-
return check(permissions, requiredPermissions);
|
|
391
|
+
return permissions !== null && (hasAdministrator(permissions) || requiredPermissions[match]((permission) => hasPermissionBit(permissions, permission)));
|
|
439
392
|
}
|
|
440
393
|
/**
|
|
441
394
|
* Returns true when the user has ADMINISTRATOR or any required permission bit.
|
|
442
395
|
*/
|
|
443
396
|
async function hasAnyGuildPermissionDiscord(guildId, userId, requiredPermissions, opts) {
|
|
444
|
-
return await hasGuildPermissionsDiscord(guildId, userId, requiredPermissions,
|
|
397
|
+
return await hasGuildPermissionsDiscord(guildId, userId, requiredPermissions, "some", opts);
|
|
445
398
|
}
|
|
446
399
|
/**
|
|
447
400
|
* Returns true when the user has ADMINISTRATOR or all required permission bits.
|
|
448
401
|
*/
|
|
449
402
|
async function hasAllGuildPermissionsDiscord(guildId, userId, requiredPermissions, opts) {
|
|
450
|
-
return await hasGuildPermissionsDiscord(guildId, userId, requiredPermissions,
|
|
403
|
+
return await hasGuildPermissionsDiscord(guildId, userId, requiredPermissions, "every", opts);
|
|
451
404
|
}
|
|
452
405
|
async function fetchChannelPermissionsDiscord(channelId, opts) {
|
|
453
406
|
opts.signal?.throwIfAborted();
|
|
@@ -491,7 +444,7 @@ var DiscordSendError = class extends Error {
|
|
|
491
444
|
constructor(message, opts) {
|
|
492
445
|
super(message);
|
|
493
446
|
this.name = "DiscordSendError";
|
|
494
|
-
|
|
447
|
+
Object.assign(this, opts);
|
|
495
448
|
}
|
|
496
449
|
toString() {
|
|
497
450
|
return this.message;
|
|
@@ -511,8 +464,10 @@ const DISCORD_CANNOT_DM = 50007;
|
|
|
511
464
|
const DISCORD_UPLOAD_TOO_LARGE = 40005;
|
|
512
465
|
const DISCORD_UPLOAD_TOO_LARGE_STATUS = 413;
|
|
513
466
|
const DISCORD_UPLOAD_TOO_LARGE_NOTICE = "Attachment skipped: Discord rejected the file as too large.";
|
|
514
|
-
function resolveRequiredDiscordSendPermissions(channelType) {
|
|
515
|
-
|
|
467
|
+
function resolveRequiredDiscordSendPermissions(channelType, hasMedia) {
|
|
468
|
+
const permissions = isDiscordThreadChannelType(channelType) ? ["ViewChannel", "SendMessagesInThreads"] : ["ViewChannel", "SendMessages"];
|
|
469
|
+
if (hasMedia) permissions.push("AttachFiles");
|
|
470
|
+
return permissions;
|
|
516
471
|
}
|
|
517
472
|
function normalizeReactionEmoji(raw) {
|
|
518
473
|
const trimmed = raw.trim();
|
|
@@ -546,17 +501,17 @@ function normalizeDiscordPollInput(input) {
|
|
|
546
501
|
layout_type: PollLayoutType.Default
|
|
547
502
|
};
|
|
548
503
|
}
|
|
504
|
+
function readDiscordErrorNumber(value, finiteNumbers = false) {
|
|
505
|
+
if (typeof value === "number") return !finiteNumbers || Number.isFinite(value) ? value : void 0;
|
|
506
|
+
return typeof value === "string" && /^\d+$/.test(value) ? Number(value) : void 0;
|
|
507
|
+
}
|
|
549
508
|
function getDiscordErrorCode(err) {
|
|
550
509
|
if (!err || typeof err !== "object") return;
|
|
551
|
-
|
|
552
|
-
if (typeof candidate === "number") return candidate;
|
|
553
|
-
if (typeof candidate === "string" && /^\d+$/.test(candidate)) return Number(candidate);
|
|
510
|
+
return readDiscordErrorNumber("code" in err && err.code !== void 0 ? err.code : "rawError" in err && err.rawError && typeof err.rawError === "object" ? err.rawError.code : void 0);
|
|
554
511
|
}
|
|
555
512
|
function getDiscordErrorStatus(err) {
|
|
556
513
|
if (!err || typeof err !== "object") return;
|
|
557
|
-
|
|
558
|
-
if (typeof candidate === "number" && Number.isFinite(candidate)) return candidate;
|
|
559
|
-
if (typeof candidate === "string" && /^\d+$/.test(candidate)) return Number(candidate);
|
|
514
|
+
return readDiscordErrorNumber("status" in err && err.status !== void 0 ? err.status : "statusCode" in err && err.statusCode !== void 0 ? err.statusCode : void 0, true);
|
|
560
515
|
}
|
|
561
516
|
function isDiscordUploadTooLargeError(err) {
|
|
562
517
|
return getDiscordErrorCode(err) === DISCORD_UPLOAD_TOO_LARGE || getDiscordErrorStatus(err) === DISCORD_UPLOAD_TOO_LARGE_STATUS;
|
|
@@ -583,16 +538,12 @@ async function buildDiscordSendError(err, ctx) {
|
|
|
583
538
|
});
|
|
584
539
|
probedChannelType = permissions.channelType;
|
|
585
540
|
const current = new Set(permissions.permissions);
|
|
586
|
-
|
|
587
|
-
if (ctx.hasMedia) required.push("AttachFiles");
|
|
588
|
-
missing = required.filter((permission) => !current.has(permission));
|
|
541
|
+
missing = resolveRequiredDiscordSendPermissions(probedChannelType, ctx.hasMedia).filter((permission) => !current.has(permission));
|
|
589
542
|
} catch {}
|
|
590
543
|
const status = getDiscordErrorStatus(err);
|
|
591
544
|
const apiDetails = [`code=${code}`, status != null ? `status=${status}` : void 0].filter(Boolean).join(" ");
|
|
592
|
-
const
|
|
593
|
-
|
|
594
|
-
const probeSummary = probedPermissions.join("/");
|
|
595
|
-
return new DiscordSendError(`${missing.length ? `discord missing permissions in channel ${ctx.channelId}: ${missing.join(", ")}` : `discord missing permissions in channel ${ctx.channelId}; permission probe did not identify missing ${probeSummary}`} (${apiDetails}). bot might be blocked by channel/thread overrides, archived thread state, reply target visibility, or app-role position`, {
|
|
545
|
+
const probeSummary = resolveRequiredDiscordSendPermissions(probedChannelType, ctx.hasMedia).join("/");
|
|
546
|
+
return new DiscordSendError(`${missing.length ? `discord missing permissions in channel ${ctx.channelId}: ${missing.join(", ")}` : `discord missing permissions in channel ${ctx.channelId}; permission check did not identify missing ${probeSummary}`} (${apiDetails}). bot might be blocked by channel/thread overrides, archived thread state, reply target visibility, or app-role position`, {
|
|
596
547
|
kind: "missing-permissions",
|
|
597
548
|
channelId: ctx.channelId,
|
|
598
549
|
missingPermissions: missing,
|
|
@@ -615,11 +566,7 @@ async function resolveDiscordTargetChannelId(raw, opts) {
|
|
|
615
566
|
return await resolveChannelId(rest, recipient, request);
|
|
616
567
|
}
|
|
617
568
|
async function resolveDiscordChannel(rest, channelId) {
|
|
618
|
-
|
|
619
|
-
return await getChannel(rest, channelId);
|
|
620
|
-
} catch {
|
|
621
|
-
return;
|
|
622
|
-
}
|
|
569
|
+
return getChannel(rest, channelId).catch(() => void 0);
|
|
623
570
|
}
|
|
624
571
|
function buildDiscordTextChunks(text, opts = {}) {
|
|
625
572
|
if (!text) return [];
|
|
@@ -669,7 +616,7 @@ async function sendDiscordChunks(params, upload) {
|
|
|
669
616
|
result = await params.request(async () => {
|
|
670
617
|
await params.onPlatformSendDispatch?.();
|
|
671
618
|
params.assertPlatformSendAuthorized?.();
|
|
672
|
-
return
|
|
619
|
+
return createChannelMessage(params.rest, params.channelId, { body });
|
|
673
620
|
}, files ? "media" : "text", { safety: "nonce-protected-create" });
|
|
674
621
|
} catch (error) {
|
|
675
622
|
if (files && upload) return upload.onRejected(error);
|
|
@@ -685,9 +632,6 @@ async function sendDiscordChunks(params, upload) {
|
|
|
685
632
|
platformMessageIds
|
|
686
633
|
};
|
|
687
634
|
}
|
|
688
|
-
async function sendDiscordText(params) {
|
|
689
|
-
return sendDiscordChunks(params);
|
|
690
|
-
}
|
|
691
635
|
async function sendDiscordMedia(params) {
|
|
692
636
|
const media = await loadOutboundMediaFromUrl(params.mediaUrl, {
|
|
693
637
|
maxBytes: params.maxBytes,
|
|
@@ -704,7 +648,7 @@ async function sendDiscordMedia(params) {
|
|
|
704
648
|
}],
|
|
705
649
|
onRejected(error) {
|
|
706
650
|
if (!isDiscordUploadTooLargeError(error)) throw error;
|
|
707
|
-
return
|
|
651
|
+
return sendDiscordChunks({
|
|
708
652
|
...params,
|
|
709
653
|
text: buildDiscordUploadTooLargeFallbackText(params.text),
|
|
710
654
|
components: void 0,
|
|
@@ -718,4 +662,4 @@ function buildReactionIdentifier(emoji) {
|
|
|
718
662
|
return emoji.name ?? "";
|
|
719
663
|
}
|
|
720
664
|
//#endregion
|
|
721
|
-
export { resolveDiscordSendEmbeds as A, validateDiscordProxyUrl as B, hasAnyChannelPermissionDiscord as C, createDiscordMessageNonce as D, buildDiscordMessageRequest as E, createDiscordRuntimeAccountContext as F, unregisterGateway as G, clearGateways as H, resolveDiscordClientAccountContext as I, resolveDiscordRest as L, parseAndResolveChannelRecipient as M, createDiscordClient as N, resolveDiscordMessageFlags as O, createDiscordRestClient as P, DISCORD_REST_TIMEOUT_MS as R, hasAllGuildPermissionsDiscord as S, SUPPRESS_NOTIFICATIONS_FLAG as T, getGateway as U, withValidatedDiscordProxy as V, registerGateway as W, canManageGuildMemberRoleDiscord as _, normalizeEmojiName as a, fetchChannelPermissionsDiscord as b, resolveChannelId as c,
|
|
665
|
+
export { resolveDiscordSendEmbeds as A, validateDiscordProxyUrl as B, hasAnyChannelPermissionDiscord as C, createDiscordMessageNonce as D, buildDiscordMessageRequest as E, createDiscordRuntimeAccountContext as F, unregisterGateway as G, clearGateways as H, resolveDiscordClientAccountContext as I, resolveDiscordRest as L, parseAndResolveChannelRecipient as M, createDiscordClient as N, resolveDiscordMessageFlags as O, createDiscordRestClient as P, DISCORD_REST_TIMEOUT_MS as R, hasAllGuildPermissionsDiscord as S, SUPPRESS_NOTIFICATIONS_FLAG as T, getGateway as U, withValidatedDiscordProxy as V, registerGateway as W, canManageGuildMemberRoleDiscord as _, normalizeEmojiName as a, fetchChannelPermissionsDiscord as b, resolveChannelId as c, sendDiscordChunks as d, sendDiscordMedia as f, DiscordSendError as g, DISCORD_MAX_STICKER_BYTES as h, normalizeDiscordPollInput as i, resolveDiscordSuppressEmbeds as j, resolveDiscordSendComponents as k, resolveDiscordChannel as l, DISCORD_MAX_EVENT_COVER_BYTES as m, buildDiscordTextChunks as n, normalizeReactionEmoji as o, DISCORD_MAX_EMOJI_BYTES as p, buildReactionIdentifier as r, normalizeStickerIds as s, buildDiscordSendError as t, resolveDiscordTargetChannelId as u, canManageGuildRoleDiscord as v, hasAnyGuildPermissionDiscord as w, fetchMemberGuildPermissionsDiscord as x, canViewDiscordGuildChannel as y, resolveDiscordProxyFetchForAccount as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as formatDiscordUserTag } from "./allow-list-
|
|
1
|
+
import { S as formatDiscordUserTag } from "./allow-list-B_ToXtew.mjs";
|
|
2
2
|
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
3
|
//#region extensions/discord/src/monitor/sender-identity.ts
|
|
4
4
|
function resolveDiscordWebhookId(message) {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { c as
|
|
2
|
-
import { t as inspectDiscordAccount } from "./account-inspect-
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { c as resolveDefaultDiscordAccountId, f as resolveDiscordAccountDisabledReason, i as listDiscordAccountIds, l as resolveDiscordAccount, p as resolveDiscordAccountDmPolicy, r as isDiscordAccountEnabledForRuntime, s as mergeDiscordAccountConfig, u as resolveDiscordAccountAllowFrom } from "./accounts-ljrzXBJi.mjs";
|
|
2
|
+
import { t as inspectDiscordAccount } from "./account-inspect-8cCu6uPG.mjs";
|
|
3
|
+
import { t as parseDiscordTarget } from "./target-parsing-C-HyNxcE.mjs";
|
|
4
|
+
import { n as discordIngressIdentity, t as selectDiscordLivePolicyConfig } from "./live-policy-config-BPoB3eQi.mjs";
|
|
5
|
+
import { t as DiscordChannelConfigSchema } from "./config-schema-_uBILpQf.mjs";
|
|
6
|
+
import { n as normalizeCompatibilityConfig } from "./doctor-contract-Bwv8EuQ_.mjs";
|
|
7
|
+
import { r as secretTargetRegistryEntries, t as collectRuntimeConfigAssignments } from "./secret-config-contract-CIsH7R3B.mjs";
|
|
8
|
+
import { n as unsupportedSecretRefSurfacePatterns, t as collectUnsupportedSecretRefConfigCandidates } from "./security-contract-DNyyjTZZ.mjs";
|
|
8
9
|
import { t as deriveLegacySessionChatType } from "./session-contract-BO5tlIdl.mjs";
|
|
9
10
|
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
10
11
|
import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
@@ -51,17 +52,15 @@ const collectDiscordSecurityWarnings = createOpenProviderConfiguredRouteWarningC
|
|
|
51
52
|
remediation: "Set channels.discord.groupPolicy=\"allowlist\" and configure channels.discord.guilds.<id>.channels"
|
|
52
53
|
}
|
|
53
54
|
});
|
|
54
|
-
const collectDiscordSecurityFindings = createConditionalWarningCollector.findings({
|
|
55
|
-
collectWarnings: collectDiscordSecurityWarnings,
|
|
56
|
-
checkId: "channels.discord.groups.open",
|
|
57
|
-
severity: "warn",
|
|
58
|
-
title: "Discord security warning"
|
|
59
|
-
});
|
|
60
|
-
const loadDiscordSecurityAuditModule = createLazyRuntimeModule(() => import("./security-audit-D42cp5N7.mjs").then((n) => n.n));
|
|
61
55
|
const discordSecurityAdapter = {
|
|
62
56
|
resolveDmPolicy: resolveDiscordDmPolicy,
|
|
63
|
-
collectWarnings:
|
|
64
|
-
|
|
57
|
+
collectWarnings: createConditionalWarningCollector.findings({
|
|
58
|
+
collectWarnings: collectDiscordSecurityWarnings,
|
|
59
|
+
checkId: "channels.discord.groups.open",
|
|
60
|
+
severity: "warn",
|
|
61
|
+
title: "Discord security warning"
|
|
62
|
+
}),
|
|
63
|
+
collectAuditFindings: async (params) => (await import("./security-audit-BFT84Uny.mjs").then((n) => n.n)).collectDiscordSecurityAuditFindings(params)
|
|
65
64
|
};
|
|
66
65
|
//#endregion
|
|
67
66
|
//#region extensions/discord/src/setup-adapter.ts
|
|
@@ -101,7 +100,7 @@ const DISCORD_LEGACY_CONFIG_RULES = [];
|
|
|
101
100
|
//#region extensions/discord/src/shared.ts
|
|
102
101
|
const DISCORD_CHANNEL = "discord";
|
|
103
102
|
const livePolicyConfigPrefixes = Object.keys(selectDiscordLivePolicyConfig({})).flatMap((key) => [`channels.discord.${key}`, `channels.discord.accounts.*.${key}`]);
|
|
104
|
-
const loadDiscordDoctorModule = createLazyRuntimeModule(() => import("./doctor-
|
|
103
|
+
const loadDiscordDoctorModule = createLazyRuntimeModule(() => import("./doctor-DSrNJ7m2.mjs"));
|
|
105
104
|
const discordDoctor = {
|
|
106
105
|
dmAllowFromMode: "topOnly",
|
|
107
106
|
groupModel: "route",
|
|
@@ -194,8 +193,8 @@ function createDiscordPluginBase(params) {
|
|
|
194
193
|
config: {
|
|
195
194
|
...discordConfigAdapter,
|
|
196
195
|
hasConfiguredState: ({ env }) => typeof env?.DISCORD_BOT_TOKEN === "string" && env.DISCORD_BOT_TOKEN.trim().length > 0,
|
|
197
|
-
isEnabled:
|
|
198
|
-
disabledReason:
|
|
196
|
+
isEnabled: isDiscordAccountEnabledForRuntime,
|
|
197
|
+
disabledReason: resolveDiscordAccountDisabledReason,
|
|
199
198
|
isConfigured: (account) => resolveConfiguredFromCredentialStatuses(account) ?? Boolean(account.token?.trim()),
|
|
200
199
|
describeAccount: (account) => describeAccountSnapshot({
|
|
201
200
|
account,
|
|
@@ -206,7 +205,18 @@ function createDiscordPluginBase(params) {
|
|
|
206
205
|
}
|
|
207
206
|
})
|
|
208
207
|
},
|
|
209
|
-
messaging: {
|
|
208
|
+
messaging: {
|
|
209
|
+
deriveLegacySessionChatType,
|
|
210
|
+
directTargetStyle: "user-prefixed",
|
|
211
|
+
inferTargetChatType: ({ to }) => {
|
|
212
|
+
try {
|
|
213
|
+
const parsed = parseDiscordTarget(to, { defaultKind: "channel" });
|
|
214
|
+
return parsed ? parsed.kind === "user" ? "direct" : "channel" : void 0;
|
|
215
|
+
} catch {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
},
|
|
210
220
|
security: discordSecurityAdapter,
|
|
211
221
|
secrets: {
|
|
212
222
|
secretTargetRegistryEntries,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.mjs";
|
|
2
|
-
import { x as ensureBindingsLoadedAsync } from "./thread-bindings.session-updates-
|
|
3
|
-
import { o as listThreadBindingsBySessionKey, u as unbindThreadBindingsBySessionKeyAsync } from "./thread-bindings-
|
|
2
|
+
import { x as ensureBindingsLoadedAsync } from "./thread-bindings.session-updates-DGSljVf6.mjs";
|
|
3
|
+
import { o as listThreadBindingsBySessionKey, u as unbindThreadBindingsBySessionKeyAsync } from "./thread-bindings-0hPTSK14.mjs";
|
|
4
4
|
import { normalizeOptionalLowercaseString, normalizeOptionalStringifiedId } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
5
5
|
//#region extensions/discord/src/subagent-hooks.ts
|
|
6
6
|
var subagent_hooks_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -8,15 +8,12 @@ var subagent_hooks_exports = /* @__PURE__ */ __exportAll({
|
|
|
8
8
|
handleDiscordSubagentDeliveryTargetAsync: () => handleDiscordSubagentDeliveryTargetAsync,
|
|
9
9
|
handleDiscordSubagentEnded: () => handleDiscordSubagentEnded
|
|
10
10
|
});
|
|
11
|
-
function normalizeThreadBindingTargetKind(raw) {
|
|
12
|
-
const normalized = normalizeOptionalLowercaseString(raw);
|
|
13
|
-
if (normalized === "subagent" || normalized === "acp") return normalized;
|
|
14
|
-
}
|
|
15
11
|
async function handleDiscordSubagentEnded(event) {
|
|
12
|
+
const targetKind = normalizeOptionalLowercaseString(event.targetKind);
|
|
16
13
|
await unbindThreadBindingsBySessionKeyAsync({
|
|
17
14
|
targetSessionKey: event.targetSessionKey,
|
|
18
15
|
accountId: event.accountId,
|
|
19
|
-
targetKind:
|
|
16
|
+
targetKind: targetKind === "subagent" || targetKind === "acp" ? targetKind : void 0,
|
|
20
17
|
reason: event.reason,
|
|
21
18
|
sendFarewell: event.sendFarewell
|
|
22
19
|
});
|
|
@@ -40,9 +37,7 @@ function resolveDiscordDeliveryTarget(event) {
|
|
|
40
37
|
...requesterAccountId ? { accountId: requesterAccountId } : {},
|
|
41
38
|
targetKind: "subagent"
|
|
42
39
|
});
|
|
43
|
-
|
|
44
|
-
if (requesterThreadId) binding = bindings.find((entry) => entry.threadId === requesterThreadId && (!requesterAccountId || entry.accountId === requesterAccountId));
|
|
45
|
-
if (!binding && bindings.length === 1) binding = bindings[0];
|
|
40
|
+
const binding = (requesterThreadId ? bindings.find((entry) => entry.threadId === requesterThreadId && (!requesterAccountId || entry.accountId === requesterAccountId)) : void 0) ?? (bindings.length === 1 ? bindings[0] : void 0);
|
|
46
41
|
if (!binding) return;
|
|
47
42
|
return { origin: {
|
|
48
43
|
channel: "discord",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as formatDiscordUserTag } from "./allow-list-
|
|
2
|
-
import { t as discord_exports } from "./discord-
|
|
1
|
+
import { S as formatDiscordUserTag } from "./allow-list-B_ToXtew.mjs";
|
|
2
|
+
import { t as discord_exports } from "./discord-BGqgx-yd.mjs";
|
|
3
3
|
//#region extensions/discord/src/monitor/system-events.ts
|
|
4
4
|
const SYSTEM_EVENT_ACTIONS = /* @__PURE__ */ new Map([
|
|
5
5
|
[discord_exports.MessageType.ChannelPinnedMessage, "pinned a message"],
|