@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,543 +0,0 @@
|
|
|
1
|
-
import { t as createDiscordActionGate } from "./accounts-ljrzXBJi.mjs";
|
|
2
|
-
import { d as normalizeDiscordMessagingTarget, f as normalizeDiscordOutboundTarget, g as hasDiscordMessageCreateAmbiguity, i as toDiscordOutboundDeliveryResult, n as createDiscordSendReceiptFromResults, p as canFallbackDiscordWebhookSend, s as resolveDiscordReplyReference, t as createDiscordSendReceipt, v as chunkDiscordTextWithMode } from "./send.receipt-C18khRYH.mjs";
|
|
3
|
-
import { t as parseDiscordTarget } from "./target-parsing-C-HyNxcE.mjs";
|
|
4
|
-
import { C as discordInboundEventDelivery, a as resolveDiscordComponentSpec, c as formatDiscordApprovalDisplayValue, n as DISCORD_PRESENTATION_CAPABILITIES, o as sendDiscordComponentMessageLazy, r as buildDiscordPresentationPayload, w as notifyDiscordInboundEventOutboundPayloadSuccess, y as resolveDiscordCurrentConversationIdentity } from "./outbound-session-route-BtUpGBTb.mjs";
|
|
5
|
-
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
6
|
-
import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env";
|
|
7
|
-
import { asOptionalRecord, normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeOptionalStringifiedId } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
8
|
-
import { getReplyPayloadTtsSupplement, resolvePayloadMediaUrls, sendPayloadMediaSequenceOrFallback, sendTextMediaPayload } from "openclaw/plugin-sdk/reply-payload";
|
|
9
|
-
import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
|
|
10
|
-
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
11
|
-
import { createReplyToFanout, resolveOutboundSendDep } from "openclaw/plugin-sdk/channel-outbound";
|
|
12
|
-
import { attachChannelToResult, createAttachedChannelResultAdapter } from "openclaw/plugin-sdk/channel-send-result";
|
|
13
|
-
import { questionGatewayRuntime } from "openclaw/plugin-sdk/question-gateway-runtime";
|
|
14
|
-
//#region extensions/discord/src/channel.conversation.ts
|
|
15
|
-
function resolveDiscordAttachedOutboundTarget(params) {
|
|
16
|
-
if (params.threadId == null) return params.to;
|
|
17
|
-
const threadId = normalizeOptionalStringifiedId(params.threadId) ?? "";
|
|
18
|
-
return threadId ? `channel:${threadId}` : params.to;
|
|
19
|
-
}
|
|
20
|
-
function buildDiscordCrossContextPresentation(params) {
|
|
21
|
-
return {
|
|
22
|
-
tone: "neutral",
|
|
23
|
-
blocks: [...params.message.trim() ? [{
|
|
24
|
-
type: "text",
|
|
25
|
-
text: params.message
|
|
26
|
-
}, { type: "divider" }] : [], {
|
|
27
|
-
type: "context",
|
|
28
|
-
text: `From ${params.originLabel}`
|
|
29
|
-
}]
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
function normalizeDiscordAcpConversationId(conversationId) {
|
|
33
|
-
const normalized = conversationId.trim();
|
|
34
|
-
return normalized ? { conversationId: normalized } : null;
|
|
35
|
-
}
|
|
36
|
-
function matchDiscordAcpConversation(params) {
|
|
37
|
-
if (params.bindingConversationId === params.conversationId) return {
|
|
38
|
-
conversationId: params.conversationId,
|
|
39
|
-
matchPriority: 2
|
|
40
|
-
};
|
|
41
|
-
if (params.parentConversationId && params.parentConversationId !== params.conversationId && params.bindingConversationId === params.parentConversationId) return {
|
|
42
|
-
conversationId: params.parentConversationId,
|
|
43
|
-
matchPriority: 1
|
|
44
|
-
};
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
function resolveDiscordConversationIdFromTargets(targets) {
|
|
48
|
-
for (const raw of targets) {
|
|
49
|
-
const trimmed = raw?.trim();
|
|
50
|
-
if (!trimmed) continue;
|
|
51
|
-
try {
|
|
52
|
-
const target = parseDiscordTarget(trimmed, { defaultKind: "channel" });
|
|
53
|
-
if (target?.normalized) return target.normalized;
|
|
54
|
-
} catch {}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function parseDiscordParentChannelFromSessionKey(raw) {
|
|
58
|
-
const match = normalizeLowercaseStringOrEmpty(raw).match(/(?:^|:)channel:([^:]+)$/);
|
|
59
|
-
return match?.[1] ? `channel:${match[1]}` : void 0;
|
|
60
|
-
}
|
|
61
|
-
function resolveDiscordCommandConversation(params) {
|
|
62
|
-
const threadConversation = resolveDiscordThreadConversationRef(params);
|
|
63
|
-
if (threadConversation) return threadConversation;
|
|
64
|
-
const conversationId = resolveDiscordCurrentConversationIdentity({
|
|
65
|
-
from: params.from,
|
|
66
|
-
chatType: params.chatType,
|
|
67
|
-
originatingTo: params.originatingTo,
|
|
68
|
-
commandTo: params.commandTo,
|
|
69
|
-
fallbackTo: params.fallbackTo
|
|
70
|
-
});
|
|
71
|
-
return conversationId ? { conversationId } : null;
|
|
72
|
-
}
|
|
73
|
-
function resolveDiscordThreadConversationRef(params) {
|
|
74
|
-
const threadId = normalizeOptionalStringifiedId(params.threadId);
|
|
75
|
-
if (!threadId) return null;
|
|
76
|
-
const targets = [
|
|
77
|
-
params.originatingTo ?? params.to,
|
|
78
|
-
params.commandTo,
|
|
79
|
-
params.fallbackTo ?? params.conversationId
|
|
80
|
-
];
|
|
81
|
-
const parentConversationId = normalizeDiscordMessagingTarget(normalizeOptionalStringifiedId(params.threadParentId) ?? "") || parseDiscordParentChannelFromSessionKey(params.parentSessionKey) || resolveDiscordConversationIdFromTargets(targets);
|
|
82
|
-
return {
|
|
83
|
-
conversationId: threadId,
|
|
84
|
-
...parentConversationId && parentConversationId !== threadId ? { parentConversationId } : {}
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
function resolveDiscordInboundConversation(params) {
|
|
88
|
-
const threadConversation = resolveDiscordThreadConversationRef({
|
|
89
|
-
to: params.to,
|
|
90
|
-
conversationId: params.conversationId,
|
|
91
|
-
threadId: params.threadId,
|
|
92
|
-
threadParentId: params.threadParentId
|
|
93
|
-
});
|
|
94
|
-
if (threadConversation) return threadConversation;
|
|
95
|
-
const conversationId = resolveDiscordCurrentConversationIdentity({
|
|
96
|
-
from: params.from,
|
|
97
|
-
chatType: params.isGroup ? "group" : "direct",
|
|
98
|
-
originatingTo: params.to,
|
|
99
|
-
fallbackTo: params.conversationId
|
|
100
|
-
});
|
|
101
|
-
return conversationId ? { conversationId } : null;
|
|
102
|
-
}
|
|
103
|
-
//#endregion
|
|
104
|
-
//#region extensions/discord/src/media-detection.ts
|
|
105
|
-
const DISCORD_VIDEO_MEDIA_EXTENSIONS = [
|
|
106
|
-
".avi",
|
|
107
|
-
".m4v",
|
|
108
|
-
".mkv",
|
|
109
|
-
".mov",
|
|
110
|
-
".mp4",
|
|
111
|
-
".webm"
|
|
112
|
-
];
|
|
113
|
-
function isLikelyDiscordVideoMedia(mediaUrl) {
|
|
114
|
-
const trimmed = mediaUrl.trim();
|
|
115
|
-
if (!trimmed) return false;
|
|
116
|
-
let path;
|
|
117
|
-
try {
|
|
118
|
-
const { pathname } = new URL(trimmed);
|
|
119
|
-
path = pathname.slice(pathname.lastIndexOf("/") + 1);
|
|
120
|
-
try {
|
|
121
|
-
path = decodeURIComponent(path);
|
|
122
|
-
} catch {}
|
|
123
|
-
} catch {
|
|
124
|
-
path = trimmed.split(/[?#]/, 1)[0] ?? trimmed;
|
|
125
|
-
}
|
|
126
|
-
const normalized = normalizeLowercaseStringOrEmpty(path);
|
|
127
|
-
return DISCORD_VIDEO_MEDIA_EXTENSIONS.some((ext) => normalized.endsWith(ext));
|
|
128
|
-
}
|
|
129
|
-
//#endregion
|
|
130
|
-
//#region extensions/discord/src/outbound-approval.ts
|
|
131
|
-
function normalizeDiscordApprovalPayload(payload) {
|
|
132
|
-
if (!asOptionalRecord(payload.channelData)?.execApproval || !payload.text) return payload;
|
|
133
|
-
return {
|
|
134
|
-
...payload,
|
|
135
|
-
text: payload.text.replace(/@everyone/gi, "@everyone").replace(/@here/gi, "@here").replace(/<@/g, "<@").replace(/<#/g, "<#")
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
//#endregion
|
|
139
|
-
//#region extensions/discord/src/outbound-send-context.ts
|
|
140
|
-
const loadDiscordSendRuntime = createLazyRuntimeModule(() => import("./send-da6ENJ9f.mjs").then((n) => n.t));
|
|
141
|
-
function resolveDiscordFormattingOptions(ctx) {
|
|
142
|
-
const formatting = ctx.formatting;
|
|
143
|
-
return {
|
|
144
|
-
textLimit: formatting?.textLimit,
|
|
145
|
-
maxLinesPerMessage: formatting?.maxLinesPerMessage,
|
|
146
|
-
tableMode: formatting?.tableMode,
|
|
147
|
-
chunkMode: formatting?.chunkMode
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
async function createDiscordPayloadSendContext(ctx) {
|
|
151
|
-
const runtime = await loadDiscordSendRuntime();
|
|
152
|
-
const nextReplyToId = createReplyToFanout(ctx);
|
|
153
|
-
return {
|
|
154
|
-
target: resolveDiscordAttachedOutboundTarget({
|
|
155
|
-
to: ctx.to,
|
|
156
|
-
threadId: ctx.threadId
|
|
157
|
-
}),
|
|
158
|
-
formatting: resolveDiscordFormattingOptions(ctx),
|
|
159
|
-
resolveReply: () => resolveDiscordReplyReference({
|
|
160
|
-
replyToId: nextReplyToId(),
|
|
161
|
-
replyToIdSource: ctx.replyToIdSource,
|
|
162
|
-
replyToMode: ctx.replyToMode
|
|
163
|
-
}),
|
|
164
|
-
send: resolveOutboundSendDep(ctx.deps, "discord") ?? runtime.sendMessageDiscord,
|
|
165
|
-
sendVoice: resolveOutboundSendDep(ctx.deps, "discordVoice") ?? runtime.sendVoiceMessageDiscord
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
//#endregion
|
|
169
|
-
//#region extensions/discord/src/outbound-payload.ts
|
|
170
|
-
const log$1 = createSubsystemLogger("discord/outbound");
|
|
171
|
-
function createDiscordUnknownPayloadResult(target) {
|
|
172
|
-
return {
|
|
173
|
-
messageId: "",
|
|
174
|
-
channelId: target,
|
|
175
|
-
receipt: createDiscordSendReceipt({
|
|
176
|
-
platformMessageIds: [],
|
|
177
|
-
channelId: target,
|
|
178
|
-
kind: "unknown"
|
|
179
|
-
})
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
async function sendDiscordOutboundPayload(params) {
|
|
183
|
-
const ctx = params.ctx;
|
|
184
|
-
const payload = normalizeDiscordApprovalPayload({
|
|
185
|
-
...ctx.payload,
|
|
186
|
-
text: ctx.payload.text ?? ""
|
|
187
|
-
});
|
|
188
|
-
const mediaUrls = resolvePayloadMediaUrls(payload);
|
|
189
|
-
const sendContext = await createDiscordPayloadSendContext(ctx);
|
|
190
|
-
const deliveryOptions = (reply = sendContext.resolveReply()) => ({
|
|
191
|
-
reply,
|
|
192
|
-
accountId: ctx.accountId ?? void 0,
|
|
193
|
-
silent: ctx.silent ?? void 0,
|
|
194
|
-
cfg: ctx.cfg,
|
|
195
|
-
onPlatformSendDispatch: ctx.onPlatformSendDispatch,
|
|
196
|
-
assertPlatformSendAuthorized: ctx.assertDirectAdapterHandoff
|
|
197
|
-
});
|
|
198
|
-
const formattedDeliveryOptions = (reply = sendContext.resolveReply()) => ({
|
|
199
|
-
...deliveryOptions(reply),
|
|
200
|
-
...sendContext.formatting
|
|
201
|
-
});
|
|
202
|
-
const mediaDeliveryOptions = (mediaUrl) => ({
|
|
203
|
-
mediaUrl,
|
|
204
|
-
mediaAccess: ctx.mediaAccess,
|
|
205
|
-
mediaLocalRoots: ctx.mediaLocalRoots,
|
|
206
|
-
mediaReadFile: ctx.mediaReadFile,
|
|
207
|
-
...formattedDeliveryOptions()
|
|
208
|
-
});
|
|
209
|
-
const payloadContext = {
|
|
210
|
-
...ctx,
|
|
211
|
-
payload
|
|
212
|
-
};
|
|
213
|
-
const deliveredResults = [];
|
|
214
|
-
let createdThreadId;
|
|
215
|
-
payloadContext.onDeliveryResult = async (result) => {
|
|
216
|
-
await ctx.onDeliveryResult?.(result);
|
|
217
|
-
const threadId = result.receipt?.threadId;
|
|
218
|
-
if (threadId && payloadContext.threadId == null) {
|
|
219
|
-
payloadContext.threadId = threadId;
|
|
220
|
-
sendContext.target = `channel:${threadId}`;
|
|
221
|
-
createdThreadId = threadId;
|
|
222
|
-
}
|
|
223
|
-
if (createdThreadId && result.target?.kind === "channel" && result.receipt) deliveredResults.push({
|
|
224
|
-
messageId: result.messageId,
|
|
225
|
-
channelId: result.target.id,
|
|
226
|
-
receipt: result.receipt
|
|
227
|
-
});
|
|
228
|
-
};
|
|
229
|
-
const completeResult = (result) => createdThreadId ? {
|
|
230
|
-
...result,
|
|
231
|
-
receipt: createDiscordSendReceiptFromResults({
|
|
232
|
-
results: deliveredResults,
|
|
233
|
-
threadId: createdThreadId
|
|
234
|
-
})
|
|
235
|
-
} : result;
|
|
236
|
-
const completeDelivery = (result) => attachChannelToResult("discord", toDiscordOutboundDeliveryResult(completeResult(result)));
|
|
237
|
-
const onDeliveryResult = async (result) => await payloadContext.onDeliveryResult?.(attachChannelToResult("discord", toDiscordOutboundDeliveryResult(result)));
|
|
238
|
-
if (payload.audioAsVoice && mediaUrls.length > 0) {
|
|
239
|
-
const voiceReply = sendContext.resolveReply();
|
|
240
|
-
let voiceFailure;
|
|
241
|
-
let lastResult = createDiscordUnknownPayloadResult(sendContext.target);
|
|
242
|
-
try {
|
|
243
|
-
const voiceUrl = expectDefined(mediaUrls.at(0), "non-empty Discord voice media URLs");
|
|
244
|
-
lastResult = await sendContext.sendVoice(sendContext.target, voiceUrl, {
|
|
245
|
-
...deliveryOptions(voiceReply),
|
|
246
|
-
mediaAccess: ctx.mediaAccess,
|
|
247
|
-
mediaLocalRoots: ctx.mediaLocalRoots,
|
|
248
|
-
mediaReadFile: ctx.mediaReadFile
|
|
249
|
-
});
|
|
250
|
-
} catch (err) {
|
|
251
|
-
if (hasDiscordMessageCreateAmbiguity(err)) throw err;
|
|
252
|
-
const supplement = getReplyPayloadTtsSupplement(payload);
|
|
253
|
-
const visibleFallbackText = payload.text?.trim() ? payload.text : void 0;
|
|
254
|
-
const hiddenFallbackText = supplement?.visibleTextAlreadyDelivered ? void 0 : supplement?.spokenText;
|
|
255
|
-
const fallbackText = visibleFallbackText ?? hiddenFallbackText;
|
|
256
|
-
if (!fallbackText && !supplement?.visibleTextAlreadyDelivered) throw err;
|
|
257
|
-
log$1.warn("discord voice send failed; continuing without voice", { error: err });
|
|
258
|
-
if (fallbackText) await sendContext.send(sendContext.target, fallbackText, {
|
|
259
|
-
verbose: false,
|
|
260
|
-
...formattedDeliveryOptions(voiceReply),
|
|
261
|
-
onDeliveryResult
|
|
262
|
-
});
|
|
263
|
-
voiceFailure = { error: err };
|
|
264
|
-
}
|
|
265
|
-
if (!voiceFailure) {
|
|
266
|
-
await onDeliveryResult(lastResult);
|
|
267
|
-
if (payload.text?.trim()) lastResult = await sendContext.send(sendContext.target, payload.text, {
|
|
268
|
-
verbose: false,
|
|
269
|
-
...formattedDeliveryOptions(),
|
|
270
|
-
onDeliveryResult
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
for (const mediaUrl of mediaUrls.slice(1)) try {
|
|
274
|
-
lastResult = await sendContext.send(sendContext.target, "", {
|
|
275
|
-
verbose: false,
|
|
276
|
-
...mediaDeliveryOptions(mediaUrl),
|
|
277
|
-
onDeliveryResult
|
|
278
|
-
});
|
|
279
|
-
} catch (err) {
|
|
280
|
-
if (!voiceFailure) throw err;
|
|
281
|
-
log$1.warn("discord remaining media send failed after voice failure", { error: err });
|
|
282
|
-
}
|
|
283
|
-
if (voiceFailure) throw voiceFailure.error;
|
|
284
|
-
return completeDelivery(lastResult);
|
|
285
|
-
}
|
|
286
|
-
const discordData = asOptionalRecord(payload.channelData?.discord) ?? {};
|
|
287
|
-
const filename = normalizeOptionalString(discordData.filename);
|
|
288
|
-
const componentSpec = await resolveDiscordComponentSpec(payload);
|
|
289
|
-
const nativeComponents = !componentSpec && Array.isArray(discordData.components) ? discordData.components : void 0;
|
|
290
|
-
const embeds = !componentSpec && Array.isArray(discordData.embeds) ? discordData.embeds : void 0;
|
|
291
|
-
if (!componentSpec && !nativeComponents && !embeds?.length && !filename) return completeResult(await sendTextMediaPayload({
|
|
292
|
-
channel: "discord",
|
|
293
|
-
ctx: payloadContext,
|
|
294
|
-
adapter: params.fallbackAdapter
|
|
295
|
-
}));
|
|
296
|
-
return completeDelivery(await sendPayloadMediaSequenceOrFallback({
|
|
297
|
-
text: payload.text ?? "",
|
|
298
|
-
mediaUrls,
|
|
299
|
-
fallbackResult: createDiscordUnknownPayloadResult(sendContext.target),
|
|
300
|
-
sendNoMedia: async () => componentSpec ? await sendDiscordComponentMessageLazy(sendContext.target, componentSpec, {
|
|
301
|
-
...formattedDeliveryOptions(),
|
|
302
|
-
filename,
|
|
303
|
-
onDeliveryResult
|
|
304
|
-
}) : await sendContext.send(sendContext.target, payload.text ?? "", {
|
|
305
|
-
verbose: false,
|
|
306
|
-
components: nativeComponents,
|
|
307
|
-
embeds,
|
|
308
|
-
filename,
|
|
309
|
-
...formattedDeliveryOptions(),
|
|
310
|
-
onDeliveryResult
|
|
311
|
-
}),
|
|
312
|
-
send: async ({ text, mediaUrl, isFirst }) => {
|
|
313
|
-
if (componentSpec && isFirst) return await sendDiscordComponentMessageLazy(sendContext.target, componentSpec, {
|
|
314
|
-
...mediaDeliveryOptions(mediaUrl),
|
|
315
|
-
filename,
|
|
316
|
-
onDeliveryResult
|
|
317
|
-
});
|
|
318
|
-
return await sendContext.send(sendContext.target, text, {
|
|
319
|
-
verbose: false,
|
|
320
|
-
...mediaDeliveryOptions(mediaUrl),
|
|
321
|
-
...!componentSpec ? {
|
|
322
|
-
components: isFirst ? nativeComponents : void 0,
|
|
323
|
-
embeds: isFirst ? embeds : void 0,
|
|
324
|
-
filename: isFirst ? filename : void 0
|
|
325
|
-
} : {},
|
|
326
|
-
onDeliveryResult
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
}));
|
|
330
|
-
}
|
|
331
|
-
//#endregion
|
|
332
|
-
//#region extensions/discord/src/outbound-adapter.ts
|
|
333
|
-
const DISCORD_TEXT_CHUNK_LIMIT = 2e3;
|
|
334
|
-
const DISCORD_PRECHUNK_MAX_LINES = Number.MAX_SAFE_INTEGER;
|
|
335
|
-
const log = createSubsystemLogger("discord/outbound");
|
|
336
|
-
const loadDiscordThreadBindings = createLazyRuntimeModule(() => import("./thread-bindings-DcvT_JgI.mjs").then((n) => n.i));
|
|
337
|
-
const loadDiscordComponentSendRuntime = createLazyRuntimeModule(() => import("./send.components-CWZUuGvA.mjs").then((n) => n.i));
|
|
338
|
-
function resolveDiscordDeliveryOptions(params) {
|
|
339
|
-
return {
|
|
340
|
-
onPlatformSendDispatch: params.onPlatformSendDispatch,
|
|
341
|
-
assertPlatformSendAuthorized: params.assertDirectAdapterHandoff,
|
|
342
|
-
onDeliveryResult: params.onDeliveryResult ? async (result) => params.onDeliveryResult?.(attachChannelToResult("discord", toDiscordOutboundDeliveryResult(result))) : void 0
|
|
343
|
-
};
|
|
344
|
-
}
|
|
345
|
-
async function maybeSendDiscordWebhookText(params) {
|
|
346
|
-
const threadId = normalizeOptionalStringifiedId(params.threadId) ?? "";
|
|
347
|
-
if (!threadId) return null;
|
|
348
|
-
const { getThreadBindingManager } = await loadDiscordThreadBindings();
|
|
349
|
-
const binding = getThreadBindingManager(params.accountId ?? void 0)?.getByThreadId(threadId);
|
|
350
|
-
if (!binding?.webhookId || !binding?.webhookToken) return null;
|
|
351
|
-
const username = normalizeOptionalString(params.identity?.name) || normalizeOptionalString(binding.label) || binding.agentId || "";
|
|
352
|
-
const { sendWebhookMessageDiscord } = await loadDiscordSendRuntime();
|
|
353
|
-
return await sendWebhookMessageDiscord(params.text, {
|
|
354
|
-
webhookId: binding.webhookId,
|
|
355
|
-
webhookToken: binding.webhookToken,
|
|
356
|
-
accountId: binding.accountId,
|
|
357
|
-
threadId: binding.threadId,
|
|
358
|
-
cfg: params.cfg,
|
|
359
|
-
replyTo: resolveDiscordReplyReference(params),
|
|
360
|
-
username: truncateUtf16Safe(username, 80) || void 0,
|
|
361
|
-
avatarUrl: normalizeOptionalString(params.identity?.avatarUrl),
|
|
362
|
-
tableMode: params.formatting?.tableMode,
|
|
363
|
-
chunking: {
|
|
364
|
-
maxChars: params.formatting?.textLimit,
|
|
365
|
-
maxLines: params.formatting?.maxLinesPerMessage
|
|
366
|
-
},
|
|
367
|
-
...resolveDiscordDeliveryOptions(params)
|
|
368
|
-
});
|
|
369
|
-
}
|
|
370
|
-
async function resolveDiscordOutboundMessageSend(params) {
|
|
371
|
-
const send = resolveOutboundSendDep(params.deps, "discord") ?? (await loadDiscordSendRuntime()).sendMessageDiscord;
|
|
372
|
-
const reply = resolveDiscordReplyReference(params);
|
|
373
|
-
return {
|
|
374
|
-
send,
|
|
375
|
-
target: resolveDiscordAttachedOutboundTarget(params),
|
|
376
|
-
options: {
|
|
377
|
-
verbose: false,
|
|
378
|
-
reply,
|
|
379
|
-
accountId: params.accountId ?? void 0,
|
|
380
|
-
silent: params.silent ?? void 0,
|
|
381
|
-
cfg: params.cfg,
|
|
382
|
-
...resolveDiscordFormattingOptions(params),
|
|
383
|
-
...resolveDiscordDeliveryOptions(params)
|
|
384
|
-
}
|
|
385
|
-
};
|
|
386
|
-
}
|
|
387
|
-
const discordOutbound = {
|
|
388
|
-
deliveryMode: "direct",
|
|
389
|
-
chunker: (text, limit, ctx) => chunkDiscordTextWithMode(text, {
|
|
390
|
-
maxChars: limit,
|
|
391
|
-
maxLines: ctx?.formatting?.maxLinesPerMessage ?? DISCORD_PRECHUNK_MAX_LINES
|
|
392
|
-
}),
|
|
393
|
-
textChunkLimit: DISCORD_TEXT_CHUNK_LIMIT,
|
|
394
|
-
pollMaxOptions: 10,
|
|
395
|
-
normalizePayload: ({ payload }) => normalizeDiscordApprovalPayload(payload),
|
|
396
|
-
presentationCapabilities: DISCORD_PRESENTATION_CAPABILITIES,
|
|
397
|
-
deliveryCapabilities: { durableFinal: {
|
|
398
|
-
text: true,
|
|
399
|
-
media: true,
|
|
400
|
-
poll: true,
|
|
401
|
-
payload: true,
|
|
402
|
-
silent: true,
|
|
403
|
-
replyTo: true,
|
|
404
|
-
thread: true,
|
|
405
|
-
messageSendingHooks: true
|
|
406
|
-
} },
|
|
407
|
-
renderPresentation: buildDiscordPresentationPayload,
|
|
408
|
-
resolveTarget: ({ to, allowFrom }) => normalizeDiscordOutboundTarget(to, allowFrom),
|
|
409
|
-
sendPayload: async (ctx) => await sendDiscordOutboundPayload({
|
|
410
|
-
ctx,
|
|
411
|
-
fallbackAdapter: discordOutbound
|
|
412
|
-
}),
|
|
413
|
-
...createAttachedChannelResultAdapter({
|
|
414
|
-
channel: "discord",
|
|
415
|
-
sendText: async (ctx) => {
|
|
416
|
-
if (!ctx.silent) try {
|
|
417
|
-
const webhookResult = await maybeSendDiscordWebhookText(ctx);
|
|
418
|
-
if (webhookResult) return toDiscordOutboundDeliveryResult(webhookResult);
|
|
419
|
-
} catch (error) {
|
|
420
|
-
if (!canFallbackDiscordWebhookSend(error)) throw error;
|
|
421
|
-
log.warn("discord webhook persona send failed; falling back to bot send", { error });
|
|
422
|
-
}
|
|
423
|
-
const { send, target, options } = await resolveDiscordOutboundMessageSend(ctx);
|
|
424
|
-
return toDiscordOutboundDeliveryResult(await send(target, ctx.text, options));
|
|
425
|
-
},
|
|
426
|
-
sendMedia: async (ctx) => {
|
|
427
|
-
const { send, target, options } = await resolveDiscordOutboundMessageSend(ctx);
|
|
428
|
-
if (ctx.audioAsVoice && ctx.mediaUrl) {
|
|
429
|
-
const sendVoice = resolveOutboundSendDep(ctx.deps, "discordVoice") ?? (await loadDiscordSendRuntime()).sendVoiceMessageDiscord;
|
|
430
|
-
return toDiscordOutboundDeliveryResult(await sendVoice(target, ctx.mediaUrl, {
|
|
431
|
-
cfg: ctx.cfg,
|
|
432
|
-
reply: options.reply,
|
|
433
|
-
accountId: ctx.accountId ?? void 0,
|
|
434
|
-
silent: ctx.silent ?? void 0,
|
|
435
|
-
mediaAccess: ctx.mediaAccess,
|
|
436
|
-
mediaLocalRoots: ctx.mediaLocalRoots,
|
|
437
|
-
mediaReadFile: ctx.mediaReadFile,
|
|
438
|
-
onPlatformSendDispatch: ctx.onPlatformSendDispatch,
|
|
439
|
-
assertPlatformSendAuthorized: ctx.assertDirectAdapterHandoff
|
|
440
|
-
}));
|
|
441
|
-
}
|
|
442
|
-
const mediaOptions = {
|
|
443
|
-
...options,
|
|
444
|
-
mediaUrl: ctx.mediaUrl,
|
|
445
|
-
mediaAccess: ctx.mediaAccess,
|
|
446
|
-
mediaLocalRoots: ctx.mediaLocalRoots,
|
|
447
|
-
mediaReadFile: ctx.mediaReadFile
|
|
448
|
-
};
|
|
449
|
-
if (ctx.text.trim() && ctx.mediaUrl && isLikelyDiscordVideoMedia(ctx.mediaUrl)) {
|
|
450
|
-
const captionResult = await send(target, ctx.text, options);
|
|
451
|
-
const mediaResult = await send(captionResult.receipt?.threadId ? `channel:${captionResult.receipt.threadId}` : target, "", {
|
|
452
|
-
...mediaOptions,
|
|
453
|
-
reply: options.reply?.scope === "all" ? options.reply : void 0
|
|
454
|
-
});
|
|
455
|
-
const threadId = captionResult.receipt?.threadId;
|
|
456
|
-
return toDiscordOutboundDeliveryResult({
|
|
457
|
-
...threadId ? captionResult : mediaResult,
|
|
458
|
-
receipt: createDiscordSendReceiptFromResults({
|
|
459
|
-
results: [captionResult, mediaResult],
|
|
460
|
-
threadId
|
|
461
|
-
})
|
|
462
|
-
});
|
|
463
|
-
}
|
|
464
|
-
return toDiscordOutboundDeliveryResult(await send(target, ctx.text, mediaOptions));
|
|
465
|
-
},
|
|
466
|
-
sendPoll: async ({ cfg, to, poll, content, accountId, threadId, silent, sessionKey, inboundEventKind, onPlatformSendDispatch, assertDirectAdapterHandoff }) => {
|
|
467
|
-
if (!createDiscordActionGate({
|
|
468
|
-
cfg,
|
|
469
|
-
accountId
|
|
470
|
-
})("polls")) throw new Error("Discord polls are disabled.");
|
|
471
|
-
const outboundTo = resolveDiscordAttachedOutboundTarget({
|
|
472
|
-
to,
|
|
473
|
-
threadId
|
|
474
|
-
});
|
|
475
|
-
const result = await (await loadDiscordSendRuntime()).sendPollDiscord(outboundTo, poll, {
|
|
476
|
-
accountId: accountId ?? void 0,
|
|
477
|
-
content,
|
|
478
|
-
threadId: threadId ?? void 0,
|
|
479
|
-
silent: silent ?? void 0,
|
|
480
|
-
cfg,
|
|
481
|
-
onPlatformSendDispatch,
|
|
482
|
-
assertPlatformSendAuthorized: assertDirectAdapterHandoff
|
|
483
|
-
});
|
|
484
|
-
discordInboundEventDelivery.notify({
|
|
485
|
-
sessionKey,
|
|
486
|
-
inboundEventKind,
|
|
487
|
-
to: outboundTo,
|
|
488
|
-
accountId
|
|
489
|
-
});
|
|
490
|
-
return result;
|
|
491
|
-
}
|
|
492
|
-
}),
|
|
493
|
-
adoptTargetFromDelivery: ({ result }) => {
|
|
494
|
-
const threadId = normalizeOptionalStringifiedId(result.receipt?.threadId);
|
|
495
|
-
return threadId ? { threadId } : null;
|
|
496
|
-
},
|
|
497
|
-
afterDeliverPayload: async ({ cfg, target, payload, results }) => {
|
|
498
|
-
notifyDiscordInboundEventOutboundPayloadSuccess({
|
|
499
|
-
payload,
|
|
500
|
-
to: resolveDiscordAttachedOutboundTarget({
|
|
501
|
-
to: target.to,
|
|
502
|
-
threadId: target.threadId
|
|
503
|
-
}),
|
|
504
|
-
accountId: target.accountId
|
|
505
|
-
});
|
|
506
|
-
const questionId = questionGatewayRuntime.readAskUserQuestionId(payload);
|
|
507
|
-
const result = results.find((candidate) => candidate.channel === "discord" && candidate.messageId);
|
|
508
|
-
const componentSpec = questionId ? await resolveDiscordComponentSpec(payload) : void 0;
|
|
509
|
-
if (questionId && result && componentSpec) {
|
|
510
|
-
const to = resolveDiscordAttachedOutboundTarget({
|
|
511
|
-
to: target.to,
|
|
512
|
-
threadId: target.threadId
|
|
513
|
-
});
|
|
514
|
-
const channelId = result.target?.kind === "channel" ? result.target.id : to;
|
|
515
|
-
questionGatewayRuntime.registerChannelDelivery({
|
|
516
|
-
questionId,
|
|
517
|
-
deliveryId: `discord:${target.accountId ?? "default"}:${channelId}:${result.messageId}`,
|
|
518
|
-
finalize: async (statusLine) => {
|
|
519
|
-
const { editDiscordComponentMessage } = await loadDiscordComponentSendRuntime();
|
|
520
|
-
await editDiscordComponentMessage(to, result.messageId, {
|
|
521
|
-
...componentSpec,
|
|
522
|
-
blocks: [...(componentSpec.blocks ?? []).filter((block) => block.type !== "actions"), {
|
|
523
|
-
type: "text",
|
|
524
|
-
text: `-# ${formatDiscordApprovalDisplayValue(statusLine)}`
|
|
525
|
-
}],
|
|
526
|
-
modal: void 0
|
|
527
|
-
}, {
|
|
528
|
-
cfg,
|
|
529
|
-
accountId: target.accountId ?? void 0
|
|
530
|
-
});
|
|
531
|
-
}
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
const threadId = normalizeOptionalStringifiedId(target.threadId);
|
|
535
|
-
if (!threadId) return;
|
|
536
|
-
const { getThreadBindingManager } = await loadDiscordThreadBindings();
|
|
537
|
-
const manager = getThreadBindingManager(target.accountId ?? void 0);
|
|
538
|
-
if (!manager?.getByThreadId(threadId)) return;
|
|
539
|
-
await manager.touchThread({ threadId });
|
|
540
|
-
}
|
|
541
|
-
};
|
|
542
|
-
//#endregion
|
|
543
|
-
export { normalizeDiscordAcpConversationId as a, resolveDiscordInboundConversation as c, matchDiscordAcpConversation as i, discordOutbound as n, resolveDiscordAttachedOutboundTarget as o, buildDiscordCrossContextPresentation as r, resolveDiscordCommandConversation as s, DISCORD_TEXT_CHUNK_LIMIT as t };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
// deno-lint-ignore-file no-explicit-any
|
|
2
|
-
import { Settings } from '../settings/index.mjs';
|
|
3
|
-
/** Conditionally freezes the value if `immutableTypes` is true, otherwise no action. */
|
|
4
|
-
export function Freeze(value) {
|
|
5
|
-
return Settings.Get().immutableTypes ? Object.freeze(value) : value;
|
|
6
|
-
}
|