@openclaw/matrix 2026.7.2-beta.2 → 2026.7.2-beta.4
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-selection-Bz00QTmQ.js → account-selection-kqquRzCf.js} +5 -5
- package/dist/api.js +6 -6
- package/dist/{approval-handler.runtime-BQZdg_dJ.js → approval-handler.runtime-AsawryfP.js} +4 -4
- package/dist/{approval-ids-De4IhOSN.js → approval-ids-XAMP8vN9.js} +1 -1
- package/dist/{approval-reaction-auth-BLJKPLku.js → approval-reaction-auth-DButmM13.js} +2 -2
- package/dist/auth-presence.js +13 -21
- package/dist/{channel-B1woOUgk.js → channel-MBtrY36B.js} +19 -13
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel.runtime-BvJm9z0w.js → channel.runtime-Bi4Dgy2P.js} +15 -16
- package/dist/{cli-CLWOkMvw.js → cli-CcPuMyCk.js} +15 -12
- package/dist/{cli-metadata-9Naf7in0.js → cli-metadata-DAhDhbYX.js} +1 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/{client-BUai6s29.js → client-BwX6rURh.js} +2 -2
- package/dist/{client-CPuYbNL8.js → client-Dg8dk8NW.js} +2 -2
- package/dist/{client-bootstrap-CNVF73sF.js → client-bootstrap-ZAaO9fZ-.js} +1 -1
- package/dist/{config-schema-BTSatSY3.js → config-schema-CggnuwnJ.js} +4 -5
- package/dist/contract-api.js +2 -2
- package/dist/{create-client-85ttAWDP.js → create-client-Und1YmJ2.js} +4 -4
- package/dist/credentials-W2EmwRhu.js +65 -0
- package/dist/credentials-read-DVmFCm7X.js +77 -0
- package/dist/{credentials-write.runtime-BDtpqvj0.js → credentials-write.runtime-Be9zNSUw.js} +1 -1
- package/dist/{crypto-runtime-DoEB5RpM.js → crypto-runtime-_j7TpS7k.js} +3 -3
- package/dist/{directory-live-0TyS9xep.js → directory-live-B6fbX6jf.js} +3 -3
- package/dist/{doctor-BGTs609f.js → doctor-C0LPJGTz.js} +1 -1
- package/dist/doctor-contract-CWVdlRQR.js +183 -0
- package/dist/doctor-contract-api.js +220 -73
- package/dist/{draft-stream-GOdPZMBm.js → draft-stream-BfibauH1.js} +1 -1
- package/dist/{encryption-guidance-BFfgq7c7.js → encryption-guidance-CbEFe38F.js} +1 -1
- package/dist/{file-sync-store-CUE9WwD2.js → file-sync-store-DUEWCEjb.js} +21 -4
- package/dist/helper-api.js +2 -2
- package/dist/{http-client-Jw5_bwQo.js → http-client-DOyTG9l2.js} +2 -2
- package/dist/{idb-persistence-BiHEEzD7.js → idb-persistence-C6zQfW2w.js} +73 -64
- package/dist/index.js +1 -1
- package/dist/{media-text-DPCtdFjk.js → media-text-Cv1VIHXW.js} +1 -1
- package/dist/{messages-DCRbGLMh.js → messages-ClTgfFl6.js} +3 -3
- package/dist/{monitor-C5EOF9et.js → monitor-2BjKS9RV.js} +93 -92
- package/dist/plugin-entry.handlers.runtime.js +1 -1
- package/dist/probe.runtime-BWkgfbiE.js +3 -0
- package/dist/{profile-update-DompcDyu.js → profile-update-C2My3TML.js} +2 -2
- package/dist/{reaction-events-QUgxkQKQ.js → reaction-events-Cj6thhmc.js} +2 -2
- package/dist/record-shared-CWWx6fvI.js +2 -0
- package/dist/{recovery-key-store-B2RglalK.js → recovery-key-store-0O8ARdT_.js} +1 -1
- package/dist/{resolve-targets-Cx1VVArA.js → resolve-targets-Dn11HT76.js} +1 -1
- package/dist/{resolver.runtime-PPrv3ZHu.js → resolver.runtime-Zguh0hH9.js} +1 -1
- package/dist/runtime-api.js +3 -3
- package/dist/{sdk-1TXuSiXZ.js → sdk-DiRXiRRf.js} +5 -5
- package/dist/{secret-contract-OZoQf0kI.js → secret-contract-M3hRmGO-.js} +21 -5
- package/dist/secret-contract-api.js +1 -1
- package/dist/{send-yre1krm8.js → send-CZCmDQu8.js} +4 -3
- package/dist/session-binding-contract-api.js +1 -1
- package/dist/{setup-bootstrap-DXVRCd4G.js → setup-bootstrap-C9w01xQK.js} +2 -2
- package/dist/{setup-core-CYQRY2oG.js → setup-core-D6gyoyeg.js} +109 -21
- package/dist/setup-plugin-api.js +4 -3
- package/dist/{setup-surface-BjvRQzK6.js → setup-surface-DZIEWtQC.js} +8 -6
- package/dist/{shared-BfW4lxGu.js → shared-C7Vm9RxI.js} +6 -6
- package/dist/{startup-verification-DSiyDKM5.js → startup-verification-D1nscMh8.js} +2 -2
- package/dist/{storage-DD-EnNJE.js → storage-BrkTJZov.js} +11 -44
- package/dist/{thread-bindings-U5ZroBeZ.js → thread-bindings-BcYBELC7.js} +3 -3
- package/dist/{tool-actions.runtime-BlfTr9b0.js → tool-actions.runtime-Dbco_Vwn.js} +7 -7
- package/dist/{verification-CGnI9k1O.js → verification-DhMBWxOJ.js} +2 -2
- package/node_modules/music-metadata/lib/common/Util.d.ts +1 -1
- package/node_modules/music-metadata/lib/common/Util.js +7 -1
- package/node_modules/music-metadata/lib/id3v2/FrameHeader.js +23 -3
- package/node_modules/music-metadata/lib/id3v2/FrameParser.js +2 -2
- package/node_modules/music-metadata/lib/id3v2/ID3v2Token.js +1 -1
- package/node_modules/music-metadata/lib/mp4/AtomToken.js +38 -13
- package/node_modules/music-metadata/lib/mpeg/MpegParser.js +1 -1
- package/node_modules/music-metadata/package.json +6 -6
- package/node_modules/typebox/build/compile/validator.d.mts +1 -4
- package/node_modules/typebox/build/guard/guard.d.mts +1 -1
- package/node_modules/typebox/build/guard/guard.mjs +5 -2
- package/node_modules/typebox/build/guard/string.mjs +16 -4
- package/node_modules/typebox/build/schema/engine/_functions.mjs +34 -15
- package/node_modules/typebox/build/type/action/readonly_object.d.mts +5 -0
- package/node_modules/typebox/build/type/action/readonly_object.mjs +8 -0
- package/node_modules/typebox/build/typebox.d.mts +1 -1
- package/node_modules/typebox/build/typebox.mjs +1 -1
- package/node_modules/typebox/package.json +1 -1
- package/node_modules/typebox/readme.md +29 -32
- package/npm-shrinkwrap.json +11 -11
- package/openclaw.plugin.json +7 -20
- package/package.json +111 -28
- package/dist/async-lock-BcLS4KOc.js +0 -19
- package/dist/credentials-CncWUieb.js +0 -56
- package/dist/credentials-read-CwNJrmwu.js +0 -112
- package/dist/doctor-contract-D2qTLe-C.js +0 -312
- package/dist/probe.runtime-BBvciVfo.js +0 -3
- package/dist/record-shared-CvzjvHRn.js +0 -2
- package/dist/{deps-DDbghaZH.js → deps-CcVJfvRM.js} +1 -1
- package/dist/{storage-paths-B4_I9iqO.js → storage-paths-gUmSydsW.js} +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
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 { f as resolveMatrixAuth } from "./shared-
|
|
4
|
-
import "./client-
|
|
5
|
-
import { t as MatrixAuthedHttpClient } from "./http-client-
|
|
3
|
+
import { f as resolveMatrixAuth } from "./shared-C7Vm9RxI.js";
|
|
4
|
+
import "./client-Dg8dk8NW.js";
|
|
5
|
+
import { t as MatrixAuthedHttpClient } from "./http-client-DOyTG9l2.js";
|
|
6
6
|
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
7
7
|
//#region extensions/matrix/src/directory-live.ts
|
|
8
8
|
var directory_live_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-
|
|
1
|
+
import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-CWVdlRQR.js";
|
|
2
2
|
import { detectPluginInstallPathIssue, formatPluginInstallPathIssue, removePluginFromConfig } from "openclaw/plugin-sdk/runtime-doctor";
|
|
3
3
|
//#region extensions/matrix/src/doctor.ts
|
|
4
4
|
async function collectMatrixInstallPathWarnings(cfg) {
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { t as isRecord } from "./record-shared-CWWx6fvI.js";
|
|
2
|
+
import { defineChannelAliasMigration, hasLegacyAccountStreamingAliases, normalizeChannelConfigEntries, stripRetiredChannelKeys } from "openclaw/plugin-sdk/runtime-doctor";
|
|
3
|
+
import { hasLegacyFlatAllowPrivateNetworkAlias, migrateLegacyFlatAllowPrivateNetworkAlias } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
4
|
+
//#region extensions/matrix/src/doctor-contract.ts
|
|
5
|
+
function parseMatrixStreamingMode(value) {
|
|
6
|
+
if (typeof value !== "string") return null;
|
|
7
|
+
const normalized = value.trim().toLowerCase();
|
|
8
|
+
return normalized === "partial" || normalized === "quiet" || normalized === "progress" || normalized === "off" ? normalized : null;
|
|
9
|
+
}
|
|
10
|
+
const streamingAliasMigration = defineChannelAliasMigration({
|
|
11
|
+
channelId: "matrix",
|
|
12
|
+
streaming: {
|
|
13
|
+
defaultMode: "off",
|
|
14
|
+
resolveMode: (entry) => {
|
|
15
|
+
const streaming = isRecord(entry.streaming) ? entry.streaming : null;
|
|
16
|
+
const parsed = parseMatrixStreamingMode(streaming ? streaming.mode : entry.streaming);
|
|
17
|
+
if (parsed) return parsed;
|
|
18
|
+
return entry.streaming === true ? "partial" : "off";
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
accountStreamingReplacesRoot: true
|
|
22
|
+
});
|
|
23
|
+
function hasLegacyMatrixRoomAllowAlias(value) {
|
|
24
|
+
const room = isRecord(value) ? value : null;
|
|
25
|
+
return Boolean(room && typeof room.allow === "boolean");
|
|
26
|
+
}
|
|
27
|
+
function hasLegacyMatrixRoomMapAllowAliases(value) {
|
|
28
|
+
const rooms = isRecord(value) ? value : null;
|
|
29
|
+
return Boolean(rooms && Object.values(rooms).some((room) => hasLegacyMatrixRoomAllowAlias(room)));
|
|
30
|
+
}
|
|
31
|
+
function hasLegacyTrustedDmPolicy(value) {
|
|
32
|
+
const root = isRecord(value) ? value : null;
|
|
33
|
+
if (!root) return false;
|
|
34
|
+
return (isRecord(root.dm) ? root.dm : null)?.policy === "trusted";
|
|
35
|
+
}
|
|
36
|
+
function migrateLegacyTrustedDmPolicy(params) {
|
|
37
|
+
const dm = isRecord(params.entry.dm) ? params.entry.dm : null;
|
|
38
|
+
if (!dm || dm.policy !== "trusted") return {
|
|
39
|
+
entry: params.entry,
|
|
40
|
+
changed: false
|
|
41
|
+
};
|
|
42
|
+
const allowFromRaw = dm.allowFrom;
|
|
43
|
+
const allowFromEntries = Array.isArray(allowFromRaw) ? allowFromRaw.filter((entry) => typeof entry === "string" && entry.trim().length > 0).length : 0;
|
|
44
|
+
const nextPolicy = allowFromEntries > 0 ? "allowlist" : "pairing";
|
|
45
|
+
const nextDm = {
|
|
46
|
+
...dm,
|
|
47
|
+
policy: nextPolicy
|
|
48
|
+
};
|
|
49
|
+
params.changes.push(`Migrated ${params.pathPrefix}.dm.policy "trusted" → "${nextPolicy}" (legacy alias removed; ${allowFromEntries > 0 ? `preserved ${allowFromEntries} ${params.pathPrefix}.dm.allowFrom ${allowFromEntries === 1 ? "entry" : "entries"}` : "no allowFrom entries present, defaulting to pairing for safety"}).`);
|
|
50
|
+
return {
|
|
51
|
+
entry: {
|
|
52
|
+
...params.entry,
|
|
53
|
+
dm: nextDm
|
|
54
|
+
},
|
|
55
|
+
changed: true
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function normalizeMatrixRoomAllowAliases(params) {
|
|
59
|
+
let changed = false;
|
|
60
|
+
const nextRooms = { ...params.rooms };
|
|
61
|
+
for (const [roomId, roomValue] of Object.entries(params.rooms)) {
|
|
62
|
+
const room = isRecord(roomValue) ? roomValue : null;
|
|
63
|
+
if (!room || typeof room.allow !== "boolean") continue;
|
|
64
|
+
const nextRoom = { ...room };
|
|
65
|
+
if (typeof nextRoom.enabled !== "boolean") nextRoom.enabled = room.allow;
|
|
66
|
+
delete nextRoom.allow;
|
|
67
|
+
nextRooms[roomId] = nextRoom;
|
|
68
|
+
changed = true;
|
|
69
|
+
params.changes.push(`Moved ${params.pathPrefix}.${roomId}.allow → ${params.pathPrefix}.${roomId}.enabled (${String(nextRoom.enabled)}).`);
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
rooms: nextRooms,
|
|
73
|
+
changed
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
const legacyConfigRules = [
|
|
77
|
+
...streamingAliasMigration.legacyConfigRules,
|
|
78
|
+
{
|
|
79
|
+
path: ["channels", "matrix"],
|
|
80
|
+
message: "channels.matrix.allowPrivateNetwork is legacy; use channels.matrix.network.dangerouslyAllowPrivateNetwork instead. Run \"openclaw doctor --fix\".",
|
|
81
|
+
match: (value) => hasLegacyFlatAllowPrivateNetworkAlias(isRecord(value) ? value : {})
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
path: [
|
|
85
|
+
"channels",
|
|
86
|
+
"matrix",
|
|
87
|
+
"accounts"
|
|
88
|
+
],
|
|
89
|
+
message: "channels.matrix.accounts.<id>.allowPrivateNetwork is legacy; use channels.matrix.accounts.<id>.network.dangerouslyAllowPrivateNetwork instead. Run \"openclaw doctor --fix\".",
|
|
90
|
+
match: (value) => hasLegacyAccountStreamingAliases(value, (account) => hasLegacyFlatAllowPrivateNetworkAlias(isRecord(account) ? account : {}))
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
path: [
|
|
94
|
+
"channels",
|
|
95
|
+
"matrix",
|
|
96
|
+
"groups"
|
|
97
|
+
],
|
|
98
|
+
message: "channels.matrix.groups.<room>.allow is legacy; use channels.matrix.groups.<room>.enabled instead. Run \"openclaw doctor --fix\".",
|
|
99
|
+
match: hasLegacyMatrixRoomMapAllowAliases
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
path: [
|
|
103
|
+
"channels",
|
|
104
|
+
"matrix",
|
|
105
|
+
"rooms"
|
|
106
|
+
],
|
|
107
|
+
message: "channels.matrix.rooms.<room>.allow is legacy; use channels.matrix.rooms.<room>.enabled instead. Run \"openclaw doctor --fix\".",
|
|
108
|
+
match: hasLegacyMatrixRoomMapAllowAliases
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
path: [
|
|
112
|
+
"channels",
|
|
113
|
+
"matrix",
|
|
114
|
+
"accounts"
|
|
115
|
+
],
|
|
116
|
+
message: "channels.matrix.accounts.<id>.{groups,rooms}.<room>.allow is legacy; use channels.matrix.accounts.<id>.{groups,rooms}.<room>.enabled instead. Run \"openclaw doctor --fix\".",
|
|
117
|
+
match: (value) => hasLegacyAccountStreamingAliases(value, (account) => {
|
|
118
|
+
if (!isRecord(account)) return false;
|
|
119
|
+
return hasLegacyMatrixRoomMapAllowAliases(account.groups) || hasLegacyMatrixRoomMapAllowAliases(account.rooms);
|
|
120
|
+
})
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
path: ["channels", "matrix"],
|
|
124
|
+
message: "channels.matrix.dm.policy \"trusted\" is legacy; use \"allowlist\" (with allowFrom entries) or \"pairing\" instead. Run \"openclaw doctor --fix\".",
|
|
125
|
+
match: hasLegacyTrustedDmPolicy
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
path: [
|
|
129
|
+
"channels",
|
|
130
|
+
"matrix",
|
|
131
|
+
"accounts"
|
|
132
|
+
],
|
|
133
|
+
message: "channels.matrix.accounts.<id>.dm.policy \"trusted\" is legacy; use \"allowlist\" (with allowFrom entries) or \"pairing\" instead. Run \"openclaw doctor --fix\".",
|
|
134
|
+
match: (value) => hasLegacyAccountStreamingAliases(value, hasLegacyTrustedDmPolicy)
|
|
135
|
+
}
|
|
136
|
+
];
|
|
137
|
+
function normalizeMatrixEntry(params) {
|
|
138
|
+
const network = migrateLegacyFlatAllowPrivateNetworkAlias(params);
|
|
139
|
+
const dmPolicy = migrateLegacyTrustedDmPolicy({
|
|
140
|
+
...params,
|
|
141
|
+
entry: network.entry
|
|
142
|
+
});
|
|
143
|
+
let entry = dmPolicy.entry;
|
|
144
|
+
let changed = network.changed || dmPolicy.changed;
|
|
145
|
+
for (const key of ["groups", "rooms"]) {
|
|
146
|
+
const rooms = isRecord(entry[key]) ? entry[key] : null;
|
|
147
|
+
if (!rooms) continue;
|
|
148
|
+
const normalized = normalizeMatrixRoomAllowAliases({
|
|
149
|
+
rooms,
|
|
150
|
+
pathPrefix: `${params.pathPrefix}.${key}`,
|
|
151
|
+
changes: params.changes
|
|
152
|
+
});
|
|
153
|
+
if (normalized.changed) {
|
|
154
|
+
entry = Object.assign({}, entry, { [key]: normalized.rooms });
|
|
155
|
+
changed = true;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
entry,
|
|
160
|
+
changed
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function normalizeCompatibilityConfig({ cfg }) {
|
|
164
|
+
const changes = [];
|
|
165
|
+
const withoutJunkStreamMode = stripRetiredChannelKeys({
|
|
166
|
+
cfg,
|
|
167
|
+
channelId: "matrix",
|
|
168
|
+
keys: /* @__PURE__ */ new Set(["streamMode"]),
|
|
169
|
+
scope: "root-and-accounts",
|
|
170
|
+
onRemove: ({ key, pathPrefix }) => changes.push(`Removed ${pathPrefix}.${key} (never read by the Matrix runtime).`)
|
|
171
|
+
}).config;
|
|
172
|
+
return normalizeChannelConfigEntries({
|
|
173
|
+
cfg: streamingAliasMigration.normalizeChannelConfig({
|
|
174
|
+
cfg: withoutJunkStreamMode,
|
|
175
|
+
changes
|
|
176
|
+
}).config,
|
|
177
|
+
channelId: "matrix",
|
|
178
|
+
changes,
|
|
179
|
+
normalizeEntry: normalizeMatrixEntry
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
//#endregion
|
|
183
|
+
export { normalizeCompatibilityConfig as n, legacyConfigRules as t };
|
|
@@ -1,14 +1,104 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { a as
|
|
1
|
+
import { a as resolveMatrixDefaultOrOnlyAccountId, n as requiresExplicitMatrixDefaultAccount } from "./account-selection-kqquRzCf.js";
|
|
2
|
+
import { t as isRecord$1 } from "./record-shared-CWWx6fvI.js";
|
|
3
|
+
import { r as resolveMatrixCredentialsDir } from "./storage-paths-gUmSydsW.js";
|
|
4
|
+
import { a as isMatrixCredentialRevocation, c as normalizeMatrixStoredCredentials, s as matrixCredentialsStoreKey, t as MATRIX_CREDENTIALS_NAMESPACE } from "./credentials-read-DVmFCm7X.js";
|
|
5
|
+
import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-CWVdlRQR.js";
|
|
6
|
+
import { C as readLegacyMatrixRecoveryKeyState, O as writeMatrixIdbSnapshotJsonToStore, T as readMatrixIdbSnapshotJsonFromStore, 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, v as openMatrixIdbSnapshotStoreOptions, x as readLegacyMatrixLegacyCryptoMigrationState, y as openMatrixLegacyCryptoMigrationStoreOptions } from "./storage-BrkTJZov.js";
|
|
7
|
+
import { a as readLegacyMatrixSyncCacheState, i as openMatrixSyncCacheStoreOptions, o as writeMatrixSyncCacheStateToStore, r as hasMatrixSyncCacheStateInStore } from "./file-sync-store-DUEWCEjb.js";
|
|
8
|
+
import { n as MATRIX_IDB_SNAPSHOT_LOCK_OPTIONS } from "./idb-persistence-lock-DAJ49nZX.js";
|
|
9
|
+
import { r as readLegacyMatrixIdbSnapshotStateUnlocked, t as isValidMatrixIdbSnapshotJson } from "./idb-persistence-C6zQfW2w.js";
|
|
5
10
|
import { a as resolveMatrixInboundDedupeStateNamespace, n as MATRIX_INBOUND_DEDUPE_TTL_MS, r as buildMatrixInboundDedupeEventKey } from "./inbound-dedupe-CaBLblef.js";
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import { createHash } from "node:crypto";
|
|
11
|
+
import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
12
|
+
import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
9
13
|
import { archiveLegacyStateSource } from "openclaw/plugin-sdk/runtime-doctor";
|
|
10
|
-
import
|
|
14
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
15
|
+
import path from "node:path";
|
|
16
|
+
import fs from "node:fs";
|
|
17
|
+
import fs$1 from "node:fs/promises";
|
|
18
|
+
import { isDeepStrictEqual } from "node:util";
|
|
19
|
+
import { withFileLock } from "openclaw/plugin-sdk/file-lock";
|
|
11
20
|
import { createPersistentDedupeImportEntry } from "openclaw/plugin-sdk/persistent-dedupe";
|
|
21
|
+
//#region extensions/matrix/src/matrix/crypto-snapshot-doctor.ts
|
|
22
|
+
async function migrateLegacyMatrixIdbSnapshot(params) {
|
|
23
|
+
const snapshotPath = path.join(params.storageRootDir, MATRIX_IDB_SNAPSHOT_FILENAME);
|
|
24
|
+
try {
|
|
25
|
+
await withFileLock(snapshotPath, MATRIX_IDB_SNAPSHOT_LOCK_OPTIONS, () => migrateLegacyMatrixIdbSnapshotLocked(params));
|
|
26
|
+
} catch (err) {
|
|
27
|
+
params.warnings.push(`Failed locking Matrix IndexedDB snapshot for ${params.storageRootDir}: ${String(err)}; left legacy source in place`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async function migrateLegacyMatrixIdbSnapshotLocked(params) {
|
|
31
|
+
const sourcePath = path.join(params.storageRootDir, MATRIX_IDB_SNAPSHOT_FILENAME);
|
|
32
|
+
let snapshot;
|
|
33
|
+
try {
|
|
34
|
+
snapshot = readLegacyMatrixIdbSnapshotStateUnlocked(params.storageRootDir);
|
|
35
|
+
} catch (err) {
|
|
36
|
+
params.warnings.push(`Failed reading Matrix IndexedDB snapshot legacy source for ${params.storageRootDir}: ${String(err)}; left source in place`);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (!snapshot) {
|
|
40
|
+
if (!fs.existsSync(sourcePath)) return;
|
|
41
|
+
const archived = await archiveLegacyMatrixIdbSnapshot(params);
|
|
42
|
+
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`);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const snapshotJson = JSON.stringify(snapshot);
|
|
46
|
+
const store = params.context.openPluginStateKeyedStore(openMatrixIdbSnapshotStoreOptions(params.storageRootDir));
|
|
47
|
+
let persisted;
|
|
48
|
+
let hadPartialState;
|
|
49
|
+
try {
|
|
50
|
+
persisted = await readMatrixIdbSnapshotJsonFromStore({ store });
|
|
51
|
+
const persistedIsValid = persisted ? isValidMatrixIdbSnapshotJson(persisted) : false;
|
|
52
|
+
hadPartialState = !persistedIsValid && (await store.entries()).length > 0;
|
|
53
|
+
if (!persistedIsValid) persisted = null;
|
|
54
|
+
} catch (err) {
|
|
55
|
+
params.warnings.push(`Failed inspecting Matrix IndexedDB snapshot SQLite state for ${params.storageRootDir}: ${String(err)}; left legacy source in place`);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (persisted && !snapshotContentMatches(persisted, snapshot)) {
|
|
59
|
+
if (await archiveLegacyMatrixIdbSnapshot(params)) params.notices.push(`Kept the canonical Matrix IndexedDB snapshot in SQLite and archived a differing legacy source for ${params.storageRootDir}`);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (!persisted) {
|
|
63
|
+
try {
|
|
64
|
+
await writeMatrixIdbSnapshotJsonToStore({
|
|
65
|
+
snapshotJson,
|
|
66
|
+
databaseCount: snapshot.length,
|
|
67
|
+
store
|
|
68
|
+
});
|
|
69
|
+
persisted = await readMatrixIdbSnapshotJsonFromStore({ store });
|
|
70
|
+
} catch (err) {
|
|
71
|
+
params.warnings.push(`Failed importing Matrix IndexedDB snapshot for ${params.storageRootDir}: ${String(err)}; left legacy source in place`);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (!persisted || !snapshotContentMatches(persisted, snapshot)) {
|
|
75
|
+
params.warnings.push(`Failed verifying Matrix IndexedDB snapshot for ${params.storageRootDir}; left legacy source in place`);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
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}`);
|
|
79
|
+
}
|
|
80
|
+
await archiveLegacyMatrixIdbSnapshot(params);
|
|
81
|
+
}
|
|
82
|
+
function snapshotContentMatches(persistedJson, snapshot) {
|
|
83
|
+
try {
|
|
84
|
+
return isDeepStrictEqual(JSON.parse(persistedJson), snapshot);
|
|
85
|
+
} catch {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async function archiveLegacyMatrixIdbSnapshot(params) {
|
|
90
|
+
const sourcePath = path.join(params.storageRootDir, MATRIX_IDB_SNAPSHOT_FILENAME);
|
|
91
|
+
const archivePath = `${sourcePath}.migrated-${(/* @__PURE__ */ new Date()).toISOString().replaceAll(":", "-")}-${randomUUID()}`;
|
|
92
|
+
try {
|
|
93
|
+
await fs$1.rename(sourcePath, archivePath);
|
|
94
|
+
params.changes.push(`Archived Matrix IndexedDB snapshot legacy source -> ${archivePath}`);
|
|
95
|
+
return true;
|
|
96
|
+
} catch (err) {
|
|
97
|
+
params.warnings.push(`Failed archiving Matrix IndexedDB snapshot legacy source: ${String(err)}`);
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
12
102
|
//#region extensions/matrix/src/matrix/monitor/inbound-dedupe-migration.ts
|
|
13
103
|
const LEGACY_SQLITE_NAMESPACE = "inbound-dedupe";
|
|
14
104
|
const LEGACY_SQLITE_MAX_ENTRIES = 2e4;
|
|
@@ -24,7 +114,7 @@ async function collectMatrixInboundDedupeSources(stateDir) {
|
|
|
24
114
|
async function visit(dir) {
|
|
25
115
|
let entries;
|
|
26
116
|
try {
|
|
27
|
-
entries = await fs.readdir(dir, { withFileTypes: true });
|
|
117
|
+
entries = await fs$1.readdir(dir, { withFileTypes: true });
|
|
28
118
|
} catch {
|
|
29
119
|
return;
|
|
30
120
|
}
|
|
@@ -71,7 +161,7 @@ function normalizeLegacyTimestamp(raw) {
|
|
|
71
161
|
return Math.max(0, Math.floor(raw));
|
|
72
162
|
}
|
|
73
163
|
function parseLegacySqliteRow(row) {
|
|
74
|
-
const value = isRecord(row.value) ? row.value : {};
|
|
164
|
+
const value = isRecord$1(row.value) ? row.value : {};
|
|
75
165
|
const roomId = typeof value.roomId === "string" ? value.roomId.trim() : "";
|
|
76
166
|
const eventId = typeof value.eventId === "string" ? value.eventId.trim() : "";
|
|
77
167
|
const ts = normalizeLegacyTimestamp(value.ts);
|
|
@@ -108,7 +198,7 @@ async function retireLegacyInboundDedupeSqliteRows(io, storageRootDir) {
|
|
|
108
198
|
}
|
|
109
199
|
async function resolveJsonRootAccountId(storageRootDir) {
|
|
110
200
|
for (const filename of [STORAGE_META_FILENAME, `${STORAGE_META_FILENAME}.migrated`]) try {
|
|
111
|
-
const metadata = normalizeMatrixStorageMetadata(JSON.parse(await fs.readFile(path.join(storageRootDir, filename), "utf8")));
|
|
201
|
+
const metadata = normalizeMatrixStorageMetadata(JSON.parse(await fs$1.readFile(path.join(storageRootDir, filename), "utf8")));
|
|
112
202
|
if (metadata?.accountId) return metadata.accountId;
|
|
113
203
|
} catch {}
|
|
114
204
|
return "default";
|
|
@@ -120,18 +210,18 @@ async function resolveJsonRootAccountId(storageRootDir) {
|
|
|
120
210
|
*/
|
|
121
211
|
async function readLegacyInboundDedupeJsonSource(storageRootDir) {
|
|
122
212
|
const jsonPath = path.join(storageRootDir, MATRIX_LEGACY_INBOUND_DEDUPE_FILENAME);
|
|
123
|
-
const raw = await fs.readFile(jsonPath, "utf8");
|
|
213
|
+
const raw = await fs$1.readFile(jsonPath, "utf8");
|
|
124
214
|
let parsed;
|
|
125
215
|
try {
|
|
126
216
|
parsed = JSON.parse(raw);
|
|
127
217
|
} catch {
|
|
128
218
|
return null;
|
|
129
219
|
}
|
|
130
|
-
if (!isRecord(parsed) || parsed.version !== LEGACY_JSON_VERSION || !Array.isArray(parsed.entries)) return null;
|
|
220
|
+
if (!isRecord$1(parsed) || parsed.version !== LEGACY_JSON_VERSION || !Array.isArray(parsed.entries)) return null;
|
|
131
221
|
const accountId = await resolveJsonRootAccountId(storageRootDir);
|
|
132
222
|
const markers = [];
|
|
133
223
|
for (const entry of parsed.entries) {
|
|
134
|
-
if (!isRecord(entry) || typeof entry.key !== "string") continue;
|
|
224
|
+
if (!isRecord$1(entry) || typeof entry.key !== "string") continue;
|
|
135
225
|
const separator = entry.key.indexOf("|");
|
|
136
226
|
if (separator <= 0) continue;
|
|
137
227
|
const roomId = entry.key.slice(0, separator).trim();
|
|
@@ -199,13 +289,46 @@ async function importNewestInboundDedupeMarkers(params) {
|
|
|
199
289
|
//#region extensions/matrix/doctor-contract-api.ts
|
|
200
290
|
const MATRIX_SYNC_CACHE_FILENAME = "bot-storage.json";
|
|
201
291
|
const MATRIX_STORAGE_META_FILENAME = "storage-meta.json";
|
|
202
|
-
async function
|
|
292
|
+
async function collectLegacyMatrixCredentialSources(params) {
|
|
293
|
+
const credentialsDir = resolveMatrixCredentialsDir(params.stateDir);
|
|
294
|
+
let entries;
|
|
295
|
+
try {
|
|
296
|
+
entries = await fs$1.readdir(credentialsDir, { withFileTypes: true });
|
|
297
|
+
} catch {
|
|
298
|
+
return [];
|
|
299
|
+
}
|
|
300
|
+
return entries.filter((entry) => entry.isFile() && /^credentials(?:-[a-z0-9._-]+)?\.json$/iu.test(entry.name)).toSorted((left, right) => {
|
|
301
|
+
if (left.name === "credentials.json") return 1;
|
|
302
|
+
if (right.name === "credentials.json") return -1;
|
|
303
|
+
return left.name.localeCompare(right.name);
|
|
304
|
+
}).map((entry) => {
|
|
305
|
+
const namedAccount = /^credentials(?:-([a-z0-9._-]+))?\.json$/iu.exec(entry.name)?.[1];
|
|
306
|
+
return {
|
|
307
|
+
accountId: namedAccount ? normalizeAccountId(namedAccount) : requiresExplicitMatrixDefaultAccount(params.config, params.env) ? null : normalizeAccountId(resolveMatrixDefaultOrOnlyAccountId(params.config, params.env)),
|
|
308
|
+
filePath: path.join(credentialsDir, entry.name)
|
|
309
|
+
};
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
async function readLegacyMatrixCredentials(source) {
|
|
313
|
+
if (!source.accountId) return null;
|
|
314
|
+
try {
|
|
315
|
+
const raw = JSON.parse(await fs$1.readFile(source.filePath, "utf8"));
|
|
316
|
+
const createdAt = isRecord(raw) && typeof raw.createdAt === "string" && raw.createdAt ? raw.createdAt : (await fs$1.stat(source.filePath)).mtime.toISOString();
|
|
317
|
+
return normalizeMatrixStoredCredentials(isRecord(raw) ? {
|
|
318
|
+
...raw,
|
|
319
|
+
createdAt
|
|
320
|
+
} : raw, source.accountId);
|
|
321
|
+
} catch {
|
|
322
|
+
return null;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
async function collectLegacyMatrixStateRoots(stateDir, filename, options) {
|
|
203
326
|
const matrixRoot = path.join(stateDir, "matrix");
|
|
204
327
|
const roots = [];
|
|
205
328
|
async function visit(dir) {
|
|
206
329
|
let entries;
|
|
207
330
|
try {
|
|
208
|
-
entries = await fs.readdir(dir, { withFileTypes: true });
|
|
331
|
+
entries = await fs$1.readdir(dir, { withFileTypes: true });
|
|
209
332
|
} catch {
|
|
210
333
|
return;
|
|
211
334
|
}
|
|
@@ -219,14 +342,14 @@ async function collectLegacyMatrixStateRoots(stateDir, filename) {
|
|
|
219
342
|
}
|
|
220
343
|
}
|
|
221
344
|
await visit(matrixRoot);
|
|
222
|
-
return roots.filter((root) => path.resolve(root) !== path.resolve(matrixRoot)).toSorted();
|
|
345
|
+
return roots.filter((root) => options?.includeMatrixRoot || path.resolve(root) !== path.resolve(matrixRoot)).toSorted();
|
|
223
346
|
}
|
|
224
347
|
async function collectLegacySyncCacheRoots(stateDir) {
|
|
225
348
|
return collectLegacyMatrixStateRoots(stateDir, MATRIX_SYNC_CACHE_FILENAME);
|
|
226
349
|
}
|
|
227
350
|
async function readLegacyMatrixStorageMetadata(storageRootDir) {
|
|
228
351
|
try {
|
|
229
|
-
return normalizeMatrixStorageMetadata(JSON.parse(await fs.readFile(path.join(storageRootDir, MATRIX_STORAGE_META_FILENAME), "utf8")));
|
|
352
|
+
return normalizeMatrixStorageMetadata(JSON.parse(await fs$1.readFile(path.join(storageRootDir, MATRIX_STORAGE_META_FILENAME), "utf8")));
|
|
230
353
|
} catch {
|
|
231
354
|
return null;
|
|
232
355
|
}
|
|
@@ -249,6 +372,74 @@ async function archiveLegacyMatrixStateFile(params) {
|
|
|
249
372
|
if (params.notice && params.warnings.length === warningCount) params.notices?.push(params.notice);
|
|
250
373
|
}
|
|
251
374
|
const stateMigrations = [
|
|
375
|
+
{
|
|
376
|
+
id: "matrix-credentials-json-to-plugin-state",
|
|
377
|
+
label: "Matrix credentials",
|
|
378
|
+
async detectLegacyState(params) {
|
|
379
|
+
const sources = await collectLegacyMatrixCredentialSources(params);
|
|
380
|
+
return sources.length > 0 ? { preview: [`Matrix credential JSON can migrate to SQLite (${sources.length} ${sources.length === 1 ? "file" : "files"})`] } : null;
|
|
381
|
+
},
|
|
382
|
+
async migrateLegacyState(params) {
|
|
383
|
+
const changes = [];
|
|
384
|
+
const warnings = [];
|
|
385
|
+
const sources = await collectLegacyMatrixCredentialSources(params);
|
|
386
|
+
const store = params.context.openPluginStateKeyedStore({
|
|
387
|
+
namespace: MATRIX_CREDENTIALS_NAMESPACE,
|
|
388
|
+
maxEntries: 256,
|
|
389
|
+
overflowPolicy: "reject-new"
|
|
390
|
+
});
|
|
391
|
+
for (const source of sources) {
|
|
392
|
+
if (!source.accountId) {
|
|
393
|
+
warnings.push(`Left ambiguous Matrix credential legacy source in place because no default account is selected: ${source.filePath}`);
|
|
394
|
+
continue;
|
|
395
|
+
}
|
|
396
|
+
const credentials = await readLegacyMatrixCredentials(source);
|
|
397
|
+
if (!credentials) {
|
|
398
|
+
warnings.push(`Left invalid Matrix credential legacy source in place: ${source.filePath}`);
|
|
399
|
+
continue;
|
|
400
|
+
}
|
|
401
|
+
const key = matrixCredentialsStoreKey(source.accountId);
|
|
402
|
+
const stored = await store.lookup(key);
|
|
403
|
+
if (isMatrixCredentialRevocation(stored, source.accountId)) {
|
|
404
|
+
changes.push(`Archived revoked Matrix credential legacy source for account ${source.accountId}`);
|
|
405
|
+
await archiveLegacyStateSource({
|
|
406
|
+
filePath: source.filePath,
|
|
407
|
+
label: "Matrix credentials",
|
|
408
|
+
changes,
|
|
409
|
+
warnings
|
|
410
|
+
});
|
|
411
|
+
continue;
|
|
412
|
+
}
|
|
413
|
+
const existing = normalizeMatrixStoredCredentials(stored, source.accountId);
|
|
414
|
+
if (existing && JSON.stringify(existing) !== JSON.stringify(credentials)) {
|
|
415
|
+
warnings.push(`Kept existing Matrix credentials for account ${source.accountId}; left differing legacy source in place`);
|
|
416
|
+
continue;
|
|
417
|
+
}
|
|
418
|
+
if (!existing) try {
|
|
419
|
+
await store.registerIfAbsent(key, credentials);
|
|
420
|
+
} catch (error) {
|
|
421
|
+
warnings.push(`Failed importing Matrix credentials for account ${source.accountId}: ${String(error)}; left legacy source in place`);
|
|
422
|
+
continue;
|
|
423
|
+
}
|
|
424
|
+
const persisted = normalizeMatrixStoredCredentials(await store.lookup(key), source.accountId);
|
|
425
|
+
if (!persisted || JSON.stringify(persisted) !== JSON.stringify(credentials)) {
|
|
426
|
+
warnings.push(`Failed verifying Matrix credentials for account ${source.accountId}; left legacy source in place`);
|
|
427
|
+
continue;
|
|
428
|
+
}
|
|
429
|
+
changes.push(`Migrated Matrix credentials for account ${source.accountId} to SQLite`);
|
|
430
|
+
await archiveLegacyStateSource({
|
|
431
|
+
filePath: source.filePath,
|
|
432
|
+
label: "Matrix credentials",
|
|
433
|
+
changes,
|
|
434
|
+
warnings
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
return {
|
|
438
|
+
changes,
|
|
439
|
+
warnings
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
},
|
|
252
443
|
{
|
|
253
444
|
id: "matrix-inbound-dedupe-to-claimable-dedupe",
|
|
254
445
|
label: "Matrix inbound dedupe markers",
|
|
@@ -486,74 +677,23 @@ const stateMigrations = [
|
|
|
486
677
|
};
|
|
487
678
|
}
|
|
488
679
|
},
|
|
489
|
-
{
|
|
490
|
-
id: "matrix-idb-snapshot-json-to-plugin-state",
|
|
491
|
-
label: "Matrix IndexedDB snapshot",
|
|
492
|
-
async detectLegacyState(params) {
|
|
493
|
-
const previews = [];
|
|
494
|
-
for (const storageRootDir of await collectLegacyMatrixStateRoots(params.stateDir, MATRIX_IDB_SNAPSHOT_FILENAME)) {
|
|
495
|
-
if (!await readLegacyMatrixIdbSnapshotState(storageRootDir)) continue;
|
|
496
|
-
previews.push(`Matrix IndexedDB snapshot JSON can migrate to SQLite: ${storageRootDir}`);
|
|
497
|
-
}
|
|
498
|
-
return previews.length > 0 ? { preview: previews } : null;
|
|
499
|
-
},
|
|
500
|
-
async migrateLegacyState(params) {
|
|
501
|
-
const changes = [];
|
|
502
|
-
const warnings = [];
|
|
503
|
-
const notices = [];
|
|
504
|
-
for (const storageRootDir of await collectLegacyMatrixStateRoots(params.stateDir, MATRIX_IDB_SNAPSHOT_FILENAME)) {
|
|
505
|
-
const snapshot = await readLegacyMatrixIdbSnapshotState(storageRootDir);
|
|
506
|
-
if (!snapshot) continue;
|
|
507
|
-
const store = params.context.openPluginStateKeyedStore(openMatrixIdbSnapshotStoreOptions(storageRootDir));
|
|
508
|
-
if (await hasMatrixIdbSnapshotStateInStore({ store })) {
|
|
509
|
-
await archiveLegacyMatrixStateFile({
|
|
510
|
-
storageRootDir,
|
|
511
|
-
filename: MATRIX_IDB_SNAPSHOT_FILENAME,
|
|
512
|
-
label: "Matrix IndexedDB snapshot",
|
|
513
|
-
changes,
|
|
514
|
-
warnings,
|
|
515
|
-
notices,
|
|
516
|
-
notice: `Kept existing Matrix IndexedDB snapshot in SQLite and archived the legacy source for ${storageRootDir}`
|
|
517
|
-
});
|
|
518
|
-
continue;
|
|
519
|
-
}
|
|
520
|
-
await writeMatrixIdbSnapshotJsonToStore({
|
|
521
|
-
snapshotJson: JSON.stringify(snapshot),
|
|
522
|
-
databaseCount: snapshot.length,
|
|
523
|
-
store
|
|
524
|
-
});
|
|
525
|
-
changes.push(`Migrated Matrix IndexedDB snapshot JSON to SQLite for ${storageRootDir}`);
|
|
526
|
-
await archiveLegacyMatrixStateFile({
|
|
527
|
-
storageRootDir,
|
|
528
|
-
filename: MATRIX_IDB_SNAPSHOT_FILENAME,
|
|
529
|
-
label: "Matrix IndexedDB snapshot",
|
|
530
|
-
changes,
|
|
531
|
-
warnings
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
return {
|
|
535
|
-
changes,
|
|
536
|
-
warnings,
|
|
537
|
-
...notices.length > 0 ? { notices } : {}
|
|
538
|
-
};
|
|
539
|
-
}
|
|
540
|
-
},
|
|
541
680
|
{
|
|
542
681
|
id: "matrix-legacy-crypto-migration-json-to-plugin-state",
|
|
543
|
-
label: "Matrix legacy crypto
|
|
682
|
+
label: "Matrix legacy crypto state",
|
|
544
683
|
async detectLegacyState(params) {
|
|
545
684
|
const previews = [];
|
|
546
|
-
for (const storageRootDir of await collectLegacyMatrixStateRoots(params.stateDir, MATRIX_LEGACY_CRYPTO_MIGRATION_FILENAME)) {
|
|
685
|
+
for (const storageRootDir of await collectLegacyMatrixStateRoots(params.stateDir, MATRIX_LEGACY_CRYPTO_MIGRATION_FILENAME, { includeMatrixRoot: true })) {
|
|
547
686
|
if (!readLegacyMatrixLegacyCryptoMigrationState(storageRootDir)) continue;
|
|
548
687
|
previews.push(`Matrix legacy crypto migration JSON can migrate to SQLite: ${storageRootDir}`);
|
|
549
688
|
}
|
|
689
|
+
for (const storageRootDir of await collectLegacyMatrixStateRoots(params.stateDir, MATRIX_IDB_SNAPSHOT_FILENAME, { includeMatrixRoot: true })) previews.push(`Matrix IndexedDB snapshot JSON can migrate to SQLite: ${storageRootDir}`);
|
|
550
690
|
return previews.length > 0 ? { preview: previews } : null;
|
|
551
691
|
},
|
|
552
692
|
async migrateLegacyState(params) {
|
|
553
693
|
const changes = [];
|
|
554
694
|
const warnings = [];
|
|
555
695
|
const notices = [];
|
|
556
|
-
for (const storageRootDir of await collectLegacyMatrixStateRoots(params.stateDir, MATRIX_LEGACY_CRYPTO_MIGRATION_FILENAME)) {
|
|
696
|
+
for (const storageRootDir of await collectLegacyMatrixStateRoots(params.stateDir, MATRIX_LEGACY_CRYPTO_MIGRATION_FILENAME, { includeMatrixRoot: true })) {
|
|
557
697
|
const state = readLegacyMatrixLegacyCryptoMigrationState(storageRootDir);
|
|
558
698
|
if (!state) continue;
|
|
559
699
|
const store = params.context.openPluginStateKeyedStore(openMatrixLegacyCryptoMigrationStoreOptions(storageRootDir));
|
|
@@ -582,6 +722,13 @@ const stateMigrations = [
|
|
|
582
722
|
warnings
|
|
583
723
|
});
|
|
584
724
|
}
|
|
725
|
+
for (const storageRootDir of await collectLegacyMatrixStateRoots(params.stateDir, MATRIX_IDB_SNAPSHOT_FILENAME, { includeMatrixRoot: true })) await migrateLegacyMatrixIdbSnapshot({
|
|
726
|
+
storageRootDir,
|
|
727
|
+
context: params.context,
|
|
728
|
+
changes,
|
|
729
|
+
notices,
|
|
730
|
+
warnings
|
|
731
|
+
});
|
|
585
732
|
return {
|
|
586
733
|
changes,
|
|
587
734
|
warnings,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as editMessageMatrix, r as prepareMatrixSingleText, s as sendSingleTextMessageMatrix, y as MsgType } from "./send-
|
|
1
|
+
import { n as editMessageMatrix, r as prepareMatrixSingleText, s as sendSingleTextMessageMatrix, y as MsgType } from "./send-CZCmDQu8.js";
|
|
2
2
|
import { createDraftStreamLoop } from "openclaw/plugin-sdk/channel-outbound";
|
|
3
3
|
//#region extensions/matrix/src/matrix/draft-stream.ts
|
|
4
4
|
const DEFAULT_THROTTLE_MS = 1e3;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as resolveMatrixDefaultOrOnlyAccountId } from "./account-selection-
|
|
1
|
+
import { a as resolveMatrixDefaultOrOnlyAccountId } from "./account-selection-kqquRzCf.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,13 +1,30 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
|
-
import { t as isRecord } from "./record-shared-
|
|
2
|
+
import { t as isRecord } from "./record-shared-CWWx6fvI.js";
|
|
3
3
|
import { t as getMatrixRuntime } from "./runtime-6S3DNFNv.js";
|
|
4
|
-
import { M as resolveMatrixSqliteStateEnv, t as claimCurrentTokenStorageState } from "./storage-
|
|
5
|
-
import { t as createAsyncLock } from "./async-lock-BcLS4KOc.js";
|
|
4
|
+
import { M as resolveMatrixSqliteStateEnv, t as claimCurrentTokenStorageState } from "./storage-BrkTJZov.js";
|
|
6
5
|
import { n as LogService } from "./logger-D0GCSDQq.js";
|
|
7
|
-
import path from "node:path";
|
|
8
6
|
import { createHash, randomUUID } from "node:crypto";
|
|
7
|
+
import path from "node:path";
|
|
9
8
|
import fs from "node:fs/promises";
|
|
10
9
|
import { Category, MemoryStore, SyncAccumulator } from "matrix-js-sdk/lib/matrix.js";
|
|
10
|
+
//#region extensions/matrix/src/matrix/async-lock.ts
|
|
11
|
+
function createAsyncLock() {
|
|
12
|
+
let lock = Promise.resolve();
|
|
13
|
+
return async function withLock(fn) {
|
|
14
|
+
const previous = lock;
|
|
15
|
+
let release;
|
|
16
|
+
lock = new Promise((resolve) => {
|
|
17
|
+
release = resolve;
|
|
18
|
+
});
|
|
19
|
+
await previous;
|
|
20
|
+
try {
|
|
21
|
+
return await fn();
|
|
22
|
+
} finally {
|
|
23
|
+
release?.();
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
11
28
|
//#region extensions/matrix/src/matrix/client/file-sync-store.ts
|
|
12
29
|
var file_sync_store_exports = /* @__PURE__ */ __exportAll({
|
|
13
30
|
SqliteBackedMatrixSyncStore: () => SqliteBackedMatrixSyncStore,
|
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-kqquRzCf.js";
|
|
2
2
|
import { n as listMatrixEnvAccountIds, r as resolveMatrixEnvAccountToken, t as getMatrixScopedEnvVarNames } from "./env-vars-B0NxQnPk.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-
|
|
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 };
|