@openclaw/discord 2026.8.1-beta.2 → 2026.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{account-inspect-CqzrH14k.js → account-inspect-BDfKyuvL.js} +1 -1
- package/dist/account-inspect-api.js +1 -1
- package/dist/{accounts-DJTf1LtA.js → accounts-CfQ-vSyf.js} +34 -1
- package/dist/action-runtime-api.js +1 -1
- package/dist/{activities-api-DS7vpdtp.js → activities-api-Dl-TOyOX.js} +134 -175
- package/dist/activities-api.js +1 -1
- package/dist/api.js +17 -17
- package/dist/{approval-handler.runtime-B6yEV79q.js → approval-handler.runtime-q4Zqo44V.js} +29 -106
- package/dist/{audit-Db-rlntl.js → audit-DgrvFPGt.js} +5 -5
- package/dist/{channel-CnnbJSt5.js → channel-BsQUalPw.js} +72 -50
- package/dist/{channel-actions.runtime-CLKrx6tr.js → channel-actions.runtime-UMGGIfSy.js} +31 -45
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/channel-type-CVLZyGYS.js +7 -0
- package/dist/{channel.setup-BFAO-V1P.js → channel.setup-rPs4dsk_.js} +5 -5
- package/dist/{outbound-session-route-DxLkrgKQ.js → components-Dk35LTf_.js} +34 -76
- package/dist/{config-schema-BgEskFAs.js → config-schema-CxPqtVI1.js} +46 -14
- package/dist/conversation-binding-route-BjvX4e35.js +43 -0
- package/dist/{directory-config-BVX7Cflc.js → directory-config-B7DY_pNG.js} +2 -2
- package/dist/directory-contract-api.js +1 -1
- package/dist/{directory-live-DGIGxpIo.js → directory-live-DuAXKkan.js} +3 -3
- package/dist/doctor-contract-api.js +2 -2
- package/dist/{doctor-BzC-TLnB.js → doctor-zQTtn6hm.js} +33 -12
- package/dist/{handle-action.guild-admin-BNVTUISF.js → handle-action.guild-admin-DZewwLr1.js} +9 -5
- package/dist/index.js +3 -4
- package/dist/ingress-identity-CzZKcPK8.js +60 -0
- package/dist/{message-handler-Unk_f10F.js → message-handler-C5By3yl5.js} +82 -6
- package/dist/{message-handler.preflight-C9zecxR9.js → message-handler.preflight-DrszWuHw.js} +44 -118
- package/dist/{message-handler.process-DWQ6UHHu.js → message-handler.process-DyFPDLCt.js} +205 -235
- package/dist/{message-utils-BSCPVgy0.js → message-text-Ca8M6TU8.js} +43 -42
- package/dist/{outbound-adapter-D9nRivT1.js → outbound-adapter-Dif8p481.js} +118 -91
- package/dist/{outbound-components-cTzwBJ60.js → outbound-components-wjv7yyAj.js} +5 -4
- package/dist/outbound-session-route-Bn4uXaoE.js +665 -0
- package/dist/owner-access-UlYi9t0M.js +107 -0
- package/dist/{pluralkit-DdiJ9KMK.js → pluralkit-9EuEN4UD.js} +1 -1
- package/dist/{probe-Bl-k5_Ku.js → probe-n6ZXxK8V.js} +1 -1
- package/dist/{probe.runtime-M9fREKvp.js → probe.runtime-CN4bdPfZ.js} +1 -1
- package/dist/{provider-DvSNb-2v.js → provider-LXiOcJrH.js} +887 -1350
- package/dist/{provider-session.runtime-BUEqD0rA.js → provider-session.runtime-DSNe7r2W.js} +3 -3
- package/dist/provider.runtime-DiInaDXO.js +2 -0
- package/dist/{realtime-session.runtime-C7wen-aF.js → realtime-session.runtime-DOViOIjY.js} +129 -134
- package/dist/{resolve-allowlist-common-D04lpEzb.js → resolve-allowlist-common-BLoYaxEG.js} +2 -2
- package/dist/{resolve-channels-Dm7jEeg6.js → resolve-channels-D2yl_2CN.js} +5 -4
- package/dist/{resolve-users-bktrCUUU.js → resolve-users-BLxfqajZ.js} +2 -2
- package/dist/{retry-CLpJcXXf.js → retry-DqHCW6PV.js} +187 -19
- package/dist/{runtime-DGsSyDTS.js → runtime-BYamRVPN.js} +89 -86
- package/dist/{runtime-DoHjckYm.js → runtime-DrxVBTtp.js} +9 -10
- package/dist/runtime-api.js +19 -25
- package/dist/{sdk-runtime-QpY8PvCh.js → sdk-runtime-6tfgYDjY.js} +57 -89
- package/dist/{secret-config-contract-B1akrlyY.js → secret-config-contract-B3i6WxV5.js} +53 -25
- package/dist/secret-contract-api.js +1 -1
- package/dist/{security-audit-jGnJF__m.js → security-audit-DKfK-iPY.js} +11 -12
- package/dist/security-audit-contract-api.js +1 -1
- package/dist/{security-audit.runtime-CPN0xFYz.js → security-audit.runtime-sKZyKgpx.js} +1 -1
- package/dist/{send-B7Q6Oc1I.js → send-UJHiAm4C.js} +82 -19
- package/dist/{send.components-iJyFXw9L.js → send.components-CrBJpGT_.js} +22 -39
- package/dist/{send.outbound-DS5tHwfR.js → send.outbound-D7JYmfm9.js} +77 -78
- package/dist/{send.shared-BmwFjW6T.js → send.shared-DZJ1akvQ.js} +136 -121
- package/dist/{sender-identity-QtalnCYv.js → sender-identity-BJtfyise.js} +1 -1
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{shared-BIXIX6uJ.js → shared-Dii2HTn7.js} +41 -14
- package/dist/subagent-hooks-JyGrtQIl.js +49 -0
- package/dist/subagent-hooks-api.js +1 -6
- package/dist/{system-events-CTqDf6_s.js → system-events-BEmcj4xJ.js} +2 -2
- package/dist/{target-resolver-maOKSqO0.js → target-resolver-V-IYae6s.js} +3 -3
- package/dist/targets-CQp53cGj.js +3 -0
- package/dist/{thread-bindings-3L8p82GV.js → thread-bindings-DvYP79fy.js} +28 -26
- package/dist/{thread-bindings.manager-DCIH6WDC.js → thread-bindings.manager-Clm77DBM.js} +11 -14
- package/dist/{thread-bindings.session-updates-bJ2KQFY6.js → thread-bindings.session-updates-CJb-BpPL.js} +1 -1
- package/dist/{thread-bindings.state-aeV8HNgV.js → thread-bindings.state-D8OMdk4O.js} +1 -1
- package/dist/threading-CXuu_7o9.js +478 -0
- package/dist/transcripts-source-BLEMH_yi.js +270 -0
- package/dist/transcripts-source-api.js +7 -2
- package/dist/{typing-CS-nNVoe.js → typing-B9snnwMe.js} +1 -1
- package/dist/{voice-runtime-BEdqNcST.js → voice-runtime-DY6_o73o.js} +250 -150
- package/node_modules/@discord/embedded-app-sdk/node_modules/uuid/README.md +19 -19
- package/node_modules/@discord/embedded-app-sdk/node_modules/uuid/dist/v1.js +7 -3
- package/node_modules/@discord/embedded-app-sdk/node_modules/uuid/dist/v7.js +5 -2
- package/node_modules/@discord/embedded-app-sdk/node_modules/uuid/dist-node/v1.js +7 -3
- package/node_modules/@discord/embedded-app-sdk/node_modules/uuid/dist-node/v7.js +5 -2
- package/node_modules/@discord/embedded-app-sdk/node_modules/uuid/package.json +4 -3
- package/node_modules/@discordjs/voice/node_modules/@types/node/README.md +1 -1
- package/node_modules/@discordjs/voice/node_modules/@types/node/child_process.d.ts +0 -1
- package/node_modules/@discordjs/voice/node_modules/@types/node/crypto.d.ts +6 -6
- package/node_modules/@discordjs/voice/node_modules/@types/node/dns/promises.d.ts +5 -5
- package/node_modules/@discordjs/voice/node_modules/@types/node/dns.d.ts +5 -5
- package/node_modules/@discordjs/voice/node_modules/@types/node/fs.d.ts +7 -0
- package/node_modules/@discordjs/voice/node_modules/@types/node/http.d.ts +30 -0
- package/node_modules/@discordjs/voice/node_modules/@types/node/http2.d.ts +4 -4
- package/node_modules/@discordjs/voice/node_modules/@types/node/os.d.ts +30 -30
- package/node_modules/@discordjs/voice/node_modules/@types/node/package.json +2 -2
- package/node_modules/@discordjs/voice/node_modules/@types/node/perf_hooks.d.ts +2 -1
- package/node_modules/@discordjs/voice/node_modules/@types/node/process.d.ts +42 -43
- package/node_modules/@discordjs/voice/node_modules/@types/node/quic.d.ts +1049 -84
- package/node_modules/@discordjs/voice/node_modules/@types/node/sqlite.d.ts +14 -1
- package/node_modules/@discordjs/voice/node_modules/@types/node/stream/iter.d.ts +3 -2
- package/node_modules/@discordjs/voice/node_modules/@types/node/test.d.ts +61 -0
- package/node_modules/@discordjs/voice/node_modules/@types/node/v8.d.ts +20 -23
- package/node_modules/discord-api-types/CHANGELOG.md +8 -0
- package/node_modules/discord-api-types/package.json +4 -4
- package/node_modules/discord-api-types/payloads/v10/channel.d.ts +2 -2
- package/node_modules/discord-api-types/payloads/v10/channel.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v10/gateway.d.ts +4 -0
- package/node_modules/discord-api-types/payloads/v10/gateway.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v10/gateway.js.map +1 -1
- package/node_modules/discord-api-types/payloads/v10/message.d.ts +4 -1
- package/node_modules/discord-api-types/payloads/v10/message.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v10/message.js +1 -0
- package/node_modules/discord-api-types/payloads/v10/message.js.map +1 -1
- package/node_modules/discord-api-types/payloads/v9/channel.d.ts +2 -2
- package/node_modules/discord-api-types/payloads/v9/channel.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v9/gateway.d.ts +4 -0
- package/node_modules/discord-api-types/payloads/v9/gateway.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v9/gateway.js.map +1 -1
- package/node_modules/discord-api-types/payloads/v9/message.d.ts +4 -1
- package/node_modules/discord-api-types/payloads/v9/message.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v9/message.js +1 -0
- package/node_modules/discord-api-types/payloads/v9/message.js.map +1 -1
- package/node_modules/typebox/build/format/date.d.mts +1 -1
- package/node_modules/typebox/build/format/date.mjs +1 -1
- package/node_modules/typebox/build/format/date_time.d.mts +2 -2
- package/node_modules/typebox/build/format/date_time.mjs +3 -3
- package/node_modules/typebox/build/format/email.d.mts +1 -1
- package/node_modules/typebox/build/format/email.mjs +2 -2
- package/node_modules/typebox/build/format/hostname.mjs +2 -10
- package/node_modules/typebox/build/format/idn_email.d.mts +1 -1
- package/node_modules/typebox/build/format/idn_email.mjs +3 -3
- package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -0
- package/node_modules/typebox/build/format/idn_hostname.mjs +3 -11
- package/node_modules/typebox/build/format/idna/format/bidi.d.mts +3 -0
- package/node_modules/typebox/build/format/idna/format/bidi.mjs +98 -0
- package/node_modules/typebox/build/format/idna/format/puny.d.mts +3 -0
- package/node_modules/typebox/build/format/idna/format/puny.mjs +144 -0
- package/node_modules/typebox/build/format/idna/hostname.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/hostname.mjs +16 -0
- package/node_modules/typebox/build/format/idna/idn-hostname.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/idn-hostname.mjs +23 -0
- package/node_modules/typebox/build/format/idna/index.d.mts +2 -0
- package/node_modules/typebox/build/format/idna/index.mjs +2 -0
- package/node_modules/typebox/build/format/idna/label/ascii.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/label/ascii.mjs +9 -0
- package/node_modules/typebox/build/format/idna/label/puny.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/label/puny.mjs +28 -0
- package/node_modules/typebox/build/format/idna/label/unicode.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/label/unicode.mjs +106 -0
- package/node_modules/typebox/build/format/idna/pattern/pattern.d.mts +30 -0
- package/node_modules/typebox/build/format/idna/pattern/pattern.mjs +70 -0
- package/node_modules/typebox/build/format/ipv4.d.mts +0 -1
- package/node_modules/typebox/build/format/ipv4.mjs +2 -32
- package/node_modules/typebox/build/format/ipv6.mjs +2 -61
- package/node_modules/typebox/build/format/iri.d.mts +2 -2
- package/node_modules/typebox/build/format/iri.mjs +26 -8
- package/node_modules/typebox/build/format/iri_reference.d.mts +2 -2
- package/node_modules/typebox/build/format/iri_reference.mjs +9 -55
- package/node_modules/typebox/build/format/regex.d.mts +1 -2
- package/node_modules/typebox/build/format/regex.mjs +2 -6
- package/node_modules/typebox/build/format/time.d.mts +2 -2
- package/node_modules/typebox/build/format/time.mjs +19 -14
- package/node_modules/typebox/build/format/uri.d.mts +1 -1
- package/node_modules/typebox/build/format/uri.mjs +3 -130
- package/node_modules/typebox/build/format/uri_reference.d.mts +1 -1
- package/node_modules/typebox/build/format/uri_reference.mjs +2 -3
- package/node_modules/typebox/build/format/uri_template.d.mts +2 -3
- package/node_modules/typebox/build/format/uri_template.mjs +4 -5
- package/node_modules/typebox/build/format/url.d.mts +3 -3
- package/node_modules/typebox/build/format/url.mjs +4 -5
- package/node_modules/typebox/build/guard/emit.d.mts +3 -1
- package/node_modules/typebox/build/guard/emit.mjs +12 -5
- package/node_modules/typebox/build/guard/guard.d.mts +8 -2
- package/node_modules/typebox/build/guard/guard.mjs +25 -4
- package/node_modules/typebox/build/guard/string.d.mts +2 -2
- package/node_modules/typebox/build/guard/string.mjs +7 -7
- package/node_modules/typebox/build/schema/engine/_context.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/_functions.mjs +1 -2
- package/node_modules/typebox/build/schema/engine/_regexp.d.mts +2 -0
- package/node_modules/typebox/build/schema/engine/_regexp.mjs +4 -0
- package/node_modules/typebox/build/schema/engine/_stack.mjs +12 -13
- package/node_modules/typebox/build/schema/engine/additionalItems.mjs +17 -7
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +4 -3
- package/node_modules/typebox/build/schema/engine/contains.mjs +18 -6
- package/node_modules/typebox/build/schema/engine/enum.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/items.mjs +26 -6
- package/node_modules/typebox/build/schema/engine/maxContains.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/minContains.mjs +14 -4
- package/node_modules/typebox/build/schema/engine/not.mjs +4 -2
- package/node_modules/typebox/build/schema/engine/oneOf.mjs +7 -6
- package/node_modules/typebox/build/schema/engine/pattern.mjs +3 -2
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +4 -3
- package/node_modules/typebox/build/schema/engine/ref.mjs +1 -7
- package/node_modules/typebox/build/schema/engine/schema.mjs +13 -4
- package/node_modules/typebox/build/schema/engine/type.mjs +1 -1
- package/node_modules/typebox/build/schema/resolve/resolve.d.mts +4 -1
- package/node_modules/typebox/build/schema/resolve/resolve.mjs +202 -1
- package/node_modules/typebox/build/schema/static/propertyNames.d.mts +5 -0
- package/node_modules/typebox/build/schema/static/propertyNames.mjs +3 -0
- package/node_modules/typebox/build/schema/static/schema.d.mts +3 -0
- package/node_modules/typebox/build/schema/types/index.d.mts +0 -2
- package/node_modules/typebox/build/schema/types/index.mjs +0 -2
- package/node_modules/typebox/build/system/memory/clone.mjs +14 -11
- package/node_modules/typebox/build/system/memory/discard.mjs +6 -5
- package/node_modules/typebox/build/system/settings/settings.d.mts +9 -0
- package/node_modules/typebox/build/system/settings/settings.mjs +2 -0
- package/node_modules/typebox/build/type/engine/call/distribute_arguments.d.mts +6 -1
- package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +16 -3
- package/node_modules/typebox/build/type/engine/call/instantiate.mjs +34 -4
- package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +5 -5
- package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +20 -26
- package/node_modules/typebox/build/type/engine/evaluate/compare.d.mts +6 -10
- package/node_modules/typebox/build/type/engine/evaluate/compare.mjs +9 -13
- package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +7 -4
- package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +12 -19
- package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +4 -20
- package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +8 -20
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +4 -4
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +11 -8
- package/node_modules/typebox/build/type/engine/evaluate/flatten.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/evaluate/flatten.mjs +3 -4
- package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +17 -2
- package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +26 -6
- package/node_modules/typebox/build/type/engine/exclude/operation.mjs +3 -4
- package/node_modules/typebox/build/type/engine/extract/operation.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/extract/operation.mjs +3 -4
- package/node_modules/typebox/build/type/engine/priority/priority.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/priority/priority.mjs +3 -4
- package/node_modules/typebox/build/type/script/mapping.d.mts +32 -29
- package/node_modules/typebox/build/type/script/mapping.mjs +18 -25
- package/node_modules/typebox/build/type/script/parser.d.mts +19 -25
- package/node_modules/typebox/build/type/script/parser.mjs +27 -23
- package/node_modules/typebox/build/value/errors/errors.d.mts +2 -2
- package/node_modules/typebox/build/value/errors/errors.mjs +1 -1
- package/node_modules/typebox/package.json +27 -27
- package/node_modules/typebox/readme.md +79 -82
- package/node_modules/undici/docs/docs/api/Client.md +21 -8
- package/node_modules/undici/lib/api/readable.js +33 -43
- package/node_modules/undici/lib/core/connect.js +16 -2
- package/node_modules/undici/lib/core/symbols.js +1 -0
- package/node_modules/undici/lib/dispatcher/client-h1.js +3 -3
- package/node_modules/undici/lib/dispatcher/client-h2.js +179 -10
- package/node_modules/undici/lib/dispatcher/client.js +74 -29
- package/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +28 -6
- package/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +15 -1
- package/node_modules/undici/lib/handler/retry-handler.js +7 -2
- package/node_modules/undici/lib/interceptor/cache.js +5 -2
- package/node_modules/undici/lib/interceptor/deduplicate.js +1 -1
- package/node_modules/undici/lib/mock/mock-utils.js +213 -24
- package/node_modules/undici/lib/util/cache.js +2 -4
- package/node_modules/undici/lib/web/websocket/websocket.js +22 -0
- package/node_modules/undici/package.json +1 -1
- package/node_modules/undici/types/client.d.ts +40 -0
- package/node_modules/ws/lib/permessage-deflate.js +3 -1
- package/node_modules/ws/package.json +1 -1
- package/openclaw.plugin.json +24 -10
- package/package.json +8 -10
- package/skills/discord/SKILL.md +1 -1
- package/dist/approval-message-safety-AcIxvrf3.js +0 -140
- package/dist/audit-core-xwjIczO0.js +0 -105
- package/dist/channel-actions-5s_hjYKd.js +0 -208
- package/dist/channel-api-CAJ0wMoV.js +0 -21
- package/dist/inbound-event-delivery-De2qxTrP.js +0 -39
- package/dist/provider.runtime-C9PnJZbZ.js +0 -2
- package/dist/runtime-api.actions.js +0 -3
- package/dist/runtime-api.lookup.js +0 -7
- package/dist/runtime-api.monitor-CHxrFPnW.js +0 -5
- package/dist/runtime-api.monitor.js +0 -8
- package/dist/runtime-api.send.js +0 -7
- package/dist/runtime-api.threads.js +0 -5
- package/dist/send.reactions-BAn0iiVQ.js +0 -78
- package/dist/send.receipt-IPI1p-SP.js +0 -66
- package/dist/subagent-hooks-CTt5KCJr.js +0 -120
- package/dist/subagent-progress-DhaE_h8a.js +0 -109
- package/dist/targets-yUFTHoAx.js +0 -3
- package/dist/transcripts-source-CfFMexGt.js +0 -123
- package/node_modules/p-map/index.d.ts +0 -155
- package/node_modules/p-map/index.js +0 -285
- package/node_modules/p-map/license +0 -9
- package/node_modules/p-map/package.json +0 -57
- package/node_modules/p-map/readme.md +0 -190
- package/node_modules/typebox/build/format/_idna.d.mts +0 -2
- package/node_modules/typebox/build/format/_idna.mjs +0 -246
- package/node_modules/typebox/build/format/_puny.d.mts +0 -1
- package/node_modules/typebox/build/format/_puny.mjs +0 -77
- package/node_modules/typebox/build/schema/resolve/ref.d.mts +0 -3
- package/node_modules/typebox/build/schema/resolve/ref.mjs +0 -146
- package/node_modules/typebox/build/schema/types/contentEncoding.d.mts +0 -9
- package/node_modules/typebox/build/schema/types/contentEncoding.mjs +0 -13
- package/node_modules/typebox/build/schema/types/contentMediaType.d.mts +0 -9
- package/node_modules/typebox/build/schema/types/contentMediaType.mjs +0 -13
- package/dist/{allow-list-DnxIlPP2.js → allow-list-BDMimASD.js} +1 -1
- package/dist/{doctor-contract-DLa-BTiU.js → doctor-contract-DsWvKIXF.js} +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./targets-
|
|
3
|
-
import { C as resolveThreadBindingMaxAgeExpiresAt, O as shouldPersistBindingMutations, S as resolveThreadBindingInactivityExpiresAt, T as saveBindingsToDisk, h as refreshUnboundThreadWebhookIdentity, m as normalizeThreadId, n as MANAGERS_BY_ACCOUNT_ID, t as BINDINGS_BY_THREAD_ID, u as getThreadBindingToken, v as removeBindingRecord, w as resolveThreadBindingMaxAgeMs$1, x as resolveThreadBindingIdleTimeoutMs$1 } from "./thread-bindings.state-
|
|
4
|
-
import { n as setThreadBindingMaxAgeBySessionKey, r as resolveBindingIdsForTargetSession, t as setThreadBindingIdleTimeoutBySessionKey } from "./thread-bindings.session-updates-
|
|
5
|
-
import { _ as resolveThreadBindingThreadName, g as resolveThreadBindingIntroText, h as formatThreadBindingDurationLabel, m as resolveThreadBindingPersonaFromRecord, n as createThreadBindingManager, o as resolveChannelIdForBinding, p as resolveThreadBindingPersona, r as getThreadBindingManager, t as createNoopThreadBindingManager } from "./thread-bindings.manager-
|
|
1
|
+
import { _ as parseDiscordTarget, on as __exportAll } from "./retry-DqHCW6PV.js";
|
|
2
|
+
import "./targets-CQp53cGj.js";
|
|
3
|
+
import { C as resolveThreadBindingMaxAgeExpiresAt, O as shouldPersistBindingMutations, S as resolveThreadBindingInactivityExpiresAt, T as saveBindingsToDisk, h as refreshUnboundThreadWebhookIdentity, m as normalizeThreadId, n as MANAGERS_BY_ACCOUNT_ID, t as BINDINGS_BY_THREAD_ID, u as getThreadBindingToken, v as removeBindingRecord, w as resolveThreadBindingMaxAgeMs$1, x as resolveThreadBindingIdleTimeoutMs$1 } from "./thread-bindings.state-D8OMdk4O.js";
|
|
4
|
+
import { n as setThreadBindingMaxAgeBySessionKey, r as resolveBindingIdsForTargetSession, t as setThreadBindingIdleTimeoutBySessionKey } from "./thread-bindings.session-updates-CJb-BpPL.js";
|
|
5
|
+
import { _ as resolveThreadBindingThreadName, g as resolveThreadBindingIntroText, h as formatThreadBindingDurationLabel, m as resolveThreadBindingPersonaFromRecord, n as createThreadBindingManager, o as resolveChannelIdForBinding, p as resolveThreadBindingPersona, r as getThreadBindingManager, t as createNoopThreadBindingManager } from "./thread-bindings.manager-Clm77DBM.js";
|
|
6
6
|
import { normalizeAccountId } from "openclaw/plugin-sdk/routing";
|
|
7
7
|
import { normalizeOptionalLowercaseString, normalizeOptionalString, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
8
8
|
import { resolveThreadBindingIdleTimeoutMs, resolveThreadBindingMaxAgeMs, resolveThreadBindingsEnabled } from "openclaw/plugin-sdk/conversation-runtime";
|
|
9
9
|
import { readAcpSessionEntry } from "openclaw/plugin-sdk/acp-runtime";
|
|
10
|
-
import
|
|
10
|
+
import { runTasksWithConcurrency } from "openclaw/plugin-sdk/concurrency-runtime";
|
|
11
11
|
//#region extensions/discord/src/monitor/thread-bindings.config.ts
|
|
12
12
|
function resolveDiscordThreadBindingIdleTimeoutMs(params) {
|
|
13
13
|
const accountId = normalizeAccountId(params.accountId);
|
|
@@ -160,27 +160,29 @@ async function reconcileAcpThreadBindingsOnStartup(params) {
|
|
|
160
160
|
});
|
|
161
161
|
}
|
|
162
162
|
if (params.healthProbe && probeTargets.length > 0) {
|
|
163
|
-
const probeResults = await
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
status: (await params.healthProbe?.({
|
|
168
|
-
cfg: params.cfg,
|
|
169
|
-
accountId: manager.accountId,
|
|
170
|
-
sessionKey,
|
|
163
|
+
const { results: probeResults } = await runTasksWithConcurrency({
|
|
164
|
+
tasks: probeTargets.map(({ binding, sessionKey, session }) => async () => {
|
|
165
|
+
try {
|
|
166
|
+
return {
|
|
171
167
|
binding,
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
168
|
+
status: (await params.healthProbe?.({
|
|
169
|
+
cfg: params.cfg,
|
|
170
|
+
accountId: manager.accountId,
|
|
171
|
+
sessionKey,
|
|
172
|
+
binding,
|
|
173
|
+
session
|
|
174
|
+
}))?.status ?? "uncertain"
|
|
175
|
+
};
|
|
176
|
+
} catch {
|
|
177
|
+
return {
|
|
178
|
+
binding,
|
|
179
|
+
status: "uncertain"
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
}),
|
|
183
|
+
limit: ACP_STARTUP_HEALTH_PROBE_CONCURRENCY_LIMIT,
|
|
184
|
+
errorMode: "stop",
|
|
185
|
+
throwOnError: true
|
|
184
186
|
});
|
|
185
187
|
for (const probeResult of probeResults) if (probeResult.status === "stale") staleBindings.push(probeResult.binding);
|
|
186
188
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as sendMessageDiscord } from "./send.outbound-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { At as getChannel, on as __exportAll, v as resolveDiscordChannelId, vt as createChannelWebhook } from "./retry-DqHCW6PV.js";
|
|
2
|
+
import { P as createDiscordRestClient } from "./send.shared-DZJ1akvQ.js";
|
|
3
|
+
import { t as sendMessageDiscord } from "./send.outbound-D7JYmfm9.js";
|
|
4
|
+
import { t as isDiscordThreadChannelType } from "./channel-type-CVLZyGYS.js";
|
|
5
|
+
import { c as sendWebhookMessageDiscord, u as createThreadDiscord } from "./send-UJHiAm4C.js";
|
|
6
|
+
import { A as toReusableWebhookKey, C as resolveThreadBindingMaxAgeExpiresAt, D as shouldDefaultPersist, E as setBindingRecord, S as resolveThreadBindingInactivityExpiresAt, T as saveBindingsToDisk, _ as rememberThreadBindingToken, b as resolveBindingRecordKey, c as ensureBindingsLoaded, f as normalizeTargetKind, g as rememberReusableWebhook, h as refreshUnboundThreadWebhookIdentity, i as REUSABLE_WEBHOOKS_BY_ACCOUNT_CHANNEL, l as forgetThreadBindingToken, m as normalizeThreadId, n as MANAGERS_BY_ACCOUNT_ID, p as normalizeThreadBindingDurationMs, r as PERSIST_BY_ACCOUNT_ID, s as THREAD_BINDING_TOUCH_PERSIST_MIN_INTERVAL_MS, t as BINDINGS_BY_THREAD_ID, u as getThreadBindingToken, v as removeBindingRecord, w as resolveThreadBindingMaxAgeMs$1, x as resolveThreadBindingIdleTimeoutMs$1, y as resolveBindingIdsForSession } from "./thread-bindings.state-D8OMdk4O.js";
|
|
7
|
+
import { parseStrictNonNegativeInteger } from "openclaw/plugin-sdk/number-runtime";
|
|
6
8
|
import { normalizeAccountId } from "openclaw/plugin-sdk/routing";
|
|
7
9
|
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
8
10
|
import { getRuntimeConfigSnapshot } from "openclaw/plugin-sdk/runtime-config-snapshot";
|
|
9
|
-
import { ChannelType } from "discord-api-types/v10";
|
|
10
|
-
import { parseStrictNonNegativeInteger as parseStrictNonNegativeInteger$1 } from "openclaw/plugin-sdk/number-runtime";
|
|
11
11
|
import { logVerbose } from "openclaw/plugin-sdk/runtime-env";
|
|
12
12
|
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
13
13
|
import { SYSTEM_MARK } from "openclaw/plugin-sdk/text-chunking";
|
|
14
14
|
import { formatThreadBindingDurationLabel, registerSessionBindingAdapter, resolveThreadBindingConversationIdFromBindingId, resolveThreadBindingFarewellText, resolveThreadBindingIntroText, resolveThreadBindingThreadName, unregisterSessionBindingAdapter } from "openclaw/plugin-sdk/conversation-runtime";
|
|
15
|
-
import {
|
|
15
|
+
import { resolveSessionAgentIdStrict } from "openclaw/plugin-sdk/agent-scope-runtime";
|
|
16
16
|
//#region extensions/discord/src/monitor/thread-bindings.persona.ts
|
|
17
17
|
const THREAD_BINDING_PERSONA_MAX_CHARS = 80;
|
|
18
18
|
function normalizePersonaLabel(value) {
|
|
@@ -106,9 +106,6 @@ function isThreadArchived(raw) {
|
|
|
106
106
|
if (asRecord.threadMetadata?.archived === true) return true;
|
|
107
107
|
return false;
|
|
108
108
|
}
|
|
109
|
-
function isThreadChannelType(type) {
|
|
110
|
-
return type === ChannelType.PublicThread || type === ChannelType.PrivateThread || type === ChannelType.AnnouncementThread;
|
|
111
|
-
}
|
|
112
109
|
function normalizeDiscordBindingChannelId(raw) {
|
|
113
110
|
const trimmed = normalizeOptionalString(raw) ?? "";
|
|
114
111
|
if (!trimmed) return null;
|
|
@@ -125,7 +122,7 @@ function summarizeDiscordError(err) {
|
|
|
125
122
|
return "error";
|
|
126
123
|
}
|
|
127
124
|
function extractNumericDiscordErrorValue(value) {
|
|
128
|
-
return parseStrictNonNegativeInteger
|
|
125
|
+
return parseStrictNonNegativeInteger(value);
|
|
129
126
|
}
|
|
130
127
|
function extractDiscordErrorStatus(err) {
|
|
131
128
|
if (!err || typeof err !== "object") return;
|
|
@@ -226,7 +223,7 @@ async function resolveChannelIdForBinding(params) {
|
|
|
226
223
|
const channelId = normalizeOptionalString(resolveDiscordChannelIdSafe(channel)) ?? "";
|
|
227
224
|
const type = channelInfo.type;
|
|
228
225
|
const parentId = normalizeOptionalString(channelInfo.parentId) ?? "";
|
|
229
|
-
if (parentId &&
|
|
226
|
+
if (parentId && isDiscordThreadChannelType(type)) return parentId;
|
|
230
227
|
return channelId || null;
|
|
231
228
|
} catch (err) {
|
|
232
229
|
logVerbose(`discord thread binding channel resolve failed for ${lookupThreadId}: ${summarizeDiscordError(err)}`);
|
|
@@ -634,7 +631,7 @@ function createThreadBindingManager(params) {
|
|
|
634
631
|
threadId,
|
|
635
632
|
targetKind,
|
|
636
633
|
targetSessionKey,
|
|
637
|
-
agentId: normalizeOptionalString(bindParams.agentId) ?? normalizeOptionalString(existingValue?.agentId) ??
|
|
634
|
+
agentId: normalizeOptionalString(bindParams.agentId) ?? normalizeOptionalString(existingValue?.agentId) ?? resolveSessionAgentIdStrict({
|
|
638
635
|
config: cfg,
|
|
639
636
|
sessionKey: targetSessionKey
|
|
640
637
|
}),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as setBindingRecord, O as shouldPersistBindingMutations, T as saveBindingsToDisk, c as ensureBindingsLoaded, t as BINDINGS_BY_THREAD_ID, y as resolveBindingIdsForSession } from "./thread-bindings.state-
|
|
1
|
+
import { E as setBindingRecord, O as shouldPersistBindingMutations, T as saveBindingsToDisk, c as ensureBindingsLoaded, t as BINDINGS_BY_THREAD_ID, y as resolveBindingIdsForSession } from "./thread-bindings.state-D8OMdk4O.js";
|
|
2
2
|
import { normalizeAccountId } from "openclaw/plugin-sdk/routing";
|
|
3
3
|
//#region extensions/discord/src/monitor/thread-bindings.session-shared.ts
|
|
4
4
|
function normalizeNonNegativeMs(raw) {
|
|
@@ -223,7 +223,7 @@ function shouldPersistBindingMutations() {
|
|
|
223
223
|
function toPersistedBindingRecord(record) {
|
|
224
224
|
const serialized = JSON.stringify(record);
|
|
225
225
|
if (!serialized) return { ...record };
|
|
226
|
-
return JSON.parse(serialized);
|
|
226
|
+
return normalizePersistedBinding(record.threadId, JSON.parse(serialized)) ?? { ...record };
|
|
227
227
|
}
|
|
228
228
|
function saveBindingsToDisk(params = {}) {
|
|
229
229
|
if (!params.force && !shouldPersistAnyBindingState()) return;
|
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
import { F as DiscordError, Ot as editChannel, Tt as createThread, jt as getChannelMessage, on as __exportAll, y as discord_exports } from "./retry-DqHCW6PV.js";
|
|
2
|
+
import { t as isDiscordThreadChannelType } from "./channel-type-CVLZyGYS.js";
|
|
3
|
+
import { d as resolveDiscordChannelParentSafe, l as resolveDiscordChannelNameSafe, s as resolveDiscordChannelIdSafe, u as resolveDiscordChannelParentIdSafe } from "./thread-bindings.manager-Clm77DBM.js";
|
|
4
|
+
import { a as formatDiscordMediaText, f as resolveDiscordChannelInfo, n as resolveDiscordForwardedMessagesTextFromSnapshots, p as resolveDiscordMessageChannelId, t as resolveDiscordEmbedText } from "./message-text-Ca8M6TU8.js";
|
|
5
|
+
import { buildAgentSessionKey } from "openclaw/plugin-sdk/routing";
|
|
6
|
+
import { normalizeOptionalString, normalizeOptionalStringifiedId } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
7
|
+
import { logVerbose } from "openclaw/plugin-sdk/runtime-env";
|
|
8
|
+
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
9
|
+
import { createReplyReferencePlanner } from "openclaw/plugin-sdk/reply-reference";
|
|
10
|
+
import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
|
|
11
|
+
import { resolveChannelModelOverride } from "openclaw/plugin-sdk/model-session-runtime";
|
|
12
|
+
import { generateConversationLabel } from "openclaw/plugin-sdk/reply-dispatch-runtime";
|
|
13
|
+
//#region extensions/discord/src/monitor/thread-title.ts
|
|
14
|
+
const DEFAULT_THREAD_TITLE_TIMEOUT_MS = 6e4;
|
|
15
|
+
const MAX_THREAD_TITLE_SOURCE_CHARS = 600;
|
|
16
|
+
const MAX_THREAD_TITLE_CHANNEL_NAME_CHARS = 120;
|
|
17
|
+
const MAX_THREAD_TITLE_CHANNEL_DESCRIPTION_CHARS = 320;
|
|
18
|
+
const DISCORD_THREAD_TITLE_SYSTEM_PROMPT = "Generate a concise Discord thread title (3-6 words) in sentence case: capitalize only the first word and words that are always capitalized. Return only the title. Use channel context when provided and avoid redundant channel-name words unless needed for clarity.";
|
|
19
|
+
async function generateThreadTitle(params) {
|
|
20
|
+
const sourceText = params.messageText.trim();
|
|
21
|
+
if (!sourceText) return null;
|
|
22
|
+
try {
|
|
23
|
+
const userMessage = buildThreadTitleCompletionUserMessage({
|
|
24
|
+
sourceText,
|
|
25
|
+
channelName: params.channelName,
|
|
26
|
+
channelDescription: params.channelDescription
|
|
27
|
+
});
|
|
28
|
+
const timeoutMs = resolveThreadTitleTimeoutMs(params.timeoutMs);
|
|
29
|
+
const generated = await generateConversationLabel({
|
|
30
|
+
cfg: params.cfg,
|
|
31
|
+
agentId: params.agentId,
|
|
32
|
+
userMessage,
|
|
33
|
+
prompt: DISCORD_THREAD_TITLE_SYSTEM_PROMPT,
|
|
34
|
+
...params.modelRef ? { modelRef: params.modelRef } : {},
|
|
35
|
+
timeoutMs,
|
|
36
|
+
maxLength: MAX_THREAD_TITLE_SOURCE_CHARS
|
|
37
|
+
});
|
|
38
|
+
return generated ? normalizeGeneratedThreadTitle(generated) : null;
|
|
39
|
+
} catch (err) {
|
|
40
|
+
logVerbose(`thread-title: title generation failed for agent ${params.agentId}: ${String(err)}`);
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function buildThreadTitleCompletionUserMessage(params) {
|
|
45
|
+
const sourceText = truncateThreadTitleSourceText(params.sourceText);
|
|
46
|
+
const channelName = normalizeTitleContextField(params.channelName, MAX_THREAD_TITLE_CHANNEL_NAME_CHARS);
|
|
47
|
+
const channelDescription = normalizeTitleContextField(params.channelDescription, MAX_THREAD_TITLE_CHANNEL_DESCRIPTION_CHARS);
|
|
48
|
+
const messageLines = [];
|
|
49
|
+
if (channelName) messageLines.push(`Channel: ${channelName}`);
|
|
50
|
+
if (channelDescription) messageLines.push(`Channel description: ${channelDescription}`);
|
|
51
|
+
messageLines.push(`Message:\n${sourceText}`);
|
|
52
|
+
return messageLines.join("\n\n");
|
|
53
|
+
}
|
|
54
|
+
function truncateThreadTitleSourceText(sourceText) {
|
|
55
|
+
if (sourceText.length <= MAX_THREAD_TITLE_SOURCE_CHARS) return sourceText;
|
|
56
|
+
return `${truncateUtf16Safe(sourceText, MAX_THREAD_TITLE_SOURCE_CHARS)}...`;
|
|
57
|
+
}
|
|
58
|
+
function resolveThreadTitleTimeoutMs(timeoutMs) {
|
|
59
|
+
return Math.max(100, Math.floor(timeoutMs ?? DEFAULT_THREAD_TITLE_TIMEOUT_MS));
|
|
60
|
+
}
|
|
61
|
+
function normalizeGeneratedThreadTitle(raw) {
|
|
62
|
+
const lines = raw.replace(/\r/g, "").split("\n");
|
|
63
|
+
let firstLine = "";
|
|
64
|
+
for (const line of lines) {
|
|
65
|
+
const trimmed = line.trim();
|
|
66
|
+
if (!trimmed) continue;
|
|
67
|
+
if (!firstLine && trimmed.startsWith("```")) continue;
|
|
68
|
+
firstLine = trimmed;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
return stripThreadTitleWrappers(firstLine);
|
|
72
|
+
}
|
|
73
|
+
function stripThreadTitleWrappers(raw) {
|
|
74
|
+
let current = raw.trim();
|
|
75
|
+
let previous = "";
|
|
76
|
+
while (current && current !== previous) {
|
|
77
|
+
previous = current;
|
|
78
|
+
current = current.replace(/^["'`]+|["'`]+$/g, "").trim();
|
|
79
|
+
current = stripBalancedWrapper(current, "**");
|
|
80
|
+
current = stripBalancedWrapper(current, "__");
|
|
81
|
+
current = stripBalancedWrapper(current, "*");
|
|
82
|
+
current = stripBalancedWrapper(current, "_");
|
|
83
|
+
current = stripBalancedWrapper(current, "~~");
|
|
84
|
+
}
|
|
85
|
+
return current;
|
|
86
|
+
}
|
|
87
|
+
function stripBalancedWrapper(text, marker) {
|
|
88
|
+
if (text.length < marker.length * 2 + 1) return text;
|
|
89
|
+
if (!text.startsWith(marker) || !text.endsWith(marker)) return text;
|
|
90
|
+
const inner = text.slice(marker.length, text.length - marker.length);
|
|
91
|
+
if (!inner || inner.includes(marker)) return text;
|
|
92
|
+
return inner;
|
|
93
|
+
}
|
|
94
|
+
function normalizeTitleContextField(raw, maxChars) {
|
|
95
|
+
const value = raw?.trim();
|
|
96
|
+
if (!value) return;
|
|
97
|
+
const singleLine = value.replace(/\s+/g, " ");
|
|
98
|
+
if (singleLine.length <= maxChars) return singleLine;
|
|
99
|
+
return `${truncateUtf16Safe(singleLine, maxChars)}...`;
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region extensions/discord/src/monitor/threading.cache.ts
|
|
103
|
+
const DISCORD_THREAD_STARTER_CACHE_TTL_MS = 300 * 1e3;
|
|
104
|
+
const DISCORD_THREAD_STARTER_NEGATIVE_CACHE_TTL_MS = 30 * 1e3;
|
|
105
|
+
const DISCORD_THREAD_STARTER_CACHE_MAX = 500;
|
|
106
|
+
const DISCORD_THREAD_STARTER_CACHE = /* @__PURE__ */ new Map();
|
|
107
|
+
function getCachedThreadStarter(key, now) {
|
|
108
|
+
const entry = DISCORD_THREAD_STARTER_CACHE.get(key);
|
|
109
|
+
if (!entry) return;
|
|
110
|
+
const ttlMs = entry.value.kind === "miss" ? DISCORD_THREAD_STARTER_NEGATIVE_CACHE_TTL_MS : DISCORD_THREAD_STARTER_CACHE_TTL_MS;
|
|
111
|
+
if (now < entry.updatedAt || now - entry.updatedAt >= ttlMs) {
|
|
112
|
+
DISCORD_THREAD_STARTER_CACHE.delete(key);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
DISCORD_THREAD_STARTER_CACHE.delete(key);
|
|
116
|
+
DISCORD_THREAD_STARTER_CACHE.set(key, entry);
|
|
117
|
+
return entry.value;
|
|
118
|
+
}
|
|
119
|
+
function setCachedThreadStarter(key, value, now) {
|
|
120
|
+
DISCORD_THREAD_STARTER_CACHE.delete(key);
|
|
121
|
+
DISCORD_THREAD_STARTER_CACHE.set(key, {
|
|
122
|
+
value,
|
|
123
|
+
updatedAt: now
|
|
124
|
+
});
|
|
125
|
+
pruneMapToMaxSize(DISCORD_THREAD_STARTER_CACHE, DISCORD_THREAD_STARTER_CACHE_MAX);
|
|
126
|
+
}
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region extensions/discord/src/monitor/threading.starter.ts
|
|
129
|
+
function isDiscordForumParentType(parentType) {
|
|
130
|
+
return parentType === discord_exports.ChannelType.GuildForum || parentType === discord_exports.ChannelType.GuildMedia;
|
|
131
|
+
}
|
|
132
|
+
const IN_FLIGHT_DISCORD_THREAD_STARTERS = /* @__PURE__ */ new Map();
|
|
133
|
+
function resolveDiscordThreadChannel(params) {
|
|
134
|
+
if (!params.isGuildMessage) return null;
|
|
135
|
+
const { message, channelInfo } = params;
|
|
136
|
+
const channel = "channel" in message ? message.channel : void 0;
|
|
137
|
+
if (channel && typeof channel === "object" && "isThread" in channel && typeof channel.isThread === "function" && channel.isThread()) return channel;
|
|
138
|
+
if (!isDiscordThreadChannelType(channelInfo?.type)) return null;
|
|
139
|
+
const messageChannelId = params.messageChannelId || resolveDiscordMessageChannelId({ message });
|
|
140
|
+
if (!messageChannelId) return null;
|
|
141
|
+
return {
|
|
142
|
+
id: messageChannelId,
|
|
143
|
+
name: channelInfo?.name ?? void 0,
|
|
144
|
+
parentId: channelInfo?.parentId ?? void 0,
|
|
145
|
+
parent: void 0,
|
|
146
|
+
ownerId: channelInfo?.ownerId ?? void 0
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
async function resolveDiscordThreadParentInfo(params) {
|
|
150
|
+
const { threadChannel, channelInfo, client } = params;
|
|
151
|
+
const parent = resolveDiscordChannelParentSafe(threadChannel);
|
|
152
|
+
let parentId = resolveDiscordChannelParentIdSafe(threadChannel) ?? resolveDiscordChannelIdSafe(parent) ?? channelInfo?.parentId ?? void 0;
|
|
153
|
+
if (!parentId && threadChannel.id) parentId = (await resolveDiscordChannelInfo(client, threadChannel.id))?.parentId ?? void 0;
|
|
154
|
+
if (!parentId) return {};
|
|
155
|
+
let parentName = resolveDiscordChannelNameSafe(parent);
|
|
156
|
+
const parentInfo = await resolveDiscordChannelInfo(client, parentId);
|
|
157
|
+
parentName = parentName ?? parentInfo?.name;
|
|
158
|
+
const parentType = parentInfo?.type;
|
|
159
|
+
return {
|
|
160
|
+
id: parentId,
|
|
161
|
+
name: parentName,
|
|
162
|
+
type: parentType
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
async function resolveDiscordThreadStarter(params) {
|
|
166
|
+
const messageChannelId = resolveDiscordThreadStarterMessageChannelId(params);
|
|
167
|
+
if (!messageChannelId) return null;
|
|
168
|
+
const cacheKey = `${params.accountId}:${params.channel.id}:${messageChannelId}`;
|
|
169
|
+
const cached = getCachedThreadStarter(cacheKey, Date.now());
|
|
170
|
+
if (cached) return cached.kind === "hit" ? cached.starter : null;
|
|
171
|
+
const inFlight = IN_FLIGHT_DISCORD_THREAD_STARTERS.get(cacheKey);
|
|
172
|
+
if (inFlight) return inFlight;
|
|
173
|
+
const pending = resolveDiscordThreadStarterUncached(params, cacheKey, messageChannelId);
|
|
174
|
+
IN_FLIGHT_DISCORD_THREAD_STARTERS.set(cacheKey, pending);
|
|
175
|
+
try {
|
|
176
|
+
return await pending;
|
|
177
|
+
} finally {
|
|
178
|
+
if (IN_FLIGHT_DISCORD_THREAD_STARTERS.get(cacheKey) === pending) IN_FLIGHT_DISCORD_THREAD_STARTERS.delete(cacheKey);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
async function resolveDiscordThreadStarterUncached(params, cacheKey, messageChannelId) {
|
|
182
|
+
const cacheMiss = () => {
|
|
183
|
+
setCachedThreadStarter(cacheKey, { kind: "miss" }, Date.now());
|
|
184
|
+
};
|
|
185
|
+
try {
|
|
186
|
+
const starter = await fetchDiscordThreadStarterMessage({
|
|
187
|
+
client: params.client,
|
|
188
|
+
messageChannelId,
|
|
189
|
+
threadId: params.channel.id
|
|
190
|
+
});
|
|
191
|
+
if (!starter) {
|
|
192
|
+
cacheMiss();
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
const payload = buildDiscordThreadStarterPayload({
|
|
196
|
+
starter,
|
|
197
|
+
resolveTimestampMs: params.resolveTimestampMs
|
|
198
|
+
});
|
|
199
|
+
if (!payload) {
|
|
200
|
+
cacheMiss();
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
setCachedThreadStarter(cacheKey, {
|
|
204
|
+
kind: "hit",
|
|
205
|
+
starter: payload
|
|
206
|
+
}, Date.now());
|
|
207
|
+
return payload;
|
|
208
|
+
} catch (error) {
|
|
209
|
+
if (isDiscordThreadStarterNegativeCacheError(error)) cacheMiss();
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
function isDiscordThreadStarterNegativeCacheError(error) {
|
|
214
|
+
return error instanceof DiscordError && (error.status === 403 || error.status === 404);
|
|
215
|
+
}
|
|
216
|
+
function resolveDiscordThreadStarterMessageChannelId(params) {
|
|
217
|
+
return isDiscordForumParentType(params.parentType) ? params.channel.id : params.parentId;
|
|
218
|
+
}
|
|
219
|
+
async function fetchDiscordThreadStarterMessage(params) {
|
|
220
|
+
const starter = await getChannelMessage(params.client.rest, params.messageChannelId, params.threadId);
|
|
221
|
+
return starter ? starter : null;
|
|
222
|
+
}
|
|
223
|
+
function buildDiscordThreadStarterPayload(params) {
|
|
224
|
+
const text = resolveDiscordThreadStarterText(params.starter);
|
|
225
|
+
if (!text) return null;
|
|
226
|
+
return {
|
|
227
|
+
text,
|
|
228
|
+
...resolveDiscordThreadStarterIdentity(params.starter),
|
|
229
|
+
timestamp: params.resolveTimestampMs(params.starter.timestamp) ?? void 0
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
function resolveDiscordThreadStarterText(starter) {
|
|
233
|
+
const content = normalizeOptionalString(starter.content) ?? "";
|
|
234
|
+
const embedText = resolveDiscordEmbedText(starter.embeds);
|
|
235
|
+
const forwardedText = resolveDiscordForwardedMessagesTextFromSnapshots(starter.message_snapshots);
|
|
236
|
+
return [content || embedText || forwardedText, formatDiscordMediaText({
|
|
237
|
+
attachments: starter.attachments ?? void 0,
|
|
238
|
+
stickers: starter.sticker_items ?? void 0
|
|
239
|
+
})].filter(Boolean).join("\n");
|
|
240
|
+
}
|
|
241
|
+
function resolveDiscordThreadStarterIdentity(starter) {
|
|
242
|
+
return {
|
|
243
|
+
author: resolveDiscordThreadStarterAuthor(starter),
|
|
244
|
+
authorId: starter.author?.id ?? void 0,
|
|
245
|
+
authorName: starter.author?.username ?? void 0,
|
|
246
|
+
authorTag: resolveDiscordThreadStarterAuthorTag(starter.author),
|
|
247
|
+
memberRoleIds: resolveDiscordThreadStarterRoleIds(starter.member)
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
function resolveDiscordThreadStarterAuthor(starter) {
|
|
251
|
+
return starter.member?.nick ?? starter.member?.displayName ?? resolveDiscordThreadStarterAuthorTag(starter.author) ?? starter.author?.username ?? starter.author?.id ?? "Unknown";
|
|
252
|
+
}
|
|
253
|
+
function resolveDiscordThreadStarterAuthorTag(author) {
|
|
254
|
+
if (!author?.username || !author.discriminator) return;
|
|
255
|
+
if (author.discriminator !== "0") return `${author.username}#${author.discriminator}`;
|
|
256
|
+
return author.username;
|
|
257
|
+
}
|
|
258
|
+
function resolveDiscordThreadStarterRoleIds(member) {
|
|
259
|
+
return Array.isArray(member?.roles) ? member.roles : void 0;
|
|
260
|
+
}
|
|
261
|
+
function resolveDiscordReplyTarget(opts) {
|
|
262
|
+
if (opts.replyToMode === "off") return;
|
|
263
|
+
const replyToId = normalizeOptionalString(opts.replyToId);
|
|
264
|
+
if (!replyToId) return;
|
|
265
|
+
if (opts.replyToMode === "all") return replyToId;
|
|
266
|
+
return opts.hasReplied ? void 0 : replyToId;
|
|
267
|
+
}
|
|
268
|
+
function sanitizeDiscordThreadName(rawName, fallbackId) {
|
|
269
|
+
return truncateUtf16Safe(truncateUtf16Safe(rawName.replace(/<@!?\d+>/g, "").replace(/<@&\d+>/g, "").replace(/<#\d+>/g, "").replace(/\s+/g, " ").trim() || `Thread ${fallbackId}`, 80), 100) || `Thread ${fallbackId}`;
|
|
270
|
+
}
|
|
271
|
+
function resolveDiscordReplyDeliveryPlan(params) {
|
|
272
|
+
const originalReplyTarget = params.replyTarget;
|
|
273
|
+
let deliverTarget = originalReplyTarget;
|
|
274
|
+
let replyTarget = originalReplyTarget;
|
|
275
|
+
if (params.createdThreadId) {
|
|
276
|
+
deliverTarget = `channel:${params.createdThreadId}`;
|
|
277
|
+
replyTarget = deliverTarget;
|
|
278
|
+
}
|
|
279
|
+
const allowReference = deliverTarget === originalReplyTarget;
|
|
280
|
+
const replyReference = createReplyReferencePlanner({
|
|
281
|
+
replyToMode: allowReference ? params.replyToMode : "off",
|
|
282
|
+
existingId: params.threadChannel ? params.messageId : void 0,
|
|
283
|
+
startId: params.messageId,
|
|
284
|
+
allowReference
|
|
285
|
+
});
|
|
286
|
+
return {
|
|
287
|
+
deliverTarget,
|
|
288
|
+
replyTarget,
|
|
289
|
+
replyReference
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
//#endregion
|
|
293
|
+
//#region extensions/discord/src/monitor/threading.auto-thread.ts
|
|
294
|
+
function resolveTrimmedDiscordMessageChannelId(params) {
|
|
295
|
+
return (params.messageChannelId || resolveDiscordMessageChannelId({ message: params.message })).trim();
|
|
296
|
+
}
|
|
297
|
+
function resolveDiscordAutoThreadContext(params) {
|
|
298
|
+
const createdThreadId = normalizeOptionalStringifiedId(params.createdThreadId) ?? "";
|
|
299
|
+
if (!createdThreadId) return null;
|
|
300
|
+
const parentSessionKey = normalizeOptionalString(params.parentSessionKey) ?? "";
|
|
301
|
+
if (!parentSessionKey) return null;
|
|
302
|
+
const threadSessionKey = params.groupScope === "main" ? parentSessionKey : buildAgentSessionKey({
|
|
303
|
+
agentId: params.agentId,
|
|
304
|
+
channel: params.channel,
|
|
305
|
+
peer: {
|
|
306
|
+
kind: "channel",
|
|
307
|
+
id: createdThreadId
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
const inheritsDistinctParent = threadSessionKey !== parentSessionKey;
|
|
311
|
+
return {
|
|
312
|
+
createdThreadId,
|
|
313
|
+
From: `${params.channel}:channel:${createdThreadId}`,
|
|
314
|
+
To: `channel:${createdThreadId}`,
|
|
315
|
+
OriginatingTo: `channel:${createdThreadId}`,
|
|
316
|
+
SessionKey: threadSessionKey,
|
|
317
|
+
...inheritsDistinctParent ? { ModelParentSessionKey: parentSessionKey } : {},
|
|
318
|
+
...inheritsDistinctParent && params.parentInheritanceEnabled === true ? { ParentSessionKey: parentSessionKey } : {}
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
async function resolveDiscordAutoThreadReplyPlan(params) {
|
|
322
|
+
const messageChannelId = resolveTrimmedDiscordMessageChannelId(params);
|
|
323
|
+
const originalReplyTarget = `channel:${params.threadChannel?.id ?? (messageChannelId || "unknown")}`;
|
|
324
|
+
const createdThreadId = await maybeCreateDiscordAutoThread({
|
|
325
|
+
client: params.client,
|
|
326
|
+
message: params.message,
|
|
327
|
+
messageChannelId: messageChannelId || void 0,
|
|
328
|
+
channel: params.channel,
|
|
329
|
+
isGuildMessage: params.isGuildMessage,
|
|
330
|
+
channelConfig: params.channelConfig,
|
|
331
|
+
threadChannel: params.threadChannel,
|
|
332
|
+
channelType: params.channelType,
|
|
333
|
+
channelName: params.channelName,
|
|
334
|
+
channelDescription: params.channelDescription,
|
|
335
|
+
baseText: params.baseText,
|
|
336
|
+
combinedBody: params.combinedBody,
|
|
337
|
+
cfg: params.cfg,
|
|
338
|
+
agentId: params.agentId
|
|
339
|
+
});
|
|
340
|
+
const deliveryPlan = resolveDiscordReplyDeliveryPlan({
|
|
341
|
+
replyTarget: originalReplyTarget,
|
|
342
|
+
replyToMode: params.replyToMode,
|
|
343
|
+
messageId: params.message.id,
|
|
344
|
+
threadChannel: params.threadChannel,
|
|
345
|
+
createdThreadId
|
|
346
|
+
});
|
|
347
|
+
const autoThreadContext = params.isGuildMessage ? resolveDiscordAutoThreadContext({
|
|
348
|
+
agentId: params.agentId,
|
|
349
|
+
channel: params.channel,
|
|
350
|
+
parentSessionKey: params.parentSessionKey,
|
|
351
|
+
createdThreadId,
|
|
352
|
+
groupScope: params.groupScope,
|
|
353
|
+
parentInheritanceEnabled: params.threadParentInheritanceEnabled
|
|
354
|
+
}) : null;
|
|
355
|
+
return {
|
|
356
|
+
...deliveryPlan,
|
|
357
|
+
createdThreadId,
|
|
358
|
+
autoThreadContext
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
async function maybeCreateDiscordAutoThread(params) {
|
|
362
|
+
if (!params.isGuildMessage) return;
|
|
363
|
+
if (!params.channelConfig?.autoThread) return;
|
|
364
|
+
if (params.threadChannel) return;
|
|
365
|
+
if (params.channelType === discord_exports.ChannelType.GuildForum || params.channelType === discord_exports.ChannelType.GuildMedia || params.channelType === discord_exports.ChannelType.GuildVoice || params.channelType === discord_exports.ChannelType.GuildStageVoice) return;
|
|
366
|
+
const messageChannelId = resolveTrimmedDiscordMessageChannelId(params);
|
|
367
|
+
if (!messageChannelId) return;
|
|
368
|
+
try {
|
|
369
|
+
try {
|
|
370
|
+
const existingThreadId = (await getChannelMessage(params.client.rest, messageChannelId, params.message.id))?.thread?.id;
|
|
371
|
+
if (existingThreadId) {
|
|
372
|
+
logVerbose(`discord: autoThread reusing existing thread ${existingThreadId} on ${messageChannelId}/${params.message.id}`);
|
|
373
|
+
return existingThreadId;
|
|
374
|
+
}
|
|
375
|
+
} catch {}
|
|
376
|
+
if (params.message.author?.bot) {
|
|
377
|
+
logVerbose(`discord: autoThread skipped for bot-authored message ${messageChannelId}/${params.message.id}`);
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
const rawThreadSource = params.baseText || params.combinedBody || "Thread";
|
|
381
|
+
const threadName = sanitizeDiscordThreadName(rawThreadSource, params.message.id);
|
|
382
|
+
const archiveDuration = params.channelConfig?.autoArchiveDuration ? Number(params.channelConfig.autoArchiveDuration) : 60;
|
|
383
|
+
const createdId = (await createThread(params.client.rest, messageChannelId, { body: {
|
|
384
|
+
name: threadName,
|
|
385
|
+
auto_archive_duration: archiveDuration
|
|
386
|
+
} }, params.message.id))?.id || "";
|
|
387
|
+
if (createdId && params.channelConfig?.autoThreadName === "generated" && params.cfg && params.agentId) {
|
|
388
|
+
const modelRef = resolveDiscordThreadTitleModelRef({
|
|
389
|
+
cfg: params.cfg,
|
|
390
|
+
channel: params.channel,
|
|
391
|
+
agentId: params.agentId,
|
|
392
|
+
threadId: createdId,
|
|
393
|
+
messageChannelId,
|
|
394
|
+
channelName: params.channelName
|
|
395
|
+
});
|
|
396
|
+
maybeRenameDiscordAutoThread({
|
|
397
|
+
client: params.client,
|
|
398
|
+
threadId: createdId,
|
|
399
|
+
currentName: threadName,
|
|
400
|
+
fallbackId: params.message.id,
|
|
401
|
+
sourceText: rawThreadSource,
|
|
402
|
+
modelRef,
|
|
403
|
+
channelName: params.channelName,
|
|
404
|
+
channelDescription: params.channelDescription,
|
|
405
|
+
cfg: params.cfg,
|
|
406
|
+
agentId: params.agentId
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
return createdId || void 0;
|
|
410
|
+
} catch (err) {
|
|
411
|
+
logVerbose(`discord: autoThread creation failed for ${messageChannelId}/${params.message.id}: ${String(err)}`);
|
|
412
|
+
try {
|
|
413
|
+
const existingThreadId = (await getChannelMessage(params.client.rest, messageChannelId, params.message.id))?.thread?.id || "";
|
|
414
|
+
if (existingThreadId) {
|
|
415
|
+
logVerbose(`discord: autoThread reusing existing thread ${existingThreadId} on ${messageChannelId}/${params.message.id}`);
|
|
416
|
+
return existingThreadId;
|
|
417
|
+
}
|
|
418
|
+
} catch {}
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
function resolveDiscordThreadTitleModelRef(params) {
|
|
423
|
+
const channel = params.channel?.trim();
|
|
424
|
+
if (!channel) return;
|
|
425
|
+
const parentSessionKey = buildAgentSessionKey({
|
|
426
|
+
agentId: params.agentId,
|
|
427
|
+
channel,
|
|
428
|
+
peer: {
|
|
429
|
+
kind: "channel",
|
|
430
|
+
id: params.messageChannelId
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
const channelLabel = params.channelName?.trim();
|
|
434
|
+
const groupChannel = channelLabel ? `#${channelLabel}` : void 0;
|
|
435
|
+
return resolveChannelModelOverride({
|
|
436
|
+
cfg: params.cfg,
|
|
437
|
+
channel,
|
|
438
|
+
groupId: params.threadId,
|
|
439
|
+
groupChatType: "channel",
|
|
440
|
+
groupChannel,
|
|
441
|
+
groupSubject: groupChannel,
|
|
442
|
+
parentSessionKey
|
|
443
|
+
})?.model;
|
|
444
|
+
}
|
|
445
|
+
async function maybeRenameDiscordAutoThread(params) {
|
|
446
|
+
try {
|
|
447
|
+
const fallbackName = sanitizeDiscordThreadName("", params.fallbackId);
|
|
448
|
+
const generated = await generateThreadTitle({
|
|
449
|
+
cfg: params.cfg,
|
|
450
|
+
agentId: params.agentId,
|
|
451
|
+
messageText: params.sourceText,
|
|
452
|
+
modelRef: params.modelRef,
|
|
453
|
+
channelName: params.channelName,
|
|
454
|
+
channelDescription: params.channelDescription
|
|
455
|
+
});
|
|
456
|
+
if (!generated) return;
|
|
457
|
+
const nextName = sanitizeDiscordThreadName(generated, params.fallbackId);
|
|
458
|
+
if (!nextName || nextName === params.currentName || nextName === fallbackName) return;
|
|
459
|
+
await editChannel(params.client.rest, params.threadId, { body: { name: nextName } });
|
|
460
|
+
} catch (err) {
|
|
461
|
+
logVerbose(`discord: autoThread rename failed for ${params.threadId}: ${String(err)}`);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
//#endregion
|
|
465
|
+
//#region extensions/discord/src/monitor/threading.ts
|
|
466
|
+
var threading_exports = /* @__PURE__ */ __exportAll({
|
|
467
|
+
maybeCreateDiscordAutoThread: () => maybeCreateDiscordAutoThread,
|
|
468
|
+
resolveDiscordAutoThreadContext: () => resolveDiscordAutoThreadContext,
|
|
469
|
+
resolveDiscordAutoThreadReplyPlan: () => resolveDiscordAutoThreadReplyPlan,
|
|
470
|
+
resolveDiscordReplyDeliveryPlan: () => resolveDiscordReplyDeliveryPlan,
|
|
471
|
+
resolveDiscordReplyTarget: () => resolveDiscordReplyTarget,
|
|
472
|
+
resolveDiscordThreadChannel: () => resolveDiscordThreadChannel,
|
|
473
|
+
resolveDiscordThreadParentInfo: () => resolveDiscordThreadParentInfo,
|
|
474
|
+
resolveDiscordThreadStarter: () => resolveDiscordThreadStarter,
|
|
475
|
+
sanitizeDiscordThreadName: () => sanitizeDiscordThreadName
|
|
476
|
+
});
|
|
477
|
+
//#endregion
|
|
478
|
+
export { resolveDiscordThreadStarter as a, resolveDiscordThreadParentInfo as i, resolveDiscordAutoThreadReplyPlan as n, sanitizeDiscordThreadName as o, resolveDiscordReplyTarget as r, threading_exports as t };
|