@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,15 @@
1
+ import { a as resolveMatrixDefaultOrOnlyAccountId } from "./account-selection-BWwIruri.js";
2
+ import { t as resolveMatrixConfigFieldPath } from "./config-paths-nsVaysCu.js";
3
+ import { normalizeOptionalAccountId } from "openclaw/plugin-sdk/account-id";
4
+ //#region extensions/matrix/src/matrix/encryption-guidance.ts
5
+ function resolveMatrixEncryptionConfigPath(cfg, accountId) {
6
+ return resolveMatrixConfigFieldPath(cfg, normalizeOptionalAccountId(accountId) ?? resolveMatrixDefaultOrOnlyAccountId(cfg), "encryption");
7
+ }
8
+ function formatMatrixEncryptionUnavailableError(cfg, accountId) {
9
+ return `Matrix encryption is not available (enable ${resolveMatrixEncryptionConfigPath(cfg, accountId)}=true)`;
10
+ }
11
+ function formatMatrixEncryptedEventDisabledWarning(cfg, accountId) {
12
+ return `matrix: encrypted event received without encryption enabled; set ${resolveMatrixEncryptionConfigPath(cfg, accountId)}=true and verify the device to decrypt`;
13
+ }
14
+ //#endregion
15
+ export { formatMatrixEncryptionUnavailableError as n, formatMatrixEncryptedEventDisabledWarning as t };
@@ -0,0 +1,63 @@
1
+ import { t as getMatrixScopedEnvVarNames } from "./env-vars-C7uQCTKn.js";
2
+ import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
3
+ //#region extensions/matrix/src/matrix/client/env-auth.ts
4
+ function cleanEnv(value) {
5
+ return typeof value === "string" ? value.trim() : "";
6
+ }
7
+ function resolveGlobalMatrixEnvConfig(env) {
8
+ return {
9
+ homeserver: cleanEnv(env.MATRIX_HOMESERVER),
10
+ userId: cleanEnv(env.MATRIX_USER_ID),
11
+ accessToken: cleanEnv(env.MATRIX_ACCESS_TOKEN) || void 0,
12
+ password: cleanEnv(env.MATRIX_PASSWORD) || void 0,
13
+ deviceId: cleanEnv(env.MATRIX_DEVICE_ID) || void 0,
14
+ deviceName: cleanEnv(env.MATRIX_DEVICE_NAME) || void 0
15
+ };
16
+ }
17
+ function hasReadyMatrixEnvAuth(config) {
18
+ const homeserver = cleanEnv(config.homeserver);
19
+ const userId = cleanEnv(config.userId);
20
+ const accessToken = cleanEnv(config.accessToken);
21
+ const password = cleanEnv(config.password);
22
+ return Boolean(homeserver && (accessToken || userId && password));
23
+ }
24
+ function resolveScopedMatrixEnvConfig(accountId, env = process.env) {
25
+ const keys = getMatrixScopedEnvVarNames(accountId);
26
+ return {
27
+ homeserver: cleanEnv(env[keys.homeserver]),
28
+ userId: cleanEnv(env[keys.userId]),
29
+ accessToken: cleanEnv(env[keys.accessToken]) || void 0,
30
+ password: cleanEnv(env[keys.password]) || void 0,
31
+ deviceId: cleanEnv(env[keys.deviceId]) || void 0,
32
+ deviceName: cleanEnv(env[keys.deviceName]) || void 0
33
+ };
34
+ }
35
+ function resolveMatrixEnvAuthReadiness(accountId, env = process.env) {
36
+ const normalizedAccountId = normalizeAccountId(accountId);
37
+ const scoped = resolveScopedMatrixEnvConfig(normalizedAccountId, env);
38
+ const scopedReady = hasReadyMatrixEnvAuth(scoped);
39
+ if (normalizedAccountId !== DEFAULT_ACCOUNT_ID) {
40
+ const keys = getMatrixScopedEnvVarNames(normalizedAccountId);
41
+ return {
42
+ ready: scopedReady,
43
+ homeserver: scoped.homeserver || void 0,
44
+ userId: scoped.userId || void 0,
45
+ sourceHint: `${keys.homeserver} (+ auth vars)`,
46
+ missingMessage: `Set per-account env vars for "${normalizedAccountId}" (for example ${keys.homeserver} + ${keys.accessToken} or ${keys.userId} + ${keys.password}).`
47
+ };
48
+ }
49
+ const defaultScoped = resolveScopedMatrixEnvConfig(DEFAULT_ACCOUNT_ID, env);
50
+ const global = resolveGlobalMatrixEnvConfig(env);
51
+ const defaultScopedReady = hasReadyMatrixEnvAuth(defaultScoped);
52
+ const globalReady = hasReadyMatrixEnvAuth(global);
53
+ const defaultKeys = getMatrixScopedEnvVarNames(DEFAULT_ACCOUNT_ID);
54
+ return {
55
+ ready: defaultScopedReady || globalReady,
56
+ homeserver: defaultScoped.homeserver || global.homeserver || void 0,
57
+ userId: defaultScoped.userId || global.userId || void 0,
58
+ sourceHint: "MATRIX_* or MATRIX_DEFAULT_*",
59
+ missingMessage: `Set Matrix env vars for the default account (for example MATRIX_HOMESERVER + MATRIX_ACCESS_TOKEN, MATRIX_USER_ID + MATRIX_PASSWORD, or ${defaultKeys.homeserver} + ${defaultKeys.accessToken}).`
60
+ };
61
+ }
62
+ //#endregion
63
+ export { resolveScopedMatrixEnvConfig as i, resolveGlobalMatrixEnvConfig as n, resolveMatrixEnvAuthReadiness as r, hasReadyMatrixEnvAuth as t };
@@ -0,0 +1,63 @@
1
+ import { normalizeAccountId, normalizeOptionalAccountId } from "openclaw/plugin-sdk/account-id";
2
+ //#region extensions/matrix/src/env-vars.ts
3
+ const MATRIX_SCOPED_ENV_SUFFIXES = [
4
+ "HOMESERVER",
5
+ "USER_ID",
6
+ "ACCESS_TOKEN",
7
+ "PASSWORD",
8
+ "DEVICE_ID",
9
+ "DEVICE_NAME"
10
+ ];
11
+ const MATRIX_GLOBAL_ENV_KEYS = MATRIX_SCOPED_ENV_SUFFIXES.map((suffix) => `MATRIX_${suffix}`);
12
+ const MATRIX_SCOPED_ENV_RE = new RegExp(`^MATRIX_(.+)_(${MATRIX_SCOPED_ENV_SUFFIXES.join("|")})$`);
13
+ function resolveMatrixEnvAccountToken(accountId) {
14
+ return Array.from(normalizeAccountId(accountId)).map((char) => /[a-z0-9]/.test(char) ? char.toUpperCase() : `_X${char.codePointAt(0)?.toString(16).toUpperCase() ?? "00"}_`).join("");
15
+ }
16
+ function getMatrixScopedEnvVarNames(accountId) {
17
+ const token = resolveMatrixEnvAccountToken(accountId);
18
+ return {
19
+ homeserver: `MATRIX_${token}_HOMESERVER`,
20
+ userId: `MATRIX_${token}_USER_ID`,
21
+ accessToken: `MATRIX_${token}_ACCESS_TOKEN`,
22
+ password: `MATRIX_${token}_PASSWORD`,
23
+ deviceId: `MATRIX_${token}_DEVICE_ID`,
24
+ deviceName: `MATRIX_${token}_DEVICE_NAME`
25
+ };
26
+ }
27
+ function decodeMatrixEnvAccountToken(token) {
28
+ let decoded = "";
29
+ for (let index = 0; index < token.length;) {
30
+ const hexEscape = /^_X([0-9A-F]+)_/.exec(token.slice(index));
31
+ if (hexEscape) {
32
+ const hex = hexEscape[1];
33
+ const codePoint = hex ? Number.parseInt(hex, 16) : NaN;
34
+ if (!Number.isFinite(codePoint)) return;
35
+ decoded += String.fromCodePoint(codePoint);
36
+ index += hexEscape[0].length;
37
+ continue;
38
+ }
39
+ const char = token[index];
40
+ if (!char || !/[A-Z0-9]/.test(char)) return;
41
+ decoded += char.toLowerCase();
42
+ index += 1;
43
+ }
44
+ const normalized = normalizeOptionalAccountId(decoded);
45
+ if (!normalized) return;
46
+ return resolveMatrixEnvAccountToken(normalized) === token ? normalized : void 0;
47
+ }
48
+ function listMatrixEnvAccountIds(env = process.env) {
49
+ const ids = /* @__PURE__ */ new Set();
50
+ for (const key of MATRIX_GLOBAL_ENV_KEYS) if (typeof env[key] === "string" && env[key]?.trim()) {
51
+ ids.add(normalizeAccountId("default"));
52
+ break;
53
+ }
54
+ for (const key of Object.keys(env)) {
55
+ const match = MATRIX_SCOPED_ENV_RE.exec(key);
56
+ if (!match) continue;
57
+ const accountId = decodeMatrixEnvAccountToken(match[1]);
58
+ if (accountId) ids.add(accountId);
59
+ }
60
+ return Array.from(ids).toSorted((a, b) => a.localeCompare(b));
61
+ }
62
+ //#endregion
63
+ export { listMatrixEnvAccountIds as n, resolveMatrixEnvAccountToken as r, getMatrixScopedEnvVarNames as t };
@@ -0,0 +1,17 @@
1
+ import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
2
+ import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
3
+ //#region extensions/matrix/src/matrix/errors.ts
4
+ function formatMatrixErrorMessage(err) {
5
+ return formatErrorMessage(err);
6
+ }
7
+ function formatMatrixErrorReason(err) {
8
+ return normalizeLowercaseStringOrEmpty(formatMatrixErrorMessage(err));
9
+ }
10
+ function isMatrixNotFoundError(err) {
11
+ const errObj = err;
12
+ if (errObj?.statusCode === 404 || errObj?.body?.errcode === "M_NOT_FOUND") return true;
13
+ const message = formatMatrixErrorReason(err);
14
+ return message.includes("m_not_found") || message.includes("[404]") || message.includes("not found");
15
+ }
16
+ //#endregion
17
+ export { formatMatrixErrorReason as n, isMatrixNotFoundError as r, formatMatrixErrorMessage as t };
@@ -0,0 +1,15 @@
1
+ import { isApprovalNotFoundError } from "openclaw/plugin-sdk/error-runtime";
2
+ import { resolveApprovalOverGateway } from "openclaw/plugin-sdk/approval-gateway-runtime";
3
+ //#region extensions/matrix/src/exec-approval-resolver.ts
4
+ async function resolveMatrixApproval(params) {
5
+ await resolveApprovalOverGateway({
6
+ cfg: params.cfg,
7
+ approvalId: params.approvalId,
8
+ decision: params.decision,
9
+ senderId: params.senderId,
10
+ gatewayUrl: params.gatewayUrl,
11
+ clientDisplayName: `Matrix approval (${params.senderId?.trim() || "unknown"})`
12
+ });
13
+ }
14
+ //#endregion
15
+ export { isApprovalNotFoundError, resolveMatrixApproval };
@@ -0,0 +1,196 @@
1
+ import { i as resolveMatrixAccount, t as listMatrixAccountIds } from "./accounts-Bm90Rzvp.js";
2
+ import { t as normalizeMatrixApproverId } from "./approval-ids-DoC2z7tR.js";
3
+ import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
4
+ import { resolveApprovalRequestChannelAccountId } from "openclaw/plugin-sdk/approval-native-runtime";
5
+ import { createResolvedApproverActionAuthAdapter, resolveApprovalApprovers } from "openclaw/plugin-sdk/approval-auth-runtime";
6
+ import { createChannelExecApprovalProfile, getExecApprovalReplyMetadata, isChannelExecApprovalClientEnabledFromConfig, isChannelExecApprovalTargetRecipient, matchesApprovalRequestFilters } from "openclaw/plugin-sdk/approval-client-runtime";
7
+ import { normalizeAccountId } from "openclaw/plugin-sdk/routing";
8
+ //#region extensions/matrix/src/approval-auth.ts
9
+ function getMatrixApprovalAuthApprovers(params) {
10
+ return resolveApprovalApprovers({
11
+ allowFrom: resolveMatrixAccount(params).config.dm?.allowFrom,
12
+ normalizeApprover: normalizeMatrixApproverId
13
+ });
14
+ }
15
+ const matrixApprovalAuth = createResolvedApproverActionAuthAdapter({
16
+ channelLabel: "Matrix",
17
+ resolveApprovers: ({ cfg, accountId }) => getMatrixApprovalAuthApprovers({
18
+ cfg,
19
+ accountId
20
+ }),
21
+ normalizeSenderId: (value) => normalizeMatrixApproverId(value)
22
+ });
23
+ //#endregion
24
+ //#region extensions/matrix/src/exec-approvals.ts
25
+ function normalizeMatrixExecApproverId(value) {
26
+ const normalized = normalizeMatrixApproverId(value);
27
+ return normalized === "*" ? void 0 : normalized;
28
+ }
29
+ function resolveMatrixExecApprovalConfig(params) {
30
+ const account = resolveMatrixAccount(params);
31
+ const config = account.config.execApprovals;
32
+ if (!config) return;
33
+ return {
34
+ ...config,
35
+ enabled: account.enabled && account.configured ? config.enabled : false
36
+ };
37
+ }
38
+ function countMatrixExecApprovalEligibleAccounts(params) {
39
+ return listMatrixAccountIds(params.cfg).filter((accountId) => {
40
+ const account = resolveMatrixAccount({
41
+ cfg: params.cfg,
42
+ accountId
43
+ });
44
+ if (!account.enabled || !account.configured) return false;
45
+ const config = resolveMatrixExecApprovalConfig({
46
+ cfg: params.cfg,
47
+ accountId
48
+ });
49
+ const filters = config?.enabled ? {
50
+ agentFilter: config.agentFilter,
51
+ sessionFilter: config.sessionFilter
52
+ } : {
53
+ agentFilter: void 0,
54
+ sessionFilter: void 0
55
+ };
56
+ return isChannelExecApprovalClientEnabledFromConfig({
57
+ enabled: config?.enabled,
58
+ approverCount: getMatrixApprovalApprovers({
59
+ cfg: params.cfg,
60
+ accountId,
61
+ approvalKind: params.approvalKind
62
+ }).length
63
+ }) && matchesApprovalRequestFilters({
64
+ request: params.request.request,
65
+ agentFilter: filters.agentFilter,
66
+ sessionFilter: filters.sessionFilter
67
+ });
68
+ }).length;
69
+ }
70
+ function matchesMatrixRequestAccount(params) {
71
+ const turnSourceChannel = normalizeLowercaseStringOrEmpty(params.request.request.turnSourceChannel);
72
+ const boundAccountId = resolveApprovalRequestChannelAccountId({
73
+ cfg: params.cfg,
74
+ request: params.request,
75
+ channel: "matrix"
76
+ });
77
+ if (turnSourceChannel && turnSourceChannel !== "matrix" && !boundAccountId) return countMatrixExecApprovalEligibleAccounts({
78
+ cfg: params.cfg,
79
+ request: params.request,
80
+ approvalKind: params.approvalKind
81
+ }) <= 1;
82
+ return !boundAccountId || !params.accountId || normalizeAccountId(boundAccountId) === normalizeAccountId(params.accountId);
83
+ }
84
+ function getMatrixExecApprovalApprovers(params) {
85
+ const account = resolveMatrixAccount(params).config;
86
+ return resolveApprovalApprovers({
87
+ explicit: account.execApprovals?.approvers,
88
+ allowFrom: account.dm?.allowFrom,
89
+ normalizeApprover: normalizeMatrixExecApproverId
90
+ });
91
+ }
92
+ function resolveMatrixApprovalKind(request) {
93
+ return request.id.startsWith("plugin:") ? "plugin" : "exec";
94
+ }
95
+ function getMatrixApprovalApprovers(params) {
96
+ if (params.approvalKind === "plugin") return getMatrixApprovalAuthApprovers({
97
+ cfg: params.cfg,
98
+ accountId: params.accountId
99
+ });
100
+ return getMatrixExecApprovalApprovers(params);
101
+ }
102
+ function isMatrixExecApprovalTargetRecipient(params) {
103
+ return isChannelExecApprovalTargetRecipient({
104
+ ...params,
105
+ channel: "matrix",
106
+ normalizeSenderId: normalizeMatrixApproverId,
107
+ matchTarget: ({ target, normalizedSenderId }) => normalizeMatrixApproverId(target.to) === normalizedSenderId
108
+ });
109
+ }
110
+ const matrixExecApprovalProfile = createChannelExecApprovalProfile({
111
+ resolveConfig: resolveMatrixExecApprovalConfig,
112
+ resolveApprovers: getMatrixExecApprovalApprovers,
113
+ normalizeSenderId: normalizeMatrixApproverId,
114
+ isTargetRecipient: isMatrixExecApprovalTargetRecipient,
115
+ matchesRequestAccount: (params) => matchesMatrixRequestAccount({
116
+ ...params,
117
+ approvalKind: "exec"
118
+ })
119
+ });
120
+ const isMatrixExecApprovalClientEnabled = matrixExecApprovalProfile.isClientEnabled;
121
+ matrixExecApprovalProfile.isApprover;
122
+ const isMatrixExecApprovalAuthorizedSender = matrixExecApprovalProfile.isAuthorizedSender;
123
+ const resolveMatrixExecApprovalTarget = matrixExecApprovalProfile.resolveTarget;
124
+ matrixExecApprovalProfile.shouldHandleRequest;
125
+ function isMatrixApprovalClientEnabled(params) {
126
+ if (params.approvalKind === "exec") return isMatrixExecApprovalClientEnabled(params);
127
+ return isChannelExecApprovalClientEnabledFromConfig({
128
+ enabled: resolveMatrixExecApprovalConfig(params)?.enabled,
129
+ approverCount: getMatrixApprovalApprovers(params).length
130
+ });
131
+ }
132
+ function isMatrixAnyApprovalClientEnabled(params) {
133
+ return isMatrixApprovalClientEnabled({
134
+ ...params,
135
+ approvalKind: "exec"
136
+ }) || isMatrixApprovalClientEnabled({
137
+ ...params,
138
+ approvalKind: "plugin"
139
+ });
140
+ }
141
+ function shouldHandleMatrixApprovalRequest(params) {
142
+ const approvalKind = resolveMatrixApprovalKind(params.request);
143
+ if (!matchesMatrixRequestAccount({
144
+ ...params,
145
+ approvalKind
146
+ })) return false;
147
+ const config = resolveMatrixExecApprovalConfig(params);
148
+ if (!isChannelExecApprovalClientEnabledFromConfig({
149
+ enabled: config?.enabled,
150
+ approverCount: getMatrixApprovalApprovers({
151
+ ...params,
152
+ approvalKind
153
+ }).length
154
+ })) return false;
155
+ return matchesApprovalRequestFilters({
156
+ request: params.request.request,
157
+ agentFilter: config?.agentFilter,
158
+ sessionFilter: config?.sessionFilter
159
+ });
160
+ }
161
+ function buildFilterCheckRequest(params) {
162
+ if (params.metadata.approvalKind === "plugin") return {
163
+ id: params.metadata.approvalId,
164
+ request: {
165
+ title: "Plugin Approval Required",
166
+ description: "",
167
+ agentId: params.metadata.agentId ?? null,
168
+ sessionKey: params.metadata.sessionKey ?? null
169
+ },
170
+ createdAtMs: 0,
171
+ expiresAtMs: 0
172
+ };
173
+ return {
174
+ id: params.metadata.approvalId,
175
+ request: {
176
+ command: "",
177
+ agentId: params.metadata.agentId ?? null,
178
+ sessionKey: params.metadata.sessionKey ?? null
179
+ },
180
+ createdAtMs: 0,
181
+ expiresAtMs: 0
182
+ };
183
+ }
184
+ function shouldSuppressLocalMatrixExecApprovalPrompt(params) {
185
+ if (!matrixExecApprovalProfile.shouldSuppressLocalPrompt(params)) return false;
186
+ const metadata = getExecApprovalReplyMetadata(params.payload);
187
+ if (!metadata) return false;
188
+ const request = buildFilterCheckRequest({ metadata });
189
+ return shouldHandleMatrixApprovalRequest({
190
+ cfg: params.cfg,
191
+ accountId: params.accountId,
192
+ request
193
+ });
194
+ }
195
+ //#endregion
196
+ export { isMatrixExecApprovalAuthorizedSender as a, shouldHandleMatrixApprovalRequest as c, matrixApprovalAuth as d, isMatrixApprovalClientEnabled as i, shouldSuppressLocalMatrixExecApprovalPrompt as l, getMatrixExecApprovalApprovers as n, isMatrixExecApprovalClientEnabled as o, isMatrixAnyApprovalClientEnabled as r, resolveMatrixExecApprovalTarget as s, getMatrixApprovalApprovers as t, getMatrixApprovalAuthApprovers as u };
@@ -0,0 +1,4 @@
1
+ import { a as resolveMatrixDefaultOrOnlyAccountId, i as resolveMatrixChannelConfig, n as requiresExplicitMatrixDefaultAccount, r as resolveConfiguredMatrixAccountIds, t as findMatrixAccountEntry } from "./account-selection-BWwIruri.js";
2
+ import { n as listMatrixEnvAccountIds, r as resolveMatrixEnvAccountToken, t as getMatrixScopedEnvVarNames } from "./env-vars-C7uQCTKn.js";
3
+ 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";
4
+ export { findMatrixAccountEntry, getMatrixScopedEnvVarNames, hashMatrixAccessToken, listMatrixEnvAccountIds, requiresExplicitMatrixDefaultAccount, resolveConfiguredMatrixAccountIds, resolveMatrixAccountStorageRoot, resolveMatrixChannelConfig, resolveMatrixCredentialsDir, resolveMatrixCredentialsFilename, resolveMatrixCredentialsPath, resolveMatrixDefaultOrOnlyAccountId, resolveMatrixEnvAccountToken, resolveMatrixHomeserverKey, resolveMatrixLegacyFlatStoragePaths, resolveMatrixLegacyFlatStoreRoot, sanitizeMatrixPathSegment };