@openclaw/matrix 2026.7.2-beta.7 → 2026.8.1-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/{account-selection-kqquRzCf.js → account-selection-CWuhuFn1.js} +7 -8
- package/dist/{accounts-DfngqebB.js → accounts-BCzyubQt.js} +3 -3
- package/dist/api.js +7 -10
- package/dist/{approval-handler.runtime-DSeaIsGa.js → approval-handler.runtime-CJXCUdRg.js} +5 -5
- package/dist/{approval-ids-BdJGPAJT.js → approval-ids-7rf7etWE.js} +1 -1
- package/dist/{approval-reaction-auth-BjOpELxu.js → approval-reaction-auth-wBwbEDpZ.js} +2 -2
- package/dist/{approval-reactions-D-BxBK_L.js → approval-reactions-tXh9KYrW.js} +2 -8
- package/dist/auth-presence.js +2 -2
- package/dist/{channel-vj788dNZ.js → channel-VSrHgTON.js} +156 -136
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel.runtime-CLoF2S9T.js → channel.runtime-pOOL0uT_.js} +70 -56
- package/dist/{config-schema-Djxw3C6b.js → channel.setup-PpxRP9Du.js} +50 -3
- package/dist/{cli-DMqfDE-q.js → cli-CkTfKC_c.js} +16 -16
- package/dist/{cli-metadata-C7D53SND.js → cli-metadata-B1d1aGM5.js} +1 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/client-CeGw0G5S.js +784 -0
- package/dist/{client-bootstrap-XsIkHNt0.js → client-bootstrap-BFwT_2VT.js} +25 -61
- package/dist/{client-6eRENr7k.js → client-sJesKQmp.js} +4 -4
- package/dist/client-support-DLj4vDeu.js +93 -0
- package/dist/config-update-Bor_Pjsv.js +150 -0
- package/dist/contract-api.js +2 -2
- package/dist/{credentials-W2EmwRhu.js → credentials-BdAaWuiR.js} +2 -1
- package/dist/credentials-read-B37cQknZ.js +51 -0
- package/dist/credentials-state-B3cuUFwZ.js +27 -0
- package/dist/{credentials-write.runtime-Be9zNSUw.js → credentials-write.runtime-nAV2-5uR.js} +1 -1
- package/dist/{crypto-runtime-D9_6J5tZ.js → crypto-runtime-Bnz3zEcS.js} +55 -32
- package/dist/direct-room-RinHjtqX.js +71 -0
- package/dist/{directory-live-C8dVBiCc.js → directory-live-Bvg2wAnR.js} +1 -2
- package/dist/{doctor-CM8ijNpW.js → doctor-EWf9CDso.js} +2 -2
- package/dist/{doctor-contract-BMSJkkAE.js → doctor-contract-DEt4O4Zt.js} +2 -3
- package/dist/doctor-contract-api.js +202 -90
- package/dist/{draft-stream-CtvOXq0Z.js → draft-stream-BRi7PRRS.js} +20 -23
- package/dist/{encryption-guidance-CbEFe38F.js → encryption-guidance-DmLY8NiO.js} +1 -1
- package/dist/{env-auth-CQsYbz-p.js → env-auth-MVS-Vv41.js} +4 -3
- package/dist/{env-vars-B0NxQnPk.js → env-vars-dGqak9dN.js} +1 -1
- package/dist/{errors-C47hvAF8.js → errors-DKVS3_DO.js} +2 -5
- package/dist/{file-sync-store-DiiFsayX.js → file-sync-store-DjskBX2o.js} +24 -3
- package/dist/helper-api.js +2 -2
- package/dist/{idb-persistence-B6x7dMsF.js → idb-persistence-BM0P27Zg.js} +3 -2
- package/dist/{inbound-dedupe-CaBLblef.js → inbound-dedupe-RvSLqdsz.js} +2 -2
- package/dist/index.js +1 -1
- package/dist/{logger-D0GCSDQq.js → logger-B_71hN6W.js} +1 -1
- package/dist/{logging-DV-p52N0.js → logging-DRjvUOIh.js} +1 -1
- package/dist/{media-text-BTwzADS_.js → media-text-JudlYOSc.js} +1 -1
- package/dist/{messages-DxQJkhxs.js → messages-BW0s-6Y9.js} +7 -7
- package/dist/{monitor-VyWlSLwo.js → monitor-Ddfc-vjX.js} +394 -384
- package/dist/plugin-entry.handlers.runtime.js +3 -3
- package/dist/probe.runtime-Dr91B_X3.js +2 -0
- package/dist/profile-D-Wubo0A.js +108 -0
- package/dist/{profile-update-CffmyW_4.js → profile-update-BkgWYDIp.js} +3 -2
- package/dist/{reaction-events-B00WSi98.js → reaction-events-nfUbFLdV.js} +9 -6
- package/dist/{recovery-key-store-BNnHvXdk.js → recovery-key-store-CognuDys.js} +5 -4
- package/dist/{resolve-targets-nm2L48sh.js → resolve-targets-BJAPY4Vb.js} +1 -1
- package/dist/{resolver.runtime-DS6uPaEe.js → resolver.runtime-LWJELYq5.js} +1 -1
- package/dist/{room-info-CAFZ3Z9J.js → room-info-BXQA7y10.js} +12 -3
- package/dist/runtime-api.js +6 -3
- package/dist/{sdk-bUytQHx7.js → sdk-DjaQFCHc.js} +229 -120
- package/dist/{secret-contract-M3hRmGO-.js → secret-contract-CufozuyJ.js} +1 -1
- package/dist/secret-contract-api.js +1 -1
- package/dist/{send-BldGYG8g.js → send-ZDLU4JTk.js} +1462 -1196
- package/dist/session-binding-contract-api.js +1 -1
- package/dist/{setup-bootstrap-Deleiibz.js → setup-bootstrap-BaXkhgJg.js} +4 -4
- package/dist/{setup-core-BVfBv2ai.js → setup-core-DQn6b5vi.js} +17 -266
- package/dist/setup-plugin-api.js +1 -44
- package/dist/{setup-surface-BBq3WeqX.js → setup-surface-DlhJdrNI.js} +9 -11
- package/dist/{startup-verification-wm3_i88s.js → startup-verification-Cs08ca8u.js} +3 -3
- package/dist/{storage-BvAkgzvT.js → storage-BsGuHngK.js} +3 -3
- package/dist/{thread-bindings-DGbl3vDW.js → thread-bindings-CcHZP3w2.js} +7 -4
- package/dist/{tool-actions.runtime-uu9blSqO.js → tool-actions.runtime-DmdRL0bN.js} +35 -18
- package/dist/{verification-DYMQ1QpI.js → verification-C7ig-bQE.js} +2 -2
- package/openclaw.plugin.json +54 -1
- package/package.json +4 -4
- package/dist/active-client-DXvz2gCo.js +0 -20
- package/dist/client-Dbso3-0V.js +0 -30
- package/dist/create-client-BmSU-q-D.js +0 -61
- package/dist/credentials-read-DVmFCm7X.js +0 -77
- package/dist/exec-approval-resolver-BCgqRtZS.js +0 -16
- package/dist/preflight-audio.runtime-BZxxQsxY.js +0 -11
- package/dist/probe.runtime-BuieqmS3.js +0 -3
- package/dist/record-shared-CWWx6fvI.js +0 -2
- package/dist/shared-CUMWxcMz.js +0 -673
- package/dist/sync-state-CWbp0QSY.js +0 -12
- package/dist/{runtime-api-D1xI_cvh.js → runtime-api-BGO16Fu8.js} +3 -3
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
|
-
import { t as getActiveMatrixClient } from "./active-client-DXvz2gCo.js";
|
|
3
2
|
import { t as isBunRuntime } from "./runtime-BefyhPWv.js";
|
|
4
3
|
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
5
4
|
import { requireRuntimeConfig } from "openclaw/plugin-sdk/plugin-config-runtime";
|
|
@@ -8,14 +7,14 @@ var client_bootstrap_exports = /* @__PURE__ */ __exportAll({
|
|
|
8
7
|
resolveRuntimeMatrixClientWithReadiness: () => resolveRuntimeMatrixClientWithReadiness,
|
|
9
8
|
withResolvedRuntimeMatrixClient: () => withResolvedRuntimeMatrixClient
|
|
10
9
|
});
|
|
11
|
-
const loadMatrixSharedClientRuntimeDeps = createLazyRuntimeModule(() =>
|
|
10
|
+
const loadMatrixSharedClientRuntimeDeps = createLazyRuntimeModule(() => import("./client-CeGw0G5S.js").then((n) => n.t).then((clientModule) => ({
|
|
12
11
|
acquireSharedMatrixClient: clientModule.acquireSharedMatrixClient,
|
|
13
|
-
resolveMatrixAuthContext: clientModule.resolveMatrixAuthContext
|
|
14
|
-
releaseSharedClientInstance: sharedModule.releaseSharedClientInstance
|
|
12
|
+
resolveMatrixAuthContext: clientModule.resolveMatrixAuthContext
|
|
15
13
|
})));
|
|
16
14
|
async function ensureResolvedClientReadiness(params) {
|
|
17
15
|
if (params.readiness === "started") {
|
|
18
|
-
await params.
|
|
16
|
+
if (params.lease) await params.lease.start();
|
|
17
|
+
else await params.client.start();
|
|
19
18
|
return;
|
|
20
19
|
}
|
|
21
20
|
if (params.readiness === "prepared" || !params.readiness && params.preparedByDefault) await params.client.prepareForOneOff();
|
|
@@ -23,87 +22,52 @@ async function ensureResolvedClientReadiness(params) {
|
|
|
23
22
|
function ensureMatrixNodeRuntime() {
|
|
24
23
|
if (isBunRuntime()) throw new Error("Matrix support requires Node (bun runtime not supported)");
|
|
25
24
|
}
|
|
26
|
-
async function
|
|
25
|
+
async function resolveRuntimeMatrixClientWithReadiness(opts) {
|
|
27
26
|
ensureMatrixNodeRuntime();
|
|
28
27
|
if (opts.client) {
|
|
29
|
-
await
|
|
30
|
-
return {
|
|
28
|
+
await ensureResolvedClientReadiness({
|
|
31
29
|
client: opts.client,
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
readiness: opts.readiness,
|
|
31
|
+
preparedByDefault: false
|
|
32
|
+
});
|
|
33
|
+
return { client: opts.client };
|
|
34
34
|
}
|
|
35
35
|
if (!opts.cfg) throw new Error("Matrix runtime client requires a resolved runtime config. Load and resolve config at the command or gateway boundary, then pass cfg through the runtime path.");
|
|
36
36
|
const cfg = requireRuntimeConfig(opts.cfg, "Matrix runtime client");
|
|
37
|
-
const { acquireSharedMatrixClient,
|
|
37
|
+
const { acquireSharedMatrixClient, resolveMatrixAuthContext } = await loadMatrixSharedClientRuntimeDeps();
|
|
38
38
|
const authContext = resolveMatrixAuthContext({
|
|
39
39
|
cfg,
|
|
40
40
|
accountId: opts.accountId
|
|
41
41
|
});
|
|
42
|
-
const
|
|
43
|
-
if (active) {
|
|
44
|
-
await opts.onResolved?.(active, { preparedByDefault: false });
|
|
45
|
-
return {
|
|
46
|
-
client: active,
|
|
47
|
-
stopOnDone: false
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
const client = await acquireSharedMatrixClient({
|
|
42
|
+
const lease = await acquireSharedMatrixClient({
|
|
51
43
|
cfg,
|
|
52
44
|
timeoutMs: opts.timeoutMs,
|
|
53
45
|
accountId: authContext.accountId,
|
|
54
|
-
startClient: false
|
|
46
|
+
startClient: false,
|
|
47
|
+
role: "transient"
|
|
55
48
|
});
|
|
56
49
|
try {
|
|
57
|
-
await
|
|
50
|
+
await ensureResolvedClientReadiness({
|
|
51
|
+
client: lease.client,
|
|
52
|
+
lease,
|
|
53
|
+
readiness: opts.readiness,
|
|
54
|
+
preparedByDefault: true
|
|
55
|
+
});
|
|
58
56
|
} catch (err) {
|
|
59
|
-
await
|
|
57
|
+
await lease.release({ mode: "stop" });
|
|
60
58
|
throw err;
|
|
61
59
|
}
|
|
62
60
|
return {
|
|
63
|
-
client,
|
|
64
|
-
|
|
65
|
-
cleanup: async (mode) => {
|
|
66
|
-
await releaseSharedClientInstance(client, mode);
|
|
67
|
-
}
|
|
61
|
+
client: lease.client,
|
|
62
|
+
lease
|
|
68
63
|
};
|
|
69
64
|
}
|
|
70
|
-
async function resolveRuntimeMatrixClientWithReadiness(opts) {
|
|
71
|
-
return await resolveRuntimeMatrixClient({
|
|
72
|
-
client: opts.client,
|
|
73
|
-
cfg: opts.cfg,
|
|
74
|
-
timeoutMs: opts.timeoutMs,
|
|
75
|
-
accountId: opts.accountId,
|
|
76
|
-
onResolved: async (client, context) => {
|
|
77
|
-
await ensureResolvedClientReadiness({
|
|
78
|
-
client,
|
|
79
|
-
readiness: opts.readiness,
|
|
80
|
-
preparedByDefault: context.preparedByDefault
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
async function stopResolvedRuntimeMatrixClient(resolved, mode = "stop") {
|
|
86
|
-
if (!resolved.stopOnDone) return;
|
|
87
|
-
if (resolved.cleanup) {
|
|
88
|
-
await resolved.cleanup(mode);
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
if (mode === "persist") {
|
|
92
|
-
await resolved.client.stopAndPersist();
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
if (mode === "discard") {
|
|
96
|
-
resolved.client.stopWithoutPersist();
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
resolved.client.stop();
|
|
100
|
-
}
|
|
101
65
|
async function withResolvedRuntimeMatrixClient(opts, run, stopMode = "stop") {
|
|
102
66
|
const resolved = await resolveRuntimeMatrixClientWithReadiness(opts);
|
|
103
67
|
try {
|
|
104
|
-
return await run(resolved.client);
|
|
68
|
+
return await run(resolved.client, resolved.lease?.abortSignal);
|
|
105
69
|
} finally {
|
|
106
|
-
await
|
|
70
|
+
await resolved.lease?.release({ mode: stopMode });
|
|
107
71
|
}
|
|
108
72
|
}
|
|
109
73
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
|
-
import {
|
|
3
|
-
import { n as withResolvedRuntimeMatrixClient } from "./client-bootstrap-
|
|
2
|
+
import { x as resolveMatrixRoomId } from "./send-ZDLU4JTk.js";
|
|
3
|
+
import { n as withResolvedRuntimeMatrixClient } from "./client-bootstrap-BFwT_2VT.js";
|
|
4
4
|
//#region extensions/matrix/src/matrix/actions/client.ts
|
|
5
5
|
var client_exports = /* @__PURE__ */ __exportAll({
|
|
6
6
|
withResolvedActionClient: () => withResolvedActionClient,
|
|
@@ -17,8 +17,8 @@ async function withStartedActionClient(opts, run) {
|
|
|
17
17
|
}, run, "persist");
|
|
18
18
|
}
|
|
19
19
|
async function withResolvedRoomAction(roomId, opts, run) {
|
|
20
|
-
return await withResolvedActionClient(opts, async (client) => {
|
|
21
|
-
return await run(client, await resolveMatrixRoomId(client, roomId));
|
|
20
|
+
return await withResolvedActionClient(opts, async (client, abortSignal) => {
|
|
21
|
+
return await run(client, await resolveMatrixRoomId(client, roomId), abortSignal);
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
//#endregion
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { t as formatMatrixErrorReason } from "./errors-DKVS3_DO.js";
|
|
2
|
+
//#region extensions/matrix/src/matrix/sync-state.ts
|
|
3
|
+
function isMatrixReadySyncState(state) {
|
|
4
|
+
return state === "PREPARED" || state === "SYNCING" || state === "CATCHUP";
|
|
5
|
+
}
|
|
6
|
+
function isMatrixDisconnectedSyncState(state) {
|
|
7
|
+
return state === "RECONNECTING" || state === "ERROR" || state === "STOPPED";
|
|
8
|
+
}
|
|
9
|
+
function isMatrixTerminalSyncState(state) {
|
|
10
|
+
return state === "STOPPED";
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region extensions/matrix/src/matrix/sdk/client-support.ts
|
|
14
|
+
const MATRIX_STATUS_DIAGNOSTIC_TIMEOUT_MS = 1e4;
|
|
15
|
+
const DEFAULT_MATRIX_LOCAL_TIMEOUT_MS = 6e4;
|
|
16
|
+
function resolveMatrixLocalTimeoutMs(raw) {
|
|
17
|
+
if (typeof raw !== "number" || !Number.isFinite(raw)) return DEFAULT_MATRIX_LOCAL_TIMEOUT_MS;
|
|
18
|
+
return Math.max(1, Math.floor(raw));
|
|
19
|
+
}
|
|
20
|
+
function unresolvedMatrixRoomKeyBackupStatus() {
|
|
21
|
+
return {
|
|
22
|
+
serverVersion: null,
|
|
23
|
+
activeVersion: null,
|
|
24
|
+
trusted: null,
|
|
25
|
+
matchesDecryptionKey: null,
|
|
26
|
+
decryptionKeyCached: null,
|
|
27
|
+
keyLoadAttempted: false,
|
|
28
|
+
keyLoadError: null
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function unresolvedMatrixDeviceVerificationStatus(params) {
|
|
32
|
+
return {
|
|
33
|
+
encryptionEnabled: true,
|
|
34
|
+
userId: params.userId,
|
|
35
|
+
deviceId: params.deviceId,
|
|
36
|
+
verified: false,
|
|
37
|
+
localVerified: false,
|
|
38
|
+
crossSigningVerified: false,
|
|
39
|
+
signedByOwner: false
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
async function resolveMatrixDiagnostic(promise, timeoutMs) {
|
|
43
|
+
return (await resolveMatrixDiagnosticResult(promise, timeoutMs)).value;
|
|
44
|
+
}
|
|
45
|
+
async function resolveMatrixDiagnosticResult(promise, timeoutMs) {
|
|
46
|
+
let timeoutId;
|
|
47
|
+
try {
|
|
48
|
+
const guarded = promise.then((value) => ({
|
|
49
|
+
error: null,
|
|
50
|
+
timedOut: false,
|
|
51
|
+
value
|
|
52
|
+
})).catch((error) => ({
|
|
53
|
+
error,
|
|
54
|
+
timedOut: false,
|
|
55
|
+
value: null
|
|
56
|
+
}));
|
|
57
|
+
const timeout = new Promise((resolve) => {
|
|
58
|
+
timeoutId = setTimeout(() => resolve({
|
|
59
|
+
error: null,
|
|
60
|
+
timedOut: true,
|
|
61
|
+
value: null
|
|
62
|
+
}), timeoutMs);
|
|
63
|
+
timeoutId.unref?.();
|
|
64
|
+
});
|
|
65
|
+
return await Promise.race([guarded, timeout]);
|
|
66
|
+
} finally {
|
|
67
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function isMatrixAccessTokenInvalidatedError(error) {
|
|
71
|
+
if (!error || typeof error !== "object") return false;
|
|
72
|
+
const err = error;
|
|
73
|
+
const errcode = err.body?.errcode ?? err.data?.errcode;
|
|
74
|
+
if (err.statusCode === 401 && errcode === "M_UNKNOWN_TOKEN") return true;
|
|
75
|
+
const reason = formatMatrixErrorReason(error);
|
|
76
|
+
return reason.includes("m_unknown_token") || reason.includes("unknown token") || reason.includes("access token") && (reason.includes("invalid") || reason.includes("unrecognized") || reason.includes("unknown"));
|
|
77
|
+
}
|
|
78
|
+
const MATRIX_INITIAL_CRYPTO_BOOTSTRAP_OPTIONS = { allowAutomaticCrossSigningReset: false };
|
|
79
|
+
const MATRIX_AUTOMATIC_REPAIR_BOOTSTRAP_OPTIONS = {
|
|
80
|
+
forceResetCrossSigning: true,
|
|
81
|
+
allowSecretStorageRecreateWithoutRecoveryKey: true,
|
|
82
|
+
strict: true
|
|
83
|
+
};
|
|
84
|
+
function createMatrixExplicitBootstrapOptions(params) {
|
|
85
|
+
return {
|
|
86
|
+
forceResetCrossSigning: params?.forceResetCrossSigning === true,
|
|
87
|
+
allowAutomaticCrossSigningReset: params?.allowAutomaticCrossSigningReset !== false,
|
|
88
|
+
allowSecretStorageRecreateWithoutRecoveryKey: true,
|
|
89
|
+
strict: params?.strict !== false
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
//#endregion
|
|
93
|
+
export { isMatrixAccessTokenInvalidatedError as a, resolveMatrixLocalTimeoutMs as c, isMatrixDisconnectedSyncState as d, isMatrixReadySyncState as f, createMatrixExplicitBootstrapOptions as i, unresolvedMatrixDeviceVerificationStatus as l, MATRIX_INITIAL_CRYPTO_BOOTSTRAP_OPTIONS as n, resolveMatrixDiagnostic as o, isMatrixTerminalSyncState as p, MATRIX_STATUS_DIAGNOSTIC_TIMEOUT_MS as r, resolveMatrixDiagnosticResult as s, MATRIX_AUTOMATIC_REPAIR_BOOTSTRAP_OPTIONS as t, unresolvedMatrixRoomKeyBackupStatus as u };
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
|
+
import { t as findMatrixAccountConfig } from "./account-config-BZWN9tGS.js";
|
|
3
|
+
import { n as resolveMatrixConfigPath$1, r as shouldStoreMatrixAccountAtTopLevel, t as resolveMatrixConfigFieldPath } from "./config-paths-CnREYb1Y.js";
|
|
4
|
+
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
5
|
+
import { normalizeSecretInputString } from "openclaw/plugin-sdk/setup";
|
|
6
|
+
import { resolveOptionalIntegerOption } from "openclaw/plugin-sdk/number-runtime";
|
|
7
|
+
import { coerceSecretRef } from "openclaw/plugin-sdk/secret-ref-runtime";
|
|
8
|
+
//#region extensions/matrix/src/matrix/config-update.ts
|
|
9
|
+
var config_update_exports = /* @__PURE__ */ __exportAll({
|
|
10
|
+
resolveMatrixConfigFieldPath: () => resolveMatrixConfigFieldPath,
|
|
11
|
+
resolveMatrixConfigPath: () => resolveMatrixConfigPath,
|
|
12
|
+
shouldStoreMatrixAccountAtTopLevel: () => shouldStoreMatrixAccountAtTopLevel,
|
|
13
|
+
updateMatrixAccountConfig: () => updateMatrixAccountConfig
|
|
14
|
+
});
|
|
15
|
+
const resolveMatrixConfigPath = resolveMatrixConfigPath$1;
|
|
16
|
+
function applyNullableStringField(target, key, value) {
|
|
17
|
+
if (value === void 0) return;
|
|
18
|
+
if (value === null) {
|
|
19
|
+
delete target[key];
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const trimmed = value.trim();
|
|
23
|
+
if (!trimmed) {
|
|
24
|
+
delete target[key];
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
target[key] = trimmed;
|
|
28
|
+
}
|
|
29
|
+
function applyNullableSecretInputField(target, key, value, defaults) {
|
|
30
|
+
if (value === void 0) return;
|
|
31
|
+
if (value === null) {
|
|
32
|
+
delete target[key];
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (typeof value === "string") {
|
|
36
|
+
const normalized = normalizeSecretInputString(value);
|
|
37
|
+
if (normalized) target[key] = normalized;
|
|
38
|
+
else delete target[key];
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const ref = coerceSecretRef(value, defaults);
|
|
42
|
+
if (!ref) throw new Error(`Invalid Matrix ${key} SecretInput.`);
|
|
43
|
+
target[key] = ref;
|
|
44
|
+
}
|
|
45
|
+
function cloneMatrixDmConfig(dm) {
|
|
46
|
+
if (!dm) return dm;
|
|
47
|
+
return {
|
|
48
|
+
...dm,
|
|
49
|
+
...dm.allowFrom ? { allowFrom: [...dm.allowFrom] } : {}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function cloneMatrixRoomMap(rooms) {
|
|
53
|
+
if (!rooms) return rooms;
|
|
54
|
+
const clonedRoomEntries = [];
|
|
55
|
+
for (const [roomId, roomCfg] of Object.entries(rooms)) clonedRoomEntries.push([roomId, roomCfg ? { ...roomCfg } : roomCfg]);
|
|
56
|
+
return Object.fromEntries(clonedRoomEntries);
|
|
57
|
+
}
|
|
58
|
+
function applyNullableArrayField(target, key, value) {
|
|
59
|
+
if (value === void 0) return;
|
|
60
|
+
if (value === null) {
|
|
61
|
+
delete target[key];
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
target[key] = [...value];
|
|
65
|
+
}
|
|
66
|
+
function updateMatrixAccountConfig(cfg, accountId, patch) {
|
|
67
|
+
const matrix = cfg.channels?.matrix ?? {};
|
|
68
|
+
const normalizedAccountId = normalizeAccountId(accountId);
|
|
69
|
+
const nextAccount = { ...findMatrixAccountConfig(cfg, normalizedAccountId) ?? (normalizedAccountId === DEFAULT_ACCOUNT_ID ? matrix : {}) };
|
|
70
|
+
if (patch.name !== void 0) if (patch.name === null) delete nextAccount.name;
|
|
71
|
+
else {
|
|
72
|
+
const trimmed = patch.name.trim();
|
|
73
|
+
if (trimmed) nextAccount.name = trimmed;
|
|
74
|
+
else delete nextAccount.name;
|
|
75
|
+
}
|
|
76
|
+
if (typeof patch.enabled === "boolean") nextAccount.enabled = patch.enabled;
|
|
77
|
+
else if (typeof nextAccount.enabled !== "boolean") nextAccount.enabled = true;
|
|
78
|
+
applyNullableStringField(nextAccount, "homeserver", patch.homeserver);
|
|
79
|
+
applyNullableStringField(nextAccount, "proxy", patch.proxy);
|
|
80
|
+
applyNullableStringField(nextAccount, "userId", patch.userId);
|
|
81
|
+
applyNullableSecretInputField(nextAccount, "accessToken", patch.accessToken, cfg.secrets?.defaults);
|
|
82
|
+
applyNullableSecretInputField(nextAccount, "password", patch.password, cfg.secrets?.defaults);
|
|
83
|
+
applyNullableStringField(nextAccount, "deviceId", patch.deviceId);
|
|
84
|
+
applyNullableStringField(nextAccount, "deviceName", patch.deviceName);
|
|
85
|
+
applyNullableStringField(nextAccount, "avatarUrl", patch.avatarUrl);
|
|
86
|
+
if (patch.allowPrivateNetwork !== void 0) {
|
|
87
|
+
const nextNetwork = nextAccount.network && typeof nextAccount.network === "object" ? { ...nextAccount.network } : {};
|
|
88
|
+
if (patch.allowPrivateNetwork === null) delete nextNetwork.dangerouslyAllowPrivateNetwork;
|
|
89
|
+
else nextNetwork.dangerouslyAllowPrivateNetwork = patch.allowPrivateNetwork;
|
|
90
|
+
if (Object.keys(nextNetwork).length > 0) nextAccount.network = nextNetwork;
|
|
91
|
+
else delete nextAccount.network;
|
|
92
|
+
}
|
|
93
|
+
if (patch.initialSyncLimit !== void 0) if (patch.initialSyncLimit === null) delete nextAccount.initialSyncLimit;
|
|
94
|
+
else {
|
|
95
|
+
const initialSyncLimit = resolveOptionalIntegerOption(patch.initialSyncLimit, { min: 0 });
|
|
96
|
+
if (initialSyncLimit === void 0) delete nextAccount.initialSyncLimit;
|
|
97
|
+
else nextAccount.initialSyncLimit = initialSyncLimit;
|
|
98
|
+
}
|
|
99
|
+
if (patch.encryption !== void 0) if (patch.encryption === null) delete nextAccount.encryption;
|
|
100
|
+
else nextAccount.encryption = patch.encryption;
|
|
101
|
+
if (patch.allowBots !== void 0) if (patch.allowBots === null) delete nextAccount.allowBots;
|
|
102
|
+
else nextAccount.allowBots = patch.allowBots;
|
|
103
|
+
if (patch.autoJoin !== void 0) if (patch.autoJoin === null) delete nextAccount.autoJoin;
|
|
104
|
+
else nextAccount.autoJoin = patch.autoJoin;
|
|
105
|
+
applyNullableArrayField(nextAccount, "autoJoinAllowlist", patch.autoJoinAllowlist);
|
|
106
|
+
if (patch.dm !== void 0) if (patch.dm === null) delete nextAccount.dm;
|
|
107
|
+
else nextAccount.dm = cloneMatrixDmConfig({
|
|
108
|
+
...nextAccount.dm,
|
|
109
|
+
...patch.dm
|
|
110
|
+
});
|
|
111
|
+
if (patch.groupPolicy !== void 0) if (patch.groupPolicy === null) delete nextAccount.groupPolicy;
|
|
112
|
+
else nextAccount.groupPolicy = patch.groupPolicy;
|
|
113
|
+
applyNullableArrayField(nextAccount, "groupAllowFrom", patch.groupAllowFrom);
|
|
114
|
+
if (patch.groups !== void 0) if (patch.groups === null) delete nextAccount.groups;
|
|
115
|
+
else nextAccount.groups = cloneMatrixRoomMap(patch.groups);
|
|
116
|
+
if (patch.rooms !== void 0) if (patch.rooms === null) delete nextAccount.rooms;
|
|
117
|
+
else nextAccount.rooms = cloneMatrixRoomMap(patch.rooms);
|
|
118
|
+
const nextAccounts = Object.fromEntries(Object.entries(matrix.accounts ?? {}).filter(([rawAccountId]) => rawAccountId === normalizedAccountId || normalizeAccountId(rawAccountId) !== normalizedAccountId));
|
|
119
|
+
if (shouldStoreMatrixAccountAtTopLevel(cfg, normalizedAccountId)) {
|
|
120
|
+
const { accounts: _ignoredAccounts, defaultAccount } = matrix;
|
|
121
|
+
const { accounts: _ignoredNextAccounts, defaultAccount: _ignoredNextDefaultAccount, ...topLevelAccount } = nextAccount;
|
|
122
|
+
return {
|
|
123
|
+
...cfg,
|
|
124
|
+
channels: {
|
|
125
|
+
...cfg.channels,
|
|
126
|
+
matrix: {
|
|
127
|
+
...defaultAccount ? { defaultAccount } : {},
|
|
128
|
+
enabled: true,
|
|
129
|
+
...topLevelAccount
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
...cfg,
|
|
136
|
+
channels: {
|
|
137
|
+
...cfg.channels,
|
|
138
|
+
matrix: {
|
|
139
|
+
...matrix,
|
|
140
|
+
enabled: true,
|
|
141
|
+
accounts: {
|
|
142
|
+
...nextAccounts,
|
|
143
|
+
[normalizedAccountId]: nextAccount
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
150
|
+
export { resolveMatrixConfigPath as n, updateMatrixAccountConfig as r, config_update_exports as t };
|
package/dist/contract-api.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as matrixOnboardingAdapter } from "./setup-surface-
|
|
1
|
+
import { c as singleAccountKeysToMove, n as matrixSetupAdapter, o as namedAccountPromotionKeys, s as resolveSingleAccountPromotionTarget } from "./setup-core-DQn6b5vi.js";
|
|
2
|
+
import { n as matrixOnboardingAdapter } from "./setup-surface-DlhJdrNI.js";
|
|
3
3
|
export { matrixSetupAdapter, matrixOnboardingAdapter as matrixSetupWizard, namedAccountPromotionKeys, resolveSingleAccountPromotionTarget, singleAccountKeysToMove };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { i as normalizeMatrixStoredCredentials, n as isMatrixCredentialRevocation, r as matrixCredentialsStoreKey } from "./credentials-state-B3cuUFwZ.js";
|
|
1
2
|
import { a as resolveMatrixCredentialsPath, r as resolveMatrixCredentialsDir } from "./storage-paths-gUmSydsW.js";
|
|
2
|
-
import { a as
|
|
3
|
+
import { a as openMatrixCredentialsStore, i as loadMatrixCredentials, n as credentialsMatchConfig, t as clearMatrixCredentials } from "./credentials-read-B37cQknZ.js";
|
|
3
4
|
import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
4
5
|
//#region extensions/matrix/src/matrix/credentials.ts
|
|
5
6
|
function requireCredentialStoreUpdate(store) {
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
|
+
import { n as getOptionalMatrixRuntime } from "./runtime-6S3DNFNv.js";
|
|
3
|
+
import { i as normalizeMatrixStoredCredentials, r as matrixCredentialsStoreKey, t as MATRIX_CREDENTIALS_NAMESPACE } from "./credentials-state-B3cuUFwZ.js";
|
|
4
|
+
import { a as resolveMatrixCredentialsPath, r as resolveMatrixCredentialsDir } from "./storage-paths-gUmSydsW.js";
|
|
5
|
+
import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
6
|
+
import { createPluginStateSyncKeyedStore } from "openclaw/plugin-sdk/plugin-state-store-runtime";
|
|
7
|
+
//#region extensions/matrix/src/matrix/credentials-read.ts
|
|
8
|
+
var credentials_read_exports = /* @__PURE__ */ __exportAll({
|
|
9
|
+
clearMatrixCredentials: () => clearMatrixCredentials,
|
|
10
|
+
credentialsMatchConfig: () => credentialsMatchConfig,
|
|
11
|
+
loadMatrixCredentials: () => loadMatrixCredentials,
|
|
12
|
+
openMatrixCredentialsStore: () => openMatrixCredentialsStore,
|
|
13
|
+
resolveMatrixCredentialsDir: () => resolveMatrixCredentialsDir,
|
|
14
|
+
resolveMatrixCredentialsPath: () => resolveMatrixCredentialsPath
|
|
15
|
+
});
|
|
16
|
+
function openMatrixCredentialsStore(env = process.env) {
|
|
17
|
+
const runtime = getOptionalMatrixRuntime();
|
|
18
|
+
return createPluginStateSyncKeyedStore("matrix", {
|
|
19
|
+
namespace: MATRIX_CREDENTIALS_NAMESPACE,
|
|
20
|
+
maxEntries: 256,
|
|
21
|
+
overflowPolicy: "reject-new",
|
|
22
|
+
env: env.OPENCLAW_STATE_DIR?.trim() || !runtime ? env : {
|
|
23
|
+
...env,
|
|
24
|
+
OPENCLAW_STATE_DIR: runtime.state.resolveStateDir(env)
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function loadMatrixCredentials(env = process.env, accountId) {
|
|
29
|
+
const normalizedAccountId = normalizeAccountId(accountId);
|
|
30
|
+
const parsed = normalizeMatrixStoredCredentials(openMatrixCredentialsStore(env).lookup(matrixCredentialsStoreKey(accountId)), normalizedAccountId);
|
|
31
|
+
if (!parsed || parsed.accountId !== normalizedAccountId) return null;
|
|
32
|
+
const { accountId: _accountId, ...credentials } = parsed;
|
|
33
|
+
return credentials;
|
|
34
|
+
}
|
|
35
|
+
function clearMatrixCredentials(env = process.env, accountId) {
|
|
36
|
+
const normalizedAccountId = normalizeAccountId(accountId);
|
|
37
|
+
openMatrixCredentialsStore(env).register(matrixCredentialsStoreKey(normalizedAccountId), {
|
|
38
|
+
accountId: normalizedAccountId,
|
|
39
|
+
kind: "revoked",
|
|
40
|
+
revokedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function credentialsMatchConfig(stored, config) {
|
|
44
|
+
if (!config.userId) {
|
|
45
|
+
if (!config.accessToken) return false;
|
|
46
|
+
return stored.homeserver === config.homeserver && stored.accessToken === config.accessToken;
|
|
47
|
+
}
|
|
48
|
+
return stored.homeserver === config.homeserver && stored.userId === config.userId;
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
export { openMatrixCredentialsStore as a, loadMatrixCredentials as i, credentialsMatchConfig as n, credentials_read_exports as r, clearMatrixCredentials as t };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
2
|
+
//#region extensions/matrix/src/matrix/credentials-state.ts
|
|
3
|
+
const MATRIX_CREDENTIALS_NAMESPACE = "credentials";
|
|
4
|
+
function matrixCredentialsStoreKey(accountId) {
|
|
5
|
+
return `account:${normalizeAccountId(accountId)}`;
|
|
6
|
+
}
|
|
7
|
+
function normalizeMatrixStoredCredentials(value, accountId) {
|
|
8
|
+
if (!value || typeof value !== "object") return null;
|
|
9
|
+
const parsed = value;
|
|
10
|
+
if (typeof parsed.homeserver !== "string" || !parsed.homeserver || typeof parsed.userId !== "string" || !parsed.userId || typeof parsed.accessToken !== "string" || !parsed.accessToken || typeof parsed.createdAt !== "string" || !parsed.createdAt) return null;
|
|
11
|
+
return {
|
|
12
|
+
accountId: normalizeAccountId(accountId ?? parsed.accountId),
|
|
13
|
+
homeserver: parsed.homeserver,
|
|
14
|
+
userId: parsed.userId,
|
|
15
|
+
accessToken: parsed.accessToken,
|
|
16
|
+
...typeof parsed.deviceId === "string" ? { deviceId: parsed.deviceId } : {},
|
|
17
|
+
createdAt: parsed.createdAt,
|
|
18
|
+
...typeof parsed.lastUsedAt === "string" ? { lastUsedAt: parsed.lastUsedAt } : {}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function isMatrixCredentialRevocation(value, accountId) {
|
|
22
|
+
if (!value || typeof value !== "object") return false;
|
|
23
|
+
const parsed = value;
|
|
24
|
+
return parsed.kind === "revoked" && typeof parsed.revokedAt === "string" && parsed.revokedAt.length > 0 && normalizeAccountId(parsed.accountId) === normalizeAccountId(accountId ?? parsed.accountId);
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { normalizeMatrixStoredCredentials as i, isMatrixCredentialRevocation as n, matrixCredentialsStoreKey as r, MATRIX_CREDENTIALS_NAMESPACE as t };
|
package/dist/{credentials-write.runtime-Be9zNSUw.js → credentials-write.runtime-nAV2-5uR.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
2
2
|
//#region extensions/matrix/src/matrix/credentials-write.runtime.ts
|
|
3
|
-
const loadMatrixCredentialsRuntime = createLazyRuntimeModule(() => import("./credentials-
|
|
3
|
+
const loadMatrixCredentialsRuntime = createLazyRuntimeModule(() => import("./credentials-BdAaWuiR.js"));
|
|
4
4
|
async function saveMatrixCredentials(...args) {
|
|
5
5
|
return (await loadMatrixCredentialsRuntime()).saveMatrixCredentials(...args);
|
|
6
6
|
}
|