@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,77 @@
1
+ import { a as resolveMatrixTargetIdentity, i as resolveMatrixDirectUserId } from "./target-ids-80nQ2gql.js";
2
+ import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
3
+ import { addAllowlistUserEntriesFromConfigEntry, buildAllowlistResolutionSummary, canonicalizeAllowlistWithResolvedIds, formatAllowlistMatchMeta, patchAllowlistUsersInConfigEntries, summarizeMapping } from "openclaw/plugin-sdk/allow-from";
4
+ import { createReplyPrefixOptions, createTypingCallbacks } from "openclaw/plugin-sdk/channel-reply-options-runtime";
5
+ import { formatLocationText, toLocationContext } from "openclaw/plugin-sdk/channel-location";
6
+ import { getAgentScopedMediaLocalRoots } from "openclaw/plugin-sdk/agent-media-payload";
7
+ import { logInboundDrop, logTypingFailure } from "openclaw/plugin-sdk/channel-logging";
8
+ import { buildChannelKeyCandidates, resolveChannelEntryMatch } from "openclaw/plugin-sdk/channel-targets";
9
+ //#region extensions/matrix/src/matrix/monitor/rooms.ts
10
+ function readLegacyRoomAllowAlias(room) {
11
+ const rawRoom = room;
12
+ return typeof rawRoom?.allow === "boolean" ? rawRoom.allow : void 0;
13
+ }
14
+ function resolveMatrixRoomConfig(params) {
15
+ const rooms = params.rooms ?? {};
16
+ const allowlistConfigured = Object.keys(rooms).length > 0;
17
+ const { entry: matched, key: matchedKey, wildcardEntry, wildcardKey } = resolveChannelEntryMatch({
18
+ entries: rooms,
19
+ keys: buildChannelKeyCandidates(params.roomId, `room:${params.roomId}`, ...params.aliases),
20
+ wildcardKey: "*"
21
+ });
22
+ const resolved = matched ?? wildcardEntry;
23
+ const legacyAllow = readLegacyRoomAllowAlias(resolved);
24
+ return {
25
+ allowed: resolved ? resolved.enabled !== false && legacyAllow !== false : false,
26
+ allowlistConfigured,
27
+ config: resolved,
28
+ matchKey: matchedKey ?? wildcardKey,
29
+ matchSource: matched ? "direct" : wildcardEntry ? "wildcard" : void 0
30
+ };
31
+ }
32
+ //#endregion
33
+ //#region extensions/matrix/src/matrix/session-store-metadata.ts
34
+ function trimMaybeString(value) {
35
+ if (typeof value !== "string") return;
36
+ const trimmed = value.trim();
37
+ return trimmed.length > 0 ? trimmed : void 0;
38
+ }
39
+ function resolveMatrixRoomTargetId(value) {
40
+ const trimmed = trimMaybeString(value);
41
+ if (!trimmed) return;
42
+ const target = resolveMatrixTargetIdentity(trimmed);
43
+ return target?.kind === "room" && target.id.startsWith("!") ? target.id : void 0;
44
+ }
45
+ function resolveMatrixSessionAccountId(value) {
46
+ const trimmed = trimMaybeString(value);
47
+ return trimmed ? normalizeAccountId(trimmed) : void 0;
48
+ }
49
+ function resolveMatrixStoredRoomId(params) {
50
+ return resolveMatrixRoomTargetId(params.deliveryTo) ?? resolveMatrixRoomTargetId(params.lastTo) ?? resolveMatrixRoomTargetId(params.originNativeChannelId) ?? resolveMatrixRoomTargetId(params.originTo);
51
+ }
52
+ function resolveMatrixStoredSessionMeta(entry) {
53
+ if (!entry) return null;
54
+ const channel = trimMaybeString(entry.deliveryContext?.channel) ?? trimMaybeString(entry.lastChannel) ?? trimMaybeString(entry.origin?.provider);
55
+ const accountId = resolveMatrixSessionAccountId(entry.deliveryContext?.accountId ?? entry.lastAccountId ?? entry.origin?.accountId) ?? void 0;
56
+ const roomId = resolveMatrixStoredRoomId({
57
+ deliveryTo: entry.deliveryContext?.to,
58
+ lastTo: entry.lastTo,
59
+ originNativeChannelId: entry.origin?.nativeChannelId,
60
+ originTo: entry.origin?.to
61
+ });
62
+ const chatType = trimMaybeString(entry.origin?.chatType) ?? trimMaybeString(entry.chatType) ?? void 0;
63
+ const directUserId = chatType === "direct" ? trimMaybeString(entry.origin?.nativeDirectUserId) ?? resolveMatrixDirectUserId({
64
+ from: trimMaybeString(entry.origin?.from),
65
+ to: (roomId ? `room:${roomId}` : void 0) ?? trimMaybeString(entry.deliveryContext?.to) ?? trimMaybeString(entry.lastTo) ?? trimMaybeString(entry.origin?.to),
66
+ chatType
67
+ }) : void 0;
68
+ if (!channel && !accountId && !roomId && !directUserId) return null;
69
+ return {
70
+ ...channel ? { channel } : {},
71
+ ...accountId ? { accountId } : {},
72
+ ...roomId ? { roomId } : {},
73
+ ...directUserId ? { directUserId } : {}
74
+ };
75
+ }
76
+ //#endregion
77
+ export { canonicalizeAllowlistWithResolvedIds as a, formatAllowlistMatchMeta as c, logInboundDrop as d, logTypingFailure as f, toLocationContext as h, buildAllowlistResolutionSummary as i, formatLocationText as l, summarizeMapping as m, resolveMatrixRoomConfig as n, createReplyPrefixOptions as o, patchAllowlistUsersInConfigEntries as p, addAllowlistUserEntriesFromConfigEntry as r, createTypingCallbacks as s, resolveMatrixStoredSessionMeta as t, getAgentScopedMediaLocalRoots as u };
@@ -0,0 +1,62 @@
1
+ import { a as resolveMatrixAccountConfig, n as hasExplicitMatrixAccountConfig } from "./account-config-D2W-V1eQ.js";
2
+ import "./accounts-Bm90Rzvp.js";
3
+ import { t as formatMatrixErrorMessage } from "./errors-CTcpEDq-.js";
4
+ import { n as bootstrapMatrixVerification } from "./verification-CZ2rDeHL.js";
5
+ //#region extensions/matrix/src/setup-bootstrap.ts
6
+ async function maybeBootstrapNewEncryptedMatrixAccount(params) {
7
+ const accountConfig = resolveMatrixAccountConfig({
8
+ cfg: params.cfg,
9
+ accountId: params.accountId
10
+ });
11
+ const previousAccountConfig = resolveMatrixAccountConfig({
12
+ cfg: params.previousCfg,
13
+ accountId: params.accountId
14
+ });
15
+ if (accountConfig.encryption !== true || hasExplicitMatrixAccountConfig(params.previousCfg, params.accountId) && previousAccountConfig.encryption === true) return {
16
+ attempted: false,
17
+ success: false,
18
+ recoveryKeyCreatedAt: null,
19
+ backupVersion: null
20
+ };
21
+ try {
22
+ const bootstrap = await bootstrapMatrixVerification({
23
+ accountId: params.accountId,
24
+ cfg: params.cfg
25
+ });
26
+ return {
27
+ attempted: true,
28
+ success: bootstrap.success,
29
+ recoveryKeyCreatedAt: bootstrap.verification.recoveryKeyCreatedAt,
30
+ backupVersion: bootstrap.verification.backupVersion,
31
+ ...bootstrap.success ? {} : { error: bootstrap.error ?? "Matrix verification bootstrap failed" }
32
+ };
33
+ } catch (err) {
34
+ return {
35
+ attempted: true,
36
+ success: false,
37
+ recoveryKeyCreatedAt: null,
38
+ backupVersion: null,
39
+ error: formatMatrixErrorMessage(err)
40
+ };
41
+ }
42
+ }
43
+ async function runMatrixSetupBootstrapAfterConfigWrite(params) {
44
+ if (resolveMatrixAccountConfig({
45
+ cfg: params.cfg,
46
+ accountId: params.accountId
47
+ }).encryption !== true) return;
48
+ const bootstrap = await maybeBootstrapNewEncryptedMatrixAccount({
49
+ previousCfg: params.previousCfg,
50
+ cfg: params.cfg,
51
+ accountId: params.accountId
52
+ });
53
+ if (!bootstrap.attempted) return;
54
+ if (bootstrap.success) {
55
+ params.runtime.log(`Matrix verification bootstrap: complete for "${params.accountId}".`);
56
+ if (bootstrap.backupVersion) params.runtime.log(`Matrix backup version for "${params.accountId}": ${bootstrap.backupVersion}`);
57
+ return;
58
+ }
59
+ params.runtime.error(`Matrix verification bootstrap warning for "${params.accountId}": ${bootstrap.error ?? "unknown bootstrap failure"}`);
60
+ }
61
+ //#endregion
62
+ export { maybeBootstrapNewEncryptedMatrixAccount, runMatrixSetupBootstrapAfterConfigWrite };
@@ -0,0 +1,116 @@
1
+ import { a as resolveMatrixAccountConfig } from "./account-config-D2W-V1eQ.js";
2
+ import { r as resolveDefaultMatrixAccountId } from "./accounts-Bm90Rzvp.js";
3
+ import { i as validateMatrixSetupInput, n as applyMatrixSetupAccountConfig, t as resolveMatrixSetupDmAllowFrom } from "./setup-dm-policy-2-r1FrQh.js";
4
+ import { t as resolveMatrixConfigFieldPath } from "./config-paths-nsVaysCu.js";
5
+ import { r as updateMatrixAccountConfig } from "./config-update-wZX-HLMn.js";
6
+ import { DEFAULT_ACCOUNT_ID, normalizeAccountId, prepareScopedSetupConfig } from "openclaw/plugin-sdk/setup";
7
+ //#region extensions/matrix/src/setup-core.ts
8
+ const channel = "matrix";
9
+ function resolveMatrixSetupAccountId(params) {
10
+ return normalizeAccountId(params.accountId?.trim() || params.name?.trim() || DEFAULT_ACCOUNT_ID);
11
+ }
12
+ function resolveMatrixSetupWizardAccountId(cfg, accountId) {
13
+ return normalizeAccountId(accountId?.trim() || resolveDefaultMatrixAccountId(cfg) || DEFAULT_ACCOUNT_ID);
14
+ }
15
+ function setMatrixDmPolicy(cfg, policy, accountId) {
16
+ const resolvedAccountId = resolveMatrixSetupWizardAccountId(cfg, accountId);
17
+ const existing = resolveMatrixAccountConfig({
18
+ cfg,
19
+ accountId: resolvedAccountId
20
+ });
21
+ const allowFrom = resolveMatrixSetupDmAllowFrom(policy, existing.dm?.allowFrom);
22
+ return updateMatrixAccountConfig(cfg, resolvedAccountId, { dm: {
23
+ ...existing.dm,
24
+ policy,
25
+ allowFrom
26
+ } });
27
+ }
28
+ function createMatrixSetupWizardProxy(loadWizardModule) {
29
+ let wizardPromise = null;
30
+ const loadWizard = () => {
31
+ wizardPromise ??= loadWizardModule().then((module) => module.matrixSetupWizard);
32
+ return wizardPromise;
33
+ };
34
+ return {
35
+ channel,
36
+ getStatus: async (ctx) => await (await loadWizard()).getStatus(ctx),
37
+ configure: async (ctx) => await (await loadWizard()).configure(ctx),
38
+ configureInteractive: async (ctx) => {
39
+ const wizard = await loadWizard();
40
+ return await (wizard.configureInteractive ?? wizard.configure)(ctx);
41
+ },
42
+ configureWhenConfigured: async (ctx) => {
43
+ const wizard = await loadWizard();
44
+ return await (wizard.configureWhenConfigured ?? wizard.configureInteractive ?? wizard.configure)(ctx);
45
+ },
46
+ afterConfigWritten: async (ctx) => await (await loadWizard()).afterConfigWritten?.(ctx),
47
+ dmPolicy: {
48
+ label: "Matrix",
49
+ channel,
50
+ policyKey: "channels.matrix.dm.policy",
51
+ allowFromKey: "channels.matrix.dm.allowFrom",
52
+ resolveConfigKeys: (cfg, accountId) => {
53
+ const resolvedAccountId = resolveMatrixSetupWizardAccountId(cfg, accountId);
54
+ return {
55
+ policyKey: resolveMatrixConfigFieldPath(cfg, resolvedAccountId, "dm.policy"),
56
+ allowFromKey: resolveMatrixConfigFieldPath(cfg, resolvedAccountId, "dm.allowFrom")
57
+ };
58
+ },
59
+ getCurrent: (cfg, accountId) => resolveMatrixAccountConfig({
60
+ cfg,
61
+ accountId: resolveMatrixSetupWizardAccountId(cfg, accountId)
62
+ }).dm?.policy ?? "pairing",
63
+ setPolicy: (cfg, policy, accountId) => setMatrixDmPolicy(cfg, policy, accountId),
64
+ promptAllowFrom: async (params) => {
65
+ const promptAllowFrom = (await loadWizard()).dmPolicy?.promptAllowFrom;
66
+ return promptAllowFrom ? await promptAllowFrom(params) : params.cfg;
67
+ }
68
+ },
69
+ disable: (cfg) => ({
70
+ ...cfg,
71
+ channels: {
72
+ ...cfg.channels,
73
+ matrix: {
74
+ ...cfg.channels?.matrix,
75
+ enabled: false
76
+ }
77
+ }
78
+ })
79
+ };
80
+ }
81
+ const matrixSetupAdapter = {
82
+ resolveAccountId: ({ accountId, input }) => resolveMatrixSetupAccountId({
83
+ accountId,
84
+ name: input?.name
85
+ }),
86
+ resolveBindingAccountId: ({ accountId, agentId }) => resolveMatrixSetupAccountId({
87
+ accountId,
88
+ name: agentId
89
+ }),
90
+ applyAccountName: ({ cfg, accountId, name }) => prepareScopedSetupConfig({
91
+ cfg,
92
+ channelKey: channel,
93
+ accountId,
94
+ name
95
+ }),
96
+ validateInput: ({ accountId, input }) => validateMatrixSetupInput({
97
+ accountId,
98
+ input
99
+ }),
100
+ applyAccountConfig: ({ cfg, accountId, input }) => applyMatrixSetupAccountConfig({
101
+ cfg,
102
+ accountId,
103
+ input
104
+ }),
105
+ afterAccountConfigWritten: async ({ previousCfg, cfg, accountId, runtime }) => {
106
+ const { runMatrixSetupBootstrapAfterConfigWrite } = await import("./setup-bootstrap-ImenBsMt.js");
107
+ await runMatrixSetupBootstrapAfterConfigWrite({
108
+ previousCfg,
109
+ cfg,
110
+ accountId,
111
+ runtime
112
+ });
113
+ }
114
+ };
115
+ //#endregion
116
+ export { matrixSetupAdapter as n, createMatrixSetupWizardProxy as t };
@@ -0,0 +1,194 @@
1
+ import { r as resolveMatrixEnvAuthReadiness } from "./env-auth-BJqGI8M6.js";
2
+ import { r as updateMatrixAccountConfig } from "./config-update-wZX-HLMn.js";
3
+ import { t as isSupportedMatrixAvatarSource } from "./profile-BlHu0wDX.js";
4
+ import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
5
+ import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/routing";
6
+ import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1, addWildcardAllowFrom, applyAccountNameToChannelSection, normalizeAccountId as normalizeAccountId$1, normalizeAllowFromEntries, normalizeSecretInputString } from "openclaw/plugin-sdk/setup";
7
+ //#region extensions/matrix/src/setup-contract.ts
8
+ const matrixSingleAccountKeysToMove = [
9
+ "deviceId",
10
+ "avatarUrl",
11
+ "initialSyncLimit",
12
+ "encryption",
13
+ "allowlistOnly",
14
+ "allowBots",
15
+ "blockStreaming",
16
+ "replyToMode",
17
+ "threadReplies",
18
+ "textChunkLimit",
19
+ "chunkMode",
20
+ "responsePrefix",
21
+ "ackReaction",
22
+ "ackReactionScope",
23
+ "reactionNotifications",
24
+ "threadBindings",
25
+ "startupVerification",
26
+ "startupVerificationCooldownHours",
27
+ "mediaMaxMb",
28
+ "autoJoin",
29
+ "autoJoinAllowlist",
30
+ "dm",
31
+ "groups",
32
+ "rooms",
33
+ "actions"
34
+ ];
35
+ const matrixNamedAccountPromotionKeys = [
36
+ "name",
37
+ "homeserver",
38
+ "userId",
39
+ "accessToken",
40
+ "password",
41
+ "deviceId",
42
+ "deviceName",
43
+ "avatarUrl",
44
+ "initialSyncLimit",
45
+ "encryption"
46
+ ];
47
+ const singleAccountKeysToMove = [...matrixSingleAccountKeysToMove];
48
+ const namedAccountPromotionKeys = [...matrixNamedAccountPromotionKeys];
49
+ function resolveSingleAccountPromotionTarget(params) {
50
+ const accounts = typeof params.channel.accounts === "object" && params.channel.accounts ? params.channel.accounts : {};
51
+ const normalizedDefaultAccount = typeof params.channel.defaultAccount === "string" && params.channel.defaultAccount.trim() ? normalizeAccountId(params.channel.defaultAccount) : void 0;
52
+ const matchedAccountId = normalizedDefaultAccount ? Object.entries(accounts).find(([accountId, value]) => accountId && value && typeof value === "object" && normalizeAccountId(accountId) === normalizedDefaultAccount)?.[0] : void 0;
53
+ if (matchedAccountId) return matchedAccountId;
54
+ if (normalizedDefaultAccount) return DEFAULT_ACCOUNT_ID;
55
+ const namedAccounts = Object.entries(accounts).filter(([accountId, value]) => accountId && typeof value === "object" && value);
56
+ if (namedAccounts.length === 1) return namedAccounts[0][0];
57
+ if (namedAccounts.length > 1 && accounts[DEFAULT_ACCOUNT_ID] && typeof accounts[DEFAULT_ACCOUNT_ID] === "object") return DEFAULT_ACCOUNT_ID;
58
+ return DEFAULT_ACCOUNT_ID;
59
+ }
60
+ //#endregion
61
+ //#region extensions/matrix/src/setup-config.ts
62
+ const channel = "matrix";
63
+ const COMMON_SINGLE_ACCOUNT_KEYS_TO_MOVE = new Set([
64
+ "name",
65
+ "enabled",
66
+ "httpPort",
67
+ "webhookPath",
68
+ "webhookUrl",
69
+ "webhookSecret",
70
+ "service",
71
+ "region",
72
+ "homeserver",
73
+ "userId",
74
+ "accessToken",
75
+ "password",
76
+ "deviceName",
77
+ "url",
78
+ "code",
79
+ "dmPolicy",
80
+ "allowFrom",
81
+ "groupPolicy",
82
+ "groupAllowFrom",
83
+ "defaultTo"
84
+ ]);
85
+ const MATRIX_SINGLE_ACCOUNT_KEYS_TO_MOVE = new Set(matrixSingleAccountKeysToMove);
86
+ const MATRIX_NAMED_ACCOUNT_PROMOTION_KEYS = new Set(matrixNamedAccountPromotionKeys);
87
+ function cloneIfObject(value) {
88
+ if (value && typeof value === "object") return structuredClone(value);
89
+ return value;
90
+ }
91
+ function resolveSetupAvatarUrl(input) {
92
+ const avatarUrl = input.avatarUrl;
93
+ if (typeof avatarUrl !== "string") return;
94
+ return avatarUrl.trim() || void 0;
95
+ }
96
+ function resolveExistingMatrixAccountKey(accounts, targetAccountId) {
97
+ const normalizedTargetAccountId = normalizeAccountId$1(targetAccountId);
98
+ return Object.keys(accounts).find((accountId) => normalizeAccountId$1(accountId) === normalizedTargetAccountId) ?? targetAccountId;
99
+ }
100
+ function moveSingleMatrixAccountConfigToNamedAccount(cfg) {
101
+ const baseConfig = cfg.channels?.[channel];
102
+ const base = typeof baseConfig === "object" && baseConfig ? baseConfig : void 0;
103
+ if (!base) return cfg;
104
+ const accounts = typeof base.accounts === "object" && base.accounts ? base.accounts : {};
105
+ const hasNamedAccounts = Object.keys(accounts).some(Boolean);
106
+ const keysToMove = Object.entries(base).filter(([key, value]) => {
107
+ if (key === "accounts" || key === "enabled" || value === void 0) return false;
108
+ if (!COMMON_SINGLE_ACCOUNT_KEYS_TO_MOVE.has(key) && !MATRIX_SINGLE_ACCOUNT_KEYS_TO_MOVE.has(key)) return false;
109
+ if (hasNamedAccounts && !MATRIX_NAMED_ACCOUNT_PROMOTION_KEYS.has(key)) return false;
110
+ return true;
111
+ }).map(([key]) => key);
112
+ if (keysToMove.length === 0) return cfg;
113
+ const resolvedTargetAccountId = resolveExistingMatrixAccountKey(accounts, resolveSingleAccountPromotionTarget({ channel: base }));
114
+ const nextAccount = { ...accounts[resolvedTargetAccountId] };
115
+ for (const key of keysToMove) nextAccount[key] = cloneIfObject(base[key]);
116
+ const nextChannel = { ...base };
117
+ for (const key of keysToMove) delete nextChannel[key];
118
+ return {
119
+ ...cfg,
120
+ channels: {
121
+ ...cfg.channels,
122
+ [channel]: {
123
+ ...nextChannel,
124
+ accounts: {
125
+ ...accounts,
126
+ [resolvedTargetAccountId]: nextAccount
127
+ }
128
+ }
129
+ }
130
+ };
131
+ }
132
+ function validateMatrixSetupInput(params) {
133
+ const avatarUrl = resolveSetupAvatarUrl(params.input);
134
+ if (avatarUrl && !isSupportedMatrixAvatarSource(avatarUrl)) return "Matrix avatar URL must be an mxc:// URI or an http(s) URL.";
135
+ if (params.input.useEnv) {
136
+ const envReadiness = resolveMatrixEnvAuthReadiness(params.accountId, process.env);
137
+ return envReadiness.ready ? null : envReadiness.missingMessage;
138
+ }
139
+ if (!params.input.homeserver?.trim()) return "Matrix requires --homeserver";
140
+ const accessToken = params.input.accessToken?.trim();
141
+ const password = normalizeSecretInputString(params.input.password);
142
+ const userId = params.input.userId?.trim();
143
+ if (!accessToken && !password) return "Matrix requires --access-token or --password";
144
+ if (!accessToken) {
145
+ if (!userId) return "Matrix requires --user-id when using --password";
146
+ if (!password) return "Matrix requires --password when using --user-id";
147
+ }
148
+ return null;
149
+ }
150
+ function applyMatrixSetupAccountConfig(params) {
151
+ const normalizedAccountId = normalizeAccountId$1(params.accountId);
152
+ const next = applyAccountNameToChannelSection({
153
+ cfg: normalizedAccountId !== DEFAULT_ACCOUNT_ID$1 ? moveSingleMatrixAccountConfigToNamedAccount(params.cfg) : params.cfg,
154
+ channelKey: channel,
155
+ accountId: normalizedAccountId,
156
+ name: params.input.name
157
+ });
158
+ const avatarUrl = resolveSetupAvatarUrl(params.input);
159
+ if (params.input.useEnv) return updateMatrixAccountConfig(next, normalizedAccountId, {
160
+ enabled: true,
161
+ homeserver: null,
162
+ allowPrivateNetwork: null,
163
+ proxy: null,
164
+ userId: null,
165
+ accessToken: null,
166
+ password: null,
167
+ deviceId: null,
168
+ deviceName: null,
169
+ avatarUrl
170
+ });
171
+ const accessToken = params.input.accessToken?.trim();
172
+ const password = normalizeSecretInputString(params.input.password);
173
+ const userId = params.input.userId?.trim();
174
+ return updateMatrixAccountConfig(next, normalizedAccountId, {
175
+ enabled: true,
176
+ homeserver: params.input.homeserver?.trim(),
177
+ allowPrivateNetwork: typeof params.input.dangerouslyAllowPrivateNetwork === "boolean" ? params.input.dangerouslyAllowPrivateNetwork : typeof params.input.allowPrivateNetwork === "boolean" ? params.input.allowPrivateNetwork : void 0,
178
+ proxy: normalizeOptionalString(params.input.proxy),
179
+ userId: password && !userId ? null : userId,
180
+ accessToken: accessToken || (password ? null : void 0),
181
+ password: password || (accessToken ? null : void 0),
182
+ deviceName: params.input.deviceName?.trim(),
183
+ avatarUrl,
184
+ initialSyncLimit: params.input.initialSyncLimit
185
+ });
186
+ }
187
+ //#endregion
188
+ //#region extensions/matrix/src/setup-dm-policy.ts
189
+ function resolveMatrixSetupDmAllowFrom(policy, allowFrom) {
190
+ if (policy === "open") return addWildcardAllowFrom(allowFrom);
191
+ return normalizeAllowFromEntries(allowFrom ?? []).filter((entry) => entry !== "*");
192
+ }
193
+ //#endregion
194
+ export { namedAccountPromotionKeys as a, validateMatrixSetupInput as i, applyMatrixSetupAccountConfig as n, resolveSingleAccountPromotionTarget as o, moveSingleMatrixAccountConfigToNamedAccount as r, singleAccountKeysToMove as s, resolveMatrixSetupDmAllowFrom as t };
@@ -0,0 +1,19 @@
1
+ import { defineBundledChannelSetupEntry } from "openclaw/plugin-sdk/channel-entry-contract";
2
+ //#region extensions/matrix/setup-entry.ts
3
+ var setup_entry_default = defineBundledChannelSetupEntry({
4
+ importMetaUrl: import.meta.url,
5
+ plugin: {
6
+ specifier: "./setup-plugin-api.js",
7
+ exportName: "matrixSetupPlugin"
8
+ },
9
+ secrets: {
10
+ specifier: "./secret-contract-api.js",
11
+ exportName: "channelSecrets"
12
+ },
13
+ runtime: {
14
+ specifier: "./runtime-setter-api.js",
15
+ exportName: "setMatrixRuntime"
16
+ }
17
+ });
18
+ //#endregion
19
+ export { setup_entry_default as default };
@@ -0,0 +1,44 @@
1
+ import { i as resolveMatrixAccount } from "./accounts-Bm90Rzvp.js";
2
+ import { r as matrixConfigAdapter, t as MatrixChannelConfigSchema } from "./config-schema-nPLpEgHl.js";
3
+ import { n as matrixSetupAdapter, t as createMatrixSetupWizardProxy } from "./setup-core-CfZy05oW.js";
4
+ import { describeAccountSnapshot } from "openclaw/plugin-sdk/account-helpers";
5
+ const matrixSetupPlugin = {
6
+ id: "matrix",
7
+ meta: {
8
+ id: "matrix",
9
+ label: "Matrix",
10
+ selectionLabel: "Matrix (plugin)",
11
+ docsPath: "/channels/matrix",
12
+ docsLabel: "matrix",
13
+ blurb: "open protocol; configure a homeserver + access token.",
14
+ order: 70,
15
+ quickstartAllowFrom: true
16
+ },
17
+ setupWizard: createMatrixSetupWizardProxy(async () => ({ matrixSetupWizard: (await import("./setup-surface-CqT_o61M.js").then((n) => n.t)).matrixSetupWizard })),
18
+ setup: matrixSetupAdapter,
19
+ capabilities: {
20
+ chatTypes: [
21
+ "direct",
22
+ "group",
23
+ "thread"
24
+ ],
25
+ polls: true,
26
+ reactions: true,
27
+ threads: true,
28
+ media: true
29
+ },
30
+ reload: { configPrefixes: ["channels.matrix"] },
31
+ configSchema: MatrixChannelConfigSchema,
32
+ config: {
33
+ ...matrixConfigAdapter,
34
+ isConfigured: (account) => account.configured,
35
+ describeAccount: (account) => describeAccountSnapshot({
36
+ account,
37
+ configured: account.configured,
38
+ extra: { baseUrl: account.homeserver }
39
+ }),
40
+ hasConfiguredState: ({ cfg }) => resolveMatrixAccount({ cfg }).configured
41
+ }
42
+ };
43
+ //#endregion
44
+ export { matrixSetupPlugin };