@openclaw/matrix 2026.3.12 → 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 (205) 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 -98
  114. package/index.ts +0 -22
  115. package/src/actions.ts +0 -195
  116. package/src/channel.directory.test.ts +0 -154
  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 -100
  160. package/src/matrix/monitor/auto-join.ts +0 -72
  161. package/src/matrix/monitor/direct.test.ts +0 -400
  162. package/src/matrix/monitor/direct.ts +0 -152
  163. package/src/matrix/monitor/events.test.ts +0 -172
  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 -767
  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 -154
  194. package/src/matrix/send-queue.ts +0 -28
  195. package/src/matrix/send.test.ts +0 -326
  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 -67
  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/tool-actions.ts +0 -164
  205. package/src/types.ts +0 -118
@@ -0,0 +1,96 @@
1
+ import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
2
+ import { hasConfiguredSecretInput } from "openclaw/plugin-sdk/secret-input-runtime";
3
+ import { listConfiguredAccountIds, resolveMergedAccountConfig, resolveNormalizedAccountEntry } from "openclaw/plugin-sdk/account-resolution-runtime";
4
+ //#region extensions/matrix/src/matrix/account-config.ts
5
+ function resolveMatrixBaseConfig(cfg) {
6
+ return cfg.channels?.matrix ?? {};
7
+ }
8
+ function resolveMatrixAccountsMap(cfg) {
9
+ const accounts = resolveMatrixBaseConfig(cfg).accounts;
10
+ if (!accounts || typeof accounts !== "object") return {};
11
+ return accounts;
12
+ }
13
+ function selectInheritedMatrixRoomEntries(params) {
14
+ const entries = params.entries;
15
+ if (!entries) return;
16
+ const selected = Object.fromEntries(Object.entries(entries).filter(([, value]) => {
17
+ const scopedAccount = typeof value?.account === "string" ? normalizeAccountId(value.account) : void 0;
18
+ return scopedAccount === void 0 || scopedAccount === params.accountId;
19
+ }));
20
+ return Object.keys(selected).length > 0 ? selected : void 0;
21
+ }
22
+ function mergeMatrixRoomEntries(inherited, accountEntries, hasAccountOverride) {
23
+ if (!inherited && !accountEntries) return;
24
+ if (hasAccountOverride && Object.keys(accountEntries ?? {}).length === 0) return;
25
+ const merged = { ...inherited };
26
+ for (const [key, value] of Object.entries(accountEntries ?? {})) {
27
+ const inheritedValue = merged[key];
28
+ merged[key] = inheritedValue && value ? {
29
+ ...inheritedValue,
30
+ ...value
31
+ } : value ?? inheritedValue;
32
+ }
33
+ return Object.keys(merged).length > 0 ? merged : void 0;
34
+ }
35
+ function listNormalizedMatrixAccountIds(cfg) {
36
+ return listConfiguredAccountIds({
37
+ accounts: resolveMatrixAccountsMap(cfg),
38
+ normalizeAccountId
39
+ });
40
+ }
41
+ function findMatrixAccountConfig(cfg, accountId) {
42
+ return resolveNormalizedAccountEntry(resolveMatrixAccountsMap(cfg), accountId, normalizeAccountId);
43
+ }
44
+ function hasExplicitMatrixAccountConfig(cfg, accountId) {
45
+ const normalized = normalizeAccountId(accountId);
46
+ if (findMatrixAccountConfig(cfg, normalized)) return true;
47
+ if (normalized !== DEFAULT_ACCOUNT_ID) return false;
48
+ const matrix = resolveMatrixBaseConfig(cfg);
49
+ return typeof matrix.enabled === "boolean" || typeof matrix.name === "string" || typeof matrix.homeserver === "string" || typeof matrix.userId === "string" || hasConfiguredSecretInput(matrix.accessToken) || hasConfiguredSecretInput(matrix.password) || typeof matrix.deviceId === "string" || typeof matrix.deviceName === "string" || typeof matrix.avatarUrl === "string";
50
+ }
51
+ function resolveMatrixAccountConfig(params) {
52
+ const accountId = normalizeAccountId(params.accountId);
53
+ const base = resolveMatrixBaseConfig(params.cfg);
54
+ const merged = resolveMergedAccountConfig({
55
+ channelConfig: base,
56
+ accounts: params.cfg.channels?.matrix?.accounts,
57
+ accountId,
58
+ normalizeAccountId,
59
+ nestedObjectKeys: [
60
+ "dm",
61
+ "actions",
62
+ "execApprovals"
63
+ ]
64
+ });
65
+ const accountConfig = findMatrixAccountConfig(params.cfg, accountId);
66
+ const groups = mergeMatrixRoomEntries(selectInheritedMatrixRoomEntries({
67
+ entries: base.groups,
68
+ accountId
69
+ }), accountConfig?.groups, Boolean(accountConfig && Object.hasOwn(accountConfig, "groups")));
70
+ const rooms = mergeMatrixRoomEntries(selectInheritedMatrixRoomEntries({
71
+ entries: base.rooms,
72
+ accountId
73
+ }), accountConfig?.rooms, Boolean(accountConfig && Object.hasOwn(accountConfig, "rooms")));
74
+ const { groups: _ignoredGroups, rooms: _ignoredRooms, ...rest } = merged;
75
+ return {
76
+ ...rest,
77
+ ...groups ? { groups } : {},
78
+ ...rooms ? { rooms } : {}
79
+ };
80
+ }
81
+ function resolveMatrixAccountAllowlistConfig(params) {
82
+ const accountId = normalizeAccountId(params.accountId);
83
+ const base = resolveMatrixBaseConfig(params.cfg);
84
+ const accountConfig = findMatrixAccountConfig(params.cfg, accountId);
85
+ const accountDm = accountConfig?.dm;
86
+ let dmAllowFrom = base.dm?.allowFrom;
87
+ if (accountDm && Object.hasOwn(accountDm, "allowFrom")) dmAllowFrom = accountDm.allowFrom;
88
+ let groupAllowFrom = base.groupAllowFrom;
89
+ if (accountConfig && Object.hasOwn(accountConfig, "groupAllowFrom")) groupAllowFrom = accountConfig.groupAllowFrom;
90
+ return {
91
+ dmAllowFrom,
92
+ groupAllowFrom
93
+ };
94
+ }
95
+ //#endregion
96
+ export { resolveMatrixAccountConfig as a, resolveMatrixAccountAllowlistConfig as i, hasExplicitMatrixAccountConfig as n, resolveMatrixBaseConfig as o, listNormalizedMatrixAccountIds as r, findMatrixAccountConfig as t };
@@ -0,0 +1,158 @@
1
+ import { n as listMatrixEnvAccountIds, t as getMatrixScopedEnvVarNames } from "./env-vars-C7uQCTKn.js";
2
+ import { t as isRecord } from "./record-shared-CHWJCTWf.js";
3
+ import { DEFAULT_ACCOUNT_ID, normalizeAccountId, normalizeOptionalAccountId } from "openclaw/plugin-sdk/account-id";
4
+ import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
5
+ import { listCombinedAccountIds, listConfiguredAccountIds, resolveListedDefaultAccountId, resolveNormalizedAccountEntry } from "openclaw/plugin-sdk/account-core";
6
+ import { hasConfiguredSecretInput } from "openclaw/plugin-sdk/secret-input-runtime";
7
+ //#region extensions/matrix/src/auth-precedence.ts
8
+ const MATRIX_DEFAULT_ACCOUNT_AUTH_ONLY_FIELDS = new Set([
9
+ "userId",
10
+ "accessToken",
11
+ "password",
12
+ "deviceId"
13
+ ]);
14
+ function resolveMatrixStringSourceValue(value) {
15
+ return typeof value === "string" ? value : "";
16
+ }
17
+ function shouldAllowBaseAuthFallback(accountId, field) {
18
+ return normalizeAccountId(accountId) === DEFAULT_ACCOUNT_ID || !MATRIX_DEFAULT_ACCOUNT_AUTH_ONLY_FIELDS.has(field);
19
+ }
20
+ function resolveMatrixAccountStringValues(params) {
21
+ const fields = [
22
+ "homeserver",
23
+ "userId",
24
+ "accessToken",
25
+ "password",
26
+ "deviceId",
27
+ "deviceName"
28
+ ];
29
+ const resolved = {};
30
+ for (const field of fields) resolved[field] = resolveMatrixStringSourceValue(params.account?.[field]) || resolveMatrixStringSourceValue(params.scopedEnv?.[field]) || (shouldAllowBaseAuthFallback(params.accountId, field) ? resolveMatrixStringSourceValue(params.channel?.[field]) || resolveMatrixStringSourceValue(params.globalEnv?.[field]) : "");
31
+ return resolved;
32
+ }
33
+ //#endregion
34
+ //#region extensions/matrix/src/account-selection.ts
35
+ function readConfiguredMatrixString(value) {
36
+ return normalizeOptionalString(value) ?? "";
37
+ }
38
+ function readConfiguredMatrixSecretSource(value) {
39
+ return hasConfiguredSecretInput(value) ? "configured" : "";
40
+ }
41
+ function resolveMatrixChannelStringSources(entry) {
42
+ if (!entry) return {};
43
+ return {
44
+ homeserver: readConfiguredMatrixString(entry.homeserver),
45
+ userId: readConfiguredMatrixString(entry.userId),
46
+ accessToken: readConfiguredMatrixSecretSource(entry.accessToken),
47
+ password: readConfiguredMatrixSecretSource(entry.password),
48
+ deviceId: readConfiguredMatrixString(entry.deviceId),
49
+ deviceName: readConfiguredMatrixString(entry.deviceName)
50
+ };
51
+ }
52
+ function readEnvMatrixString(env, key) {
53
+ return normalizeOptionalString(env[key]) ?? "";
54
+ }
55
+ function resolveScopedMatrixEnvStringSources(accountId, env) {
56
+ const keys = getMatrixScopedEnvVarNames(accountId);
57
+ return {
58
+ homeserver: readEnvMatrixString(env, keys.homeserver),
59
+ userId: readEnvMatrixString(env, keys.userId),
60
+ accessToken: readEnvMatrixString(env, keys.accessToken),
61
+ password: readEnvMatrixString(env, keys.password),
62
+ deviceId: readEnvMatrixString(env, keys.deviceId),
63
+ deviceName: readEnvMatrixString(env, keys.deviceName)
64
+ };
65
+ }
66
+ function resolveGlobalMatrixEnvStringSources(env) {
67
+ return {
68
+ homeserver: readEnvMatrixString(env, "MATRIX_HOMESERVER"),
69
+ userId: readEnvMatrixString(env, "MATRIX_USER_ID"),
70
+ accessToken: readEnvMatrixString(env, "MATRIX_ACCESS_TOKEN"),
71
+ password: readEnvMatrixString(env, "MATRIX_PASSWORD"),
72
+ deviceId: readEnvMatrixString(env, "MATRIX_DEVICE_ID"),
73
+ deviceName: readEnvMatrixString(env, "MATRIX_DEVICE_NAME")
74
+ };
75
+ }
76
+ function hasUsableResolvedMatrixAuth(values) {
77
+ return Boolean(values.homeserver && (values.accessToken || values.userId));
78
+ }
79
+ function hasFreshResolvedMatrixAuth(values) {
80
+ return Boolean(values.homeserver && (values.accessToken || values.userId && values.password));
81
+ }
82
+ function resolveEffectiveMatrixAccountSources(params) {
83
+ const normalizedAccountId = normalizeAccountId(params.accountId);
84
+ return resolveMatrixAccountStringValues({
85
+ accountId: normalizedAccountId,
86
+ scopedEnv: resolveScopedMatrixEnvStringSources(normalizedAccountId, params.env),
87
+ channel: resolveMatrixChannelStringSources(params.channel),
88
+ globalEnv: resolveGlobalMatrixEnvStringSources(params.env)
89
+ });
90
+ }
91
+ function hasUsableEffectiveMatrixAccountSource(params) {
92
+ return hasUsableResolvedMatrixAuth(resolveEffectiveMatrixAccountSources(params));
93
+ }
94
+ function hasFreshEffectiveMatrixAccountSource(params) {
95
+ return hasFreshResolvedMatrixAuth(resolveEffectiveMatrixAccountSources(params));
96
+ }
97
+ function hasConfiguredDefaultMatrixAccountSource(params) {
98
+ return hasFreshEffectiveMatrixAccountSource({
99
+ channel: params.channel,
100
+ accountId: DEFAULT_ACCOUNT_ID,
101
+ env: params.env
102
+ });
103
+ }
104
+ function resolveMatrixChannelConfig(cfg) {
105
+ return isRecord(cfg.channels?.matrix) ? cfg.channels.matrix : null;
106
+ }
107
+ function findMatrixAccountEntry(cfg, accountId) {
108
+ const channel = resolveMatrixChannelConfig(cfg);
109
+ if (!channel) return null;
110
+ const accounts = isRecord(channel.accounts) ? channel.accounts : null;
111
+ if (!accounts) return null;
112
+ const entry = resolveNormalizedAccountEntry(accounts, accountId, normalizeAccountId);
113
+ return isRecord(entry) ? entry : null;
114
+ }
115
+ function resolveConfiguredMatrixAccountIds(cfg, env = process.env) {
116
+ const channel = resolveMatrixChannelConfig(cfg);
117
+ const configuredAccountIds = listConfiguredAccountIds({
118
+ accounts: channel && isRecord(channel.accounts) ? channel.accounts : void 0,
119
+ normalizeAccountId
120
+ });
121
+ if (hasConfiguredDefaultMatrixAccountSource({
122
+ channel,
123
+ env
124
+ })) configuredAccountIds.push(DEFAULT_ACCOUNT_ID);
125
+ return listCombinedAccountIds({
126
+ configuredAccountIds,
127
+ additionalAccountIds: listMatrixEnvAccountIds(env).filter((accountId) => normalizeAccountId(accountId) === DEFAULT_ACCOUNT_ID ? hasConfiguredDefaultMatrixAccountSource({
128
+ channel,
129
+ env
130
+ }) : hasUsableEffectiveMatrixAccountSource({
131
+ channel,
132
+ accountId,
133
+ env
134
+ })),
135
+ fallbackAccountIdWhenEmpty: channel ? DEFAULT_ACCOUNT_ID : void 0
136
+ });
137
+ }
138
+ function resolveMatrixDefaultOrOnlyAccountId(cfg, env = process.env) {
139
+ const channel = resolveMatrixChannelConfig(cfg);
140
+ if (!channel) return DEFAULT_ACCOUNT_ID;
141
+ const configuredDefault = normalizeOptionalAccountId(typeof channel.defaultAccount === "string" ? channel.defaultAccount : void 0);
142
+ return resolveListedDefaultAccountId({
143
+ accountIds: resolveConfiguredMatrixAccountIds(cfg, env),
144
+ configuredDefaultAccountId: configuredDefault,
145
+ ambiguousFallbackAccountId: DEFAULT_ACCOUNT_ID
146
+ });
147
+ }
148
+ function requiresExplicitMatrixDefaultAccount(cfg, env = process.env) {
149
+ const channel = resolveMatrixChannelConfig(cfg);
150
+ if (!channel) return false;
151
+ const configuredAccountIds = resolveConfiguredMatrixAccountIds(cfg, env);
152
+ if (configuredAccountIds.length <= 1) return false;
153
+ if (configuredAccountIds.includes(DEFAULT_ACCOUNT_ID)) return false;
154
+ const configuredDefault = normalizeOptionalAccountId(typeof channel.defaultAccount === "string" ? channel.defaultAccount : void 0);
155
+ return !(configuredDefault && configuredAccountIds.includes(configuredDefault));
156
+ }
157
+ //#endregion
158
+ export { resolveMatrixDefaultOrOnlyAccountId as a, resolveMatrixChannelConfig as i, requiresExplicitMatrixDefaultAccount as n, resolveMatrixAccountStringValues as o, resolveConfiguredMatrixAccountIds as r, findMatrixAccountEntry as t };
@@ -0,0 +1,130 @@
1
+ import { a as resolveMatrixDefaultOrOnlyAccountId, o as resolveMatrixAccountStringValues, r as resolveConfiguredMatrixAccountIds } from "./account-selection-BWwIruri.js";
2
+ import { a as resolveMatrixAccountConfig, o as resolveMatrixBaseConfig, t as findMatrixAccountConfig } from "./account-config-D2W-V1eQ.js";
3
+ import { i as resolveScopedMatrixEnvConfig, n as resolveGlobalMatrixEnvConfig } from "./env-auth-BJqGI8M6.js";
4
+ import { i as loadMatrixCredentials, n as credentialsMatchConfig } from "./credentials-read-cmHgousK.js";
5
+ import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
6
+ import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
7
+ import { hasConfiguredSecretInput } from "openclaw/plugin-sdk/secret-input-runtime";
8
+ //#region extensions/matrix/src/matrix/accounts.ts
9
+ function clean(value) {
10
+ return normalizeOptionalString(value) ?? "";
11
+ }
12
+ function resolveMatrixAccountAuthView(params) {
13
+ const normalizedAccountId = normalizeAccountId(params.accountId);
14
+ const matrix = resolveMatrixBaseConfig(params.cfg);
15
+ const account = findMatrixAccountConfig(params.cfg, normalizedAccountId) ?? {};
16
+ const resolvedStrings = resolveMatrixAccountStringValues({
17
+ accountId: normalizedAccountId,
18
+ account: {
19
+ homeserver: clean(account.homeserver),
20
+ userId: clean(account.userId),
21
+ accessToken: typeof account.accessToken === "string" ? clean(account.accessToken) : "",
22
+ password: typeof account.password === "string" ? clean(account.password) : "",
23
+ deviceId: clean(account.deviceId),
24
+ deviceName: clean(account.deviceName)
25
+ },
26
+ scopedEnv: resolveScopedMatrixEnvConfig(normalizedAccountId, params.env),
27
+ channel: {
28
+ homeserver: clean(matrix.homeserver),
29
+ userId: clean(matrix.userId),
30
+ accessToken: typeof matrix.accessToken === "string" ? clean(matrix.accessToken) : "",
31
+ password: typeof matrix.password === "string" ? clean(matrix.password) : "",
32
+ deviceId: clean(matrix.deviceId),
33
+ deviceName: clean(matrix.deviceName)
34
+ },
35
+ globalEnv: resolveGlobalMatrixEnvConfig(params.env)
36
+ });
37
+ return {
38
+ homeserver: resolvedStrings.homeserver,
39
+ userId: resolvedStrings.userId,
40
+ accessToken: resolvedStrings.accessToken || void 0,
41
+ password: resolvedStrings.password || void 0
42
+ };
43
+ }
44
+ function resolveMatrixAccountUserId(params) {
45
+ const env = params.env ?? process.env;
46
+ const authView = resolveMatrixAccountAuthView({
47
+ cfg: params.cfg,
48
+ accountId: params.accountId,
49
+ env
50
+ });
51
+ const configuredUserId = authView.userId.trim();
52
+ if (configuredUserId) return configuredUserId;
53
+ const stored = loadMatrixCredentials(env, params.accountId);
54
+ if (!stored) return null;
55
+ if (authView.homeserver && stored.homeserver !== authView.homeserver) return null;
56
+ if (authView.accessToken && stored.accessToken !== authView.accessToken) return null;
57
+ return stored.userId.trim() || null;
58
+ }
59
+ function listMatrixAccountIds(cfg) {
60
+ const ids = resolveConfiguredMatrixAccountIds(cfg, process.env);
61
+ return ids.length > 0 ? ids : [DEFAULT_ACCOUNT_ID];
62
+ }
63
+ function resolveDefaultMatrixAccountId(cfg) {
64
+ return normalizeAccountId(resolveMatrixDefaultOrOnlyAccountId(cfg));
65
+ }
66
+ function resolveConfiguredMatrixBotUserIds(params) {
67
+ const env = params.env ?? process.env;
68
+ const currentAccountId = normalizeAccountId(params.accountId);
69
+ const accountIds = new Set(resolveConfiguredMatrixAccountIds(params.cfg, env));
70
+ if (resolveMatrixAccount({
71
+ cfg: params.cfg,
72
+ accountId: DEFAULT_ACCOUNT_ID,
73
+ env
74
+ }).configured) accountIds.add(DEFAULT_ACCOUNT_ID);
75
+ const ids = /* @__PURE__ */ new Set();
76
+ for (const accountId of accountIds) {
77
+ if (normalizeAccountId(accountId) === currentAccountId) continue;
78
+ if (!resolveMatrixAccount({
79
+ cfg: params.cfg,
80
+ accountId,
81
+ env
82
+ }).configured) continue;
83
+ const userId = resolveMatrixAccountUserId({
84
+ cfg: params.cfg,
85
+ accountId,
86
+ env
87
+ });
88
+ if (userId) ids.add(userId);
89
+ }
90
+ return ids;
91
+ }
92
+ function resolveMatrixAccount(params) {
93
+ const env = params.env ?? process.env;
94
+ const accountId = normalizeAccountId(params.accountId ?? resolveDefaultMatrixAccountId(params.cfg));
95
+ const matrixBase = resolveMatrixBaseConfig(params.cfg);
96
+ const base = resolveMatrixAccountConfig({
97
+ cfg: params.cfg,
98
+ accountId,
99
+ env
100
+ });
101
+ const explicitAuthConfig = accountId === DEFAULT_ACCOUNT_ID ? base : findMatrixAccountConfig(params.cfg, accountId) ?? {};
102
+ const enabled = base.enabled !== false && matrixBase.enabled !== false;
103
+ const authView = resolveMatrixAccountAuthView({
104
+ cfg: params.cfg,
105
+ accountId,
106
+ env
107
+ });
108
+ const hasHomeserver = Boolean(authView.homeserver);
109
+ const hasUserId = Boolean(authView.userId);
110
+ const hasAccessToken = Boolean(authView.accessToken) || hasConfiguredSecretInput(explicitAuthConfig.accessToken);
111
+ const hasPassword = Boolean(authView.password);
112
+ const hasPasswordAuth = hasUserId && (hasPassword || hasConfiguredSecretInput(explicitAuthConfig.password));
113
+ const stored = loadMatrixCredentials(env, accountId);
114
+ const hasStored = stored && authView.homeserver ? credentialsMatchConfig(stored, {
115
+ homeserver: authView.homeserver,
116
+ userId: authView.userId || ""
117
+ }) : false;
118
+ const configured = hasHomeserver && (hasAccessToken || hasPasswordAuth || hasStored);
119
+ return {
120
+ accountId,
121
+ enabled,
122
+ name: normalizeOptionalString(base.name),
123
+ configured,
124
+ homeserver: authView.homeserver || void 0,
125
+ userId: authView.userId || void 0,
126
+ config: base
127
+ };
128
+ }
129
+ //#endregion
130
+ export { resolveMatrixAccount as i, resolveConfiguredMatrixBotUserIds as n, resolveDefaultMatrixAccountId as r, listMatrixAccountIds as t };
@@ -0,0 +1,20 @@
1
+ import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
2
+ //#region extensions/matrix/src/matrix/active-client.ts
3
+ const activeClients = /* @__PURE__ */ new Map();
4
+ function resolveAccountKey(accountId) {
5
+ return normalizeAccountId(accountId) || DEFAULT_ACCOUNT_ID;
6
+ }
7
+ function setActiveMatrixClient(client, accountId) {
8
+ const key = resolveAccountKey(accountId);
9
+ if (!client) {
10
+ activeClients.delete(key);
11
+ return;
12
+ }
13
+ activeClients.set(key, client);
14
+ }
15
+ function getActiveMatrixClient(accountId) {
16
+ const key = resolveAccountKey(accountId);
17
+ return activeClients.get(key) ?? null;
18
+ }
19
+ //#endregion
20
+ export { setActiveMatrixClient as n, getActiveMatrixClient as t };
@@ -0,0 +1,68 @@
1
+ import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
2
+ import { resolveAllowlistMatchByCandidates } from "openclaw/plugin-sdk/allow-from";
3
+ import { normalizeStringEntries } from "openclaw/plugin-sdk/string-normalization-runtime";
4
+ //#region extensions/matrix/src/matrix/monitor/allowlist.ts
5
+ function normalizeAllowList(list) {
6
+ return normalizeStringEntries(list);
7
+ }
8
+ function normalizeMatrixUser(raw) {
9
+ const value = (raw ?? "").trim();
10
+ if (!value) return "";
11
+ if (!value.startsWith("@") || !value.includes(":")) return normalizeLowercaseStringOrEmpty(value);
12
+ const withoutAt = value.slice(1);
13
+ const splitIndex = withoutAt.indexOf(":");
14
+ if (splitIndex === -1) return normalizeLowercaseStringOrEmpty(value);
15
+ const localpart = normalizeLowercaseStringOrEmpty(withoutAt.slice(0, splitIndex));
16
+ const server = normalizeLowercaseStringOrEmpty(withoutAt.slice(splitIndex + 1));
17
+ if (!server) return normalizeLowercaseStringOrEmpty(value);
18
+ return `@${localpart}:${server}`;
19
+ }
20
+ function normalizeMatrixUserId(raw) {
21
+ const trimmed = (raw ?? "").trim();
22
+ if (!trimmed) return "";
23
+ const lowered = normalizeLowercaseStringOrEmpty(trimmed);
24
+ if (lowered.startsWith("matrix:")) return normalizeMatrixUser(trimmed.slice(7));
25
+ if (lowered.startsWith("user:")) return normalizeMatrixUser(trimmed.slice(5));
26
+ return normalizeMatrixUser(trimmed);
27
+ }
28
+ function normalizeMatrixAllowListEntry(raw) {
29
+ const trimmed = raw.trim();
30
+ if (!trimmed) return "";
31
+ if (trimmed === "*") return trimmed;
32
+ const lowered = normalizeLowercaseStringOrEmpty(trimmed);
33
+ if (lowered.startsWith("matrix:")) return `matrix:${normalizeMatrixUser(trimmed.slice(7))}`;
34
+ if (lowered.startsWith("user:")) return `user:${normalizeMatrixUser(trimmed.slice(5))}`;
35
+ return normalizeMatrixUser(trimmed);
36
+ }
37
+ function normalizeMatrixAllowList(list) {
38
+ return normalizeAllowList(list).map((entry) => normalizeMatrixAllowListEntry(entry));
39
+ }
40
+ function resolveMatrixAllowListMatch(params) {
41
+ const allowList = params.allowList;
42
+ if (allowList.length === 0) return { allowed: false };
43
+ if (allowList.includes("*")) return {
44
+ allowed: true,
45
+ matchKey: "*",
46
+ matchSource: "wildcard"
47
+ };
48
+ const userId = normalizeMatrixUser(params.userId);
49
+ return resolveAllowlistMatchByCandidates({
50
+ allowList,
51
+ candidates: [
52
+ {
53
+ value: userId,
54
+ source: "id"
55
+ },
56
+ {
57
+ value: userId ? `matrix:${userId}` : "",
58
+ source: "prefixed-id"
59
+ },
60
+ {
61
+ value: userId ? `user:${userId}` : "",
62
+ source: "prefixed-user"
63
+ }
64
+ ]
65
+ });
66
+ }
67
+ //#endregion
68
+ export { normalizeMatrixUserId as n, resolveMatrixAllowListMatch as r, normalizeMatrixAllowList as t };
package/dist/api.js ADDED
@@ -0,0 +1,12 @@
1
+ import { d as setMatrixThreadBindingIdleTimeoutBySessionKey, n as getMatrixThreadBindingManager, p as setMatrixThreadBindingMaxAgeBySessionKey, s as resetMatrixThreadBindingsForTests } from "./thread-bindings-shared-DK-d-oYX.js";
2
+ import { a as resolveMatrixDefaultOrOnlyAccountId, i as resolveMatrixChannelConfig, n as requiresExplicitMatrixDefaultAccount, r as resolveConfiguredMatrixAccountIds, t as findMatrixAccountEntry } from "./account-selection-BWwIruri.js";
3
+ import { n as listMatrixEnvAccountIds, r as resolveMatrixEnvAccountToken, t as getMatrixScopedEnvVarNames } from "./env-vars-C7uQCTKn.js";
4
+ import { a as resolveMatrixCredentialsPath, c as resolveMatrixLegacyFlatStoreRoot, i as resolveMatrixCredentialsFilename, l as sanitizeMatrixPathSegment, n as resolveMatrixAccountStorageRoot, o as resolveMatrixHomeserverKey, r as resolveMatrixCredentialsDir, s as resolveMatrixLegacyFlatStoragePaths, t as hashMatrixAccessToken } from "./storage-paths-BJLdnCjV.js";
5
+ import { t as matrixPlugin } from "./channel-DJNir3Rb.js";
6
+ import { n as matrixSetupAdapter, t as createMatrixSetupWizardProxy } from "./setup-core-CfZy05oW.js";
7
+ import { n as matrixOnboardingAdapter } from "./setup-surface-CqT_o61M.js";
8
+ import { t as createMatrixThreadBindingManager } from "./thread-bindings-B9mesxXk.js";
9
+ //#region extensions/matrix/api.ts
10
+ const matrixSessionBindingAdapterChannels = ["matrix"];
11
+ //#endregion
12
+ export { createMatrixSetupWizardProxy, createMatrixThreadBindingManager, findMatrixAccountEntry, getMatrixScopedEnvVarNames, getMatrixThreadBindingManager, hashMatrixAccessToken, listMatrixEnvAccountIds, matrixOnboardingAdapter, matrixOnboardingAdapter as matrixSetupWizard, matrixPlugin, matrixSessionBindingAdapterChannels, matrixSetupAdapter, requiresExplicitMatrixDefaultAccount, resetMatrixThreadBindingsForTests, resolveConfiguredMatrixAccountIds, resolveMatrixAccountStorageRoot, resolveMatrixChannelConfig, resolveMatrixCredentialsDir, resolveMatrixCredentialsFilename, resolveMatrixCredentialsPath, resolveMatrixDefaultOrOnlyAccountId, resolveMatrixEnvAccountToken, resolveMatrixHomeserverKey, resolveMatrixLegacyFlatStoragePaths, resolveMatrixLegacyFlatStoreRoot, sanitizeMatrixPathSegment, setMatrixThreadBindingIdleTimeoutBySessionKey, setMatrixThreadBindingMaxAgeBySessionKey };