@openclaw/discord 2026.9.6 → 2026.9.8
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/assets/icon.png +0 -0
- package/dist/.setup/{account-inspect-BwQj24ht.mjs → account-inspect-De8hOUxG.mjs} +1 -1
- package/dist/.setup/{accounts-CwJQoLjM.mjs → accounts-ChaMcixG.mjs} +1 -4
- package/dist/.setup/{activities-api-COU4-0nR.mjs → activities-api-tvbsU2e3.mjs} +38 -66
- package/dist/.setup/{api-CBK9zcq5.mjs → api-DVbJwZVt.mjs} +10 -2
- package/dist/.setup/{approval-handler.runtime-CbBktBb4.mjs → approval-handler.runtime-DxCK2Rux.mjs} +49 -125
- package/dist/.setup/{approval-message-updates-jf9zMaIC.mjs → approval-message-updates-BKFqavHZ.mjs} +2 -2
- package/dist/.setup/{audit-vKbh-LFR.mjs → audit-CLg9I71N.mjs} +5 -5
- package/dist/.setup/{channel-Dv4e3Jpc.mjs → channel-DxlUVU9t.mjs} +121 -227
- package/dist/.setup/{channel-type-DKnjV1XW.mjs → channel-type-DRCrEMss.mjs} +22 -22
- package/dist/.setup/{channel.setup-0NX6FFwi.mjs → channel.setup-CRo1GjV7.mjs} +6 -9
- package/dist/.setup/{components-yBEb75bB.mjs → components-Cq1PvIpN.mjs} +41 -69
- package/dist/.setup/{config-schema-CiZz-mtA.mjs → config-schema-oxELUSDx.mjs} +19 -44
- package/dist/.setup/{conversation-binding-route-B7qImK_b.mjs → conversation-binding-route-Caz_XuFH.mjs} +10 -5
- package/dist/.setup/{directory-config-BytTftz-.mjs → directory-config-esqNn0Eo.mjs} +6 -9
- package/dist/.setup/{directory-live--EGTH0DC.mjs → directory-live-DtKRHuGV.mjs} +6 -12
- package/dist/.setup/{discord-BXpHW-cu.mjs → discord-0xJYfdDD.mjs} +82 -386
- package/dist/.setup/{doctor-D1R-uFIu.mjs → doctor-BCl1H5tl.mjs} +21 -36
- package/dist/.setup/{doctor-contract-Co5vRCZ6.mjs → doctor-contract-CvvgwrrG.mjs} +41 -50
- package/dist/.setup/{channel-actions.runtime-leZuw01r.mjs → handle-action-CUvQWnE7.mjs} +67 -104
- package/dist/.setup/{handle-action.guild-admin-DcFa8NwA.mjs → handle-action.guild-admin-Df-8gVle.mjs} +62 -120
- package/dist/.setup/{live-policy-config-eKQ-PLdy.mjs → live-policy-config-8Pv20CHc.mjs} +2 -3
- package/dist/.setup/{message-handler-X6ejmbtY.mjs → message-handler-B-Jk4oDk.mjs} +18 -94
- package/dist/.setup/{message-handler.preflight-pluralkit-8Xji34AF.mjs → message-handler.preflight-pluralkit-CWLUBVcx.mjs} +8 -10
- package/dist/.setup/{message-handler.preflight-DE_POxFc.mjs → message-handler.preflight-v-__NSDq.mjs} +69 -180
- package/dist/.setup/{message-handler.process-CCmIVnxy.mjs → message-handler.process-BNFFuChn.mjs} +65 -86
- package/dist/.setup/{outbound-adapter-ClIgmu4F.mjs → outbound-adapter-BobT-kse.mjs} +105 -19
- package/dist/.setup/{outbound-session-route-VulUE0yV.mjs → outbound-session-route-zVGxxceg.mjs} +140 -108
- package/dist/.setup/{pluralkit-CdAt1G0P.mjs → pluralkit-a6_NLfH9.mjs} +1 -1
- package/dist/.setup/{presence-cache-dYSHPWMx.mjs → presence-cache-Di3H3DIU.mjs} +0 -4
- package/dist/.setup/{probe-CupW4we4.mjs → probe-LYrIHlBF.mjs} +13 -4
- package/dist/.setup/{provider-iOf73HW-.mjs → provider-B_G5hASF.mjs} +721 -1416
- package/dist/.setup/provider-session.runtime-BYlTBFD2.mjs +6 -0
- package/dist/.setup/provider.runtime-CUE3UxER.mjs +2 -0
- package/dist/.setup/{realtime-session.runtime-Dz8uVutq.mjs → realtime-session.runtime-oUd9DOcz.mjs} +41 -55
- package/dist/.setup/{receive-recovery-DHst8WRx.mjs → receive-recovery-CHPOsnLc.mjs} +1 -4
- package/dist/.setup/{resolve-allowlist-common-CwMBzbx9.mjs → resolve-allowlist-common-DPdRggu5.mjs} +4 -7
- package/dist/.setup/{resolve-channels-BbvsLQOZ.mjs → resolve-channels-BFPNRmVv.mjs} +21 -40
- package/dist/.setup/{resolve-users-ByFlR7LQ.mjs → resolve-users-0-aBuCy3.mjs} +4 -4
- package/dist/.setup/{retry-BEYkDy0P.mjs → retry-pz_cSha2.mjs} +3 -3
- package/dist/.setup/rolldown-runtime-B4FMCO8f.mjs +28 -0
- package/dist/.setup/{runtime-B8lJfyrA.mjs → runtime-FN000lxA.mjs} +60 -162
- package/dist/.setup/runtime-doctor-migrations-CshUGl36.mjs +159 -0
- package/dist/.setup/{runtime-DisDbixd.mjs → runtime-sUksZ--Q.mjs} +2 -5
- package/dist/.setup/{secret-config-contract-DFu9hfU8.mjs → secret-config-contract-uOE2J7yM.mjs} +15 -85
- package/dist/.setup/{security-audit-s5w50-Ly.mjs → security-audit-Cdaegq7C.mjs} +3 -1
- package/dist/.setup/{send-CIBzvXjS.mjs → send-CrfEI6Bs.mjs} +53 -108
- package/dist/.setup/{send.components-ChY21qr-.mjs → send.components-DxQAMfES.mjs} +62 -107
- package/dist/.setup/{send.outbound-QTyuFupn.mjs → send.outbound-BISKnb-a.mjs} +66 -140
- package/dist/.setup/{send.shared-VNvWfX2T.mjs → send.shared-DGFkbkQR.mjs} +10 -25
- package/dist/.setup/{sender-identity-0Ymgvmaj.mjs → sender-identity-B9X5Vb9R.mjs} +2 -3
- package/dist/.setup/setup-plugin-api-BQUBxbhe.mjs +3 -0
- package/dist/.setup/{shared-DHPDaMSx.mjs → shared-B3wZ4hN-.mjs} +25 -32
- package/dist/.setup/{subagent-hooks-CjW7r8Pe.mjs → subagent-hooks-nlUE9ow7.mjs} +5 -6
- package/dist/.setup/system-events-CdeZnvPV.mjs +33 -0
- package/dist/.setup/{target-resolver-BXpy6VT8.mjs → target-resolver-BuLapkhy.mjs} +9 -12
- package/dist/.setup/targets-0KUcEIYx.mjs +3 -0
- package/dist/.setup/{thread-bindings-CEh2dhqP.mjs → thread-bindings-D7TfgjR_.mjs} +33 -35
- package/dist/.setup/{thread-bindings.manager-ve-i6oqt.mjs → thread-bindings.manager-DN-NissX.mjs} +325 -233
- package/dist/.setup/thread-bindings.session-updates-CshfKghV.mjs +359 -0
- package/dist/.setup/{thread-bindings.state-BThFQEga.mjs → thread-bindings.state-g6v9zAym.mjs} +21 -62
- package/dist/.setup/{transcripts-source-DVegW0WI.mjs → transcripts-source-p8EV179h.mjs} +76 -235
- package/dist/.setup/{typing-BKZL5fGj.mjs → typing-BiHCzBRu.mjs} +2 -1
- package/dist/.setup/{voice-runtime-elTtjEIG.mjs → voice-runtime-B46rcwrG.mjs} +140 -244
- package/dist/account-inspect-api.js +1 -1
- package/dist/action-runtime-api.js +1 -1
- package/dist/activities-api.js +1 -1
- package/dist/api.js +18 -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 +4 -4
- package/dist/index.js +1 -1
- package/dist/runtime-api.js +20 -20
- package/dist/secret-contract-api.js +1 -1
- package/dist/security-audit-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 +15 -24
- package/dist/subagent-hooks-api.js +3 -4
- package/dist/transcripts-source-api.js +1 -1
- package/node_modules/@types/node/README.md +2 -2
- package/node_modules/@types/node/child_process.d.ts +1 -1
- package/node_modules/@types/node/crypto.d.ts +20 -8
- package/node_modules/@types/node/ffi.d.ts +14 -0
- package/node_modules/@types/node/http2.d.ts +3 -2
- package/node_modules/@types/node/net.d.ts +16 -4
- package/node_modules/@types/node/package.json +2 -17
- package/node_modules/@types/node/process.d.ts +1 -0
- package/node_modules/@types/node/quic.d.ts +39 -1
- package/node_modules/@types/node/stream/iter.d.ts +9 -12
- package/node_modules/@types/node/test/reporters.d.ts +1 -0
- package/node_modules/@types/node/test.d.ts +72 -0
- package/node_modules/@types/node/tls.d.ts +14 -10
- package/node_modules/@types/node/vm.d.ts +2 -1
- package/node_modules/@types/node/worker_threads.d.ts +4 -1
- package/node_modules/typebox/build/compile/code.mjs +1 -2
- package/node_modules/typebox/build/compile/validator.mjs +5 -1
- package/node_modules/typebox/build/format/iri.mjs +16 -9
- package/node_modules/typebox/build/guard/emit.mjs +2 -2
- package/node_modules/typebox/build/guard/guard.d.mts +7 -5
- package/node_modules/typebox/build/guard/guard.mjs +14 -9
- package/node_modules/typebox/build/guard/index.mjs +6 -0
- package/node_modules/typebox/build/guard/unicode/unicode.d.mts +6 -0
- package/node_modules/typebox/build/guard/unicode/unicode.mjs +35 -0
- package/node_modules/typebox/build/guard/{string.mjs → unicode/unicode_segment.mjs} +16 -19
- package/node_modules/typebox/build/schema/build.mjs +2 -3
- package/node_modules/typebox/build/schema/engine/_pathing.d.mts +1 -0
- package/node_modules/typebox/build/schema/engine/_pathing.mjs +11 -0
- package/node_modules/typebox/build/schema/engine/_refine.mjs +13 -5
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +2 -1
- package/node_modules/typebox/build/schema/engine/dependencies.mjs +2 -1
- package/node_modules/typebox/build/schema/engine/dependentSchemas.mjs +2 -1
- package/node_modules/typebox/build/schema/engine/dynamicRef.d.mts +1 -1
- package/node_modules/typebox/build/schema/engine/dynamicRef.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/format.mjs +9 -2
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +3 -2
- package/node_modules/typebox/build/schema/engine/properties.mjs +3 -2
- package/node_modules/typebox/build/schema/engine/propertyNames.mjs +2 -1
- package/node_modules/typebox/build/schema/engine/recursiveRef.d.mts +1 -1
- package/node_modules/typebox/build/schema/engine/recursiveRef.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/ref.d.mts +1 -1
- package/node_modules/typebox/build/schema/engine/ref.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/schema.mjs +24 -24
- package/node_modules/typebox/build/schema/parse.mjs +3 -0
- package/node_modules/typebox/build/schema/pointer/pointer.d.mts +1 -6
- package/node_modules/typebox/build/schema/pointer/pointer.mjs +47 -64
- package/node_modules/typebox/build/system/settings/internal.d.mts +2 -0
- package/node_modules/typebox/build/system/settings/internal.mjs +20 -0
- package/node_modules/typebox/build/system/settings/settings.d.mts +11 -0
- package/node_modules/typebox/build/system/settings/settings.mjs +14 -0
- package/node_modules/typebox/build/type/extends/inference.d.mts +1 -1
- package/node_modules/typebox/build/type/extends/inference.mjs +15 -2
- package/node_modules/typebox/build/type/extends/tuple.d.mts +2 -1
- package/node_modules/typebox/build/type/extends/tuple.mjs +21 -1
- package/node_modules/typebox/build/value/parse/parse.mjs +10 -4
- package/node_modules/typebox/package.json +1 -1
- package/node_modules/typebox/readme.md +3 -1
- package/openclaw.plugin.json +21 -1
- package/package.json +5 -5
- package/dist/.setup/agent-components.runtime-CEPrf2SY.mjs +0 -4
- package/dist/.setup/probe.runtime-DBQ_AGPe.mjs +0 -2
- package/dist/.setup/provider-session.runtime-DrGAYnZv.mjs +0 -6
- package/dist/.setup/provider.runtime-BmjW_pIw.mjs +0 -2
- package/dist/.setup/security-audit.runtime-DHtYenx9.mjs +0 -2
- package/dist/.setup/setup-plugin-api-Dvr41dyx.mjs +0 -3
- package/dist/.setup/system-events-B2YEEMbS.mjs +0 -34
- package/dist/.setup/targets-CvemhN3i.mjs +0 -3
- package/dist/.setup/thread-bindings.session-updates-DCQq1WZ5.mjs +0 -55
- /package/node_modules/typebox/build/guard/{string.d.mts → unicode/unicode_segment.d.mts} +0 -0
|
@@ -1,33 +1,21 @@
|
|
|
1
|
-
import { h as readDiscordComponentSpec, m as coerceDiscordComponentParam } from "./components-
|
|
2
|
-
import { l as resolveDiscordChannelConfigWithFallback, o as normalizeDiscordSlug, r as isDiscordGroupAllowedByPolicy, t as isDiscordThreadChannelType,
|
|
3
|
-
import { o as mergeDiscordAccountConfig, s as resolveDefaultDiscordAccountId, t as createDiscordActionGate } from "./accounts-
|
|
4
|
-
import { r as sendDiscordComponentMessage } from "./send.components-
|
|
5
|
-
import { b as
|
|
6
|
-
import {
|
|
7
|
-
import { r as sendStickerDiscord, t as sendMessageDiscord } from "./send.outbound-
|
|
8
|
-
import { n as getPresence } from "./presence-cache-
|
|
9
|
-
import { A as listScheduledEventsDiscord, B as moveChannelDiscord, C as fetchChannelInfoDiscord, D as fetchVoiceStatusDiscord, E as fetchRoleInfoDiscord, F as uploadEmojiDiscord, H as setChannelPermissionDiscord, I as uploadStickerDiscord, L as createChannelDiscord, M as resolveEventCoverImage, N as timeoutMemberDiscord, O as kickMemberDiscord, P as listGuildEmojisDiscord, R as deleteChannelDiscord, S as createScheduledEventDiscord, T as fetchMemberInfoDiscord, V as removeChannelPermissionDiscord, _ as readMessagesDiscord, a as removeReactionDiscord, b as addRoleDiscord, d as deleteMessageDiscord, f as editMessageDiscord, g as pinMessageDiscord, h as listThreadsDiscord, i as removeOwnReactionsDiscord, j as removeRoleDiscord, k as listGuildChannelsDiscord, l as DiscordThreadInitialMessageError, m as listPinsDiscord, n as fetchReactionsDiscord, p as fetchMessageDiscord, r as reactMessageDiscord, s as sendVoiceMessageDiscord, u as createThreadDiscord, v as searchMessagesDiscord, w as fetchGuildInfoDiscord, x as banMemberDiscord, y as unpinMessageDiscord, z as editChannelDiscord } from "./send-
|
|
10
|
-
import "./targets-
|
|
1
|
+
import { h as readDiscordComponentSpec, m as coerceDiscordComponentParam } from "./components-Cq1PvIpN.mjs";
|
|
2
|
+
import { l as resolveDiscordChannelConfigWithFallback, o as normalizeDiscordSlug, r as isDiscordGroupAllowedByPolicy, t as isDiscordThreadChannelType, y as resolveGroupDmAllow } from "./channel-type-DRCrEMss.mjs";
|
|
3
|
+
import { o as mergeDiscordAccountConfig, s as resolveDefaultDiscordAccountId, t as createDiscordActionGate } from "./accounts-ChaMcixG.mjs";
|
|
4
|
+
import { r as sendDiscordComponentMessage } from "./send.components-DxQAMfES.mjs";
|
|
5
|
+
import { b as parseDiscordTarget, f as createReusableDiscordReplyReference, m as resolveDiscordReplyReference, x as resolveDiscordChannelId } from "./retry-pz_cSha2.mjs";
|
|
6
|
+
import { C as hasAnyChannelPermissionDiscord, H as getGateway, P as createDiscordRuntimeAccountContext, _ as canManageGuildMemberRoleDiscord, b as fetchChannelPermissionsDiscord, n as buildDiscordTextChunks, u as resolveDiscordTargetChannelId, v as canManageGuildRoleDiscord, w as hasAnyGuildPermissionDiscord, y as canViewDiscordGuildChannel } from "./send.shared-DGFkbkQR.mjs";
|
|
7
|
+
import { r as sendStickerDiscord, t as sendMessageDiscord } from "./send.outbound-BISKnb-a.mjs";
|
|
8
|
+
import { n as getPresence } from "./presence-cache-Di3H3DIU.mjs";
|
|
9
|
+
import { A as listScheduledEventsDiscord, B as moveChannelDiscord, C as fetchChannelInfoDiscord, D as fetchVoiceStatusDiscord, E as fetchRoleInfoDiscord, F as uploadEmojiDiscord, H as setChannelPermissionDiscord, I as uploadStickerDiscord, L as createChannelDiscord, M as resolveEventCoverImage, N as timeoutMemberDiscord, O as kickMemberDiscord, P as listGuildEmojisDiscord, R as deleteChannelDiscord, S as createScheduledEventDiscord, T as fetchMemberInfoDiscord, V as removeChannelPermissionDiscord, _ as readMessagesDiscord, a as removeReactionDiscord, b as addRoleDiscord, d as deleteMessageDiscord, f as editMessageDiscord, g as pinMessageDiscord, h as listThreadsDiscord, i as removeOwnReactionsDiscord, j as removeRoleDiscord, k as listGuildChannelsDiscord, l as DiscordThreadInitialMessageError, m as listPinsDiscord, n as fetchReactionsDiscord, p as fetchMessageDiscord, r as reactMessageDiscord, s as sendVoiceMessageDiscord, u as createThreadDiscord, v as searchMessagesDiscord, w as fetchGuildInfoDiscord, x as banMemberDiscord, y as unpinMessageDiscord, z as editChannelDiscord } from "./send-CrfEI6Bs.mjs";
|
|
10
|
+
import "./targets-0KUcEIYx.mjs";
|
|
11
11
|
import { ChannelType, PermissionFlagsBits } from "discord-api-types/v10";
|
|
12
12
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
13
|
-
import { asBoolean, isRecord, normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
13
|
+
import { asBoolean, asOptionalRecord, isRecord, normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
14
14
|
import { createChannelProgressDraftCompositor } from "openclaw/plugin-sdk/channel-outbound";
|
|
15
15
|
import { resolveOpenProviderRuntimeGroupPolicy } from "openclaw/plugin-sdk/runtime-group-policy";
|
|
16
16
|
import { assertMediaNotDataUrl, jsonResult, parseAvailableTags, readNonNegativeIntegerParam, readPositiveIntegerParam, readReactionParams, readStringArrayParam, readStringParam, withNormalizedTimestamp } from "openclaw/plugin-sdk/channel-actions";
|
|
17
17
|
import { normalizeAccountId } from "openclaw/plugin-sdk/account-resolution";
|
|
18
18
|
import { readBooleanParam } from "openclaw/plugin-sdk/boolean-param";
|
|
19
|
-
//#region extensions/discord/src/actions/runtime.messaging.runtime.ts
|
|
20
|
-
async function resolveDiscordReactionTargetChannelId(params) {
|
|
21
|
-
try {
|
|
22
|
-
return resolveDiscordChannelId(params.target);
|
|
23
|
-
} catch {
|
|
24
|
-
return (await resolveDiscordTargetChannelId(params.target, {
|
|
25
|
-
cfg: params.cfg,
|
|
26
|
-
accountId: params.accountId
|
|
27
|
-
})).channelId;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
//#endregion
|
|
31
19
|
//#region extensions/discord/src/actions/runtime.shared.ts
|
|
32
20
|
/** Discord REST auto_archive_duration allowlist (minutes). */
|
|
33
21
|
const DISCORD_AUTO_ARCHIVE_MINUTES = /* @__PURE__ */ new Set([
|
|
@@ -392,19 +380,10 @@ function createDiscordMessagingActionContext(params) {
|
|
|
392
380
|
const targetChannelId = resolveDiscordChannelId(channelId);
|
|
393
381
|
const target = await resolveReadTargetContext(targetChannelId);
|
|
394
382
|
const currentConversation = isCurrentReadTarget(targetChannelId);
|
|
395
|
-
if (guildId)
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
if (!isDiscordReadTargetAllowedInGuild({
|
|
400
|
-
groupPolicy,
|
|
401
|
-
guildInfo,
|
|
402
|
-
target
|
|
403
|
-
})) throw new Error("Discord read target channel is not allowed.");
|
|
404
|
-
return;
|
|
405
|
-
}
|
|
406
|
-
if (target.guildId) {
|
|
407
|
-
const guildInfo = await resolveReadGuildEntry(target.guildId);
|
|
383
|
+
if (guildId && target.metadataKnown && target.guildId !== guildId) throw new Error("Discord read target channel is not allowed.");
|
|
384
|
+
const targetGuildId = guildId || target.guildId;
|
|
385
|
+
if (targetGuildId) {
|
|
386
|
+
const guildInfo = await resolveReadGuildEntry(targetGuildId);
|
|
408
387
|
if (directOperator && isExpandedReadTargetEnabled(guildInfo, target, false) || currentConversation && isExpandedReadTargetEnabled(guildInfo, target, true)) return;
|
|
409
388
|
if (!isDiscordReadTargetAllowedInGuild({
|
|
410
389
|
groupPolicy,
|
|
@@ -500,11 +479,14 @@ function createDiscordMessagingActionContext(params) {
|
|
|
500
479
|
}
|
|
501
480
|
return resolveDiscordChannelId(target);
|
|
502
481
|
}
|
|
503
|
-
|
|
504
|
-
target
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
482
|
+
try {
|
|
483
|
+
return resolveDiscordChannelId(target);
|
|
484
|
+
} catch {
|
|
485
|
+
return (await resolveDiscordTargetChannelId(target, {
|
|
486
|
+
cfg: params.cfg,
|
|
487
|
+
accountId: resolvedReactionAccountId
|
|
488
|
+
})).channelId;
|
|
489
|
+
}
|
|
508
490
|
},
|
|
509
491
|
withOpts,
|
|
510
492
|
withReactionRuntimeOptions: (extra) => ({
|
|
@@ -644,19 +626,6 @@ async function verifySenderGuildAdminPermission(params) {
|
|
|
644
626
|
if (canManageRole === false || targetType === "role" && canManageRole === null) throw new Error("Sender cannot manage the requested role overwrite.");
|
|
645
627
|
}
|
|
646
628
|
}
|
|
647
|
-
async function runRoleMutation(params) {
|
|
648
|
-
const guildId = readStringParam(params.values, "guildId", { required: true });
|
|
649
|
-
const userId = readStringParam(params.values, "userId", { required: true });
|
|
650
|
-
const roleId = readStringParam(params.values, "roleId", { required: true });
|
|
651
|
-
await params.mutate({
|
|
652
|
-
guildId,
|
|
653
|
-
userId,
|
|
654
|
-
roleId
|
|
655
|
-
}, createDiscordActionOptions({
|
|
656
|
-
cfg: params.cfg,
|
|
657
|
-
accountId: params.accountId
|
|
658
|
-
}));
|
|
659
|
-
}
|
|
660
629
|
function readChannelPermissionTarget(params) {
|
|
661
630
|
return {
|
|
662
631
|
channelId: readStringParam(params, "channelId", { required: true }),
|
|
@@ -697,6 +666,7 @@ async function handleDiscordGuildAction(action, params, isActionEnabled, cfg, op
|
|
|
697
666
|
channelTargetRequiredMessage: "Discord guild metadata reads require a wildcard channel allowlist for this guild."
|
|
698
667
|
});
|
|
699
668
|
};
|
|
669
|
+
assertGuildAdminActionEnabled(action, isActionEnabled);
|
|
700
670
|
switch (action) {
|
|
701
671
|
case "memberInfo": {
|
|
702
672
|
if (!isActionEnabled("memberInfo")) throw new Error("Discord member info is disabled.");
|
|
@@ -753,7 +723,6 @@ async function handleDiscordGuildAction(action, params, isActionEnabled, cfg, op
|
|
|
753
723
|
});
|
|
754
724
|
}
|
|
755
725
|
case "emojiUpload": {
|
|
756
|
-
if (!isActionEnabled("emojiUploads")) throw new Error("Discord emoji uploads are disabled.");
|
|
757
726
|
const guildId = readStringParam(params, "guildId", { required: true });
|
|
758
727
|
const name = readStringParam(params, "name", { required: true });
|
|
759
728
|
const mediaUrl = readStringParam(params, "mediaUrl", { required: true });
|
|
@@ -774,7 +743,6 @@ async function handleDiscordGuildAction(action, params, isActionEnabled, cfg, op
|
|
|
774
743
|
});
|
|
775
744
|
}
|
|
776
745
|
case "stickerUpload": {
|
|
777
|
-
if (!isActionEnabled("stickerUploads")) throw new Error("Discord sticker uploads are disabled.");
|
|
778
746
|
const guildId = readStringParam(params, "guildId", { required: true });
|
|
779
747
|
const name = readStringParam(params, "name", { required: true });
|
|
780
748
|
const description = readStringParam(params, "description", { required: true });
|
|
@@ -797,23 +765,17 @@ async function handleDiscordGuildAction(action, params, isActionEnabled, cfg, op
|
|
|
797
765
|
});
|
|
798
766
|
}
|
|
799
767
|
case "roleAdd":
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
if (!isActionEnabled("roles", false)) throw new Error("Discord role changes are disabled.");
|
|
810
|
-
await runRoleMutation({
|
|
811
|
-
cfg,
|
|
812
|
-
accountId,
|
|
813
|
-
values: params,
|
|
814
|
-
mutate: removeRoleDiscord
|
|
815
|
-
});
|
|
768
|
+
case "roleRemove": {
|
|
769
|
+
const guildId = readStringParam(params, "guildId", { required: true });
|
|
770
|
+
const userId = readStringParam(params, "userId", { required: true });
|
|
771
|
+
const roleId = readStringParam(params, "roleId", { required: true });
|
|
772
|
+
await (action === "roleAdd" ? addRoleDiscord : removeRoleDiscord)({
|
|
773
|
+
guildId,
|
|
774
|
+
userId,
|
|
775
|
+
roleId
|
|
776
|
+
}, withOpts());
|
|
816
777
|
return jsonResult({ ok: true });
|
|
778
|
+
}
|
|
817
779
|
case "channelInfo": {
|
|
818
780
|
if (!isActionEnabled("channelInfo")) throw new Error("Discord channel info is disabled.");
|
|
819
781
|
const channelId = readStringParam(params, "channelId", { required: true });
|
|
@@ -860,7 +822,6 @@ async function handleDiscordGuildAction(action, params, isActionEnabled, cfg, op
|
|
|
860
822
|
});
|
|
861
823
|
}
|
|
862
824
|
case "eventCreate": {
|
|
863
|
-
if (!isActionEnabled("events")) throw new Error("Discord events are disabled.");
|
|
864
825
|
const guildId = readStringParam(params, "guildId", { required: true });
|
|
865
826
|
const name = readStringParam(params, "name", { required: true });
|
|
866
827
|
const startTime = readStringParam(params, "startTime", { required: true });
|
|
@@ -888,71 +849,41 @@ async function handleDiscordGuildAction(action, params, isActionEnabled, cfg, op
|
|
|
888
849
|
event
|
|
889
850
|
});
|
|
890
851
|
}
|
|
852
|
+
case "categoryCreate":
|
|
891
853
|
case "channelCreate": {
|
|
892
|
-
|
|
893
|
-
|
|
854
|
+
const channel = await createChannelDiscord(action === "categoryCreate" ? {
|
|
855
|
+
guildId: readStringParam(params, "guildId", { required: true }),
|
|
856
|
+
name: readStringParam(params, "name", { required: true }),
|
|
857
|
+
type: 4,
|
|
858
|
+
position: readNonNegativeIntegerParam(params, "position")
|
|
859
|
+
} : readDiscordChannelCreateParams(params), withOpts());
|
|
894
860
|
return jsonResult({
|
|
895
861
|
ok: true,
|
|
896
|
-
channel
|
|
862
|
+
[action === "categoryCreate" ? "category" : "channel"]: channel
|
|
897
863
|
});
|
|
898
864
|
}
|
|
865
|
+
case "categoryEdit":
|
|
899
866
|
case "channelEdit": {
|
|
900
|
-
|
|
901
|
-
|
|
867
|
+
const channel = await editChannelDiscord(action === "categoryEdit" ? {
|
|
868
|
+
channelId: readStringParam(params, "categoryId", { required: true }),
|
|
869
|
+
name: readStringParam(params, "name"),
|
|
870
|
+
position: readNonNegativeIntegerParam(params, "position")
|
|
871
|
+
} : readDiscordChannelEditParams(params), withOpts());
|
|
902
872
|
return jsonResult({
|
|
903
873
|
ok: true,
|
|
904
|
-
channel
|
|
874
|
+
[action === "categoryEdit" ? "category" : "channel"]: channel
|
|
905
875
|
});
|
|
906
876
|
}
|
|
877
|
+
case "categoryDelete":
|
|
907
878
|
case "channelDelete": {
|
|
908
|
-
|
|
909
|
-
const channelId = readStringParam(params, "channelId", { required: true });
|
|
879
|
+
const channelId = readStringParam(params, action === "categoryDelete" ? "categoryId" : "channelId", { required: true });
|
|
910
880
|
const result = await deleteChannelDiscord(channelId, withOpts());
|
|
911
881
|
return jsonResult(result);
|
|
912
882
|
}
|
|
913
883
|
case "channelMove":
|
|
914
|
-
if (!isActionEnabled("channels")) throw new Error("Discord channel management is disabled.");
|
|
915
884
|
await moveChannelDiscord(readDiscordChannelMoveParams(params), withOpts());
|
|
916
885
|
return jsonResult({ ok: true });
|
|
917
|
-
case "categoryCreate": {
|
|
918
|
-
if (!isActionEnabled("channels")) throw new Error("Discord channel management is disabled.");
|
|
919
|
-
const guildId = readStringParam(params, "guildId", { required: true });
|
|
920
|
-
const name = readStringParam(params, "name", { required: true });
|
|
921
|
-
const position = readNonNegativeIntegerParam(params, "position");
|
|
922
|
-
const channel = await createChannelDiscord({
|
|
923
|
-
guildId,
|
|
924
|
-
name,
|
|
925
|
-
type: 4,
|
|
926
|
-
position: position ?? void 0
|
|
927
|
-
}, withOpts());
|
|
928
|
-
return jsonResult({
|
|
929
|
-
ok: true,
|
|
930
|
-
category: channel
|
|
931
|
-
});
|
|
932
|
-
}
|
|
933
|
-
case "categoryEdit": {
|
|
934
|
-
if (!isActionEnabled("channels")) throw new Error("Discord channel management is disabled.");
|
|
935
|
-
const categoryId = readStringParam(params, "categoryId", { required: true });
|
|
936
|
-
const name = readStringParam(params, "name");
|
|
937
|
-
const position = readNonNegativeIntegerParam(params, "position");
|
|
938
|
-
const channel = await editChannelDiscord({
|
|
939
|
-
channelId: categoryId,
|
|
940
|
-
name: name ?? void 0,
|
|
941
|
-
position: position ?? void 0
|
|
942
|
-
}, withOpts());
|
|
943
|
-
return jsonResult({
|
|
944
|
-
ok: true,
|
|
945
|
-
category: channel
|
|
946
|
-
});
|
|
947
|
-
}
|
|
948
|
-
case "categoryDelete": {
|
|
949
|
-
if (!isActionEnabled("channels")) throw new Error("Discord channel management is disabled.");
|
|
950
|
-
const categoryId = readStringParam(params, "categoryId", { required: true });
|
|
951
|
-
const result = await deleteChannelDiscord(categoryId, withOpts());
|
|
952
|
-
return jsonResult(result);
|
|
953
|
-
}
|
|
954
886
|
case "channelPermissionSet": {
|
|
955
|
-
if (!isActionEnabled("channels")) throw new Error("Discord channel management is disabled.");
|
|
956
887
|
const { channelId, targetId } = readChannelPermissionTarget(params);
|
|
957
888
|
const targetType = readStringParam(params, "targetType", { required: true }) === "member" ? 1 : 0;
|
|
958
889
|
const allow = readStringParam(params, "allow");
|
|
@@ -967,7 +898,6 @@ async function handleDiscordGuildAction(action, params, isActionEnabled, cfg, op
|
|
|
967
898
|
return jsonResult({ ok: true });
|
|
968
899
|
}
|
|
969
900
|
case "channelPermissionRemove": {
|
|
970
|
-
if (!isActionEnabled("channels")) throw new Error("Discord channel management is disabled.");
|
|
971
901
|
const { channelId, targetId } = readChannelPermissionTarget(params);
|
|
972
902
|
await removeChannelPermissionDiscord(channelId, targetId, withOpts());
|
|
973
903
|
return jsonResult({ ok: true });
|
|
@@ -986,19 +916,6 @@ function parseDiscordMessageLink(link) {
|
|
|
986
916
|
messageId: match[3]
|
|
987
917
|
};
|
|
988
918
|
}
|
|
989
|
-
function describeDiscordMessageListResult(value) {
|
|
990
|
-
if (Array.isArray(value)) return "array";
|
|
991
|
-
if (value === null) return "null";
|
|
992
|
-
if (value && typeof value === "object") {
|
|
993
|
-
const keys = Object.keys(value).toSorted();
|
|
994
|
-
return keys.length ? `object with keys ${keys.join(", ")}` : "object";
|
|
995
|
-
}
|
|
996
|
-
return typeof value;
|
|
997
|
-
}
|
|
998
|
-
function assertDiscordMessageListResult(value) {
|
|
999
|
-
if (Array.isArray(value)) return value;
|
|
1000
|
-
throw new Error(`Discord message read returned ${describeDiscordMessageListResult(value)} instead of an array.`);
|
|
1001
|
-
}
|
|
1002
919
|
async function handleDiscordMessageManagementAction(ctx) {
|
|
1003
920
|
switch (ctx.action) {
|
|
1004
921
|
case "permissions": {
|
|
@@ -1048,7 +965,7 @@ async function handleDiscordMessageManagementAction(ctx) {
|
|
|
1048
965
|
after: readStringParam(ctx.params, "after"),
|
|
1049
966
|
around: readStringParam(ctx.params, "around")
|
|
1050
967
|
};
|
|
1051
|
-
const messages = messageId ? [await fetchMessageDiscord(channelId, messageId, ctx.withOpts())] :
|
|
968
|
+
const messages = messageId ? [await fetchMessageDiscord(channelId, messageId, ctx.withOpts())] : await readMessagesDiscord(channelId, query, ctx.withOpts());
|
|
1052
969
|
return jsonResult({
|
|
1053
970
|
ok: true,
|
|
1054
971
|
channelId,
|
|
@@ -1092,20 +1009,13 @@ async function handleDiscordMessageManagementAction(ctx) {
|
|
|
1092
1009
|
await deleteMessageDiscord(channelId, messageId, ctx.withOpts());
|
|
1093
1010
|
return jsonResult({ ok: true });
|
|
1094
1011
|
}
|
|
1095
|
-
case "pinMessage":
|
|
1096
|
-
if (!ctx.isActionEnabled("pins")) throw new Error("Discord pins are disabled.");
|
|
1097
|
-
const channelId = ctx.resolveChannelId();
|
|
1098
|
-
const messageId = readStringParam(ctx.params, "messageId", { required: true });
|
|
1099
|
-
await ctx.assertReadTargetAllowed({ channelId });
|
|
1100
|
-
await pinMessageDiscord(channelId, messageId, ctx.withOpts());
|
|
1101
|
-
return jsonResult({ ok: true });
|
|
1102
|
-
}
|
|
1012
|
+
case "pinMessage":
|
|
1103
1013
|
case "unpinMessage": {
|
|
1104
1014
|
if (!ctx.isActionEnabled("pins")) throw new Error("Discord pins are disabled.");
|
|
1105
1015
|
const channelId = ctx.resolveChannelId();
|
|
1106
1016
|
const messageId = readStringParam(ctx.params, "messageId", { required: true });
|
|
1107
1017
|
await ctx.assertReadTargetAllowed({ channelId });
|
|
1108
|
-
await unpinMessageDiscord(channelId, messageId, ctx.withOpts());
|
|
1018
|
+
await (ctx.action === "pinMessage" ? pinMessageDiscord : unpinMessageDiscord)(channelId, messageId, ctx.withOpts());
|
|
1109
1019
|
return jsonResult({ ok: true });
|
|
1110
1020
|
}
|
|
1111
1021
|
case "listPins": {
|
|
@@ -1154,10 +1064,6 @@ async function handleDiscordMessageManagementAction(ctx) {
|
|
|
1154
1064
|
authorIds: authorIdList.length ? authorIdList : void 0,
|
|
1155
1065
|
limit
|
|
1156
1066
|
}, ctx.withOpts());
|
|
1157
|
-
if (!results || typeof results !== "object") return jsonResult({
|
|
1158
|
-
ok: true,
|
|
1159
|
-
results
|
|
1160
|
-
});
|
|
1161
1067
|
const messages = results.messages;
|
|
1162
1068
|
const normalizedMessages = Array.isArray(messages) ? messages.map((group) => Array.isArray(group) ? group.map((msg) => ctx.normalizeMessage(msg)) : group) : messages;
|
|
1163
1069
|
return jsonResult({
|
|
@@ -1180,8 +1086,8 @@ async function handleDiscordReactionMessagingAction(ctx) {
|
|
|
1180
1086
|
const channelId = await ctx.resolveReactionChannelId();
|
|
1181
1087
|
const messageId = readStringParam(ctx.params, "messageId", { required: true });
|
|
1182
1088
|
const { emoji, remove, isEmpty } = readReactionParams(ctx.params, { removeErrorMessage: "Emoji is required to remove a Discord reaction." });
|
|
1089
|
+
await ctx.assertReadTargetAllowed({ channelId });
|
|
1183
1090
|
if (remove) {
|
|
1184
|
-
await ctx.assertReadTargetAllowed({ channelId });
|
|
1185
1091
|
await removeReactionDiscord(channelId, messageId, emoji, ctx.withReactionRuntimeOptions());
|
|
1186
1092
|
return jsonResult({
|
|
1187
1093
|
ok: true,
|
|
@@ -1189,14 +1095,12 @@ async function handleDiscordReactionMessagingAction(ctx) {
|
|
|
1189
1095
|
});
|
|
1190
1096
|
}
|
|
1191
1097
|
if (isEmpty) {
|
|
1192
|
-
await ctx.assertReadTargetAllowed({ channelId });
|
|
1193
1098
|
const removed = await removeOwnReactionsDiscord(channelId, messageId, ctx.withReactionRuntimeOptions());
|
|
1194
1099
|
return jsonResult({
|
|
1195
1100
|
ok: true,
|
|
1196
1101
|
removed: removed.removed
|
|
1197
1102
|
});
|
|
1198
1103
|
}
|
|
1199
|
-
await ctx.assertReadTargetAllowed({ channelId });
|
|
1200
1104
|
await reactMessageDiscord(channelId, messageId, emoji, ctx.withReactionRuntimeOptions());
|
|
1201
1105
|
return jsonResult({
|
|
1202
1106
|
ok: true,
|
|
@@ -1220,9 +1124,6 @@ async function handleDiscordReactionMessagingAction(ctx) {
|
|
|
1220
1124
|
}
|
|
1221
1125
|
//#endregion
|
|
1222
1126
|
//#region extensions/discord/src/actions/runtime.messaging.send.ts
|
|
1223
|
-
function hasDiscordComponentObjectKeys(value) {
|
|
1224
|
-
return Boolean(value && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length > 0);
|
|
1225
|
-
}
|
|
1226
1127
|
function resolveActionReplyReference(ctx, replyToId) {
|
|
1227
1128
|
const reply = ctx.options?.reply;
|
|
1228
1129
|
return reply ? resolveDiscordReplyReference({
|
|
@@ -1232,15 +1133,11 @@ function resolveActionReplyReference(ctx, replyToId) {
|
|
|
1232
1133
|
}) : createReusableDiscordReplyReference(replyToId);
|
|
1233
1134
|
}
|
|
1234
1135
|
function readDiscordThreadArchiveTimestamp(thread) {
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
if (metadata && typeof metadata === "object" && !Array.isArray(metadata)) {
|
|
1238
|
-
const archiveTimestamp = metadata.archive_timestamp;
|
|
1239
|
-
if (typeof archiveTimestamp === "string" && archiveTimestamp.trim()) return archiveTimestamp;
|
|
1240
|
-
}
|
|
1136
|
+
const archiveTimestamp = asOptionalRecord(asOptionalRecord(thread)?.thread_metadata)?.archive_timestamp;
|
|
1137
|
+
return typeof archiveTimestamp === "string" && archiveTimestamp.trim() ? archiveTimestamp : void 0;
|
|
1241
1138
|
}
|
|
1242
1139
|
function normalizeDiscordThreadListActionResult(params) {
|
|
1243
|
-
const record =
|
|
1140
|
+
const record = asOptionalRecord(params.value);
|
|
1244
1141
|
const threadItems = Array.isArray(record?.threads) ? record.threads : [];
|
|
1245
1142
|
const hasMore = record?.has_more === true;
|
|
1246
1143
|
const nextBefore = params.includeArchived && hasMore ? readDiscordThreadArchiveTimestamp(threadItems[threadItems.length - 1]) : void 0;
|
|
@@ -1328,7 +1225,8 @@ async function handleDiscordMessageSendAction(ctx) {
|
|
|
1328
1225
|
const silent = ctx.params.silent === true;
|
|
1329
1226
|
const suppressEmbeds = ctx.params.suppressEmbeds === void 0 ? void 0 : ctx.params.suppressEmbeds === true;
|
|
1330
1227
|
const rawComponents = coerceDiscordComponentParam(ctx.params.components);
|
|
1331
|
-
const
|
|
1228
|
+
const componentRecord = asOptionalRecord(rawComponents);
|
|
1229
|
+
const componentSpec = componentRecord && Object.keys(componentRecord).length > 0 ? readDiscordComponentSpec(componentRecord) : null;
|
|
1332
1230
|
const components = Array.isArray(rawComponents) || typeof rawComponents === "function" ? rawComponents : void 0;
|
|
1333
1231
|
const mediaUrl = readStringParam(ctx.params, "mediaUrl", { trim: false }) ?? readStringParam(ctx.params, "path", { trim: false }) ?? readStringParam(ctx.params, "filePath", { trim: false });
|
|
1334
1232
|
const rawEmbeds = ctx.params.embeds;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { n as __reExport, t as __exportAll } from "./rolldown-runtime-B4FMCO8f.mjs";
|
|
2
|
+
//#region packages/normalization-core/src/record-coerce.ts
|
|
3
|
+
/** Type guard for non-array object records at browser-safe boundaries. */
|
|
4
|
+
function isRecord(value) {
|
|
5
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
6
|
+
}
|
|
7
|
+
/** Returns a non-array record or null. */
|
|
8
|
+
function asNullableRecord(value) {
|
|
9
|
+
return isRecord(value) ? value : null;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/config/channel-config-normalization.ts
|
|
13
|
+
/** Applies one channel-specific doctor migration to every object-shaped account. */
|
|
14
|
+
function normalizeChannelAccounts(params) {
|
|
15
|
+
const rawAccounts = asNullableRecord(params.entry.accounts);
|
|
16
|
+
if (!rawAccounts) return {
|
|
17
|
+
entry: params.entry,
|
|
18
|
+
changed: false
|
|
19
|
+
};
|
|
20
|
+
let changed = false;
|
|
21
|
+
const accounts = { ...rawAccounts };
|
|
22
|
+
for (const [accountId, value] of Object.entries(rawAccounts)) {
|
|
23
|
+
const account = asNullableRecord(value);
|
|
24
|
+
if (!account) continue;
|
|
25
|
+
const normalized = params.normalizeAccount({
|
|
26
|
+
account,
|
|
27
|
+
accountId,
|
|
28
|
+
pathPrefix: `${params.pathPrefix}.accounts.${accountId}`,
|
|
29
|
+
changes: params.changes
|
|
30
|
+
});
|
|
31
|
+
if (normalized.changed) {
|
|
32
|
+
accounts[accountId] = normalized.entry;
|
|
33
|
+
changed = true;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return changed ? {
|
|
37
|
+
entry: {
|
|
38
|
+
...params.entry,
|
|
39
|
+
accounts
|
|
40
|
+
},
|
|
41
|
+
changed: true
|
|
42
|
+
} : {
|
|
43
|
+
entry: params.entry,
|
|
44
|
+
changed: false
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/** Applies the same channel-specific doctor migration at root and account scope. */
|
|
48
|
+
function normalizeChannelConfigEntries(params) {
|
|
49
|
+
const changes = params.changes ?? [];
|
|
50
|
+
const channels = params.cfg.channels;
|
|
51
|
+
const entry = asNullableRecord(channels?.[params.channelId]);
|
|
52
|
+
if (!entry) return {
|
|
53
|
+
config: params.cfg,
|
|
54
|
+
changes
|
|
55
|
+
};
|
|
56
|
+
const channelPath = `channels.${params.channelId}`;
|
|
57
|
+
const root = params.normalizeEntry({
|
|
58
|
+
entry,
|
|
59
|
+
pathPrefix: channelPath,
|
|
60
|
+
changes
|
|
61
|
+
});
|
|
62
|
+
const accounts = normalizeChannelAccounts({
|
|
63
|
+
entry: root.entry,
|
|
64
|
+
pathPrefix: channelPath,
|
|
65
|
+
changes,
|
|
66
|
+
normalizeAccount: (accountParams) => params.normalizeEntry({
|
|
67
|
+
entry: accountParams.account,
|
|
68
|
+
accountId: accountParams.accountId,
|
|
69
|
+
pathPrefix: accountParams.pathPrefix,
|
|
70
|
+
changes: accountParams.changes
|
|
71
|
+
})
|
|
72
|
+
});
|
|
73
|
+
if (!root.changed && !accounts.changed) return {
|
|
74
|
+
config: params.cfg,
|
|
75
|
+
changes
|
|
76
|
+
};
|
|
77
|
+
return {
|
|
78
|
+
config: {
|
|
79
|
+
...params.cfg,
|
|
80
|
+
channels: {
|
|
81
|
+
...channels,
|
|
82
|
+
[params.channelId]: accounts.entry
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
changes
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/plugin-sdk/legacy-webhook-listener-migration.ts
|
|
90
|
+
/** Preserve explicitly configured webhook listeners while moving ingress onto Gateway routes. */
|
|
91
|
+
function createLegacyWebhookListenerDoctorContract(params) {
|
|
92
|
+
const portKey = params.portKey ?? "webhookPort";
|
|
93
|
+
const hostKey = params.hostKey === void 0 ? "webhookHost" : params.hostKey;
|
|
94
|
+
const source = (entry) => params.webhookKey ? asNullableRecord(entry[params.webhookKey]) : entry;
|
|
95
|
+
const hasLegacy = (value) => {
|
|
96
|
+
const entry = asNullableRecord(value);
|
|
97
|
+
const listener = entry && source(entry);
|
|
98
|
+
return Boolean(listener && (Object.hasOwn(listener, portKey) || hostKey && Object.hasOwn(listener, hostKey)));
|
|
99
|
+
};
|
|
100
|
+
const prefix = `channels.${params.channelKey}`;
|
|
101
|
+
return {
|
|
102
|
+
legacyConfigRules: [{
|
|
103
|
+
path: ["channels", params.channelKey],
|
|
104
|
+
message: `${prefix} webhook listeners moved to Gateway routes. Run "openclaw doctor --fix" to preserve explicitly configured listener settings as legacyWebhook.`,
|
|
105
|
+
match: (value) => {
|
|
106
|
+
const accounts = asNullableRecord(asNullableRecord(value)?.accounts);
|
|
107
|
+
return hasLegacy(value) || Object.values(accounts ?? {}).some(hasLegacy);
|
|
108
|
+
}
|
|
109
|
+
}],
|
|
110
|
+
normalizeCompatibilityConfig: ({ cfg }) => {
|
|
111
|
+
const root = asNullableRecord(asNullableRecord(cfg.channels)?.[params.channelKey]);
|
|
112
|
+
const inherited = root && source(root);
|
|
113
|
+
const canonicalRoot = asNullableRecord(root?.legacyWebhook);
|
|
114
|
+
return normalizeChannelConfigEntries({
|
|
115
|
+
cfg,
|
|
116
|
+
channelId: params.channelKey,
|
|
117
|
+
normalizeEntry: ({ entry, accountId, pathPrefix, changes }) => {
|
|
118
|
+
const listener = source(entry);
|
|
119
|
+
if (!listener || !hasLegacy(entry)) return {
|
|
120
|
+
entry,
|
|
121
|
+
changed: false
|
|
122
|
+
};
|
|
123
|
+
const next = { ...entry };
|
|
124
|
+
const port = Object.hasOwn(listener, portKey) ? listener[portKey] : (accountId ? canonicalRoot?.port ?? inherited?.[portKey] : void 0) ?? params.defaultPort;
|
|
125
|
+
const inheritedHost = accountId ? canonicalRoot ? canonicalRoot.host : (hostKey ? inherited?.[hostKey] : void 0) ?? params.defaultHost : params.defaultHost;
|
|
126
|
+
const host = hostKey ? listener[hostKey] ?? inheritedHost : inheritedHost;
|
|
127
|
+
const legacyPath = [pathPrefix, params.webhookKey].filter(Boolean).join(".");
|
|
128
|
+
if (Object.hasOwn(entry, "legacyWebhook")) changes.push(`Removed ${legacyPath} legacy listener keys; ${pathPrefix}.legacyWebhook is already configured.`);
|
|
129
|
+
else if (accountId && root?.legacyWebhook === false) changes.push(`Removed ${legacyPath} legacy listener keys; ${prefix}.legacyWebhook: false keeps this account's inherited listener disabled.`);
|
|
130
|
+
else {
|
|
131
|
+
next.legacyWebhook = {
|
|
132
|
+
port,
|
|
133
|
+
...host !== void 0 ? { host } : {}
|
|
134
|
+
};
|
|
135
|
+
changes.push(`Moved ${legacyPath} listener settings to ${pathPrefix}.legacyWebhook. Point the external callback or reverse proxy at the Gateway port and webhook path, verify delivery, then set legacyWebhook: false to disable legacy forwarding.`);
|
|
136
|
+
}
|
|
137
|
+
const updated = params.webhookKey ? { ...listener } : next;
|
|
138
|
+
delete updated[portKey];
|
|
139
|
+
if (hostKey) delete updated[hostKey];
|
|
140
|
+
if (params.webhookKey) {
|
|
141
|
+
if (Object.keys(updated).length) next[params.webhookKey] = updated;
|
|
142
|
+
else delete next[params.webhookKey];
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
entry: next,
|
|
146
|
+
changed: true
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
//#endregion
|
|
154
|
+
//#region \0openclaw:bundled-sdk:openclaw/plugin-sdk/runtime-doctor-migrations
|
|
155
|
+
var runtime_doctor_migrations_exports = /* @__PURE__ */ __exportAll({ createLegacyWebhookListenerDoctorContract: () => createLegacyWebhookListenerDoctorContract });
|
|
156
|
+
import * as import_openclaw_plugin_sdk_runtime_doctor_migrations from "openclaw/plugin-sdk/runtime-doctor-migrations";
|
|
157
|
+
__reExport(runtime_doctor_migrations_exports, import_openclaw_plugin_sdk_runtime_doctor_migrations);
|
|
158
|
+
//#endregion
|
|
159
|
+
export { runtime_doctor_migrations_exports as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as resolveDiscordAccount, g as selectDiscordActivitiesRuntimeConfig, n as isDiscordAccountEnabledForRuntime, r as listDiscordAccountIds } from "./accounts-
|
|
2
|
-
import {
|
|
1
|
+
import { c as resolveDiscordAccount, g as selectDiscordActivitiesRuntimeConfig, n as isDiscordAccountEnabledForRuntime, r as listDiscordAccountIds } from "./accounts-ChaMcixG.mjs";
|
|
2
|
+
import { R as resolveDiscordProxyFetchForAccount } from "./send.shared-DGFkbkQR.mjs";
|
|
3
3
|
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
4
|
//#region extensions/discord/src/activities/config.ts
|
|
5
5
|
function resolveDiscordActivitiesConfig(account, env = process.env) {
|
|
@@ -65,9 +65,6 @@ var DiscordActivitiesRuntime = class {
|
|
|
65
65
|
hasEnabledAccounts(cfg = this.currentConfig()) {
|
|
66
66
|
return listDiscordAccountIds(cfg).some((accountId) => this.resolveAccount(accountId, cfg) !== null);
|
|
67
67
|
}
|
|
68
|
-
isAccountEnabled(accountId, cfg = this.currentConfig()) {
|
|
69
|
-
return this.resolveAccount(accountId, cfg) !== null;
|
|
70
|
-
}
|
|
71
68
|
};
|
|
72
69
|
let activeRuntime;
|
|
73
70
|
function setDiscordActivitiesRuntime(runtime) {
|