@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,19 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { q as withDiscordRequestAuthority } from "./discord-DGVSguhx.mjs";
|
|
2
|
+
import { i as resolveDiscordEndpointMediaGuard, n as getDiscordEndpointRuntime } from "./endpoint-runtime-lf4DeLas.mjs";
|
|
2
3
|
import { t as getDiscordRuntime } from "./runtime-DgnVQ7zW.mjs";
|
|
3
|
-
import { D as
|
|
4
|
-
import { E as hasDiscordMessageStickers, T as resolveDiscordCdnPolicy, b as resolveDiscordMessageText, j as resolveDiscordMessageChannelId, k as resolveDiscordReferencedReplyMessageId } from "./transcripts-source-
|
|
4
|
+
import { D as createMessageDispatchData, E as createDiscordLivePolicyReader } from "./provider-BN2bCIUp.mjs";
|
|
5
|
+
import { E as hasDiscordMessageStickers, T as resolveDiscordCdnPolicy, b as resolveDiscordMessageText, j as resolveDiscordMessageChannelId, k as resolveDiscordReferencedReplyMessageId } from "./transcripts-source-ie9GBWaU.mjs";
|
|
5
6
|
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
6
7
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
7
8
|
import { danger } from "openclaw/plugin-sdk/runtime-env";
|
|
8
9
|
import { normalizeNullableString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
9
10
|
import { createRuntimeConfigReader } from "openclaw/plugin-sdk/runtime-config-snapshot";
|
|
10
|
-
import {
|
|
11
|
-
import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
|
|
11
|
+
import { Routes } from "discord-api-types/v10";
|
|
12
12
|
import { saveRemoteMedia } from "openclaw/plugin-sdk/media-runtime";
|
|
13
13
|
import { logDebug } from "openclaw/plugin-sdk/logging-core";
|
|
14
|
-
import { DEFAULT_INGRESS_RETRY_MAX_ATTEMPTS, createChannelIngressError, createChannelIngressMonitor, createChannelRunQueue } from "openclaw/plugin-sdk/channel-outbound";
|
|
15
|
-
import { fanInChannelIngressLifecycles } from "openclaw/plugin-sdk/channel-ingress-runtime";
|
|
16
14
|
import { createDeferred } from "openclaw/plugin-sdk/concurrency-runtime";
|
|
15
|
+
import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
|
|
16
|
+
import { DEFAULT_INGRESS_RETRY_MAX_ATTEMPTS, createChannelIngressError, createChannelIngressMonitor, createChannelRunQueue, resolveChannelMessageSourceReplyDeliveryMode } from "openclaw/plugin-sdk/channel-outbound";
|
|
17
|
+
import { racePromiseWithAbortSignal } from "openclaw/plugin-sdk/time-runtime";
|
|
18
|
+
import { fanInChannelIngressLifecycles, prepareChannelIngressEvent } from "openclaw/plugin-sdk/channel-ingress-runtime";
|
|
17
19
|
import { createChannelInboundDebouncer, resolveInboundDebounceMs, shouldDebounceTextInbound } from "openclaw/plugin-sdk/channel-inbound";
|
|
18
20
|
//#region extensions/discord/src/monitor/ingress.ts
|
|
19
21
|
const DISCORD_INGRESS_PAYLOAD_VERSION = 1;
|
|
@@ -63,6 +65,22 @@ function createDiscordIngressMonitor(params) {
|
|
|
63
65
|
const monitor = createChannelIngressMonitor({
|
|
64
66
|
queue,
|
|
65
67
|
inspect: inspectDiscordMessage,
|
|
68
|
+
prepareAdmission: async (rawMessage, { receivedAt, signal }) => {
|
|
69
|
+
const prepared = await prepareChannelIngressEvent(rawMessage, {
|
|
70
|
+
channelId: "discord",
|
|
71
|
+
accountId: params.accountId,
|
|
72
|
+
signal
|
|
73
|
+
});
|
|
74
|
+
if (!prepared) return;
|
|
75
|
+
return {
|
|
76
|
+
raw: decodeDiscordIngressPayload({
|
|
77
|
+
version: DISCORD_INGRESS_PAYLOAD_VERSION,
|
|
78
|
+
receivedAt,
|
|
79
|
+
rawMessage: prepared.event
|
|
80
|
+
}, rawMessage.id).body.rawMessage,
|
|
81
|
+
assertCurrent: prepared.assertCurrent
|
|
82
|
+
};
|
|
83
|
+
},
|
|
66
84
|
payload: {
|
|
67
85
|
version: DISCORD_INGRESS_PAYLOAD_VERSION,
|
|
68
86
|
serialize: (rawMessage, { receivedAt }) => ({
|
|
@@ -78,7 +96,7 @@ function createDiscordIngressMonitor(params) {
|
|
|
78
96
|
createClaimError: (kind) => new DiscordIngressPayloadError(kind === "invalid-version" ? "Discord ingress payload version is unsupported" : "Discord message identity changed after durable admission")
|
|
79
97
|
},
|
|
80
98
|
deliver: async (rawMessage, lifecycle) => {
|
|
81
|
-
const event =
|
|
99
|
+
const event = createMessageDispatchData(params.client, rawMessage);
|
|
82
100
|
return await params.dispatch(event, lifecycle);
|
|
83
101
|
},
|
|
84
102
|
pollIntervalMs: DISCORD_INGRESS_DRAIN_INTERVAL_MS,
|
|
@@ -105,6 +123,10 @@ function createDiscordIngressMonitor(params) {
|
|
|
105
123
|
};
|
|
106
124
|
return null;
|
|
107
125
|
},
|
|
126
|
+
onDeadLetter: async (claim, _failure, signal) => {
|
|
127
|
+
const { rawMessage } = decodeDiscordIngressPayload(claim.payload, claim.id).body;
|
|
128
|
+
await params.onDeadLetter?.(createMessageDispatchData(params.client, rawMessage), signal);
|
|
129
|
+
},
|
|
108
130
|
onLog: (message) => params.runtime.error?.(danger(`discord ingress: ${message}`))
|
|
109
131
|
},
|
|
110
132
|
onError: (error) => params.runtime.error?.(danger(`discord ingress drain failed: ${formatErrorMessage(error)}`))
|
|
@@ -194,93 +216,9 @@ function createDiscordAvatarResolver() {
|
|
|
194
216
|
} };
|
|
195
217
|
}
|
|
196
218
|
//#endregion
|
|
197
|
-
//#region extensions/discord/src/monitor/message-run-queue.ts
|
|
198
|
-
const loadMessageProcessRuntime = createLazyRuntimeModule(() => import("./message-handler.process-DsMtetRf.mjs"));
|
|
199
|
-
async function processDiscordQueuedMessage(params) {
|
|
200
|
-
const abortSignal = params.job.context.abortSignal && params.lifecycleSignal ? AbortSignal.any([params.job.context.abortSignal, params.lifecycleSignal]) : params.job.context.abortSignal ?? params.lifecycleSignal;
|
|
201
|
-
try {
|
|
202
|
-
await (params.testing?.processDiscordMessage ?? (await loadMessageProcessRuntime()).processDiscordMessage)({
|
|
203
|
-
...params.job.context,
|
|
204
|
-
abortSignal
|
|
205
|
-
});
|
|
206
|
-
if (abortSignal?.aborted) await params.job.ingressSettlement?.cancel();
|
|
207
|
-
else await params.job.ingressSettlement?.settle();
|
|
208
|
-
} catch (error) {
|
|
209
|
-
if (abortSignal?.aborted) await params.job.ingressSettlement?.cancel();
|
|
210
|
-
else await params.job.ingressSettlement?.abandon(error);
|
|
211
|
-
throw error;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
function createDiscordMessageRunQueue(params) {
|
|
215
|
-
const skippedCleanup = /* @__PURE__ */ new Set();
|
|
216
|
-
const runQueue = createChannelRunQueue({
|
|
217
|
-
setStatus: params.setStatus,
|
|
218
|
-
abortSignal: params.abortSignal,
|
|
219
|
-
onError: (error) => {
|
|
220
|
-
params.runtime.error(danger(`discord message run failed: ${String(error)}`));
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
let lifecycleActive = !params.abortSignal?.aborted;
|
|
224
|
-
const pendingTasks = /* @__PURE__ */ new Set();
|
|
225
|
-
const onAbort = () => void cleanupSkippedQueuedMessages();
|
|
226
|
-
async function cleanupSkippedQueuedMessages() {
|
|
227
|
-
params.abortSignal?.removeEventListener("abort", onAbort);
|
|
228
|
-
if (!lifecycleActive && skippedCleanup.size === 0) return;
|
|
229
|
-
lifecycleActive = false;
|
|
230
|
-
const cleanups = [...skippedCleanup];
|
|
231
|
-
skippedCleanup.clear();
|
|
232
|
-
for (const cleanup of cleanups) await cleanup();
|
|
233
|
-
}
|
|
234
|
-
if (params.abortSignal?.aborted) cleanupSkippedQueuedMessages();
|
|
235
|
-
else params.abortSignal?.addEventListener("abort", onAbort, { once: true });
|
|
236
|
-
return {
|
|
237
|
-
enqueue(job) {
|
|
238
|
-
const { promise: pending, resolve: resolvePending } = createDeferred();
|
|
239
|
-
pendingTasks.add(pending);
|
|
240
|
-
const settlePending = () => {
|
|
241
|
-
pendingTasks.delete(pending);
|
|
242
|
-
resolvePending();
|
|
243
|
-
};
|
|
244
|
-
const cleanupSkipped = async () => {
|
|
245
|
-
try {
|
|
246
|
-
await job.ingressSettlement?.cancel();
|
|
247
|
-
} catch (error) {
|
|
248
|
-
try {
|
|
249
|
-
params.runtime.error(danger(`discord queued message cleanup failed: ${String(error)}`));
|
|
250
|
-
} catch {}
|
|
251
|
-
} finally {
|
|
252
|
-
settlePending();
|
|
253
|
-
}
|
|
254
|
-
};
|
|
255
|
-
if (!lifecycleActive) {
|
|
256
|
-
cleanupSkipped();
|
|
257
|
-
return pending;
|
|
258
|
-
}
|
|
259
|
-
skippedCleanup.add(cleanupSkipped);
|
|
260
|
-
runQueue.enqueue(job.context.message.id, async ({ lifecycleSignal }) => {
|
|
261
|
-
skippedCleanup.delete(cleanupSkipped);
|
|
262
|
-
try {
|
|
263
|
-
await processDiscordQueuedMessage({
|
|
264
|
-
job,
|
|
265
|
-
lifecycleSignal,
|
|
266
|
-
testing: params.testing
|
|
267
|
-
});
|
|
268
|
-
} finally {
|
|
269
|
-
settlePending();
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
return pending;
|
|
273
|
-
},
|
|
274
|
-
async deactivate() {
|
|
275
|
-
runQueue.deactivate();
|
|
276
|
-
await cleanupSkippedQueuedMessages();
|
|
277
|
-
await Promise.allSettled(pendingTasks);
|
|
278
|
-
}
|
|
279
|
-
};
|
|
280
|
-
}
|
|
281
|
-
//#endregion
|
|
282
219
|
//#region extensions/discord/src/monitor/message-dispatcher.ts
|
|
283
|
-
const loadMessagePreflightRuntime = createLazyRuntimeModule(() => import("./message-handler.preflight-
|
|
220
|
+
const loadMessagePreflightRuntime = createLazyRuntimeModule(() => import("./message-handler.preflight-BZcZE1o-.mjs"));
|
|
221
|
+
const loadMessageProcessRuntime = createLazyRuntimeModule(() => import("./message-handler.process-B0n-mQ99.mjs"));
|
|
284
222
|
function createDiscordMessageDispatcher(params) {
|
|
285
223
|
const readPolicy = params.readPolicy ?? createDiscordLivePolicyReader({
|
|
286
224
|
...params,
|
|
@@ -302,15 +240,43 @@ function createDiscordMessageDispatcher(params) {
|
|
|
302
240
|
}
|
|
303
241
|
});
|
|
304
242
|
const readConfig = createRuntimeConfigReader(params.cfg);
|
|
305
|
-
const
|
|
306
|
-
const
|
|
307
|
-
runtime: params.runtime,
|
|
243
|
+
const skippedCleanup = /* @__PURE__ */ new Set();
|
|
244
|
+
const runQueue = createChannelRunQueue({
|
|
308
245
|
setStatus: params.setStatus,
|
|
309
246
|
abortSignal: params.abortSignal,
|
|
310
|
-
|
|
247
|
+
onError: (error) => {
|
|
248
|
+
params.runtime.error(danger(`discord message run failed: ${String(error)}`));
|
|
249
|
+
}
|
|
311
250
|
});
|
|
251
|
+
let lifecycleActive = !params.abortSignal?.aborted;
|
|
252
|
+
const pendingTasks = /* @__PURE__ */ new Set();
|
|
253
|
+
const onAbort = () => void cleanupSkippedQueuedMessages();
|
|
254
|
+
async function cleanupSkippedQueuedMessages() {
|
|
255
|
+
params.abortSignal?.removeEventListener("abort", onAbort);
|
|
256
|
+
if (!lifecycleActive && skippedCleanup.size === 0) return;
|
|
257
|
+
lifecycleActive = false;
|
|
258
|
+
const cleanups = [...skippedCleanup];
|
|
259
|
+
skippedCleanup.clear();
|
|
260
|
+
for (const cleanup of cleanups) await cleanup();
|
|
261
|
+
}
|
|
262
|
+
if (params.abortSignal?.aborted) cleanupSkippedQueuedMessages();
|
|
263
|
+
else params.abortSignal?.addEventListener("abort", onAbort, { once: true });
|
|
312
264
|
const dispatcherShutdown = new AbortController();
|
|
313
265
|
const avatarResolver = createDiscordAvatarResolver();
|
|
266
|
+
const preflightMessage = async (data, client, options) => {
|
|
267
|
+
const policy = await readPolicy();
|
|
268
|
+
const { preflightDiscordMessage } = await loadMessagePreflightRuntime();
|
|
269
|
+
return await preflightDiscordMessage({
|
|
270
|
+
...params,
|
|
271
|
+
...policy,
|
|
272
|
+
...options,
|
|
273
|
+
isPolicyCurrent: policy.isCurrent,
|
|
274
|
+
avatarResolver,
|
|
275
|
+
ackReactionScope: params.discordConfig?.ackReactionScope ?? policy.cfg.messages?.ackReactionScope ?? "group-mentions",
|
|
276
|
+
data,
|
|
277
|
+
client
|
|
278
|
+
});
|
|
279
|
+
};
|
|
314
280
|
const pendingDebounceEntries = /* @__PURE__ */ new Set();
|
|
315
281
|
const pendingCancellationSettlements = /* @__PURE__ */ new Set();
|
|
316
282
|
const resolveDebounceKey = (entry) => {
|
|
@@ -357,20 +323,11 @@ function createDiscordMessageDispatcher(params) {
|
|
|
357
323
|
return;
|
|
358
324
|
}
|
|
359
325
|
try {
|
|
360
|
-
const
|
|
361
|
-
const { cfg } = policy;
|
|
362
|
-
const ctx = await (preflightDiscordMessageImpl ?? (await loadMessagePreflightRuntime()).preflightDiscordMessage)({
|
|
363
|
-
...params,
|
|
364
|
-
...policy,
|
|
365
|
-
isPolicyCurrent: policy.isCurrent,
|
|
366
|
-
avatarResolver,
|
|
367
|
-
ackReactionScope: params.discordConfig?.ackReactionScope ?? cfg.messages?.ackReactionScope ?? "group-mentions",
|
|
326
|
+
const ctx = await racePromiseWithAbortSignal(() => preflightMessage(last.data, last.client, {
|
|
368
327
|
abortSignal,
|
|
369
|
-
data: last.data,
|
|
370
|
-
client: last.client,
|
|
371
328
|
precedingMessages: entries.slice(0, -1).map((entry) => entry.data.message),
|
|
372
329
|
turnAdoptionLifecycle: admissionLifecycle
|
|
373
|
-
});
|
|
330
|
+
}), abortSignal);
|
|
374
331
|
if (abortSignal?.aborted) {
|
|
375
332
|
await ingress.cancel();
|
|
376
333
|
return;
|
|
@@ -379,10 +336,54 @@ function createDiscordMessageDispatcher(params) {
|
|
|
379
336
|
await ingress.settle();
|
|
380
337
|
return;
|
|
381
338
|
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
339
|
+
const { promise: pending, resolve: resolvePending } = createDeferred();
|
|
340
|
+
pendingTasks.add(pending);
|
|
341
|
+
const settlePending = () => {
|
|
342
|
+
pendingTasks.delete(pending);
|
|
343
|
+
resolvePending();
|
|
344
|
+
};
|
|
345
|
+
const cleanupSkipped = async () => {
|
|
346
|
+
try {
|
|
347
|
+
await ingress.cancel();
|
|
348
|
+
} catch (error) {
|
|
349
|
+
try {
|
|
350
|
+
params.runtime.error(danger(`discord queued message cleanup failed: ${String(error)}`));
|
|
351
|
+
} catch {}
|
|
352
|
+
} finally {
|
|
353
|
+
settlePending();
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
if (!lifecycleActive) {
|
|
357
|
+
cleanupSkipped();
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
skippedCleanup.add(cleanupSkipped);
|
|
361
|
+
runQueue.enqueue(ctx.message.id, async ({ lifecycleSignal }) => {
|
|
362
|
+
skippedCleanup.delete(cleanupSkipped);
|
|
363
|
+
try {
|
|
364
|
+
const processAbortSignal = ctx.abortSignal && lifecycleSignal ? AbortSignal.any([ctx.abortSignal, lifecycleSignal]) : ctx.abortSignal ?? lifecycleSignal;
|
|
365
|
+
try {
|
|
366
|
+
await racePromiseWithAbortSignal(async () => {
|
|
367
|
+
const { processDiscordMessage } = await loadMessageProcessRuntime();
|
|
368
|
+
await processDiscordMessage({
|
|
369
|
+
...ctx,
|
|
370
|
+
abortSignal: processAbortSignal
|
|
371
|
+
});
|
|
372
|
+
}, processAbortSignal);
|
|
373
|
+
if (processAbortSignal?.aborted) await ingress.cancel();
|
|
374
|
+
else await ingress.settle();
|
|
375
|
+
} catch (error) {
|
|
376
|
+
if (processAbortSignal?.aborted) await ingress.cancel();
|
|
377
|
+
else {
|
|
378
|
+
await ingress.abandon(error);
|
|
379
|
+
throw error;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
} finally {
|
|
383
|
+
settlePending();
|
|
384
|
+
}
|
|
385
385
|
});
|
|
386
|
+
await pending;
|
|
386
387
|
} catch (error) {
|
|
387
388
|
if (abortSignal?.aborted) {
|
|
388
389
|
await ingress.cancel();
|
|
@@ -446,14 +447,51 @@ function createDiscordMessageDispatcher(params) {
|
|
|
446
447
|
const result = dispatchMessage(data, client, options);
|
|
447
448
|
return options?.turnAdoptionLifecycle ? result : result.then(() => void 0);
|
|
448
449
|
};
|
|
450
|
+
handler.notifyDeadLetter = async (data, client, signal) => {
|
|
451
|
+
const abortSignal = AbortSignal.any([
|
|
452
|
+
signal,
|
|
453
|
+
dispatcherShutdown.signal,
|
|
454
|
+
...params.abortSignal ? [params.abortSignal] : []
|
|
455
|
+
]);
|
|
456
|
+
const ctx = await preflightMessage(data, client, { abortSignal });
|
|
457
|
+
if (!ctx) {
|
|
458
|
+
params.runtime.error(danger(`discord ingress: dead-letter notice suppressed for ${data.message.id} (access or reply policy denied, or authority expired)`));
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
const assertCurrent = () => {
|
|
462
|
+
abortSignal.throwIfAborted();
|
|
463
|
+
if (!lifecycleActive || ctx.isPolicyCurrent?.() !== true) throw new Error("discord dead-letter notice suppressed: access authority expired");
|
|
464
|
+
if (resolveChannelMessageSourceReplyDeliveryMode({
|
|
465
|
+
cfg: readConfig(),
|
|
466
|
+
ctx: {
|
|
467
|
+
ChatType: ctx.isDirectMessage ? "direct" : ctx.isGroupDm ? "group" : ctx.isGuildMessage ? "channel" : void 0,
|
|
468
|
+
InboundEventKind: ctx.inboundEventKind
|
|
469
|
+
}
|
|
470
|
+
}) === "message_tool_only") throw new Error("discord dead-letter notice suppressed: source-reply policy");
|
|
471
|
+
};
|
|
472
|
+
assertCurrent();
|
|
473
|
+
await withDiscordRequestAuthority(assertCurrent, () => client.rest.post(Routes.channelMessages(ctx.messageChannelId), { body: {
|
|
474
|
+
content: "⚠️ Couldn't process this message after repeated failures. Please try again.",
|
|
475
|
+
message_reference: {
|
|
476
|
+
message_id: data.message.id,
|
|
477
|
+
fail_if_not_exists: false
|
|
478
|
+
},
|
|
479
|
+
allowed_mentions: {
|
|
480
|
+
parse: [],
|
|
481
|
+
replied_user: false
|
|
482
|
+
}
|
|
483
|
+
} }));
|
|
484
|
+
};
|
|
449
485
|
handler.deactivate = async () => {
|
|
450
486
|
dispatcherShutdown.abort(/* @__PURE__ */ new Error("discord-message-handler-deactivated"));
|
|
451
487
|
const pendingKeys = new Set([...pendingDebounceEntries].map((entry) => entry.debounceKey).filter((key) => key !== void 0));
|
|
452
488
|
for (const key of pendingKeys) debouncer.cancelKey(key);
|
|
453
489
|
pendingDebounceEntries.clear();
|
|
454
490
|
await Promise.allSettled(pendingCancellationSettlements);
|
|
455
|
-
|
|
491
|
+
runQueue.deactivate();
|
|
492
|
+
await cleanupSkippedQueuedMessages();
|
|
456
493
|
await debouncer.drain();
|
|
494
|
+
await Promise.allSettled(pendingTasks);
|
|
457
495
|
};
|
|
458
496
|
return handler;
|
|
459
497
|
}
|
|
@@ -461,12 +499,13 @@ function createDiscordMessageDispatcher(params) {
|
|
|
461
499
|
//#region extensions/discord/src/monitor/message-handler.ts
|
|
462
500
|
function createDiscordMessageHandler(params) {
|
|
463
501
|
const dispatcher = createDiscordMessageDispatcher(params);
|
|
464
|
-
const ingress =
|
|
502
|
+
const ingress = createDiscordIngressMonitor({
|
|
465
503
|
...params,
|
|
466
504
|
dispatch: (event, lifecycle) => dispatcher(event, params.client, {
|
|
467
505
|
abortSignal: lifecycle.abortSignal,
|
|
468
506
|
turnAdoptionLifecycle: lifecycle
|
|
469
|
-
})
|
|
507
|
+
}),
|
|
508
|
+
onDeadLetter: (event, signal) => dispatcher.notifyDeadLetter(event, params.client, signal)
|
|
470
509
|
});
|
|
471
510
|
ingress.start();
|
|
472
511
|
const activeAdmissions = /* @__PURE__ */ new Set();
|