@openclaw/discord 2026.7.2-beta.4 → 2026.7.2-beta.5
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/README.md +1 -1
- package/dist/{account-inspect-Dztmn4J4.js → account-inspect-SXiCBCgP.js} +1 -1
- package/dist/account-inspect-api.js +1 -1
- package/dist/{accounts-D2LKPukU.js → accounts-DJTf1LtA.js} +13 -15
- package/dist/action-runtime-api.js +1 -1
- package/dist/{activities-api-8TMGXUH4.js → activities-api-CHnz7E7t.js} +5 -5
- package/dist/activities-api.js +1 -1
- package/dist/api.js +16 -16
- package/dist/{approval-handler.runtime-ClZpan85.js → approval-handler.runtime-86UuBchU.js} +5 -5
- package/dist/{approval-message-safety-LyND6GR3.js → approval-message-safety-yjFtfJcK.js} +2 -2
- package/dist/{audit-CFfounXC.js → audit-BF8hmDKp.js} +4 -4
- package/dist/{channel-yq-so4jJ.js → channel-DnOg9aoT.js} +19 -18
- package/dist/{channel-actions-C8n1zWZ-.js → channel-actions-BweII8kV.js} +4 -4
- package/dist/{channel-actions.runtime-CgJy35O0.js → channel-actions.runtime-Dsv063Re.js} +6 -6
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel.setup-Tn_O2B7F.js → channel.setup-Cpv7n0I8.js} +23 -50
- package/dist/{chunk-BrZocpfs.js → chunk-CMVEczdm.js} +12 -0
- package/dist/{directory-config-DF85-bUY.js → directory-config-677F_rhf.js} +2 -2
- package/dist/directory-contract-api.js +1 -1
- package/dist/{directory-live-CrMtTrb0.js → directory-live-BQk4bBOC.js} +6 -6
- package/dist/{doctor-CORGPgoY.js → doctor-DIcs6IDL.js} +4 -4
- package/dist/{doctor-contract-BPUD3Di9.js → doctor-contract-CCFMIDk9.js} +15 -58
- package/dist/doctor-contract-api.js +1 -1
- package/dist/{handle-action.guild-admin-DikBWer5.js → handle-action.guild-admin-D14y2JtA.js} +2 -2
- package/dist/index.js +2 -2
- package/dist/legacy-state-migrations-api.js +1 -34
- package/dist/{manager.runtime-DVvlH8NR.js → manager.runtime-asX6a4R4.js} +3 -3
- package/dist/{message-handler-1ui-YxsF.js → message-handler-CxjL-a-8.js} +7 -47
- package/dist/message-handler.history-CJOsN9w5.js +28 -0
- package/dist/{message-handler.preflight-CAEQvP3t.js → message-handler.preflight-D-5zBjwh.js} +33 -48
- package/dist/{message-handler.process-REBztvIW.js → message-handler.process-W9QxWA1g.js} +58 -44
- package/dist/{message-utils-ajbkdTVA.js → message-utils-DSxXsDcG.js} +1 -1
- package/dist/model-picker-preference-primitives-D25pnCOu.js +37 -0
- package/dist/{outbound-adapter-XZWo4_HD.js → outbound-adapter-kse7KV--.js} +61 -96
- package/dist/{outbound-components-CTFDDcq5.js → outbound-components-DNgLQwXl.js} +3 -3
- package/dist/{outbound-session-route-D_nc_Ayk.js → outbound-session-route-DJUzy5WA.js} +1 -1
- package/dist/{pluralkit-CCovPs9s.js → pluralkit-DbN-Z7BG.js} +1 -1
- package/dist/{probe-Bci2pS8M.js → probe-BYRdyuw1.js} +43 -53
- package/dist/{probe.runtime-C88gnnXj.js → probe.runtime-uyKOQSBB.js} +1 -1
- package/dist/{provider-CfiChtjf.js → provider-Ca5Gua1B.js} +143 -123
- package/dist/{provider-session.runtime-D9GTBKPg.js → provider-session.runtime-IEheobg4.js} +3 -3
- package/dist/provider.runtime-Bn8horYu.js +2 -0
- package/dist/{resolve-allowlist-common-C1hTvZa4.js → resolve-allowlist-common-BU6_eGKg.js} +1 -1
- package/dist/{resolve-channels-CmFAdMeQ.js → resolve-channels-ByNsOMJj.js} +2 -2
- package/dist/{resolve-users-Cmu75lZy.js → resolve-users-CgWAonw-.js} +2 -2
- package/dist/{runtime-D-6AugWA.js → runtime-BZm4_qXV.js} +9 -9
- package/dist/runtime-api.actions.js +2 -2
- package/dist/runtime-api.js +19 -19
- package/dist/runtime-api.lookup.js +5 -5
- package/dist/{runtime-api.monitor-DPa2ZoSK.js → runtime-api.monitor-BKYTUIuf.js} +2 -2
- package/dist/runtime-api.monitor.js +4 -4
- package/dist/runtime-api.send.js +6 -6
- package/dist/runtime-api.threads.js +3 -3
- package/dist/{runtime-TwM8IrZU.js → runtime-h03Wce1c.js} +2 -2
- package/dist/security-audit-contract-api.js +1 -1
- package/dist/{security-audit-njzOejQp.js → security-audit-jGnJF__m.js} +38 -0
- package/dist/{security-audit.runtime-DZbDdAnw.js → security-audit.runtime-CPN0xFYz.js} +1 -1
- package/dist/{send-CfnXLUXq.js → send-C_PfNVFH.js} +5 -5
- package/dist/{send.components-V7cyCKbH.js → send.components-BrfbRJNq.js} +5 -5
- package/dist/{send.outbound-BbC2qjpH.js → send.outbound-1t1CryCK.js} +10 -35
- package/dist/{send.reactions-bLrJCZ4G.js → send.reactions-gesJG-Yp.js} +2 -2
- package/dist/{send.shared-Dfacnk-E.js → send.shared-BRGI9T9F.js} +3 -3
- package/dist/session-binding-contract-api.js +1 -1
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{shared-DMA7f3a8.js → shared--6-q1Zhl.js} +5 -5
- package/dist/{subagent-hooks-kFyJQ-MK.js → subagent-hooks-Dx9hr5Qy.js} +3 -3
- package/dist/subagent-hooks-api.js +2 -2
- package/dist/{subagent-progress-mjPRFz-a.js → subagent-progress-BZREb7jm.js} +2 -2
- package/dist/{system-events-BSlhBq3u.js → system-events-tVfIe6Xm.js} +1 -1
- package/dist/{target-resolver-Bo1oWLPO.js → target-resolver-_m_TsenB.js} +3 -3
- package/dist/targets-DqNz_mmW.js +3 -0
- package/dist/{thread-bindings-DAHJuT22.js → thread-bindings-u_7pNz5d.js} +4 -4
- package/dist/{thread-bindings.discord-api-C_tCQcv3.js → thread-bindings.discord-api-DOCKdVgx.js} +4 -4
- package/dist/{thread-bindings.manager-DlZEGvC1.js → thread-bindings.manager-BB-OD9-d.js} +5 -4
- package/dist/{transcripts-source-CyJ-sc3n.js → transcripts-source-BW2VfPX0.js} +1 -1
- package/dist/transcripts-source-api.js +1 -1
- package/dist/{typing-Ci9nhuSi.js → typing-eAhz8LT2.js} +1 -1
- package/package.json +4 -5
- package/dist/provider.runtime-DSzKjpKs.js +0 -2
- package/dist/targets-CB8ahjZk.js +0 -3
- package/npm-shrinkwrap.json +0 -1139
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { d as discord_exports, gt as deleteChannelMessage, pt as createChannelMessage, t as chunkDiscordTextWithMode, u as resolveDiscordChannelId, vt as editChannelMessage } from "./chunk-
|
|
2
|
-
import { f as resolveDiscordMaxLinesPerMessage } from "./accounts-
|
|
3
|
-
import { F as createDiscordRestClient, I as createDiscordRuntimeAccountContext, _ as resolveDiscordMessageFlags, d as resolveDiscordTargetChannelId } from "./send.shared-
|
|
1
|
+
import { d as discord_exports, gt as deleteChannelMessage, pt as createChannelMessage, t as chunkDiscordTextWithMode, u as resolveDiscordChannelId, vt as editChannelMessage } from "./chunk-CMVEczdm.js";
|
|
2
|
+
import { f as resolveDiscordMaxLinesPerMessage } from "./accounts-DJTf1LtA.js";
|
|
3
|
+
import { F as createDiscordRestClient, I as createDiscordRuntimeAccountContext, _ as resolveDiscordMessageFlags, d as resolveDiscordTargetChannelId } from "./send.shared-BRGI9T9F.js";
|
|
4
4
|
import { C as resolveTimestampMs, a as normalizeDiscordSlug, r as normalizeDiscordAllowList } from "./allow-list-DzKrtfah.js";
|
|
5
|
-
import { i as discordTextHasBroadcastMention } from "./send.outbound-
|
|
6
|
-
import { s as editMessageDiscord } from "./send-
|
|
5
|
+
import { i as discordTextHasBroadcastMention } from "./send.outbound-1t1CryCK.js";
|
|
6
|
+
import { s as editMessageDiscord } from "./send-C_PfNVFH.js";
|
|
7
7
|
import { n as DISCORD_ATTACHMENT_TOTAL_TIMEOUT_MS, t as DISCORD_ATTACHMENT_IDLE_TIMEOUT_MS } from "./timeouts-B9cy6RvQ.js";
|
|
8
|
-
import { i as removeReactionDiscord, n as reactMessageDiscord } from "./send.reactions-
|
|
9
|
-
import "./targets-
|
|
10
|
-
import { r as resolveDiscordConversationIdentity } from "./approval-message-safety-
|
|
8
|
+
import { i as removeReactionDiscord, n as reactMessageDiscord } from "./send.reactions-gesJG-Yp.js";
|
|
9
|
+
import "./targets-DqNz_mmW.js";
|
|
10
|
+
import { r as resolveDiscordConversationIdentity } from "./approval-message-safety-yjFtfJcK.js";
|
|
11
11
|
import { t as beginDiscordInboundEventDeliveryCorrelation } from "./inbound-event-delivery-CEPlt2uz.js";
|
|
12
|
-
import { t as DISCORD_TEXT_CHUNK_LIMIT } from "./outbound-adapter-
|
|
13
|
-
import { D as resolveDiscordAutoThreadReplyPlan, _ as buildDiscordInboundAccessContext, a as sanitizeDiscordFrontChannelReplyPayloads, c as resolveReplyContext, i as formatDiscordReplySkip, k as resolveDiscordThreadStarter, n as deliverDiscordReply, o as buildDirectLabel, r as formatDiscordReplyDeliveryFailure, s as buildGuildLabel, v as createDiscordSupplementalContextAccessChecker } from "./provider-
|
|
14
|
-
import { a as formatDiscordMediaText, c as resolveReferencedReplyMediaList, i as resolveDiscordMessageText, u as resolveDiscordMessageStickers } from "./message-utils-
|
|
12
|
+
import { t as DISCORD_TEXT_CHUNK_LIMIT } from "./outbound-adapter-kse7KV--.js";
|
|
13
|
+
import { D as resolveDiscordAutoThreadReplyPlan, _ as buildDiscordInboundAccessContext, a as sanitizeDiscordFrontChannelReplyPayloads, c as resolveReplyContext, i as formatDiscordReplySkip, k as resolveDiscordThreadStarter, n as deliverDiscordReply, o as buildDirectLabel, r as formatDiscordReplyDeliveryFailure, s as buildGuildLabel, v as createDiscordSupplementalContextAccessChecker } from "./provider-Ca5Gua1B.js";
|
|
14
|
+
import { a as formatDiscordMediaText, c as resolveReferencedReplyMediaList, i as resolveDiscordMessageText, u as resolveDiscordMessageStickers } from "./message-utils-DSxXsDcG.js";
|
|
15
15
|
import { n as resolveDiscordWebhookId } from "./sender-identity-mG_zsdox.js";
|
|
16
|
-
import { t as
|
|
16
|
+
import { n as filterDiscordHistoryEntriesForContext, t as createDiscordHistorySenderProvenance } from "./message-handler.history-CJOsN9w5.js";
|
|
17
|
+
import { t as sendTyping } from "./typing-eAhz8LT2.js";
|
|
17
18
|
import { buildAgentSessionKey, resolveThreadSessionKeys } from "openclaw/plugin-sdk/routing";
|
|
18
19
|
import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
|
|
19
20
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
@@ -31,8 +32,8 @@ import { EmbeddedBlockChunker, resolveAckReaction, resolveAgentConfig, resolveHu
|
|
|
31
32
|
import { isDangerousNameMatchingEnabled } from "openclaw/plugin-sdk/dangerous-name-runtime";
|
|
32
33
|
import { buildChannelInboundEventContext, dispatchChannelInboundTurn, formatInboundEnvelope, hasFinalInboundReplyDispatch, resolveEnvelopeFormatOptions, toHistoryMediaEntries, toInboundMediaFacts } from "openclaw/plugin-sdk/channel-inbound";
|
|
33
34
|
import { getSessionEntry, readSessionUpdatedAt, resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
|
|
35
|
+
import { buildHistoryContextFromEntries, buildInboundHistoryFromEntries, createChannelHistoryWindow } from "openclaw/plugin-sdk/reply-history";
|
|
34
36
|
import { resolveChannelContextVisibilityMode } from "openclaw/plugin-sdk/context-visibility-runtime";
|
|
35
|
-
import { createChannelHistoryWindow } from "openclaw/plugin-sdk/reply-history";
|
|
36
37
|
import { DEFAULT_TIMING, createStatusReactionController, logAckFailure, logTypingFailure, shouldAckReaction } from "openclaw/plugin-sdk/channel-feedback";
|
|
37
38
|
import { readLatestAssistantTextByIdentity } from "openclaw/plugin-sdk/session-transcript-runtime";
|
|
38
39
|
//#region extensions/discord/src/monitor/message-handler.retry.ts
|
|
@@ -90,7 +91,7 @@ async function buildDiscordMessageProcessContext(params) {
|
|
|
90
91
|
const groupChannel = isGuildMessage && displayChannelSlug ? `#${displayChannelSlug}` : void 0;
|
|
91
92
|
const senderName = sender.isPluralKit ? sender.name ?? author.username : data.member?.nickname ?? author.globalName ?? author.username;
|
|
92
93
|
const senderUsername = sender.isPluralKit ? sender.tag ?? sender.name ?? author.username : author.username;
|
|
93
|
-
const { groupSystemPrompt, ownerAllowFrom,
|
|
94
|
+
const { groupSystemPrompt, ownerAllowFrom, channelStructuredContext } = buildDiscordInboundAccessContext({
|
|
94
95
|
channelConfig,
|
|
95
96
|
guildInfo,
|
|
96
97
|
sender: {
|
|
@@ -125,6 +126,7 @@ async function buildDiscordMessageProcessContext(params) {
|
|
|
125
126
|
sessionKey: route.sessionKey
|
|
126
127
|
});
|
|
127
128
|
const channelHistory = createChannelHistoryWindow({ historyMap: guildHistories });
|
|
129
|
+
let visibleChannelHistory;
|
|
128
130
|
let combinedBody = formatInboundEnvelope({
|
|
129
131
|
channel: "Discord",
|
|
130
132
|
from: fromLabel,
|
|
@@ -138,20 +140,29 @@ async function buildDiscordMessageProcessContext(params) {
|
|
|
138
140
|
const shouldIncludeChannelHistory = !isDirectMessage && (ctx.inboundEventKind === "room_event" || !(isGuildMessage && channelConfig?.autoThread && !threadChannel));
|
|
139
141
|
if (shouldIncludeChannelHistory) {
|
|
140
142
|
removeDiscordReplayHistoryEntry(guildHistories, messageChannelId, message.id);
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
143
|
+
if (historyLimit > 0) {
|
|
144
|
+
const filteredHistory = filterDiscordHistoryEntriesForContext({
|
|
145
|
+
entries: guildHistories.get(messageChannelId) ?? [],
|
|
146
|
+
mode: contextVisibilityMode,
|
|
147
|
+
isSenderAllowed: isSupplementalContextSenderAllowed
|
|
148
|
+
});
|
|
149
|
+
visibleChannelHistory = filteredHistory.entries;
|
|
150
|
+
if (filteredHistory.omitted > 0) logVerbose(`discord: omit ${filteredHistory.omitted} pending history entries (mode=${contextVisibilityMode})`);
|
|
151
|
+
combinedBody = buildHistoryContextFromEntries({
|
|
152
|
+
entries: visibleChannelHistory,
|
|
153
|
+
currentMessage: combinedBody,
|
|
154
|
+
formatEntry: (entry) => formatInboundEnvelope({
|
|
155
|
+
channel: "Discord",
|
|
156
|
+
from: fromLabel,
|
|
157
|
+
timestamp: entry.timestamp,
|
|
158
|
+
body: `${entry.body} [id:${entry.messageId ?? "unknown"} channel:${messageChannelId}]`,
|
|
159
|
+
chatType: "channel",
|
|
160
|
+
senderLabel: entry.sender,
|
|
161
|
+
envelope: envelopeOptions
|
|
162
|
+
}),
|
|
163
|
+
excludeLast: false
|
|
164
|
+
});
|
|
165
|
+
}
|
|
155
166
|
}
|
|
156
167
|
const replyContext = resolveReplyContext(message, resolveDiscordMessageText);
|
|
157
168
|
const replySenderAllowed = replyContext ? isSupplementalContextSenderAllowed({
|
|
@@ -247,8 +258,8 @@ async function buildDiscordMessageProcessContext(params) {
|
|
|
247
258
|
return null;
|
|
248
259
|
}
|
|
249
260
|
const lastRouteTo = dmConversationTarget ?? effectiveTo;
|
|
250
|
-
const inboundHistory = shouldIncludeChannelHistory ?
|
|
251
|
-
|
|
261
|
+
const inboundHistory = shouldIncludeChannelHistory ? buildInboundHistoryFromEntries({
|
|
262
|
+
entries: visibleChannelHistory ?? [],
|
|
252
263
|
limit: historyLimit
|
|
253
264
|
}) : void 0;
|
|
254
265
|
const originatingTo = autoThreadContext?.OriginatingTo ?? dmConversationTarget ?? replyTarget;
|
|
@@ -353,7 +364,7 @@ async function buildDiscordMessageProcessContext(params) {
|
|
|
353
364
|
GroupSubject: isDirectMessage ? void 0 : groupChannel,
|
|
354
365
|
GroupChannel: groupChannel,
|
|
355
366
|
...isGuildMessage ? { GroupRequireMention: ctx.groupRequireMention } : {},
|
|
356
|
-
|
|
367
|
+
ChannelStructuredContext: channelStructuredContext,
|
|
357
368
|
OwnerAllowFrom: ownerAllowFrom
|
|
358
369
|
}
|
|
359
370
|
});
|
|
@@ -370,7 +381,11 @@ async function buildDiscordMessageProcessContext(params) {
|
|
|
370
381
|
sender: senderName,
|
|
371
382
|
body: historyText,
|
|
372
383
|
timestamp: resolveTimestampMs(message.timestamp),
|
|
373
|
-
messageId: message.id
|
|
384
|
+
messageId: message.id,
|
|
385
|
+
senderProvenance: createDiscordHistorySenderProvenance({
|
|
386
|
+
sender,
|
|
387
|
+
memberRoleIds
|
|
388
|
+
})
|
|
374
389
|
},
|
|
375
390
|
media: toHistoryMediaEntries(mediaList, { messageId: message.id }),
|
|
376
391
|
messageId: message.id
|
|
@@ -1379,9 +1394,8 @@ async function processDiscordMessageInner(ctx, observer) {
|
|
|
1379
1394
|
}
|
|
1380
1395
|
});
|
|
1381
1396
|
const sourceRepliesAreToolOnly = sourceReplyDeliveryMode === "message_tool_only";
|
|
1382
|
-
const
|
|
1383
|
-
const
|
|
1384
|
-
const configuredTypingInterval = routedAgentConfig?.typingIntervalSeconds ?? cfg.agents?.defaults?.typingIntervalSeconds;
|
|
1397
|
+
const configuredTypingMode = resolveAgentConfig(cfg, route.agentId)?.typingMode ?? cfg.agents?.defaults?.typingMode;
|
|
1398
|
+
const configuredTypingInterval = cfg.agents?.defaults?.typingIntervalSeconds;
|
|
1385
1399
|
const shouldDisableCoreTypingKeepalive = sourceRepliesAreToolOnly && configuredTypingMode === void 0 && configuredTypingInterval === void 0;
|
|
1386
1400
|
const mediaLocalRoots = getAgentScopedMediaLocalRoots(cfg, route.agentId);
|
|
1387
1401
|
const isRoomEvent = ctx.inboundEventKind === "room_event";
|
|
@@ -1501,7 +1515,7 @@ async function processDiscordMessageInner(ctx, observer) {
|
|
|
1501
1515
|
isReasoning: void 0
|
|
1502
1516
|
}));
|
|
1503
1517
|
if (!replies.length) return { visibleReplySent: false };
|
|
1504
|
-
await deliverDiscordReply({
|
|
1518
|
+
const result = await deliverDiscordReply({
|
|
1505
1519
|
cfg,
|
|
1506
1520
|
replies,
|
|
1507
1521
|
target: deliverTarget,
|
|
@@ -1520,8 +1534,8 @@ async function processDiscordMessageInner(ctx, observer) {
|
|
|
1520
1534
|
mediaLocalRoots,
|
|
1521
1535
|
kind: "block"
|
|
1522
1536
|
});
|
|
1523
|
-
replyReference.markSent();
|
|
1524
|
-
return
|
|
1537
|
+
if (result.visibleReplySent) replyReference.markSent();
|
|
1538
|
+
return result;
|
|
1525
1539
|
}
|
|
1526
1540
|
if (isFinal && !options?.allowFallbackOnlyToolWarning && isFallbackOnlyToolWarningFinal(payload)) {
|
|
1527
1541
|
if (!userFacingFinalDelivered && (!finalReplyStartNotified || userFacingFinalDeliveryFailed)) pendingToolWarningFinal = {
|
|
@@ -1599,7 +1613,7 @@ async function processDiscordMessageInner(ctx, observer) {
|
|
|
1599
1613
|
const allowedMentions = discordTextHasBroadcastMention(fallbackPayload.text ?? "") ? TARGETED_ONLY_ALLOWED_MENTIONS : void 0;
|
|
1600
1614
|
const replyToId = replyReference.use();
|
|
1601
1615
|
notifyFinalReplyStart();
|
|
1602
|
-
await deliverDiscordReply({
|
|
1616
|
+
return (await deliverDiscordReply({
|
|
1603
1617
|
cfg,
|
|
1604
1618
|
replies: [fallbackPayload],
|
|
1605
1619
|
target: deliverTarget,
|
|
@@ -1618,8 +1632,7 @@ async function processDiscordMessageInner(ctx, observer) {
|
|
|
1618
1632
|
mediaLocalRoots,
|
|
1619
1633
|
allowedMentions,
|
|
1620
1634
|
kind: info.kind
|
|
1621
|
-
});
|
|
1622
|
-
return true;
|
|
1635
|
+
})).visibleReplySent;
|
|
1623
1636
|
},
|
|
1624
1637
|
onNormalDelivered: () => {
|
|
1625
1638
|
markUserFacingFinalDelivered();
|
|
@@ -1643,7 +1656,7 @@ async function processDiscordMessageInner(ctx, observer) {
|
|
|
1643
1656
|
...deliverablePayload,
|
|
1644
1657
|
text: deliverablePayload.text?.trim() ? `${deliverablePayload.text.trimEnd()}\n${receiptLine}` : receiptLine
|
|
1645
1658
|
} : deliverablePayload;
|
|
1646
|
-
await deliverDiscordReply({
|
|
1659
|
+
const result = await deliverDiscordReply({
|
|
1647
1660
|
cfg,
|
|
1648
1661
|
replies: [payloadForDelivery],
|
|
1649
1662
|
target: deliverTarget,
|
|
@@ -1662,6 +1675,7 @@ async function processDiscordMessageInner(ctx, observer) {
|
|
|
1662
1675
|
mediaLocalRoots,
|
|
1663
1676
|
kind: info.kind
|
|
1664
1677
|
});
|
|
1678
|
+
if (!result.visibleReplySent) return result;
|
|
1665
1679
|
replyReference.markSent();
|
|
1666
1680
|
if (isFinal && deliverablePayload.isError !== true) {
|
|
1667
1681
|
if (receiptLine) {
|
|
@@ -1675,7 +1689,7 @@ async function processDiscordMessageInner(ctx, observer) {
|
|
|
1675
1689
|
await draftStream?.clear();
|
|
1676
1690
|
}
|
|
1677
1691
|
}
|
|
1678
|
-
return
|
|
1692
|
+
return result;
|
|
1679
1693
|
};
|
|
1680
1694
|
const onDiscordDeliveryError = (err, info) => {
|
|
1681
1695
|
if (info.kind === "final" && finalReplyStartNotified && !userFacingFinalDelivered) userFacingFinalDeliveryFailed = true;
|
|
@@ -1734,7 +1748,7 @@ async function processDiscordMessageInner(ctx, observer) {
|
|
|
1734
1748
|
onFreshSettledDelivery: deliverPendingToolWarningFinalIfNeeded
|
|
1735
1749
|
},
|
|
1736
1750
|
delivery: {
|
|
1737
|
-
|
|
1751
|
+
deliverWithProviderMessageSending: deliverDiscordPayload,
|
|
1738
1752
|
onError: onDiscordDeliveryError
|
|
1739
1753
|
},
|
|
1740
1754
|
record: turn.record,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as resolveDiscordChannelInfoSafe } from "./thread-bindings.discord-api-
|
|
1
|
+
import { f as resolveDiscordChannelInfoSafe } from "./thread-bindings.discord-api-DOCKdVgx.js";
|
|
2
2
|
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeOptionalStringifiedId, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
3
|
import { ComponentType, StickerFormatType } from "discord-api-types/v10";
|
|
4
4
|
import { asDateTimestampMs, resolveExpiresAtMsFromDurationMs } from "openclaw/plugin-sdk/number-runtime";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { normalizeProviderId } from "openclaw/plugin-sdk/provider-model-shared";
|
|
3
|
+
//#region extensions/discord/src/monitor/model-picker-preference-primitives.ts
|
|
4
|
+
function normalizeModelRef(raw) {
|
|
5
|
+
const value = raw?.trim();
|
|
6
|
+
if (!value) return null;
|
|
7
|
+
const slashIndex = value.indexOf("/");
|
|
8
|
+
if (slashIndex <= 0 || slashIndex >= value.length - 1) return null;
|
|
9
|
+
const provider = normalizeProviderId(value.slice(0, slashIndex));
|
|
10
|
+
const model = value.slice(slashIndex + 1).trim();
|
|
11
|
+
return provider && model ? `${provider}/${model}` : null;
|
|
12
|
+
}
|
|
13
|
+
function sanitizeRecentModels(models, limit) {
|
|
14
|
+
const deduped = [];
|
|
15
|
+
const seen = /* @__PURE__ */ new Set();
|
|
16
|
+
if (!Array.isArray(models)) return deduped;
|
|
17
|
+
for (const item of models) {
|
|
18
|
+
const normalized = normalizeModelRef(typeof item === "string" ? item : void 0);
|
|
19
|
+
if (!normalized || seen.has(normalized)) continue;
|
|
20
|
+
seen.add(normalized);
|
|
21
|
+
deduped.push(normalized);
|
|
22
|
+
if (deduped.length >= limit) break;
|
|
23
|
+
}
|
|
24
|
+
return deduped;
|
|
25
|
+
}
|
|
26
|
+
function hashSegment(value, length) {
|
|
27
|
+
return createHash("sha256").update(value, "utf8").digest("hex").slice(0, length);
|
|
28
|
+
}
|
|
29
|
+
function buildPreferenceModelKey(scopeKey, modelRef) {
|
|
30
|
+
return `v1:${hashSegment(scopeKey, 32)}:${hashSegment(modelRef, 24)}`;
|
|
31
|
+
}
|
|
32
|
+
function timestampMs(value) {
|
|
33
|
+
const parsed = typeof value === "string" ? Date.parse(value) : NaN;
|
|
34
|
+
return Number.isFinite(parsed) ? parsed : 0;
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { timestampMs as i, normalizeModelRef as n, sanitizeRecentModels as r, buildPreferenceModelKey as t };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { c as normalizeDiscordOutboundTarget, i as resolveDiscordReplyReference, t as chunkDiscordTextWithMode } from "./chunk-
|
|
1
|
+
import { c as normalizeDiscordOutboundTarget, i as resolveDiscordReplyReference, t as chunkDiscordTextWithMode } from "./chunk-CMVEczdm.js";
|
|
2
2
|
import { t as createDiscordSendReceipt } from "./send.receipt-CuwRrpFz.js";
|
|
3
|
-
import { n as formatDiscordApprovalDisplayValue } from "./approval-message-safety-
|
|
3
|
+
import { n as formatDiscordApprovalDisplayValue } from "./approval-message-safety-yjFtfJcK.js";
|
|
4
4
|
import { n as notifyDiscordInboundEventOutboundPayloadSuccess } from "./inbound-event-delivery-CEPlt2uz.js";
|
|
5
|
-
import { a as sendDiscordComponentMessageLazy, i as resolveDiscordComponentSpec, n as buildDiscordPresentationPayload, t as DISCORD_PRESENTATION_CAPABILITIES } from "./outbound-components-
|
|
5
|
+
import { a as sendDiscordComponentMessageLazy, i as resolveDiscordComponentSpec, n as buildDiscordPresentationPayload, t as DISCORD_PRESENTATION_CAPABILITIES } from "./outbound-components-DNgLQwXl.js";
|
|
6
6
|
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeOptionalStringifiedId } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
7
7
|
import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
|
|
8
8
|
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
@@ -59,7 +59,7 @@ function normalizeDiscordApprovalPayload(payload) {
|
|
|
59
59
|
}
|
|
60
60
|
//#endregion
|
|
61
61
|
//#region extensions/discord/src/outbound-send-context.ts
|
|
62
|
-
const loadDiscordSendRuntime = createLazyRuntimeModule(() => import("./send-
|
|
62
|
+
const loadDiscordSendRuntime = createLazyRuntimeModule(() => import("./send-C_PfNVFH.js").then((n) => n.t));
|
|
63
63
|
function resolveDiscordOutboundTarget(params) {
|
|
64
64
|
if (params.threadId == null) return params.to;
|
|
65
65
|
const threadId = normalizeOptionalStringifiedId(params.threadId) ?? "";
|
|
@@ -238,14 +238,8 @@ async function sendDiscordOutboundPayload(params) {
|
|
|
238
238
|
//#endregion
|
|
239
239
|
//#region extensions/discord/src/outbound-adapter.ts
|
|
240
240
|
const DISCORD_TEXT_CHUNK_LIMIT = 2e3;
|
|
241
|
-
const
|
|
242
|
-
const
|
|
243
|
-
const DISCORD_INTERNAL_RUNTIME_SCAFFOLDING_TAG_RE = /<\s*\/?\s*(?:system-reminder|previous_response)\b[^>]*>/gi;
|
|
244
|
-
function stripDiscordInternalRuntimeScaffolding(text) {
|
|
245
|
-
return text.replace(DISCORD_INTERNAL_RUNTIME_SCAFFOLDING_BLOCK_RE, "").replace(DISCORD_INTERNAL_RUNTIME_SCAFFOLDING_SELF_CLOSING_RE, "").replace(DISCORD_INTERNAL_RUNTIME_SCAFFOLDING_TAG_RE, "");
|
|
246
|
-
}
|
|
247
|
-
const loadDiscordThreadBindings = createLazyRuntimeModule(() => import("./thread-bindings-DAHJuT22.js").then((n) => n.t));
|
|
248
|
-
const loadDiscordComponentSendRuntime = createLazyRuntimeModule(() => import("./send.components-V7cyCKbH.js").then((n) => n.i));
|
|
241
|
+
const loadDiscordThreadBindings = createLazyRuntimeModule(() => import("./thread-bindings-u_7pNz5d.js").then((n) => n.t));
|
|
242
|
+
const loadDiscordComponentSendRuntime = createLazyRuntimeModule(() => import("./send.components-BrfbRJNq.js").then((n) => n.i));
|
|
249
243
|
function resolveDiscordWebhookIdentity(params) {
|
|
250
244
|
const usernameRaw = normalizeOptionalString(params.identity?.name);
|
|
251
245
|
const fallbackUsername = normalizeOptionalString(params.binding.label) ?? params.binding.agentId;
|
|
@@ -279,6 +273,32 @@ async function maybeSendDiscordWebhookText(params) {
|
|
|
279
273
|
avatarUrl: persona.avatarUrl
|
|
280
274
|
});
|
|
281
275
|
}
|
|
276
|
+
async function resolveDiscordOutboundMessageSend(params) {
|
|
277
|
+
const send = resolveOutboundSendDep(params.deps, "discord") ?? (await loadDiscordSendRuntime()).sendMessageDiscord;
|
|
278
|
+
const reply = resolveDiscordReplyReference({
|
|
279
|
+
replyToId: params.replyToId,
|
|
280
|
+
replyToIdSource: params.replyToIdSource,
|
|
281
|
+
replyToMode: params.replyToMode
|
|
282
|
+
});
|
|
283
|
+
return {
|
|
284
|
+
send,
|
|
285
|
+
target: resolveDiscordOutboundTarget({
|
|
286
|
+
to: params.to,
|
|
287
|
+
threadId: params.threadId
|
|
288
|
+
}),
|
|
289
|
+
options: {
|
|
290
|
+
verbose: false,
|
|
291
|
+
reply,
|
|
292
|
+
accountId: params.accountId ?? void 0,
|
|
293
|
+
silent: params.silent ?? void 0,
|
|
294
|
+
cfg: params.cfg,
|
|
295
|
+
...resolveDiscordFormattingOptions({ formatting: params.formatting }),
|
|
296
|
+
onDeliveryResult: params.onDeliveryResult ? async (result) => {
|
|
297
|
+
await params.onDeliveryResult?.(attachChannelToResult("discord", result));
|
|
298
|
+
} : void 0
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
}
|
|
282
302
|
const discordOutbound = {
|
|
283
303
|
deliveryMode: "direct",
|
|
284
304
|
chunker: (text, limit, ctx) => chunkDiscordTextWithMode(text, {
|
|
@@ -286,7 +306,6 @@ const discordOutbound = {
|
|
|
286
306
|
maxLines: ctx?.formatting?.maxLinesPerMessage
|
|
287
307
|
}),
|
|
288
308
|
textChunkLimit: DISCORD_TEXT_CHUNK_LIMIT,
|
|
289
|
-
sanitizeText: ({ text }) => stripDiscordInternalRuntimeScaffolding(text),
|
|
290
309
|
pollMaxOptions: 10,
|
|
291
310
|
normalizePayload: ({ payload }) => normalizeDiscordApprovalPayload(payload),
|
|
292
311
|
presentationCapabilities: DISCORD_PRESENTATION_CAPABILITIES,
|
|
@@ -313,98 +332,44 @@ const discordOutbound = {
|
|
|
313
332
|
}),
|
|
314
333
|
...createAttachedChannelResultAdapter({
|
|
315
334
|
channel: "discord",
|
|
316
|
-
sendText: async (
|
|
317
|
-
if (!silent) {
|
|
335
|
+
sendText: async (ctx) => {
|
|
336
|
+
if (!ctx.silent) {
|
|
318
337
|
const webhookResult = await maybeSendDiscordWebhookText({
|
|
319
|
-
cfg,
|
|
320
|
-
text,
|
|
321
|
-
threadId,
|
|
322
|
-
accountId,
|
|
323
|
-
identity,
|
|
324
|
-
replyToId
|
|
338
|
+
cfg: ctx.cfg,
|
|
339
|
+
text: ctx.text,
|
|
340
|
+
threadId: ctx.threadId,
|
|
341
|
+
accountId: ctx.accountId,
|
|
342
|
+
identity: ctx.identity,
|
|
343
|
+
replyToId: ctx.replyToId
|
|
325
344
|
}).catch(() => null);
|
|
326
345
|
if (webhookResult) return webhookResult;
|
|
327
346
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
threadId
|
|
331
|
-
}), text, {
|
|
332
|
-
verbose: false,
|
|
333
|
-
reply: resolveDiscordReplyReference({
|
|
334
|
-
replyToId,
|
|
335
|
-
replyToIdSource,
|
|
336
|
-
replyToMode
|
|
337
|
-
}),
|
|
338
|
-
accountId: accountId ?? void 0,
|
|
339
|
-
silent: silent ?? void 0,
|
|
340
|
-
cfg,
|
|
341
|
-
...resolveDiscordFormattingOptions({ formatting }),
|
|
342
|
-
onDeliveryResult: onDeliveryResult ? async (result) => {
|
|
343
|
-
await onDeliveryResult(attachChannelToResult("discord", result));
|
|
344
|
-
} : void 0
|
|
345
|
-
});
|
|
347
|
+
const { send, target, options } = await resolveDiscordOutboundMessageSend(ctx);
|
|
348
|
+
return await send(target, ctx.text, options);
|
|
346
349
|
},
|
|
347
|
-
sendMedia: async (
|
|
348
|
-
const send
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
const reply = resolveDiscordReplyReference({
|
|
355
|
-
replyToId,
|
|
356
|
-
replyToIdSource,
|
|
357
|
-
replyToMode
|
|
350
|
+
sendMedia: async (ctx) => {
|
|
351
|
+
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, {
|
|
353
|
+
cfg: ctx.cfg,
|
|
354
|
+
reply: options.reply,
|
|
355
|
+
accountId: ctx.accountId ?? void 0,
|
|
356
|
+
silent: ctx.silent ?? void 0
|
|
358
357
|
});
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
reply,
|
|
369
|
-
accountId: accountId ?? void 0,
|
|
370
|
-
silent: silent ?? void 0,
|
|
371
|
-
cfg,
|
|
372
|
-
...formattingOptions,
|
|
373
|
-
onDeliveryResult: onDeliveryResult ? async (result) => {
|
|
374
|
-
await onDeliveryResult(attachChannelToResult("discord", result));
|
|
375
|
-
} : void 0
|
|
376
|
-
});
|
|
358
|
+
const mediaOptions = {
|
|
359
|
+
...options,
|
|
360
|
+
mediaUrl: ctx.mediaUrl,
|
|
361
|
+
mediaAccess: ctx.mediaAccess,
|
|
362
|
+
mediaLocalRoots: ctx.mediaLocalRoots,
|
|
363
|
+
mediaReadFile: ctx.mediaReadFile
|
|
364
|
+
};
|
|
365
|
+
if (ctx.text.trim() && ctx.mediaUrl && isLikelyDiscordVideoMedia(ctx.mediaUrl)) {
|
|
366
|
+
await send(target, ctx.text, options);
|
|
377
367
|
return await send(target, "", {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
reply: reply?.scope === "all" ? reply : void 0,
|
|
381
|
-
mediaAccess,
|
|
382
|
-
mediaLocalRoots,
|
|
383
|
-
mediaReadFile,
|
|
384
|
-
accountId: accountId ?? void 0,
|
|
385
|
-
silent: silent ?? void 0,
|
|
386
|
-
cfg,
|
|
387
|
-
...formattingOptions,
|
|
388
|
-
onDeliveryResult: onDeliveryResult ? async (result) => {
|
|
389
|
-
await onDeliveryResult(attachChannelToResult("discord", result));
|
|
390
|
-
} : void 0
|
|
368
|
+
...mediaOptions,
|
|
369
|
+
reply: options.reply?.scope === "all" ? options.reply : void 0
|
|
391
370
|
});
|
|
392
371
|
}
|
|
393
|
-
return await send(target, text,
|
|
394
|
-
verbose: false,
|
|
395
|
-
mediaUrl,
|
|
396
|
-
mediaAccess,
|
|
397
|
-
mediaLocalRoots,
|
|
398
|
-
mediaReadFile,
|
|
399
|
-
reply,
|
|
400
|
-
accountId: accountId ?? void 0,
|
|
401
|
-
silent: silent ?? void 0,
|
|
402
|
-
cfg,
|
|
403
|
-
...formattingOptions,
|
|
404
|
-
onDeliveryResult: onDeliveryResult ? async (result) => {
|
|
405
|
-
await onDeliveryResult(attachChannelToResult("discord", result));
|
|
406
|
-
} : void 0
|
|
407
|
-
});
|
|
372
|
+
return await send(target, ctx.text, mediaOptions);
|
|
408
373
|
},
|
|
409
374
|
sendPoll: async ({ cfg, to, poll, accountId, threadId, silent }) => await (await loadDiscordSendRuntime()).sendPollDiscord(resolveDiscordOutboundTarget({
|
|
410
375
|
to,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h as readDiscordComponentSpec } from "./outbound-session-route-
|
|
1
|
+
import { h as readDiscordComponentSpec } from "./outbound-session-route-DJUzy5WA.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-BrfbRJNq.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("./outbound-session-route-
|
|
37
|
+
const loadDiscordSharedInteractive = createLazyRuntimeModule(() => import("./outbound-session-route-DJUzy5WA.js").then((n) => n.o));
|
|
38
38
|
function addPayloadTextFallback(spec, payload) {
|
|
39
39
|
return spec.text ? spec : {
|
|
40
40
|
...spec,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as Section, B as Label, G as ChannelSelectMenu, H as RadioGroup, J as LinkButton, K as Container, Q as Row, U as TextInput, V as Modal, W as Button, X as MentionableSelectMenu, Y as MediaGallery, Yt as __exportAll, Z as RoleSelectMenu, et as Separator, it as UserSelectMenu, l as parseDiscordTarget, nt as TextDisplay, ot as parseCustomId, q as File, rt as Thumbnail, tt as StringSelectMenu, z as CheckboxGroup } from "./chunk-
|
|
1
|
+
import { $ as Section, B as Label, G as ChannelSelectMenu, H as RadioGroup, J as LinkButton, K as Container, Q as Row, U as TextInput, V as Modal, W as Button, X as MentionableSelectMenu, Y as MediaGallery, Yt as __exportAll, Z as RoleSelectMenu, et as Separator, it as UserSelectMenu, l as parseDiscordTarget, nt as TextDisplay, ot as parseCustomId, q as File, rt as Thumbnail, tt as StringSelectMenu, z as CheckboxGroup } from "./chunk-CMVEczdm.js";
|
|
2
2
|
import { buildOutboundBaseSessionKey } from "openclaw/plugin-sdk/routing";
|
|
3
3
|
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
4
|
import { ButtonStyle, MessageFlags, TextInputStyle } from "discord-api-types/v10";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Yt as __exportAll } from "./chunk-
|
|
1
|
+
import { Yt as __exportAll } from "./chunk-CMVEczdm.js";
|
|
2
2
|
import { readProviderJsonResponse, 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";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { p as normalizeDiscordToken } from "./accounts-
|
|
1
|
+
import { p as normalizeDiscordToken } from "./accounts-DJTf1LtA.js";
|
|
2
2
|
import { n as DiscordApiError, r as fetchDiscord } from "./api-C43z8vUm.js";
|
|
3
3
|
import { readResponseWithLimit } from "openclaw/plugin-sdk/response-limit-runtime";
|
|
4
4
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
5
5
|
import { resolveFetch } from "openclaw/plugin-sdk/fetch-runtime";
|
|
6
|
-
import { fetchWithTimeout } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
6
|
+
import { fetchWithTimeout, runChannelProbe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
7
7
|
//#region extensions/discord/src/probe.ts
|
|
8
8
|
const DISCORD_API_BASE = "https://discord.com/api/v10";
|
|
9
9
|
const DISCORD_PROBE_GET_ME_LABEL = "discord.probe.getMe";
|
|
@@ -69,60 +69,50 @@ async function readDiscordProbeGetMeJson(response, timeoutMs, deadlineMs) {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
async function probeDiscord(token, timeoutMs, opts) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
elapsedMs: 0
|
|
81
|
-
};
|
|
82
|
-
if (!normalized) return {
|
|
83
|
-
...result,
|
|
84
|
-
error: "missing token",
|
|
85
|
-
elapsedMs: Date.now() - started
|
|
86
|
-
};
|
|
87
|
-
let res;
|
|
88
|
-
try {
|
|
89
|
-
const getMeUrl = `${DISCORD_API_BASE}/users/@me`;
|
|
90
|
-
const getMeDeadlineMs = Date.now() + timeoutMs;
|
|
91
|
-
res = await fetchWithTimeout(getMeUrl, { headers: { Authorization: `Bot ${normalized}` } }, timeoutMs, getResolvedFetch(fetcher));
|
|
92
|
-
if (!res.ok) {
|
|
93
|
-
result.status = res.status;
|
|
94
|
-
result.error = `getMe failed (${res.status})`;
|
|
95
|
-
return {
|
|
96
|
-
...result,
|
|
97
|
-
elapsedMs: Date.now() - started
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
const json = await readDiscordProbeGetMeJson(res, timeoutMs, getMeDeadlineMs);
|
|
101
|
-
result.ok = true;
|
|
102
|
-
result.bot = {
|
|
103
|
-
id: json.id ?? null,
|
|
104
|
-
username: json.username ?? null
|
|
105
|
-
};
|
|
106
|
-
if (includeApplication) {
|
|
107
|
-
const elapsedMs = Math.max(0, Date.now() - started);
|
|
108
|
-
const completionReserveMs = Math.min(DISCORD_PROBE_COMPLETION_RESERVE_MAX_MS, Math.max(1, Math.floor(timeoutMs / 10)));
|
|
109
|
-
const applicationTimeoutMs = Math.floor(timeoutMs - elapsedMs - completionReserveMs);
|
|
110
|
-
if (applicationTimeoutMs > 0) result.application = await fetchDiscordApplicationSummary(normalized, applicationTimeoutMs, fetcher) ?? void 0;
|
|
111
|
-
}
|
|
112
|
-
return {
|
|
113
|
-
...result,
|
|
114
|
-
elapsedMs: Date.now() - started
|
|
72
|
+
return await runChannelProbe(void 0, async ({ startedAt }) => {
|
|
73
|
+
const fetcher = opts?.fetcher ?? fetch;
|
|
74
|
+
const includeApplication = opts?.includeApplication === true;
|
|
75
|
+
const normalized = normalizeDiscordToken(token, "channels.discord.token");
|
|
76
|
+
const result = {
|
|
77
|
+
ok: false,
|
|
78
|
+
status: null,
|
|
79
|
+
error: null
|
|
115
80
|
};
|
|
116
|
-
|
|
117
|
-
return {
|
|
81
|
+
if (!normalized) return {
|
|
118
82
|
...result,
|
|
119
|
-
|
|
120
|
-
error: formatErrorMessage(err),
|
|
121
|
-
elapsedMs: Date.now() - started
|
|
83
|
+
error: "missing token"
|
|
122
84
|
};
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
85
|
+
let res;
|
|
86
|
+
try {
|
|
87
|
+
const getMeUrl = `${DISCORD_API_BASE}/users/@me`;
|
|
88
|
+
const getMeDeadlineMs = Date.now() + timeoutMs;
|
|
89
|
+
res = await fetchWithTimeout(getMeUrl, { headers: { Authorization: `Bot ${normalized}` } }, timeoutMs, getResolvedFetch(fetcher));
|
|
90
|
+
if (!res.ok) return {
|
|
91
|
+
...result,
|
|
92
|
+
status: res.status,
|
|
93
|
+
error: `getMe failed (${res.status})`
|
|
94
|
+
};
|
|
95
|
+
const json = await readDiscordProbeGetMeJson(res, timeoutMs, getMeDeadlineMs);
|
|
96
|
+
result.ok = true;
|
|
97
|
+
result.bot = {
|
|
98
|
+
id: json.id ?? null,
|
|
99
|
+
username: json.username ?? null
|
|
100
|
+
};
|
|
101
|
+
if (includeApplication) {
|
|
102
|
+
const elapsedMs = Math.max(0, Date.now() - startedAt);
|
|
103
|
+
const completionReserveMs = Math.min(DISCORD_PROBE_COMPLETION_RESERVE_MAX_MS, Math.max(1, Math.floor(timeoutMs / 10)));
|
|
104
|
+
const applicationTimeoutMs = Math.floor(timeoutMs - elapsedMs - completionReserveMs);
|
|
105
|
+
if (applicationTimeoutMs > 0) result.application = await fetchDiscordApplicationSummary(normalized, applicationTimeoutMs, fetcher) ?? void 0;
|
|
106
|
+
}
|
|
107
|
+
return result;
|
|
108
|
+
} finally {
|
|
109
|
+
if (res?.bodyUsed !== true) await res?.body?.cancel().catch(() => void 0);
|
|
110
|
+
}
|
|
111
|
+
}, (error) => ({
|
|
112
|
+
ok: false,
|
|
113
|
+
status: error instanceof Response ? error.status : null,
|
|
114
|
+
error: formatErrorMessage(error)
|
|
115
|
+
}));
|
|
126
116
|
}
|
|
127
117
|
/**
|
|
128
118
|
* Extract the application (bot user) ID from a Discord bot token by
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as resolveDiscordPrivilegedIntentsFromFlags, i as probeDiscord, n as fetchDiscordApplicationSummary, r as parseApplicationIdFromToken, t as fetchDiscordApplicationId } from "./probe-
|
|
1
|
+
import { a as resolveDiscordPrivilegedIntentsFromFlags, i as probeDiscord, n as fetchDiscordApplicationSummary, r as parseApplicationIdFromToken, t as fetchDiscordApplicationId } from "./probe-BYRdyuw1.js";
|
|
2
2
|
export { fetchDiscordApplicationId, fetchDiscordApplicationSummary, parseApplicationIdFromToken, probeDiscord, resolveDiscordPrivilegedIntentsFromFlags };
|