@openclaw/matrix 2026.3.13 → 2026.5.10-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account-config-D2W-V1eQ.js +96 -0
- package/dist/account-selection-BWwIruri.js +158 -0
- package/dist/accounts-Bm90Rzvp.js +130 -0
- package/dist/active-client-uhlxdhEy.js +20 -0
- package/dist/allowlist-sTzpCn5d.js +68 -0
- package/dist/api.js +12 -0
- package/dist/approval-handler.runtime-DWTQfd4m.js +370 -0
- package/dist/approval-ids-DoC2z7tR.js +7 -0
- package/dist/approval-reaction-auth-DbcA1gGd.js +27 -0
- package/dist/approval-reactions-o2_tuH8D.js +162 -0
- package/dist/async-lock-uQfhfQIY.js +19 -0
- package/dist/auth-presence.js +26 -0
- package/dist/backup-health-Cabu_WQC.js +60 -0
- package/dist/channel-H_6lMgwf.js +1116 -0
- package/dist/channel-plugin-api.js +2 -0
- package/dist/channel.runtime-BnO9f0pR.js +246 -0
- package/dist/cli-CYZ9yVcB.js +1340 -0
- package/dist/cli-metadata-DPIHnoa6.js +22 -0
- package/dist/cli-metadata.js +2 -0
- package/dist/client-DkcXnm0X.js +25 -0
- package/dist/client-_hckQNGW.js +31 -0
- package/dist/client-bootstrap-Rb8oHvhH.js +114 -0
- package/dist/config--5-S2Akv.js +452 -0
- package/dist/config-paths-nsVaysCu.js +19 -0
- package/dist/config-schema-nPLpEgHl.js +200 -0
- package/dist/config-secret-input.runtime-DiKFehsE.js +2 -0
- package/dist/config-update-wZX-HLMn.js +143 -0
- package/dist/contract-api.js +9 -0
- package/dist/create-client-DCnqDaqd.js +64 -0
- package/dist/credentials-DV6fWXhC.js +56 -0
- package/dist/credentials-read-cmHgousK.js +112 -0
- package/dist/credentials-write.runtime-zniTq-Gr.js +17 -0
- package/dist/crypto-node.runtime-pihzdpY7.js +12 -0
- package/dist/crypto-runtime-ZI0zAtn3.js +1214 -0
- package/dist/deps-C6WqKY7m.js +235 -0
- package/dist/device-health-UVYpbA_W.js +16 -0
- package/dist/direct-management-DMMMgtTB.js +249 -0
- package/dist/direct-room-XkutHjES.js +76 -0
- package/dist/directory-live-DmOtMhyr.js +150 -0
- package/dist/doctor-C4__7c-U.js +153 -0
- package/dist/doctor-contract-D4-64QuJ.js +246 -0
- package/dist/doctor-contract-api.js +2 -0
- package/dist/draft-stream-BE2QevQQ.js +144 -0
- package/dist/encryption-guidance-BPi3A_m3.js +15 -0
- package/dist/env-auth-BJqGI8M6.js +63 -0
- package/dist/env-vars-C7uQCTKn.js +63 -0
- package/dist/errors-CTcpEDq-.js +17 -0
- package/dist/exec-approval-resolver-Bza9Dhlm.js +15 -0
- package/dist/exec-approvals-Crnh543m.js +196 -0
- package/dist/helper-api.js +4 -0
- package/dist/http-client-C7AeVJay.js +319 -0
- package/dist/index.js +46 -0
- package/dist/legacy-crypto-inspector-poDWldgy.js +41 -0
- package/dist/legacy-crypto-restore-Biw-w2ng.js +85 -0
- package/dist/logger-CnZRVrux.js +78 -0
- package/dist/logging-DZHSPP5N.js +99 -0
- package/dist/matrix-migration.runtime-WY6ffcrf.js +525 -0
- package/dist/media-text-DU6nWZuj.js +146 -0
- package/dist/messages-BpihMh82.js +140 -0
- package/dist/migration-snapshot-backup-DaCHTp8C.js +69 -0
- package/dist/migration-snapshot.runtime-CKHE3xF9.js +2 -0
- package/dist/monitor-BaRCKyLd.js +4175 -0
- package/dist/plugin-entry.handlers.runtime.js +51 -0
- package/dist/probe.runtime-BvAzYAIe.js +3 -0
- package/dist/profile-BlHu0wDX.js +111 -0
- package/dist/profile-update-DjeBNgIV.js +69 -0
- package/dist/reaction-common-ejrL19w-.js +71 -0
- package/dist/reaction-events-CiARZfjk.js +121 -0
- package/dist/record-shared-CHWJCTWf.js +2 -0
- package/dist/recovery-key-store-BTJ6jz5v.js +294 -0
- package/dist/resolve-targets-YtJnw1Tb.js +140 -0
- package/dist/resolver.runtime-D9piiGEl.js +5 -0
- package/dist/rolldown-runtime-DUslC3ob.js +14 -0
- package/dist/route-D6rg-iXN.js +161 -0
- package/dist/runtime-C6X4h_SJ.js +6 -0
- package/dist/runtime-Dog86njy.js +8 -0
- package/dist/runtime-api-DTKcXOhp.js +24 -0
- package/dist/runtime-api.js +25 -0
- package/dist/runtime-heavy-api.js +3 -0
- package/dist/runtime-setter-api.js +2 -0
- package/dist/sdk-B2vZA27-.js +1416 -0
- package/dist/secret-contract-DcrJWCQI.js +120 -0
- package/dist/secret-contract-api.js +2 -0
- package/dist/send-Bo0DU1ca.js +1200 -0
- package/dist/session-store-metadata-DQXjgNLt.js +77 -0
- package/dist/setup-bootstrap-ImenBsMt.js +62 -0
- package/dist/setup-core-CfZy05oW.js +116 -0
- package/dist/setup-dm-policy-2-r1FrQh.js +194 -0
- package/dist/setup-entry.js +19 -0
- package/dist/setup-plugin-api.js +44 -0
- package/dist/setup-surface-CqT_o61M.js +540 -0
- package/dist/shared-CpMoYKm1.js +195 -0
- package/dist/startup-abort-56edvmbM.js +32 -0
- package/dist/startup-verification-Demyp0bP.js +132 -0
- package/dist/storage-paths-BJLdnCjV.js +52 -0
- package/dist/storage-tC3ujLiW.js +281 -0
- package/dist/subagent-hooks-DQbyqq9V.js +149 -0
- package/dist/subagent-hooks-api.js +23 -0
- package/dist/sync-state-C_beeevA.js +12 -0
- package/dist/target-ids-80nQ2gql.js +77 -0
- package/dist/test-api.js +4 -0
- package/dist/thread-binding-api-Cq_E-E1K.js +17 -0
- package/dist/thread-binding-api.js +2 -0
- package/dist/thread-bindings-B9mesxXk.js +352 -0
- package/dist/thread-bindings-runtime.js +2 -0
- package/dist/thread-bindings-shared-DK-d-oYX.js +97 -0
- package/dist/timeout-abort-signal-CtaIaP1v.js +2 -0
- package/dist/tool-actions.runtime-ThYhfHtZ.js +532 -0
- package/dist/url-validation-DiK9j7jz.js +36 -0
- package/dist/verification-CZ2rDeHL.js +345 -0
- package/openclaw.plugin.json +796 -1
- package/package.json +82 -16
- package/CHANGELOG.md +0 -104
- package/index.ts +0 -22
- package/src/actions.ts +0 -195
- package/src/channel.directory.test.ts +0 -135
- package/src/channel.ts +0 -461
- package/src/config-schema.test.ts +0 -26
- package/src/config-schema.ts +0 -62
- package/src/directory-live.test.ts +0 -85
- package/src/directory-live.ts +0 -209
- package/src/group-mentions.ts +0 -52
- package/src/matrix/accounts.test.ts +0 -131
- package/src/matrix/accounts.ts +0 -114
- package/src/matrix/actions/client.ts +0 -47
- package/src/matrix/actions/limits.test.ts +0 -15
- package/src/matrix/actions/limits.ts +0 -6
- package/src/matrix/actions/messages.ts +0 -126
- package/src/matrix/actions/pins.test.ts +0 -74
- package/src/matrix/actions/pins.ts +0 -84
- package/src/matrix/actions/reactions.test.ts +0 -109
- package/src/matrix/actions/reactions.ts +0 -102
- package/src/matrix/actions/room.ts +0 -85
- package/src/matrix/actions/summary.ts +0 -75
- package/src/matrix/actions/types.ts +0 -85
- package/src/matrix/actions.ts +0 -15
- package/src/matrix/active-client.ts +0 -32
- package/src/matrix/client/config.ts +0 -245
- package/src/matrix/client/create-client.ts +0 -125
- package/src/matrix/client/logging.ts +0 -46
- package/src/matrix/client/runtime.ts +0 -4
- package/src/matrix/client/shared.test.ts +0 -85
- package/src/matrix/client/shared.ts +0 -210
- package/src/matrix/client/startup.test.ts +0 -49
- package/src/matrix/client/startup.ts +0 -29
- package/src/matrix/client/storage.ts +0 -131
- package/src/matrix/client/types.ts +0 -34
- package/src/matrix/client-bootstrap.ts +0 -47
- package/src/matrix/client.test.ts +0 -56
- package/src/matrix/client.ts +0 -14
- package/src/matrix/credentials.ts +0 -125
- package/src/matrix/deps.test.ts +0 -74
- package/src/matrix/deps.ts +0 -126
- package/src/matrix/format.test.ts +0 -33
- package/src/matrix/format.ts +0 -22
- package/src/matrix/index.ts +0 -11
- package/src/matrix/monitor/access-policy.ts +0 -126
- package/src/matrix/monitor/allowlist.test.ts +0 -45
- package/src/matrix/monitor/allowlist.ts +0 -94
- package/src/matrix/monitor/auto-join.ts +0 -72
- package/src/matrix/monitor/direct.test.ts +0 -396
- package/src/matrix/monitor/direct.ts +0 -152
- package/src/matrix/monitor/events.test.ts +0 -186
- package/src/matrix/monitor/events.ts +0 -168
- package/src/matrix/monitor/handler.body-for-agent.test.ts +0 -196
- package/src/matrix/monitor/handler.ts +0 -768
- package/src/matrix/monitor/inbound-body.test.ts +0 -73
- package/src/matrix/monitor/inbound-body.ts +0 -28
- package/src/matrix/monitor/index.test.ts +0 -18
- package/src/matrix/monitor/index.ts +0 -414
- package/src/matrix/monitor/location.ts +0 -100
- package/src/matrix/monitor/media.test.ts +0 -86
- package/src/matrix/monitor/media.ts +0 -118
- package/src/matrix/monitor/mentions.test.ts +0 -154
- package/src/matrix/monitor/mentions.ts +0 -62
- package/src/matrix/monitor/replies.test.ts +0 -184
- package/src/matrix/monitor/replies.ts +0 -124
- package/src/matrix/monitor/room-info.ts +0 -55
- package/src/matrix/monitor/rooms.test.ts +0 -124
- package/src/matrix/monitor/rooms.ts +0 -47
- package/src/matrix/monitor/threads.ts +0 -68
- package/src/matrix/monitor/types.ts +0 -39
- package/src/matrix/poll-types.test.ts +0 -21
- package/src/matrix/poll-types.ts +0 -167
- package/src/matrix/probe.ts +0 -69
- package/src/matrix/sdk-runtime.ts +0 -18
- package/src/matrix/send/client.ts +0 -99
- package/src/matrix/send/formatting.ts +0 -93
- package/src/matrix/send/media.ts +0 -230
- package/src/matrix/send/targets.test.ts +0 -98
- package/src/matrix/send/targets.ts +0 -150
- package/src/matrix/send/types.ts +0 -110
- package/src/matrix/send-queue.test.ts +0 -145
- package/src/matrix/send-queue.ts +0 -28
- package/src/matrix/send.test.ts +0 -319
- package/src/matrix/send.ts +0 -267
- package/src/onboarding.ts +0 -462
- package/src/outbound.test.ts +0 -159
- package/src/outbound.ts +0 -58
- package/src/resolve-targets.test.ts +0 -68
- package/src/resolve-targets.ts +0 -125
- package/src/runtime.ts +0 -6
- package/src/secret-input.ts +0 -13
- package/src/test-mocks.ts +0 -53
- package/src/tool-actions.ts +0 -164
- package/src/types.ts +0 -118
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { t as formatMatrixErrorMessage } from "./errors-CTcpEDq-.js";
|
|
2
|
+
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
|
+
//#region extensions/matrix/src/plugin-entry.runtime.ts
|
|
4
|
+
let matrixVerificationRuntimePromise;
|
|
5
|
+
function loadMatrixVerificationRuntime() {
|
|
6
|
+
matrixVerificationRuntimePromise ??= import("./verification-CZ2rDeHL.js").then((n) => n.y);
|
|
7
|
+
return matrixVerificationRuntimePromise;
|
|
8
|
+
}
|
|
9
|
+
function sendError(respond, err) {
|
|
10
|
+
respond(false, { error: formatMatrixErrorMessage(err) });
|
|
11
|
+
}
|
|
12
|
+
async function handleVerifyRecoveryKey({ params, respond }) {
|
|
13
|
+
try {
|
|
14
|
+
const { verifyMatrixRecoveryKey } = await loadMatrixVerificationRuntime();
|
|
15
|
+
const key = normalizeOptionalString(params?.key);
|
|
16
|
+
if (!key) {
|
|
17
|
+
respond(false, { error: "key required" });
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const result = await verifyMatrixRecoveryKey(key, { accountId: normalizeOptionalString(params?.accountId) });
|
|
21
|
+
respond(result.success, result);
|
|
22
|
+
} catch (err) {
|
|
23
|
+
sendError(respond, err);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
async function handleVerificationBootstrap({ params, respond }) {
|
|
27
|
+
try {
|
|
28
|
+
const { bootstrapMatrixVerification } = await loadMatrixVerificationRuntime();
|
|
29
|
+
const result = await bootstrapMatrixVerification({
|
|
30
|
+
accountId: normalizeOptionalString(params?.accountId),
|
|
31
|
+
recoveryKey: typeof params?.recoveryKey === "string" ? params.recoveryKey : void 0,
|
|
32
|
+
forceResetCrossSigning: params?.forceResetCrossSigning === true
|
|
33
|
+
});
|
|
34
|
+
respond(result.success, result);
|
|
35
|
+
} catch (err) {
|
|
36
|
+
sendError(respond, err);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async function handleVerificationStatus({ params, respond }) {
|
|
40
|
+
try {
|
|
41
|
+
const { getMatrixVerificationStatus } = await loadMatrixVerificationRuntime();
|
|
42
|
+
respond(true, await getMatrixVerificationStatus({
|
|
43
|
+
accountId: normalizeOptionalString(params?.accountId),
|
|
44
|
+
includeRecoveryKey: params?.includeRecoveryKey === true
|
|
45
|
+
}));
|
|
46
|
+
} catch (err) {
|
|
47
|
+
sendError(respond, err);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
export { handleVerificationBootstrap, handleVerificationStatus, handleVerifyRecoveryKey };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-DUslC3ob.js";
|
|
2
|
+
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
|
+
//#region extensions/matrix/src/matrix/profile.ts
|
|
4
|
+
var profile_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
MATRIX_PROFILE_AVATAR_MAX_BYTES: () => MATRIX_PROFILE_AVATAR_MAX_BYTES,
|
|
6
|
+
isMatrixHttpAvatarUri: () => isMatrixHttpAvatarUri,
|
|
7
|
+
isMatrixMxcUri: () => isMatrixMxcUri,
|
|
8
|
+
isSupportedMatrixAvatarSource: () => isSupportedMatrixAvatarSource,
|
|
9
|
+
syncMatrixOwnProfile: () => syncMatrixOwnProfile
|
|
10
|
+
});
|
|
11
|
+
const MATRIX_PROFILE_AVATAR_MAX_BYTES = 10 * 1024 * 1024;
|
|
12
|
+
function isMatrixMxcUri(value) {
|
|
13
|
+
return normalizeLowercaseStringOrEmpty(normalizeOptionalString(value)).startsWith("mxc://");
|
|
14
|
+
}
|
|
15
|
+
function isMatrixHttpAvatarUri(value) {
|
|
16
|
+
const normalized = normalizeLowercaseStringOrEmpty(normalizeOptionalString(value));
|
|
17
|
+
return normalized.startsWith("https://") || normalized.startsWith("http://");
|
|
18
|
+
}
|
|
19
|
+
function isSupportedMatrixAvatarSource(value) {
|
|
20
|
+
return isMatrixMxcUri(value) || isMatrixHttpAvatarUri(value);
|
|
21
|
+
}
|
|
22
|
+
async function uploadAvatarMedia(params) {
|
|
23
|
+
const media = await params.loadAvatar(params.avatarSource, params.avatarMaxBytes);
|
|
24
|
+
return await params.client.uploadContent(media.buffer, media.contentType, media.fileName || "avatar");
|
|
25
|
+
}
|
|
26
|
+
async function resolveAvatarUrl(params) {
|
|
27
|
+
const avatarPath = normalizeOptionalString(params.avatarPath) ?? null;
|
|
28
|
+
if (avatarPath) {
|
|
29
|
+
if (!params.loadAvatarFromPath) throw new Error("Matrix avatar path upload requires a media loader.");
|
|
30
|
+
return {
|
|
31
|
+
resolvedAvatarUrl: await uploadAvatarMedia({
|
|
32
|
+
client: params.client,
|
|
33
|
+
avatarSource: avatarPath,
|
|
34
|
+
avatarMaxBytes: params.avatarMaxBytes,
|
|
35
|
+
loadAvatar: params.loadAvatarFromPath
|
|
36
|
+
}),
|
|
37
|
+
uploadedAvatarSource: "path",
|
|
38
|
+
convertedAvatarFromHttp: false
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const avatarUrl = normalizeOptionalString(params.avatarUrl) ?? null;
|
|
42
|
+
if (!avatarUrl) return {
|
|
43
|
+
resolvedAvatarUrl: null,
|
|
44
|
+
uploadedAvatarSource: null,
|
|
45
|
+
convertedAvatarFromHttp: false
|
|
46
|
+
};
|
|
47
|
+
if (isMatrixMxcUri(avatarUrl)) return {
|
|
48
|
+
resolvedAvatarUrl: avatarUrl,
|
|
49
|
+
uploadedAvatarSource: null,
|
|
50
|
+
convertedAvatarFromHttp: false
|
|
51
|
+
};
|
|
52
|
+
if (!isMatrixHttpAvatarUri(avatarUrl)) throw new Error("Matrix avatar URL must be an mxc:// URI or an http(s) URL.");
|
|
53
|
+
if (!params.loadAvatarFromUrl) throw new Error("Matrix avatar URL conversion requires a media loader.");
|
|
54
|
+
return {
|
|
55
|
+
resolvedAvatarUrl: await uploadAvatarMedia({
|
|
56
|
+
client: params.client,
|
|
57
|
+
avatarSource: avatarUrl,
|
|
58
|
+
avatarMaxBytes: params.avatarMaxBytes,
|
|
59
|
+
loadAvatar: params.loadAvatarFromUrl
|
|
60
|
+
}),
|
|
61
|
+
uploadedAvatarSource: "http",
|
|
62
|
+
convertedAvatarFromHttp: true
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
async function syncMatrixOwnProfile(params) {
|
|
66
|
+
const desiredDisplayName = normalizeOptionalString(params.displayName) ?? null;
|
|
67
|
+
const avatar = await resolveAvatarUrl({
|
|
68
|
+
client: params.client,
|
|
69
|
+
avatarUrl: params.avatarUrl ?? null,
|
|
70
|
+
avatarPath: params.avatarPath ?? null,
|
|
71
|
+
avatarMaxBytes: params.avatarMaxBytes ?? 10485760,
|
|
72
|
+
loadAvatarFromUrl: params.loadAvatarFromUrl,
|
|
73
|
+
loadAvatarFromPath: params.loadAvatarFromPath
|
|
74
|
+
});
|
|
75
|
+
const desiredAvatarUrl = avatar.resolvedAvatarUrl;
|
|
76
|
+
if (!desiredDisplayName && !desiredAvatarUrl) return {
|
|
77
|
+
skipped: true,
|
|
78
|
+
displayNameUpdated: false,
|
|
79
|
+
avatarUpdated: false,
|
|
80
|
+
resolvedAvatarUrl: null,
|
|
81
|
+
uploadedAvatarSource: avatar.uploadedAvatarSource,
|
|
82
|
+
convertedAvatarFromHttp: avatar.convertedAvatarFromHttp
|
|
83
|
+
};
|
|
84
|
+
let currentDisplayName;
|
|
85
|
+
let currentAvatarUrl;
|
|
86
|
+
try {
|
|
87
|
+
const currentProfile = await params.client.getUserProfile(params.userId);
|
|
88
|
+
currentDisplayName = normalizeOptionalString(currentProfile.displayname);
|
|
89
|
+
currentAvatarUrl = normalizeOptionalString(currentProfile.avatar_url);
|
|
90
|
+
} catch {}
|
|
91
|
+
let displayNameUpdated = false;
|
|
92
|
+
let avatarUpdated = false;
|
|
93
|
+
if (desiredDisplayName && currentDisplayName !== desiredDisplayName) {
|
|
94
|
+
await params.client.setDisplayName(desiredDisplayName);
|
|
95
|
+
displayNameUpdated = true;
|
|
96
|
+
}
|
|
97
|
+
if (desiredAvatarUrl && currentAvatarUrl !== desiredAvatarUrl) {
|
|
98
|
+
await params.client.setAvatarUrl(desiredAvatarUrl);
|
|
99
|
+
avatarUpdated = true;
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
skipped: false,
|
|
103
|
+
displayNameUpdated,
|
|
104
|
+
avatarUpdated,
|
|
105
|
+
resolvedAvatarUrl: desiredAvatarUrl,
|
|
106
|
+
uploadedAvatarSource: avatar.uploadedAvatarSource,
|
|
107
|
+
convertedAvatarFromHttp: avatar.convertedAvatarFromHttp
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
export { profile_exports as n, syncMatrixOwnProfile as r, isSupportedMatrixAvatarSource as t };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { t as getMatrixRuntime } from "./runtime-Dog86njy.js";
|
|
2
|
+
import { n as resolveMatrixConfigPath, r as updateMatrixAccountConfig } from "./config-update-wZX-HLMn.js";
|
|
3
|
+
import { r as syncMatrixOwnProfile } from "./profile-BlHu0wDX.js";
|
|
4
|
+
import { n as withResolvedActionClient } from "./client-DkcXnm0X.js";
|
|
5
|
+
import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
6
|
+
//#region extensions/matrix/src/matrix/actions/profile.ts
|
|
7
|
+
async function updateMatrixOwnProfile(opts = {}) {
|
|
8
|
+
const displayName = opts.displayName?.trim();
|
|
9
|
+
const avatarUrl = opts.avatarUrl?.trim();
|
|
10
|
+
const avatarPath = opts.avatarPath?.trim();
|
|
11
|
+
const runtime = getMatrixRuntime();
|
|
12
|
+
return await withResolvedActionClient(opts, async (client) => {
|
|
13
|
+
return await syncMatrixOwnProfile({
|
|
14
|
+
client,
|
|
15
|
+
userId: await client.getUserId(),
|
|
16
|
+
displayName: displayName || void 0,
|
|
17
|
+
avatarUrl: avatarUrl || void 0,
|
|
18
|
+
avatarPath: avatarPath || void 0,
|
|
19
|
+
loadAvatarFromUrl: async (url, maxBytes) => await runtime.media.loadWebMedia(url, maxBytes),
|
|
20
|
+
loadAvatarFromPath: async (path, maxBytes) => await runtime.media.loadWebMedia(path, {
|
|
21
|
+
maxBytes,
|
|
22
|
+
localRoots: opts.mediaLocalRoots
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
}, "persist");
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region extensions/matrix/src/profile-update.ts
|
|
29
|
+
async function applyMatrixProfileUpdate(params) {
|
|
30
|
+
const runtime = getMatrixRuntime();
|
|
31
|
+
const persistedCfg = runtime.config.current();
|
|
32
|
+
const accountId = normalizeAccountId(params.account);
|
|
33
|
+
const displayName = params.displayName?.trim() || null;
|
|
34
|
+
const avatarUrl = params.avatarUrl?.trim() || null;
|
|
35
|
+
const avatarPath = params.avatarPath?.trim() || null;
|
|
36
|
+
if (!displayName && !avatarUrl && !avatarPath) throw new Error("Provide name/displayName and/or avatarUrl/avatarPath.");
|
|
37
|
+
const synced = await updateMatrixOwnProfile({
|
|
38
|
+
cfg: params.cfg,
|
|
39
|
+
accountId,
|
|
40
|
+
displayName: displayName ?? void 0,
|
|
41
|
+
avatarUrl: avatarUrl ?? void 0,
|
|
42
|
+
avatarPath: avatarPath ?? void 0,
|
|
43
|
+
mediaLocalRoots: params.mediaLocalRoots
|
|
44
|
+
});
|
|
45
|
+
const persistedAvatarUrl = synced.uploadedAvatarSource && synced.resolvedAvatarUrl ? synced.resolvedAvatarUrl : avatarUrl;
|
|
46
|
+
const updated = updateMatrixAccountConfig(persistedCfg, accountId, {
|
|
47
|
+
name: displayName ?? void 0,
|
|
48
|
+
avatarUrl: persistedAvatarUrl ?? void 0
|
|
49
|
+
});
|
|
50
|
+
await runtime.config.replaceConfigFile({
|
|
51
|
+
nextConfig: updated,
|
|
52
|
+
afterWrite: { mode: "auto" }
|
|
53
|
+
});
|
|
54
|
+
return {
|
|
55
|
+
accountId,
|
|
56
|
+
displayName,
|
|
57
|
+
avatarUrl: persistedAvatarUrl ?? null,
|
|
58
|
+
profile: {
|
|
59
|
+
displayNameUpdated: synced.displayNameUpdated,
|
|
60
|
+
avatarUpdated: synced.avatarUpdated,
|
|
61
|
+
resolvedAvatarUrl: synced.resolvedAvatarUrl,
|
|
62
|
+
uploadedAvatarSource: synced.uploadedAvatarSource,
|
|
63
|
+
convertedAvatarFromHttp: synced.convertedAvatarFromHttp
|
|
64
|
+
},
|
|
65
|
+
configPath: resolveMatrixConfigPath(updated, accountId)
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { updateMatrixOwnProfile as n, applyMatrixProfileUpdate as t };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
2
|
+
//#region extensions/matrix/src/matrix/reaction-common.ts
|
|
3
|
+
const MATRIX_ANNOTATION_RELATION_TYPE = "m.annotation";
|
|
4
|
+
const MATRIX_REACTION_EVENT_TYPE = "m.reaction";
|
|
5
|
+
function normalizeMatrixReactionMessageId(messageId) {
|
|
6
|
+
const normalized = messageId.trim();
|
|
7
|
+
if (!normalized) throw new Error("Matrix reaction requires a messageId");
|
|
8
|
+
return normalized;
|
|
9
|
+
}
|
|
10
|
+
function normalizeMatrixReactionEmoji(emoji) {
|
|
11
|
+
const normalized = emoji.trim();
|
|
12
|
+
if (!normalized) throw new Error("Matrix reaction requires an emoji");
|
|
13
|
+
return normalized;
|
|
14
|
+
}
|
|
15
|
+
function buildMatrixReactionContent(messageId, emoji) {
|
|
16
|
+
return { "m.relates_to": {
|
|
17
|
+
rel_type: MATRIX_ANNOTATION_RELATION_TYPE,
|
|
18
|
+
event_id: normalizeMatrixReactionMessageId(messageId),
|
|
19
|
+
key: normalizeMatrixReactionEmoji(emoji)
|
|
20
|
+
} };
|
|
21
|
+
}
|
|
22
|
+
function buildMatrixReactionRelationsPath(roomId, messageId) {
|
|
23
|
+
return `/_matrix/client/v1/rooms/${encodeURIComponent(roomId)}/relations/${encodeURIComponent(normalizeMatrixReactionMessageId(messageId))}/${MATRIX_ANNOTATION_RELATION_TYPE}/${MATRIX_REACTION_EVENT_TYPE}`;
|
|
24
|
+
}
|
|
25
|
+
function extractMatrixReactionAnnotation(content) {
|
|
26
|
+
if (!content || typeof content !== "object") return;
|
|
27
|
+
const relatesTo = content["m.relates_to"];
|
|
28
|
+
if (!relatesTo || typeof relatesTo !== "object") return;
|
|
29
|
+
if (typeof relatesTo.rel_type === "string" && relatesTo.rel_type !== "m.annotation") return;
|
|
30
|
+
const key = normalizeOptionalString(relatesTo.key) ?? "";
|
|
31
|
+
if (!key) return;
|
|
32
|
+
return {
|
|
33
|
+
key,
|
|
34
|
+
eventId: (normalizeOptionalString(relatesTo.event_id) ?? "") || void 0
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function extractMatrixReactionKey(content) {
|
|
38
|
+
return extractMatrixReactionAnnotation(content)?.key;
|
|
39
|
+
}
|
|
40
|
+
function summarizeMatrixReactionEvents(events) {
|
|
41
|
+
const summaries = /* @__PURE__ */ new Map();
|
|
42
|
+
for (const event of events) {
|
|
43
|
+
const key = extractMatrixReactionKey(event.content);
|
|
44
|
+
if (!key) continue;
|
|
45
|
+
const sender = normalizeOptionalString(event.sender) ?? "";
|
|
46
|
+
const entry = summaries.get(key) ?? {
|
|
47
|
+
key,
|
|
48
|
+
count: 0,
|
|
49
|
+
users: []
|
|
50
|
+
};
|
|
51
|
+
entry.count += 1;
|
|
52
|
+
if (sender && !entry.users.includes(sender)) entry.users.push(sender);
|
|
53
|
+
summaries.set(key, entry);
|
|
54
|
+
}
|
|
55
|
+
return Array.from(summaries.values());
|
|
56
|
+
}
|
|
57
|
+
function selectOwnMatrixReactionEventIds(events, userId, emoji) {
|
|
58
|
+
const senderId = normalizeOptionalString(userId) ?? "";
|
|
59
|
+
if (!senderId) return [];
|
|
60
|
+
const targetEmoji = normalizeOptionalString(emoji);
|
|
61
|
+
const ids = [];
|
|
62
|
+
for (const event of events) {
|
|
63
|
+
if ((normalizeOptionalString(event.sender) ?? "") !== senderId) continue;
|
|
64
|
+
if (targetEmoji && extractMatrixReactionKey(event.content) !== targetEmoji) continue;
|
|
65
|
+
const eventId = normalizeOptionalString(event.event_id);
|
|
66
|
+
if (eventId) ids.push(eventId);
|
|
67
|
+
}
|
|
68
|
+
return ids;
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { extractMatrixReactionAnnotation as a, buildMatrixReactionRelationsPath as i, MATRIX_REACTION_EVENT_TYPE as n, selectOwnMatrixReactionEventIds as o, buildMatrixReactionContent as r, summarizeMatrixReactionEvents as s, MATRIX_ANNOTATION_RELATION_TYPE as t };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { a as resolveMatrixAccountConfig } from "./account-config-D2W-V1eQ.js";
|
|
2
|
+
import { a as extractMatrixReactionAnnotation } from "./reaction-common-ejrL19w-.js";
|
|
3
|
+
import { a as unregisterMatrixApprovalReactionTarget, i as resolveMatrixApprovalReactionTargetWithPersistence } from "./approval-reactions-o2_tuH8D.js";
|
|
4
|
+
import { i as resolveMatrixThreadRouting, r as resolveMatrixThreadRootId, t as resolveMatrixInboundRoute } from "./route-D6rg-iXN.js";
|
|
5
|
+
import { getSessionBindingService } from "openclaw/plugin-sdk/session-binding-runtime";
|
|
6
|
+
//#region extensions/matrix/src/matrix/monitor/reaction-events.ts
|
|
7
|
+
let approvalReactionAuthPromise;
|
|
8
|
+
let execApprovalResolverPromise;
|
|
9
|
+
function loadApprovalReactionAuth() {
|
|
10
|
+
approvalReactionAuthPromise ??= import("./approval-reaction-auth-DbcA1gGd.js");
|
|
11
|
+
return approvalReactionAuthPromise;
|
|
12
|
+
}
|
|
13
|
+
function loadExecApprovalResolver() {
|
|
14
|
+
execApprovalResolverPromise ??= import("./exec-approval-resolver-Bza9Dhlm.js");
|
|
15
|
+
return execApprovalResolverPromise;
|
|
16
|
+
}
|
|
17
|
+
function resolveMatrixReactionNotificationMode(params) {
|
|
18
|
+
const matrixConfig = params.cfg.channels?.matrix;
|
|
19
|
+
return resolveMatrixAccountConfig({
|
|
20
|
+
cfg: params.cfg,
|
|
21
|
+
accountId: params.accountId
|
|
22
|
+
}).reactionNotifications ?? matrixConfig?.reactionNotifications ?? "own";
|
|
23
|
+
}
|
|
24
|
+
async function maybeResolveMatrixApprovalReaction(params) {
|
|
25
|
+
if (!params.target) return false;
|
|
26
|
+
const approvalKind = params.target.approvalId.startsWith("plugin:") ? "plugin" : "exec";
|
|
27
|
+
const { isMatrixApprovalReactionAuthorizedSender } = await loadApprovalReactionAuth();
|
|
28
|
+
if (!isMatrixApprovalReactionAuthorizedSender({
|
|
29
|
+
...params,
|
|
30
|
+
approvalKind
|
|
31
|
+
})) return false;
|
|
32
|
+
const { isApprovalNotFoundError, resolveMatrixApproval } = await loadExecApprovalResolver();
|
|
33
|
+
try {
|
|
34
|
+
await resolveMatrixApproval({
|
|
35
|
+
cfg: params.cfg,
|
|
36
|
+
approvalId: params.target.approvalId,
|
|
37
|
+
decision: params.target.decision,
|
|
38
|
+
senderId: params.senderId
|
|
39
|
+
});
|
|
40
|
+
params.logVerboseMessage(`matrix: approval reaction resolved id=${params.target.approvalId} sender=${params.senderId} decision=${params.target.decision}`);
|
|
41
|
+
return true;
|
|
42
|
+
} catch (err) {
|
|
43
|
+
if (isApprovalNotFoundError(err)) {
|
|
44
|
+
unregisterMatrixApprovalReactionTarget({
|
|
45
|
+
roomId: params.roomId,
|
|
46
|
+
eventId: params.targetEventId
|
|
47
|
+
});
|
|
48
|
+
params.logVerboseMessage(`matrix: approval reaction ignored for expired approval id=${params.target.approvalId} sender=${params.senderId}`);
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
params.logVerboseMessage(`matrix: approval reaction failed id=${params.target.approvalId} sender=${params.senderId}: ${String(err)}`);
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async function handleInboundMatrixReaction(params) {
|
|
56
|
+
const reaction = extractMatrixReactionAnnotation(params.event.content);
|
|
57
|
+
if (!reaction?.eventId) return;
|
|
58
|
+
if (params.senderId === params.selfUserId) return;
|
|
59
|
+
const approvalTarget = await resolveMatrixApprovalReactionTargetWithPersistence({
|
|
60
|
+
roomId: params.roomId,
|
|
61
|
+
eventId: reaction.eventId,
|
|
62
|
+
reactionKey: reaction.key
|
|
63
|
+
});
|
|
64
|
+
if (await maybeResolveMatrixApprovalReaction({
|
|
65
|
+
cfg: params.cfg,
|
|
66
|
+
accountId: params.accountId,
|
|
67
|
+
senderId: params.senderId,
|
|
68
|
+
target: approvalTarget,
|
|
69
|
+
targetEventId: reaction.eventId,
|
|
70
|
+
roomId: params.roomId,
|
|
71
|
+
logVerboseMessage: params.logVerboseMessage
|
|
72
|
+
})) return;
|
|
73
|
+
const notificationMode = resolveMatrixReactionNotificationMode({
|
|
74
|
+
cfg: params.cfg,
|
|
75
|
+
accountId: params.accountId
|
|
76
|
+
});
|
|
77
|
+
if (notificationMode === "off") return;
|
|
78
|
+
const targetEvent = await params.client.getEvent(params.roomId, reaction.eventId).catch((err) => {
|
|
79
|
+
params.logVerboseMessage(`matrix: failed resolving reaction target room=${params.roomId} id=${reaction.eventId}: ${String(err)}`);
|
|
80
|
+
return null;
|
|
81
|
+
});
|
|
82
|
+
const targetSender = targetEvent && typeof targetEvent.sender === "string" ? targetEvent.sender.trim() : "";
|
|
83
|
+
if (!targetSender) return;
|
|
84
|
+
if (notificationMode === "own" && targetSender !== params.selfUserId) return;
|
|
85
|
+
const targetContent = targetEvent && targetEvent.content && typeof targetEvent.content === "object" ? targetEvent.content : void 0;
|
|
86
|
+
const threadRootId = targetContent ? resolveMatrixThreadRootId({
|
|
87
|
+
event: targetEvent,
|
|
88
|
+
content: targetContent
|
|
89
|
+
}) : void 0;
|
|
90
|
+
const accountConfig = resolveMatrixAccountConfig({
|
|
91
|
+
cfg: params.cfg,
|
|
92
|
+
accountId: params.accountId
|
|
93
|
+
});
|
|
94
|
+
const thread = resolveMatrixThreadRouting({
|
|
95
|
+
isDirectMessage: params.isDirectMessage,
|
|
96
|
+
threadReplies: accountConfig.threadReplies ?? "inbound",
|
|
97
|
+
dmThreadReplies: accountConfig.dm?.threadReplies,
|
|
98
|
+
messageId: reaction.eventId,
|
|
99
|
+
threadRootId
|
|
100
|
+
});
|
|
101
|
+
const { route, runtimeBindingId } = resolveMatrixInboundRoute({
|
|
102
|
+
cfg: params.cfg,
|
|
103
|
+
accountId: params.accountId,
|
|
104
|
+
roomId: params.roomId,
|
|
105
|
+
senderId: params.senderId,
|
|
106
|
+
isDirectMessage: params.isDirectMessage,
|
|
107
|
+
dmSessionScope: accountConfig.dm?.sessionScope ?? "per-user",
|
|
108
|
+
threadId: thread.threadId,
|
|
109
|
+
eventTs: params.event.origin_server_ts,
|
|
110
|
+
resolveAgentRoute: params.core.channel.routing.resolveAgentRoute
|
|
111
|
+
});
|
|
112
|
+
if (runtimeBindingId) getSessionBindingService().touch(runtimeBindingId, params.event.origin_server_ts);
|
|
113
|
+
const text = `Matrix reaction added: ${reaction.key} by ${params.senderLabel} on msg ${reaction.eventId}`;
|
|
114
|
+
params.core.system.enqueueSystemEvent(text, {
|
|
115
|
+
sessionKey: route.sessionKey,
|
|
116
|
+
contextKey: `matrix:reaction:add:${params.roomId}:${reaction.eventId}:${params.senderId}:${reaction.key}`
|
|
117
|
+
});
|
|
118
|
+
params.logVerboseMessage(`matrix: reaction event enqueued room=${params.roomId} target=${reaction.eventId} sender=${params.senderId} emoji=${reaction.key}`);
|
|
119
|
+
}
|
|
120
|
+
//#endregion
|
|
121
|
+
export { handleInboundMatrixReaction, resolveMatrixReactionNotificationMode };
|