@openclaw/discord 2026.10.1 → 2026.10.5-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.setup/account-inspect-8cCu6uPG.mjs +31 -0
- package/dist/.setup/{accounts-HE9-mj1L.mjs → accounts-ljrzXBJi.mjs} +47 -45
- package/dist/.setup/{allow-list-vxkG9_JD.mjs → allow-list-B_ToXtew.mjs} +34 -101
- package/dist/.setup/{api-DlNUkDqj.mjs → api-CtmE1OUN.mjs} +25 -31
- package/dist/.setup/{approval-handler.runtime-DmnEa54W.mjs → approval-handler.runtime-D7FoZSn0.mjs} +30 -53
- package/dist/.setup/{approval-message-updates-B0jdSqOj.mjs → approval-message-updates-CIGByUcE.mjs} +2 -2
- package/dist/.setup/{audit-BpikUwN_.mjs → audit-zSawfbsN.mjs} +5 -8
- package/dist/.setup/{channel-Dr-AUnGt.mjs → channel-DI7DMzu0.mjs} +136 -215
- package/dist/.setup/{channel-access-BRp3Y-rF.mjs → channel-access-DasWY_OV.mjs} +6 -7
- package/dist/.setup/{channel.setup-BmNvkidb.mjs → channel.setup-DdFVN1mr.mjs} +35 -64
- package/dist/.setup/{components-DLJR0xU-.mjs → components-HN9052L1.mjs} +123 -146
- package/dist/.setup/{config-schema-BQWfnSCx.mjs → config-schema-_uBILpQf.mjs} +7 -3
- package/dist/.setup/{conversation-binding-route-DicJC1Lj.mjs → conversation-binding-route-DTjCBx-O.mjs} +1 -1
- package/dist/.setup/{directory-config-gqsdcplU.mjs → directory-config-3iVub-3m.mjs} +1 -1
- package/dist/.setup/{directory-live-Bipr0eUJ.mjs → directory-live-DLygQVtW.mjs} +18 -22
- package/dist/.setup/{discord-9gysrhzp.mjs → discord-BGqgx-yd.mjs} +686 -854
- package/dist/.setup/{doctor-B2bskDcF.mjs → doctor-DSrNJ7m2.mjs} +36 -47
- package/dist/.setup/{doctor-contract-Bg3NPAMw.mjs → doctor-contract-Bwv8EuQ_.mjs} +7 -16
- package/dist/.setup/{handle-action-UmkjXBfo.mjs → handle-action-CXH1h1tq.mjs} +25 -38
- package/dist/.setup/{handle-action.guild-admin-CB4sc9VV.mjs → handle-action.guild-admin-CHKW6PIs.mjs} +25 -31
- package/dist/.setup/{live-policy-config-VxexfRKo.mjs → live-policy-config-BPoB3eQi.mjs} +1 -1
- package/dist/.setup/{message-handler-BK69A-NB.mjs → message-handler-Ii_etru1.mjs} +9 -14
- package/dist/.setup/{message-handler.preflight-DFpsh90H.mjs → message-handler.preflight-C7YuSRl_.mjs} +79 -128
- package/dist/.setup/{message-handler.preflight-pluralkit-BXGGVmpe.mjs → message-handler.preflight-pluralkit-C3iAG--b.mjs} +6 -6
- package/dist/.setup/{message-handler.process-TKoqcqIP.mjs → message-handler.process-ClgWYH6o.mjs} +234 -206
- package/dist/.setup/{outbound-adapter-D4wRAb5S.mjs → outbound-adapter-D8OOIuKn.mjs} +73 -112
- package/dist/.setup/{outbound-session-route-BvBH4LC6.mjs → outbound-session-route-B0Hpwn3Q.mjs} +57 -115
- package/dist/.setup/output-activity-uBpMSX75.mjs +11 -0
- package/dist/.setup/{pluralkit-a6_NLfH9.mjs → pluralkit-B64dfq_j.mjs} +3 -1
- package/dist/.setup/{preflight-audio-DHGIHEpv.mjs → preflight-audio-wWgsZG5F.mjs} +1 -5
- package/dist/.setup/{presence-cache-Dg3_dADn.mjs → presence-cache-DCeTsL73.mjs} +3 -6
- package/dist/.setup/{probe-BwSKpnZf.mjs → probe-D3P1x4aN.mjs} +10 -18
- package/dist/.setup/{provider-YP8gN9_o.mjs → provider-D9EzOfG8.mjs} +2990 -3903
- package/dist/.setup/{provider-session.runtime-D1gkPxHT.mjs → provider-session.runtime-CsnRvddI.mjs} +5 -5
- package/dist/.setup/provider.runtime-BQVcM7Pg.mjs +2 -0
- package/dist/.setup/{realtime-session.runtime-BKUQBy1u.mjs → realtime-session.runtime-CxGBk8H-.mjs} +69 -98
- package/dist/.setup/{receive-recovery-DgkX7Qvi.mjs → receive-recovery-eVmK2_hl.mjs} +2 -12
- package/dist/.setup/resolve-allowlist-common-DNSsUQRF.mjs +66 -0
- package/dist/.setup/resolve-channels-UdT38DzU.mjs +173 -0
- package/dist/.setup/{resolve-users-DNrwvunm.mjs → resolve-users-DnCsrXZ_.mjs} +12 -41
- package/dist/.setup/{runtime-CESTexGn.mjs → runtime-CRTkKU1G.mjs} +202 -313
- package/dist/.setup/{runtime-DPcmPST9.mjs → runtime-DPm3gZXk.mjs} +2 -2
- package/dist/.setup/{secret-config-contract-uOE2J7yM.mjs → secret-config-contract-CIsH7R3B.mjs} +9 -18
- package/dist/.setup/{security-audit-D42cp5N7.mjs → security-audit-BFT84Uny.mjs} +1 -2
- package/dist/.setup/security-contract-DNyyjTZZ.mjs +19 -0
- package/dist/.setup/{send-CJk3VP5q.mjs → send-DbILKgcm.mjs} +184 -241
- package/dist/.setup/{send.components-dPljuV24.mjs → send.components-FxOS3CeP.mjs} +47 -63
- package/dist/.setup/{send.outbound-rOboMO_6.mjs → send.outbound-_jx4Xpd3.mjs} +178 -202
- package/dist/.setup/{send.receipt-DVOg2Oaw.mjs → send.receipt-BAlzXd8e.mjs} +33 -109
- package/dist/.setup/{send.shared-C4CN24D9.mjs → send.shared-CjQ4jbMA.mjs} +97 -153
- package/dist/.setup/{sender-identity-AHpUNr72.mjs → sender-identity-BNBvGt1l.mjs} +1 -1
- package/dist/.setup/setup-plugin-api-xfOFmxHP.mjs +3 -0
- package/dist/.setup/{shared-BoBnM5kM.mjs → shared-CestGDpq.mjs} +30 -20
- package/dist/.setup/{subagent-hooks-HH8Uy9cx.mjs → subagent-hooks-CME7dSGf.mjs} +5 -10
- package/dist/.setup/{system-events-Cwxaww8i.mjs → system-events-BwwSDCw4.mjs} +2 -2
- package/dist/.setup/target-parsing-C-HyNxcE.mjs +48 -0
- package/dist/.setup/{target-resolver-CSFoPQ12.mjs → target-resolver-Bse8fuTi.mjs} +11 -27
- package/dist/.setup/targets-DZJjkzwv.mjs +3 -0
- package/dist/.setup/{thread-bindings-DjQCkmsd.mjs → thread-bindings-0hPTSK14.mjs} +61 -52
- package/dist/.setup/{thread-bindings.manager-D2-GYZ5s.mjs → thread-bindings.manager-CdNa6UIs.mjs} +138 -211
- package/dist/.setup/{thread-bindings.session-updates-Bu_CGr_O.mjs → thread-bindings.session-updates-DGSljVf6.mjs} +60 -99
- package/dist/.setup/threading-BKe3E3tp.mjs +246 -0
- package/dist/.setup/{timeouts-pun7VJ02.mjs → timeouts-CuNARfyw.mjs} +10 -18
- package/dist/.setup/{transcripts-source-CaZQnGRH.mjs → transcripts-source-0qQYVu2H.mjs} +50 -368
- package/dist/.setup/{voice-runtime-DDymtIw8.mjs → voice-runtime-QlZJ4sHv.mjs} +166 -322
- package/dist/account-inspect-api.js +1 -1
- package/dist/action-runtime-api.js +1 -1
- package/dist/activities-api.js +77 -120
- package/dist/api.js +19 -18
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/directory-contract-api.js +1 -1
- package/dist/doctor-contract-api.js +1 -1
- package/dist/runtime-api.js +21 -20
- 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/setup-entry.js +1 -1
- package/dist/setup-plugin-api.js +1 -1
- package/dist/src/voice/audio-worker.runtime.js +38 -57
- package/dist/subagent-hooks-api.js +1 -1
- package/dist/transcripts-source-api.js +1 -1
- package/node_modules/discord-api-types/_generated_/rest/v10/interfaces.d.ts +21 -0
- package/node_modules/discord-api-types/_generated_/rest/v10/interfaces.d.ts.map +1 -1
- package/node_modules/discord-api-types/_generated_/rest/v9/interfaces.d.ts +21 -0
- package/node_modules/discord-api-types/_generated_/rest/v9/interfaces.d.ts.map +1 -1
- package/node_modules/discord-api-types/globals.d.ts +6 -0
- package/node_modules/discord-api-types/globals.d.ts.map +1 -1
- package/node_modules/discord-api-types/globals.js +6 -0
- package/node_modules/discord-api-types/globals.js.map +1 -1
- package/node_modules/discord-api-types/package.json +3 -3
- package/node_modules/discord-api-types/payloads/index.mjs +1 -0
- package/node_modules/discord-api-types/payloads/v10/applicationIdentityProfile.d.ts +207 -0
- package/node_modules/discord-api-types/payloads/v10/applicationIdentityProfile.d.ts.map +1 -0
- package/node_modules/discord-api-types/payloads/v10/applicationIdentityProfile.js +25 -0
- package/node_modules/discord-api-types/payloads/v10/applicationIdentityProfile.js.map +1 -0
- package/node_modules/discord-api-types/payloads/v10/autoModeration.d.ts +1 -1
- package/node_modules/discord-api-types/payloads/v10/autoModeration.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v10/guild.d.ts +27 -23
- package/node_modules/discord-api-types/payloads/v10/guild.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v10/guild.js +26 -22
- package/node_modules/discord-api-types/payloads/v10/guild.js.map +1 -1
- package/node_modules/discord-api-types/payloads/v10/index.d.ts +1 -0
- package/node_modules/discord-api-types/payloads/v10/index.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v10/index.js +1 -0
- package/node_modules/discord-api-types/payloads/v10/index.js.map +1 -1
- package/node_modules/discord-api-types/payloads/v10/index.mjs +1 -0
- package/node_modules/discord-api-types/payloads/v9/applicationIdentityProfile.d.ts +207 -0
- package/node_modules/discord-api-types/payloads/v9/applicationIdentityProfile.d.ts.map +1 -0
- package/node_modules/discord-api-types/payloads/v9/applicationIdentityProfile.js +25 -0
- package/node_modules/discord-api-types/payloads/v9/applicationIdentityProfile.js.map +1 -0
- package/node_modules/discord-api-types/payloads/v9/autoModeration.d.ts +1 -1
- package/node_modules/discord-api-types/payloads/v9/autoModeration.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v9/guild.d.ts +27 -23
- package/node_modules/discord-api-types/payloads/v9/guild.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v9/guild.js +26 -22
- package/node_modules/discord-api-types/payloads/v9/guild.js.map +1 -1
- package/node_modules/discord-api-types/payloads/v9/index.d.ts +1 -0
- package/node_modules/discord-api-types/payloads/v9/index.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v9/index.js +1 -0
- package/node_modules/discord-api-types/payloads/v9/index.js.map +1 -1
- package/node_modules/discord-api-types/payloads/v9/index.mjs +1 -0
- package/node_modules/discord-api-types/rest/common.d.ts +2 -0
- package/node_modules/discord-api-types/rest/common.d.ts.map +1 -1
- package/node_modules/discord-api-types/rest/common.js +2 -0
- package/node_modules/discord-api-types/rest/common.js.map +1 -1
- package/node_modules/discord-api-types/rest/v10/applicationIdentityProfile.d.ts +70 -0
- package/node_modules/discord-api-types/rest/v10/applicationIdentityProfile.d.ts.map +1 -0
- package/node_modules/discord-api-types/rest/v10/applicationIdentityProfile.js +3 -0
- package/node_modules/discord-api-types/rest/v10/applicationIdentityProfile.js.map +1 -0
- package/node_modules/discord-api-types/rest/v10/index.d.ts +1 -0
- package/node_modules/discord-api-types/rest/v10/index.d.ts.map +1 -1
- package/node_modules/discord-api-types/rest/v10/index.js +29 -0
- package/node_modules/discord-api-types/rest/v10/index.js.map +1 -1
- package/node_modules/discord-api-types/rest/v10/interactions.d.ts +4 -2
- package/node_modules/discord-api-types/rest/v10/interactions.d.ts.map +1 -1
- package/node_modules/discord-api-types/rest/v10/user.d.ts +2 -2
- package/node_modules/discord-api-types/rest/v10/user.d.ts.map +1 -1
- package/node_modules/discord-api-types/rest/v9/applicationIdentityProfile.d.ts +70 -0
- package/node_modules/discord-api-types/rest/v9/applicationIdentityProfile.d.ts.map +1 -0
- package/node_modules/discord-api-types/rest/v9/applicationIdentityProfile.js +3 -0
- package/node_modules/discord-api-types/rest/v9/applicationIdentityProfile.js.map +1 -0
- package/node_modules/discord-api-types/rest/v9/index.d.ts +1 -0
- package/node_modules/discord-api-types/rest/v9/index.d.ts.map +1 -1
- package/node_modules/discord-api-types/rest/v9/index.js +29 -0
- package/node_modules/discord-api-types/rest/v9/index.js.map +1 -1
- package/node_modules/discord-api-types/rest/v9/interactions.d.ts +4 -2
- package/node_modules/discord-api-types/rest/v9/interactions.d.ts.map +1 -1
- package/node_modules/discord-api-types/rest/v9/user.d.ts +2 -2
- package/node_modules/discord-api-types/rest/v9/user.d.ts.map +1 -1
- package/node_modules/discord-api-types/v10.mjs +1 -0
- package/node_modules/discord-api-types/v9.mjs +1 -0
- package/node_modules/ws/lib/websocket.js +17 -3
- package/node_modules/ws/package.json +1 -1
- package/openclaw.plugin.json +3 -6
- package/package.json +7 -12
- package/dist/.setup/account-inspect-DsER5ILV.mjs +0 -45
- package/dist/.setup/provider.runtime-CZ51OIgD.mjs +0 -2
- package/dist/.setup/resolve-allowlist-common-BUyU3C-T.mjs +0 -27
- package/dist/.setup/resolve-channels-DA6QlhZN.mjs +0 -246
- package/dist/.setup/security-contract-DSHk7I2w.mjs +0 -26
- package/dist/.setup/setup-plugin-api-BVlCz3fm.mjs +0 -3
- package/dist/.setup/targets-bqXQENmX.mjs +0 -3
- package/dist/control-ui/2afbdab1d3aa65a789d8a3eba666f4b1ec5df07073538fe30d6cf32093a1fb2d/index.js +0 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { buildMessagingTarget, parseMentionPrefixOrAtUserTarget, requireTargetKind } from "openclaw/plugin-sdk/channel-targets";
|
|
2
|
+
//#region extensions/discord/src/target-parsing.ts
|
|
3
|
+
function parseDiscordTarget(raw, options = {}) {
|
|
4
|
+
const trimmed = raw.trim();
|
|
5
|
+
if (!trimmed) return;
|
|
6
|
+
const providerPrefix = /^discord:(channel|user):(.+)$/i.exec(trimmed);
|
|
7
|
+
if (providerPrefix) {
|
|
8
|
+
const kind = providerPrefix[1]?.toLowerCase();
|
|
9
|
+
const id = providerPrefix[2]?.trim();
|
|
10
|
+
if (kind && id) return buildMessagingTarget(kind, id, `${kind}:${id}`);
|
|
11
|
+
}
|
|
12
|
+
const userTarget = parseMentionPrefixOrAtUserTarget({
|
|
13
|
+
raw: trimmed,
|
|
14
|
+
mentionPattern: /^<@!?(\d+)>$/,
|
|
15
|
+
prefixes: [
|
|
16
|
+
{
|
|
17
|
+
prefix: "user:",
|
|
18
|
+
kind: "user"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
prefix: "channel:",
|
|
22
|
+
kind: "channel"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
prefix: "discord:",
|
|
26
|
+
kind: "user"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
atUserPattern: /^\d+$/,
|
|
30
|
+
atUserErrorMessage: "Discord DMs require a user id (use user:<id> or a <@id> mention)"
|
|
31
|
+
});
|
|
32
|
+
if (userTarget) return userTarget;
|
|
33
|
+
if (/^\d+$/.test(trimmed)) {
|
|
34
|
+
if (options.defaultKind) return buildMessagingTarget(options.defaultKind, trimmed, trimmed);
|
|
35
|
+
throw new Error(options.ambiguousMessage ?? `Ambiguous Discord recipient "${trimmed}". For DMs use "user:${trimmed}" or "<@${trimmed}>"; for channels use "channel:${trimmed}".`);
|
|
36
|
+
}
|
|
37
|
+
return buildMessagingTarget("channel", trimmed, trimmed);
|
|
38
|
+
}
|
|
39
|
+
function resolveDiscordChannelId(raw) {
|
|
40
|
+
const target = parseDiscordTarget(raw, { defaultKind: "channel" });
|
|
41
|
+
return requireTargetKind({
|
|
42
|
+
platform: "Discord",
|
|
43
|
+
target,
|
|
44
|
+
kind: "channel"
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { resolveDiscordChannelId as n, parseDiscordTarget as t };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { c as allowFromContainsDiscordUserId
|
|
4
|
-
import { o as rememberDiscordDirectoryUser, r as listDiscordDirectoryPeersLive } from "./directory-live-
|
|
2
|
+
import { l as resolveDiscordAccount, u as resolveDiscordAccountAllowFrom } from "./accounts-ljrzXBJi.mjs";
|
|
3
|
+
import { c as allowFromContainsDiscordUserId } from "./send.receipt-BAlzXd8e.mjs";
|
|
4
|
+
import { o as rememberDiscordDirectoryUser, r as listDiscordDirectoryPeersLive } from "./directory-live-DLygQVtW.mjs";
|
|
5
|
+
import { t as parseDiscordTarget } from "./target-parsing-C-HyNxcE.mjs";
|
|
5
6
|
import { buildMessagingTarget } from "openclaw/plugin-sdk/channel-targets";
|
|
6
7
|
//#region extensions/discord/src/target-resolver.ts
|
|
7
8
|
var target_resolver_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -16,9 +17,12 @@ async function resolveDiscordTarget(raw, options, parseOptions = {}) {
|
|
|
16
17
|
const trimmed = raw.trim();
|
|
17
18
|
if (!trimmed) return;
|
|
18
19
|
const likelyUsername = !/^(user:|channel:|discord:|@|<@!?)|[\d]+$/.test(trimmed);
|
|
19
|
-
const shouldLookup =
|
|
20
|
-
if (/^\d+$/.test(trimmed) && parseOptions.defaultKind !== "user" &&
|
|
21
|
-
|
|
20
|
+
const shouldLookup = /^<@!?(\d+)>$/.test(trimmed) || /^(user:|discord:)/.test(trimmed) || trimmed.startsWith("@") || /^\d+$/.test(trimmed) && parseOptions.defaultKind === "user" || likelyUsername;
|
|
21
|
+
if (/^\d+$/.test(trimmed) && parseOptions.defaultKind !== "user" && allowFromContainsDiscordUserId(resolveDiscordAccountAllowFrom(options) ?? [], trimmed)) return buildMessagingTarget("user", trimmed, trimmed);
|
|
22
|
+
let directParse;
|
|
23
|
+
try {
|
|
24
|
+
directParse = parseDiscordTarget(trimmed, parseOptions);
|
|
25
|
+
} catch {}
|
|
22
26
|
if (directParse && directParse.kind !== "channel" && !likelyUsername) return directParse;
|
|
23
27
|
if (!shouldLookup) return directParse ?? parseDiscordTarget(trimmed, parseOptions);
|
|
24
28
|
try {
|
|
@@ -29,10 +33,7 @@ async function resolveDiscordTarget(raw, options, parseOptions = {}) {
|
|
|
29
33
|
}))[0];
|
|
30
34
|
if (match && match.kind === "user") {
|
|
31
35
|
const userId = match.id.replace(/^user:/, "");
|
|
32
|
-
const resolvedAccountId = resolveDiscordAccount(
|
|
33
|
-
cfg: options.cfg,
|
|
34
|
-
accountId: options.accountId
|
|
35
|
-
}).accountId;
|
|
36
|
+
const resolvedAccountId = resolveDiscordAccount(options).accountId;
|
|
36
37
|
rememberDiscordDirectoryUser({
|
|
37
38
|
accountId: resolvedAccountId,
|
|
38
39
|
userId,
|
|
@@ -52,22 +53,5 @@ async function parseAndResolveDiscordTarget(raw, options, parseOptions = {}) {
|
|
|
52
53
|
if (!resolved) throw new Error("Recipient is required for Discord sends");
|
|
53
54
|
return resolved;
|
|
54
55
|
}
|
|
55
|
-
function safeParseDiscordTarget(input, options) {
|
|
56
|
-
try {
|
|
57
|
-
return parseDiscordTarget(input, options);
|
|
58
|
-
} catch {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
function isConfiguredAllowedDiscordDmUser(input, options) {
|
|
63
|
-
const allowFrom = resolveDiscordAccountAllowFrom({
|
|
64
|
-
cfg: options.cfg,
|
|
65
|
-
accountId: options.accountId
|
|
66
|
-
}) ?? [];
|
|
67
|
-
return allowFromContainsDiscordUserId(allowFrom, input);
|
|
68
|
-
}
|
|
69
|
-
function isExplicitUserLookup(input, options) {
|
|
70
|
-
return /^<@!?(\d+)>$/.test(input) || /^(user:|discord:)/.test(input) || input.startsWith("@") || /^\d+$/.test(input) && options.defaultKind === "user";
|
|
71
|
-
}
|
|
72
56
|
//#endregion
|
|
73
57
|
export { resolveDiscordTarget as n, target_resolver_exports as r, parseAndResolveDiscordTarget as t };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import "./targets-
|
|
4
|
-
import { C as getThreadBindingToken, E as refreshUnboundThreadWebhookIdentity, F as resolveThreadBindingMaxAgeMs$1, M as resolveThreadBindingIdleTimeoutMs$1, N as resolveThreadBindingInactivityExpiresAt, P as resolveThreadBindingMaxAgeExpiresAt, _ as MANAGERS_BY_ACCOUNT_ID, a as mutateBindingsForTargetSession, g as BINDINGS_BY_THREAD_ID, i as setThreadBindingMaxAgeBySessionKeyAsync, n as setThreadBindingIdleTimeoutBySessionKeyAsync, o as resolveBindingIdsForTargetSession, r as setThreadBindingMaxAgeBySessionKey, t as setThreadBindingIdleTimeoutBySessionKey, u as removeBindingRecordSync } from "./thread-bindings.session-updates-
|
|
5
|
-
import { c as resolveThreadBindingPersonaFromRecord, i as createNoopThreadBindingManager, n as getThreadBindingManager, o as resolveChannelIdForBinding, s as resolveThreadBindingPersona, t as createThreadBindingManager } from "./thread-bindings.manager-
|
|
6
|
-
import { normalizeOptionalLowercaseString, normalizeOptionalString, normalizeOptionalStringifiedId, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
2
|
+
import { t as parseDiscordTarget } from "./target-parsing-C-HyNxcE.mjs";
|
|
3
|
+
import "./targets-DZJjkzwv.mjs";
|
|
4
|
+
import { C as getThreadBindingToken, E as refreshUnboundThreadWebhookIdentity, F as resolveThreadBindingMaxAgeMs$1, M as resolveThreadBindingIdleTimeoutMs$1, N as resolveThreadBindingInactivityExpiresAt, P as resolveThreadBindingMaxAgeExpiresAt, _ as MANAGERS_BY_ACCOUNT_ID, a as mutateBindingsForTargetSession, g as BINDINGS_BY_THREAD_ID, i as setThreadBindingMaxAgeBySessionKeyAsync, n as setThreadBindingIdleTimeoutBySessionKeyAsync, o as resolveBindingIdsForTargetSession, r as setThreadBindingMaxAgeBySessionKey, t as setThreadBindingIdleTimeoutBySessionKey, u as removeBindingRecordSync } from "./thread-bindings.session-updates-DGSljVf6.mjs";
|
|
5
|
+
import { c as resolveThreadBindingPersonaFromRecord, i as createNoopThreadBindingManager, n as getThreadBindingManager, o as resolveChannelIdForBinding, s as resolveThreadBindingPersona, t as createThreadBindingManager } from "./thread-bindings.manager-CdNa6UIs.mjs";
|
|
7
6
|
import { normalizeAccountId } from "openclaw/plugin-sdk/routing";
|
|
7
|
+
import { normalizeOptionalLowercaseString, normalizeOptionalString, normalizeOptionalStringifiedId, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
8
8
|
import { formatThreadBindingDurationLabel as formatThreadBindingDurationLabel$1, resolveThreadBindingIdleTimeoutMs, resolveThreadBindingIntroText, resolveThreadBindingIntroText as resolveThreadBindingIntroText$1, resolveThreadBindingMaxAgeMs, resolveThreadBindingThreadName, resolveThreadBindingThreadName as resolveThreadBindingThreadName$1, resolveThreadBindingsEnabled } from "openclaw/plugin-sdk/conversation-runtime";
|
|
9
|
-
import { readAcpSessionEntry } from "openclaw/plugin-sdk/acp-runtime";
|
|
9
|
+
import { prepareAcpSessionEntryRead, readAcpSessionEntry, rethrowIncognitoSessionError } from "openclaw/plugin-sdk/acp-runtime";
|
|
10
10
|
import { runTasksWithConcurrency } from "openclaw/plugin-sdk/concurrency-runtime";
|
|
11
11
|
//#region extensions/discord/src/monitor/thread-bindings.config.ts
|
|
12
12
|
function resolveDiscordThreadBindingIdleTimeoutMs(params) {
|
|
@@ -41,17 +41,18 @@ async function autoBindSpawnedDiscordSubagent(params) {
|
|
|
41
41
|
const manager = getThreadBindingManager(params.accountId);
|
|
42
42
|
if (!manager) return null;
|
|
43
43
|
const managerToken = getThreadBindingToken(manager.accountId);
|
|
44
|
+
const resolveChannel = (threadId) => resolveChannelIdForBinding({
|
|
45
|
+
cfg: params.cfg,
|
|
46
|
+
accountId: manager.accountId,
|
|
47
|
+
token: managerToken,
|
|
48
|
+
threadId
|
|
49
|
+
});
|
|
44
50
|
const requesterThreadId = normalizeOptionalStringifiedId(params.threadId);
|
|
45
51
|
let channelId = "";
|
|
46
52
|
if (requesterThreadId) {
|
|
47
53
|
const existing = manager.getByThreadId(requesterThreadId);
|
|
48
54
|
if (existing?.channelId?.trim()) channelId = existing.channelId.trim();
|
|
49
|
-
else channelId = await
|
|
50
|
-
cfg: params.cfg,
|
|
51
|
-
accountId: manager.accountId,
|
|
52
|
-
token: managerToken,
|
|
53
|
-
threadId: requesterThreadId
|
|
54
|
-
}) ?? "";
|
|
55
|
+
else channelId = await resolveChannel(requesterThreadId) ?? "";
|
|
55
56
|
}
|
|
56
57
|
if (!channelId) {
|
|
57
58
|
const to = normalizeOptionalString(params.to) ?? "";
|
|
@@ -59,12 +60,7 @@ async function autoBindSpawnedDiscordSubagent(params) {
|
|
|
59
60
|
try {
|
|
60
61
|
const target = parseDiscordTarget(to, { defaultKind: "channel" });
|
|
61
62
|
if (!target || target.kind !== "channel") return null;
|
|
62
|
-
channelId = await
|
|
63
|
-
cfg: params.cfg,
|
|
64
|
-
accountId: manager.accountId,
|
|
65
|
-
token: managerToken,
|
|
66
|
-
threadId: target.id
|
|
67
|
-
}) ?? "";
|
|
63
|
+
channelId = await resolveChannel(target.id) ?? "";
|
|
68
64
|
} catch {
|
|
69
65
|
return null;
|
|
70
66
|
}
|
|
@@ -93,7 +89,6 @@ async function autoBindSpawnedDiscordSubagent(params) {
|
|
|
93
89
|
/** @deprecated Public SDK compatibility; bundled callers use the awaited variant. */
|
|
94
90
|
function unbindThreadBindingsBySessionKey(params) {
|
|
95
91
|
const ids = resolveBindingIdsForTargetSession(params);
|
|
96
|
-
if (ids.length === 0) return [];
|
|
97
92
|
const removed = [];
|
|
98
93
|
for (const bindingKey of ids) {
|
|
99
94
|
const record = BINDINGS_BY_THREAD_ID.get(bindingKey);
|
|
@@ -117,6 +112,14 @@ async function unbindThreadBindingsBySessionKeyAsync(input) {
|
|
|
117
112
|
});
|
|
118
113
|
}
|
|
119
114
|
async function reconcileAcpThreadBindingsOnStartup(params) {
|
|
115
|
+
const preparations = /* @__PURE__ */ new Map();
|
|
116
|
+
try {
|
|
117
|
+
return await reconcileAcpThreadBindings(params, preparations);
|
|
118
|
+
} finally {
|
|
119
|
+
preparations.forEach((prepared) => prepared.release());
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
async function reconcileAcpThreadBindings(params, preparations) {
|
|
120
123
|
const manager = getThreadBindingManager(params.accountId);
|
|
121
124
|
if (!manager) return {
|
|
122
125
|
checked: 0,
|
|
@@ -132,17 +135,20 @@ async function reconcileAcpThreadBindingsOnStartup(params) {
|
|
|
132
135
|
staleBindings.push(binding);
|
|
133
136
|
continue;
|
|
134
137
|
}
|
|
135
|
-
const
|
|
138
|
+
const input = {
|
|
136
139
|
cfg: params.cfg,
|
|
137
140
|
sessionKey,
|
|
138
141
|
agentId: binding.agentId
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
142
|
+
};
|
|
143
|
+
const preparation = (params.prepareSession ?? prepareAcpSessionEntryRead)(input);
|
|
144
|
+
const prepared = preparation ? await preparation : void 0;
|
|
145
|
+
if (prepared) {
|
|
146
|
+
preparations.set(binding, prepared);
|
|
147
|
+
prepared.assertCurrent();
|
|
143
148
|
}
|
|
144
|
-
|
|
145
|
-
if (
|
|
149
|
+
const session = prepared ? prepared.session : readAcpSessionEntry(input);
|
|
150
|
+
if (session?.storeReadFailed) continue;
|
|
151
|
+
if (!session?.acp) {
|
|
146
152
|
staleBindings.push(binding);
|
|
147
153
|
continue;
|
|
148
154
|
}
|
|
@@ -157,45 +163,48 @@ async function reconcileAcpThreadBindingsOnStartup(params) {
|
|
|
157
163
|
const { results: probeResults } = await runTasksWithConcurrency({
|
|
158
164
|
tasks: probeTargets.map(({ binding, sessionKey, session }) => async () => {
|
|
159
165
|
try {
|
|
160
|
-
return {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
accountId: manager.accountId,
|
|
165
|
-
sessionKey,
|
|
166
|
-
binding,
|
|
167
|
-
session
|
|
168
|
-
}))?.status ?? "uncertain"
|
|
169
|
-
};
|
|
170
|
-
} catch {
|
|
171
|
-
return {
|
|
166
|
+
return (await params.healthProbe?.({
|
|
167
|
+
cfg: params.cfg,
|
|
168
|
+
accountId: manager.accountId,
|
|
169
|
+
sessionKey,
|
|
172
170
|
binding,
|
|
173
|
-
|
|
174
|
-
};
|
|
171
|
+
session
|
|
172
|
+
}))?.status === "stale" ? binding : void 0;
|
|
173
|
+
} catch (error) {
|
|
174
|
+
rethrowIncognitoSessionError(error);
|
|
175
|
+
return;
|
|
175
176
|
}
|
|
176
177
|
}),
|
|
177
178
|
limit: ACP_STARTUP_HEALTH_PROBE_CONCURRENCY_LIMIT,
|
|
178
179
|
errorMode: "stop",
|
|
179
180
|
throwOnError: true
|
|
180
181
|
});
|
|
181
|
-
for (const
|
|
182
|
+
for (const binding of probeResults) if (binding) staleBindings.push(binding);
|
|
182
183
|
}
|
|
183
|
-
if (staleBindings.length === 0) return {
|
|
184
|
-
checked: acpBindings.length,
|
|
185
|
-
removed: 0,
|
|
186
|
-
staleSessionKeys: []
|
|
187
|
-
};
|
|
188
184
|
const staleSessionKeys = [];
|
|
189
185
|
let removed = 0;
|
|
190
186
|
for (const binding of staleBindings) {
|
|
191
187
|
staleSessionKeys.push(binding.targetSessionKey);
|
|
192
188
|
if (getThreadBindingManager(manager.accountId) !== manager || manager.getByThreadId(binding.threadId) !== binding) continue;
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
189
|
+
let sourceFailure;
|
|
190
|
+
try {
|
|
191
|
+
if (await manager.unbindThread({
|
|
192
|
+
threadId: binding.threadId,
|
|
193
|
+
expected: binding,
|
|
194
|
+
assertCurrent() {
|
|
195
|
+
try {
|
|
196
|
+
preparations.get(binding)?.assertCurrent();
|
|
197
|
+
} catch (error) {
|
|
198
|
+
sourceFailure = error;
|
|
199
|
+
throw error;
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
reason: "stale-session",
|
|
203
|
+
sendFarewell: params.sendFarewell ?? false
|
|
204
|
+
})) removed += 1;
|
|
205
|
+
} finally {
|
|
206
|
+
rethrowIncognitoSessionError(sourceFailure);
|
|
207
|
+
}
|
|
199
208
|
}
|
|
200
209
|
return {
|
|
201
210
|
checked: acpBindings.length,
|