@openclaw/discord 2026.10.10 → 2026.11.5-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.setup/{account-inspect-X_Xlr42B.mjs → account-inspect-CSz5Qodj.mjs} +1 -1
- package/dist/.setup/{accounts-C18HNgge.mjs → accounts-DtjvhJUj.mjs} +9 -6
- package/dist/.setup/{active-turn-thread-route-BAc_Xik-.mjs → active-turn-thread-route-DkPnk2x8.mjs} +1 -2
- package/dist/.setup/{allow-list-D1ZGfhXh.mjs → allow-list-DahA0Jxh.mjs} +3 -150
- package/dist/.setup/{api-Bth1wKF9.mjs → api-Bp0HI4q3.mjs} +10 -20
- package/dist/.setup/{approval-handler.runtime-BAoEELJJ.mjs → approval-handler.runtime-Cy53ugTf.mjs} +80 -61
- package/dist/.setup/{approval-message-updates-Cks-MSCJ.mjs → approval-message-updates-DqOXxPss.mjs} +2 -2
- package/dist/.setup/{audit-Dw_rAZIz.mjs → audit-DoPKOfQE.mjs} +4 -4
- package/dist/.setup/{channel-BMpMAeQL.mjs → channel-Ds6iuNdy.mjs} +134 -201
- package/dist/.setup/channel-access-DhJhVrdZ.mjs +23 -0
- package/dist/.setup/channel.setup-BLt9dkIG.mjs +235 -0
- package/dist/.setup/{components-BvOWSPxr.mjs → components-WTfUxead.mjs} +208 -426
- package/dist/.setup/components.base-C5sAPHe4.mjs +31 -0
- package/dist/.setup/{config-schema-Coyq5wOr.mjs → config-schema-GX2yDgIH.mjs} +6 -7
- package/dist/.setup/{conversation-binding-route-DOPUZNYo.mjs → conversation-binding-route-CZdm-X5A.mjs} +2 -2
- package/dist/.setup/{directory-config-CIqVnQtn.mjs → directory-config-BXJuh9-J.mjs} +1 -1
- package/dist/.setup/{directory-live-DUuPEWub.mjs → directory-live-CEopeb8Q.mjs} +55 -62
- package/dist/.setup/{discord-eFlHX1Gn.mjs → discord-r79VFjJp.mjs} +1087 -1664
- package/dist/.setup/{doctor-Dty_Ossy.mjs → doctor-UfLW8nye.mjs} +3 -5
- package/dist/.setup/endpoint-runtime-BM3x-m6O.mjs +138 -0
- package/dist/.setup/guilds-DQucP5Tn.mjs +21 -0
- package/dist/.setup/{handle-action-DXY91jF-.mjs → handle-action-BarHOi-v.mjs} +15 -15
- package/dist/.setup/{handle-action.guild-admin-BvBCfhXF.mjs → handle-action.guild-admin-oRUb8p_O.mjs} +5 -5
- package/dist/.setup/listeners-CHgTENFu.mjs +46 -0
- package/dist/.setup/{live-policy-config-DO1Fk2hp.mjs → live-policy-config-EKp4O6zx.mjs} +2 -3
- package/dist/.setup/{message-handler-fL1j1NiR.mjs → message-handler-DUeT8Asf.mjs} +154 -113
- package/dist/.setup/{message-handler.preflight-DkjwNZAd.mjs → message-handler.preflight-C6TNtKW0.mjs} +30 -104
- package/dist/.setup/{message-handler.preflight-pluralkit-DR4BnvMU.mjs → message-handler.preflight-pluralkit-6E9TFmmN.mjs} +9 -22
- package/dist/.setup/{message-handler.process-ClOwIPDK.mjs → message-handler.process-D8_oQ5Cp.mjs} +256 -367
- package/dist/.setup/outbound-payload-DUsrFICb.mjs +445 -0
- package/dist/.setup/{outbound-session-route-TFBPPkoz.mjs → outbound-session-route-Cb8cv4Oi.mjs} +138 -86
- package/dist/.setup/{preflight-audio-CwtPIsvk.mjs → preflight-audio-r4BbaJxh.mjs} +1 -5
- package/dist/.setup/{presence-cache-CgutE4NN.mjs → presence-cache-B3xj3b0l.mjs} +1 -6
- package/dist/.setup/{probe-DNge7OEP.mjs → probe-BUmJyH35.mjs} +5 -9
- package/dist/.setup/{provider-BBDuE14w.mjs → provider-Dm2ERSxe.mjs} +3600 -4454
- package/dist/.setup/{provider-session.runtime-D8hMXXqJ.mjs → provider-session.runtime-DCIqDsIg.mjs} +3 -3
- package/dist/.setup/provider.runtime-DmxPGoUg.mjs +1 -0
- package/dist/.setup/proxy-fetch-B8cK6FLQ.mjs +29 -0
- package/dist/.setup/{realtime-session.runtime-cetognkp.mjs → realtime-session.runtime-WJL6NdwK.mjs} +43 -81
- package/dist/.setup/{receive-recovery-C77CVdGM.mjs → receive-recovery-DV_v5ROf.mjs} +13 -27
- package/dist/.setup/{resolve-allowlist-common-CI77288n.mjs → resolve-allowlist-common-C37fgnYG.mjs} +3 -12
- package/dist/.setup/{resolve-channels-DYc6-xgV.mjs → resolve-channels-CwpnQ7C2.mjs} +5 -4
- package/dist/.setup/{resolve-users-BQT7XWF2.mjs → resolve-users-D6jSwe8R.mjs} +4 -7
- package/dist/.setup/{runtime-CcijhTJT.mjs → runtime-B-PgPsGR.mjs} +6 -6
- package/dist/.setup/{runtime-CI0UJqeS.mjs → runtime-DhOMlnYS.mjs} +196 -235
- package/dist/.setup/{secret-config-contract-BdbCvqnM.mjs → secret-config-contract-CP6teHec.mjs} +4 -9
- package/dist/.setup/{send-Cbq-IVsS.mjs → send-DnLL6XoO.mjs} +149 -174
- package/dist/.setup/{send.components-BV6ucNpJ.mjs → send.components-xB43CksK.mjs} +61 -71
- package/dist/.setup/{send.outbound-CGhBhzjQ.mjs → send.outbound-B11X6TOE.mjs} +75 -129
- package/dist/.setup/{send.receipt-Dw-_r5Bx.mjs → send.receipt-CMteCIZS.mjs} +29 -31
- package/dist/.setup/{send.shared-D4MioxW_.mjs → send.shared-BcLLZBul.mjs} +38 -112
- package/dist/.setup/{sender-identity-DrN5c4ec.mjs → sender-identity-CGNpdJmb.mjs} +3 -9
- package/dist/.setup/setup-plugin-api-C6AMx3hu.mjs +2 -0
- package/dist/.setup/{shared-Bp0sxD5R.mjs → shared-BEYw16he.mjs} +8 -10
- package/dist/.setup/shared-interactive-DKBw4SNV.mjs +311 -0
- package/dist/.setup/{subagent-hooks-mQbDkvuD.mjs → subagent-hooks-DlYElpXa.mjs} +1 -1
- package/dist/.setup/{system-events-2zc2eGfF.mjs → system-events--Pk6y9aP.mjs} +2 -2
- package/dist/.setup/{target-resolver-CAHeVfmZ.mjs → target-resolver-Bo9EpGp_.mjs} +3 -3
- package/dist/.setup/{thread-bindings-Dg7X_ZXP.mjs → thread-bindings-BF-hr-bg.mjs} +12 -20
- package/dist/.setup/{thread-bindings.manager-DCDYksah.mjs → thread-bindings.manager-CQCkha5r.mjs} +22 -42
- package/dist/.setup/{thread-bindings.session-updates-C76plLS3.mjs → thread-bindings.session-updates-C2gJAj_I.mjs} +11 -18
- package/dist/.setup/{threading-l0UfrE6x.mjs → threading-HA9C2wYR.mjs} +68 -104
- package/dist/.setup/{timeouts-DTrUsJ_W.mjs → timeouts-CT9hnmo4.mjs} +1 -1
- package/dist/.setup/{transcripts-source-CGgOaWcu.mjs → transcripts-source-DzpzETZR.mjs} +102 -172
- package/dist/.setup/{voice-runtime-DY1EwDfi.mjs → voice-runtime-Bo_nsVvX.mjs} +231 -448
- package/dist/.source-module-urls/d6c089460280c5a04184542d6712e04545caeb1ebb290d3504377b4cc5e22fea.json +1 -1
- package/dist/account-inspect-api.js +1 -1
- package/dist/action-runtime-api.js +1 -1
- package/dist/activities-api.js +285 -337
- package/dist/api.js +16 -16
- package/dist/assets/embedded-app-sdk.mjs +1 -1
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/directory-contract-api.js +1 -1
- package/dist/runtime-api.js +22 -22
- package/dist/secret-contract-api.js +1 -1
- package/dist/setup-entry.js +1 -1
- package/dist/setup-plugin-api.js +1 -1
- package/dist/src/voice/audio-worker.runtime.js +56 -68
- package/dist/subagent-hooks-api.js +1 -1
- package/dist/transcripts-source-api.js +1 -1
- package/node_modules/@discord/embedded-app-sdk/output/lib/zod/lib/index.cjs +2 -3
- package/node_modules/@discord/embedded-app-sdk/output/lib/zod/lib/index.mjs +2 -3
- package/node_modules/@napi-rs/wasm-runtime/dist/fs.js +3339 -4021
- package/node_modules/@napi-rs/wasm-runtime/package.json +1 -1
- package/node_modules/@types/lodash/README.md +1 -1
- package/node_modules/@types/lodash/common/function.d.ts +2 -2
- package/node_modules/@types/lodash/package.json +2 -2
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/package.json +2 -2
- package/node_modules/@types/node/util.d.ts +6 -3
- package/node_modules/discord-api-types/package.json +4 -4
- package/node_modules/discord-api-types/rest/v10/index.d.ts +8 -0
- package/node_modules/discord-api-types/rest/v10/index.d.ts.map +1 -1
- package/node_modules/discord-api-types/rest/v10/index.js +8 -0
- package/node_modules/discord-api-types/rest/v10/index.js.map +1 -1
- package/node_modules/discord-api-types/rest/v10/oauth2.d.ts +26 -2
- package/node_modules/discord-api-types/rest/v10/oauth2.d.ts.map +1 -1
- package/node_modules/discord-api-types/rest/v9/index.d.ts +8 -0
- package/node_modules/discord-api-types/rest/v9/index.d.ts.map +1 -1
- package/node_modules/discord-api-types/rest/v9/index.js +8 -0
- package/node_modules/discord-api-types/rest/v9/index.js.map +1 -1
- package/node_modules/discord-api-types/rest/v9/oauth2.d.ts +26 -2
- package/node_modules/discord-api-types/rest/v9/oauth2.d.ts.map +1 -1
- package/node_modules/typebox/build/format/duration.d.mts +2 -2
- package/node_modules/typebox/build/format/duration.mjs +2 -2
- package/node_modules/typebox/build/format/idn_email.d.mts +1 -0
- package/node_modules/typebox/build/format/idn_email.mjs +1 -0
- package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -1
- package/node_modules/typebox/build/format/idn_hostname.mjs +1 -1
- package/node_modules/typebox/build/format/ipv4.d.mts +2 -2
- package/node_modules/typebox/build/format/ipv4.mjs +2 -2
- package/node_modules/typebox/build/format/ipv6.d.mts +1 -1
- package/node_modules/typebox/build/format/ipv6.mjs +1 -1
- package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
- package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
- package/node_modules/typebox/build/schema/build.mjs +1 -0
- package/node_modules/typebox/build/schema/engine/_unique.d.mts +4 -2
- package/node_modules/typebox/build/schema/engine/_unique.mjs +7 -3
- package/node_modules/typebox/build/schema/engine/additionalItems.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/additionalProperties.d.mts +0 -3
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +15 -17
- package/node_modules/typebox/build/schema/engine/contains.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/index.d.mts +1 -0
- package/node_modules/typebox/build/schema/engine/index.mjs +1 -0
- package/node_modules/typebox/build/schema/engine/items.mjs +7 -4
- package/node_modules/typebox/build/schema/engine/maxContains.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/minContains.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/oneOf.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/propertyNames.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs +2 -2
- package/node_modules/typebox/build/system/hashing/hash.mjs +63 -34
- package/node_modules/typebox/build/system/locale/en_US.mjs +2 -1
- package/node_modules/typebox/build/system/memory/assign.d.mts +2 -8
- package/node_modules/typebox/build/system/memory/assign.mjs +13 -6
- package/node_modules/typebox/build/system/memory/clone.d.mts +4 -5
- package/node_modules/typebox/build/system/memory/clone.mjs +8 -96
- package/node_modules/typebox/build/system/memory/create.d.mts +1 -5
- package/node_modules/typebox/build/system/memory/create.mjs +18 -13
- package/node_modules/typebox/build/system/memory/deep.d.mts +2 -0
- package/node_modules/typebox/build/system/memory/deep.mjs +108 -0
- package/node_modules/typebox/build/system/memory/discard.d.mts +1 -1
- package/node_modules/typebox/build/system/memory/discard.mjs +9 -8
- package/node_modules/typebox/build/system/memory/finalize.d.mts +4 -0
- package/node_modules/typebox/build/system/memory/finalize.mjs +30 -0
- package/node_modules/typebox/build/system/memory/keys.d.mts +2 -0
- package/node_modules/typebox/build/system/memory/keys.mjs +8 -0
- package/node_modules/typebox/build/system/memory/update.d.mts +1 -4
- package/node_modules/typebox/build/system/memory/update.mjs +43 -16
- package/node_modules/typebox/build/type/engine/call/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/call/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +2 -24
- package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +2 -29
- package/node_modules/typebox/build/type/engine/evaluate/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/evaluate/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +5 -1
- package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +6 -1
- package/node_modules/typebox/build/type/engine/evaluate/property.d.mts +30 -0
- package/node_modules/typebox/build/type/engine/evaluate/property.mjs +29 -0
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +1 -4
- package/node_modules/typebox/build/type/engine/object/from_intersect.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/object/from_intersect.mjs +2 -2
- package/node_modules/typebox/build/type/engine/object/from_union.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +1 -4
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +1 -4
- package/node_modules/typebox/build/type/engine/this/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/this/index.mjs +1 -0
- package/node_modules/typebox/build/value/clone/clone.d.mts +4 -3
- package/node_modules/typebox/build/value/clone/clone.mjs +5 -7
- package/node_modules/typebox/build/value/repair/from_cyclic.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_cyclic.mjs +6 -0
- package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +25 -14
- package/node_modules/typebox/package.json +1 -1
- package/node_modules/typebox/readme.md +1 -1
- package/node_modules/undici/docs/docs/api/Interceptors.md +15 -2
- package/node_modules/undici/lib/dispatcher/client-h2.js +78 -3
- package/node_modules/undici/lib/dispatcher/pool-base.js +20 -3
- package/node_modules/undici/package.json +3 -3
- package/node_modules/undici/types/api.d.ts +1 -1
- package/node_modules/undici/types/utility.d.ts +4 -4
- package/node_modules/uuid/package.json +17 -17
- package/node_modules/zod/package.json +1 -1
- package/node_modules/zod/src/v4/classic/tests/array.test.ts +27 -0
- package/node_modules/zod/src/v4/classic/tests/map.test.ts +7 -0
- package/node_modules/zod/src/v4/classic/tests/set.test.ts +6 -0
- package/node_modules/zod/src/v4/core/compile.ts +9 -0
- package/node_modules/zod/src/v4/core/schemas.ts +35 -1
- package/node_modules/zod/src/v4/core/util.ts +13 -0
- package/node_modules/zod/src/v4/core/versions.ts +1 -1
- package/node_modules/zod/v4/core/compile.cjs +8 -0
- package/node_modules/zod/v4/core/compile.js +8 -0
- package/node_modules/zod/v4/core/schemas.cjs +30 -0
- package/node_modules/zod/v4/core/schemas.d.cts +3 -1
- package/node_modules/zod/v4/core/schemas.d.ts +3 -1
- package/node_modules/zod/v4/core/schemas.js +30 -0
- package/node_modules/zod/v4/core/util.cjs +15 -0
- package/node_modules/zod/v4/core/util.d.cts +2 -0
- package/node_modules/zod/v4/core/util.d.ts +2 -0
- package/node_modules/zod/v4/core/util.js +14 -0
- package/node_modules/zod/v4/core/versions.cjs +1 -1
- package/node_modules/zod/v4/core/versions.js +1 -1
- package/openclaw.plugin.json +1 -31
- package/package.json +8 -8
- package/dist/.setup/channel-access-BPrWoEXM.mjs +0 -47
- package/dist/.setup/channel.setup-DVe7Y3Jf.mjs +0 -245
- package/dist/.setup/outbound-adapter-DWyAWBFh.mjs +0 -537
- package/dist/.setup/provider.runtime-BQ1z4Aq1.mjs +0 -1
- package/dist/.setup/setup-plugin-api-B4J6wmL1.mjs +0 -2
- package/dist/.setup/targets-BaklhOqq.mjs +0 -3
- package/node_modules/typebox/build/system/memory/freeze.d.mts +0 -4
- package/node_modules/typebox/build/system/memory/freeze.mjs +0 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.mjs";
|
|
2
|
-
import { d as unbindThreadBindingsBySessionKeyAsync, o as listThreadBindingsBySessionKey, s as listThreadBindingsBySessionKeyAsync } from "./thread-bindings-
|
|
2
|
+
import { d as unbindThreadBindingsBySessionKeyAsync, o as listThreadBindingsBySessionKey, s as listThreadBindingsBySessionKeyAsync } from "./thread-bindings-BF-hr-bg.mjs";
|
|
3
3
|
import { normalizeOptionalLowercaseString, normalizeOptionalStringifiedId } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
4
|
import { warnPluginSdkDeprecation } from "openclaw/plugin-sdk/thread-bindings-session-runtime";
|
|
5
5
|
// extensions/discord/src/subagent-hooks.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { t as discord_exports } from "./discord-r79VFjJp.mjs";
|
|
2
|
+
import { S as formatDiscordUserTag } from "./allow-list-DahA0Jxh.mjs";
|
|
3
3
|
// extensions/discord/src/monitor/system-events.ts
|
|
4
4
|
const SYSTEM_EVENT_ACTIONS = /* @__PURE__ */ new Map([
|
|
5
5
|
[discord_exports.MessageType.ChannelPinnedMessage, "pinned a message"],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.mjs";
|
|
2
|
-
import { l as resolveDiscordAccount, u as resolveDiscordAccountAllowFrom } from "./accounts-
|
|
3
|
-
import {
|
|
4
|
-
import { o as rememberDiscordDirectoryUser, r as listDiscordDirectoryPeersLive } from "./directory-live-
|
|
2
|
+
import { l as resolveDiscordAccount, u as resolveDiscordAccountAllowFrom } from "./accounts-DtjvhJUj.mjs";
|
|
3
|
+
import { a as allowFromContainsDiscordUserId } from "./send.receipt-CMteCIZS.mjs";
|
|
4
|
+
import { o as rememberDiscordDirectoryUser, r as listDiscordDirectoryPeersLive } from "./directory-live-CEopeb8Q.mjs";
|
|
5
5
|
import { t as parseDiscordTarget } from "./target-parsing-BiuhcK9Q.mjs";
|
|
6
6
|
import { buildMessagingTarget } from "openclaw/plugin-sdk/channel-targets";
|
|
7
7
|
// extensions/discord/src/target-resolver.ts
|
|
@@ -1,31 +1,23 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.mjs";
|
|
2
2
|
import { t as parseDiscordTarget } from "./target-parsing-BiuhcK9Q.mjs";
|
|
3
|
-
import "./
|
|
4
|
-
import {
|
|
5
|
-
import { c as resolveThreadBindingPersonaFromRecord, i as createNoopThreadBindingManager, n as getThreadBindingManager, o as resolveChannelIdForBinding, s as resolveThreadBindingPersona, t as createThreadBindingManager } from "./thread-bindings.manager-DCDYksah.mjs";
|
|
6
|
-
import { normalizeAccountId } from "openclaw/plugin-sdk/routing";
|
|
3
|
+
import { D as refreshUnboundThreadWebhookIdentity, F as resolveThreadBindingMaxAgeMs, M as resolveThreadBindingIdleTimeoutMs, N as resolveThreadBindingInactivityExpiresAt, P as resolveThreadBindingMaxAgeExpiresAt, S as ensureBindingsLoadedAsync, _ as MANAGERS_BY_ACCOUNT_ID, a as mutateBindingsForTargetSession, g as BINDINGS_BY_THREAD_ID, i as setThreadBindingMaxAgeBySessionKeyAsync, n as setThreadBindingIdleTimeoutBySessionKeyAsync, o as resolveBindingIdsForTargetSession, r as setThreadBindingMaxAgeBySessionKey, t as setThreadBindingIdleTimeoutBySessionKey, u as removeBindingRecordSync, w as getThreadBindingToken, x as ensureBindingsLoaded } from "./thread-bindings.session-updates-C2gJAj_I.mjs";
|
|
4
|
+
import { c as resolveThreadBindingPersonaFromRecord, i as createNoopThreadBindingManager, n as getThreadBindingManager, o as resolveChannelIdForBinding, s as resolveThreadBindingPersona, t as createThreadBindingManager } from "./thread-bindings.manager-CQCkha5r.mjs";
|
|
7
5
|
import { normalizeOptionalLowercaseString, normalizeOptionalString, normalizeOptionalStringifiedId, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
8
|
-
import {
|
|
6
|
+
import { runTasksWithConcurrency } from "openclaw/plugin-sdk/concurrency-runtime";
|
|
7
|
+
import { formatThreadBindingDurationLabel as formatThreadBindingDurationLabel$1, resolveThreadBindingIdleTimeoutMsForChannel, resolveThreadBindingIntroText, resolveThreadBindingIntroText as resolveThreadBindingIntroText$1, resolveThreadBindingMaxAgeMsForChannel, resolveThreadBindingThreadName, resolveThreadBindingThreadName as resolveThreadBindingThreadName$1, resolveThreadBindingsEnabled } from "openclaw/plugin-sdk/conversation-runtime";
|
|
9
8
|
import { warnPluginSdkDeprecation } from "openclaw/plugin-sdk/thread-bindings-session-runtime";
|
|
10
9
|
import { prepareAcpSessionEntryRead, readAcpSessionEntryAsync, rethrowIncognitoSessionError } from "openclaw/plugin-sdk/acp-runtime";
|
|
11
|
-
import { runTasksWithConcurrency } from "openclaw/plugin-sdk/concurrency-runtime";
|
|
12
10
|
// extensions/discord/src/monitor/thread-bindings.config.ts
|
|
13
11
|
function resolveDiscordThreadBindingIdleTimeoutMs(params) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return resolveThreadBindingIdleTimeoutMs({
|
|
18
|
-
channelIdleHoursRaw: account?.idleHours ?? root?.idleHours,
|
|
19
|
-
sessionIdleHoursRaw: params.cfg.session?.threadBindings?.idleHours
|
|
12
|
+
return resolveThreadBindingIdleTimeoutMsForChannel({
|
|
13
|
+
...params,
|
|
14
|
+
channel: "discord"
|
|
20
15
|
});
|
|
21
16
|
}
|
|
22
17
|
function resolveDiscordThreadBindingMaxAgeMs(params) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return resolveThreadBindingMaxAgeMs({
|
|
27
|
-
channelMaxAgeHoursRaw: account?.maxAgeHours ?? root?.maxAgeHours,
|
|
28
|
-
sessionMaxAgeHoursRaw: params.cfg.session?.threadBindings?.maxAgeHours
|
|
18
|
+
return resolveThreadBindingMaxAgeMsForChannel({
|
|
19
|
+
...params,
|
|
20
|
+
channel: "discord"
|
|
29
21
|
});
|
|
30
22
|
}
|
|
31
23
|
// extensions/discord/src/monitor/thread-bindings.lifecycle.ts
|
|
@@ -245,11 +237,11 @@ var thread_bindings_exports = /* @__PURE__ */ __exportAll({
|
|
|
245
237
|
reconcileAcpThreadBindingsOnStartup: () => reconcileAcpThreadBindingsOnStartup,
|
|
246
238
|
resolveDiscordThreadBindingIdleTimeoutMs: () => resolveDiscordThreadBindingIdleTimeoutMs,
|
|
247
239
|
resolveDiscordThreadBindingMaxAgeMs: () => resolveDiscordThreadBindingMaxAgeMs,
|
|
248
|
-
resolveThreadBindingIdleTimeoutMs: () => resolveThreadBindingIdleTimeoutMs
|
|
240
|
+
resolveThreadBindingIdleTimeoutMs: () => resolveThreadBindingIdleTimeoutMs,
|
|
249
241
|
resolveThreadBindingInactivityExpiresAt: () => resolveThreadBindingInactivityExpiresAt,
|
|
250
242
|
resolveThreadBindingIntroText: () => resolveThreadBindingIntroText$1,
|
|
251
243
|
resolveThreadBindingMaxAgeExpiresAt: () => resolveThreadBindingMaxAgeExpiresAt,
|
|
252
|
-
resolveThreadBindingMaxAgeMs: () => resolveThreadBindingMaxAgeMs
|
|
244
|
+
resolveThreadBindingMaxAgeMs: () => resolveThreadBindingMaxAgeMs,
|
|
253
245
|
resolveThreadBindingPersona: () => resolveThreadBindingPersona,
|
|
254
246
|
resolveThreadBindingPersonaFromRecord: () => resolveThreadBindingPersonaFromRecord,
|
|
255
247
|
resolveThreadBindingThreadName: () => resolveThreadBindingThreadName$1,
|
package/dist/.setup/{thread-bindings.manager-DCDYksah.mjs → thread-bindings.manager-CQCkha5r.mjs}
RENAMED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { p as canFallbackDiscordWebhookSend } from "./send.receipt-
|
|
2
|
+
import { N as createDiscordRestClient } from "./send.shared-BcLLZBul.mjs";
|
|
3
|
+
import { O as getChannel, q as withDiscordRequestAuthority, t as discord_exports, z as DiscordError } from "./discord-r79VFjJp.mjs";
|
|
4
|
+
import { w as isDiscordThreadChannelType } from "./allow-list-DahA0Jxh.mjs";
|
|
5
|
+
import { p as canFallbackDiscordWebhookSend } from "./send.receipt-CMteCIZS.mjs";
|
|
6
6
|
import { n as resolveDiscordChannelId } from "./target-parsing-BiuhcK9Q.mjs";
|
|
7
|
-
import { c as sendWebhookMessageDiscord, u as createThreadDiscord } from "./send-
|
|
8
|
-
import { t as sendMessageDiscord } from "./send.outbound-
|
|
9
|
-
import { A as
|
|
10
|
-
import {
|
|
7
|
+
import { c as sendWebhookMessageDiscord, u as createThreadDiscord } from "./send-DnLL6XoO.mjs";
|
|
8
|
+
import { t as sendMessageDiscord } from "./send.outbound-B11X6TOE.mjs";
|
|
9
|
+
import { A as resolveBindingRecordKey, C as forgetThreadBindingToken, D as refreshUnboundThreadWebhookIdentity, E as normalizeThreadBindingDurationMs, F as resolveThreadBindingMaxAgeMs, I as shouldDefaultPersist, L as toBindingRecordKey, M as resolveThreadBindingIdleTimeoutMs, O as rememberThreadBindingToken, R as toReusableWebhookKey, S as ensureBindingsLoadedAsync, T as normalizeTargetKind, _ as MANAGERS_BY_ACCOUNT_ID, b as THREAD_BINDING_TOUCH_PERSIST_MIN_INTERVAL_MS, c as drainThreadBindingAccountOperations, d as runThreadBindingAccountOperation, f as runThreadBindingMutation, g as BINDINGS_BY_THREAD_ID, h as updateBindingRecordSync, j as resolvePreparedThreadBindingLifecycle, k as resolveBindingIdsForSession, l as drainThreadBindingMutations, m as snapshotThreadBindingMetadata, p as shouldPersistAnyBindingState, s as commitBindingRecord, v as PERSIST_BY_ACCOUNT_ID, w as getThreadBindingToken, y as REUSABLE_WEBHOOKS_BY_ACCOUNT_CHANNEL } from "./thread-bindings.session-updates-C2gJAj_I.mjs";
|
|
10
|
+
import { t as resolveDiscordChannelInfoSafe } from "./channel-access-DhJhVrdZ.mjs";
|
|
11
|
+
import { coerceErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
11
12
|
import { createSubsystemLogger, logVerbose } from "openclaw/plugin-sdk/runtime-env";
|
|
12
13
|
import { normalizeAccountId } from "openclaw/plugin-sdk/routing";
|
|
13
|
-
import { normalizeOptionalString, normalizeOptionalStringifiedId } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
14
|
+
import { asNonArrayRecord, normalizeOptionalString, normalizeOptionalStringifiedId } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
14
15
|
import { getRuntimeConfigSnapshot } from "openclaw/plugin-sdk/runtime-config-snapshot";
|
|
15
|
-
import { parseStrictNonNegativeInteger as parseStrictNonNegativeInteger$1 } from "openclaw/plugin-sdk/number-runtime";
|
|
16
16
|
import { SYSTEM_MARK } from "openclaw/plugin-sdk/text-chunking";
|
|
17
17
|
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
18
18
|
import { resolveThreadBindingFarewellText, resolveThreadBindingThreadName, unregisterSessionBindingAdapter } from "openclaw/plugin-sdk/conversation-runtime";
|
|
@@ -49,16 +49,11 @@ function normalizeDiscordBindingChannelId(raw) {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
function summarizeDiscordError(err) {
|
|
52
|
-
if (err instanceof Error) return err
|
|
53
|
-
if (typeof err === "string" || typeof err === "number" || typeof err === "boolean" || typeof err === "bigint" || typeof err === "symbol") return String(err);
|
|
52
|
+
if (err instanceof Error || err != null && typeof err !== "object" && typeof err !== "function") return coerceErrorMessage(err);
|
|
54
53
|
return "error";
|
|
55
54
|
}
|
|
56
55
|
function isDiscordThreadGoneError(err) {
|
|
57
|
-
|
|
58
|
-
const candidate = err;
|
|
59
|
-
if ((parseStrictNonNegativeInteger$1(candidate.code) ?? parseStrictNonNegativeInteger$1(candidate.rawError?.code) ?? parseStrictNonNegativeInteger$1(candidate.body?.code) ?? parseStrictNonNegativeInteger$1(candidate.response?.body?.code) ?? parseStrictNonNegativeInteger$1(candidate.response?.data?.code)) === 10003) return true;
|
|
60
|
-
const status = parseStrictNonNegativeInteger$1(candidate.status) ?? parseStrictNonNegativeInteger$1(candidate.statusCode) ?? parseStrictNonNegativeInteger$1(candidate.response?.status);
|
|
61
|
-
return status === 404 || status === 403;
|
|
56
|
+
return err instanceof DiscordError && (err.discordCode === 10003 || err.status === 404 || err.status === 403);
|
|
62
57
|
}
|
|
63
58
|
async function maybeSendBindingMessage(params) {
|
|
64
59
|
const assertCurrent = params.assertCurrent;
|
|
@@ -109,12 +104,13 @@ async function createWebhookForChannel(params) {
|
|
|
109
104
|
accountId: params.accountId,
|
|
110
105
|
token: params.token
|
|
111
106
|
}).rest;
|
|
112
|
-
const
|
|
107
|
+
const rawCreated = await withDiscordRequestAuthority(assertCreateAllowed, () => {
|
|
113
108
|
assertCreateAllowed?.();
|
|
114
|
-
return
|
|
109
|
+
return rest.post(discord_exports.Routes.channelWebhooks(params.channelId), { body: { name: "OpenClaw Agents" } });
|
|
115
110
|
});
|
|
116
|
-
const
|
|
117
|
-
const
|
|
111
|
+
const created = asNonArrayRecord(rawCreated);
|
|
112
|
+
const webhookId = normalizeOptionalString(created.id) ?? "";
|
|
113
|
+
const webhookToken = normalizeOptionalString(created.token) ?? "";
|
|
118
114
|
if (!webhookId || !webhookToken) return {};
|
|
119
115
|
return {
|
|
120
116
|
webhookId,
|
|
@@ -126,21 +122,7 @@ async function createWebhookForChannel(params) {
|
|
|
126
122
|
}
|
|
127
123
|
}
|
|
128
124
|
function findReusableWebhook(params) {
|
|
129
|
-
|
|
130
|
-
const cached = REUSABLE_WEBHOOKS_BY_ACCOUNT_CHANNEL.get(reusableKey);
|
|
131
|
-
if (cached) return {
|
|
132
|
-
webhookId: cached.webhookId,
|
|
133
|
-
webhookToken: cached.webhookToken
|
|
134
|
-
};
|
|
135
|
-
for (const record of BINDINGS_BY_THREAD_ID.values()) {
|
|
136
|
-
if (record.accountId !== params.accountId || record.channelId !== params.channelId || !record.webhookId || !record.webhookToken) continue;
|
|
137
|
-
rememberReusableWebhook(record);
|
|
138
|
-
return {
|
|
139
|
-
webhookId: record.webhookId,
|
|
140
|
-
webhookToken: record.webhookToken
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
return {};
|
|
125
|
+
return REUSABLE_WEBHOOKS_BY_ACCOUNT_CHANNEL.get(toReusableWebhookKey(params)) ?? {};
|
|
144
126
|
}
|
|
145
127
|
async function resolveChannelIdForBinding(params) {
|
|
146
128
|
const explicit = normalizeDiscordBindingChannelId(params.channelId);
|
|
@@ -155,7 +137,7 @@ async function resolveChannelIdForBinding(params) {
|
|
|
155
137
|
}).rest;
|
|
156
138
|
const channel = await getChannel(rest, lookupThreadId);
|
|
157
139
|
const channelInfo = resolveDiscordChannelInfoSafe(channel);
|
|
158
|
-
const channelId = normalizeOptionalString(
|
|
140
|
+
const channelId = normalizeOptionalString(channelInfo.id) ?? "";
|
|
159
141
|
const type = channelInfo.type;
|
|
160
142
|
const parentId = normalizeOptionalString(channelInfo.parentId) ?? "";
|
|
161
143
|
if (parentId && isDiscordThreadChannelType(type)) return parentId;
|
|
@@ -317,7 +299,6 @@ function createNoopThreadBindingManager(accountIdRaw) {
|
|
|
317
299
|
getIdleTimeoutMs: () => DEFAULT_THREAD_BINDING_IDLE_TIMEOUT_MS,
|
|
318
300
|
getMaxAgeMs: () => 0,
|
|
319
301
|
getByThreadId: () => void 0,
|
|
320
|
-
getBySessionKey: () => void 0,
|
|
321
302
|
listBySessionKey: () => [],
|
|
322
303
|
listBindings: () => [],
|
|
323
304
|
touchThread: async () => null,
|
|
@@ -509,11 +490,11 @@ function createLoadedThreadBindingManager(params) {
|
|
|
509
490
|
text: resolveThreadBindingFarewellText({
|
|
510
491
|
reason: notification.reason,
|
|
511
492
|
farewellText: notification.farewellText,
|
|
512
|
-
idleTimeoutMs: resolveThreadBindingIdleTimeoutMs
|
|
493
|
+
idleTimeoutMs: resolveThreadBindingIdleTimeoutMs({
|
|
513
494
|
record: removed,
|
|
514
495
|
defaultIdleTimeoutMs: idleTimeoutMs
|
|
515
496
|
}),
|
|
516
|
-
maxAgeMs: resolveThreadBindingMaxAgeMs
|
|
497
|
+
maxAgeMs: resolveThreadBindingMaxAgeMs({
|
|
517
498
|
record: removed,
|
|
518
499
|
defaultMaxAgeMs: maxAgeMs
|
|
519
500
|
})
|
|
@@ -524,7 +505,6 @@ function createLoadedThreadBindingManager(params) {
|
|
|
524
505
|
getIdleTimeoutMs: () => idleTimeoutMs,
|
|
525
506
|
getMaxAgeMs: () => maxAgeMs,
|
|
526
507
|
getByThreadId: (threadId) => getBinding(threadId)?.record,
|
|
527
|
-
getBySessionKey: (targetSessionKey) => manager.listBySessionKey(targetSessionKey)[0],
|
|
528
508
|
listBySessionKey: (targetSessionKey) => resolveBindingIdsForSession({
|
|
529
509
|
targetSessionKey,
|
|
530
510
|
accountId
|
|
@@ -756,7 +736,7 @@ function createLoadedThreadBindingManager(params) {
|
|
|
756
736
|
sweepPromise = void 0;
|
|
757
737
|
});
|
|
758
738
|
}, THREAD_BINDINGS_SWEEP_INTERVAL_MS);
|
|
759
|
-
if (shouldDefaultPersist()) sweepTimer.unref
|
|
739
|
+
if (shouldDefaultPersist()) sweepTimer.unref();
|
|
760
740
|
}
|
|
761
741
|
const sessionBindingAdapter = createThreadBindingSessionAdapter({
|
|
762
742
|
accountId,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { J as stripUndefinedFields } from "./discord-r79VFjJp.mjs";
|
|
1
2
|
import { t as getDiscordRuntime } from "./runtime-DcBvHOm1.mjs";
|
|
2
3
|
import { logVerbose } from "openclaw/plugin-sdk/runtime-env";
|
|
3
4
|
import { normalizeAccountId, resolveAgentIdFromSessionKey } from "openclaw/plugin-sdk/routing";
|
|
@@ -6,6 +7,7 @@ import { resolveNonNegativeIntegerOption, resolveOptionalIntegerOption } from "o
|
|
|
6
7
|
import { resolveGlobalSingleton } from "openclaw/plugin-sdk/global-singleton";
|
|
7
8
|
import { createPluginStateErrorReporter } from "openclaw/plugin-sdk/plugin-state-runtime";
|
|
8
9
|
import { resolveThreadBindingExpiry, warnPluginSdkDeprecation } from "openclaw/plugin-sdk/thread-bindings-session-runtime";
|
|
10
|
+
import { enqueueKeyedTask } from "openclaw/plugin-sdk/keyed-async-queue";
|
|
9
11
|
import { recordOutboundMessageIdentity } from "openclaw/plugin-sdk/outbound-echo-runtime";
|
|
10
12
|
// extensions/discord/src/monitor/thread-bindings.state.ts
|
|
11
13
|
const THREAD_BINDINGS_STATE_KEY = Symbol.for("openclaw.discordThreadBindingsState");
|
|
@@ -26,7 +28,6 @@ function createThreadBindingsGlobalState() {
|
|
|
26
28
|
};
|
|
27
29
|
}
|
|
28
30
|
const THREAD_BINDINGS_STATE = resolveGlobalSingleton(THREAD_BINDINGS_STATE_KEY, createThreadBindingsGlobalState);
|
|
29
|
-
THREAD_BINDINGS_STATE.accountOperationTails ??= /* @__PURE__ */ new WeakMap();
|
|
30
31
|
const MANAGERS_BY_ACCOUNT_ID = THREAD_BINDINGS_STATE.managersByAccountId;
|
|
31
32
|
const BINDINGS_BY_THREAD_ID = THREAD_BINDINGS_STATE.bindingsByThreadId;
|
|
32
33
|
const BINDINGS_BY_SESSION_KEY = THREAD_BINDINGS_STATE.bindingsBySessionKey;
|
|
@@ -283,22 +284,15 @@ function snapshotThreadBindingJson(value) {
|
|
|
283
284
|
return serialized ? JSON.parse(serialized) : void 0;
|
|
284
285
|
}
|
|
285
286
|
function snapshotThreadBindingMetadata(input) {
|
|
286
|
-
return asOptionalObjectRecord(snapshotThreadBindingJson(input.metadata
|
|
287
|
-
}
|
|
288
|
-
function toPersistedBindingRecord(record) {
|
|
289
|
-
return normalizePersistedBinding(record.threadId, snapshotThreadBindingJson(record)) ?? { ...record };
|
|
287
|
+
return asOptionalObjectRecord(snapshotThreadBindingJson(input.metadata));
|
|
290
288
|
}
|
|
291
289
|
function runThreadBindingAccountOperation(managers, operation) {
|
|
292
290
|
if (managers.length === 0) return operation();
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
for (const manager of managers) tails.set(manager, settled);
|
|
298
|
-
settled.then(() => {
|
|
299
|
-
for (const manager of managers) if (tails.get(manager) === settled) tails.delete(manager);
|
|
291
|
+
return enqueueKeyedTask({
|
|
292
|
+
tails: THREAD_BINDINGS_STATE.accountOperationTails,
|
|
293
|
+
keys: managers,
|
|
294
|
+
task: operation
|
|
300
295
|
});
|
|
301
|
-
return result;
|
|
302
296
|
}
|
|
303
297
|
function drainThreadBindingAccountOperations(manager) {
|
|
304
298
|
return THREAD_BINDINGS_STATE.accountOperationTails.get(manager) ?? Promise.resolve();
|
|
@@ -333,8 +327,7 @@ async function commitBindingRecord(params) {
|
|
|
333
327
|
const store = openThreadBindingsStoreAsync();
|
|
334
328
|
for (const [key, record] of records) {
|
|
335
329
|
assertCurrent();
|
|
336
|
-
|
|
337
|
-
await store.register(key, persisted, { assertCurrent });
|
|
330
|
+
await store.register(key, stripUndefinedFields(record), { assertCurrent });
|
|
338
331
|
committedWrites += 1;
|
|
339
332
|
targetCommitted ||= key === params.bindingKey;
|
|
340
333
|
}
|
|
@@ -383,10 +376,10 @@ function persistBindingsSync(update) {
|
|
|
383
376
|
for (const [key, record] of BINDINGS_BY_THREAD_ID) if (key === update?.bindingKey) {
|
|
384
377
|
if (!store.update) throw new Error("Discord synchronous compatibility requires atomic state update");
|
|
385
378
|
const next = update.transform(record);
|
|
386
|
-
store.update(key, () =>
|
|
379
|
+
store.update(key, () => stripUndefinedFields(next));
|
|
387
380
|
updatedRecord = next;
|
|
388
381
|
if (next !== record) setBindingRecord(next);
|
|
389
|
-
} else store.register(key,
|
|
382
|
+
} else store.register(key, stripUndefinedFields(record));
|
|
390
383
|
for (const entry of store.entries()) if (!BINDINGS_BY_THREAD_ID.has(entry.key)) store.delete(entry.key);
|
|
391
384
|
THREAD_BINDINGS_STATE.loadedPersistentBindings = BINDINGS_BY_THREAD_ID.size > 0;
|
|
392
385
|
THREAD_BINDINGS_STATE.lastPersistedAtMs = Date.now();
|
|
@@ -520,4 +513,4 @@ const setThreadBindingMaxAgeBySessionKeyAsync = maxAgeSetters.setAsync;
|
|
|
520
513
|
const setThreadBindingIdleTimeoutBySessionKey = idleSetters.set;
|
|
521
514
|
/** @deprecated Use setThreadBindingMaxAgeBySessionKeyAsync; compatible through 2026-12-31, removed in the first January 2027 stable. */
|
|
522
515
|
const setThreadBindingMaxAgeBySessionKey = maxAgeSetters.set;
|
|
523
|
-
export {
|
|
516
|
+
export { resolveBindingRecordKey as A, forgetThreadBindingToken as C, refreshUnboundThreadWebhookIdentity as D, normalizeThreadBindingDurationMs as E, resolveThreadBindingMaxAgeMs as F, shouldDefaultPersist as I, toBindingRecordKey as L, resolveThreadBindingIdleTimeoutMs as M, resolveThreadBindingInactivityExpiresAt as N, rememberThreadBindingToken as O, resolveThreadBindingMaxAgeExpiresAt as P, toReusableWebhookKey as R, ensureBindingsLoadedAsync as S, normalizeTargetKind as T, MANAGERS_BY_ACCOUNT_ID as _, mutateBindingsForTargetSession as a, THREAD_BINDING_TOUCH_PERSIST_MIN_INTERVAL_MS as b, drainThreadBindingAccountOperations as c, runThreadBindingAccountOperation as d, runThreadBindingMutation as f, BINDINGS_BY_THREAD_ID as g, updateBindingRecordSync as h, setThreadBindingMaxAgeBySessionKeyAsync as i, resolvePreparedThreadBindingLifecycle as j, resolveBindingIdsForSession as k, drainThreadBindingMutations as l, snapshotThreadBindingMetadata as m, setThreadBindingIdleTimeoutBySessionKeyAsync as n, resolveBindingIdsForTargetSession as o, shouldPersistAnyBindingState as p, setThreadBindingMaxAgeBySessionKey as r, commitBindingRecord as s, setThreadBindingIdleTimeoutBySessionKey as t, removeBindingRecordSync as u, PERSIST_BY_ACCOUNT_ID as v, getThreadBindingToken as w, ensureBindingsLoaded as x, REUSABLE_WEBHOOKS_BY_ACCOUNT_CHANNEL as y };
|
|
@@ -1,56 +1,25 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { d as resolveDiscordReplyDeliveryPlan, f as resolveDiscordReplyTarget, g as sanitizeDiscordThreadName, h as resolveDiscordThreadStarter, j as resolveDiscordMessageChannelId, m as resolveDiscordThreadParentInfo, p as resolveDiscordThreadChannel } from "./transcripts-source-
|
|
2
|
+
import { T as createThread, k as getChannelMessage, t as discord_exports } from "./discord-r79VFjJp.mjs";
|
|
3
|
+
import { d as resolveDiscordReplyDeliveryPlan, f as resolveDiscordReplyTarget, g as sanitizeDiscordThreadName, h as resolveDiscordThreadStarter, j as resolveDiscordMessageChannelId, m as resolveDiscordThreadParentInfo, p as resolveDiscordThreadChannel } from "./transcripts-source-DzpzETZR.mjs";
|
|
4
4
|
import { logVerbose } from "openclaw/plugin-sdk/runtime-env";
|
|
5
5
|
import { buildAgentSessionKey } from "openclaw/plugin-sdk/routing";
|
|
6
6
|
import { normalizeOptionalString, normalizeOptionalStringifiedId } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
7
7
|
import { Routes } from "discord-api-types/v10";
|
|
8
|
-
import {
|
|
8
|
+
import { truncateWithMarker } from "openclaw/plugin-sdk/string-normalization-runtime";
|
|
9
9
|
import { resolveChannelModelOverride } from "openclaw/plugin-sdk/model-session-runtime";
|
|
10
10
|
import { generateConversationLabel } from "openclaw/plugin-sdk/reply-dispatch-runtime";
|
|
11
|
-
// extensions/discord/src/monitor/thread
|
|
11
|
+
// extensions/discord/src/monitor/threading.auto-thread.ts
|
|
12
12
|
const DEFAULT_THREAD_TITLE_TIMEOUT_MS = 6e4;
|
|
13
13
|
const MAX_THREAD_TITLE_SOURCE_CHARS = 600;
|
|
14
14
|
const MAX_THREAD_TITLE_CHANNEL_NAME_CHARS = 120;
|
|
15
15
|
const MAX_THREAD_TITLE_CHANNEL_DESCRIPTION_CHARS = 320;
|
|
16
16
|
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.";
|
|
17
|
-
async function generateThreadTitle(params) {
|
|
18
|
-
const sourceText = params.messageText.trim();
|
|
19
|
-
if (!sourceText) return null;
|
|
20
|
-
try {
|
|
21
|
-
const userMessage = buildThreadTitleCompletionUserMessage({
|
|
22
|
-
sourceText,
|
|
23
|
-
channelName: params.channelName,
|
|
24
|
-
channelDescription: params.channelDescription
|
|
25
|
-
});
|
|
26
|
-
const generated = await generateConversationLabel({
|
|
27
|
-
cfg: params.cfg,
|
|
28
|
-
agentId: params.agentId,
|
|
29
|
-
userMessage,
|
|
30
|
-
prompt: DISCORD_THREAD_TITLE_SYSTEM_PROMPT,
|
|
31
|
-
...params.modelRef ? { modelRef: params.modelRef } : {},
|
|
32
|
-
timeoutMs: Math.max(100, Math.floor(params.timeoutMs ?? DEFAULT_THREAD_TITLE_TIMEOUT_MS)),
|
|
33
|
-
maxLength: MAX_THREAD_TITLE_SOURCE_CHARS
|
|
34
|
-
});
|
|
35
|
-
return generated ? normalizeGeneratedThreadTitle(generated) : null;
|
|
36
|
-
} catch (err) {
|
|
37
|
-
logVerbose(`thread-title: title generation failed for agent ${params.agentId}: ${String(err)}`);
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
function buildThreadTitleCompletionUserMessage(params) {
|
|
42
|
-
const sourceText = truncateThreadTitleText(params.sourceText, MAX_THREAD_TITLE_SOURCE_CHARS);
|
|
43
|
-
const channelName = normalizeTitleContextField(params.channelName, MAX_THREAD_TITLE_CHANNEL_NAME_CHARS);
|
|
44
|
-
const channelDescription = normalizeTitleContextField(params.channelDescription, MAX_THREAD_TITLE_CHANNEL_DESCRIPTION_CHARS);
|
|
45
|
-
return [
|
|
46
|
-
channelName ? `Channel: ${channelName}` : void 0,
|
|
47
|
-
channelDescription ? `Channel description: ${channelDescription}` : void 0,
|
|
48
|
-
`Message:\n${sourceText}`
|
|
49
|
-
].filter(Boolean).join("\n\n");
|
|
50
|
-
}
|
|
51
17
|
function truncateThreadTitleText(text, maxChars) {
|
|
52
|
-
|
|
53
|
-
|
|
18
|
+
return truncateWithMarker(text, maxChars, {
|
|
19
|
+
marker: "...",
|
|
20
|
+
reserve: 0,
|
|
21
|
+
trimEnd: false
|
|
22
|
+
});
|
|
54
23
|
}
|
|
55
24
|
function normalizeGeneratedThreadTitle(raw) {
|
|
56
25
|
return stripThreadTitleWrappers(raw.replace(/\r/g, "").split("\n").find((line) => line.trim() && !line.trim().startsWith("```")) ?? "");
|
|
@@ -81,7 +50,6 @@ function normalizeTitleContextField(raw, maxChars) {
|
|
|
81
50
|
if (!value) return;
|
|
82
51
|
return truncateThreadTitleText(value.replace(/\s+/g, " "), maxChars);
|
|
83
52
|
}
|
|
84
|
-
// extensions/discord/src/monitor/threading.auto-thread.ts
|
|
85
53
|
function resolveTrimmedDiscordMessageChannelId(params) {
|
|
86
54
|
return (params.messageChannelId || resolveDiscordMessageChannelId({ message: params.message })).trim();
|
|
87
55
|
}
|
|
@@ -130,7 +98,6 @@ async function resolveDiscordAutoThreadReplyPlan(params) {
|
|
|
130
98
|
}) : null;
|
|
131
99
|
return {
|
|
132
100
|
...deliveryPlan,
|
|
133
|
-
createdThreadId,
|
|
134
101
|
autoThreadContext
|
|
135
102
|
};
|
|
136
103
|
}
|
|
@@ -142,10 +109,7 @@ async function maybeCreateDiscordAutoThread(params) {
|
|
|
142
109
|
const findExistingThread = async () => {
|
|
143
110
|
try {
|
|
144
111
|
const existingThreadId = (await getChannelMessage(params.client.rest, messageChannelId, params.message.id))?.thread?.id;
|
|
145
|
-
if (existingThreadId)
|
|
146
|
-
logVerbose(`discord: autoThread reusing existing thread ${existingThreadId} on ${messageChannelId}/${params.message.id}`);
|
|
147
|
-
return existingThreadId;
|
|
148
|
-
}
|
|
112
|
+
if (existingThreadId) return existingThreadId;
|
|
149
113
|
} catch {}
|
|
150
114
|
};
|
|
151
115
|
try {
|
|
@@ -162,27 +126,65 @@ async function maybeCreateDiscordAutoThread(params) {
|
|
|
162
126
|
name: threadName,
|
|
163
127
|
auto_archive_duration: archiveDuration
|
|
164
128
|
} }, params.message.id))?.id || "";
|
|
165
|
-
if (createdId && params.channelConfig?.autoThreadName === "generated"
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
maybeRenameDiscordAutoThread({
|
|
175
|
-
client: params.client,
|
|
176
|
-
threadId: createdId,
|
|
177
|
-
currentName: threadName,
|
|
178
|
-
fallbackId: params.message.id,
|
|
179
|
-
sourceText: rawThreadSource,
|
|
180
|
-
modelRef,
|
|
181
|
-
channelName: params.channelName,
|
|
182
|
-
channelDescription: params.channelDescription,
|
|
183
|
-
cfg: params.cfg,
|
|
184
|
-
agentId: params.agentId
|
|
129
|
+
if (createdId && params.channelConfig?.autoThreadName === "generated") {
|
|
130
|
+
const { client, channelName, channelDescription, cfg, agentId, channel } = params;
|
|
131
|
+
const parentSessionKey = buildAgentSessionKey({
|
|
132
|
+
agentId,
|
|
133
|
+
channel,
|
|
134
|
+
peer: {
|
|
135
|
+
kind: "channel",
|
|
136
|
+
id: messageChannelId
|
|
137
|
+
}
|
|
185
138
|
});
|
|
139
|
+
const channelLabel = channelName?.trim();
|
|
140
|
+
const groupChannel = channelLabel ? `#${channelLabel}` : void 0;
|
|
141
|
+
const modelRef = resolveChannelModelOverride({
|
|
142
|
+
cfg,
|
|
143
|
+
channel,
|
|
144
|
+
groupId: createdId,
|
|
145
|
+
groupChatType: "channel",
|
|
146
|
+
groupChannel,
|
|
147
|
+
groupSubject: groupChannel,
|
|
148
|
+
parentSessionKey
|
|
149
|
+
})?.model;
|
|
150
|
+
const fallbackId = params.message.id;
|
|
151
|
+
(async () => {
|
|
152
|
+
try {
|
|
153
|
+
const fallbackName = sanitizeDiscordThreadName("", fallbackId);
|
|
154
|
+
const sourceText = rawThreadSource.trim();
|
|
155
|
+
const rawChannelName = channelName;
|
|
156
|
+
const rawChannelDescription = channelDescription;
|
|
157
|
+
let generated = null;
|
|
158
|
+
if (sourceText) try {
|
|
159
|
+
const titleSourceText = truncateThreadTitleText(sourceText, MAX_THREAD_TITLE_SOURCE_CHARS);
|
|
160
|
+
const titleChannelName = normalizeTitleContextField(rawChannelName, MAX_THREAD_TITLE_CHANNEL_NAME_CHARS);
|
|
161
|
+
const titleChannelDescription = normalizeTitleContextField(rawChannelDescription, MAX_THREAD_TITLE_CHANNEL_DESCRIPTION_CHARS);
|
|
162
|
+
const userMessage = [
|
|
163
|
+
titleChannelName ? `Channel: ${titleChannelName}` : void 0,
|
|
164
|
+
titleChannelDescription ? `Channel description: ${titleChannelDescription}` : void 0,
|
|
165
|
+
`Message:\n${titleSourceText}`
|
|
166
|
+
].filter(Boolean).join("\n\n");
|
|
167
|
+
const label = await generateConversationLabel({
|
|
168
|
+
cfg,
|
|
169
|
+
agentId,
|
|
170
|
+
userMessage,
|
|
171
|
+
prompt: DISCORD_THREAD_TITLE_SYSTEM_PROMPT,
|
|
172
|
+
...modelRef ? { modelRef } : {},
|
|
173
|
+
timeoutMs: DEFAULT_THREAD_TITLE_TIMEOUT_MS,
|
|
174
|
+
maxLength: MAX_THREAD_TITLE_SOURCE_CHARS
|
|
175
|
+
});
|
|
176
|
+
generated = label ? normalizeGeneratedThreadTitle(label) : null;
|
|
177
|
+
} catch (err) {
|
|
178
|
+
logVerbose(`thread-title: title generation failed for agent ${agentId}: ${String(err)}`);
|
|
179
|
+
}
|
|
180
|
+
if (!generated) return;
|
|
181
|
+
const nextName = sanitizeDiscordThreadName(generated, fallbackId);
|
|
182
|
+
if (!nextName || nextName === threadName || nextName === fallbackName) return;
|
|
183
|
+
await client.rest.patch(Routes.channel(createdId), { body: { name: nextName } });
|
|
184
|
+
} catch (err) {
|
|
185
|
+
logVerbose(`discord: autoThread rename failed for ${createdId}: ${String(err)}`);
|
|
186
|
+
}
|
|
187
|
+
})();
|
|
186
188
|
}
|
|
187
189
|
return createdId || void 0;
|
|
188
190
|
} catch (err) {
|
|
@@ -190,44 +192,6 @@ async function maybeCreateDiscordAutoThread(params) {
|
|
|
190
192
|
return findExistingThread();
|
|
191
193
|
}
|
|
192
194
|
}
|
|
193
|
-
function resolveDiscordThreadTitleModelRef(params) {
|
|
194
|
-
const channel = params.channel?.trim();
|
|
195
|
-
if (!channel) return;
|
|
196
|
-
const parentSessionKey = buildAgentSessionKey({
|
|
197
|
-
agentId: params.agentId,
|
|
198
|
-
channel,
|
|
199
|
-
peer: {
|
|
200
|
-
kind: "channel",
|
|
201
|
-
id: params.messageChannelId
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
const channelLabel = params.channelName?.trim();
|
|
205
|
-
const groupChannel = channelLabel ? `#${channelLabel}` : void 0;
|
|
206
|
-
return resolveChannelModelOverride({
|
|
207
|
-
cfg: params.cfg,
|
|
208
|
-
channel,
|
|
209
|
-
groupId: params.threadId,
|
|
210
|
-
groupChatType: "channel",
|
|
211
|
-
groupChannel,
|
|
212
|
-
groupSubject: groupChannel,
|
|
213
|
-
parentSessionKey
|
|
214
|
-
})?.model;
|
|
215
|
-
}
|
|
216
|
-
async function maybeRenameDiscordAutoThread(params) {
|
|
217
|
-
try {
|
|
218
|
-
const fallbackName = sanitizeDiscordThreadName("", params.fallbackId);
|
|
219
|
-
const generated = await generateThreadTitle({
|
|
220
|
-
...params,
|
|
221
|
-
messageText: params.sourceText
|
|
222
|
-
});
|
|
223
|
-
if (!generated) return;
|
|
224
|
-
const nextName = sanitizeDiscordThreadName(generated, params.fallbackId);
|
|
225
|
-
if (!nextName || nextName === params.currentName || nextName === fallbackName) return;
|
|
226
|
-
await params.client.rest.patch(Routes.channel(params.threadId), { body: { name: nextName } });
|
|
227
|
-
} catch (err) {
|
|
228
|
-
logVerbose(`discord: autoThread rename failed for ${params.threadId}: ${String(err)}`);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
195
|
// extensions/discord/src/monitor/threading.ts
|
|
232
196
|
var threading_exports = /* @__PURE__ */ __exportAll({
|
|
233
197
|
maybeCreateDiscordAutoThread: () => maybeCreateDiscordAutoThread,
|
|
@@ -57,7 +57,7 @@ async function withAbortTimeout(params) {
|
|
|
57
57
|
reject(params.createTimeoutError());
|
|
58
58
|
controller.abort();
|
|
59
59
|
}, timeoutMs);
|
|
60
|
-
timeoutTimer.unref
|
|
60
|
+
timeoutTimer.unref();
|
|
61
61
|
});
|
|
62
62
|
try {
|
|
63
63
|
return await Promise.race([params.run(controller.signal), timeoutPromise]);
|