@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,11 +1,13 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.mjs";
|
|
2
|
-
import { D as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { _ as recordDiscordMessageCreateAmbiguity,
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
2
|
+
import { C as hasAnyChannelPermissionDiscord, D as createDiscordMessageNonce, F as resolveDiscordClientAccountContext, I as resolveDiscordRest, M as createDiscordClient, O as resolveDiscordMessageFlags, S as hasAllGuildPermissionsDiscord, _ as canManageGuildMemberRoleDiscord, a as normalizeEmojiName, b as fetchChannelPermissionsDiscord, c as resolveChannelId, d as sendDiscordChunks, g as DiscordSendError, h as DISCORD_MAX_STICKER_BYTES, j as resolveDiscordSuppressEmbeds, m as DISCORD_MAX_EVENT_COVER_BYTES, n as buildDiscordTextChunks, o as normalizeReactionEmoji, p as DISCORD_MAX_EMOJI_BYTES, r as buildReactionIdentifier, t as buildDiscordSendError, v as canManageGuildRoleDiscord, w as hasAnyGuildPermissionDiscord, x as fetchMemberGuildPermissionsDiscord, y as canViewDiscordGuildChannel } from "./send.shared-BcLLZBul.mjs";
|
|
3
|
+
import { B as RateLimitError, C as listMessageReactionUsers, D as editChannelMessage, E as deleteChannelMessage, F as getGuildVoiceState, G as readRetryAfter, H as isUnknownDiscordVoiceStateError, I as listGuildEmojis, J as stripUndefinedFields, L as DISCORD_REST_TIMEOUT_MS, M as unpinChannelMessage, N as getGuild, O as getChannel, P as getGuildMember, S as deleteOwnMessageReaction, T as createThread, U as readDiscordCode, V as isUnknownDiscordMessageError, W as readDiscordMessage, j as pinChannelMessage, k as getChannelMessage, q as withDiscordRequestAuthority, w as createChannelMessage, x as createOwnMessageReaction, z as DiscordError } from "./discord-r79VFjJp.mjs";
|
|
4
|
+
import { C as parseDiscordRetryAfterBodySeconds } from "./allow-list-DahA0Jxh.mjs";
|
|
5
|
+
import { _ as recordDiscordMessageCreateAmbiguity, h as createDiscordRetryRunner, m as classifyDiscordDeliveryFailure, n as createDiscordSendReceiptFromResults, r as createDiscordSendResult, v as chunkDiscordTextWithMode } from "./send.receipt-CMteCIZS.mjs";
|
|
6
|
+
import { n as getDiscordEndpointRuntime, r as resolveDiscordEndpointAttachmentGuard } from "./endpoint-runtime-BM3x-m6O.mjs";
|
|
7
|
+
import { o as parseDiscordHttpErrorBody } from "./api-Bp0HI4q3.mjs";
|
|
8
|
+
import { t as parseAndResolveDiscordTarget } from "./target-resolver-Bo9EpGp_.mjs";
|
|
9
|
+
import { a as prepareDiscordOutboundText, n as sendPollDiscord, r as sendStickerDiscord, t as sendMessageDiscord } from "./send.outbound-B11X6TOE.mjs";
|
|
10
|
+
import { n as DISCORD_ATTACHMENT_TOTAL_TIMEOUT_MS } from "./timeouts-CT9hnmo4.mjs";
|
|
9
11
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
10
12
|
import { resolvePreferredOpenClawTmpDir, withTempWorkspace } from "openclaw/plugin-sdk/temp-path";
|
|
11
13
|
import { normalizeLowercaseStringOrEmpty, normalizeOptionalLowercaseString, normalizeOptionalString, normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
@@ -14,8 +16,8 @@ import { MEDIA_FFMPEG_MAX_AUDIO_DURATION_SECS, buildOutboundMediaLoadOptions, ex
|
|
|
14
16
|
import { requireRuntimeConfig } from "openclaw/plugin-sdk/plugin-config-runtime";
|
|
15
17
|
import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
|
|
16
18
|
import { parseStrictFiniteNumber, resolveExpiresAtMsFromDurationMs, timestampMsToIsoString } from "openclaw/plugin-sdk/number-runtime";
|
|
17
|
-
import crypto from "node:crypto";
|
|
18
19
|
import { fetchWithSsrFGuard } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
20
|
+
import crypto from "node:crypto";
|
|
19
21
|
import { readProviderJsonResponse, readResponseTextLimited } from "openclaw/plugin-sdk/provider-http";
|
|
20
22
|
import { loadWebMediaRaw } from "openclaw/plugin-sdk/web-media";
|
|
21
23
|
import { recordChannelActivity } from "openclaw/plugin-sdk/channel-activity-runtime";
|
|
@@ -49,13 +51,7 @@ async function editChannelDiscord(payload, opts) {
|
|
|
49
51
|
archived: payload.archived,
|
|
50
52
|
locked: payload.locked,
|
|
51
53
|
auto_archive_duration: payload.autoArchiveDuration,
|
|
52
|
-
available_tags: payload.availableTags
|
|
53
|
-
id: tag.id,
|
|
54
|
-
name: tag.name,
|
|
55
|
-
moderated: tag.moderated,
|
|
56
|
-
emoji_id: tag.emoji_id,
|
|
57
|
-
emoji_name: tag.emoji_name
|
|
58
|
-
}))
|
|
54
|
+
available_tags: payload.availableTags
|
|
59
55
|
});
|
|
60
56
|
return await rest.patch(Routes.channel(payload.channelId), { body });
|
|
61
57
|
}
|
|
@@ -238,9 +234,16 @@ function assertDiscordResponseArray(value, label) {
|
|
|
238
234
|
if (!Array.isArray(value)) throw new Error(`Unexpected Discord response for ${label}: expected array.`);
|
|
239
235
|
return value;
|
|
240
236
|
}
|
|
241
|
-
function
|
|
242
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(
|
|
243
|
-
|
|
237
|
+
function assertDiscordSearchResponse(value) {
|
|
238
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("Unexpected Discord response for message search: expected object.");
|
|
239
|
+
const result = value;
|
|
240
|
+
if (result.code === 11e4) {
|
|
241
|
+
const message = typeof result.message === "string" && result.message.trim() ? result.message.trim() : "Discord search index is not yet available";
|
|
242
|
+
const retryAfter = parseDiscordRetryAfterBodySeconds(result.retry_after);
|
|
243
|
+
const retryHint = retryAfter === void 0 ? "" : ` (retry after ${retryAfter}s)`;
|
|
244
|
+
throw new Error(`Discord message search unavailable: ${message}${retryHint}`);
|
|
245
|
+
}
|
|
246
|
+
if (!Array.isArray(result.messages)) throw new Error("Unexpected Discord response for message search: expected messages array.");
|
|
244
247
|
}
|
|
245
248
|
function describeDiscordThreadInitialMessageFailure(delivery) {
|
|
246
249
|
if (delivery?.failedChunkDelivery === "unknown") return delivery.deliveredChunkCount > 0 ? "Discord thread was created, but delivery of the remaining initial content could not be confirmed" : "Discord thread was created, but initial message delivery could not be confirmed";
|
|
@@ -252,10 +255,7 @@ var DiscordThreadInitialMessageError = class extends Error {
|
|
|
252
255
|
const initialMessageWarning = describeDiscordThreadInitialMessageFailure(initialMessageDelivery);
|
|
253
256
|
super(`${initialMessageWarning}: ${initialMessageError}`, { cause: error });
|
|
254
257
|
this.name = "DiscordThreadInitialMessageError";
|
|
255
|
-
this.initialMessageDelivery = initialMessageDelivery
|
|
256
|
-
...initialMessageDelivery,
|
|
257
|
-
deliveredMessageIds: [...initialMessageDelivery.deliveredMessageIds]
|
|
258
|
-
} : void 0;
|
|
258
|
+
this.initialMessageDelivery = initialMessageDelivery;
|
|
259
259
|
this.initialMessageError = initialMessageError;
|
|
260
260
|
this.initialMessageWarning = initialMessageWarning;
|
|
261
261
|
this.thread = thread;
|
|
@@ -313,7 +313,20 @@ async function deleteMessageDiscord(channelId, messageId, opts) {
|
|
|
313
313
|
return { ok: true };
|
|
314
314
|
}
|
|
315
315
|
async function listPinsDiscord(channelId, opts) {
|
|
316
|
-
|
|
316
|
+
const rest = resolveDiscordRest(opts);
|
|
317
|
+
const messages = [];
|
|
318
|
+
let before;
|
|
319
|
+
while (true) {
|
|
320
|
+
const page = await rest.get(Routes.channelMessagesPins(channelId), {
|
|
321
|
+
limit: 50,
|
|
322
|
+
...before ? { before } : {}
|
|
323
|
+
});
|
|
324
|
+
messages.push(...page.items.map((pin) => pin.message));
|
|
325
|
+
if (!page.has_more) return messages;
|
|
326
|
+
const nextBefore = page.items.at(-1)?.pinned_at;
|
|
327
|
+
if (!nextBefore || nextBefore === before) throw new Error("Discord pin pagination did not advance.");
|
|
328
|
+
before = nextBefore;
|
|
329
|
+
}
|
|
317
330
|
}
|
|
318
331
|
async function createThreadDiscord(channelId, payload, opts) {
|
|
319
332
|
const assertCreateAllowed = opts.assertCreateAllowed;
|
|
@@ -408,14 +421,8 @@ async function searchMessagesDiscord(query, opts) {
|
|
|
408
421
|
const limit = Math.min(Math.max(Math.floor(query.limit), 1), 25);
|
|
409
422
|
params.set("limit", String(limit));
|
|
410
423
|
}
|
|
411
|
-
const result =
|
|
412
|
-
|
|
413
|
-
const message = typeof result.message === "string" && result.message.trim() ? result.message.trim() : "Discord search index is not yet available";
|
|
414
|
-
const retryAfter = parseDiscordRetryAfterBodySeconds(result.retry_after);
|
|
415
|
-
const retryHint = retryAfter === void 0 ? "" : ` (retry after ${retryAfter}s)`;
|
|
416
|
-
throw new Error(`Discord message search unavailable: ${message}${retryHint}`);
|
|
417
|
-
}
|
|
418
|
-
if (!Array.isArray(result.messages)) throw new Error("Unexpected Discord response for message search: expected messages array.");
|
|
424
|
+
const result = await rest.get(`/guilds/${query.guildId}/messages/search?${params.toString()}`);
|
|
425
|
+
assertDiscordSearchResponse(result);
|
|
419
426
|
return result;
|
|
420
427
|
}
|
|
421
428
|
// extensions/discord/src/send.webhook.ts
|
|
@@ -433,7 +440,7 @@ async function throwWebhookResponseError(response, signal) {
|
|
|
433
440
|
const parsed = parseDiscordHttpErrorBody(raw);
|
|
434
441
|
if (response.status === 429) throw new RateLimitError(response, {
|
|
435
442
|
message: readDiscordMessage(parsed, "Rate limited"),
|
|
436
|
-
retry_after: readRetryAfter(parsed, response
|
|
443
|
+
retry_after: readRetryAfter(parsed, response),
|
|
437
444
|
code: readDiscordCode(parsed),
|
|
438
445
|
global: parsed && typeof parsed === "object" && "global" in parsed ? Boolean(parsed.global) : false
|
|
439
446
|
});
|
|
@@ -443,7 +450,6 @@ async function sendWebhookMessageDiscord(text, opts) {
|
|
|
443
450
|
const webhookId = normalizeOptionalString(opts.webhookId) ?? "";
|
|
444
451
|
const webhookToken = normalizeOptionalString(opts.webhookToken) ?? "";
|
|
445
452
|
if (!webhookId || !webhookToken) throw new Error("Discord webhook id/token are required");
|
|
446
|
-
const reply = typeof opts.replyTo === "string" ? createReusableDiscordReplyReference(normalizeOptionalString(opts.replyTo)) : opts.replyTo;
|
|
447
453
|
const { account, proxyFetch } = resolveDiscordClientAccountContext({
|
|
448
454
|
cfg: opts.cfg,
|
|
449
455
|
accountId: opts.accountId
|
|
@@ -469,6 +475,7 @@ async function sendWebhookMessageDiscord(text, opts) {
|
|
|
469
475
|
if (opts.threadId != null && opts.threadId !== "") url.searchParams.set("thread_id", String(opts.threadId));
|
|
470
476
|
const deadline = buildTimeoutAbortSignal({
|
|
471
477
|
timeoutMs: DISCORD_WEBHOOK_TIMEOUT_MS,
|
|
478
|
+
signal: opts.signal,
|
|
472
479
|
operation: "discord.webhook.send"
|
|
473
480
|
});
|
|
474
481
|
const request = createDiscordRetryRunner({ signal: deadline.signal });
|
|
@@ -479,11 +486,6 @@ async function sendWebhookMessageDiscord(text, opts) {
|
|
|
479
486
|
const results = [];
|
|
480
487
|
try {
|
|
481
488
|
for (const content of chunks.length ? chunks : [""]) {
|
|
482
|
-
const replyTo = resolveDiscordReplyMessageId(reply, results.length === 0);
|
|
483
|
-
const messageReference = replyTo ? {
|
|
484
|
-
message_id: replyTo,
|
|
485
|
-
fail_if_not_exists: false
|
|
486
|
-
} : void 0;
|
|
487
489
|
const response = await request(async () => {
|
|
488
490
|
await opts.onPlatformSendDispatch?.();
|
|
489
491
|
opts.assertPlatformSendAuthorized?.();
|
|
@@ -494,8 +496,7 @@ async function sendWebhookMessageDiscord(text, opts) {
|
|
|
494
496
|
content,
|
|
495
497
|
username: normalizeOptionalString(opts.username),
|
|
496
498
|
avatar_url: normalizeOptionalString(opts.avatarUrl),
|
|
497
|
-
...flags ? { flags } : {}
|
|
498
|
-
...messageReference ? { message_reference: messageReference } : {}
|
|
499
|
+
...flags ? { flags } : {}
|
|
499
500
|
}),
|
|
500
501
|
signal: deadline.signal
|
|
501
502
|
});
|
|
@@ -517,8 +518,7 @@ async function sendWebhookMessageDiscord(text, opts) {
|
|
|
517
518
|
result: payload,
|
|
518
519
|
fallbackChannelId: opts.threadId ? String(opts.threadId) : "",
|
|
519
520
|
kind: "text",
|
|
520
|
-
...opts.threadId != null ? { threadId: opts.threadId } : {}
|
|
521
|
-
reply: createReusableDiscordReplyReference(replyTo)
|
|
521
|
+
...opts.threadId != null ? { threadId: opts.threadId } : {}
|
|
522
522
|
});
|
|
523
523
|
const resultConversationId = result.channelId.trim();
|
|
524
524
|
if (result.messageId && resultConversationId) recordOutboundMessageIdentity({
|
|
@@ -543,7 +543,7 @@ async function sendWebhookMessageDiscord(text, opts) {
|
|
|
543
543
|
deadline.cleanup();
|
|
544
544
|
}
|
|
545
545
|
}
|
|
546
|
-
// extensions/discord/src/voice
|
|
546
|
+
// extensions/discord/src/send.voice.ts
|
|
547
547
|
const WAVEFORM_SAMPLES = 256;
|
|
548
548
|
const DISCORD_OPUS_SAMPLE_RATE_HZ = 48e3;
|
|
549
549
|
const DISCORD_VOICE_ERROR_BODY_LIMIT_BYTES = 8192;
|
|
@@ -692,127 +692,11 @@ async function createVoiceRequestError(response, fallbackMessage) {
|
|
|
692
692
|
const parsed = parseDiscordHttpErrorBody(raw);
|
|
693
693
|
if (response.status === 429) throw new RateLimitError(response, {
|
|
694
694
|
message: readDiscordMessage(parsed, "You are being rate limited."),
|
|
695
|
-
retry_after: readRetryAfter(parsed, response
|
|
695
|
+
retry_after: readRetryAfter(parsed, response),
|
|
696
696
|
global: parsed && typeof parsed === "object" && "global" in parsed ? Boolean(parsed.global) : false
|
|
697
697
|
});
|
|
698
698
|
return new DiscordError(response, parsed ?? { message: fallbackMessage });
|
|
699
699
|
}
|
|
700
|
-
async function requestVoiceUploadUrl(params) {
|
|
701
|
-
const endpoint = params.endpointRuntime;
|
|
702
|
-
const url = `${endpoint?.descriptor.restApiBaseUrl ?? params.rest.options?.baseUrl ?? "https://discord.com/api"}/channels/${params.channelId}/attachments`;
|
|
703
|
-
const uploadUrlInit = {
|
|
704
|
-
method: "POST",
|
|
705
|
-
headers: {
|
|
706
|
-
Authorization: `Bot ${params.botToken}`,
|
|
707
|
-
"Content-Type": "application/json"
|
|
708
|
-
},
|
|
709
|
-
body: JSON.stringify({ files: [{
|
|
710
|
-
filename: params.filename,
|
|
711
|
-
file_size: params.fileSize,
|
|
712
|
-
id: "0"
|
|
713
|
-
}] })
|
|
714
|
-
};
|
|
715
|
-
const { response: res, release } = endpoint ? {
|
|
716
|
-
response: await endpoint.fetch(url, {
|
|
717
|
-
...uploadUrlInit,
|
|
718
|
-
signal: AbortSignal.timeout(params.rest.options.timeout)
|
|
719
|
-
}),
|
|
720
|
-
release: async () => {}
|
|
721
|
-
} : await fetchWithSsrFGuard({
|
|
722
|
-
url,
|
|
723
|
-
init: uploadUrlInit,
|
|
724
|
-
timeoutMs: params.rest.options.timeout,
|
|
725
|
-
policy: DISCORD_VOICE_UPLOAD_SSRF_POLICY,
|
|
726
|
-
auditContext: "discord.voice.upload-url"
|
|
727
|
-
});
|
|
728
|
-
try {
|
|
729
|
-
if (!res.ok) throw await createVoiceRequestError(res, "Upload URL request failed");
|
|
730
|
-
return await readProviderJsonResponse(res, "discord.voice.upload-url");
|
|
731
|
-
} finally {
|
|
732
|
-
await release();
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
async function uploadVoiceAttachment(params) {
|
|
736
|
-
const endpointGuard = resolveDiscordEndpointAttachmentGuard(params.uploadUrl, params.endpointRuntime);
|
|
737
|
-
const { response: uploadResponse, release } = await fetchWithSsrFGuard({
|
|
738
|
-
url: params.uploadUrl,
|
|
739
|
-
init: {
|
|
740
|
-
method: "PUT",
|
|
741
|
-
headers: { "Content-Type": "audio/ogg" },
|
|
742
|
-
body: new Uint8Array(params.audioBuffer)
|
|
743
|
-
},
|
|
744
|
-
timeoutMs: DISCORD_ATTACHMENT_TOTAL_TIMEOUT_MS,
|
|
745
|
-
policy: endpointGuard?.policy ?? DISCORD_VOICE_UPLOAD_SSRF_POLICY,
|
|
746
|
-
...endpointGuard ? {
|
|
747
|
-
maxRedirects: endpointGuard.maxRedirects,
|
|
748
|
-
requireHttps: endpointGuard.requireHttps
|
|
749
|
-
} : {},
|
|
750
|
-
auditContext: "discord.voice.attachment-upload"
|
|
751
|
-
});
|
|
752
|
-
try {
|
|
753
|
-
if (!uploadResponse.ok) throw await createVoiceRequestError(uploadResponse, "Failed to upload voice message");
|
|
754
|
-
await uploadResponse.body?.cancel().catch(() => void 0);
|
|
755
|
-
} finally {
|
|
756
|
-
await release();
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
async function sendDiscordVoiceMessage(rest, channelId, audioBuffer, metadata, replyTo, request, silent, token, onPlatformSendDispatch, assertPlatformSendAuthorized) {
|
|
760
|
-
const filename = "voice-message.ogg";
|
|
761
|
-
const fileSize = audioBuffer.byteLength;
|
|
762
|
-
const endpointRuntime = getDiscordEndpointRuntime() ?? null;
|
|
763
|
-
if (!token) throw new Error("Discord bot token is required for voice message upload");
|
|
764
|
-
const { upload_filename } = await request(async () => {
|
|
765
|
-
const uploadUrlResponse = await requestVoiceUploadUrl({
|
|
766
|
-
rest,
|
|
767
|
-
endpointRuntime,
|
|
768
|
-
channelId,
|
|
769
|
-
botToken: token,
|
|
770
|
-
filename,
|
|
771
|
-
fileSize
|
|
772
|
-
});
|
|
773
|
-
if (!uploadUrlResponse.attachments?.[0]) throw new Error("Failed to get upload URL for voice message");
|
|
774
|
-
const attachment = uploadUrlResponse.attachments[0];
|
|
775
|
-
await uploadVoiceAttachment({
|
|
776
|
-
uploadUrl: attachment.upload_url,
|
|
777
|
-
audioBuffer,
|
|
778
|
-
endpointRuntime
|
|
779
|
-
});
|
|
780
|
-
return attachment;
|
|
781
|
-
}, "voice-upload");
|
|
782
|
-
const messagePayload = {
|
|
783
|
-
flags: MessageFlags.IsVoiceMessage | (silent ? MessageFlags.SuppressNotifications : 0),
|
|
784
|
-
nonce: createDiscordMessageNonce(),
|
|
785
|
-
enforce_nonce: true,
|
|
786
|
-
attachments: [{
|
|
787
|
-
id: "0",
|
|
788
|
-
filename,
|
|
789
|
-
uploaded_filename: upload_filename,
|
|
790
|
-
duration_secs: metadata.durationSecs,
|
|
791
|
-
waveform: metadata.waveform
|
|
792
|
-
}],
|
|
793
|
-
...replyTo ? { message_reference: {
|
|
794
|
-
message_id: replyTo,
|
|
795
|
-
fail_if_not_exists: false
|
|
796
|
-
} } : {}
|
|
797
|
-
};
|
|
798
|
-
let messageCreateMayHaveCommitted = false;
|
|
799
|
-
try {
|
|
800
|
-
return await request(async () => {
|
|
801
|
-
await onPlatformSendDispatch?.();
|
|
802
|
-
assertPlatformSendAuthorized?.();
|
|
803
|
-
try {
|
|
804
|
-
return await rest.post(`/channels/${channelId}/messages`, { body: messagePayload });
|
|
805
|
-
} catch (error) {
|
|
806
|
-
messageCreateMayHaveCommitted ||= classifyDiscordDeliveryFailure(error) === "ambiguous";
|
|
807
|
-
throw error;
|
|
808
|
-
}
|
|
809
|
-
}, "voice-message", { safety: "nonce-protected-create" });
|
|
810
|
-
} catch (error) {
|
|
811
|
-
if (messageCreateMayHaveCommitted) recordDiscordMessageCreateAmbiguity(error);
|
|
812
|
-
throw error;
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
// extensions/discord/src/send.voice.ts
|
|
816
700
|
/** Discord voice messages require OGG/Opus audio with a waveform and cannot include text. */
|
|
817
701
|
async function sendVoiceMessageDiscord(to, audioPath, opts) {
|
|
818
702
|
return await withDiscordRequestAuthority(opts.assertPlatformSendAuthorized, async () => {
|
|
@@ -840,12 +724,111 @@ async function sendVoiceMessageDiscord(to, audioPath, opts) {
|
|
|
840
724
|
cfg
|
|
841
725
|
});
|
|
842
726
|
const { token, rest, request, account: accountInfo } = client;
|
|
843
|
-
const recipient = await
|
|
844
|
-
|
|
727
|
+
const recipient = await parseAndResolveDiscordTarget(to, {
|
|
728
|
+
cfg,
|
|
729
|
+
accountId: accountInfo.accountId
|
|
730
|
+
}, { defaultKind: "channel" });
|
|
731
|
+
const resolvedChannelId = (await resolveChannelId(rest, recipient, request)).channelId;
|
|
732
|
+
channelId = resolvedChannelId;
|
|
845
733
|
ogg = await ensureOggOpus(localInputPath);
|
|
846
734
|
const metadata = await getVoiceMessageMetadata(ogg.path);
|
|
847
735
|
const audioBuffer = await fs.readFile(ogg.path);
|
|
848
|
-
const
|
|
736
|
+
const filename = "voice-message.ogg";
|
|
737
|
+
const endpointRuntime = getDiscordEndpointRuntime() ?? null;
|
|
738
|
+
if (!token) throw new Error("Discord bot token is required for voice message upload");
|
|
739
|
+
const { upload_filename } = await request(async () => {
|
|
740
|
+
let uploadUrlResponse;
|
|
741
|
+
const url = `${endpointRuntime?.descriptor.restApiBaseUrl ?? rest.options?.baseUrl ?? "https://discord.com/api"}/channels/${channelId}/attachments`;
|
|
742
|
+
const uploadUrlInit = {
|
|
743
|
+
method: "POST",
|
|
744
|
+
headers: {
|
|
745
|
+
Authorization: `Bot ${token}`,
|
|
746
|
+
"Content-Type": "application/json"
|
|
747
|
+
},
|
|
748
|
+
body: JSON.stringify({ files: [{
|
|
749
|
+
filename,
|
|
750
|
+
file_size: audioBuffer.byteLength,
|
|
751
|
+
id: "0"
|
|
752
|
+
}] })
|
|
753
|
+
};
|
|
754
|
+
const { response: res, release: releaseNegotiation } = endpointRuntime ? {
|
|
755
|
+
response: await endpointRuntime.fetch(url, {
|
|
756
|
+
...uploadUrlInit,
|
|
757
|
+
signal: AbortSignal.timeout(rest.options.timeout)
|
|
758
|
+
}),
|
|
759
|
+
release: async () => {}
|
|
760
|
+
} : await fetchWithSsrFGuard({
|
|
761
|
+
url,
|
|
762
|
+
init: uploadUrlInit,
|
|
763
|
+
timeoutMs: rest.options.timeout,
|
|
764
|
+
policy: DISCORD_VOICE_UPLOAD_SSRF_POLICY,
|
|
765
|
+
auditContext: "discord.voice.upload-url"
|
|
766
|
+
});
|
|
767
|
+
try {
|
|
768
|
+
if (!res.ok) throw await createVoiceRequestError(res, "Upload URL request failed");
|
|
769
|
+
uploadUrlResponse = await readProviderJsonResponse(res, "discord.voice.upload-url");
|
|
770
|
+
} finally {
|
|
771
|
+
await releaseNegotiation();
|
|
772
|
+
}
|
|
773
|
+
if (!uploadUrlResponse.attachments?.[0]) throw new Error("Failed to get upload URL for voice message");
|
|
774
|
+
const attachment = uploadUrlResponse.attachments[0];
|
|
775
|
+
const endpointGuard = resolveDiscordEndpointAttachmentGuard(attachment.upload_url, endpointRuntime);
|
|
776
|
+
const { response: uploadResponse, release: releaseUpload } = await fetchWithSsrFGuard({
|
|
777
|
+
url: attachment.upload_url,
|
|
778
|
+
init: {
|
|
779
|
+
method: "PUT",
|
|
780
|
+
headers: { "Content-Type": "audio/ogg" },
|
|
781
|
+
body: new Uint8Array(audioBuffer)
|
|
782
|
+
},
|
|
783
|
+
timeoutMs: DISCORD_ATTACHMENT_TOTAL_TIMEOUT_MS,
|
|
784
|
+
policy: endpointGuard?.policy ?? DISCORD_VOICE_UPLOAD_SSRF_POLICY,
|
|
785
|
+
...endpointGuard ? {
|
|
786
|
+
maxRedirects: endpointGuard.maxRedirects,
|
|
787
|
+
requireHttps: endpointGuard.requireHttps
|
|
788
|
+
} : {},
|
|
789
|
+
auditContext: "discord.voice.attachment-upload"
|
|
790
|
+
});
|
|
791
|
+
try {
|
|
792
|
+
if (!uploadResponse.ok) throw await createVoiceRequestError(uploadResponse, "Failed to upload voice message");
|
|
793
|
+
await uploadResponse.body?.cancel().catch(() => void 0);
|
|
794
|
+
} finally {
|
|
795
|
+
await releaseUpload();
|
|
796
|
+
}
|
|
797
|
+
return attachment;
|
|
798
|
+
}, "voice-upload");
|
|
799
|
+
const messagePayload = {
|
|
800
|
+
flags: MessageFlags.IsVoiceMessage | (opts.silent ? MessageFlags.SuppressNotifications : 0),
|
|
801
|
+
nonce: createDiscordMessageNonce(),
|
|
802
|
+
enforce_nonce: true,
|
|
803
|
+
attachments: [{
|
|
804
|
+
id: "0",
|
|
805
|
+
filename,
|
|
806
|
+
uploaded_filename: upload_filename,
|
|
807
|
+
duration_secs: metadata.durationSecs,
|
|
808
|
+
waveform: metadata.waveform
|
|
809
|
+
}],
|
|
810
|
+
...opts.reply?.messageId ? { message_reference: {
|
|
811
|
+
message_id: opts.reply.messageId,
|
|
812
|
+
fail_if_not_exists: false
|
|
813
|
+
} } : {}
|
|
814
|
+
};
|
|
815
|
+
let result;
|
|
816
|
+
let messageCreateMayHaveCommitted = false;
|
|
817
|
+
try {
|
|
818
|
+
result = await request(async () => {
|
|
819
|
+
await opts.onPlatformSendDispatch?.();
|
|
820
|
+
opts.assertPlatformSendAuthorized?.();
|
|
821
|
+
try {
|
|
822
|
+
return await createChannelMessage(rest, resolvedChannelId, { body: messagePayload });
|
|
823
|
+
} catch (error) {
|
|
824
|
+
messageCreateMayHaveCommitted ||= classifyDiscordDeliveryFailure(error) === "ambiguous";
|
|
825
|
+
throw error;
|
|
826
|
+
}
|
|
827
|
+
}, "voice-message", { safety: "nonce-protected-create" });
|
|
828
|
+
} catch (error) {
|
|
829
|
+
if (messageCreateMayHaveCommitted) recordDiscordMessageCreateAmbiguity(error);
|
|
830
|
+
throw error;
|
|
831
|
+
}
|
|
849
832
|
recordChannelActivity({
|
|
850
833
|
channel: "discord",
|
|
851
834
|
accountId: accountInfo.accountId,
|
|
@@ -881,17 +864,9 @@ async function sendTypingDiscord(channelId, opts) {
|
|
|
881
864
|
};
|
|
882
865
|
}
|
|
883
866
|
// extensions/discord/src/send.reactions.ts
|
|
884
|
-
function resolveDiscordReactionClient(opts) {
|
|
885
|
-
if (opts.rest && opts.cfg && opts.accountId) return createDiscordClient(opts);
|
|
886
|
-
const cfg = requireRuntimeConfig(opts.cfg, "Discord reactions");
|
|
887
|
-
return createDiscordClient({
|
|
888
|
-
...opts,
|
|
889
|
-
cfg
|
|
890
|
-
});
|
|
891
|
-
}
|
|
892
867
|
function reactionMutation(operation, label) {
|
|
893
868
|
return async (channelId, messageId, emoji, opts) => {
|
|
894
|
-
const { rest, request } =
|
|
869
|
+
const { rest, request } = createDiscordClient(opts);
|
|
895
870
|
const encoded = normalizeReactionEmoji(emoji);
|
|
896
871
|
await request(() => operation(rest, channelId, messageId, encoded), label);
|
|
897
872
|
return { ok: true };
|
|
@@ -900,7 +875,7 @@ function reactionMutation(operation, label) {
|
|
|
900
875
|
const reactMessageDiscord = reactionMutation(createOwnMessageReaction, "react");
|
|
901
876
|
const removeReactionDiscord = reactionMutation(deleteOwnMessageReaction, "reaction-remove");
|
|
902
877
|
async function removeOwnReactionsDiscord(channelId, messageId, opts) {
|
|
903
|
-
const { rest, request } =
|
|
878
|
+
const { rest, request } = createDiscordClient(opts);
|
|
904
879
|
const message = await request(() => getChannelMessage(rest, channelId, messageId), "reaction-list");
|
|
905
880
|
const identifiers = /* @__PURE__ */ new Set();
|
|
906
881
|
for (const reaction of message.reactions ?? []) {
|
|
@@ -919,7 +894,7 @@ async function removeOwnReactionsDiscord(channelId, messageId, opts) {
|
|
|
919
894
|
};
|
|
920
895
|
}
|
|
921
896
|
async function fetchReactionsDiscord(channelId, messageId, opts) {
|
|
922
|
-
const { rest, request } =
|
|
897
|
+
const { rest, request } = createDiscordClient(opts);
|
|
923
898
|
const reactions = (await request(() => getChannelMessage(rest, channelId, messageId), "reaction-list")).reactions ?? [];
|
|
924
899
|
const limit = typeof opts.limit === "number" && Number.isFinite(opts.limit) ? Math.min(Math.max(Math.floor(opts.limit), 1), 100) : 100;
|
|
925
900
|
const summaries = [];
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.mjs";
|
|
2
|
-
import { D as createDiscordMessageNonce, M as
|
|
3
|
-
import {
|
|
4
|
-
import { r as createDiscordSendResult } from "./send.receipt-
|
|
5
|
-
import { t as
|
|
6
|
-
import {
|
|
2
|
+
import { D as createDiscordMessageNonce, M as createDiscordClient, T as SUPPRESS_NOTIFICATIONS_FLAG, c as resolveChannelId, l as resolveDiscordChannel, t as buildDiscordSendError } from "./send.shared-BcLLZBul.mjs";
|
|
3
|
+
import { D as editChannelMessage, f as serializePayload, q as withDiscordRequestAuthority, w as createChannelMessage } from "./discord-r79VFjJp.mjs";
|
|
4
|
+
import { r as createDiscordSendResult } from "./send.receipt-CMteCIZS.mjs";
|
|
5
|
+
import { t as parseAndResolveDiscordTarget } from "./target-resolver-Bo9EpGp_.mjs";
|
|
6
|
+
import { t as sendMessageDiscord } from "./send.outbound-B11X6TOE.mjs";
|
|
7
|
+
import { a as buildDiscordComponentMessage, u as resolveDiscordComponentAttachmentName } from "./components-WTfUxead.mjs";
|
|
7
8
|
import { n as getOptionalDiscordRuntime } from "./runtime-DcBvHOm1.mjs";
|
|
8
9
|
import { hasNonEmptyString, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
9
10
|
import { ChannelType } from "discord-api-types/v10";
|
|
@@ -178,6 +179,8 @@ function registerDiscordComponentEntries(params) {
|
|
|
178
179
|
return discordComponentRegistryState.withRegistryLock(async () => {
|
|
179
180
|
for (const entry of normalizedEntries) discordComponentRegistryState.componentEntries.set(entry.id, entry);
|
|
180
181
|
for (const entry of normalizedModals) discordComponentRegistryState.modalEntries.set(entry.id, entry);
|
|
182
|
+
const pruneAt = Date.now();
|
|
183
|
+
for (const store of [discordComponentRegistryState.componentEntries, discordComponentRegistryState.modalEntries]) for (const [id, entry] of store) if (entry.expiresAt !== void 0 && !isFutureDateTimestampMs(entry.expiresAt, { nowMs: pruneAt })) store.delete(id);
|
|
181
184
|
await Promise.all([registerPersistentRegistryEntries({
|
|
182
185
|
entries: normalizedEntries,
|
|
183
186
|
ttlMs,
|
|
@@ -259,34 +262,58 @@ function registerBuiltDiscordComponentMessage(params) {
|
|
|
259
262
|
ttlMs: params.ttlMs
|
|
260
263
|
});
|
|
261
264
|
}
|
|
262
|
-
function
|
|
263
|
-
|
|
264
|
-
|
|
265
|
+
async function sendDiscordComponentMessage(to, spec, opts) {
|
|
266
|
+
return await withDiscordRequestAuthority(opts.assertPlatformSendAuthorized, async () => {
|
|
267
|
+
const classicMessage = opts.mediaUrl ? resolveClassicDiscordMessage(spec) : void 0;
|
|
268
|
+
if (classicMessage) return await sendMessageDiscord(to, classicMessage.text, {
|
|
269
|
+
...opts,
|
|
270
|
+
filename: opts.filename?.trim() || classicMessage.filename
|
|
271
|
+
});
|
|
272
|
+
return await writeDiscordComponentMessage(to, spec, opts);
|
|
273
|
+
});
|
|
265
274
|
}
|
|
266
|
-
async function
|
|
267
|
-
|
|
268
|
-
|
|
275
|
+
async function editDiscordComponentMessage(to, messageId, spec, opts) {
|
|
276
|
+
return await writeDiscordComponentMessage(to, spec, opts, messageId);
|
|
277
|
+
}
|
|
278
|
+
async function writeDiscordComponentMessage(to, spec, opts, messageId) {
|
|
279
|
+
const creating = messageId === void 0;
|
|
280
|
+
const cfg = requireRuntimeConfig(opts.cfg, creating ? "Discord component send" : "Discord component edit");
|
|
281
|
+
const { token, rest, request, account: accountInfo } = createDiscordClient({
|
|
282
|
+
...opts,
|
|
283
|
+
cfg
|
|
284
|
+
});
|
|
285
|
+
const recipient = await parseAndResolveDiscordTarget(to, {
|
|
286
|
+
cfg,
|
|
287
|
+
accountId: accountInfo.accountId
|
|
288
|
+
}, { defaultKind: "channel" });
|
|
289
|
+
const { channelId } = await resolveChannelId(rest, recipient, request);
|
|
290
|
+
if (creating) {
|
|
291
|
+
const channel = await resolveDiscordChannel(rest, channelId);
|
|
292
|
+
if (channel && DISCORD_FORUM_LIKE_TYPES.has(channel.type)) throw new Error("Discord components are not supported in forum-style channels");
|
|
293
|
+
}
|
|
294
|
+
const messageReference = opts.reply ? {
|
|
295
|
+
message_id: opts.reply.messageId,
|
|
269
296
|
fail_if_not_exists: false
|
|
270
297
|
} : void 0;
|
|
271
|
-
let
|
|
298
|
+
let componentSpec = spec;
|
|
272
299
|
let resolvedFileName;
|
|
273
300
|
let files;
|
|
274
301
|
let attachmentNames;
|
|
275
|
-
if (
|
|
276
|
-
const media = await loadOutboundMediaFromUrl(
|
|
277
|
-
mediaAccess:
|
|
278
|
-
mediaLocalRoots:
|
|
279
|
-
mediaReadFile:
|
|
302
|
+
if (opts.mediaUrl) {
|
|
303
|
+
const media = await loadOutboundMediaFromUrl(opts.mediaUrl, {
|
|
304
|
+
mediaAccess: opts.mediaAccess,
|
|
305
|
+
mediaLocalRoots: opts.mediaLocalRoots,
|
|
306
|
+
mediaReadFile: opts.mediaReadFile
|
|
280
307
|
});
|
|
281
|
-
const filenameOverride =
|
|
282
|
-
attachmentNames = extractComponentAttachmentNames(
|
|
308
|
+
const filenameOverride = opts.filename?.trim();
|
|
309
|
+
attachmentNames = extractComponentAttachmentNames(componentSpec);
|
|
283
310
|
const explicitAttachmentName = attachmentNames[0];
|
|
284
311
|
resolvedFileName = filenameOverride || explicitAttachmentName || media.fileName || `upload${extensionForMime(media.contentType) ?? ""}`;
|
|
285
312
|
if (attachmentNames.length === 0) {
|
|
286
313
|
const file = `attachment://${resolvedFileName}`;
|
|
287
|
-
|
|
288
|
-
...
|
|
289
|
-
blocks: [...
|
|
314
|
+
componentSpec = {
|
|
315
|
+
...componentSpec,
|
|
316
|
+
blocks: [...componentSpec.blocks ?? [], {
|
|
290
317
|
type: "file",
|
|
291
318
|
file
|
|
292
319
|
}]
|
|
@@ -299,64 +326,27 @@ async function buildDiscordComponentPayload(params) {
|
|
|
299
326
|
contentType: media.contentType
|
|
300
327
|
}];
|
|
301
328
|
}
|
|
302
|
-
const uniqueAttachmentNames = uniqueStrings(attachmentNames ?? extractComponentAttachmentNames(
|
|
329
|
+
const uniqueAttachmentNames = uniqueStrings(attachmentNames ?? extractComponentAttachmentNames(componentSpec));
|
|
303
330
|
if (uniqueAttachmentNames.length > 1) throw new Error("Discord component attachments currently support a single file. Use media-gallery for multiple files.");
|
|
304
331
|
const expectedAttachmentName = uniqueAttachmentNames[0];
|
|
305
332
|
if (expectedAttachmentName && resolvedFileName && expectedAttachmentName !== resolvedFileName) throw new Error(`Component file block expects attachment "${expectedAttachmentName}", but the uploaded file is "${resolvedFileName}". Update components.blocks[].file or provide a matching filename.`);
|
|
306
|
-
if (!
|
|
333
|
+
if (!opts.mediaUrl && expectedAttachmentName) throw new Error("Discord component file blocks require a media attachment (media/path/filePath).");
|
|
307
334
|
const buildResult = buildDiscordComponentMessage({
|
|
308
|
-
spec,
|
|
309
|
-
sessionKey:
|
|
310
|
-
agentId:
|
|
311
|
-
accountId:
|
|
335
|
+
spec: componentSpec,
|
|
336
|
+
sessionKey: opts.sessionKey,
|
|
337
|
+
agentId: opts.agentId,
|
|
338
|
+
accountId: accountInfo.accountId
|
|
312
339
|
});
|
|
313
|
-
const flags = buildDiscordComponentMessageFlags(buildResult.components);
|
|
314
|
-
const finalFlags = params.opts.silent ? (flags ?? 0) | SUPPRESS_NOTIFICATIONS_FLAG : flags ?? void 0;
|
|
315
340
|
const payload = {
|
|
316
341
|
components: buildResult.components,
|
|
317
|
-
allowed_mentions:
|
|
318
|
-
...
|
|
342
|
+
allowed_mentions: opts.allowedMentions,
|
|
343
|
+
...opts.silent ? { flags: SUPPRESS_NOTIFICATIONS_FLAG } : {},
|
|
319
344
|
...files ? { files } : {}
|
|
320
345
|
};
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
...messageReference ? { message_reference: messageReference } : {}
|
|
325
|
-
},
|
|
326
|
-
buildResult
|
|
346
|
+
const componentBody = {
|
|
347
|
+
...serializePayload(payload),
|
|
348
|
+
...messageReference ? { message_reference: messageReference } : {}
|
|
327
349
|
};
|
|
328
|
-
}
|
|
329
|
-
async function sendDiscordComponentMessage(to, spec, opts) {
|
|
330
|
-
return await withDiscordRequestAuthority(opts.assertPlatformSendAuthorized, async () => {
|
|
331
|
-
const classicMessage = opts.mediaUrl ? resolveClassicDiscordMessage(spec) : void 0;
|
|
332
|
-
if (classicMessage) return await sendMessageDiscord(to, classicMessage.text, {
|
|
333
|
-
...opts,
|
|
334
|
-
filename: opts.filename?.trim() || classicMessage.filename
|
|
335
|
-
});
|
|
336
|
-
return await writeDiscordComponentMessage(to, spec, opts);
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
async function editDiscordComponentMessage(to, messageId, spec, opts) {
|
|
340
|
-
return await writeDiscordComponentMessage(to, spec, opts, messageId);
|
|
341
|
-
}
|
|
342
|
-
async function writeDiscordComponentMessage(to, spec, opts, messageId) {
|
|
343
|
-
const creating = messageId === void 0;
|
|
344
|
-
const cfg = requireRuntimeConfig(opts.cfg, creating ? "Discord component send" : "Discord component edit");
|
|
345
|
-
const { token, rest, request, account: accountInfo } = createDiscordClient({
|
|
346
|
-
...opts,
|
|
347
|
-
cfg
|
|
348
|
-
});
|
|
349
|
-
const recipient = await parseAndResolveChannelRecipient(to, cfg, accountInfo.accountId);
|
|
350
|
-
const { channelId } = await resolveChannelId(rest, recipient, request);
|
|
351
|
-
if (creating) {
|
|
352
|
-
const channel = await resolveDiscordChannel(rest, channelId);
|
|
353
|
-
if (channel && DISCORD_FORUM_LIKE_TYPES.has(channel.type)) throw new Error("Discord components are not supported in forum-style channels");
|
|
354
|
-
}
|
|
355
|
-
const { body: componentBody, buildResult } = await buildDiscordComponentPayload({
|
|
356
|
-
spec,
|
|
357
|
-
opts,
|
|
358
|
-
accountId: accountInfo.accountId
|
|
359
|
-
});
|
|
360
350
|
const body = creating ? {
|
|
361
351
|
...componentBody,
|
|
362
352
|
nonce: createDiscordMessageNonce(),
|
|
@@ -393,7 +383,7 @@ async function writeDiscordComponentMessage(to, spec, opts, messageId) {
|
|
|
393
383
|
await registerBuiltDiscordComponentMessage({
|
|
394
384
|
buildResult,
|
|
395
385
|
messageId: result.id ?? messageId,
|
|
396
|
-
ttlMs:
|
|
386
|
+
ttlMs: accountInfo.config.agentComponents?.ttlMs
|
|
397
387
|
});
|
|
398
388
|
recordChannelActivity({
|
|
399
389
|
channel: "discord",
|