@openclaw/matrix 2026.5.27 → 2026.5.28-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 (72) hide show
  1. package/dist/api.js +4 -4
  2. package/dist/{approval-handler.runtime-D2nZfRw6.js → approval-handler.runtime-pR4jcWts.js} +7 -37
  3. package/dist/{approval-ids-DzBw_AG3.js → approval-ids-BsGUOwIc.js} +1 -1
  4. package/dist/{approval-reaction-auth-BvK3dXMH.js → approval-reaction-auth-CstZA90i.js} +2 -2
  5. package/dist/{channel-BLuA_9If.js → channel-EfS9AcXo.js} +15 -15
  6. package/dist/channel-plugin-api.js +1 -1
  7. package/dist/{channel.runtime-CCAsyp75.js → channel.runtime-BSL4fCB_.js} +7 -7
  8. package/dist/{cli-Bo50M7l4.js → cli-CYLqmzNw.js} +15 -14
  9. package/dist/{cli-metadata-CqUHNx_0.js → cli-metadata-TxtMWnLo.js} +1 -1
  10. package/dist/cli-metadata.js +1 -1
  11. package/dist/{client-QO7vDxm0.js → client-D6nL0ymL.js} +2 -2
  12. package/dist/{client-BgsOzckO.js → client-DxQ7tWJq.js} +2 -2
  13. package/dist/{client-bootstrap-DK9i3KZ5.js → client-bootstrap-BtddaQGi.js} +1 -1
  14. package/dist/{config-schema-DuSRVdwT.js → config-schema-CRsTmqKY.js} +1 -1
  15. package/dist/contract-api.js +3 -3
  16. package/dist/{create-client-hdBEoEIm.js → create-client-D5Ie4y1a.js} +2 -2
  17. package/dist/{crypto-runtime-BcQzS9DV.js → crypto-runtime-CpQeK8kh.js} +4 -4
  18. package/dist/{deps-CAdiytPJ.js → deps-BVWGd2XS.js} +12 -2
  19. package/dist/{directory-live-2-Vb6nss.js → directory-live-kLKfwyDt.js} +2 -2
  20. package/dist/{doctor-qLh9PyE4.js → doctor-CENc9ks0.js} +1 -1
  21. package/dist/{draft-stream-BBVqdEbn.js → draft-stream-D7KMDYlS.js} +1 -1
  22. package/dist/index.js +1 -1
  23. package/dist/{legacy-crypto-inspector-BRdo-WqV.js → legacy-crypto-inspector-tJOj25VL.js} +1 -1
  24. package/dist/{logging-BR-gcAjp.js → logging-BD9Wmviv.js} +2 -9
  25. package/dist/{matrix-migration.runtime-BhJb4ZII.js → matrix-migration.runtime-CZOep_JX.js} +1 -1
  26. package/dist/{media-text-C6q1S0AJ.js → media-text-ybU6tiB2.js} +1 -1
  27. package/dist/{messages-D-VxmWkC.js → messages-CHjewhaA.js} +5 -5
  28. package/dist/{monitor-DO1yiHWm.js → monitor-DjfcOAje.js} +25 -26
  29. package/dist/plugin-entry.handlers.runtime.js +1 -1
  30. package/dist/probe.runtime-BjFSknLp.js +3 -0
  31. package/dist/{profile-update-B_LpeC8E.js → profile-update-B4HzVfDS.js} +2 -2
  32. package/dist/{reaction-events-BefH3-Gu.js → reaction-events-gK5X5uu5.js} +1 -1
  33. package/dist/recovery-key-store-B3-wYrMU.js +294 -0
  34. package/dist/{resolve-targets-BPhBqXyj.js → resolve-targets-DaTQqtPq.js} +1 -1
  35. package/dist/{resolver.runtime-BOS3foyc.js → resolver.runtime-Dj10Iq3r.js} +1 -1
  36. package/dist/{runtime-api-B-jlPE4A.js → runtime-api-CsF7Kokd.js} +2 -2
  37. package/dist/runtime-api.js +1 -1
  38. package/dist/runtime-heavy-api.js +1 -1
  39. package/dist/{sdk-BKBZkPKt.js → sdk-DTo3Hzko.js} +14 -304
  40. package/dist/{send-DivaFHb1.js → send-DX-aOjPW.js} +1 -1
  41. package/dist/{setup-bootstrap-ClcP-tDQ.js → setup-bootstrap-D9XeWu6O.js} +2 -2
  42. package/dist/{setup-core-s8s_Qudu.js → setup-core-BU4BO6DB.js} +7 -2
  43. package/dist/setup-plugin-api.js +3 -3
  44. package/dist/{setup-surface-BOt10HNf.js → setup-surface-BIFSsw6q.js} +5 -5
  45. package/dist/{shared-3K27tl8e.js → shared-CZ622gSf.js} +113 -5
  46. package/dist/{thread-bindings-CLjJrThw.js → thread-bindings-DjC1mhh_.js} +1 -1
  47. package/dist/{tool-actions.runtime-Vky1krcK.js → tool-actions.runtime-D4A9O27R.js} +20 -21
  48. package/dist/{verification-Dar6QON4.js → verification-CUSz9cFP.js} +1 -1
  49. package/node_modules/linkify-it/build/index.cjs.js +99 -94
  50. package/node_modules/linkify-it/index.mjs +99 -94
  51. package/node_modules/linkify-it/package.json +11 -1
  52. package/node_modules/markdown-it/README.md +13 -17
  53. package/node_modules/markdown-it/dist/index.cjs.js +111 -31
  54. package/node_modules/markdown-it/dist/markdown-it.js +117 -31
  55. package/node_modules/markdown-it/dist/markdown-it.min.js +2 -2
  56. package/node_modules/markdown-it/lib/common/utils.mjs +30 -1
  57. package/node_modules/markdown-it/lib/index.mjs +1 -1
  58. package/node_modules/markdown-it/lib/rules_block/heading.mjs +2 -2
  59. package/node_modules/markdown-it/lib/rules_block/html_block.mjs +12 -1
  60. package/node_modules/markdown-it/lib/rules_block/lheading.mjs +4 -1
  61. package/node_modules/markdown-it/lib/rules_block/paragraph.mjs +3 -1
  62. package/node_modules/markdown-it/lib/rules_core/smartquotes.mjs +37 -21
  63. package/node_modules/markdown-it/lib/rules_inline/entity.mjs +2 -2
  64. package/node_modules/markdown-it/lib/rules_inline/state_inline.mjs +37 -6
  65. package/node_modules/markdown-it/package.json +14 -3
  66. package/node_modules/matrix-js-sdk/CHANGELOG.md +7 -0
  67. package/node_modules/matrix-js-sdk/package.json +1 -1
  68. package/npm-shrinkwrap.json +35 -15
  69. package/package.json +6 -6
  70. package/dist/probe.runtime-9S17Q3Mo.js +0 -3
  71. package/dist/startup-abort-Bs0Up_Qx.js +0 -109
  72. package/dist/test-api.js +0 -4
@@ -1,25 +1,24 @@
1
1
  import { t as isMatrixQualifiedUserId } from "./target-ids-B-5aQxwn.js";
2
2
  import { c as resolveMatrixAccountConfig, s as resolveMatrixAccountAllowlistConfig } from "./config-paths-ZBCMwSos.js";
3
3
  import { t as getMatrixRuntime } from "./runtime-6S3DNFNv.js";
4
- import { m as resolveConfiguredMatrixBotUserIds } from "./setup-core-s8s_Qudu.js";
5
- import { a as buildAllowlistResolutionSummary, c as createTypingCallbacks, d as logInboundDrop, f as logTypingFailure, h as toLocationContext, i as addAllowlistUserEntriesFromConfigEntry, l as formatLocationText, m as summarizeMapping, n as resolveMatrixStoredSessionMeta, o as canonicalizeAllowlistWithResolvedIds, p as patchAllowlistUsersInConfigEntries, r as resolveMatrixRoomConfig, s as createReplyPrefixOptions, u as getAgentScopedMediaLocalRoots } from "./channel-BLuA_9If.js";
6
- import { a as normalizeMatrixUserId, i as normalizeMatrixAllowList, o as resolveMatrixAllowListMatch } from "./config-schema-DuSRVdwT.js";
4
+ import { m as resolveConfiguredMatrixBotUserIds } from "./setup-core-BU4BO6DB.js";
5
+ import { a as buildAllowlistResolutionSummary, c as createTypingCallbacks, d as logInboundDrop, f as logTypingFailure, h as toLocationContext, i as addAllowlistUserEntriesFromConfigEntry, l as formatLocationText, m as summarizeMapping, n as resolveMatrixStoredSessionMeta, o as canonicalizeAllowlistWithResolvedIds, p as patchAllowlistUsersInConfigEntries, r as resolveMatrixRoomConfig, s as createReplyPrefixOptions, u as getAgentScopedMediaLocalRoots } from "./channel-EfS9AcXo.js";
6
+ import { a as normalizeMatrixUserId, i as normalizeMatrixAllowList, o as resolveMatrixAllowListMatch } from "./config-schema-CRsTmqKY.js";
7
7
  import { r as isMatrixNotFoundError, t as formatMatrixErrorMessage } from "./errors-C47hvAF8.js";
8
8
  import { i as resolveMatrixStateFilePath } from "./storage-onzulLbU.js";
9
- import { D as parsePollStartContent, S as formatPollAsText, T as isPollStartType, _ as readJoinedMatrixMembers, a as sendMessageMatrix, f as promoteMatrixDirectRoomCandidate, g as isStrictDirectMembership, h as hasDirectMatrixMemberFlag, t as chunkMatrixText, v as MATRIX_OPENCLAW_FINALIZED_PREVIEW_KEY, w as isPollEventType } from "./send-DivaFHb1.js";
10
- import { t as createMatrixThreadBindingManager } from "./thread-bindings-CLjJrThw.js";
11
- import { t as createAsyncLock } from "./async-lock-BcLS4KOc.js";
12
- import { i as throwIfMatrixStartupAborted, o as LogService, r as isMatrixStartupAbortError } from "./startup-abort-Bs0Up_Qx.js";
13
- import { i as isMatrixMediaSizeLimitError, r as MatrixMediaSizeLimitError } from "./http-client-DJNugFzO.js";
14
- import { n as isMatrixReadySyncState, r as isMatrixTerminalSyncState, t as isMatrixDisconnectedSyncState } from "./sync-state-CWbp0QSY.js";
15
- import { a as resolveMatrixMessageBody, i as resolveMatrixMessageAttachment, n as formatMatrixMediaUnavailableText, r as formatMatrixMessageText, s as fetchMatrixPollSnapshot, t as formatMatrixMediaTooLargeText } from "./media-text-C6q1S0AJ.js";
9
+ import { D as parsePollStartContent, S as formatPollAsText, T as isPollStartType, _ as readJoinedMatrixMembers, a as sendMessageMatrix, f as promoteMatrixDirectRoomCandidate, g as isStrictDirectMembership, h as hasDirectMatrixMemberFlag, t as chunkMatrixText, v as MATRIX_OPENCLAW_FINALIZED_PREVIEW_KEY, w as isPollEventType } from "./send-DX-aOjPW.js";
10
+ import { t as createMatrixThreadBindingManager } from "./thread-bindings-DjC1mhh_.js";
11
+ import { a as resolveMatrixMessageBody, i as resolveMatrixMessageAttachment, n as formatMatrixMediaUnavailableText, r as formatMatrixMessageText, s as fetchMatrixPollSnapshot, t as formatMatrixMediaTooLargeText } from "./media-text-ybU6tiB2.js";
16
12
  import { n as setActiveMatrixClient } from "./active-client-DXvz2gCo.js";
17
13
  import { t as isBunRuntime } from "./runtime-BefyhPWv.js";
18
- import { c as backfillMatrixAuthDeviceIdAfterStartup, i as resolveSharedMatrixClient, l as resolveMatrixAuth, n as releaseSharedClientInstance, u as resolveMatrixAuthContext } from "./shared-3K27tl8e.js";
19
- import "./client-QO7vDxm0.js";
20
- import { d as resolveDefaultGroupPolicy, h as warnMissingProviderGroupPolicyFallbackOnce, m as resolveThreadBindingMaxAgeMsForChannel, p as resolveThreadBindingIdleTimeoutMsForChannel, t as GROUP_POLICY_BLOCKED_LABEL, u as resolveAllowlistProviderRuntimeGroupPolicy } from "./runtime-api-B-jlPE4A.js";
21
- import { t as resolveMatrixTargets } from "./resolve-targets-BPhBqXyj.js";
14
+ import { _ as resolveMatrixAuthContext, f as LogService, g as resolveMatrixAuth, h as backfillMatrixAuthDeviceIdAfterStartup, i as resolveSharedMatrixClient, l as isMatrixStartupAbortError, n as releaseSharedClientInstance, u as throwIfMatrixStartupAborted } from "./shared-CZ622gSf.js";
15
+ import "./client-D6nL0ymL.js";
16
+ import { i as isMatrixMediaSizeLimitError, r as MatrixMediaSizeLimitError } from "./http-client-DJNugFzO.js";
17
+ import { d as resolveDefaultGroupPolicy, h as warnMissingProviderGroupPolicyFallbackOnce, m as resolveThreadBindingMaxAgeMsForChannel, p as resolveThreadBindingIdleTimeoutMsForChannel, t as GROUP_POLICY_BLOCKED_LABEL, u as resolveAllowlistProviderRuntimeGroupPolicy } from "./runtime-api-CsF7Kokd.js";
18
+ import { t as resolveMatrixTargets } from "./resolve-targets-DaTQqtPq.js";
22
19
  import { t as formatMatrixEncryptedEventDisabledWarning } from "./encryption-guidance-CU-OAPMg.js";
20
+ import { t as createAsyncLock } from "./async-lock-BcLS4KOc.js";
21
+ import { n as isMatrixReadySyncState, r as isMatrixTerminalSyncState, t as isMatrixDisconnectedSyncState } from "./sync-state-CWbp0QSY.js";
23
22
  import { a as EventType, i as resolveMatrixThreadRouting, n as resolveMatrixReplyToEventId, o as RelationType, r as resolveMatrixThreadRootId, t as resolveMatrixInboundRoute } from "./route-DY6at4qJ.js";
24
23
  import { normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeStringifiedEntries, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
25
24
  import { buildChannelProgressDraftLineForEntry, createChannelProgressDraftGate, createPreviewMessageReceipt, defineFinalizableLivePreviewAdapter, deliverWithFinalizableLivePreviewAdapter, formatChannelProgressDraftLine, formatChannelProgressDraftLineForEntry, formatChannelProgressDraftText, isChannelProgressDraftWorkToolName, mergeChannelProgressDraftLine, normalizeChannelProgressDraftLineIdentity, resolveChannelProgressDraftMaxLines, waitUntilAbort } from "openclaw/plugin-sdk/channel-outbound";
@@ -27,6 +26,7 @@ import { CHANNEL_APPROVAL_NATIVE_RUNTIME_CONTEXT_CAPABILITY } from "openclaw/plu
27
26
  import { resolveInboundLastRouteSessionKey } from "openclaw/plugin-sdk/routing";
28
27
  import { buildChannelInboundEventContext, hasFinalInboundReplyDispatch, toInboundMediaFacts } from "openclaw/plugin-sdk/channel-inbound";
29
28
  import { loadSessionStore, resolveSessionStoreEntry } from "openclaw/plugin-sdk/session-store-runtime";
29
+ import { parseStrictFiniteNumber, resolveOptionalIntegerOption } from "openclaw/plugin-sdk/number-runtime";
30
30
  import { readJsonFileWithFallback, writeJsonFileAtomically } from "openclaw/plugin-sdk/json-store";
31
31
  import { format } from "node:util";
32
32
  import { buildTtsSupplementMediaPayload, getReplyPayloadTtsSupplement } from "openclaw/plugin-sdk/reply-payload";
@@ -809,7 +809,7 @@ const SAS_NOTICE_RETRY_DELAY_MS = 750;
809
809
  const VERIFICATION_EVENT_STARTUP_GRACE_MS = 3e4;
810
810
  let matrixDirectRoomDepsPromise;
811
811
  async function loadMatrixDirectRoomDeps() {
812
- matrixDirectRoomDepsPromise ??= Promise.all([import("./send-DivaFHb1.js").then((n) => n.d), import("./send-DivaFHb1.js").then((n) => n.m)]).then(([directManagementModule, directRoomModule]) => ({
812
+ matrixDirectRoomDepsPromise ??= Promise.all([import("./send-DX-aOjPW.js").then((n) => n.d), import("./send-DX-aOjPW.js").then((n) => n.m)]).then(([directManagementModule, directRoomModule]) => ({
813
813
  inspectMatrixDirectRooms: directManagementModule.inspectMatrixDirectRooms,
814
814
  isStrictDirectRoom: directRoomModule.isStrictDirectRoom
815
815
  }));
@@ -1411,9 +1411,9 @@ function parseGeoUri(value) {
1411
1411
  const [coordsPart, ...paramParts] = trimmed.slice(4).split(";");
1412
1412
  const coords = coordsPart.split(",");
1413
1413
  if (coords.length < 2) return null;
1414
- const latitude = Number.parseFloat(coords[0] ?? "");
1415
- const longitude = Number.parseFloat(coords[1] ?? "");
1416
- if (!Number.isFinite(latitude) || !Number.isFinite(longitude)) return null;
1414
+ const latitude = parseStrictFiniteNumber(coords[0] ?? "");
1415
+ const longitude = parseStrictFiniteNumber(coords[1] ?? "");
1416
+ if (latitude === void 0 || longitude === void 0) return null;
1417
1417
  const params = /* @__PURE__ */ new Map();
1418
1418
  for (const part of paramParts) {
1419
1419
  const segment = part.trim();
@@ -1427,11 +1427,10 @@ function parseGeoUri(value) {
1427
1427
  params.set(key, valuePart ? decodeGeoUriParamValue(valuePart) : "");
1428
1428
  }
1429
1429
  const accuracyRaw = params.get("u");
1430
- const accuracy = accuracyRaw ? Number.parseFloat(accuracyRaw) : void 0;
1431
1430
  return {
1432
1431
  latitude,
1433
1432
  longitude,
1434
- accuracy: Number.isFinite(accuracy) ? accuracy : void 0
1433
+ accuracy: accuracyRaw ? parseStrictFiniteNumber(accuracyRaw) : void 0
1435
1434
  };
1436
1435
  }
1437
1436
  function resolveMatrixLocation(params) {
@@ -2018,7 +2017,7 @@ let sessionBindingRuntimePromise;
2018
2017
  let matrixReactionEventsPromise;
2019
2018
  let matrixDraftStreamPromise;
2020
2019
  function loadMatrixSendModule() {
2021
- matrixSendModulePromise ??= import("./send-DivaFHb1.js").then((n) => n.l);
2020
+ matrixSendModulePromise ??= import("./send-DX-aOjPW.js").then((n) => n.l);
2022
2021
  return matrixSendModulePromise;
2023
2022
  }
2024
2023
  function loadAcpBindingRuntime() {
@@ -2030,11 +2029,11 @@ function loadSessionBindingRuntime() {
2030
2029
  return sessionBindingRuntimePromise;
2031
2030
  }
2032
2031
  function loadMatrixReactionEvents() {
2033
- matrixReactionEventsPromise ??= import("./reaction-events-BefH3-Gu.js");
2032
+ matrixReactionEventsPromise ??= import("./reaction-events-gK5X5uu5.js");
2034
2033
  return matrixReactionEventsPromise;
2035
2034
  }
2036
2035
  function loadMatrixDraftStream() {
2037
- matrixDraftStreamPromise ??= import("./draft-stream-BBVqdEbn.js");
2036
+ matrixDraftStreamPromise ??= import("./draft-stream-D7KMDYlS.js");
2038
2037
  return matrixDraftStreamPromise;
2039
2038
  }
2040
2039
  async function matrixTextWouldActivateMentions(client, text) {
@@ -3760,9 +3759,9 @@ function createMatrixRoomInfoResolver(client) {
3760
3759
  let matrixStartupMaintenanceDepsPromise;
3761
3760
  async function loadMatrixStartupMaintenanceDeps() {
3762
3761
  matrixStartupMaintenanceDepsPromise ??= Promise.all([
3763
- import("./setup-core-s8s_Qudu.js").then((n) => n.s),
3762
+ import("./setup-core-BU4BO6DB.js").then((n) => n.s),
3764
3763
  import("./device-health-D4LBxuPq.js"),
3765
- import("./setup-core-s8s_Qudu.js").then((n) => n.a),
3764
+ import("./setup-core-BU4BO6DB.js").then((n) => n.a),
3766
3765
  import("./legacy-crypto-restore-BgW3I87R.js"),
3767
3766
  import("./startup-verification-BmTEngvU.js")
3768
3767
  ]).then(([configUpdateModule, deviceHealthModule, profileModule, legacyCryptoRestoreModule, startupVerificationModule]) => ({
@@ -4108,7 +4107,7 @@ async function monitorMatrixProvider(opts = {}) {
4108
4107
  cfg,
4109
4108
  accountId: effectiveAccountId
4110
4109
  });
4111
- const resolvedInitialSyncLimit = typeof opts.initialSyncLimit === "number" ? Math.max(0, Math.floor(opts.initialSyncLimit)) : auth.initialSyncLimit;
4110
+ const resolvedInitialSyncLimit = resolveOptionalIntegerOption(opts.initialSyncLimit, { min: 0 }) ?? auth.initialSyncLimit;
4112
4111
  const authWithLimit = resolvedInitialSyncLimit === auth.initialSyncLimit ? auth : {
4113
4112
  ...auth,
4114
4113
  initialSyncLimit: resolvedInitialSyncLimit
@@ -3,7 +3,7 @@ import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runti
3
3
  //#region extensions/matrix/src/plugin-entry.runtime.ts
4
4
  let matrixVerificationRuntimePromise;
5
5
  function loadMatrixVerificationRuntime() {
6
- matrixVerificationRuntimePromise ??= import("./verification-Dar6QON4.js").then((n) => n.y);
6
+ matrixVerificationRuntimePromise ??= import("./verification-CUSz9cFP.js").then((n) => n.y);
7
7
  return matrixVerificationRuntimePromise;
8
8
  }
9
9
  function sendError(respond, err) {
@@ -0,0 +1,3 @@
1
+ import { t as createMatrixClient } from "./create-client-D5Ie4y1a.js";
2
+ import "./client-D6nL0ymL.js";
3
+ export { createMatrixClient };
@@ -1,6 +1,6 @@
1
1
  import { t as getMatrixRuntime } from "./runtime-6S3DNFNv.js";
2
- import { c as resolveMatrixConfigPath, l as updateMatrixAccountConfig, o as syncMatrixOwnProfile } from "./setup-core-s8s_Qudu.js";
3
- import { n as withResolvedActionClient } from "./client-BgsOzckO.js";
2
+ import { c as resolveMatrixConfigPath, l as updateMatrixAccountConfig, o as syncMatrixOwnProfile } from "./setup-core-BU4BO6DB.js";
3
+ import { n as withResolvedActionClient } from "./client-DxQ7tWJq.js";
4
4
  import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
5
5
  //#region extensions/matrix/src/matrix/actions/profile.ts
6
6
  async function updateMatrixOwnProfile(opts = {}) {
@@ -7,7 +7,7 @@ import { getSessionBindingService } from "openclaw/plugin-sdk/session-binding-ru
7
7
  let approvalReactionAuthPromise;
8
8
  let execApprovalResolverPromise;
9
9
  function loadApprovalReactionAuth() {
10
- approvalReactionAuthPromise ??= import("./approval-reaction-auth-BvK3dXMH.js");
10
+ approvalReactionAuthPromise ??= import("./approval-reaction-auth-CstZA90i.js");
11
11
  return approvalReactionAuthPromise;
12
12
  }
13
13
  function loadExecApprovalResolver() {
@@ -0,0 +1,294 @@
1
+ import { n as formatMatrixErrorReason, t as formatMatrixErrorMessage } from "./errors-C47hvAF8.js";
2
+ import { f as LogService } from "./shared-CZ622gSf.js";
3
+ import { loadJsonFile, saveJsonFile } from "openclaw/plugin-sdk/json-store";
4
+ import { decodeRecoveryKey } from "matrix-js-sdk/lib/crypto-api/recovery-key.js";
5
+ //#region extensions/matrix/src/matrix/sdk/idb-persistence-lock.ts
6
+ const MATRIX_IDB_PERSIST_INTERVAL_MS = 6e4;
7
+ const IDB_SNAPSHOT_LOCK_STALE_MS = 5 * 6e4;
8
+ const IDB_SNAPSHOT_LOCK_RETRY_BASE = {
9
+ factor: 2,
10
+ minTimeout: 50,
11
+ maxTimeout: 5e3,
12
+ randomize: true
13
+ };
14
+ function computeRetryDelayMs(retries, attempt) {
15
+ return Math.min(retries.maxTimeout, Math.max(retries.minTimeout, retries.minTimeout * retries.factor ** attempt));
16
+ }
17
+ function computeMinimumRetryWindowMs(retries) {
18
+ let total = 0;
19
+ const attempts = Math.max(1, retries.retries + 1);
20
+ for (let attempt = 0; attempt < attempts - 1; attempt += 1) total += computeRetryDelayMs(retries, attempt);
21
+ return total;
22
+ }
23
+ function resolveRetriesForMinimumWindowMs(retries, minimumWindowMs) {
24
+ const resolved = {
25
+ ...retries,
26
+ retries: 0
27
+ };
28
+ while (computeMinimumRetryWindowMs(resolved) < minimumWindowMs) resolved.retries += 1;
29
+ return resolved;
30
+ }
31
+ const MATRIX_IDB_SNAPSHOT_LOCK_OPTIONS = {
32
+ retries: resolveRetriesForMinimumWindowMs(IDB_SNAPSHOT_LOCK_RETRY_BASE, MATRIX_IDB_PERSIST_INTERVAL_MS),
33
+ stale: IDB_SNAPSHOT_LOCK_STALE_MS
34
+ };
35
+ //#endregion
36
+ //#region extensions/matrix/src/matrix/sdk/recovery-key-store.ts
37
+ function isRepairableSecretStorageAccessError(err) {
38
+ const message = formatMatrixErrorReason(err);
39
+ if (!message) return false;
40
+ if (message.includes("getsecretstoragekey callback returned falsey")) return true;
41
+ if (message.includes("decrypting secret") && message.includes("bad mac")) return true;
42
+ return false;
43
+ }
44
+ var MatrixRecoveryKeyStore = class {
45
+ constructor(recoveryKeyPath) {
46
+ this.recoveryKeyPath = recoveryKeyPath;
47
+ this.secretStorageKeyCache = /* @__PURE__ */ new Map();
48
+ this.stagedRecoveryKey = null;
49
+ this.stagedRecoveryKeyUsed = false;
50
+ this.stagedCacheKeyIds = /* @__PURE__ */ new Set();
51
+ }
52
+ buildCryptoCallbacks() {
53
+ return {
54
+ getSecretStorageKey: async ({ keys }) => {
55
+ const requestedKeyIds = Object.keys(keys ?? {});
56
+ if (requestedKeyIds.length === 0) return null;
57
+ const staged = this.resolveStagedSecretStorageKey(requestedKeyIds);
58
+ if (staged) return staged;
59
+ for (const keyId of requestedKeyIds) {
60
+ const cached = this.secretStorageKeyCache.get(keyId);
61
+ if (cached) return [keyId, new Uint8Array(cached.key)];
62
+ }
63
+ const stored = this.loadStoredRecoveryKey();
64
+ if (!stored?.privateKeyBase64) return null;
65
+ const privateKey = new Uint8Array(Buffer.from(stored.privateKeyBase64, "base64"));
66
+ if (privateKey.length === 0) return null;
67
+ if (stored.keyId && requestedKeyIds.includes(stored.keyId)) {
68
+ this.rememberSecretStorageKey(stored.keyId, privateKey, stored.keyInfo);
69
+ return [stored.keyId, privateKey];
70
+ }
71
+ const firstRequestedKeyId = requestedKeyIds[0];
72
+ if (!firstRequestedKeyId) return null;
73
+ this.rememberSecretStorageKey(firstRequestedKeyId, privateKey, stored.keyInfo);
74
+ return [firstRequestedKeyId, privateKey];
75
+ },
76
+ cacheSecretStorageKey: (keyId, keyInfo, key) => {
77
+ const privateKey = new Uint8Array(key);
78
+ const normalizedKeyInfo = {
79
+ passphrase: keyInfo?.passphrase,
80
+ name: typeof keyInfo?.name === "string" ? keyInfo.name : void 0
81
+ };
82
+ this.rememberSecretStorageKey(keyId, privateKey, normalizedKeyInfo);
83
+ const stored = this.loadStoredRecoveryKey();
84
+ this.saveRecoveryKeyToDisk({
85
+ keyId,
86
+ keyInfo: normalizedKeyInfo,
87
+ privateKey,
88
+ encodedPrivateKey: stored?.encodedPrivateKey
89
+ });
90
+ }
91
+ };
92
+ }
93
+ getRecoveryKeySummary() {
94
+ const stored = this.loadStoredRecoveryKey();
95
+ if (!stored) return null;
96
+ return {
97
+ encodedPrivateKey: stored.encodedPrivateKey,
98
+ keyId: stored.keyId,
99
+ createdAt: stored.createdAt
100
+ };
101
+ }
102
+ resolveEncodedRecoveryKeyInput(params) {
103
+ const encodedPrivateKey = params.encodedPrivateKey.trim();
104
+ if (!encodedPrivateKey) throw new Error("Matrix recovery key is required");
105
+ let privateKey;
106
+ try {
107
+ privateKey = decodeRecoveryKey(encodedPrivateKey);
108
+ } catch (err) {
109
+ throw new Error(`Invalid Matrix recovery key: ${formatMatrixErrorMessage(err)}`, { cause: err });
110
+ }
111
+ const keyId = typeof params.keyId === "string" && params.keyId.trim() ? params.keyId.trim() : null;
112
+ return {
113
+ encodedPrivateKey,
114
+ privateKey,
115
+ keyId,
116
+ keyInfo: params.keyInfo ?? this.loadStoredRecoveryKey()?.keyInfo
117
+ };
118
+ }
119
+ storeEncodedRecoveryKey(params) {
120
+ const prepared = this.resolveEncodedRecoveryKeyInput(params);
121
+ this.saveRecoveryKeyToDisk({
122
+ keyId: prepared.keyId,
123
+ keyInfo: prepared.keyInfo,
124
+ privateKey: prepared.privateKey,
125
+ encodedPrivateKey: prepared.encodedPrivateKey
126
+ });
127
+ if (prepared.keyId) this.rememberSecretStorageKey(prepared.keyId, prepared.privateKey, prepared.keyInfo);
128
+ return this.getRecoveryKeySummary() ?? {};
129
+ }
130
+ stageEncodedRecoveryKey(params) {
131
+ const prepared = this.resolveEncodedRecoveryKeyInput(params);
132
+ this.discardStagedRecoveryKey();
133
+ this.stagedRecoveryKey = {
134
+ version: 1,
135
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
136
+ keyId: prepared.keyId,
137
+ encodedPrivateKey: prepared.encodedPrivateKey,
138
+ privateKeyBase64: Buffer.from(prepared.privateKey).toString("base64"),
139
+ keyInfo: prepared.keyInfo
140
+ };
141
+ }
142
+ hasStagedRecoveryKeyBeenUsed() {
143
+ return this.stagedRecoveryKeyUsed;
144
+ }
145
+ commitStagedRecoveryKey(params) {
146
+ if (!this.stagedRecoveryKey) return this.getRecoveryKeySummary();
147
+ const staged = this.stagedRecoveryKey;
148
+ const privateKey = new Uint8Array(Buffer.from(staged.privateKeyBase64, "base64"));
149
+ const keyId = typeof params?.keyId === "string" && params.keyId.trim() ? params.keyId.trim() : staged.keyId;
150
+ this.saveRecoveryKeyToDisk({
151
+ keyId,
152
+ keyInfo: params?.keyInfo ?? staged.keyInfo,
153
+ privateKey,
154
+ encodedPrivateKey: staged.encodedPrivateKey
155
+ });
156
+ this.clearStagedRecoveryKeyTracking();
157
+ return this.getRecoveryKeySummary();
158
+ }
159
+ discardStagedRecoveryKey() {
160
+ for (const keyId of this.stagedCacheKeyIds) this.secretStorageKeyCache.delete(keyId);
161
+ this.clearStagedRecoveryKeyTracking();
162
+ }
163
+ async bootstrapSecretStorageWithRecoveryKey(crypto, options = {}) {
164
+ let status = null;
165
+ const getSecretStorageStatus = crypto.getSecretStorageStatus;
166
+ if (typeof getSecretStorageStatus === "function") try {
167
+ status = await getSecretStorageStatus.call(crypto);
168
+ } catch (err) {
169
+ LogService.warn("MatrixClientLite", "Failed to read secret storage status:", err);
170
+ }
171
+ const hasDefaultSecretStorageKey = Boolean(status?.defaultKeyId);
172
+ const hasKnownInvalidSecrets = Object.values(status?.secretStorageKeyValidityMap ?? {}).some((valid) => !valid);
173
+ let generatedRecoveryKey = false;
174
+ const storedRecovery = this.loadStoredRecoveryKey();
175
+ const stagedRecovery = this.stagedRecoveryKey;
176
+ const sourceRecovery = options.forceNewRecoveryKey === true ? null : stagedRecovery ?? storedRecovery;
177
+ let recoveryKey = sourceRecovery ? {
178
+ keyInfo: sourceRecovery.keyInfo,
179
+ privateKey: new Uint8Array(Buffer.from(sourceRecovery.privateKeyBase64, "base64")),
180
+ encodedPrivateKey: sourceRecovery.encodedPrivateKey
181
+ } : null;
182
+ if (recoveryKey && status?.defaultKeyId) {
183
+ const defaultKeyId = status.defaultKeyId;
184
+ if (!stagedRecovery) {
185
+ this.rememberSecretStorageKey(defaultKeyId, recoveryKey.privateKey, recoveryKey.keyInfo);
186
+ if (storedRecovery && storedRecovery.keyId !== defaultKeyId) this.saveRecoveryKeyToDisk({
187
+ keyId: defaultKeyId,
188
+ keyInfo: recoveryKey.keyInfo,
189
+ privateKey: recoveryKey.privateKey,
190
+ encodedPrivateKey: recoveryKey.encodedPrivateKey
191
+ });
192
+ }
193
+ }
194
+ const ensureRecoveryKey = async () => {
195
+ if (recoveryKey) {
196
+ if (stagedRecovery) this.stagedRecoveryKeyUsed = true;
197
+ return recoveryKey;
198
+ }
199
+ if (typeof crypto.createRecoveryKeyFromPassphrase !== "function") throw new Error("Matrix crypto backend does not support recovery key generation (createRecoveryKeyFromPassphrase missing)");
200
+ recoveryKey = await crypto.createRecoveryKeyFromPassphrase();
201
+ this.saveRecoveryKeyToDisk(recoveryKey);
202
+ generatedRecoveryKey = true;
203
+ return recoveryKey;
204
+ };
205
+ const shouldRecreateSecretStorage = options.forceNewSecretStorage === true || !hasDefaultSecretStorageKey || !recoveryKey && status?.ready === false || hasKnownInvalidSecrets;
206
+ if (hasKnownInvalidSecrets) recoveryKey = null;
207
+ const secretStorageOptions = { setupNewKeyBackup: options.setupNewKeyBackup === true };
208
+ if (shouldRecreateSecretStorage) {
209
+ secretStorageOptions.setupNewSecretStorage = true;
210
+ secretStorageOptions.createSecretStorageKey = ensureRecoveryKey;
211
+ }
212
+ try {
213
+ await crypto.bootstrapSecretStorage(secretStorageOptions);
214
+ } catch (err) {
215
+ if (!(options.allowSecretStorageRecreateWithoutRecoveryKey === true && hasDefaultSecretStorageKey && isRepairableSecretStorageAccessError(err))) throw err;
216
+ recoveryKey = null;
217
+ LogService.warn("MatrixClientLite", "Secret storage exists on the server but local recovery material cannot unlock it; recreating secret storage during explicit bootstrap.");
218
+ await crypto.bootstrapSecretStorage({
219
+ setupNewSecretStorage: true,
220
+ setupNewKeyBackup: options.setupNewKeyBackup === true,
221
+ createSecretStorageKey: ensureRecoveryKey
222
+ });
223
+ }
224
+ if (generatedRecoveryKey && this.recoveryKeyPath) LogService.warn("MatrixClientLite", `Generated Matrix recovery key and saved it to ${this.recoveryKeyPath}. Keep this file secure.`);
225
+ }
226
+ clearStagedRecoveryKeyTracking() {
227
+ this.stagedRecoveryKey = null;
228
+ this.stagedRecoveryKeyUsed = false;
229
+ this.stagedCacheKeyIds.clear();
230
+ }
231
+ resolveStagedSecretStorageKey(requestedKeyIds) {
232
+ const staged = this.stagedRecoveryKey;
233
+ if (!staged?.privateKeyBase64) return null;
234
+ const privateKey = new Uint8Array(Buffer.from(staged.privateKeyBase64, "base64"));
235
+ if (privateKey.length === 0) return null;
236
+ const keyId = staged.keyId && requestedKeyIds.includes(staged.keyId) ? staged.keyId : requestedKeyIds[0];
237
+ if (!keyId) return null;
238
+ this.rememberStagedSecretStorageKey(keyId, privateKey, staged.keyInfo);
239
+ this.stagedCacheKeyIds.add(keyId);
240
+ return [keyId, privateKey];
241
+ }
242
+ rememberStagedSecretStorageKey(keyId, key, keyInfo) {
243
+ this.stagedRecoveryKeyUsed = true;
244
+ this.rememberSecretStorageKey(keyId, key, keyInfo);
245
+ }
246
+ rememberSecretStorageKey(keyId, key, keyInfo) {
247
+ if (!keyId.trim()) return;
248
+ this.secretStorageKeyCache.set(keyId, {
249
+ key: new Uint8Array(key),
250
+ keyInfo
251
+ });
252
+ }
253
+ loadStoredRecoveryKey() {
254
+ if (!this.recoveryKeyPath) return null;
255
+ try {
256
+ const parsed = loadJsonFile(this.recoveryKeyPath);
257
+ if (parsed?.version !== 1 || typeof parsed.createdAt !== "string" || typeof parsed.privateKeyBase64 !== "string" || !parsed.privateKeyBase64.trim()) return null;
258
+ return {
259
+ version: 1,
260
+ createdAt: parsed.createdAt,
261
+ keyId: typeof parsed.keyId === "string" ? parsed.keyId : null,
262
+ encodedPrivateKey: typeof parsed.encodedPrivateKey === "string" ? parsed.encodedPrivateKey : void 0,
263
+ privateKeyBase64: parsed.privateKeyBase64,
264
+ keyInfo: parsed.keyInfo && typeof parsed.keyInfo === "object" ? {
265
+ passphrase: parsed.keyInfo.passphrase,
266
+ name: typeof parsed.keyInfo.name === "string" ? parsed.keyInfo.name : void 0
267
+ } : void 0
268
+ };
269
+ } catch {
270
+ return null;
271
+ }
272
+ }
273
+ saveRecoveryKeyToDisk(params) {
274
+ if (!this.recoveryKeyPath) return;
275
+ try {
276
+ const payload = {
277
+ version: 1,
278
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
279
+ keyId: typeof params.keyId === "string" ? params.keyId : null,
280
+ encodedPrivateKey: params.encodedPrivateKey,
281
+ privateKeyBase64: Buffer.from(params.privateKey).toString("base64"),
282
+ keyInfo: params.keyInfo ? {
283
+ passphrase: params.keyInfo.passphrase,
284
+ name: params.keyInfo.name
285
+ } : void 0
286
+ };
287
+ saveJsonFile(this.recoveryKeyPath, payload);
288
+ } catch (err) {
289
+ LogService.warn("MatrixClientLite", "Failed to persist recovery key:", err);
290
+ }
291
+ }
292
+ };
293
+ //#endregion
294
+ export { MATRIX_IDB_SNAPSHOT_LOCK_OPTIONS as i, isRepairableSecretStorageAccessError as n, MATRIX_IDB_PERSIST_INTERVAL_MS as r, MatrixRecoveryKeyStore as t };
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
2
  import { n as normalizeMatrixMessagingTarget, t as isMatrixQualifiedUserId } from "./target-ids-B-5aQxwn.js";
3
- import { n as listMatrixDirectoryGroupsLive, r as listMatrixDirectoryPeersLive } from "./directory-live-2-Vb6nss.js";
3
+ import { n as listMatrixDirectoryGroupsLive, r as listMatrixDirectoryPeersLive } from "./directory-live-kLKfwyDt.js";
4
4
  import { normalizeOptionalLowercaseString } from "openclaw/plugin-sdk/string-coerce-runtime";
5
5
  //#region extensions/matrix/src/resolve-targets.ts
6
6
  var resolve_targets_exports = /* @__PURE__ */ __exportAll({ resolveMatrixTargets: () => resolveMatrixTargets });
@@ -1,4 +1,4 @@
1
- import { t as resolveMatrixTargets } from "./resolve-targets-BPhBqXyj.js";
1
+ import { t as resolveMatrixTargets } from "./resolve-targets-DaTQqtPq.js";
2
2
  //#region extensions/matrix/src/resolver.runtime.ts
3
3
  const matrixResolverRuntime = { resolveMatrixTargets };
4
4
  //#endregion
@@ -3,7 +3,7 @@ import "openclaw/plugin-sdk/account-id";
3
3
  import { resolveThreadBindingIdleTimeoutMsForChannel, resolveThreadBindingMaxAgeMsForChannel } from "openclaw/plugin-sdk/conversation-runtime";
4
4
  import { resolveOutboundSendDep } from "openclaw/plugin-sdk/channel-outbound";
5
5
  import { chunkTextForOutbound as chunkTextForOutbound$1 } from "openclaw/plugin-sdk/text-chunking";
6
- import { createActionGate as createActionGate$1, jsonResult, readNumberParam as readNumberParam$1, readReactionParams, readStringArrayParam, readStringParam as readStringParam$1 } from "openclaw/plugin-sdk/channel-actions";
6
+ import { createActionGate as createActionGate$1, jsonResult, readPositiveIntegerParam as readPositiveIntegerParam$1, readReactionParams, readStringArrayParam, readStringParam as readStringParam$1 } from "openclaw/plugin-sdk/channel-actions";
7
7
  import "openclaw/plugin-sdk/routing";
8
8
  import "openclaw/plugin-sdk/channel-status";
9
9
  import "openclaw/plugin-sdk/channel-config-primitives";
@@ -18,4 +18,4 @@ import { formatZonedTimestamp } from "openclaw/plugin-sdk/time-runtime";
18
18
  import "openclaw/plugin-sdk/channel-feedback";
19
19
  import { GROUP_POLICY_BLOCKED_LABEL, resolveAllowlistProviderRuntimeGroupPolicy, resolveDefaultGroupPolicy, warnMissingProviderGroupPolicyFallbackOnce } from "openclaw/plugin-sdk/runtime-group-policy";
20
20
  import "openclaw/plugin-sdk/acp-binding-runtime";
21
- export { jsonResult as a, readStringArrayParam as c, resolveDefaultGroupPolicy as d, resolveOutboundSendDep as f, warnMissingProviderGroupPolicyFallbackOnce as h, formatZonedTimestamp as i, readStringParam$1 as l, resolveThreadBindingMaxAgeMsForChannel as m, chunkTextForOutbound$1 as n, readNumberParam$1 as o, resolveThreadBindingIdleTimeoutMsForChannel as p, createActionGate$1 as r, readReactionParams as s, GROUP_POLICY_BLOCKED_LABEL as t, resolveAllowlistProviderRuntimeGroupPolicy as u };
21
+ export { jsonResult as a, readStringArrayParam as c, resolveDefaultGroupPolicy as d, resolveOutboundSendDep as f, warnMissingProviderGroupPolicyFallbackOnce as h, formatZonedTimestamp as i, readStringParam$1 as l, resolveThreadBindingMaxAgeMsForChannel as m, chunkTextForOutbound$1 as n, readPositiveIntegerParam$1 as o, resolveThreadBindingIdleTimeoutMsForChannel as p, createActionGate$1 as r, readReactionParams as s, GROUP_POLICY_BLOCKED_LABEL as t, resolveAllowlistProviderRuntimeGroupPolicy as u };
@@ -3,7 +3,7 @@ import { a as resolveMatrixDefaultOrOnlyAccountId, i as resolveMatrixChannelConf
3
3
  import { n as listMatrixEnvAccountIds, r as resolveMatrixEnvAccountToken, t as getMatrixScopedEnvVarNames } from "./env-vars-KzaYveuy.js";
4
4
  import { r as setMatrixRuntime } from "./runtime-6S3DNFNv.js";
5
5
  import { a as resolveMatrixCredentialsPath, c as resolveMatrixLegacyFlatStoreRoot, i as resolveMatrixCredentialsFilename, l as sanitizeMatrixPathSegment, n as resolveMatrixAccountStorageRoot, o as resolveMatrixHomeserverKey, r as resolveMatrixCredentialsDir, s as resolveMatrixLegacyFlatStoragePaths, t as hashMatrixAccessToken } from "./storage-paths-BV2Z7bns.js";
6
- import { n as ensureMatrixSdkInstalled, r as isMatrixSdkAvailable } from "./deps-CAdiytPJ.js";
6
+ import { n as ensureMatrixSdkInstalled, r as isMatrixSdkAvailable } from "./deps-BVWGd2XS.js";
7
7
  import { assertHttpUrlTargetsPrivateNetwork, closeDispatcher, createPinnedDispatcher, resolvePinnedHostnameWithPolicy, ssrfPolicyFromAllowPrivateNetwork, ssrfPolicyFromDangerouslyAllowPrivateNetwork } from "openclaw/plugin-sdk/ssrf-runtime";
8
8
  import { writeJsonFileAtomically } from "openclaw/plugin-sdk/json-store";
9
9
  import { formatZonedTimestamp } from "openclaw/plugin-sdk/time-runtime";
@@ -1,3 +1,3 @@
1
- import { a as detectLegacyMatrixCrypto, i as autoPrepareLegacyMatrixCrypto, n as hasPendingMatrixMigration, o as autoMigrateLegacyMatrixState, r as resolveMatrixMigrationStatus, s as detectLegacyMatrixState, t as hasActionableMatrixMigration } from "./matrix-migration.runtime-BhJb4ZII.js";
1
+ import { a as detectLegacyMatrixCrypto, i as autoPrepareLegacyMatrixCrypto, n as hasPendingMatrixMigration, o as autoMigrateLegacyMatrixState, r as resolveMatrixMigrationStatus, s as detectLegacyMatrixState, t as hasActionableMatrixMigration } from "./matrix-migration.runtime-CZOep_JX.js";
2
2
  import { t as maybeCreateMatrixMigrationSnapshot } from "./migration-snapshot-backup-YcCrSjbE.js";
3
3
  export { autoMigrateLegacyMatrixState, autoPrepareLegacyMatrixCrypto, detectLegacyMatrixCrypto, detectLegacyMatrixState, hasActionableMatrixMigration, hasPendingMatrixMigration, maybeCreateMatrixMigrationSnapshot, resolveMatrixMigrationStatus };