@openclaw/discord 2026.11.7 → 2026.11.10-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -0
- package/dist/.setup/{account-inspect-DGkdWwix.mjs → account-inspect-CSz5Qodj.mjs} +2 -3
- package/dist/.setup/{accounts-C_25wyxC.mjs → accounts-DtjvhJUj.mjs} +4 -8
- package/dist/.setup/{active-turn-thread-route-KvRTAVE3.mjs → active-turn-thread-route-DkPnk2x8.mjs} +1 -2
- package/dist/.setup/{allow-list-C3j0qLDp.mjs → allow-list-CkqpzPvP.mjs} +4 -8
- package/dist/.setup/{api-DYRggUgK.mjs → api-C4j_kC-2.mjs} +4 -6
- package/dist/.setup/{approval-handler.runtime-BN4W1r0o.mjs → approval-handler.runtime-DXzPFNvC.mjs} +10 -10
- package/dist/.setup/{approval-message-updates-DKsCfxSW.mjs → approval-message-updates-DqOXxPss.mjs} +3 -4
- package/dist/.setup/{audit-BL6EoUun.mjs → audit-B9vk3V2z.mjs} +6 -7
- package/dist/.setup/{channel-DdI2l55_.mjs → channel-CKffiPiV.mjs} +38 -41
- package/dist/.setup/{channel-access-9cyzozUP.mjs → channel-access-DhJhVrdZ.mjs} +1 -2
- package/dist/.setup/{channel.setup-kNWMxlgu.mjs → channel.setup-DmGdG9BH.mjs} +7 -10
- package/dist/.setup/{command-deploy-store-DFkBTViB.mjs → command-deploy-store-DPWiBMks.mjs} +1 -2
- package/dist/.setup/{command-owners-C7rUdqUX.mjs → command-owners-BzlhNBxA.mjs} +1 -2
- package/dist/.setup/{components-C1Phe3uw.mjs → components-GePlato3.mjs} +10 -16
- package/dist/.setup/{components.base-CiS0h_XP.mjs → components.base-C5sAPHe4.mjs} +1 -2
- package/dist/.setup/config-DDwcUaxT.mjs +20 -0
- package/dist/.setup/{config-schema-BNKN1cu5.mjs → config-schema-D3M1livr.mjs} +5 -7
- package/dist/.setup/{conversation-binding-route-K_jFbvi5.mjs → conversation-binding-route-CAaWWJdQ.mjs} +2 -3
- package/dist/.setup/conversation-fork-B6PiUuln.mjs +197 -0
- package/dist/.setup/{directory-config-Ble81PWH.mjs → directory-config-BXJuh9-J.mjs} +3 -4
- package/dist/.setup/{directory-live-CY2-qrHI.mjs → directory-live-B9UoQG9g.mjs} +9 -64
- package/dist/.setup/{discord-BRVFhk09.mjs → discord-cXPUdHQi.mjs} +98 -77
- package/dist/.setup/{doctor-RqH-6JB0.mjs → doctor-MTAWTgRa.mjs} +7 -8
- package/dist/.setup/{doctor-contract-Bwv8EuQ_.mjs → doctor-contract-Dstl3cMg.mjs} +2 -3
- package/dist/.setup/{endpoint-runtime-lf4DeLas.mjs → endpoint-runtime-BM3x-m6O.mjs} +1 -2
- package/dist/.setup/{guilds-BSnrns-F.mjs → guilds-DYBhgnfq.mjs} +3 -4
- package/dist/.setup/{handle-action-uD87h2FK.mjs → handle-action-El1ok7Ak.mjs} +13 -12
- package/dist/.setup/{handle-action.guild-admin-CqBx_3mG.mjs → handle-action.guild-admin-CxYfg02j.mjs} +7 -5
- package/dist/.setup/identity-link-B7KOBo_l.mjs +74 -0
- package/dist/.setup/{listeners-DnHLrLIN.mjs → listeners-DIyynRvV.mjs} +2 -3
- package/dist/.setup/{live-policy-config-y0Qy36X3.mjs → live-policy-config-DjIHWFla.mjs} +3 -5
- package/dist/.setup/{message-handler-CWL_u0X8.mjs → message-handler-DP3cAQCZ.mjs} +18 -17
- package/dist/.setup/{message-handler.preflight-83tpEdBG.mjs → message-handler.preflight-S5yc9UdR.mjs} +20 -27
- package/dist/.setup/{message-handler.preflight-pluralkit-Dhcx7Ifz.mjs → message-handler.preflight-pluralkit-BFntgVKc.mjs} +10 -14
- package/dist/.setup/{message-handler.process-BC-wNZwK.mjs → message-handler.process-bXE_4sq5.mjs} +56 -67
- package/dist/.setup/oauth-http-DdVyzSbo.mjs +40 -0
- package/dist/.setup/{outbound-payload-CK3_bDvK.mjs → outbound-payload-Dh6xCO6z.mjs} +18 -13
- package/dist/.setup/{outbound-session-route-Ay_DnOOl.mjs → outbound-session-route-G_fK5RAh.mjs} +22 -34
- package/dist/.setup/{output-activity-uBpMSX75.mjs → output-activity-CDgs2s3O.mjs} +1 -2
- package/dist/.setup/{pluralkit-B64dfq_j.mjs → pluralkit-DcXbHTpQ.mjs} +2 -3
- package/dist/.setup/{preflight-audio-C6QtD6HX.mjs → preflight-audio-r4BbaJxh.mjs} +1 -2
- package/dist/.setup/{presence-cache-Dq-3nH7R.mjs → presence-cache-B3xj3b0l.mjs} +1 -2
- package/dist/.setup/{probe-CbDJojNV.mjs → probe-CfGMZwFD.mjs} +5 -6
- package/dist/.setup/{provider-CRb3Myky.mjs → provider-BA4ysXXm.mjs} +200 -249
- package/dist/.setup/{provider-session.runtime-3cZpps3H.mjs → provider-session.runtime-Cr2oPicL.mjs} +3 -3
- package/dist/.setup/provider.runtime-D4BlQKDq.mjs +1 -0
- package/dist/.setup/{proxy-fetch-BzXwBAXt.mjs → proxy-fetch-B8cK6FLQ.mjs} +1 -2
- package/dist/.setup/{realtime-session.runtime-BRYpjS9P.mjs → realtime-session.runtime-DQvAKxj9.mjs} +15 -25
- package/dist/.setup/{receive-recovery-C3Ks4wAQ.mjs → receive-recovery-DV_v5ROf.mjs} +3 -6
- package/dist/.setup/{resolve-allowlist-common-B-S0wRIw.mjs → resolve-allowlist-common-CYdqBUgV.mjs} +3 -4
- package/dist/.setup/{resolve-channels-g16NM6Ho.mjs → resolve-channels-BNnyfCR8.mjs} +6 -7
- package/dist/.setup/{resolve-users-DAfOOXdy.mjs → resolve-users-CDMAGrzv.mjs} +5 -6
- package/dist/.setup/{rolldown-runtime-B4FMCO8f.mjs → rolldown-runtime-nwUcYXjP.mjs} +1 -2
- package/dist/.setup/{runtime--HZ9r3tF.mjs → runtime-CkeNX7ic.mjs} +59 -50
- package/dist/.setup/{runtime-BMgTyuwg.mjs → runtime-DSaHEGJd.mjs} +4 -24
- package/dist/.setup/{runtime-DgnVQ7zW.mjs → runtime-DcBvHOm1.mjs} +1 -2
- package/dist/.setup/{runtime-doctor-migrations-BPV-R4G9.mjs → runtime-doctor-migrations-BpV1jKk0.mjs} +5 -9
- package/dist/.setup/{secret-config-contract-B1kE4sDv.mjs → secret-config-contract-CP6teHec.mjs} +1 -2
- package/dist/.setup/{security-audit-BFT84Uny.mjs → security-audit-CTwisG7c.mjs} +3 -4
- package/dist/.setup/{security-contract-DNyyjTZZ.mjs → security-contract-D-o0iWDk.mjs} +1 -2
- package/dist/.setup/{security-doctor-nGgPm65L.mjs → security-doctor-4s7omTZd.mjs} +1 -2
- package/dist/.setup/{send-CtvwfZQ2.mjs → send-DKzwsZkm.mjs} +26 -31
- package/dist/.setup/{send.components-CtLtE0yD.mjs → send.components-CIZALYDP.mjs} +12 -14
- package/dist/.setup/{send.outbound-D58xXPgs.mjs → send.outbound-cQ4Ohmsc.mjs} +11 -16
- package/dist/.setup/send.permissions-BvH_Dr8p.mjs +369 -0
- package/dist/.setup/{send.receipt-DLOV4qx6.mjs → send.receipt-CZ7ks6g7.mjs} +64 -17
- package/dist/.setup/send.shared-D2lh737v.mjs +259 -0
- package/dist/.setup/{sender-identity-BbA7FNbr.mjs → sender-identity-Dt5ELjRN.mjs} +2 -3
- package/dist/.setup/{session-contract-BO5tlIdl.mjs → session-contract-Bq71MS78.mjs} +1 -2
- package/dist/.setup/{session-key-normalization-CCHGNSQw.mjs → session-key-normalization-Cfvze5hd.mjs} +1 -2
- package/dist/.setup/setup-plugin-api-BJt8tAAC.mjs +2 -0
- package/dist/.setup/{shared-Dv2DamaK.mjs → shared-Bf7ifHlc.mjs} +14 -17
- package/dist/.setup/{shared-interactive-DmzaoKOM.mjs → shared-interactive-DKBw4SNV.mjs} +7 -12
- package/dist/.setup/{subagent-hooks-yT45eTyz.mjs → subagent-hooks-CVmIOrAR.mjs} +4 -5
- package/dist/.setup/{system-events-Dlzp9Jcj.mjs → system-events-DB6p2H4l.mjs} +3 -4
- package/dist/.setup/{target-parsing-C-HyNxcE.mjs → target-parsing-BiuhcK9Q.mjs} +1 -2
- package/dist/.setup/{target-resolver-BzaZPBm9.mjs → target-resolver-48znkzky.mjs} +6 -7
- package/dist/.setup/{thread-binding-api-BDZJD4na.mjs → thread-binding-api-Drd4Zu-5.mjs} +1 -2
- package/dist/.setup/{thread-bindings-DRWhgKCc.mjs → thread-bindings-DTHVdmvF.mjs} +7 -10
- package/dist/.setup/{thread-bindings.manager-CWJKirn1.mjs → thread-bindings.manager-6EnH3YZh.mjs} +45 -30
- package/dist/.setup/{thread-bindings.session-updates-DzJrXc4w.mjs → thread-bindings.session-updates-BPO6pPzd.mjs} +9 -12
- package/dist/.setup/{threading-BbsPuT5G.mjs → threading-PC3IIaHd.mjs} +5 -7
- package/dist/.setup/{timeouts-cIxzatmv.mjs → timeouts-CT9hnmo4.mjs} +1 -2
- package/dist/.setup/{transcripts-source-DIW1fU_P.mjs → transcripts-source-C3F_ErM1.mjs} +20 -33
- package/dist/.setup/{typing-CNlSKY5S.mjs → typing-DAv4S2fI.mjs} +2 -3
- package/dist/.setup/{voice-runtime-oJ6BZs5D.mjs → voice-runtime-CZGbraKC.mjs} +28 -46
- package/dist/.source-module-urls/d6c089460280c5a04184542d6712e04545caeb1ebb290d3504377b4cc5e22fea.json +1 -1
- package/dist/account-inspect-api.js +2 -3
- package/dist/action-runtime-api.js +1 -1
- package/dist/activities-api.js +10 -50
- package/dist/api.js +21 -22
- package/dist/assets/embedded-app-sdk.mjs +1 -1
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/contract-api.js +1 -1
- package/dist/directory-contract-api.js +2 -3
- package/dist/doctor-contract-api.js +7 -8
- package/dist/index.js +1 -2
- package/dist/runtime-api.js +23 -22
- package/dist/runtime-setter-api.js +1 -1
- package/dist/secret-contract-api.js +1 -1
- package/dist/security-audit-contract-api.js +1 -1
- package/dist/security-contract-api.js +1 -1
- package/dist/session-key-api.js +1 -1
- package/dist/setup-entry.js +2 -3
- package/dist/setup-plugin-api.js +1 -1
- package/dist/src/voice/audio-worker.runtime.js +14 -26
- package/dist/subagent-hooks-api.js +2 -3
- package/dist/thread-binding-api.js +1 -1
- package/dist/transcripts-source-api.js +2 -3
- package/node_modules/@discord/embedded-app-sdk/output/lib/zod/lib/index.cjs +2 -3
- package/node_modules/@discord/embedded-app-sdk/output/lib/zod/lib/index.mjs +2 -3
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/package.json +2 -2
- package/node_modules/@types/node/zlib.d.ts +752 -0
- package/node_modules/typebox/build/format/date_time.d.mts +2 -1
- package/node_modules/typebox/build/format/date_time.mjs +12 -3
- package/node_modules/typebox/package.json +1 -1
- package/openclaw.plugin.json +7 -2
- package/package.json +5 -5
- package/dist/.setup/provider.runtime-tmkt3QOg.mjs +0 -1
- package/dist/.setup/send.shared-B_KKRrD7.mjs +0 -589
- package/dist/.setup/setup-plugin-api-ty5RJrMy.mjs +0 -2
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { i as listDiscordAccountIds, l as resolveDiscordAccount } from "./accounts-DtjvhJUj.mjs";
|
|
2
|
+
import { t as fetchDiscordJson } from "./oauth-http-DdVyzSbo.mjs";
|
|
3
|
+
import { t as resolveDiscordActivitiesConfig } from "./config-DDwcUaxT.mjs";
|
|
4
|
+
// extensions/discord/src/identity-link.ts
|
|
5
|
+
function credentials(cfg, accountId) {
|
|
6
|
+
if (!listDiscordAccountIds(cfg).includes(accountId)) return;
|
|
7
|
+
const account = resolveDiscordAccount({
|
|
8
|
+
cfg,
|
|
9
|
+
accountId
|
|
10
|
+
});
|
|
11
|
+
const oauth = resolveDiscordActivitiesConfig(account.config);
|
|
12
|
+
const applicationId = oauth.enabled ? oauth.applicationId ?? account.config.applicationId : void 0;
|
|
13
|
+
return account.enabled && oauth.enabled && applicationId ? {
|
|
14
|
+
applicationId,
|
|
15
|
+
clientSecret: oauth.clientSecret
|
|
16
|
+
} : void 0;
|
|
17
|
+
}
|
|
18
|
+
const discordIdentityLink = { async prepare(cfg, accountId) {
|
|
19
|
+
const credential = credentials(cfg, accountId);
|
|
20
|
+
if (!credential) return;
|
|
21
|
+
return {
|
|
22
|
+
isCurrent(current) {
|
|
23
|
+
const value = credentials(current, accountId);
|
|
24
|
+
return value?.applicationId === credential.applicationId && value?.clientSecret === credential.clientSecret;
|
|
25
|
+
},
|
|
26
|
+
authorizationUrl({ state, redirectUri }) {
|
|
27
|
+
const url = new URL("https://discord.com/oauth2/authorize");
|
|
28
|
+
url.search = new URLSearchParams({
|
|
29
|
+
client_id: credential.applicationId,
|
|
30
|
+
redirect_uri: redirectUri,
|
|
31
|
+
response_type: "code",
|
|
32
|
+
scope: "identify",
|
|
33
|
+
state,
|
|
34
|
+
prompt: "consent"
|
|
35
|
+
}).toString();
|
|
36
|
+
return url.href;
|
|
37
|
+
},
|
|
38
|
+
async exchange({ code, redirectUri, signal, assertCurrent }) {
|
|
39
|
+
assertCurrent();
|
|
40
|
+
const token = await fetchDiscordJson({
|
|
41
|
+
url: "https://discord.com/api/oauth2/token",
|
|
42
|
+
auditContext: "discord-profile-link-token",
|
|
43
|
+
init: {
|
|
44
|
+
method: "POST",
|
|
45
|
+
signal,
|
|
46
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
47
|
+
body: new URLSearchParams({
|
|
48
|
+
grant_type: "authorization_code",
|
|
49
|
+
client_id: credential.applicationId,
|
|
50
|
+
client_secret: credential.clientSecret,
|
|
51
|
+
code,
|
|
52
|
+
redirect_uri: redirectUri
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
assertCurrent();
|
|
57
|
+
const accessToken = token.body?.access_token;
|
|
58
|
+
if (!token.ok || typeof accessToken !== "string" || !accessToken) throw new Error("Discord sign-in could not be verified. Try connecting again.");
|
|
59
|
+
const user = await fetchDiscordJson({
|
|
60
|
+
url: "https://discord.com/api/v10/users/@me",
|
|
61
|
+
auditContext: "discord-profile-link-user",
|
|
62
|
+
init: {
|
|
63
|
+
signal,
|
|
64
|
+
headers: { Authorization: "Bearer " + accessToken }
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
assertCurrent();
|
|
68
|
+
const senderId = user.body?.id;
|
|
69
|
+
if (!user.ok || typeof senderId !== "string" || !/^[0-9]{17,20}$/.test(senderId) || user.body?.bot === true) throw new Error("Discord did not return a verified personal account. Try connecting again.");
|
|
70
|
+
return { senderId };
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
} };
|
|
74
|
+
export { discordIdentityLink };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as discord_exports } from "./discord-
|
|
1
|
+
import { t as discord_exports } from "./discord-cXPUdHQi.mjs";
|
|
2
2
|
import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env";
|
|
3
3
|
import { formatErrorMessage } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
4
|
-
|
|
4
|
+
// extensions/discord/src/voice/listeners.ts
|
|
5
5
|
const logger = createSubsystemLogger("discord/voice");
|
|
6
6
|
function startAutoJoin(operation, context = "") {
|
|
7
7
|
operation().catch((err) => logger.warn(`discord voice: autoJoin${context} failed: ${formatErrorMessage(err)}`));
|
|
@@ -43,5 +43,4 @@ var DiscordVoiceStateUpdateListener = class {
|
|
|
43
43
|
await this.manager.handleVoiceStateUpdate(data, transition ? transition.previous ?? null : void 0);
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
|
-
//#endregion
|
|
47
46
|
export { DiscordVoiceGuildCreateListener, DiscordVoiceReadyListener, DiscordVoiceResumedListener, DiscordVoiceStateUpdateListener };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as normalizeDiscordAllowList } from "./allow-list-
|
|
1
|
+
import { i as normalizeDiscordAllowList } from "./allow-list-CkqpzPvP.mjs";
|
|
2
2
|
import { defineStableChannelIngressIdentity } from "openclaw/plugin-sdk/channel-ingress-runtime";
|
|
3
|
-
|
|
3
|
+
// extensions/discord/src/monitor/ingress-identity.ts
|
|
4
4
|
const DISCORD_ALLOW_LIST_PREFIXES = [
|
|
5
5
|
"discord:",
|
|
6
6
|
"user:",
|
|
@@ -54,8 +54,7 @@ const discordIngressIdentity = defineStableChannelIngressIdentity({
|
|
|
54
54
|
sensitivity: "pii"
|
|
55
55
|
}))
|
|
56
56
|
});
|
|
57
|
-
|
|
58
|
-
//#region extensions/discord/src/live-policy-config.ts
|
|
57
|
+
// extensions/discord/src/live-policy-config.ts
|
|
59
58
|
/** Account policy consumed at inbound admission, without replacing the transport. */
|
|
60
59
|
function selectDiscordLivePolicyConfig(config) {
|
|
61
60
|
return {
|
|
@@ -68,5 +67,4 @@ function selectDiscordLivePolicyConfig(config) {
|
|
|
68
67
|
dangerouslyAllowNameMatching: config.dangerouslyAllowNameMatching
|
|
69
68
|
};
|
|
70
69
|
}
|
|
71
|
-
//#endregion
|
|
72
70
|
export { discordIngressIdentity as n, selectDiscordLivePolicyConfig as t };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { q as withDiscordRequestAuthority } from "./discord-
|
|
2
|
-
import { i as resolveDiscordEndpointMediaGuard, n as getDiscordEndpointRuntime } from "./endpoint-runtime-
|
|
3
|
-
import { t as getDiscordRuntime } from "./runtime-
|
|
4
|
-
import { D as createMessageDispatchData, E as createDiscordLivePolicyReader } from "./provider-
|
|
5
|
-
import { E as hasDiscordMessageStickers, T as resolveDiscordCdnPolicy, b as resolveDiscordMessageText, j as resolveDiscordMessageChannelId, k as resolveDiscordReferencedReplyMessageId } from "./transcripts-source-
|
|
1
|
+
import { q as withDiscordRequestAuthority } from "./discord-cXPUdHQi.mjs";
|
|
2
|
+
import { i as resolveDiscordEndpointMediaGuard, n as getDiscordEndpointRuntime } from "./endpoint-runtime-BM3x-m6O.mjs";
|
|
3
|
+
import { t as getDiscordRuntime } from "./runtime-DcBvHOm1.mjs";
|
|
4
|
+
import { D as createMessageDispatchData, E as createDiscordLivePolicyReader } from "./provider-BA4ysXXm.mjs";
|
|
5
|
+
import { E as hasDiscordMessageStickers, T as resolveDiscordCdnPolicy, b as resolveDiscordMessageText, j as resolveDiscordMessageChannelId, k as resolveDiscordReferencedReplyMessageId } from "./transcripts-source-C3F_ErM1.mjs";
|
|
6
6
|
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
7
7
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
8
8
|
import { danger } from "openclaw/plugin-sdk/runtime-env";
|
|
@@ -17,7 +17,7 @@ import { DEFAULT_INGRESS_RETRY_MAX_ATTEMPTS, createChannelIngressError, createCh
|
|
|
17
17
|
import { racePromiseWithAbortSignal } from "openclaw/plugin-sdk/time-runtime";
|
|
18
18
|
import { fanInChannelIngressLifecycles, prepareChannelIngressEvent } from "openclaw/plugin-sdk/channel-ingress-runtime";
|
|
19
19
|
import { createChannelInboundDebouncer, resolveInboundDebounceMs, shouldDebounceTextInbound } from "openclaw/plugin-sdk/channel-inbound";
|
|
20
|
-
|
|
20
|
+
// extensions/discord/src/monitor/ingress.ts
|
|
21
21
|
const DISCORD_INGRESS_PAYLOAD_VERSION = 1;
|
|
22
22
|
const DISCORD_INGRESS_DRAIN_INTERVAL_MS = 1e3;
|
|
23
23
|
const DiscordIngressPayloadError = createChannelIngressError("DiscordIngressPayloadError");
|
|
@@ -64,6 +64,7 @@ function createDiscordIngressMonitor(params) {
|
|
|
64
64
|
const queue = params.queue ?? getDiscordRuntime().state.openChannelIngressQueue({ accountId: params.accountId });
|
|
65
65
|
const monitor = createChannelIngressMonitor({
|
|
66
66
|
queue,
|
|
67
|
+
abortSignal: params.abortSignal,
|
|
67
68
|
inspect: inspectDiscordMessage,
|
|
68
69
|
prepareAdmission: async (rawMessage, { receivedAt, signal }) => {
|
|
69
70
|
const prepared = await prepareChannelIngressEvent(rawMessage, {
|
|
@@ -107,6 +108,10 @@ function createDiscordIngressMonitor(params) {
|
|
|
107
108
|
},
|
|
108
109
|
appendRetryDelaysMs: [0],
|
|
109
110
|
drain: {
|
|
111
|
+
prioritizePending: ({ payload }) => {
|
|
112
|
+
const raw = payload?.rawMessage;
|
|
113
|
+
return Boolean(params.botUserId && raw?.guild_id && Date.parse(raw.timestamp) >= Date.now() - 9e5 && Array.isArray(raw.mentions) && raw.mentions.some((user) => user?.id === params.botUserId));
|
|
114
|
+
},
|
|
110
115
|
deferredLaneOccupancy: "release",
|
|
111
116
|
retryPolicy: {
|
|
112
117
|
maxAttempts: DEFAULT_INGRESS_RETRY_MAX_ATTEMPTS,
|
|
@@ -139,8 +144,7 @@ function createDiscordIngressMonitor(params) {
|
|
|
139
144
|
stop: monitor.stop
|
|
140
145
|
};
|
|
141
146
|
}
|
|
142
|
-
|
|
143
|
-
//#region extensions/discord/src/monitor/message-avatar.ts
|
|
147
|
+
// extensions/discord/src/monitor/message-avatar.ts
|
|
144
148
|
const DISCORD_AVATAR_MAX_BYTES = 262144;
|
|
145
149
|
const DISCORD_AVATAR_CACHE_MAX_ENTRIES = 128;
|
|
146
150
|
const DISCORD_GUILD_ICON_TTL_MS = 3e5;
|
|
@@ -194,7 +198,7 @@ function createDiscordAvatarResolver() {
|
|
|
194
198
|
client.fetchGuild(guildId).then((guild) => {
|
|
195
199
|
const hash = guild.icon ?? null;
|
|
196
200
|
setBoundedEntry(guildIcons, guildId, {
|
|
197
|
-
expiresAt:
|
|
201
|
+
expiresAt: performance.now() + DISCORD_GUILD_ICON_TTL_MS,
|
|
198
202
|
hash
|
|
199
203
|
});
|
|
200
204
|
if (hash) resolveSavedAvatar(`${conversationId}\0${hash}`, discordAvatarUrl("icons", guildId, hash), endpointRuntime);
|
|
@@ -211,14 +215,13 @@ function createDiscordAvatarResolver() {
|
|
|
211
215
|
return hash ? resolveSavedAvatar(`${params.conversationId}\0${hash}`, discordAvatarUrl("avatars", params.author.id, hash), endpointRuntime) : void 0;
|
|
212
216
|
}
|
|
213
217
|
const guildIcon = guildIcons.get(params.guildId);
|
|
214
|
-
if (!guildIcon || guildIcon.expiresAt <=
|
|
218
|
+
if (!guildIcon || guildIcon.expiresAt <= performance.now()) refreshGuildIcon(params.client, params.guildId, params.conversationId, endpointRuntime);
|
|
215
219
|
return guildIcon?.hash ? resolveSavedAvatar(`${params.conversationId}\0${guildIcon.hash}`, discordAvatarUrl("icons", params.guildId, guildIcon.hash), endpointRuntime) : void 0;
|
|
216
220
|
} };
|
|
217
221
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
const
|
|
221
|
-
const loadMessageProcessRuntime = createLazyRuntimeModule(() => import("./message-handler.process-BC-wNZwK.mjs"));
|
|
222
|
+
// extensions/discord/src/monitor/message-dispatcher.ts
|
|
223
|
+
const loadMessagePreflightRuntime = createLazyRuntimeModule(() => import("./message-handler.preflight-S5yc9UdR.mjs"));
|
|
224
|
+
const loadMessageProcessRuntime = createLazyRuntimeModule(() => import("./message-handler.process-bXE_4sq5.mjs"));
|
|
222
225
|
function createDiscordMessageDispatcher(params) {
|
|
223
226
|
const readPolicy = params.readPolicy ?? createDiscordLivePolicyReader({
|
|
224
227
|
...params,
|
|
@@ -495,8 +498,7 @@ function createDiscordMessageDispatcher(params) {
|
|
|
495
498
|
};
|
|
496
499
|
return handler;
|
|
497
500
|
}
|
|
498
|
-
|
|
499
|
-
//#region extensions/discord/src/monitor/message-handler.ts
|
|
501
|
+
// extensions/discord/src/monitor/message-handler.ts
|
|
500
502
|
function createDiscordMessageHandler(params) {
|
|
501
503
|
const dispatcher = createDiscordMessageDispatcher(params);
|
|
502
504
|
const ingress = createDiscordIngressMonitor({
|
|
@@ -528,5 +530,4 @@ function createDiscordMessageHandler(params) {
|
|
|
528
530
|
};
|
|
529
531
|
return handler;
|
|
530
532
|
}
|
|
531
|
-
//#endregion
|
|
532
533
|
export { createDiscordMessageHandler as t };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { c as resolveDefaultDiscordAccountId } from "./accounts-
|
|
2
|
-
import { h as Message, k as getChannelMessage, t as discord_exports } from "./discord-
|
|
3
|
-
import { S as formatDiscordUserTag, a as normalizeDiscordDisplaySlug, f as resolveDiscordGuildEntry, h as resolveDiscordMentionPolicy, l as resolveDiscordChannelConfigWithFallback, o as normalizeDiscordSlug, p as resolveDiscordMemberAccessState } from "./allow-list-
|
|
4
|
-
import { n as DISCORD_ATTACHMENT_TOTAL_TIMEOUT_MS, t as DISCORD_ATTACHMENT_IDLE_TIMEOUT_MS } from "./timeouts-
|
|
5
|
-
import { _ as resolveDiscordConversationIdentity, h as resolveDiscordEffectiveRoute, m as resolveDiscordConversationRoute, p as buildDiscordRoutePeer, y as resolveDiscordRuntimeBindingConversationId } from "./outbound-session-route-
|
|
6
|
-
import { n as resolveDiscordConversationBindingRouteAsync } from "./conversation-binding-route-
|
|
7
|
-
import { n as resolveDiscordChannelNameSafe } from "./channel-access-
|
|
8
|
-
import { A as resolveDiscordTextCommandAccess, T as handleDiscordDmCommandDecision, k as resolveDiscordDmCommandAccess, n as resolveDiscordPreflightChannelAccess } from "./provider-
|
|
9
|
-
import { A as resolveDiscordChannelInfo, C as resolveMediaList, D as resolveDiscordMessageStickers, O as resolveDiscordReferencedReplyMessage, S as resolveForwardedMediaList, _ as resolveDiscordMessageBatch, b as resolveDiscordMessageText, j as resolveDiscordMessageChannelId, v as resolveDiscordMessageHistoryText, y as resolveDiscordMessageMentionDocuments } from "./transcripts-source-
|
|
10
|
-
import { n as resolveDiscordWebhookId, t as resolveDiscordSenderIdentity } from "./sender-identity-
|
|
11
|
-
import { a as createDiscordHistorySenderProvenance, c as hasRawDiscordUserMention, d as matchesActiveDiscordMentionPatterns, f as resolveDiscordMentionState, i as loadSystemEventsRuntime, l as isBoundThreadBotSystemMessage, n as loadDiscordThreadingRuntime, p as shouldIgnoreBoundThreadWebhookMessage, r as loadPreflightAudioRuntime, s as resolveDiscordHistoryMediaIds, t as resolveDiscordPreflightPluralKitInfo, u as isDiscordThreadChannelMessage } from "./message-handler.preflight-pluralkit-
|
|
1
|
+
import { c as resolveDefaultDiscordAccountId } from "./accounts-DtjvhJUj.mjs";
|
|
2
|
+
import { h as Message, k as getChannelMessage, t as discord_exports } from "./discord-cXPUdHQi.mjs";
|
|
3
|
+
import { S as formatDiscordUserTag, a as normalizeDiscordDisplaySlug, f as resolveDiscordGuildEntry, h as resolveDiscordMentionPolicy, l as resolveDiscordChannelConfigWithFallback, o as normalizeDiscordSlug, p as resolveDiscordMemberAccessState } from "./allow-list-CkqpzPvP.mjs";
|
|
4
|
+
import { n as DISCORD_ATTACHMENT_TOTAL_TIMEOUT_MS, t as DISCORD_ATTACHMENT_IDLE_TIMEOUT_MS } from "./timeouts-CT9hnmo4.mjs";
|
|
5
|
+
import { _ as resolveDiscordConversationIdentity, h as resolveDiscordEffectiveRoute, m as resolveDiscordConversationRoute, p as buildDiscordRoutePeer, y as resolveDiscordRuntimeBindingConversationId } from "./outbound-session-route-G_fK5RAh.mjs";
|
|
6
|
+
import { n as resolveDiscordConversationBindingRouteAsync } from "./conversation-binding-route-CAaWWJdQ.mjs";
|
|
7
|
+
import { n as resolveDiscordChannelNameSafe } from "./channel-access-DhJhVrdZ.mjs";
|
|
8
|
+
import { A as resolveDiscordTextCommandAccess, T as handleDiscordDmCommandDecision, k as resolveDiscordDmCommandAccess, n as resolveDiscordPreflightChannelAccess } from "./provider-BA4ysXXm.mjs";
|
|
9
|
+
import { A as resolveDiscordChannelInfo, C as resolveMediaList, D as resolveDiscordMessageStickers, O as resolveDiscordReferencedReplyMessage, S as resolveForwardedMediaList, _ as resolveDiscordMessageBatch, b as resolveDiscordMessageText, j as resolveDiscordMessageChannelId, v as resolveDiscordMessageHistoryText, y as resolveDiscordMessageMentionDocuments } from "./transcripts-source-C3F_ErM1.mjs";
|
|
10
|
+
import { n as resolveDiscordWebhookId, t as resolveDiscordSenderIdentity } from "./sender-identity-Dt5ELjRN.mjs";
|
|
11
|
+
import { a as createDiscordHistorySenderProvenance, c as hasRawDiscordUserMention, d as matchesActiveDiscordMentionPatterns, f as resolveDiscordMentionState, i as loadSystemEventsRuntime, l as isBoundThreadBotSystemMessage, n as loadDiscordThreadingRuntime, p as shouldIgnoreBoundThreadWebhookMessage, r as loadPreflightAudioRuntime, s as resolveDiscordHistoryMediaIds, t as resolveDiscordPreflightPluralKitInfo, u as isDiscordThreadChannelMessage } from "./message-handler.preflight-pluralkit-BFntgVKc.mjs";
|
|
12
12
|
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
13
13
|
import { getChildLogger, logVerbose } from "openclaw/plugin-sdk/runtime-env";
|
|
14
14
|
import { MessageReferenceType, MessageType } from "discord-api-types/v10";
|
|
@@ -20,13 +20,13 @@ import { mimeTypeFromFilePath } from "openclaw/plugin-sdk/media-mime";
|
|
|
20
20
|
import { isDangerousNameMatchingEnabled } from "openclaw/plugin-sdk/dangerous-name-runtime";
|
|
21
21
|
import { buildMentionRegexes, classifyChannelInboundEvent, logInboundDrop, recordChannelBotPairLoopAndCheckSuppression, resolveGroupThreadMentionFacts, resolveInboundMentionDecision, resolveUnmentionedGroupInboundPolicy, toHistoryMediaEntries, toInboundMediaFactsWithMetadata } from "openclaw/plugin-sdk/channel-inbound";
|
|
22
22
|
import { enqueueRoutedSystemEvent } from "openclaw/plugin-sdk/system-event-runtime";
|
|
23
|
+
import { shouldHandleTextCommands } from "openclaw/plugin-sdk/command-surface";
|
|
23
24
|
import { hasControlCommand } from "openclaw/plugin-sdk/command-detection";
|
|
24
25
|
import { isAbortRequestText } from "openclaw/plugin-sdk/command-primitives-runtime";
|
|
25
|
-
import { shouldHandleTextCommands } from "openclaw/plugin-sdk/command-surface";
|
|
26
26
|
import { createChannelHistoryWindow } from "openclaw/plugin-sdk/reply-history";
|
|
27
|
-
|
|
27
|
+
// extensions/discord/src/monitor/message-handler.dm-preflight.ts
|
|
28
28
|
const loadConversationRuntime$1 = createLazyRuntimeModule(() => import("openclaw/plugin-sdk/conversation-binding-runtime"));
|
|
29
|
-
const loadDiscordSendRuntime = createLazyRuntimeModule(() => import("./send-
|
|
29
|
+
const loadDiscordSendRuntime = createLazyRuntimeModule(() => import("./send-DKzwsZkm.mjs").then((n) => n.t));
|
|
30
30
|
async function resolveDiscordDmPreflightAccess(params) {
|
|
31
31
|
if (params.dmPolicy === "disabled") {
|
|
32
32
|
logVerbose("discord: drop dm (dmPolicy: disabled)");
|
|
@@ -108,8 +108,7 @@ async function resolveDiscordDmPreflightAccess(params) {
|
|
|
108
108
|
});
|
|
109
109
|
return null;
|
|
110
110
|
}
|
|
111
|
-
|
|
112
|
-
//#region extensions/discord/src/monitor/message-handler.hydration.ts
|
|
111
|
+
// extensions/discord/src/monitor/message-handler.hydration.ts
|
|
113
112
|
function shouldHydrateDiscordMessagePayload(message) {
|
|
114
113
|
let currentText;
|
|
115
114
|
try {
|
|
@@ -180,8 +179,7 @@ async function hydrateDiscordMessageIfNeeded(params) {
|
|
|
180
179
|
})
|
|
181
180
|
};
|
|
182
181
|
}
|
|
183
|
-
|
|
184
|
-
//#region extensions/discord/src/monitor/message-handler.preflight-channel-context.ts
|
|
182
|
+
// extensions/discord/src/monitor/message-handler.preflight-channel-context.ts
|
|
185
183
|
function resolveDiscordPreflightChannelContext(params) {
|
|
186
184
|
const threadName = params.threadChannel?.name;
|
|
187
185
|
const displayChannelName = threadName ?? params.channelName;
|
|
@@ -204,8 +202,7 @@ function resolveDiscordPreflightChannelContext(params) {
|
|
|
204
202
|
}) : null
|
|
205
203
|
};
|
|
206
204
|
}
|
|
207
|
-
|
|
208
|
-
//#region extensions/discord/src/monitor/message-handler.preflight-history.ts
|
|
205
|
+
// extensions/discord/src/monitor/message-handler.preflight-history.ts
|
|
209
206
|
function buildDiscordPreflightHistoryEntry(params) {
|
|
210
207
|
const textForHistory = resolveDiscordMessageHistoryText(params.message, { includeForwarded: true });
|
|
211
208
|
return params.isGuildMessage && params.historyLimit > 0 && textForHistory ? {
|
|
@@ -217,8 +214,7 @@ function buildDiscordPreflightHistoryEntry(params) {
|
|
|
217
214
|
senderProvenance: createDiscordHistorySenderProvenance(params)
|
|
218
215
|
} : void 0;
|
|
219
216
|
}
|
|
220
|
-
|
|
221
|
-
//#region extensions/discord/src/monitor/message-handler.preflight-thread.ts
|
|
217
|
+
// extensions/discord/src/monitor/message-handler.preflight-thread.ts
|
|
222
218
|
async function resolveDiscordPreflightThreadContext(params) {
|
|
223
219
|
const { resolveDiscordThreadChannel, resolveDiscordThreadParentInfo } = await loadDiscordThreadingRuntime();
|
|
224
220
|
const earlyThreadChannel = resolveDiscordThreadChannel(params);
|
|
@@ -236,8 +232,7 @@ async function resolveDiscordPreflightThreadContext(params) {
|
|
|
236
232
|
earlyThreadParentType: parentInfo.type
|
|
237
233
|
};
|
|
238
234
|
}
|
|
239
|
-
|
|
240
|
-
//#region extensions/discord/src/monitor/message-handler.routing-preflight.ts
|
|
235
|
+
// extensions/discord/src/monitor/message-handler.routing-preflight.ts
|
|
241
236
|
const loadConversationRuntime = createLazyRuntimeModule(() => import("openclaw/plugin-sdk/conversation-binding-runtime"));
|
|
242
237
|
async function resolveDiscordPreflightRoute(params) {
|
|
243
238
|
const conversationRuntime = await loadConversationRuntime();
|
|
@@ -287,8 +282,7 @@ async function resolveDiscordPreflightRoute(params) {
|
|
|
287
282
|
baseSessionKey: effectiveRoute.sessionKey
|
|
288
283
|
};
|
|
289
284
|
}
|
|
290
|
-
|
|
291
|
-
//#region extensions/discord/src/monitor/message-handler.preflight.ts
|
|
285
|
+
// extensions/discord/src/monitor/message-handler.preflight.ts
|
|
292
286
|
const DISCORD_HISTORY_MEDIA_MAX_ATTACHMENTS = 4;
|
|
293
287
|
const DISCORD_HISTORY_MEDIA_MAX_BYTES = 10485760;
|
|
294
288
|
const DISCORD_HISTORY_MEDIA_IDLE_TIMEOUT_MS = 1e3;
|
|
@@ -817,5 +811,4 @@ async function preflightDiscordMessage(params) {
|
|
|
817
811
|
canDetectMention
|
|
818
812
|
};
|
|
819
813
|
}
|
|
820
|
-
//#endregion
|
|
821
814
|
export { preflightDiscordMessage };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { w as isDiscordThreadChannelType } from "./allow-list-
|
|
2
|
-
import { D as resolveDiscordMessageStickers } from "./transcripts-source-
|
|
1
|
+
import { w as isDiscordThreadChannelType } from "./allow-list-CkqpzPvP.mjs";
|
|
2
|
+
import { D as resolveDiscordMessageStickers } from "./transcripts-source-C3F_ErM1.mjs";
|
|
3
3
|
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
4
4
|
import { logVerbose } from "openclaw/plugin-sdk/runtime-env";
|
|
5
5
|
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
6
6
|
import { findCodeRegions, isInsideCode } from "openclaw/plugin-sdk/text-chunking";
|
|
7
7
|
import { filterSupplementalContextItems } from "openclaw/plugin-sdk/security-runtime";
|
|
8
8
|
import { implicitMentionKindWhen, matchesMentionWithExplicit, normalizeMentionText } from "openclaw/plugin-sdk/channel-inbound";
|
|
9
|
-
|
|
9
|
+
// extensions/discord/src/monitor/message-handler.preflight-helpers.ts
|
|
10
10
|
const DISCORD_BOUND_THREAD_SYSTEM_PREFIXES = [
|
|
11
11
|
"⚙️",
|
|
12
12
|
"🤖",
|
|
@@ -74,8 +74,7 @@ function shouldIgnoreBoundThreadWebhookMessage(params) {
|
|
|
74
74
|
const threadId = normalizeOptionalString(params.threadId) ?? "";
|
|
75
75
|
return Boolean(threadId && params.threadBinding);
|
|
76
76
|
}
|
|
77
|
-
|
|
78
|
-
//#region extensions/discord/src/monitor/message-handler.history.ts
|
|
77
|
+
// extensions/discord/src/monitor/message-handler.history.ts
|
|
79
78
|
function createDiscordHistorySenderProvenance(params) {
|
|
80
79
|
return Object.freeze({
|
|
81
80
|
id: params.sender.id,
|
|
@@ -96,14 +95,12 @@ function filterDiscordHistoryEntriesForContext(params) {
|
|
|
96
95
|
function resolveDiscordHistoryMediaIds(message) {
|
|
97
96
|
return [...(message.attachments ?? []).map((attachment) => `attachment:${attachment.id}`), ...resolveDiscordMessageStickers(message).map((sticker) => `sticker:${sticker.id}`)];
|
|
98
97
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
const
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
//#endregion
|
|
106
|
-
//#region extensions/discord/src/monitor/message-handler.preflight-pluralkit.ts
|
|
98
|
+
// extensions/discord/src/monitor/message-handler.preflight-runtime.ts
|
|
99
|
+
const loadPluralKitRuntime = createLazyRuntimeModule(() => import("./pluralkit-DcXbHTpQ.mjs").then((n) => n.n));
|
|
100
|
+
const loadPreflightAudioRuntime = createLazyRuntimeModule(() => import("./preflight-audio-r4BbaJxh.mjs"));
|
|
101
|
+
const loadSystemEventsRuntime = createLazyRuntimeModule(() => import("./system-events-DB6p2H4l.mjs"));
|
|
102
|
+
const loadDiscordThreadingRuntime = createLazyRuntimeModule(() => import("./threading-PC3IIaHd.mjs").then((n) => n.t));
|
|
103
|
+
// extensions/discord/src/monitor/message-handler.preflight-pluralkit.ts
|
|
107
104
|
async function resolveDiscordPreflightPluralKitInfo(params) {
|
|
108
105
|
if (!params.config?.enabled || !params.webhookId) return null;
|
|
109
106
|
try {
|
|
@@ -119,5 +116,4 @@ async function resolveDiscordPreflightPluralKitInfo(params) {
|
|
|
119
116
|
return null;
|
|
120
117
|
}
|
|
121
118
|
}
|
|
122
|
-
//#endregion
|
|
123
119
|
export { createDiscordHistorySenderProvenance as a, hasRawDiscordUserMention as c, matchesActiveDiscordMentionPatterns as d, resolveDiscordMentionState as f, loadSystemEventsRuntime as i, isBoundThreadBotSystemMessage as l, loadDiscordThreadingRuntime as n, filterDiscordHistoryEntriesForContext as o, shouldIgnoreBoundThreadWebhookMessage as p, loadPreflightAudioRuntime as r, resolveDiscordHistoryMediaIds as s, resolveDiscordPreflightPluralKitInfo as t, isDiscordThreadChannelMessage as u };
|
package/dist/.setup/{message-handler.process-BC-wNZwK.mjs → message-handler.process-bXE_4sq5.mjs}
RENAMED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { m as resolveDiscordMaxLinesPerMessage } from "./accounts-
|
|
2
|
-
import {
|
|
3
|
-
import { D as editChannelMessage, E as deleteChannelMessage, K as captureDiscordRequestAuthority, P as getGuildMember, h as Message, q as withDiscordRequestAuthority, t as discord_exports } from "./discord-
|
|
4
|
-
import { i as normalizeDiscordAllowList, o as normalizeDiscordSlug } from "./allow-list-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { n as
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import { t as
|
|
1
|
+
import { m as resolveDiscordMaxLinesPerMessage } from "./accounts-DtjvhJUj.mjs";
|
|
2
|
+
import { d as createDiscordRestClient, f as createDiscordRuntimeAccountContext } from "./send.permissions-BvH_Dr8p.mjs";
|
|
3
|
+
import { D as editChannelMessage, E as deleteChannelMessage, K as captureDiscordRequestAuthority, P as getGuildMember, h as Message, q as withDiscordRequestAuthority, t as discord_exports } from "./discord-cXPUdHQi.mjs";
|
|
4
|
+
import { i as normalizeDiscordAllowList, o as normalizeDiscordSlug } from "./allow-list-CkqpzPvP.mjs";
|
|
5
|
+
import { S as chunkDiscordTextWithMode, y as createDiscordRetryRunner } from "./send.receipt-CZ7ks6g7.mjs";
|
|
6
|
+
import { b as resolveDiscordMessageFlags, u as resolveDiscordTargetChannelId } from "./send.shared-D2lh737v.mjs";
|
|
7
|
+
import { n as resolveDiscordChannelId } from "./target-parsing-BiuhcK9Q.mjs";
|
|
8
|
+
import { a as removeReactionDiscord, r as reactMessageDiscord } from "./send-DKzwsZkm.mjs";
|
|
9
|
+
import { o as discordTextHasBroadcastMention } from "./send.outbound-cQ4Ohmsc.mjs";
|
|
10
|
+
import { n as DISCORD_ATTACHMENT_TOTAL_TIMEOUT_MS, t as DISCORD_ATTACHMENT_IDLE_TIMEOUT_MS } from "./timeouts-CT9hnmo4.mjs";
|
|
11
|
+
import { S as discordInboundEventDelivery, _ as resolveDiscordConversationIdentity, p as buildDiscordRoutePeer } from "./outbound-session-route-G_fK5RAh.mjs";
|
|
12
|
+
import { t as DISCORD_TEXT_CHUNK_LIMIT } from "./outbound-payload-Dh6xCO6z.mjs";
|
|
13
|
+
import { C as buildDiscordInboundAccessContext, c as formatDiscordReplySkip, d as buildGuildLabel, f as resolveReplyContext, l as sanitizeDiscordFrontChannelReplyPayloads, o as deliverDiscordReply, s as formatDiscordReplyDeliveryFailure, u as buildDirectLabel, w as createDiscordSupplementalContextAccessChecker } from "./provider-BA4ysXXm.mjs";
|
|
14
|
+
import { D as resolveDiscordMessageStickers, b as resolveDiscordMessageText, h as resolveDiscordThreadStarter, k as resolveDiscordReferencedReplyMessageId, v as resolveDiscordMessageHistoryText, w as resolveReferencedReplyMediaList, x as formatDiscordMediaText } from "./transcripts-source-C3F_ErM1.mjs";
|
|
15
|
+
import { n as resolveDiscordWebhookId, t as resolveDiscordSenderIdentity } from "./sender-identity-Dt5ELjRN.mjs";
|
|
16
|
+
import { n as resolveDiscordAutoThreadReplyPlan } from "./threading-PC3IIaHd.mjs";
|
|
17
|
+
import { t as beginDiscordActiveTurnThreadRoute } from "./active-turn-thread-route-DkPnk2x8.mjs";
|
|
18
|
+
import { a as createDiscordHistorySenderProvenance, l as isBoundThreadBotSystemMessage, o as filterDiscordHistoryEntriesForContext, p as shouldIgnoreBoundThreadWebhookMessage, s as resolveDiscordHistoryMediaIds, t as resolveDiscordPreflightPluralKitInfo } from "./message-handler.preflight-pluralkit-BFntgVKc.mjs";
|
|
19
|
+
import { t as sendTyping } from "./typing-DAv4S2fI.mjs";
|
|
19
20
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
20
21
|
import { danger, logVerbose, sleepWithAbort } from "openclaw/plugin-sdk/runtime-env";
|
|
21
22
|
import { buildAgentSessionKey, resolveThreadSessionKeys } from "openclaw/plugin-sdk/routing";
|
|
@@ -41,9 +42,8 @@ import { getGlobalHookRunner } from "openclaw/plugin-sdk/plugin-runtime";
|
|
|
41
42
|
import { buildHistoryContextFromEntries, buildInboundHistoryFromEntries, createChannelHistoryWindow } from "openclaw/plugin-sdk/reply-history";
|
|
42
43
|
import { resolveChannelContextVisibilityMode } from "openclaw/plugin-sdk/context-visibility-runtime";
|
|
43
44
|
import { formatAudioTranscriptForAgent } from "openclaw/plugin-sdk/media-understanding-runtime";
|
|
44
|
-
import { isReplySessionInitConflictError } from "openclaw/plugin-sdk/reply-runtime";
|
|
45
45
|
import { createStatusReactionController, logAckFailure, logTypingFailure, shouldAckReaction } from "openclaw/plugin-sdk/channel-feedback";
|
|
46
|
-
|
|
46
|
+
// extensions/discord/src/monitor/message-handler.recent-history.ts
|
|
47
47
|
/** Fetch a physical recent window, never walking older pages to refill filtered rows. */
|
|
48
48
|
async function recoverDiscordChannelHistory(params) {
|
|
49
49
|
const { ctx, isCurrent } = params;
|
|
@@ -150,11 +150,12 @@ async function recoverDiscordChannelHistory(params) {
|
|
|
150
150
|
return [];
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
// extensions/discord/src/monitor/message-handler.retry.ts
|
|
154
|
+
const REPLY_SESSION_INIT_CONFLICT_MESSAGE_RE = /^reply session initialization conflicted for \S+$/u;
|
|
155
155
|
const DISCORD_SESSION_CONFLICT_FAILURE_TEXT = "⚠️ Couldn't process this message because the session stayed busy. Please try again in a moment.";
|
|
156
156
|
async function completeDiscordSessionConflict(error, sourceReplyDeliveryMode, deliver, onDeliveryError) {
|
|
157
|
-
|
|
157
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
158
|
+
if (!REPLY_SESSION_INIT_CONFLICT_MESSAGE_RE.test(message)) return;
|
|
158
159
|
if (sourceReplyDeliveryMode === "message_tool_only") return "suppressed";
|
|
159
160
|
try {
|
|
160
161
|
return (await deliver({
|
|
@@ -171,8 +172,7 @@ function removeDiscordReplayHistoryEntry(historyMap, historyKey, messageId) {
|
|
|
171
172
|
if (!history) return;
|
|
172
173
|
for (let index = history.length - 1; index >= 0; index -= 1) if (history[index]?.messageId === messageId) history.splice(index, 1);
|
|
173
174
|
}
|
|
174
|
-
|
|
175
|
-
//#region extensions/discord/src/monitor/message-handler.context.ts
|
|
175
|
+
// extensions/discord/src/monitor/message-handler.context.ts
|
|
176
176
|
function normalizeDiscordDmOwnerEntry(entry) {
|
|
177
177
|
const candidate = normalizeDiscordAllowList([entry], [
|
|
178
178
|
"discord:",
|
|
@@ -585,8 +585,7 @@ async function buildDiscordMessageProcessContext(params) {
|
|
|
585
585
|
replyPlan
|
|
586
586
|
};
|
|
587
587
|
}
|
|
588
|
-
|
|
589
|
-
//#region extensions/discord/src/monitor/message-handler.process-reactions.ts
|
|
588
|
+
// extensions/discord/src/monitor/message-handler.process-reactions.ts
|
|
590
589
|
function createDiscordMessageReactionRuntime(params) {
|
|
591
590
|
const { ctx } = params;
|
|
592
591
|
const { cfg, accountId, token, ackReactionScope, message, messageChannelId, isGuildMessage, isDirectMessage, isGroupDm, canDetectMention, effectiveWasMentioned, shouldBypassMention, route } = ctx;
|
|
@@ -715,8 +714,7 @@ function createDiscordMessageReactionRuntime(params) {
|
|
|
715
714
|
finish
|
|
716
715
|
};
|
|
717
716
|
}
|
|
718
|
-
|
|
719
|
-
//#region extensions/discord/src/draft-stream.ts
|
|
717
|
+
// extensions/discord/src/draft-stream.ts
|
|
720
718
|
/** Discord messages cap at 2000 characters. */
|
|
721
719
|
const DISCORD_STREAM_MAX_CHARS = 2e3;
|
|
722
720
|
const DEFAULT_THROTTLE_MS = 1200;
|
|
@@ -854,8 +852,7 @@ function createDiscordDraftStream(params) {
|
|
|
854
852
|
forceNewMessage: lifecycle.reset
|
|
855
853
|
};
|
|
856
854
|
}
|
|
857
|
-
|
|
858
|
-
//#region extensions/discord/src/monitor/message-handler.draft-preview.ts
|
|
855
|
+
// extensions/discord/src/monitor/message-handler.draft-preview.ts
|
|
859
856
|
function createDiscordDraftPreviewController(params) {
|
|
860
857
|
const runInChannelScope = AsyncLocalStorage.snapshot();
|
|
861
858
|
const assertChannelAuthority = captureDiscordRequestAuthority();
|
|
@@ -1170,8 +1167,7 @@ function isEmptyDiscordProgressLine(line) {
|
|
|
1170
1167
|
function shouldStartDiscordProgressDraftNow(line) {
|
|
1171
1168
|
return typeof line === "object" && line?.kind === "patch" && Boolean(line.detail);
|
|
1172
1169
|
}
|
|
1173
|
-
|
|
1174
|
-
//#region extensions/discord/src/monitor/message-handler.process-reply-runtime.ts
|
|
1170
|
+
// extensions/discord/src/monitor/message-handler.process-reply-runtime.ts
|
|
1175
1171
|
function formatDiscordGroupThreadReply(text, participant) {
|
|
1176
1172
|
return `**${participant.name.replace(/[\\`*_{}[\]()<>#!|]/g, "\\$&").replace(/\s+/g, " ")}**\n${text}`;
|
|
1177
1173
|
}
|
|
@@ -1192,7 +1188,7 @@ function createDiscordBeforePayloadDelivery(params) {
|
|
|
1192
1188
|
}));
|
|
1193
1189
|
return null;
|
|
1194
1190
|
}
|
|
1195
|
-
if (payload.isReasoning || payload.isCommentary) return payload;
|
|
1191
|
+
if (payload.isReasoning || payload.isCommentary || payload.isCompactionNotice) return payload;
|
|
1196
1192
|
if (params.draftPreview.draftStream && params.draftPreview.isProgressMode && info.kind === "block" && !resolveSendableOutboundReplyParts(payload).hasMedia && !payload.isError) return null;
|
|
1197
1193
|
if (info.kind === "final" && !params.isFallbackOnlyToolWarningFinal(payload)) params.draftPreview.freezeProgress();
|
|
1198
1194
|
return payload;
|
|
@@ -1306,8 +1302,7 @@ function createDiscordMessageReplyRuntime(params) {
|
|
|
1306
1302
|
resolvedBlockStreamingEnabled: resolveChannelStreamingBlockEnabled(discordConfig)
|
|
1307
1303
|
};
|
|
1308
1304
|
}
|
|
1309
|
-
|
|
1310
|
-
//#region extensions/discord/src/monitor/message-handler.process.ts
|
|
1305
|
+
// extensions/discord/src/monitor/message-handler.process.ts
|
|
1311
1306
|
const TARGETED_ONLY_ALLOWED_MENTIONS = { parse: [AllowedMentionsTypes.User, AllowedMentionsTypes.Role] };
|
|
1312
1307
|
function isFallbackOnlyToolWarningFinal(payload) {
|
|
1313
1308
|
if (payload.isError !== true || !isReplyPayloadNonTerminalToolErrorWarning(payload)) return false;
|
|
@@ -1356,26 +1351,9 @@ async function processDiscordMessage(ctx) {
|
|
|
1356
1351
|
if (!processContext) return;
|
|
1357
1352
|
const { ctxPayload, persistedSessionKey, record, replyPlan } = processContext;
|
|
1358
1353
|
let deliverTarget = replyPlan.deliverTarget;
|
|
1359
|
-
const sourceMessageId = ctx.canonicalMessageId ?? message.id;
|
|
1360
1354
|
const sourceReplyReference = replyPlan.replyReference;
|
|
1361
1355
|
let adoptedThreadId;
|
|
1362
1356
|
let threadReplyDelivered = false;
|
|
1363
|
-
let onThreadAdopted = void 0;
|
|
1364
|
-
const endActiveThreadRoute = beginDiscordActiveTurnThreadRoute(ctxPayload.SessionKey, {
|
|
1365
|
-
accountId,
|
|
1366
|
-
sourceChannelId: messageChannelId,
|
|
1367
|
-
sourceMessageId,
|
|
1368
|
-
onThreadAdopted: async (threadId) => {
|
|
1369
|
-
adoptedThreadId = threadId;
|
|
1370
|
-
await onThreadAdopted?.(threadId);
|
|
1371
|
-
},
|
|
1372
|
-
onThreadReplyDelivered: () => {
|
|
1373
|
-
threadReplyDelivered = true;
|
|
1374
|
-
},
|
|
1375
|
-
onThreadAdoptionError: (error) => {
|
|
1376
|
-
logVerbose(`discord: failed to move active progress into adopted thread (${String(error)})`);
|
|
1377
|
-
}
|
|
1378
|
-
});
|
|
1379
1357
|
const replyReference = {
|
|
1380
1358
|
peek: () => adoptedThreadId ? void 0 : sourceReplyReference.peek(),
|
|
1381
1359
|
use: () => adoptedThreadId ? void 0 : sourceReplyReference.use(),
|
|
@@ -1392,10 +1370,23 @@ async function processDiscordMessage(ctx) {
|
|
|
1392
1370
|
feedbackRest: reactions.feedbackRest,
|
|
1393
1371
|
deliveryRest: reactions.deliveryRest
|
|
1394
1372
|
});
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1373
|
+
const beginActiveThreadRoute = () => beginDiscordActiveTurnThreadRoute(ctxPayload.SessionKey, {
|
|
1374
|
+
accountId,
|
|
1375
|
+
sourceChannelId: messageChannelId,
|
|
1376
|
+
sourceMessageId: ctx.canonicalMessageId ?? message.id,
|
|
1377
|
+
onThreadAdopted: async (threadId) => {
|
|
1378
|
+
adoptedThreadId = threadId;
|
|
1379
|
+
deliverTarget = `channel:${threadId}`;
|
|
1380
|
+
await draftPreview.retarget(threadId);
|
|
1381
|
+
},
|
|
1382
|
+
onThreadReplyDelivered: () => {
|
|
1383
|
+
threadReplyDelivered = true;
|
|
1384
|
+
},
|
|
1385
|
+
onThreadAdoptionError: (error) => {
|
|
1386
|
+
logVerbose(`discord: failed to move active progress into adopted thread (${String(error)})`);
|
|
1387
|
+
}
|
|
1388
|
+
});
|
|
1389
|
+
const endActiveThreadRoute = beginActiveThreadRoute();
|
|
1399
1390
|
const { lifecycle } = draftPreview;
|
|
1400
1391
|
const hasCompletedFinalReply = () => lifecycle.finalSucceeded || lifecycle.previewFinalized;
|
|
1401
1392
|
const observeFinalDelivery = async () => {
|
|
@@ -1408,16 +1399,15 @@ async function processDiscordMessage(ctx) {
|
|
|
1408
1399
|
await retainedProgress;
|
|
1409
1400
|
};
|
|
1410
1401
|
let pendingToolWarningFinal;
|
|
1411
|
-
const progressSessionKey = ctxPayload.SessionKey;
|
|
1412
1402
|
const reasoningLevel = await (async () => {
|
|
1413
1403
|
const cfgDefault = resolveAgentConfig(cfg, route.agentId ?? "main")?.reasoningDefault ?? cfg.agents?.defaults?.reasoningDefault;
|
|
1414
1404
|
const configDefault = cfgDefault === "on" || cfgDefault === "stream" ? cfgDefault : "off";
|
|
1415
|
-
if (!
|
|
1405
|
+
if (!ctxPayload.SessionKey) return configDefault;
|
|
1416
1406
|
try {
|
|
1417
1407
|
const storePath = resolveStorePath(cfg.session?.store, { agentId: route.agentId });
|
|
1418
1408
|
const level = (await getSessionEntryAsync({
|
|
1419
1409
|
agentId: route.agentId,
|
|
1420
|
-
sessionKey:
|
|
1410
|
+
sessionKey: ctxPayload.SessionKey,
|
|
1421
1411
|
storePath
|
|
1422
1412
|
}))?.reasoningLevel;
|
|
1423
1413
|
if (level === "on" || level === "stream" || level === "off") return level;
|
|
@@ -1426,7 +1416,6 @@ async function processDiscordMessage(ctx) {
|
|
|
1426
1416
|
}
|
|
1427
1417
|
return configDefault;
|
|
1428
1418
|
})();
|
|
1429
|
-
const reasoningDurableEnabled = reasoningLevel === "on";
|
|
1430
1419
|
const reasoningWindowEnabled = reasoningLevel === "stream";
|
|
1431
1420
|
let shouldYieldDraftCommentary = async () => false;
|
|
1432
1421
|
let turnCommentaryVisible = false;
|
|
@@ -1450,7 +1439,7 @@ async function processDiscordMessage(ctx) {
|
|
|
1450
1439
|
progressPreambleEnabled: draftPreview.draftStream && draftPreview.isProgressMode ? true : void 0,
|
|
1451
1440
|
commentaryPayloadsEnabled: draftPreview.isProgressMode ? draftPreview.commentaryProgressEnabled : void 0,
|
|
1452
1441
|
shouldDeliverCommentaryPayloads: draftPreview.isProgressMode && draftPreview.commentaryProgressEnabled ? () => turnCommentaryVisible : void 0,
|
|
1453
|
-
reasoningPayloadsEnabled:
|
|
1442
|
+
reasoningPayloadsEnabled: reasoningLevel === "on",
|
|
1454
1443
|
onVerboseProgressVisibilityAsync: async (isActive) => {
|
|
1455
1444
|
shouldYieldDraftCommentary = isActive;
|
|
1456
1445
|
turnCommentaryVisible = await isActive();
|
|
@@ -1603,9 +1592,7 @@ async function processDiscordMessage(ctx) {
|
|
|
1603
1592
|
}
|
|
1604
1593
|
if (isFinal && !replyLifecycleStarted && !isRoomEvent && configuredTypingMode !== "never") await onDiscordReplyStart();
|
|
1605
1594
|
const draftStream = draftPreview.draftStream;
|
|
1606
|
-
if (draftStream && draftPreview.isProgressMode && info.kind === "block" && !deliverablePayload.isCommentary) {
|
|
1607
|
-
if (!resolveSendableOutboundReplyParts(deliverablePayload).hasMedia && !deliverablePayload.isError) return { visibleReplySent: false };
|
|
1608
|
-
}
|
|
1595
|
+
if (draftStream && draftPreview.isProgressMode && info.kind === "block" && !deliverablePayload.isCommentary && !deliverablePayload.isCompactionNotice && !resolveSendableOutboundReplyParts(deliverablePayload).hasMedia && !deliverablePayload.isError) return { visibleReplySent: false };
|
|
1609
1596
|
let deliveryResult = { visibleReplySent: false };
|
|
1610
1597
|
await lifecycle.deliver({
|
|
1611
1598
|
kind: info.kind,
|
|
@@ -1714,7 +1701,10 @@ async function processDiscordMessage(ctx) {
|
|
|
1714
1701
|
skillFilter: ctx.channelConfig?.skills,
|
|
1715
1702
|
sourceReplyDeliveryMode,
|
|
1716
1703
|
typingKeepalive: shouldDisableCoreTypingKeepalive ? false : void 0,
|
|
1717
|
-
queuedDeliveryCorrelations: isRoomEvent ? [{ begin: beginQueuedDeliveryCorrelation }] :
|
|
1704
|
+
queuedDeliveryCorrelations: [...isRoomEvent ? [{ begin: beginQueuedDeliveryCorrelation }] : [], { begin: () => {
|
|
1705
|
+
endActiveThreadRoute();
|
|
1706
|
+
return beginActiveThreadRoute();
|
|
1707
|
+
} }],
|
|
1718
1708
|
suppressTyping: isRoomEvent ? true : void 0,
|
|
1719
1709
|
allowProgressCallbacksWhenSourceDeliverySuppressed: sourceRepliesAreToolOnly && draftPreview.draftStream && draftPreview.isProgressMode ? true : void 0,
|
|
1720
1710
|
disableBlockStreaming: sourceRepliesAreToolOnly ? true : draftPreview.disableBlockStreamingForDraft ?? (typeof resolvedBlockStreamingEnabled === "boolean" ? !resolvedBlockStreamingEnabled : void 0),
|
|
@@ -1761,5 +1751,4 @@ async function processDiscordMessage(ctx) {
|
|
|
1761
1751
|
});
|
|
1762
1752
|
}
|
|
1763
1753
|
}
|
|
1764
|
-
//#endregion
|
|
1765
1754
|
export { processDiscordMessage };
|