@openclaw/matrix 2026.3.13 → 2026.5.9-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.
Files changed (206) hide show
  1. package/dist/account-config-D2W-V1eQ.js +96 -0
  2. package/dist/account-selection-BWwIruri.js +158 -0
  3. package/dist/accounts-Bm90Rzvp.js +130 -0
  4. package/dist/active-client-uhlxdhEy.js +20 -0
  5. package/dist/allowlist-sTzpCn5d.js +68 -0
  6. package/dist/api.js +12 -0
  7. package/dist/approval-handler.runtime-DWTQfd4m.js +370 -0
  8. package/dist/approval-ids-DoC2z7tR.js +7 -0
  9. package/dist/approval-reaction-auth-DbcA1gGd.js +27 -0
  10. package/dist/approval-reactions-o2_tuH8D.js +162 -0
  11. package/dist/async-lock-uQfhfQIY.js +19 -0
  12. package/dist/auth-presence.js +26 -0
  13. package/dist/backup-health-Cabu_WQC.js +60 -0
  14. package/dist/channel-DJNir3Rb.js +1116 -0
  15. package/dist/channel-plugin-api.js +2 -0
  16. package/dist/channel.runtime-BQu0hTih.js +246 -0
  17. package/dist/cli-BmfTmg7x.js +1340 -0
  18. package/dist/cli-metadata-B-PCEzrA.js +22 -0
  19. package/dist/cli-metadata.js +2 -0
  20. package/dist/client-DkcXnm0X.js +25 -0
  21. package/dist/client-_hckQNGW.js +31 -0
  22. package/dist/client-bootstrap-Rb8oHvhH.js +114 -0
  23. package/dist/config--5-S2Akv.js +452 -0
  24. package/dist/config-paths-nsVaysCu.js +19 -0
  25. package/dist/config-schema-nPLpEgHl.js +200 -0
  26. package/dist/config-secret-input.runtime-DiKFehsE.js +2 -0
  27. package/dist/config-update-wZX-HLMn.js +143 -0
  28. package/dist/contract-api.js +9 -0
  29. package/dist/create-client-DCnqDaqd.js +64 -0
  30. package/dist/credentials-DV6fWXhC.js +56 -0
  31. package/dist/credentials-read-cmHgousK.js +112 -0
  32. package/dist/credentials-write.runtime-zniTq-Gr.js +17 -0
  33. package/dist/crypto-node.runtime-pihzdpY7.js +12 -0
  34. package/dist/crypto-runtime-ZI0zAtn3.js +1214 -0
  35. package/dist/deps-C6WqKY7m.js +235 -0
  36. package/dist/device-health-UVYpbA_W.js +16 -0
  37. package/dist/direct-management-DMMMgtTB.js +249 -0
  38. package/dist/direct-room-XkutHjES.js +76 -0
  39. package/dist/directory-live-DmOtMhyr.js +150 -0
  40. package/dist/doctor-C4__7c-U.js +153 -0
  41. package/dist/doctor-contract-D4-64QuJ.js +246 -0
  42. package/dist/doctor-contract-api.js +2 -0
  43. package/dist/draft-stream-BE2QevQQ.js +144 -0
  44. package/dist/encryption-guidance-BPi3A_m3.js +15 -0
  45. package/dist/env-auth-BJqGI8M6.js +63 -0
  46. package/dist/env-vars-C7uQCTKn.js +63 -0
  47. package/dist/errors-CTcpEDq-.js +17 -0
  48. package/dist/exec-approval-resolver-Bza9Dhlm.js +15 -0
  49. package/dist/exec-approvals-Crnh543m.js +196 -0
  50. package/dist/helper-api.js +4 -0
  51. package/dist/http-client-C7AeVJay.js +319 -0
  52. package/dist/index.js +46 -0
  53. package/dist/legacy-crypto-inspector-poDWldgy.js +41 -0
  54. package/dist/legacy-crypto-restore-Biw-w2ng.js +85 -0
  55. package/dist/logger-CnZRVrux.js +78 -0
  56. package/dist/logging-DZHSPP5N.js +99 -0
  57. package/dist/matrix-migration.runtime-WY6ffcrf.js +525 -0
  58. package/dist/media-text-DU6nWZuj.js +146 -0
  59. package/dist/messages-BpihMh82.js +140 -0
  60. package/dist/migration-snapshot-backup-DaCHTp8C.js +69 -0
  61. package/dist/migration-snapshot.runtime-CKHE3xF9.js +2 -0
  62. package/dist/monitor-C_81r_Ck.js +4125 -0
  63. package/dist/plugin-entry.handlers.runtime.js +51 -0
  64. package/dist/probe.runtime-BvAzYAIe.js +3 -0
  65. package/dist/profile-BlHu0wDX.js +111 -0
  66. package/dist/profile-update-DjeBNgIV.js +69 -0
  67. package/dist/reaction-common-ejrL19w-.js +71 -0
  68. package/dist/reaction-events-CiARZfjk.js +121 -0
  69. package/dist/record-shared-CHWJCTWf.js +2 -0
  70. package/dist/recovery-key-store-BTJ6jz5v.js +294 -0
  71. package/dist/resolve-targets-YtJnw1Tb.js +140 -0
  72. package/dist/resolver.runtime-D9piiGEl.js +5 -0
  73. package/dist/rolldown-runtime-DUslC3ob.js +14 -0
  74. package/dist/route-D6rg-iXN.js +161 -0
  75. package/dist/runtime-C6X4h_SJ.js +6 -0
  76. package/dist/runtime-Dog86njy.js +8 -0
  77. package/dist/runtime-api-BXWBFIqm.js +25 -0
  78. package/dist/runtime-api.js +25 -0
  79. package/dist/runtime-heavy-api.js +3 -0
  80. package/dist/runtime-setter-api.js +2 -0
  81. package/dist/sdk-B2vZA27-.js +1416 -0
  82. package/dist/secret-contract-DcrJWCQI.js +120 -0
  83. package/dist/secret-contract-api.js +2 -0
  84. package/dist/send-Bo0DU1ca.js +1200 -0
  85. package/dist/session-store-metadata-DI5SCofx.js +77 -0
  86. package/dist/setup-bootstrap-ImenBsMt.js +62 -0
  87. package/dist/setup-core-CfZy05oW.js +116 -0
  88. package/dist/setup-dm-policy-2-r1FrQh.js +194 -0
  89. package/dist/setup-entry.js +19 -0
  90. package/dist/setup-plugin-api.js +44 -0
  91. package/dist/setup-surface-CqT_o61M.js +540 -0
  92. package/dist/shared-CpMoYKm1.js +195 -0
  93. package/dist/startup-abort-56edvmbM.js +32 -0
  94. package/dist/startup-verification-Demyp0bP.js +132 -0
  95. package/dist/storage-paths-BJLdnCjV.js +52 -0
  96. package/dist/storage-tC3ujLiW.js +281 -0
  97. package/dist/subagent-hooks-DQbyqq9V.js +149 -0
  98. package/dist/subagent-hooks-api.js +23 -0
  99. package/dist/sync-state-C_beeevA.js +12 -0
  100. package/dist/target-ids-80nQ2gql.js +77 -0
  101. package/dist/test-api.js +4 -0
  102. package/dist/thread-binding-api-Cq_E-E1K.js +17 -0
  103. package/dist/thread-binding-api.js +2 -0
  104. package/dist/thread-bindings-B9mesxXk.js +352 -0
  105. package/dist/thread-bindings-runtime.js +2 -0
  106. package/dist/thread-bindings-shared-DK-d-oYX.js +97 -0
  107. package/dist/timeout-abort-signal-CtaIaP1v.js +2 -0
  108. package/dist/tool-actions.runtime-BIH49vRr.js +532 -0
  109. package/dist/url-validation-DiK9j7jz.js +36 -0
  110. package/dist/verification-CZ2rDeHL.js +345 -0
  111. package/openclaw.plugin.json +788 -1
  112. package/package.json +82 -16
  113. package/CHANGELOG.md +0 -104
  114. package/index.ts +0 -22
  115. package/src/actions.ts +0 -195
  116. package/src/channel.directory.test.ts +0 -135
  117. package/src/channel.ts +0 -461
  118. package/src/config-schema.test.ts +0 -26
  119. package/src/config-schema.ts +0 -62
  120. package/src/directory-live.test.ts +0 -85
  121. package/src/directory-live.ts +0 -209
  122. package/src/group-mentions.ts +0 -52
  123. package/src/matrix/accounts.test.ts +0 -131
  124. package/src/matrix/accounts.ts +0 -114
  125. package/src/matrix/actions/client.ts +0 -47
  126. package/src/matrix/actions/limits.test.ts +0 -15
  127. package/src/matrix/actions/limits.ts +0 -6
  128. package/src/matrix/actions/messages.ts +0 -126
  129. package/src/matrix/actions/pins.test.ts +0 -74
  130. package/src/matrix/actions/pins.ts +0 -84
  131. package/src/matrix/actions/reactions.test.ts +0 -109
  132. package/src/matrix/actions/reactions.ts +0 -102
  133. package/src/matrix/actions/room.ts +0 -85
  134. package/src/matrix/actions/summary.ts +0 -75
  135. package/src/matrix/actions/types.ts +0 -85
  136. package/src/matrix/actions.ts +0 -15
  137. package/src/matrix/active-client.ts +0 -32
  138. package/src/matrix/client/config.ts +0 -245
  139. package/src/matrix/client/create-client.ts +0 -125
  140. package/src/matrix/client/logging.ts +0 -46
  141. package/src/matrix/client/runtime.ts +0 -4
  142. package/src/matrix/client/shared.test.ts +0 -85
  143. package/src/matrix/client/shared.ts +0 -210
  144. package/src/matrix/client/startup.test.ts +0 -49
  145. package/src/matrix/client/startup.ts +0 -29
  146. package/src/matrix/client/storage.ts +0 -131
  147. package/src/matrix/client/types.ts +0 -34
  148. package/src/matrix/client-bootstrap.ts +0 -47
  149. package/src/matrix/client.test.ts +0 -56
  150. package/src/matrix/client.ts +0 -14
  151. package/src/matrix/credentials.ts +0 -125
  152. package/src/matrix/deps.test.ts +0 -74
  153. package/src/matrix/deps.ts +0 -126
  154. package/src/matrix/format.test.ts +0 -33
  155. package/src/matrix/format.ts +0 -22
  156. package/src/matrix/index.ts +0 -11
  157. package/src/matrix/monitor/access-policy.ts +0 -126
  158. package/src/matrix/monitor/allowlist.test.ts +0 -45
  159. package/src/matrix/monitor/allowlist.ts +0 -94
  160. package/src/matrix/monitor/auto-join.ts +0 -72
  161. package/src/matrix/monitor/direct.test.ts +0 -396
  162. package/src/matrix/monitor/direct.ts +0 -152
  163. package/src/matrix/monitor/events.test.ts +0 -186
  164. package/src/matrix/monitor/events.ts +0 -168
  165. package/src/matrix/monitor/handler.body-for-agent.test.ts +0 -196
  166. package/src/matrix/monitor/handler.ts +0 -768
  167. package/src/matrix/monitor/inbound-body.test.ts +0 -73
  168. package/src/matrix/monitor/inbound-body.ts +0 -28
  169. package/src/matrix/monitor/index.test.ts +0 -18
  170. package/src/matrix/monitor/index.ts +0 -414
  171. package/src/matrix/monitor/location.ts +0 -100
  172. package/src/matrix/monitor/media.test.ts +0 -86
  173. package/src/matrix/monitor/media.ts +0 -118
  174. package/src/matrix/monitor/mentions.test.ts +0 -154
  175. package/src/matrix/monitor/mentions.ts +0 -62
  176. package/src/matrix/monitor/replies.test.ts +0 -184
  177. package/src/matrix/monitor/replies.ts +0 -124
  178. package/src/matrix/monitor/room-info.ts +0 -55
  179. package/src/matrix/monitor/rooms.test.ts +0 -124
  180. package/src/matrix/monitor/rooms.ts +0 -47
  181. package/src/matrix/monitor/threads.ts +0 -68
  182. package/src/matrix/monitor/types.ts +0 -39
  183. package/src/matrix/poll-types.test.ts +0 -21
  184. package/src/matrix/poll-types.ts +0 -167
  185. package/src/matrix/probe.ts +0 -69
  186. package/src/matrix/sdk-runtime.ts +0 -18
  187. package/src/matrix/send/client.ts +0 -99
  188. package/src/matrix/send/formatting.ts +0 -93
  189. package/src/matrix/send/media.ts +0 -230
  190. package/src/matrix/send/targets.test.ts +0 -98
  191. package/src/matrix/send/targets.ts +0 -150
  192. package/src/matrix/send/types.ts +0 -110
  193. package/src/matrix/send-queue.test.ts +0 -145
  194. package/src/matrix/send-queue.ts +0 -28
  195. package/src/matrix/send.test.ts +0 -319
  196. package/src/matrix/send.ts +0 -267
  197. package/src/onboarding.ts +0 -462
  198. package/src/outbound.test.ts +0 -159
  199. package/src/outbound.ts +0 -58
  200. package/src/resolve-targets.test.ts +0 -68
  201. package/src/resolve-targets.ts +0 -125
  202. package/src/runtime.ts +0 -6
  203. package/src/secret-input.ts +0 -13
  204. package/src/test-mocks.ts +0 -53
  205. package/src/tool-actions.ts +0 -164
  206. package/src/types.ts +0 -118
@@ -0,0 +1,140 @@
1
+ import { r as isMatrixNotFoundError } from "./errors-CTcpEDq-.js";
2
+ import { a as sendMessageMatrix, h as isPollEventType, n as editMessageMatrix } from "./send-Bo0DU1ca.js";
3
+ import { n as MATRIX_REACTION_EVENT_TYPE } from "./reaction-common-ejrL19w-.js";
4
+ import { a as resolveMatrixMessageBody, c as resolveMatrixPollRootEventId, i as resolveMatrixMessageAttachment, o as fetchMatrixPollMessageSummary } from "./media-text-DU6nWZuj.js";
5
+ import { r as withResolvedRoomAction } from "./client-DkcXnm0X.js";
6
+ import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
7
+ //#region extensions/matrix/src/matrix/actions/limits.ts
8
+ function resolveMatrixActionLimit(raw, fallback) {
9
+ if (typeof raw !== "number" || !Number.isFinite(raw)) return fallback;
10
+ return Math.max(1, Math.floor(raw));
11
+ }
12
+ //#endregion
13
+ //#region extensions/matrix/src/matrix/actions/types.ts
14
+ const EventType = {
15
+ RoomMessage: "m.room.message",
16
+ RoomPinnedEvents: "m.room.pinned_events",
17
+ RoomTopic: "m.room.topic",
18
+ Reaction: MATRIX_REACTION_EVENT_TYPE
19
+ };
20
+ //#endregion
21
+ //#region extensions/matrix/src/matrix/actions/summary.ts
22
+ function summarizeMatrixRawEvent(event) {
23
+ const content = event.content;
24
+ const relates = content["m.relates_to"];
25
+ let relType;
26
+ let eventId;
27
+ if (relates) {
28
+ if ("rel_type" in relates) {
29
+ relType = relates.rel_type;
30
+ eventId = relates.event_id;
31
+ } else if ("m.in_reply_to" in relates) eventId = relates["m.in_reply_to"]?.event_id;
32
+ }
33
+ const relatesTo = relType || eventId ? {
34
+ relType,
35
+ eventId
36
+ } : void 0;
37
+ return {
38
+ eventId: event.event_id,
39
+ sender: event.sender,
40
+ body: resolveMatrixMessageBody({
41
+ body: content.body,
42
+ filename: content.filename,
43
+ msgtype: content.msgtype
44
+ }),
45
+ msgtype: content.msgtype,
46
+ attachment: resolveMatrixMessageAttachment({
47
+ body: content.body,
48
+ filename: content.filename,
49
+ msgtype: content.msgtype
50
+ }),
51
+ timestamp: event.origin_server_ts,
52
+ relatesTo
53
+ };
54
+ }
55
+ async function readPinnedEvents(client, roomId) {
56
+ try {
57
+ return (await client.getRoomStateEvent(roomId, EventType.RoomPinnedEvents, "")).pinned.filter((id) => id.trim().length > 0);
58
+ } catch (err) {
59
+ if (isMatrixNotFoundError(err)) return [];
60
+ throw err;
61
+ }
62
+ }
63
+ async function fetchEventSummary(client, roomId, eventId) {
64
+ try {
65
+ const raw = await client.getEvent(roomId, eventId);
66
+ if (raw.unsigned?.redacted_because) return null;
67
+ const pollSummary = await fetchMatrixPollMessageSummary(client, roomId, raw);
68
+ if (pollSummary) return pollSummary;
69
+ return summarizeMatrixRawEvent(raw);
70
+ } catch {
71
+ return null;
72
+ }
73
+ }
74
+ //#endregion
75
+ //#region extensions/matrix/src/matrix/actions/messages.ts
76
+ async function sendMatrixMessage(to, content, opts = {}) {
77
+ if (!opts.cfg) throw new Error("Matrix message actions require a resolved runtime config.");
78
+ return await sendMessageMatrix(to, content, {
79
+ cfg: opts.cfg,
80
+ mediaUrl: opts.mediaUrl,
81
+ mediaLocalRoots: opts.mediaLocalRoots,
82
+ replyToId: opts.replyToId,
83
+ threadId: opts.threadId,
84
+ audioAsVoice: opts.audioAsVoice,
85
+ accountId: opts.accountId ?? void 0,
86
+ client: opts.client,
87
+ timeoutMs: opts.timeoutMs
88
+ });
89
+ }
90
+ async function editMatrixMessage(roomId, messageId, content, opts = {}) {
91
+ if (!opts.cfg) throw new Error("Matrix message actions require a resolved runtime config.");
92
+ const trimmed = content.trim();
93
+ if (!trimmed) throw new Error("Matrix edit requires content");
94
+ return { eventId: await editMessageMatrix(roomId, messageId, trimmed, {
95
+ cfg: opts.cfg,
96
+ accountId: opts.accountId ?? void 0,
97
+ client: opts.client,
98
+ timeoutMs: opts.timeoutMs
99
+ }) || null };
100
+ }
101
+ async function deleteMatrixMessage(roomId, messageId, opts = {}) {
102
+ await withResolvedRoomAction(roomId, opts, async (client, resolvedRoom) => {
103
+ await client.redactEvent(resolvedRoom, messageId, opts.reason);
104
+ });
105
+ }
106
+ async function readMatrixMessages(roomId, opts = {}) {
107
+ return await withResolvedRoomAction(roomId, opts, async (client, resolvedRoom) => {
108
+ const limit = resolveMatrixActionLimit(opts.limit, 20);
109
+ const token = normalizeOptionalString(opts.before) ?? normalizeOptionalString(opts.after);
110
+ const dir = opts.after ? "f" : "b";
111
+ const res = await client.doRequest("GET", `/_matrix/client/v3/rooms/${encodeURIComponent(resolvedRoom)}/messages`, {
112
+ dir,
113
+ limit,
114
+ from: token
115
+ });
116
+ const hydratedChunk = await client.hydrateEvents(resolvedRoom, res.chunk);
117
+ const seenPollRoots = /* @__PURE__ */ new Set();
118
+ const messages = [];
119
+ for (const event of hydratedChunk) {
120
+ if (event.unsigned?.redacted_because) continue;
121
+ if (event.type === EventType.RoomMessage) {
122
+ messages.push(summarizeMatrixRawEvent(event));
123
+ continue;
124
+ }
125
+ if (!isPollEventType(event.type)) continue;
126
+ const pollRootId = resolveMatrixPollRootEventId(event);
127
+ if (!pollRootId || seenPollRoots.has(pollRootId)) continue;
128
+ seenPollRoots.add(pollRootId);
129
+ const pollSummary = await fetchMatrixPollMessageSummary(client, resolvedRoom, event);
130
+ if (pollSummary) messages.push(pollSummary);
131
+ }
132
+ return {
133
+ messages,
134
+ nextBatch: res.end ?? null,
135
+ prevBatch: res.start ?? null
136
+ };
137
+ });
138
+ }
139
+ //#endregion
140
+ export { fetchEventSummary as a, resolveMatrixActionLimit as c, sendMatrixMessage as i, editMatrixMessage as n, readPinnedEvents as o, readMatrixMessages as r, EventType as s, deleteMatrixMessage as t };
@@ -0,0 +1,69 @@
1
+ import fs from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { resolveRequiredHomeDir, resolveStateDir } from "openclaw/plugin-sdk/state-paths";
5
+ import { writeJsonFileAtomically } from "openclaw/plugin-sdk/json-store";
6
+ //#region extensions/matrix/src/migration-snapshot-backup.ts
7
+ const MATRIX_MIGRATION_SNAPSHOT_DIRNAME = "openclaw-migrations";
8
+ function loadSnapshotMarker(filePath) {
9
+ try {
10
+ if (!fs.existsSync(filePath)) return null;
11
+ const parsed = JSON.parse(fs.readFileSync(filePath, "utf8"));
12
+ if (parsed.version !== 1 || typeof parsed.createdAt !== "string" || typeof parsed.archivePath !== "string" || typeof parsed.trigger !== "string") return null;
13
+ return {
14
+ version: 1,
15
+ createdAt: parsed.createdAt,
16
+ archivePath: parsed.archivePath,
17
+ trigger: parsed.trigger,
18
+ includeWorkspace: parsed.includeWorkspace === true
19
+ };
20
+ } catch {
21
+ return null;
22
+ }
23
+ }
24
+ function resolveMatrixMigrationSnapshotMarkerPath(env = process.env) {
25
+ const stateDir = resolveStateDir(env, os.homedir);
26
+ return path.join(stateDir, "matrix", "migration-snapshot.json");
27
+ }
28
+ function resolveMatrixMigrationSnapshotOutputDir(env = process.env) {
29
+ const homeDir = resolveRequiredHomeDir(env, os.homedir);
30
+ return path.join(homeDir, "Backups", MATRIX_MIGRATION_SNAPSHOT_DIRNAME);
31
+ }
32
+ async function maybeCreateMatrixMigrationSnapshot(params) {
33
+ const env = params.env ?? process.env;
34
+ const createBackupArchive = params.createBackupArchive ?? (await import("openclaw/plugin-sdk/runtime")).createBackupArchive;
35
+ const markerPath = resolveMatrixMigrationSnapshotMarkerPath(env);
36
+ const existingMarker = loadSnapshotMarker(markerPath);
37
+ if (existingMarker?.archivePath && fs.existsSync(existingMarker.archivePath)) {
38
+ params.log?.info?.(`matrix: reusing existing pre-migration backup snapshot: ${existingMarker.archivePath}`);
39
+ return {
40
+ created: false,
41
+ archivePath: existingMarker.archivePath,
42
+ markerPath
43
+ };
44
+ }
45
+ if (existingMarker?.archivePath && !fs.existsSync(existingMarker.archivePath)) params.log?.warn?.(`matrix: previous migration snapshot is missing (${existingMarker.archivePath}); creating a replacement backup before continuing`);
46
+ const snapshot = await createBackupArchive({
47
+ output: (() => {
48
+ const outputDir = params.outputDir ?? resolveMatrixMigrationSnapshotOutputDir(env);
49
+ fs.mkdirSync(outputDir, { recursive: true });
50
+ return outputDir;
51
+ })(),
52
+ includeWorkspace: false
53
+ });
54
+ await writeJsonFileAtomically(markerPath, {
55
+ version: 1,
56
+ createdAt: snapshot.createdAt,
57
+ archivePath: snapshot.archivePath,
58
+ trigger: params.trigger,
59
+ includeWorkspace: snapshot.includeWorkspace
60
+ });
61
+ params.log?.info?.(`matrix: created pre-migration backup snapshot: ${snapshot.archivePath}`);
62
+ return {
63
+ created: true,
64
+ archivePath: snapshot.archivePath,
65
+ markerPath
66
+ };
67
+ }
68
+ //#endregion
69
+ export { maybeCreateMatrixMigrationSnapshot as t };
@@ -0,0 +1,2 @@
1
+ import { t as maybeCreateMatrixMigrationSnapshot } from "./migration-snapshot-backup-DaCHTp8C.js";
2
+ export { maybeCreateMatrixMigrationSnapshot };