@openclaw/matrix 2026.5.27 → 2026.5.28-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.js +4 -4
- package/dist/{approval-handler.runtime-D2nZfRw6.js → approval-handler.runtime-pR4jcWts.js} +7 -37
- package/dist/{approval-ids-DzBw_AG3.js → approval-ids-BsGUOwIc.js} +1 -1
- package/dist/{approval-reaction-auth-BvK3dXMH.js → approval-reaction-auth-CstZA90i.js} +2 -2
- package/dist/{channel-BLuA_9If.js → channel-EfS9AcXo.js} +15 -15
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel.runtime-CCAsyp75.js → channel.runtime-BSL4fCB_.js} +7 -7
- package/dist/{cli-Bo50M7l4.js → cli-CYLqmzNw.js} +15 -14
- package/dist/{cli-metadata-CqUHNx_0.js → cli-metadata-TxtMWnLo.js} +1 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/{client-QO7vDxm0.js → client-D6nL0ymL.js} +2 -2
- package/dist/{client-BgsOzckO.js → client-DxQ7tWJq.js} +2 -2
- package/dist/{client-bootstrap-DK9i3KZ5.js → client-bootstrap-BtddaQGi.js} +1 -1
- package/dist/{config-schema-DuSRVdwT.js → config-schema-CRsTmqKY.js} +1 -1
- package/dist/contract-api.js +3 -3
- package/dist/{create-client-hdBEoEIm.js → create-client-D5Ie4y1a.js} +2 -2
- package/dist/{crypto-runtime-BcQzS9DV.js → crypto-runtime-CpQeK8kh.js} +4 -4
- package/dist/{deps-CAdiytPJ.js → deps-BVWGd2XS.js} +12 -2
- package/dist/{directory-live-2-Vb6nss.js → directory-live-kLKfwyDt.js} +2 -2
- package/dist/{doctor-qLh9PyE4.js → doctor-CENc9ks0.js} +1 -1
- package/dist/{draft-stream-BBVqdEbn.js → draft-stream-D7KMDYlS.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/{legacy-crypto-inspector-BRdo-WqV.js → legacy-crypto-inspector-tJOj25VL.js} +1 -1
- package/dist/{logging-BR-gcAjp.js → logging-BD9Wmviv.js} +2 -9
- package/dist/{matrix-migration.runtime-BhJb4ZII.js → matrix-migration.runtime-CZOep_JX.js} +1 -1
- package/dist/{media-text-C6q1S0AJ.js → media-text-ybU6tiB2.js} +1 -1
- package/dist/{messages-D-VxmWkC.js → messages-CHjewhaA.js} +5 -5
- package/dist/{monitor-DO1yiHWm.js → monitor-DjfcOAje.js} +25 -26
- package/dist/plugin-entry.handlers.runtime.js +1 -1
- package/dist/probe.runtime-BjFSknLp.js +3 -0
- package/dist/{profile-update-B_LpeC8E.js → profile-update-B4HzVfDS.js} +2 -2
- package/dist/{reaction-events-BefH3-Gu.js → reaction-events-gK5X5uu5.js} +1 -1
- package/dist/recovery-key-store-B3-wYrMU.js +294 -0
- package/dist/{resolve-targets-BPhBqXyj.js → resolve-targets-DaTQqtPq.js} +1 -1
- package/dist/{resolver.runtime-BOS3foyc.js → resolver.runtime-Dj10Iq3r.js} +1 -1
- package/dist/{runtime-api-B-jlPE4A.js → runtime-api-CsF7Kokd.js} +2 -2
- package/dist/runtime-api.js +1 -1
- package/dist/runtime-heavy-api.js +1 -1
- package/dist/{sdk-BKBZkPKt.js → sdk-DTo3Hzko.js} +14 -304
- package/dist/{send-DivaFHb1.js → send-DX-aOjPW.js} +1 -1
- package/dist/{setup-bootstrap-ClcP-tDQ.js → setup-bootstrap-D9XeWu6O.js} +2 -2
- package/dist/{setup-core-s8s_Qudu.js → setup-core-BU4BO6DB.js} +7 -2
- package/dist/setup-plugin-api.js +3 -3
- package/dist/{setup-surface-BOt10HNf.js → setup-surface-BIFSsw6q.js} +5 -5
- package/dist/{shared-3K27tl8e.js → shared-CZ622gSf.js} +113 -5
- package/dist/{thread-bindings-CLjJrThw.js → thread-bindings-DjC1mhh_.js} +1 -1
- package/dist/{tool-actions.runtime-Vky1krcK.js → tool-actions.runtime-D4A9O27R.js} +20 -21
- package/dist/{verification-Dar6QON4.js → verification-CUSz9cFP.js} +1 -1
- package/node_modules/linkify-it/build/index.cjs.js +99 -94
- package/node_modules/linkify-it/index.mjs +99 -94
- package/node_modules/linkify-it/package.json +11 -1
- package/node_modules/markdown-it/README.md +13 -17
- package/node_modules/markdown-it/dist/index.cjs.js +111 -31
- package/node_modules/markdown-it/dist/markdown-it.js +117 -31
- package/node_modules/markdown-it/dist/markdown-it.min.js +2 -2
- package/node_modules/markdown-it/lib/common/utils.mjs +30 -1
- package/node_modules/markdown-it/lib/index.mjs +1 -1
- package/node_modules/markdown-it/lib/rules_block/heading.mjs +2 -2
- package/node_modules/markdown-it/lib/rules_block/html_block.mjs +12 -1
- package/node_modules/markdown-it/lib/rules_block/lheading.mjs +4 -1
- package/node_modules/markdown-it/lib/rules_block/paragraph.mjs +3 -1
- package/node_modules/markdown-it/lib/rules_core/smartquotes.mjs +37 -21
- package/node_modules/markdown-it/lib/rules_inline/entity.mjs +2 -2
- package/node_modules/markdown-it/lib/rules_inline/state_inline.mjs +37 -6
- package/node_modules/markdown-it/package.json +14 -3
- package/node_modules/matrix-js-sdk/CHANGELOG.md +7 -0
- package/node_modules/matrix-js-sdk/package.json +1 -1
- package/npm-shrinkwrap.json +35 -15
- package/package.json +6 -6
- package/dist/probe.runtime-9S17Q3Mo.js +0 -3
- package/dist/startup-abort-Bs0Up_Qx.js +0 -109
- package/dist/test-api.js +0 -4
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
1
|
import { t as isRecord } from "./record-shared-CvzjvHRn.js";
|
|
3
2
|
import { n as formatMatrixErrorReason, r as isMatrixNotFoundError, t as formatMatrixErrorMessage } from "./errors-C47hvAF8.js";
|
|
4
3
|
import { t as claimCurrentTokenStorageState } from "./storage-onzulLbU.js";
|
|
4
|
+
import { c as createMatrixStartupAbortError, d as ConsoleLogger, f as LogService, p as noop, u as throwIfMatrixStartupAborted } from "./shared-CZ622gSf.js";
|
|
5
|
+
import { a as matrixEventToRaw, n as createMatrixGuardedFetch, o as parseMxc, t as MatrixAuthedHttpClient } from "./http-client-DJNugFzO.js";
|
|
5
6
|
import { n as resolveMatrixRoomKeyBackupReadinessError } from "./backup-health-Dm_YMVFT.js";
|
|
7
|
+
import { createMatrixJsSdkClientLogger } from "./logging-BD9Wmviv.js";
|
|
6
8
|
import { t as createAsyncLock } from "./async-lock-BcLS4KOc.js";
|
|
7
|
-
import { a as ConsoleLogger, i as throwIfMatrixStartupAborted, n as createMatrixStartupAbortError, o as LogService, s as noop } from "./startup-abort-Bs0Up_Qx.js";
|
|
8
|
-
import { t as createMatrixJsSdkClientLogger } from "./logging-BR-gcAjp.js";
|
|
9
|
-
import { a as matrixEventToRaw, n as createMatrixGuardedFetch, o as parseMxc, t as MatrixAuthedHttpClient } from "./http-client-DJNugFzO.js";
|
|
10
9
|
import { n as isMatrixReadySyncState, r as isMatrixTerminalSyncState } from "./sync-state-CWbp0QSY.js";
|
|
10
|
+
import { n as isRepairableSecretStorageAccessError, r as MATRIX_IDB_PERSIST_INTERVAL_MS, t as MatrixRecoveryKeyStore } from "./recovery-key-store-B3-wYrMU.js";
|
|
11
11
|
import { normalizeNullableString, normalizeStringEntries, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
12
12
|
import { readFileSync } from "node:fs";
|
|
13
13
|
import path from "node:path";
|
|
14
|
-
import {
|
|
14
|
+
import { writeJsonFileAtomically } from "openclaw/plugin-sdk/json-store";
|
|
15
15
|
import { KeyedAsyncQueue } from "openclaw/plugin-sdk/keyed-async-queue";
|
|
16
|
+
import fs$1 from "node:fs/promises";
|
|
16
17
|
import { EventEmitter } from "node:events";
|
|
17
18
|
import { Category, ClientEvent, Filter, MatrixEventEvent, MemoryStore, Preset, SyncAccumulator, createClient } from "matrix-js-sdk/lib/matrix.js";
|
|
18
19
|
import { VerificationMethod } from "matrix-js-sdk/lib/types.js";
|
|
19
|
-
import fs$1 from "node:fs/promises";
|
|
20
|
-
import { decodeRecoveryKey } from "matrix-js-sdk/lib/crypto-api/recovery-key.js";
|
|
21
20
|
//#region extensions/matrix/src/matrix/client/file-sync-store.ts
|
|
22
21
|
const STORE_VERSION = 1;
|
|
23
22
|
const PERSIST_DEBOUNCE_MS = 250;
|
|
@@ -207,302 +206,13 @@ var FileBackedMatrixSyncStore = class extends MemoryStore {
|
|
|
207
206
|
}
|
|
208
207
|
};
|
|
209
208
|
//#endregion
|
|
210
|
-
//#region extensions/matrix/src/matrix/sdk/idb-persistence-lock.ts
|
|
211
|
-
const MATRIX_IDB_PERSIST_INTERVAL_MS = 6e4;
|
|
212
|
-
const IDB_SNAPSHOT_LOCK_STALE_MS = 5 * 6e4;
|
|
213
|
-
const IDB_SNAPSHOT_LOCK_RETRY_BASE = {
|
|
214
|
-
factor: 2,
|
|
215
|
-
minTimeout: 50,
|
|
216
|
-
maxTimeout: 5e3,
|
|
217
|
-
randomize: true
|
|
218
|
-
};
|
|
219
|
-
function computeRetryDelayMs(retries, attempt) {
|
|
220
|
-
return Math.min(retries.maxTimeout, Math.max(retries.minTimeout, retries.minTimeout * retries.factor ** attempt));
|
|
221
|
-
}
|
|
222
|
-
function computeMinimumRetryWindowMs(retries) {
|
|
223
|
-
let total = 0;
|
|
224
|
-
const attempts = Math.max(1, retries.retries + 1);
|
|
225
|
-
for (let attempt = 0; attempt < attempts - 1; attempt += 1) total += computeRetryDelayMs(retries, attempt);
|
|
226
|
-
return total;
|
|
227
|
-
}
|
|
228
|
-
function resolveRetriesForMinimumWindowMs(retries, minimumWindowMs) {
|
|
229
|
-
const resolved = {
|
|
230
|
-
...retries,
|
|
231
|
-
retries: 0
|
|
232
|
-
};
|
|
233
|
-
while (computeMinimumRetryWindowMs(resolved) < minimumWindowMs) resolved.retries += 1;
|
|
234
|
-
return resolved;
|
|
235
|
-
}
|
|
236
|
-
const MATRIX_IDB_SNAPSHOT_LOCK_OPTIONS = {
|
|
237
|
-
retries: resolveRetriesForMinimumWindowMs(IDB_SNAPSHOT_LOCK_RETRY_BASE, MATRIX_IDB_PERSIST_INTERVAL_MS),
|
|
238
|
-
stale: IDB_SNAPSHOT_LOCK_STALE_MS
|
|
239
|
-
};
|
|
240
|
-
//#endregion
|
|
241
|
-
//#region extensions/matrix/src/matrix/sdk/recovery-key-store.ts
|
|
242
|
-
function isRepairableSecretStorageAccessError(err) {
|
|
243
|
-
const message = formatMatrixErrorReason(err);
|
|
244
|
-
if (!message) return false;
|
|
245
|
-
if (message.includes("getsecretstoragekey callback returned falsey")) return true;
|
|
246
|
-
if (message.includes("decrypting secret") && message.includes("bad mac")) return true;
|
|
247
|
-
return false;
|
|
248
|
-
}
|
|
249
|
-
var MatrixRecoveryKeyStore = class {
|
|
250
|
-
constructor(recoveryKeyPath) {
|
|
251
|
-
this.recoveryKeyPath = recoveryKeyPath;
|
|
252
|
-
this.secretStorageKeyCache = /* @__PURE__ */ new Map();
|
|
253
|
-
this.stagedRecoveryKey = null;
|
|
254
|
-
this.stagedRecoveryKeyUsed = false;
|
|
255
|
-
this.stagedCacheKeyIds = /* @__PURE__ */ new Set();
|
|
256
|
-
}
|
|
257
|
-
buildCryptoCallbacks() {
|
|
258
|
-
return {
|
|
259
|
-
getSecretStorageKey: async ({ keys }) => {
|
|
260
|
-
const requestedKeyIds = Object.keys(keys ?? {});
|
|
261
|
-
if (requestedKeyIds.length === 0) return null;
|
|
262
|
-
const staged = this.resolveStagedSecretStorageKey(requestedKeyIds);
|
|
263
|
-
if (staged) return staged;
|
|
264
|
-
for (const keyId of requestedKeyIds) {
|
|
265
|
-
const cached = this.secretStorageKeyCache.get(keyId);
|
|
266
|
-
if (cached) return [keyId, new Uint8Array(cached.key)];
|
|
267
|
-
}
|
|
268
|
-
const stored = this.loadStoredRecoveryKey();
|
|
269
|
-
if (!stored?.privateKeyBase64) return null;
|
|
270
|
-
const privateKey = new Uint8Array(Buffer.from(stored.privateKeyBase64, "base64"));
|
|
271
|
-
if (privateKey.length === 0) return null;
|
|
272
|
-
if (stored.keyId && requestedKeyIds.includes(stored.keyId)) {
|
|
273
|
-
this.rememberSecretStorageKey(stored.keyId, privateKey, stored.keyInfo);
|
|
274
|
-
return [stored.keyId, privateKey];
|
|
275
|
-
}
|
|
276
|
-
const firstRequestedKeyId = requestedKeyIds[0];
|
|
277
|
-
if (!firstRequestedKeyId) return null;
|
|
278
|
-
this.rememberSecretStorageKey(firstRequestedKeyId, privateKey, stored.keyInfo);
|
|
279
|
-
return [firstRequestedKeyId, privateKey];
|
|
280
|
-
},
|
|
281
|
-
cacheSecretStorageKey: (keyId, keyInfo, key) => {
|
|
282
|
-
const privateKey = new Uint8Array(key);
|
|
283
|
-
const normalizedKeyInfo = {
|
|
284
|
-
passphrase: keyInfo?.passphrase,
|
|
285
|
-
name: typeof keyInfo?.name === "string" ? keyInfo.name : void 0
|
|
286
|
-
};
|
|
287
|
-
this.rememberSecretStorageKey(keyId, privateKey, normalizedKeyInfo);
|
|
288
|
-
const stored = this.loadStoredRecoveryKey();
|
|
289
|
-
this.saveRecoveryKeyToDisk({
|
|
290
|
-
keyId,
|
|
291
|
-
keyInfo: normalizedKeyInfo,
|
|
292
|
-
privateKey,
|
|
293
|
-
encodedPrivateKey: stored?.encodedPrivateKey
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
|
-
getRecoveryKeySummary() {
|
|
299
|
-
const stored = this.loadStoredRecoveryKey();
|
|
300
|
-
if (!stored) return null;
|
|
301
|
-
return {
|
|
302
|
-
encodedPrivateKey: stored.encodedPrivateKey,
|
|
303
|
-
keyId: stored.keyId,
|
|
304
|
-
createdAt: stored.createdAt
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
resolveEncodedRecoveryKeyInput(params) {
|
|
308
|
-
const encodedPrivateKey = params.encodedPrivateKey.trim();
|
|
309
|
-
if (!encodedPrivateKey) throw new Error("Matrix recovery key is required");
|
|
310
|
-
let privateKey;
|
|
311
|
-
try {
|
|
312
|
-
privateKey = decodeRecoveryKey(encodedPrivateKey);
|
|
313
|
-
} catch (err) {
|
|
314
|
-
throw new Error(`Invalid Matrix recovery key: ${formatMatrixErrorMessage(err)}`, { cause: err });
|
|
315
|
-
}
|
|
316
|
-
const keyId = typeof params.keyId === "string" && params.keyId.trim() ? params.keyId.trim() : null;
|
|
317
|
-
return {
|
|
318
|
-
encodedPrivateKey,
|
|
319
|
-
privateKey,
|
|
320
|
-
keyId,
|
|
321
|
-
keyInfo: params.keyInfo ?? this.loadStoredRecoveryKey()?.keyInfo
|
|
322
|
-
};
|
|
323
|
-
}
|
|
324
|
-
storeEncodedRecoveryKey(params) {
|
|
325
|
-
const prepared = this.resolveEncodedRecoveryKeyInput(params);
|
|
326
|
-
this.saveRecoveryKeyToDisk({
|
|
327
|
-
keyId: prepared.keyId,
|
|
328
|
-
keyInfo: prepared.keyInfo,
|
|
329
|
-
privateKey: prepared.privateKey,
|
|
330
|
-
encodedPrivateKey: prepared.encodedPrivateKey
|
|
331
|
-
});
|
|
332
|
-
if (prepared.keyId) this.rememberSecretStorageKey(prepared.keyId, prepared.privateKey, prepared.keyInfo);
|
|
333
|
-
return this.getRecoveryKeySummary() ?? {};
|
|
334
|
-
}
|
|
335
|
-
stageEncodedRecoveryKey(params) {
|
|
336
|
-
const prepared = this.resolveEncodedRecoveryKeyInput(params);
|
|
337
|
-
this.discardStagedRecoveryKey();
|
|
338
|
-
this.stagedRecoveryKey = {
|
|
339
|
-
version: 1,
|
|
340
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
341
|
-
keyId: prepared.keyId,
|
|
342
|
-
encodedPrivateKey: prepared.encodedPrivateKey,
|
|
343
|
-
privateKeyBase64: Buffer.from(prepared.privateKey).toString("base64"),
|
|
344
|
-
keyInfo: prepared.keyInfo
|
|
345
|
-
};
|
|
346
|
-
}
|
|
347
|
-
hasStagedRecoveryKeyBeenUsed() {
|
|
348
|
-
return this.stagedRecoveryKeyUsed;
|
|
349
|
-
}
|
|
350
|
-
commitStagedRecoveryKey(params) {
|
|
351
|
-
if (!this.stagedRecoveryKey) return this.getRecoveryKeySummary();
|
|
352
|
-
const staged = this.stagedRecoveryKey;
|
|
353
|
-
const privateKey = new Uint8Array(Buffer.from(staged.privateKeyBase64, "base64"));
|
|
354
|
-
const keyId = typeof params?.keyId === "string" && params.keyId.trim() ? params.keyId.trim() : staged.keyId;
|
|
355
|
-
this.saveRecoveryKeyToDisk({
|
|
356
|
-
keyId,
|
|
357
|
-
keyInfo: params?.keyInfo ?? staged.keyInfo,
|
|
358
|
-
privateKey,
|
|
359
|
-
encodedPrivateKey: staged.encodedPrivateKey
|
|
360
|
-
});
|
|
361
|
-
this.clearStagedRecoveryKeyTracking();
|
|
362
|
-
return this.getRecoveryKeySummary();
|
|
363
|
-
}
|
|
364
|
-
discardStagedRecoveryKey() {
|
|
365
|
-
for (const keyId of this.stagedCacheKeyIds) this.secretStorageKeyCache.delete(keyId);
|
|
366
|
-
this.clearStagedRecoveryKeyTracking();
|
|
367
|
-
}
|
|
368
|
-
async bootstrapSecretStorageWithRecoveryKey(crypto, options = {}) {
|
|
369
|
-
let status = null;
|
|
370
|
-
const getSecretStorageStatus = crypto.getSecretStorageStatus;
|
|
371
|
-
if (typeof getSecretStorageStatus === "function") try {
|
|
372
|
-
status = await getSecretStorageStatus.call(crypto);
|
|
373
|
-
} catch (err) {
|
|
374
|
-
LogService.warn("MatrixClientLite", "Failed to read secret storage status:", err);
|
|
375
|
-
}
|
|
376
|
-
const hasDefaultSecretStorageKey = Boolean(status?.defaultKeyId);
|
|
377
|
-
const hasKnownInvalidSecrets = Object.values(status?.secretStorageKeyValidityMap ?? {}).some((valid) => !valid);
|
|
378
|
-
let generatedRecoveryKey = false;
|
|
379
|
-
const storedRecovery = this.loadStoredRecoveryKey();
|
|
380
|
-
const stagedRecovery = this.stagedRecoveryKey;
|
|
381
|
-
const sourceRecovery = options.forceNewRecoveryKey === true ? null : stagedRecovery ?? storedRecovery;
|
|
382
|
-
let recoveryKey = sourceRecovery ? {
|
|
383
|
-
keyInfo: sourceRecovery.keyInfo,
|
|
384
|
-
privateKey: new Uint8Array(Buffer.from(sourceRecovery.privateKeyBase64, "base64")),
|
|
385
|
-
encodedPrivateKey: sourceRecovery.encodedPrivateKey
|
|
386
|
-
} : null;
|
|
387
|
-
if (recoveryKey && status?.defaultKeyId) {
|
|
388
|
-
const defaultKeyId = status.defaultKeyId;
|
|
389
|
-
if (!stagedRecovery) {
|
|
390
|
-
this.rememberSecretStorageKey(defaultKeyId, recoveryKey.privateKey, recoveryKey.keyInfo);
|
|
391
|
-
if (storedRecovery && storedRecovery.keyId !== defaultKeyId) this.saveRecoveryKeyToDisk({
|
|
392
|
-
keyId: defaultKeyId,
|
|
393
|
-
keyInfo: recoveryKey.keyInfo,
|
|
394
|
-
privateKey: recoveryKey.privateKey,
|
|
395
|
-
encodedPrivateKey: recoveryKey.encodedPrivateKey
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
const ensureRecoveryKey = async () => {
|
|
400
|
-
if (recoveryKey) {
|
|
401
|
-
if (stagedRecovery) this.stagedRecoveryKeyUsed = true;
|
|
402
|
-
return recoveryKey;
|
|
403
|
-
}
|
|
404
|
-
if (typeof crypto.createRecoveryKeyFromPassphrase !== "function") throw new Error("Matrix crypto backend does not support recovery key generation (createRecoveryKeyFromPassphrase missing)");
|
|
405
|
-
recoveryKey = await crypto.createRecoveryKeyFromPassphrase();
|
|
406
|
-
this.saveRecoveryKeyToDisk(recoveryKey);
|
|
407
|
-
generatedRecoveryKey = true;
|
|
408
|
-
return recoveryKey;
|
|
409
|
-
};
|
|
410
|
-
const shouldRecreateSecretStorage = options.forceNewSecretStorage === true || !hasDefaultSecretStorageKey || !recoveryKey && status?.ready === false || hasKnownInvalidSecrets;
|
|
411
|
-
if (hasKnownInvalidSecrets) recoveryKey = null;
|
|
412
|
-
const secretStorageOptions = { setupNewKeyBackup: options.setupNewKeyBackup === true };
|
|
413
|
-
if (shouldRecreateSecretStorage) {
|
|
414
|
-
secretStorageOptions.setupNewSecretStorage = true;
|
|
415
|
-
secretStorageOptions.createSecretStorageKey = ensureRecoveryKey;
|
|
416
|
-
}
|
|
417
|
-
try {
|
|
418
|
-
await crypto.bootstrapSecretStorage(secretStorageOptions);
|
|
419
|
-
} catch (err) {
|
|
420
|
-
if (!(options.allowSecretStorageRecreateWithoutRecoveryKey === true && hasDefaultSecretStorageKey && isRepairableSecretStorageAccessError(err))) throw err;
|
|
421
|
-
recoveryKey = null;
|
|
422
|
-
LogService.warn("MatrixClientLite", "Secret storage exists on the server but local recovery material cannot unlock it; recreating secret storage during explicit bootstrap.");
|
|
423
|
-
await crypto.bootstrapSecretStorage({
|
|
424
|
-
setupNewSecretStorage: true,
|
|
425
|
-
setupNewKeyBackup: options.setupNewKeyBackup === true,
|
|
426
|
-
createSecretStorageKey: ensureRecoveryKey
|
|
427
|
-
});
|
|
428
|
-
}
|
|
429
|
-
if (generatedRecoveryKey && this.recoveryKeyPath) LogService.warn("MatrixClientLite", `Generated Matrix recovery key and saved it to ${this.recoveryKeyPath}. Keep this file secure.`);
|
|
430
|
-
}
|
|
431
|
-
clearStagedRecoveryKeyTracking() {
|
|
432
|
-
this.stagedRecoveryKey = null;
|
|
433
|
-
this.stagedRecoveryKeyUsed = false;
|
|
434
|
-
this.stagedCacheKeyIds.clear();
|
|
435
|
-
}
|
|
436
|
-
resolveStagedSecretStorageKey(requestedKeyIds) {
|
|
437
|
-
const staged = this.stagedRecoveryKey;
|
|
438
|
-
if (!staged?.privateKeyBase64) return null;
|
|
439
|
-
const privateKey = new Uint8Array(Buffer.from(staged.privateKeyBase64, "base64"));
|
|
440
|
-
if (privateKey.length === 0) return null;
|
|
441
|
-
const keyId = staged.keyId && requestedKeyIds.includes(staged.keyId) ? staged.keyId : requestedKeyIds[0];
|
|
442
|
-
if (!keyId) return null;
|
|
443
|
-
this.rememberStagedSecretStorageKey(keyId, privateKey, staged.keyInfo);
|
|
444
|
-
this.stagedCacheKeyIds.add(keyId);
|
|
445
|
-
return [keyId, privateKey];
|
|
446
|
-
}
|
|
447
|
-
rememberStagedSecretStorageKey(keyId, key, keyInfo) {
|
|
448
|
-
this.stagedRecoveryKeyUsed = true;
|
|
449
|
-
this.rememberSecretStorageKey(keyId, key, keyInfo);
|
|
450
|
-
}
|
|
451
|
-
rememberSecretStorageKey(keyId, key, keyInfo) {
|
|
452
|
-
if (!keyId.trim()) return;
|
|
453
|
-
this.secretStorageKeyCache.set(keyId, {
|
|
454
|
-
key: new Uint8Array(key),
|
|
455
|
-
keyInfo
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
loadStoredRecoveryKey() {
|
|
459
|
-
if (!this.recoveryKeyPath) return null;
|
|
460
|
-
try {
|
|
461
|
-
const parsed = loadJsonFile(this.recoveryKeyPath);
|
|
462
|
-
if (parsed?.version !== 1 || typeof parsed.createdAt !== "string" || typeof parsed.privateKeyBase64 !== "string" || !parsed.privateKeyBase64.trim()) return null;
|
|
463
|
-
return {
|
|
464
|
-
version: 1,
|
|
465
|
-
createdAt: parsed.createdAt,
|
|
466
|
-
keyId: typeof parsed.keyId === "string" ? parsed.keyId : null,
|
|
467
|
-
encodedPrivateKey: typeof parsed.encodedPrivateKey === "string" ? parsed.encodedPrivateKey : void 0,
|
|
468
|
-
privateKeyBase64: parsed.privateKeyBase64,
|
|
469
|
-
keyInfo: parsed.keyInfo && typeof parsed.keyInfo === "object" ? {
|
|
470
|
-
passphrase: parsed.keyInfo.passphrase,
|
|
471
|
-
name: typeof parsed.keyInfo.name === "string" ? parsed.keyInfo.name : void 0
|
|
472
|
-
} : void 0
|
|
473
|
-
};
|
|
474
|
-
} catch {
|
|
475
|
-
return null;
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
saveRecoveryKeyToDisk(params) {
|
|
479
|
-
if (!this.recoveryKeyPath) return;
|
|
480
|
-
try {
|
|
481
|
-
const payload = {
|
|
482
|
-
version: 1,
|
|
483
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
484
|
-
keyId: typeof params.keyId === "string" ? params.keyId : null,
|
|
485
|
-
encodedPrivateKey: params.encodedPrivateKey,
|
|
486
|
-
privateKeyBase64: Buffer.from(params.privateKey).toString("base64"),
|
|
487
|
-
keyInfo: params.keyInfo ? {
|
|
488
|
-
passphrase: params.keyInfo.passphrase,
|
|
489
|
-
name: params.keyInfo.name
|
|
490
|
-
} : void 0
|
|
491
|
-
};
|
|
492
|
-
saveJsonFile(this.recoveryKeyPath, payload);
|
|
493
|
-
} catch (err) {
|
|
494
|
-
LogService.warn("MatrixClientLite", "Failed to persist recovery key:", err);
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
};
|
|
498
|
-
//#endregion
|
|
499
209
|
//#region extensions/matrix/src/matrix/sdk.ts
|
|
500
|
-
var sdk_exports = /* @__PURE__ */ __exportAll({
|
|
501
|
-
ConsoleLogger: () => ConsoleLogger,
|
|
502
|
-
LogService: () => LogService,
|
|
503
|
-
MatrixClient: () => MatrixClient
|
|
504
|
-
});
|
|
505
210
|
const MATRIX_STATUS_DIAGNOSTIC_TIMEOUT_MS = 1e4;
|
|
211
|
+
const DEFAULT_MATRIX_LOCAL_TIMEOUT_MS = 6e4;
|
|
212
|
+
function resolveMatrixLocalTimeoutMs(raw) {
|
|
213
|
+
if (typeof raw !== "number" || !Number.isFinite(raw)) return DEFAULT_MATRIX_LOCAL_TIMEOUT_MS;
|
|
214
|
+
return Math.max(1, Math.floor(raw));
|
|
215
|
+
}
|
|
506
216
|
function unresolvedMatrixRoomKeyBackupStatus() {
|
|
507
217
|
return {
|
|
508
218
|
serverVersion: null,
|
|
@@ -578,7 +288,7 @@ function createMatrixExplicitBootstrapOptions(params) {
|
|
|
578
288
|
let loadedMatrixCryptoRuntime = null;
|
|
579
289
|
let matrixCryptoRuntimePromise = null;
|
|
580
290
|
async function loadMatrixCryptoRuntime() {
|
|
581
|
-
matrixCryptoRuntimePromise ??= import("./crypto-runtime-
|
|
291
|
+
matrixCryptoRuntimePromise ??= import("./crypto-runtime-CpQeK8kh.js").then((runtime) => {
|
|
582
292
|
loadedMatrixCryptoRuntime = runtime;
|
|
583
293
|
return runtime;
|
|
584
294
|
});
|
|
@@ -616,7 +326,7 @@ var MatrixClient = class {
|
|
|
616
326
|
ssrfPolicy: opts.ssrfPolicy,
|
|
617
327
|
dispatcherPolicy: opts.dispatcherPolicy
|
|
618
328
|
});
|
|
619
|
-
this.localTimeoutMs =
|
|
329
|
+
this.localTimeoutMs = resolveMatrixLocalTimeoutMs(opts.localTimeoutMs);
|
|
620
330
|
this.initialSyncLimit = opts.initialSyncLimit;
|
|
621
331
|
this.syncFilter = opts.syncFilter;
|
|
622
332
|
this.encryptionEnabled = opts.encryption === true;
|
|
@@ -1701,4 +1411,4 @@ var MatrixClient = class {
|
|
|
1701
1411
|
}
|
|
1702
1412
|
};
|
|
1703
1413
|
//#endregion
|
|
1704
|
-
export {
|
|
1414
|
+
export { ConsoleLogger, LogService, MatrixClient };
|
|
@@ -229,7 +229,7 @@ function buildPollResponseContent(pollEventId, answerIds) {
|
|
|
229
229
|
//#region extensions/matrix/src/matrix/send/client.ts
|
|
230
230
|
let matrixSendClientRuntimePromise = null;
|
|
231
231
|
async function loadMatrixSendClientRuntime() {
|
|
232
|
-
matrixSendClientRuntimePromise ??= import("./client-bootstrap-
|
|
232
|
+
matrixSendClientRuntimePromise ??= import("./client-bootstrap-BtddaQGi.js").then((n) => n.t);
|
|
233
233
|
return await matrixSendClientRuntimePromise;
|
|
234
234
|
}
|
|
235
235
|
function resolveMediaMaxBytes(accountId, cfg) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as hasExplicitMatrixAccountConfig, c as resolveMatrixAccountConfig } from "./config-paths-ZBCMwSos.js";
|
|
2
|
-
import "./setup-core-
|
|
2
|
+
import "./setup-core-BU4BO6DB.js";
|
|
3
3
|
import { t as formatMatrixErrorMessage } from "./errors-C47hvAF8.js";
|
|
4
|
-
import { n as bootstrapMatrixVerification } from "./verification-
|
|
4
|
+
import { n as bootstrapMatrixVerification } from "./verification-CUSz9cFP.js";
|
|
5
5
|
//#region extensions/matrix/src/setup-bootstrap.ts
|
|
6
6
|
async function maybeBootstrapNewEncryptedMatrixAccount(params) {
|
|
7
7
|
const accountConfig = resolveMatrixAccountConfig({
|
|
@@ -8,6 +8,7 @@ import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "opencl
|
|
|
8
8
|
import { hasConfiguredSecretInput } from "openclaw/plugin-sdk/secret-input-runtime";
|
|
9
9
|
import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1, normalizeAccountId as normalizeAccountId$1 } from "openclaw/plugin-sdk/routing";
|
|
10
10
|
import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$2, addWildcardAllowFrom, applyAccountNameToChannelSection, normalizeAccountId as normalizeAccountId$2, normalizeAllowFromEntries, normalizeSecretInputString, prepareScopedSetupConfig } from "openclaw/plugin-sdk/setup";
|
|
11
|
+
import { resolveOptionalIntegerOption } from "openclaw/plugin-sdk/number-runtime";
|
|
11
12
|
import { coerceSecretRef as coerceSecretRef$1 } from "openclaw/plugin-sdk/secret-ref-runtime";
|
|
12
13
|
//#region extensions/matrix/src/matrix/accounts.ts
|
|
13
14
|
function clean(value) {
|
|
@@ -272,7 +273,11 @@ function updateMatrixAccountConfig(cfg, accountId, patch) {
|
|
|
272
273
|
else delete nextAccount.network;
|
|
273
274
|
}
|
|
274
275
|
if (patch.initialSyncLimit !== void 0) if (patch.initialSyncLimit === null) delete nextAccount.initialSyncLimit;
|
|
275
|
-
else
|
|
276
|
+
else {
|
|
277
|
+
const initialSyncLimit = resolveOptionalIntegerOption(patch.initialSyncLimit, { min: 0 });
|
|
278
|
+
if (initialSyncLimit === void 0) delete nextAccount.initialSyncLimit;
|
|
279
|
+
else nextAccount.initialSyncLimit = initialSyncLimit;
|
|
280
|
+
}
|
|
276
281
|
if (patch.encryption !== void 0) if (patch.encryption === null) delete nextAccount.encryption;
|
|
277
282
|
else nextAccount.encryption = patch.encryption;
|
|
278
283
|
if (patch.allowBots !== void 0) if (patch.allowBots === null) delete nextAccount.allowBots;
|
|
@@ -664,7 +669,7 @@ const matrixSetupAdapter = {
|
|
|
664
669
|
input
|
|
665
670
|
}),
|
|
666
671
|
afterAccountConfigWritten: async ({ previousCfg, cfg, accountId, runtime }) => {
|
|
667
|
-
const { runMatrixSetupBootstrapAfterConfigWrite } = await import("./setup-bootstrap-
|
|
672
|
+
const { runMatrixSetupBootstrapAfterConfigWrite } = await import("./setup-bootstrap-D9XeWu6O.js");
|
|
668
673
|
await runMatrixSetupBootstrapAfterConfigWrite({
|
|
669
674
|
previousCfg,
|
|
670
675
|
cfg,
|
package/dist/setup-plugin-api.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as resolveMatrixAccount, n as matrixSetupAdapter, t as createMatrixSetupWizardProxy } from "./setup-core-
|
|
2
|
-
import { r as matrixConfigAdapter, t as MatrixChannelConfigSchema } from "./config-schema-
|
|
1
|
+
import { g as resolveMatrixAccount, n as matrixSetupAdapter, t as createMatrixSetupWizardProxy } from "./setup-core-BU4BO6DB.js";
|
|
2
|
+
import { r as matrixConfigAdapter, t as MatrixChannelConfigSchema } from "./config-schema-CRsTmqKY.js";
|
|
3
3
|
import { describeAccountSnapshot } from "openclaw/plugin-sdk/account-helpers";
|
|
4
4
|
const matrixSetupPlugin = {
|
|
5
5
|
id: "matrix",
|
|
@@ -13,7 +13,7 @@ const matrixSetupPlugin = {
|
|
|
13
13
|
order: 70,
|
|
14
14
|
quickstartAllowFrom: true
|
|
15
15
|
},
|
|
16
|
-
setupWizard: createMatrixSetupWizardProxy(async () => ({ matrixSetupWizard: (await import("./setup-surface-
|
|
16
|
+
setupWizard: createMatrixSetupWizardProxy(async () => ({ matrixSetupWizard: (await import("./setup-surface-BIFSsw6q.js").then((n) => n.t)).matrixSetupWizard })),
|
|
17
17
|
setup: matrixSetupAdapter,
|
|
18
18
|
capabilities: {
|
|
19
19
|
chatTypes: [
|
|
@@ -2,9 +2,9 @@ import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
|
2
2
|
import { n as requiresExplicitMatrixDefaultAccount } from "./account-selection-C3arLOhC.js";
|
|
3
3
|
import { c as resolveMatrixAccountConfig, t as resolveMatrixConfigFieldPath } from "./config-paths-ZBCMwSos.js";
|
|
4
4
|
import { r as resolveMatrixEnvAuthReadiness } from "./env-auth-DIzOApj0.js";
|
|
5
|
-
import { g as resolveMatrixAccount, h as resolveDefaultMatrixAccountId, i as moveSingleMatrixAccountConfigToNamedAccount, l as updateMatrixAccountConfig, p as listMatrixAccountIds, r as resolveMatrixSetupDmAllowFrom } from "./setup-core-
|
|
5
|
+
import { g as resolveMatrixAccount, h as resolveDefaultMatrixAccountId, i as moveSingleMatrixAccountConfigToNamedAccount, l as updateMatrixAccountConfig, p as listMatrixAccountIds, r as resolveMatrixSetupDmAllowFrom } from "./setup-core-BU4BO6DB.js";
|
|
6
6
|
import { n as validateMatrixHomeserverUrl, r as isPrivateOrLoopbackHost, t as resolveValidatedMatrixHomeserverUrl } from "./url-validation-GRHde6lq.js";
|
|
7
|
-
import { n as ensureMatrixSdkInstalled, r as isMatrixSdkAvailable } from "./deps-
|
|
7
|
+
import { n as ensureMatrixSdkInstalled, r as isMatrixSdkAvailable } from "./deps-BVWGd2XS.js";
|
|
8
8
|
import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
|
|
9
9
|
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeStringifiedOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
10
10
|
import { formatDocsLink, hasConfiguredSecretInput, mergeAllowFromEntries, normalizeAccountId as normalizeAccountId$1, promptAccountId, promptChannelAccessConfig, splitSetupEntries } from "openclaw/plugin-sdk/setup";
|
|
@@ -104,7 +104,7 @@ async function promptMatrixAllowFrom(params) {
|
|
|
104
104
|
pending.push(part);
|
|
105
105
|
}
|
|
106
106
|
if (pending.length > 0) {
|
|
107
|
-
const { resolveMatrixTargets } = await import("./resolve-targets-
|
|
107
|
+
const { resolveMatrixTargets } = await import("./resolve-targets-DaTQqtPq.js").then((n) => n.n);
|
|
108
108
|
const results = await resolveMatrixTargets({
|
|
109
109
|
cfg,
|
|
110
110
|
accountId,
|
|
@@ -232,7 +232,7 @@ async function configureMatrixAccessPrompts(params) {
|
|
|
232
232
|
resolvedIds.push(cleaned);
|
|
233
233
|
continue;
|
|
234
234
|
}
|
|
235
|
-
const { listMatrixDirectoryGroupsLive } = await import("./directory-live-
|
|
235
|
+
const { listMatrixDirectoryGroupsLive } = await import("./directory-live-kLKfwyDt.js").then((n) => n.t);
|
|
236
236
|
const matches = await listMatrixDirectoryGroupsLive({
|
|
237
237
|
cfg: next,
|
|
238
238
|
accountId: params.accountId,
|
|
@@ -507,7 +507,7 @@ const matrixOnboardingAdapter = {
|
|
|
507
507
|
});
|
|
508
508
|
},
|
|
509
509
|
afterConfigWritten: async ({ previousCfg, cfg, accountId, runtime }) => {
|
|
510
|
-
const { runMatrixSetupBootstrapAfterConfigWrite } = await import("./setup-bootstrap-
|
|
510
|
+
const { runMatrixSetupBootstrapAfterConfigWrite } = await import("./setup-bootstrap-D9XeWu6O.js");
|
|
511
511
|
await runMatrixSetupBootstrapAfterConfigWrite({
|
|
512
512
|
previousCfg,
|
|
513
513
|
cfg,
|
|
@@ -3,15 +3,18 @@ import { a as resolveMatrixDefaultOrOnlyAccountId, n as requiresExplicitMatrixDe
|
|
|
3
3
|
import { t as getMatrixScopedEnvVarNames } from "./env-vars-KzaYveuy.js";
|
|
4
4
|
import { i as findMatrixAccountConfig, l as resolveMatrixBaseConfig, o as listNormalizedMatrixAccountIds, t as resolveMatrixConfigFieldPath } from "./config-paths-ZBCMwSos.js";
|
|
5
5
|
import { i as resolveScopedMatrixEnvConfig, n as resolveGlobalMatrixEnvConfig } from "./env-auth-DIzOApj0.js";
|
|
6
|
+
import { t as getMatrixRuntime } from "./runtime-6S3DNFNv.js";
|
|
6
7
|
import { t as resolveValidatedMatrixHomeserverUrl } from "./url-validation-GRHde6lq.js";
|
|
7
8
|
import { r as repairCurrentTokenStorageMetaDeviceId } from "./storage-onzulLbU.js";
|
|
8
|
-
import { o as LogService, t as awaitMatrixStartupWithAbort } from "./startup-abort-Bs0Up_Qx.js";
|
|
9
9
|
import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1, normalizeAccountId as normalizeAccountId$1, normalizeOptionalAccountId, normalizeOptionalAccountId as normalizeOptionalAccountId$1 } from "openclaw/plugin-sdk/account-id";
|
|
10
10
|
import { coerceSecretRef, normalizeResolvedSecretInputString } from "openclaw/plugin-sdk/secret-input-runtime";
|
|
11
11
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
12
12
|
import { isPrivateNetworkOptInEnabled, ssrfPolicyFromDangerouslyAllowPrivateNetwork as ssrfPolicyFromDangerouslyAllowPrivateNetwork$1 } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
13
|
+
import { resolveOptionalIntegerOption } from "openclaw/plugin-sdk/number-runtime";
|
|
13
14
|
import { requireRuntimeConfig } from "openclaw/plugin-sdk/plugin-config-runtime";
|
|
14
15
|
import { retryAsync } from "openclaw/plugin-sdk/retry-runtime";
|
|
16
|
+
import { format } from "node:util";
|
|
17
|
+
import { redactSensitiveText } from "openclaw/plugin-sdk/logging-core";
|
|
15
18
|
//#region extensions/matrix/src/matrix/client/config.ts
|
|
16
19
|
let matrixAuthClientDepsPromise;
|
|
17
20
|
let matrixCredentialsReadDepsPromise;
|
|
@@ -19,7 +22,7 @@ let matrixCredentialsWriteRuntimePromise;
|
|
|
19
22
|
let matrixSecretInputDepsPromise;
|
|
20
23
|
const MATRIX_AUTH_REQUEST_RETRY_RE = /\b(fetch failed|econnreset|econnrefused|enotfound|etimedout|ehostunreach|enetunreach|eai_again|und_err_|socket hang up|network|headers timeout|body timeout|connect timeout)\b/i;
|
|
21
24
|
async function loadMatrixAuthClientDeps() {
|
|
22
|
-
matrixAuthClientDepsPromise ??= Promise.all([import("./sdk-
|
|
25
|
+
matrixAuthClientDepsPromise ??= Promise.all([import("./sdk-DTo3Hzko.js"), import("./logging-BD9Wmviv.js")]).then(([sdkModule, loggingModule]) => ({
|
|
23
26
|
MatrixClient: sdkModule.MatrixClient,
|
|
24
27
|
ensureMatrixSdkLoggingConfigured: loggingModule.ensureMatrixSdkLoggingConfigured
|
|
25
28
|
}));
|
|
@@ -176,7 +179,7 @@ function readMatrixAccountConfigField(cfg, accountId, account, field, opts) {
|
|
|
176
179
|
});
|
|
177
180
|
}
|
|
178
181
|
function clampMatrixInitialSyncLimit(value) {
|
|
179
|
-
return
|
|
182
|
+
return resolveOptionalIntegerOption(value, { min: 0 });
|
|
180
183
|
}
|
|
181
184
|
function buildMatrixNetworkFields(params) {
|
|
182
185
|
const dispatcherPolicy = params.dispatcherPolicy ?? (params.proxy ? {
|
|
@@ -449,6 +452,111 @@ async function backfillMatrixAuthDeviceIdAfterStartup(params) {
|
|
|
449
452
|
}, env, params.auth.accountId) === "saved" ? deviceId : void 0;
|
|
450
453
|
}
|
|
451
454
|
//#endregion
|
|
455
|
+
//#region extensions/matrix/src/matrix/sdk/logger.ts
|
|
456
|
+
function noop() {}
|
|
457
|
+
let forceConsoleLogging = false;
|
|
458
|
+
function setMatrixConsoleLogging(enabled) {
|
|
459
|
+
forceConsoleLogging = enabled;
|
|
460
|
+
}
|
|
461
|
+
function resolveRuntimeLogger(module) {
|
|
462
|
+
if (forceConsoleLogging) return null;
|
|
463
|
+
try {
|
|
464
|
+
return getMatrixRuntime().logging.getChildLogger({ module: `matrix:${module}` });
|
|
465
|
+
} catch {
|
|
466
|
+
return null;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
function formatMessage(module, messageOrObject) {
|
|
470
|
+
if (messageOrObject.length === 0) return `[${module}]`;
|
|
471
|
+
return redactSensitiveText(`[${module}] ${format(...messageOrObject)}`);
|
|
472
|
+
}
|
|
473
|
+
var ConsoleLogger = class {
|
|
474
|
+
emit(level, module, ...messageOrObject) {
|
|
475
|
+
const runtimeLogger = resolveRuntimeLogger(module);
|
|
476
|
+
const message = formatMessage(module, messageOrObject);
|
|
477
|
+
if (runtimeLogger) {
|
|
478
|
+
if (level === "debug") {
|
|
479
|
+
runtimeLogger.debug?.(message);
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
runtimeLogger[level](message);
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
if (level === "debug") {
|
|
486
|
+
console.debug(message);
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
console[level](message);
|
|
490
|
+
}
|
|
491
|
+
trace(module, ...messageOrObject) {
|
|
492
|
+
this.emit("debug", module, ...messageOrObject);
|
|
493
|
+
}
|
|
494
|
+
debug(module, ...messageOrObject) {
|
|
495
|
+
this.emit("debug", module, ...messageOrObject);
|
|
496
|
+
}
|
|
497
|
+
info(module, ...messageOrObject) {
|
|
498
|
+
this.emit("info", module, ...messageOrObject);
|
|
499
|
+
}
|
|
500
|
+
warn(module, ...messageOrObject) {
|
|
501
|
+
this.emit("warn", module, ...messageOrObject);
|
|
502
|
+
}
|
|
503
|
+
error(module, ...messageOrObject) {
|
|
504
|
+
this.emit("error", module, ...messageOrObject);
|
|
505
|
+
}
|
|
506
|
+
};
|
|
507
|
+
let activeLogger = new ConsoleLogger();
|
|
508
|
+
const LogService = {
|
|
509
|
+
setLogger(logger) {
|
|
510
|
+
activeLogger = logger;
|
|
511
|
+
},
|
|
512
|
+
trace(module, ...messageOrObject) {
|
|
513
|
+
activeLogger.trace(module, ...messageOrObject);
|
|
514
|
+
},
|
|
515
|
+
debug(module, ...messageOrObject) {
|
|
516
|
+
activeLogger.debug(module, ...messageOrObject);
|
|
517
|
+
},
|
|
518
|
+
info(module, ...messageOrObject) {
|
|
519
|
+
activeLogger.info(module, ...messageOrObject);
|
|
520
|
+
},
|
|
521
|
+
warn(module, ...messageOrObject) {
|
|
522
|
+
activeLogger.warn(module, ...messageOrObject);
|
|
523
|
+
},
|
|
524
|
+
error(module, ...messageOrObject) {
|
|
525
|
+
activeLogger.error(module, ...messageOrObject);
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
//#endregion
|
|
529
|
+
//#region extensions/matrix/src/matrix/startup-abort.ts
|
|
530
|
+
function createMatrixStartupAbortError() {
|
|
531
|
+
const error = /* @__PURE__ */ new Error("Matrix startup aborted");
|
|
532
|
+
error.name = "AbortError";
|
|
533
|
+
return error;
|
|
534
|
+
}
|
|
535
|
+
function throwIfMatrixStartupAborted(abortSignal) {
|
|
536
|
+
if (abortSignal?.aborted === true) throw createMatrixStartupAbortError();
|
|
537
|
+
}
|
|
538
|
+
function isMatrixStartupAbortError(error) {
|
|
539
|
+
return error instanceof Error && error.name === "AbortError";
|
|
540
|
+
}
|
|
541
|
+
async function awaitMatrixStartupWithAbort(promise, abortSignal) {
|
|
542
|
+
if (!abortSignal) return await promise;
|
|
543
|
+
if (abortSignal.aborted) throw createMatrixStartupAbortError();
|
|
544
|
+
return await new Promise((resolve, reject) => {
|
|
545
|
+
const onAbort = () => {
|
|
546
|
+
abortSignal.removeEventListener("abort", onAbort);
|
|
547
|
+
reject(createMatrixStartupAbortError());
|
|
548
|
+
};
|
|
549
|
+
abortSignal.addEventListener("abort", onAbort, { once: true });
|
|
550
|
+
promise.then((value) => {
|
|
551
|
+
abortSignal.removeEventListener("abort", onAbort);
|
|
552
|
+
resolve(value);
|
|
553
|
+
}, (error) => {
|
|
554
|
+
abortSignal.removeEventListener("abort", onAbort);
|
|
555
|
+
reject(error);
|
|
556
|
+
});
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
//#endregion
|
|
452
560
|
//#region extensions/matrix/src/matrix/client/shared.ts
|
|
453
561
|
var shared_exports = /* @__PURE__ */ __exportAll({
|
|
454
562
|
acquireSharedMatrixClient: () => acquireSharedMatrixClient,
|
|
@@ -461,7 +569,7 @@ var shared_exports = /* @__PURE__ */ __exportAll({
|
|
|
461
569
|
});
|
|
462
570
|
let matrixCreateClientDepsPromise;
|
|
463
571
|
async function loadMatrixCreateClientDeps() {
|
|
464
|
-
matrixCreateClientDepsPromise ??= import("./create-client-
|
|
572
|
+
matrixCreateClientDepsPromise ??= import("./create-client-D5Ie4y1a.js").then((n) => n.n).then((runtime) => ({ createMatrixClient: runtime.createMatrixClient }));
|
|
465
573
|
return await matrixCreateClientDepsPromise;
|
|
466
574
|
}
|
|
467
575
|
const sharedClientStates = /* @__PURE__ */ new Map();
|
|
@@ -638,4 +746,4 @@ async function releaseSharedClientInstance(client, mode = "stop") {
|
|
|
638
746
|
return true;
|
|
639
747
|
}
|
|
640
748
|
//#endregion
|
|
641
|
-
export { shared_exports as a,
|
|
749
|
+
export { resolveMatrixAuthContext as _, shared_exports as a, createMatrixStartupAbortError as c, ConsoleLogger as d, LogService as f, resolveMatrixAuth as g, backfillMatrixAuthDeviceIdAfterStartup as h, resolveSharedMatrixClient as i, isMatrixStartupAbortError as l, setMatrixConsoleLogging as m, releaseSharedClientInstance as n, stopSharedClientForAccount as o, noop as p, removeSharedClientInstance as r, stopSharedClientInstance as s, acquireSharedMatrixClient as t, throwIfMatrixStartupAborted as u, resolveMatrixConfigForAccount as v };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as listBindingsForAccount, c as resolveBindingKey, f as setMatrixThreadBindingManagerEntry, h as toSessionBindingRecord, l as resolveEffectiveBindingExpiry, m as toMatrixBindingTargetKind, o as removeBindingRecord, r as getMatrixThreadBindingManagerEntry, t as deleteMatrixThreadBindingManagerEntry, u as setBindingRecord } from "./thread-bindings-shared-CKnY4LSd.js";
|
|
2
2
|
import { i as resolveMatrixStateFilePath, t as claimCurrentTokenStorageState } from "./storage-onzulLbU.js";
|
|
3
|
-
import { a as sendMessageMatrix } from "./send-
|
|
3
|
+
import { a as sendMessageMatrix } from "./send-DX-aOjPW.js";
|
|
4
4
|
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
5
5
|
import { registerSessionBindingAdapter, resolveThreadBindingFarewellText, unregisterSessionBindingAdapter } from "openclaw/plugin-sdk/thread-bindings-session-runtime";
|
|
6
6
|
import path from "node:path";
|