@openclaw/discord 2026.8.1-beta.2 → 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-CqzrH14k.js → account-inspect-D5xmUpnj.js} +1 -1
- 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/{activities-api-DS7vpdtp.js → activities-api-KCBAmWxD.js} +133 -175
- package/dist/activities-api.js +1 -1
- package/dist/api.js +17 -17
- package/dist/{approval-handler.runtime-B6yEV79q.js → approval-handler.runtime-B12RCYr8.js} +6 -6
- package/dist/{approval-message-safety-AcIxvrf3.js → approval-message-safety-XGFPbDoI.js} +89 -3
- package/dist/{audit-Db-rlntl.js → audit-Yc7eZDd6.js} +5 -5
- package/dist/{channel-actions-5s_hjYKd.js → channel-actions-Dr2QI8Bf.js} +10 -6
- package/dist/{channel-actions.runtime-CLKrx6tr.js → channel-actions.runtime-CODTvo7c.js} +53 -68
- package/dist/{channel-CnnbJSt5.js → channel-cXYzGc4L.js} +74 -50
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel.setup-BFAO-V1P.js → channel.setup-CSiwnMgs.js} +5 -5
- package/dist/{outbound-session-route-DxLkrgKQ.js → components-ezGKo_Yh.js} +3 -49
- package/dist/{config-schema-BgEskFAs.js → config-schema-DC5kDtQ5.js} +33 -7
- package/dist/conversation-binding-route-D6rCQ5S0.js +43 -0
- package/dist/{directory-config-BVX7Cflc.js → directory-config-XyCfoqLg.js} +2 -2
- package/dist/directory-contract-api.js +1 -1
- package/dist/{directory-live-DGIGxpIo.js → directory-live-Df0NbFJB.js} +3 -3
- package/dist/{doctor-BzC-TLnB.js → doctor-DYY31GrO.js} +33 -12
- package/dist/doctor-contract-api.js +3 -3
- package/dist/{handle-action.guild-admin-BNVTUISF.js → handle-action.guild-admin-6Tvvinsa.js} +2 -2
- package/dist/index.js +3 -4
- package/dist/{message-handler-Unk_f10F.js → message-handler-B61q5MOF.js} +82 -6
- package/dist/{message-handler.preflight-C9zecxR9.js → message-handler.preflight-Bzg_Hawz.js} +36 -46
- package/dist/{message-handler.process-DWQ6UHHu.js → message-handler.process--4_712Ec.js} +159 -183
- package/dist/{message-utils-BSCPVgy0.js → message-utils-BXLLnFl6.js} +31 -32
- package/dist/{outbound-adapter-D9nRivT1.js → outbound-adapter-DxHTOqiN.js} +83 -53
- package/dist/{outbound-components-cTzwBJ60.js → outbound-components-B2PL0ooH.js} +3 -3
- package/dist/owner-access-Bg41VzAf.js +107 -0
- package/dist/{pluralkit-DdiJ9KMK.js → pluralkit-dUl4v1X3.js} +1 -1
- package/dist/{probe-Bl-k5_Ku.js → probe-BTdtVRwU.js} +1 -1
- package/dist/{probe.runtime-M9fREKvp.js → probe.runtime-Dq5-PRKT.js} +1 -1
- package/dist/{provider-DvSNb-2v.js → provider-DlK_ynqt.js} +356 -967
- package/dist/{provider-session.runtime-BUEqD0rA.js → provider-session.runtime-CvvphHvs.js} +3 -3
- package/dist/provider.runtime-CzKGRiAF.js +2 -0
- package/dist/{realtime-session.runtime-C7wen-aF.js → realtime-session.runtime-ysbMG8v7.js} +24 -13
- package/dist/{resolve-allowlist-common-D04lpEzb.js → resolve-allowlist-common-DIVXbD1P.js} +2 -2
- package/dist/{resolve-channels-Dm7jEeg6.js → resolve-channels-CGeUoIqb.js} +3 -3
- package/dist/{resolve-users-bktrCUUU.js → resolve-users-BtKxLUZv.js} +2 -2
- package/dist/{retry-CLpJcXXf.js → retry-DNsVTeTo.js} +18 -64
- package/dist/{runtime-DoHjckYm.js → runtime-CQovMsH3.js} +9 -10
- package/dist/{runtime-DGsSyDTS.js → runtime-D71_VFLr.js} +29 -43
- package/dist/runtime-api.actions.js +2 -2
- package/dist/runtime-api.js +22 -21
- 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 +4 -4
- package/dist/{sdk-runtime-QpY8PvCh.js → sdk-runtime-37OU6_Yh.js} +3 -4
- 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-B7Q6Oc1I.js → send-rQIffSYu.js} +10 -10
- package/dist/{send.components-iJyFXw9L.js → send.components-ChK1wS7w.js} +14 -24
- package/dist/{send.outbound-DS5tHwfR.js → send.outbound-HIkgji_7.js} +26 -16
- package/dist/{send.reactions-BAn0iiVQ.js → send.reactions-gmJ6yFPo.js} +2 -2
- package/dist/{send.receipt-IPI1p-SP.js → send.receipt-Cnhoautb.js} +11 -1
- package/dist/{send.shared-BmwFjW6T.js → send.shared-B3fpaLWJ.js} +104 -104
- package/dist/{sender-identity-QtalnCYv.js → sender-identity-BJtfyise.js} +1 -1
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{shared-BIXIX6uJ.js → shared-CaAaoksy.js} +15 -10
- package/dist/subagent-hooks-CNT2ZJTJ.js +49 -0
- package/dist/subagent-hooks-api.js +2 -2
- package/dist/{subagent-progress-DhaE_h8a.js → subagent-progress-FPLqBY1s.js} +5 -4
- package/dist/{system-events-CTqDf6_s.js → system-events-Nuwoq_au.js} +2 -2
- package/dist/{target-resolver-maOKSqO0.js → target-resolver-DIXShHaZ.js} +3 -3
- package/dist/targets-B2pf49zc.js +3 -0
- package/dist/{thread-bindings-3L8p82GV.js → thread-bindings-VlymUnbz.js} +29 -26
- package/dist/{thread-bindings.manager-DCIH6WDC.js → thread-bindings.manager-CngsgErq.js} +9 -8
- package/dist/{thread-bindings.session-updates-bJ2KQFY6.js → thread-bindings.session-updates-CJb-BpPL.js} +1 -1
- package/dist/{thread-bindings.state-aeV8HNgV.js → thread-bindings.state-D8OMdk4O.js} +1 -1
- 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-CS-nNVoe.js → typing-oLiS5Z13.js} +1 -1
- package/dist/{voice-runtime-BEdqNcST.js → voice-runtime-CjNFaynA.js} +181 -91
- package/openclaw.plugin.json +12 -6
- package/package.json +4 -6
- package/dist/accounts-DJTf1LtA.js +0 -219
- package/dist/channel-api-CAJ0wMoV.js +0 -21
- package/dist/provider.runtime-C9PnJZbZ.js +0 -2
- package/dist/runtime-api.monitor-CHxrFPnW.js +0 -5
- package/dist/subagent-hooks-CTt5KCJr.js +0 -120
- package/dist/targets-yUFTHoAx.js +0 -3
- package/dist/transcripts-source-CfFMexGt.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/{allow-list-DnxIlPP2.js → allow-list-BDMimASD.js} +1 -1
- package/dist/{audit-core-xwjIczO0.js → audit-core-BCX8UeFH.js} +1 -1
- package/dist/{doctor-contract-DLa-BTiU.js → doctor-contract-DsWvKIXF.js} +1 -1
- package/dist/{security-audit-jGnJF__m.js → security-audit-BfJhAXZp.js} +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as createThreadBindingManager, t as createNoopThreadBindingManager } from "./thread-bindings.manager-
|
|
2
|
-
import { a as reconcileAcpThreadBindingsOnStartup } from "./thread-bindings-
|
|
3
|
-
import { t as createDiscordMessageHandler } from "./message-handler-
|
|
1
|
+
import { n as createThreadBindingManager, t as createNoopThreadBindingManager } from "./thread-bindings.manager-CngsgErq.js";
|
|
2
|
+
import { a as reconcileAcpThreadBindingsOnStartup } from "./thread-bindings-VlymUnbz.js";
|
|
3
|
+
import { t as createDiscordMessageHandler } from "./message-handler-B61q5MOF.js";
|
|
4
4
|
import { resolveThreadBindingIdleTimeoutMs, resolveThreadBindingMaxAgeMs, resolveThreadBindingsEnabled } from "openclaw/plugin-sdk/conversation-runtime";
|
|
5
5
|
import { getAcpSessionManager, isAcpRuntimeError } from "openclaw/plugin-sdk/acp-runtime";
|
|
6
6
|
export { createDiscordMessageHandler, createNoopThreadBindingManager, createThreadBindingManager, getAcpSessionManager, isAcpRuntimeError, reconcileAcpThreadBindingsOnStartup, resolveThreadBindingIdleTimeoutMs, resolveThreadBindingMaxAgeMs, resolveThreadBindingsEnabled };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as discordRealtimeVoiceSecretOwnerId } from "./secret-config-contract-B3i6WxV5.js";
|
|
2
|
+
import { S as formatVoiceLogPreview, b as formatVoiceIngressPrompt, h as createDiscordOpusEncodeStream, m as convertRealtimePcm24kMonoToDiscordPcm48kStereo, p as convertDiscordPcm48kStereoToRealtimePcm24kMono, t as loadDiscordVoiceSdk, u as logVoiceVerbose, x as maybeControlDiscordVoiceAgentRun } from "./sdk-runtime-37OU6_Yh.js";
|
|
2
3
|
import { asDateTimestampMs, resolveExpiresAtMsFromDurationMs } from "openclaw/plugin-sdk/number-runtime";
|
|
3
4
|
import { formatErrorMessage } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
4
5
|
import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env";
|
|
5
6
|
import { sliceUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
6
|
-
import {
|
|
7
|
+
import { assertSecretOwnerAvailable, isSecretOwnerAvailable } from "openclaw/plugin-sdk/channel-secret-owner-runtime";
|
|
8
|
+
import { REALTIME_VOICE_AGENT_CONSULT_TOOL_NAME, REALTIME_VOICE_AGENT_CONTROL_TOOL, REALTIME_VOICE_AGENT_CONTROL_TOOL_NAME, REALTIME_VOICE_AUDIO_FORMAT_PCM16_24KHZ, buildRealtimeVoiceSessionInstructions, buildRealtimeVoiceSpeakExactMessage, canonicalizeRealtimeVoiceProviderId, classifyRealtimeVoiceConsultToolCall, classifySkippableRealtimeVoiceConsultTranscript, controlRealtimeVoiceAgentRun, createRealtimeVoiceAgentTalkbackQueue, createRealtimeVoiceSessionHarness, createRealtimeVoiceTurnContextTracker, isRealtimeVoiceWakeNameRequired, matchRealtimeVoiceActivationName, matchRealtimeVoiceConsultQuestions, parseRealtimeVoiceAgentControlToolArgs, realtimeVoiceAudioDurationMs, resolveConfiguredRealtimeVoiceProvider, resolveRealtimeVoiceAgentConsultTools, resolveRealtimeVoiceBargeIn, resolveRealtimeVoiceInterruptResponseOnInputAudio, resolveRealtimeVoiceMinBargeInAudioEndMs, resolveRealtimeVoiceSessionPolicy } from "openclaw/plugin-sdk/realtime-voice";
|
|
7
9
|
import { PassThrough, pipeline } from "node:stream";
|
|
8
10
|
//#region extensions/discord/src/voice/realtime-transcript.ts
|
|
9
11
|
function mergeRealtimePartialTranscript(previous, next) {
|
|
@@ -17,7 +19,7 @@ const logger$3 = createSubsystemLogger("discord/voice");
|
|
|
17
19
|
const DISCORD_REALTIME_PENDING_SPEAKER_CONTEXT_LIMIT = 32;
|
|
18
20
|
const DISCORD_REALTIME_IGNORED_WAKE_NAME_CONTEXT_TTL_MS = 1e4;
|
|
19
21
|
const DISCORD_REALTIME_WAKE_NAME_FOLLOWUP_TTL_MS = 1e4;
|
|
20
|
-
const REALTIME_PCM16_BYTES_PER_SAMPLE
|
|
22
|
+
const REALTIME_PCM16_BYTES_PER_SAMPLE = 2;
|
|
21
23
|
const DISCORD_REALTIME_TRAILING_SILENCE_MIN_MS = 700;
|
|
22
24
|
const DISCORD_REALTIME_TRAILING_SILENCE_MAX_MS = 3e3;
|
|
23
25
|
var DiscordRealtimeTurns = class {
|
|
@@ -153,7 +155,7 @@ var DiscordRealtimeTurns = class {
|
|
|
153
155
|
const providerId = this.params.providerId() ?? this.params.realtimeConfig()?.provider ?? "openai";
|
|
154
156
|
const rawSilenceDurationMs = (this.params.realtimeConfig()?.providers?.[providerId])?.silenceDurationMs;
|
|
155
157
|
const silenceMs = Math.min(DISCORD_REALTIME_TRAILING_SILENCE_MAX_MS, Math.max(DISCORD_REALTIME_TRAILING_SILENCE_MIN_MS, typeof rawSilenceDurationMs === "number" && Number.isFinite(rawSilenceDurationMs) ? rawSilenceDurationMs : 0));
|
|
156
|
-
const silenceBytes = Math.ceil(24e3 * silenceMs / 1e3) * REALTIME_PCM16_BYTES_PER_SAMPLE
|
|
158
|
+
const silenceBytes = Math.ceil(24e3 * silenceMs / 1e3) * REALTIME_PCM16_BYTES_PER_SAMPLE;
|
|
157
159
|
const silence = Buffer.alloc(silenceBytes);
|
|
158
160
|
bridge.sendAudio(silence);
|
|
159
161
|
logger$3.info(`discord voice: realtime trailing silence sent guild=${this.params.entry.guildId} channel=${this.params.entry.channelId} user=${turn.context.userId} speaker=${turn.context.speakerLabel} silenceMs=${silenceMs} realtimeBytes=${silence.length}`);
|
|
@@ -356,7 +358,9 @@ var DiscordRealtimeConsults = class {
|
|
|
356
358
|
await session.submitToolResult(callId, { text });
|
|
357
359
|
}
|
|
358
360
|
async handleAcceptedTranscript(acceptedText, forcedSpeakerContext, providerEpoch) {
|
|
359
|
-
const
|
|
361
|
+
const usesRealtimeAgentHandoff = this.params.usesRealtimeAgentHandoff();
|
|
362
|
+
const fallbackSpeakerContext = this.params.isAgentProxy && !usesRealtimeAgentHandoff ? forcedSpeakerContext ?? this.params.turns.consumePendingSpeakerContext() : void 0;
|
|
363
|
+
const pendingForcedConsult = this.params.isAgentProxy && usesRealtimeAgentHandoff ? this.prepareForcedAgentProxyConsult(acceptedText, forcedSpeakerContext) : void 0;
|
|
360
364
|
let control;
|
|
361
365
|
try {
|
|
362
366
|
control = await maybeControlDiscordVoiceAgentRun({
|
|
@@ -376,11 +380,11 @@ var DiscordRealtimeConsults = class {
|
|
|
376
380
|
return;
|
|
377
381
|
}
|
|
378
382
|
if (!this.params.isAgentProxy) return;
|
|
379
|
-
if (
|
|
383
|
+
if (usesRealtimeAgentHandoff) {
|
|
380
384
|
if (pendingForcedConsult) this.schedulePreparedForcedAgentProxyConsult(pendingForcedConsult);
|
|
381
385
|
return;
|
|
382
386
|
}
|
|
383
|
-
this.talkback.enqueue(acceptedText,
|
|
387
|
+
this.talkback.enqueue(acceptedText, fallbackSpeakerContext);
|
|
384
388
|
}
|
|
385
389
|
createTalkbackQueue() {
|
|
386
390
|
const providerEpoch = this.params.providerEpoch();
|
|
@@ -635,7 +639,6 @@ const DISCORD_REALTIME_WAKE_ACKS = [
|
|
|
635
639
|
"Got it.",
|
|
636
640
|
"One sec."
|
|
637
641
|
];
|
|
638
|
-
const REALTIME_PCM16_BYTES_PER_SAMPLE = 2;
|
|
639
642
|
const DISCORD_RAW_PCM_FRAME_BYTES = 3840;
|
|
640
643
|
const DISCORD_REALTIME_OUTPUT_PREROLL_FRAMES = 25;
|
|
641
644
|
function isRealtimeResponseCancellationRace(event) {
|
|
@@ -644,10 +647,6 @@ function isRealtimeResponseCancellationRace(event) {
|
|
|
644
647
|
function normalizeControlSpeechText(text) {
|
|
645
648
|
return text.toLowerCase().replace(/\s+/g, " ").trim();
|
|
646
649
|
}
|
|
647
|
-
function pcm16MonoDurationMs(audio, sampleRate) {
|
|
648
|
-
if (audio.length === 0 || sampleRate <= 0) return 0;
|
|
649
|
-
return audio.length / REALTIME_PCM16_BYTES_PER_SAMPLE * 1e3 / sampleRate;
|
|
650
|
-
}
|
|
651
650
|
var DiscordRealtimePlayback = class {
|
|
652
651
|
constructor(params) {
|
|
653
652
|
this.params = params;
|
|
@@ -717,7 +716,7 @@ var DiscordRealtimePlayback = class {
|
|
|
717
716
|
audioStarted: true
|
|
718
717
|
};
|
|
719
718
|
this.params.harness.recordOutputAudio(realtimePcm24kMono, {
|
|
720
|
-
audioMs:
|
|
719
|
+
audioMs: realtimeVoiceAudioDurationMs(REALTIME_VOICE_AUDIO_FORMAT_PCM16_24KHZ, realtimePcm24kMono.byteLength),
|
|
721
720
|
sourceAudioBytes: realtimePcm24kMono.length,
|
|
722
721
|
sinkAudioBytes: discordPcm.length
|
|
723
722
|
});
|
|
@@ -1118,14 +1117,25 @@ var DiscordRealtimeVoiceSession = class {
|
|
|
1118
1117
|
generation: lifecycleGeneration,
|
|
1119
1118
|
instance: this
|
|
1120
1119
|
};
|
|
1120
|
+
const configuredProviderId = this.realtimeConfig?.provider?.trim();
|
|
1121
|
+
if (configuredProviderId) {
|
|
1122
|
+
const ownerProviderIds = /* @__PURE__ */ new Set([configuredProviderId]);
|
|
1123
|
+
const canonicalProviderId = canonicalizeRealtimeVoiceProviderId(configuredProviderId, this.params.cfg);
|
|
1124
|
+
if (canonicalProviderId) ownerProviderIds.add(canonicalProviderId);
|
|
1125
|
+
for (const providerId of ownerProviderIds) assertSecretOwnerAvailable("capability", discordRealtimeVoiceSecretOwnerId(this.params.accountId, providerId));
|
|
1126
|
+
}
|
|
1121
1127
|
const resolved = resolveConfiguredRealtimeVoiceProvider({
|
|
1122
1128
|
configuredProviderId: this.realtimeConfig?.provider,
|
|
1123
1129
|
providerConfigs: buildProviderConfigs(this.realtimeConfig),
|
|
1124
1130
|
providerConfigOverrides: buildProviderConfigOverrides(this.realtimeConfig),
|
|
1125
1131
|
cfg: this.params.cfg,
|
|
1132
|
+
agentId: this.params.entry.route.agentId,
|
|
1126
1133
|
defaultModel: this.realtimeConfig?.model,
|
|
1134
|
+
isProviderAvailable: (provider) => isSecretOwnerAvailable("capability", discordRealtimeVoiceSecretOwnerId(this.params.accountId, provider.id)),
|
|
1135
|
+
assertProviderAvailable: (provider) => assertSecretOwnerAvailable("capability", discordRealtimeVoiceSecretOwnerId(this.params.accountId, provider.id)),
|
|
1127
1136
|
noRegisteredProviderMessage: "No configured realtime voice provider registered"
|
|
1128
1137
|
});
|
|
1138
|
+
assertSecretOwnerAvailable("capability", discordRealtimeVoiceSecretOwnerId(this.params.accountId, resolved.provider.id));
|
|
1129
1139
|
this.realtimeProviderId = resolved.provider.id;
|
|
1130
1140
|
const isAgentProxy = isDiscordAgentProxyVoiceMode(this.params.mode);
|
|
1131
1141
|
const { toolPolicy, consultToolsAllow, consultPolicy, wakeNamePolicy, wakeNames, autoRespondToAudio } = resolveRealtimeVoiceSessionPolicy({
|
|
@@ -1161,6 +1171,7 @@ var DiscordRealtimeVoiceSession = class {
|
|
|
1161
1171
|
this.bridge = this.harness.createBridge({
|
|
1162
1172
|
provider: resolved.provider,
|
|
1163
1173
|
cfg: this.params.cfg,
|
|
1174
|
+
agentId: this.params.entry.route.agentId,
|
|
1164
1175
|
providerConfig: resolved.providerConfig,
|
|
1165
1176
|
audioFormat: REALTIME_VOICE_AUDIO_FORMAT_PCM16_24KHZ,
|
|
1166
1177
|
instructions,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { m as normalizeDiscordToken } from "./accounts-DNl-oCEw.js";
|
|
2
2
|
import { r as fetchDiscord } from "./api-DNVbJyEy.js";
|
|
3
|
-
import { a as normalizeDiscordSlug } from "./allow-list-
|
|
3
|
+
import { a as normalizeDiscordSlug } from "./allow-list-BDMimASD.js";
|
|
4
4
|
//#region extensions/discord/src/guilds.ts
|
|
5
5
|
async function listGuilds(token, fetcher, options) {
|
|
6
6
|
return (await fetchDiscord("/users/@me/guilds", token, fetcher, options)).filter((guild) => typeof guild.id === "string" && typeof guild.name === "string").map((guild) => ({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { en as __exportAll } from "./retry-DNsVTeTo.js";
|
|
2
2
|
import { n as DiscordApiError, r as fetchDiscord, t as DISCORD_DIRECTORY_LOOKUP_TIMEOUT_MS } from "./api-DNVbJyEy.js";
|
|
3
|
-
import { a as normalizeDiscordSlug } from "./allow-list-
|
|
4
|
-
import { i as listGuilds, n as filterDiscordGuilds, r as resolveDiscordAllowlistToken, t as buildDiscordUnresolvedResults } from "./resolve-allowlist-common-
|
|
3
|
+
import { a as normalizeDiscordSlug } from "./allow-list-BDMimASD.js";
|
|
4
|
+
import { i as listGuilds, n as filterDiscordGuilds, r as resolveDiscordAllowlistToken, t as buildDiscordUnresolvedResults } from "./resolve-allowlist-common-DIVXbD1P.js";
|
|
5
5
|
//#region extensions/discord/src/resolve-channels.ts
|
|
6
6
|
var resolve_channels_exports = /* @__PURE__ */ __exportAll({ resolveDiscordChannelAllowlist: () => resolveDiscordChannelAllowlist });
|
|
7
7
|
function parseDiscordChannelInput(raw) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { en as __exportAll } from "./retry-DNsVTeTo.js";
|
|
2
2
|
import { r as fetchDiscord, t as DISCORD_DIRECTORY_LOOKUP_TIMEOUT_MS } from "./api-DNVbJyEy.js";
|
|
3
|
-
import { i as listGuilds, n as filterDiscordGuilds, r as resolveDiscordAllowlistToken, t as buildDiscordUnresolvedResults } from "./resolve-allowlist-common-
|
|
3
|
+
import { i as listGuilds, n as filterDiscordGuilds, r as resolveDiscordAllowlistToken, t as buildDiscordUnresolvedResults } from "./resolve-allowlist-common-DIVXbD1P.js";
|
|
4
4
|
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
5
5
|
//#region extensions/discord/src/resolve-users.ts
|
|
6
6
|
var resolve_users_exports = /* @__PURE__ */ __exportAll({ resolveDiscordUserAllowlist: () => resolveDiscordUserAllowlist });
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { t as parseDiscordRetryAfterBodySeconds } from "./retry-after-DdLPmPoa.js";
|
|
2
|
+
import { k as parseDiscordTarget } from "./accounts-DNl-oCEw.js";
|
|
2
3
|
import "node:module";
|
|
3
4
|
import { redactIdentifier, redactSensitiveFieldValue } from "openclaw/plugin-sdk/logging-core";
|
|
4
5
|
import { ApplicationCommandOptionType, ApplicationCommandType, ButtonStyle, ComponentType, GatewayDispatchEvents, InteractionContextType, InteractionResponseType, InteractionType, MessageFlags, Routes, TextInputStyle } from "discord-api-types/v10";
|
|
@@ -13,7 +14,6 @@ import { readResponseWithLimit } from "openclaw/plugin-sdk/response-limit-runtim
|
|
|
13
14
|
import { collectErrorGraphCandidates, extractErrorCode, formatErrorMessage, readErrorName } from "openclaw/plugin-sdk/error-runtime";
|
|
14
15
|
import { classifyTransientNetworkErrorCode, createChannelApiRetryRunner, parseRetryAfterHeaderSeconds, resolveRetryConfig, retryAsync } from "openclaw/plugin-sdk/retry-runtime";
|
|
15
16
|
import { sleepWithAbort } from "openclaw/plugin-sdk/runtime-env";
|
|
16
|
-
import { buildMessagingTarget, parseMentionPrefixOrAtUserTarget, requireTargetKind } from "openclaw/plugin-sdk/channel-targets";
|
|
17
17
|
import { resolveAllowlistMatchByCandidates } from "openclaw/plugin-sdk/allow-from";
|
|
18
18
|
import { chunkMarkdownTextWithMode } from "openclaw/plugin-sdk/reply-chunking";
|
|
19
19
|
import { chunkTextForOutbound } from "openclaw/plugin-sdk/text-chunking";
|
|
@@ -810,15 +810,12 @@ var Embed = class {
|
|
|
810
810
|
};
|
|
811
811
|
//#endregion
|
|
812
812
|
//#region extensions/discord/src/internal/payload.ts
|
|
813
|
-
function
|
|
814
|
-
return component.
|
|
815
|
-
}
|
|
816
|
-
function payloadHasV2Components(payload) {
|
|
817
|
-
return Boolean(payload.components?.some((component) => component.isV2));
|
|
813
|
+
function hasDiscordV2Components(components) {
|
|
814
|
+
return Boolean(components?.some((component) => "isV2" in component && component.isV2 || "type" in component && component.type !== ComponentType.ActionRow));
|
|
818
815
|
}
|
|
819
816
|
function normalizePayloadFlags(payload) {
|
|
820
817
|
const flags = payload.ephemeral ? (payload.flags ?? 0) | MessageFlags.Ephemeral : payload.flags;
|
|
821
|
-
if (!
|
|
818
|
+
if (!hasDiscordV2Components(payload.components)) return flags;
|
|
822
819
|
if (payload.content || payload.embeds?.length) throw new Error("Discord Components V2 payloads cannot include content or embeds");
|
|
823
820
|
return (flags ?? 0) | MessageFlags.IsComponentsV2;
|
|
824
821
|
}
|
|
@@ -828,7 +825,7 @@ function serializePayload(payload) {
|
|
|
828
825
|
return stripUndefinedFields({
|
|
829
826
|
content: payload.content,
|
|
830
827
|
embeds: payload.embeds?.map((entry) => "serialize" in entry ? entry.serialize() : entry),
|
|
831
|
-
components: payload.components?.map((entry) =>
|
|
828
|
+
components: payload.components?.map((entry) => "serialize" in entry ? entry.serialize() : entry),
|
|
832
829
|
allowed_mentions: payload.allowed_mentions ?? payload.allowedMentions,
|
|
833
830
|
flags,
|
|
834
831
|
tts: payload.tts,
|
|
@@ -993,6 +990,12 @@ var Guild = class extends Base {
|
|
|
993
990
|
get name() {
|
|
994
991
|
return this.rawDataValue?.name ?? "";
|
|
995
992
|
}
|
|
993
|
+
get icon() {
|
|
994
|
+
return this.rawDataValue?.icon;
|
|
995
|
+
}
|
|
996
|
+
get iconUrl() {
|
|
997
|
+
return this.icon ? `https://cdn.discordapp.com/icons/${this.id}/${this.icon}.png` : null;
|
|
998
|
+
}
|
|
996
999
|
};
|
|
997
1000
|
var GuildMember = class extends Base {
|
|
998
1001
|
constructor(client, rawData) {
|
|
@@ -1381,12 +1384,9 @@ function findCommandOption(options, name) {
|
|
|
1381
1384
|
if (!name) return;
|
|
1382
1385
|
return options?.find((option) => option.name === name);
|
|
1383
1386
|
}
|
|
1384
|
-
function hasCommandOptions(command) {
|
|
1385
|
-
return "options" in command;
|
|
1386
|
-
}
|
|
1387
1387
|
function resolveFocusedCommandOptionAutocompleteHandler(command, interaction) {
|
|
1388
1388
|
const focusedName = interaction.options.getFocused()?.name;
|
|
1389
|
-
const autocomplete = findCommandOption(
|
|
1389
|
+
const autocomplete = findCommandOption(command.commandKind === "group" ? findSelectedSubcommand(command.subcommands, interaction)?.options : command.options, focusedName)?.autocomplete;
|
|
1390
1390
|
return typeof autocomplete === "function" ? autocomplete : void 0;
|
|
1391
1391
|
}
|
|
1392
1392
|
var BaseCommand = class {
|
|
@@ -1417,6 +1417,7 @@ var BaseCommand = class {
|
|
|
1417
1417
|
var Command = class extends BaseCommand {
|
|
1418
1418
|
constructor(..._args) {
|
|
1419
1419
|
super(..._args);
|
|
1420
|
+
this.commandKind = "leaf";
|
|
1420
1421
|
this.type = ApplicationCommandType.ChatInput;
|
|
1421
1422
|
}
|
|
1422
1423
|
async autocomplete(interaction) {
|
|
@@ -1438,6 +1439,7 @@ var Command = class extends BaseCommand {
|
|
|
1438
1439
|
var CommandWithSubcommands = class extends BaseCommand {
|
|
1439
1440
|
constructor(..._args2) {
|
|
1440
1441
|
super(..._args2);
|
|
1442
|
+
this.commandKind = "group";
|
|
1441
1443
|
this.type = ApplicationCommandType.ChatInput;
|
|
1442
1444
|
}
|
|
1443
1445
|
async run(interaction) {
|
|
@@ -1825,12 +1827,12 @@ async function dispatchInteraction(client, rawData) {
|
|
|
1825
1827
|
await optionAutocomplete(autocompleteInteraction);
|
|
1826
1828
|
return;
|
|
1827
1829
|
}
|
|
1828
|
-
if ("
|
|
1830
|
+
if (command.commandKind === "leaf") await command.autocomplete(autocompleteInteraction);
|
|
1829
1831
|
return;
|
|
1830
1832
|
}
|
|
1831
1833
|
if (rawData.type === InteractionType.ApplicationCommand) {
|
|
1832
1834
|
const command = client.commands.find((entry) => entry.name === readInteractionName(rawData));
|
|
1833
|
-
if (command
|
|
1835
|
+
if (command) {
|
|
1834
1836
|
await deferCommandInteractionIfNeeded(command, interaction);
|
|
1835
1837
|
await command.run(interaction);
|
|
1836
1838
|
}
|
|
@@ -2965,6 +2967,7 @@ var discord_exports = /* @__PURE__ */ __exportAll({
|
|
|
2965
2967
|
getThreadMember: () => getThreadMember,
|
|
2966
2968
|
getUser: () => getUser,
|
|
2967
2969
|
getWebhookMessage: () => getWebhookMessage,
|
|
2970
|
+
hasDiscordV2Components: () => hasDiscordV2Components,
|
|
2968
2971
|
isUnknownDiscordVoiceStateError: () => isUnknownDiscordVoiceStateError,
|
|
2969
2972
|
listApplicationCommands: () => listApplicationCommands,
|
|
2970
2973
|
listChannelArchivedThreads: () => listChannelArchivedThreads,
|
|
@@ -2995,55 +2998,6 @@ var discord_exports = /* @__PURE__ */ __exportAll({
|
|
|
2995
2998
|
import * as import_discord_api_types_v10 from "discord-api-types/v10";
|
|
2996
2999
|
__reExport(discord_exports, import_discord_api_types_v10);
|
|
2997
3000
|
//#endregion
|
|
2998
|
-
//#region extensions/discord/src/target-parsing.ts
|
|
2999
|
-
function parseDiscordTarget(raw, options = {}) {
|
|
3000
|
-
const trimmed = raw.trim();
|
|
3001
|
-
if (!trimmed) return;
|
|
3002
|
-
const providerPrefixedTarget = parseDiscordProviderPrefixedTarget(trimmed);
|
|
3003
|
-
if (providerPrefixedTarget) return providerPrefixedTarget;
|
|
3004
|
-
const userTarget = parseMentionPrefixOrAtUserTarget({
|
|
3005
|
-
raw: trimmed,
|
|
3006
|
-
mentionPattern: /^<@!?(\d+)>$/,
|
|
3007
|
-
prefixes: [
|
|
3008
|
-
{
|
|
3009
|
-
prefix: "user:",
|
|
3010
|
-
kind: "user"
|
|
3011
|
-
},
|
|
3012
|
-
{
|
|
3013
|
-
prefix: "channel:",
|
|
3014
|
-
kind: "channel"
|
|
3015
|
-
},
|
|
3016
|
-
{
|
|
3017
|
-
prefix: "discord:",
|
|
3018
|
-
kind: "user"
|
|
3019
|
-
}
|
|
3020
|
-
],
|
|
3021
|
-
atUserPattern: /^\d+$/,
|
|
3022
|
-
atUserErrorMessage: "Discord DMs require a user id (use user:<id> or a <@id> mention)"
|
|
3023
|
-
});
|
|
3024
|
-
if (userTarget) return userTarget;
|
|
3025
|
-
if (/^\d+$/.test(trimmed)) {
|
|
3026
|
-
if (options.defaultKind) return buildMessagingTarget(options.defaultKind, trimmed, trimmed);
|
|
3027
|
-
throw new Error(options.ambiguousMessage ?? `Ambiguous Discord recipient "${trimmed}". For DMs use "user:${trimmed}" or "<@${trimmed}>"; for channels use "channel:${trimmed}".`);
|
|
3028
|
-
}
|
|
3029
|
-
return buildMessagingTarget("channel", trimmed, trimmed);
|
|
3030
|
-
}
|
|
3031
|
-
function parseDiscordProviderPrefixedTarget(raw) {
|
|
3032
|
-
const match = /^discord:(channel|user):(.+)$/i.exec(raw);
|
|
3033
|
-
if (!match) return;
|
|
3034
|
-
const kind = match[1]?.toLowerCase();
|
|
3035
|
-
const id = match[2]?.trim();
|
|
3036
|
-
if (!kind || !id) return;
|
|
3037
|
-
return buildMessagingTarget(kind, id, `${kind}:${id}`);
|
|
3038
|
-
}
|
|
3039
|
-
function resolveDiscordChannelId(raw) {
|
|
3040
|
-
return requireTargetKind({
|
|
3041
|
-
platform: "Discord",
|
|
3042
|
-
target: parseDiscordTarget(raw, { defaultKind: "channel" }),
|
|
3043
|
-
kind: "channel"
|
|
3044
|
-
});
|
|
3045
|
-
}
|
|
3046
|
-
//#endregion
|
|
3047
3001
|
//#region extensions/discord/src/normalize.ts
|
|
3048
3002
|
function normalizeDiscordMessagingTarget(raw) {
|
|
3049
3003
|
return parseDiscordTarget(raw, { defaultKind: "channel" })?.normalized;
|
|
@@ -3447,4 +3401,4 @@ function createDiscordRetryRunner(params) {
|
|
|
3447
3401
|
};
|
|
3448
3402
|
}
|
|
3449
3403
|
//#endregion
|
|
3450
|
-
export {
|
|
3404
|
+
export { MediaGallery as $, timeoutGuildMember as $t, RateLimitError as A, pinChannelMessage as At, hasDiscordV2Components as B, deleteChannelPermission as Bt, ThreadDeleteListener as C, editChannelMessage as Ct, Plugin as D, listChannelArchivedThreads as Dt, Client as E, getThreadMember as Et, Command as F, createGuildBan as Ft, Modal as G, listGuildChannels as Gt, Embed as H, getGuildMember as Ht, CommandWithSubcommands as I, createGuildChannel as It, Button as J, listGuildScheduledEvents as Jt, RadioGroup as K, listGuildEmojis as Kt, Guild as L, createGuildEmoji as Lt, readDiscordCode as M, sendChannelTyping as Mt, readDiscordMessage as N, unpinChannelMessage as Nt, RequestClient as O, listChannelMessages as Ot, readRetryAfter as P, addGuildMemberRole as Pt, LinkButton as Q, removeGuildMemberRole as Qt, Message as R, createGuildScheduledEvent as Rt, ResumedListener as S, editChannel as St, VoiceStateUpdateListener as T, getChannelMessage as Tt, CheckboxGroup as U, getGuildVoiceState as Ut, serializePayload as V, getGuild as Vt, Label as W, listGuildActiveThreads as Wt, Container as X, putChannelPermission as Xt, ChannelSelectMenu as Y, moveGuildChannels as Yt, File as Z, removeGuildMember as Zt, MessageCreateListener as _, listMessageReactionUsers as _t, chunkDiscordTextWithMode as a, StringSelectMenu as at, PresenceUpdateListener as b, deleteChannel as bt, resolveDiscordReplyReference as c, UserSelectMenu as ct, normalizeDiscordMessagingTarget as d, stripUndefinedFields as dt, __exportAll as en, MentionableSelectMenu as et, normalizeDiscordOutboundTarget as f, createChannelWebhook as ft, InteractionCreateListener as g, deleteOwnMessageReaction as gt, GuildDeleteListener as h, createOwnMessageReaction as ht, recordDiscordMessageCreateAmbiguity as i, Separator as it, isUnknownDiscordVoiceStateError as j, searchGuildMessages as jt, DiscordError as k, listChannelPins as kt, allowFromContainsDiscordUserId as l, BaseMessageInteractiveComponent as lt, GuildCreateListener as m, getCurrentUser as mt, createDiscordRetryRunner as n, Row as nt, createReusableDiscordReplyReference as o, TextDisplay as ot, discord_exports as p, createUserDmChannel as pt, TextInput as q, listGuildRoles as qt, hasDiscordMessageCreateAmbiguity as r, Section as rt, resolveDiscordReplyMessageId as s, Thumbnail as st, classifyDiscordDeliveryFailure as t, RoleSelectMenu as tt, looksLikeDiscordTargetId as u, parseCustomId as ut, MessageReactionAddListener as v, createChannelMessage as vt, ThreadUpdateListener as w, getChannel as wt, ReadyListener as x, deleteChannelMessage as xt, MessageReactionRemoveListener as y, createThread as yt, User as z, createGuildSticker as zt };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { c as resolveDiscordAccount, g as selectDiscordActivitiesRuntimeConfig, n as isDiscordAccountEnabledForRuntime, r as listDiscordAccountIds } from "./accounts-DNl-oCEw.js";
|
|
2
|
+
import { B as resolveDiscordProxyFetchForAccount } from "./send.shared-B3fpaLWJ.js";
|
|
3
3
|
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
4
|
//#region extensions/discord/src/activities/config.ts
|
|
5
5
|
function resolveDiscordActivitiesConfig(account, env = process.env) {
|
|
@@ -30,7 +30,7 @@ var DiscordActivitiesRuntime = class {
|
|
|
30
30
|
this.learnedApplicationIds = /* @__PURE__ */ new Map();
|
|
31
31
|
}
|
|
32
32
|
currentConfig() {
|
|
33
|
-
return this.getCurrentConfig?.() ?? this.startupConfig;
|
|
33
|
+
return selectDiscordActivitiesRuntimeConfig(this.getCurrentConfig?.() ?? this.startupConfig);
|
|
34
34
|
}
|
|
35
35
|
registerApplicationId(accountId, applicationId) {
|
|
36
36
|
const trimmed = applicationId.trim();
|
|
@@ -41,7 +41,7 @@ var DiscordActivitiesRuntime = class {
|
|
|
41
41
|
cfg,
|
|
42
42
|
accountId
|
|
43
43
|
});
|
|
44
|
-
if (!isDiscordAccountEnabledForRuntime(account, cfg)) return null;
|
|
44
|
+
if (!listDiscordAccountIds(cfg).includes(account.accountId) || !isDiscordAccountEnabledForRuntime(account, cfg) || account.tokenStatus !== "available") return null;
|
|
45
45
|
const activities = resolveDiscordActivitiesConfig(account.config, this.env);
|
|
46
46
|
if (!activities.enabled) return null;
|
|
47
47
|
const applicationId = activities.applicationId ?? this.learnedApplicationIds.get(account.accountId) ?? account.config.applicationId?.trim();
|
|
@@ -62,12 +62,11 @@ var DiscordActivitiesRuntime = class {
|
|
|
62
62
|
if (applicationId) return accounts.find((account) => account.applicationId === applicationId) ?? null;
|
|
63
63
|
return accounts.length === 1 ? accounts[0] ?? null : null;
|
|
64
64
|
}
|
|
65
|
+
hasEnabledAccounts(cfg = this.currentConfig()) {
|
|
66
|
+
return listDiscordAccountIds(cfg).some((accountId) => this.resolveAccount(accountId, cfg) !== null);
|
|
67
|
+
}
|
|
65
68
|
isAccountEnabled(accountId, cfg = this.currentConfig()) {
|
|
66
|
-
|
|
67
|
-
cfg,
|
|
68
|
-
accountId
|
|
69
|
-
});
|
|
70
|
-
return isDiscordAccountEnabledForRuntime(account, cfg) && resolveDiscordActivitiesConfig(account.config, this.env).enabled;
|
|
69
|
+
return this.resolveAccount(accountId, cfg) !== null;
|
|
71
70
|
}
|
|
72
71
|
};
|
|
73
72
|
let activeRuntime;
|
|
@@ -78,4 +77,4 @@ function getDiscordActivitiesRuntime() {
|
|
|
78
77
|
return activeRuntime;
|
|
79
78
|
}
|
|
80
79
|
//#endregion
|
|
81
|
-
export {
|
|
80
|
+
export { getDiscordActivitiesRuntime as n, setDiscordActivitiesRuntime as r, DiscordActivitiesRuntime as t };
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { a as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { c as resolveDiscordReplyReference, o as createReusableDiscordReplyReference } from "./retry-DNsVTeTo.js";
|
|
2
|
+
import { m as readDiscordComponentSpec } from "./components-ezGKo_Yh.js";
|
|
3
|
+
import { A as resolveDiscordChannelId, C as readPositiveIntegerParam, D as withNormalizedTimestamp, E as readStringParam, S as readNonNegativeIntegerParam, T as readStringArrayParam, _ as assertMediaNotDataUrl, b as parseAvailableTags, o as mergeDiscordAccountConfig, s as resolveDefaultDiscordAccountId, t as createDiscordActionGate, v as jsonResult, w as readReactionParams, x as readBooleanParam } from "./accounts-DNl-oCEw.js";
|
|
4
|
+
import { r as sendDiscordComponentMessage } from "./send.components-ChK1wS7w.js";
|
|
5
|
+
import { a as normalizeDiscordSlug, c as resolveDiscordChannelConfigWithFallback, n as isDiscordGroupAllowedByPolicy, v as resolveGroupDmAllow } from "./allow-list-BDMimASD.js";
|
|
6
|
+
import { E as isThreadChannelType$1, I as createDiscordRuntimeAccountContext, T as hasAnyGuildPermissionDiscord, W as getGateway, d as resolveDiscordTargetChannelId, v as canManageGuildMemberRoleDiscord, w as hasAnyChannelPermissionDiscord, x as fetchChannelPermissionsDiscord, y as canManageGuildRoleDiscord } from "./send.shared-B3fpaLWJ.js";
|
|
7
|
+
import { r as sendStickerDiscord, t as sendMessageDiscord } from "./send.outbound-HIkgji_7.js";
|
|
8
8
|
import { n as getPresence } from "./presence-cache-z1N8MbJ3.js";
|
|
9
|
-
import { A as listGuildEmojisDiscord, C as fetchVoiceStatusDiscord, D as removeRoleDiscord, E as listScheduledEventsDiscord, F as editChannelDiscord, I as moveChannelDiscord, L as removeChannelPermissionDiscord, M as uploadStickerDiscord, N as createChannelDiscord, O as resolveEventCoverImage, P as deleteChannelDiscord, R as setChannelPermissionDiscord, S as fetchRoleInfoDiscord, T as listGuildChannelsDiscord, _ as banMemberDiscord, a as DiscordThreadInitialMessageError, b as fetchGuildInfoDiscord, c as editMessageDiscord, d as listThreadsDiscord, f as pinMessageDiscord, g as addRoleDiscord, h as unpinMessageDiscord, j as uploadEmojiDiscord, k as timeoutMemberDiscord, l as fetchMessageDiscord, m as searchMessagesDiscord, o as createThreadDiscord, p as readMessagesDiscord, r as sendVoiceMessageDiscord, s as deleteMessageDiscord, u as listPinsDiscord, v as createScheduledEventDiscord, w as kickMemberDiscord, x as fetchMemberInfoDiscord, y as fetchChannelInfoDiscord } from "./send-
|
|
10
|
-
import { i as removeReactionDiscord, n as reactMessageDiscord, r as removeOwnReactionsDiscord, t as fetchReactionsDiscord } from "./send.reactions-
|
|
11
|
-
import "./targets-
|
|
12
|
-
import { asBoolean, normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
9
|
+
import { A as listGuildEmojisDiscord, C as fetchVoiceStatusDiscord, D as removeRoleDiscord, E as listScheduledEventsDiscord, F as editChannelDiscord, I as moveChannelDiscord, L as removeChannelPermissionDiscord, M as uploadStickerDiscord, N as createChannelDiscord, O as resolveEventCoverImage, P as deleteChannelDiscord, R as setChannelPermissionDiscord, S as fetchRoleInfoDiscord, T as listGuildChannelsDiscord, _ as banMemberDiscord, a as DiscordThreadInitialMessageError, b as fetchGuildInfoDiscord, c as editMessageDiscord, d as listThreadsDiscord, f as pinMessageDiscord, g as addRoleDiscord, h as unpinMessageDiscord, j as uploadEmojiDiscord, k as timeoutMemberDiscord, l as fetchMessageDiscord, m as searchMessagesDiscord, o as createThreadDiscord, p as readMessagesDiscord, r as sendVoiceMessageDiscord, s as deleteMessageDiscord, u as listPinsDiscord, v as createScheduledEventDiscord, w as kickMemberDiscord, x as fetchMemberInfoDiscord, y as fetchChannelInfoDiscord } from "./send-rQIffSYu.js";
|
|
10
|
+
import { i as removeReactionDiscord, n as reactMessageDiscord, r as removeOwnReactionsDiscord, t as fetchReactionsDiscord } from "./send.reactions-gmJ6yFPo.js";
|
|
11
|
+
import "./targets-B2pf49zc.js";
|
|
13
12
|
import { ChannelType, PermissionFlagsBits } from "discord-api-types/v10";
|
|
14
13
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
15
|
-
import {
|
|
14
|
+
import { asBoolean, isRecord, normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
16
15
|
import { resolveOpenProviderRuntimeGroupPolicy } from "openclaw/plugin-sdk/runtime-group-policy";
|
|
16
|
+
import { normalizeAccountId } from "openclaw/plugin-sdk/account-resolution";
|
|
17
17
|
//#region extensions/discord/src/actions/runtime-deps.ts
|
|
18
18
|
const discordGuildActionRuntime = {
|
|
19
19
|
addRoleDiscord,
|
|
@@ -71,7 +71,6 @@ const discordMessagingActionRuntime = {
|
|
|
71
71
|
searchMessagesDiscord,
|
|
72
72
|
sendDiscordComponentMessage,
|
|
73
73
|
sendMessageDiscord,
|
|
74
|
-
sendPollDiscord,
|
|
75
74
|
sendStickerDiscord,
|
|
76
75
|
sendVoiceMessageDiscord,
|
|
77
76
|
unpinMessageDiscord
|
|
@@ -1114,9 +1113,8 @@ async function handleDiscordMessageManagementAction(ctx) {
|
|
|
1114
1113
|
if (rawInferChannelId) try {
|
|
1115
1114
|
const inferChannelId = discordMessagingActionRuntime.resolveDiscordChannelId(rawInferChannelId);
|
|
1116
1115
|
const channelInfo = await discordMessagingActionRuntime.fetchChannelInfoDiscord(inferChannelId, ctx.withOpts());
|
|
1117
|
-
if (channelInfo
|
|
1118
|
-
const
|
|
1119
|
-
const resolved = record.guild_id ?? record.guildId;
|
|
1116
|
+
if (isRecord(channelInfo)) {
|
|
1117
|
+
const resolved = channelInfo.guild_id ?? channelInfo.guildId;
|
|
1120
1118
|
if (typeof resolved === "string" && resolved.trim()) guildId = resolved.trim();
|
|
1121
1119
|
}
|
|
1122
1120
|
} catch {}
|
|
@@ -1206,6 +1204,14 @@ async function handleDiscordReactionMessagingAction(ctx) {
|
|
|
1206
1204
|
function hasDiscordComponentObjectKeys(value) {
|
|
1207
1205
|
return Boolean(value && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length > 0);
|
|
1208
1206
|
}
|
|
1207
|
+
function resolveActionReplyReference(ctx, replyToId) {
|
|
1208
|
+
const reply = ctx.options?.reply;
|
|
1209
|
+
return reply ? resolveDiscordReplyReference({
|
|
1210
|
+
replyToId: reply.replyToId,
|
|
1211
|
+
replyToIdSource: reply.source,
|
|
1212
|
+
replyToMode: reply.source === "implicit" ? reply.mode : void 0
|
|
1213
|
+
}) : createReusableDiscordReplyReference(replyToId);
|
|
1214
|
+
}
|
|
1209
1215
|
function readDiscordThreadArchiveTimestamp(thread) {
|
|
1210
1216
|
if (!thread || typeof thread !== "object" || Array.isArray(thread)) return;
|
|
1211
1217
|
const metadata = thread.thread_metadata;
|
|
@@ -1289,26 +1295,6 @@ async function handleDiscordMessageSendAction(ctx) {
|
|
|
1289
1295
|
await discordMessagingActionRuntime.sendStickerDiscord(to, stickerIds, ctx.withOpts({ content }));
|
|
1290
1296
|
return jsonResult({ ok: true });
|
|
1291
1297
|
}
|
|
1292
|
-
case "poll": {
|
|
1293
|
-
if (!ctx.isActionEnabled("polls")) throw new Error("Discord polls are disabled.");
|
|
1294
|
-
const to = readStringParam(ctx.params, "to", { required: true });
|
|
1295
|
-
const content = readStringParam(ctx.params, "content");
|
|
1296
|
-
const question = readStringParam(ctx.params, "question", { required: true });
|
|
1297
|
-
const answers = readStringArrayParam(ctx.params, "answers", {
|
|
1298
|
-
required: true,
|
|
1299
|
-
label: "answers"
|
|
1300
|
-
});
|
|
1301
|
-
const allowMultiselect = readBooleanParam(ctx.params, "allowMultiselect");
|
|
1302
|
-
const durationHours = readPositiveIntegerParam(ctx.params, "durationHours");
|
|
1303
|
-
const maxSelections = resolvePollMaxSelections(answers.length, allowMultiselect);
|
|
1304
|
-
await discordMessagingActionRuntime.sendPollDiscord(to, {
|
|
1305
|
-
question,
|
|
1306
|
-
options: answers,
|
|
1307
|
-
maxSelections,
|
|
1308
|
-
durationHours
|
|
1309
|
-
}, ctx.withOpts({ content }));
|
|
1310
|
-
return jsonResult({ ok: true });
|
|
1311
|
-
}
|
|
1312
1298
|
case "sendMessage": {
|
|
1313
1299
|
if (!ctx.isActionEnabled("messages")) throw new Error("Discord message sends are disabled.");
|
|
1314
1300
|
const to = readStringParam(ctx.params, "to", { required: true });
|
|
@@ -1319,15 +1305,15 @@ async function handleDiscordMessageSendAction(ctx) {
|
|
|
1319
1305
|
const componentSpec = hasDiscordComponentObjectKeys(rawComponents) ? discordMessagingActionRuntime.readDiscordComponentSpec(rawComponents) : null;
|
|
1320
1306
|
const components = Array.isArray(rawComponents) || typeof rawComponents === "function" ? rawComponents : void 0;
|
|
1321
1307
|
const mediaUrl = readStringParam(ctx.params, "mediaUrl", { trim: false }) ?? readStringParam(ctx.params, "path", { trim: false }) ?? readStringParam(ctx.params, "filePath", { trim: false });
|
|
1308
|
+
const rawEmbeds = ctx.params.embeds;
|
|
1309
|
+
const embeds = Array.isArray(rawEmbeds) ? rawEmbeds : void 0;
|
|
1322
1310
|
const content = readStringParam(ctx.params, "content", {
|
|
1323
|
-
required: !asVoice && !componentSpec && !components && !mediaUrl,
|
|
1311
|
+
required: !asVoice && !componentSpec && !components && !embeds?.length && !mediaUrl,
|
|
1324
1312
|
allowEmpty: true
|
|
1325
1313
|
});
|
|
1326
1314
|
const filename = readStringParam(ctx.params, "filename");
|
|
1327
1315
|
const replyTo = readStringParam(ctx.params, "replyTo");
|
|
1328
1316
|
const threadName = readStringParam(ctx.params, "threadName");
|
|
1329
|
-
const rawEmbeds = ctx.params.embeds;
|
|
1330
|
-
const embeds = Array.isArray(rawEmbeds) ? rawEmbeds : void 0;
|
|
1331
1317
|
const sessionKey = readStringParam(ctx.params, "__sessionKey");
|
|
1332
1318
|
const agentId = readStringParam(ctx.params, "__agentId");
|
|
1333
1319
|
if (componentSpec) {
|
|
@@ -1344,7 +1330,7 @@ async function handleDiscordMessageSendAction(ctx) {
|
|
|
1344
1330
|
result: await discordMessagingActionRuntime.sendDiscordComponentMessage(to, payload, {
|
|
1345
1331
|
...ctx.withOpts(),
|
|
1346
1332
|
silent,
|
|
1347
|
-
reply:
|
|
1333
|
+
reply: resolveActionReplyReference(ctx, replyTo),
|
|
1348
1334
|
sessionKey: sessionKey ?? void 0,
|
|
1349
1335
|
agentId: agentId ?? void 0,
|
|
1350
1336
|
mediaUrl: mediaUrl ?? void 0,
|
|
@@ -1369,7 +1355,7 @@ async function handleDiscordMessageSendAction(ctx) {
|
|
|
1369
1355
|
ok: true,
|
|
1370
1356
|
result: await discordMessagingActionRuntime.sendVoiceMessageDiscord(to, mediaUrl, {
|
|
1371
1357
|
...ctx.withOpts(),
|
|
1372
|
-
reply:
|
|
1358
|
+
reply: resolveActionReplyReference(ctx, replyTo),
|
|
1373
1359
|
silent,
|
|
1374
1360
|
mediaAccess: ctx.options?.mediaAccess,
|
|
1375
1361
|
mediaLocalRoots: ctx.options?.mediaLocalRoots,
|
|
@@ -1391,7 +1377,7 @@ async function handleDiscordMessageSendAction(ctx) {
|
|
|
1391
1377
|
filename: filename ?? void 0,
|
|
1392
1378
|
mediaLocalRoots: ctx.options?.mediaLocalRoots,
|
|
1393
1379
|
mediaReadFile: ctx.options?.mediaReadFile,
|
|
1394
|
-
reply:
|
|
1380
|
+
reply: resolveActionReplyReference(ctx, replyTo),
|
|
1395
1381
|
components,
|
|
1396
1382
|
embeds,
|
|
1397
1383
|
silent,
|
|
@@ -1479,7 +1465,7 @@ async function handleDiscordMessageSendAction(ctx) {
|
|
|
1479
1465
|
mediaAccess: ctx.options?.mediaAccess,
|
|
1480
1466
|
mediaLocalRoots: ctx.options?.mediaLocalRoots,
|
|
1481
1467
|
mediaReadFile: ctx.options?.mediaReadFile,
|
|
1482
|
-
reply:
|
|
1468
|
+
reply: resolveActionReplyReference(ctx, replyTo)
|
|
1483
1469
|
})
|
|
1484
1470
|
});
|
|
1485
1471
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { c as readDiscordChannelMoveParams, i as requiredGuildPermissionForModerationAction, l as readDiscordParentIdParam, n as isDiscordModerationAction, o as readDiscordChannelCreateParams, r as readDiscordModerationCommand, s as readDiscordChannelEditParams, t as handleDiscordAction } from "./runtime-
|
|
2
|
-
import { t as discordMessageActions } from "./channel-actions-
|
|
1
|
+
import { c as readDiscordChannelMoveParams, i as requiredGuildPermissionForModerationAction, l as readDiscordParentIdParam, n as isDiscordModerationAction, o as readDiscordChannelCreateParams, r as readDiscordModerationCommand, s as readDiscordChannelEditParams, t as handleDiscordAction } from "./runtime-D71_VFLr.js";
|
|
2
|
+
import { t as discordMessageActions } from "./channel-actions-Dr2QI8Bf.js";
|
|
3
3
|
export { discordMessageActions, handleDiscordAction, isDiscordModerationAction, readDiscordChannelCreateParams, readDiscordChannelEditParams, readDiscordChannelMoveParams, readDiscordModerationCommand, readDiscordParentIdParam, requiredGuildPermissionForModerationAction };
|