@openclaw/matrix 2026.9.1-beta.1 → 2026.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{account-config-BZWN9tGS.js → account-config-CRsKoMqJ.js} +1 -1
- package/dist/{account-selection-CWuhuFn1.js → account-selection-DA-jfx22.js} +74 -36
- package/dist/{accounts-BCzyubQt.js → accounts-DR1c4xF_.js} +4 -5
- package/dist/api.js +5 -5
- package/dist/{approval-handler.runtime-G9fLHUWe.js → approval-handler.runtime-BJCD4dLf.js} +34 -11
- package/dist/{approval-ids-C6FD3pVY.js → approval-ids-Bst7HM_o.js} +1 -1
- package/dist/{approval-reaction-auth-60xHiDtQ.js → approval-reaction-auth-DhH8QOSe.js} +2 -2
- package/dist/{approval-reactions-tXh9KYrW.js → approval-reactions-1fwEhoK9.js} +1 -1
- package/dist/{channel-CBEvelTE.js → channel-Bs8VLb6q.js} +63 -58
- package/dist/channel-plugin-api.js +1 -1
- package/dist/channel.runtime-CCJRhdH5.js +76 -0
- package/dist/{channel.setup-sWPOGyQG.js → channel.setup-DhmDXwPp.js} +32 -22
- package/dist/{cli-DrTD2a_q.js → cli-IvDUuiDH.js} +179 -135
- package/dist/{cli-metadata-DrYVwQ_r.js → cli-metadata-BGryAl2e.js} +1 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/{client-hs1ePy2O.js → client-Dj4mcf-s.js} +73 -22
- package/dist/{client-bootstrap-BxdxjCwA.js → client-bootstrap-n1Rqc8Go.js} +1 -1
- package/dist/{client-BUtHbzib.js → client-oNOlldJI.js} +2 -2
- package/dist/{config-update-Bor_Pjsv.js → config-update-BnX26jCO.js} +48 -31
- package/dist/contract-api.js +2 -2
- package/dist/{credentials-BdAaWuiR.js → credentials-DJj2xs3q.js} +4 -8
- package/dist/{credentials-read-B37cQknZ.js → credentials-read-mexhw-Ur.js} +7 -5
- package/dist/{credentials-write.runtime-nAV2-5uR.js → credentials-write.runtime-DQt-kgJq.js} +1 -1
- package/dist/{crypto-runtime-C4WDYxlP.js → crypto-runtime-m1eplj3b.js} +7 -7
- package/dist/crypto-snapshot-doctor.runtime-D0v841D_.js +91 -0
- package/dist/{deps-CcVJfvRM.js → deps-mtxF2mHI.js} +1 -1
- package/dist/{directory-live-D0KfJlby.js → directory-live-DLUgWBhA.js} +8 -6
- package/dist/{doctor-EWf9CDso.js → doctor-CJE8wO6y.js} +1 -1
- package/dist/{doctor-contract-DEt4O4Zt.js → doctor-contract-HyWFZQVG.js} +5 -4
- package/dist/doctor-contract-api.js +89 -109
- package/dist/{draft-stream-B_m79Ynb.js → draft-stream-DglwxWzJ.js} +1 -1
- package/dist/{encryption-guidance-DmLY8NiO.js → encryption-guidance-BNcZNQZI.js} +3 -2
- package/dist/helper-api.js +1 -1
- package/dist/{http-client-D8o8b9u6.js → http-client-DOmFvKvB.js} +10 -7
- package/dist/{idb-persistence-DfgW720p.js → idb-persistence-CU7CNLlX.js} +2 -2
- package/dist/{idb-persistence-lock-DAJ49nZX.js → idb-persistence-lock-B3fZXyF_.js} +1 -1
- package/dist/{inbound-dedupe-RvSLqdsz.js → inbound-dedupe-Ch33GU06.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/{messages-Dow9EOoJ.js → messages-Czn8lNEh.js} +154 -5
- package/dist/{monitor-DBB47wTy.js → monitor-DouG43FJ.js} +200 -156
- package/dist/outbound-Co_tJyE6.js +220 -0
- package/dist/plugin-entry.handlers.runtime.js +1 -1
- package/dist/probe.runtime-B1YPxG9x.js +2 -0
- package/dist/{profile-update-C61NR24_.js → profile-update-CAl8nZNG.js} +5 -4
- package/dist/{profile-D-Wubo0A.js → profile-vmjsmhh4.js} +1 -1
- package/dist/{reaction-events-BZUgLIZI.js → reaction-events-C_7G7bvI.js} +9 -7
- package/dist/{resolve-targets-DXzZwsIY.js → resolve-targets-B64O69Nd.js} +1 -1
- package/dist/{resolver.runtime-p5qJ3Kst.js → resolver.runtime-TRmePJDV.js} +1 -1
- package/dist/{room-info-BXQA7y10.js → room-info-6viLR3NH.js} +55 -1
- package/dist/runtime-api.js +2 -2
- package/dist/{sdk-CljOKEvc.js → sdk-C1yfda1L.js} +534 -26
- package/dist/{send-BKu9Ghi4.js → send-B5XChnvB.js} +31 -33
- package/dist/session-binding-contract-api.js +1 -1
- package/dist/{setup-bootstrap-CpE6C3qV.js → setup-bootstrap-S_loyUyM.js} +3 -3
- package/dist/{setup-core-CyvaCOOr.js → setup-core-XkIfQ65J.js} +8 -7
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{setup-surface-DtRvRcCT.js → setup-surface-B2yZ8KGc.js} +84 -79
- package/dist/{startup-verification-Cs08ca8u.js → startup-verification-1Ney1mmI.js} +2 -2
- package/dist/{storage-BsGuHngK.js → storage-BVf4uucD.js} +5 -4
- package/dist/{subagent-hooks-CMoZaARG.js → subagent-hooks-DeICLbU5.js} +5 -1
- package/dist/subagent-hooks-api.js +1 -1
- package/dist/sync-cache-state-d-A_OhbU.js +234 -0
- package/dist/{thread-bindings-BvyU66kE.js → thread-bindings-BkBnn4te.js} +4 -4
- package/dist/{tool-actions.runtime-DD6jUxFK.js → tool-actions.runtime-a5L5xGSP.js} +226 -215
- package/dist/{verification-BP-3-XYn.js → verification-XJtTc5DI.js} +2 -2
- package/node_modules/markdown-it/dist/browser/markdown-it.esm.min.mjs +216 -183
- package/node_modules/markdown-it/dist/browser/markdown-it.esm.min.mjs.map +1 -1
- package/node_modules/markdown-it/dist/browser/markdown-it.umd.min.js +7 -7
- package/node_modules/markdown-it/dist/browser/markdown-it.umd.min.js.map +1 -1
- package/node_modules/markdown-it/dist/markdown-it.cjs.js +98 -106
- package/node_modules/markdown-it/dist/markdown-it.cjs.js.map +1 -1
- package/node_modules/markdown-it/dist/markdown-it.d.mts +42 -71
- package/node_modules/markdown-it/dist/markdown-it.mjs +98 -106
- package/node_modules/markdown-it/dist/markdown-it.mjs.map +1 -1
- package/node_modules/markdown-it/package.json +1 -2
- package/node_modules/matrix-js-sdk/lib/client.d.ts +2 -1
- package/node_modules/matrix-js-sdk/lib/client.js +6 -2
- package/node_modules/matrix-js-sdk/lib/sync.js +8 -8
- package/node_modules/matrix-js-sdk/src/client.ts +7 -3
- package/node_modules/matrix-js-sdk/src/sync.ts +8 -8
- package/node_modules/typebox/build/format/email.mjs +1 -1
- package/node_modules/typebox/build/format/idna/idn-hostname.mjs +19 -1
- package/node_modules/typebox/build/format/json_pointer.d.mts +2 -2
- package/node_modules/typebox/build/format/json_pointer.mjs +2 -2
- package/node_modules/typebox/build/format/json_pointer_uri_fragment.d.mts +2 -2
- package/node_modules/typebox/build/format/json_pointer_uri_fragment.mjs +2 -2
- package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
- package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
- package/node_modules/typebox/build/system/memory/assign.mjs +2 -1
- package/node_modules/typebox/build/system/memory/create.mjs +3 -4
- package/node_modules/typebox/build/system/memory/discard.mjs +2 -2
- package/node_modules/typebox/build/system/memory/freeze.d.mts +4 -0
- package/node_modules/typebox/build/system/memory/freeze.mjs +6 -0
- package/node_modules/typebox/build/system/memory/update.mjs +3 -2
- package/node_modules/typebox/package.json +1 -1
- package/openclaw.plugin.json +17 -3
- package/package.json +8 -7
- package/dist/channel.runtime-CiDl9deX.js +0 -276
- package/dist/env-auth-MVS-Vv41.js +0 -64
- package/dist/file-sync-store-DjskBX2o.js +0 -436
- package/dist/media-text-OR9uoC4W.js +0 -153
- package/dist/probe.runtime-CRM7RIrB.js +0 -2
- package/dist/recovery-key-store-CognuDys.js +0 -276
|
@@ -1,100 +1,75 @@
|
|
|
1
|
-
import { a as resolveMatrixDefaultOrOnlyAccountId, n as requiresExplicitMatrixDefaultAccount } from "./account-selection-
|
|
1
|
+
import { a as resolveMatrixDefaultOrOnlyAccountId, n as requiresExplicitMatrixDefaultAccount } from "./account-selection-DA-jfx22.js";
|
|
2
2
|
import { i as normalizeMatrixStoredCredentials, n as isMatrixCredentialRevocation, r as matrixCredentialsStoreKey, t as MATRIX_CREDENTIALS_NAMESPACE } from "./credentials-state-B3cuUFwZ.js";
|
|
3
3
|
import { r as resolveMatrixCredentialsDir } from "./storage-paths-gUmSydsW.js";
|
|
4
|
-
import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-
|
|
5
|
-
import { C as readLegacyMatrixRecoveryKeyState,
|
|
6
|
-
import { a as readLegacyMatrixSyncCacheState,
|
|
7
|
-
import { n as MATRIX_IDB_SNAPSHOT_LOCK_OPTIONS } from "./idb-persistence-lock-DAJ49nZX.js";
|
|
8
|
-
import { r as readLegacyMatrixIdbSnapshotStateUnlocked, t as isValidMatrixIdbSnapshotJson } from "./idb-persistence-DfgW720p.js";
|
|
4
|
+
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";
|
|
9
7
|
import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
10
8
|
import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
11
|
-
import { createHash
|
|
9
|
+
import { createHash } from "node:crypto";
|
|
12
10
|
import path from "node:path";
|
|
13
11
|
import { archiveLegacyStateSource } from "openclaw/plugin-sdk/runtime-doctor-migrations";
|
|
14
|
-
import fs from "node:fs";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
await withFileLock(snapshotPath, MATRIX_IDB_SNAPSHOT_LOCK_OPTIONS, () => migrateLegacyMatrixIdbSnapshotLocked(params));
|
|
23
|
-
} catch (err) {
|
|
24
|
-
params.warnings.push(`Failed locking Matrix IndexedDB snapshot for ${params.storageRootDir}: ${String(err)}; left legacy source in place`);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
async function migrateLegacyMatrixIdbSnapshotLocked(params) {
|
|
28
|
-
const sourcePath = path.join(params.storageRootDir, MATRIX_IDB_SNAPSHOT_FILENAME);
|
|
29
|
-
let snapshot;
|
|
30
|
-
try {
|
|
31
|
-
snapshot = readLegacyMatrixIdbSnapshotStateUnlocked(params.storageRootDir);
|
|
32
|
-
} catch (err) {
|
|
33
|
-
params.warnings.push(`Failed reading Matrix IndexedDB snapshot legacy source for ${params.storageRootDir}: ${String(err)}; left source in place`);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
if (!snapshot) {
|
|
37
|
-
if (!fs.existsSync(sourcePath)) return;
|
|
38
|
-
const archived = await archiveLegacyMatrixIdbSnapshot(params);
|
|
39
|
-
params.warnings.push(archived ? `Matrix IndexedDB snapshot legacy source is invalid for ${params.storageRootDir}; archived without import` : `Matrix IndexedDB snapshot legacy source is invalid for ${params.storageRootDir}; left active because archival failed`);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
const snapshotJson = JSON.stringify(snapshot);
|
|
43
|
-
const store = params.context.openPluginStateKeyedStore(openMatrixIdbSnapshotStoreOptions(params.storageRootDir));
|
|
44
|
-
let persisted;
|
|
45
|
-
let hadPartialState;
|
|
46
|
-
try {
|
|
47
|
-
persisted = await readMatrixIdbSnapshotJsonFromStore({ store });
|
|
48
|
-
const persistedIsValid = persisted ? isValidMatrixIdbSnapshotJson(persisted) : false;
|
|
49
|
-
hadPartialState = !persistedIsValid && (await store.entries()).length > 0;
|
|
50
|
-
if (!persistedIsValid) persisted = null;
|
|
51
|
-
} catch (err) {
|
|
52
|
-
params.warnings.push(`Failed inspecting Matrix IndexedDB snapshot SQLite state for ${params.storageRootDir}: ${String(err)}; left legacy source in place`);
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (persisted && !snapshotContentMatches(persisted, snapshot)) {
|
|
56
|
-
if (await archiveLegacyMatrixIdbSnapshot(params)) params.notices.push(`Kept the canonical Matrix IndexedDB snapshot in SQLite and archived a differing legacy source for ${params.storageRootDir}`);
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
if (!persisted) {
|
|
12
|
+
import fs from "node:fs/promises";
|
|
13
|
+
//#region extensions/matrix/src/matrix/account-state-schema-doctor.ts
|
|
14
|
+
const STATE_DATABASE_FILENAME = "openclaw.sqlite";
|
|
15
|
+
async function collectMatrixAccountStateRoots(stateDir) {
|
|
16
|
+
const accountsRoot = path.join(stateDir, "matrix", "accounts");
|
|
17
|
+
const roots = /* @__PURE__ */ new Set();
|
|
18
|
+
async function visit(dir, allowMissing = false) {
|
|
19
|
+
let entries;
|
|
60
20
|
try {
|
|
61
|
-
await
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
});
|
|
66
|
-
persisted = await readMatrixIdbSnapshotJsonFromStore({ store });
|
|
67
|
-
} catch (err) {
|
|
68
|
-
params.warnings.push(`Failed importing Matrix IndexedDB snapshot for ${params.storageRootDir}: ${String(err)}; left legacy source in place`);
|
|
69
|
-
return;
|
|
21
|
+
entries = await fs.readdir(dir, { withFileTypes: true });
|
|
22
|
+
} catch (error) {
|
|
23
|
+
if (allowMissing && typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") return;
|
|
24
|
+
throw error;
|
|
70
25
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
26
|
+
for (const entry of entries) {
|
|
27
|
+
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);
|
|
74
30
|
}
|
|
75
|
-
params.changes.push(hadPartialState ? `Repaired partial or invalid Matrix IndexedDB snapshot SQLite state for ${params.storageRootDir}` : `Migrated Matrix IndexedDB snapshot JSON to SQLite for ${params.storageRootDir}`);
|
|
76
31
|
}
|
|
77
|
-
await
|
|
32
|
+
await visit(accountsRoot, true);
|
|
33
|
+
return [...roots].toSorted();
|
|
78
34
|
}
|
|
79
|
-
function
|
|
80
|
-
|
|
81
|
-
return isDeepStrictEqual(JSON.parse(persistedJson), snapshot);
|
|
82
|
-
} catch {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
35
|
+
function describeMatrixAccountStateMigration(storageRootDir, migration) {
|
|
36
|
+
return `Matrix account SQLite schema migration (${migration.kind}): ${storageRootDir}`;
|
|
85
37
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
38
|
+
const matrixAccountStateSchemaMigration = {
|
|
39
|
+
id: "matrix-account-sqlite-schema",
|
|
40
|
+
label: "Matrix account SQLite schemas",
|
|
41
|
+
async detectLegacyState(params) {
|
|
42
|
+
const preview = [];
|
|
43
|
+
for (const storageRootDir of await collectMatrixAccountStateRoots(params.stateDir)) {
|
|
44
|
+
const { detectOpenClawStateDatabaseSchemaMigrations } = await import("openclaw/plugin-sdk/doctor-repair-runtime");
|
|
45
|
+
const env = resolveMatrixSqliteStateEnv({
|
|
46
|
+
env: params.env,
|
|
47
|
+
stateDir: storageRootDir
|
|
48
|
+
});
|
|
49
|
+
preview.push(...detectOpenClawStateDatabaseSchemaMigrations({ env }).map((migration) => describeMatrixAccountStateMigration(storageRootDir, migration)));
|
|
50
|
+
}
|
|
51
|
+
return preview.length > 0 ? { preview } : null;
|
|
52
|
+
},
|
|
53
|
+
async migrateLegacyState(params) {
|
|
54
|
+
const changes = [];
|
|
55
|
+
const warnings = [];
|
|
56
|
+
for (const storageRootDir of await collectMatrixAccountStateRoots(params.stateDir)) {
|
|
57
|
+
const { detectOpenClawStateDatabaseSchemaMigrations, repairOpenClawStateDatabaseSchema } = await import("openclaw/plugin-sdk/doctor-repair-runtime");
|
|
58
|
+
const env = resolveMatrixSqliteStateEnv({
|
|
59
|
+
env: params.env,
|
|
60
|
+
stateDir: storageRootDir
|
|
61
|
+
});
|
|
62
|
+
if (detectOpenClawStateDatabaseSchemaMigrations({ env }).length === 0) continue;
|
|
63
|
+
const repaired = repairOpenClawStateDatabaseSchema({ env });
|
|
64
|
+
changes.push(...repaired.changes.map((change) => `Matrix account SQLite ${storageRootDir}: ${change}`));
|
|
65
|
+
warnings.push(...repaired.warnings.map((warning) => `Matrix account SQLite ${storageRootDir}: ${warning}`));
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
changes,
|
|
69
|
+
warnings
|
|
70
|
+
};
|
|
96
71
|
}
|
|
97
|
-
}
|
|
72
|
+
};
|
|
98
73
|
//#endregion
|
|
99
74
|
//#region extensions/matrix/src/matrix/monitor/inbound-dedupe-migration.ts
|
|
100
75
|
const LEGACY_SQLITE_NAMESPACE = "inbound-dedupe";
|
|
@@ -143,7 +118,7 @@ async function collectMatrixInboundDedupeSources(stateDir) {
|
|
|
143
118
|
async function visit(dir, allowMissing = false) {
|
|
144
119
|
let entries;
|
|
145
120
|
try {
|
|
146
|
-
entries = await fs
|
|
121
|
+
entries = await fs.readdir(dir, { withFileTypes: true });
|
|
147
122
|
} catch (err) {
|
|
148
123
|
if (allowMissing && err.code === "ENOENT") return;
|
|
149
124
|
warnings.push(`Failed scanning Matrix inbound dedupe sources under ${dir}: ${String(err)}`);
|
|
@@ -269,7 +244,7 @@ async function verifyMatrixInboundDedupeSourcesRetired(stateDir) {
|
|
|
269
244
|
}
|
|
270
245
|
async function resolveJsonRootAccountId(storageRootDir) {
|
|
271
246
|
for (const filename of [STORAGE_META_FILENAME, `${STORAGE_META_FILENAME}.migrated`]) try {
|
|
272
|
-
const metadata = normalizeMatrixStorageMetadata(JSON.parse(await fs
|
|
247
|
+
const metadata = normalizeMatrixStorageMetadata(JSON.parse(await fs.readFile(path.join(storageRootDir, filename), "utf8")));
|
|
273
248
|
if (metadata?.accountId) return metadata.accountId;
|
|
274
249
|
} catch {}
|
|
275
250
|
return "default";
|
|
@@ -281,7 +256,7 @@ async function resolveJsonRootAccountId(storageRootDir) {
|
|
|
281
256
|
*/
|
|
282
257
|
async function readLegacyInboundDedupeJsonSource(storageRootDir) {
|
|
283
258
|
const jsonPath = path.join(storageRootDir, MATRIX_LEGACY_INBOUND_DEDUPE_FILENAME);
|
|
284
|
-
const raw = await fs
|
|
259
|
+
const raw = await fs.readFile(jsonPath, "utf8");
|
|
285
260
|
let parsed;
|
|
286
261
|
try {
|
|
287
262
|
parsed = JSON.parse(raw);
|
|
@@ -317,7 +292,7 @@ async function readLegacyInboundDedupeJsonSource(storageRootDir) {
|
|
|
317
292
|
*/
|
|
318
293
|
async function importNewestInboundDedupeMarkers(params) {
|
|
319
294
|
const { createPersistentDedupeImportEntry } = await import("openclaw/plugin-sdk/persistent-dedupe");
|
|
320
|
-
const { buildMatrixInboundDedupeEventKey, MATRIX_INBOUND_DEDUPE_STATE_MAX_ENTRIES, MATRIX_INBOUND_DEDUPE_TTL_MS, resolveMatrixInboundDedupeStateNamespace } = await import("./inbound-dedupe-
|
|
295
|
+
const { buildMatrixInboundDedupeEventKey, MATRIX_INBOUND_DEDUPE_STATE_MAX_ENTRIES, MATRIX_INBOUND_DEDUPE_TTL_MS, resolveMatrixInboundDedupeStateNamespace } = await import("./inbound-dedupe-Ch33GU06.js");
|
|
321
296
|
const now = params.now ?? Date.now();
|
|
322
297
|
const stateMaxEntries = params.stateMaxEntries ?? MATRIX_INBOUND_DEDUPE_STATE_MAX_ENTRIES;
|
|
323
298
|
const newestByKey = /* @__PURE__ */ new Map();
|
|
@@ -389,7 +364,7 @@ async function collectLegacyMatrixCredentialSources(params) {
|
|
|
389
364
|
const credentialsDir = resolveMatrixCredentialsDir(params.stateDir);
|
|
390
365
|
let entries;
|
|
391
366
|
try {
|
|
392
|
-
entries = await fs
|
|
367
|
+
entries = await fs.readdir(credentialsDir, { withFileTypes: true });
|
|
393
368
|
} catch {
|
|
394
369
|
return [];
|
|
395
370
|
}
|
|
@@ -408,8 +383,8 @@ async function collectLegacyMatrixCredentialSources(params) {
|
|
|
408
383
|
async function readLegacyMatrixCredentials(source) {
|
|
409
384
|
if (!source.accountId) return null;
|
|
410
385
|
try {
|
|
411
|
-
const raw = JSON.parse(await fs
|
|
412
|
-
const createdAt = isRecord(raw) && typeof raw.createdAt === "string" && raw.createdAt ? raw.createdAt : (await fs
|
|
386
|
+
const raw = JSON.parse(await fs.readFile(source.filePath, "utf8"));
|
|
387
|
+
const createdAt = isRecord(raw) && typeof raw.createdAt === "string" && raw.createdAt ? raw.createdAt : (await fs.stat(source.filePath)).mtime.toISOString();
|
|
413
388
|
return normalizeMatrixStoredCredentials(isRecord(raw) ? {
|
|
414
389
|
...raw,
|
|
415
390
|
createdAt
|
|
@@ -424,7 +399,7 @@ async function collectLegacyMatrixStateRoots(stateDir, filename, options) {
|
|
|
424
399
|
async function visit(dir) {
|
|
425
400
|
let entries;
|
|
426
401
|
try {
|
|
427
|
-
entries = await fs
|
|
402
|
+
entries = await fs.readdir(dir, { withFileTypes: true });
|
|
428
403
|
} catch {
|
|
429
404
|
return;
|
|
430
405
|
}
|
|
@@ -440,12 +415,18 @@ async function collectLegacyMatrixStateRoots(stateDir, filename, options) {
|
|
|
440
415
|
await visit(matrixRoot);
|
|
441
416
|
return roots.filter((root) => options?.includeMatrixRoot || path.resolve(root) !== path.resolve(matrixRoot)).toSorted();
|
|
442
417
|
}
|
|
443
|
-
async function
|
|
444
|
-
|
|
418
|
+
async function* readLegacyMatrixSyncCaches(stateDir) {
|
|
419
|
+
for (const storageRootDir of await collectLegacyMatrixStateRoots(stateDir, MATRIX_SYNC_CACHE_FILENAME)) {
|
|
420
|
+
const persisted = await readLegacyMatrixSyncCacheState(storageRootDir);
|
|
421
|
+
if (persisted) yield {
|
|
422
|
+
storageRootDir,
|
|
423
|
+
persisted
|
|
424
|
+
};
|
|
425
|
+
}
|
|
445
426
|
}
|
|
446
427
|
async function readLegacyMatrixStorageMetadata(storageRootDir) {
|
|
447
428
|
try {
|
|
448
|
-
return normalizeMatrixStorageMetadata(JSON.parse(await fs
|
|
429
|
+
return normalizeMatrixStorageMetadata(JSON.parse(await fs.readFile(path.join(storageRootDir, MATRIX_STORAGE_META_FILENAME), "utf8")));
|
|
449
430
|
} catch {
|
|
450
431
|
return null;
|
|
451
432
|
}
|
|
@@ -468,6 +449,7 @@ async function archiveLegacyMatrixStateFile(params) {
|
|
|
468
449
|
if (params.notice && params.warnings.length === warningCount) params.notices?.push(params.notice);
|
|
469
450
|
}
|
|
470
451
|
const stateMigrations = [
|
|
452
|
+
matrixAccountStateSchemaMigration,
|
|
471
453
|
{
|
|
472
454
|
id: "matrix-credentials-json-to-plugin-state",
|
|
473
455
|
label: "Matrix credentials",
|
|
@@ -698,19 +680,14 @@ const stateMigrations = [
|
|
|
698
680
|
label: "Matrix sync cache",
|
|
699
681
|
async detectLegacyState(params) {
|
|
700
682
|
const previews = [];
|
|
701
|
-
for (const storageRootDir of
|
|
702
|
-
if (!await readLegacyMatrixSyncCacheState(storageRootDir)) continue;
|
|
703
|
-
previews.push(`Matrix sync cache JSON can migrate to SQLite: ${storageRootDir}`);
|
|
704
|
-
}
|
|
683
|
+
for await (const { storageRootDir } of readLegacyMatrixSyncCaches(params.stateDir)) previews.push(`Matrix sync cache JSON can migrate to SQLite: ${storageRootDir}`);
|
|
705
684
|
return previews.length > 0 ? { preview: previews } : null;
|
|
706
685
|
},
|
|
707
686
|
async migrateLegacyState(params) {
|
|
708
687
|
const changes = [];
|
|
709
688
|
const warnings = [];
|
|
710
689
|
const notices = [];
|
|
711
|
-
for (const storageRootDir of
|
|
712
|
-
const persisted = await readLegacyMatrixSyncCacheState(storageRootDir);
|
|
713
|
-
if (!persisted) continue;
|
|
690
|
+
for await (const { storageRootDir, persisted } of readLegacyMatrixSyncCaches(params.stateDir)) {
|
|
714
691
|
const store = params.context.openPluginStateKeyedStore(openMatrixSyncCacheStoreOptions(storageRootDir));
|
|
715
692
|
if (await hasMatrixSyncCacheStateInStore({
|
|
716
693
|
storageRootDir,
|
|
@@ -840,13 +817,16 @@ const stateMigrations = [
|
|
|
840
817
|
warnings
|
|
841
818
|
});
|
|
842
819
|
}
|
|
843
|
-
for (const storageRootDir of await collectLegacyMatrixStateRoots(params.stateDir, MATRIX_IDB_SNAPSHOT_FILENAME, { includeMatrixRoot: true }))
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
820
|
+
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");
|
|
822
|
+
await migrateLegacyMatrixIdbSnapshot({
|
|
823
|
+
storageRootDir,
|
|
824
|
+
context: params.context,
|
|
825
|
+
changes,
|
|
826
|
+
notices,
|
|
827
|
+
warnings
|
|
828
|
+
});
|
|
829
|
+
}
|
|
850
830
|
return {
|
|
851
831
|
changes,
|
|
852
832
|
warnings,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { T as MsgType, a as sendSingleTextMessageMatrix, c as prepareMatrixSingleText, t as editMessageMatrix } from "./send-B5XChnvB.js";
|
|
2
2
|
import { createFinalizableDraftStreamControlsForState } from "openclaw/plugin-sdk/channel-outbound";
|
|
3
3
|
//#region extensions/matrix/src/matrix/draft-stream.ts
|
|
4
4
|
const DEFAULT_THROTTLE_MS = 1e3;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { a as resolveMatrixDefaultOrOnlyAccountId } from "./account-selection-
|
|
1
|
+
import { a as resolveMatrixDefaultOrOnlyAccountId } from "./account-selection-DA-jfx22.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
|
|
5
5
|
function resolveMatrixEncryptionConfigPath(cfg, accountId) {
|
|
6
|
-
|
|
6
|
+
const effectiveAccountId = normalizeOptionalAccountId(accountId) ?? resolveMatrixDefaultOrOnlyAccountId(cfg);
|
|
7
|
+
return resolveMatrixConfigFieldPath(cfg, effectiveAccountId, "encryption");
|
|
7
8
|
}
|
|
8
9
|
function formatMatrixEncryptionUnavailableError(cfg, accountId) {
|
|
9
10
|
return `Matrix encryption is not available (enable ${resolveMatrixEncryptionConfigPath(cfg, accountId)}=true)`;
|
package/dist/helper-api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as resolveMatrixDefaultOrOnlyAccountId, i as resolveMatrixChannelConfig, n as requiresExplicitMatrixDefaultAccount, r as resolveConfiguredMatrixAccountIds, t as findMatrixAccountEntry } from "./account-selection-
|
|
1
|
+
import { a as resolveMatrixDefaultOrOnlyAccountId, i as resolveMatrixChannelConfig, n as requiresExplicitMatrixDefaultAccount, r as resolveConfiguredMatrixAccountIds, t as findMatrixAccountEntry } from "./account-selection-DA-jfx22.js";
|
|
2
2
|
import { n as listMatrixEnvAccountIds, r as resolveMatrixEnvAccountToken, t as getMatrixScopedEnvVarNames } from "./env-vars-dGqak9dN.js";
|
|
3
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
4
|
export { findMatrixAccountEntry, getMatrixScopedEnvVarNames, hashMatrixAccessToken, listMatrixEnvAccountIds, requiresExplicitMatrixDefaultAccount, resolveConfiguredMatrixAccountIds, resolveMatrixAccountStorageRoot, resolveMatrixChannelConfig, resolveMatrixCredentialsDir, resolveMatrixCredentialsFilename, resolveMatrixCredentialsPath, resolveMatrixDefaultOrOnlyAccountId, resolveMatrixEnvAccountToken, resolveMatrixHomeserverKey, sanitizeMatrixPathSegment };
|
|
@@ -28,8 +28,8 @@ async function readResponseWithLimit$1(res, maxBytes, opts) {
|
|
|
28
28
|
}
|
|
29
29
|
//#endregion
|
|
30
30
|
//#region extensions/matrix/src/matrix/sdk/transport.ts
|
|
31
|
-
const MATRIX_JSON_RESPONSE_MAX_BYTES =
|
|
32
|
-
const MATRIX_SDK_RESPONSE_MAX_BYTES =
|
|
31
|
+
const MATRIX_JSON_RESPONSE_MAX_BYTES = 8388608;
|
|
32
|
+
const MATRIX_SDK_RESPONSE_MAX_BYTES = 67108864;
|
|
33
33
|
function normalizeEndpoint(endpoint) {
|
|
34
34
|
if (!endpoint) return "/";
|
|
35
35
|
return endpoint.startsWith("/") ? endpoint : `/${endpoint}`;
|
|
@@ -116,7 +116,8 @@ async function fetchWithMatrixGuardedRedirects(params) {
|
|
|
116
116
|
for (let redirectCount = 0; redirectCount <= maxRedirects; redirectCount += 1) {
|
|
117
117
|
let dispatcher;
|
|
118
118
|
try {
|
|
119
|
-
|
|
119
|
+
const pinned = await resolvePinnedHostnameWithPolicy(currentUrl.hostname, { policy: params.ssrfPolicy });
|
|
120
|
+
dispatcher = createPinnedDispatcher(pinned, params.dispatcherPolicy, params.ssrfPolicy);
|
|
120
121
|
const response = await fetchWithMatrixDispatcher({
|
|
121
122
|
url: currentUrl.toString(),
|
|
122
123
|
init: {
|
|
@@ -216,10 +217,12 @@ async function performMatrixRequest(params) {
|
|
|
216
217
|
headers.set("Accept", params.raw ? "*/*" : "application/json");
|
|
217
218
|
if (params.accessToken) headers.set("Authorization", `Bearer ${params.accessToken}`);
|
|
218
219
|
let body;
|
|
219
|
-
if (params.body !== void 0)
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
220
|
+
if (params.body !== void 0) {
|
|
221
|
+
if (params.body instanceof Uint8Array || params.body instanceof ArrayBuffer || typeof params.body === "string") body = params.body;
|
|
222
|
+
else {
|
|
223
|
+
headers.set("Content-Type", "application/json");
|
|
224
|
+
body = JSON.stringify(params.body);
|
|
225
|
+
}
|
|
223
226
|
}
|
|
224
227
|
const { response, release } = await fetchWithMatrixGuardedRedirects({
|
|
225
228
|
url: baseUrl.toString(),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as writeMatrixIdbSnapshotJson, f as MATRIX_IDB_SNAPSHOT_FILENAME, w as readMatrixIdbSnapshotJson } from "./storage-
|
|
1
|
+
import { D as writeMatrixIdbSnapshotJson, f as MATRIX_IDB_SNAPSHOT_FILENAME, w as readMatrixIdbSnapshotJson } from "./storage-BVf4uucD.js";
|
|
2
2
|
import { n as LogService } from "./logger-B_71hN6W.js";
|
|
3
|
-
import { n as MATRIX_IDB_SNAPSHOT_LOCK_OPTIONS } from "./idb-persistence-lock-
|
|
3
|
+
import { n as MATRIX_IDB_SNAPSHOT_LOCK_OPTIONS } from "./idb-persistence-lock-B3fZXyF_.js";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { toErrorObject } from "openclaw/plugin-sdk/error-runtime";
|
|
6
6
|
import fs from "node:fs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region extensions/matrix/src/matrix/sdk/idb-persistence-lock.ts
|
|
2
2
|
const MATRIX_IDB_PERSIST_INTERVAL_MS = 6e4;
|
|
3
|
-
const IDB_SNAPSHOT_LOCK_STALE_MS =
|
|
3
|
+
const IDB_SNAPSHOT_LOCK_STALE_MS = 3e5;
|
|
4
4
|
const IDB_SNAPSHOT_LOCK_RETRY_BASE = {
|
|
5
5
|
factor: 2,
|
|
6
6
|
minTimeout: 50,
|
|
@@ -4,7 +4,7 @@ import { createChannelReplayGuard, resolvePersistentDedupePluginStateNamespace }
|
|
|
4
4
|
const MATRIX_INBOUND_DEDUPE_PLUGIN_ID = "matrix";
|
|
5
5
|
const MATRIX_INBOUND_DEDUPE_NAMESPACE_PREFIX = "matrix.inbound-dedupe";
|
|
6
6
|
const MATRIX_INBOUND_DEDUPE_NAMESPACE = "global";
|
|
7
|
-
const MATRIX_INBOUND_DEDUPE_TTL_MS =
|
|
7
|
+
const MATRIX_INBOUND_DEDUPE_TTL_MS = 2592e6;
|
|
8
8
|
const MATRIX_INBOUND_DEDUPE_MEMORY_MAX = 5e3;
|
|
9
9
|
const MATRIX_INBOUND_DEDUPE_STATE_MAX_ENTRIES = 2e4;
|
|
10
10
|
function resolveMatrixInboundDedupeAccountId(accountId) {
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as registerMatrixCliMetadata } from "./cli-metadata-
|
|
1
|
+
import { n as registerMatrixCliMetadata } from "./cli-metadata-BGryAl2e.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,14 +1,163 @@
|
|
|
1
1
|
import { n as MATRIX_REACTION_EVENT_TYPE } from "./reaction-common-DkrQdBSZ.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { r as withResolvedRoomAction } from "./client-BUtHbzib.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-B5XChnvB.js";
|
|
3
|
+
import { r as withResolvedRoomAction } from "./client-oNOlldJI.js";
|
|
5
4
|
import { n as isMatrixNotFoundError } from "./errors-DKVS3_DO.js";
|
|
6
|
-
import { asNullableObjectRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
5
|
+
import { asNullableObjectRecord, asNullableRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
//#region extensions/matrix/src/matrix/poll-summary.ts
|
|
8
|
+
function resolveMatrixPollRootEventId(event) {
|
|
9
|
+
if (isPollStartType(event.type)) {
|
|
10
|
+
const eventId = event.event_id?.trim();
|
|
11
|
+
return eventId ? eventId : null;
|
|
12
|
+
}
|
|
13
|
+
return resolvePollReferenceEventId(event.content);
|
|
14
|
+
}
|
|
15
|
+
async function readAllPollRelations(client, roomId, pollEventId) {
|
|
16
|
+
const relationEvents = [];
|
|
17
|
+
const seenCursors = /* @__PURE__ */ new Set();
|
|
18
|
+
let nextBatch;
|
|
19
|
+
do {
|
|
20
|
+
const page = await client.getRelations(roomId, pollEventId, "m.reference", void 0, { from: nextBatch });
|
|
21
|
+
relationEvents.push(...page.events);
|
|
22
|
+
nextBatch = page.nextBatch ?? void 0;
|
|
23
|
+
if (nextBatch && seenCursors.has(nextBatch)) throw new Error("Matrix poll pagination returned a repeated cursor");
|
|
24
|
+
if (nextBatch) seenCursors.add(nextBatch);
|
|
25
|
+
} while (nextBatch);
|
|
26
|
+
return relationEvents;
|
|
27
|
+
}
|
|
28
|
+
async function fetchMatrixPollSnapshot(client, roomId, event) {
|
|
29
|
+
if (!isPollEventType(event.type)) return null;
|
|
30
|
+
const pollEventId = resolveMatrixPollRootEventId(event);
|
|
31
|
+
if (!pollEventId) return null;
|
|
32
|
+
const rootEvent = isPollStartType(event.type) ? event : await client.getEvent(roomId, pollEventId);
|
|
33
|
+
if (!isPollStartType(rootEvent.type)) return null;
|
|
34
|
+
const pollStartContent = rootEvent.content;
|
|
35
|
+
const pollSummary = parsePollStartContent(pollStartContent);
|
|
36
|
+
if (!pollSummary) return null;
|
|
37
|
+
const relationEvents = await readAllPollRelations(client, roomId, pollEventId);
|
|
38
|
+
const pollResults = buildPollResultsSummary({
|
|
39
|
+
pollEventId,
|
|
40
|
+
roomId,
|
|
41
|
+
sender: rootEvent.sender,
|
|
42
|
+
senderName: rootEvent.sender,
|
|
43
|
+
content: pollStartContent,
|
|
44
|
+
relationEvents
|
|
45
|
+
});
|
|
46
|
+
return {
|
|
47
|
+
pollEventId,
|
|
48
|
+
triggerEvent: event,
|
|
49
|
+
rootEvent,
|
|
50
|
+
text: pollResults ? formatPollResultsAsText(pollResults) : formatPollAsText(pollSummary)
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
async function fetchMatrixPollMessageSummary(client, roomId, event) {
|
|
54
|
+
const snapshot = await fetchMatrixPollSnapshot(client, roomId, event);
|
|
55
|
+
if (!snapshot) return null;
|
|
56
|
+
return {
|
|
57
|
+
eventId: snapshot.pollEventId,
|
|
58
|
+
sender: snapshot.rootEvent.sender,
|
|
59
|
+
body: snapshot.text,
|
|
60
|
+
msgtype: "m.text",
|
|
61
|
+
timestamp: snapshot.triggerEvent.origin_server_ts || snapshot.rootEvent.origin_server_ts
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
7
65
|
//#region extensions/matrix/src/matrix/actions/limits.ts
|
|
8
66
|
function resolveMatrixActionLimit(raw, fallback) {
|
|
9
67
|
return Math.max(1, Math.floor(raw !== void 0 && Number.isFinite(raw) ? raw : fallback));
|
|
10
68
|
}
|
|
11
69
|
//#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
|
|
12
161
|
//#region extensions/matrix/src/matrix/actions/types.ts
|
|
13
162
|
const EventType = {
|
|
14
163
|
RoomMessage: "m.room.message",
|
|
@@ -258,4 +407,4 @@ async function isMatrixPollRootThreaded(params) {
|
|
|
258
407
|
return hydratedRoot ? isMatrixThreadEvent(hydratedRoot) : false;
|
|
259
408
|
}
|
|
260
409
|
//#endregion
|
|
261
|
-
export { fetchEventSummary as a,
|
|
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 };
|