@openclaw/matrix 2026.9.1 → 2026.9.3

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 (91) hide show
  1. package/dist/{account-selection-DA-jfx22.js → account-selection-Bbtc483D.js} +9 -1
  2. package/dist/{accounts-DR1c4xF_.js → accounts-GwSAk9vY.js} +2 -2
  3. package/dist/api.js +6 -6
  4. package/dist/{approval-handler.runtime-B_6ytY5I.js → approval-handler.runtime-tJLn5JFB.js} +6 -6
  5. package/dist/{approval-ids-CfHtZ9d1.js → approval-ids-DJZ9ZTuS.js} +1 -1
  6. package/dist/{approval-reaction-auth-BpDvJqfy.js → approval-reaction-auth-Cd0sKHFc.js} +2 -2
  7. package/dist/{channel-b-jES-oi.js → channel-BpYiqmx-.js} +10 -39
  8. package/dist/channel-plugin-api.js +1 -1
  9. package/dist/{channel.runtime-BkqjwEDU.js → channel.runtime-dfEvRdLQ.js} +6 -11
  10. package/dist/{channel.setup-BY42QaL7.js → channel.setup-oxd8RsIr.js} +7 -4
  11. package/dist/{cli-CtYeU7ol.js → cli-_49Vsqs4.js} +149 -115
  12. package/dist/{cli-metadata-B7MQjR5S.js → cli-metadata-D19lmKmz.js} +1 -1
  13. package/dist/cli-metadata.js +1 -1
  14. package/dist/{client-D2utPQ1E.js → client-BXQCQDfY.js} +2 -2
  15. package/dist/{client-Dj4mcf-s.js → client-COLiUdWe.js} +6 -6
  16. package/dist/{client-bootstrap-n1Rqc8Go.js → client-bootstrap-CQwf9qrm.js} +1 -6
  17. package/dist/contract-api.js +2 -2
  18. package/dist/{credentials-DJj2xs3q.js → credentials-DysXbkv2.js} +2 -2
  19. package/dist/{credentials-read-mexhw-Ur.js → credentials-read-WWpqi88V.js} +1 -1
  20. package/dist/{credentials-write.runtime-DQt-kgJq.js → credentials-write.runtime-D22lPwRO.js} +1 -1
  21. package/dist/{crypto-runtime-m1eplj3b.js → crypto-runtime-BvunIYVn.js} +2 -2
  22. package/dist/{crypto-snapshot-doctor.runtime-D0v841D_.js → crypto-snapshot-doctor.runtime-DxgUMXUy.js} +2 -2
  23. package/dist/{directory-live-DLUgWBhA.js → directory-live-DABCxf8j.js} +2 -2
  24. package/dist/doctor-contract-api.js +43 -23
  25. package/dist/{draft-stream-DPYdv4fE.js → draft-stream-DSwgyyBi.js} +16 -5
  26. package/dist/{encryption-guidance-BNcZNQZI.js → encryption-guidance-mDyxJV9U.js} +1 -1
  27. package/dist/{event-helpers-XRfAbOIh.js → event-helpers-CspuhE9k.js} +9 -1
  28. package/dist/helper-api.js +3 -3
  29. package/dist/{http-client-DOmFvKvB.js → http-client-BfPeF4CE.js} +1 -1
  30. package/dist/{idb-persistence-CU7CNLlX.js → idb-persistence-DBdwHSWg.js} +1 -1
  31. package/dist/index.js +1 -1
  32. package/dist/{messages-C1U3b1oN.js → messages-H4mi9Cap.js} +6 -99
  33. package/dist/{monitor-SNnu-0bp.js → monitor-3Fw96uiE.js} +84 -118
  34. package/dist/{outbound-CeCEtF_q.js → outbound-UPI45TD_.js} +1 -1
  35. package/dist/plugin-entry.handlers.runtime.js +1 -1
  36. package/dist/probe.runtime-DdXTrrmo.js +2 -0
  37. package/dist/{profile-update-Cd1p8ABr.js → profile-update-DWEg8Ylt.js} +1 -1
  38. package/dist/{reaction-events-DveJRUaX.js → reaction-events-D-iSW0iM.js} +5 -7
  39. package/dist/{resolve-targets-B64O69Nd.js → resolve-targets-BpnALDzR.js} +1 -1
  40. package/dist/{resolver.runtime-TRmePJDV.js → resolver.runtime-B83WkznZ.js} +1 -1
  41. package/dist/{room-info-DVkKDscD.js → room-info-CjnbX52D.js} +7 -4
  42. package/dist/runtime-api.js +2 -2
  43. package/dist/{sdk-C1yfda1L.js → sdk-CX9b0N8Q.js} +13 -6
  44. package/dist/{send-DG7Bnj7_.js → send-B9l1lKau.js} +201 -97
  45. package/dist/session-binding-contract-api.js +1 -1
  46. package/dist/{setup-bootstrap-Co985F63.js → setup-bootstrap-CSI1L1lm.js} +2 -2
  47. package/dist/{setup-core-CEF6exLW.js → setup-core-DuTlyqRz.js} +3 -3
  48. package/dist/setup-plugin-api.js +1 -1
  49. package/dist/{setup-surface-BSlj1vnL.js → setup-surface-fZing1WZ.js} +6 -6
  50. package/dist/{startup-verification-1Ney1mmI.js → startup-verification-BTSf31hS.js} +2 -1
  51. package/dist/storage-CV-pfV_2.js +320 -0
  52. package/dist/{storage-BVf4uucD.js → storage-metadata-DYArLcq1.js} +14 -319
  53. package/dist/{storage-paths-gUmSydsW.js → storage-paths-DVCANXTc.js} +13 -1
  54. package/dist/{sync-cache-state-d-A_OhbU.js → sync-cache-state-C-mhj3xb.js} +9 -3
  55. package/dist/{thread-bindings-DgxQEB99.js → thread-bindings-CRyf5on_.js} +3 -2
  56. package/dist/{tool-actions.runtime-vbkQgU7D.js → tool-actions.runtime-D5-hTkDu.js} +10 -10
  57. package/dist/types-DzSc7Sqm.js +32 -0
  58. package/dist/{verification-D-iOebn4.js → verification-B_aqtbx-.js} +2 -2
  59. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/package.json +1 -1
  60. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm.d.ts +69 -4
  61. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.cjs +526 -432
  62. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.js +358 -265
  63. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.wasm +0 -0
  64. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.wasm.d.ts +8 -7
  65. package/node_modules/markdown-it/dist/browser/markdown-it.esm.min.mjs +216 -183
  66. package/node_modules/markdown-it/dist/browser/markdown-it.esm.min.mjs.map +1 -1
  67. package/node_modules/markdown-it/dist/browser/markdown-it.umd.min.js +7 -7
  68. package/node_modules/markdown-it/dist/browser/markdown-it.umd.min.js.map +1 -1
  69. package/node_modules/markdown-it/dist/markdown-it.cjs.js +98 -106
  70. package/node_modules/markdown-it/dist/markdown-it.cjs.js.map +1 -1
  71. package/node_modules/markdown-it/dist/markdown-it.d.mts +42 -71
  72. package/node_modules/markdown-it/dist/markdown-it.mjs +98 -106
  73. package/node_modules/markdown-it/dist/markdown-it.mjs.map +1 -1
  74. package/node_modules/markdown-it/package.json +1 -2
  75. package/node_modules/typebox/build/format/json_pointer.d.mts +2 -2
  76. package/node_modules/typebox/build/format/json_pointer.mjs +2 -2
  77. package/node_modules/typebox/build/format/json_pointer_uri_fragment.d.mts +2 -2
  78. package/node_modules/typebox/build/format/json_pointer_uri_fragment.mjs +2 -2
  79. package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
  80. package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
  81. package/node_modules/typebox/build/system/memory/assign.mjs +2 -1
  82. package/node_modules/typebox/build/system/memory/create.mjs +3 -4
  83. package/node_modules/typebox/build/system/memory/discard.mjs +2 -2
  84. package/node_modules/typebox/build/system/memory/freeze.d.mts +4 -0
  85. package/node_modules/typebox/build/system/memory/freeze.mjs +6 -0
  86. package/node_modules/typebox/build/system/memory/update.mjs +3 -2
  87. package/node_modules/typebox/package.json +1 -1
  88. package/openclaw.plugin.json +24 -3
  89. package/package.json +7 -7
  90. package/dist/probe.runtime-B1YPxG9x.js +0 -2
  91. package/dist/runtime-BefyhPWv.js +0 -6
@@ -2,7 +2,7 @@ import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
2
2
  //#region extensions/matrix/src/cli-metadata.ts
3
3
  function registerMatrixCliMetadata(api) {
4
4
  api.registerCli(async ({ program }) => {
5
- const { registerMatrixCli } = await import("./cli-CtYeU7ol.js");
5
+ const { registerMatrixCli } = await import("./cli-_49Vsqs4.js");
6
6
  registerMatrixCli({ program });
7
7
  }, { descriptors: [{
8
8
  name: "matrix",
@@ -1,2 +1,2 @@
1
- import { n as registerMatrixCliMetadata, t as cli_metadata_default } from "./cli-metadata-B7MQjR5S.js";
1
+ import { n as registerMatrixCliMetadata, t as cli_metadata_default } from "./cli-metadata-D19lmKmz.js";
2
2
  export { cli_metadata_default as default, registerMatrixCliMetadata };
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
- import { b as resolveMatrixRoomId } from "./send-DG7Bnj7_.js";
3
- import { n as withResolvedRuntimeMatrixClient } from "./client-bootstrap-n1Rqc8Go.js";
2
+ import { O as resolveMatrixRoomId } from "./send-B9l1lKau.js";
3
+ import { n as withResolvedRuntimeMatrixClient } from "./client-bootstrap-CQwf9qrm.js";
4
4
  //#region extensions/matrix/src/matrix/actions/client.ts
5
5
  var client_exports = /* @__PURE__ */ __exportAll({
6
6
  withResolvedActionClient: () => withResolvedActionClient,
@@ -1,10 +1,10 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
- import { a as resolveMatrixDefaultOrOnlyAccountId, c as resolveScopedMatrixEnvConfig, l as resolveMatrixAccountStringValues, n as requiresExplicitMatrixDefaultAccount, o as resolveGlobalMatrixEnvConfig } from "./account-selection-DA-jfx22.js";
2
+ import { l as resolveScopedMatrixEnvConfig, o as resolveMatrixDefaultOrOnlyAccountId, r as requiresExplicitMatrixDefaultAccount, s as resolveGlobalMatrixEnvConfig, u as resolveMatrixAccountStringValues } from "./account-selection-Bbtc483D.js";
3
3
  import { t as getMatrixScopedEnvVarNames } from "./env-vars-dGqak9dN.js";
4
4
  import { o as resolveMatrixBaseConfig, r as listNormalizedMatrixAccountIds, t as findMatrixAccountConfig } from "./account-config-CRsKoMqJ.js";
5
5
  import { t as resolveMatrixConfigFieldPath } from "./config-paths-CnREYb1Y.js";
6
6
  import { t as resolveValidatedMatrixHomeserverUrl } from "./url-validation-GRHde6lq.js";
7
- import { d as writeStorageMeta, l as resolveMatrixStoragePaths, r as maybeMigrateLegacyStorage, s as repairCurrentTokenStorageMetaDeviceId } from "./storage-BVf4uucD.js";
7
+ import { i as repairCurrentTokenStorageMetaDeviceId, n as maybeMigrateLegacyStorage, o as resolveMatrixStoragePaths, s as writeStorageMeta } from "./storage-CV-pfV_2.js";
8
8
  import { n as LogService } from "./logger-B_71hN6W.js";
9
9
  import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
10
10
  import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
@@ -20,13 +20,13 @@ import { sleepWithAbort } from "openclaw/plugin-sdk/runtime-env";
20
20
  import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
21
21
  import { AsyncLocalStorage } from "node:async_hooks";
22
22
  //#region extensions/matrix/src/matrix/client/config.ts
23
- const loadMatrixAuthClientDeps = createLazyRuntimeModule(() => Promise.all([import("./sdk-C1yfda1L.js").then((n) => n.t), import("./logging-DRjvUOIh.js").then((n) => n.n)]).then(([sdkModule, loggingModule]) => ({
23
+ const loadMatrixAuthClientDeps = createLazyRuntimeModule(() => Promise.all([import("./sdk-CX9b0N8Q.js").then((n) => n.t), import("./logging-DRjvUOIh.js").then((n) => n.n)]).then(([sdkModule, loggingModule]) => ({
24
24
  MatrixClient: sdkModule.MatrixClient,
25
25
  ensureMatrixSdkLoggingConfigured: loggingModule.ensureMatrixSdkLoggingConfigured
26
26
  })));
27
27
  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;
28
- const loadMatrixCredentialsReadDeps = createLazyRuntimeModule(() => import("./credentials-read-mexhw-Ur.js").then((n) => n.r));
29
- const loadMatrixCredentialsWriteRuntime = createLazyRuntimeModule(() => import("./credentials-write.runtime-DQt-kgJq.js"));
28
+ const loadMatrixCredentialsReadDeps = createLazyRuntimeModule(() => import("./credentials-read-WWpqi88V.js").then((n) => n.r));
29
+ const loadMatrixCredentialsWriteRuntime = createLazyRuntimeModule(() => import("./credentials-write.runtime-D22lPwRO.js"));
30
30
  const loadMatrixSecretInputDeps = createLazyRuntimeModule(() => import("./config-secret-input.runtime-CwsP3--c.js"));
31
31
  function shouldRetryMatrixAuthRequest(err) {
32
32
  return MATRIX_AUTH_REQUEST_RETRY_RE.test(formatErrorMessage(err));
@@ -416,7 +416,7 @@ async function backfillMatrixAuthDeviceIdAfterStartup(params) {
416
416
  //#endregion
417
417
  //#region extensions/matrix/src/matrix/client/create-client.ts
418
418
  var create_client_exports = /* @__PURE__ */ __exportAll({ createMatrixClient: () => createMatrixClient });
419
- const loadMatrixCreateClientRuntimeDeps = createLazyRuntimeModule(() => Promise.all([import("./sdk-C1yfda1L.js").then((n) => n.t), import("./logging-DRjvUOIh.js").then((n) => n.n)]).then(([sdkModule, loggingModule]) => ({
419
+ const loadMatrixCreateClientRuntimeDeps = createLazyRuntimeModule(() => Promise.all([import("./sdk-CX9b0N8Q.js").then((n) => n.t), import("./logging-DRjvUOIh.js").then((n) => n.n)]).then(([sdkModule, loggingModule]) => ({
420
420
  MatrixClient: sdkModule.MatrixClient,
421
421
  ensureMatrixSdkLoggingConfigured: loggingModule.ensureMatrixSdkLoggingConfigured
422
422
  })));
@@ -1,5 +1,4 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
- import { t as isBunRuntime } from "./runtime-BefyhPWv.js";
3
2
  import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
4
3
  import { requireRuntimeConfig } from "openclaw/plugin-sdk/plugin-config-runtime";
5
4
  //#region extensions/matrix/src/matrix/client-bootstrap.ts
@@ -7,7 +6,7 @@ var client_bootstrap_exports = /* @__PURE__ */ __exportAll({
7
6
  resolveRuntimeMatrixClientWithReadiness: () => resolveRuntimeMatrixClientWithReadiness,
8
7
  withResolvedRuntimeMatrixClient: () => withResolvedRuntimeMatrixClient
9
8
  });
10
- const loadMatrixSharedClientRuntimeDeps = createLazyRuntimeModule(() => import("./client-Dj4mcf-s.js").then((n) => n.t).then((clientModule) => ({
9
+ const loadMatrixSharedClientRuntimeDeps = createLazyRuntimeModule(() => import("./client-COLiUdWe.js").then((n) => n.t).then((clientModule) => ({
11
10
  acquireSharedMatrixClient: clientModule.acquireSharedMatrixClient,
12
11
  resolveMatrixAuthContext: clientModule.resolveMatrixAuthContext
13
12
  })));
@@ -19,11 +18,7 @@ async function ensureResolvedClientReadiness(params) {
19
18
  }
20
19
  if (params.readiness === "prepared" || !params.readiness && params.preparedByDefault) await params.client.prepareForOneOff();
21
20
  }
22
- function ensureMatrixNodeRuntime() {
23
- if (isBunRuntime()) throw new Error("Matrix support requires Node (bun runtime not supported)");
24
- }
25
21
  async function resolveRuntimeMatrixClientWithReadiness(opts) {
26
- ensureMatrixNodeRuntime();
27
22
  if (opts.client) {
28
23
  await ensureResolvedClientReadiness({
29
24
  client: opts.client,
@@ -1,3 +1,3 @@
1
- import { c as singleAccountKeysToMove, n as matrixSetupAdapter, o as namedAccountPromotionKeys, s as resolveSingleAccountPromotionTarget } from "./setup-core-CEF6exLW.js";
2
- import { n as matrixOnboardingAdapter } from "./setup-surface-BSlj1vnL.js";
1
+ import { c as singleAccountKeysToMove, n as matrixSetupAdapter, o as namedAccountPromotionKeys, s as resolveSingleAccountPromotionTarget } from "./setup-core-DuTlyqRz.js";
2
+ import { n as matrixOnboardingAdapter } from "./setup-surface-fZing1WZ.js";
3
3
  export { matrixSetupAdapter, matrixOnboardingAdapter as matrixSetupWizard, namedAccountPromotionKeys, resolveSingleAccountPromotionTarget, singleAccountKeysToMove };
@@ -1,6 +1,6 @@
1
1
  import { i as normalizeMatrixStoredCredentials, n as isMatrixCredentialRevocation, r as matrixCredentialsStoreKey } from "./credentials-state-B3cuUFwZ.js";
2
- import { a as resolveMatrixCredentialsPath, r as resolveMatrixCredentialsDir } from "./storage-paths-gUmSydsW.js";
3
- import { a as openMatrixCredentialsStore, i as loadMatrixCredentials, n as credentialsMatchConfig, t as clearMatrixCredentials } from "./credentials-read-mexhw-Ur.js";
2
+ import { i as resolveMatrixCredentialsDir, o as resolveMatrixCredentialsPath } from "./storage-paths-DVCANXTc.js";
3
+ import { a as openMatrixCredentialsStore, i as loadMatrixCredentials, n as credentialsMatchConfig, t as clearMatrixCredentials } from "./credentials-read-WWpqi88V.js";
4
4
  import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
5
5
  //#region extensions/matrix/src/matrix/credentials.ts
6
6
  async function saveMatrixCredentials(credentials, env = process.env, accountId) {
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
2
  import { n as getOptionalMatrixRuntime } from "./runtime-6S3DNFNv.js";
3
3
  import { i as normalizeMatrixStoredCredentials, r as matrixCredentialsStoreKey, t as MATRIX_CREDENTIALS_NAMESPACE } from "./credentials-state-B3cuUFwZ.js";
4
- import { a as resolveMatrixCredentialsPath, r as resolveMatrixCredentialsDir } from "./storage-paths-gUmSydsW.js";
4
+ import { i as resolveMatrixCredentialsDir, o as resolveMatrixCredentialsPath } from "./storage-paths-DVCANXTc.js";
5
5
  import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
6
6
  import { createPluginStateSyncKeyedStore } from "openclaw/plugin-sdk/plugin-state-store-runtime";
7
7
  //#region extensions/matrix/src/matrix/credentials-read.ts
@@ -1,6 +1,6 @@
1
1
  import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
2
2
  //#region extensions/matrix/src/matrix/credentials-write.runtime.ts
3
- const loadMatrixCredentialsRuntime = createLazyRuntimeModule(() => import("./credentials-DJj2xs3q.js"));
3
+ const loadMatrixCredentialsRuntime = createLazyRuntimeModule(() => import("./credentials-DysXbkv2.js"));
4
4
  async function saveMatrixCredentials(...args) {
5
5
  return (await loadMatrixCredentialsRuntime()).saveMatrixCredentials(...args);
6
6
  }
@@ -1,7 +1,7 @@
1
1
  import { t as ensureMatrixCryptoRuntime } from "./deps-mtxF2mHI.js";
2
2
  import { n as LogService, r as noop } from "./logger-B_71hN6W.js";
3
- import { i as restoreIdbFromDisk, n as persistIdbToDisk } from "./idb-persistence-CU7CNLlX.js";
4
- import { n as isRepairableSecretStorageAccessError } from "./sdk-C1yfda1L.js";
3
+ import { i as restoreIdbFromDisk, n as persistIdbToDisk } from "./idb-persistence-DBdwHSWg.js";
4
+ import { n as isRepairableSecretStorageAccessError } from "./sdk-CX9b0N8Q.js";
5
5
  import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
6
6
  import { formatErrorMessage, toStringifiedError } from "openclaw/plugin-sdk/error-runtime";
7
7
  import { resolveDateTimestampMs, resolveTimestampMsToIsoString } from "openclaw/plugin-sdk/number-runtime";
@@ -1,6 +1,6 @@
1
- import { O as writeMatrixIdbSnapshotJsonToStore, T as readMatrixIdbSnapshotJsonFromStore, f as MATRIX_IDB_SNAPSHOT_FILENAME, v as openMatrixIdbSnapshotStoreOptions } from "./storage-BVf4uucD.js";
1
+ import { T as writeMatrixIdbSnapshotJsonToStore, m as openMatrixIdbSnapshotStoreOptions, o as MATRIX_IDB_SNAPSHOT_FILENAME, x as readMatrixIdbSnapshotJsonFromStore } from "./storage-metadata-DYArLcq1.js";
2
2
  import { n as MATRIX_IDB_SNAPSHOT_LOCK_OPTIONS } from "./idb-persistence-lock-B3fZXyF_.js";
3
- import { r as readLegacyMatrixIdbSnapshotStateUnlocked, t as isValidMatrixIdbSnapshotJson } from "./idb-persistence-CU7CNLlX.js";
3
+ import { r as readLegacyMatrixIdbSnapshotStateUnlocked, t as isValidMatrixIdbSnapshotJson } from "./idb-persistence-DBdwHSWg.js";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import path from "node:path";
6
6
  import fs from "node:fs";
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
2
  import { r as normalizeMatrixMessagingTarget, t as isMatrixQualifiedUserId } from "./target-ids-Nwx7cMVE.js";
3
- import { l as resolveMatrixAuth } from "./client-Dj4mcf-s.js";
4
- import { t as MatrixAuthedHttpClient } from "./http-client-DOmFvKvB.js";
3
+ import { l as resolveMatrixAuth } from "./client-COLiUdWe.js";
4
+ import { t as MatrixAuthedHttpClient } from "./http-client-BfPeF4CE.js";
5
5
  import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
6
6
  //#region extensions/matrix/src/directory-live.ts
7
7
  var directory_live_exports = /* @__PURE__ */ __exportAll({
@@ -1,9 +1,8 @@
1
- import { a as resolveMatrixDefaultOrOnlyAccountId, n as requiresExplicitMatrixDefaultAccount } from "./account-selection-DA-jfx22.js";
2
1
  import { i as normalizeMatrixStoredCredentials, n as isMatrixCredentialRevocation, r as matrixCredentialsStoreKey, t as MATRIX_CREDENTIALS_NAMESPACE } from "./credentials-state-B3cuUFwZ.js";
3
- import { r as resolveMatrixCredentialsDir } from "./storage-paths-gUmSydsW.js";
2
+ import { c as resolveMatrixStateLayoutChildDepth, i as resolveMatrixCredentialsDir } from "./storage-paths-DVCANXTc.js";
4
3
  import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-HyWFZQVG.js";
5
- import { C as readLegacyMatrixRecoveryKeyState, M as resolveMatrixSqliteStateEnv, a as openMatrixStorageMetaStoreOptions, b as openMatrixRecoveryKeyStoreOptions, f as MATRIX_IDB_SNAPSHOT_FILENAME, g as hasMatrixRecoveryKeyStateInStore, h as hasMatrixLegacyCryptoMigrationStateInStore, i as normalizeMatrixStorageMetadata, j as writeMatrixRecoveryKeyStateToStore, k as writeMatrixLegacyCryptoMigrationStateToStore, m as MATRIX_RECOVERY_KEY_FILENAME, n as hasMatrixStorageMetaStateInStore, p as MATRIX_LEGACY_CRYPTO_MIGRATION_FILENAME, u as writeMatrixStorageMetaStateToStore, x as readLegacyMatrixLegacyCryptoMigrationState, y as openMatrixLegacyCryptoMigrationStoreOptions } from "./storage-BVf4uucD.js";
6
- import { a as readLegacyMatrixSyncCacheState, c as writeMatrixSyncCacheStateToStore, i as openMatrixSyncCacheStoreOptions, r as hasMatrixSyncCacheStateInStore } from "./sync-cache-state-d-A_OhbU.js";
4
+ import { E as writeMatrixLegacyCryptoMigrationStateToStore, O as writeMatrixRecoveryKeyStateToStore, _ as readLegacyMatrixLegacyCryptoMigrationState, a as writeMatrixStorageMetaStateToStore, c as MATRIX_RECOVERY_KEY_FILENAME, g as openMatrixRecoveryKeyStoreOptions, h as openMatrixLegacyCryptoMigrationStoreOptions, i as openMatrixStorageMetaStoreOptions, k as resolveMatrixSqliteStateEnv, l as hasMatrixLegacyCryptoMigrationStateInStore, n as hasMatrixStorageMetaStateInStore, o as MATRIX_IDB_SNAPSHOT_FILENAME, r as normalizeMatrixStorageMetadata, s as MATRIX_LEGACY_CRYPTO_MIGRATION_FILENAME, u as hasMatrixRecoveryKeyStateInStore, y as readLegacyMatrixRecoveryKeyState } from "./storage-metadata-DYArLcq1.js";
5
+ import { a as readLegacyMatrixSyncCacheState, c as writeMatrixSyncCacheStateToStore, i as openMatrixSyncCacheStoreOptions, r as hasMatrixSyncCacheStateInStore } from "./sync-cache-state-C-mhj3xb.js";
7
6
  import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
8
7
  import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
9
8
  import { createHash } from "node:crypto";
@@ -13,9 +12,9 @@ import fs from "node:fs/promises";
13
12
  //#region extensions/matrix/src/matrix/account-state-schema-doctor.ts
14
13
  const STATE_DATABASE_FILENAME = "openclaw.sqlite";
15
14
  async function collectMatrixAccountStateRoots(stateDir) {
16
- const accountsRoot = path.join(stateDir, "matrix", "accounts");
15
+ const matrixRoot = path.join(stateDir, "matrix");
17
16
  const roots = /* @__PURE__ */ new Set();
18
- async function visit(dir, allowMissing = false) {
17
+ async function visit(dir, depth, allowMissing = false) {
19
18
  let entries;
20
19
  try {
21
20
  entries = await fs.readdir(dir, { withFileTypes: true });
@@ -25,11 +24,20 @@ async function collectMatrixAccountStateRoots(stateDir) {
25
24
  }
26
25
  for (const entry of entries) {
27
26
  const entryPath = path.join(dir, entry.name);
28
- if (entry.isFile() && entry.name === STATE_DATABASE_FILENAME && path.basename(dir) === "state") roots.add(path.dirname(dir));
29
- else if (entry.isDirectory()) await visit(entryPath);
27
+ if (entry.isFile() && depth === 5 && entry.name === STATE_DATABASE_FILENAME) {
28
+ roots.add(path.dirname(dir));
29
+ continue;
30
+ }
31
+ if (!entry.isDirectory()) continue;
32
+ if ((depth === 2 || depth === 4) && entry.name === "state") {
33
+ await visit(entryPath, 5);
34
+ continue;
35
+ }
36
+ const childDepth = resolveMatrixStateLayoutChildDepth(depth, entry.name);
37
+ if (childDepth !== null) await visit(entryPath, childDepth);
30
38
  }
31
39
  }
32
- await visit(accountsRoot, true);
40
+ await visit(matrixRoot, 0, true);
33
41
  return [...roots].toSorted();
34
42
  }
35
43
  function describeMatrixAccountStateMigration(storageRootDir, migration) {
@@ -39,9 +47,9 @@ const matrixAccountStateSchemaMigration = {
39
47
  id: "matrix-account-sqlite-schema",
40
48
  label: "Matrix account SQLite schemas",
41
49
  async detectLegacyState(params) {
42
- const { detectOpenClawStateDatabaseSchemaMigrations } = await import("openclaw/plugin-sdk/doctor-repair-runtime");
43
50
  const preview = [];
44
51
  for (const storageRootDir of await collectMatrixAccountStateRoots(params.stateDir)) {
52
+ const { detectOpenClawStateDatabaseSchemaMigrations } = await import("openclaw/plugin-sdk/doctor-repair-runtime");
45
53
  const env = resolveMatrixSqliteStateEnv({
46
54
  env: params.env,
47
55
  stateDir: storageRootDir
@@ -51,10 +59,10 @@ const matrixAccountStateSchemaMigration = {
51
59
  return preview.length > 0 ? { preview } : null;
52
60
  },
53
61
  async migrateLegacyState(params) {
54
- const { detectOpenClawStateDatabaseSchemaMigrations, repairOpenClawStateDatabaseSchema } = await import("openclaw/plugin-sdk/doctor-repair-runtime");
55
62
  const changes = [];
56
63
  const warnings = [];
57
64
  for (const storageRootDir of await collectMatrixAccountStateRoots(params.stateDir)) {
65
+ const { detectOpenClawStateDatabaseSchemaMigrations, repairOpenClawStateDatabaseSchema } = await import("openclaw/plugin-sdk/doctor-repair-runtime");
58
66
  const env = resolveMatrixSqliteStateEnv({
59
67
  env: params.env,
60
68
  stateDir: storageRootDir
@@ -115,7 +123,7 @@ async function collectMatrixInboundDedupeSources(stateDir) {
115
123
  const sqliteRoots = /* @__PURE__ */ new Set();
116
124
  const jsonRoots = /* @__PURE__ */ new Set();
117
125
  const warnings = [];
118
- async function visit(dir, allowMissing = false) {
126
+ async function visit(dir, depth, allowMissing = false) {
119
127
  let entries;
120
128
  try {
121
129
  entries = await fs.readdir(dir, { withFileTypes: true });
@@ -124,17 +132,24 @@ async function collectMatrixInboundDedupeSources(stateDir) {
124
132
  warnings.push(`Failed scanning Matrix inbound dedupe sources under ${dir}: ${String(err)}`);
125
133
  return;
126
134
  }
135
+ const isStorageRoot = depth === 0 || depth === 2 || depth === 4;
127
136
  for (const entry of entries) {
128
137
  const entryPath = path.join(dir, entry.name);
129
138
  if (entry.isFile()) {
130
- if (entry.name === "openclaw.sqlite" && path.basename(dir) === "state") sqliteRoots.add(path.dirname(dir));
131
- else if (entry.name === "inbound-dedupe.json") jsonRoots.add(dir);
139
+ if (isStorageRoot && entry.name === "inbound-dedupe.json") jsonRoots.add(dir);
140
+ else if (depth === 5 && entry.name === "openclaw.sqlite") sqliteRoots.add(path.dirname(dir));
141
+ continue;
142
+ }
143
+ if (!entry.isDirectory()) continue;
144
+ if (isStorageRoot && entry.name === "state") {
145
+ await visit(entryPath, 5);
132
146
  continue;
133
147
  }
134
- if (entry.isDirectory()) await visit(entryPath);
148
+ const childDepth = resolveMatrixStateLayoutChildDepth(depth, entry.name);
149
+ if (childDepth !== null) await visit(entryPath, childDepth);
135
150
  }
136
151
  }
137
- await visit(matrixRoot, true);
152
+ await visit(matrixRoot, 0, true);
138
153
  const matrixRootResolved = path.resolve(matrixRoot);
139
154
  const isAccountRoot = (root) => path.resolve(root) !== matrixRootResolved;
140
155
  const roots = {
@@ -368,11 +383,14 @@ async function collectLegacyMatrixCredentialSources(params) {
368
383
  } catch {
369
384
  return [];
370
385
  }
371
- return entries.filter((entry) => entry.isFile() && /^credentials(?:-[a-z0-9._-]+)?\.json$/iu.test(entry.name)).toSorted((left, right) => {
386
+ const files = entries.filter((entry) => entry.isFile() && /^credentials(?:-[a-z0-9._-]+)?\.json$/iu.test(entry.name)).toSorted((left, right) => {
372
387
  if (left.name === "credentials.json") return 1;
373
388
  if (right.name === "credentials.json") return -1;
374
389
  return left.name.localeCompare(right.name);
375
- }).map((entry) => {
390
+ });
391
+ if (files.length === 0) return [];
392
+ const { requiresExplicitMatrixDefaultAccount, resolveMatrixDefaultOrOnlyAccountId } = await import("./account-selection-Bbtc483D.js").then((n) => n.t);
393
+ return files.map((entry) => {
376
394
  const namedAccount = /^credentials(?:-([a-z0-9._-]+))?\.json$/iu.exec(entry.name)?.[1];
377
395
  return {
378
396
  accountId: namedAccount ? normalizeAccountId(namedAccount) : requiresExplicitMatrixDefaultAccount(params.config, params.env) ? null : normalizeAccountId(resolveMatrixDefaultOrOnlyAccountId(params.config, params.env)),
@@ -396,7 +414,7 @@ async function readLegacyMatrixCredentials(source) {
396
414
  async function collectLegacyMatrixStateRoots(stateDir, filename, options) {
397
415
  const matrixRoot = path.join(stateDir, "matrix");
398
416
  const roots = [];
399
- async function visit(dir) {
417
+ async function visit(dir, depth) {
400
418
  let entries;
401
419
  try {
402
420
  entries = await fs.readdir(dir, { withFileTypes: true });
@@ -405,14 +423,16 @@ async function collectLegacyMatrixStateRoots(stateDir, filename, options) {
405
423
  }
406
424
  for (const entry of entries) {
407
425
  const entryPath = path.join(dir, entry.name);
408
- if (entry.isFile() && entry.name === filename) {
426
+ if ((depth === 0 || depth === 2 || depth === 4) && entry.isFile() && entry.name === filename) {
409
427
  roots.push(dir);
410
428
  continue;
411
429
  }
412
- if (entry.isDirectory()) await visit(entryPath);
430
+ if (!entry.isDirectory()) continue;
431
+ const childDepth = resolveMatrixStateLayoutChildDepth(depth, entry.name);
432
+ if (childDepth !== null) await visit(entryPath, childDepth);
413
433
  }
414
434
  }
415
- await visit(matrixRoot);
435
+ await visit(matrixRoot, 0);
416
436
  return roots.filter((root) => options?.includeMatrixRoot || path.resolve(root) !== path.resolve(matrixRoot)).toSorted();
417
437
  }
418
438
  async function* readLegacyMatrixSyncCaches(stateDir) {
@@ -818,7 +838,7 @@ const stateMigrations = [
818
838
  });
819
839
  }
820
840
  for (const storageRootDir of await collectLegacyMatrixStateRoots(params.stateDir, MATRIX_IDB_SNAPSHOT_FILENAME, { includeMatrixRoot: true })) {
821
- const { migrateLegacyMatrixIdbSnapshot } = await import("./crypto-snapshot-doctor.runtime-D0v841D_.js");
841
+ const { migrateLegacyMatrixIdbSnapshot } = await import("./crypto-snapshot-doctor.runtime-DxgUMXUy.js");
822
842
  await migrateLegacyMatrixIdbSnapshot({
823
843
  storageRootDir,
824
844
  context: params.context,
@@ -1,4 +1,5 @@
1
- import { T as MsgType, a as sendSingleTextMessageMatrix, c as prepareMatrixSingleText, t as editMessageMatrix } from "./send-DG7Bnj7_.js";
1
+ import { a as sendSingleTextMessageMatrix, m as prepareMatrixSingleText, t as editMessageMatrix } from "./send-B9l1lKau.js";
2
+ import { i as MsgType } from "./types-DzSc7Sqm.js";
2
3
  import { createFinalizableDraftStreamControlsForState } from "openclaw/plugin-sdk/channel-outbound";
3
4
  //#region extensions/matrix/src/matrix/draft-stream.ts
4
5
  const DEFAULT_THROTTLE_MS = 1e3;
@@ -114,24 +115,34 @@ function createMatrixDraftStream(params) {
114
115
  await stopDraft();
115
116
  return currentEventId;
116
117
  };
117
- const reset = () => {
118
- replyToId = params.preserveReplyId ? params.replyToId : void 0;
118
+ const resetCurrentMessage = () => {
119
119
  currentEventId = void 0;
120
120
  lastSentText = "";
121
121
  lastSentContent = "";
122
- streamState.stopped = false;
123
- streamState.final = false;
124
122
  sendFailed = false;
125
123
  finalizeInPlaceBlocked = false;
126
124
  liveFinalized = false;
127
125
  loop.resetPending();
128
126
  loop.resetThrottleWindow();
129
127
  };
128
+ const reset = () => {
129
+ replyToId = params.preserveReplyId ? params.replyToId : void 0;
130
+ streamState.stopped = false;
131
+ streamState.final = false;
132
+ resetCurrentMessage();
133
+ };
134
+ const deleteCurrentMessage = async () => {
135
+ loop.resetPending();
136
+ await loop.waitForInFlight();
137
+ if (currentEventId) await client.redactEvent(roomId, currentEventId);
138
+ resetCurrentMessage();
139
+ };
130
140
  return {
131
141
  update,
132
142
  flush: loop.flush,
133
143
  stop,
134
144
  discardPending,
145
+ deleteCurrentMessage,
135
146
  finalizeLive,
136
147
  reset,
137
148
  eventId: () => currentEventId,
@@ -1,4 +1,4 @@
1
- import { a as resolveMatrixDefaultOrOnlyAccountId } from "./account-selection-DA-jfx22.js";
1
+ import { o as resolveMatrixDefaultOrOnlyAccountId } from "./account-selection-Bbtc483D.js";
2
2
  import { t as resolveMatrixConfigFieldPath } from "./config-paths-CnREYb1Y.js";
3
3
  import { normalizeOptionalAccountId } from "openclaw/plugin-sdk/account-id";
4
4
  //#region extensions/matrix/src/matrix/encryption-guidance.ts
@@ -1,5 +1,9 @@
1
1
  import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
2
2
  //#region extensions/matrix/src/matrix/sdk/event-helpers.ts
3
+ const matrixEventProjections = /* @__PURE__ */ new WeakMap();
4
+ function getMatrixEventProjection(event) {
5
+ return matrixEventProjections.get(event);
6
+ }
3
7
  function matrixEventToRaw(event, opts = {}) {
4
8
  const originalContent = event.getOriginalContent();
5
9
  const content = opts.contentMode === "original" ? originalContent : event.getContent();
@@ -18,6 +22,10 @@ function matrixEventToRaw(event, opts = {}) {
18
22
  };
19
23
  const stateKey = event.getStateKey() ?? event.getWireStateKey();
20
24
  if (typeof stateKey === "string") raw.state_key = stateKey;
25
+ matrixEventProjections.set(raw, {
26
+ decryptionFailure: event.isDecryptionFailure(),
27
+ originalContent
28
+ });
21
29
  return raw;
22
30
  }
23
31
  function parseMxc(url) {
@@ -43,4 +51,4 @@ function buildHttpError(statusCode, bodyText) {
43
51
  return Object.assign(new Error(message), { statusCode });
44
52
  }
45
53
  //#endregion
46
- export { matrixEventToRaw as n, parseMxc as r, buildHttpError as t };
54
+ export { parseMxc as i, getMatrixEventProjection as n, matrixEventToRaw as r, buildHttpError as t };
@@ -1,4 +1,4 @@
1
- import { a as resolveMatrixDefaultOrOnlyAccountId, i as resolveMatrixChannelConfig, n as requiresExplicitMatrixDefaultAccount, r as resolveConfiguredMatrixAccountIds, t as findMatrixAccountEntry } from "./account-selection-DA-jfx22.js";
1
+ import { a as resolveMatrixChannelConfig, i as resolveConfiguredMatrixAccountIds, n as findMatrixAccountEntry, o as resolveMatrixDefaultOrOnlyAccountId, r as requiresExplicitMatrixDefaultAccount } from "./account-selection-Bbtc483D.js";
2
2
  import { n as listMatrixEnvAccountIds, r as resolveMatrixEnvAccountToken, t as getMatrixScopedEnvVarNames } from "./env-vars-dGqak9dN.js";
3
- import { a as resolveMatrixCredentialsPath, i as resolveMatrixCredentialsFilename, n as resolveMatrixAccountStorageRoot, o as resolveMatrixHomeserverKey, r as resolveMatrixCredentialsDir, s as sanitizeMatrixPathSegment, t as hashMatrixAccessToken } from "./storage-paths-gUmSydsW.js";
4
- export { findMatrixAccountEntry, getMatrixScopedEnvVarNames, hashMatrixAccessToken, listMatrixEnvAccountIds, requiresExplicitMatrixDefaultAccount, resolveConfiguredMatrixAccountIds, resolveMatrixAccountStorageRoot, resolveMatrixChannelConfig, resolveMatrixCredentialsDir, resolveMatrixCredentialsFilename, resolveMatrixCredentialsPath, resolveMatrixDefaultOrOnlyAccountId, resolveMatrixEnvAccountToken, resolveMatrixHomeserverKey, sanitizeMatrixPathSegment };
3
+ import { a as resolveMatrixCredentialsFilename, c as resolveMatrixStateLayoutChildDepth, i as resolveMatrixCredentialsDir, l as sanitizeMatrixPathSegment, n as isMatrixActiveTokenRootDirectory, o as resolveMatrixCredentialsPath, r as resolveMatrixAccountStorageRoot, s as resolveMatrixHomeserverKey, t as hashMatrixAccessToken } from "./storage-paths-DVCANXTc.js";
4
+ export { findMatrixAccountEntry, getMatrixScopedEnvVarNames, hashMatrixAccessToken, isMatrixActiveTokenRootDirectory, listMatrixEnvAccountIds, requiresExplicitMatrixDefaultAccount, resolveConfiguredMatrixAccountIds, resolveMatrixAccountStorageRoot, resolveMatrixChannelConfig, resolveMatrixCredentialsDir, resolveMatrixCredentialsFilename, resolveMatrixCredentialsPath, resolveMatrixDefaultOrOnlyAccountId, resolveMatrixEnvAccountToken, resolveMatrixHomeserverKey, resolveMatrixStateLayoutChildDepth, sanitizeMatrixPathSegment };
@@ -1,4 +1,4 @@
1
- import { t as buildHttpError } from "./event-helpers-XRfAbOIh.js";
1
+ import { t as buildHttpError } from "./event-helpers-CspuhE9k.js";
2
2
  import { parseMediaContentLength } from "openclaw/plugin-sdk/media-runtime";
3
3
  import { buildTimeoutAbortSignal } from "openclaw/plugin-sdk/extension-shared";
4
4
  import { readResponseWithLimit } from "openclaw/plugin-sdk/response-limit-runtime";
@@ -1,4 +1,4 @@
1
- import { D as writeMatrixIdbSnapshotJson, f as MATRIX_IDB_SNAPSHOT_FILENAME, w as readMatrixIdbSnapshotJson } from "./storage-BVf4uucD.js";
1
+ import { b as readMatrixIdbSnapshotJson, o as MATRIX_IDB_SNAPSHOT_FILENAME, w as writeMatrixIdbSnapshotJson } from "./storage-metadata-DYArLcq1.js";
2
2
  import { n as LogService } from "./logger-B_71hN6W.js";
3
3
  import { n as MATRIX_IDB_SNAPSHOT_LOCK_OPTIONS } from "./idb-persistence-lock-B3fZXyF_.js";
4
4
  import path from "node:path";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as registerMatrixCliMetadata } from "./cli-metadata-B7MQjR5S.js";
1
+ import { n as registerMatrixCliMetadata } from "./cli-metadata-D19lmKmz.js";
2
2
  import { registerMatrixSubagentHooks } from "./subagent-hooks-api.js";
3
3
  import { defineBundledChannelEntry } from "openclaw/plugin-sdk/channel-entry-contract";
4
4
  import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
@@ -1,9 +1,8 @@
1
+ import { S as isPollStartType, T as resolvePollReferenceEventId, b as formatPollResultsAsText, f as resolveMatrixMessageAttachment, p as resolveMatrixReplacementContent, r as sendMessageMatrix, t as editMessageMatrix, v as buildPollResultsSummary, w as parsePollStartContent, x as isPollEventType, y as formatPollAsText } from "./send-B9l1lKau.js";
1
2
  import { n as MATRIX_REACTION_EVENT_TYPE } from "./reaction-common-DkrQdBSZ.js";
2
- import { _ as resolvePollReferenceEventId, d as formatPollAsText, f as formatPollResultsAsText, g as parsePollStartContent, m as isPollStartType, p as isPollEventType, r as sendMessageMatrix, t as editMessageMatrix, u as buildPollResultsSummary } from "./send-DG7Bnj7_.js";
3
- import { r as withResolvedRoomAction } from "./client-D2utPQ1E.js";
3
+ import { r as withResolvedRoomAction } from "./client-BXQCQDfY.js";
4
4
  import { n as isMatrixNotFoundError } from "./errors-DKVS3_DO.js";
5
- import { asNullableObjectRecord, asNullableRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
6
- import path from "node:path";
5
+ import { asNullableObjectRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
7
6
  //#region extensions/matrix/src/matrix/poll-summary.ts
8
7
  function resolveMatrixPollRootEventId(event) {
9
8
  if (isPollStartType(event.type)) {
@@ -67,97 +66,6 @@ function resolveMatrixActionLimit(raw, fallback) {
67
66
  return Math.max(1, Math.floor(raw !== void 0 && Number.isFinite(raw) ? raw : fallback));
68
67
  }
69
68
  //#endregion
70
- //#region extensions/matrix/src/matrix/media-text.ts
71
- const MATRIX_MEDIA_KINDS = {
72
- "m.audio": "audio",
73
- "m.file": "file",
74
- "m.image": "image",
75
- "m.sticker": "sticker",
76
- "m.video": "video"
77
- };
78
- function resolveMatrixMediaKind(msgtype) {
79
- return MATRIX_MEDIA_KINDS[msgtype ?? ""] ?? null;
80
- }
81
- function resolveMatrixMediaLabel(kind, fallback = "media") {
82
- return `${kind ?? fallback} attachment`;
83
- }
84
- function formatMatrixAttachmentMarker(params) {
85
- const label = resolveMatrixMediaLabel(params.kind);
86
- if (params.tooLarge) return `[matrix ${label} too large]`;
87
- return params.unavailable ? `[matrix ${label} unavailable]` : `[matrix ${label}]`;
88
- }
89
- function isLikelyBareFilename(text) {
90
- const trimmed = text.trim();
91
- if (!trimmed || trimmed.includes("\n") || /\s/.test(trimmed)) return false;
92
- if (path.basename(trimmed) !== trimmed) return false;
93
- return path.extname(trimmed).length > 1;
94
- }
95
- function resolveCaptionOrFilename(params) {
96
- const body = params.body?.trim() ?? "";
97
- const filename = params.filename?.trim() ?? "";
98
- if (filename) {
99
- if (!body || body === filename) return { filename };
100
- return {
101
- caption: body,
102
- filename
103
- };
104
- }
105
- if (!body) return {};
106
- if (isLikelyBareFilename(body)) return { filename: body };
107
- return { caption: body };
108
- }
109
- function resolveBundledMatrixReplacementContent(event) {
110
- const replacement = asNullableObjectRecord(event.unsigned?.["m.relations"]?.["m.replace"]);
111
- if (!replacement || event.state_key !== void 0) return;
112
- const content = asNullableObjectRecord(replacement.content);
113
- const relation = asNullableObjectRecord(content?.["m.relates_to"]);
114
- const newContent = content?.["m.new_content"];
115
- if (replacement.sender !== event.sender || replacement.type !== event.type || replacement.state_key !== void 0 || asNullableObjectRecord(replacement.unsigned)?.redacted_because || !relation || relation.rel_type !== "m.replace" || relation.event_id !== event.event_id) return;
116
- return asNullableRecord(newContent) ?? void 0;
117
- }
118
- function resolveMatrixMessageAttachment(params) {
119
- const kind = resolveMatrixMediaKind(params.msgtype);
120
- if (!kind) return;
121
- const resolved = resolveCaptionOrFilename(params);
122
- return {
123
- kind,
124
- caption: resolved.caption,
125
- filename: resolved.filename
126
- };
127
- }
128
- function formatMatrixAttachmentText(params) {
129
- if (!params.attachment) return;
130
- return formatMatrixAttachmentMarker({
131
- kind: params.attachment.kind,
132
- tooLarge: params.tooLarge,
133
- unavailable: params.unavailable
134
- });
135
- }
136
- function formatMatrixMessageText(params) {
137
- const attachment = resolveMatrixMessageAttachment(params);
138
- const body = attachment ? attachment.caption ?? "" : params.body?.trim() ?? "";
139
- const marker = formatMatrixAttachmentText({
140
- attachment,
141
- tooLarge: params.tooLarge,
142
- unavailable: params.unavailable
143
- });
144
- if (!marker) return body || void 0;
145
- if (!body) return marker;
146
- return `${body}\n\n${marker}`;
147
- }
148
- function formatMatrixMediaUnavailableText(params) {
149
- return formatMatrixMessageText({
150
- ...params,
151
- unavailable: true
152
- }) ?? "";
153
- }
154
- function formatMatrixMediaTooLargeText(params) {
155
- return formatMatrixMessageText({
156
- ...params,
157
- tooLarge: true
158
- }) ?? "";
159
- }
160
- //#endregion
161
69
  //#region extensions/matrix/src/matrix/actions/types.ts
162
70
  const EventType = {
163
71
  RoomMessage: "m.room.message",
@@ -190,7 +98,7 @@ function parseMatrixRawEvent(value) {
190
98
  function summarizeMatrixRawEvent(event) {
191
99
  const content = event.content;
192
100
  const relates = content["m.relates_to"];
193
- const displayContent = relates?.rel_type === "m.replace" ? content["m.new_content"] ?? content : resolveBundledMatrixReplacementContent(event) ?? content;
101
+ const displayContent = relates?.rel_type === "m.replace" ? content["m.new_content"] ?? content : resolveMatrixReplacementContent(event) ?? content;
194
102
  let relType;
195
103
  let eventId;
196
104
  if (relates) {
@@ -254,8 +162,7 @@ function resolveLatestMatrixReplacements(events) {
254
162
  for (const event of events) {
255
163
  const targetId = resolveMatrixReplacementTarget(event);
256
164
  const original = targetId ? originals.get(targetId) : void 0;
257
- const newContent = event.content["m.new_content"];
258
- if (!targetId || !original || event.sender !== original.sender || event.type !== original.type || event.state_key !== void 0 || event.unsigned?.redacted_because || !newContent || typeof newContent !== "object" || Array.isArray(newContent)) continue;
165
+ if (!targetId || !original || !resolveMatrixReplacementContent(original, event)) continue;
259
166
  const latest = replacements.get(targetId);
260
167
  if (!latest || event.origin_server_ts > latest.origin_server_ts || event.origin_server_ts === latest.origin_server_ts && event.event_id > latest.event_id) replacements.set(targetId, event);
261
168
  }
@@ -407,4 +314,4 @@ async function isMatrixPollRootThreaded(params) {
407
314
  return hydratedRoot ? isMatrixThreadEvent(hydratedRoot) : false;
408
315
  }
409
316
  //#endregion
410
- export { fetchEventSummary as a, formatMatrixMediaTooLargeText as c, isLikelyBareFilename as d, resolveBundledMatrixReplacementContent as f, sendMatrixMessage as i, formatMatrixMediaUnavailableText as l, fetchMatrixPollSnapshot as m, editMatrixMessage as n, readPinnedEvents as o, resolveMatrixActionLimit as p, readMatrixMessages as r, EventType as s, deleteMatrixMessage as t, formatMatrixMessageText as u };
317
+ export { fetchEventSummary as a, resolveMatrixActionLimit as c, sendMatrixMessage as i, fetchMatrixPollSnapshot as l, editMatrixMessage as n, readPinnedEvents as o, readMatrixMessages as r, EventType as s, deleteMatrixMessage as t };