@openclaw/matrix 2026.5.14-beta.1 → 2026.5.16-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/api.js +4 -4
- package/dist/{approval-handler.runtime-DcgDdi8L.js → approval-handler.runtime--UYE3D2j.js} +5 -6
- package/dist/{approval-ids-DoC2z7tR.js → approval-ids-D6IQvvRE.js} +1 -1
- package/dist/{approval-reaction-auth-BY5VFY-q.js → approval-reaction-auth-99PRu7rF.js} +2 -2
- package/dist/{channel-eRrwLDE9.js → channel-CwN56Pko.js} +285 -26
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel.runtime-CsQesLGI.js → channel.runtime-9qwvlUwp.js} +8 -8
- package/dist/{cli-DAMPUa3J.js → cli-BeWdjXLV.js} +15 -17
- package/dist/{cli-metadata-Bt5SrlLo.js → cli-metadata-B2_76YSe.js} +1 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/{client-DrmLRQnw.js → client-D6fFVbNM.js} +2 -2
- package/dist/{client-bootstrap-Ba68NvZB.js → client-bootstrap-DBwUKgC3.js} +3 -3
- package/dist/{client-DBDvsx0D.js → client-oci1tD6-.js} +4 -5
- package/dist/{account-config-LVxGiX7e.js → config-paths-msaDGRh6.js} +18 -1
- package/dist/{config-schema-DOKrNEs_.js → config-schema-BPCzSyjT.js} +70 -4
- package/dist/contract-api.js +5 -6
- package/dist/{create-client-ChlpNpAA.js → create-client-BahCtURn.js} +4 -4
- package/dist/{credentials-DV6fWXhC.js → credentials-DK0lK9cZ.js} +1 -1
- package/dist/{credentials-write.runtime-zniTq-Gr.js → credentials-write.runtime-DhPvBU-C.js} +1 -1
- package/dist/{crypto-runtime-BevaUxax.js → crypto-runtime-B-SPS5mv.js} +5 -5
- package/dist/{directory-live-Btsr0yok.js → directory-live-BCfx1C0G.js} +3 -3
- package/dist/{doctor-qL-bgDwE.js → doctor-KuNYX5N3.js} +3 -3
- package/dist/doctor-contract-api.js +1 -1
- package/dist/{draft-stream-B-hyLmMw.js → draft-stream-BayHVmtO.js} +1 -2
- package/dist/{encryption-guidance-BPi3A_m3.js → encryption-guidance-1QoIvd-g.js} +1 -1
- package/dist/{http-client-C7AeVJay.js → http-client-DS3UoC_p.js} +1 -1
- package/dist/index.js +2 -2
- package/dist/{legacy-crypto-inspector-C4VpBdDV.js → legacy-crypto-inspector-_gWJGVQ_.js} +1 -1
- package/dist/{legacy-crypto-restore-Biw-w2ng.js → legacy-crypto-restore-B9eF1gob.js} +1 -1
- package/dist/{logging-DZHSPP5N.js → logging-bJ8EEe1G.js} +1 -1
- package/dist/{matrix-migration.runtime-CDasos7a.js → matrix-migration.runtime-Cf_wX9mk.js} +3 -3
- package/dist/{media-text-BLL8-Dr3.js → media-text-4h4YwCGC.js} +1 -1
- package/dist/{messages-BJi_jdEA.js → messages-BKTEUSwJ.js} +5 -5
- package/dist/{migration-snapshot.runtime-CKHE3xF9.js → migration-snapshot.runtime-C7yiKWS7.js} +1 -1
- package/dist/{monitor-COvHRaUQ.js → monitor-DPJO3wS1.js} +35 -35
- package/dist/plugin-entry.handlers.runtime.js +2 -2
- package/dist/probe.runtime-zExLz3Ek.js +3 -0
- package/dist/{profile-update-DK5rfmA-.js → profile-update-BAAflurI.js} +2 -3
- package/dist/{reaction-events-Cfvkp-A-.js → reaction-events-Dimh8FUE.js} +6 -6
- package/dist/{resolve-targets-ZSM4KKln.js → resolve-targets-DPqngj4V.js} +1 -1
- package/dist/{resolver.runtime-m_D8JSm3.js → resolver.runtime-C0RDK0VW.js} +1 -1
- package/dist/{route-D6rg-iXN.js → route-R-ajT21_.js} +1 -1
- package/dist/{runtime-api-DTKcXOhp.js → runtime-api-C-QeChQj.js} +1 -1
- package/dist/runtime-api.js +1 -1
- package/dist/runtime-heavy-api.js +2 -2
- package/dist/{sdk-BLBGvKEe.js → sdk-BwfNtBhM.js} +301 -13
- package/dist/secret-contract-api.js +1 -1
- package/dist/{send-D651usmb.js → send-CdoJ1pZY.js} +323 -6
- package/dist/{setup-bootstrap-DT2Gj9hX.js → setup-bootstrap-krQU60Az.js} +4 -4
- package/dist/setup-core-CgOV8zmh.js +675 -0
- package/dist/setup-plugin-api.js +3 -4
- package/dist/{setup-surface-KzA9__US.js → setup-surface-BgUaEySF.js} +7 -10
- package/dist/{config-xD5Y8nFT.js → shared-BlXw87Kp.js} +199 -9
- package/dist/{logger-CnZRVrux.js → startup-abort-br7BZHJQ.js} +32 -1
- package/dist/{startup-verification-Demyp0bP.js → startup-verification-CTfhD7V_.js} +2 -2
- package/dist/{storage-tC3ujLiW.js → storage-HI1nL3im.js} +1 -1
- package/dist/{subagent-hooks-DQbyqq9V.js → subagent-hooks-api-BgQgDwAS.js} +22 -1
- package/dist/subagent-hooks-api.js +1 -22
- package/dist/test-api.js +2 -2
- package/dist/thread-binding-api.js +1 -1
- package/dist/{thread-bindings-DHUszTA0.js → thread-bindings-8AyQOYDT.js} +2 -2
- package/dist/{tool-actions.runtime-Bn8bvkQN.js → tool-actions.runtime-BuCnleVD.js} +9 -9
- package/dist/{verification-BJT2k9TI.js → verification-DvC37Z_y.js} +2 -2
- package/package.json +6 -6
- package/dist/accounts--0L_EuMK.js +0 -130
- package/dist/allowlist-sTzpCn5d.js +0 -68
- package/dist/config-paths-nsVaysCu.js +0 -19
- package/dist/config-update-BBkpLB9o.js +0 -143
- package/dist/direct-management--Y8ypgLv.js +0 -251
- package/dist/direct-room-XkutHjES.js +0 -76
- package/dist/exec-approvals-to3d_jMv.js +0 -196
- package/dist/probe.runtime-sh9piX22.js +0 -3
- package/dist/profile-BlHu0wDX.js +0 -111
- package/dist/recovery-key-store-BTJ6jz5v.js +0 -294
- package/dist/session-store-metadata-DQXjgNLt.js +0 -77
- package/dist/setup-core-C-uKN68n.js +0 -116
- package/dist/setup-dm-policy-0_kFUfW4.js +0 -195
- package/dist/shared-DarXfhzC.js +0 -195
- package/dist/startup-abort-56edvmbM.js +0 -32
- /package/dist/{active-client-uhlxdhEy.js → active-client-DUi-lumi.js} +0 -0
- /package/dist/{approval-reactions-o2_tuH8D.js → approval-reactions-Cwd1PMCC.js} +0 -0
- /package/dist/{async-lock-uQfhfQIY.js → async-lock-SsmtFXtt.js} +0 -0
- /package/dist/{backup-health-Cabu_WQC.js → backup-health-3BHbHxyd.js} +0 -0
- /package/dist/{config-secret-input.runtime-DiKFehsE.js → config-secret-input.runtime-nbLCnJq7.js} +0 -0
- /package/dist/{crypto-node.runtime-pihzdpY7.js → crypto-node.runtime-D9qxgRPa.js} +0 -0
- /package/dist/{deps-DR0MIYrW.js → deps-LqqGWPWt.js} +0 -0
- /package/dist/{device-health-UVYpbA_W.js → device-health-Di9MUzFj.js} +0 -0
- /package/dist/{doctor-contract-D4-64QuJ.js → doctor-contract-s4gUPmRN.js} +0 -0
- /package/dist/{errors-CTcpEDq-.js → errors-BpHgvm2o.js} +0 -0
- /package/dist/{exec-approval-resolver-Bza9Dhlm.js → exec-approval-resolver-C8faS0XB.js} +0 -0
- /package/dist/{migration-snapshot-backup-DaCHTp8C.js → migration-snapshot-backup-BWTIFXgQ.js} +0 -0
- /package/dist/{reaction-common-ejrL19w-.js → reaction-common-B-QgNfEs.js} +0 -0
- /package/dist/{runtime-C6X4h_SJ.js → runtime-lwTSy9Yt.js} +0 -0
- /package/dist/{secret-contract-DcrJWCQI.js → secret-contract-e4SdhUtT.js} +0 -0
- /package/dist/{sync-state-C_beeevA.js → sync-state-Bx0gPaGA.js} +0 -0
- /package/dist/{thread-binding-api-Cq_E-E1K.js → thread-binding-api-Bx55B6hm.js} +0 -0
- /package/dist/{timeout-abort-signal-CtaIaP1v.js → timeout-abort-signal-sT0wAxVn.js} +0 -0
- /package/dist/{url-validation-DiK9j7jz.js → url-validation-CBZBxN3F.js} +0 -0
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-DUslC3ob.js";
|
|
2
2
|
import { n as requiresExplicitMatrixDefaultAccount } from "./account-selection-BWwIruri.js";
|
|
3
|
-
import {
|
|
3
|
+
import { c as resolveMatrixAccountConfig, t as resolveMatrixConfigFieldPath } from "./config-paths-msaDGRh6.js";
|
|
4
4
|
import { r as resolveMatrixEnvAuthReadiness } from "./env-auth-BJqGI8M6.js";
|
|
5
|
-
import {
|
|
6
|
-
import { r as
|
|
7
|
-
import {
|
|
8
|
-
import { r as updateMatrixAccountConfig } from "./config-update-BBkpLB9o.js";
|
|
9
|
-
import { n as validateMatrixHomeserverUrl, r as isPrivateOrLoopbackHost, t as resolveValidatedMatrixHomeserverUrl } from "./url-validation-DiK9j7jz.js";
|
|
10
|
-
import { n as ensureMatrixSdkInstalled, r as isMatrixSdkAvailable } from "./deps-DR0MIYrW.js";
|
|
5
|
+
import { g as resolveMatrixAccount, h as resolveDefaultMatrixAccountId, i as moveSingleMatrixAccountConfigToNamedAccount, l as updateMatrixAccountConfig, p as listMatrixAccountIds, r as resolveMatrixSetupDmAllowFrom } from "./setup-core-CgOV8zmh.js";
|
|
6
|
+
import { n as validateMatrixHomeserverUrl, r as isPrivateOrLoopbackHost, t as resolveValidatedMatrixHomeserverUrl } from "./url-validation-CBZBxN3F.js";
|
|
7
|
+
import { n as ensureMatrixSdkInstalled, r as isMatrixSdkAvailable } from "./deps-LqqGWPWt.js";
|
|
11
8
|
import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
|
|
12
9
|
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeStringifiedOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
13
10
|
import { formatDocsLink, hasConfiguredSecretInput, mergeAllowFromEntries, normalizeAccountId as normalizeAccountId$1, promptAccountId, promptChannelAccessConfig, splitSetupEntries } from "openclaw/plugin-sdk/setup";
|
|
@@ -107,7 +104,7 @@ async function promptMatrixAllowFrom(params) {
|
|
|
107
104
|
pending.push(part);
|
|
108
105
|
}
|
|
109
106
|
if (pending.length > 0) {
|
|
110
|
-
const { resolveMatrixTargets } = await import("./resolve-targets-
|
|
107
|
+
const { resolveMatrixTargets } = await import("./resolve-targets-DPqngj4V.js").then((n) => n.n);
|
|
111
108
|
const results = await resolveMatrixTargets({
|
|
112
109
|
cfg,
|
|
113
110
|
accountId,
|
|
@@ -235,7 +232,7 @@ async function configureMatrixAccessPrompts(params) {
|
|
|
235
232
|
resolvedIds.push(cleaned);
|
|
236
233
|
continue;
|
|
237
234
|
}
|
|
238
|
-
const { listMatrixDirectoryGroupsLive } = await import("./directory-live-
|
|
235
|
+
const { listMatrixDirectoryGroupsLive } = await import("./directory-live-BCfx1C0G.js").then((n) => n.t);
|
|
239
236
|
const matches = await listMatrixDirectoryGroupsLive({
|
|
240
237
|
cfg: next,
|
|
241
238
|
accountId: params.accountId,
|
|
@@ -510,7 +507,7 @@ const matrixOnboardingAdapter = {
|
|
|
510
507
|
});
|
|
511
508
|
},
|
|
512
509
|
afterConfigWritten: async ({ previousCfg, cfg, accountId, runtime }) => {
|
|
513
|
-
const { runMatrixSetupBootstrapAfterConfigWrite } = await import("./setup-bootstrap-
|
|
510
|
+
const { runMatrixSetupBootstrapAfterConfigWrite } = await import("./setup-bootstrap-krQU60Az.js");
|
|
514
511
|
await runMatrixSetupBootstrapAfterConfigWrite({
|
|
515
512
|
previousCfg,
|
|
516
513
|
cfg,
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-DUslC3ob.js";
|
|
1
2
|
import { a as resolveMatrixDefaultOrOnlyAccountId, n as requiresExplicitMatrixDefaultAccount, o as resolveMatrixAccountStringValues } from "./account-selection-BWwIruri.js";
|
|
2
3
|
import { t as getMatrixScopedEnvVarNames } from "./env-vars-C7uQCTKn.js";
|
|
3
|
-
import {
|
|
4
|
+
import { i as findMatrixAccountConfig, l as resolveMatrixBaseConfig, o as listNormalizedMatrixAccountIds, t as resolveMatrixConfigFieldPath } from "./config-paths-msaDGRh6.js";
|
|
4
5
|
import { i as resolveScopedMatrixEnvConfig, n as resolveGlobalMatrixEnvConfig } from "./env-auth-BJqGI8M6.js";
|
|
5
|
-
import { t as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1, normalizeAccountId as normalizeAccountId$1, normalizeOptionalAccountId as normalizeOptionalAccountId$1 } from "openclaw/plugin-sdk/account-id";
|
|
6
|
+
import { t as resolveValidatedMatrixHomeserverUrl } from "./url-validation-CBZBxN3F.js";
|
|
7
|
+
import { r as repairCurrentTokenStorageMetaDeviceId } from "./storage-HI1nL3im.js";
|
|
8
|
+
import { o as LogService, t as awaitMatrixStartupWithAbort } from "./startup-abort-br7BZHJQ.js";
|
|
9
|
+
import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1, normalizeAccountId as normalizeAccountId$1, normalizeOptionalAccountId, normalizeOptionalAccountId as normalizeOptionalAccountId$1 } from "openclaw/plugin-sdk/account-id";
|
|
9
10
|
import { coerceSecretRef, normalizeResolvedSecretInputString } from "openclaw/plugin-sdk/secret-input-runtime";
|
|
10
11
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
11
12
|
import { isPrivateNetworkOptInEnabled, ssrfPolicyFromDangerouslyAllowPrivateNetwork as ssrfPolicyFromDangerouslyAllowPrivateNetwork$1 } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
@@ -19,7 +20,7 @@ let matrixSecretInputDepsPromise;
|
|
|
19
20
|
let matrixAuthClientDepsForTest;
|
|
20
21
|
const MATRIX_AUTH_REQUEST_RETRY_RE = /\b(fetch failed|econnreset|econnrefused|enotfound|etimedout|ehostunreach|enetunreach|eai_again|und_err_|socket hang up|network|headers timeout|body timeout|connect timeout)\b/i;
|
|
21
22
|
async function loadMatrixAuthClientDeps() {
|
|
22
|
-
matrixAuthClientDepsPromise ??= Promise.all([import("./sdk-
|
|
23
|
+
matrixAuthClientDepsPromise ??= Promise.all([import("./sdk-BwfNtBhM.js").then((n) => n.n), import("./logging-bJ8EEe1G.js").then((n) => n.n)]).then(([sdkModule, loggingModule]) => ({
|
|
23
24
|
MatrixClient: sdkModule.MatrixClient,
|
|
24
25
|
ensureMatrixSdkLoggingConfigured: loggingModule.ensureMatrixSdkLoggingConfigured
|
|
25
26
|
}));
|
|
@@ -33,11 +34,11 @@ async function loadMatrixCredentialsReadDeps() {
|
|
|
33
34
|
return await matrixCredentialsReadDepsPromise;
|
|
34
35
|
}
|
|
35
36
|
async function loadMatrixCredentialsWriteRuntime() {
|
|
36
|
-
matrixCredentialsWriteRuntimePromise ??= import("./credentials-write.runtime-
|
|
37
|
+
matrixCredentialsWriteRuntimePromise ??= import("./credentials-write.runtime-DhPvBU-C.js");
|
|
37
38
|
return await matrixCredentialsWriteRuntimePromise;
|
|
38
39
|
}
|
|
39
40
|
async function loadMatrixSecretInputDeps() {
|
|
40
|
-
matrixSecretInputDepsPromise ??= import("./config-secret-input.runtime-
|
|
41
|
+
matrixSecretInputDepsPromise ??= import("./config-secret-input.runtime-nbLCnJq7.js").then((runtime) => ({ resolveConfiguredSecretInputString: runtime.resolveConfiguredSecretInputString }));
|
|
41
42
|
return await matrixSecretInputDepsPromise;
|
|
42
43
|
}
|
|
43
44
|
function shouldRetryMatrixAuthRequest(err) {
|
|
@@ -449,4 +450,193 @@ async function backfillMatrixAuthDeviceIdAfterStartup(params) {
|
|
|
449
450
|
}, env, params.auth.accountId) === "saved" ? deviceId : void 0;
|
|
450
451
|
}
|
|
451
452
|
//#endregion
|
|
452
|
-
|
|
453
|
+
//#region extensions/matrix/src/matrix/client/shared.ts
|
|
454
|
+
var shared_exports = /* @__PURE__ */ __exportAll({
|
|
455
|
+
acquireSharedMatrixClient: () => acquireSharedMatrixClient,
|
|
456
|
+
releaseSharedClientInstance: () => releaseSharedClientInstance,
|
|
457
|
+
removeSharedClientInstance: () => removeSharedClientInstance,
|
|
458
|
+
resolveSharedMatrixClient: () => resolveSharedMatrixClient,
|
|
459
|
+
stopSharedClient: () => stopSharedClient,
|
|
460
|
+
stopSharedClientForAccount: () => stopSharedClientForAccount,
|
|
461
|
+
stopSharedClientInstance: () => stopSharedClientInstance
|
|
462
|
+
});
|
|
463
|
+
let matrixCreateClientDepsPromise;
|
|
464
|
+
async function loadMatrixCreateClientDeps() {
|
|
465
|
+
matrixCreateClientDepsPromise ??= import("./create-client-BahCtURn.js").then((n) => n.n).then((runtime) => ({ createMatrixClient: runtime.createMatrixClient }));
|
|
466
|
+
return await matrixCreateClientDepsPromise;
|
|
467
|
+
}
|
|
468
|
+
const sharedClientStates = /* @__PURE__ */ new Map();
|
|
469
|
+
const sharedClientPromises = /* @__PURE__ */ new Map();
|
|
470
|
+
function serializeDispatcherPolicyKey(auth) {
|
|
471
|
+
return JSON.stringify(auth.dispatcherPolicy ?? null);
|
|
472
|
+
}
|
|
473
|
+
function buildSharedClientKey(auth) {
|
|
474
|
+
return [
|
|
475
|
+
auth.homeserver,
|
|
476
|
+
auth.userId,
|
|
477
|
+
auth.accessToken,
|
|
478
|
+
auth.encryption ? "e2ee" : "plain",
|
|
479
|
+
auth.allowPrivateNetwork ? "private-net" : "strict-net",
|
|
480
|
+
serializeDispatcherPolicyKey(auth),
|
|
481
|
+
auth.accountId
|
|
482
|
+
].join("|");
|
|
483
|
+
}
|
|
484
|
+
async function createSharedMatrixClient(params) {
|
|
485
|
+
const { createMatrixClient } = await loadMatrixCreateClientDeps();
|
|
486
|
+
return {
|
|
487
|
+
client: await createMatrixClient({
|
|
488
|
+
homeserver: params.auth.homeserver,
|
|
489
|
+
userId: params.auth.userId,
|
|
490
|
+
accessToken: params.auth.accessToken,
|
|
491
|
+
password: params.auth.password,
|
|
492
|
+
deviceId: params.auth.deviceId,
|
|
493
|
+
encryption: params.auth.encryption,
|
|
494
|
+
localTimeoutMs: params.timeoutMs,
|
|
495
|
+
initialSyncLimit: params.auth.initialSyncLimit,
|
|
496
|
+
accountId: params.auth.accountId,
|
|
497
|
+
allowPrivateNetwork: params.auth.allowPrivateNetwork,
|
|
498
|
+
ssrfPolicy: params.auth.ssrfPolicy,
|
|
499
|
+
dispatcherPolicy: params.auth.dispatcherPolicy
|
|
500
|
+
}),
|
|
501
|
+
key: buildSharedClientKey(params.auth),
|
|
502
|
+
started: false,
|
|
503
|
+
cryptoReady: false,
|
|
504
|
+
startPromise: null,
|
|
505
|
+
leases: 0
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
function findSharedClientStateByInstance(client) {
|
|
509
|
+
for (const state of sharedClientStates.values()) if (state.client === client) return state;
|
|
510
|
+
return null;
|
|
511
|
+
}
|
|
512
|
+
function deleteSharedClientState(state) {
|
|
513
|
+
sharedClientStates.delete(state.key);
|
|
514
|
+
sharedClientPromises.delete(state.key);
|
|
515
|
+
}
|
|
516
|
+
async function ensureSharedClientStarted(params) {
|
|
517
|
+
const waitForStart = async (startPromise) => {
|
|
518
|
+
await awaitMatrixStartupWithAbort(startPromise, params.abortSignal);
|
|
519
|
+
};
|
|
520
|
+
if (params.state.started) return;
|
|
521
|
+
if (params.state.startPromise) {
|
|
522
|
+
await waitForStart(params.state.startPromise);
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
const guardedStart = (async () => {
|
|
526
|
+
const client = params.state.client;
|
|
527
|
+
if (params.encryption && !params.state.cryptoReady) try {
|
|
528
|
+
const joinedRooms = await client.getJoinedRooms();
|
|
529
|
+
if (client.crypto) {
|
|
530
|
+
await client.crypto.prepare(joinedRooms);
|
|
531
|
+
params.state.cryptoReady = true;
|
|
532
|
+
}
|
|
533
|
+
} catch (err) {
|
|
534
|
+
LogService.warn("MatrixClientLite", "Failed to prepare crypto:", err);
|
|
535
|
+
}
|
|
536
|
+
await client.start({ abortSignal: params.abortSignal });
|
|
537
|
+
params.state.started = true;
|
|
538
|
+
})().finally(() => {
|
|
539
|
+
if (params.state.startPromise === guardedStart) params.state.startPromise = null;
|
|
540
|
+
});
|
|
541
|
+
params.state.startPromise = guardedStart;
|
|
542
|
+
await waitForStart(guardedStart);
|
|
543
|
+
}
|
|
544
|
+
async function resolveSharedMatrixClientState(params = {}) {
|
|
545
|
+
const requestedAccountId = normalizeOptionalAccountId(params.accountId);
|
|
546
|
+
if (params.auth && requestedAccountId && requestedAccountId !== params.auth.accountId) throw new Error(`Matrix shared client account mismatch: requested ${requestedAccountId}, auth resolved ${params.auth.accountId}`);
|
|
547
|
+
const authContext = (() => {
|
|
548
|
+
if (params.auth) return null;
|
|
549
|
+
if (!params.cfg) throw new Error("Matrix shared client requires a resolved runtime config. Load and resolve config at the command or gateway boundary, then pass cfg through the runtime path.");
|
|
550
|
+
return resolveMatrixAuthContext({
|
|
551
|
+
cfg: params.cfg,
|
|
552
|
+
env: params.env,
|
|
553
|
+
accountId: params.accountId
|
|
554
|
+
});
|
|
555
|
+
})();
|
|
556
|
+
const auth = params.auth ?? await resolveMatrixAuth({
|
|
557
|
+
cfg: authContext?.cfg ?? params.cfg,
|
|
558
|
+
env: authContext?.env ?? params.env,
|
|
559
|
+
accountId: authContext?.accountId
|
|
560
|
+
});
|
|
561
|
+
const key = buildSharedClientKey(auth);
|
|
562
|
+
const shouldStart = params.startClient !== false;
|
|
563
|
+
const existingState = sharedClientStates.get(key);
|
|
564
|
+
if (existingState) {
|
|
565
|
+
if (shouldStart) await ensureSharedClientStarted({
|
|
566
|
+
state: existingState,
|
|
567
|
+
encryption: auth.encryption,
|
|
568
|
+
abortSignal: params.abortSignal
|
|
569
|
+
});
|
|
570
|
+
return existingState;
|
|
571
|
+
}
|
|
572
|
+
const existingPromise = sharedClientPromises.get(key);
|
|
573
|
+
if (existingPromise) {
|
|
574
|
+
const pending = await existingPromise;
|
|
575
|
+
if (shouldStart) await ensureSharedClientStarted({
|
|
576
|
+
state: pending,
|
|
577
|
+
encryption: auth.encryption,
|
|
578
|
+
abortSignal: params.abortSignal
|
|
579
|
+
});
|
|
580
|
+
return pending;
|
|
581
|
+
}
|
|
582
|
+
const creationPromise = createSharedMatrixClient({
|
|
583
|
+
auth,
|
|
584
|
+
timeoutMs: params.timeoutMs
|
|
585
|
+
});
|
|
586
|
+
sharedClientPromises.set(key, creationPromise);
|
|
587
|
+
try {
|
|
588
|
+
const created = await creationPromise;
|
|
589
|
+
sharedClientStates.set(key, created);
|
|
590
|
+
if (shouldStart) await ensureSharedClientStarted({
|
|
591
|
+
state: created,
|
|
592
|
+
encryption: auth.encryption,
|
|
593
|
+
abortSignal: params.abortSignal
|
|
594
|
+
});
|
|
595
|
+
return created;
|
|
596
|
+
} finally {
|
|
597
|
+
sharedClientPromises.delete(key);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
async function resolveSharedMatrixClient(params = {}) {
|
|
601
|
+
return (await resolveSharedMatrixClientState(params)).client;
|
|
602
|
+
}
|
|
603
|
+
async function acquireSharedMatrixClient(params = {}) {
|
|
604
|
+
const state = await resolveSharedMatrixClientState(params);
|
|
605
|
+
state.leases += 1;
|
|
606
|
+
return state.client;
|
|
607
|
+
}
|
|
608
|
+
function stopSharedClient() {
|
|
609
|
+
for (const state of sharedClientStates.values()) state.client.stop();
|
|
610
|
+
sharedClientStates.clear();
|
|
611
|
+
sharedClientPromises.clear();
|
|
612
|
+
}
|
|
613
|
+
function stopSharedClientForAccount(auth) {
|
|
614
|
+
const key = buildSharedClientKey(auth);
|
|
615
|
+
const state = sharedClientStates.get(key);
|
|
616
|
+
if (!state) return;
|
|
617
|
+
state.client.stop();
|
|
618
|
+
deleteSharedClientState(state);
|
|
619
|
+
}
|
|
620
|
+
function removeSharedClientInstance(client) {
|
|
621
|
+
const state = findSharedClientStateByInstance(client);
|
|
622
|
+
if (!state) return false;
|
|
623
|
+
deleteSharedClientState(state);
|
|
624
|
+
return true;
|
|
625
|
+
}
|
|
626
|
+
function stopSharedClientInstance(client) {
|
|
627
|
+
if (!removeSharedClientInstance(client)) return;
|
|
628
|
+
client.stop();
|
|
629
|
+
}
|
|
630
|
+
async function releaseSharedClientInstance(client, mode = "stop") {
|
|
631
|
+
const state = findSharedClientStateByInstance(client);
|
|
632
|
+
if (!state) return false;
|
|
633
|
+
state.leases = Math.max(0, state.leases - 1);
|
|
634
|
+
if (state.leases > 0) return false;
|
|
635
|
+
deleteSharedClientState(state);
|
|
636
|
+
if (mode === "persist") await client.stopAndPersist();
|
|
637
|
+
else if (mode === "discard") client.stopWithoutPersist();
|
|
638
|
+
else client.stop();
|
|
639
|
+
return true;
|
|
640
|
+
}
|
|
641
|
+
//#endregion
|
|
642
|
+
export { shared_exports as a, backfillMatrixAuthDeviceIdAfterStartup as c, resolveMatrixConfigForAccount as d, resolveSharedMatrixClient as i, resolveMatrixAuth as l, releaseSharedClientInstance as n, stopSharedClientForAccount as o, removeSharedClientInstance as r, stopSharedClientInstance as s, acquireSharedMatrixClient as t, resolveMatrixAuthContext as u };
|
|
@@ -75,4 +75,35 @@ const LogService = {
|
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
77
|
//#endregion
|
|
78
|
-
|
|
78
|
+
//#region extensions/matrix/src/matrix/startup-abort.ts
|
|
79
|
+
function createMatrixStartupAbortError() {
|
|
80
|
+
const error = /* @__PURE__ */ new Error("Matrix startup aborted");
|
|
81
|
+
error.name = "AbortError";
|
|
82
|
+
return error;
|
|
83
|
+
}
|
|
84
|
+
function throwIfMatrixStartupAborted(abortSignal) {
|
|
85
|
+
if (abortSignal?.aborted === true) throw createMatrixStartupAbortError();
|
|
86
|
+
}
|
|
87
|
+
function isMatrixStartupAbortError(error) {
|
|
88
|
+
return error instanceof Error && error.name === "AbortError";
|
|
89
|
+
}
|
|
90
|
+
async function awaitMatrixStartupWithAbort(promise, abortSignal) {
|
|
91
|
+
if (!abortSignal) return await promise;
|
|
92
|
+
if (abortSignal.aborted) throw createMatrixStartupAbortError();
|
|
93
|
+
return await new Promise((resolve, reject) => {
|
|
94
|
+
const onAbort = () => {
|
|
95
|
+
abortSignal.removeEventListener("abort", onAbort);
|
|
96
|
+
reject(createMatrixStartupAbortError());
|
|
97
|
+
};
|
|
98
|
+
abortSignal.addEventListener("abort", onAbort, { once: true });
|
|
99
|
+
promise.then((value) => {
|
|
100
|
+
abortSignal.removeEventListener("abort", onAbort);
|
|
101
|
+
resolve(value);
|
|
102
|
+
}, (error) => {
|
|
103
|
+
abortSignal.removeEventListener("abort", onAbort);
|
|
104
|
+
reject(error);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
export { ConsoleLogger as a, setMatrixConsoleLogging as c, throwIfMatrixStartupAborted as i, createMatrixStartupAbortError as n, LogService as o, isMatrixStartupAbortError as r, noop as s, awaitMatrixStartupWithAbort as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as formatMatrixErrorMessage } from "./errors-
|
|
2
|
-
import { a as resolveMatrixStoragePaths } from "./storage-
|
|
1
|
+
import { t as formatMatrixErrorMessage } from "./errors-BpHgvm2o.js";
|
|
2
|
+
import { a as resolveMatrixStoragePaths } from "./storage-HI1nL3im.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { readJsonFileWithFallback, writeJsonFileAtomically } from "openclaw/plugin-sdk/json-store";
|
|
5
5
|
import fs from "node:fs/promises";
|
|
@@ -178,7 +178,7 @@ async function maybeMigrateLegacyStorage(params) {
|
|
|
178
178
|
if (!shouldMigrateStorage && !shouldMigrateCrypto) return;
|
|
179
179
|
assertLegacyMigrationAccountSelection({ accountKey: params.storagePaths.accountKey });
|
|
180
180
|
const logger = getMatrixRuntime().logging.getChildLogger({ module: "matrix-storage" });
|
|
181
|
-
const { maybeCreateMatrixMigrationSnapshot } = await import("./migration-snapshot.runtime-
|
|
181
|
+
const { maybeCreateMatrixMigrationSnapshot } = await import("./migration-snapshot.runtime-C7yiKWS7.js");
|
|
182
182
|
await maybeCreateMatrixMigrationSnapshot({
|
|
183
183
|
trigger: "matrix-client-fallback",
|
|
184
184
|
env: params.env,
|
|
@@ -146,4 +146,25 @@ function handleMatrixSubagentDeliveryTarget(event) {
|
|
|
146
146
|
} };
|
|
147
147
|
}
|
|
148
148
|
//#endregion
|
|
149
|
-
|
|
149
|
+
//#region extensions/matrix/subagent-hooks-api.ts
|
|
150
|
+
let matrixSubagentHooksPromise = null;
|
|
151
|
+
function loadMatrixSubagentHooksModule() {
|
|
152
|
+
matrixSubagentHooksPromise ??= Promise.resolve().then(() => subagent_hooks_exports);
|
|
153
|
+
return matrixSubagentHooksPromise;
|
|
154
|
+
}
|
|
155
|
+
function registerMatrixSubagentHooks(api) {
|
|
156
|
+
api.on("subagent_spawning", async (event) => {
|
|
157
|
+
const { handleMatrixSubagentSpawning } = await loadMatrixSubagentHooksModule();
|
|
158
|
+
return await handleMatrixSubagentSpawning(api, event);
|
|
159
|
+
});
|
|
160
|
+
api.on("subagent_ended", async (event) => {
|
|
161
|
+
const { handleMatrixSubagentEnded } = await loadMatrixSubagentHooksModule();
|
|
162
|
+
await handleMatrixSubagentEnded(event);
|
|
163
|
+
});
|
|
164
|
+
api.on("subagent_delivery_target", async (event) => {
|
|
165
|
+
const { handleMatrixSubagentDeliveryTarget } = await loadMatrixSubagentHooksModule();
|
|
166
|
+
return handleMatrixSubagentDeliveryTarget(event);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
//#endregion
|
|
170
|
+
export { subagent_hooks_exports as a, handleMatrixSubagentSpawning as i, handleMatrixSubagentDeliveryTarget as n, handleMatrixSubagentEnded as r, registerMatrixSubagentHooks as t };
|
|
@@ -1,23 +1,2 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
//#region extensions/matrix/subagent-hooks-api.ts
|
|
3
|
-
let matrixSubagentHooksPromise = null;
|
|
4
|
-
function loadMatrixSubagentHooksModule() {
|
|
5
|
-
matrixSubagentHooksPromise ??= import("./subagent-hooks-DQbyqq9V.js").then((n) => n.i);
|
|
6
|
-
return matrixSubagentHooksPromise;
|
|
7
|
-
}
|
|
8
|
-
function registerMatrixSubagentHooks(api) {
|
|
9
|
-
api.on("subagent_spawning", async (event) => {
|
|
10
|
-
const { handleMatrixSubagentSpawning } = await loadMatrixSubagentHooksModule();
|
|
11
|
-
return await handleMatrixSubagentSpawning(api, event);
|
|
12
|
-
});
|
|
13
|
-
api.on("subagent_ended", async (event) => {
|
|
14
|
-
const { handleMatrixSubagentEnded } = await loadMatrixSubagentHooksModule();
|
|
15
|
-
await handleMatrixSubagentEnded(event);
|
|
16
|
-
});
|
|
17
|
-
api.on("subagent_delivery_target", async (event) => {
|
|
18
|
-
const { handleMatrixSubagentDeliveryTarget } = await loadMatrixSubagentHooksModule();
|
|
19
|
-
return handleMatrixSubagentDeliveryTarget(event);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
//#endregion
|
|
1
|
+
import { i as handleMatrixSubagentSpawning, n as handleMatrixSubagentDeliveryTarget, r as handleMatrixSubagentEnded, t as registerMatrixSubagentHooks } from "./subagent-hooks-api-BgQgDwAS.js";
|
|
23
2
|
export { handleMatrixSubagentDeliveryTarget, handleMatrixSubagentEnded, handleMatrixSubagentSpawning, registerMatrixSubagentHooks };
|
package/dist/test-api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { r as setMatrixRuntime } from "./runtime-Dog86njy.js";
|
|
2
|
-
import { t as matrixPlugin } from "./channel-
|
|
3
|
-
import { t as MatrixClient } from "./sdk-
|
|
2
|
+
import { t as matrixPlugin } from "./channel-CwN56Pko.js";
|
|
3
|
+
import { t as MatrixClient } from "./sdk-BwfNtBhM.js";
|
|
4
4
|
export { MatrixClient, matrixPlugin, setMatrixRuntime };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as resolveMatrixInboundConversation, t as defaultTopLevelPlacement } from "./thread-binding-api-
|
|
1
|
+
import { n as resolveMatrixInboundConversation, t as defaultTopLevelPlacement } from "./thread-binding-api-Bx55B6hm.js";
|
|
2
2
|
export { defaultTopLevelPlacement, resolveMatrixInboundConversation as resolveInboundConversation };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as listBindingsForAccount, c as resolveBindingKey, f as setMatrixThreadBindingManagerEntry, h as toSessionBindingRecord, l as resolveEffectiveBindingExpiry, m as toMatrixBindingTargetKind, o as removeBindingRecord, r as getMatrixThreadBindingManagerEntry, t as deleteMatrixThreadBindingManagerEntry, u as setBindingRecord } from "./thread-bindings-shared-DK-d-oYX.js";
|
|
2
|
-
import { i as resolveMatrixStateFilePath, t as claimCurrentTokenStorageState } from "./storage-
|
|
3
|
-
import { a as sendMessageMatrix } from "./send-
|
|
2
|
+
import { i as resolveMatrixStateFilePath, t as claimCurrentTokenStorageState } from "./storage-HI1nL3im.js";
|
|
3
|
+
import { a as sendMessageMatrix } from "./send-CdoJ1pZY.js";
|
|
4
4
|
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
5
5
|
import { registerSessionBindingAdapter, resolveThreadBindingFarewellText, unregisterSessionBindingAdapter } from "openclaw/plugin-sdk/thread-bindings-session-runtime";
|
|
6
6
|
import path from "node:path";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./
|
|
3
|
-
import {
|
|
4
|
-
import { i as buildMatrixReactionRelationsPath, o as selectOwnMatrixReactionEventIds, s as summarizeMatrixReactionEvents } from "./reaction-common-
|
|
5
|
-
import { n as withResolvedActionClient, r as withResolvedRoomAction } from "./client-
|
|
6
|
-
import { a as fetchEventSummary, c as resolveMatrixActionLimit, i as sendMatrixMessage, n as editMatrixMessage, o as readPinnedEvents, r as readMatrixMessages, s as EventType, t as deleteMatrixMessage } from "./messages-
|
|
7
|
-
import { a as jsonResult, c as readStringArrayParam, l as readStringParam, o as readNumberParam, r as createActionGate, s as readReactionParams } from "./runtime-api-
|
|
8
|
-
import { t as applyMatrixProfileUpdate } from "./profile-update-
|
|
9
|
-
import { _ as scanMatrixVerificationQr, a as confirmMatrixVerificationSas, b as verifyMatrixRecoveryKey, c as getMatrixRoomKeyBackupStatus, d as listMatrixVerifications, f as mismatchMatrixVerificationSas, h as restoreMatrixRoomKeyBackup, i as confirmMatrixVerificationReciprocateQr, l as getMatrixVerificationSas, n as bootstrapMatrixVerification, o as generateMatrixVerificationQr, p as requestMatrixVerification, r as cancelMatrixVerification, s as getMatrixEncryptionStatus, t as acceptMatrixVerification, u as getMatrixVerificationStatus, v as startMatrixVerification } from "./verification-
|
|
1
|
+
import { c as resolveMatrixAccountConfig } from "./config-paths-msaDGRh6.js";
|
|
2
|
+
import "./setup-core-CgOV8zmh.js";
|
|
3
|
+
import { E as parsePollStart, T as isPollStartType, b as buildPollResponseContent, i as reactMatrixMessage, u as resolveMatrixRoomId } from "./send-CdoJ1pZY.js";
|
|
4
|
+
import { i as buildMatrixReactionRelationsPath, o as selectOwnMatrixReactionEventIds, s as summarizeMatrixReactionEvents } from "./reaction-common-B-QgNfEs.js";
|
|
5
|
+
import { n as withResolvedActionClient, r as withResolvedRoomAction } from "./client-D6fFVbNM.js";
|
|
6
|
+
import { a as fetchEventSummary, c as resolveMatrixActionLimit, i as sendMatrixMessage, n as editMatrixMessage, o as readPinnedEvents, r as readMatrixMessages, s as EventType, t as deleteMatrixMessage } from "./messages-BKTEUSwJ.js";
|
|
7
|
+
import { a as jsonResult, c as readStringArrayParam, l as readStringParam, o as readNumberParam, r as createActionGate, s as readReactionParams } from "./runtime-api-C-QeChQj.js";
|
|
8
|
+
import { t as applyMatrixProfileUpdate } from "./profile-update-BAAflurI.js";
|
|
9
|
+
import { _ as scanMatrixVerificationQr, a as confirmMatrixVerificationSas, b as verifyMatrixRecoveryKey, c as getMatrixRoomKeyBackupStatus, d as listMatrixVerifications, f as mismatchMatrixVerificationSas, h as restoreMatrixRoomKeyBackup, i as confirmMatrixVerificationReciprocateQr, l as getMatrixVerificationSas, n as bootstrapMatrixVerification, o as generateMatrixVerificationQr, p as requestMatrixVerification, r as cancelMatrixVerification, s as getMatrixEncryptionStatus, t as acceptMatrixVerification, u as getMatrixVerificationStatus, v as startMatrixVerification } from "./verification-DvC37Z_y.js";
|
|
10
10
|
import { normalizeOptionalLowercaseString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
11
11
|
//#region extensions/matrix/src/matrix/actions/polls.ts
|
|
12
12
|
function normalizeOptionIndexes(indexes) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-DUslC3ob.js";
|
|
2
|
-
import { i as withStartedActionClient, n as withResolvedActionClient } from "./client-
|
|
3
|
-
import { n as formatMatrixEncryptionUnavailableError } from "./encryption-guidance-
|
|
2
|
+
import { i as withStartedActionClient, n as withResolvedActionClient } from "./client-D6fFVbNM.js";
|
|
3
|
+
import { n as formatMatrixEncryptionUnavailableError } from "./encryption-guidance-1QoIvd-g.js";
|
|
4
4
|
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
5
5
|
import { requireRuntimeConfig } from "openclaw/plugin-sdk/plugin-config-runtime";
|
|
6
6
|
import { setTimeout } from "node:timers/promises";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/matrix",
|
|
3
|
-
"version": "2026.5.
|
|
3
|
+
"version": "2026.5.16-beta.1",
|
|
4
4
|
"description": "OpenClaw Matrix channel plugin",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"type": "module",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@matrix-org/matrix-sdk-crypto-nodejs": "0.5.1",
|
|
12
|
-
"@matrix-org/matrix-sdk-crypto-wasm": "18.
|
|
12
|
+
"@matrix-org/matrix-sdk-crypto-wasm": "18.3.0",
|
|
13
13
|
"fake-indexeddb": "6.2.5",
|
|
14
14
|
"markdown-it": "14.1.1",
|
|
15
|
-
"matrix-js-sdk": "41.5.0
|
|
15
|
+
"matrix-js-sdk": "41.5.0",
|
|
16
16
|
"music-metadata": "11.12.3",
|
|
17
17
|
"typebox": "1.1.38",
|
|
18
18
|
"zod": "4.4.3"
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"openclaw": "workspace:*"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"openclaw": ">=2026.5.
|
|
25
|
+
"openclaw": ">=2026.5.16-beta.1"
|
|
26
26
|
},
|
|
27
27
|
"peerDependenciesMeta": {
|
|
28
28
|
"openclaw": {
|
|
@@ -87,10 +87,10 @@
|
|
|
87
87
|
"allowInvalidConfigRecovery": true
|
|
88
88
|
},
|
|
89
89
|
"compat": {
|
|
90
|
-
"pluginApi": ">=2026.5.
|
|
90
|
+
"pluginApi": ">=2026.5.16-beta.1"
|
|
91
91
|
},
|
|
92
92
|
"build": {
|
|
93
|
-
"openclawVersion": "2026.5.
|
|
93
|
+
"openclawVersion": "2026.5.16-beta.1"
|
|
94
94
|
},
|
|
95
95
|
"release": {
|
|
96
96
|
"publishToClawHub": true,
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { a as resolveMatrixDefaultOrOnlyAccountId, o as resolveMatrixAccountStringValues, r as resolveConfiguredMatrixAccountIds } from "./account-selection-BWwIruri.js";
|
|
2
|
-
import { a as resolveMatrixAccountConfig, o as resolveMatrixBaseConfig, t as findMatrixAccountConfig } from "./account-config-LVxGiX7e.js";
|
|
3
|
-
import { i as resolveScopedMatrixEnvConfig, n as resolveGlobalMatrixEnvConfig } from "./env-auth-BJqGI8M6.js";
|
|
4
|
-
import { i as loadMatrixCredentials, n as credentialsMatchConfig } from "./credentials-read-cmHgousK.js";
|
|
5
|
-
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
6
|
-
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
7
|
-
import { hasConfiguredSecretInput } from "openclaw/plugin-sdk/secret-input-runtime";
|
|
8
|
-
//#region extensions/matrix/src/matrix/accounts.ts
|
|
9
|
-
function clean(value) {
|
|
10
|
-
return normalizeOptionalString(value) ?? "";
|
|
11
|
-
}
|
|
12
|
-
function resolveMatrixAccountAuthView(params) {
|
|
13
|
-
const normalizedAccountId = normalizeAccountId(params.accountId);
|
|
14
|
-
const matrix = resolveMatrixBaseConfig(params.cfg);
|
|
15
|
-
const account = findMatrixAccountConfig(params.cfg, normalizedAccountId) ?? {};
|
|
16
|
-
const resolvedStrings = resolveMatrixAccountStringValues({
|
|
17
|
-
accountId: normalizedAccountId,
|
|
18
|
-
account: {
|
|
19
|
-
homeserver: clean(account.homeserver),
|
|
20
|
-
userId: clean(account.userId),
|
|
21
|
-
accessToken: typeof account.accessToken === "string" ? clean(account.accessToken) : "",
|
|
22
|
-
password: typeof account.password === "string" ? clean(account.password) : "",
|
|
23
|
-
deviceId: clean(account.deviceId),
|
|
24
|
-
deviceName: clean(account.deviceName)
|
|
25
|
-
},
|
|
26
|
-
scopedEnv: resolveScopedMatrixEnvConfig(normalizedAccountId, params.env),
|
|
27
|
-
channel: {
|
|
28
|
-
homeserver: clean(matrix.homeserver),
|
|
29
|
-
userId: clean(matrix.userId),
|
|
30
|
-
accessToken: typeof matrix.accessToken === "string" ? clean(matrix.accessToken) : "",
|
|
31
|
-
password: typeof matrix.password === "string" ? clean(matrix.password) : "",
|
|
32
|
-
deviceId: clean(matrix.deviceId),
|
|
33
|
-
deviceName: clean(matrix.deviceName)
|
|
34
|
-
},
|
|
35
|
-
globalEnv: resolveGlobalMatrixEnvConfig(params.env)
|
|
36
|
-
});
|
|
37
|
-
return {
|
|
38
|
-
homeserver: resolvedStrings.homeserver,
|
|
39
|
-
userId: resolvedStrings.userId,
|
|
40
|
-
accessToken: resolvedStrings.accessToken || void 0,
|
|
41
|
-
password: resolvedStrings.password || void 0
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
function resolveMatrixAccountUserId(params) {
|
|
45
|
-
const env = params.env ?? process.env;
|
|
46
|
-
const authView = resolveMatrixAccountAuthView({
|
|
47
|
-
cfg: params.cfg,
|
|
48
|
-
accountId: params.accountId,
|
|
49
|
-
env
|
|
50
|
-
});
|
|
51
|
-
const configuredUserId = authView.userId.trim();
|
|
52
|
-
if (configuredUserId) return configuredUserId;
|
|
53
|
-
const stored = loadMatrixCredentials(env, params.accountId);
|
|
54
|
-
if (!stored) return null;
|
|
55
|
-
if (authView.homeserver && stored.homeserver !== authView.homeserver) return null;
|
|
56
|
-
if (authView.accessToken && stored.accessToken !== authView.accessToken) return null;
|
|
57
|
-
return stored.userId.trim() || null;
|
|
58
|
-
}
|
|
59
|
-
function listMatrixAccountIds(cfg) {
|
|
60
|
-
const ids = resolveConfiguredMatrixAccountIds(cfg, process.env);
|
|
61
|
-
return ids.length > 0 ? ids : [DEFAULT_ACCOUNT_ID];
|
|
62
|
-
}
|
|
63
|
-
function resolveDefaultMatrixAccountId(cfg) {
|
|
64
|
-
return normalizeAccountId(resolveMatrixDefaultOrOnlyAccountId(cfg));
|
|
65
|
-
}
|
|
66
|
-
function resolveConfiguredMatrixBotUserIds(params) {
|
|
67
|
-
const env = params.env ?? process.env;
|
|
68
|
-
const currentAccountId = normalizeAccountId(params.accountId);
|
|
69
|
-
const accountIds = new Set(resolveConfiguredMatrixAccountIds(params.cfg, env));
|
|
70
|
-
if (resolveMatrixAccount({
|
|
71
|
-
cfg: params.cfg,
|
|
72
|
-
accountId: DEFAULT_ACCOUNT_ID,
|
|
73
|
-
env
|
|
74
|
-
}).configured) accountIds.add(DEFAULT_ACCOUNT_ID);
|
|
75
|
-
const ids = /* @__PURE__ */ new Set();
|
|
76
|
-
for (const accountId of accountIds) {
|
|
77
|
-
if (normalizeAccountId(accountId) === currentAccountId) continue;
|
|
78
|
-
if (!resolveMatrixAccount({
|
|
79
|
-
cfg: params.cfg,
|
|
80
|
-
accountId,
|
|
81
|
-
env
|
|
82
|
-
}).configured) continue;
|
|
83
|
-
const userId = resolveMatrixAccountUserId({
|
|
84
|
-
cfg: params.cfg,
|
|
85
|
-
accountId,
|
|
86
|
-
env
|
|
87
|
-
});
|
|
88
|
-
if (userId) ids.add(userId);
|
|
89
|
-
}
|
|
90
|
-
return ids;
|
|
91
|
-
}
|
|
92
|
-
function resolveMatrixAccount(params) {
|
|
93
|
-
const env = params.env ?? process.env;
|
|
94
|
-
const accountId = normalizeAccountId(params.accountId ?? resolveDefaultMatrixAccountId(params.cfg));
|
|
95
|
-
const matrixBase = resolveMatrixBaseConfig(params.cfg);
|
|
96
|
-
const base = resolveMatrixAccountConfig({
|
|
97
|
-
cfg: params.cfg,
|
|
98
|
-
accountId,
|
|
99
|
-
env
|
|
100
|
-
});
|
|
101
|
-
const explicitAuthConfig = accountId === DEFAULT_ACCOUNT_ID ? base : findMatrixAccountConfig(params.cfg, accountId) ?? {};
|
|
102
|
-
const enabled = base.enabled !== false && matrixBase.enabled !== false;
|
|
103
|
-
const authView = resolveMatrixAccountAuthView({
|
|
104
|
-
cfg: params.cfg,
|
|
105
|
-
accountId,
|
|
106
|
-
env
|
|
107
|
-
});
|
|
108
|
-
const hasHomeserver = Boolean(authView.homeserver);
|
|
109
|
-
const hasUserId = Boolean(authView.userId);
|
|
110
|
-
const hasAccessToken = Boolean(authView.accessToken) || hasConfiguredSecretInput(explicitAuthConfig.accessToken);
|
|
111
|
-
const hasPassword = Boolean(authView.password);
|
|
112
|
-
const hasPasswordAuth = hasUserId && (hasPassword || hasConfiguredSecretInput(explicitAuthConfig.password));
|
|
113
|
-
const stored = loadMatrixCredentials(env, accountId);
|
|
114
|
-
const hasStored = stored && authView.homeserver ? credentialsMatchConfig(stored, {
|
|
115
|
-
homeserver: authView.homeserver,
|
|
116
|
-
userId: authView.userId || ""
|
|
117
|
-
}) : false;
|
|
118
|
-
const configured = hasHomeserver && (hasAccessToken || hasPasswordAuth || hasStored);
|
|
119
|
-
return {
|
|
120
|
-
accountId,
|
|
121
|
-
enabled,
|
|
122
|
-
name: normalizeOptionalString(base.name),
|
|
123
|
-
configured,
|
|
124
|
-
homeserver: authView.homeserver || void 0,
|
|
125
|
-
userId: authView.userId || void 0,
|
|
126
|
-
config: base
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
//#endregion
|
|
130
|
-
export { resolveMatrixAccount as i, resolveConfiguredMatrixBotUserIds as n, resolveDefaultMatrixAccountId as r, listMatrixAccountIds as t };
|