@openclaw/discord 2026.10.10 → 2026.11.5-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.setup/{account-inspect-X_Xlr42B.mjs → account-inspect-CSz5Qodj.mjs} +1 -1
- package/dist/.setup/{accounts-C18HNgge.mjs → accounts-DtjvhJUj.mjs} +9 -6
- package/dist/.setup/{active-turn-thread-route-BAc_Xik-.mjs → active-turn-thread-route-DkPnk2x8.mjs} +1 -2
- package/dist/.setup/{allow-list-D1ZGfhXh.mjs → allow-list-DahA0Jxh.mjs} +3 -150
- package/dist/.setup/{api-Bth1wKF9.mjs → api-Bp0HI4q3.mjs} +10 -20
- package/dist/.setup/{approval-handler.runtime-BAoEELJJ.mjs → approval-handler.runtime-Cy53ugTf.mjs} +80 -61
- package/dist/.setup/{approval-message-updates-Cks-MSCJ.mjs → approval-message-updates-DqOXxPss.mjs} +2 -2
- package/dist/.setup/{audit-Dw_rAZIz.mjs → audit-DoPKOfQE.mjs} +4 -4
- package/dist/.setup/{channel-BMpMAeQL.mjs → channel-Ds6iuNdy.mjs} +134 -201
- package/dist/.setup/channel-access-DhJhVrdZ.mjs +23 -0
- package/dist/.setup/channel.setup-BLt9dkIG.mjs +235 -0
- package/dist/.setup/{components-BvOWSPxr.mjs → components-WTfUxead.mjs} +208 -426
- package/dist/.setup/components.base-C5sAPHe4.mjs +31 -0
- package/dist/.setup/{config-schema-Coyq5wOr.mjs → config-schema-GX2yDgIH.mjs} +6 -7
- package/dist/.setup/{conversation-binding-route-DOPUZNYo.mjs → conversation-binding-route-CZdm-X5A.mjs} +2 -2
- package/dist/.setup/{directory-config-CIqVnQtn.mjs → directory-config-BXJuh9-J.mjs} +1 -1
- package/dist/.setup/{directory-live-DUuPEWub.mjs → directory-live-CEopeb8Q.mjs} +55 -62
- package/dist/.setup/{discord-eFlHX1Gn.mjs → discord-r79VFjJp.mjs} +1087 -1664
- package/dist/.setup/{doctor-Dty_Ossy.mjs → doctor-UfLW8nye.mjs} +3 -5
- package/dist/.setup/endpoint-runtime-BM3x-m6O.mjs +138 -0
- package/dist/.setup/guilds-DQucP5Tn.mjs +21 -0
- package/dist/.setup/{handle-action-DXY91jF-.mjs → handle-action-BarHOi-v.mjs} +15 -15
- package/dist/.setup/{handle-action.guild-admin-BvBCfhXF.mjs → handle-action.guild-admin-oRUb8p_O.mjs} +5 -5
- package/dist/.setup/listeners-CHgTENFu.mjs +46 -0
- package/dist/.setup/{live-policy-config-DO1Fk2hp.mjs → live-policy-config-EKp4O6zx.mjs} +2 -3
- package/dist/.setup/{message-handler-fL1j1NiR.mjs → message-handler-DUeT8Asf.mjs} +154 -113
- package/dist/.setup/{message-handler.preflight-DkjwNZAd.mjs → message-handler.preflight-C6TNtKW0.mjs} +30 -104
- package/dist/.setup/{message-handler.preflight-pluralkit-DR4BnvMU.mjs → message-handler.preflight-pluralkit-6E9TFmmN.mjs} +9 -22
- package/dist/.setup/{message-handler.process-ClOwIPDK.mjs → message-handler.process-D8_oQ5Cp.mjs} +256 -367
- package/dist/.setup/outbound-payload-DUsrFICb.mjs +445 -0
- package/dist/.setup/{outbound-session-route-TFBPPkoz.mjs → outbound-session-route-Cb8cv4Oi.mjs} +138 -86
- package/dist/.setup/{preflight-audio-CwtPIsvk.mjs → preflight-audio-r4BbaJxh.mjs} +1 -5
- package/dist/.setup/{presence-cache-CgutE4NN.mjs → presence-cache-B3xj3b0l.mjs} +1 -6
- package/dist/.setup/{probe-DNge7OEP.mjs → probe-BUmJyH35.mjs} +5 -9
- package/dist/.setup/{provider-BBDuE14w.mjs → provider-Dm2ERSxe.mjs} +3600 -4454
- package/dist/.setup/{provider-session.runtime-D8hMXXqJ.mjs → provider-session.runtime-DCIqDsIg.mjs} +3 -3
- package/dist/.setup/provider.runtime-DmxPGoUg.mjs +1 -0
- package/dist/.setup/proxy-fetch-B8cK6FLQ.mjs +29 -0
- package/dist/.setup/{realtime-session.runtime-cetognkp.mjs → realtime-session.runtime-WJL6NdwK.mjs} +43 -81
- package/dist/.setup/{receive-recovery-C77CVdGM.mjs → receive-recovery-DV_v5ROf.mjs} +13 -27
- package/dist/.setup/{resolve-allowlist-common-CI77288n.mjs → resolve-allowlist-common-C37fgnYG.mjs} +3 -12
- package/dist/.setup/{resolve-channels-DYc6-xgV.mjs → resolve-channels-CwpnQ7C2.mjs} +5 -4
- package/dist/.setup/{resolve-users-BQT7XWF2.mjs → resolve-users-D6jSwe8R.mjs} +4 -7
- package/dist/.setup/{runtime-CcijhTJT.mjs → runtime-B-PgPsGR.mjs} +6 -6
- package/dist/.setup/{runtime-CI0UJqeS.mjs → runtime-DhOMlnYS.mjs} +196 -235
- package/dist/.setup/{secret-config-contract-BdbCvqnM.mjs → secret-config-contract-CP6teHec.mjs} +4 -9
- package/dist/.setup/{send-Cbq-IVsS.mjs → send-DnLL6XoO.mjs} +149 -174
- package/dist/.setup/{send.components-BV6ucNpJ.mjs → send.components-xB43CksK.mjs} +61 -71
- package/dist/.setup/{send.outbound-CGhBhzjQ.mjs → send.outbound-B11X6TOE.mjs} +75 -129
- package/dist/.setup/{send.receipt-Dw-_r5Bx.mjs → send.receipt-CMteCIZS.mjs} +29 -31
- package/dist/.setup/{send.shared-D4MioxW_.mjs → send.shared-BcLLZBul.mjs} +38 -112
- package/dist/.setup/{sender-identity-DrN5c4ec.mjs → sender-identity-CGNpdJmb.mjs} +3 -9
- package/dist/.setup/setup-plugin-api-C6AMx3hu.mjs +2 -0
- package/dist/.setup/{shared-Bp0sxD5R.mjs → shared-BEYw16he.mjs} +8 -10
- package/dist/.setup/shared-interactive-DKBw4SNV.mjs +311 -0
- package/dist/.setup/{subagent-hooks-mQbDkvuD.mjs → subagent-hooks-DlYElpXa.mjs} +1 -1
- package/dist/.setup/{system-events-2zc2eGfF.mjs → system-events--Pk6y9aP.mjs} +2 -2
- package/dist/.setup/{target-resolver-CAHeVfmZ.mjs → target-resolver-Bo9EpGp_.mjs} +3 -3
- package/dist/.setup/{thread-bindings-Dg7X_ZXP.mjs → thread-bindings-BF-hr-bg.mjs} +12 -20
- package/dist/.setup/{thread-bindings.manager-DCDYksah.mjs → thread-bindings.manager-CQCkha5r.mjs} +22 -42
- package/dist/.setup/{thread-bindings.session-updates-C76plLS3.mjs → thread-bindings.session-updates-C2gJAj_I.mjs} +11 -18
- package/dist/.setup/{threading-l0UfrE6x.mjs → threading-HA9C2wYR.mjs} +68 -104
- package/dist/.setup/{timeouts-DTrUsJ_W.mjs → timeouts-CT9hnmo4.mjs} +1 -1
- package/dist/.setup/{transcripts-source-CGgOaWcu.mjs → transcripts-source-DzpzETZR.mjs} +102 -172
- package/dist/.setup/{voice-runtime-DY1EwDfi.mjs → voice-runtime-Bo_nsVvX.mjs} +231 -448
- package/dist/.source-module-urls/d6c089460280c5a04184542d6712e04545caeb1ebb290d3504377b4cc5e22fea.json +1 -1
- package/dist/account-inspect-api.js +1 -1
- package/dist/action-runtime-api.js +1 -1
- package/dist/activities-api.js +285 -337
- package/dist/api.js +16 -16
- package/dist/assets/embedded-app-sdk.mjs +1 -1
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/directory-contract-api.js +1 -1
- package/dist/runtime-api.js +22 -22
- package/dist/secret-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 +56 -68
- package/dist/subagent-hooks-api.js +1 -1
- package/dist/transcripts-source-api.js +1 -1
- package/node_modules/@discord/embedded-app-sdk/output/lib/zod/lib/index.cjs +2 -3
- package/node_modules/@discord/embedded-app-sdk/output/lib/zod/lib/index.mjs +2 -3
- package/node_modules/@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-BPrWoEXM.mjs +0 -47
- package/dist/.setup/channel.setup-DVe7Y3Jf.mjs +0 -245
- package/dist/.setup/outbound-adapter-DWyAWBFh.mjs +0 -537
- package/dist/.setup/provider.runtime-BQ1z4Aq1.mjs +0 -1
- package/dist/.setup/setup-plugin-api-B4J6wmL1.mjs +0 -2
- package/dist/.setup/targets-BaklhOqq.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-r79VFjJp.mjs";
|
|
2
|
+
import { i as resolveDiscordEndpointMediaGuard, n as getDiscordEndpointRuntime } from "./endpoint-runtime-BM3x-m6O.mjs";
|
|
2
3
|
import { t as getDiscordRuntime } from "./runtime-DcBvHOm1.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-Dm2ERSxe.mjs";
|
|
5
|
+
import { E as hasDiscordMessageStickers, T as resolveDiscordCdnPolicy, b as resolveDiscordMessageText, j as resolveDiscordMessageChannelId, k as resolveDiscordReferencedReplyMessageId } from "./transcripts-source-DzpzETZR.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
|
// 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)}`))
|
|
@@ -192,91 +214,9 @@ function createDiscordAvatarResolver() {
|
|
|
192
214
|
return guildIcon?.hash ? resolveSavedAvatar(`${params.conversationId}\0${guildIcon.hash}`, discordAvatarUrl("icons", params.guildId, guildIcon.hash), endpointRuntime) : void 0;
|
|
193
215
|
} };
|
|
194
216
|
}
|
|
195
|
-
// extensions/discord/src/monitor/message-run-queue.ts
|
|
196
|
-
const loadMessageProcessRuntime = createLazyRuntimeModule(() => import("./message-handler.process-ClOwIPDK.mjs"));
|
|
197
|
-
async function processDiscordQueuedMessage(params) {
|
|
198
|
-
const abortSignal = params.job.context.abortSignal && params.lifecycleSignal ? AbortSignal.any([params.job.context.abortSignal, params.lifecycleSignal]) : params.job.context.abortSignal ?? params.lifecycleSignal;
|
|
199
|
-
try {
|
|
200
|
-
await (params.testing?.processDiscordMessage ?? (await loadMessageProcessRuntime()).processDiscordMessage)({
|
|
201
|
-
...params.job.context,
|
|
202
|
-
abortSignal
|
|
203
|
-
});
|
|
204
|
-
if (abortSignal?.aborted) await params.job.ingressSettlement?.cancel();
|
|
205
|
-
else await params.job.ingressSettlement?.settle();
|
|
206
|
-
} catch (error) {
|
|
207
|
-
if (abortSignal?.aborted) await params.job.ingressSettlement?.cancel();
|
|
208
|
-
else await params.job.ingressSettlement?.abandon(error);
|
|
209
|
-
throw error;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
function createDiscordMessageRunQueue(params) {
|
|
213
|
-
const skippedCleanup = /* @__PURE__ */ new Set();
|
|
214
|
-
const runQueue = createChannelRunQueue({
|
|
215
|
-
setStatus: params.setStatus,
|
|
216
|
-
abortSignal: params.abortSignal,
|
|
217
|
-
onError: (error) => {
|
|
218
|
-
params.runtime.error(danger(`discord message run failed: ${String(error)}`));
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
let lifecycleActive = !params.abortSignal?.aborted;
|
|
222
|
-
const pendingTasks = /* @__PURE__ */ new Set();
|
|
223
|
-
const onAbort = () => void cleanupSkippedQueuedMessages();
|
|
224
|
-
async function cleanupSkippedQueuedMessages() {
|
|
225
|
-
params.abortSignal?.removeEventListener("abort", onAbort);
|
|
226
|
-
if (!lifecycleActive && skippedCleanup.size === 0) return;
|
|
227
|
-
lifecycleActive = false;
|
|
228
|
-
const cleanups = [...skippedCleanup];
|
|
229
|
-
skippedCleanup.clear();
|
|
230
|
-
for (const cleanup of cleanups) await cleanup();
|
|
231
|
-
}
|
|
232
|
-
if (params.abortSignal?.aborted) cleanupSkippedQueuedMessages();
|
|
233
|
-
else params.abortSignal?.addEventListener("abort", onAbort, { once: true });
|
|
234
|
-
return {
|
|
235
|
-
enqueue(job) {
|
|
236
|
-
const { promise: pending, resolve: resolvePending } = createDeferred();
|
|
237
|
-
pendingTasks.add(pending);
|
|
238
|
-
const settlePending = () => {
|
|
239
|
-
pendingTasks.delete(pending);
|
|
240
|
-
resolvePending();
|
|
241
|
-
};
|
|
242
|
-
const cleanupSkipped = async () => {
|
|
243
|
-
try {
|
|
244
|
-
await job.ingressSettlement?.cancel();
|
|
245
|
-
} catch (error) {
|
|
246
|
-
try {
|
|
247
|
-
params.runtime.error(danger(`discord queued message cleanup failed: ${String(error)}`));
|
|
248
|
-
} catch {}
|
|
249
|
-
} finally {
|
|
250
|
-
settlePending();
|
|
251
|
-
}
|
|
252
|
-
};
|
|
253
|
-
if (!lifecycleActive) {
|
|
254
|
-
cleanupSkipped();
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
skippedCleanup.add(cleanupSkipped);
|
|
258
|
-
runQueue.enqueue(job.context.message.id, async ({ lifecycleSignal }) => {
|
|
259
|
-
skippedCleanup.delete(cleanupSkipped);
|
|
260
|
-
try {
|
|
261
|
-
await processDiscordQueuedMessage({
|
|
262
|
-
job,
|
|
263
|
-
lifecycleSignal,
|
|
264
|
-
testing: params.testing
|
|
265
|
-
});
|
|
266
|
-
} finally {
|
|
267
|
-
settlePending();
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
},
|
|
271
|
-
async deactivate() {
|
|
272
|
-
runQueue.deactivate();
|
|
273
|
-
await cleanupSkippedQueuedMessages();
|
|
274
|
-
await Promise.allSettled(pendingTasks);
|
|
275
|
-
}
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
217
|
// extensions/discord/src/monitor/message-dispatcher.ts
|
|
279
|
-
const loadMessagePreflightRuntime = createLazyRuntimeModule(() => import("./message-handler.preflight-
|
|
218
|
+
const loadMessagePreflightRuntime = createLazyRuntimeModule(() => import("./message-handler.preflight-C6TNtKW0.mjs"));
|
|
219
|
+
const loadMessageProcessRuntime = createLazyRuntimeModule(() => import("./message-handler.process-D8_oQ5Cp.mjs"));
|
|
280
220
|
function createDiscordMessageDispatcher(params) {
|
|
281
221
|
const readPolicy = params.readPolicy ?? createDiscordLivePolicyReader({
|
|
282
222
|
...params,
|
|
@@ -298,15 +238,43 @@ function createDiscordMessageDispatcher(params) {
|
|
|
298
238
|
}
|
|
299
239
|
});
|
|
300
240
|
const readConfig = createRuntimeConfigReader(params.cfg);
|
|
301
|
-
const
|
|
302
|
-
const
|
|
303
|
-
runtime: params.runtime,
|
|
241
|
+
const skippedCleanup = /* @__PURE__ */ new Set();
|
|
242
|
+
const runQueue = createChannelRunQueue({
|
|
304
243
|
setStatus: params.setStatus,
|
|
305
244
|
abortSignal: params.abortSignal,
|
|
306
|
-
|
|
245
|
+
onError: (error) => {
|
|
246
|
+
params.runtime.error(danger(`discord message run failed: ${String(error)}`));
|
|
247
|
+
}
|
|
307
248
|
});
|
|
249
|
+
let lifecycleActive = !params.abortSignal?.aborted;
|
|
250
|
+
const pendingTasks = /* @__PURE__ */ new Set();
|
|
251
|
+
const onAbort = () => void cleanupSkippedQueuedMessages();
|
|
252
|
+
async function cleanupSkippedQueuedMessages() {
|
|
253
|
+
params.abortSignal?.removeEventListener("abort", onAbort);
|
|
254
|
+
if (!lifecycleActive && skippedCleanup.size === 0) return;
|
|
255
|
+
lifecycleActive = false;
|
|
256
|
+
const cleanups = [...skippedCleanup];
|
|
257
|
+
skippedCleanup.clear();
|
|
258
|
+
for (const cleanup of cleanups) await cleanup();
|
|
259
|
+
}
|
|
260
|
+
if (params.abortSignal?.aborted) cleanupSkippedQueuedMessages();
|
|
261
|
+
else params.abortSignal?.addEventListener("abort", onAbort, { once: true });
|
|
308
262
|
const dispatcherShutdown = new AbortController();
|
|
309
263
|
const avatarResolver = createDiscordAvatarResolver();
|
|
264
|
+
const preflightMessage = async (data, client, options) => {
|
|
265
|
+
const policy = await readPolicy();
|
|
266
|
+
const { preflightDiscordMessage } = await loadMessagePreflightRuntime();
|
|
267
|
+
return await preflightDiscordMessage({
|
|
268
|
+
...params,
|
|
269
|
+
...policy,
|
|
270
|
+
...options,
|
|
271
|
+
isPolicyCurrent: policy.isCurrent,
|
|
272
|
+
avatarResolver,
|
|
273
|
+
ackReactionScope: params.discordConfig?.ackReactionScope ?? policy.cfg.messages?.ackReactionScope ?? "group-mentions",
|
|
274
|
+
data,
|
|
275
|
+
client
|
|
276
|
+
});
|
|
277
|
+
};
|
|
310
278
|
const pendingDebounceEntries = /* @__PURE__ */ new Set();
|
|
311
279
|
const pendingCancellationSettlements = /* @__PURE__ */ new Set();
|
|
312
280
|
const resolveDebounceKey = (entry) => {
|
|
@@ -353,20 +321,11 @@ function createDiscordMessageDispatcher(params) {
|
|
|
353
321
|
return;
|
|
354
322
|
}
|
|
355
323
|
try {
|
|
356
|
-
const
|
|
357
|
-
const { cfg } = policy;
|
|
358
|
-
const ctx = await (preflightDiscordMessageImpl ?? (await loadMessagePreflightRuntime()).preflightDiscordMessage)({
|
|
359
|
-
...params,
|
|
360
|
-
...policy,
|
|
361
|
-
isPolicyCurrent: policy.isCurrent,
|
|
362
|
-
avatarResolver,
|
|
363
|
-
ackReactionScope: params.discordConfig?.ackReactionScope ?? cfg.messages?.ackReactionScope ?? "group-mentions",
|
|
324
|
+
const ctx = await racePromiseWithAbortSignal(() => preflightMessage(last.data, last.client, {
|
|
364
325
|
abortSignal,
|
|
365
|
-
data: last.data,
|
|
366
|
-
client: last.client,
|
|
367
326
|
precedingMessages: entries.slice(0, -1).map((entry) => entry.data.message),
|
|
368
327
|
turnAdoptionLifecycle: admissionLifecycle
|
|
369
|
-
});
|
|
328
|
+
}), abortSignal);
|
|
370
329
|
if (abortSignal?.aborted) {
|
|
371
330
|
await ingress.cancel();
|
|
372
331
|
return;
|
|
@@ -375,10 +334,54 @@ function createDiscordMessageDispatcher(params) {
|
|
|
375
334
|
await ingress.settle();
|
|
376
335
|
return;
|
|
377
336
|
}
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
337
|
+
const { promise: pending, resolve: resolvePending } = createDeferred();
|
|
338
|
+
pendingTasks.add(pending);
|
|
339
|
+
const settlePending = () => {
|
|
340
|
+
pendingTasks.delete(pending);
|
|
341
|
+
resolvePending();
|
|
342
|
+
};
|
|
343
|
+
const cleanupSkipped = async () => {
|
|
344
|
+
try {
|
|
345
|
+
await ingress.cancel();
|
|
346
|
+
} catch (error) {
|
|
347
|
+
try {
|
|
348
|
+
params.runtime.error(danger(`discord queued message cleanup failed: ${String(error)}`));
|
|
349
|
+
} catch {}
|
|
350
|
+
} finally {
|
|
351
|
+
settlePending();
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
if (!lifecycleActive) {
|
|
355
|
+
cleanupSkipped();
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
skippedCleanup.add(cleanupSkipped);
|
|
359
|
+
runQueue.enqueue(ctx.message.id, async ({ lifecycleSignal }) => {
|
|
360
|
+
skippedCleanup.delete(cleanupSkipped);
|
|
361
|
+
try {
|
|
362
|
+
const processAbortSignal = ctx.abortSignal && lifecycleSignal ? AbortSignal.any([ctx.abortSignal, lifecycleSignal]) : ctx.abortSignal ?? lifecycleSignal;
|
|
363
|
+
try {
|
|
364
|
+
await racePromiseWithAbortSignal(async () => {
|
|
365
|
+
const { processDiscordMessage } = await loadMessageProcessRuntime();
|
|
366
|
+
await processDiscordMessage({
|
|
367
|
+
...ctx,
|
|
368
|
+
abortSignal: processAbortSignal
|
|
369
|
+
});
|
|
370
|
+
}, processAbortSignal);
|
|
371
|
+
if (processAbortSignal?.aborted) await ingress.cancel();
|
|
372
|
+
else await ingress.settle();
|
|
373
|
+
} catch (error) {
|
|
374
|
+
if (processAbortSignal?.aborted) await ingress.cancel();
|
|
375
|
+
else {
|
|
376
|
+
await ingress.abandon(error);
|
|
377
|
+
throw error;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
} finally {
|
|
381
|
+
settlePending();
|
|
382
|
+
}
|
|
381
383
|
});
|
|
384
|
+
await pending;
|
|
382
385
|
} catch (error) {
|
|
383
386
|
if (abortSignal?.aborted) {
|
|
384
387
|
await ingress.cancel();
|
|
@@ -442,26 +445,64 @@ function createDiscordMessageDispatcher(params) {
|
|
|
442
445
|
const result = dispatchMessage(data, client, options);
|
|
443
446
|
return options?.turnAdoptionLifecycle ? result : result.then(() => void 0);
|
|
444
447
|
};
|
|
448
|
+
handler.notifyDeadLetter = async (data, client, signal) => {
|
|
449
|
+
const abortSignal = AbortSignal.any([
|
|
450
|
+
signal,
|
|
451
|
+
dispatcherShutdown.signal,
|
|
452
|
+
...params.abortSignal ? [params.abortSignal] : []
|
|
453
|
+
]);
|
|
454
|
+
const ctx = await preflightMessage(data, client, { abortSignal });
|
|
455
|
+
if (!ctx) {
|
|
456
|
+
params.runtime.error(danger(`discord ingress: dead-letter notice suppressed for ${data.message.id} (access or reply policy denied, or authority expired)`));
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
const assertCurrent = () => {
|
|
460
|
+
abortSignal.throwIfAborted();
|
|
461
|
+
if (!lifecycleActive || ctx.isPolicyCurrent?.() !== true) throw new Error("discord dead-letter notice suppressed: access authority expired");
|
|
462
|
+
if (resolveChannelMessageSourceReplyDeliveryMode({
|
|
463
|
+
cfg: readConfig(),
|
|
464
|
+
ctx: {
|
|
465
|
+
ChatType: ctx.isDirectMessage ? "direct" : ctx.isGroupDm ? "group" : ctx.isGuildMessage ? "channel" : void 0,
|
|
466
|
+
InboundEventKind: ctx.inboundEventKind
|
|
467
|
+
}
|
|
468
|
+
}) === "message_tool_only") throw new Error("discord dead-letter notice suppressed: source-reply policy");
|
|
469
|
+
};
|
|
470
|
+
assertCurrent();
|
|
471
|
+
await withDiscordRequestAuthority(assertCurrent, () => client.rest.post(Routes.channelMessages(ctx.messageChannelId), { body: {
|
|
472
|
+
content: "⚠️ Couldn't process this message after repeated failures. Please try again.",
|
|
473
|
+
message_reference: {
|
|
474
|
+
message_id: data.message.id,
|
|
475
|
+
fail_if_not_exists: false
|
|
476
|
+
},
|
|
477
|
+
allowed_mentions: {
|
|
478
|
+
parse: [],
|
|
479
|
+
replied_user: false
|
|
480
|
+
}
|
|
481
|
+
} }));
|
|
482
|
+
};
|
|
445
483
|
handler.deactivate = async () => {
|
|
446
484
|
dispatcherShutdown.abort(/* @__PURE__ */ new Error("discord-message-handler-deactivated"));
|
|
447
485
|
const pendingKeys = new Set([...pendingDebounceEntries].map((entry) => entry.debounceKey).filter((key) => key !== void 0));
|
|
448
486
|
for (const key of pendingKeys) debouncer.cancelKey(key);
|
|
449
487
|
pendingDebounceEntries.clear();
|
|
450
488
|
await Promise.allSettled(pendingCancellationSettlements);
|
|
489
|
+
runQueue.deactivate();
|
|
490
|
+
await cleanupSkippedQueuedMessages();
|
|
451
491
|
await debouncer.drain();
|
|
452
|
-
await
|
|
492
|
+
await Promise.allSettled(pendingTasks);
|
|
453
493
|
};
|
|
454
494
|
return handler;
|
|
455
495
|
}
|
|
456
496
|
// extensions/discord/src/monitor/message-handler.ts
|
|
457
497
|
function createDiscordMessageHandler(params) {
|
|
458
498
|
const dispatcher = createDiscordMessageDispatcher(params);
|
|
459
|
-
const ingress =
|
|
499
|
+
const ingress = createDiscordIngressMonitor({
|
|
460
500
|
...params,
|
|
461
501
|
dispatch: (event, lifecycle) => dispatcher(event, params.client, {
|
|
462
502
|
abortSignal: lifecycle.abortSignal,
|
|
463
503
|
turnAdoptionLifecycle: lifecycle
|
|
464
|
-
})
|
|
504
|
+
}),
|
|
505
|
+
onDeadLetter: (event, signal) => dispatcher.notifyDeadLetter(event, params.client, signal)
|
|
465
506
|
});
|
|
466
507
|
ingress.start();
|
|
467
508
|
const activeAdmissions = /* @__PURE__ */ new Set();
|