@openclaw/matrix 2026.5.12 → 2026.5.14-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.
Files changed (99) hide show
  1. package/dist/api.js +4 -4
  2. package/dist/{approval-handler.runtime-LpWmoFyw.js → approval-handler.runtime-Q8ZlmQv_.js} +5 -6
  3. package/dist/{approval-ids-DoC2z7tR.js → approval-ids-D6IQvvRE.js} +1 -1
  4. package/dist/{approval-reaction-auth-DbcA1gGd.js → approval-reaction-auth-99PRu7rF.js} +2 -2
  5. package/dist/{channel-B-R2dceO.js → channel-BLKRuTHs.js} +285 -26
  6. package/dist/channel-plugin-api.js +1 -1
  7. package/dist/{channel.runtime-DdtNY_To.js → channel.runtime-9qwvlUwp.js} +8 -8
  8. package/dist/{cli-Cq80go7q.js → cli-BeWdjXLV.js} +15 -17
  9. package/dist/{cli-metadata-OtekEqAD.js → cli-metadata-B2_76YSe.js} +1 -1
  10. package/dist/cli-metadata.js +1 -1
  11. package/dist/{client-DzjShjVN.js → client-D6fFVbNM.js} +2 -2
  12. package/dist/{client-bootstrap-Am_ZEH3x.js → client-bootstrap-DBwUKgC3.js} +3 -3
  13. package/dist/{client-CyxIx4Fv.js → client-oci1tD6-.js} +4 -5
  14. package/dist/{account-config-D2W-V1eQ.js → config-paths-msaDGRh6.js} +20 -2
  15. package/dist/{config-schema-B975BYl0.js → config-schema-BPCzSyjT.js} +102 -4
  16. package/dist/contract-api.js +5 -6
  17. package/dist/{create-client-DpoW106T.js → create-client-BahCtURn.js} +4 -4
  18. package/dist/{credentials-DV6fWXhC.js → credentials-DK0lK9cZ.js} +1 -1
  19. package/dist/{credentials-write.runtime-zniTq-Gr.js → credentials-write.runtime-DhPvBU-C.js} +1 -1
  20. package/dist/{crypto-runtime-DS6R8y_n.js → crypto-runtime-B-SPS5mv.js} +5 -5
  21. package/dist/{deps-CU5W9Ixu.js → deps-LqqGWPWt.js} +10 -14
  22. package/dist/{directory-live-Bn66SRSD.js → directory-live-BCfx1C0G.js} +3 -3
  23. package/dist/{doctor-KjAvjAJu.js → doctor-KuNYX5N3.js} +3 -3
  24. package/dist/doctor-contract-api.js +1 -1
  25. package/dist/{draft-stream-D_FlbmCh.js → draft-stream-BayHVmtO.js} +1 -2
  26. package/dist/{encryption-guidance-BPi3A_m3.js → encryption-guidance-1QoIvd-g.js} +1 -1
  27. package/dist/{http-client-C7AeVJay.js → http-client-DS3UoC_p.js} +1 -1
  28. package/dist/index.js +2 -2
  29. package/dist/{legacy-crypto-inspector-pB252vPO.js → legacy-crypto-inspector-_gWJGVQ_.js} +1 -1
  30. package/dist/{legacy-crypto-restore-Biw-w2ng.js → legacy-crypto-restore-B9eF1gob.js} +1 -1
  31. package/dist/{logging-DZHSPP5N.js → logging-bJ8EEe1G.js} +1 -1
  32. package/dist/{matrix-migration.runtime-DfjNMeoX.js → matrix-migration.runtime-Cf_wX9mk.js} +3 -3
  33. package/dist/{media-text-psyGloYl.js → media-text-4h4YwCGC.js} +1 -1
  34. package/dist/{messages-DQ8xXWiP.js → messages-BKTEUSwJ.js} +5 -5
  35. package/dist/{migration-snapshot.runtime-CKHE3xF9.js → migration-snapshot.runtime-C7yiKWS7.js} +1 -1
  36. package/dist/{monitor-C8cEvvTe.js → monitor-k-b_TmCm.js} +66 -46
  37. package/dist/plugin-entry.handlers.runtime.js +2 -2
  38. package/dist/probe.runtime-zExLz3Ek.js +3 -0
  39. package/dist/{profile-update-DleMeUHj.js → profile-update-BAAflurI.js} +2 -3
  40. package/dist/{reaction-events-CiARZfjk.js → reaction-events-Dimh8FUE.js} +6 -6
  41. package/dist/{resolve-targets-BbzYe9Qi.js → resolve-targets-DPqngj4V.js} +1 -1
  42. package/dist/{resolver.runtime-BWFMWEsg.js → resolver.runtime-C0RDK0VW.js} +1 -1
  43. package/dist/{route-D6rg-iXN.js → route-R-ajT21_.js} +1 -1
  44. package/dist/{runtime-api-DTKcXOhp.js → runtime-api-C-QeChQj.js} +1 -1
  45. package/dist/runtime-api.js +1 -1
  46. package/dist/runtime-heavy-api.js +2 -2
  47. package/dist/{sdk-DXWmb94u.js → sdk-BwfNtBhM.js} +301 -13
  48. package/dist/secret-contract-api.js +1 -1
  49. package/dist/{send-Df-pDuG6.js → send-CdoJ1pZY.js} +323 -6
  50. package/dist/{setup-bootstrap-DXWxzR7A.js → setup-bootstrap-krQU60Az.js} +4 -4
  51. package/dist/setup-core-CgOV8zmh.js +675 -0
  52. package/dist/setup-plugin-api.js +3 -4
  53. package/dist/{setup-surface-DuRQrrpU.js → setup-surface-BgUaEySF.js} +7 -10
  54. package/dist/{config-BR4uLzNs.js → shared-BlXw87Kp.js} +199 -9
  55. package/dist/{logger-CnZRVrux.js → startup-abort-br7BZHJQ.js} +32 -1
  56. package/dist/{startup-verification-Demyp0bP.js → startup-verification-CTfhD7V_.js} +2 -2
  57. package/dist/{storage-tC3ujLiW.js → storage-HI1nL3im.js} +1 -1
  58. package/dist/{subagent-hooks-DQbyqq9V.js → subagent-hooks-api-BgQgDwAS.js} +22 -1
  59. package/dist/subagent-hooks-api.js +1 -22
  60. package/dist/test-api.js +2 -2
  61. package/dist/thread-binding-api.js +1 -1
  62. package/dist/{thread-bindings--P1UYe7t.js → thread-bindings-8AyQOYDT.js} +2 -2
  63. package/dist/{tool-actions.runtime-AFGhzK--.js → tool-actions.runtime-BuCnleVD.js} +9 -9
  64. package/dist/{verification-BbGdzYQl.js → verification-DvC37Z_y.js} +2 -2
  65. package/openclaw.plugin.json +96 -0
  66. package/package.json +6 -6
  67. package/dist/accounts-Bm90Rzvp.js +0 -130
  68. package/dist/allowlist-sTzpCn5d.js +0 -68
  69. package/dist/config-paths-nsVaysCu.js +0 -19
  70. package/dist/config-update-wZX-HLMn.js +0 -143
  71. package/dist/direct-management--Y8ypgLv.js +0 -251
  72. package/dist/direct-room-XkutHjES.js +0 -76
  73. package/dist/exec-approvals-Crnh543m.js +0 -196
  74. package/dist/probe.runtime-NE73hi9o.js +0 -3
  75. package/dist/profile-BlHu0wDX.js +0 -111
  76. package/dist/recovery-key-store-BTJ6jz5v.js +0 -294
  77. package/dist/session-store-metadata-DQXjgNLt.js +0 -77
  78. package/dist/setup-core-B5X7HxAP.js +0 -116
  79. package/dist/setup-dm-policy-Ca3jA4YW.js +0 -195
  80. package/dist/shared-CkbpEI5j.js +0 -195
  81. package/dist/startup-abort-56edvmbM.js +0 -32
  82. /package/dist/{active-client-uhlxdhEy.js → active-client-DUi-lumi.js} +0 -0
  83. /package/dist/{approval-reactions-o2_tuH8D.js → approval-reactions-Cwd1PMCC.js} +0 -0
  84. /package/dist/{async-lock-uQfhfQIY.js → async-lock-SsmtFXtt.js} +0 -0
  85. /package/dist/{backup-health-Cabu_WQC.js → backup-health-3BHbHxyd.js} +0 -0
  86. /package/dist/{config-secret-input.runtime-DiKFehsE.js → config-secret-input.runtime-nbLCnJq7.js} +0 -0
  87. /package/dist/{crypto-node.runtime-pihzdpY7.js → crypto-node.runtime-D9qxgRPa.js} +0 -0
  88. /package/dist/{device-health-UVYpbA_W.js → device-health-Di9MUzFj.js} +0 -0
  89. /package/dist/{doctor-contract-D4-64QuJ.js → doctor-contract-s4gUPmRN.js} +0 -0
  90. /package/dist/{errors-CTcpEDq-.js → errors-BpHgvm2o.js} +0 -0
  91. /package/dist/{exec-approval-resolver-Bza9Dhlm.js → exec-approval-resolver-C8faS0XB.js} +0 -0
  92. /package/dist/{migration-snapshot-backup-DaCHTp8C.js → migration-snapshot-backup-BWTIFXgQ.js} +0 -0
  93. /package/dist/{reaction-common-ejrL19w-.js → reaction-common-B-QgNfEs.js} +0 -0
  94. /package/dist/{runtime-C6X4h_SJ.js → runtime-lwTSy9Yt.js} +0 -0
  95. /package/dist/{secret-contract-DcrJWCQI.js → secret-contract-e4SdhUtT.js} +0 -0
  96. /package/dist/{sync-state-C_beeevA.js → sync-state-Bx0gPaGA.js} +0 -0
  97. /package/dist/{thread-binding-api-Cq_E-E1K.js → thread-binding-api-Bx55B6hm.js} +0 -0
  98. /package/dist/{timeout-abort-signal-CtaIaP1v.js → timeout-abort-signal-sT0wAxVn.js} +0 -0
  99. /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 { a as resolveMatrixAccountConfig } from "./account-config-D2W-V1eQ.js";
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 { i as resolveMatrixAccount, r as resolveDefaultMatrixAccountId, t as listMatrixAccountIds } from "./accounts-Bm90Rzvp.js";
6
- import { r as moveSingleMatrixAccountConfigToNamedAccount, t as resolveMatrixSetupDmAllowFrom } from "./setup-dm-policy-Ca3jA4YW.js";
7
- import { t as resolveMatrixConfigFieldPath } from "./config-paths-nsVaysCu.js";
8
- import { r as updateMatrixAccountConfig } from "./config-update-wZX-HLMn.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-CU5W9Ixu.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-BbzYe9Qi.js").then((n) => n.n);
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-Bn66SRSD.js").then((n) => n.t);
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-DXWxzR7A.js");
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 { o as resolveMatrixBaseConfig, r as listNormalizedMatrixAccountIds, t as findMatrixAccountConfig } from "./account-config-D2W-V1eQ.js";
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 resolveMatrixConfigFieldPath } from "./config-paths-nsVaysCu.js";
6
- import { t as resolveValidatedMatrixHomeserverUrl } from "./url-validation-DiK9j7jz.js";
7
- import { r as repairCurrentTokenStorageMetaDeviceId } from "./storage-tC3ujLiW.js";
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-DXWmb94u.js").then((n) => n.n), import("./logging-DZHSPP5N.js").then((n) => n.n)]).then(([sdkModule, loggingModule]) => ({
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-zniTq-Gr.js");
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-DiKFehsE.js").then((runtime) => ({ resolveConfiguredSecretInputString: runtime.resolveConfiguredSecretInputString }));
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
- export { resolveMatrixConfigForAccount as i, resolveMatrixAuth as n, resolveMatrixAuthContext as r, backfillMatrixAuthDeviceIdAfterStartup as t };
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
- export { setMatrixConsoleLogging as i, LogService as n, noop as r, ConsoleLogger as t };
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-CTcpEDq-.js";
2
- import { a as resolveMatrixStoragePaths } from "./storage-tC3ujLiW.js";
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-CKHE3xF9.js");
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
- export { subagent_hooks_exports as i, handleMatrixSubagentEnded as n, handleMatrixSubagentSpawning as r, handleMatrixSubagentDeliveryTarget as t };
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 handleMatrixSubagentEnded, r as handleMatrixSubagentSpawning, t as handleMatrixSubagentDeliveryTarget } from "./subagent-hooks-DQbyqq9V.js";
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-B-R2dceO.js";
3
- import { t as MatrixClient } from "./sdk-DXWmb94u.js";
2
+ import { t as matrixPlugin } from "./channel-BLKRuTHs.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-Cq_E-E1K.js";
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-tC3ujLiW.js";
3
- import { a as sendMessageMatrix } from "./send-Df-pDuG6.js";
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 { a as resolveMatrixAccountConfig } from "./account-config-D2W-V1eQ.js";
2
- import "./accounts-Bm90Rzvp.js";
3
- import { _ as parsePollStart, d as buildPollResponseContent, g as isPollStartType, i as reactMatrixMessage, u as resolveMatrixRoomId } from "./send-Df-pDuG6.js";
4
- import { i as buildMatrixReactionRelationsPath, o as selectOwnMatrixReactionEventIds, s as summarizeMatrixReactionEvents } from "./reaction-common-ejrL19w-.js";
5
- import { n as withResolvedActionClient, r as withResolvedRoomAction } from "./client-DzjShjVN.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-DQ8xXWiP.js";
7
- import { a as jsonResult, c as readStringArrayParam, l as readStringParam, o as readNumberParam, r as createActionGate, s as readReactionParams } from "./runtime-api-DTKcXOhp.js";
8
- import { t as applyMatrixProfileUpdate } from "./profile-update-DleMeUHj.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-BbGdzYQl.js";
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-DzjShjVN.js";
3
- import { n as formatMatrixEncryptionUnavailableError } from "./encryption-guidance-BPi3A_m3.js";
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";
@@ -276,6 +276,30 @@
276
276
  }
277
277
  ]
278
278
  },
279
+ "botLoopProtection": {
280
+ "type": "object",
281
+ "properties": {
282
+ "enabled": {
283
+ "type": "boolean"
284
+ },
285
+ "maxEventsPerWindow": {
286
+ "type": "integer",
287
+ "exclusiveMinimum": 0,
288
+ "maximum": 9007199254740991
289
+ },
290
+ "windowSeconds": {
291
+ "type": "integer",
292
+ "exclusiveMinimum": 0,
293
+ "maximum": 9007199254740991
294
+ },
295
+ "cooldownSeconds": {
296
+ "type": "integer",
297
+ "exclusiveMinimum": 0,
298
+ "maximum": 9007199254740991
299
+ }
300
+ },
301
+ "additionalProperties": false
302
+ },
279
303
  "groupPolicy": {
280
304
  "type": "string",
281
305
  "enum": [
@@ -616,6 +640,30 @@
616
640
  }
617
641
  ]
618
642
  },
643
+ "botLoopProtection": {
644
+ "type": "object",
645
+ "properties": {
646
+ "enabled": {
647
+ "type": "boolean"
648
+ },
649
+ "maxEventsPerWindow": {
650
+ "type": "integer",
651
+ "exclusiveMinimum": 0,
652
+ "maximum": 9007199254740991
653
+ },
654
+ "windowSeconds": {
655
+ "type": "integer",
656
+ "exclusiveMinimum": 0,
657
+ "maximum": 9007199254740991
658
+ },
659
+ "cooldownSeconds": {
660
+ "type": "integer",
661
+ "exclusiveMinimum": 0,
662
+ "maximum": 9007199254740991
663
+ }
664
+ },
665
+ "additionalProperties": false
666
+ },
619
667
  "tools": {
620
668
  "type": "object",
621
669
  "properties": {
@@ -695,6 +743,30 @@
695
743
  }
696
744
  ]
697
745
  },
746
+ "botLoopProtection": {
747
+ "type": "object",
748
+ "properties": {
749
+ "enabled": {
750
+ "type": "boolean"
751
+ },
752
+ "maxEventsPerWindow": {
753
+ "type": "integer",
754
+ "exclusiveMinimum": 0,
755
+ "maximum": 9007199254740991
756
+ },
757
+ "windowSeconds": {
758
+ "type": "integer",
759
+ "exclusiveMinimum": 0,
760
+ "maximum": 9007199254740991
761
+ },
762
+ "cooldownSeconds": {
763
+ "type": "integer",
764
+ "exclusiveMinimum": 0,
765
+ "maximum": 9007199254740991
766
+ }
767
+ },
768
+ "additionalProperties": false
769
+ },
698
770
  "tools": {
699
771
  "type": "object",
700
772
  "properties": {
@@ -781,6 +853,30 @@
781
853
  "label": "Matrix",
782
854
  "description": "open protocol; install the plugin to enable.",
783
855
  "uiHints": {
856
+ "allowBots": {
857
+ "label": "Matrix Allow Bot Messages",
858
+ "help": "Allow messages from other configured Matrix bot accounts to trigger replies (default: false). Set \"mentions\" to require a visible room mention."
859
+ },
860
+ "botLoopProtection": {
861
+ "label": "Matrix Bot Loop Protection",
862
+ "help": "Sliding-window guard for accepted Matrix configured-bot loops. Default is enabled whenever allowBots lets configured bot messages reach dispatch."
863
+ },
864
+ "botLoopProtection.enabled": {
865
+ "label": "Matrix Bot Loop Protection Enabled",
866
+ "help": "Enable the bot-pair loop guard. Defaults to true when allowBots is true or \"mentions\", and false when configured bot messages are ignored."
867
+ },
868
+ "botLoopProtection.maxEventsPerWindow": {
869
+ "label": "Matrix Bot Loop Events per Window",
870
+ "help": "Maximum accepted bot-pair messages within the sliding window before suppression starts. Default: 20."
871
+ },
872
+ "botLoopProtection.windowSeconds": {
873
+ "label": "Matrix Bot Loop Window Seconds",
874
+ "help": "Sliding window length for counting bot-pair messages. Default: 60."
875
+ },
876
+ "botLoopProtection.cooldownSeconds": {
877
+ "label": "Matrix Bot Loop Cooldown Seconds",
878
+ "help": "How long to suppress the bot pair after it exceeds the budget. Default: 60."
879
+ },
784
880
  "dangerouslyAllowNameMatching": {
785
881
  "label": "Matrix Display Name Matching",
786
882
  "help": "Compatibility opt-in for resolving Matrix display names and joined room names in allowlists. Prefer full @user:server IDs and room IDs or aliases because names are mutable."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/matrix",
3
- "version": "2026.5.12",
3
+ "version": "2026.5.14-beta.2",
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.2.0",
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-rc.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.12"
25
+ "openclaw": ">=2026.5.14-beta.2"
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.12"
90
+ "pluginApi": ">=2026.5.14-beta.2"
91
91
  },
92
92
  "build": {
93
- "openclawVersion": "2026.5.12"
93
+ "openclawVersion": "2026.5.14-beta.2"
94
94
  },
95
95
  "release": {
96
96
  "publishToClawHub": true,