@openclaw/discord 2026.11.3 → 2026.11.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 → account-inspect-DGkdWwix.mjs} +1 -1
- package/dist/.setup/{accounts-ljrzXBJi.mjs → accounts-C_25wyxC.mjs} +9 -6
- package/dist/.setup/{active-turn-thread-route-C4tp9noA.mjs → active-turn-thread-route-KvRTAVE3.mjs} +1 -2
- package/dist/.setup/{allow-list-BKqOldGy.mjs → allow-list-BXrS8-R9.mjs} +4 -152
- package/dist/.setup/{api-DqmMUZau.mjs → api-BlBD4ism.mjs} +10 -20
- package/dist/.setup/{approval-handler.runtime-D0qu1um7.mjs → approval-handler.runtime-BGYjX1t9.mjs} +80 -61
- package/dist/.setup/{approval-message-updates-CdurC9Ej.mjs → approval-message-updates-DKsCfxSW.mjs} +2 -2
- package/dist/.setup/{audit-ChorIwio.mjs → audit-5b-FXj9R.mjs} +4 -4
- package/dist/.setup/{channel-ZilgdF5e.mjs → channel-CWwTHWFo.mjs} +134 -202
- package/dist/.setup/channel-access-9cyzozUP.mjs +24 -0
- package/dist/.setup/channel.setup-B3MtmBQG.mjs +238 -0
- package/dist/.setup/{components-Du9NhD8h.mjs → components-YCvQ6YLS.mjs} +209 -430
- package/dist/.setup/components.base-CiS0h_XP.mjs +32 -0
- package/dist/.setup/{config-schema-_uBILpQf.mjs → config-schema-BNKN1cu5.mjs} +6 -7
- package/dist/.setup/{conversation-binding-route-8Ul1KpGF.mjs → conversation-binding-route-kCTw8cij.mjs} +2 -2
- package/dist/.setup/{directory-config-3iVub-3m.mjs → directory-config-Ble81PWH.mjs} +1 -1
- package/dist/.setup/{directory-live-BDVl2DoC.mjs → directory-live-DH3tpS3x.mjs} +52 -57
- package/dist/.setup/{discord-BMD-JiVS.mjs → discord-DGVSguhx.mjs} +1124 -1710
- package/dist/.setup/{doctor-hQKbkNKq.mjs → doctor-eujgbnpZ.mjs} +3 -5
- package/dist/.setup/endpoint-runtime-lf4DeLas.mjs +139 -0
- package/dist/.setup/guilds-eDq22iSM.mjs +22 -0
- package/dist/.setup/{handle-action-B1lmt4ms.mjs → handle-action-CktwmzMz.mjs} +15 -15
- package/dist/.setup/{handle-action.guild-admin-B6g31cwt.mjs → handle-action.guild-admin-WLQ7fRqI.mjs} +5 -5
- package/dist/.setup/listeners-Df8lx3vK.mjs +47 -0
- package/dist/.setup/{live-policy-config-C_Q966Wh.mjs → live-policy-config-DiBVuaU6.mjs} +2 -3
- package/dist/.setup/{message-handler-CkI3yMjL.mjs → message-handler-hhNSioxo.mjs} +154 -115
- package/dist/.setup/{message-handler.preflight-CEfkFV9U.mjs → message-handler.preflight-BZcZE1o-.mjs} +30 -105
- package/dist/.setup/{message-handler.preflight-pluralkit-D5si80_L.mjs → message-handler.preflight-pluralkit-CYZfXXb6.mjs} +9 -22
- package/dist/.setup/{message-handler.process-DsMtetRf.mjs → message-handler.process-B0n-mQ99.mjs} +256 -373
- package/dist/.setup/outbound-payload-BaZmjewa.mjs +447 -0
- package/dist/.setup/{outbound-session-route-BtUpGBTb.mjs → outbound-session-route-Cgx4i9cS.mjs} +139 -86
- package/dist/.setup/{preflight-audio-wWgsZG5F.mjs → preflight-audio-C6QtD6HX.mjs} +1 -5
- package/dist/.setup/{presence-cache-DCeTsL73.mjs → presence-cache-Dq-3nH7R.mjs} +1 -6
- package/dist/.setup/{probe-CBaoCs-c.mjs → probe-DezB-6xz.mjs} +5 -9
- package/dist/.setup/{provider-CI_OLfvz.mjs → provider-BN2bCIUp.mjs} +3440 -4308
- package/dist/.setup/{provider-session.runtime-TWOo_JZx.mjs → provider-session.runtime-Dr_5X43t.mjs} +3 -3
- package/dist/.setup/provider.runtime-BuJpl0Pv.mjs +1 -0
- package/dist/.setup/proxy-fetch-BzXwBAXt.mjs +30 -0
- package/dist/.setup/{realtime-session.runtime-DvfS4vJj.mjs → realtime-session.runtime-BTDWsV4d.mjs} +44 -81
- package/dist/.setup/{receive-recovery-CKvaG2Hf.mjs → receive-recovery-C3Ks4wAQ.mjs} +13 -27
- package/dist/.setup/{resolve-allowlist-common-cIjtqh2F.mjs → resolve-allowlist-common-Bk8Fj6Ik.mjs} +3 -13
- package/dist/.setup/{resolve-channels-Cj5i7hzj.mjs → resolve-channels-Bp8frXvc.mjs} +7 -8
- package/dist/.setup/{resolve-users-BQLbysRB.mjs → resolve-users-Cvcj22sG.mjs} +4 -7
- package/dist/.setup/{runtime-RWnuJgWB.mjs → runtime-BJaCvlmq.mjs} +196 -239
- package/dist/.setup/{runtime-plifsKg9.mjs → runtime-BMgTyuwg.mjs} +6 -6
- package/dist/.setup/{secret-config-contract-z6FhbT8E.mjs → secret-config-contract-B1kE4sDv.mjs} +4 -9
- package/dist/.setup/{send-da6ENJ9f.mjs → send-CVW7V-VZ.mjs} +149 -175
- package/dist/.setup/{send.components-CWZUuGvA.mjs → send.components-C8YXdnO_.mjs} +59 -71
- package/dist/.setup/{send.outbound-qZ3iK3Vq.mjs → send.outbound-Uzcmh3Yd.mjs} +76 -129
- package/dist/.setup/{send.receipt-C18khRYH.mjs → send.receipt-NZDOTZBU.mjs} +30 -32
- package/dist/.setup/{send.shared-CnlMgoqQ.mjs → send.shared-a_6Oeyg1.mjs} +38 -115
- package/dist/.setup/{sender-identity-DgbJykq0.mjs → sender-identity-76HFb8eK.mjs} +3 -9
- package/dist/.setup/setup-plugin-api-BExhGEhL.mjs +2 -0
- package/dist/.setup/shared-interactive-DmzaoKOM.mjs +316 -0
- package/dist/.setup/{shared-CY5vJM48.mjs → shared-yDUSExm2.mjs} +8 -11
- package/dist/.setup/{subagent-hooks-CIu2TFz3.mjs → subagent-hooks-CDkdHQyy.mjs} +1 -1
- package/dist/.setup/{system-events-DCOLXkwS.mjs → system-events-yfWz150v.mjs} +2 -2
- package/dist/.setup/{target-resolver-CApivu3G.mjs → target-resolver-BOOzqxxM.mjs} +3 -3
- package/dist/.setup/{thread-bindings-DcvT_JgI.mjs → thread-bindings-zce4cpu_.mjs} +12 -20
- package/dist/.setup/{thread-bindings.manager-5Sh7yedN.mjs → thread-bindings.manager-NywKzUtc.mjs} +22 -42
- package/dist/.setup/{thread-bindings.session-updates-BMdJeJMc.mjs → thread-bindings.session-updates-D0j7oh8S.mjs} +11 -18
- package/dist/.setup/{threading-CzjFeUSe.mjs → threading-DodLYDt-.mjs} +68 -105
- package/dist/.setup/{timeouts-CuNARfyw.mjs → timeouts-cIxzatmv.mjs} +1 -1
- package/dist/.setup/{transcripts-source-8RDQrSVb.mjs → transcripts-source-ie9GBWaU.mjs} +110 -179
- package/dist/.setup/{voice-runtime-BsDILmAv.mjs → voice-runtime-B7V_LTdX.mjs} +231 -452
- package/dist/.source-module-urls/d6c089460280c5a04184542d6712e04545caeb1ebb290d3504377b4cc5e22fea.json +1 -0
- package/dist/account-inspect-api.js +1 -1
- package/dist/action-runtime-api.js +1 -2
- package/dist/activities-api.js +286 -341
- package/dist/api.js +16 -16
- package/dist/channel-config-api.js +1 -2
- package/dist/channel-plugin-api.js +1 -2
- package/dist/contract-api.js +1 -2
- package/dist/directory-contract-api.js +1 -1
- package/dist/runtime-api.js +22 -22
- package/dist/runtime-setter-api.js +1 -2
- package/dist/secret-contract-api.js +1 -2
- package/dist/security-audit-contract-api.js +1 -2
- package/dist/security-contract-api.js +1 -2
- package/dist/session-key-api.js +1 -2
- package/dist/setup-entry.js +1 -1
- package/dist/setup-plugin-api.js +1 -2
- package/dist/src/voice/audio-worker.runtime.js +56 -68
- package/dist/subagent-hooks-api.js +1 -1
- package/dist/thread-binding-api.js +1 -2
- package/dist/transcripts-source-api.js +1 -1
- 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-DasWY_OV.mjs +0 -48
- package/dist/.setup/channel.setup-DaDQdctj.mjs +0 -249
- package/dist/.setup/outbound-adapter-DfAanoCO.mjs +0 -543
- package/dist/.setup/provider.runtime-DnionCyo.mjs +0 -2
- package/dist/.setup/setup-plugin-api-D1QuM187.mjs +0 -3
- package/dist/.setup/targets-UWWZ6gF7.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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as listDiscordAccountIds, n as inspectDiscordAccountConfig, v as resolveDiscordAccountAvailability } from "./accounts-
|
|
1
|
+
import { i as listDiscordAccountIds, n as inspectDiscordAccountConfig, v as resolveDiscordAccountAvailability } from "./accounts-C_25wyxC.mjs";
|
|
2
2
|
import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
|
|
3
3
|
import { normalizeSecretInputString } from "openclaw/plugin-sdk/secret-input";
|
|
4
4
|
//#region extensions/discord/src/account-inspect.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
2
|
-
import {
|
|
2
|
+
import { normalizeResolvedSecretInputString, resolveSecretInputString } from "openclaw/plugin-sdk/secret-input";
|
|
3
3
|
import { createAccountActionGate, createAccountListHelpers } from "openclaw/plugin-sdk/account-helpers";
|
|
4
4
|
import { mapAllowFromEntries, normalizeChannelDmPolicy } from "openclaw/plugin-sdk/channel-config-helpers";
|
|
5
5
|
import { resolveConfiguredFromCredentialStatuses } from "openclaw/plugin-sdk/channel-status";
|
|
@@ -8,13 +8,16 @@ import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runti
|
|
|
8
8
|
import { getRuntimeConfigSnapshot, getRuntimeConfigSourceSnapshot, selectApplicableRuntimeConfig } from "openclaw/plugin-sdk/runtime-config-snapshot";
|
|
9
9
|
//#region extensions/discord/src/account-token-inspect.ts
|
|
10
10
|
function inspectDiscordConfiguredToken(value) {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const credential = resolveSecretInputString({
|
|
12
|
+
value,
|
|
13
|
+
path: "Discord token",
|
|
14
|
+
mode: "inspect"
|
|
15
|
+
});
|
|
16
|
+
return credential.status === "missing" ? null : {
|
|
17
|
+
token: credential.value?.replace(/^Bot\s+/i, "") ?? "",
|
|
14
18
|
tokenSource: "config",
|
|
15
|
-
tokenStatus:
|
|
19
|
+
tokenStatus: credential.status
|
|
16
20
|
};
|
|
17
|
-
return null;
|
|
18
21
|
}
|
|
19
22
|
function inspectDiscordAccountTokenState(params) {
|
|
20
23
|
const configuredToken = inspectDiscordConfiguredToken(params.accountToken) ?? (params.hasAccountToken ? null : inspectDiscordConfiguredToken(params.channelToken));
|
package/dist/.setup/{active-turn-thread-route-C4tp9noA.mjs → active-turn-thread-route-KvRTAVE3.mjs}
RENAMED
|
@@ -18,14 +18,13 @@ async function notifyDiscordActiveTurnThreadCreated(params) {
|
|
|
18
18
|
const sourceChannelId = normalizeOptionalString(params.sourceChannelId);
|
|
19
19
|
const sourceMessageId = normalizeOptionalString(params.sourceMessageId);
|
|
20
20
|
const route = key ? Array.from(activeRoutes.get(key) ?? []).find((candidate) => sourceChannelId === candidate.sourceChannelId && sourceMessageId === candidate.sourceMessageId && (!candidate.accountId || !params.accountId || candidate.accountId === params.accountId)) : void 0;
|
|
21
|
-
if (!route || !threadId) return
|
|
21
|
+
if (!route || !threadId) return;
|
|
22
22
|
route.adoptedThreadId = threadId;
|
|
23
23
|
try {
|
|
24
24
|
await route.onThreadAdopted(threadId);
|
|
25
25
|
} catch (error) {
|
|
26
26
|
route.onThreadAdoptionError?.(error);
|
|
27
27
|
}
|
|
28
|
-
return true;
|
|
29
28
|
}
|
|
30
29
|
function notifyDiscordActiveTurnThreadReplyDelivered(params) {
|
|
31
30
|
const key = normalizeOptionalString(params.sessionKey ?? void 0);
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
2
2
|
import { ChannelType } from "discord-api-types/v10";
|
|
3
|
-
import { asFiniteNumberInRange,
|
|
4
|
-
import { readResponseWithLimit } from "openclaw/plugin-sdk/response-limit-runtime";
|
|
5
|
-
import { fetchWithSsrFGuard, isBlockedHostnameOrIp, isLoopbackHost } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
3
|
+
import { asFiniteNumberInRange, parseStrictFiniteNumber } from "openclaw/plugin-sdk/number-runtime";
|
|
6
4
|
import { buildChannelKeyCandidates, normalizeChannelSlug, resolveChannelEntryMatchWithFallback, resolveChannelMatchConfig } from "openclaw/plugin-sdk/channel-targets";
|
|
7
5
|
import { resolveAllowlistMatchByCandidates } from "openclaw/plugin-sdk/allow-from";
|
|
8
6
|
//#region extensions/discord/src/channel-type.ts
|
|
@@ -10,142 +8,6 @@ function isDiscordThreadChannelType(channelType) {
|
|
|
10
8
|
return channelType === ChannelType.AnnouncementThread || channelType === ChannelType.PublicThread || channelType === ChannelType.PrivateThread;
|
|
11
9
|
}
|
|
12
10
|
//#endregion
|
|
13
|
-
//#region extensions/discord/src/endpoint-runtime.ts
|
|
14
|
-
const DISCORD_ENDPOINT_RESPONSE_MAX_BYTES = 8388608;
|
|
15
|
-
const DISCORD_API_URL_ENV = "DISCORD_API_URL";
|
|
16
|
-
function parseHttpAnchor(value, label) {
|
|
17
|
-
let url;
|
|
18
|
-
try {
|
|
19
|
-
url = new URL(value);
|
|
20
|
-
} catch {
|
|
21
|
-
throw new Error(`${label} must be a valid URL`);
|
|
22
|
-
}
|
|
23
|
-
if (url.protocol !== "https:" && !(url.protocol === "http:" && isLoopbackHost(url.hostname))) throw new Error(`${label} must use HTTPS or loopback HTTP`);
|
|
24
|
-
if (url.username || url.password || url.hash) throw new Error(`${label} must not contain credentials or a fragment`);
|
|
25
|
-
return url;
|
|
26
|
-
}
|
|
27
|
-
function normalizeRestApiBaseUrl(value) {
|
|
28
|
-
const url = parseHttpAnchor(value, "Discord endpoint REST API base URL");
|
|
29
|
-
if (url.search) throw new Error("Discord endpoint REST API base URL must not contain a query");
|
|
30
|
-
url.pathname = url.pathname.replace(/\/+$/u, "") || "/";
|
|
31
|
-
return url;
|
|
32
|
-
}
|
|
33
|
-
function resolveDescriptor(apiUrl) {
|
|
34
|
-
const restApiBaseUrl = normalizeRestApiBaseUrl(apiUrl);
|
|
35
|
-
const gatewayBotUrl = new URL(`${restApiBaseUrl.pathname.replace(/\/+$/u, "")}/gateway/bot`, restApiBaseUrl.origin);
|
|
36
|
-
const gatewayOriginUrl = new URL(restApiBaseUrl.origin);
|
|
37
|
-
gatewayOriginUrl.protocol = gatewayOriginUrl.protocol === "https:" ? "wss:" : "ws:";
|
|
38
|
-
if (gatewayOriginUrl.protocol === "wss:" && isBlockedHostnameOrIp(gatewayOriginUrl.hostname)) throw new Error("Discord endpoint Gateway origin must not target a private/internal/special-use hostname or IP address");
|
|
39
|
-
return Object.freeze({
|
|
40
|
-
restApiBaseUrl: restApiBaseUrl.toString().replace(/\/$/u, ""),
|
|
41
|
-
gatewayBotUrl: gatewayBotUrl.toString(),
|
|
42
|
-
gatewayOrigin: gatewayOriginUrl.origin
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
function isWithinRestApiBase(target, restApiBaseUrl) {
|
|
46
|
-
if (target.origin !== restApiBaseUrl.origin) return false;
|
|
47
|
-
const basePath = restApiBaseUrl.pathname.replace(/\/+$/u, "");
|
|
48
|
-
return basePath === "" || target.pathname === basePath || target.pathname.startsWith(`${basePath}/`);
|
|
49
|
-
}
|
|
50
|
-
function assertEndpointHttpTarget(target, descriptor) {
|
|
51
|
-
const restApiBaseUrl = new URL(descriptor.restApiBaseUrl);
|
|
52
|
-
const gatewayBotUrl = new URL(descriptor.gatewayBotUrl);
|
|
53
|
-
if (!isWithinRestApiBase(target, restApiBaseUrl) && target.toString() !== gatewayBotUrl.toString()) throw new Error("Discord endpoint request is outside the configured boundaries");
|
|
54
|
-
}
|
|
55
|
-
function requestInitFromRequest(request, signal) {
|
|
56
|
-
return {
|
|
57
|
-
method: request.method,
|
|
58
|
-
headers: request.headers,
|
|
59
|
-
...request.body ? {
|
|
60
|
-
body: request.body,
|
|
61
|
-
duplex: "half"
|
|
62
|
-
} : {},
|
|
63
|
-
signal,
|
|
64
|
-
cache: request.cache,
|
|
65
|
-
credentials: request.credentials,
|
|
66
|
-
integrity: request.integrity,
|
|
67
|
-
keepalive: request.keepalive,
|
|
68
|
-
mode: request.mode,
|
|
69
|
-
referrer: request.referrer,
|
|
70
|
-
referrerPolicy: request.referrerPolicy
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
function createEndpointFetch(descriptor) {
|
|
74
|
-
const allowedOrigins = Array.from(/* @__PURE__ */ new Set([new URL(descriptor.restApiBaseUrl).origin, new URL(descriptor.gatewayBotUrl).origin]));
|
|
75
|
-
return async (input, init, beforeRequest) => {
|
|
76
|
-
const request = new Request(input, init);
|
|
77
|
-
const target = new URL(request.url);
|
|
78
|
-
assertEndpointHttpTarget(target, descriptor);
|
|
79
|
-
const guarded = await fetchWithSsrFGuard({
|
|
80
|
-
url: target.toString(),
|
|
81
|
-
init: requestInitFromRequest(request, request.signal),
|
|
82
|
-
signal: request.signal,
|
|
83
|
-
requireHttps: target.protocol === "https:",
|
|
84
|
-
policy: { allowedOrigins },
|
|
85
|
-
maxRedirects: 0,
|
|
86
|
-
capture: false,
|
|
87
|
-
auditContext: "discord.endpoint-runtime",
|
|
88
|
-
beforeRequest
|
|
89
|
-
});
|
|
90
|
-
try {
|
|
91
|
-
const body = await readResponseWithLimit(guarded.response, DISCORD_ENDPOINT_RESPONSE_MAX_BYTES, { onOverflow: ({ size, maxBytes }) => /* @__PURE__ */ new Error(`Discord endpoint response too large: ${size} bytes (limit: ${maxBytes} bytes)`) });
|
|
92
|
-
return new Response(body.byteLength > 0 ? new Uint8Array(body) : null, {
|
|
93
|
-
status: guarded.response.status,
|
|
94
|
-
statusText: guarded.response.statusText,
|
|
95
|
-
headers: guarded.response.headers
|
|
96
|
-
});
|
|
97
|
-
} finally {
|
|
98
|
-
await guarded.release();
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
/** Resolve the process-wide Discord API override using the same env convention as sibling channels. */
|
|
103
|
-
function getDiscordEndpointRuntime(env = process.env) {
|
|
104
|
-
const apiUrl = env[DISCORD_API_URL_ENV]?.trim();
|
|
105
|
-
if (!apiUrl) return;
|
|
106
|
-
const descriptor = resolveDescriptor(apiUrl);
|
|
107
|
-
return Object.freeze({
|
|
108
|
-
descriptor,
|
|
109
|
-
fetch: createEndpointFetch(descriptor)
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
function resolveDiscordEndpointMediaGuard(url, retainedRuntime) {
|
|
113
|
-
const guard = resolveEndpointResourceGuard(url, "media", retainedRuntime);
|
|
114
|
-
return guard ? {
|
|
115
|
-
maxRedirects: guard.maxRedirects,
|
|
116
|
-
ssrfPolicy: guard.policy
|
|
117
|
-
} : void 0;
|
|
118
|
-
}
|
|
119
|
-
function resolveDiscordEndpointAttachmentGuard(url, retainedRuntime) {
|
|
120
|
-
return resolveEndpointResourceGuard(url, "attachment upload", retainedRuntime);
|
|
121
|
-
}
|
|
122
|
-
function resolveEndpointResourceGuard(url, kind, retainedRuntime) {
|
|
123
|
-
if (retainedRuntime === null) return;
|
|
124
|
-
const runtime = retainedRuntime ?? getDiscordEndpointRuntime();
|
|
125
|
-
if (!runtime) return;
|
|
126
|
-
const target = parseHttpAnchor(url, `Discord endpoint ${kind} URL`);
|
|
127
|
-
const restOrigin = new URL(runtime.descriptor.restApiBaseUrl).origin;
|
|
128
|
-
if (target.origin !== restOrigin) throw new Error(`Discord endpoint ${kind} URL is outside the configured REST origin`);
|
|
129
|
-
return {
|
|
130
|
-
maxRedirects: 0,
|
|
131
|
-
policy: {
|
|
132
|
-
allowedOrigins: [restOrigin],
|
|
133
|
-
hostnameAllowlist: [target.hostname]
|
|
134
|
-
},
|
|
135
|
-
requireHttps: target.protocol === "https:"
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
function assertDiscordEndpointGatewayUrl(url, gatewayOrigin) {
|
|
139
|
-
if (!gatewayOrigin) return;
|
|
140
|
-
let parsed;
|
|
141
|
-
try {
|
|
142
|
-
parsed = new URL(url);
|
|
143
|
-
} catch {
|
|
144
|
-
throw new Error("Discord endpoint returned an invalid Gateway WebSocket URL");
|
|
145
|
-
}
|
|
146
|
-
if (parsed.origin !== gatewayOrigin || parsed.username || parsed.password || parsed.hash) throw new Error("Discord endpoint Gateway URL is outside the configured WebSocket origin");
|
|
147
|
-
}
|
|
148
|
-
//#endregion
|
|
149
11
|
//#region extensions/discord/src/retry-after.ts
|
|
150
12
|
const RETRY_AFTER_BODY_SECONDS_RE = /^(?:\d+\.?\d*|\.\d+)$/;
|
|
151
13
|
const MAX_SAFE_RETRY_AFTER_SECONDS = Number.MAX_SAFE_INTEGER / 1e3;
|
|
@@ -158,12 +20,6 @@ function parseDiscordRetryAfterBodySeconds(value) {
|
|
|
158
20
|
}
|
|
159
21
|
//#endregion
|
|
160
22
|
//#region extensions/discord/src/monitor/format.ts
|
|
161
|
-
function resolveDiscordSystemLocation(params) {
|
|
162
|
-
const { isDirectMessage, isGroupDm, guild, channelName } = params;
|
|
163
|
-
if (isDirectMessage) return "DM";
|
|
164
|
-
if (isGroupDm) return `Group DM #${channelName}`;
|
|
165
|
-
return guild?.name ? `${guild.name} #${channelName}` : `#${channelName}`;
|
|
166
|
-
}
|
|
167
23
|
function formatDiscordReactionEmoji(emoji) {
|
|
168
24
|
if (emoji.id && emoji.name) return `<:${emoji.name}:${emoji.id}>`;
|
|
169
25
|
if (emoji.id) return `emoji:${emoji.id}`;
|
|
@@ -174,9 +30,6 @@ function formatDiscordUserTag(user) {
|
|
|
174
30
|
if (discriminator && discriminator !== "0") return `${user.username}#${discriminator}`;
|
|
175
31
|
return user.username ?? user.id;
|
|
176
32
|
}
|
|
177
|
-
function resolveTimestampMs(timestamp) {
|
|
178
|
-
return parseDateStringTimestampMs(timestamp);
|
|
179
|
-
}
|
|
180
33
|
//#endregion
|
|
181
34
|
//#region extensions/discord/src/monitor/allow-list.ts
|
|
182
35
|
const DISCORD_OWNER_ALLOWLIST_PREFIXES = [
|
|
@@ -216,7 +69,7 @@ function normalizeDiscordSlug(value) {
|
|
|
216
69
|
return normalizeChannelSlug(value);
|
|
217
70
|
}
|
|
218
71
|
function normalizeDiscordDisplaySlug(value) {
|
|
219
|
-
return normalizeLowercaseStringOrEmpty(value).normalize("NFC").replace(
|
|
72
|
+
return normalizeLowercaseStringOrEmpty(value).normalize("NFC").replace(/^#/, "").replace(/[\s_]+/g, "-").replace(/[^\p{L}\p{M}\p{N}-]+/gu, "-").replace(/-{2,}/g, "-").replace(/^-+|-+$/g, "");
|
|
220
73
|
}
|
|
221
74
|
function allowListMatches(list, candidate, params) {
|
|
222
75
|
return resolveDiscordAllowListMatch({
|
|
@@ -441,10 +294,9 @@ function resolveGroupDmAllow(params) {
|
|
|
441
294
|
function shouldEmitDiscordReactionNotification(params) {
|
|
442
295
|
const mode = params.mode ?? "own";
|
|
443
296
|
if (mode === "off") return false;
|
|
444
|
-
const accessGuildInfo = params.guildInfo ?? (params.allowlist ? { users: params.allowlist } : null);
|
|
445
297
|
const { hasAccessRestrictions, memberAllowed } = resolveDiscordMemberAccessState({
|
|
446
298
|
channelConfig: params.channelConfig,
|
|
447
|
-
guildInfo:
|
|
299
|
+
guildInfo: params.guildInfo,
|
|
448
300
|
memberRoleIds: params.memberRoleIds ?? [],
|
|
449
301
|
sender: {
|
|
450
302
|
id: params.userId,
|
|
@@ -460,4 +312,4 @@ function shouldEmitDiscordReactionNotification(params) {
|
|
|
460
312
|
return false;
|
|
461
313
|
}
|
|
462
314
|
//#endregion
|
|
463
|
-
export {
|
|
315
|
+
export { parseDiscordRetryAfterBodySeconds as C, formatDiscordUserTag as S, resolveDiscordOwnerAllowFrom as _, normalizeDiscordDisplaySlug as a, shouldEmitDiscordReactionNotification as b, resolveDiscordChannelConfig as c, resolveDiscordCommandAuthorized as d, resolveDiscordGuildEntry as f, resolveDiscordOwnerAccess as g, resolveDiscordMentionPolicy as h, normalizeDiscordAllowList as i, resolveDiscordChannelConfigWithFallback as l, resolveDiscordMemberAllowed as m, hasConfiguredDiscordChannels as n, normalizeDiscordSlug as o, resolveDiscordMemberAccessState as p, isDiscordGroupAllowedByPolicy as r, resolveDiscordAllowListMatch as s, allowListMatches as t, resolveDiscordChannelPolicyCommandAuthorizer as u, resolveDiscordShouldRequireMention as v, isDiscordThreadChannelType as w, formatDiscordReactionEmoji as x, resolveGroupDmAllow as y };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as parseDiscordRetryAfterBodySeconds } from "./allow-list-BXrS8-R9.mjs";
|
|
2
|
+
import { n as getDiscordEndpointRuntime } from "./endpoint-runtime-lf4DeLas.mjs";
|
|
2
3
|
import { sleepWithAbort } from "openclaw/plugin-sdk/runtime-env";
|
|
3
4
|
import { resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
|
|
4
5
|
import { captureChannelReadAuthority, captureEffectAuthority, resolveFetch } from "openclaw/plugin-sdk/fetch-runtime";
|
|
@@ -50,22 +51,9 @@ function parseDiscordApiErrorPayload(text) {
|
|
|
50
51
|
return null;
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
|
-
function
|
|
54
|
-
const payload = parseDiscordApiErrorPayload(text);
|
|
55
|
-
const retryAfter = parseDiscordRetryAfterBodySeconds(payload?.retry_after);
|
|
56
|
-
if (retryAfter !== void 0) return retryAfter;
|
|
57
|
-
const header = response.headers.get("Retry-After");
|
|
58
|
-
return header ? parseRetryAfterHeaderSeconds(header) : void 0;
|
|
59
|
-
}
|
|
60
|
-
function formatRetryAfterSeconds(raw) {
|
|
61
|
-
const value = parseDiscordRetryAfterBodySeconds(raw);
|
|
62
|
-
if (value === void 0) return;
|
|
63
|
-
return `${value < 10 ? value.toFixed(1) : Math.round(value).toString()}s`;
|
|
64
|
-
}
|
|
65
|
-
function formatDiscordApiErrorTextUntrusted(text, response) {
|
|
54
|
+
function formatDiscordApiErrorTextUntrusted(text, response, payload, retryAfter) {
|
|
66
55
|
const trimmed = text.trim();
|
|
67
56
|
if (!trimmed) return;
|
|
68
|
-
const payload = parseDiscordApiErrorPayload(trimmed);
|
|
69
57
|
if (!payload) {
|
|
70
58
|
if (trimmed.startsWith("{") && trimmed.endsWith("}")) return "unknown error";
|
|
71
59
|
const summary = summarizeDiscordResponseBody(trimmed);
|
|
@@ -76,8 +64,8 @@ function formatDiscordApiErrorTextUntrusted(text, response) {
|
|
|
76
64
|
return summary;
|
|
77
65
|
}
|
|
78
66
|
const message = typeof payload.message === "string" && payload.message.trim() ? payload.message.trim() : "unknown error";
|
|
79
|
-
|
|
80
|
-
return
|
|
67
|
+
if (retryAfter === void 0) return message;
|
|
68
|
+
return `${message} (retry after ${retryAfter < 10 ? retryAfter.toFixed(1) : Math.round(retryAfter).toString()}s)`;
|
|
81
69
|
}
|
|
82
70
|
var DiscordApiError = class extends Error {
|
|
83
71
|
constructor(message, status, retryAfter) {
|
|
@@ -98,7 +86,7 @@ function createDiscordRequestSignal(options) {
|
|
|
98
86
|
};
|
|
99
87
|
const controller = new AbortController();
|
|
100
88
|
const timeout = setTimeout(() => controller.abort(), resolveTimerTimeoutMs(options.timeoutMs, 1));
|
|
101
|
-
timeout.unref
|
|
89
|
+
timeout.unref();
|
|
102
90
|
return {
|
|
103
91
|
signal: options.signal ? AbortSignal.any([options.signal, controller.signal]) : controller.signal,
|
|
104
92
|
cleanup: () => clearTimeout(timeout)
|
|
@@ -130,10 +118,12 @@ async function requestDiscord(path, token, options) {
|
|
|
130
118
|
const res = endpoint ? await effect.run(request) : await effect.initiate(request);
|
|
131
119
|
if (!res.ok) {
|
|
132
120
|
const text = await readResponseTextLimited(res, DISCORD_API_ERROR_BODY_LIMIT_BYTES).catch(() => "");
|
|
133
|
-
const
|
|
121
|
+
const errorPayload = parseDiscordApiErrorPayload(text);
|
|
122
|
+
const bodyRetryAfter = parseDiscordRetryAfterBodySeconds(errorPayload?.retry_after);
|
|
123
|
+
const untrustedDetail = formatDiscordApiErrorTextUntrusted(text, res, errorPayload, bodyRetryAfter);
|
|
134
124
|
const detail = untrustedDetail ? redactToolPayloadText(untrustedDetail) : untrustedDetail;
|
|
135
125
|
const suffix = detail ? `: ${detail}` : "";
|
|
136
|
-
const retryAfter = res.status === 429 ?
|
|
126
|
+
const retryAfter = res.status === 429 ? bodyRetryAfter ?? parseRetryAfterHeaderSeconds(res.headers.get("Retry-After")) ?? DISCORD_API_429_FALLBACK_RETRY_AFTER_SECONDS : void 0;
|
|
137
127
|
throw new DiscordApiError(`Discord API ${path} failed (${res.status})${suffix}`, res.status, retryAfter);
|
|
138
128
|
}
|
|
139
129
|
const responseBody = await readResponseWithLimit(res, DISCORD_API_RESPONSE_BODY_LIMIT_BYTES, { onOverflow: ({ size, maxBytes }) => /* @__PURE__ */ new Error(`Discord API ${path} response body too large: ${size} bytes (limit: ${maxBytes} bytes)`) });
|
package/dist/.setup/{approval-handler.runtime-D0qu1um7.mjs → approval-handler.runtime-BGYjX1t9.mjs}
RENAMED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { D as createDiscordMessageNonce,
|
|
2
|
-
import { D as
|
|
3
|
-
import { y as findGraphemeChunkEnd } from "./send.receipt-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { D as createDiscordMessageNonce, M as createDiscordClient } from "./send.shared-a_6Oeyg1.mjs";
|
|
2
|
+
import { D as editChannelMessage, E as deleteChannelMessage, J as stripUndefinedFields, f as serializePayload, w as createChannelMessage, y as createUserDmChannel } from "./discord-DGVSguhx.mjs";
|
|
3
|
+
import { y as findGraphemeChunkEnd } from "./send.receipt-NZDOTZBU.mjs";
|
|
4
|
+
import { r as colorToNumber } from "./components.base-CiS0h_XP.mjs";
|
|
5
|
+
import { a as DISCORD_APPROVAL_DECISIONS, o as buildExecApprovalCustomId } from "./shared-interactive-DmzaoKOM.mjs";
|
|
6
|
+
import { c as formatDiscordApprovalDisplayValue, k as isDiscordExecApprovalClientEnabled, s as DISCORD_APPROVAL_ALLOWED_MENTIONS } from "./outbound-session-route-Cgx4i9cS.mjs";
|
|
7
|
+
import { r as shouldHandleDiscordApprovalRequest } from "./channel-CWwTHWFo.mjs";
|
|
8
|
+
import { t as discordApprovalMessageUpdates } from "./approval-message-updates-DKsCfxSW.mjs";
|
|
8
9
|
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
9
|
-
import { ButtonStyle } from "discord-api-types/v10";
|
|
10
|
+
import { ButtonStyle, ComponentType } from "discord-api-types/v10";
|
|
10
11
|
import { logDebug, logError } from "openclaw/plugin-sdk/logging-core";
|
|
11
|
-
import { createChannelApprovalNativeRuntimeAdapterAsync } from "openclaw/plugin-sdk/approval-handler-runtime";
|
|
12
12
|
import { formatChannelApprovalResolvedLabel } from "openclaw/plugin-sdk/approval-runtime";
|
|
13
|
+
import { createChannelApprovalNativeRuntimeAdapterAsync } from "openclaw/plugin-sdk/approval-handler-runtime";
|
|
13
14
|
//#region extensions/discord/src/approval-handler.runtime.ts
|
|
14
15
|
function resolveHandlerContext(params) {
|
|
15
16
|
const context = params.context;
|
|
@@ -20,14 +21,14 @@ function resolveHandlerContext(params) {
|
|
|
20
21
|
context
|
|
21
22
|
};
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
}
|
|
24
|
+
function createApprovalActionButton(view, descriptor) {
|
|
25
|
+
return {
|
|
26
|
+
type: ComponentType.Button,
|
|
27
|
+
custom_id: buildExecApprovalCustomId(view.approvalId, view.approvalKind, descriptor.decision),
|
|
28
|
+
label: descriptor.label,
|
|
29
|
+
style: descriptor.style === "success" ? ButtonStyle.Success : descriptor.style === "primary" ? ButtonStyle.Primary : descriptor.style === "danger" ? ButtonStyle.Danger : ButtonStyle.Secondary
|
|
30
|
+
};
|
|
31
|
+
}
|
|
31
32
|
function buildExecApprovalPayload(container) {
|
|
32
33
|
return {
|
|
33
34
|
components: [container],
|
|
@@ -46,49 +47,56 @@ function createApprovalContainer(view) {
|
|
|
46
47
|
const commandPreview = formatCommandPreview(plugin ? view.title : view.commandText, plugin ? 700 : pending ? 1e3 : 500);
|
|
47
48
|
const secondaryText = plugin ? view.description : view.commandPreview;
|
|
48
49
|
const commandSecondaryPreview = secondaryText ? formatCommandPreview(secondaryText, plugin ? 1e3 : pending ? 500 : 300) : null;
|
|
49
|
-
const decisionLabel = view.phase === "resolved" ? formatChannelApprovalResolvedLabel(view, (decision) => decision
|
|
50
|
+
const decisionLabel = view.phase === "resolved" ? formatChannelApprovalResolvedLabel(view, (decision) => DISCORD_APPROVAL_DECISIONS[decision].label) : void 0;
|
|
50
51
|
const title = pending ? `${approvalLabel} Approval Required` : `${approvalLabel} Approval: ${view.phase === "expired" ? "Expired" : decisionLabel}`;
|
|
51
52
|
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";
|
|
52
|
-
const accentColor = view.phase === "expired" ? "#99AAB5" : view.phase === "resolved" ? view.decision
|
|
53
|
+
const accentColor = view.phase === "expired" ? "#99AAB5" : view.phase === "resolved" ? DISCORD_APPROVAL_DECISIONS[view.decision].color : plugin ? view.severity === "critical" ? "#ED4245" : view.severity === "info" ? "#5865F2" : "#FAA61A" : "#FFA500";
|
|
53
54
|
const approvalId = formatDiscordApprovalDisplayValue(view.approvalId);
|
|
54
55
|
const footer = pending ? `Expires <t:${Math.max(0, Math.floor(view.expiresAtMs / 1e3))}:R> · ID: ${approvalId}` : `ID: ${approvalId}`;
|
|
55
56
|
const components = [
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
{
|
|
58
|
+
type: ComponentType.TextDisplay,
|
|
59
|
+
content: `## ${title}`
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
type: ComponentType.TextDisplay,
|
|
63
|
+
content: description
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
type: ComponentType.Separator,
|
|
59
67
|
divider: true,
|
|
60
|
-
spacing:
|
|
61
|
-
}
|
|
62
|
-
|
|
68
|
+
spacing: 1
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
type: ComponentType.TextDisplay,
|
|
72
|
+
content: `### ${systemAgent ? "Change" : "Command"}\n\`\`\`\n${commandPreview}\n\`\`\``
|
|
73
|
+
}
|
|
63
74
|
];
|
|
64
|
-
if (commandSecondaryPreview) components.push(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
75
|
+
if (commandSecondaryPreview) components.push({
|
|
76
|
+
type: ComponentType.TextDisplay,
|
|
77
|
+
content: `### Shell Preview\n\`\`\`\n${commandSecondaryPreview}\n\`\`\``
|
|
78
|
+
});
|
|
79
|
+
if (view.metadata.length) components.push({
|
|
80
|
+
type: ComponentType.TextDisplay,
|
|
81
|
+
content: view.metadata.map((item) => `- ${item.label}: ${item.value}`).join("\n")
|
|
82
|
+
});
|
|
83
|
+
if (pending) components.push({
|
|
84
|
+
type: ComponentType.ActionRow,
|
|
85
|
+
components: view.actions.map((descriptor) => createApprovalActionButton(view, descriptor))
|
|
86
|
+
});
|
|
87
|
+
components.push({
|
|
88
|
+
type: ComponentType.Separator,
|
|
68
89
|
divider: false,
|
|
69
|
-
spacing:
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
accountId: params.accountId
|
|
80
|
-
});
|
|
81
|
-
let request;
|
|
82
|
-
if (operation === "delete") request = () => deleteChannelMessage(rest, params.channelId, params.messageId);
|
|
83
|
-
else {
|
|
84
|
-
const payload = buildExecApprovalPayload(params.container);
|
|
85
|
-
request = () => editChannelMessage(rest, params.channelId, params.messageId, { body: stripUndefinedFields(serializePayload(payload)) });
|
|
86
|
-
}
|
|
87
|
-
await discordApprovalMessageUpdates.enqueue(params.messageId, () => discordRequest(request, `${operation}-approval`));
|
|
88
|
-
return;
|
|
89
|
-
} catch (err) {
|
|
90
|
-
logError(`discord approvals: failed to ${operation} message: ${String(err)}`);
|
|
91
|
-
}
|
|
90
|
+
spacing: 1
|
|
91
|
+
}, {
|
|
92
|
+
type: ComponentType.TextDisplay,
|
|
93
|
+
content: `-# ${footer}`
|
|
94
|
+
});
|
|
95
|
+
return {
|
|
96
|
+
type: ComponentType.Container,
|
|
97
|
+
components,
|
|
98
|
+
accent_color: colorToNumber(accentColor)
|
|
99
|
+
};
|
|
92
100
|
}
|
|
93
101
|
function buildTerminalApprovalResult(params) {
|
|
94
102
|
if (!resolveHandlerContext(params)) return { kind: "delete" };
|
|
@@ -205,15 +213,26 @@ const discordApprovalNativeRuntime = createChannelApprovalNativeRuntimeAdapterAs
|
|
|
205
213
|
});
|
|
206
214
|
if (!resolved) return;
|
|
207
215
|
const container = payload;
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
216
|
+
const { token } = resolved.context;
|
|
217
|
+
const { discordChannelId, discordMessageId } = entry;
|
|
218
|
+
const operations = phase === "resolved" && resolved.context.config.cleanupAfterResolve ? ["delete", "update"] : ["update"];
|
|
219
|
+
for (const operation of operations) try {
|
|
220
|
+
const { rest, request: discordRequest } = createDiscordClient({
|
|
221
|
+
cfg,
|
|
222
|
+
token,
|
|
223
|
+
accountId: resolved.accountId
|
|
224
|
+
});
|
|
225
|
+
let request;
|
|
226
|
+
if (operation === "delete") request = () => deleteChannelMessage(rest, discordChannelId, discordMessageId);
|
|
227
|
+
else {
|
|
228
|
+
const messagePayload = buildExecApprovalPayload(container);
|
|
229
|
+
request = () => editChannelMessage(rest, discordChannelId, discordMessageId, { body: stripUndefinedFields(serializePayload(messagePayload)) });
|
|
230
|
+
}
|
|
231
|
+
await discordApprovalMessageUpdates.enqueue(discordMessageId, () => discordRequest(request, `${operation}-approval`));
|
|
232
|
+
return;
|
|
233
|
+
} catch (err) {
|
|
234
|
+
logError(`discord approvals: failed to ${operation} message: ${String(err)}`);
|
|
235
|
+
}
|
|
217
236
|
}
|
|
218
237
|
},
|
|
219
238
|
observe: {
|
package/dist/.setup/{approval-message-updates-CdurC9Ej.mjs → approval-message-updates-DKsCfxSW.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { i as parseCustomId } from "./components.base-CiS0h_XP.mjs";
|
|
2
|
+
import { s as parseExecApprovalData } from "./shared-interactive-DmzaoKOM.mjs";
|
|
3
3
|
import { KeyedAsyncQueue } from "openclaw/plugin-sdk/keyed-async-queue";
|
|
4
4
|
//#region extensions/discord/src/approval-message-updates.ts
|
|
5
5
|
const discordApprovalMessageUpdates = new KeyedAsyncQueue();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.mjs";
|
|
2
|
-
import { t as inspectDiscordAccount } from "./account-inspect-
|
|
3
|
-
import { b as fetchChannelPermissionsDiscord } from "./send.shared-
|
|
4
|
-
import "./send-
|
|
5
|
-
import {
|
|
2
|
+
import { t as inspectDiscordAccount } from "./account-inspect-DGkdWwix.mjs";
|
|
3
|
+
import { b as fetchChannelPermissionsDiscord } from "./send.shared-a_6Oeyg1.mjs";
|
|
4
|
+
import "./send-CVW7V-VZ.mjs";
|
|
5
|
+
import { T as collectDiscordAuditChannelIdsForAccount, w as auditDiscordChannelPermissionsWithFetcher } from "./outbound-session-route-Cgx4i9cS.mjs";
|
|
6
6
|
//#region extensions/discord/src/audit.ts
|
|
7
7
|
var audit_exports = /* @__PURE__ */ __exportAll({
|
|
8
8
|
auditDiscordChannelPermissions: () => auditDiscordChannelPermissions,
|