@openclaw/discord 2026.11.3 → 2026.11.5-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.setup/{account-inspect-8cCu6uPG.mjs → account-inspect-DGkdWwix.mjs} +1 -1
- package/dist/.setup/{accounts-ljrzXBJi.mjs → accounts-C_25wyxC.mjs} +9 -6
- package/dist/.setup/{active-turn-thread-route-C4tp9noA.mjs → active-turn-thread-route-KvRTAVE3.mjs} +1 -2
- package/dist/.setup/{allow-list-BKqOldGy.mjs → allow-list-BXrS8-R9.mjs} +4 -152
- package/dist/.setup/{api-DqmMUZau.mjs → api-BlBD4ism.mjs} +10 -20
- package/dist/.setup/{approval-handler.runtime-D0qu1um7.mjs → approval-handler.runtime-BGYjX1t9.mjs} +80 -61
- package/dist/.setup/{approval-message-updates-CdurC9Ej.mjs → approval-message-updates-DKsCfxSW.mjs} +2 -2
- package/dist/.setup/{audit-ChorIwio.mjs → audit-5b-FXj9R.mjs} +4 -4
- package/dist/.setup/{channel-ZilgdF5e.mjs → channel-CWwTHWFo.mjs} +134 -202
- package/dist/.setup/channel-access-9cyzozUP.mjs +24 -0
- package/dist/.setup/channel.setup-B3MtmBQG.mjs +238 -0
- package/dist/.setup/{components-Du9NhD8h.mjs → components-YCvQ6YLS.mjs} +209 -430
- package/dist/.setup/components.base-CiS0h_XP.mjs +32 -0
- package/dist/.setup/{config-schema-_uBILpQf.mjs → config-schema-BNKN1cu5.mjs} +6 -7
- package/dist/.setup/{conversation-binding-route-8Ul1KpGF.mjs → conversation-binding-route-kCTw8cij.mjs} +2 -2
- package/dist/.setup/{directory-config-3iVub-3m.mjs → directory-config-Ble81PWH.mjs} +1 -1
- package/dist/.setup/{directory-live-BDVl2DoC.mjs → directory-live-DH3tpS3x.mjs} +52 -57
- package/dist/.setup/{discord-BMD-JiVS.mjs → discord-DGVSguhx.mjs} +1124 -1710
- package/dist/.setup/{doctor-hQKbkNKq.mjs → doctor-eujgbnpZ.mjs} +3 -5
- package/dist/.setup/endpoint-runtime-lf4DeLas.mjs +139 -0
- package/dist/.setup/guilds-eDq22iSM.mjs +22 -0
- package/dist/.setup/{handle-action-B1lmt4ms.mjs → handle-action-CktwmzMz.mjs} +15 -15
- package/dist/.setup/{handle-action.guild-admin-B6g31cwt.mjs → handle-action.guild-admin-WLQ7fRqI.mjs} +5 -5
- package/dist/.setup/listeners-Df8lx3vK.mjs +47 -0
- package/dist/.setup/{live-policy-config-C_Q966Wh.mjs → live-policy-config-DiBVuaU6.mjs} +2 -3
- package/dist/.setup/{message-handler-CkI3yMjL.mjs → message-handler-hhNSioxo.mjs} +154 -115
- package/dist/.setup/{message-handler.preflight-CEfkFV9U.mjs → message-handler.preflight-BZcZE1o-.mjs} +30 -105
- package/dist/.setup/{message-handler.preflight-pluralkit-D5si80_L.mjs → message-handler.preflight-pluralkit-CYZfXXb6.mjs} +9 -22
- package/dist/.setup/{message-handler.process-DsMtetRf.mjs → message-handler.process-B0n-mQ99.mjs} +256 -373
- package/dist/.setup/outbound-payload-BaZmjewa.mjs +447 -0
- package/dist/.setup/{outbound-session-route-BtUpGBTb.mjs → outbound-session-route-Cgx4i9cS.mjs} +139 -86
- package/dist/.setup/{preflight-audio-wWgsZG5F.mjs → preflight-audio-C6QtD6HX.mjs} +1 -5
- package/dist/.setup/{presence-cache-DCeTsL73.mjs → presence-cache-Dq-3nH7R.mjs} +1 -6
- package/dist/.setup/{probe-CBaoCs-c.mjs → probe-DezB-6xz.mjs} +5 -9
- package/dist/.setup/{provider-CI_OLfvz.mjs → provider-BN2bCIUp.mjs} +3440 -4308
- package/dist/.setup/{provider-session.runtime-TWOo_JZx.mjs → provider-session.runtime-Dr_5X43t.mjs} +3 -3
- package/dist/.setup/provider.runtime-BuJpl0Pv.mjs +1 -0
- package/dist/.setup/proxy-fetch-BzXwBAXt.mjs +30 -0
- package/dist/.setup/{realtime-session.runtime-DvfS4vJj.mjs → realtime-session.runtime-BTDWsV4d.mjs} +44 -81
- package/dist/.setup/{receive-recovery-CKvaG2Hf.mjs → receive-recovery-C3Ks4wAQ.mjs} +13 -27
- package/dist/.setup/{resolve-allowlist-common-cIjtqh2F.mjs → resolve-allowlist-common-Bk8Fj6Ik.mjs} +3 -13
- package/dist/.setup/{resolve-channels-Cj5i7hzj.mjs → resolve-channels-Bp8frXvc.mjs} +7 -8
- package/dist/.setup/{resolve-users-BQLbysRB.mjs → resolve-users-Cvcj22sG.mjs} +4 -7
- package/dist/.setup/{runtime-RWnuJgWB.mjs → runtime-BJaCvlmq.mjs} +196 -239
- package/dist/.setup/{runtime-plifsKg9.mjs → runtime-BMgTyuwg.mjs} +6 -6
- package/dist/.setup/{secret-config-contract-z6FhbT8E.mjs → secret-config-contract-B1kE4sDv.mjs} +4 -9
- package/dist/.setup/{send-da6ENJ9f.mjs → send-CVW7V-VZ.mjs} +149 -175
- package/dist/.setup/{send.components-CWZUuGvA.mjs → send.components-C8YXdnO_.mjs} +59 -71
- package/dist/.setup/{send.outbound-qZ3iK3Vq.mjs → send.outbound-Uzcmh3Yd.mjs} +76 -129
- package/dist/.setup/{send.receipt-C18khRYH.mjs → send.receipt-NZDOTZBU.mjs} +30 -32
- package/dist/.setup/{send.shared-CnlMgoqQ.mjs → send.shared-a_6Oeyg1.mjs} +38 -115
- package/dist/.setup/{sender-identity-DgbJykq0.mjs → sender-identity-76HFb8eK.mjs} +3 -9
- package/dist/.setup/setup-plugin-api-BExhGEhL.mjs +2 -0
- package/dist/.setup/shared-interactive-DmzaoKOM.mjs +316 -0
- package/dist/.setup/{shared-CY5vJM48.mjs → shared-yDUSExm2.mjs} +8 -11
- package/dist/.setup/{subagent-hooks-CIu2TFz3.mjs → subagent-hooks-CDkdHQyy.mjs} +1 -1
- package/dist/.setup/{system-events-DCOLXkwS.mjs → system-events-yfWz150v.mjs} +2 -2
- package/dist/.setup/{target-resolver-CApivu3G.mjs → target-resolver-BOOzqxxM.mjs} +3 -3
- package/dist/.setup/{thread-bindings-DcvT_JgI.mjs → thread-bindings-zce4cpu_.mjs} +12 -20
- package/dist/.setup/{thread-bindings.manager-5Sh7yedN.mjs → thread-bindings.manager-NywKzUtc.mjs} +22 -42
- package/dist/.setup/{thread-bindings.session-updates-BMdJeJMc.mjs → thread-bindings.session-updates-D0j7oh8S.mjs} +11 -18
- package/dist/.setup/{threading-CzjFeUSe.mjs → threading-DodLYDt-.mjs} +68 -105
- package/dist/.setup/{timeouts-CuNARfyw.mjs → timeouts-cIxzatmv.mjs} +1 -1
- package/dist/.setup/{transcripts-source-8RDQrSVb.mjs → transcripts-source-ie9GBWaU.mjs} +110 -179
- package/dist/.setup/{voice-runtime-BsDILmAv.mjs → voice-runtime-B7V_LTdX.mjs} +231 -452
- package/dist/.source-module-urls/d6c089460280c5a04184542d6712e04545caeb1ebb290d3504377b4cc5e22fea.json +1 -0
- package/dist/account-inspect-api.js +1 -1
- package/dist/action-runtime-api.js +1 -2
- package/dist/activities-api.js +286 -341
- package/dist/api.js +16 -16
- package/dist/channel-config-api.js +1 -2
- package/dist/channel-plugin-api.js +1 -2
- package/dist/contract-api.js +1 -2
- package/dist/directory-contract-api.js +1 -1
- package/dist/runtime-api.js +22 -22
- package/dist/runtime-setter-api.js +1 -2
- package/dist/secret-contract-api.js +1 -2
- package/dist/security-audit-contract-api.js +1 -2
- package/dist/security-contract-api.js +1 -2
- package/dist/session-key-api.js +1 -2
- package/dist/setup-entry.js +1 -1
- package/dist/setup-plugin-api.js +1 -2
- package/dist/src/voice/audio-worker.runtime.js +56 -68
- package/dist/subagent-hooks-api.js +1 -1
- package/dist/thread-binding-api.js +1 -2
- package/dist/transcripts-source-api.js +1 -1
- package/node_modules/@napi-rs/wasm-runtime/dist/fs.js +3339 -4021
- package/node_modules/@napi-rs/wasm-runtime/package.json +1 -1
- package/node_modules/@types/lodash/README.md +1 -1
- package/node_modules/@types/lodash/common/function.d.ts +2 -2
- package/node_modules/@types/lodash/package.json +2 -2
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/package.json +2 -2
- package/node_modules/@types/node/util.d.ts +6 -3
- package/node_modules/discord-api-types/package.json +4 -4
- package/node_modules/discord-api-types/rest/v10/index.d.ts +8 -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 +8 -0
- package/node_modules/discord-api-types/rest/v10/index.js.map +1 -1
- package/node_modules/discord-api-types/rest/v10/oauth2.d.ts +26 -2
- package/node_modules/discord-api-types/rest/v10/oauth2.d.ts.map +1 -1
- package/node_modules/discord-api-types/rest/v9/index.d.ts +8 -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 +8 -0
- package/node_modules/discord-api-types/rest/v9/index.js.map +1 -1
- package/node_modules/discord-api-types/rest/v9/oauth2.d.ts +26 -2
- package/node_modules/discord-api-types/rest/v9/oauth2.d.ts.map +1 -1
- package/node_modules/typebox/build/format/duration.d.mts +2 -2
- package/node_modules/typebox/build/format/duration.mjs +2 -2
- package/node_modules/typebox/build/format/idn_email.d.mts +1 -0
- package/node_modules/typebox/build/format/idn_email.mjs +1 -0
- package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -1
- package/node_modules/typebox/build/format/idn_hostname.mjs +1 -1
- package/node_modules/typebox/build/format/ipv4.d.mts +2 -2
- package/node_modules/typebox/build/format/ipv4.mjs +2 -2
- package/node_modules/typebox/build/format/ipv6.d.mts +1 -1
- package/node_modules/typebox/build/format/ipv6.mjs +1 -1
- package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
- package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
- package/node_modules/typebox/build/schema/build.mjs +1 -0
- package/node_modules/typebox/build/schema/engine/_unique.d.mts +4 -2
- package/node_modules/typebox/build/schema/engine/_unique.mjs +7 -3
- package/node_modules/typebox/build/schema/engine/additionalItems.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/additionalProperties.d.mts +0 -3
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +15 -17
- package/node_modules/typebox/build/schema/engine/contains.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/index.d.mts +1 -0
- package/node_modules/typebox/build/schema/engine/index.mjs +1 -0
- package/node_modules/typebox/build/schema/engine/items.mjs +7 -4
- package/node_modules/typebox/build/schema/engine/maxContains.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/minContains.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/oneOf.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/propertyNames.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs +2 -2
- package/node_modules/typebox/build/system/hashing/hash.mjs +63 -34
- package/node_modules/typebox/build/system/locale/en_US.mjs +2 -1
- package/node_modules/typebox/build/system/memory/assign.d.mts +2 -8
- package/node_modules/typebox/build/system/memory/assign.mjs +13 -6
- package/node_modules/typebox/build/system/memory/clone.d.mts +4 -5
- package/node_modules/typebox/build/system/memory/clone.mjs +8 -96
- package/node_modules/typebox/build/system/memory/create.d.mts +1 -5
- package/node_modules/typebox/build/system/memory/create.mjs +18 -13
- package/node_modules/typebox/build/system/memory/deep.d.mts +2 -0
- package/node_modules/typebox/build/system/memory/deep.mjs +108 -0
- package/node_modules/typebox/build/system/memory/discard.d.mts +1 -1
- package/node_modules/typebox/build/system/memory/discard.mjs +9 -8
- package/node_modules/typebox/build/system/memory/finalize.d.mts +4 -0
- package/node_modules/typebox/build/system/memory/finalize.mjs +30 -0
- package/node_modules/typebox/build/system/memory/keys.d.mts +2 -0
- package/node_modules/typebox/build/system/memory/keys.mjs +8 -0
- package/node_modules/typebox/build/system/memory/update.d.mts +1 -4
- package/node_modules/typebox/build/system/memory/update.mjs +43 -16
- package/node_modules/typebox/build/type/engine/call/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/call/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +2 -24
- package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +2 -29
- package/node_modules/typebox/build/type/engine/evaluate/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/evaluate/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +5 -1
- package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +6 -1
- package/node_modules/typebox/build/type/engine/evaluate/property.d.mts +30 -0
- package/node_modules/typebox/build/type/engine/evaluate/property.mjs +29 -0
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +1 -4
- package/node_modules/typebox/build/type/engine/object/from_intersect.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/object/from_intersect.mjs +2 -2
- package/node_modules/typebox/build/type/engine/object/from_union.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +1 -4
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +1 -4
- package/node_modules/typebox/build/type/engine/this/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/this/index.mjs +1 -0
- package/node_modules/typebox/build/value/clone/clone.d.mts +4 -3
- package/node_modules/typebox/build/value/clone/clone.mjs +5 -7
- package/node_modules/typebox/build/value/repair/from_cyclic.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_cyclic.mjs +6 -0
- package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +25 -14
- package/node_modules/typebox/package.json +1 -1
- package/node_modules/typebox/readme.md +1 -1
- package/node_modules/undici/docs/docs/api/Interceptors.md +15 -2
- package/node_modules/undici/lib/dispatcher/client-h2.js +78 -3
- package/node_modules/undici/lib/dispatcher/pool-base.js +20 -3
- package/node_modules/undici/package.json +3 -3
- package/node_modules/undici/types/api.d.ts +1 -1
- package/node_modules/undici/types/utility.d.ts +4 -4
- package/node_modules/uuid/package.json +17 -17
- package/node_modules/zod/package.json +1 -1
- package/node_modules/zod/src/v4/classic/tests/array.test.ts +27 -0
- package/node_modules/zod/src/v4/classic/tests/map.test.ts +7 -0
- package/node_modules/zod/src/v4/classic/tests/set.test.ts +6 -0
- package/node_modules/zod/src/v4/core/compile.ts +9 -0
- package/node_modules/zod/src/v4/core/schemas.ts +35 -1
- package/node_modules/zod/src/v4/core/util.ts +13 -0
- package/node_modules/zod/src/v4/core/versions.ts +1 -1
- package/node_modules/zod/v4/core/compile.cjs +8 -0
- package/node_modules/zod/v4/core/compile.js +8 -0
- package/node_modules/zod/v4/core/schemas.cjs +30 -0
- package/node_modules/zod/v4/core/schemas.d.cts +3 -1
- package/node_modules/zod/v4/core/schemas.d.ts +3 -1
- package/node_modules/zod/v4/core/schemas.js +30 -0
- package/node_modules/zod/v4/core/util.cjs +15 -0
- package/node_modules/zod/v4/core/util.d.cts +2 -0
- package/node_modules/zod/v4/core/util.d.ts +2 -0
- package/node_modules/zod/v4/core/util.js +14 -0
- package/node_modules/zod/v4/core/versions.cjs +1 -1
- package/node_modules/zod/v4/core/versions.js +1 -1
- package/openclaw.plugin.json +1 -31
- package/package.json +8 -8
- package/dist/.setup/channel-access-DasWY_OV.mjs +0 -48
- package/dist/.setup/channel.setup-DaDQdctj.mjs +0 -249
- package/dist/.setup/outbound-adapter-DfAanoCO.mjs +0 -543
- package/dist/.setup/provider.runtime-DnionCyo.mjs +0 -2
- package/dist/.setup/setup-plugin-api-D1QuM187.mjs +0 -3
- package/dist/.setup/targets-UWWZ6gF7.mjs +0 -3
- package/node_modules/typebox/build/system/memory/freeze.d.mts +0 -4
- package/node_modules/typebox/build/system/memory/freeze.mjs +0 -6
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.mjs";
|
|
2
|
-
import { A as resolveDiscordSendEmbeds, D as createDiscordMessageNonce, E as buildDiscordMessageRequest, M as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { a as normalizeDiscordSnowflake, i as normalizeDiscordHandleKey, s as resolveDiscordDirectoryUserId } from "./directory-live-
|
|
2
|
+
import { A as resolveDiscordSendEmbeds, D as createDiscordMessageNonce, E as buildDiscordMessageRequest, M as createDiscordClient, O as resolveDiscordMessageFlags, c as resolveChannelId, d as sendDiscordChunks, f as sendDiscordMedia, i as normalizeDiscordPollInput, j as resolveDiscordSuppressEmbeds, k as resolveDiscordSendComponents, l as resolveDiscordChannel, n as buildDiscordTextChunks, s as normalizeStickerIds, t as buildDiscordSendError } from "./send.shared-a_6Oeyg1.mjs";
|
|
3
|
+
import { T as createThread, q as withDiscordRequestAuthority, w as createChannelMessage } from "./discord-DGVSguhx.mjs";
|
|
4
|
+
import { n as createDiscordSendReceiptFromResults, r as createDiscordSendResult, u as createReusableDiscordReplyReference } from "./send.receipt-NZDOTZBU.mjs";
|
|
5
|
+
import { a as normalizeDiscordSnowflake, i as normalizeDiscordHandleKey, s as resolveDiscordDirectoryUserId } from "./directory-live-DH3tpS3x.mjs";
|
|
6
|
+
import { t as parseAndResolveDiscordTarget } from "./target-resolver-BOOzqxxM.mjs";
|
|
6
7
|
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
7
8
|
import { ChannelType } from "discord-api-types/v10";
|
|
8
9
|
import { requireRuntimeConfig } from "openclaw/plugin-sdk/plugin-config-runtime";
|
|
@@ -13,6 +14,35 @@ import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
|
13
14
|
import { recordChannelActivity } from "openclaw/plugin-sdk/channel-activity-runtime";
|
|
14
15
|
import { resolveMarkdownTableMode } from "openclaw/plugin-sdk/markdown-table-runtime";
|
|
15
16
|
import { fromMarkdown } from "mdast-util-from-markdown";
|
|
17
|
+
//#region extensions/discord/src/url-ranges.ts
|
|
18
|
+
const DISCORD_URL_START_RE = /(?:[A-Za-z][A-Za-z0-9+.-]*:\/\/|www\.|\/\/|mailto:)/giu;
|
|
19
|
+
function findDiscordUrlRanges(markdown) {
|
|
20
|
+
const ranges = [];
|
|
21
|
+
for (const match of markdown.matchAll(DISCORD_URL_START_RE)) {
|
|
22
|
+
const start = match.index;
|
|
23
|
+
const preceding = markdown[start - 1] ?? "";
|
|
24
|
+
if (/[\p{L}\p{N}]/u.test(preceding) || preceding === "_" && markdown[start - 2] !== "_") continue;
|
|
25
|
+
let end = start + match[0].length;
|
|
26
|
+
let parenthesisDepth = 0;
|
|
27
|
+
while (end < markdown.length) {
|
|
28
|
+
const char = markdown[end];
|
|
29
|
+
if (!char || /[\s<>]/u.test(char)) break;
|
|
30
|
+
if (char === "(") parenthesisDepth += 1;
|
|
31
|
+
else if (char === ")") {
|
|
32
|
+
if (parenthesisDepth === 0) break;
|
|
33
|
+
parenthesisDepth -= 1;
|
|
34
|
+
}
|
|
35
|
+
end += 1;
|
|
36
|
+
}
|
|
37
|
+
while (/[.,!?;:'"]/u.test(markdown[end - 1] ?? "")) end -= 1;
|
|
38
|
+
ranges.push({
|
|
39
|
+
start,
|
|
40
|
+
end
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return ranges;
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
16
46
|
//#region extensions/discord/src/mentions.ts
|
|
17
47
|
const MENTION_CANDIDATE_PATTERN = /(^|[\s([{"'.,;:!?])@([a-z0-9_.-]{2,32}(?:#[0-9]{4})?)/gi;
|
|
18
48
|
const DISCORD_RESERVED_MENTIONS = /* @__PURE__ */ new Set(["everyone", "here"]);
|
|
@@ -20,14 +50,9 @@ const DISCORD_DISCRIMINATOR_SUFFIX = /#\d{4}$/;
|
|
|
20
50
|
const DISCORD_BROADCAST_MENTION_PATTERN = /@(everyone|here)\b/;
|
|
21
51
|
function formatMention(params) {
|
|
22
52
|
const userId = params.userId == null ? null : normalizeDiscordSnowflake(params.userId);
|
|
23
|
-
const roleId = params.roleId == null ? null : normalizeDiscordSnowflake(params.roleId);
|
|
24
53
|
const channelId = params.channelId == null ? null : normalizeDiscordSnowflake(params.channelId);
|
|
25
|
-
const mentions = [
|
|
26
|
-
|
|
27
|
-
roleId ? `<@&${roleId}>` : null,
|
|
28
|
-
channelId ? `<#${channelId}>` : null
|
|
29
|
-
].filter((entry) => Boolean(entry));
|
|
30
|
-
if (mentions.length !== 1) throw new Error("formatMention requires exactly one of userId, roleId, or channelId");
|
|
54
|
+
const mentions = [userId ? `<@${userId}>` : null, channelId ? `<#${channelId}>` : null].filter((entry) => Boolean(entry));
|
|
55
|
+
if (mentions.length !== 1) throw new Error("formatMention requires exactly one of userId or channelId");
|
|
31
56
|
return expectDefined(mentions.at(0), "single Discord mention target");
|
|
32
57
|
}
|
|
33
58
|
function resolveConfiguredMentionAlias(handle, mentionAliases) {
|
|
@@ -45,15 +70,20 @@ function resolveConfiguredMentionAlias(handle, mentionAliases) {
|
|
|
45
70
|
}
|
|
46
71
|
}
|
|
47
72
|
function rewritePlainTextMentions(text, params) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
73
|
+
const urlRanges = findDiscordUrlRanges(text);
|
|
74
|
+
return text.replace(MENTION_CANDIDATE_PATTERN, (match, prefix, handle, offset) => {
|
|
75
|
+
const mentionStart = offset + prefix.length;
|
|
76
|
+
if (urlRanges.some(({ start, end }) => start <= mentionStart && mentionStart < end)) return match;
|
|
77
|
+
for (let candidate = handle; candidate.length >= 2; candidate = candidate.slice(0, -1)) {
|
|
78
|
+
if (DISCORD_RESERVED_MENTIONS.has(candidate.toLowerCase())) return match;
|
|
79
|
+
const userId = resolveConfiguredMentionAlias(candidate, params.mentionAliases) ?? resolveDiscordDirectoryUserId({
|
|
80
|
+
accountId: params.accountId,
|
|
81
|
+
handle: candidate
|
|
82
|
+
});
|
|
83
|
+
if (userId) return `${prefix}${formatMention({ userId })}${handle.slice(candidate.length)}`;
|
|
84
|
+
if (!candidate.endsWith(".")) return match;
|
|
85
|
+
}
|
|
86
|
+
return match;
|
|
57
87
|
});
|
|
58
88
|
}
|
|
59
89
|
function countBacktickRun(text, index) {
|
|
@@ -111,80 +141,14 @@ function discordTextHasBroadcastMention(text) {
|
|
|
111
141
|
//#endregion
|
|
112
142
|
//#region extensions/discord/src/markdown.ts
|
|
113
143
|
const DISCORD_NATIVE_TOKEN_RE = /<a?:[A-Za-z0-9_]+:\d+>|<\/[^>]+:\d+>/giu;
|
|
114
|
-
const DISCORD_URL_START_RE = /(?:[A-Za-z][A-Za-z0-9+.-]*:\/\/|www\.)/giu;
|
|
115
|
-
function findDiscordUrlRanges(markdown) {
|
|
116
|
-
const ranges = [];
|
|
117
|
-
for (const match of markdown.matchAll(DISCORD_URL_START_RE)) {
|
|
118
|
-
const start = match.index;
|
|
119
|
-
const preceding = markdown[start - 1] ?? "";
|
|
120
|
-
if (/[\p{L}\p{N}]/u.test(preceding) || preceding === "_" && markdown[start - 2] !== "_") continue;
|
|
121
|
-
let end = start + match[0].length;
|
|
122
|
-
let parenthesisDepth = 0;
|
|
123
|
-
while (end < markdown.length) {
|
|
124
|
-
const char = markdown[end];
|
|
125
|
-
if (!char || /[\s<>]/u.test(char)) break;
|
|
126
|
-
if (char === "(") parenthesisDepth += 1;
|
|
127
|
-
else if (char === ")") {
|
|
128
|
-
if (parenthesisDepth === 0) break;
|
|
129
|
-
parenthesisDepth -= 1;
|
|
130
|
-
}
|
|
131
|
-
end += 1;
|
|
132
|
-
}
|
|
133
|
-
ranges.push({
|
|
134
|
-
start,
|
|
135
|
-
end
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
return ranges;
|
|
139
|
-
}
|
|
140
|
-
function markdownSemanticSignature(root) {
|
|
141
|
-
const parts = [];
|
|
142
|
-
const pending = [{
|
|
143
|
-
node: root,
|
|
144
|
-
parentStrong: false
|
|
145
|
-
}];
|
|
146
|
-
for (let event = pending.pop(); event; event = pending.pop()) {
|
|
147
|
-
if (event.exiting) {
|
|
148
|
-
parts.push(")");
|
|
149
|
-
continue;
|
|
150
|
-
}
|
|
151
|
-
const { node } = event;
|
|
152
|
-
const redundantStrong = event.parentStrong && node.type === "strong";
|
|
153
|
-
const { children: childNodes, position: _position, ...fields } = node;
|
|
154
|
-
const children = childNodes ?? [];
|
|
155
|
-
if (!redundantStrong) {
|
|
156
|
-
parts.push(`(${JSON.stringify(fields)}`);
|
|
157
|
-
pending.push({
|
|
158
|
-
node,
|
|
159
|
-
parentStrong: event.parentStrong,
|
|
160
|
-
exiting: true
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
const parentStrong = event.parentStrong || node.type === "strong";
|
|
164
|
-
for (let index = children.length - 1; index >= 0; index -= 1) {
|
|
165
|
-
const child = children[index];
|
|
166
|
-
if (child) pending.push({
|
|
167
|
-
node: child,
|
|
168
|
-
parentStrong
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
return parts.join("\n");
|
|
173
|
-
}
|
|
174
144
|
function normalizeDiscordBold(markdown) {
|
|
175
145
|
if (!markdown.includes("__")) return markdown;
|
|
176
146
|
const spans = [];
|
|
177
147
|
const contentEdits = [];
|
|
178
148
|
const starEmphasisDelimiters = /* @__PURE__ */ new Set();
|
|
179
149
|
const astLinkRanges = [];
|
|
180
|
-
const
|
|
181
|
-
const activeSpanIds = [];
|
|
182
|
-
const pending = [{ node: sourceTree }];
|
|
150
|
+
const pending = [{ node: fromMarkdown(markdown) }];
|
|
183
151
|
for (let event = pending.pop(); event; event = pending.pop()) {
|
|
184
|
-
if (event.exiting !== void 0) {
|
|
185
|
-
activeSpanIds.pop();
|
|
186
|
-
continue;
|
|
187
|
-
}
|
|
188
152
|
const { node } = event;
|
|
189
153
|
const start = node.position?.start.offset;
|
|
190
154
|
const end = node.position?.end.offset;
|
|
@@ -192,18 +156,18 @@ function normalizeDiscordBold(markdown) {
|
|
|
192
156
|
start,
|
|
193
157
|
end
|
|
194
158
|
});
|
|
195
|
-
let
|
|
159
|
+
let spanId = event.spanId;
|
|
160
|
+
let enteredSpan = false;
|
|
196
161
|
if (node.type === "strong" && start !== void 0 && end !== void 0 && markdown.startsWith("__", start) && markdown.slice(end - 2, end) === "__") {
|
|
197
|
-
|
|
162
|
+
spanId = spans.length;
|
|
198
163
|
spans.push({
|
|
199
164
|
start,
|
|
200
165
|
end
|
|
201
166
|
});
|
|
202
|
-
|
|
167
|
+
enteredSpan = true;
|
|
203
168
|
}
|
|
204
|
-
const spanId = activeSpanIds.at(-1);
|
|
205
169
|
if (spanId !== void 0 && start !== void 0 && end !== void 0) {
|
|
206
|
-
if (node.type === "strong" &&
|
|
170
|
+
if (node.type === "strong" && !enteredSpan && markdown.startsWith("**", start) && markdown.slice(end - 2, end) === "**") contentEdits.push({
|
|
207
171
|
spanId,
|
|
208
172
|
start,
|
|
209
173
|
marker: "****",
|
|
@@ -245,14 +209,13 @@ function normalizeDiscordBold(markdown) {
|
|
|
245
209
|
});
|
|
246
210
|
}
|
|
247
211
|
}
|
|
248
|
-
if (enteredSpanId !== void 0) pending.push({
|
|
249
|
-
node,
|
|
250
|
-
exiting: enteredSpanId
|
|
251
|
-
});
|
|
252
212
|
const children = node.children ?? [];
|
|
253
213
|
for (let index = children.length - 1; index >= 0; index -= 1) {
|
|
254
214
|
const child = children[index];
|
|
255
|
-
if (child) pending.push({
|
|
215
|
+
if (child) pending.push({
|
|
216
|
+
node: child,
|
|
217
|
+
spanId
|
|
218
|
+
});
|
|
256
219
|
}
|
|
257
220
|
}
|
|
258
221
|
if (spans.length === 0) return markdown;
|
|
@@ -269,7 +232,7 @@ function normalizeDiscordBold(markdown) {
|
|
|
269
232
|
...findDiscordUrlRanges(markdown),
|
|
270
233
|
...astLinkRanges,
|
|
271
234
|
...nativeTokenRanges
|
|
272
|
-
].
|
|
235
|
+
].sort((left, right) => left.start - right.start).map(({ start, end: rawEnd }) => {
|
|
273
236
|
let end = rawEnd;
|
|
274
237
|
while (/[.,!?;:'"]/u.test(markdown[end - 1] ?? "")) end -= 1;
|
|
275
238
|
let previousEnd = -1;
|
|
@@ -293,55 +256,34 @@ function normalizeDiscordBold(markdown) {
|
|
|
293
256
|
marker: "**",
|
|
294
257
|
consume: 2,
|
|
295
258
|
delimiter: true
|
|
296
|
-
}))), ...contentEdits].
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
const spanEdits = editsBySpan.get(edit.spanId) ?? [];
|
|
300
|
-
spanEdits.push(edit);
|
|
301
|
-
editsBySpan.set(edit.spanId, spanEdits);
|
|
302
|
-
}
|
|
303
|
-
const renderEdits = (selectedEdits, start = 0, end = markdown.length) => {
|
|
304
|
-
let cursor = start;
|
|
259
|
+
}))), ...contentEdits].sort((left, right) => left.start - right.start);
|
|
260
|
+
const renderEdits = (selectedEdits) => {
|
|
261
|
+
let cursor = 0;
|
|
305
262
|
let rendered = "";
|
|
306
263
|
for (const edit of selectedEdits) {
|
|
307
264
|
rendered += `${markdown.slice(cursor, edit.start)}${edit.marker}`;
|
|
308
265
|
cursor = edit.start + edit.consume;
|
|
309
266
|
}
|
|
310
|
-
return rendered + markdown.slice(cursor
|
|
267
|
+
return rendered + markdown.slice(cursor);
|
|
311
268
|
};
|
|
312
269
|
const protectedSpanIds = /* @__PURE__ */ new Set();
|
|
313
270
|
const protectedEditKeys = /* @__PURE__ */ new Set();
|
|
314
|
-
const spansWithProtectedContent = /* @__PURE__ */ new Set();
|
|
315
271
|
let rangeIndex = 0;
|
|
316
272
|
for (const edit of edits) {
|
|
317
273
|
while ((protectedRanges[rangeIndex]?.end ?? Number.POSITIVE_INFINITY) <= edit.start) rangeIndex += 1;
|
|
318
274
|
const range = protectedRanges[rangeIndex];
|
|
319
275
|
if (range && (edit.consume === 0 ? edit.start >= range.start && edit.start < range.end : edit.start < range.end && edit.start + edit.consume > range.start)) {
|
|
320
|
-
if (edit.delimiter) protectedSpanIds.add(edit.spanId);
|
|
321
|
-
else {
|
|
322
|
-
protectedEditKeys.add(`${edit.start}:${edit.consume}:${edit.marker}`);
|
|
323
|
-
spansWithProtectedContent.add(edit.spanId);
|
|
324
|
-
}
|
|
276
|
+
if (edit.delimiter || !astLinkRanges.some(({ start, end }) => edit.start >= start && edit.start + edit.consume <= end)) protectedSpanIds.add(edit.spanId);
|
|
277
|
+
else protectedEditKeys.add(`${edit.start}:${edit.consume}:${edit.marker}`);
|
|
325
278
|
}
|
|
326
279
|
}
|
|
327
|
-
for (const spanId of spansWithProtectedContent) {
|
|
328
|
-
const span = spans[spanId];
|
|
329
|
-
if (!span) continue;
|
|
330
|
-
const localRendered = renderEdits((editsBySpan.get(spanId) ?? []).filter((edit) => {
|
|
331
|
-
const key = `${edit.start}:${edit.consume}:${edit.marker}`;
|
|
332
|
-
return !protectedEditKeys.has(key);
|
|
333
|
-
}), span.start, span.end);
|
|
334
|
-
const localSource = markdown.slice(span.start, span.end);
|
|
335
|
-
if (markdownSemanticSignature(fromMarkdown(localRendered)) !== markdownSemanticSignature(fromMarkdown(localSource))) protectedSpanIds.add(spanId);
|
|
336
|
-
}
|
|
337
280
|
const seenEdits = /* @__PURE__ */ new Set();
|
|
338
|
-
|
|
281
|
+
return renderEdits(edits.filter((edit) => {
|
|
339
282
|
const key = `${edit.start}:${edit.consume}:${edit.marker}`;
|
|
340
283
|
if (protectedSpanIds.has(edit.spanId) || protectedEditKeys.has(key) || seenEdits.has(key)) return false;
|
|
341
284
|
seenEdits.add(key);
|
|
342
285
|
return true;
|
|
343
286
|
}));
|
|
344
|
-
return markdownSemanticSignature(fromMarkdown(rendered)) === markdownSemanticSignature(sourceTree) ? rendered : markdown;
|
|
345
287
|
}
|
|
346
288
|
function renderDiscordMarkdown(markdown, tableMode) {
|
|
347
289
|
return normalizeDiscordBold(convertMarkdownTables(markdown, tableMode));
|
|
@@ -376,7 +318,6 @@ const DEFAULT_DISCORD_MEDIA_MAX_MB = 100;
|
|
|
376
318
|
const DISCORD_FORUM_REQUIRE_TAG_FLAG = 16;
|
|
377
319
|
/** Discord thread names are capped at 100 characters. */
|
|
378
320
|
const DISCORD_THREAD_NAME_LIMIT = 100;
|
|
379
|
-
/** Derive a thread title from the first non-empty line of the message text. */
|
|
380
321
|
function deriveForumThreadName(text) {
|
|
381
322
|
const firstLine = normalizeOptionalString(text.split("\n").find((line) => normalizeOptionalString(line))) ?? "";
|
|
382
323
|
return truncateUtf16Safe(firstLine, DISCORD_THREAD_NAME_LIMIT) || (/* @__PURE__ */ new Date()).toISOString().slice(0, 16);
|
|
@@ -405,7 +346,10 @@ async function sendMessageDiscord(to, text, opts) {
|
|
|
405
346
|
tableMode: opts.tableMode,
|
|
406
347
|
textLimit: opts.textLimit
|
|
407
348
|
});
|
|
408
|
-
const recipient = await
|
|
349
|
+
const recipient = await parseAndResolveDiscordTarget(to, {
|
|
350
|
+
cfg,
|
|
351
|
+
accountId: accountInfo.accountId
|
|
352
|
+
}, { defaultKind: "channel" });
|
|
409
353
|
const { channelId } = await resolveChannelId(rest, recipient, request);
|
|
410
354
|
const channel = await resolveDiscordChannel(rest, channelId);
|
|
411
355
|
const deliveredResults = [];
|
|
@@ -587,7 +531,10 @@ async function sendDiscordStructuredMessage(to, opts, kind, buildPayload) {
|
|
|
587
531
|
...opts,
|
|
588
532
|
cfg
|
|
589
533
|
});
|
|
590
|
-
const recipient = await
|
|
534
|
+
const recipient = await parseAndResolveDiscordTarget(to, {
|
|
535
|
+
cfg,
|
|
536
|
+
accountId: account.accountId
|
|
537
|
+
}, { defaultKind: "channel" });
|
|
591
538
|
const { channelId } = await resolveChannelId(rest, recipient, request);
|
|
592
539
|
const content = opts.content?.trim() ? rewriteDiscordKnownMentions(opts.content, {
|
|
593
540
|
accountId: account.accountId,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as RateLimitError } from "./discord-DGVSguhx.mjs";
|
|
2
2
|
import { t as parseDiscordTarget } from "./target-parsing-C-HyNxcE.mjs";
|
|
3
3
|
import { collectErrorGraphCandidates, extractErrorCode, formatErrorMessage, readErrorName } from "openclaw/plugin-sdk/error-runtime";
|
|
4
4
|
import { sleepWithAbort } from "openclaw/plugin-sdk/runtime-env";
|
|
@@ -430,7 +430,7 @@ function createDiscordRetryRunner(params) {
|
|
|
430
430
|
throw err;
|
|
431
431
|
}
|
|
432
432
|
};
|
|
433
|
-
const shouldRetry = (err, attempt) => isRetryableDiscordError(err, safety) && (attempt < retryConfig.attempts || observedGatewayDisconnect &&
|
|
433
|
+
const shouldRetry = (err, attempt) => isRetryableDiscordError(err, safety) && (attempt < retryConfig.attempts || observedGatewayDisconnect && !(err instanceof RateLimitError) && !collectDiscordErrorCandidates(err).some((candidate) => readDiscordErrorStatus(candidate) !== void 0));
|
|
434
434
|
const retryAfterMs = (err) => err instanceof RateLimitError ? err.retryAfter * 1e3 : void 0;
|
|
435
435
|
const signal = params.signal;
|
|
436
436
|
if (signal) return retryAsync(runRequest, {
|
|
@@ -460,6 +460,25 @@ function createDiscordRetryRunner(params) {
|
|
|
460
460
|
};
|
|
461
461
|
}
|
|
462
462
|
//#endregion
|
|
463
|
+
//#region extensions/discord/src/reply-reference.ts
|
|
464
|
+
function resolveDiscordReplyReference(params) {
|
|
465
|
+
if (!params.replyToId) return;
|
|
466
|
+
const singleUse = params.replyToIdSource !== "explicit" && params.replyToMode !== void 0 && isSingleUseReplyToMode(params.replyToMode);
|
|
467
|
+
return {
|
|
468
|
+
messageId: params.replyToId,
|
|
469
|
+
scope: singleUse ? "first" : "all"
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
function createReusableDiscordReplyReference(messageId) {
|
|
473
|
+
return messageId ? {
|
|
474
|
+
messageId,
|
|
475
|
+
scope: "all"
|
|
476
|
+
} : void 0;
|
|
477
|
+
}
|
|
478
|
+
function resolveDiscordReplyMessageId(reply, isFirst) {
|
|
479
|
+
return reply && (isFirst || reply.scope === "all") ? reply.messageId : void 0;
|
|
480
|
+
}
|
|
481
|
+
//#endregion
|
|
463
482
|
//#region extensions/discord/src/normalize.ts
|
|
464
483
|
function normalizeDiscordMessagingTarget(raw) {
|
|
465
484
|
return parseDiscordTarget(raw, { defaultKind: "channel" })?.normalized;
|
|
@@ -506,25 +525,6 @@ function looksLikeDiscordTargetId(raw) {
|
|
|
506
525
|
return /^<@!?\d+>$/.test(trimmed) || /^(?:(?:user|channel|discord):\d+|discord:(?:user|channel):\d+)$/i.test(trimmed) || /^\d{6,}$/.test(trimmed);
|
|
507
526
|
}
|
|
508
527
|
//#endregion
|
|
509
|
-
//#region extensions/discord/src/reply-reference.ts
|
|
510
|
-
function resolveDiscordReplyReference(params) {
|
|
511
|
-
if (!params.replyToId) return;
|
|
512
|
-
const singleUse = params.replyToIdSource !== "explicit" && params.replyToMode !== void 0 && isSingleUseReplyToMode(params.replyToMode);
|
|
513
|
-
return {
|
|
514
|
-
messageId: params.replyToId,
|
|
515
|
-
scope: singleUse ? "first" : "all"
|
|
516
|
-
};
|
|
517
|
-
}
|
|
518
|
-
function createReusableDiscordReplyReference(messageId) {
|
|
519
|
-
return messageId ? {
|
|
520
|
-
messageId,
|
|
521
|
-
scope: "all"
|
|
522
|
-
} : void 0;
|
|
523
|
-
}
|
|
524
|
-
function resolveDiscordReplyMessageId(reply, isFirst) {
|
|
525
|
-
return reply && (isFirst || reply.scope === "all") ? reply.messageId : void 0;
|
|
526
|
-
}
|
|
527
|
-
//#endregion
|
|
528
528
|
//#region extensions/discord/src/send.receipt.ts
|
|
529
529
|
function toDiscordOutboundDeliveryResult(result) {
|
|
530
530
|
const { channelId, ...delivery } = result;
|
|
@@ -541,17 +541,15 @@ function createDiscordSendReceiptFromResults(params) {
|
|
|
541
541
|
results: attachChannelToResults("discord", params.results),
|
|
542
542
|
threadId: params.threadId
|
|
543
543
|
});
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
parts: receipt.parts.map(({ platformMessageId, kind, threadId, replyToId, raw }, index) => ({
|
|
547
|
-
platformMessageId,
|
|
548
|
-
kind,
|
|
544
|
+
receipt.parts.forEach((part, index) => {
|
|
545
|
+
Object.assign(part, {
|
|
549
546
|
index,
|
|
550
|
-
threadId,
|
|
551
|
-
replyToId,
|
|
552
|
-
raw
|
|
553
|
-
})
|
|
554
|
-
};
|
|
547
|
+
threadId: part.threadId,
|
|
548
|
+
replyToId: part.replyToId,
|
|
549
|
+
raw: part.raw
|
|
550
|
+
});
|
|
551
|
+
});
|
|
552
|
+
return receipt;
|
|
555
553
|
}
|
|
556
554
|
function createDiscordSendReceipt(params) {
|
|
557
555
|
const results = params.platformMessageIds.map((messageId) => messageId.trim()).filter(Boolean).map((messageId, index) => {
|
|
@@ -591,4 +589,4 @@ function createDiscordSendResult(params) {
|
|
|
591
589
|
};
|
|
592
590
|
}
|
|
593
591
|
//#endregion
|
|
594
|
-
export { recordDiscordMessageCreateAmbiguity as _,
|
|
592
|
+
export { recordDiscordMessageCreateAmbiguity as _, allowFromContainsDiscordUserId as a, normalizeDiscordMessagingTarget as c, resolveDiscordReplyMessageId as d, resolveDiscordReplyReference as f, hasDiscordMessageCreateAmbiguity as g, createDiscordRetryRunner as h, toDiscordOutboundDeliveryResult as i, normalizeDiscordOutboundTarget as l, classifyDiscordDeliveryFailure as m, createDiscordSendReceiptFromResults as n, looksLikeDiscordTargetId as o, canFallbackDiscordWebhookSend as p, createDiscordSendResult as r, matchesDiscordToolContextTarget as s, createDiscordSendReceipt as t, createReusableDiscordReplyReference as u, chunkDiscordTextWithMode as v, findGraphemeChunkEnd as y };
|