@openclaw/discord 2026.9.8 → 2026.10.1-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/.setup/{account-inspect-De8hOUxG.mjs → account-inspect-CjKqkDnH.mjs} +2 -2
- package/dist/.setup/{accounts-ChaMcixG.mjs → accounts-DXHCL8Zm.mjs} +9 -32
- package/dist/.setup/{active-turn-thread-route-fmHl1HNd.mjs → active-turn-thread-route-C4tp9noA.mjs} +5 -9
- package/dist/.setup/{activities-api-tvbsU2e3.mjs → activities-api-BL_hJ0JQ.mjs} +15 -18
- package/dist/.setup/{api-DVbJwZVt.mjs → api-_oznjffB.mjs} +1 -1
- package/dist/.setup/{approval-handler.runtime-DxCK2Rux.mjs → approval-handler.runtime-BilYSrRF.mjs} +22 -61
- package/dist/.setup/{approval-message-updates-BKFqavHZ.mjs → approval-message-updates-CgRwc2_Q.mjs} +2 -2
- package/dist/.setup/{audit-CLg9I71N.mjs → audit-DtvzxONM.mjs} +4 -4
- package/dist/.setup/{channel-access-C12aDZ0p.mjs → channel-access-BRp3Y-rF.mjs} +4 -17
- package/dist/.setup/{channel-type-DRCrEMss.mjs → channel-type-D1_b5UhU.mjs} +12 -16
- package/dist/.setup/{channel-DxlUVU9t.mjs → channel-z5lQMS_9.mjs} +79 -75
- package/dist/.setup/{channel.setup-CRo1GjV7.mjs → channel.setup-DBJtugJO.mjs} +14 -34
- package/dist/.setup/{components-Cq1PvIpN.mjs → components-CzXLR3QH.mjs} +56 -72
- package/dist/.setup/{config-schema-oxELUSDx.mjs → config-schema-CsemBDpS.mjs} +6 -17
- package/dist/.setup/{conversation-binding-route-Caz_XuFH.mjs → conversation-binding-route-Bi62ApSt.mjs} +1 -1
- package/dist/.setup/{directory-config-esqNn0Eo.mjs → directory-config-BH1LA-gi.mjs} +1 -1
- package/dist/.setup/{directory-live-DtKRHuGV.mjs → directory-live-C9xz7IPm.mjs} +10 -13
- package/dist/.setup/{discord-0xJYfdDD.mjs → discord-J7aRzq2Q.mjs} +101 -381
- package/dist/.setup/{doctor-BCl1H5tl.mjs → doctor-DxSAngJq.mjs} +31 -70
- package/dist/.setup/doctor-contract-Bg3NPAMw.mjs +137 -0
- package/dist/.setup/{handle-action-CUvQWnE7.mjs → handle-action-DlmFX-_G.mjs} +10 -11
- package/dist/.setup/{handle-action.guild-admin-Df-8gVle.mjs → handle-action.guild-admin-BnyqTczR.mjs} +67 -129
- package/dist/.setup/{live-policy-config-8Pv20CHc.mjs → live-policy-config-emmPNyh4.mjs} +1 -1
- package/dist/.setup/{message-handler-B-Jk4oDk.mjs → message-handler-BNToPZrx.mjs} +7 -6
- package/dist/.setup/{message-handler.preflight-v-__NSDq.mjs → message-handler.preflight-D0BcCyI7.mjs} +13 -23
- package/dist/.setup/{message-handler.preflight-pluralkit-CWLUBVcx.mjs → message-handler.preflight-pluralkit-D1g3eq0B.mjs} +5 -8
- package/dist/.setup/{message-handler.process-BNFFuChn.mjs → message-handler.process-CThRmCWK.mjs} +57 -96
- package/dist/.setup/{outbound-adapter-BobT-kse.mjs → outbound-adapter-BPq0c2wY.mjs} +11 -17
- package/dist/.setup/{outbound-session-route-zVGxxceg.mjs → outbound-session-route-DGPPKA0z.mjs} +21 -46
- package/dist/.setup/{presence-cache-Di3H3DIU.mjs → presence-cache-Dg3_dADn.mjs} +2 -4
- package/dist/.setup/{probe-LYrIHlBF.mjs → probe-DIRY8vh7.mjs} +17 -27
- package/dist/.setup/{provider-B_G5hASF.mjs → provider-D2OKMo0f.mjs} +273 -446
- package/dist/.setup/{provider-session.runtime-BYlTBFD2.mjs → provider-session.runtime-BupCTZQv.mjs} +3 -3
- package/dist/.setup/provider.runtime-BaW_JnfU.mjs +2 -0
- package/dist/.setup/{realtime-session.runtime-oUd9DOcz.mjs → realtime-session.runtime-D5RSC8Mm.mjs} +6 -8
- package/dist/.setup/{receive-recovery-CHPOsnLc.mjs → receive-recovery-GqF2PUN_.mjs} +1 -4
- package/dist/.setup/{resolve-allowlist-common-DPdRggu5.mjs → resolve-allowlist-common-DUYRrrVB.mjs} +5 -9
- package/dist/.setup/{resolve-channels-BFPNRmVv.mjs → resolve-channels--MUatisx.mjs} +3 -3
- package/dist/.setup/{resolve-users-0-aBuCy3.mjs → resolve-users-CxLcDmM0.mjs} +6 -9
- package/dist/.setup/{retry-pz_cSha2.mjs → retry-BKzO25k4.mjs} +27 -51
- package/dist/.setup/{runtime-sUksZ--Q.mjs → runtime-CerRBfaa.mjs} +2 -2
- package/dist/.setup/{runtime-FN000lxA.mjs → runtime-CwUA0RLr.mjs} +228 -255
- package/dist/.setup/{runtime-doctor-migrations-CshUGl36.mjs → runtime-doctor-migrations-BPV-R4G9.mjs} +6 -0
- package/dist/.setup/{security-audit-Cdaegq7C.mjs → security-audit-D42cp5N7.mjs} +21 -48
- package/dist/.setup/{send-CrfEI6Bs.mjs → send-2X7m2Zmw.mjs} +45 -58
- package/dist/.setup/{send.components-DxQAMfES.mjs → send.components-RqvgmCs3.mjs} +44 -90
- package/dist/.setup/{send.outbound-BISKnb-a.mjs → send.outbound-B4QHSEzm.mjs} +60 -98
- package/dist/.setup/{send.shared-DGFkbkQR.mjs → send.shared-BQIUh6Vn.mjs} +13 -20
- package/dist/.setup/{sender-identity-B9X5Vb9R.mjs → sender-identity-CooeYfAn.mjs} +1 -1
- package/dist/.setup/{session-key-normalization-wJgsKPNF.mjs → session-key-normalization-CCHGNSQw.mjs} +3 -9
- package/dist/.setup/setup-plugin-api-nn_giXvZ.mjs +3 -0
- package/dist/.setup/{shared-B3wZ4hN-.mjs → shared-CIJn6AEC.mjs} +7 -7
- package/dist/.setup/{subagent-hooks-nlUE9ow7.mjs → subagent-hooks-BYlVnxzy.mjs} +4 -9
- package/dist/.setup/{system-events-CdeZnvPV.mjs → system-events-CQ3if_pS.mjs} +2 -2
- package/dist/.setup/{target-resolver-BuLapkhy.mjs → target-resolver-Dzxf80Y3.mjs} +5 -13
- package/dist/.setup/targets-Lf8D55w-.mjs +3 -0
- package/dist/.setup/{thread-bindings-D7TfgjR_.mjs → thread-bindings-yNNlcUWE.mjs} +5 -6
- package/dist/.setup/{thread-bindings.manager-DN-NissX.mjs → thread-bindings.manager-plk0zJAW.mjs} +14 -20
- package/dist/.setup/{thread-bindings.session-updates-CshfKghV.mjs → thread-bindings.session-updates-C9aKtVs6.mjs} +295 -5
- package/dist/.setup/{timeouts-D86uWLt_.mjs → timeouts-pun7VJ02.mjs} +2 -15
- package/dist/.setup/{transcripts-source-p8EV179h.mjs → transcripts-source-CNWswry-.mjs} +31 -79
- package/dist/.setup/typing-CNlSKY5S.mjs +11 -0
- package/dist/.setup/{voice-runtime-B46rcwrG.mjs → voice-runtime-Bc75quiH.mjs} +62 -110
- package/dist/account-inspect-api.js +1 -1
- package/dist/action-runtime-api.js +1 -1
- package/dist/activities-api.js +1 -1
- package/dist/api.js +18 -18
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/control-ui/2afbdab1d3aa65a789d8a3eba666f4b1ec5df07073538fe30d6cf32093a1fb2d/index.js +1 -0
- package/dist/directory-contract-api.js +1 -1
- package/dist/doctor-contract-api.js +19 -128
- package/dist/index.js +1 -1
- package/dist/runtime-api.js +20 -21
- package/dist/security-audit-contract-api.js +1 -1
- package/dist/session-key-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 +6 -8
- package/dist/subagent-hooks-api.js +1 -1
- package/dist/transcripts-source-api.js +1 -1
- package/node_modules/libopus-wasm/CHANGELOG.md +8 -0
- package/node_modules/libopus-wasm/dist/discordjs.d.ts.map +1 -1
- package/node_modules/libopus-wasm/dist/discordjs.js +14 -2
- package/node_modules/libopus-wasm/dist/generated/libopus.generated.mjs +0 -0
- package/node_modules/libopus-wasm/dist/index.d.ts.map +1 -1
- package/node_modules/libopus-wasm/dist/index.js +55 -100
- package/node_modules/libopus-wasm/package.json +5 -5
- package/node_modules/undici/README.md +10 -1
- package/node_modules/undici/docs/docs/api/Agent.md +8 -8
- package/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +9 -6
- package/node_modules/undici/docs/docs/api/Dispatcher.md +9 -0
- package/node_modules/undici/docs/docs/api/Errors.md +25 -0
- package/node_modules/undici/docs/docs/api/Fetch.md +10 -0
- package/node_modules/undici/docs/docs/api/Interceptors.md +4 -3
- package/node_modules/undici/docs/docs/api/Pool.md +5 -6
- package/node_modules/undici/docs/docs/index.md +10 -1
- package/node_modules/undici/lib/api/readable.js +1 -2
- package/node_modules/undici/lib/core/request.js +23 -2
- package/node_modules/undici/lib/core/util.js +0 -39
- package/node_modules/undici/lib/dispatcher/client-h1.js +11 -4
- package/node_modules/undici/lib/dispatcher/client-h2.js +52 -8
- package/node_modules/undici/lib/dispatcher/client.js +6 -1
- package/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +21 -6
- package/node_modules/undici/lib/dispatcher/pool-base.js +63 -2
- package/node_modules/undici/lib/dispatcher/pool.js +90 -7
- package/node_modules/undici/lib/dispatcher/proxy-agent.js +16 -3
- package/node_modules/undici/lib/handler/deduplication-handler.js +24 -11
- package/node_modules/undici/lib/handler/redirect-handler.js +5 -0
- package/node_modules/undici/lib/handler/retry-handler.js +72 -13
- package/node_modules/undici/lib/interceptor/cache.js +4 -1
- package/node_modules/undici/lib/interceptor/decompress.js +236 -69
- package/node_modules/undici/lib/web/cache/cache.js +17 -8
- package/node_modules/undici/lib/web/cache/cachestorage.js +11 -5
- package/node_modules/undici/lib/web/cookies/index.js +19 -7
- package/node_modules/undici/lib/web/cookies/util.js +3 -1
- package/node_modules/undici/lib/web/eventsource/eventsource.js +25 -1
- package/node_modules/undici/lib/web/fetch/body.js +22 -15
- package/node_modules/undici/lib/web/fetch/data-url.js +6 -6
- package/node_modules/undici/lib/web/fetch/formdata.js +30 -36
- package/node_modules/undici/lib/web/fetch/headers.js +34 -31
- package/node_modules/undici/lib/web/fetch/index.js +46 -25
- package/node_modules/undici/lib/web/fetch/request.js +74 -79
- package/node_modules/undici/lib/web/fetch/response.js +43 -44
- package/node_modules/undici/lib/web/fetch/util.js +7 -7
- package/node_modules/undici/lib/web/infra/index.js +16 -1
- package/node_modules/undici/lib/web/webidl/index.js +2 -14
- package/node_modules/undici/lib/web/websocket/connection.js +33 -12
- package/node_modules/undici/lib/web/websocket/events.js +43 -26
- package/node_modules/undici/lib/web/websocket/receiver.js +2 -0
- package/node_modules/undici/lib/web/websocket/stream/websocketerror.js +13 -10
- package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +19 -4
- package/node_modules/undici/lib/web/websocket/websocket.js +44 -41
- package/node_modules/undici/package.json +1 -1
- package/node_modules/undici/types/diagnostics-channel.d.ts +2 -1
- package/node_modules/undici/types/interceptors.d.ts +1 -1
- package/node_modules/undici/types/webidl.d.ts +13 -7
- package/openclaw.plugin.json +6 -0
- package/package.json +12 -7
- package/dist/.setup/doctor-contract-CvvgwrrG.mjs +0 -409
- package/dist/.setup/model-picker-preference-primitives-BHT1LkR_.mjs +0 -37
- package/dist/.setup/provider.runtime-CUE3UxER.mjs +0 -2
- package/dist/.setup/setup-plugin-api-BQUBxbhe.mjs +0 -3
- package/dist/.setup/targets-0KUcEIYx.mjs +0 -3
- package/dist/.setup/thread-bindings.state-g6v9zAym.mjs +0 -331
- package/dist/.setup/typing-BiHCzBRu.mjs +0 -15
|
@@ -1,331 +0,0 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.mjs";
|
|
2
|
-
import { t as getDiscordRuntime } from "./runtime-DgnVQ7zW.mjs";
|
|
3
|
-
import { resolveGlobalSingleton } from "openclaw/plugin-sdk/global-singleton";
|
|
4
|
-
import { normalizeAccountId, resolveAgentIdFromSessionKey } from "openclaw/plugin-sdk/routing";
|
|
5
|
-
import { asFiniteNumber, normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeOptionalStringifiedId } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
6
|
-
import { logVerbose } from "openclaw/plugin-sdk/runtime-env";
|
|
7
|
-
import { recordOutboundMessageIdentity } from "openclaw/plugin-sdk/outbound-echo-runtime";
|
|
8
|
-
import { resolveThreadBindingExpiry } from "openclaw/plugin-sdk/thread-bindings-session-runtime";
|
|
9
|
-
//#region extensions/discord/src/monitor/thread-bindings.state.ts
|
|
10
|
-
var thread_bindings_state_exports = /* @__PURE__ */ __exportAll({
|
|
11
|
-
BINDINGS_BY_THREAD_ID: () => BINDINGS_BY_THREAD_ID,
|
|
12
|
-
MANAGERS_BY_ACCOUNT_ID: () => MANAGERS_BY_ACCOUNT_ID,
|
|
13
|
-
PERSIST_BY_ACCOUNT_ID: () => PERSIST_BY_ACCOUNT_ID,
|
|
14
|
-
REUSABLE_WEBHOOKS_BY_ACCOUNT_CHANNEL: () => REUSABLE_WEBHOOKS_BY_ACCOUNT_CHANNEL,
|
|
15
|
-
THREAD_BINDINGS_MAX_ENTRIES: () => THREAD_BINDINGS_MAX_ENTRIES,
|
|
16
|
-
THREAD_BINDINGS_NAMESPACE: () => THREAD_BINDINGS_NAMESPACE,
|
|
17
|
-
THREAD_BINDINGS_STATE: () => THREAD_BINDINGS_STATE,
|
|
18
|
-
THREAD_BINDING_TOUCH_PERSIST_MIN_INTERVAL_MS: () => THREAD_BINDING_TOUCH_PERSIST_MIN_INTERVAL_MS,
|
|
19
|
-
ensureBindingsLoaded: () => ensureBindingsLoaded,
|
|
20
|
-
ensureBindingsLoadedAsync: () => ensureBindingsLoadedAsync,
|
|
21
|
-
forgetThreadBindingToken: () => forgetThreadBindingToken,
|
|
22
|
-
getThreadBindingToken: () => getThreadBindingToken,
|
|
23
|
-
normalizePersistedBinding: () => normalizePersistedBinding,
|
|
24
|
-
normalizeTargetKind: () => normalizeTargetKind,
|
|
25
|
-
normalizeThreadBindingDurationMs: () => normalizeThreadBindingDurationMs,
|
|
26
|
-
openThreadBindingsStore: () => openThreadBindingsStore,
|
|
27
|
-
refreshUnboundThreadWebhookIdentity: () => refreshUnboundThreadWebhookIdentity,
|
|
28
|
-
rememberReusableWebhook: () => rememberReusableWebhook,
|
|
29
|
-
rememberThreadBindingToken: () => rememberThreadBindingToken,
|
|
30
|
-
removeBindingRecord: () => removeBindingRecord,
|
|
31
|
-
resolveBindingIdsForSession: () => resolveBindingIdsForSession,
|
|
32
|
-
resolveBindingRecordKey: () => resolveBindingRecordKey,
|
|
33
|
-
resolvePreparedThreadBindingLifecycle: () => resolvePreparedThreadBindingLifecycle,
|
|
34
|
-
resolveThreadBindingIdleTimeoutMs: () => resolveThreadBindingIdleTimeoutMs,
|
|
35
|
-
resolveThreadBindingInactivityExpiresAt: () => resolveThreadBindingInactivityExpiresAt,
|
|
36
|
-
resolveThreadBindingMaxAgeExpiresAt: () => resolveThreadBindingMaxAgeExpiresAt,
|
|
37
|
-
resolveThreadBindingMaxAgeMs: () => resolveThreadBindingMaxAgeMs,
|
|
38
|
-
setBindingRecord: () => setBindingRecord,
|
|
39
|
-
shouldDefaultPersist: () => shouldDefaultPersist,
|
|
40
|
-
toBindingRecordKey: () => toBindingRecordKey,
|
|
41
|
-
toReusableWebhookKey: () => toReusableWebhookKey
|
|
42
|
-
});
|
|
43
|
-
const THREAD_BINDINGS_STATE_KEY = Symbol.for("openclaw.discordThreadBindingsState");
|
|
44
|
-
function createThreadBindingsGlobalState() {
|
|
45
|
-
return {
|
|
46
|
-
managersByAccountId: /* @__PURE__ */ new Map(),
|
|
47
|
-
bindingsByThreadId: /* @__PURE__ */ new Map(),
|
|
48
|
-
bindingsBySessionKey: /* @__PURE__ */ new Map(),
|
|
49
|
-
tokensByAccountId: /* @__PURE__ */ new Map(),
|
|
50
|
-
reusableWebhooksByAccountChannel: /* @__PURE__ */ new Map(),
|
|
51
|
-
persistByAccountId: /* @__PURE__ */ new Map(),
|
|
52
|
-
loadedBindings: false,
|
|
53
|
-
loadedPersistentBindings: false,
|
|
54
|
-
persistenceAvailable: true,
|
|
55
|
-
lastPersistedAtMs: 0,
|
|
56
|
-
revision: 0,
|
|
57
|
-
mutationTail: Promise.resolve(),
|
|
58
|
-
accountOperationTails: /* @__PURE__ */ new WeakMap()
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
const THREAD_BINDINGS_STATE = resolveGlobalSingleton(THREAD_BINDINGS_STATE_KEY, createThreadBindingsGlobalState);
|
|
62
|
-
THREAD_BINDINGS_STATE.accountOperationTails ??= /* @__PURE__ */ new WeakMap();
|
|
63
|
-
const MANAGERS_BY_ACCOUNT_ID = THREAD_BINDINGS_STATE.managersByAccountId;
|
|
64
|
-
const BINDINGS_BY_THREAD_ID = THREAD_BINDINGS_STATE.bindingsByThreadId;
|
|
65
|
-
const BINDINGS_BY_SESSION_KEY = THREAD_BINDINGS_STATE.bindingsBySessionKey;
|
|
66
|
-
const TOKENS_BY_ACCOUNT_ID = THREAD_BINDINGS_STATE.tokensByAccountId;
|
|
67
|
-
const REUSABLE_WEBHOOKS_BY_ACCOUNT_CHANNEL = THREAD_BINDINGS_STATE.reusableWebhooksByAccountChannel;
|
|
68
|
-
const PERSIST_BY_ACCOUNT_ID = THREAD_BINDINGS_STATE.persistByAccountId;
|
|
69
|
-
const THREAD_BINDING_TOUCH_PERSIST_MIN_INTERVAL_MS = 15e3;
|
|
70
|
-
const THREAD_BINDINGS_NAMESPACE = "thread-bindings";
|
|
71
|
-
const THREAD_BINDINGS_MAX_ENTRIES = 1e4;
|
|
72
|
-
function rememberThreadBindingToken(params) {
|
|
73
|
-
const normalizedAccountId = normalizeAccountId(params.accountId);
|
|
74
|
-
const token = params.token?.trim();
|
|
75
|
-
if (!token) return;
|
|
76
|
-
TOKENS_BY_ACCOUNT_ID.set(normalizedAccountId, token);
|
|
77
|
-
}
|
|
78
|
-
function forgetThreadBindingToken(accountId) {
|
|
79
|
-
TOKENS_BY_ACCOUNT_ID.delete(normalizeAccountId(accountId));
|
|
80
|
-
}
|
|
81
|
-
function getThreadBindingToken(accountId) {
|
|
82
|
-
return TOKENS_BY_ACCOUNT_ID.get(normalizeAccountId(accountId));
|
|
83
|
-
}
|
|
84
|
-
function shouldDefaultPersist() {
|
|
85
|
-
return !(process.env.VITEST || false);
|
|
86
|
-
}
|
|
87
|
-
function openThreadBindingsStore() {
|
|
88
|
-
return getDiscordRuntime().state.openSyncKeyedStore({
|
|
89
|
-
namespace: THREAD_BINDINGS_NAMESPACE,
|
|
90
|
-
maxEntries: THREAD_BINDINGS_MAX_ENTRIES
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
function normalizeTargetKind(raw, targetSessionKey) {
|
|
94
|
-
if (raw === "subagent" || raw === "acp") return raw;
|
|
95
|
-
return targetSessionKey.includes(":subagent:") ? "subagent" : "acp";
|
|
96
|
-
}
|
|
97
|
-
function toBindingRecordKey(params) {
|
|
98
|
-
return `${normalizeAccountId(params.accountId)}:${params.threadId.trim()}`;
|
|
99
|
-
}
|
|
100
|
-
function resolveBindingRecordKey(params) {
|
|
101
|
-
const threadId = normalizeOptionalStringifiedId(params.threadId);
|
|
102
|
-
if (!threadId) return;
|
|
103
|
-
return toBindingRecordKey({
|
|
104
|
-
accountId: normalizeAccountId(params.accountId),
|
|
105
|
-
threadId
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
function normalizePersistedBinding(threadIdKey, raw) {
|
|
109
|
-
if (!raw || typeof raw !== "object") return null;
|
|
110
|
-
const value = raw;
|
|
111
|
-
const threadId = normalizeOptionalStringifiedId(value.threadId ?? threadIdKey);
|
|
112
|
-
const channelId = normalizeOptionalString(value.channelId) ?? "";
|
|
113
|
-
const targetSessionKey = normalizeOptionalString(value.targetSessionKey) ?? "";
|
|
114
|
-
if (!threadId || !channelId || !targetSessionKey) return null;
|
|
115
|
-
const accountId = normalizeAccountId(value.accountId);
|
|
116
|
-
const targetKind = normalizeTargetKind(value.targetKind, targetSessionKey);
|
|
117
|
-
const agentId = (normalizeOptionalString(value.agentId) ?? "") || resolveAgentIdFromSessionKey(targetSessionKey);
|
|
118
|
-
const label = normalizeOptionalString(value.label);
|
|
119
|
-
const webhookId = normalizeOptionalString(value.webhookId);
|
|
120
|
-
const webhookToken = normalizeOptionalString(value.webhookToken);
|
|
121
|
-
const boundBy = normalizeOptionalString(value.boundBy) ?? "system";
|
|
122
|
-
const boundAt = typeof value.boundAt === "number" && Number.isFinite(value.boundAt) ? Math.floor(value.boundAt) : Date.now();
|
|
123
|
-
const lastActivityAt = typeof value.lastActivityAt === "number" && Number.isFinite(value.lastActivityAt) ? Math.max(0, Math.floor(value.lastActivityAt)) : boundAt;
|
|
124
|
-
const idleTimeoutMs = typeof value.idleTimeoutMs === "number" && Number.isFinite(value.idleTimeoutMs) ? Math.max(0, Math.floor(value.idleTimeoutMs)) : void 0;
|
|
125
|
-
const maxAgeMs = typeof value.maxAgeMs === "number" && Number.isFinite(value.maxAgeMs) ? Math.max(0, Math.floor(value.maxAgeMs)) : void 0;
|
|
126
|
-
const metadata = value.metadata && typeof value.metadata === "object" ? { ...value.metadata } : void 0;
|
|
127
|
-
const record = {
|
|
128
|
-
accountId,
|
|
129
|
-
channelId,
|
|
130
|
-
threadId,
|
|
131
|
-
targetKind,
|
|
132
|
-
targetSessionKey,
|
|
133
|
-
agentId,
|
|
134
|
-
boundBy,
|
|
135
|
-
boundAt,
|
|
136
|
-
lastActivityAt
|
|
137
|
-
};
|
|
138
|
-
if (label !== void 0) record.label = label;
|
|
139
|
-
if (webhookId !== void 0) record.webhookId = webhookId;
|
|
140
|
-
if (webhookToken !== void 0) record.webhookToken = webhookToken;
|
|
141
|
-
if (idleTimeoutMs !== void 0) record.idleTimeoutMs = idleTimeoutMs;
|
|
142
|
-
if (maxAgeMs !== void 0) record.maxAgeMs = maxAgeMs;
|
|
143
|
-
if (metadata !== void 0) record.metadata = metadata;
|
|
144
|
-
return record;
|
|
145
|
-
}
|
|
146
|
-
function normalizeThreadBindingDurationMs(raw, defaultsTo) {
|
|
147
|
-
if (typeof raw !== "number" || !Number.isFinite(raw)) return defaultsTo;
|
|
148
|
-
const durationMs = Math.floor(raw);
|
|
149
|
-
if (durationMs < 0) return defaultsTo;
|
|
150
|
-
return durationMs;
|
|
151
|
-
}
|
|
152
|
-
function resolveThreadBindingIdleTimeoutMs(params) {
|
|
153
|
-
return Math.max(0, Math.floor(asFiniteNumber(params.record.idleTimeoutMs) ?? params.defaultIdleTimeoutMs));
|
|
154
|
-
}
|
|
155
|
-
function resolveThreadBindingMaxAgeMs(params) {
|
|
156
|
-
return Math.max(0, Math.floor(asFiniteNumber(params.record.maxAgeMs) ?? params.defaultMaxAgeMs));
|
|
157
|
-
}
|
|
158
|
-
function resolveTimestampExpiry(timestamp, durationMs) {
|
|
159
|
-
if (durationMs <= 0) return;
|
|
160
|
-
const at = Math.floor(timestamp);
|
|
161
|
-
return Number.isFinite(at) && at > 0 ? at + durationMs : void 0;
|
|
162
|
-
}
|
|
163
|
-
function resolvePreparedThreadBindingLifecycle(params) {
|
|
164
|
-
const idleTimeoutMs = resolveThreadBindingIdleTimeoutMs({
|
|
165
|
-
record: params.record,
|
|
166
|
-
defaultIdleTimeoutMs: params.idleTimeoutMs
|
|
167
|
-
});
|
|
168
|
-
const maxAgeMs = resolveThreadBindingMaxAgeMs({
|
|
169
|
-
record: params.record,
|
|
170
|
-
defaultMaxAgeMs: params.maxAgeMs
|
|
171
|
-
});
|
|
172
|
-
return {
|
|
173
|
-
idleTimeoutMs,
|
|
174
|
-
maxAgeMs,
|
|
175
|
-
...resolveThreadBindingExpiry({
|
|
176
|
-
inactivityExpiresAt: resolveTimestampExpiry(params.record.lastActivityAt, idleTimeoutMs),
|
|
177
|
-
maxAgeExpiresAt: resolveTimestampExpiry(params.record.boundAt, maxAgeMs)
|
|
178
|
-
})
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
function resolveThreadBindingInactivityExpiresAt(params) {
|
|
182
|
-
const idleTimeoutMs = resolveThreadBindingIdleTimeoutMs({
|
|
183
|
-
record: params.record,
|
|
184
|
-
defaultIdleTimeoutMs: params.defaultIdleTimeoutMs
|
|
185
|
-
});
|
|
186
|
-
return resolveTimestampExpiry(params.record.lastActivityAt, idleTimeoutMs);
|
|
187
|
-
}
|
|
188
|
-
function resolveThreadBindingMaxAgeExpiresAt(params) {
|
|
189
|
-
const maxAgeMs = resolveThreadBindingMaxAgeMs({
|
|
190
|
-
record: params.record,
|
|
191
|
-
defaultMaxAgeMs: params.defaultMaxAgeMs
|
|
192
|
-
});
|
|
193
|
-
return resolveTimestampExpiry(params.record.boundAt, maxAgeMs);
|
|
194
|
-
}
|
|
195
|
-
function linkSessionBinding(targetSessionKey, bindingKey) {
|
|
196
|
-
const key = targetSessionKey.trim();
|
|
197
|
-
if (!key) return;
|
|
198
|
-
const threads = BINDINGS_BY_SESSION_KEY.get(key) ?? /* @__PURE__ */ new Set();
|
|
199
|
-
threads.add(bindingKey);
|
|
200
|
-
BINDINGS_BY_SESSION_KEY.set(key, threads);
|
|
201
|
-
}
|
|
202
|
-
function unlinkSessionBinding(targetSessionKey, bindingKey) {
|
|
203
|
-
const key = targetSessionKey.trim();
|
|
204
|
-
if (!key) return;
|
|
205
|
-
const threads = BINDINGS_BY_SESSION_KEY.get(key);
|
|
206
|
-
if (!threads) return;
|
|
207
|
-
threads.delete(bindingKey);
|
|
208
|
-
if (threads.size === 0) BINDINGS_BY_SESSION_KEY.delete(key);
|
|
209
|
-
}
|
|
210
|
-
function toReusableWebhookKey(params) {
|
|
211
|
-
return `${normalizeLowercaseStringOrEmpty(params.accountId)}:${params.channelId.trim()}`;
|
|
212
|
-
}
|
|
213
|
-
function rememberReusableWebhook(record) {
|
|
214
|
-
const webhookId = record.webhookId?.trim();
|
|
215
|
-
const webhookToken = record.webhookToken?.trim();
|
|
216
|
-
if (!webhookId || !webhookToken) return;
|
|
217
|
-
const key = toReusableWebhookKey({
|
|
218
|
-
accountId: record.accountId,
|
|
219
|
-
channelId: record.channelId
|
|
220
|
-
});
|
|
221
|
-
REUSABLE_WEBHOOKS_BY_ACCOUNT_CHANNEL.set(key, {
|
|
222
|
-
webhookId,
|
|
223
|
-
webhookToken
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
function refreshUnboundThreadWebhookIdentity(record) {
|
|
227
|
-
const sourceId = record.webhookId?.trim();
|
|
228
|
-
if (!sourceId) return;
|
|
229
|
-
recordOutboundMessageIdentity({
|
|
230
|
-
channel: "discord",
|
|
231
|
-
accountId: record.accountId,
|
|
232
|
-
conversationId: record.threadId,
|
|
233
|
-
sourceId
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
function setBindingRecord(record) {
|
|
237
|
-
const bindingKey = toBindingRecordKey({
|
|
238
|
-
accountId: record.accountId,
|
|
239
|
-
threadId: record.threadId
|
|
240
|
-
});
|
|
241
|
-
const existing = BINDINGS_BY_THREAD_ID.get(bindingKey);
|
|
242
|
-
if (existing) unlinkSessionBinding(existing.targetSessionKey, bindingKey);
|
|
243
|
-
BINDINGS_BY_THREAD_ID.set(bindingKey, record);
|
|
244
|
-
THREAD_BINDINGS_STATE.revision += 1;
|
|
245
|
-
linkSessionBinding(record.targetSessionKey, bindingKey);
|
|
246
|
-
rememberReusableWebhook(record);
|
|
247
|
-
}
|
|
248
|
-
function removeBindingRecord(bindingKeyRaw) {
|
|
249
|
-
const key = bindingKeyRaw.trim();
|
|
250
|
-
if (!key) return null;
|
|
251
|
-
const existing = BINDINGS_BY_THREAD_ID.get(key);
|
|
252
|
-
if (!existing) return null;
|
|
253
|
-
BINDINGS_BY_THREAD_ID.delete(key);
|
|
254
|
-
THREAD_BINDINGS_STATE.revision += 1;
|
|
255
|
-
unlinkSessionBinding(existing.targetSessionKey, key);
|
|
256
|
-
return existing;
|
|
257
|
-
}
|
|
258
|
-
function beginBindingsLoad() {
|
|
259
|
-
THREAD_BINDINGS_STATE.loadedBindings = true;
|
|
260
|
-
BINDINGS_BY_THREAD_ID.clear();
|
|
261
|
-
THREAD_BINDINGS_STATE.revision += 1;
|
|
262
|
-
BINDINGS_BY_SESSION_KEY.clear();
|
|
263
|
-
REUSABLE_WEBHOOKS_BY_ACCOUNT_CHANNEL.clear();
|
|
264
|
-
THREAD_BINDINGS_STATE.loadedPersistentBindings = false;
|
|
265
|
-
}
|
|
266
|
-
function restoreBindings(entries) {
|
|
267
|
-
THREAD_BINDINGS_STATE.persistenceAvailable = true;
|
|
268
|
-
THREAD_BINDINGS_STATE.loadedPersistentBindings = entries.length > 0;
|
|
269
|
-
for (const entry of entries) {
|
|
270
|
-
const normalized = normalizePersistedBinding(entry.key, entry.value);
|
|
271
|
-
if (!normalized) continue;
|
|
272
|
-
setBindingRecord(normalized);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
function ensureBindingsLoaded() {
|
|
276
|
-
if (THREAD_BINDINGS_STATE.loadedBindings) return;
|
|
277
|
-
beginBindingsLoad();
|
|
278
|
-
let entries;
|
|
279
|
-
try {
|
|
280
|
-
entries = openThreadBindingsStore().entries();
|
|
281
|
-
} catch {
|
|
282
|
-
THREAD_BINDINGS_STATE.persistenceAvailable = false;
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
restoreBindings(entries);
|
|
286
|
-
}
|
|
287
|
-
async function loadBindingsAsync() {
|
|
288
|
-
let entries;
|
|
289
|
-
try {
|
|
290
|
-
entries = await getDiscordRuntime().state.openKeyedStore({
|
|
291
|
-
namespace: THREAD_BINDINGS_NAMESPACE,
|
|
292
|
-
maxEntries: THREAD_BINDINGS_MAX_ENTRIES
|
|
293
|
-
}).entries();
|
|
294
|
-
} catch {
|
|
295
|
-
if (!THREAD_BINDINGS_STATE.loadedBindings) {
|
|
296
|
-
beginBindingsLoad();
|
|
297
|
-
THREAD_BINDINGS_STATE.persistenceAvailable = false;
|
|
298
|
-
logVerbose("discord thread binding persistence unavailable; keeping bindings in memory");
|
|
299
|
-
}
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
if (THREAD_BINDINGS_STATE.loadedBindings) return;
|
|
303
|
-
beginBindingsLoad();
|
|
304
|
-
restoreBindings(entries);
|
|
305
|
-
}
|
|
306
|
-
async function ensureBindingsLoadedAsync() {
|
|
307
|
-
if (THREAD_BINDINGS_STATE.loadedBindings) return;
|
|
308
|
-
const loading = THREAD_BINDINGS_STATE.loadingBindings ??= loadBindingsAsync();
|
|
309
|
-
try {
|
|
310
|
-
await loading;
|
|
311
|
-
} finally {
|
|
312
|
-
if (THREAD_BINDINGS_STATE.loadingBindings === loading) delete THREAD_BINDINGS_STATE.loadingBindings;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
function resolveBindingIdsForSession(params) {
|
|
316
|
-
const key = params.targetSessionKey.trim();
|
|
317
|
-
if (!key) return [];
|
|
318
|
-
const ids = BINDINGS_BY_SESSION_KEY.get(key);
|
|
319
|
-
if (!ids) return [];
|
|
320
|
-
const out = [];
|
|
321
|
-
for (const bindingKey of ids.values()) {
|
|
322
|
-
const record = BINDINGS_BY_THREAD_ID.get(bindingKey);
|
|
323
|
-
if (!record) continue;
|
|
324
|
-
if (params.accountId && record.accountId !== params.accountId) continue;
|
|
325
|
-
if (params.targetKind && record.targetKind !== params.targetKind) continue;
|
|
326
|
-
out.push(bindingKey);
|
|
327
|
-
}
|
|
328
|
-
return out;
|
|
329
|
-
}
|
|
330
|
-
//#endregion
|
|
331
|
-
export { thread_bindings_state_exports as A, resolvePreparedThreadBindingLifecycle as C, resolveThreadBindingMaxAgeMs as D, resolveThreadBindingMaxAgeExpiresAt as E, toReusableWebhookKey as M, setBindingRecord as O, resolveBindingRecordKey as S, resolveThreadBindingInactivityExpiresAt as T, refreshUnboundThreadWebhookIdentity as _, THREAD_BINDINGS_MAX_ENTRIES as a, removeBindingRecord as b, THREAD_BINDING_TOUCH_PERSIST_MIN_INTERVAL_MS as c, forgetThreadBindingToken as d, getThreadBindingToken as f, openThreadBindingsStore as g, normalizeThreadBindingDurationMs as h, REUSABLE_WEBHOOKS_BY_ACCOUNT_CHANNEL as i, toBindingRecordKey as j, shouldDefaultPersist as k, ensureBindingsLoaded as l, normalizeTargetKind as m, MANAGERS_BY_ACCOUNT_ID as n, THREAD_BINDINGS_NAMESPACE as o, normalizePersistedBinding as p, PERSIST_BY_ACCOUNT_ID as r, THREAD_BINDINGS_STATE as s, BINDINGS_BY_THREAD_ID as t, ensureBindingsLoadedAsync as u, rememberReusableWebhook as v, resolveThreadBindingIdleTimeoutMs as w, resolveBindingIdsForSession as x, rememberThreadBindingToken as y };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.mjs";
|
|
2
|
-
import { St as sendChannelTyping } from "./discord-0xJYfdDD.mjs";
|
|
3
|
-
import { c as raceWithTimeout } from "./timeouts-D86uWLt_.mjs";
|
|
4
|
-
//#region extensions/discord/src/monitor/typing.ts
|
|
5
|
-
var typing_exports = /* @__PURE__ */ __exportAll({ sendTyping: () => sendTyping });
|
|
6
|
-
const DISCORD_TYPING_START_TIMEOUT_MS = 5e3;
|
|
7
|
-
async function sendTyping(params) {
|
|
8
|
-
if ((await raceWithTimeout({
|
|
9
|
-
promise: sendChannelTyping(params.rest, params.channelId).then(() => ({ kind: "sent" })),
|
|
10
|
-
timeoutMs: DISCORD_TYPING_START_TIMEOUT_MS,
|
|
11
|
-
onTimeout: () => ({ kind: "timeout" })
|
|
12
|
-
})).kind === "timeout") throw new Error(`discord typing start timed out after ${DISCORD_TYPING_START_TIMEOUT_MS}ms`);
|
|
13
|
-
}
|
|
14
|
-
//#endregion
|
|
15
|
-
export { typing_exports as n, sendTyping as t };
|