@openclaw/discord 2026.11.5 → 2026.11.10-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/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-BXrS8-R9.mjs → allow-list-CkqpzPvP.mjs} +5 -9
- package/dist/.setup/{api-BlBD4ism.mjs → api-C4j_kC-2.mjs} +4 -6
- package/dist/.setup/{approval-handler.runtime-o2N6GRFH.mjs → approval-handler.runtime-DjtQbUPp.mjs} +10 -10
- package/dist/.setup/{approval-message-updates-DKsCfxSW.mjs → approval-message-updates-DqOXxPss.mjs} +3 -4
- package/dist/.setup/{audit-5b-FXj9R.mjs → audit-B9vk3V2z.mjs} +6 -7
- package/dist/.setup/{channel-CplVDtyZ.mjs → channel-Cihfaj84.mjs} +38 -41
- package/dist/.setup/{channel-access-9cyzozUP.mjs → channel-access-DhJhVrdZ.mjs} +1 -2
- package/dist/.setup/{channel.setup-B3MtmBQG.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-YCvQ6YLS.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-kCTw8cij.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-B9UoQG9g.mjs +90 -0
- package/dist/.setup/{discord-DGVSguhx.mjs → discord-cXPUdHQi.mjs} +98 -77
- package/dist/.setup/{doctor-eujgbnpZ.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-eDq22iSM.mjs → guilds-DYBhgnfq.mjs} +3 -4
- package/dist/.setup/{handle-action-CktwmzMz.mjs → handle-action-El1ok7Ak.mjs} +13 -12
- package/dist/.setup/{handle-action.guild-admin-WLQ7fRqI.mjs → handle-action.guild-admin-CxYfg02j.mjs} +7 -5
- package/dist/.setup/identity-link-B7KOBo_l.mjs +74 -0
- package/dist/.setup/{listeners-Df8lx3vK.mjs → listeners-DIyynRvV.mjs} +2 -3
- package/dist/.setup/{live-policy-config-DiBVuaU6.mjs → live-policy-config-DjIHWFla.mjs} +3 -5
- package/dist/.setup/{message-handler-DeoWTD-4.mjs → message-handler-BoQcvdfV.mjs} +18 -17
- package/dist/.setup/{message-handler.preflight-DKOjgF0z.mjs → message-handler.preflight-C7uhmcsV.mjs} +20 -27
- package/dist/.setup/{message-handler.preflight-pluralkit-CYZfXXb6.mjs → message-handler.preflight-pluralkit-BFntgVKc.mjs} +10 -14
- package/dist/.setup/{message-handler.process-RKRgMCJy.mjs → message-handler.process-B29pkCxQ.mjs} +54 -66
- package/dist/.setup/oauth-http-DdVyzSbo.mjs +40 -0
- package/dist/.setup/{outbound-payload-BaZmjewa.mjs → outbound-payload-Dh6xCO6z.mjs} +18 -13
- package/dist/.setup/{outbound-session-route-Cgx4i9cS.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-DezB-6xz.mjs → probe-CfGMZwFD.mjs} +5 -6
- package/dist/.setup/{provider-D63dgDSw.mjs → provider-CnDxdXUm.mjs} +252 -246
- package/dist/.setup/{provider-session.runtime-ePktW62k.mjs → provider-session.runtime-CCBGrm-d.mjs} +3 -3
- package/dist/.setup/provider.runtime-BoSMAwDb.mjs +1 -0
- package/dist/.setup/{proxy-fetch-BzXwBAXt.mjs → proxy-fetch-B8cK6FLQ.mjs} +1 -2
- package/dist/.setup/{realtime-session.runtime-rlZ3WzwC.mjs → realtime-session.runtime-OD95VAEG.mjs} +15 -25
- package/dist/.setup/{receive-recovery-C3Ks4wAQ.mjs → receive-recovery-DV_v5ROf.mjs} +3 -6
- package/dist/.setup/{resolve-allowlist-common-Bk8Fj6Ik.mjs → resolve-allowlist-common-CYdqBUgV.mjs} +3 -4
- package/dist/.setup/{resolve-channels-Bp8frXvc.mjs → resolve-channels-BNnyfCR8.mjs} +10 -9
- package/dist/.setup/{resolve-users-Cvcj22sG.mjs → resolve-users-CDMAGrzv.mjs} +5 -6
- package/dist/.setup/{rolldown-runtime-B4FMCO8f.mjs → rolldown-runtime-nwUcYXjP.mjs} +1 -2
- package/dist/.setup/{runtime-BJaCvlmq.mjs → runtime-CkeNX7ic.mjs} +62 -51
- 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-CVW7V-VZ.mjs → send-DKzwsZkm.mjs} +28 -32
- package/dist/.setup/{send.components-C8YXdnO_.mjs → send.components-CIZALYDP.mjs} +12 -14
- package/dist/.setup/{send.outbound-Uzcmh3Yd.mjs → send.outbound-cQ4Ohmsc.mjs} +11 -16
- package/dist/.setup/send.permissions-BvH_Dr8p.mjs +369 -0
- package/dist/.setup/{send.receipt-NZDOTZBU.mjs → send.receipt-CZ7ks6g7.mjs} +64 -17
- package/dist/.setup/send.shared-D2lh737v.mjs +259 -0
- package/dist/.setup/{sender-identity-76HFb8eK.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-yDUSExm2.mjs → shared-Bf7ifHlc.mjs} +14 -17
- package/dist/.setup/{shared-interactive-DmzaoKOM.mjs → shared-interactive-DKBw4SNV.mjs} +7 -12
- package/dist/.setup/{subagent-hooks-CDkdHQyy.mjs → subagent-hooks-CVmIOrAR.mjs} +4 -5
- package/dist/.setup/{system-events-yfWz150v.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-BOOzqxxM.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-zce4cpu_.mjs → thread-bindings-DTHVdmvF.mjs} +7 -10
- package/dist/.setup/{thread-bindings.manager-NywKzUtc.mjs → thread-bindings.manager-6EnH3YZh.mjs} +45 -30
- package/dist/.setup/{thread-bindings.session-updates-D0j7oh8S.mjs → thread-bindings.session-updates-BPO6pPzd.mjs} +9 -12
- package/dist/.setup/{threading-DodLYDt-.mjs → threading-PC3IIaHd.mjs} +5 -7
- package/dist/.setup/{timeouts-cIxzatmv.mjs → timeouts-CT9hnmo4.mjs} +1 -2
- package/dist/.setup/{transcripts-source-ie9GBWaU.mjs → transcripts-source-C3F_ErM1.mjs} +33 -46
- package/dist/.setup/{typing-CNlSKY5S.mjs → typing-DAv4S2fI.mjs} +2 -3
- package/dist/.setup/{voice-runtime-Dc8Su9Cm.mjs → voice-runtime-CzV3fXxV.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/directory-live-DH3tpS3x.mjs +0 -144
- package/dist/.setup/provider.runtime-DcNkwhPW.mjs +0 -1
- package/dist/.setup/send.shared-a_6Oeyg1.mjs +0 -589
- package/dist/.setup/setup-plugin-api-BExhGEhL.mjs +0 -2
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
2
|
+
// extensions/discord/src/activities/config.ts
|
|
3
|
+
function resolveDiscordActivitiesConfig(account, env = process.env) {
|
|
4
|
+
if (!account.activities) return {
|
|
5
|
+
enabled: false,
|
|
6
|
+
reason: "not-configured"
|
|
7
|
+
};
|
|
8
|
+
const clientSecret = normalizeOptionalString(account.activities.clientSecret) ?? normalizeOptionalString(env.DISCORD_CLIENT_SECRET);
|
|
9
|
+
if (!clientSecret) return {
|
|
10
|
+
enabled: false,
|
|
11
|
+
reason: "missing-client-secret"
|
|
12
|
+
};
|
|
13
|
+
const applicationId = normalizeOptionalString(account.activities.applicationId);
|
|
14
|
+
return {
|
|
15
|
+
enabled: true,
|
|
16
|
+
clientSecret,
|
|
17
|
+
...applicationId ? { applicationId } : {}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export { resolveDiscordActivitiesConfig as t };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { t as runtime_doctor_migrations_exports } from "./runtime-doctor-migrations-
|
|
1
|
+
import { t as runtime_doctor_migrations_exports } from "./runtime-doctor-migrations-BpV1jKk0.mjs";
|
|
2
2
|
import { buildSecretInputSchema, registerSensitiveConfigSchema } from "openclaw/plugin-sdk/secret-input";
|
|
3
3
|
import { normalizeLegacyDmAliases } from "openclaw/plugin-sdk/channel-config-helpers";
|
|
4
4
|
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
5
5
|
import { createChannelConfigUiHints } from "openclaw/plugin-sdk/channel-core";
|
|
6
6
|
import { ChannelBotLoopProtectionSchema, ChannelDangerouslyAllowNameMatchingSchema, ChannelPreviewStreamingConfigSchema, ChannelThreadBindingsSchema, ProviderCommandsSchema, TtsConfigSchema, buildChannelAccountSchemaParts, buildChannelAllowBotsSchema, buildChannelConfigSchema, buildChannelExecApprovalsSchema, buildChannelReactionShape, buildGroupEntrySchema, refineChannelDmPolicy } from "openclaw/plugin-sdk/channel-config-schema";
|
|
7
7
|
import { z } from "zod";
|
|
8
|
-
|
|
8
|
+
// extensions/discord/src/config-ui-hints.ts
|
|
9
9
|
const discordChannelConfigUiHints = {
|
|
10
10
|
"": {
|
|
11
11
|
label: "Discord",
|
|
@@ -65,7 +65,7 @@ const discordChannelConfigUiHints = {
|
|
|
65
65
|
},
|
|
66
66
|
"thread.inheritParent": {
|
|
67
67
|
label: "Discord Thread Parent Inheritance",
|
|
68
|
-
help: "If true, Discord thread sessions inherit the parent channel
|
|
68
|
+
help: "If true, Discord thread sessions inherit the parent channel chat history (default: false)."
|
|
69
69
|
},
|
|
70
70
|
"threadBindings.enabled": {
|
|
71
71
|
label: "Discord Thread Binding Enabled",
|
|
@@ -85,7 +85,7 @@ const discordChannelConfigUiHints = {
|
|
|
85
85
|
},
|
|
86
86
|
"threadBindings.defaultSpawnContext": {
|
|
87
87
|
label: "Discord Thread Spawn Context",
|
|
88
|
-
help: "Default native subagent context for thread-bound spawns. \"fork\" starts from the requester
|
|
88
|
+
help: "Default native subagent context for thread-bound spawns. \"fork\" starts from the requester chat history; \"isolated\" starts clean. Default: \"fork\"."
|
|
89
89
|
},
|
|
90
90
|
"agentComponents.ttlMs": {
|
|
91
91
|
label: "Discord Component TTL (ms)",
|
|
@@ -335,8 +335,7 @@ const discordChannelConfigUiHints = {
|
|
|
335
335
|
help: "Optional Activity application ID. Defaults to the bot application ID learned at gateway startup."
|
|
336
336
|
}
|
|
337
337
|
};
|
|
338
|
-
|
|
339
|
-
//#region extensions/discord/src/config-schema.ts
|
|
338
|
+
// extensions/discord/src/config-schema.ts
|
|
340
339
|
const SecretInputSchema = buildSecretInputSchema();
|
|
341
340
|
const DiscordIdSchema = z.union([z.string(), z.number()]).transform((value, ctx) => {
|
|
342
341
|
if (typeof value === "number") {
|
|
@@ -638,5 +637,4 @@ const DiscordConfigSchemaBase = DiscordAccountSchemaBase.safeExtend({
|
|
|
638
637
|
});
|
|
639
638
|
const DiscordConfigSchema = z.preprocess(normalizeShippedDiscordDmAliases, DiscordConfigSchemaBase);
|
|
640
639
|
const DiscordChannelConfigSchema = buildChannelConfigSchema(DiscordConfigSchema, { uiHints: discordChannelConfigUiHints });
|
|
641
|
-
//#endregion
|
|
642
640
|
export { DiscordChannelConfigSchema as t };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { g as shouldIgnoreStaleDiscordRouteBinding } from "./outbound-session-route-
|
|
1
|
+
import { g as shouldIgnoreStaleDiscordRouteBinding } from "./outbound-session-route-G_fK5RAh.mjs";
|
|
2
2
|
import { logVerbose } from "openclaw/plugin-sdk/runtime-env";
|
|
3
3
|
import { inspectRuntimeConversationBindingRoute, resolveConfiguredBindingRoute, resolveRuntimeConversationBindingRouteAsync } from "openclaw/plugin-sdk/conversation-binding-runtime";
|
|
4
|
-
|
|
4
|
+
// extensions/discord/src/monitor/conversation-binding-route.ts
|
|
5
5
|
function prepareDiscordBindingRoute(params) {
|
|
6
6
|
let baseRoute;
|
|
7
7
|
return {
|
|
@@ -64,5 +64,4 @@ function applyDiscordBindingRoute(params, resolvedRuntimeRoute, baseRoute) {
|
|
|
64
64
|
configuredRoute
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
-
//#endregion
|
|
68
67
|
export { resolveDiscordConversationBindingRouteAsync as n, resolveDiscordConversationBindingRoute as t };
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { i as listDiscordAccountIds, l as resolveDiscordAccount, r as isDiscordAccountEnabledForRuntime } from "./accounts-DtjvhJUj.mjs";
|
|
2
|
+
import { d as createDiscordRestClient, o as fetchThreadForkPermissionsDiscord, r as canViewDiscordGuildChannel } from "./send.permissions-BvH_Dr8p.mjs";
|
|
3
|
+
import { A as getThreadMember, O as getChannel, T as createThread, q as withDiscordRequestAuthority } from "./discord-cXPUdHQi.mjs";
|
|
4
|
+
import { v as classifyDiscordDeliveryFailure } from "./send.receipt-CZ7ks6g7.mjs";
|
|
5
|
+
import { n as resolveDiscordChannelId } from "./target-parsing-BiuhcK9Q.mjs";
|
|
6
|
+
import { createRuntimeConfigReader } from "openclaw/plugin-sdk/runtime-config-snapshot";
|
|
7
|
+
import { ChannelFlags, ChannelType, Routes } from "discord-api-types/v10";
|
|
8
|
+
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
9
|
+
import { getSessionBindingService } from "openclaw/plugin-sdk/conversation-binding-runtime";
|
|
10
|
+
import { isDeepStrictEqual } from "node:util";
|
|
11
|
+
// extensions/discord/src/conversation-fork.ts
|
|
12
|
+
/** Native placement only: core owns transcript copying and excerpt selection. */
|
|
13
|
+
const prepareDiscordConversationFork = async (params) => {
|
|
14
|
+
const sourceId = params.source.conversationId;
|
|
15
|
+
const senderId = params.senderId;
|
|
16
|
+
if (!params.isGroup || !/^\d+$/u.test(sourceId) || !senderId || !/^\d+$/u.test(senderId)) return {
|
|
17
|
+
ok: false,
|
|
18
|
+
reason: "Discord /fork requires an existing server thread or forum post and an identified requester."
|
|
19
|
+
};
|
|
20
|
+
if (params.source.threadId && params.source.threadId !== sourceId) return {
|
|
21
|
+
ok: false,
|
|
22
|
+
reason: "Discord fork source does not match the current native thread."
|
|
23
|
+
};
|
|
24
|
+
let expectedParentId;
|
|
25
|
+
try {
|
|
26
|
+
expectedParentId = params.source.parentConversationId ? resolveDiscordChannelId(params.source.parentConversationId) : void 0;
|
|
27
|
+
} catch {
|
|
28
|
+
return {
|
|
29
|
+
ok: false,
|
|
30
|
+
reason: "Discord fork parent channel is invalid."
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const readConfig = createRuntimeConfigReader(params.cfg);
|
|
34
|
+
const cfg = readConfig();
|
|
35
|
+
const account = resolveDiscordAccount({
|
|
36
|
+
cfg,
|
|
37
|
+
accountId: params.accountId
|
|
38
|
+
});
|
|
39
|
+
if (!listDiscordAccountIds(cfg).includes(account.accountId) || !isDiscordAccountEnabledForRuntime(account, cfg) || !account.token) return {
|
|
40
|
+
ok: false,
|
|
41
|
+
reason: "The selected Discord bot account is disabled or unavailable."
|
|
42
|
+
};
|
|
43
|
+
const assertCurrent = () => {
|
|
44
|
+
params.signal?.throwIfAborted();
|
|
45
|
+
params.assertCurrent();
|
|
46
|
+
const currentCfg = readConfig();
|
|
47
|
+
const current = resolveDiscordAccount({
|
|
48
|
+
cfg: currentCfg,
|
|
49
|
+
accountId: account.accountId
|
|
50
|
+
});
|
|
51
|
+
if (!listDiscordAccountIds(currentCfg).includes(account.accountId) || !isDiscordAccountEnabledForRuntime(current, currentCfg) || current.token !== account.token || !isDeepStrictEqual(current.config, account.config)) throw new Error("Discord fork account changed. Run /fork again with the current account.");
|
|
52
|
+
};
|
|
53
|
+
const opts = {
|
|
54
|
+
cfg: params.cfg,
|
|
55
|
+
accountId: account.accountId,
|
|
56
|
+
signal: params.signal
|
|
57
|
+
};
|
|
58
|
+
const rest = createDiscordRestClient(opts).rest;
|
|
59
|
+
const service = getSessionBindingService();
|
|
60
|
+
const assertBindingSupported = () => {
|
|
61
|
+
assertCurrent();
|
|
62
|
+
const capabilities = service.getCapabilities({
|
|
63
|
+
channel: "discord",
|
|
64
|
+
accountId: account.accountId
|
|
65
|
+
});
|
|
66
|
+
if (!capabilities.adapterAvailable || !capabilities.bindSupported || !capabilities.placements.includes("current")) throw new Error("Discord thread bindings are unavailable. Enable thread bindings for this bot account before using /fork.");
|
|
67
|
+
};
|
|
68
|
+
const qualify = async () => {
|
|
69
|
+
assertBindingSupported();
|
|
70
|
+
const source = await getChannel(rest, sourceId);
|
|
71
|
+
assertCurrent();
|
|
72
|
+
if (source.type !== ChannelType.PublicThread && source.type !== ChannelType.PrivateThread) throw new Error("Discord /fork supports existing text threads and forum posts, not DMs, unthreaded channels, announcement threads, or media posts.");
|
|
73
|
+
const parentId = source.parent_id;
|
|
74
|
+
const guildId = source.guild_id;
|
|
75
|
+
if (!parentId || !guildId || expectedParentId && expectedParentId !== parentId) throw new Error("Discord could not verify the source thread's parent server channel.");
|
|
76
|
+
const parent = await getChannel(rest, parentId);
|
|
77
|
+
assertCurrent();
|
|
78
|
+
if (parent.type !== ChannelType.GuildText && parent.type !== ChannelType.GuildForum || parent.guild_id !== guildId || source.type === ChannelType.PrivateThread && parent.type !== ChannelType.GuildText) throw new Error("Discord /fork supports text-channel threads and forum posts only; media and announcement parents are not supported.");
|
|
79
|
+
const { requesterCanRead, botPermissions } = await fetchThreadForkPermissionsDiscord(guildId, source, parent, senderId, {
|
|
80
|
+
...opts,
|
|
81
|
+
rest
|
|
82
|
+
});
|
|
83
|
+
assertCurrent();
|
|
84
|
+
if (!requesterCanRead) throw new Error("Discord could not confirm your access to the source thread, its message history, and its parent channel.");
|
|
85
|
+
if ([
|
|
86
|
+
"ViewChannel",
|
|
87
|
+
"ReadMessageHistory",
|
|
88
|
+
"SendMessagesInThreads",
|
|
89
|
+
source.type === ChannelType.PrivateThread ? "CreatePrivateThreads" : parent.type === ChannelType.GuildForum ? "SendMessages" : "CreatePublicThreads"
|
|
90
|
+
].some((permission) => !botPermissions.includes(permission))) throw new Error("The Discord bot needs View Channel, Read Message History, Send Messages in Threads, and permission to create this kind of thread or forum post in the parent channel.");
|
|
91
|
+
const tags = parent.type === ChannelType.GuildForum ? (source.applied_tags ?? []).filter((id) => parent.available_tags.some((tag) => tag.id === id && (!tag.moderated || botPermissions.includes("ManageThreads")))).slice(0, 5) : [];
|
|
92
|
+
if (parent.type === ChannelType.GuildForum && ((parent.flags ?? 0) & ChannelFlags.RequireTag) !== 0 && tags.length === 0) throw new Error("This Discord forum requires a tag, but no source tag can be reused. Add an available tag to the source post before forking.");
|
|
93
|
+
return {
|
|
94
|
+
source,
|
|
95
|
+
parent,
|
|
96
|
+
parentId,
|
|
97
|
+
guildId,
|
|
98
|
+
tags
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
let prepared;
|
|
102
|
+
try {
|
|
103
|
+
prepared = await withDiscordRequestAuthority(assertCurrent, qualify);
|
|
104
|
+
} catch (error) {
|
|
105
|
+
assertCurrent();
|
|
106
|
+
return {
|
|
107
|
+
ok: false,
|
|
108
|
+
reason: error instanceof Error ? error.message : "Discord could not verify this fork source."
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
let attempted = false;
|
|
112
|
+
return {
|
|
113
|
+
ok: true,
|
|
114
|
+
assertCurrent,
|
|
115
|
+
formatRecap: (text) => {
|
|
116
|
+
const literal = text.replace(/@/gu, "@").replace(/</gu, "‹");
|
|
117
|
+
const runs = literal.match(/`+/gu) ?? [];
|
|
118
|
+
const fence = "`".repeat(Math.max(3, ...runs.map((run) => run.length + 1)));
|
|
119
|
+
return {
|
|
120
|
+
text: [
|
|
121
|
+
fence,
|
|
122
|
+
literal,
|
|
123
|
+
fence
|
|
124
|
+
].join("\n"),
|
|
125
|
+
channelData: { discord: { literalText: true } }
|
|
126
|
+
};
|
|
127
|
+
},
|
|
128
|
+
create: async (targetSessionKey) => {
|
|
129
|
+
assertCurrent();
|
|
130
|
+
if (attempted) throw new Error("This Discord fork creation was already attempted. Inspect the parent channel before running /fork again.");
|
|
131
|
+
attempted = true;
|
|
132
|
+
const fresh = await withDiscordRequestAuthority(assertCurrent, qualify);
|
|
133
|
+
assertCurrent();
|
|
134
|
+
if (fresh.source.type !== prepared.source.type || fresh.parentId !== prepared.parentId || fresh.guildId !== prepared.guildId) throw new Error("The Discord fork source changed while copying the session. No sibling was created.");
|
|
135
|
+
const name = truncateUtf16Safe((params.title?.trim() || "Fork: " + fresh.source.name).replace(/[\r\n\t]/gu, " "), 100);
|
|
136
|
+
const privateThread = fresh.source.type === ChannelType.PrivateThread;
|
|
137
|
+
const forum = fresh.parent.type === ChannelType.GuildForum;
|
|
138
|
+
const body = {
|
|
139
|
+
name,
|
|
140
|
+
...fresh.parent.default_auto_archive_duration !== void 0 ? { auto_archive_duration: fresh.parent.default_auto_archive_duration } : {},
|
|
141
|
+
...forum ? {
|
|
142
|
+
message: {
|
|
143
|
+
content: "Forked conversation. Context follows.",
|
|
144
|
+
allowed_mentions: { parse: [] }
|
|
145
|
+
},
|
|
146
|
+
...fresh.tags.length ? { applied_tags: fresh.tags } : {}
|
|
147
|
+
} : {
|
|
148
|
+
type: fresh.source.type,
|
|
149
|
+
...privateThread ? { invitable: false } : {}
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
let created;
|
|
153
|
+
assertBindingSupported();
|
|
154
|
+
try {
|
|
155
|
+
created = await withDiscordRequestAuthority(assertCurrent, () => createThread(rest, fresh.parentId, { body }));
|
|
156
|
+
} catch (error) {
|
|
157
|
+
const outcome = classifyDiscordDeliveryFailure(error);
|
|
158
|
+
throw new Error(outcome === "rejected" || outcome === "pre-connect" ? "Discord did not create the fork. Check bot permissions and the parent channel's thread requirements." : "Discord fork creation is uncertain; a sibling may exist. Inspect the parent channel before retrying. No automatic retry was made.", { cause: error });
|
|
159
|
+
}
|
|
160
|
+
const url = /^\d+$/u.test(created.id ?? "") ? "https://discord.com/channels/" + fresh.guildId + "/" + created.id : void 0;
|
|
161
|
+
try {
|
|
162
|
+
assertCurrent();
|
|
163
|
+
if (!url || created.id === sourceId || created.id === fresh.parentId || created.parent_id !== fresh.parentId || created.guild_id !== fresh.guildId || created.type !== fresh.source.type || privateThread && created.thread_metadata?.invitable !== false) throw new Error("Discord did not confirm the expected sibling placement and privacy.");
|
|
164
|
+
if (privateThread) await withDiscordRequestAuthority(assertCurrent, async () => {
|
|
165
|
+
await rest.put(Routes.threadMembers(created.id, senderId));
|
|
166
|
+
assertCurrent();
|
|
167
|
+
const member = await getThreadMember(rest, created.id, senderId);
|
|
168
|
+
assertCurrent();
|
|
169
|
+
if (member.user_id !== senderId || !await canViewDiscordGuildChannel(fresh.guildId, created.id, senderId, opts)) throw new Error("Discord could not confirm requester access to the private fork.");
|
|
170
|
+
});
|
|
171
|
+
assertCurrent();
|
|
172
|
+
const binding = await withDiscordRequestAuthority(assertCurrent, () => service.bind({
|
|
173
|
+
targetSessionKey,
|
|
174
|
+
targetKind: "session",
|
|
175
|
+
placement: "current",
|
|
176
|
+
conversation: {
|
|
177
|
+
channel: "discord",
|
|
178
|
+
accountId: account.accountId,
|
|
179
|
+
conversationId: created.id,
|
|
180
|
+
parentConversationId: fresh.parentId
|
|
181
|
+
},
|
|
182
|
+
metadata: { boundBy: senderId },
|
|
183
|
+
assertCurrent
|
|
184
|
+
}));
|
|
185
|
+
assertCurrent();
|
|
186
|
+
return {
|
|
187
|
+
binding,
|
|
188
|
+
url,
|
|
189
|
+
...privateThread ? { notice: "Private fork: only you and the bot are added; other source members are not automatically included. Server members with Manage Threads may still have access. Member invitations are disabled." } : {}
|
|
190
|
+
};
|
|
191
|
+
} catch (error) {
|
|
192
|
+
throw new Error("Discord created a sibling" + (url ? " at " + url : " with an unverified identity") + ", but fork setup did not complete. No recap was sent. Inspect this sibling before retrying.", { cause: error });
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
export { prepareDiscordConversationFork };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-
|
|
2
|
-
import { c as resolveDefaultDiscordAccountId, s as mergeDiscordAccountConfig, u as resolveDiscordAccountAllowFrom } from "./accounts-
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.mjs";
|
|
2
|
+
import { c as resolveDefaultDiscordAccountId, s as mergeDiscordAccountConfig, u as resolveDiscordAccountAllowFrom } from "./accounts-DtjvhJUj.mjs";
|
|
3
3
|
import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
4
4
|
import { createResolvedDirectoryEntriesLister } from "openclaw/plugin-sdk/directory-config-runtime";
|
|
5
|
-
|
|
5
|
+
// extensions/discord/src/directory-config.ts
|
|
6
6
|
var directory_config_exports = /* @__PURE__ */ __exportAll({
|
|
7
7
|
listDiscordDirectoryGroupsFromConfig: () => listDiscordDirectoryGroupsFromConfig,
|
|
8
8
|
listDiscordDirectoryPeersFromConfig: () => listDiscordDirectoryPeersFromConfig
|
|
@@ -42,5 +42,4 @@ const listDiscordDirectoryGroupsFromConfig = createResolvedDirectoryEntriesListe
|
|
|
42
42
|
return /^\d+$/.test(cleaned) ? `channel:${cleaned}` : null;
|
|
43
43
|
}
|
|
44
44
|
});
|
|
45
|
-
//#endregion
|
|
46
45
|
export { listDiscordDirectoryGroupsFromConfig as n, listDiscordDirectoryPeersFromConfig as r, directory_config_exports as t };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.mjs";
|
|
2
|
+
import { h as normalizeDiscordToken, l as resolveDiscordAccount } from "./accounts-DtjvhJUj.mjs";
|
|
3
|
+
import { a as normalizeDiscordDisplaySlug } from "./allow-list-CkqpzPvP.mjs";
|
|
4
|
+
import { f as rememberDiscordDirectoryUser } from "./send.receipt-CZ7ks6g7.mjs";
|
|
5
|
+
import { t as DISCORD_DIRECTORY_LOOKUP_TIMEOUT_MS } from "./api-C4j_kC-2.mjs";
|
|
6
|
+
import { n as listGuilds, r as searchDiscordGuildMembers, t as listDiscordGuildChannels } from "./guilds-DYBhgnfq.mjs";
|
|
7
|
+
import { normalizeOptionalLowercaseString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
8
|
+
// extensions/discord/src/directory-live.ts
|
|
9
|
+
var directory_live_exports = /* @__PURE__ */ __exportAll({
|
|
10
|
+
listDiscordDirectoryGroupsLive: () => listDiscordDirectoryGroupsLive,
|
|
11
|
+
listDiscordDirectoryPeersLive: () => listDiscordDirectoryPeersLive
|
|
12
|
+
});
|
|
13
|
+
function resolveDiscordDirectoryAccess(params) {
|
|
14
|
+
const account = resolveDiscordAccount({
|
|
15
|
+
cfg: params.cfg,
|
|
16
|
+
accountId: params.accountId
|
|
17
|
+
});
|
|
18
|
+
const token = normalizeDiscordToken(account.token, "channels.discord.token");
|
|
19
|
+
if (!token) return null;
|
|
20
|
+
return {
|
|
21
|
+
token,
|
|
22
|
+
query: normalizeOptionalLowercaseString(params.query) ?? "",
|
|
23
|
+
accountId: account.accountId
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
async function listDiscordDirectoryLive(params, kind) {
|
|
27
|
+
const access = resolveDiscordDirectoryAccess(params);
|
|
28
|
+
if (!access || kind === "user" && !access.query) return [];
|
|
29
|
+
const { token, query, accountId } = access;
|
|
30
|
+
const channelQuery = normalizeDiscordDisplaySlug(query);
|
|
31
|
+
const guilds = await listGuilds(token, fetch, { timeoutMs: DISCORD_DIRECTORY_LOOKUP_TIMEOUT_MS });
|
|
32
|
+
const rows = [];
|
|
33
|
+
const seenUserIds = /* @__PURE__ */ new Set();
|
|
34
|
+
const limit = kind === "user" && typeof params.limit === "number" && params.limit > 0 ? params.limit : 25;
|
|
35
|
+
for (const guild of guilds) {
|
|
36
|
+
if (!guild.id || !guild.name) continue;
|
|
37
|
+
if (kind === "group") {
|
|
38
|
+
const channels = await listDiscordGuildChannels(token, fetch, guild.id);
|
|
39
|
+
for (const channel of channels) {
|
|
40
|
+
const name = channel.name?.trim();
|
|
41
|
+
if (!name) continue;
|
|
42
|
+
if (channelQuery && !normalizeDiscordDisplaySlug(name).includes(channelQuery)) continue;
|
|
43
|
+
rows.push({
|
|
44
|
+
kind: "group",
|
|
45
|
+
id: `channel:${channel.id}`,
|
|
46
|
+
name,
|
|
47
|
+
handle: `#${name}`,
|
|
48
|
+
raw: channel
|
|
49
|
+
});
|
|
50
|
+
if (typeof params.limit === "number" && params.limit > 0 && rows.length >= params.limit) return rows;
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
const members = await searchDiscordGuildMembers(token, fetch, guild.id, query, Math.min(limit, 100));
|
|
54
|
+
for (const member of members) {
|
|
55
|
+
const user = member.user;
|
|
56
|
+
if (!user?.id) continue;
|
|
57
|
+
rememberDiscordDirectoryUser({
|
|
58
|
+
accountId,
|
|
59
|
+
userId: user.id,
|
|
60
|
+
handles: [
|
|
61
|
+
user.username,
|
|
62
|
+
user.global_name,
|
|
63
|
+
member.nick,
|
|
64
|
+
user.username ? `@${user.username}` : null
|
|
65
|
+
]
|
|
66
|
+
});
|
|
67
|
+
if (seenUserIds.has(user.id)) continue;
|
|
68
|
+
seenUserIds.add(user.id);
|
|
69
|
+
const name = member.nick?.trim() || user.global_name?.trim() || user.username?.trim();
|
|
70
|
+
rows.push({
|
|
71
|
+
kind: "user",
|
|
72
|
+
id: `user:${user.id}`,
|
|
73
|
+
name: name || void 0,
|
|
74
|
+
handle: user.username ? `@${user.username}` : void 0,
|
|
75
|
+
rank: user.bot ? 0 : 1,
|
|
76
|
+
raw: member
|
|
77
|
+
});
|
|
78
|
+
if (rows.length >= limit) return rows;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return rows;
|
|
83
|
+
}
|
|
84
|
+
function listDiscordDirectoryGroupsLive(params) {
|
|
85
|
+
return listDiscordDirectoryLive(params, "group");
|
|
86
|
+
}
|
|
87
|
+
function listDiscordDirectoryPeersLive(params) {
|
|
88
|
+
return listDiscordDirectoryLive(params, "user");
|
|
89
|
+
}
|
|
90
|
+
export { listDiscordDirectoryGroupsLive as n, listDiscordDirectoryPeersLive as r, directory_live_exports as t };
|