@openclaw/discord 2026.9.1-beta.1 → 2026.9.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/account-inspect-BY-ve3yH.js +45 -0
- package/dist/account-inspect-api.js +1 -1
- package/dist/{accounts-CfQ-vSyf.js → accounts-CwJQoLjM.js} +89 -45
- package/dist/action-runtime-api.js +1 -1
- package/dist/{activities-api-q-9PaaHH.js → activities-api-CTcGq3Hf.js} +30 -17
- package/dist/activities-api.js +1 -1
- package/dist/{allow-list-BDMimASD.js → allow-list-DBTtR2dz.js} +13 -35
- package/dist/{api-DNVbJyEy.js → api-BfmEP6wp.js} +6 -5
- package/dist/api.js +18 -18
- package/dist/{approval-handler.runtime-B7qhK3fR.js → approval-handler.runtime-DUSe5fyH.js} +19 -12
- package/dist/{audit-CBEv_ERu.js → audit-DpPfwoJM.js} +8 -7
- package/dist/{channel-Dx1tMTfx.js → channel-BHajPgwR.js} +29 -23
- package/dist/{channel-actions.runtime-CLWWu9nC.js → channel-actions.runtime-DS8pXo0S.js} +38 -38
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel.setup-DOzXS2Pk.js → channel.setup-BWmMe1tT.js} +18 -18
- package/dist/command-owners-D78sAoOz.js +10 -0
- package/dist/{components-B9V5o361.js → components-BimX47Mq.js} +111 -149
- package/dist/{config-schema-BR13IAx6.js → config-schema-B797-Spt.js} +19 -12
- package/dist/{conversation-binding-route-DJYrY2TQ.js → conversation-binding-route-DuR5NGIx.js} +1 -1
- package/dist/{directory-config-BK6eqekJ.js → directory-config-CD2v2Szs.js} +2 -2
- package/dist/directory-contract-api.js +1 -1
- package/dist/{directory-live-DSAJSrJk.js → directory-live-DaJzWJ2N.js} +4 -4
- package/dist/{doctor-Cm7Y1pJ2.js → doctor-D4HH1inA.js} +9 -6
- package/dist/{doctor-contract-DsWvKIXF.js → doctor-contract-Co5vRCZ6.js} +9 -6
- package/dist/doctor-contract-api.js +31 -28
- package/dist/{handle-action.guild-admin-BdwCRHmm.js → handle-action.guild-admin-4We6wWQU.js} +6 -3
- package/dist/index.js +1 -1
- package/dist/ingress-identity-XNmW-mZS.js +60 -0
- package/dist/{message-handler-BXpWZyni.js → message-handler-DhgBabyU.js} +61 -70
- package/dist/{message-handler.preflight-Ba5LAY_X.js → message-handler.preflight-oZ7dQCd0.js} +41 -101
- package/dist/{message-handler.process-3HEzmemS.js → message-handler.process-BzCYf1pa.js} +82 -108
- package/dist/{message-text-aiwO5R2F.js → message-text-DK4NnBg-.js} +11 -6
- package/dist/{outbound-adapter-BE4jSq2d.js → outbound-adapter-CtggmGh9.js} +52 -67
- package/dist/{outbound-components-oLpg8Qzb.js → outbound-components-Dn8SJWMS.js} +5 -4
- package/dist/{outbound-session-route-Cg15ZFJd.js → outbound-session-route-Q_HEusBQ.js} +57 -15
- package/dist/{owner-access-UlYi9t0M.js → owner-access-Cp8r6Ipf.js} +9 -7
- package/dist/{pluralkit-Tiyl70dx.js → pluralkit-BY75YcK0.js} +2 -2
- package/dist/{probe-n6ZXxK8V.js → probe-3ovFAp3b.js} +3 -3
- package/dist/{probe.runtime-CN4bdPfZ.js → probe.runtime-BckHn3cJ.js} +1 -1
- package/dist/{provider-session.runtime-B9xe-Qaf.js → provider-session.runtime-BL2lHBH7.js} +3 -3
- package/dist/{provider-B11xwilq.js → provider-uKmmrDM4.js} +299 -136
- package/dist/provider.runtime-C-IkWF2w.js +2 -0
- package/dist/{realtime-session.runtime-CU8IQUS-.js → realtime-session.runtime-CGYm1t_0.js} +798 -448
- package/dist/{resolve-allowlist-common-BLoYaxEG.js → resolve-allowlist-common-sKIKy-cF.js} +3 -3
- package/dist/{resolve-channels-C2sT_n67.js → resolve-channels-CoiMlWy0.js} +4 -4
- package/dist/{resolve-users-CzpjLwjy.js → resolve-users-DJpiokfW.js} +5 -4
- package/dist/{retry-Cv4jCU5Z.js → retry-DQt1zDgH.js} +356 -214
- package/dist/{retry-after-DdLPmPoa.js → retry-after-BrLjLUJi.js} +2 -1
- package/dist/{runtime-CY4PRMF-.js → runtime-BHsdEdr5.js} +2 -2
- package/dist/{runtime-BHrTlFkf.js → runtime-Ghtfh5ZA.js} +151 -109
- package/dist/runtime-api.js +20 -20
- package/dist/{secret-config-contract-B3i6WxV5.js → secret-config-contract-DFu9hfU8.js} +14 -6
- package/dist/secret-contract-api.js +1 -1
- package/dist/{security-audit-BfJhAXZp.js → security-audit-DKfK-iPY.js} +10 -11
- package/dist/security-audit-contract-api.js +1 -1
- package/dist/{security-audit.runtime-BVKF9VtY.js → security-audit.runtime-sKZyKgpx.js} +1 -1
- package/dist/{send-C49MFF9j.js → send-CZeWKUiA.js} +132 -100
- package/dist/{send.components-DKKAw5VX.js → send.components-BG5IDABj.js} +21 -15
- package/dist/{send.outbound-zam0TrZx.js → send.outbound-DHuFUL6W.js} +42 -63
- package/dist/{send.shared-JjljcV4O.js → send.shared-B0n_fWzu.js} +77 -149
- package/dist/{sender-identity-BJtfyise.js → sender-identity-B8Ncfi63.js} +1 -1
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{shared-_5EcP4jW.js → shared-C3dKun_X.js} +24 -15
- package/dist/{subagent-hooks-DQzvOptn.js → subagent-hooks-ZoQXEI1E.js} +2 -2
- package/dist/subagent-hooks-api.js +1 -1
- package/dist/{system-events-C7yxaHWP.js → system-events-DFF_awl7.js} +2 -2
- package/dist/{target-resolver-vxIh6O3-.js → target-resolver-DLtHDwMK.js} +6 -5
- package/dist/targets-BObRyaKX.js +3 -0
- package/dist/{thread-bindings-DW5F9vat.js → thread-bindings-DKvsNjQR.js} +7 -6
- package/dist/{thread-bindings.manager-ByOtwjo_.js → thread-bindings.manager-pbbRT5gb.js} +38 -29
- package/dist/{thread-bindings.session-updates-CJb-BpPL.js → thread-bindings.session-updates-t6jeFB1-.js} +3 -2
- package/dist/{thread-bindings.state-D8OMdk4O.js → thread-bindings.state-DtgOqsbX.js} +34 -1
- package/dist/{threading-agH1T_6s.js → threading-BCx49X-6.js} +8 -6
- package/dist/{timeouts-B9cy6RvQ.js → timeouts-D86uWLt_.js} +1 -1
- package/dist/{transcripts-source-BR11iHA4.js → transcripts-source-Dc6Nnli5.js} +55 -7
- package/dist/transcripts-source-api.js +1 -1
- package/dist/{typing-Dc_YMY2e.js → typing-CuopV-Hi.js} +2 -2
- package/dist/{voice-runtime-DIeaa8fJ.js → voice-runtime-BQnILUbG.js} +492 -105
- package/node_modules/@discord/embedded-app-sdk/node_modules/@types/lodash/README.md +1 -1
- package/node_modules/@discord/embedded-app-sdk/node_modules/@types/lodash/conforms.d.ts +2 -0
- package/node_modules/@discord/embedded-app-sdk/node_modules/@types/lodash/package.json +3 -3
- package/node_modules/@discord/embedded-app-sdk/node_modules/@types/lodash/stubArray.d.ts +2 -0
- package/node_modules/@discord/embedded-app-sdk/node_modules/@types/lodash/stubObject.d.ts +2 -0
- package/node_modules/@discord/embedded-app-sdk/node_modules/@types/lodash/stubString.d.ts +2 -0
- package/node_modules/@discordjs/voice/node_modules/@types/node/README.md +1 -1
- package/node_modules/@discordjs/voice/node_modules/@types/node/buffer.buffer.d.ts +5 -5
- package/node_modules/@discordjs/voice/node_modules/@types/node/crypto.d.ts +2 -2
- package/node_modules/@discordjs/voice/node_modules/@types/node/http.d.ts +16 -0
- package/node_modules/@discordjs/voice/node_modules/@types/node/http2.d.ts +10 -2
- package/node_modules/@discordjs/voice/node_modules/@types/node/package.json +2 -2
- package/node_modules/@discordjs/voice/node_modules/@types/node/process.d.ts +52 -0
- package/node_modules/@discordjs/voice/node_modules/@types/node/quic.d.ts +210 -28
- package/node_modules/@discordjs/voice/node_modules/@types/node/sqlite.d.ts +6 -2
- package/node_modules/@discordjs/voice/node_modules/@types/node/test.d.ts +36 -0
- package/node_modules/typebox/build/format/email.mjs +1 -1
- package/node_modules/typebox/build/format/idna/idn-hostname.mjs +19 -1
- package/node_modules/typebox/build/format/json_pointer.d.mts +2 -2
- package/node_modules/typebox/build/format/json_pointer.mjs +2 -2
- package/node_modules/typebox/build/format/json_pointer_uri_fragment.d.mts +2 -2
- package/node_modules/typebox/build/format/json_pointer_uri_fragment.mjs +2 -2
- 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/system/memory/assign.mjs +2 -1
- package/node_modules/typebox/build/system/memory/create.mjs +3 -4
- package/node_modules/typebox/build/system/memory/discard.mjs +2 -2
- package/node_modules/typebox/build/system/memory/freeze.d.mts +4 -0
- package/node_modules/typebox/build/system/memory/freeze.mjs +6 -0
- package/node_modules/typebox/build/system/memory/update.mjs +3 -2
- package/node_modules/typebox/package.json +1 -1
- package/node_modules/undici/docs/docs/api/Client.md +4 -0
- package/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +3 -2
- package/node_modules/undici/docs/docs/api/EventSource.md +4 -0
- package/node_modules/undici/docs/docs/api/Interceptors.md +7 -3
- package/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +7 -1
- package/node_modules/undici/lib/cache/memory-cache-store.js +2 -2
- package/node_modules/undici/lib/core/symbols.js +2 -0
- package/node_modules/undici/lib/dispatcher/agent.js +7 -2
- package/node_modules/undici/lib/dispatcher/balanced-pool.js +7 -4
- package/node_modules/undici/lib/dispatcher/client-h1.js +12 -4
- package/node_modules/undici/lib/dispatcher/client-h2.js +43 -3
- package/node_modules/undici/lib/dispatcher/client.js +3 -2
- package/node_modules/undici/lib/dispatcher/dispatcher-base.js +13 -1
- package/node_modules/undici/lib/dispatcher/dispatcher.js +15 -1
- package/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +3 -0
- package/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +10 -3
- package/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -1
- package/node_modules/undici/lib/dispatcher/retry-agent.js +3 -0
- package/node_modules/undici/lib/dispatcher/round-robin-pool.js +1 -1
- package/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +91 -21
- package/node_modules/undici/lib/handler/cache-handler.js +29 -5
- package/node_modules/undici/lib/handler/decorator-handler.js +7 -1
- package/node_modules/undici/lib/handler/deduplication-handler.js +12 -6
- package/node_modules/undici/lib/handler/redirect-handler.js +21 -4
- package/node_modules/undici/lib/handler/retry-handler.js +148 -30
- package/node_modules/undici/lib/interceptor/cache.js +65 -12
- package/node_modules/undici/lib/interceptor/decompress.js +115 -13
- package/node_modules/undici/lib/interceptor/deduplicate.js +5 -4
- package/node_modules/undici/lib/interceptor/dns.js +7 -0
- package/node_modules/undici/lib/interceptor/dump.js +10 -23
- package/node_modules/undici/lib/mock/mock-agent.js +13 -1
- package/node_modules/undici/lib/mock/mock-utils.js +11 -10
- package/node_modules/undici/lib/util/cache.js +45 -3
- package/node_modules/undici/lib/web/cookies/parse.js +150 -147
- package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +28 -1
- package/node_modules/undici/lib/web/eventsource/eventsource.js +13 -3
- package/node_modules/undici/lib/web/fetch/index.js +6 -0
- package/node_modules/undici/lib/web/fetch/request.js +2 -3
- package/node_modules/undici/lib/web/fetch/util.js +6 -1
- package/node_modules/undici/lib/web/webidl/index.js +3 -3
- package/node_modules/undici/lib/web/websocket/connection.js +1 -1
- package/node_modules/undici/lib/web/websocket/permessage-deflate.js +5 -0
- package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +8 -10
- package/node_modules/undici/package.json +3 -3
- package/node_modules/undici/types/client.d.ts +10 -0
- package/node_modules/undici/types/interceptors.d.ts +2 -0
- package/node_modules/undici/types/mock-agent.d.ts +11 -10
- package/node_modules/undici/types/socks5-proxy-agent.d.ts +2 -0
- package/openclaw.plugin.json +15 -8
- package/package.json +7 -6
- package/skills/discord/SKILL.md +1 -1
- package/dist/account-inspect-BDfKyuvL.js +0 -89
- package/dist/provider.runtime-DiYaHvOz.js +0 -2
- package/dist/sdk-runtime-4geQHtXc.js +0 -338
- package/dist/targets-CtTKvntJ.js +0 -3
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { _ as inspectDiscordAccountTokenState, o as mergeDiscordAccountConfig, r as listDiscordAccountIds, s as resolveDefaultDiscordAccountId, u as resolveDiscordAccountConfig, v as resolveDiscordAccountAvailability } from "./accounts-CwJQoLjM.js";
|
|
2
|
+
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
3
|
+
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
|
+
import { normalizeSecretInputString } from "openclaw/plugin-sdk/secret-input";
|
|
5
|
+
//#region extensions/discord/src/account-inspect.ts
|
|
6
|
+
function inspectDiscordAccountPrimary(params) {
|
|
7
|
+
const accountId = normalizeAccountId(params.accountId ?? resolveDefaultDiscordAccountId(params.cfg));
|
|
8
|
+
const merged = mergeDiscordAccountConfig(params.cfg, accountId);
|
|
9
|
+
const enabled = params.cfg.channels?.discord?.enabled !== false && merged.enabled !== false;
|
|
10
|
+
const accountConfig = resolveDiscordAccountConfig(params.cfg, accountId);
|
|
11
|
+
const hasAccountToken = Boolean(accountConfig && Object.hasOwn(accountConfig, "token"));
|
|
12
|
+
return inspectDiscordAccountTokenState({
|
|
13
|
+
base: {
|
|
14
|
+
accountId,
|
|
15
|
+
enabled,
|
|
16
|
+
name: normalizeOptionalString(merged.name)
|
|
17
|
+
},
|
|
18
|
+
config: merged,
|
|
19
|
+
accountToken: accountConfig?.token,
|
|
20
|
+
hasAccountToken,
|
|
21
|
+
channelToken: params.cfg.channels?.discord?.token,
|
|
22
|
+
resolveFallbackToken: () => {
|
|
23
|
+
const envToken = accountId === DEFAULT_ACCOUNT_ID ? normalizeSecretInputString(params.envToken ?? process.env.DISCORD_BOT_TOKEN) : void 0;
|
|
24
|
+
return {
|
|
25
|
+
token: envToken?.replace(/^Bot\s+/i, "") ?? "",
|
|
26
|
+
source: envToken ? "env" : "none"
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function inspectDiscordAccount(params) {
|
|
32
|
+
const account = inspectDiscordAccountPrimary(params);
|
|
33
|
+
return {
|
|
34
|
+
...account,
|
|
35
|
+
...resolveDiscordAccountAvailability({
|
|
36
|
+
account,
|
|
37
|
+
resolveAccounts: () => listDiscordAccountIds(params.cfg).map((accountId) => inspectDiscordAccountPrimary({
|
|
38
|
+
...params,
|
|
39
|
+
accountId
|
|
40
|
+
}))
|
|
41
|
+
})
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { inspectDiscordAccount as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as inspectDiscordAccount } from "./account-inspect-
|
|
1
|
+
import { t as inspectDiscordAccount } from "./account-inspect-BY-ve3yH.js";
|
|
2
2
|
//#region extensions/discord/account-inspect-api.ts
|
|
3
3
|
function inspectDiscordReadOnlyAccount(cfg, accountId) {
|
|
4
4
|
return inspectDiscordAccount({
|
|
@@ -4,8 +4,87 @@ import { mapAllowFromEntries, normalizeChannelDmPolicy } from "openclaw/plugin-s
|
|
|
4
4
|
import { resolveConfiguredFromCredentialStatuses } from "openclaw/plugin-sdk/channel-status";
|
|
5
5
|
import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1, normalizeAccountId as normalizeAccountId$1, resolveAccountEntry } from "openclaw/plugin-sdk/routing";
|
|
6
6
|
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
7
|
+
import { hasConfiguredSecretInput, normalizeResolvedSecretInputString, normalizeSecretInputString, resolveSecretInputString } from "openclaw/plugin-sdk/secret-input";
|
|
7
8
|
import { getRuntimeConfigSnapshot, getRuntimeConfigSourceSnapshot, selectApplicableRuntimeConfig } from "openclaw/plugin-sdk/runtime-config-snapshot";
|
|
8
|
-
|
|
9
|
+
//#region extensions/discord/src/account-token-inspect.ts
|
|
10
|
+
function inspectDiscordConfiguredToken(value) {
|
|
11
|
+
const normalized = normalizeSecretInputString(value);
|
|
12
|
+
if (normalized) return {
|
|
13
|
+
token: normalized.replace(/^Bot\s+/i, ""),
|
|
14
|
+
tokenSource: "config",
|
|
15
|
+
tokenStatus: "available"
|
|
16
|
+
};
|
|
17
|
+
if (hasConfiguredSecretInput(value)) return {
|
|
18
|
+
token: "",
|
|
19
|
+
tokenSource: "config",
|
|
20
|
+
tokenStatus: "configured_unavailable"
|
|
21
|
+
};
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
function inspectDiscordAccountTokenState(params) {
|
|
25
|
+
const accountToken = inspectDiscordConfiguredToken(params.accountToken);
|
|
26
|
+
if (accountToken) return {
|
|
27
|
+
...params.base,
|
|
28
|
+
...accountToken,
|
|
29
|
+
configured: true,
|
|
30
|
+
config: params.config
|
|
31
|
+
};
|
|
32
|
+
if (params.hasAccountToken) return {
|
|
33
|
+
...params.base,
|
|
34
|
+
token: "",
|
|
35
|
+
tokenSource: "none",
|
|
36
|
+
tokenStatus: "missing",
|
|
37
|
+
configured: false,
|
|
38
|
+
config: params.config
|
|
39
|
+
};
|
|
40
|
+
const channelToken = inspectDiscordConfiguredToken(params.channelToken);
|
|
41
|
+
if (channelToken) return {
|
|
42
|
+
...params.base,
|
|
43
|
+
...channelToken,
|
|
44
|
+
configured: true,
|
|
45
|
+
config: params.config
|
|
46
|
+
};
|
|
47
|
+
const fallback = params.resolveFallbackToken();
|
|
48
|
+
if (fallback.token) return {
|
|
49
|
+
...params.base,
|
|
50
|
+
token: fallback.token,
|
|
51
|
+
tokenSource: fallback.source,
|
|
52
|
+
tokenStatus: "available",
|
|
53
|
+
configured: true,
|
|
54
|
+
config: params.config
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
...params.base,
|
|
58
|
+
token: "",
|
|
59
|
+
tokenSource: "none",
|
|
60
|
+
tokenStatus: "missing",
|
|
61
|
+
configured: false,
|
|
62
|
+
config: params.config
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/** Runtime and inspection keep the first enabled owner, preferring config over env tokens. */
|
|
66
|
+
function resolveDiscordAccountAvailability(params) {
|
|
67
|
+
if (!params.account.enabled) return {
|
|
68
|
+
enabled: false,
|
|
69
|
+
stateReason: "disabled"
|
|
70
|
+
};
|
|
71
|
+
const token = params.account.token.trim();
|
|
72
|
+
let owner;
|
|
73
|
+
if (token) for (const account of params.resolveAccounts()) {
|
|
74
|
+
if (!account.enabled || account.token.trim() !== token) continue;
|
|
75
|
+
const priority = account.tokenSource === "config" ? 2 : account.tokenSource === "env" ? 1 : 0;
|
|
76
|
+
if (!owner || priority > owner.priority) owner = {
|
|
77
|
+
accountId: account.accountId,
|
|
78
|
+
priority
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const duplicateOwner = owner && owner.accountId !== params.account.accountId ? owner.accountId : void 0;
|
|
82
|
+
return {
|
|
83
|
+
enabled: !duplicateOwner,
|
|
84
|
+
stateReason: duplicateOwner ? `duplicate bot token; using account "${duplicateOwner}"` : void 0
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
9
88
|
//#region extensions/discord/src/runtime-config.ts
|
|
10
89
|
function selectDiscordRuntimeConfig(inputConfig) {
|
|
11
90
|
return selectApplicableRuntimeConfig({
|
|
@@ -186,55 +265,20 @@ function resolveDiscordMaxLinesPerMessage(params) {
|
|
|
186
265
|
accountId: params.accountId
|
|
187
266
|
}).config.maxLinesPerMessage;
|
|
188
267
|
}
|
|
189
|
-
function
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
for (const [index, accountId] of accountIds.entries()) {
|
|
195
|
-
const account = resolveDiscordAccount({
|
|
196
|
-
cfg: params.cfg,
|
|
268
|
+
function inspectDiscordRuntimeAvailability(account, cfg) {
|
|
269
|
+
return resolveDiscordAccountAvailability({
|
|
270
|
+
account,
|
|
271
|
+
resolveAccounts: () => listDiscordAccountIds(cfg).map((accountId) => resolveDiscordAccount({
|
|
272
|
+
cfg,
|
|
197
273
|
accountId
|
|
198
|
-
})
|
|
199
|
-
const accountToken = account.token.trim();
|
|
200
|
-
if (!account.enabled || accountToken !== token) continue;
|
|
201
|
-
const priority = account.tokenSource === "config" ? 2 : account.tokenSource === "env" ? 1 : 0;
|
|
202
|
-
if (!owner || priority > owner.priority) {
|
|
203
|
-
owner = {
|
|
204
|
-
accountId: account.accountId,
|
|
205
|
-
priority,
|
|
206
|
-
index
|
|
207
|
-
};
|
|
208
|
-
continue;
|
|
209
|
-
}
|
|
210
|
-
if (priority === owner.priority && index < owner.index) owner = {
|
|
211
|
-
accountId: account.accountId,
|
|
212
|
-
priority,
|
|
213
|
-
index
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
return owner?.accountId;
|
|
217
|
-
}
|
|
218
|
-
function resolveDiscordDuplicateTokenOwner(params) {
|
|
219
|
-
const owner = resolveDiscordAccountTokenOwner({
|
|
220
|
-
cfg: params.cfg,
|
|
221
|
-
token: params.account.token
|
|
274
|
+
}))
|
|
222
275
|
});
|
|
223
|
-
return owner && owner !== params.account.accountId ? owner : void 0;
|
|
224
276
|
}
|
|
225
277
|
function isDiscordAccountEnabledForRuntime(account, cfg) {
|
|
226
|
-
return account.enabled
|
|
227
|
-
cfg,
|
|
228
|
-
account
|
|
229
|
-
});
|
|
278
|
+
return inspectDiscordRuntimeAvailability(account, cfg).enabled;
|
|
230
279
|
}
|
|
231
280
|
function resolveDiscordAccountDisabledReason(account, cfg) {
|
|
232
|
-
|
|
233
|
-
const owner = resolveDiscordDuplicateTokenOwner({
|
|
234
|
-
cfg,
|
|
235
|
-
account
|
|
236
|
-
});
|
|
237
|
-
return owner ? `duplicate bot token; using account "${owner}"` : "disabled";
|
|
281
|
+
return inspectDiscordRuntimeAvailability(account, cfg).stateReason ?? "disabled";
|
|
238
282
|
}
|
|
239
283
|
function listEnabledDiscordAccounts(cfg) {
|
|
240
284
|
return listDiscordAccountIds(cfg).map((accountId) => resolveDiscordAccount({
|
|
@@ -249,4 +293,4 @@ function listDiscordStartupAccountIds(cfg) {
|
|
|
249
293
|
return [defaultAccountId, ...startupAccountIds.filter((candidateId) => candidateId !== defaultAccountId)];
|
|
250
294
|
}
|
|
251
295
|
//#endregion
|
|
252
|
-
export { listEnabledDiscordAccounts as a, resolveDiscordAccount as c, resolveDiscordAccountDisabledReason as d, resolveDiscordAccountDmPolicy as f, selectDiscordActivitiesRuntimeConfig as g, resolveDiscordToken as h, listDiscordStartupAccountIds as i, resolveDiscordAccountAllowFrom as l, normalizeDiscordToken as m, isDiscordAccountEnabledForRuntime as n, mergeDiscordAccountConfig as o, resolveDiscordMaxLinesPerMessage as p, listDiscordAccountIds as r, resolveDefaultDiscordAccountId as s, createDiscordActionGate as t, resolveDiscordAccountConfig as u };
|
|
296
|
+
export { inspectDiscordAccountTokenState as _, listEnabledDiscordAccounts as a, resolveDiscordAccount as c, resolveDiscordAccountDisabledReason as d, resolveDiscordAccountDmPolicy as f, selectDiscordActivitiesRuntimeConfig as g, resolveDiscordToken as h, listDiscordStartupAccountIds as i, resolveDiscordAccountAllowFrom as l, normalizeDiscordToken as m, isDiscordAccountEnabledForRuntime as n, mergeDiscordAccountConfig as o, resolveDiscordMaxLinesPerMessage as p, listDiscordAccountIds as r, resolveDefaultDiscordAccountId as s, createDiscordActionGate as t, resolveDiscordAccountConfig as u, resolveDiscordAccountAvailability as v };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as handleDiscordAction } from "./runtime-
|
|
1
|
+
import { t as handleDiscordAction } from "./runtime-Ghtfh5ZA.js";
|
|
2
2
|
export { handleDiscordAction };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { c as resolveDiscordAccount } from "./accounts-
|
|
4
|
-
import { r as sendDiscordComponentMessage } from "./send.components-
|
|
5
|
-
import { r as setDiscordActivitiesRuntime, t as DiscordActivitiesRuntime } from "./runtime-
|
|
1
|
+
import { y as resolveDiscordChannelId$1 } from "./retry-DQt1zDgH.js";
|
|
2
|
+
import { S as parseDiscordActivityCustomId, i as buildDiscordPresentationComponents } from "./components-BimX47Mq.js";
|
|
3
|
+
import { c as resolveDiscordAccount } from "./accounts-CwJQoLjM.js";
|
|
4
|
+
import { r as sendDiscordComponentMessage } from "./send.components-BG5IDABj.js";
|
|
5
|
+
import { r as setDiscordActivitiesRuntime, t as DiscordActivitiesRuntime } from "./runtime-BHsdEdr5.js";
|
|
6
6
|
import fs from "node:fs/promises";
|
|
7
7
|
import { logError } from "openclaw/plugin-sdk/logging-core";
|
|
8
8
|
import { resolveRequestClientIp } from "openclaw/plugin-sdk/webhook-ingress";
|
|
9
|
-
import { WEBHOOK_BODY_READ_DEFAULTS, readJsonBodyWithLimit } from "openclaw/plugin-sdk/webhook-request-guards";
|
|
9
|
+
import { WEBHOOK_BODY_READ_DEFAULTS, readJsonBodyWithLimit, sendHttpRequestRejection } from "openclaw/plugin-sdk/webhook-request-guards";
|
|
10
10
|
import { randomBytes } from "node:crypto";
|
|
11
11
|
import { readProviderJsonResponse } from "openclaw/plugin-sdk/provider-http";
|
|
12
12
|
import { fetchWithSsrFGuard as fetchWithSsrFGuard$1 } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
@@ -14,7 +14,7 @@ import { fetchWithSsrFGuard as fetchWithSsrFGuard$1 } from "openclaw/plugin-sdk/
|
|
|
14
14
|
const DISCORD_TOKEN_URL = "https://discord.com/api/oauth2/token";
|
|
15
15
|
const DISCORD_USER_URL = "https://discord.com/api/v10/users/@me";
|
|
16
16
|
const DISCORD_HOST = "discord.com";
|
|
17
|
-
const JSON_MAX_BYTES =
|
|
17
|
+
const JSON_MAX_BYTES = 65536;
|
|
18
18
|
const INSTANCE_ID_MAX_LENGTH = 256;
|
|
19
19
|
function normalizeInstanceId(value) {
|
|
20
20
|
const instanceId = value?.trim();
|
|
@@ -243,7 +243,8 @@ run().catch((error) => {
|
|
|
243
243
|
`;
|
|
244
244
|
//#endregion
|
|
245
245
|
//#region extensions/discord/src/activities/http.ts
|
|
246
|
-
const BODY_MAX_BYTES =
|
|
246
|
+
const BODY_MAX_BYTES = 8192;
|
|
247
|
+
const JSON_CONTENT_TYPE = "application/json; charset=utf-8";
|
|
247
248
|
const WIDGET_ID_PATTERN = /^[A-Za-z0-9_-]{22}$/;
|
|
248
249
|
const DOC_TOKEN_PATTERN = /^[A-Za-z0-9_-]{43}$/;
|
|
249
250
|
const DISCORD_ACTIVITY_WIDGET_CSP = "sandbox allow-scripts; default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data: blob:; font-src data:; connect-src 'none'; frame-ancestors *";
|
|
@@ -260,8 +261,11 @@ function respond(res, statusCode, body, contentType, headers) {
|
|
|
260
261
|
res.end(body);
|
|
261
262
|
return true;
|
|
262
263
|
}
|
|
264
|
+
function jsonBody(body) {
|
|
265
|
+
return `${JSON.stringify(body)}\n`;
|
|
266
|
+
}
|
|
263
267
|
function respondJson(res, statusCode, body) {
|
|
264
|
-
return respond(res, statusCode,
|
|
268
|
+
return respond(res, statusCode, jsonBody(body), JSON_CONTENT_TYPE);
|
|
265
269
|
}
|
|
266
270
|
function notFound(res, widgetDocument = false) {
|
|
267
271
|
return respond(res, 404, "not found", "text/plain; charset=utf-8", widgetDocument ? { "Content-Security-Policy": DISCORD_ACTIVITY_WIDGET_CSP } : void 0);
|
|
@@ -309,9 +313,17 @@ function createDiscordActivityHttpHandler(deps) {
|
|
|
309
313
|
const bodyResult = await readJsonBodyWithLimit(req, {
|
|
310
314
|
maxBytes: BODY_MAX_BYTES,
|
|
311
315
|
timeoutMs: bodyTimeoutMs,
|
|
312
|
-
emptyObjectOnEmpty: true
|
|
316
|
+
emptyObjectOnEmpty: true,
|
|
317
|
+
destroyOnLimit: false
|
|
313
318
|
});
|
|
314
|
-
if (!bodyResult.ok && bodyResult.code === "REQUEST_BODY_TIMEOUT")
|
|
319
|
+
if (!bodyResult.ok && bodyResult.code === "REQUEST_BODY_TIMEOUT") {
|
|
320
|
+
await sendHttpRequestRejection(req, res, 408, jsonBody({ error: "request body timeout" }), JSON_CONTENT_TYPE);
|
|
321
|
+
return true;
|
|
322
|
+
}
|
|
323
|
+
if (!bodyResult.ok && bodyResult.code === "PAYLOAD_TOO_LARGE") {
|
|
324
|
+
await sendHttpRequestRejection(req, res, 413, jsonBody({ error: "request body too large" }), JSON_CONTENT_TYPE);
|
|
325
|
+
return true;
|
|
326
|
+
}
|
|
315
327
|
const body = bodyResult.ok && bodyResult.value && typeof bodyResult.value === "object" && !Array.isArray(bodyResult.value) ? bodyResult.value : null;
|
|
316
328
|
const code = typeof body?.code === "string" ? body.code.trim() : "";
|
|
317
329
|
if (!code) return respondJson(res, 401, { error: "invalid authorization code" });
|
|
@@ -466,7 +478,7 @@ function createDiscordActivityHttpHandler(deps) {
|
|
|
466
478
|
}
|
|
467
479
|
//#endregion
|
|
468
480
|
//#region extensions/discord/src/activities/presenter.ts
|
|
469
|
-
const DISCORD_WIDGET_HTML_MAX_BYTES =
|
|
481
|
+
const DISCORD_WIDGET_HTML_MAX_BYTES = 49152;
|
|
470
482
|
function resolveDiscordChannelId(context) {
|
|
471
483
|
const raw = context.nativeChannelId?.trim() || context.currentMessagingTarget?.trim() || context.currentChannelId?.trim() || context.deliveryContext?.to?.trim();
|
|
472
484
|
if (!raw) return;
|
|
@@ -593,12 +605,12 @@ function createDiscordWidgetPresenter(runtime, deps = {}) {
|
|
|
593
605
|
}
|
|
594
606
|
//#endregion
|
|
595
607
|
//#region extensions/discord/src/activities/store.ts
|
|
596
|
-
const DAY_MS =
|
|
608
|
+
const DAY_MS = 864e5;
|
|
597
609
|
const DISCORD_EPOCH_MS = 14200704e5;
|
|
598
610
|
const WIDGET_TTL_MS = 7 * DAY_MS;
|
|
599
|
-
const SESSION_TTL_MS =
|
|
600
|
-
const DOC_TOKEN_TTL_MS =
|
|
601
|
-
const PENDING_LAUNCH_TTL_MS =
|
|
611
|
+
const SESSION_TTL_MS = 9e5;
|
|
612
|
+
const DOC_TOKEN_TTL_MS = 6e4;
|
|
613
|
+
const PENDING_LAUNCH_TTL_MS = 12e4;
|
|
602
614
|
function requireAtomicUpdate(store) {
|
|
603
615
|
if (!store.update) throw new Error("Discord Activities require atomic plugin state updates");
|
|
604
616
|
return store;
|
|
@@ -722,7 +734,8 @@ var DiscordActivityStore = class {
|
|
|
722
734
|
//#region extensions/discord/src/activities/register.ts
|
|
723
735
|
function registerDiscordActivities$1(api) {
|
|
724
736
|
setDiscordActivitiesRuntime(void 0);
|
|
725
|
-
const
|
|
737
|
+
const store = new DiscordActivityStore(openDiscordActivityStores((options) => api.runtime.state.openKeyedStore(options)));
|
|
738
|
+
const runtime = new DiscordActivitiesRuntime(store, api.config, api.runtime.config?.current ? () => api.runtime.config.current() : void 0);
|
|
726
739
|
setDiscordActivitiesRuntime(runtime);
|
|
727
740
|
const http = createDiscordActivityHttpHandler({
|
|
728
741
|
runtime,
|
package/dist/activities-api.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as registerDiscordActivities } from "./activities-api-
|
|
1
|
+
import { t as registerDiscordActivities } from "./activities-api-CTcGq3Hf.js";
|
|
2
2
|
export { registerDiscordActivities };
|
|
@@ -181,38 +181,12 @@ function resolveDiscordOwnerAllowFrom(params) {
|
|
|
181
181
|
return [match.matchKey];
|
|
182
182
|
}
|
|
183
183
|
function resolveDiscordOwnerAccess(params) {
|
|
184
|
-
const
|
|
185
|
-
const ownerAllowList = normalizeDiscordAllowList(ownerAllowFrom && ownerAllowFrom.length > 0 ? ownerAllowFrom : void 0, DISCORD_OWNER_ALLOWLIST_PREFIXES);
|
|
184
|
+
const ownerAllowList = normalizeDiscordAllowList(params.allowFrom?.filter((entry) => (normalizeOptionalString(entry) ?? "") !== "*"), DISCORD_OWNER_ALLOWLIST_PREFIXES);
|
|
186
185
|
return {
|
|
187
186
|
ownerAllowList,
|
|
188
|
-
ownerAllowed: ownerAllowList
|
|
189
|
-
id: params.sender.id,
|
|
190
|
-
name: params.sender.name,
|
|
191
|
-
tag: params.sender.tag
|
|
192
|
-
}, { allowNameMatching: params.allowNameMatching }) : false
|
|
187
|
+
ownerAllowed: ownerAllowList !== null && allowListMatches(ownerAllowList, params.sender, { allowNameMatching: params.allowNameMatching })
|
|
193
188
|
};
|
|
194
189
|
}
|
|
195
|
-
function resolveDiscordCommandOwnerAllowFrom(cfg) {
|
|
196
|
-
const raw = cfg.commands?.ownerAllowFrom;
|
|
197
|
-
if (!Array.isArray(raw) || raw.length === 0) return;
|
|
198
|
-
const entries = [];
|
|
199
|
-
for (const entry of raw) {
|
|
200
|
-
const trimmed = normalizeOptionalString(String(entry ?? "")) ?? "";
|
|
201
|
-
if (!trimmed) continue;
|
|
202
|
-
const separatorIndex = trimmed.indexOf(":");
|
|
203
|
-
if (separatorIndex > 0) {
|
|
204
|
-
const prefix = trimmed.slice(0, separatorIndex).toLowerCase();
|
|
205
|
-
if (prefix === "discord") {
|
|
206
|
-
const remainder = normalizeOptionalString(trimmed.slice(separatorIndex + 1)) ?? "";
|
|
207
|
-
if (remainder) entries.push(remainder);
|
|
208
|
-
continue;
|
|
209
|
-
}
|
|
210
|
-
if (prefix !== "user" && prefix !== "pk") continue;
|
|
211
|
-
}
|
|
212
|
-
entries.push(trimmed);
|
|
213
|
-
}
|
|
214
|
-
return entries.length > 0 ? entries : void 0;
|
|
215
|
-
}
|
|
216
190
|
function resolveDiscordCommandAuthorized(params) {
|
|
217
191
|
if (!params.isDirectMessage) return true;
|
|
218
192
|
const allowList = normalizeDiscordAllowList(params.allowFrom, [
|
|
@@ -258,10 +232,12 @@ function buildDiscordChannelKeys(params) {
|
|
|
258
232
|
return buildChannelKeyCandidates(params.id, allowNameMatch ? params.slug : void 0, allowNameMatch ? params.name : void 0);
|
|
259
233
|
}
|
|
260
234
|
function resolveDiscordChannelEntryMatch(channels, params, parentParams) {
|
|
235
|
+
const keys = buildDiscordChannelKeys(params);
|
|
236
|
+
const parentKeys = parentParams ? buildDiscordChannelKeys(parentParams) : void 0;
|
|
261
237
|
return resolveChannelEntryMatchWithFallback({
|
|
262
238
|
entries: channels,
|
|
263
|
-
keys
|
|
264
|
-
parentKeys
|
|
239
|
+
keys,
|
|
240
|
+
parentKeys,
|
|
265
241
|
wildcardKey: "*"
|
|
266
242
|
});
|
|
267
243
|
}
|
|
@@ -288,18 +264,19 @@ function resolveDiscordChannelConfig(params) {
|
|
|
288
264
|
const { guildInfo, channelId, channelName, channelSlug } = params;
|
|
289
265
|
const channels = guildInfo?.channels;
|
|
290
266
|
if (!hasConfiguredDiscordChannels(channels)) return null;
|
|
291
|
-
|
|
267
|
+
const match = resolveDiscordChannelEntryMatch(channels, {
|
|
292
268
|
id: channelId,
|
|
293
269
|
name: channelName,
|
|
294
270
|
slug: channelSlug
|
|
295
|
-
})
|
|
271
|
+
});
|
|
272
|
+
return resolveChannelMatchConfig(match, resolveDiscordChannelConfigEntry) ?? { allowed: false };
|
|
296
273
|
}
|
|
297
274
|
function resolveDiscordChannelConfigWithFallback(params) {
|
|
298
275
|
const { guildInfo, channelId, channelName, channelSlug, parentId, parentName, parentSlug, scope } = params;
|
|
299
276
|
const channels = guildInfo?.channels;
|
|
300
277
|
if (!hasConfiguredDiscordChannels(channels)) return null;
|
|
301
278
|
const resolvedParentSlug = parentSlug ?? (parentName ? normalizeDiscordSlug(parentName) : "");
|
|
302
|
-
|
|
279
|
+
const match = resolveDiscordChannelEntryMatch(channels, {
|
|
303
280
|
id: channelId,
|
|
304
281
|
name: channelName,
|
|
305
282
|
slug: channelSlug,
|
|
@@ -308,7 +285,8 @@ function resolveDiscordChannelConfigWithFallback(params) {
|
|
|
308
285
|
id: parentId ?? "",
|
|
309
286
|
name: parentName,
|
|
310
287
|
slug: resolvedParentSlug
|
|
311
|
-
} : void 0)
|
|
288
|
+
} : void 0);
|
|
289
|
+
return resolveChannelMatchConfig(match, resolveDiscordChannelConfigEntry) ?? { allowed: false };
|
|
312
290
|
}
|
|
313
291
|
function resolveDiscordShouldRequireMention(params) {
|
|
314
292
|
if (!params.isGuildMessage) return false;
|
|
@@ -382,4 +360,4 @@ function shouldEmitDiscordReactionNotification(params) {
|
|
|
382
360
|
return false;
|
|
383
361
|
}
|
|
384
362
|
//#endregion
|
|
385
|
-
export { resolveTimestampMs as
|
|
363
|
+
export { resolveTimestampMs as S, resolveGroupDmAllow as _, normalizeDiscordSlug as a, formatDiscordUserTag as b, resolveDiscordChannelConfigWithFallback as c, resolveDiscordGuildEntry as d, resolveDiscordMemberAccessState as f, resolveDiscordShouldRequireMention as g, resolveDiscordOwnerAllowFrom as h, normalizeDiscordDisplaySlug as i, resolveDiscordChannelPolicyCommandAuthorizer as l, resolveDiscordOwnerAccess as m, isDiscordGroupAllowedByPolicy as n, resolveDiscordAllowListMatch as o, resolveDiscordMemberAllowed as p, normalizeDiscordAllowList as r, resolveDiscordChannelConfig as s, allowListMatches as t, resolveDiscordCommandAuthorized as u, shouldEmitDiscordReactionNotification as v, resolveDiscordSystemLocation as x, formatDiscordReactionEmoji as y };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as parseDiscordRetryAfterBodySeconds } from "./retry-after-
|
|
1
|
+
import { t as parseDiscordRetryAfterBodySeconds } from "./retry-after-BrLjLUJi.js";
|
|
2
2
|
import { redactToolPayloadText } from "openclaw/plugin-sdk/logging-core";
|
|
3
3
|
import { resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
|
|
4
4
|
import { readResponseWithLimit } from "openclaw/plugin-sdk/response-limit-runtime";
|
|
@@ -27,12 +27,12 @@ const DISCORD_API_BASE = "https://discord.com/api/v10";
|
|
|
27
27
|
const DISCORD_API_RETRY_DEFAULTS = {
|
|
28
28
|
attempts: 3,
|
|
29
29
|
minDelayMs: 500,
|
|
30
|
-
maxDelayMs:
|
|
30
|
+
maxDelayMs: 3e5,
|
|
31
31
|
jitter: .1
|
|
32
32
|
};
|
|
33
33
|
const DISCORD_API_429_FALLBACK_RETRY_AFTER_SECONDS = 60;
|
|
34
|
-
const DISCORD_API_ERROR_BODY_LIMIT_BYTES =
|
|
35
|
-
const DISCORD_API_RESPONSE_BODY_LIMIT_BYTES =
|
|
34
|
+
const DISCORD_API_ERROR_BODY_LIMIT_BYTES = 8192;
|
|
35
|
+
const DISCORD_API_RESPONSE_BODY_LIMIT_BYTES = 4194304;
|
|
36
36
|
const DISCORD_DIRECTORY_LOOKUP_TIMEOUT_MS = 1e4;
|
|
37
37
|
function parseDiscordApiErrorPayload(text) {
|
|
38
38
|
const trimmed = text.trim();
|
|
@@ -46,7 +46,8 @@ function parseDiscordApiErrorPayload(text) {
|
|
|
46
46
|
return null;
|
|
47
47
|
}
|
|
48
48
|
function parseRetryAfterSeconds(text, response) {
|
|
49
|
-
const
|
|
49
|
+
const payload = parseDiscordApiErrorPayload(text);
|
|
50
|
+
const retryAfter = parseDiscordRetryAfterBodySeconds(payload?.retry_after);
|
|
50
51
|
if (retryAfter !== void 0) return retryAfter;
|
|
51
52
|
const header = response.headers.get("Retry-After");
|
|
52
53
|
if (!header) return;
|
package/dist/api.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { _ as
|
|
2
|
-
import {
|
|
3
|
-
import { a as listEnabledDiscordAccounts, c as resolveDiscordAccount, o as mergeDiscordAccountConfig, p as resolveDiscordMaxLinesPerMessage, r as listDiscordAccountIds, s as resolveDefaultDiscordAccountId, t as createDiscordActionGate, u as resolveDiscordAccountConfig } from "./accounts-
|
|
4
|
-
import { i as requestDiscord, n as DiscordApiError, r as fetchDiscord } from "./api-
|
|
5
|
-
import { i as parseDiscordSendTarget, n as resolveDiscordTarget } from "./target-resolver-
|
|
6
|
-
import { t as inspectDiscordAccount } from "./account-inspect-
|
|
7
|
-
import { i as DISCORD_DEFAULT_LISTENER_TIMEOUT_MS, n as DISCORD_ATTACHMENT_TOTAL_TIMEOUT_MS, r as DISCORD_DEFAULT_INBOUND_WORKER_TIMEOUT_MS, t as DISCORD_ATTACHMENT_IDLE_TIMEOUT_MS } from "./timeouts-
|
|
8
|
-
import "./targets-
|
|
9
|
-
import { C as shouldSuppressLocalDiscordExecApprovalPrompt, S as isDiscordExecApprovalClientEnabled, b as getDiscordExecApprovalApprovers, x as isDiscordExecApprovalApprover } from "./outbound-session-route-
|
|
10
|
-
import { i as resolveDiscordGroupToolPolicy, n as collectDiscordStatusIssues, r as resolveDiscordGroupRequireMention, t as discordPlugin } from "./channel-
|
|
1
|
+
import { _ as normalizeDiscordOutboundTarget, g as normalizeDiscordMessagingTarget, h as looksLikeDiscordTargetId, v as parseDiscordTarget, y as resolveDiscordChannelId } from "./retry-DQt1zDgH.js";
|
|
2
|
+
import { D as parseDiscordModalCustomIdForInteraction, E as parseDiscordModalCustomId, T as parseDiscordComponentCustomIdForInteraction, _ as DISCORD_COMPONENT_CUSTOM_ID_KEY, b as buildDiscordComponentCustomId, d as buildDiscordComponentMessage, f as buildDiscordComponentMessageFlags, g as resolveDiscordComponentAttachmentName, h as readDiscordComponentSpec, l as DiscordFormModal, n as formatDiscordComponentEventText, p as DISCORD_COMPONENT_ATTACHMENT_PREFIX, r as buildDiscordInteractiveComponents, u as createDiscordFormModal, v as DISCORD_MODAL_CUSTOM_ID_KEY, w as parseDiscordComponentCustomId, x as buildDiscordModalCustomId } from "./components-BimX47Mq.js";
|
|
3
|
+
import { a as listEnabledDiscordAccounts, c as resolveDiscordAccount, o as mergeDiscordAccountConfig, p as resolveDiscordMaxLinesPerMessage, r as listDiscordAccountIds, s as resolveDefaultDiscordAccountId, t as createDiscordActionGate, u as resolveDiscordAccountConfig } from "./accounts-CwJQoLjM.js";
|
|
4
|
+
import { i as requestDiscord, n as DiscordApiError, r as fetchDiscord } from "./api-BfmEP6wp.js";
|
|
5
|
+
import { i as parseDiscordSendTarget, n as resolveDiscordTarget } from "./target-resolver-DLtHDwMK.js";
|
|
6
|
+
import { t as inspectDiscordAccount } from "./account-inspect-BY-ve3yH.js";
|
|
7
|
+
import { i as DISCORD_DEFAULT_LISTENER_TIMEOUT_MS, n as DISCORD_ATTACHMENT_TOTAL_TIMEOUT_MS, r as DISCORD_DEFAULT_INBOUND_WORKER_TIMEOUT_MS, t as DISCORD_ATTACHMENT_IDLE_TIMEOUT_MS } from "./timeouts-D86uWLt_.js";
|
|
8
|
+
import "./targets-BObRyaKX.js";
|
|
9
|
+
import { C as shouldSuppressLocalDiscordExecApprovalPrompt, S as isDiscordExecApprovalClientEnabled, b as getDiscordExecApprovalApprovers, x as isDiscordExecApprovalApprover } from "./outbound-session-route-Q_HEusBQ.js";
|
|
10
|
+
import { i as resolveDiscordGroupToolPolicy, n as collectDiscordStatusIssues, r as resolveDiscordGroupRequireMention, t as discordPlugin } from "./channel-BHajPgwR.js";
|
|
11
11
|
import { t as normalizeExplicitDiscordSessionKey } from "./session-key-normalization-wJgsKPNF.js";
|
|
12
|
-
import { t as discordSetupPlugin } from "./channel.setup-
|
|
13
|
-
import { n as handleDiscordSubagentEnded, t as handleDiscordSubagentDeliveryTarget } from "./subagent-hooks-
|
|
14
|
-
import { t as tryHandleDiscordMessageActionGuildAdmin } from "./handle-action.guild-admin-
|
|
15
|
-
import { n as listDiscordDirectoryGroupsFromConfig, r as listDiscordDirectoryPeersFromConfig } from "./directory-config-
|
|
16
|
-
import { t as fetchPluralKitMessageInfo } from "./pluralkit-
|
|
17
|
-
import { i as probeDiscord, n as fetchDiscordApplicationSummary, o as resolveDiscordPrivilegedIntentsFromFlags, r as parseApplicationIdFromToken, t as fetchDiscordApplicationId } from "./probe-
|
|
18
|
-
import { t as collectDiscordSecurityAuditFindings } from "./security-audit-
|
|
12
|
+
import { t as discordSetupPlugin } from "./channel.setup-BWmMe1tT.js";
|
|
13
|
+
import { n as handleDiscordSubagentEnded, t as handleDiscordSubagentDeliveryTarget } from "./subagent-hooks-ZoQXEI1E.js";
|
|
14
|
+
import { t as tryHandleDiscordMessageActionGuildAdmin } from "./handle-action.guild-admin-4We6wWQU.js";
|
|
15
|
+
import { n as listDiscordDirectoryGroupsFromConfig, r as listDiscordDirectoryPeersFromConfig } from "./directory-config-CD2v2Szs.js";
|
|
16
|
+
import { t as fetchPluralKitMessageInfo } from "./pluralkit-BY75YcK0.js";
|
|
17
|
+
import { i as probeDiscord, n as fetchDiscordApplicationSummary, o as resolveDiscordPrivilegedIntentsFromFlags, r as parseApplicationIdFromToken, t as fetchDiscordApplicationId } from "./probe-3ovFAp3b.js";
|
|
18
|
+
import { t as collectDiscordSecurityAuditFindings } from "./security-audit-DKfK-iPY.js";
|
|
19
19
|
import { resolveOpenProviderRuntimeGroupPolicy as resolveDiscordRuntimeGroupPolicy } from "openclaw/plugin-sdk/runtime-group-policy";
|
|
20
20
|
//#region extensions/discord/api.ts
|
|
21
|
-
const handleDiscordMessageAction = async (...args) => (await import("./channel-actions.runtime-
|
|
21
|
+
const handleDiscordMessageAction = async (...args) => (await import("./channel-actions.runtime-DS8pXo0S.js")).handleDiscordMessageAction(...args);
|
|
22
22
|
/**
|
|
23
23
|
* @deprecated Shipped `@openclaw/discord/api` compatibility only. Use native
|
|
24
24
|
* `AbortSignal.any` after filtering optional signals. Removal with the next
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { s as buildExecApprovalCustomId } from "./components-
|
|
3
|
-
import { N as createDiscordClient, O as createDiscordMessageNonce } from "./send.shared-
|
|
4
|
-
import { S as isDiscordExecApprovalClientEnabled, n as DISCORD_APPROVAL_ALLOWED_MENTIONS, r as formatDiscordApprovalDisplayValue } from "./outbound-session-route-
|
|
5
|
-
import { a as shouldHandleDiscordApprovalRequest } from "./channel-
|
|
1
|
+
import { At as editChannelMessage, J as serializePayload, Ot as deleteChannelMessage, Tt as createChannelMessage, bt as createUserDmChannel, dt as Separator, lt as Row, pt as TextDisplay, rt as Container, tt as Button, vt as stripUndefinedFields } from "./retry-DQt1zDgH.js";
|
|
2
|
+
import { s as buildExecApprovalCustomId } from "./components-BimX47Mq.js";
|
|
3
|
+
import { N as createDiscordClient, O as createDiscordMessageNonce } from "./send.shared-B0n_fWzu.js";
|
|
4
|
+
import { S as isDiscordExecApprovalClientEnabled, n as DISCORD_APPROVAL_ALLOWED_MENTIONS, r as formatDiscordApprovalDisplayValue } from "./outbound-session-route-Q_HEusBQ.js";
|
|
5
|
+
import { a as shouldHandleDiscordApprovalRequest } from "./channel-BHajPgwR.js";
|
|
6
6
|
import { logDebug, logError } from "openclaw/plugin-sdk/logging-core";
|
|
7
7
|
import { ButtonStyle } from "discord-api-types/v10";
|
|
8
8
|
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
@@ -52,7 +52,7 @@ var ExecApprovalContainer = class extends DiscordUiContainer {
|
|
|
52
52
|
divider: true,
|
|
53
53
|
spacing: "small"
|
|
54
54
|
}));
|
|
55
|
-
components.push(new TextDisplay(`### Command\n\`\`\`\n${params.commandPreview}\n\`\`\``));
|
|
55
|
+
components.push(new TextDisplay(`### ${params.commandLabel ?? "Command"}\n\`\`\`\n${params.commandPreview}\n\`\`\``));
|
|
56
56
|
if (params.commandSecondaryPreview) components.push(new TextDisplay(`### Shell Preview\n\`\`\`\n${params.commandSecondaryPreview}\n\`\`\``));
|
|
57
57
|
if (params.metadataLines?.length) components.push(new TextDisplay(params.metadataLines.join("\n")));
|
|
58
58
|
if (params.actionRow) components.push(params.actionRow);
|
|
@@ -140,15 +140,16 @@ function resolveCommandPreviews(commandText, commandPreview, maxChars, secondary
|
|
|
140
140
|
function createApprovalContainer(params) {
|
|
141
141
|
const { view } = params;
|
|
142
142
|
const plugin = view.approvalKind === "plugin";
|
|
143
|
+
const systemAgent = view.approvalKind === "system-agent";
|
|
143
144
|
const pending = view.phase === "pending";
|
|
144
|
-
const approvalLabel = plugin ? "Plugin" : "Exec";
|
|
145
|
+
const approvalLabel = plugin ? "Plugin" : systemAgent ? "OpenClaw Change" : "Exec";
|
|
145
146
|
const { commandPreview, commandSecondaryPreview } = plugin ? {
|
|
146
147
|
commandPreview: formatCommandPreview(view.title, 700),
|
|
147
148
|
commandSecondaryPreview: formatOptionalCommandPreview(view.description, 1e3)
|
|
148
149
|
} : resolveCommandPreviews(view.commandText, view.commandPreview, pending ? 1e3 : 500, pending ? 500 : 300);
|
|
149
|
-
const decisionLabel = view.phase !== "resolved" ? void 0 : view.decision === "allow-once" ? "Allowed (once)" : view.decision === "allow-always" ? "Allowed (always)" : "Denied";
|
|
150
|
+
const decisionLabel = view.phase !== "resolved" ? void 0 : systemAgent && view.terminalStatus === "cancelled" ? "Cancelled" : systemAgent && view.applicationStatus === "applied" ? "Applied" : systemAgent && view.applicationStatus === "not-applied" ? "Not applied" : view.decision === "allow-once" ? "Allowed (once)" : view.decision === "allow-always" ? "Allowed (always)" : "Denied";
|
|
150
151
|
const title = pending ? `${approvalLabel} Approval Required` : `${approvalLabel} Approval: ${view.phase === "expired" ? "Expired" : decisionLabel}`;
|
|
151
|
-
const description = pending ? plugin ? "A plugin action needs your approval." : "A command needs your approval." : view.phase === "expired" ? "This approval request has expired." : view.resolvedBy ? `Resolved by ${formatDiscordApprovalDisplayValue(view.resolvedBy)}` : "Resolved";
|
|
152
|
+
const description = pending ? plugin ? "A plugin action needs your approval." : systemAgent ? "An OpenClaw change needs your approval." : "A command needs your approval." : view.phase === "expired" ? "This approval request has expired." : view.resolvedBy ? `Resolved by ${formatDiscordApprovalDisplayValue(view.resolvedBy)}` : "Resolved";
|
|
152
153
|
const accentColor = view.phase === "expired" ? "#99AAB5" : view.phase === "resolved" ? view.decision === "deny" ? "#ED4245" : view.decision === "allow-always" ? "#5865F2" : "#57F287" : plugin ? view.severity === "critical" ? "#ED4245" : view.severity === "info" ? "#5865F2" : "#FAA61A" : "#FFA500";
|
|
153
154
|
const approvalId = formatDiscordApprovalDisplayValue(view.approvalId);
|
|
154
155
|
const footer = pending ? `Expires <t:${Math.max(0, Math.floor(view.expiresAtMs / 1e3))}:R> · ID: ${approvalId}` : `ID: ${approvalId}`;
|
|
@@ -157,6 +158,7 @@ function createApprovalContainer(params) {
|
|
|
157
158
|
accountId: params.accountId,
|
|
158
159
|
title,
|
|
159
160
|
description,
|
|
161
|
+
commandLabel: systemAgent ? "Change" : "Command",
|
|
160
162
|
commandPreview,
|
|
161
163
|
commandSecondaryPreview,
|
|
162
164
|
metadataLines: buildApprovalMetadataLines(view.metadata),
|
|
@@ -196,7 +198,11 @@ async function finalizeMessage(params) {
|
|
|
196
198
|
}
|
|
197
199
|
}
|
|
198
200
|
const discordApprovalNativeRuntime = createChannelApprovalNativeRuntimeAdapter({
|
|
199
|
-
eventKinds: [
|
|
201
|
+
eventKinds: [
|
|
202
|
+
"exec",
|
|
203
|
+
"plugin",
|
|
204
|
+
"system-agent"
|
|
205
|
+
],
|
|
200
206
|
availability: {
|
|
201
207
|
isConfigured: (params) => {
|
|
202
208
|
const resolved = resolveHandlerContext(params);
|
|
@@ -224,12 +230,13 @@ const discordApprovalNativeRuntime = createChannelApprovalNativeRuntimeAdapter({
|
|
|
224
230
|
context
|
|
225
231
|
});
|
|
226
232
|
if (!resolved) return { body: {} };
|
|
227
|
-
|
|
233
|
+
const container = createApprovalContainer({
|
|
228
234
|
view,
|
|
229
235
|
cfg,
|
|
230
236
|
accountId: resolved.accountId,
|
|
231
237
|
actionRow: createApprovalActionRow(view)
|
|
232
|
-
})
|
|
238
|
+
});
|
|
239
|
+
return { body: stripUndefinedFields(serializePayload(buildExecApprovalPayload(container))) };
|
|
233
240
|
},
|
|
234
241
|
buildResolvedResult: ({ cfg, accountId, context, view }) => {
|
|
235
242
|
const resolvedContext = resolveHandlerContext({
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { x as fetchChannelPermissionsDiscord } from "./send.shared-
|
|
3
|
-
import { t as inspectDiscordAccount } from "./account-inspect-
|
|
4
|
-
import "./send-
|
|
5
|
-
import { _ as auditDiscordChannelPermissionsWithFetcher, v as collectDiscordAuditChannelIdsForAccount } from "./outbound-session-route-
|
|
1
|
+
import { sn as __exportAll } from "./retry-DQt1zDgH.js";
|
|
2
|
+
import { x as fetchChannelPermissionsDiscord } from "./send.shared-B0n_fWzu.js";
|
|
3
|
+
import { t as inspectDiscordAccount } from "./account-inspect-BY-ve3yH.js";
|
|
4
|
+
import "./send-CZeWKUiA.js";
|
|
5
|
+
import { _ as auditDiscordChannelPermissionsWithFetcher, v as collectDiscordAuditChannelIdsForAccount } from "./outbound-session-route-Q_HEusBQ.js";
|
|
6
6
|
//#region extensions/discord/src/audit.ts
|
|
7
7
|
var audit_exports = /* @__PURE__ */ __exportAll({
|
|
8
8
|
auditDiscordChannelPermissions: () => auditDiscordChannelPermissions,
|
|
9
9
|
collectDiscordAuditChannelIds: () => collectDiscordAuditChannelIds
|
|
10
10
|
});
|
|
11
11
|
function collectDiscordAuditChannelIds(params) {
|
|
12
|
-
|
|
12
|
+
const account = inspectDiscordAccount({
|
|
13
13
|
cfg: params.cfg,
|
|
14
14
|
accountId: params.accountId
|
|
15
|
-
})
|
|
15
|
+
});
|
|
16
|
+
return collectDiscordAuditChannelIdsForAccount(account.config);
|
|
16
17
|
}
|
|
17
18
|
async function auditDiscordChannelPermissions(params) {
|
|
18
19
|
return await auditDiscordChannelPermissionsWithFetcher({
|