@openclaw/discord 2026.10.10 → 2026.11.5-beta.1
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-X_Xlr42B.mjs → account-inspect-CSz5Qodj.mjs} +1 -1
- package/dist/.setup/{accounts-C18HNgge.mjs → accounts-DtjvhJUj.mjs} +9 -6
- package/dist/.setup/{active-turn-thread-route-BAc_Xik-.mjs → active-turn-thread-route-DkPnk2x8.mjs} +1 -2
- package/dist/.setup/{allow-list-D1ZGfhXh.mjs → allow-list-DahA0Jxh.mjs} +3 -150
- package/dist/.setup/{api-Bth1wKF9.mjs → api-Bp0HI4q3.mjs} +10 -20
- package/dist/.setup/{approval-handler.runtime-BAoEELJJ.mjs → approval-handler.runtime-Cy53ugTf.mjs} +80 -61
- package/dist/.setup/{approval-message-updates-Cks-MSCJ.mjs → approval-message-updates-DqOXxPss.mjs} +2 -2
- package/dist/.setup/{audit-Dw_rAZIz.mjs → audit-DoPKOfQE.mjs} +4 -4
- package/dist/.setup/{channel-BMpMAeQL.mjs → channel-Ds6iuNdy.mjs} +134 -201
- package/dist/.setup/channel-access-DhJhVrdZ.mjs +23 -0
- package/dist/.setup/channel.setup-BLt9dkIG.mjs +235 -0
- package/dist/.setup/{components-BvOWSPxr.mjs → components-WTfUxead.mjs} +208 -426
- package/dist/.setup/components.base-C5sAPHe4.mjs +31 -0
- package/dist/.setup/{config-schema-Coyq5wOr.mjs → config-schema-GX2yDgIH.mjs} +6 -7
- package/dist/.setup/{conversation-binding-route-DOPUZNYo.mjs → conversation-binding-route-CZdm-X5A.mjs} +2 -2
- package/dist/.setup/{directory-config-CIqVnQtn.mjs → directory-config-BXJuh9-J.mjs} +1 -1
- package/dist/.setup/{directory-live-DUuPEWub.mjs → directory-live-CEopeb8Q.mjs} +55 -62
- package/dist/.setup/{discord-eFlHX1Gn.mjs → discord-r79VFjJp.mjs} +1087 -1664
- package/dist/.setup/{doctor-Dty_Ossy.mjs → doctor-UfLW8nye.mjs} +3 -5
- package/dist/.setup/endpoint-runtime-BM3x-m6O.mjs +138 -0
- package/dist/.setup/guilds-DQucP5Tn.mjs +21 -0
- package/dist/.setup/{handle-action-DXY91jF-.mjs → handle-action-BarHOi-v.mjs} +15 -15
- package/dist/.setup/{handle-action.guild-admin-BvBCfhXF.mjs → handle-action.guild-admin-oRUb8p_O.mjs} +5 -5
- package/dist/.setup/listeners-CHgTENFu.mjs +46 -0
- package/dist/.setup/{live-policy-config-DO1Fk2hp.mjs → live-policy-config-EKp4O6zx.mjs} +2 -3
- package/dist/.setup/{message-handler-fL1j1NiR.mjs → message-handler-DUeT8Asf.mjs} +154 -113
- package/dist/.setup/{message-handler.preflight-DkjwNZAd.mjs → message-handler.preflight-C6TNtKW0.mjs} +30 -104
- package/dist/.setup/{message-handler.preflight-pluralkit-DR4BnvMU.mjs → message-handler.preflight-pluralkit-6E9TFmmN.mjs} +9 -22
- package/dist/.setup/{message-handler.process-ClOwIPDK.mjs → message-handler.process-D8_oQ5Cp.mjs} +256 -367
- package/dist/.setup/outbound-payload-DUsrFICb.mjs +445 -0
- package/dist/.setup/{outbound-session-route-TFBPPkoz.mjs → outbound-session-route-Cb8cv4Oi.mjs} +138 -86
- package/dist/.setup/{preflight-audio-CwtPIsvk.mjs → preflight-audio-r4BbaJxh.mjs} +1 -5
- package/dist/.setup/{presence-cache-CgutE4NN.mjs → presence-cache-B3xj3b0l.mjs} +1 -6
- package/dist/.setup/{probe-DNge7OEP.mjs → probe-BUmJyH35.mjs} +5 -9
- package/dist/.setup/{provider-BBDuE14w.mjs → provider-Dm2ERSxe.mjs} +3600 -4454
- package/dist/.setup/{provider-session.runtime-D8hMXXqJ.mjs → provider-session.runtime-DCIqDsIg.mjs} +3 -3
- package/dist/.setup/provider.runtime-DmxPGoUg.mjs +1 -0
- package/dist/.setup/proxy-fetch-B8cK6FLQ.mjs +29 -0
- package/dist/.setup/{realtime-session.runtime-cetognkp.mjs → realtime-session.runtime-WJL6NdwK.mjs} +43 -81
- package/dist/.setup/{receive-recovery-C77CVdGM.mjs → receive-recovery-DV_v5ROf.mjs} +13 -27
- package/dist/.setup/{resolve-allowlist-common-CI77288n.mjs → resolve-allowlist-common-C37fgnYG.mjs} +3 -12
- package/dist/.setup/{resolve-channels-DYc6-xgV.mjs → resolve-channels-CwpnQ7C2.mjs} +5 -4
- package/dist/.setup/{resolve-users-BQT7XWF2.mjs → resolve-users-D6jSwe8R.mjs} +4 -7
- package/dist/.setup/{runtime-CcijhTJT.mjs → runtime-B-PgPsGR.mjs} +6 -6
- package/dist/.setup/{runtime-CI0UJqeS.mjs → runtime-DhOMlnYS.mjs} +196 -235
- package/dist/.setup/{secret-config-contract-BdbCvqnM.mjs → secret-config-contract-CP6teHec.mjs} +4 -9
- package/dist/.setup/{send-Cbq-IVsS.mjs → send-DnLL6XoO.mjs} +149 -174
- package/dist/.setup/{send.components-BV6ucNpJ.mjs → send.components-xB43CksK.mjs} +61 -71
- package/dist/.setup/{send.outbound-CGhBhzjQ.mjs → send.outbound-B11X6TOE.mjs} +75 -129
- package/dist/.setup/{send.receipt-Dw-_r5Bx.mjs → send.receipt-CMteCIZS.mjs} +29 -31
- package/dist/.setup/{send.shared-D4MioxW_.mjs → send.shared-BcLLZBul.mjs} +38 -112
- package/dist/.setup/{sender-identity-DrN5c4ec.mjs → sender-identity-CGNpdJmb.mjs} +3 -9
- package/dist/.setup/setup-plugin-api-C6AMx3hu.mjs +2 -0
- package/dist/.setup/{shared-Bp0sxD5R.mjs → shared-BEYw16he.mjs} +8 -10
- package/dist/.setup/shared-interactive-DKBw4SNV.mjs +311 -0
- package/dist/.setup/{subagent-hooks-mQbDkvuD.mjs → subagent-hooks-DlYElpXa.mjs} +1 -1
- package/dist/.setup/{system-events-2zc2eGfF.mjs → system-events--Pk6y9aP.mjs} +2 -2
- package/dist/.setup/{target-resolver-CAHeVfmZ.mjs → target-resolver-Bo9EpGp_.mjs} +3 -3
- package/dist/.setup/{thread-bindings-Dg7X_ZXP.mjs → thread-bindings-BF-hr-bg.mjs} +12 -20
- package/dist/.setup/{thread-bindings.manager-DCDYksah.mjs → thread-bindings.manager-CQCkha5r.mjs} +22 -42
- package/dist/.setup/{thread-bindings.session-updates-C76plLS3.mjs → thread-bindings.session-updates-C2gJAj_I.mjs} +11 -18
- package/dist/.setup/{threading-l0UfrE6x.mjs → threading-HA9C2wYR.mjs} +68 -104
- package/dist/.setup/{timeouts-DTrUsJ_W.mjs → timeouts-CT9hnmo4.mjs} +1 -1
- package/dist/.setup/{transcripts-source-CGgOaWcu.mjs → transcripts-source-DzpzETZR.mjs} +102 -172
- package/dist/.setup/{voice-runtime-DY1EwDfi.mjs → voice-runtime-Bo_nsVvX.mjs} +231 -448
- package/dist/.source-module-urls/d6c089460280c5a04184542d6712e04545caeb1ebb290d3504377b4cc5e22fea.json +1 -1
- package/dist/account-inspect-api.js +1 -1
- package/dist/action-runtime-api.js +1 -1
- package/dist/activities-api.js +285 -337
- package/dist/api.js +16 -16
- package/dist/assets/embedded-app-sdk.mjs +1 -1
- 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/runtime-api.js +22 -22
- package/dist/secret-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 +56 -68
- package/dist/subagent-hooks-api.js +1 -1
- package/dist/transcripts-source-api.js +1 -1
- package/node_modules/@discord/embedded-app-sdk/output/lib/zod/lib/index.cjs +2 -3
- package/node_modules/@discord/embedded-app-sdk/output/lib/zod/lib/index.mjs +2 -3
- package/node_modules/@napi-rs/wasm-runtime/dist/fs.js +3339 -4021
- package/node_modules/@napi-rs/wasm-runtime/package.json +1 -1
- package/node_modules/@types/lodash/README.md +1 -1
- package/node_modules/@types/lodash/common/function.d.ts +2 -2
- package/node_modules/@types/lodash/package.json +2 -2
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/package.json +2 -2
- package/node_modules/@types/node/util.d.ts +6 -3
- package/node_modules/discord-api-types/package.json +4 -4
- package/node_modules/discord-api-types/rest/v10/index.d.ts +8 -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 +8 -0
- package/node_modules/discord-api-types/rest/v10/index.js.map +1 -1
- package/node_modules/discord-api-types/rest/v10/oauth2.d.ts +26 -2
- package/node_modules/discord-api-types/rest/v10/oauth2.d.ts.map +1 -1
- package/node_modules/discord-api-types/rest/v9/index.d.ts +8 -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 +8 -0
- package/node_modules/discord-api-types/rest/v9/index.js.map +1 -1
- package/node_modules/discord-api-types/rest/v9/oauth2.d.ts +26 -2
- package/node_modules/discord-api-types/rest/v9/oauth2.d.ts.map +1 -1
- package/node_modules/typebox/build/format/duration.d.mts +2 -2
- package/node_modules/typebox/build/format/duration.mjs +2 -2
- package/node_modules/typebox/build/format/idn_email.d.mts +1 -0
- package/node_modules/typebox/build/format/idn_email.mjs +1 -0
- package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -1
- package/node_modules/typebox/build/format/idn_hostname.mjs +1 -1
- package/node_modules/typebox/build/format/ipv4.d.mts +2 -2
- package/node_modules/typebox/build/format/ipv4.mjs +2 -2
- package/node_modules/typebox/build/format/ipv6.d.mts +1 -1
- package/node_modules/typebox/build/format/ipv6.mjs +1 -1
- package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
- package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
- package/node_modules/typebox/build/schema/build.mjs +1 -0
- package/node_modules/typebox/build/schema/engine/_unique.d.mts +4 -2
- package/node_modules/typebox/build/schema/engine/_unique.mjs +7 -3
- package/node_modules/typebox/build/schema/engine/additionalItems.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/additionalProperties.d.mts +0 -3
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +15 -17
- package/node_modules/typebox/build/schema/engine/contains.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/index.d.mts +1 -0
- package/node_modules/typebox/build/schema/engine/index.mjs +1 -0
- package/node_modules/typebox/build/schema/engine/items.mjs +7 -4
- package/node_modules/typebox/build/schema/engine/maxContains.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/minContains.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/oneOf.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/propertyNames.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs +2 -2
- package/node_modules/typebox/build/system/hashing/hash.mjs +63 -34
- package/node_modules/typebox/build/system/locale/en_US.mjs +2 -1
- package/node_modules/typebox/build/system/memory/assign.d.mts +2 -8
- package/node_modules/typebox/build/system/memory/assign.mjs +13 -6
- package/node_modules/typebox/build/system/memory/clone.d.mts +4 -5
- package/node_modules/typebox/build/system/memory/clone.mjs +8 -96
- package/node_modules/typebox/build/system/memory/create.d.mts +1 -5
- package/node_modules/typebox/build/system/memory/create.mjs +18 -13
- package/node_modules/typebox/build/system/memory/deep.d.mts +2 -0
- package/node_modules/typebox/build/system/memory/deep.mjs +108 -0
- package/node_modules/typebox/build/system/memory/discard.d.mts +1 -1
- package/node_modules/typebox/build/system/memory/discard.mjs +9 -8
- package/node_modules/typebox/build/system/memory/finalize.d.mts +4 -0
- package/node_modules/typebox/build/system/memory/finalize.mjs +30 -0
- package/node_modules/typebox/build/system/memory/keys.d.mts +2 -0
- package/node_modules/typebox/build/system/memory/keys.mjs +8 -0
- package/node_modules/typebox/build/system/memory/update.d.mts +1 -4
- package/node_modules/typebox/build/system/memory/update.mjs +43 -16
- package/node_modules/typebox/build/type/engine/call/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/call/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +2 -24
- package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +2 -29
- package/node_modules/typebox/build/type/engine/evaluate/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/evaluate/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +5 -1
- package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +6 -1
- package/node_modules/typebox/build/type/engine/evaluate/property.d.mts +30 -0
- package/node_modules/typebox/build/type/engine/evaluate/property.mjs +29 -0
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +1 -4
- package/node_modules/typebox/build/type/engine/object/from_intersect.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/object/from_intersect.mjs +2 -2
- package/node_modules/typebox/build/type/engine/object/from_union.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +1 -4
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +1 -4
- package/node_modules/typebox/build/type/engine/this/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/this/index.mjs +1 -0
- package/node_modules/typebox/build/value/clone/clone.d.mts +4 -3
- package/node_modules/typebox/build/value/clone/clone.mjs +5 -7
- package/node_modules/typebox/build/value/repair/from_cyclic.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_cyclic.mjs +6 -0
- package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +25 -14
- package/node_modules/typebox/package.json +1 -1
- package/node_modules/typebox/readme.md +1 -1
- package/node_modules/undici/docs/docs/api/Interceptors.md +15 -2
- package/node_modules/undici/lib/dispatcher/client-h2.js +78 -3
- package/node_modules/undici/lib/dispatcher/pool-base.js +20 -3
- package/node_modules/undici/package.json +3 -3
- package/node_modules/undici/types/api.d.ts +1 -1
- package/node_modules/undici/types/utility.d.ts +4 -4
- package/node_modules/uuid/package.json +17 -17
- package/node_modules/zod/package.json +1 -1
- package/node_modules/zod/src/v4/classic/tests/array.test.ts +27 -0
- package/node_modules/zod/src/v4/classic/tests/map.test.ts +7 -0
- package/node_modules/zod/src/v4/classic/tests/set.test.ts +6 -0
- package/node_modules/zod/src/v4/core/compile.ts +9 -0
- package/node_modules/zod/src/v4/core/schemas.ts +35 -1
- package/node_modules/zod/src/v4/core/util.ts +13 -0
- package/node_modules/zod/src/v4/core/versions.ts +1 -1
- package/node_modules/zod/v4/core/compile.cjs +8 -0
- package/node_modules/zod/v4/core/compile.js +8 -0
- package/node_modules/zod/v4/core/schemas.cjs +30 -0
- package/node_modules/zod/v4/core/schemas.d.cts +3 -1
- package/node_modules/zod/v4/core/schemas.d.ts +3 -1
- package/node_modules/zod/v4/core/schemas.js +30 -0
- package/node_modules/zod/v4/core/util.cjs +15 -0
- package/node_modules/zod/v4/core/util.d.cts +2 -0
- package/node_modules/zod/v4/core/util.d.ts +2 -0
- package/node_modules/zod/v4/core/util.js +14 -0
- package/node_modules/zod/v4/core/versions.cjs +1 -1
- package/node_modules/zod/v4/core/versions.js +1 -1
- package/openclaw.plugin.json +1 -31
- package/package.json +8 -8
- package/dist/.setup/channel-access-BPrWoEXM.mjs +0 -47
- package/dist/.setup/channel.setup-DVe7Y3Jf.mjs +0 -245
- package/dist/.setup/outbound-adapter-DWyAWBFh.mjs +0 -537
- package/dist/.setup/provider.runtime-BQ1z4Aq1.mjs +0 -1
- package/dist/.setup/setup-plugin-api-B4J6wmL1.mjs +0 -2
- package/dist/.setup/targets-BaklhOqq.mjs +0 -3
- package/node_modules/typebox/build/system/memory/freeze.d.mts +0 -4
- package/node_modules/typebox/build/system/memory/freeze.mjs +0 -6
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { c as resolveDefaultDiscordAccountId, g as resolveDiscordToken, n as inspectDiscordAccountConfig, s as mergeDiscordAccountConfig, u as resolveDiscordAccountAllowFrom } from "./accounts-DtjvhJUj.mjs";
|
|
2
|
+
import { r as discordSetupContract, t as createDiscordPluginBase } from "./shared-BEYw16he.mjs";
|
|
3
|
+
import { t as resolveDiscordChannelAllowlist } from "./resolve-channels-CwpnQ7C2.mjs";
|
|
4
|
+
import { t as resolveDiscordUserAllowlist } from "./resolve-users-D6jSwe8R.mjs";
|
|
5
|
+
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
6
|
+
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
7
|
+
import { resolveBasicAllowFromEntries } from "openclaw/plugin-sdk/allow-from";
|
|
8
|
+
import { createAccountScopedAllowFromSection, createAccountScopedGroupAccessSection, createSetupTranslator, createStandardChannelSetupStatus, defineTokenCredential, parseMentionOrPrefixedId, patchChannelConfigForAccount, promptResolvedAllowFrom, resolveEntriesWithOptionalToken, resolveSetupAccountId, setSetupChannelEnabled, splitSetupEntries } from "openclaw/plugin-sdk/setup-runtime";
|
|
9
|
+
import { createChannelDmPolicy } from "openclaw/plugin-sdk/channel-dm-policy";
|
|
10
|
+
import { formatDocsLink } from "openclaw/plugin-sdk/setup-tools";
|
|
11
|
+
// extensions/discord/src/setup-account-state.ts
|
|
12
|
+
function resolveDiscordSetupAccountConfig(params) {
|
|
13
|
+
const accountId = normalizeAccountId(params.accountId ?? resolveDefaultDiscordAccountId(params.cfg));
|
|
14
|
+
return {
|
|
15
|
+
accountId,
|
|
16
|
+
config: mergeDiscordAccountConfig(params.cfg, accountId)
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function inspectDiscordSetupAccount(params) {
|
|
20
|
+
return inspectDiscordAccountConfig(params, { resolveFallbackToken: (accountId) => resolveDiscordToken(params.cfg, { accountId }) });
|
|
21
|
+
}
|
|
22
|
+
// extensions/discord/src/setup-core.ts
|
|
23
|
+
const t = createSetupTranslator();
|
|
24
|
+
const channel = "discord";
|
|
25
|
+
const DISCORD_TOKEN_HELP_LINES = [
|
|
26
|
+
t("wizard.discord.tokenHelpCreateApplication"),
|
|
27
|
+
t("wizard.discord.tokenHelpCopyToken"),
|
|
28
|
+
t("wizard.discord.tokenHelpInviteBot"),
|
|
29
|
+
t("wizard.discord.tokenHelpMessageContentIntent"),
|
|
30
|
+
t("wizard.channels.docs", { link: formatDocsLink("/discord", "discord") })
|
|
31
|
+
];
|
|
32
|
+
function getDiscordAllowFromHelpLines() {
|
|
33
|
+
return [
|
|
34
|
+
t("wizard.discord.allowlistIntro"),
|
|
35
|
+
t("wizard.discord.examples"),
|
|
36
|
+
"- 123456789012345678",
|
|
37
|
+
"- @alice",
|
|
38
|
+
"- alice#1234",
|
|
39
|
+
t("wizard.discord.multipleEntries"),
|
|
40
|
+
t("wizard.channels.docs", { link: formatDocsLink("/discord", "discord") })
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
function setDiscordGuildChannelAllowlist(cfg, accountId, resolved) {
|
|
44
|
+
const entries = Array.isArray(resolved) ? resolved.flatMap((entry) => {
|
|
45
|
+
if (!entry || typeof entry !== "object") return [];
|
|
46
|
+
const row = entry;
|
|
47
|
+
if (row.resolved === false) return [];
|
|
48
|
+
const guildKey = normalizeOptionalString(row.guildId ?? row.guildKey);
|
|
49
|
+
if (!guildKey) return [];
|
|
50
|
+
const channelKey = normalizeOptionalString(row.channelId ?? row.channelKey);
|
|
51
|
+
return channelKey ? [{
|
|
52
|
+
guildKey,
|
|
53
|
+
channelKey
|
|
54
|
+
}] : [{ guildKey }];
|
|
55
|
+
}) : [];
|
|
56
|
+
const guilds = { ...accountId === DEFAULT_ACCOUNT_ID ? cfg.channels?.discord?.guilds ?? {} : cfg.channels?.discord?.accounts?.[accountId]?.guilds ?? {} };
|
|
57
|
+
for (const entry of entries) {
|
|
58
|
+
const guildKey = entry.guildKey;
|
|
59
|
+
const existing = guilds[guildKey] ?? {};
|
|
60
|
+
if (entry.channelKey) {
|
|
61
|
+
const channels = { ...existing.channels };
|
|
62
|
+
channels[entry.channelKey] = { enabled: true };
|
|
63
|
+
guilds[guildKey] = {
|
|
64
|
+
...existing,
|
|
65
|
+
channels
|
|
66
|
+
};
|
|
67
|
+
} else guilds[guildKey] = existing;
|
|
68
|
+
}
|
|
69
|
+
return patchChannelConfigForAccount({
|
|
70
|
+
cfg,
|
|
71
|
+
channel,
|
|
72
|
+
accountId,
|
|
73
|
+
patch: { guilds }
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function parseDiscordAllowFromId(value) {
|
|
77
|
+
return parseMentionOrPrefixedId({
|
|
78
|
+
value,
|
|
79
|
+
mentionPattern: /^<@!?(\d+)>$/,
|
|
80
|
+
prefixPattern: /^(user:|discord:)/i,
|
|
81
|
+
idPattern: /^\d+$/
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
async function promptDiscordAllowFrom(params) {
|
|
85
|
+
const accountId = resolveSetupAccountId({
|
|
86
|
+
accountId: params.accountId,
|
|
87
|
+
defaultAccountId: resolveDefaultDiscordAccountId(params.cfg)
|
|
88
|
+
});
|
|
89
|
+
const account = resolveDiscordSetupAccountConfig({
|
|
90
|
+
cfg: params.cfg,
|
|
91
|
+
accountId
|
|
92
|
+
});
|
|
93
|
+
const noteTitle = t("wizard.discord.allowlistTitle");
|
|
94
|
+
await params.prompter.note(getDiscordAllowFromHelpLines().join("\n"), noteTitle);
|
|
95
|
+
const allowFrom = await promptResolvedAllowFrom({
|
|
96
|
+
prompter: params.prompter,
|
|
97
|
+
existing: resolveDiscordAccountAllowFrom({
|
|
98
|
+
cfg: params.cfg,
|
|
99
|
+
accountId
|
|
100
|
+
}) ?? [],
|
|
101
|
+
token: resolveDiscordToken(params.cfg, { accountId }).token,
|
|
102
|
+
message: t("wizard.discord.allowFromPrompt"),
|
|
103
|
+
placeholder: "@alice, 123456789012345678",
|
|
104
|
+
label: noteTitle,
|
|
105
|
+
parseInputs: splitSetupEntries,
|
|
106
|
+
parseId: parseDiscordAllowFromId,
|
|
107
|
+
invalidWithoutTokenNote: t("wizard.discord.allowFromInvalidWithoutToken"),
|
|
108
|
+
resolveEntries: async ({ token, entries }) => await resolveBasicAllowFromEntries({
|
|
109
|
+
token,
|
|
110
|
+
entries,
|
|
111
|
+
resolveEntries: resolveDiscordUserAllowlist
|
|
112
|
+
})
|
|
113
|
+
});
|
|
114
|
+
return patchChannelConfigForAccount({
|
|
115
|
+
cfg: params.cfg,
|
|
116
|
+
channel,
|
|
117
|
+
accountId: account.accountId,
|
|
118
|
+
patch: {
|
|
119
|
+
allowFrom,
|
|
120
|
+
dm: {
|
|
121
|
+
...account.config.dm,
|
|
122
|
+
enabled: typeof account.config.dm?.enabled === "boolean" ? account.config.dm.enabled : true
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
const discordDmPolicy = createChannelDmPolicy({
|
|
128
|
+
label: "Discord",
|
|
129
|
+
channel,
|
|
130
|
+
resolveAccount: (cfg, accountId) => resolveDiscordSetupAccountConfig({
|
|
131
|
+
cfg,
|
|
132
|
+
accountId
|
|
133
|
+
}),
|
|
134
|
+
buildPatch: ({ account, policy, allowFrom }) => ({
|
|
135
|
+
dmPolicy: policy,
|
|
136
|
+
...allowFrom === void 0 ? {} : { allowFrom },
|
|
137
|
+
dm: {
|
|
138
|
+
...account.config.dm,
|
|
139
|
+
enabled: typeof account.config.dm?.enabled === "boolean" ? account.config.dm.enabled : true
|
|
140
|
+
}
|
|
141
|
+
}),
|
|
142
|
+
promptAllowFrom: promptDiscordAllowFrom
|
|
143
|
+
});
|
|
144
|
+
const discordSetupWizard = {
|
|
145
|
+
channel,
|
|
146
|
+
status: createStandardChannelSetupStatus({
|
|
147
|
+
channelLabel: "Discord",
|
|
148
|
+
configuredLabel: t("wizard.channels.statusConfigured"),
|
|
149
|
+
unconfiguredLabel: t("wizard.channels.statusNeedsToken"),
|
|
150
|
+
configuredHint: t("wizard.channels.statusConfigured"),
|
|
151
|
+
unconfiguredHint: t("wizard.channels.statusNeedsToken"),
|
|
152
|
+
configuredScore: 2,
|
|
153
|
+
unconfiguredScore: 1,
|
|
154
|
+
resolveConfigured: ({ cfg, accountId }) => inspectDiscordSetupAccount({
|
|
155
|
+
cfg,
|
|
156
|
+
accountId
|
|
157
|
+
}).configured
|
|
158
|
+
}),
|
|
159
|
+
credentials: [defineTokenCredential({
|
|
160
|
+
inputKey: "token",
|
|
161
|
+
configKey: "token",
|
|
162
|
+
providerHint: channel,
|
|
163
|
+
credentialLabel: t("wizard.discord.botToken"),
|
|
164
|
+
preferredEnvVar: "DISCORD_BOT_TOKEN",
|
|
165
|
+
helpTitle: t("wizard.discord.botToken"),
|
|
166
|
+
helpLines: DISCORD_TOKEN_HELP_LINES,
|
|
167
|
+
envPrompt: t("wizard.discord.tokenEnvPrompt"),
|
|
168
|
+
keepPrompt: t("wizard.discord.tokenKeepPrompt"),
|
|
169
|
+
inputPrompt: t("wizard.discord.tokenInputPrompt"),
|
|
170
|
+
allowEnv: ({ accountId }) => accountId === DEFAULT_ACCOUNT_ID,
|
|
171
|
+
resolveAccount: inspectDiscordSetupAccount,
|
|
172
|
+
accountConfigured: (account) => account.configured,
|
|
173
|
+
hasConfiguredValue: (account) => account.tokenStatus !== "missing",
|
|
174
|
+
resolvedValue: (account) => normalizeOptionalString(account.token),
|
|
175
|
+
envValue: ({ accountId }) => accountId === DEFAULT_ACCOUNT_ID ? normalizeOptionalString(process.env.DISCORD_BOT_TOKEN) : void 0
|
|
176
|
+
})],
|
|
177
|
+
groupAccess: createAccountScopedGroupAccessSection({
|
|
178
|
+
channel,
|
|
179
|
+
label: t("wizard.discord.channelsLabel"),
|
|
180
|
+
placeholder: "My Server/#general, guildId/channelId, #support",
|
|
181
|
+
currentPolicy: ({ cfg, accountId }) => resolveDiscordSetupAccountConfig({
|
|
182
|
+
cfg,
|
|
183
|
+
accountId
|
|
184
|
+
}).config.groupPolicy ?? "allowlist",
|
|
185
|
+
currentEntries: ({ cfg, accountId }) => Object.entries(resolveDiscordSetupAccountConfig({
|
|
186
|
+
cfg,
|
|
187
|
+
accountId
|
|
188
|
+
}).config.guilds ?? {}).flatMap(([guildKey, value]) => {
|
|
189
|
+
const channelKeys = Object.keys(value?.channels ?? {});
|
|
190
|
+
if (channelKeys.length === 0) return [/^\d+$/.test(guildKey) ? `guild:${guildKey}` : guildKey];
|
|
191
|
+
return channelKeys.map((channelKey) => `${guildKey}/${channelKey}`);
|
|
192
|
+
}),
|
|
193
|
+
updatePrompt: ({ cfg, accountId }) => Boolean(resolveDiscordSetupAccountConfig({
|
|
194
|
+
cfg,
|
|
195
|
+
accountId
|
|
196
|
+
}).config.guilds),
|
|
197
|
+
resolveAllowlist: async (params) => await resolveEntriesWithOptionalToken({
|
|
198
|
+
token: resolveDiscordToken(params.cfg, { accountId: params.accountId }).token || (typeof params.credentialValues.token === "string" ? params.credentialValues.token : ""),
|
|
199
|
+
entries: params.entries,
|
|
200
|
+
buildWithoutToken: (input) => ({
|
|
201
|
+
input,
|
|
202
|
+
resolved: false
|
|
203
|
+
}),
|
|
204
|
+
resolveEntries: resolveDiscordChannelAllowlist
|
|
205
|
+
}),
|
|
206
|
+
fallbackResolved: (entries) => entries.map((input) => ({
|
|
207
|
+
input,
|
|
208
|
+
resolved: false
|
|
209
|
+
})),
|
|
210
|
+
applyAllowlist: ({ cfg, accountId, resolved }) => setDiscordGuildChannelAllowlist(cfg, accountId, resolved)
|
|
211
|
+
}),
|
|
212
|
+
allowFrom: createAccountScopedAllowFromSection({
|
|
213
|
+
channel,
|
|
214
|
+
credentialInputKey: "token",
|
|
215
|
+
helpTitle: "Discord allowlist",
|
|
216
|
+
helpLines: getDiscordAllowFromHelpLines(),
|
|
217
|
+
message: t("wizard.discord.allowFromPrompt"),
|
|
218
|
+
placeholder: "@alice, 123456789012345678",
|
|
219
|
+
invalidWithoutCredentialNote: t("wizard.discord.allowFromInvalidWithoutToken"),
|
|
220
|
+
parseId: parseDiscordAllowFromId,
|
|
221
|
+
resolveEntries: async ({ cfg, accountId, credentialValues, entries }) => await resolveBasicAllowFromEntries({
|
|
222
|
+
token: resolveDiscordToken(cfg, { accountId }).token || (typeof credentialValues.token === "string" ? credentialValues.token : ""),
|
|
223
|
+
entries,
|
|
224
|
+
resolveEntries: resolveDiscordUserAllowlist
|
|
225
|
+
})
|
|
226
|
+
}),
|
|
227
|
+
dmPolicy: discordDmPolicy,
|
|
228
|
+
disable: (cfg) => setSetupChannelEnabled(cfg, channel, false)
|
|
229
|
+
};
|
|
230
|
+
// extensions/discord/src/channel.setup.ts
|
|
231
|
+
const discordSetupPlugin = { ...createDiscordPluginBase({
|
|
232
|
+
setupWizard: discordSetupWizard,
|
|
233
|
+
setupContract: discordSetupContract
|
|
234
|
+
}) };
|
|
235
|
+
export { discordSetupPlugin as t };
|