@openclaw/discord 2026.7.2-beta.7 → 2026.8.1-beta.3
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-SXiCBCgP.js → account-inspect-D5xmUpnj.js} +49 -43
- package/dist/account-inspect-api.js +1 -1
- package/dist/accounts-DNl-oCEw.js +371 -0
- package/dist/action-runtime-api.js +1 -1
- package/dist/{active-turn-thread-route-MlKWp8RD.js → active-turn-thread-route-fmHl1HNd.js} +9 -11
- package/dist/{activities-api-DTKsuDxf.js → activities-api-KCBAmWxD.js} +133 -175
- package/dist/activities-api.js +1 -1
- package/dist/{allow-list-DzKrtfah.js → allow-list-BDMimASD.js} +2 -3
- package/dist/{api-DnrK9gML.js → api-DNVbJyEy.js} +7 -2
- package/dist/api.js +18 -18
- package/dist/{approval-handler.runtime-HymvFTYn.js → approval-handler.runtime-B12RCYr8.js} +6 -6
- package/dist/{approval-message-safety-DEyKVsAw.js → approval-message-safety-XGFPbDoI.js} +89 -3
- package/dist/{audit-CjsrabP8.js → audit-Yc7eZDd6.js} +5 -5
- package/dist/{channel-actions-uXFTJX3o.js → channel-actions-Dr2QI8Bf.js} +11 -7
- package/dist/{channel-actions.runtime-CIYU90sl.js → channel-actions.runtime-CODTvo7c.js} +99 -97
- package/dist/{channel-vKa-76xY.js → channel-cXYzGc4L.js} +102 -104
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel.setup-CmcwZ_qd.js → channel.setup-CSiwnMgs.js} +16 -54
- package/dist/{outbound-session-route-H-HoyH5U.js → components-ezGKo_Yh.js} +69 -142
- package/dist/{config-schema-WHRQcY19.js → config-schema-DC5kDtQ5.js} +42 -11
- package/dist/conversation-binding-route-D6rCQ5S0.js +43 -0
- package/dist/{directory-config-D_LojtCe.js → directory-config-XyCfoqLg.js} +2 -2
- package/dist/directory-contract-api.js +1 -1
- package/dist/{directory-live-Bw5Ephzv.js → directory-live-Df0NbFJB.js} +7 -4
- package/dist/{doctor-Bc4S1qyd.js → doctor-DYY31GrO.js} +34 -13
- package/dist/{doctor-contract-CCFMIDk9.js → doctor-contract-DsWvKIXF.js} +2 -3
- package/dist/doctor-contract-api.js +147 -2
- package/dist/{handle-action.guild-admin-D6VRRW-C.js → handle-action.guild-admin-6Tvvinsa.js} +4 -7
- package/dist/{inbound-event-delivery-CEPlt2uz.js → inbound-event-delivery-De2qxTrP.js} +4 -25
- package/dist/index.js +5 -4
- package/dist/{message-handler-CeiSulIw.js → message-handler-B61q5MOF.js} +118 -33
- package/dist/{message-handler.preflight-DibgQFf2.js → message-handler.preflight-Bzg_Hawz.js} +75 -61
- package/dist/{message-handler.process-Dnc_oz9y.js → message-handler.process--4_712Ec.js} +236 -296
- package/dist/{message-utils-BgTwT_q7.js → message-utils-BXLLnFl6.js} +34 -35
- package/dist/{model-picker-preference-primitives-D25pnCOu.js → model-picker-preference-primitives-BHT1LkR_.js} +3 -3
- package/dist/{outbound-adapter-DtE-i2OJ.js → outbound-adapter-DxHTOqiN.js} +157 -68
- package/dist/{outbound-components-C7GVyfPh.js → outbound-components-B2PL0ooH.js} +3 -3
- package/dist/owner-access-Bg41VzAf.js +107 -0
- package/dist/{pluralkit-CD4B11JB.js → pluralkit-dUl4v1X3.js} +1 -1
- package/dist/{preflight-audio-BjnQZ5yS.js → preflight-audio-DrnqFA8U.js} +22 -28
- package/dist/{probe-BeWKhjqX.js → probe-BTdtVRwU.js} +37 -13
- package/dist/probe.runtime-Dq5-PRKT.js +2 -0
- package/dist/{provider-DfQJX3z5.js → provider-DlK_ynqt.js} +1131 -2021
- package/dist/{provider-session.runtime-Bo88k0pV.js → provider-session.runtime-CvvphHvs.js} +3 -3
- package/dist/provider.runtime-CzKGRiAF.js +2 -0
- package/dist/realtime-session.runtime-ysbMG8v7.js +1351 -0
- package/dist/{resolve-allowlist-common-DHERApxi.js → resolve-allowlist-common-DIVXbD1P.js} +3 -3
- package/dist/{resolve-channels-BjepAj8b.js → resolve-channels-CGeUoIqb.js} +4 -4
- package/dist/{resolve-users-Bc28htgt.js → resolve-users-BtKxLUZv.js} +3 -3
- package/dist/{chunk-DX4jpFQP.js → retry-DNsVTeTo.js} +308 -131
- package/dist/{runtime-BmW_j_hl.js → runtime-CQovMsH3.js} +12 -15
- package/dist/{runtime-_aRC6V2s.js → runtime-D71_VFLr.js} +49 -58
- package/dist/runtime-api.actions.js +2 -2
- package/dist/runtime-api.js +23 -23
- package/dist/runtime-api.lookup.js +5 -5
- package/dist/runtime-api.monitor-CzeTYF32.js +6 -0
- package/dist/runtime-api.monitor.js +6 -5
- package/dist/runtime-api.send.js +6 -6
- package/dist/runtime-api.threads.js +5 -6
- package/dist/sdk-runtime-37OU6_Yh.js +369 -0
- package/dist/{secret-config-contract-B1akrlyY.js → secret-config-contract-B3i6WxV5.js} +53 -25
- package/dist/secret-contract-api.js +1 -1
- package/dist/security-audit-contract-api.js +1 -1
- package/dist/{security-audit.runtime-CPN0xFYz.js → security-audit.runtime-BVKF9VtY.js} +1 -1
- package/dist/{send-CdkZ6zeW.js → send-rQIffSYu.js} +180 -91
- package/dist/{send.components-5uqwkjgE.js → send.components-ChK1wS7w.js} +32 -46
- package/dist/{send.outbound-D-80Ej-t.js → send.outbound-HIkgji_7.js} +57 -34
- package/dist/{send.reactions-CtlmGd_o.js → send.reactions-gmJ6yFPo.js} +14 -21
- package/dist/{send.receipt-CuwRrpFz.js → send.receipt-Cnhoautb.js} +29 -1
- package/dist/{send.shared-jpvAG_u6.js → send.shared-B3fpaLWJ.js} +112 -181
- package/dist/{sender-identity-mG_zsdox.js → sender-identity-BJtfyise.js} +1 -1
- package/dist/setup-entry.js +0 -5
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{shared-CXF1tup1.js → shared-CaAaoksy.js} +27 -23
- package/dist/subagent-hooks-CNT2ZJTJ.js +49 -0
- package/dist/subagent-hooks-api.js +2 -6
- package/dist/subagent-progress-FPLqBY1s.js +110 -0
- package/dist/{system-events-DdUqf91B.js → system-events-Nuwoq_au.js} +2 -2
- package/dist/{target-resolver-C3s_2m0t.js → target-resolver-DIXShHaZ.js} +3 -3
- package/dist/targets-B2pf49zc.js +3 -0
- package/dist/{thread-bindings-C-M-ly7P.js → thread-bindings-VlymUnbz.js} +29 -28
- package/dist/{thread-bindings.manager-DYvSlrva.js → thread-bindings.manager-CngsgErq.js} +258 -29
- package/dist/{thread-bindings.session-updates-DAIlp7Px.js → thread-bindings.session-updates-CJb-BpPL.js} +1 -1
- package/dist/{thread-bindings.state-Cgi5uRn-.js → thread-bindings.state-D8OMdk4O.js} +3 -16
- package/dist/threading-DU6pgeGm.js +456 -0
- package/dist/transcripts-source-DeIMNbRh.js +265 -0
- package/dist/transcripts-source-api.js +7 -2
- package/dist/{typing--Mzo2kM7.js → typing-oLiS5Z13.js} +1 -1
- package/dist/voice-runtime-CjNFaynA.js +2549 -0
- package/openclaw.plugin.json +215 -25
- package/package.json +15 -11
- package/skills/discord/SKILL.md +22 -115
- package/dist/accounts-DJTf1LtA.js +0 -219
- package/dist/channel-api-CAJ0wMoV.js +0 -21
- package/dist/legacy-state-migrations-api.js +0 -138
- package/dist/manager.runtime-Bjav3pfC.js +0 -3655
- package/dist/preflight-audio.runtime-CoCXMM8r.js +0 -7
- package/dist/probe.runtime-DqFGFMbZ.js +0 -2
- package/dist/provider.runtime-Cy7XZmyh.js +0 -2
- package/dist/runtime-api.monitor-CCRubd3-.js +0 -5
- package/dist/session-binding-contract-api.js +0 -2
- package/dist/subagent-hooks-Dxy7Fmnq.js +0 -120
- package/dist/subagent-progress-DI3sYLLo.js +0 -664
- package/dist/targets-Dv_RN7vT.js +0 -3
- package/dist/thread-bindings.discord-api-BoDNqamb.js +0 -246
- package/dist/transcripts-source-DIKGsTGT.js +0 -123
- package/node_modules/p-map/index.d.ts +0 -155
- package/node_modules/p-map/index.js +0 -285
- package/node_modules/p-map/license +0 -9
- package/node_modules/p-map/package.json +0 -57
- package/node_modules/p-map/readme.md +0 -190
- package/dist/{audit-core-xwjIczO0.js → audit-core-BCX8UeFH.js} +1 -1
- package/dist/{security-audit-jGnJF__m.js → security-audit-BfJhAXZp.js} +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeOptionalStringifiedId, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
1
|
+
import { c as resolveDiscordChannelInfoSafe } from "./thread-bindings.manager-CngsgErq.js";
|
|
3
2
|
import { ComponentType, StickerFormatType } from "discord-api-types/v10";
|
|
4
3
|
import { asDateTimestampMs, resolveExpiresAtMsFromDurationMs } from "openclaw/plugin-sdk/number-runtime";
|
|
5
|
-
import {
|
|
4
|
+
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeOptionalStringifiedId, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
5
|
+
import { getFileExtension, normalizeMimeType } from "openclaw/plugin-sdk/media-mime";
|
|
6
|
+
import { getChildLogger, logVerbose } from "openclaw/plugin-sdk/runtime-env";
|
|
6
7
|
import { saveRemoteMedia } from "openclaw/plugin-sdk/media-runtime";
|
|
7
8
|
import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
|
|
8
9
|
import { formatMediaPlaceholderText } from "openclaw/plugin-sdk/channel-inbound";
|
|
9
|
-
import { getFileExtension, normalizeMimeType } from "openclaw/plugin-sdk/media-mime";
|
|
10
10
|
//#region extensions/discord/src/monitor/message-channel-info-state.ts
|
|
11
11
|
const discordChannelInfoCacheState = { entries: /* @__PURE__ */ new Map() };
|
|
12
12
|
//#endregion
|
|
@@ -115,7 +115,7 @@ function formatDiscordSnapshotAuthor(author) {
|
|
|
115
115
|
if (author.id) return `@${author.id}`;
|
|
116
116
|
}
|
|
117
117
|
//#endregion
|
|
118
|
-
//#region extensions/discord/src/monitor/
|
|
118
|
+
//#region extensions/discord/src/monitor/media-ssrf-policy.ts
|
|
119
119
|
const DISCORD_MEDIA_SSRF_POLICY = {
|
|
120
120
|
hostnameAllowlist: [
|
|
121
121
|
"cdn.discordapp.com",
|
|
@@ -125,6 +125,25 @@ const DISCORD_MEDIA_SSRF_POLICY = {
|
|
|
125
125
|
],
|
|
126
126
|
allowRfc2544BenchmarkRange: true
|
|
127
127
|
};
|
|
128
|
+
function mergeHostnameList(...lists) {
|
|
129
|
+
const merged = lists.flatMap((list) => list ?? []).map((value) => value.trim()).filter((value) => value.length > 0);
|
|
130
|
+
return merged.length > 0 ? uniqueStrings(merged) : void 0;
|
|
131
|
+
}
|
|
132
|
+
/** Merges caller network policy with the Discord-owned CDN allowlist. */
|
|
133
|
+
function resolveDiscordCdnPolicy(policy) {
|
|
134
|
+
if (!policy) return DISCORD_MEDIA_SSRF_POLICY;
|
|
135
|
+
const hostnameAllowlist = mergeHostnameList(DISCORD_MEDIA_SSRF_POLICY.hostnameAllowlist, policy.hostnameAllowlist);
|
|
136
|
+
const allowedHostnames = mergeHostnameList(DISCORD_MEDIA_SSRF_POLICY.allowedHostnames, policy.allowedHostnames);
|
|
137
|
+
return {
|
|
138
|
+
...DISCORD_MEDIA_SSRF_POLICY,
|
|
139
|
+
...policy,
|
|
140
|
+
...allowedHostnames ? { allowedHostnames } : {},
|
|
141
|
+
...hostnameAllowlist ? { hostnameAllowlist } : {},
|
|
142
|
+
allowRfc2544BenchmarkRange: Boolean(DISCORD_MEDIA_SSRF_POLICY.allowRfc2544BenchmarkRange) || Boolean(policy.allowRfc2544BenchmarkRange)
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region extensions/discord/src/monitor/message-media.ts
|
|
128
147
|
const AUDIO_ATTACHMENT_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
129
148
|
".aac",
|
|
130
149
|
".caf",
|
|
@@ -171,26 +190,9 @@ function resolveDiscordMediaClassification(params) {
|
|
|
171
190
|
...kind ? { kind } : {}
|
|
172
191
|
};
|
|
173
192
|
}
|
|
174
|
-
function mergeHostnameList(...lists) {
|
|
175
|
-
const merged = lists.flatMap((list) => list ?? []).map((value) => value.trim()).filter((value) => value.length > 0);
|
|
176
|
-
if (merged.length === 0) return;
|
|
177
|
-
return uniqueStrings(merged);
|
|
178
|
-
}
|
|
179
|
-
function resolveDiscordMediaSsrFPolicy(policy) {
|
|
180
|
-
if (!policy) return DISCORD_MEDIA_SSRF_POLICY;
|
|
181
|
-
const hostnameAllowlist = mergeHostnameList(DISCORD_MEDIA_SSRF_POLICY.hostnameAllowlist, policy.hostnameAllowlist);
|
|
182
|
-
const allowedHostnames = mergeHostnameList(DISCORD_MEDIA_SSRF_POLICY.allowedHostnames, policy.allowedHostnames);
|
|
183
|
-
return {
|
|
184
|
-
...DISCORD_MEDIA_SSRF_POLICY,
|
|
185
|
-
...policy,
|
|
186
|
-
...allowedHostnames ? { allowedHostnames } : {},
|
|
187
|
-
...hostnameAllowlist ? { hostnameAllowlist } : {},
|
|
188
|
-
allowRfc2544BenchmarkRange: Boolean(DISCORD_MEDIA_SSRF_POLICY.allowRfc2544BenchmarkRange) || Boolean(policy.allowRfc2544BenchmarkRange)
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
193
|
async function resolveMediaList(message, maxBytes, options) {
|
|
192
194
|
const out = [];
|
|
193
|
-
const resolvedSsrFPolicy =
|
|
195
|
+
const resolvedSsrFPolicy = resolveDiscordCdnPolicy(options?.ssrfPolicy);
|
|
194
196
|
await appendResolvedMediaFromAttachments({
|
|
195
197
|
attachments: message.attachments ?? [],
|
|
196
198
|
maxBytes,
|
|
@@ -218,7 +220,7 @@ async function resolveMediaList(message, maxBytes, options) {
|
|
|
218
220
|
async function resolveForwardedMediaList(message, maxBytes, options) {
|
|
219
221
|
const snapshots = resolveDiscordMessageSnapshots(message);
|
|
220
222
|
const out = [];
|
|
221
|
-
const resolvedSsrFPolicy =
|
|
223
|
+
const resolvedSsrFPolicy = resolveDiscordCdnPolicy(options?.ssrfPolicy);
|
|
222
224
|
if (snapshots.length > 0) {
|
|
223
225
|
for (const snapshot of snapshots) {
|
|
224
226
|
await appendResolvedMediaFromAttachments({
|
|
@@ -276,7 +278,7 @@ async function resolveReferencedReplyMediaList(message, maxBytes, options) {
|
|
|
276
278
|
const referencedReply = resolveDiscordReferencedReplyMessage(message);
|
|
277
279
|
const out = [];
|
|
278
280
|
if (!referencedReply) return out;
|
|
279
|
-
const resolvedSsrFPolicy =
|
|
281
|
+
const resolvedSsrFPolicy = resolveDiscordCdnPolicy(options?.ssrfPolicy);
|
|
280
282
|
await appendResolvedMediaFromAttachments({
|
|
281
283
|
attachments: referencedReply.attachments,
|
|
282
284
|
maxBytes,
|
|
@@ -368,7 +370,7 @@ async function appendResolvedMediaFromAttachments(params) {
|
|
|
368
370
|
});
|
|
369
371
|
} catch (err) {
|
|
370
372
|
const id = attachment.id ?? attachmentUrl;
|
|
371
|
-
|
|
373
|
+
getChildLogger({ module: "discord-media" }).warn(`${params.errorPrefix} ${id}: ${String(err)}`);
|
|
372
374
|
const classification = resolveDiscordMediaClassification({ attachment });
|
|
373
375
|
params.out.push({ ...classification });
|
|
374
376
|
}
|
|
@@ -442,7 +444,7 @@ async function appendResolvedMediaFromStickers(params) {
|
|
|
442
444
|
lastError = err;
|
|
443
445
|
}
|
|
444
446
|
if (lastError) {
|
|
445
|
-
|
|
447
|
+
getChildLogger({ module: "discord-media" }).warn(`${params.errorPrefix} ${sticker.id}: ${formatStickerError(lastError)}`);
|
|
446
448
|
if (candidates[0]) params.out.push({
|
|
447
449
|
contentType: inferStickerContentType(sticker),
|
|
448
450
|
kind: "sticker"
|
|
@@ -467,14 +469,11 @@ function formatDiscordMediaText(params) {
|
|
|
467
469
|
}
|
|
468
470
|
//#endregion
|
|
469
471
|
//#region extensions/discord/src/monitor/message-text.ts
|
|
470
|
-
function resolveDiscordEmbedText(
|
|
471
|
-
|
|
472
|
-
const description = normalizeOptionalString(embed?.description) ?? "";
|
|
473
|
-
if (title && description) return `${title}\n${description}`;
|
|
474
|
-
return title || description || "";
|
|
472
|
+
function resolveDiscordEmbedText(embeds) {
|
|
473
|
+
return (embeds ?? []).flatMap(({ title, description }) => [normalizeOptionalString(title), normalizeOptionalString(description)]).filter(Boolean).join("\n");
|
|
475
474
|
}
|
|
476
475
|
function resolveDiscordMessageText(message, options) {
|
|
477
|
-
const embedText = resolveDiscordEmbedText(message.embeds
|
|
476
|
+
const embedText = resolveDiscordEmbedText(message.embeds);
|
|
478
477
|
const componentText = extractDiscordComponentsV2Text(resolveDiscordMessageComponents(message));
|
|
479
478
|
const baseText = resolveDiscordMentions(normalizeOptionalString(message.content) || embedText || componentText || normalizeOptionalString(options?.fallbackText) || "", message);
|
|
480
479
|
if (!options?.includeForwarded) return baseText;
|
|
@@ -557,9 +556,9 @@ function resolveDiscordSnapshotMessageText(snapshot) {
|
|
|
557
556
|
attachments: snapshot.attachments ?? void 0,
|
|
558
557
|
stickers: resolveDiscordSnapshotStickers(snapshot)
|
|
559
558
|
});
|
|
560
|
-
const embedText = resolveDiscordEmbedText(snapshot.embeds
|
|
559
|
+
const embedText = resolveDiscordEmbedText(snapshot.embeds);
|
|
561
560
|
const componentText = extractDiscordComponentsV2Text(snapshot.components);
|
|
562
561
|
return [content || embedText || componentText, attachmentText].filter(Boolean).join("\n");
|
|
563
562
|
}
|
|
564
563
|
//#endregion
|
|
565
|
-
export { formatDiscordMediaText as a, resolveReferencedReplyMediaList as c,
|
|
564
|
+
export { formatDiscordMediaText as a, resolveReferencedReplyMediaList as c, resolveDiscordMessageStickers as d, resolveDiscordChannelInfo as f, resolveDiscordMessageText as i, resolveDiscordCdnPolicy as l, resolveDiscordForwardedMessagesTextFromSnapshots as n, resolveForwardedMediaList as o, resolveDiscordMessageChannelId as p, resolveDiscordMessageHistoryText as r, resolveMediaList as s, resolveDiscordEmbedText as t, hasDiscordMessageStickers as u };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { normalizeProviderId } from "openclaw/plugin-sdk/
|
|
2
|
+
import { normalizeProviderId } from "openclaw/plugin-sdk/model-ref-parse";
|
|
3
3
|
//#region extensions/discord/src/monitor/model-picker-preference-primitives.ts
|
|
4
4
|
function normalizeModelRef(raw) {
|
|
5
5
|
const value = raw?.trim();
|
|
@@ -29,9 +29,9 @@ function hashSegment(value, length) {
|
|
|
29
29
|
function buildPreferenceModelKey(scopeKey, modelRef) {
|
|
30
30
|
return `v1:${hashSegment(scopeKey, 32)}:${hashSegment(modelRef, 24)}`;
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function preferenceTimestampMs(value) {
|
|
33
33
|
const parsed = typeof value === "string" ? Date.parse(value) : NaN;
|
|
34
34
|
return Number.isFinite(parsed) ? parsed : 0;
|
|
35
35
|
}
|
|
36
36
|
//#endregion
|
|
37
|
-
export {
|
|
37
|
+
export { sanitizeRecentModels as i, normalizeModelRef as n, preferenceTimestampMs as r, buildPreferenceModelKey as t };
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import { n as
|
|
4
|
-
import { n as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { a as chunkDiscordTextWithMode, c as resolveDiscordReplyReference, f as normalizeDiscordOutboundTarget, r as hasDiscordMessageCreateAmbiguity } from "./retry-DNsVTeTo.js";
|
|
2
|
+
import { t as createDiscordActionGate } from "./accounts-DNl-oCEw.js";
|
|
3
|
+
import { i as toDiscordOutboundDeliveryResult, n as createDiscordSendReceiptFromResults, t as createDiscordSendReceipt } from "./send.receipt-Cnhoautb.js";
|
|
4
|
+
import { n as formatDiscordApprovalDisplayValue } from "./approval-message-safety-XGFPbDoI.js";
|
|
5
|
+
import { n as notifyDiscordInboundEventOutboundPayloadSuccess, t as discordInboundEventDelivery } from "./inbound-event-delivery-De2qxTrP.js";
|
|
6
|
+
import { a as sendDiscordComponentMessageLazy, i as resolveDiscordComponentSpec, n as buildDiscordPresentationPayload, t as DISCORD_PRESENTATION_CAPABILITIES } from "./outbound-components-B2PL0ooH.js";
|
|
7
7
|
import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
|
|
8
|
+
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeOptionalStringifiedId } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
9
|
+
import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env";
|
|
8
10
|
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
9
11
|
import { createReplyToFanout, resolveOutboundSendDep } from "openclaw/plugin-sdk/channel-outbound";
|
|
12
|
+
import { attachChannelToResult, createAttachedChannelResultAdapter } from "openclaw/plugin-sdk/channel-send-result";
|
|
10
13
|
import { getReplyPayloadTtsSupplement, resolvePayloadMediaUrls, sendPayloadMediaSequenceOrFallback, sendTextMediaPayload } from "openclaw/plugin-sdk/reply-payload";
|
|
11
14
|
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
12
|
-
import { attachChannelToResult, createAttachedChannelResultAdapter } from "openclaw/plugin-sdk/channel-send-result";
|
|
13
15
|
import { questionGatewayRuntime } from "openclaw/plugin-sdk/question-gateway-runtime";
|
|
14
16
|
//#region extensions/discord/src/media-detection.ts
|
|
15
17
|
const DISCORD_VIDEO_MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
@@ -59,7 +61,7 @@ function normalizeDiscordApprovalPayload(payload) {
|
|
|
59
61
|
}
|
|
60
62
|
//#endregion
|
|
61
63
|
//#region extensions/discord/src/outbound-send-context.ts
|
|
62
|
-
const loadDiscordSendRuntime = createLazyRuntimeModule(() => import("./send-
|
|
64
|
+
const loadDiscordSendRuntime = createLazyRuntimeModule(() => import("./send-rQIffSYu.js").then((n) => n.t));
|
|
63
65
|
function resolveDiscordOutboundTarget(params) {
|
|
64
66
|
if (params.threadId == null) return params.to;
|
|
65
67
|
const threadId = normalizeOptionalStringifiedId(params.threadId) ?? "";
|
|
@@ -95,9 +97,10 @@ async function createDiscordPayloadSendContext(ctx) {
|
|
|
95
97
|
}
|
|
96
98
|
//#endregion
|
|
97
99
|
//#region extensions/discord/src/outbound-payload.ts
|
|
100
|
+
const log$1 = createSubsystemLogger("discord/outbound");
|
|
98
101
|
function resolveDiscordDeliveryProgress(ctx) {
|
|
99
102
|
return ctx.onDeliveryResult ? async (result) => {
|
|
100
|
-
await ctx.onDeliveryResult?.(attachChannelToResult("discord", result));
|
|
103
|
+
await ctx.onDeliveryResult?.(attachChannelToResult("discord", toDiscordOutboundDeliveryResult(result)));
|
|
101
104
|
} : void 0;
|
|
102
105
|
}
|
|
103
106
|
function createDiscordUnknownPayloadResult(target) {
|
|
@@ -116,7 +119,8 @@ function resolveDiscordDeliveryOptions(ctx, sendContext, reply = sendContext.res
|
|
|
116
119
|
reply,
|
|
117
120
|
accountId: ctx.accountId ?? void 0,
|
|
118
121
|
silent: ctx.silent ?? void 0,
|
|
119
|
-
cfg: ctx.cfg
|
|
122
|
+
cfg: ctx.cfg,
|
|
123
|
+
onPlatformSendDispatch: ctx.onPlatformSendDispatch
|
|
120
124
|
};
|
|
121
125
|
}
|
|
122
126
|
function resolveDiscordFormattedDeliveryOptions(ctx, sendContext, reply = sendContext.resolveReply()) {
|
|
@@ -144,37 +148,51 @@ async function sendDiscordOutboundPayload(params) {
|
|
|
144
148
|
const sendContext = await createDiscordPayloadSendContext(ctx);
|
|
145
149
|
if (payload.audioAsVoice && mediaUrls.length > 0) {
|
|
146
150
|
const voiceReply = sendContext.resolveReply();
|
|
147
|
-
let
|
|
148
|
-
let lastResult;
|
|
151
|
+
let voiceFailure;
|
|
152
|
+
let lastResult = createDiscordUnknownPayloadResult(sendContext.target);
|
|
149
153
|
try {
|
|
150
154
|
const voiceUrl = expectDefined(mediaUrls.at(0), "non-empty Discord voice media URLs");
|
|
151
|
-
lastResult = await sendContext.sendVoice(sendContext.target, voiceUrl, {
|
|
152
|
-
|
|
155
|
+
lastResult = await sendContext.sendVoice(sendContext.target, voiceUrl, {
|
|
156
|
+
...resolveDiscordDeliveryOptions(ctx, sendContext, voiceReply),
|
|
157
|
+
mediaAccess: ctx.mediaAccess,
|
|
158
|
+
mediaLocalRoots: ctx.mediaLocalRoots,
|
|
159
|
+
mediaReadFile: ctx.mediaReadFile
|
|
160
|
+
});
|
|
153
161
|
} catch (err) {
|
|
162
|
+
if (hasDiscordMessageCreateAmbiguity(err)) throw err;
|
|
154
163
|
const supplement = getReplyPayloadTtsSupplement(payload);
|
|
155
164
|
const visibleFallbackText = payload.text?.trim() ? payload.text : void 0;
|
|
156
165
|
const hiddenFallbackText = supplement?.visibleTextAlreadyDelivered ? void 0 : supplement?.spokenText;
|
|
157
166
|
const fallbackText = visibleFallbackText ?? hiddenFallbackText;
|
|
158
|
-
if (!fallbackText
|
|
159
|
-
|
|
160
|
-
|
|
167
|
+
if (!fallbackText && !supplement?.visibleTextAlreadyDelivered) throw err;
|
|
168
|
+
log$1.warn("discord voice send failed; continuing without voice", { error: err });
|
|
169
|
+
if (fallbackText) await sendContext.send(sendContext.target, fallbackText, {
|
|
161
170
|
verbose: false,
|
|
162
171
|
...resolveDiscordFormattedDeliveryOptions(ctx, sendContext, voiceReply),
|
|
163
172
|
onDeliveryResult: resolveDiscordDeliveryProgress(ctx)
|
|
164
173
|
});
|
|
174
|
+
voiceFailure = { error: err };
|
|
165
175
|
}
|
|
166
|
-
if (
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
176
|
+
if (!voiceFailure) {
|
|
177
|
+
await ctx.onDeliveryResult?.(attachChannelToResult("discord", toDiscordOutboundDeliveryResult(lastResult)));
|
|
178
|
+
if (payload.text?.trim()) lastResult = await sendContext.send(sendContext.target, payload.text, {
|
|
179
|
+
verbose: false,
|
|
180
|
+
...resolveDiscordFormattedDeliveryOptions(ctx, sendContext),
|
|
181
|
+
onDeliveryResult: resolveDiscordDeliveryProgress(ctx)
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
for (const mediaUrl of mediaUrls.slice(1)) try {
|
|
185
|
+
lastResult = await sendContext.send(sendContext.target, "", {
|
|
186
|
+
verbose: false,
|
|
187
|
+
...resolveDiscordMediaDeliveryOptions(ctx, sendContext, mediaUrl),
|
|
188
|
+
onDeliveryResult: resolveDiscordDeliveryProgress(ctx)
|
|
189
|
+
});
|
|
190
|
+
} catch (err) {
|
|
191
|
+
if (!voiceFailure) throw err;
|
|
192
|
+
log$1.warn("discord remaining media send failed after voice failure", { error: err });
|
|
193
|
+
}
|
|
194
|
+
if (voiceFailure) throw voiceFailure.error;
|
|
195
|
+
return attachChannelToResult("discord", toDiscordOutboundDeliveryResult(lastResult));
|
|
178
196
|
}
|
|
179
197
|
const componentSpec = await resolveDiscordComponentSpec(payload);
|
|
180
198
|
if (!componentSpec) {
|
|
@@ -182,7 +200,7 @@ async function sendDiscordOutboundPayload(params) {
|
|
|
182
200
|
const nativeComponents = Array.isArray(discordData.components) ? discordData.components : void 0;
|
|
183
201
|
const embeds = Array.isArray(discordData.embeds) ? discordData.embeds : void 0;
|
|
184
202
|
const filename = normalizeOptionalString(discordData.filename);
|
|
185
|
-
if (nativeComponents || embeds?.length || filename) return attachChannelToResult("discord", await sendPayloadMediaSequenceOrFallback({
|
|
203
|
+
if (nativeComponents || embeds?.length || filename) return attachChannelToResult("discord", toDiscordOutboundDeliveryResult(await sendPayloadMediaSequenceOrFallback({
|
|
186
204
|
text: payload.text ?? "",
|
|
187
205
|
mediaUrls,
|
|
188
206
|
fallbackResult: createDiscordUnknownPayloadResult(sendContext.target),
|
|
@@ -202,17 +220,40 @@ async function sendDiscordOutboundPayload(params) {
|
|
|
202
220
|
filename: isFirst ? filename : void 0,
|
|
203
221
|
onDeliveryResult: resolveDiscordDeliveryProgress(ctx)
|
|
204
222
|
})
|
|
205
|
-
}));
|
|
206
|
-
|
|
223
|
+
})));
|
|
224
|
+
const payloadContext = {
|
|
225
|
+
...ctx,
|
|
226
|
+
payload
|
|
227
|
+
};
|
|
228
|
+
const deliveredResults = [];
|
|
229
|
+
let createdThreadId;
|
|
230
|
+
payloadContext.onDeliveryResult = async (result) => {
|
|
231
|
+
await ctx.onDeliveryResult?.(result);
|
|
232
|
+
const threadId = result.receipt?.threadId;
|
|
233
|
+
if (threadId && payloadContext.threadId == null) {
|
|
234
|
+
payloadContext.threadId = threadId;
|
|
235
|
+
createdThreadId = threadId;
|
|
236
|
+
}
|
|
237
|
+
if (createdThreadId && result.target?.kind === "channel" && result.receipt) deliveredResults.push({
|
|
238
|
+
messageId: result.messageId,
|
|
239
|
+
channelId: result.target.id,
|
|
240
|
+
receipt: result.receipt
|
|
241
|
+
});
|
|
242
|
+
};
|
|
243
|
+
const result = await sendTextMediaPayload({
|
|
207
244
|
channel: "discord",
|
|
208
|
-
ctx:
|
|
209
|
-
...ctx,
|
|
210
|
-
payload
|
|
211
|
-
},
|
|
245
|
+
ctx: payloadContext,
|
|
212
246
|
adapter: params.fallbackAdapter
|
|
213
247
|
});
|
|
248
|
+
return createdThreadId ? {
|
|
249
|
+
...result,
|
|
250
|
+
receipt: createDiscordSendReceiptFromResults({
|
|
251
|
+
results: deliveredResults,
|
|
252
|
+
threadId: createdThreadId
|
|
253
|
+
})
|
|
254
|
+
} : result;
|
|
214
255
|
}
|
|
215
|
-
return attachChannelToResult("discord", await sendPayloadMediaSequenceOrFallback({
|
|
256
|
+
return attachChannelToResult("discord", toDiscordOutboundDeliveryResult(await sendPayloadMediaSequenceOrFallback({
|
|
216
257
|
text: payload.text ?? "",
|
|
217
258
|
mediaUrls,
|
|
218
259
|
fallbackResult: createDiscordUnknownPayloadResult(sendContext.target),
|
|
@@ -233,13 +274,14 @@ async function sendDiscordOutboundPayload(params) {
|
|
|
233
274
|
onDeliveryResult: resolveDiscordDeliveryProgress(ctx)
|
|
234
275
|
});
|
|
235
276
|
}
|
|
236
|
-
}));
|
|
277
|
+
})));
|
|
237
278
|
}
|
|
238
279
|
//#endregion
|
|
239
280
|
//#region extensions/discord/src/outbound-adapter.ts
|
|
240
281
|
const DISCORD_TEXT_CHUNK_LIMIT = 2e3;
|
|
241
|
-
const
|
|
242
|
-
const
|
|
282
|
+
const log = createSubsystemLogger("discord/outbound");
|
|
283
|
+
const loadDiscordThreadBindings = createLazyRuntimeModule(() => import("./thread-bindings-VlymUnbz.js").then((n) => n.t));
|
|
284
|
+
const loadDiscordComponentSendRuntime = createLazyRuntimeModule(() => import("./send.components-ChK1wS7w.js").then((n) => n.i));
|
|
243
285
|
function resolveDiscordWebhookIdentity(params) {
|
|
244
286
|
const usernameRaw = normalizeOptionalString(params.identity?.name);
|
|
245
287
|
const fallbackUsername = normalizeOptionalString(params.binding.label) ?? params.binding.agentId;
|
|
@@ -270,7 +312,8 @@ async function maybeSendDiscordWebhookText(params) {
|
|
|
270
312
|
cfg: params.cfg,
|
|
271
313
|
replyTo: params.replyToId ?? void 0,
|
|
272
314
|
username: persona.username,
|
|
273
|
-
avatarUrl: persona.avatarUrl
|
|
315
|
+
avatarUrl: persona.avatarUrl,
|
|
316
|
+
onPlatformSendDispatch: params.onPlatformSendDispatch
|
|
274
317
|
});
|
|
275
318
|
}
|
|
276
319
|
async function resolveDiscordOutboundMessageSend(params) {
|
|
@@ -294,8 +337,9 @@ async function resolveDiscordOutboundMessageSend(params) {
|
|
|
294
337
|
cfg: params.cfg,
|
|
295
338
|
...resolveDiscordFormattingOptions({ formatting: params.formatting }),
|
|
296
339
|
onDeliveryResult: params.onDeliveryResult ? async (result) => {
|
|
297
|
-
await params.onDeliveryResult?.(attachChannelToResult("discord", result));
|
|
298
|
-
} : void 0
|
|
340
|
+
await params.onDeliveryResult?.(attachChannelToResult("discord", toDiscordOutboundDeliveryResult(result)));
|
|
341
|
+
} : void 0,
|
|
342
|
+
onPlatformSendDispatch: params.onPlatformSendDispatch
|
|
299
343
|
}
|
|
300
344
|
};
|
|
301
345
|
}
|
|
@@ -334,27 +378,41 @@ const discordOutbound = {
|
|
|
334
378
|
channel: "discord",
|
|
335
379
|
sendText: async (ctx) => {
|
|
336
380
|
if (!ctx.silent) {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
381
|
+
let webhookSelected = false;
|
|
382
|
+
try {
|
|
383
|
+
const webhookResult = await maybeSendDiscordWebhookText({
|
|
384
|
+
cfg: ctx.cfg,
|
|
385
|
+
text: ctx.text,
|
|
386
|
+
threadId: ctx.threadId,
|
|
387
|
+
accountId: ctx.accountId,
|
|
388
|
+
identity: ctx.identity,
|
|
389
|
+
replyToId: ctx.replyToId,
|
|
390
|
+
onPlatformSendDispatch: ctx.onPlatformSendDispatch ? async () => {
|
|
391
|
+
webhookSelected = true;
|
|
392
|
+
await ctx.onPlatformSendDispatch?.();
|
|
393
|
+
} : void 0
|
|
394
|
+
});
|
|
395
|
+
if (webhookResult) return toDiscordOutboundDeliveryResult(webhookResult);
|
|
396
|
+
} catch (error) {
|
|
397
|
+
if (webhookSelected) throw error;
|
|
398
|
+
log.warn("discord webhook persona send failed; falling back to bot send", { error });
|
|
399
|
+
}
|
|
346
400
|
}
|
|
347
401
|
const { send, target, options } = await resolveDiscordOutboundMessageSend(ctx);
|
|
348
|
-
return await send(target, ctx.text, options);
|
|
402
|
+
return toDiscordOutboundDeliveryResult(await send(target, ctx.text, options));
|
|
349
403
|
},
|
|
350
404
|
sendMedia: async (ctx) => {
|
|
351
405
|
const { send, target, options } = await resolveDiscordOutboundMessageSend(ctx);
|
|
352
|
-
if (ctx.audioAsVoice && ctx.mediaUrl) return await (resolveOutboundSendDep(ctx.deps, "discordVoice") ?? (await loadDiscordSendRuntime()).sendVoiceMessageDiscord)(target, ctx.mediaUrl, {
|
|
406
|
+
if (ctx.audioAsVoice && ctx.mediaUrl) return toDiscordOutboundDeliveryResult(await (resolveOutboundSendDep(ctx.deps, "discordVoice") ?? (await loadDiscordSendRuntime()).sendVoiceMessageDiscord)(target, ctx.mediaUrl, {
|
|
353
407
|
cfg: ctx.cfg,
|
|
354
408
|
reply: options.reply,
|
|
355
409
|
accountId: ctx.accountId ?? void 0,
|
|
356
|
-
silent: ctx.silent ?? void 0
|
|
357
|
-
|
|
410
|
+
silent: ctx.silent ?? void 0,
|
|
411
|
+
mediaAccess: ctx.mediaAccess,
|
|
412
|
+
mediaLocalRoots: ctx.mediaLocalRoots,
|
|
413
|
+
mediaReadFile: ctx.mediaReadFile,
|
|
414
|
+
onPlatformSendDispatch: ctx.onPlatformSendDispatch
|
|
415
|
+
}));
|
|
358
416
|
const mediaOptions = {
|
|
359
417
|
...options,
|
|
360
418
|
mediaUrl: ctx.mediaUrl,
|
|
@@ -363,23 +421,53 @@ const discordOutbound = {
|
|
|
363
421
|
mediaReadFile: ctx.mediaReadFile
|
|
364
422
|
};
|
|
365
423
|
if (ctx.text.trim() && ctx.mediaUrl && isLikelyDiscordVideoMedia(ctx.mediaUrl)) {
|
|
366
|
-
await send(target, ctx.text, options);
|
|
367
|
-
|
|
424
|
+
const captionResult = await send(target, ctx.text, options);
|
|
425
|
+
const mediaResult = await send(captionResult.receipt?.threadId ? `channel:${captionResult.receipt.threadId}` : target, "", {
|
|
368
426
|
...mediaOptions,
|
|
369
427
|
reply: options.reply?.scope === "all" ? options.reply : void 0
|
|
370
428
|
});
|
|
429
|
+
const threadId = captionResult.receipt?.threadId;
|
|
430
|
+
if (!threadId) return toDiscordOutboundDeliveryResult(mediaResult);
|
|
431
|
+
return toDiscordOutboundDeliveryResult({
|
|
432
|
+
...captionResult,
|
|
433
|
+
receipt: createDiscordSendReceiptFromResults({
|
|
434
|
+
results: [captionResult, mediaResult],
|
|
435
|
+
threadId
|
|
436
|
+
})
|
|
437
|
+
});
|
|
371
438
|
}
|
|
372
|
-
return await send(target, ctx.text, mediaOptions);
|
|
439
|
+
return toDiscordOutboundDeliveryResult(await send(target, ctx.text, mediaOptions));
|
|
373
440
|
},
|
|
374
|
-
sendPoll: async ({ cfg, to, poll, accountId, threadId, silent }) =>
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
441
|
+
sendPoll: async ({ cfg, to, poll, content, accountId, threadId, silent, sessionKey, inboundEventKind, onPlatformSendDispatch }) => {
|
|
442
|
+
if (!createDiscordActionGate({
|
|
443
|
+
cfg,
|
|
444
|
+
accountId
|
|
445
|
+
})("polls")) throw new Error("Discord polls are disabled.");
|
|
446
|
+
const outboundTo = resolveDiscordOutboundTarget({
|
|
447
|
+
to,
|
|
448
|
+
threadId
|
|
449
|
+
});
|
|
450
|
+
const result = await (await loadDiscordSendRuntime()).sendPollDiscord(outboundTo, poll, {
|
|
451
|
+
accountId: accountId ?? void 0,
|
|
452
|
+
content,
|
|
453
|
+
threadId: threadId ?? void 0,
|
|
454
|
+
silent: silent ?? void 0,
|
|
455
|
+
cfg,
|
|
456
|
+
onPlatformSendDispatch
|
|
457
|
+
});
|
|
458
|
+
discordInboundEventDelivery.notify({
|
|
459
|
+
sessionKey,
|
|
460
|
+
inboundEventKind,
|
|
461
|
+
to: outboundTo,
|
|
462
|
+
accountId
|
|
463
|
+
});
|
|
464
|
+
return result;
|
|
465
|
+
}
|
|
382
466
|
}),
|
|
467
|
+
adoptTargetFromDelivery: ({ result }) => {
|
|
468
|
+
const threadId = normalizeOptionalStringifiedId(result.receipt?.threadId);
|
|
469
|
+
return threadId ? { threadId } : null;
|
|
470
|
+
},
|
|
383
471
|
afterDeliverPayload: async ({ cfg, target, payload, results }) => {
|
|
384
472
|
notifyDiscordInboundEventOutboundPayloadSuccess({
|
|
385
473
|
payload,
|
|
@@ -397,9 +485,10 @@ const discordOutbound = {
|
|
|
397
485
|
to: target.to,
|
|
398
486
|
threadId: target.threadId
|
|
399
487
|
});
|
|
488
|
+
const channelId = result.target?.kind === "channel" ? result.target.id : to;
|
|
400
489
|
questionGatewayRuntime.registerChannelDelivery({
|
|
401
490
|
questionId,
|
|
402
|
-
deliveryId: `discord:${target.accountId ?? "default"}:${
|
|
491
|
+
deliveryId: `discord:${target.accountId ?? "default"}:${channelId}:${result.messageId}`,
|
|
403
492
|
finalize: async (statusLine) => {
|
|
404
493
|
const { editDiscordComponentMessage } = await loadDiscordComponentSendRuntime();
|
|
405
494
|
await editDiscordComponentMessage(to, result.messageId, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { m as readDiscordComponentSpec } from "./components-ezGKo_Yh.js";
|
|
2
2
|
import { createLazyRuntimeModule, createLazyRuntimeNamedExport } from "openclaw/plugin-sdk/lazy-runtime";
|
|
3
3
|
//#region extensions/discord/src/outbound-components.ts
|
|
4
4
|
const DISCORD_MESSAGE_COMPONENT_LIMIT = 40;
|
|
@@ -30,11 +30,11 @@ const DISCORD_PRESENTATION_CAPABILITIES = {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
|
-
const loadDiscordComponentSend = createLazyRuntimeNamedExport(() => import("./send.components-
|
|
33
|
+
const loadDiscordComponentSend = createLazyRuntimeNamedExport(() => import("./send.components-ChK1wS7w.js").then((n) => n.i), "sendDiscordComponentMessage");
|
|
34
34
|
async function sendDiscordComponentMessageLazy(...args) {
|
|
35
35
|
return await (await loadDiscordComponentSend())(...args);
|
|
36
36
|
}
|
|
37
|
-
const loadDiscordSharedInteractive = createLazyRuntimeModule(() => import("./
|
|
37
|
+
const loadDiscordSharedInteractive = createLazyRuntimeModule(() => import("./components-ezGKo_Yh.js").then((n) => n.a));
|
|
38
38
|
function addPayloadTextFallback(spec, payload) {
|
|
39
39
|
return spec.text ? spec : {
|
|
40
40
|
...spec,
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { l as resolveDiscordAccountAllowFrom } from "./accounts-DNl-oCEw.js";
|
|
2
|
+
import { c as resolveDiscordChannelConfigWithFallback, d as resolveDiscordCommandOwnerAllowFrom, f as resolveDiscordGuildEntry, n as isDiscordGroupAllowedByPolicy, p as resolveDiscordMemberAccessState, r as normalizeDiscordAllowList, t as allowListMatches } from "./allow-list-BDMimASD.js";
|
|
3
|
+
import { resolveCommandAuthorizedFromAuthorizers } from "openclaw/plugin-sdk/command-auth-native";
|
|
4
|
+
import { resolveOpenProviderRuntimeGroupPolicy } from "openclaw/plugin-sdk/runtime-group-policy";
|
|
5
|
+
//#region extensions/discord/src/voice/access.ts
|
|
6
|
+
async function authorizeDiscordVoiceIngress(params) {
|
|
7
|
+
const groupPolicy = params.groupPolicy ?? resolveOpenProviderRuntimeGroupPolicy({
|
|
8
|
+
providerConfigPresent: params.cfg.channels?.discord !== void 0,
|
|
9
|
+
groupPolicy: params.discordConfig.groupPolicy,
|
|
10
|
+
defaultGroupPolicy: params.cfg.channels?.defaults?.groupPolicy
|
|
11
|
+
}).groupPolicy;
|
|
12
|
+
const guildInfo = resolveDiscordGuildEntry({
|
|
13
|
+
guild: params.guild ?? {
|
|
14
|
+
id: params.guildId,
|
|
15
|
+
...params.guildName ? { name: params.guildName } : {}
|
|
16
|
+
},
|
|
17
|
+
guildId: params.guildId,
|
|
18
|
+
guildEntries: params.discordConfig.guilds
|
|
19
|
+
});
|
|
20
|
+
const channelConfig = params.channelId ? resolveDiscordChannelConfigWithFallback({
|
|
21
|
+
guildInfo,
|
|
22
|
+
channelId: params.channelId,
|
|
23
|
+
channelName: params.channelName,
|
|
24
|
+
channelSlug: params.channelSlug,
|
|
25
|
+
parentId: params.parentId,
|
|
26
|
+
parentName: params.parentName,
|
|
27
|
+
parentSlug: params.parentSlug,
|
|
28
|
+
scope: params.scope
|
|
29
|
+
}) : null;
|
|
30
|
+
if (channelConfig?.enabled === false) return {
|
|
31
|
+
ok: false,
|
|
32
|
+
message: "This channel is disabled."
|
|
33
|
+
};
|
|
34
|
+
const channelAllowlistConfigured = Boolean(guildInfo?.channels) && Object.keys(guildInfo?.channels ?? {}).length > 0;
|
|
35
|
+
if (!params.channelId && groupPolicy === "allowlist" && channelAllowlistConfigured) return {
|
|
36
|
+
ok: false,
|
|
37
|
+
message: `${params.channelLabel ?? "This channel"} is not allowlisted for voice commands.`
|
|
38
|
+
};
|
|
39
|
+
const channelAllowed = channelConfig ? channelConfig.allowed : !channelAllowlistConfigured;
|
|
40
|
+
if (!isDiscordGroupAllowedByPolicy({
|
|
41
|
+
groupPolicy,
|
|
42
|
+
guildAllowlisted: Boolean(guildInfo),
|
|
43
|
+
channelAllowlistConfigured,
|
|
44
|
+
channelAllowed
|
|
45
|
+
}) || channelConfig?.allowed === false) return {
|
|
46
|
+
ok: false,
|
|
47
|
+
message: `${params.channelLabel ?? "This channel"} is not allowlisted for voice commands.`
|
|
48
|
+
};
|
|
49
|
+
const { hasAccessRestrictions, memberAllowed } = resolveDiscordMemberAccessState({
|
|
50
|
+
channelConfig,
|
|
51
|
+
guildInfo,
|
|
52
|
+
memberRoleIds: params.memberRoleIds,
|
|
53
|
+
sender: params.sender,
|
|
54
|
+
allowNameMatching: false
|
|
55
|
+
});
|
|
56
|
+
const admissionAllowList = normalizeDiscordAllowList(params.admissionAllowFrom ?? params.discordConfig.allowFrom ?? params.discordConfig.allowFrom, [
|
|
57
|
+
"discord:",
|
|
58
|
+
"user:",
|
|
59
|
+
"pk:"
|
|
60
|
+
]);
|
|
61
|
+
const admissionAllowed = admissionAllowList ? allowListMatches(admissionAllowList, params.sender, { allowNameMatching: false }) : false;
|
|
62
|
+
const useAccessGroups = params.useAccessGroups ?? true;
|
|
63
|
+
return resolveCommandAuthorizedFromAuthorizers({
|
|
64
|
+
useAccessGroups,
|
|
65
|
+
authorizers: useAccessGroups ? [{
|
|
66
|
+
configured: admissionAllowList != null,
|
|
67
|
+
allowed: admissionAllowed
|
|
68
|
+
}, {
|
|
69
|
+
configured: hasAccessRestrictions,
|
|
70
|
+
allowed: memberAllowed
|
|
71
|
+
}] : [{
|
|
72
|
+
configured: hasAccessRestrictions,
|
|
73
|
+
allowed: memberAllowed
|
|
74
|
+
}],
|
|
75
|
+
modeWhenAccessGroupsOff: "configured"
|
|
76
|
+
}) ? {
|
|
77
|
+
ok: true,
|
|
78
|
+
channelConfig
|
|
79
|
+
} : {
|
|
80
|
+
ok: false,
|
|
81
|
+
message: "You are not authorized to use this command."
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region extensions/discord/src/voice/config.ts
|
|
86
|
+
function resolveDiscordVoiceEnabled(voice) {
|
|
87
|
+
if (voice?.enabled !== void 0) return voice.enabled;
|
|
88
|
+
return voice !== void 0;
|
|
89
|
+
}
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region extensions/discord/src/voice/owner-access.ts
|
|
92
|
+
function resolveDiscordVoiceAccess(params) {
|
|
93
|
+
const commandOwnerAllowFrom = resolveDiscordCommandOwnerAllowFrom(params.cfg);
|
|
94
|
+
if (commandOwnerAllowFrom) return {
|
|
95
|
+
admissionAllowFrom: commandOwnerAllowFrom,
|
|
96
|
+
ownerAllowFrom: commandOwnerAllowFrom
|
|
97
|
+
};
|
|
98
|
+
return {
|
|
99
|
+
admissionAllowFrom: resolveDiscordAccountAllowFrom({
|
|
100
|
+
cfg: params.cfg,
|
|
101
|
+
accountId: params.accountId
|
|
102
|
+
}) ?? params.discordConfig.allowFrom ?? [],
|
|
103
|
+
ownerAllowFrom: []
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
export { resolveDiscordVoiceEnabled as n, authorizeDiscordVoiceIngress as r, resolveDiscordVoiceAccess as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { en as __exportAll } from "./retry-DNsVTeTo.js";
|
|
2
2
|
import { readProviderJsonObjectResponse, readResponseTextLimited } from "openclaw/plugin-sdk/provider-http";
|
|
3
3
|
import { resolveFetch } from "openclaw/plugin-sdk/fetch-runtime";
|
|
4
4
|
import { buildTimeoutAbortSignal } from "openclaw/plugin-sdk/extension-shared";
|