@openclaw/discord 2026.10.2 → 2026.10.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 +31 -0
- package/dist/.setup/{accounts-HE9-mj1L.mjs → accounts-ljrzXBJi.mjs} +47 -45
- package/dist/.setup/{allow-list-vxkG9_JD.mjs → allow-list-B_ToXtew.mjs} +34 -101
- package/dist/.setup/{api-DlNUkDqj.mjs → api-CtmE1OUN.mjs} +25 -31
- package/dist/.setup/{approval-handler.runtime-DmnEa54W.mjs → approval-handler.runtime-D7FoZSn0.mjs} +30 -53
- package/dist/.setup/{approval-message-updates-B0jdSqOj.mjs → approval-message-updates-CIGByUcE.mjs} +2 -2
- package/dist/.setup/{audit-BpikUwN_.mjs → audit-zSawfbsN.mjs} +5 -8
- package/dist/.setup/{channel-Dr-AUnGt.mjs → channel-DI7DMzu0.mjs} +136 -215
- package/dist/.setup/{channel-access-BRp3Y-rF.mjs → channel-access-DasWY_OV.mjs} +6 -7
- package/dist/.setup/{channel.setup-BmNvkidb.mjs → channel.setup-DdFVN1mr.mjs} +35 -64
- package/dist/.setup/{components-DLJR0xU-.mjs → components-HN9052L1.mjs} +123 -146
- package/dist/.setup/{config-schema-BQWfnSCx.mjs → config-schema-_uBILpQf.mjs} +7 -3
- package/dist/.setup/{conversation-binding-route-DicJC1Lj.mjs → conversation-binding-route-DTjCBx-O.mjs} +1 -1
- package/dist/.setup/{directory-config-gqsdcplU.mjs → directory-config-3iVub-3m.mjs} +1 -1
- package/dist/.setup/{directory-live-Bipr0eUJ.mjs → directory-live-DLygQVtW.mjs} +18 -22
- package/dist/.setup/{discord-9gysrhzp.mjs → discord-BGqgx-yd.mjs} +686 -854
- package/dist/.setup/{doctor-B2bskDcF.mjs → doctor-DSrNJ7m2.mjs} +36 -47
- package/dist/.setup/{doctor-contract-Bg3NPAMw.mjs → doctor-contract-Bwv8EuQ_.mjs} +7 -16
- package/dist/.setup/{handle-action-UmkjXBfo.mjs → handle-action-CXH1h1tq.mjs} +25 -38
- package/dist/.setup/{handle-action.guild-admin-CB4sc9VV.mjs → handle-action.guild-admin-CHKW6PIs.mjs} +25 -31
- package/dist/.setup/{live-policy-config-VxexfRKo.mjs → live-policy-config-BPoB3eQi.mjs} +1 -1
- package/dist/.setup/{message-handler-BK69A-NB.mjs → message-handler-Ii_etru1.mjs} +9 -14
- package/dist/.setup/{message-handler.preflight-DFpsh90H.mjs → message-handler.preflight-C7YuSRl_.mjs} +79 -128
- package/dist/.setup/{message-handler.preflight-pluralkit-BXGGVmpe.mjs → message-handler.preflight-pluralkit-C3iAG--b.mjs} +6 -6
- package/dist/.setup/{message-handler.process-TKoqcqIP.mjs → message-handler.process-ClgWYH6o.mjs} +234 -206
- package/dist/.setup/{outbound-adapter-D4wRAb5S.mjs → outbound-adapter-D8OOIuKn.mjs} +73 -112
- package/dist/.setup/{outbound-session-route-BvBH4LC6.mjs → outbound-session-route-B0Hpwn3Q.mjs} +57 -115
- package/dist/.setup/output-activity-uBpMSX75.mjs +11 -0
- package/dist/.setup/{pluralkit-a6_NLfH9.mjs → pluralkit-B64dfq_j.mjs} +3 -1
- package/dist/.setup/{preflight-audio-DHGIHEpv.mjs → preflight-audio-wWgsZG5F.mjs} +1 -5
- package/dist/.setup/{presence-cache-Dg3_dADn.mjs → presence-cache-DCeTsL73.mjs} +3 -6
- package/dist/.setup/{probe-BwSKpnZf.mjs → probe-D3P1x4aN.mjs} +10 -18
- package/dist/.setup/{provider-YP8gN9_o.mjs → provider-D9EzOfG8.mjs} +2990 -3903
- package/dist/.setup/{provider-session.runtime-D1gkPxHT.mjs → provider-session.runtime-CsnRvddI.mjs} +5 -5
- package/dist/.setup/provider.runtime-BQVcM7Pg.mjs +2 -0
- package/dist/.setup/{realtime-session.runtime-BKUQBy1u.mjs → realtime-session.runtime-CxGBk8H-.mjs} +69 -98
- package/dist/.setup/{receive-recovery-DgkX7Qvi.mjs → receive-recovery-eVmK2_hl.mjs} +2 -12
- package/dist/.setup/resolve-allowlist-common-DNSsUQRF.mjs +66 -0
- package/dist/.setup/resolve-channels-UdT38DzU.mjs +173 -0
- package/dist/.setup/{resolve-users-DNrwvunm.mjs → resolve-users-DnCsrXZ_.mjs} +12 -41
- package/dist/.setup/{runtime-CESTexGn.mjs → runtime-CRTkKU1G.mjs} +202 -313
- package/dist/.setup/{runtime-DPcmPST9.mjs → runtime-DPm3gZXk.mjs} +2 -2
- package/dist/.setup/{secret-config-contract-uOE2J7yM.mjs → secret-config-contract-CIsH7R3B.mjs} +9 -18
- package/dist/.setup/{security-audit-D42cp5N7.mjs → security-audit-BFT84Uny.mjs} +1 -2
- package/dist/.setup/security-contract-DNyyjTZZ.mjs +19 -0
- package/dist/.setup/{send-CJk3VP5q.mjs → send-DbILKgcm.mjs} +184 -241
- package/dist/.setup/{send.components-dPljuV24.mjs → send.components-FxOS3CeP.mjs} +47 -63
- package/dist/.setup/{send.outbound-rOboMO_6.mjs → send.outbound-_jx4Xpd3.mjs} +178 -202
- package/dist/.setup/{send.receipt-DVOg2Oaw.mjs → send.receipt-BAlzXd8e.mjs} +33 -109
- package/dist/.setup/{send.shared-C4CN24D9.mjs → send.shared-CjQ4jbMA.mjs} +97 -153
- package/dist/.setup/{sender-identity-AHpUNr72.mjs → sender-identity-BNBvGt1l.mjs} +1 -1
- package/dist/.setup/setup-plugin-api-xfOFmxHP.mjs +3 -0
- package/dist/.setup/{shared-BoBnM5kM.mjs → shared-CestGDpq.mjs} +30 -20
- package/dist/.setup/{subagent-hooks-HH8Uy9cx.mjs → subagent-hooks-CME7dSGf.mjs} +5 -10
- package/dist/.setup/{system-events-Cwxaww8i.mjs → system-events-BwwSDCw4.mjs} +2 -2
- package/dist/.setup/target-parsing-C-HyNxcE.mjs +48 -0
- package/dist/.setup/{target-resolver-CSFoPQ12.mjs → target-resolver-Bse8fuTi.mjs} +11 -27
- package/dist/.setup/targets-DZJjkzwv.mjs +3 -0
- package/dist/.setup/{thread-bindings-DjQCkmsd.mjs → thread-bindings-0hPTSK14.mjs} +61 -52
- package/dist/.setup/{thread-bindings.manager-D2-GYZ5s.mjs → thread-bindings.manager-CdNa6UIs.mjs} +138 -211
- package/dist/.setup/{thread-bindings.session-updates-Bu_CGr_O.mjs → thread-bindings.session-updates-DGSljVf6.mjs} +60 -99
- package/dist/.setup/threading-BKe3E3tp.mjs +246 -0
- package/dist/.setup/{timeouts-pun7VJ02.mjs → timeouts-CuNARfyw.mjs} +10 -18
- package/dist/.setup/{transcripts-source-CaZQnGRH.mjs → transcripts-source-0qQYVu2H.mjs} +50 -368
- package/dist/.setup/{voice-runtime-DDymtIw8.mjs → voice-runtime-QlZJ4sHv.mjs} +166 -322
- package/dist/account-inspect-api.js +1 -1
- package/dist/action-runtime-api.js +1 -1
- package/dist/activities-api.js +77 -120
- package/dist/api.js +19 -18
- 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/doctor-contract-api.js +1 -1
- package/dist/runtime-api.js +21 -20
- package/dist/secret-contract-api.js +1 -1
- package/dist/security-audit-contract-api.js +1 -1
- package/dist/security-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 +38 -57
- package/dist/subagent-hooks-api.js +1 -1
- package/dist/transcripts-source-api.js +1 -1
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/crypto.d.ts +2 -2
- package/node_modules/@types/node/dgram.d.ts +1 -1
- package/node_modules/@types/node/package.json +2 -2
- package/node_modules/@types/node/zlib.d.ts +6 -0
- package/node_modules/@types/ws/README.md +1 -1
- package/node_modules/@types/ws/index.d.mts +4 -0
- package/node_modules/@types/ws/index.d.ts +4 -0
- package/node_modules/@types/ws/package.json +3 -3
- package/node_modules/discord-api-types/_generated_/rest/v10/interfaces.d.ts +21 -0
- package/node_modules/discord-api-types/_generated_/rest/v10/interfaces.d.ts.map +1 -1
- package/node_modules/discord-api-types/_generated_/rest/v9/interfaces.d.ts +21 -0
- package/node_modules/discord-api-types/_generated_/rest/v9/interfaces.d.ts.map +1 -1
- package/node_modules/discord-api-types/globals.d.ts +6 -0
- package/node_modules/discord-api-types/globals.d.ts.map +1 -1
- package/node_modules/discord-api-types/globals.js +6 -0
- package/node_modules/discord-api-types/globals.js.map +1 -1
- package/node_modules/discord-api-types/package.json +3 -3
- package/node_modules/discord-api-types/payloads/index.mjs +1 -0
- package/node_modules/discord-api-types/payloads/v10/applicationIdentityProfile.d.ts +207 -0
- package/node_modules/discord-api-types/payloads/v10/applicationIdentityProfile.d.ts.map +1 -0
- package/node_modules/discord-api-types/payloads/v10/applicationIdentityProfile.js +25 -0
- package/node_modules/discord-api-types/payloads/v10/applicationIdentityProfile.js.map +1 -0
- package/node_modules/discord-api-types/payloads/v10/autoModeration.d.ts +1 -1
- package/node_modules/discord-api-types/payloads/v10/autoModeration.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v10/guild.d.ts +27 -23
- package/node_modules/discord-api-types/payloads/v10/guild.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v10/guild.js +26 -22
- package/node_modules/discord-api-types/payloads/v10/guild.js.map +1 -1
- package/node_modules/discord-api-types/payloads/v10/index.d.ts +1 -0
- package/node_modules/discord-api-types/payloads/v10/index.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v10/index.js +1 -0
- package/node_modules/discord-api-types/payloads/v10/index.js.map +1 -1
- package/node_modules/discord-api-types/payloads/v10/index.mjs +1 -0
- package/node_modules/discord-api-types/payloads/v9/applicationIdentityProfile.d.ts +207 -0
- package/node_modules/discord-api-types/payloads/v9/applicationIdentityProfile.d.ts.map +1 -0
- package/node_modules/discord-api-types/payloads/v9/applicationIdentityProfile.js +25 -0
- package/node_modules/discord-api-types/payloads/v9/applicationIdentityProfile.js.map +1 -0
- package/node_modules/discord-api-types/payloads/v9/autoModeration.d.ts +1 -1
- package/node_modules/discord-api-types/payloads/v9/autoModeration.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v9/guild.d.ts +27 -23
- package/node_modules/discord-api-types/payloads/v9/guild.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v9/guild.js +26 -22
- package/node_modules/discord-api-types/payloads/v9/guild.js.map +1 -1
- package/node_modules/discord-api-types/payloads/v9/index.d.ts +1 -0
- package/node_modules/discord-api-types/payloads/v9/index.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v9/index.js +1 -0
- package/node_modules/discord-api-types/payloads/v9/index.js.map +1 -1
- package/node_modules/discord-api-types/payloads/v9/index.mjs +1 -0
- package/node_modules/discord-api-types/rest/common.d.ts +2 -0
- package/node_modules/discord-api-types/rest/common.d.ts.map +1 -1
- package/node_modules/discord-api-types/rest/common.js +2 -0
- package/node_modules/discord-api-types/rest/common.js.map +1 -1
- package/node_modules/discord-api-types/rest/v10/applicationIdentityProfile.d.ts +70 -0
- package/node_modules/discord-api-types/rest/v10/applicationIdentityProfile.d.ts.map +1 -0
- package/node_modules/discord-api-types/rest/v10/applicationIdentityProfile.js +3 -0
- package/node_modules/discord-api-types/rest/v10/applicationIdentityProfile.js.map +1 -0
- package/node_modules/discord-api-types/rest/v10/index.d.ts +1 -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 +29 -0
- package/node_modules/discord-api-types/rest/v10/index.js.map +1 -1
- package/node_modules/discord-api-types/rest/v10/interactions.d.ts +4 -2
- package/node_modules/discord-api-types/rest/v10/interactions.d.ts.map +1 -1
- package/node_modules/discord-api-types/rest/v10/user.d.ts +2 -2
- package/node_modules/discord-api-types/rest/v10/user.d.ts.map +1 -1
- package/node_modules/discord-api-types/rest/v9/applicationIdentityProfile.d.ts +70 -0
- package/node_modules/discord-api-types/rest/v9/applicationIdentityProfile.d.ts.map +1 -0
- package/node_modules/discord-api-types/rest/v9/applicationIdentityProfile.js +3 -0
- package/node_modules/discord-api-types/rest/v9/applicationIdentityProfile.js.map +1 -0
- package/node_modules/discord-api-types/rest/v9/index.d.ts +1 -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 +29 -0
- package/node_modules/discord-api-types/rest/v9/index.js.map +1 -1
- package/node_modules/discord-api-types/rest/v9/interactions.d.ts +4 -2
- package/node_modules/discord-api-types/rest/v9/interactions.d.ts.map +1 -1
- package/node_modules/discord-api-types/rest/v9/user.d.ts +2 -2
- package/node_modules/discord-api-types/rest/v9/user.d.ts.map +1 -1
- package/node_modules/discord-api-types/v10.mjs +1 -0
- package/node_modules/discord-api-types/v9.mjs +1 -0
- package/node_modules/micromark/dev/lib/compile.d.ts.map +1 -1
- package/node_modules/micromark/dev/lib/compile.js +14 -4
- package/node_modules/micromark/dev/lib/create-tokenizer.d.ts.map +1 -1
- package/node_modules/micromark/dev/lib/create-tokenizer.js +7 -6
- package/node_modules/micromark/dev/lib/initialize/document.js +25 -21
- package/node_modules/micromark/dev/lib/initialize/text.d.ts.map +1 -1
- package/node_modules/micromark/dev/lib/initialize/text.js +10 -6
- package/node_modules/micromark/dev/lib/preprocess.d.ts.map +1 -1
- package/node_modules/micromark/dev/lib/preprocess.js +19 -21
- package/node_modules/micromark/lib/compile.d.ts.map +1 -1
- package/node_modules/micromark/lib/compile.js +37 -29
- package/node_modules/micromark/lib/create-tokenizer.d.ts.map +1 -1
- package/node_modules/micromark/lib/create-tokenizer.js +37 -35
- package/node_modules/micromark/lib/initialize/document.js +21 -13
- package/node_modules/micromark/lib/initialize/text.d.ts.map +1 -1
- package/node_modules/micromark/lib/initialize/text.js +7 -3
- package/node_modules/micromark/lib/preprocess.d.ts.map +1 -1
- package/node_modules/micromark/lib/preprocess.js +16 -19
- package/node_modules/micromark/package.json +2 -15
- package/node_modules/micromark-core-commonmark/dev/lib/attention.js +18 -24
- package/node_modules/micromark-core-commonmark/dev/lib/code-fenced.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/dev/lib/code-fenced.js +1 -43
- package/node_modules/micromark-core-commonmark/dev/lib/code-indented.js +19 -43
- package/node_modules/micromark-core-commonmark/dev/lib/heading-atx.js +2 -6
- package/node_modules/micromark-core-commonmark/dev/lib/html-flow.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/dev/lib/html-flow.js +2 -53
- package/node_modules/micromark-core-commonmark/dev/lib/label-end.js +14 -12
- package/node_modules/micromark-core-commonmark/dev/lib/label-start-image.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/dev/lib/label-start-image.js +14 -5
- package/node_modules/micromark-core-commonmark/dev/lib/label-start-link.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/dev/lib/label-start-link.js +14 -5
- package/node_modules/micromark-core-commonmark/dev/lib/partial-non-lazy-continuation.d.ts +4 -0
- package/node_modules/micromark-core-commonmark/dev/lib/partial-non-lazy-continuation.d.ts.map +1 -0
- package/node_modules/micromark-core-commonmark/dev/lib/partial-non-lazy-continuation.js +67 -0
- package/node_modules/micromark-core-commonmark/dev/lib/setext-underline.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/dev/lib/setext-underline.js +8 -5
- package/node_modules/micromark-core-commonmark/lib/attention.js +14 -24
- package/node_modules/micromark-core-commonmark/lib/code-fenced.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/lib/code-fenced.js +1 -39
- package/node_modules/micromark-core-commonmark/lib/code-indented.js +11 -29
- package/node_modules/micromark-core-commonmark/lib/heading-atx.js +2 -6
- package/node_modules/micromark-core-commonmark/lib/html-flow.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/lib/html-flow.js +2 -51
- package/node_modules/micromark-core-commonmark/lib/label-end.js +11 -10
- package/node_modules/micromark-core-commonmark/lib/label-start-image.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/lib/label-start-image.js +11 -3
- package/node_modules/micromark-core-commonmark/lib/label-start-link.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/lib/label-start-link.js +11 -3
- package/node_modules/micromark-core-commonmark/lib/partial-non-lazy-continuation.d.ts +4 -0
- package/node_modules/micromark-core-commonmark/lib/partial-non-lazy-continuation.d.ts.map +1 -0
- package/node_modules/micromark-core-commonmark/lib/partial-non-lazy-continuation.js +61 -0
- package/node_modules/micromark-core-commonmark/lib/setext-underline.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/lib/setext-underline.js +7 -5
- package/node_modules/micromark-core-commonmark/package.json +4 -16
- package/node_modules/micromark-factory-space/dev/index.d.ts +24 -1
- package/node_modules/micromark-factory-space/dev/index.d.ts.map +1 -1
- package/node_modules/micromark-factory-space/dev/index.js +58 -3
- package/node_modules/micromark-factory-space/index.d.ts +24 -1
- package/node_modules/micromark-factory-space/index.d.ts.map +1 -1
- package/node_modules/micromark-factory-space/index.js +55 -3
- package/node_modules/micromark-factory-space/package.json +1 -10
- package/node_modules/micromark-factory-space/readme.md +25 -25
- package/node_modules/micromark-util-edit-map/dev/index.d.ts +78 -0
- package/node_modules/micromark-util-edit-map/dev/index.d.ts.map +1 -0
- package/node_modules/micromark-util-edit-map/dev/index.js +237 -0
- package/node_modules/micromark-util-edit-map/index.d.ts +78 -0
- package/node_modules/micromark-util-edit-map/index.d.ts.map +1 -0
- package/node_modules/micromark-util-edit-map/index.js +225 -0
- package/node_modules/micromark-util-edit-map/license +22 -0
- package/node_modules/micromark-util-edit-map/package.json +48 -0
- package/node_modules/micromark-util-edit-map/readme.md +234 -0
- package/node_modules/micromark-util-types/index.d.ts +6 -3
- package/node_modules/micromark-util-types/package.json +2 -36
- package/node_modules/ws/lib/websocket.js +17 -3
- package/node_modules/ws/package.json +1 -1
- package/openclaw.plugin.json +3 -6
- package/package.json +7 -12
- package/dist/.setup/account-inspect-DsER5ILV.mjs +0 -45
- package/dist/.setup/provider.runtime-CZ51OIgD.mjs +0 -2
- package/dist/.setup/resolve-allowlist-common-BUyU3C-T.mjs +0 -27
- package/dist/.setup/resolve-channels-DA6QlhZN.mjs +0 -246
- package/dist/.setup/security-contract-DSHk7I2w.mjs +0 -26
- package/dist/.setup/setup-plugin-api-BVlCz3fm.mjs +0 -3
- package/dist/.setup/targets-bqXQENmX.mjs +0 -3
- package/dist/control-ui/2afbdab1d3aa65a789d8a3eba666f4b1ec5df07073538fe30d6cf32093a1fb2d/index.js +0 -1
package/dist/.setup/{message-handler.process-TKoqcqIP.mjs → message-handler.process-ClgWYH6o.mjs}
RENAMED
|
@@ -1,29 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as normalizeDiscordAllowList, o as normalizeDiscordSlug, w as resolveTimestampMs } from "./allow-list-
|
|
3
|
-
import { F as createDiscordRuntimeAccountContext, O as resolveDiscordMessageFlags, P as createDiscordRestClient, u as resolveDiscordTargetChannelId } from "./send.shared-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { a as
|
|
8
|
-
import {
|
|
9
|
-
import "./
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
1
|
+
import { m as resolveDiscordMaxLinesPerMessage } from "./accounts-ljrzXBJi.mjs";
|
|
2
|
+
import { i as normalizeDiscordAllowList, o as normalizeDiscordSlug, w as resolveTimestampMs } from "./allow-list-B_ToXtew.mjs";
|
|
3
|
+
import { F as createDiscordRuntimeAccountContext, O as resolveDiscordMessageFlags, P as createDiscordRestClient, u as resolveDiscordTargetChannelId } from "./send.shared-CjQ4jbMA.mjs";
|
|
4
|
+
import { U as captureDiscordRequestAuthority, W as withDiscordRequestAuthority, Z as Message, _t as getGuildMember, lt as deleteChannelMessage, t as discord_exports, ut as editChannelMessage } from "./discord-BGqgx-yd.mjs";
|
|
5
|
+
import { v as chunkDiscordTextWithMode } from "./send.receipt-BAlzXd8e.mjs";
|
|
6
|
+
import { n as resolveDiscordChannelId } from "./target-parsing-C-HyNxcE.mjs";
|
|
7
|
+
import { a as removeReactionDiscord, r as reactMessageDiscord } from "./send-DbILKgcm.mjs";
|
|
8
|
+
import { a as discordTextHasBroadcastMention } from "./send.outbound-_jx4Xpd3.mjs";
|
|
9
|
+
import { n as DISCORD_ATTACHMENT_TOTAL_TIMEOUT_MS, t as DISCORD_ATTACHMENT_IDLE_TIMEOUT_MS } from "./timeouts-CuNARfyw.mjs";
|
|
10
|
+
import "./targets-DZJjkzwv.mjs";
|
|
11
|
+
import { b as discordInboundEventDelivery, h as resolveDiscordConversationIdentity, u as buildDiscordRoutePeer } from "./outbound-session-route-B0Hpwn3Q.mjs";
|
|
12
|
+
import { t as DISCORD_TEXT_CHUNK_LIMIT } from "./outbound-adapter-D8OOIuKn.mjs";
|
|
13
|
+
import { T as createDiscordSupplementalContextAccessChecker, c as formatDiscordReplySkip, d as buildGuildLabel, f as resolveReplyContext, l as sanitizeDiscordFrontChannelReplyPayloads, o as deliverDiscordReply, s as formatDiscordReplyDeliveryFailure, u as buildDirectLabel, w as buildDiscordInboundAccessContext } from "./provider-D9EzOfG8.mjs";
|
|
14
|
+
import { D as resolveDiscordMessageStickers, b as resolveDiscordMessageText, h as resolveDiscordThreadStarter, k as resolveDiscordReferencedReplyMessageId, v as resolveDiscordMessageHistoryText, w as resolveReferencedReplyMediaList, x as formatDiscordMediaText } from "./transcripts-source-0qQYVu2H.mjs";
|
|
15
|
+
import { n as resolveDiscordWebhookId, t as resolveDiscordSenderIdentity } from "./sender-identity-BNBvGt1l.mjs";
|
|
16
|
+
import { n as resolveDiscordAutoThreadReplyPlan } from "./threading-BKe3E3tp.mjs";
|
|
15
17
|
import { t as beginDiscordActiveTurnThreadRoute } from "./active-turn-thread-route-C4tp9noA.mjs";
|
|
16
|
-
import { a as createDiscordHistorySenderProvenance, l as isBoundThreadBotSystemMessage, m as shouldIgnoreBoundThreadWebhookMessage, o as filterDiscordHistoryEntriesForContext, s as resolveDiscordHistoryMediaIds, t as resolveDiscordPreflightPluralKitInfo } from "./message-handler.preflight-pluralkit-
|
|
18
|
+
import { a as createDiscordHistorySenderProvenance, l as isBoundThreadBotSystemMessage, m as shouldIgnoreBoundThreadWebhookMessage, o as filterDiscordHistoryEntriesForContext, s as resolveDiscordHistoryMediaIds, t as resolveDiscordPreflightPluralKitInfo } from "./message-handler.preflight-pluralkit-C3iAG--b.mjs";
|
|
17
19
|
import { t as sendTyping } from "./typing-CNlSKY5S.mjs";
|
|
18
20
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
19
21
|
import { danger, logVerbose, shouldLogVerbose, sleepWithAbort } from "openclaw/plugin-sdk/runtime-env";
|
|
20
|
-
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
21
22
|
import { buildAgentSessionKey, resolveThreadSessionKeys } from "openclaw/plugin-sdk/routing";
|
|
22
|
-
import {
|
|
23
|
+
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
24
|
+
import { AllowedMentionsTypes, Routes } from "discord-api-types/v10";
|
|
23
25
|
import { getAgentScopedMediaLocalRoots } from "openclaw/plugin-sdk/media-runtime";
|
|
24
26
|
import { getReplyPayloadTtsSupplement, isReplyPayloadNonTerminalToolErrorWarning, resolveSendableOutboundReplyParts } from "openclaw/plugin-sdk/reply-payload";
|
|
25
27
|
import { resolveChunkMode } from "openclaw/plugin-sdk/reply-chunking";
|
|
26
28
|
import { stripInlineDirectiveTagsForDelivery, stripReasoningTagsFromText } from "openclaw/plugin-sdk/text-chunking";
|
|
29
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
27
30
|
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
28
31
|
import { resolveBatchedReplyThreadingPolicy } from "openclaw/plugin-sdk/reply-reference";
|
|
29
32
|
import { resolveMarkdownTableMode } from "openclaw/plugin-sdk/markdown-table-runtime";
|
|
@@ -33,7 +36,7 @@ import { resolvePinnedMainDmOwnerFromAllowlist as resolvePinnedMainDmOwnerFromAl
|
|
|
33
36
|
import { resolveAgentConfig } from "openclaw/plugin-sdk/agent-scope-runtime";
|
|
34
37
|
import { isDangerousNameMatchingEnabled } from "openclaw/plugin-sdk/dangerous-name-runtime";
|
|
35
38
|
import { EmbeddedBlockChunker, resolveAckReaction, resolveAgentConfig as resolveAgentConfig$1, resolveHumanDelayConfig } from "openclaw/plugin-sdk/agent-runtime";
|
|
36
|
-
import { getSessionEntry,
|
|
39
|
+
import { getSessionEntry, readSessionUpdatedAtAsync, resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
|
|
37
40
|
import { buildChannelInboundEventContext, createCommandTurnContext, dispatchChannelInboundTurn, formatInboundEnvelope, formatInboundMediaUnavailableText, getGroupThreadDeliverySession, hasFinalInboundReplyDispatch, readAgentRunTerminalOutcome, resolveEnvelopeFormatOptions, toHistoryMediaEntries, toInboundMediaFactsWithMetadata } from "openclaw/plugin-sdk/channel-inbound";
|
|
38
41
|
import { getGlobalHookRunner } from "openclaw/plugin-sdk/plugin-runtime";
|
|
39
42
|
import { buildHistoryContextFromEntries, buildInboundHistoryFromEntries, createChannelHistoryWindow } from "openclaw/plugin-sdk/reply-history";
|
|
@@ -387,7 +390,7 @@ async function buildDiscordMessageProcessContext(params) {
|
|
|
387
390
|
threadParentInheritanceEnabled
|
|
388
391
|
});
|
|
389
392
|
if (!isHistoryCurrent()) return null;
|
|
390
|
-
const { deliverTarget, replyTarget,
|
|
393
|
+
const { deliverTarget, replyTarget, autoThreadContext } = replyPlan;
|
|
391
394
|
const conversationParentId = threadChannel ? threadParentId : autoThreadContext ? messageChannelId : void 0;
|
|
392
395
|
const effectiveFrom = isDirectMessage ? `discord:${author.id}` : autoThreadContext?.From ?? `discord:channel:${messageChannelId}`;
|
|
393
396
|
const dmConversationTarget = isDirectMessage ? resolveDiscordConversationIdentity({
|
|
@@ -406,7 +409,7 @@ async function buildDiscordMessageProcessContext(params) {
|
|
|
406
409
|
}) : void 0;
|
|
407
410
|
const originatingTo = autoThreadContext?.OriginatingTo ?? dmConversationTarget ?? replyTarget;
|
|
408
411
|
const effectiveSessionKey = boundSessionKey ?? autoThreadContext?.SessionKey ?? threadKeys.sessionKey;
|
|
409
|
-
const effectivePreviousTimestamp = effectiveSessionKey === route.sessionKey ? previousTimestamp :
|
|
412
|
+
const effectivePreviousTimestamp = effectiveSessionKey === route.sessionKey ? previousTimestamp : await readSessionUpdatedAtAsync({
|
|
410
413
|
storePath,
|
|
411
414
|
sessionKey: effectiveSessionKey
|
|
412
415
|
});
|
|
@@ -421,13 +424,6 @@ async function buildDiscordMessageProcessContext(params) {
|
|
|
421
424
|
threadId: threadChannel?.id ?? autoThreadContext?.createdThreadId ?? void 0
|
|
422
425
|
});
|
|
423
426
|
if (!isHistoryCurrent()) return null;
|
|
424
|
-
const conversationThreadId = threadChannel?.id ?? autoThreadContext?.createdThreadId;
|
|
425
|
-
const conversationChannelId = conversationThreadId ?? messageChannelId;
|
|
426
|
-
const conversationGuildId = isGuildMessage ? guildInfo?.id ?? data.guild?.id ?? data.guild_id : "@me";
|
|
427
|
-
const conversationLink = /^\d+$/.test(conversationChannelId) && conversationGuildId && (conversationGuildId === "@me" || /^\d+$/.test(conversationGuildId)) ? {
|
|
428
|
-
url: `https://discord.com/channels/${conversationGuildId}/${conversationChannelId}`,
|
|
429
|
-
label: conversationThreadId ? "Discord Thread" : "Discord Conversation"
|
|
430
|
-
} : void 0;
|
|
431
427
|
const batchMessageIds = ctx.sourceMessageIds && ctx.sourceMessageIds.length > 1 ? [...ctx.sourceMessageIds] : void 0;
|
|
432
428
|
const ctxPayload = await (ctx.buildContext ?? buildChannelInboundEventContext)({
|
|
433
429
|
channelIngress,
|
|
@@ -459,7 +455,6 @@ async function buildDiscordMessageProcessContext(params) {
|
|
|
459
455
|
}),
|
|
460
456
|
nativeChannelId: messageChannelId,
|
|
461
457
|
avatar: ctx.conversationAvatar,
|
|
462
|
-
link: conversationLink,
|
|
463
458
|
label: fromLabel,
|
|
464
459
|
spaceId: isGuildMessage ? (guildInfo?.id ?? data.guild?.id ?? data.guild_id ?? guildSlug) || void 0 : void 0,
|
|
465
460
|
parentId: conversationParentId,
|
|
@@ -575,31 +570,25 @@ async function buildDiscordMessageProcessContext(params) {
|
|
|
575
570
|
return {
|
|
576
571
|
ctxPayload,
|
|
577
572
|
persistedSessionKey,
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
}
|
|
594
|
-
onRecordError: (err) => {
|
|
595
|
-
logVerbose(`discord: failed updating session meta: ${String(err)}`);
|
|
596
|
-
}
|
|
573
|
+
record: {
|
|
574
|
+
updateLastRoute: {
|
|
575
|
+
sessionKey: persistedSessionKey,
|
|
576
|
+
channel: "discord",
|
|
577
|
+
to: lastRouteTo,
|
|
578
|
+
accountId: route.accountId,
|
|
579
|
+
mainDmOwnerPin: isDirectMessage && persistedSessionKey === route.mainSessionKey && pinnedMainDmOwner ? {
|
|
580
|
+
ownerRecipient: pinnedMainDmOwner,
|
|
581
|
+
senderRecipient: author.id,
|
|
582
|
+
onSkip: ({ ownerRecipient, senderRecipient }) => {
|
|
583
|
+
logVerbose(`discord: skip main-session last route for ${senderRecipient} (pinned owner ${ownerRecipient})`);
|
|
584
|
+
}
|
|
585
|
+
} : void 0
|
|
586
|
+
},
|
|
587
|
+
onRecordError: (err) => {
|
|
588
|
+
logVerbose(`discord: failed updating session meta: ${String(err)}`);
|
|
597
589
|
}
|
|
598
590
|
},
|
|
599
|
-
replyPlan
|
|
600
|
-
deliverTarget,
|
|
601
|
-
replyTarget,
|
|
602
|
-
replyReference
|
|
591
|
+
replyPlan
|
|
603
592
|
};
|
|
604
593
|
}
|
|
605
594
|
//#endregion
|
|
@@ -626,13 +615,12 @@ function createDiscordMessageProgressRuntime(params) {
|
|
|
626
615
|
})();
|
|
627
616
|
const reasoningDurableEnabled = reasoningLevel === "on";
|
|
628
617
|
const reasoningWindowEnabled = reasoningLevel === "stream";
|
|
629
|
-
let shouldYieldDraftCommentary = () => false;
|
|
630
|
-
|
|
631
|
-
if (draftPreview.handleAssistantMessageBoundary()) params.onTurnReset();
|
|
632
|
-
};
|
|
618
|
+
let shouldYieldDraftCommentary = async () => false;
|
|
619
|
+
let turnCommentaryVisible = false;
|
|
633
620
|
return { replyOptions: {
|
|
621
|
+
progressRequiresReply: draftPreview.isProgressMode ? true : void 0,
|
|
634
622
|
onAssistantMessageStart: draftPreview.draftStream ? () => {
|
|
635
|
-
handleAssistantMessageBoundary();
|
|
623
|
+
if (draftPreview.handleAssistantMessageBoundary()) params.onTurnReset();
|
|
636
624
|
return false;
|
|
637
625
|
} : void 0,
|
|
638
626
|
onReasoningEnd: draftPreview.draftStream ? () => {
|
|
@@ -648,13 +636,14 @@ function createDiscordMessageProgressRuntime(params) {
|
|
|
648
636
|
commentaryProgressEnabled: draftPreview.isProgressMode ? draftPreview.commentaryProgressEnabled : void 0,
|
|
649
637
|
progressPreambleEnabled: draftPreview.draftStream && draftPreview.isProgressMode ? true : void 0,
|
|
650
638
|
commentaryPayloadsEnabled: draftPreview.isProgressMode ? draftPreview.commentaryProgressEnabled : void 0,
|
|
651
|
-
shouldDeliverCommentaryPayloads: draftPreview.isProgressMode && draftPreview.commentaryProgressEnabled ? () =>
|
|
639
|
+
shouldDeliverCommentaryPayloads: draftPreview.isProgressMode && draftPreview.commentaryProgressEnabled ? () => turnCommentaryVisible : void 0,
|
|
652
640
|
reasoningPayloadsEnabled: reasoningDurableEnabled,
|
|
653
|
-
|
|
641
|
+
onVerboseProgressVisibilityAsync: async (isActive) => {
|
|
654
642
|
shouldYieldDraftCommentary = isActive;
|
|
643
|
+
turnCommentaryVisible = await isActive();
|
|
655
644
|
},
|
|
656
645
|
onNarrationUpdate: draftPreview.narrationProgressEnabled ? async (payload) => {
|
|
657
|
-
if (
|
|
646
|
+
if (await shouldYieldDraftCommentary() || abortSignal?.aborted) return;
|
|
658
647
|
await draftPreview.pushNarrationProgress(payload.text);
|
|
659
648
|
} : void 0,
|
|
660
649
|
onProgressNarratorLifecycle: draftPreview.narrationProgressEnabled ? (lifecycle) => draftPreview.setProgressNarratorLifecycle(lifecycle) : void 0,
|
|
@@ -673,7 +662,7 @@ function createDiscordMessageProgressRuntime(params) {
|
|
|
673
662
|
return await draftPreview.pushToolEvent(payload);
|
|
674
663
|
},
|
|
675
664
|
onItemEvent: async (payload) => {
|
|
676
|
-
if (payload.kind === "preamble" && shouldYieldDraftCommentary()) return;
|
|
665
|
+
if (abortSignal?.aborted || payload.kind === "preamble" && await shouldYieldDraftCommentary()) return;
|
|
677
666
|
return await draftPreview.pushItemEvent(payload);
|
|
678
667
|
},
|
|
679
668
|
onPlanUpdate: async (payload) => {
|
|
@@ -704,10 +693,7 @@ function createDiscordMessageProgressRuntime(params) {
|
|
|
704
693
|
function createDiscordAckReactionContext(params) {
|
|
705
694
|
return {
|
|
706
695
|
rest: params.rest,
|
|
707
|
-
...createDiscordRuntimeAccountContext(
|
|
708
|
-
cfg: params.cfg,
|
|
709
|
-
accountId: params.accountId
|
|
710
|
-
})
|
|
696
|
+
...createDiscordRuntimeAccountContext(params)
|
|
711
697
|
};
|
|
712
698
|
}
|
|
713
699
|
function createDiscordAckReactionAdapter(params) {
|
|
@@ -778,19 +764,18 @@ function createDiscordMessageReactionRuntime(params) {
|
|
|
778
764
|
});
|
|
779
765
|
let statusReactionTarget = `${messageChannelId}/${message.id}`;
|
|
780
766
|
let statusReactionsActive = statusReactionsEnabled;
|
|
767
|
+
const logReactionFailure = (target, error) => logAckFailure({
|
|
768
|
+
log: logVerbose,
|
|
769
|
+
channel: "discord",
|
|
770
|
+
target,
|
|
771
|
+
error
|
|
772
|
+
});
|
|
781
773
|
const createController = (enabled, adapter, initialEmoji) => createStatusReactionController({
|
|
782
774
|
enabled,
|
|
783
775
|
adapter,
|
|
784
776
|
initialEmoji,
|
|
785
777
|
presentation: "acknowledgement",
|
|
786
|
-
onError: (err) =>
|
|
787
|
-
logAckFailure({
|
|
788
|
-
log: logVerbose,
|
|
789
|
-
channel: "discord",
|
|
790
|
-
target: statusReactionTarget,
|
|
791
|
-
error: err
|
|
792
|
-
});
|
|
793
|
-
}
|
|
778
|
+
onError: (err) => logReactionFailure(statusReactionTarget, err)
|
|
794
779
|
});
|
|
795
780
|
let statusReactions = createController(statusReactionsEnabled, discordAdapter, ackReaction);
|
|
796
781
|
const resolveTrackedReactionChannelId = async (args) => {
|
|
@@ -818,12 +803,7 @@ function createDiscordMessageReactionRuntime(params) {
|
|
|
818
803
|
try {
|
|
819
804
|
trackedChannelId = await resolveTrackedReactionChannelId(args);
|
|
820
805
|
} catch (err) {
|
|
821
|
-
|
|
822
|
-
log: logVerbose,
|
|
823
|
-
channel: "discord",
|
|
824
|
-
target: `${normalizeOptionalString(args.to) ?? normalizeOptionalString(args.channelId) ?? messageChannelId}/${trackedMessageId}`,
|
|
825
|
-
error: err
|
|
826
|
-
});
|
|
806
|
+
logReactionFailure(`${normalizeOptionalString(args.to) ?? normalizeOptionalString(args.channelId) ?? messageChannelId}/${trackedMessageId}`, err);
|
|
827
807
|
return;
|
|
828
808
|
}
|
|
829
809
|
statusReactionTarget = `${trackedChannelId}/${trackedMessageId}`;
|
|
@@ -850,15 +830,12 @@ function createDiscordMessageReactionRuntime(params) {
|
|
|
850
830
|
});
|
|
851
831
|
};
|
|
852
832
|
const finish = async (result) => {
|
|
853
|
-
if (statusReactionsActive)
|
|
854
|
-
|
|
855
|
-
statusReactions.restoreInitial();
|
|
856
|
-
return;
|
|
857
|
-
}
|
|
833
|
+
if (!statusReactionsActive) return;
|
|
834
|
+
if (!result.dispatchAborted) {
|
|
858
835
|
if (result.dispatchError || result.finalDeliveryFailed) await statusReactions.setError();
|
|
859
836
|
else await statusReactions.setDone();
|
|
860
|
-
statusReactions.restoreInitial();
|
|
861
837
|
}
|
|
838
|
+
statusReactions.restoreInitial();
|
|
862
839
|
};
|
|
863
840
|
return {
|
|
864
841
|
feedbackRest,
|
|
@@ -886,7 +863,6 @@ function createDiscordDraftStream(params) {
|
|
|
886
863
|
let channelId = params.channelId;
|
|
887
864
|
const rest = params.rest;
|
|
888
865
|
const flags = resolveDiscordMessageFlags({ suppressEmbeds: params.suppressEmbeds });
|
|
889
|
-
const resolveReplyToMessageId = () => typeof params.replyToMessageId === "function" ? params.replyToMessageId() : params.replyToMessageId;
|
|
890
866
|
const streamState = {
|
|
891
867
|
stopped: false,
|
|
892
868
|
final: false
|
|
@@ -918,7 +894,7 @@ function createDiscordDraftStream(params) {
|
|
|
918
894
|
if (generation === lifecycle.generation) lastSentText = trimmed;
|
|
919
895
|
return true;
|
|
920
896
|
}
|
|
921
|
-
const replyToMessageId =
|
|
897
|
+
const replyToMessageId = (typeof params.replyToMessageId === "function" ? params.replyToMessageId() : params.replyToMessageId)?.trim();
|
|
922
898
|
const messageReference = replyToMessageId ? {
|
|
923
899
|
message_id: replyToMessageId,
|
|
924
900
|
fail_if_not_exists: false
|
|
@@ -949,23 +925,22 @@ function createDiscordDraftStream(params) {
|
|
|
949
925
|
return false;
|
|
950
926
|
}
|
|
951
927
|
};
|
|
952
|
-
const clearMessageId = () => {
|
|
953
|
-
streamMessage = void 0;
|
|
954
|
-
lastSentText = "";
|
|
955
|
-
loop.resetThrottleWindow();
|
|
956
|
-
};
|
|
957
928
|
const lifecycle = createFinalizableDraftLifecycle({
|
|
958
929
|
throttleMs,
|
|
959
930
|
coalesceInFlight: true,
|
|
960
931
|
state: streamState,
|
|
961
|
-
sendOrEditStreamMessage,
|
|
932
|
+
sendOrEditStreamMessage: (update) => withDiscordRequestAuthority(update.assertCurrent, () => sendOrEditStreamMessage(update)),
|
|
962
933
|
emptyValue: {
|
|
963
934
|
text: "",
|
|
964
935
|
complete: false
|
|
965
936
|
},
|
|
966
937
|
isEmpty: (value) => !value.text,
|
|
967
938
|
readMessageId: () => streamMessage,
|
|
968
|
-
clearMessageId
|
|
939
|
+
clearMessageId: () => {
|
|
940
|
+
streamMessage = void 0;
|
|
941
|
+
lastSentText = "";
|
|
942
|
+
loop.resetThrottleWindow();
|
|
943
|
+
},
|
|
969
944
|
isValidMessageId: (value) => value !== void 0,
|
|
970
945
|
deleteMessage: (message) => deleteChannelMessage(rest, message.channelId, message.messageId),
|
|
971
946
|
warn: params.warn,
|
|
@@ -974,7 +949,8 @@ function createDiscordDraftStream(params) {
|
|
|
974
949
|
const { loop, update: updateDraft, stop, discardPending, seal } = lifecycle;
|
|
975
950
|
const update = (text, options) => updateDraft({
|
|
976
951
|
text,
|
|
977
|
-
complete: options?.complete === true
|
|
952
|
+
complete: options?.complete === true,
|
|
953
|
+
assertCurrent: options?.assertCurrent
|
|
978
954
|
});
|
|
979
955
|
/** Move the draft to another channel, preserving its current text. */
|
|
980
956
|
const retarget = async (nextChannelId) => {
|
|
@@ -1004,6 +980,7 @@ function createDiscordDraftStream(params) {
|
|
|
1004
980
|
flush: loop.flush,
|
|
1005
981
|
messageId: () => streamMessage?.messageId,
|
|
1006
982
|
lastDeliveredText: () => lastSentText,
|
|
983
|
+
isStopped: () => streamState.stopped,
|
|
1007
984
|
clear: () => lifecycle.retireCurrent(discardPending),
|
|
1008
985
|
deleteCurrentMessage: () => lifecycle.retireCurrent(async () => {
|
|
1009
986
|
loop.resetPending();
|
|
@@ -1020,14 +997,76 @@ function createDiscordDraftStream(params) {
|
|
|
1020
997
|
//#endregion
|
|
1021
998
|
//#region extensions/discord/src/preview-streaming.ts
|
|
1022
999
|
function resolveDiscordPreviewStreamMode(params = {}) {
|
|
1023
|
-
return resolveChannelPreviewStreamMode(params, "
|
|
1000
|
+
return resolveChannelPreviewStreamMode(params, "progress");
|
|
1001
|
+
}
|
|
1002
|
+
//#endregion
|
|
1003
|
+
//#region extensions/discord/src/monitor/message-handler.progress-continuation.ts
|
|
1004
|
+
/** The registry owns task settlement; Discord keeps the confirmed transport and its cleanup. */
|
|
1005
|
+
function retainDiscordProgressDraft(params) {
|
|
1006
|
+
let retired = false;
|
|
1007
|
+
const assertChannelCurrent = () => {
|
|
1008
|
+
params.assertChannelAuthority?.();
|
|
1009
|
+
if (params.isPolicyCurrent?.() === false) throw new Error("Discord channel policy is no longer current");
|
|
1010
|
+
};
|
|
1011
|
+
const assertCurrent = () => {
|
|
1012
|
+
assertChannelCurrent();
|
|
1013
|
+
if (retired) throw new Error("Discord retained progress authority is no longer current");
|
|
1014
|
+
};
|
|
1015
|
+
const compositor = createChannelProgressDraftCompositor({
|
|
1016
|
+
preparedItems: true,
|
|
1017
|
+
showWorkStatus: true,
|
|
1018
|
+
entry: params.entry,
|
|
1019
|
+
mode: "progress",
|
|
1020
|
+
active: true,
|
|
1021
|
+
seed: params.seed,
|
|
1022
|
+
reasoningGate: false,
|
|
1023
|
+
toolIcons: true,
|
|
1024
|
+
initialSnapshot: params.snapshot,
|
|
1025
|
+
update: async (text, options) => {
|
|
1026
|
+
if (retired) return false;
|
|
1027
|
+
params.stream.update(text, {
|
|
1028
|
+
complete: true,
|
|
1029
|
+
assertCurrent
|
|
1030
|
+
});
|
|
1031
|
+
if (options.flush) await params.stream.flush();
|
|
1032
|
+
return params.stream.lastDeliveredText() === text;
|
|
1033
|
+
}
|
|
1034
|
+
});
|
|
1035
|
+
let queue = Promise.resolve();
|
|
1036
|
+
const enqueue = (work) => {
|
|
1037
|
+
queue = params.runInChannelScope(() => queue.then(work).catch((error) => {
|
|
1038
|
+
params.log("discord: retained progress failed (" + String(error) + ")");
|
|
1039
|
+
}));
|
|
1040
|
+
};
|
|
1041
|
+
let started = false;
|
|
1042
|
+
return {
|
|
1043
|
+
push: (item) => enqueue(async () => {
|
|
1044
|
+
if (retired) return;
|
|
1045
|
+
if (!started) {
|
|
1046
|
+
started = true;
|
|
1047
|
+
await compositor.start();
|
|
1048
|
+
}
|
|
1049
|
+
await compositor.pushItemEvent(item);
|
|
1050
|
+
}),
|
|
1051
|
+
retire: () => {
|
|
1052
|
+
if (retired) return;
|
|
1053
|
+
retired = true;
|
|
1054
|
+
compositor.markFinalReplyStarted();
|
|
1055
|
+
enqueue(() => withDiscordRequestAuthority(assertChannelCurrent, async () => {
|
|
1056
|
+
await params.stream.clear();
|
|
1057
|
+
await params.stream.cleanupPendingMessages();
|
|
1058
|
+
}));
|
|
1059
|
+
}
|
|
1060
|
+
};
|
|
1024
1061
|
}
|
|
1025
1062
|
//#endregion
|
|
1026
1063
|
//#region extensions/discord/src/monitor/message-handler.draft-preview.ts
|
|
1027
1064
|
function createDiscordDraftPreviewController(params) {
|
|
1065
|
+
const runInChannelScope = AsyncLocalStorage.snapshot();
|
|
1066
|
+
const assertChannelAuthority = captureDiscordRequestAuthority();
|
|
1028
1067
|
const discordStreamMode = resolveDiscordPreviewStreamMode(params.discordConfig);
|
|
1029
1068
|
const hookRunner = getGlobalHookRunner();
|
|
1030
|
-
const allowProviderPreview = !params.groupThread && !((hookRunner?.hasHooks("reply_payload_sending") ?? false) || (hookRunner?.hasHooks("message_sending") ?? false));
|
|
1069
|
+
const allowProviderPreview = !params.groupThread && !params.isRoomEvent && !((hookRunner?.hasHooks("reply_payload_sending") ?? false) || (hookRunner?.hasHooks("message_sending") ?? false));
|
|
1031
1070
|
const draftMaxChars = Math.min(params.textLimit, 2e3);
|
|
1032
1071
|
const canStreamProgressDraftForToolOnlySource = params.sourceRepliesAreToolOnly && discordStreamMode === "progress";
|
|
1033
1072
|
const previewAvailable = allowProviderPreview && (!params.sourceRepliesAreToolOnly || canStreamProgressDraftForToolOnlySource) && discordStreamMode !== "off";
|
|
@@ -1035,9 +1074,11 @@ function createDiscordDraftPreviewController(params) {
|
|
|
1035
1074
|
previewAvailable,
|
|
1036
1075
|
blockStreamingDefault: params.cfg.agents?.defaults?.blockStreamingDefault
|
|
1037
1076
|
});
|
|
1038
|
-
const
|
|
1077
|
+
const canStreamDraft = previewAvailable && !accountBlockStreamingEnabled;
|
|
1078
|
+
let currentChannelId = params.deliverChannelId;
|
|
1079
|
+
const createDraftStream = () => createDiscordDraftStream({
|
|
1039
1080
|
rest: params.deliveryRest,
|
|
1040
|
-
channelId:
|
|
1081
|
+
channelId: currentChannelId,
|
|
1041
1082
|
maxChars: draftMaxChars,
|
|
1042
1083
|
replyToMessageId: () => params.replyReference.peek(),
|
|
1043
1084
|
minInitialChars: discordStreamMode === "progress" ? 0 : 30,
|
|
@@ -1045,9 +1086,9 @@ function createDiscordDraftPreviewController(params) {
|
|
|
1045
1086
|
throttleMs: 1200,
|
|
1046
1087
|
log: params.log,
|
|
1047
1088
|
warn: params.log
|
|
1048
|
-
})
|
|
1089
|
+
});
|
|
1090
|
+
let draftStream = canStreamDraft ? createDraftStream() : void 0;
|
|
1049
1091
|
const draftChunking = draftStream && discordStreamMode === "block" ? resolveChannelDraftStreamingChunking(params.cfg, "discord", params.accountId, { fallbackLimit: DISCORD_TEXT_CHUNK_LIMIT }) : void 0;
|
|
1050
|
-
const shouldSplitPreviewMessages = discordStreamMode === "block";
|
|
1051
1092
|
const draftChunker = draftChunking ? new EmbeddedBlockChunker(draftChunking) : void 0;
|
|
1052
1093
|
let lastPartialText = "";
|
|
1053
1094
|
let draftText = "";
|
|
@@ -1058,12 +1099,14 @@ function createDiscordDraftPreviewController(params) {
|
|
|
1058
1099
|
const progressSeed = `${params.accountId}:${params.deliverChannelId}`;
|
|
1059
1100
|
const progressDraft = createChannelProgressDraftCompositor({
|
|
1060
1101
|
preparedItems: true,
|
|
1102
|
+
showWorkStatus: true,
|
|
1061
1103
|
entry: params.discordConfig,
|
|
1062
1104
|
mode: discordStreamMode,
|
|
1063
1105
|
active: Boolean(draftStream),
|
|
1064
1106
|
seed: progressSeed,
|
|
1065
1107
|
reasoningLinePrefix: "🧠 ",
|
|
1066
1108
|
commentaryLinePrefix: "💬 ",
|
|
1109
|
+
toolIcons: true,
|
|
1067
1110
|
commentaryItalics: false,
|
|
1068
1111
|
update: async (previewText, options) => {
|
|
1069
1112
|
if (!draftStream) return false;
|
|
@@ -1092,8 +1135,8 @@ function createDiscordDraftPreviewController(params) {
|
|
|
1092
1135
|
if (draftChunker?.hasBuffered()) {
|
|
1093
1136
|
draftChunker.drain({
|
|
1094
1137
|
force: true,
|
|
1095
|
-
emit: (chunk) => {
|
|
1096
|
-
draftText += chunk;
|
|
1138
|
+
emit: (chunk, metadata) => {
|
|
1139
|
+
draftText += metadata?.sourceText ?? chunk;
|
|
1097
1140
|
}
|
|
1098
1141
|
});
|
|
1099
1142
|
draftChunker.reset();
|
|
@@ -1104,10 +1147,14 @@ function createDiscordDraftPreviewController(params) {
|
|
|
1104
1147
|
const lifecycle = createLivePreviewLifecycle({
|
|
1105
1148
|
draft: draftStream ? {
|
|
1106
1149
|
flush,
|
|
1107
|
-
id: draftStream
|
|
1108
|
-
seal:
|
|
1109
|
-
|
|
1110
|
-
|
|
1150
|
+
id: () => draftStream?.messageId(),
|
|
1151
|
+
seal: async () => {
|
|
1152
|
+
await draftStream?.seal();
|
|
1153
|
+
},
|
|
1154
|
+
discardPending: async () => {
|
|
1155
|
+
await draftStream?.discardPending();
|
|
1156
|
+
},
|
|
1157
|
+
clear: async () => await draftStream?.clear()
|
|
1111
1158
|
} : void 0,
|
|
1112
1159
|
retainOnError: true,
|
|
1113
1160
|
cleanupUndelivered: true,
|
|
@@ -1127,27 +1174,28 @@ function createDiscordDraftPreviewController(params) {
|
|
|
1127
1174
|
hasStreamedAssistantText = false;
|
|
1128
1175
|
draftChunker?.reset();
|
|
1129
1176
|
};
|
|
1130
|
-
const forceNewMessageIfNeeded = () => {
|
|
1131
|
-
if (shouldSplitPreviewMessages && hasStreamedAssistantText) {
|
|
1132
|
-
params.log("discord: calling forceNewMessage() for draft stream");
|
|
1133
|
-
draftStream?.forceNewMessage();
|
|
1134
|
-
}
|
|
1135
|
-
resetProgressState();
|
|
1136
|
-
};
|
|
1137
1177
|
const beginNewProgressTurn = (options) => {
|
|
1138
1178
|
const beganNewTurn = progressDraft.beginNewTurn(options);
|
|
1139
|
-
if (!beganNewTurn) progressDraft.beginAssistantMessage();
|
|
1140
1179
|
if (beganNewTurn) {
|
|
1180
|
+
if (!draftStream && canStreamDraft) draftStream = createDraftStream();
|
|
1141
1181
|
lifecycle.reset();
|
|
1142
1182
|
progressNarratorLifecycle?.beginTurn();
|
|
1143
|
-
}
|
|
1183
|
+
} else progressDraft.beginAssistantMessage();
|
|
1144
1184
|
if (discordStreamMode === "progress") {
|
|
1145
1185
|
if (beganNewTurn) draftStream?.forceNewMessage("discard");
|
|
1146
|
-
} else
|
|
1186
|
+
} else {
|
|
1187
|
+
if (discordStreamMode === "block" && hasStreamedAssistantText) {
|
|
1188
|
+
params.log("discord: calling forceNewMessage() for draft stream");
|
|
1189
|
+
draftStream?.forceNewMessage();
|
|
1190
|
+
}
|
|
1191
|
+
resetProgressState();
|
|
1192
|
+
}
|
|
1147
1193
|
return beganNewTurn;
|
|
1148
1194
|
};
|
|
1149
1195
|
return {
|
|
1150
|
-
draftStream
|
|
1196
|
+
get draftStream() {
|
|
1197
|
+
return draftStream;
|
|
1198
|
+
},
|
|
1151
1199
|
lifecycle,
|
|
1152
1200
|
narrationProgressEnabled,
|
|
1153
1201
|
narrationHideCommandText,
|
|
@@ -1163,44 +1211,44 @@ function createDiscordDraftPreviewController(params) {
|
|
|
1163
1211
|
progressNarratorLifecycle = narratorLifecycle;
|
|
1164
1212
|
},
|
|
1165
1213
|
freezeProgress,
|
|
1166
|
-
async
|
|
1167
|
-
const
|
|
1168
|
-
|
|
1214
|
+
async adoptProgressDraft(payload, info) {
|
|
1215
|
+
const stream = draftStream;
|
|
1216
|
+
const adopt = info.adoptProgressDraft;
|
|
1217
|
+
if (!stream || discordStreamMode !== "progress" || !adopt || info.kind !== "final" || payload.isError || payload.isCommentary || payload.isReasoning || resolveSendableOutboundReplyParts(payload).hasMedia || payload.interactive !== void 0 || payload.presentation !== void 0 || payload.channelData !== void 0 || lifecycle.previewFinalized) return false;
|
|
1169
1218
|
const snapshot = progressDraft.getSnapshot();
|
|
1170
|
-
|
|
1219
|
+
const text = progressDraft.getText().trimEnd();
|
|
1220
|
+
if (!text || !progressDraft.hasStatusHeadline && !progressDraft.hasPlanProgress && !snapshot.lines.length) return false;
|
|
1171
1221
|
const assertCurrent = () => {
|
|
1172
1222
|
params.abortSignal?.throwIfAborted();
|
|
1173
1223
|
info.assertPlatformSendAuthorized?.();
|
|
1174
1224
|
};
|
|
1175
|
-
|
|
1225
|
+
freezeProgress();
|
|
1226
|
+
await withDiscordRequestAuthority(assertCurrent, async () => {
|
|
1176
1227
|
assertCurrent();
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
draftStream.update(text, { complete: true });
|
|
1180
|
-
await draftStream.flush();
|
|
1228
|
+
stream.update(text, { complete: true });
|
|
1229
|
+
await stream.flush();
|
|
1181
1230
|
assertCurrent();
|
|
1182
|
-
const messageId = draftStream.messageId();
|
|
1183
|
-
if (!messageId || !text || draftStream.lastDeliveredText() !== text) return false;
|
|
1184
|
-
if (!await adopt({
|
|
1185
|
-
channel: "discord",
|
|
1186
|
-
accountId: params.accountId,
|
|
1187
|
-
...target,
|
|
1188
|
-
messageId,
|
|
1189
|
-
text,
|
|
1190
|
-
snapshot
|
|
1191
|
-
})) return false;
|
|
1192
|
-
if (draftStream.messageId() === messageId) {
|
|
1193
|
-
lifecycle.retainPreview();
|
|
1194
|
-
draftStream.forceNewMessage();
|
|
1195
|
-
progressDraft.markFinalReplyDelivered();
|
|
1196
|
-
resetProgressState();
|
|
1197
|
-
await draftStream.discardPending();
|
|
1198
|
-
}
|
|
1199
|
-
return true;
|
|
1200
1231
|
});
|
|
1232
|
+
if (!stream.messageId() || stream.isStopped() || stream.lastDeliveredText() !== text || draftStream !== stream) return false;
|
|
1233
|
+
assertCurrent();
|
|
1234
|
+
if (!adopt(retainDiscordProgressDraft({
|
|
1235
|
+
stream,
|
|
1236
|
+
snapshot,
|
|
1237
|
+
entry: params.discordConfig,
|
|
1238
|
+
seed: progressSeed,
|
|
1239
|
+
log: params.log,
|
|
1240
|
+
runInChannelScope,
|
|
1241
|
+
assertChannelAuthority,
|
|
1242
|
+
isPolicyCurrent: params.isPolicyCurrent
|
|
1243
|
+
}))) return false;
|
|
1244
|
+
lifecycle.retainPreview();
|
|
1245
|
+
draftStream = void 0;
|
|
1246
|
+
resetProgressState();
|
|
1247
|
+
return true;
|
|
1201
1248
|
},
|
|
1202
1249
|
async retarget(channelId) {
|
|
1203
1250
|
await draftStream?.retarget(channelId);
|
|
1251
|
+
currentChannelId = channelId;
|
|
1204
1252
|
},
|
|
1205
1253
|
async finalizeProgressDraft() {
|
|
1206
1254
|
if (!draftStream || discordStreamMode !== "progress") return false;
|
|
@@ -1219,20 +1267,19 @@ function createDiscordDraftPreviewController(params) {
|
|
|
1219
1267
|
pushReasoningProgress: progressDraft.pushReasoningProgress.bind(progressDraft),
|
|
1220
1268
|
pushNarrationProgress: progressDraft.pushNarrationProgress.bind(progressDraft),
|
|
1221
1269
|
updateFromPartial(text) {
|
|
1222
|
-
|
|
1270
|
+
const stream = draftStream;
|
|
1271
|
+
if (!stream || !text) return;
|
|
1223
1272
|
const cleaned = stripInlineDirectiveTagsForDelivery(stripReasoningTagsFromText(text, {
|
|
1224
1273
|
mode: "strict",
|
|
1225
1274
|
trim: "both"
|
|
1226
1275
|
})).text;
|
|
1227
|
-
if (!cleaned || cleaned.startsWith("Reasoning:\n")) return;
|
|
1228
|
-
if (cleaned === lastPartialText) return;
|
|
1229
|
-
if (discordStreamMode === "progress") return;
|
|
1276
|
+
if (!cleaned || cleaned.startsWith("Reasoning:\n") || cleaned === lastPartialText || discordStreamMode === "progress") return;
|
|
1230
1277
|
progressDraft.resetActivity({ suppressed: true });
|
|
1231
1278
|
hasStreamedAssistantText = true;
|
|
1232
1279
|
if (discordStreamMode === "partial") {
|
|
1233
1280
|
if (lastPartialText && lastPartialText.startsWith(cleaned) && cleaned.length < lastPartialText.length) return;
|
|
1234
1281
|
lastPartialText = cleaned;
|
|
1235
|
-
|
|
1282
|
+
stream.update(cleaned);
|
|
1236
1283
|
return;
|
|
1237
1284
|
}
|
|
1238
1285
|
let delta = cleaned;
|
|
@@ -1245,15 +1292,16 @@ function createDiscordDraftPreviewController(params) {
|
|
|
1245
1292
|
if (!delta) return;
|
|
1246
1293
|
if (!draftChunker) {
|
|
1247
1294
|
draftText = cleaned;
|
|
1248
|
-
|
|
1295
|
+
stream.update(draftText);
|
|
1249
1296
|
return;
|
|
1250
1297
|
}
|
|
1251
1298
|
draftChunker.append(delta);
|
|
1252
1299
|
draftChunker.drain({
|
|
1253
1300
|
force: false,
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1301
|
+
mutablePreview: true,
|
|
1302
|
+
emit: (chunk, metadata) => {
|
|
1303
|
+
draftText += metadata?.sourceText ?? chunk;
|
|
1304
|
+
stream.update(draftText);
|
|
1257
1305
|
}
|
|
1258
1306
|
});
|
|
1259
1307
|
},
|
|
@@ -1287,11 +1335,7 @@ function shouldStartDiscordProgressDraftNow(line) {
|
|
|
1287
1335
|
//#region extensions/discord/src/monitor/reply-typing-feedback.ts
|
|
1288
1336
|
const DISCORD_REPLY_TYPING_MAX_DURATION_MS = 12e5;
|
|
1289
1337
|
function createDiscordReplyTypingFeedback(params) {
|
|
1290
|
-
const rest = params.rest ?? createDiscordRestClient(
|
|
1291
|
-
cfg: params.cfg,
|
|
1292
|
-
token: params.token,
|
|
1293
|
-
accountId: params.accountId
|
|
1294
|
-
}).rest;
|
|
1338
|
+
const rest = params.rest ?? createDiscordRestClient(params).rest;
|
|
1295
1339
|
return createTypingCallbacks({
|
|
1296
1340
|
start: () => sendTyping({
|
|
1297
1341
|
rest,
|
|
@@ -1340,8 +1384,8 @@ function createDiscordBeforePayloadDelivery(params) {
|
|
|
1340
1384
|
function createDiscordMessageReplyRuntime(params) {
|
|
1341
1385
|
const { ctx, processContext } = params;
|
|
1342
1386
|
const { cfg, discordConfig, accountId, token, guildHistories, historyLimit, textLimit, messageChannelId, isDirectMessage, route } = ctx;
|
|
1343
|
-
const { ctxPayload,
|
|
1344
|
-
const deliverChannelId = deliverTarget.startsWith("channel:") ? deliverTarget.slice(8) : messageChannelId;
|
|
1387
|
+
const { ctxPayload, replyPlan } = processContext;
|
|
1388
|
+
const deliverChannelId = replyPlan.deliverTarget.startsWith("channel:") ? replyPlan.deliverTarget.slice(8) : messageChannelId;
|
|
1345
1389
|
let typingFeedback;
|
|
1346
1390
|
const getTypingFeedback = () => typingFeedback ??= createDiscordReplyTypingFeedback({
|
|
1347
1391
|
cfg,
|
|
@@ -1422,15 +1466,17 @@ function createDiscordMessageReplyRuntime(params) {
|
|
|
1422
1466
|
resolveCurrentTurnTranscriptFinalText,
|
|
1423
1467
|
draftPreview: createDiscordDraftPreviewController({
|
|
1424
1468
|
groupThread: Boolean(ctxPayload.GroupThread),
|
|
1469
|
+
isRoomEvent: params.isRoomEvent,
|
|
1425
1470
|
cfg,
|
|
1426
1471
|
discordConfig,
|
|
1427
1472
|
accountId,
|
|
1428
1473
|
abortSignal: ctx.abortSignal,
|
|
1474
|
+
isPolicyCurrent: ctx.isPolicyCurrent,
|
|
1429
1475
|
sourceRepliesAreToolOnly: params.sourceRepliesAreToolOnly,
|
|
1430
1476
|
textLimit,
|
|
1431
1477
|
deliveryRest: params.deliveryRest,
|
|
1432
1478
|
deliverChannelId,
|
|
1433
|
-
replyReference,
|
|
1479
|
+
replyReference: params.replyReference,
|
|
1434
1480
|
onFinalReplyStart: params.onFinalReplyStart,
|
|
1435
1481
|
onFinalReplyDelivered: params.onFinalReplyDelivered,
|
|
1436
1482
|
log: logVerbose
|
|
@@ -1476,16 +1522,15 @@ function createDiscordMessageActiveThreadRoute(params) {
|
|
|
1476
1522
|
}
|
|
1477
1523
|
//#endregion
|
|
1478
1524
|
//#region extensions/discord/src/monitor/message-handler.process.ts
|
|
1479
|
-
const TARGETED_ONLY_ALLOWED_MENTIONS = { parse: [
|
|
1525
|
+
const TARGETED_ONLY_ALLOWED_MENTIONS = { parse: [AllowedMentionsTypes.User, AllowedMentionsTypes.Role] };
|
|
1480
1526
|
function isFallbackOnlyToolWarningFinal(payload) {
|
|
1481
1527
|
if (payload.isError !== true || !isReplyPayloadNonTerminalToolErrorWarning(payload)) return false;
|
|
1482
1528
|
return !resolveSendableOutboundReplyParts(payload).hasMedia;
|
|
1483
1529
|
}
|
|
1484
1530
|
async function processDiscordMessage(ctx, observer) {
|
|
1485
1531
|
const dispatchStartedAt = Date.now();
|
|
1486
|
-
const { cfg, accountId, token, runtime, textLimit, replyToMode, message, messageChannelId, isGuildMessage, isDirectMessage, isGroupDm, messageText, threadBindings, route, abortSignal, isPolicyCurrent, turnAdoptionLifecycle, preparedMedia: mediaList } = ctx;
|
|
1532
|
+
const { cfg, accountId, token, runtime, textLimit, replyToMode, message, messageChannelId, isGuildMessage, isDirectMessage, isGroupDm, messageText: text, threadBindings, route, abortSignal, isPolicyCurrent, turnAdoptionLifecycle, preparedMedia: mediaList } = ctx;
|
|
1487
1533
|
if (abortSignal?.aborted || isPolicyCurrent?.() === false) return;
|
|
1488
|
-
const text = messageText;
|
|
1489
1534
|
if (!text && mediaList.length === 0) {
|
|
1490
1535
|
logVerbose("discord: drop message " + message.id + " (empty content)");
|
|
1491
1536
|
return;
|
|
@@ -1523,14 +1568,14 @@ async function processDiscordMessage(ctx, observer) {
|
|
|
1523
1568
|
mediaList
|
|
1524
1569
|
});
|
|
1525
1570
|
if (!processContext) return;
|
|
1526
|
-
const { ctxPayload, persistedSessionKey,
|
|
1527
|
-
let deliverTarget =
|
|
1571
|
+
const { ctxPayload, persistedSessionKey, record, replyPlan } = processContext;
|
|
1572
|
+
let deliverTarget = replyPlan.deliverTarget;
|
|
1528
1573
|
const activeThreadRoute = createDiscordMessageActiveThreadRoute({
|
|
1529
1574
|
sessionKey: ctxPayload.SessionKey,
|
|
1530
1575
|
accountId,
|
|
1531
1576
|
sourceChannelId: messageChannelId,
|
|
1532
1577
|
sourceMessageId: ctx.canonicalMessageId ?? message.id,
|
|
1533
|
-
sourceReplyReference,
|
|
1578
|
+
sourceReplyReference: replyPlan.replyReference,
|
|
1534
1579
|
log: logVerbose
|
|
1535
1580
|
});
|
|
1536
1581
|
const replyReference = activeThreadRoute.replyReference;
|
|
@@ -1540,10 +1585,8 @@ async function processDiscordMessage(ctx, observer) {
|
|
|
1540
1585
|
});
|
|
1541
1586
|
const { replyPipeline, onModelSelected, tableMode, maxLinesPerMessage, chunkMode, beginQueuedDeliveryCorrelation, endDeliveryCorrelation, resolveCurrentTurnTranscriptFinalText, draftPreview, resolvedBlockStreamingEnabled } = createDiscordMessageReplyRuntime({
|
|
1542
1587
|
ctx,
|
|
1543
|
-
processContext
|
|
1544
|
-
|
|
1545
|
-
replyReference
|
|
1546
|
-
},
|
|
1588
|
+
processContext,
|
|
1589
|
+
replyReference,
|
|
1547
1590
|
sourceRepliesAreToolOnly,
|
|
1548
1591
|
shouldDisableCoreTypingKeepalive,
|
|
1549
1592
|
isRoomEvent,
|
|
@@ -1553,13 +1596,12 @@ async function processDiscordMessage(ctx, observer) {
|
|
|
1553
1596
|
onFinalReplyStart: observer?.onFinalReplyStart,
|
|
1554
1597
|
onFinalReplyDelivered: observer?.onFinalReplyDelivered
|
|
1555
1598
|
});
|
|
1556
|
-
let deliverThreadId = ctxPayload.MessageThreadId;
|
|
1557
1599
|
activeThreadRoute.bindThreadAdoption(async (threadId) => {
|
|
1558
1600
|
deliverTarget = `channel:${threadId}`;
|
|
1559
|
-
deliverThreadId = threadId;
|
|
1560
1601
|
await draftPreview.retarget(threadId);
|
|
1561
1602
|
});
|
|
1562
1603
|
const { lifecycle } = draftPreview;
|
|
1604
|
+
const hasCompletedFinalReply = () => lifecycle.finalSucceeded || lifecycle.previewFinalized;
|
|
1563
1605
|
const observeFinalDelivery = async () => {
|
|
1564
1606
|
if (lifecycle.finalSucceeded) return;
|
|
1565
1607
|
draftPreview.freezeProgress();
|
|
@@ -1570,16 +1612,15 @@ async function processDiscordMessage(ctx, observer) {
|
|
|
1570
1612
|
await retainedProgress;
|
|
1571
1613
|
};
|
|
1572
1614
|
let pendingToolWarningFinal;
|
|
1573
|
-
const resetDeliveryState = () => {
|
|
1574
|
-
pendingToolWarningFinal = void 0;
|
|
1575
|
-
};
|
|
1576
1615
|
const progress = createDiscordMessageProgressRuntime({
|
|
1577
1616
|
ctx,
|
|
1578
1617
|
sessionKey: ctxPayload.SessionKey,
|
|
1579
1618
|
sourceRepliesAreToolOnly,
|
|
1580
1619
|
draftPreview,
|
|
1581
1620
|
reactions,
|
|
1582
|
-
onTurnReset:
|
|
1621
|
+
onTurnReset: () => {
|
|
1622
|
+
pendingToolWarningFinal = void 0;
|
|
1623
|
+
}
|
|
1583
1624
|
});
|
|
1584
1625
|
let replyLifecycleStarted = false;
|
|
1585
1626
|
const onDiscordReplyStart = async () => {
|
|
@@ -1596,13 +1637,14 @@ async function processDiscordMessage(ctx, observer) {
|
|
|
1596
1637
|
isFallbackOnlyToolWarningFinal
|
|
1597
1638
|
});
|
|
1598
1639
|
const deliverDiscordPayload = async (incomingPayload, info, options) => {
|
|
1640
|
+
const logSkippedDelivery = (reason) => logVerbose(formatDiscordReplySkip({
|
|
1641
|
+
kind: info.kind,
|
|
1642
|
+
reason,
|
|
1643
|
+
target: deliverTarget,
|
|
1644
|
+
sessionKey: ctxPayload.SessionKey
|
|
1645
|
+
}));
|
|
1599
1646
|
if (abortSignal?.aborted) {
|
|
1600
|
-
|
|
1601
|
-
kind: info.kind,
|
|
1602
|
-
reason: "aborted before delivery",
|
|
1603
|
-
target: deliverTarget,
|
|
1604
|
-
sessionKey: ctxPayload.SessionKey
|
|
1605
|
-
}));
|
|
1647
|
+
logSkippedDelivery("aborted before delivery");
|
|
1606
1648
|
return { visibleReplySent: false };
|
|
1607
1649
|
}
|
|
1608
1650
|
const deliverySession = options?.deliverySession ?? getGroupThreadDeliverySession();
|
|
@@ -1655,7 +1697,7 @@ async function processDiscordMessage(ctx, observer) {
|
|
|
1655
1697
|
return result;
|
|
1656
1698
|
}
|
|
1657
1699
|
if (isFinal && !options?.allowFallbackOnlyToolWarning && isFallbackOnlyToolWarningFinal(payload)) {
|
|
1658
|
-
if (!
|
|
1700
|
+
if (!hasCompletedFinalReply() && (!lifecycle.finalStarted || lifecycle.finalFailed)) pendingToolWarningFinal = {
|
|
1659
1701
|
payload,
|
|
1660
1702
|
info,
|
|
1661
1703
|
deliverySession
|
|
@@ -1674,18 +1716,10 @@ async function processDiscordMessage(ctx, observer) {
|
|
|
1674
1716
|
} : payload;
|
|
1675
1717
|
const [deliverablePayload] = sanitizeDiscordFrontChannelReplyPayloads([effectivePayload], { kind: info.kind });
|
|
1676
1718
|
if (!deliverablePayload) {
|
|
1677
|
-
|
|
1678
|
-
kind: info.kind,
|
|
1679
|
-
reason: "internal-only payload",
|
|
1680
|
-
target: deliverTarget,
|
|
1681
|
-
sessionKey: ctxPayload.SessionKey
|
|
1682
|
-
}));
|
|
1719
|
+
logSkippedDelivery("internal-only payload");
|
|
1683
1720
|
return { visibleReplySent: false };
|
|
1684
1721
|
}
|
|
1685
|
-
if (await draftPreview.
|
|
1686
|
-
to: isDirectMessage ? ctxPayload.OriginatingTo ?? ctxPayload.To ?? deliverTarget : deliverTarget,
|
|
1687
|
-
threadId: deliverThreadId
|
|
1688
|
-
})) {
|
|
1722
|
+
if (await draftPreview.adoptProgressDraft(deliverablePayload, info)) {
|
|
1689
1723
|
replyReference.markSent();
|
|
1690
1724
|
return { visibleReplySent: true };
|
|
1691
1725
|
}
|
|
@@ -1701,12 +1735,7 @@ async function processDiscordMessage(ctx, observer) {
|
|
|
1701
1735
|
isError: deliverablePayload.isError === true,
|
|
1702
1736
|
deliverNormally: async () => {
|
|
1703
1737
|
if (abortSignal?.aborted) {
|
|
1704
|
-
|
|
1705
|
-
kind: info.kind,
|
|
1706
|
-
reason: "aborted before delivery",
|
|
1707
|
-
target: deliverTarget,
|
|
1708
|
-
sessionKey: ctxPayload.SessionKey
|
|
1709
|
-
}));
|
|
1738
|
+
logSkippedDelivery("aborted before delivery");
|
|
1710
1739
|
return deliveryResult;
|
|
1711
1740
|
}
|
|
1712
1741
|
const freshPreviewFinal = draftStream && isFinal && !draftPreview.isProgressMode && !deliverablePayload.isError;
|
|
@@ -1743,7 +1772,7 @@ async function processDiscordMessage(ctx, observer) {
|
|
|
1743
1772
|
let dispatchError = false;
|
|
1744
1773
|
let dispatchAborted = false;
|
|
1745
1774
|
const deliverPendingToolWarningFinalIfNeeded = async () => {
|
|
1746
|
-
if (!pendingToolWarningFinal ||
|
|
1775
|
+
if (!pendingToolWarningFinal || hasCompletedFinalReply() || abortSignal?.aborted) return;
|
|
1747
1776
|
const pending = pendingToolWarningFinal;
|
|
1748
1777
|
pendingToolWarningFinal = void 0;
|
|
1749
1778
|
try {
|
|
@@ -1793,7 +1822,7 @@ async function processDiscordMessage(ctx, observer) {
|
|
|
1793
1822
|
deliverWithProviderMessageSending: deliverDiscordPayload,
|
|
1794
1823
|
onError: onDiscordDeliveryError
|
|
1795
1824
|
},
|
|
1796
|
-
record
|
|
1825
|
+
record,
|
|
1797
1826
|
history: isRoomEvent ? void 0 : {
|
|
1798
1827
|
isGroup: isGuildMessage,
|
|
1799
1828
|
historyKey: messageChannelId,
|
|
@@ -1853,11 +1882,10 @@ async function processDiscordMessage(ctx, observer) {
|
|
|
1853
1882
|
finalDeliveryFailed
|
|
1854
1883
|
});
|
|
1855
1884
|
}
|
|
1856
|
-
|
|
1857
|
-
if (!finalDispatchResult || !hasFinalInboundReplyDispatch(finalDispatchResult)) return;
|
|
1885
|
+
if (!dispatchResult || !hasFinalInboundReplyDispatch(dispatchResult)) return;
|
|
1858
1886
|
if (shouldLogVerbose()) {
|
|
1859
|
-
const finalCount =
|
|
1860
|
-
logVerbose(`discord: delivered ${finalCount} reply${finalCount === 1 ? "" : "ies"} to ${replyTarget}`);
|
|
1887
|
+
const finalCount = dispatchResult.settledReceipt?.counts.final.delivered ?? 0;
|
|
1888
|
+
logVerbose(`discord: delivered ${finalCount} reply${finalCount === 1 ? "" : "ies"} to ${replyPlan.replyTarget}`);
|
|
1861
1889
|
}
|
|
1862
1890
|
}
|
|
1863
1891
|
//#endregion
|