@openclaw/matrix 2026.5.12 → 2026.5.14-beta.2

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 (99) hide show
  1. package/dist/api.js +4 -4
  2. package/dist/{approval-handler.runtime-LpWmoFyw.js → approval-handler.runtime-Q8ZlmQv_.js} +5 -6
  3. package/dist/{approval-ids-DoC2z7tR.js → approval-ids-D6IQvvRE.js} +1 -1
  4. package/dist/{approval-reaction-auth-DbcA1gGd.js → approval-reaction-auth-99PRu7rF.js} +2 -2
  5. package/dist/{channel-B-R2dceO.js → channel-BLKRuTHs.js} +285 -26
  6. package/dist/channel-plugin-api.js +1 -1
  7. package/dist/{channel.runtime-DdtNY_To.js → channel.runtime-9qwvlUwp.js} +8 -8
  8. package/dist/{cli-Cq80go7q.js → cli-BeWdjXLV.js} +15 -17
  9. package/dist/{cli-metadata-OtekEqAD.js → cli-metadata-B2_76YSe.js} +1 -1
  10. package/dist/cli-metadata.js +1 -1
  11. package/dist/{client-DzjShjVN.js → client-D6fFVbNM.js} +2 -2
  12. package/dist/{client-bootstrap-Am_ZEH3x.js → client-bootstrap-DBwUKgC3.js} +3 -3
  13. package/dist/{client-CyxIx4Fv.js → client-oci1tD6-.js} +4 -5
  14. package/dist/{account-config-D2W-V1eQ.js → config-paths-msaDGRh6.js} +20 -2
  15. package/dist/{config-schema-B975BYl0.js → config-schema-BPCzSyjT.js} +102 -4
  16. package/dist/contract-api.js +5 -6
  17. package/dist/{create-client-DpoW106T.js → create-client-BahCtURn.js} +4 -4
  18. package/dist/{credentials-DV6fWXhC.js → credentials-DK0lK9cZ.js} +1 -1
  19. package/dist/{credentials-write.runtime-zniTq-Gr.js → credentials-write.runtime-DhPvBU-C.js} +1 -1
  20. package/dist/{crypto-runtime-DS6R8y_n.js → crypto-runtime-B-SPS5mv.js} +5 -5
  21. package/dist/{deps-CU5W9Ixu.js → deps-LqqGWPWt.js} +10 -14
  22. package/dist/{directory-live-Bn66SRSD.js → directory-live-BCfx1C0G.js} +3 -3
  23. package/dist/{doctor-KjAvjAJu.js → doctor-KuNYX5N3.js} +3 -3
  24. package/dist/doctor-contract-api.js +1 -1
  25. package/dist/{draft-stream-D_FlbmCh.js → draft-stream-BayHVmtO.js} +1 -2
  26. package/dist/{encryption-guidance-BPi3A_m3.js → encryption-guidance-1QoIvd-g.js} +1 -1
  27. package/dist/{http-client-C7AeVJay.js → http-client-DS3UoC_p.js} +1 -1
  28. package/dist/index.js +2 -2
  29. package/dist/{legacy-crypto-inspector-pB252vPO.js → legacy-crypto-inspector-_gWJGVQ_.js} +1 -1
  30. package/dist/{legacy-crypto-restore-Biw-w2ng.js → legacy-crypto-restore-B9eF1gob.js} +1 -1
  31. package/dist/{logging-DZHSPP5N.js → logging-bJ8EEe1G.js} +1 -1
  32. package/dist/{matrix-migration.runtime-DfjNMeoX.js → matrix-migration.runtime-Cf_wX9mk.js} +3 -3
  33. package/dist/{media-text-psyGloYl.js → media-text-4h4YwCGC.js} +1 -1
  34. package/dist/{messages-DQ8xXWiP.js → messages-BKTEUSwJ.js} +5 -5
  35. package/dist/{migration-snapshot.runtime-CKHE3xF9.js → migration-snapshot.runtime-C7yiKWS7.js} +1 -1
  36. package/dist/{monitor-C8cEvvTe.js → monitor-k-b_TmCm.js} +66 -46
  37. package/dist/plugin-entry.handlers.runtime.js +2 -2
  38. package/dist/probe.runtime-zExLz3Ek.js +3 -0
  39. package/dist/{profile-update-DleMeUHj.js → profile-update-BAAflurI.js} +2 -3
  40. package/dist/{reaction-events-CiARZfjk.js → reaction-events-Dimh8FUE.js} +6 -6
  41. package/dist/{resolve-targets-BbzYe9Qi.js → resolve-targets-DPqngj4V.js} +1 -1
  42. package/dist/{resolver.runtime-BWFMWEsg.js → resolver.runtime-C0RDK0VW.js} +1 -1
  43. package/dist/{route-D6rg-iXN.js → route-R-ajT21_.js} +1 -1
  44. package/dist/{runtime-api-DTKcXOhp.js → runtime-api-C-QeChQj.js} +1 -1
  45. package/dist/runtime-api.js +1 -1
  46. package/dist/runtime-heavy-api.js +2 -2
  47. package/dist/{sdk-DXWmb94u.js → sdk-BwfNtBhM.js} +301 -13
  48. package/dist/secret-contract-api.js +1 -1
  49. package/dist/{send-Df-pDuG6.js → send-CdoJ1pZY.js} +323 -6
  50. package/dist/{setup-bootstrap-DXWxzR7A.js → setup-bootstrap-krQU60Az.js} +4 -4
  51. package/dist/setup-core-CgOV8zmh.js +675 -0
  52. package/dist/setup-plugin-api.js +3 -4
  53. package/dist/{setup-surface-DuRQrrpU.js → setup-surface-BgUaEySF.js} +7 -10
  54. package/dist/{config-BR4uLzNs.js → shared-BlXw87Kp.js} +199 -9
  55. package/dist/{logger-CnZRVrux.js → startup-abort-br7BZHJQ.js} +32 -1
  56. package/dist/{startup-verification-Demyp0bP.js → startup-verification-CTfhD7V_.js} +2 -2
  57. package/dist/{storage-tC3ujLiW.js → storage-HI1nL3im.js} +1 -1
  58. package/dist/{subagent-hooks-DQbyqq9V.js → subagent-hooks-api-BgQgDwAS.js} +22 -1
  59. package/dist/subagent-hooks-api.js +1 -22
  60. package/dist/test-api.js +2 -2
  61. package/dist/thread-binding-api.js +1 -1
  62. package/dist/{thread-bindings--P1UYe7t.js → thread-bindings-8AyQOYDT.js} +2 -2
  63. package/dist/{tool-actions.runtime-AFGhzK--.js → tool-actions.runtime-BuCnleVD.js} +9 -9
  64. package/dist/{verification-BbGdzYQl.js → verification-DvC37Z_y.js} +2 -2
  65. package/openclaw.plugin.json +96 -0
  66. package/package.json +6 -6
  67. package/dist/accounts-Bm90Rzvp.js +0 -130
  68. package/dist/allowlist-sTzpCn5d.js +0 -68
  69. package/dist/config-paths-nsVaysCu.js +0 -19
  70. package/dist/config-update-wZX-HLMn.js +0 -143
  71. package/dist/direct-management--Y8ypgLv.js +0 -251
  72. package/dist/direct-room-XkutHjES.js +0 -76
  73. package/dist/exec-approvals-Crnh543m.js +0 -196
  74. package/dist/probe.runtime-NE73hi9o.js +0 -3
  75. package/dist/profile-BlHu0wDX.js +0 -111
  76. package/dist/recovery-key-store-BTJ6jz5v.js +0 -294
  77. package/dist/session-store-metadata-DQXjgNLt.js +0 -77
  78. package/dist/setup-core-B5X7HxAP.js +0 -116
  79. package/dist/setup-dm-policy-Ca3jA4YW.js +0 -195
  80. package/dist/shared-CkbpEI5j.js +0 -195
  81. package/dist/startup-abort-56edvmbM.js +0 -32
  82. /package/dist/{active-client-uhlxdhEy.js → active-client-DUi-lumi.js} +0 -0
  83. /package/dist/{approval-reactions-o2_tuH8D.js → approval-reactions-Cwd1PMCC.js} +0 -0
  84. /package/dist/{async-lock-uQfhfQIY.js → async-lock-SsmtFXtt.js} +0 -0
  85. /package/dist/{backup-health-Cabu_WQC.js → backup-health-3BHbHxyd.js} +0 -0
  86. /package/dist/{config-secret-input.runtime-DiKFehsE.js → config-secret-input.runtime-nbLCnJq7.js} +0 -0
  87. /package/dist/{crypto-node.runtime-pihzdpY7.js → crypto-node.runtime-D9qxgRPa.js} +0 -0
  88. /package/dist/{device-health-UVYpbA_W.js → device-health-Di9MUzFj.js} +0 -0
  89. /package/dist/{doctor-contract-D4-64QuJ.js → doctor-contract-s4gUPmRN.js} +0 -0
  90. /package/dist/{errors-CTcpEDq-.js → errors-BpHgvm2o.js} +0 -0
  91. /package/dist/{exec-approval-resolver-Bza9Dhlm.js → exec-approval-resolver-C8faS0XB.js} +0 -0
  92. /package/dist/{migration-snapshot-backup-DaCHTp8C.js → migration-snapshot-backup-BWTIFXgQ.js} +0 -0
  93. /package/dist/{reaction-common-ejrL19w-.js → reaction-common-B-QgNfEs.js} +0 -0
  94. /package/dist/{runtime-C6X4h_SJ.js → runtime-lwTSy9Yt.js} +0 -0
  95. /package/dist/{secret-contract-DcrJWCQI.js → secret-contract-e4SdhUtT.js} +0 -0
  96. /package/dist/{sync-state-C_beeevA.js → sync-state-Bx0gPaGA.js} +0 -0
  97. /package/dist/{thread-binding-api-Cq_E-E1K.js → thread-binding-api-Bx55B6hm.js} +0 -0
  98. /package/dist/{timeout-abort-signal-CtaIaP1v.js → timeout-abort-signal-sT0wAxVn.js} +0 -0
  99. /package/dist/{url-validation-DiK9j7jz.js → url-validation-CBZBxN3F.js} +0 -0
@@ -0,0 +1,675 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-DUslC3ob.js";
2
+ import { a as resolveMatrixDefaultOrOnlyAccountId, o as resolveMatrixAccountStringValues, r as resolveConfiguredMatrixAccountIds } from "./account-selection-BWwIruri.js";
3
+ import { c as resolveMatrixAccountConfig, i as findMatrixAccountConfig, l as resolveMatrixBaseConfig, n as resolveMatrixConfigPath$1, r as shouldStoreMatrixAccountAtTopLevel, t as resolveMatrixConfigFieldPath } from "./config-paths-msaDGRh6.js";
4
+ import { i as resolveScopedMatrixEnvConfig, n as resolveGlobalMatrixEnvConfig, r as resolveMatrixEnvAuthReadiness } from "./env-auth-BJqGI8M6.js";
5
+ import { i as loadMatrixCredentials, n as credentialsMatchConfig } from "./credentials-read-cmHgousK.js";
6
+ import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
7
+ import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
8
+ import { hasConfiguredSecretInput } from "openclaw/plugin-sdk/secret-input-runtime";
9
+ import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1, normalizeAccountId as normalizeAccountId$1 } from "openclaw/plugin-sdk/routing";
10
+ import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$2, addWildcardAllowFrom, applyAccountNameToChannelSection, normalizeAccountId as normalizeAccountId$2, normalizeAllowFromEntries, normalizeSecretInputString, prepareScopedSetupConfig } from "openclaw/plugin-sdk/setup";
11
+ import { coerceSecretRef as coerceSecretRef$1 } from "openclaw/plugin-sdk/secret-ref-runtime";
12
+ //#region extensions/matrix/src/matrix/accounts.ts
13
+ function clean(value) {
14
+ return normalizeOptionalString(value) ?? "";
15
+ }
16
+ function resolveMatrixAccountAuthView(params) {
17
+ const normalizedAccountId = normalizeAccountId(params.accountId);
18
+ const matrix = resolveMatrixBaseConfig(params.cfg);
19
+ const account = findMatrixAccountConfig(params.cfg, normalizedAccountId) ?? {};
20
+ const resolvedStrings = resolveMatrixAccountStringValues({
21
+ accountId: normalizedAccountId,
22
+ account: {
23
+ homeserver: clean(account.homeserver),
24
+ userId: clean(account.userId),
25
+ accessToken: typeof account.accessToken === "string" ? clean(account.accessToken) : "",
26
+ password: typeof account.password === "string" ? clean(account.password) : "",
27
+ deviceId: clean(account.deviceId),
28
+ deviceName: clean(account.deviceName)
29
+ },
30
+ scopedEnv: resolveScopedMatrixEnvConfig(normalizedAccountId, params.env),
31
+ channel: {
32
+ homeserver: clean(matrix.homeserver),
33
+ userId: clean(matrix.userId),
34
+ accessToken: typeof matrix.accessToken === "string" ? clean(matrix.accessToken) : "",
35
+ password: typeof matrix.password === "string" ? clean(matrix.password) : "",
36
+ deviceId: clean(matrix.deviceId),
37
+ deviceName: clean(matrix.deviceName)
38
+ },
39
+ globalEnv: resolveGlobalMatrixEnvConfig(params.env)
40
+ });
41
+ return {
42
+ homeserver: resolvedStrings.homeserver,
43
+ userId: resolvedStrings.userId,
44
+ accessToken: resolvedStrings.accessToken || void 0,
45
+ password: resolvedStrings.password || void 0
46
+ };
47
+ }
48
+ function resolveMatrixAccountUserId(params) {
49
+ const env = params.env ?? process.env;
50
+ const authView = resolveMatrixAccountAuthView({
51
+ cfg: params.cfg,
52
+ accountId: params.accountId,
53
+ env
54
+ });
55
+ const configuredUserId = authView.userId.trim();
56
+ if (configuredUserId) return configuredUserId;
57
+ const stored = loadMatrixCredentials(env, params.accountId);
58
+ if (!stored) return null;
59
+ if (authView.homeserver && stored.homeserver !== authView.homeserver) return null;
60
+ if (authView.accessToken && stored.accessToken !== authView.accessToken) return null;
61
+ return stored.userId.trim() || null;
62
+ }
63
+ function listMatrixAccountIds(cfg) {
64
+ const ids = resolveConfiguredMatrixAccountIds(cfg, process.env);
65
+ return ids.length > 0 ? ids : [DEFAULT_ACCOUNT_ID];
66
+ }
67
+ function resolveDefaultMatrixAccountId(cfg) {
68
+ return normalizeAccountId(resolveMatrixDefaultOrOnlyAccountId(cfg));
69
+ }
70
+ function resolveConfiguredMatrixBotUserIds(params) {
71
+ const env = params.env ?? process.env;
72
+ const currentAccountId = normalizeAccountId(params.accountId);
73
+ const accountIds = new Set(resolveConfiguredMatrixAccountIds(params.cfg, env));
74
+ if (resolveMatrixAccount({
75
+ cfg: params.cfg,
76
+ accountId: DEFAULT_ACCOUNT_ID,
77
+ env
78
+ }).configured) accountIds.add(DEFAULT_ACCOUNT_ID);
79
+ const ids = /* @__PURE__ */ new Set();
80
+ for (const accountId of accountIds) {
81
+ if (normalizeAccountId(accountId) === currentAccountId) continue;
82
+ if (!resolveMatrixAccount({
83
+ cfg: params.cfg,
84
+ accountId,
85
+ env
86
+ }).configured) continue;
87
+ const userId = resolveMatrixAccountUserId({
88
+ cfg: params.cfg,
89
+ accountId,
90
+ env
91
+ });
92
+ if (userId) ids.add(userId);
93
+ }
94
+ return ids;
95
+ }
96
+ function resolveMatrixAccount(params) {
97
+ const env = params.env ?? process.env;
98
+ const accountId = normalizeAccountId(params.accountId ?? resolveDefaultMatrixAccountId(params.cfg));
99
+ const matrixBase = resolveMatrixBaseConfig(params.cfg);
100
+ const base = resolveMatrixAccountConfig({
101
+ cfg: params.cfg,
102
+ accountId,
103
+ env
104
+ });
105
+ const explicitAuthConfig = accountId === DEFAULT_ACCOUNT_ID ? base : findMatrixAccountConfig(params.cfg, accountId) ?? {};
106
+ const enabled = base.enabled !== false && matrixBase.enabled !== false;
107
+ const authView = resolveMatrixAccountAuthView({
108
+ cfg: params.cfg,
109
+ accountId,
110
+ env
111
+ });
112
+ const hasHomeserver = Boolean(authView.homeserver);
113
+ const hasUserId = Boolean(authView.userId);
114
+ const hasAccessToken = Boolean(authView.accessToken) || hasConfiguredSecretInput(explicitAuthConfig.accessToken);
115
+ const hasPassword = Boolean(authView.password);
116
+ const hasPasswordAuth = hasUserId && (hasPassword || hasConfiguredSecretInput(explicitAuthConfig.password));
117
+ const stored = loadMatrixCredentials(env, accountId);
118
+ const hasStored = stored && authView.homeserver ? credentialsMatchConfig(stored, {
119
+ homeserver: authView.homeserver,
120
+ userId: authView.userId || ""
121
+ }) : false;
122
+ const configured = hasHomeserver && (hasAccessToken || hasPasswordAuth || hasStored);
123
+ return {
124
+ accountId,
125
+ enabled,
126
+ name: normalizeOptionalString(base.name),
127
+ configured,
128
+ homeserver: authView.homeserver || void 0,
129
+ userId: authView.userId || void 0,
130
+ config: base
131
+ };
132
+ }
133
+ //#endregion
134
+ //#region extensions/matrix/src/setup-contract.ts
135
+ const matrixSingleAccountKeysToMove = [
136
+ "deviceId",
137
+ "avatarUrl",
138
+ "initialSyncLimit",
139
+ "encryption",
140
+ "allowlistOnly",
141
+ "dangerouslyAllowNameMatching",
142
+ "allowBots",
143
+ "blockStreaming",
144
+ "replyToMode",
145
+ "threadReplies",
146
+ "textChunkLimit",
147
+ "chunkMode",
148
+ "responsePrefix",
149
+ "ackReaction",
150
+ "ackReactionScope",
151
+ "reactionNotifications",
152
+ "threadBindings",
153
+ "startupVerification",
154
+ "startupVerificationCooldownHours",
155
+ "mediaMaxMb",
156
+ "autoJoin",
157
+ "autoJoinAllowlist",
158
+ "dm",
159
+ "groups",
160
+ "rooms",
161
+ "actions"
162
+ ];
163
+ const matrixNamedAccountPromotionKeys = [
164
+ "name",
165
+ "homeserver",
166
+ "userId",
167
+ "accessToken",
168
+ "password",
169
+ "deviceId",
170
+ "deviceName",
171
+ "avatarUrl",
172
+ "initialSyncLimit",
173
+ "encryption"
174
+ ];
175
+ const singleAccountKeysToMove = [...matrixSingleAccountKeysToMove];
176
+ const namedAccountPromotionKeys = [...matrixNamedAccountPromotionKeys];
177
+ function resolveSingleAccountPromotionTarget(params) {
178
+ const accounts = typeof params.channel.accounts === "object" && params.channel.accounts ? params.channel.accounts : {};
179
+ const normalizedDefaultAccount = typeof params.channel.defaultAccount === "string" && params.channel.defaultAccount.trim() ? normalizeAccountId$1(params.channel.defaultAccount) : void 0;
180
+ const matchedAccountId = normalizedDefaultAccount ? Object.entries(accounts).find(([accountId, value]) => accountId && value && typeof value === "object" && normalizeAccountId$1(accountId) === normalizedDefaultAccount)?.[0] : void 0;
181
+ if (matchedAccountId) return matchedAccountId;
182
+ if (normalizedDefaultAccount) return DEFAULT_ACCOUNT_ID$1;
183
+ const namedAccounts = Object.entries(accounts).filter(([accountId, value]) => accountId && typeof value === "object" && value);
184
+ if (namedAccounts.length === 1) return namedAccounts[0][0];
185
+ if (namedAccounts.length > 1 && accounts[DEFAULT_ACCOUNT_ID$1] && typeof accounts[DEFAULT_ACCOUNT_ID$1] === "object") return DEFAULT_ACCOUNT_ID$1;
186
+ return DEFAULT_ACCOUNT_ID$1;
187
+ }
188
+ //#endregion
189
+ //#region extensions/matrix/src/matrix/config-update.ts
190
+ var config_update_exports = /* @__PURE__ */ __exportAll({
191
+ resolveMatrixConfigFieldPath: () => resolveMatrixConfigFieldPath,
192
+ resolveMatrixConfigPath: () => resolveMatrixConfigPath,
193
+ shouldStoreMatrixAccountAtTopLevel: () => shouldStoreMatrixAccountAtTopLevel,
194
+ updateMatrixAccountConfig: () => updateMatrixAccountConfig
195
+ });
196
+ const resolveMatrixConfigPath = resolveMatrixConfigPath$1;
197
+ function applyNullableStringField(target, key, value) {
198
+ if (value === void 0) return;
199
+ if (value === null) {
200
+ delete target[key];
201
+ return;
202
+ }
203
+ const trimmed = value.trim();
204
+ if (!trimmed) {
205
+ delete target[key];
206
+ return;
207
+ }
208
+ target[key] = trimmed;
209
+ }
210
+ function applyNullableSecretInputField(target, key, value, defaults) {
211
+ if (value === void 0) return;
212
+ if (value === null) {
213
+ delete target[key];
214
+ return;
215
+ }
216
+ if (typeof value === "string") {
217
+ const normalized = normalizeSecretInputString(value);
218
+ if (normalized) target[key] = normalized;
219
+ else delete target[key];
220
+ return;
221
+ }
222
+ const ref = coerceSecretRef$1(value, defaults);
223
+ if (!ref) throw new Error(`Invalid Matrix ${key} SecretInput.`);
224
+ target[key] = ref;
225
+ }
226
+ function cloneMatrixDmConfig(dm) {
227
+ if (!dm) return dm;
228
+ return {
229
+ ...dm,
230
+ ...dm.allowFrom ? { allowFrom: [...dm.allowFrom] } : {}
231
+ };
232
+ }
233
+ function cloneMatrixRoomMap(rooms) {
234
+ if (!rooms) return rooms;
235
+ return Object.fromEntries(Object.entries(rooms).map(([roomId, roomCfg]) => [roomId, roomCfg ? { ...roomCfg } : roomCfg]));
236
+ }
237
+ function applyNullableArrayField(target, key, value) {
238
+ if (value === void 0) return;
239
+ if (value === null) {
240
+ delete target[key];
241
+ return;
242
+ }
243
+ target[key] = [...value];
244
+ }
245
+ function updateMatrixAccountConfig(cfg, accountId, patch) {
246
+ const matrix = cfg.channels?.matrix ?? {};
247
+ const normalizedAccountId = normalizeAccountId(accountId);
248
+ const nextAccount = { ...findMatrixAccountConfig(cfg, normalizedAccountId) ?? (normalizedAccountId === DEFAULT_ACCOUNT_ID ? matrix : {}) };
249
+ if (patch.name !== void 0) if (patch.name === null) delete nextAccount.name;
250
+ else {
251
+ const trimmed = patch.name.trim();
252
+ if (trimmed) nextAccount.name = trimmed;
253
+ else delete nextAccount.name;
254
+ }
255
+ if (typeof patch.enabled === "boolean") nextAccount.enabled = patch.enabled;
256
+ else if (typeof nextAccount.enabled !== "boolean") nextAccount.enabled = true;
257
+ applyNullableStringField(nextAccount, "homeserver", patch.homeserver);
258
+ applyNullableStringField(nextAccount, "proxy", patch.proxy);
259
+ applyNullableStringField(nextAccount, "userId", patch.userId);
260
+ applyNullableSecretInputField(nextAccount, "accessToken", patch.accessToken, cfg.secrets?.defaults);
261
+ applyNullableSecretInputField(nextAccount, "password", patch.password, cfg.secrets?.defaults);
262
+ applyNullableStringField(nextAccount, "deviceId", patch.deviceId);
263
+ applyNullableStringField(nextAccount, "deviceName", patch.deviceName);
264
+ applyNullableStringField(nextAccount, "avatarUrl", patch.avatarUrl);
265
+ if (patch.allowPrivateNetwork !== void 0) {
266
+ const nextNetwork = nextAccount.network && typeof nextAccount.network === "object" ? { ...nextAccount.network } : {};
267
+ if (patch.allowPrivateNetwork === null) delete nextNetwork.dangerouslyAllowPrivateNetwork;
268
+ else nextNetwork.dangerouslyAllowPrivateNetwork = patch.allowPrivateNetwork;
269
+ if (Object.keys(nextNetwork).length > 0) nextAccount.network = nextNetwork;
270
+ else delete nextAccount.network;
271
+ }
272
+ if (patch.initialSyncLimit !== void 0) if (patch.initialSyncLimit === null) delete nextAccount.initialSyncLimit;
273
+ else nextAccount.initialSyncLimit = Math.max(0, Math.floor(patch.initialSyncLimit));
274
+ if (patch.encryption !== void 0) if (patch.encryption === null) delete nextAccount.encryption;
275
+ else nextAccount.encryption = patch.encryption;
276
+ if (patch.allowBots !== void 0) if (patch.allowBots === null) delete nextAccount.allowBots;
277
+ else nextAccount.allowBots = patch.allowBots;
278
+ if (patch.autoJoin !== void 0) if (patch.autoJoin === null) delete nextAccount.autoJoin;
279
+ else nextAccount.autoJoin = patch.autoJoin;
280
+ applyNullableArrayField(nextAccount, "autoJoinAllowlist", patch.autoJoinAllowlist);
281
+ if (patch.dm !== void 0) if (patch.dm === null) delete nextAccount.dm;
282
+ else nextAccount.dm = cloneMatrixDmConfig({
283
+ ...nextAccount.dm,
284
+ ...patch.dm
285
+ });
286
+ if (patch.groupPolicy !== void 0) if (patch.groupPolicy === null) delete nextAccount.groupPolicy;
287
+ else nextAccount.groupPolicy = patch.groupPolicy;
288
+ applyNullableArrayField(nextAccount, "groupAllowFrom", patch.groupAllowFrom);
289
+ if (patch.groups !== void 0) if (patch.groups === null) delete nextAccount.groups;
290
+ else nextAccount.groups = cloneMatrixRoomMap(patch.groups);
291
+ if (patch.rooms !== void 0) if (patch.rooms === null) delete nextAccount.rooms;
292
+ else nextAccount.rooms = cloneMatrixRoomMap(patch.rooms);
293
+ const nextAccounts = Object.fromEntries(Object.entries(matrix.accounts ?? {}).filter(([rawAccountId]) => rawAccountId === normalizedAccountId || normalizeAccountId(rawAccountId) !== normalizedAccountId));
294
+ if (shouldStoreMatrixAccountAtTopLevel(cfg, normalizedAccountId)) {
295
+ const { accounts: _ignoredAccounts, defaultAccount } = matrix;
296
+ const { accounts: _ignoredNextAccounts, defaultAccount: _ignoredNextDefaultAccount, ...topLevelAccount } = nextAccount;
297
+ return {
298
+ ...cfg,
299
+ channels: {
300
+ ...cfg.channels,
301
+ matrix: {
302
+ ...defaultAccount ? { defaultAccount } : {},
303
+ enabled: true,
304
+ ...topLevelAccount
305
+ }
306
+ }
307
+ };
308
+ }
309
+ return {
310
+ ...cfg,
311
+ channels: {
312
+ ...cfg.channels,
313
+ matrix: {
314
+ ...matrix,
315
+ enabled: true,
316
+ accounts: {
317
+ ...nextAccounts,
318
+ [normalizedAccountId]: nextAccount
319
+ }
320
+ }
321
+ }
322
+ };
323
+ }
324
+ //#endregion
325
+ //#region extensions/matrix/src/matrix/profile.ts
326
+ var profile_exports = /* @__PURE__ */ __exportAll({
327
+ MATRIX_PROFILE_AVATAR_MAX_BYTES: () => MATRIX_PROFILE_AVATAR_MAX_BYTES,
328
+ isMatrixHttpAvatarUri: () => isMatrixHttpAvatarUri,
329
+ isMatrixMxcUri: () => isMatrixMxcUri,
330
+ isSupportedMatrixAvatarSource: () => isSupportedMatrixAvatarSource,
331
+ syncMatrixOwnProfile: () => syncMatrixOwnProfile
332
+ });
333
+ const MATRIX_PROFILE_AVATAR_MAX_BYTES = 10 * 1024 * 1024;
334
+ function isMatrixMxcUri(value) {
335
+ return normalizeLowercaseStringOrEmpty(normalizeOptionalString(value)).startsWith("mxc://");
336
+ }
337
+ function isMatrixHttpAvatarUri(value) {
338
+ const normalized = normalizeLowercaseStringOrEmpty(normalizeOptionalString(value));
339
+ return normalized.startsWith("https://") || normalized.startsWith("http://");
340
+ }
341
+ function isSupportedMatrixAvatarSource(value) {
342
+ return isMatrixMxcUri(value) || isMatrixHttpAvatarUri(value);
343
+ }
344
+ async function uploadAvatarMedia(params) {
345
+ const media = await params.loadAvatar(params.avatarSource, params.avatarMaxBytes);
346
+ return await params.client.uploadContent(media.buffer, media.contentType, media.fileName || "avatar");
347
+ }
348
+ async function resolveAvatarUrl(params) {
349
+ const avatarPath = normalizeOptionalString(params.avatarPath) ?? null;
350
+ if (avatarPath) {
351
+ if (!params.loadAvatarFromPath) throw new Error("Matrix avatar path upload requires a media loader.");
352
+ return {
353
+ resolvedAvatarUrl: await uploadAvatarMedia({
354
+ client: params.client,
355
+ avatarSource: avatarPath,
356
+ avatarMaxBytes: params.avatarMaxBytes,
357
+ loadAvatar: params.loadAvatarFromPath
358
+ }),
359
+ uploadedAvatarSource: "path",
360
+ convertedAvatarFromHttp: false
361
+ };
362
+ }
363
+ const avatarUrl = normalizeOptionalString(params.avatarUrl) ?? null;
364
+ if (!avatarUrl) return {
365
+ resolvedAvatarUrl: null,
366
+ uploadedAvatarSource: null,
367
+ convertedAvatarFromHttp: false
368
+ };
369
+ if (isMatrixMxcUri(avatarUrl)) return {
370
+ resolvedAvatarUrl: avatarUrl,
371
+ uploadedAvatarSource: null,
372
+ convertedAvatarFromHttp: false
373
+ };
374
+ if (!isMatrixHttpAvatarUri(avatarUrl)) throw new Error("Matrix avatar URL must be an mxc:// URI or an http(s) URL.");
375
+ if (!params.loadAvatarFromUrl) throw new Error("Matrix avatar URL conversion requires a media loader.");
376
+ return {
377
+ resolvedAvatarUrl: await uploadAvatarMedia({
378
+ client: params.client,
379
+ avatarSource: avatarUrl,
380
+ avatarMaxBytes: params.avatarMaxBytes,
381
+ loadAvatar: params.loadAvatarFromUrl
382
+ }),
383
+ uploadedAvatarSource: "http",
384
+ convertedAvatarFromHttp: true
385
+ };
386
+ }
387
+ async function syncMatrixOwnProfile(params) {
388
+ const desiredDisplayName = normalizeOptionalString(params.displayName) ?? null;
389
+ const avatar = await resolveAvatarUrl({
390
+ client: params.client,
391
+ avatarUrl: params.avatarUrl ?? null,
392
+ avatarPath: params.avatarPath ?? null,
393
+ avatarMaxBytes: params.avatarMaxBytes ?? 10485760,
394
+ loadAvatarFromUrl: params.loadAvatarFromUrl,
395
+ loadAvatarFromPath: params.loadAvatarFromPath
396
+ });
397
+ const desiredAvatarUrl = avatar.resolvedAvatarUrl;
398
+ if (!desiredDisplayName && !desiredAvatarUrl) return {
399
+ skipped: true,
400
+ displayNameUpdated: false,
401
+ avatarUpdated: false,
402
+ resolvedAvatarUrl: null,
403
+ uploadedAvatarSource: avatar.uploadedAvatarSource,
404
+ convertedAvatarFromHttp: avatar.convertedAvatarFromHttp
405
+ };
406
+ let currentDisplayName;
407
+ let currentAvatarUrl;
408
+ try {
409
+ const currentProfile = await params.client.getUserProfile(params.userId);
410
+ currentDisplayName = normalizeOptionalString(currentProfile.displayname);
411
+ currentAvatarUrl = normalizeOptionalString(currentProfile.avatar_url);
412
+ } catch {}
413
+ let displayNameUpdated = false;
414
+ let avatarUpdated = false;
415
+ if (desiredDisplayName && currentDisplayName !== desiredDisplayName) {
416
+ await params.client.setDisplayName(desiredDisplayName);
417
+ displayNameUpdated = true;
418
+ }
419
+ if (desiredAvatarUrl && currentAvatarUrl !== desiredAvatarUrl) {
420
+ await params.client.setAvatarUrl(desiredAvatarUrl);
421
+ avatarUpdated = true;
422
+ }
423
+ return {
424
+ skipped: false,
425
+ displayNameUpdated,
426
+ avatarUpdated,
427
+ resolvedAvatarUrl: desiredAvatarUrl,
428
+ uploadedAvatarSource: avatar.uploadedAvatarSource,
429
+ convertedAvatarFromHttp: avatar.convertedAvatarFromHttp
430
+ };
431
+ }
432
+ //#endregion
433
+ //#region extensions/matrix/src/setup-config.ts
434
+ const channel$1 = "matrix";
435
+ const COMMON_SINGLE_ACCOUNT_KEYS_TO_MOVE = new Set([
436
+ "name",
437
+ "enabled",
438
+ "httpPort",
439
+ "webhookPath",
440
+ "webhookUrl",
441
+ "webhookSecret",
442
+ "service",
443
+ "region",
444
+ "homeserver",
445
+ "userId",
446
+ "accessToken",
447
+ "password",
448
+ "deviceName",
449
+ "url",
450
+ "code",
451
+ "dmPolicy",
452
+ "allowFrom",
453
+ "groupPolicy",
454
+ "groupAllowFrom",
455
+ "defaultTo"
456
+ ]);
457
+ const MATRIX_SINGLE_ACCOUNT_KEYS_TO_MOVE = new Set(matrixSingleAccountKeysToMove);
458
+ const MATRIX_NAMED_ACCOUNT_PROMOTION_KEYS = new Set(matrixNamedAccountPromotionKeys);
459
+ function cloneIfObject(value) {
460
+ if (value && typeof value === "object") return structuredClone(value);
461
+ return value;
462
+ }
463
+ function resolveSetupAvatarUrl(input) {
464
+ const avatarUrl = input.avatarUrl;
465
+ if (typeof avatarUrl !== "string") return;
466
+ return avatarUrl.trim() || void 0;
467
+ }
468
+ function resolveExistingMatrixAccountKey(accounts, targetAccountId) {
469
+ const normalizedTargetAccountId = normalizeAccountId$2(targetAccountId);
470
+ return Object.keys(accounts).find((accountId) => normalizeAccountId$2(accountId) === normalizedTargetAccountId) ?? targetAccountId;
471
+ }
472
+ function moveSingleMatrixAccountConfigToNamedAccount(cfg) {
473
+ const baseConfig = cfg.channels?.[channel$1];
474
+ const base = typeof baseConfig === "object" && baseConfig ? baseConfig : void 0;
475
+ if (!base) return cfg;
476
+ const accounts = typeof base.accounts === "object" && base.accounts ? base.accounts : {};
477
+ const hasNamedAccounts = Object.keys(accounts).some(Boolean);
478
+ const keysToMove = Object.entries(base).filter(([key, value]) => {
479
+ if (key === "accounts" || key === "enabled" || value === void 0) return false;
480
+ if (!COMMON_SINGLE_ACCOUNT_KEYS_TO_MOVE.has(key) && !MATRIX_SINGLE_ACCOUNT_KEYS_TO_MOVE.has(key)) return false;
481
+ if (hasNamedAccounts && !MATRIX_NAMED_ACCOUNT_PROMOTION_KEYS.has(key)) return false;
482
+ return true;
483
+ }).map(([key]) => key);
484
+ if (keysToMove.length === 0) return cfg;
485
+ const resolvedTargetAccountId = resolveExistingMatrixAccountKey(accounts, resolveSingleAccountPromotionTarget({ channel: base }));
486
+ const nextAccount = { ...accounts[resolvedTargetAccountId] };
487
+ for (const key of keysToMove) nextAccount[key] = cloneIfObject(base[key]);
488
+ const nextChannel = { ...base };
489
+ for (const key of keysToMove) delete nextChannel[key];
490
+ return {
491
+ ...cfg,
492
+ channels: {
493
+ ...cfg.channels,
494
+ [channel$1]: {
495
+ ...nextChannel,
496
+ accounts: {
497
+ ...accounts,
498
+ [resolvedTargetAccountId]: nextAccount
499
+ }
500
+ }
501
+ }
502
+ };
503
+ }
504
+ function validateMatrixSetupInput(params) {
505
+ const avatarUrl = resolveSetupAvatarUrl(params.input);
506
+ if (avatarUrl && !isSupportedMatrixAvatarSource(avatarUrl)) return "Matrix avatar URL must be an mxc:// URI or an http(s) URL.";
507
+ if (params.input.useEnv) {
508
+ const envReadiness = resolveMatrixEnvAuthReadiness(params.accountId, process.env);
509
+ return envReadiness.ready ? null : envReadiness.missingMessage;
510
+ }
511
+ if (!params.input.homeserver?.trim()) return "Matrix requires --homeserver";
512
+ const accessToken = params.input.accessToken?.trim();
513
+ const password = normalizeSecretInputString(params.input.password);
514
+ const userId = params.input.userId?.trim();
515
+ if (!accessToken && !password) return "Matrix requires --access-token or --password";
516
+ if (!accessToken) {
517
+ if (!userId) return "Matrix requires --user-id when using --password";
518
+ if (!password) return "Matrix requires --password when using --user-id";
519
+ }
520
+ return null;
521
+ }
522
+ function applyMatrixSetupAccountConfig(params) {
523
+ const normalizedAccountId = normalizeAccountId$2(params.accountId);
524
+ const next = applyAccountNameToChannelSection({
525
+ cfg: normalizedAccountId !== DEFAULT_ACCOUNT_ID$2 ? moveSingleMatrixAccountConfigToNamedAccount(params.cfg) : params.cfg,
526
+ channelKey: channel$1,
527
+ accountId: normalizedAccountId,
528
+ name: params.input.name
529
+ });
530
+ const avatarUrl = resolveSetupAvatarUrl(params.input);
531
+ if (params.input.useEnv) return updateMatrixAccountConfig(next, normalizedAccountId, {
532
+ enabled: true,
533
+ homeserver: null,
534
+ allowPrivateNetwork: null,
535
+ proxy: null,
536
+ userId: null,
537
+ accessToken: null,
538
+ password: null,
539
+ deviceId: null,
540
+ deviceName: null,
541
+ avatarUrl
542
+ });
543
+ const accessToken = params.input.accessToken?.trim();
544
+ const password = normalizeSecretInputString(params.input.password);
545
+ const userId = params.input.userId?.trim();
546
+ return updateMatrixAccountConfig(next, normalizedAccountId, {
547
+ enabled: true,
548
+ homeserver: params.input.homeserver?.trim(),
549
+ allowPrivateNetwork: typeof params.input.dangerouslyAllowPrivateNetwork === "boolean" ? params.input.dangerouslyAllowPrivateNetwork : typeof params.input.allowPrivateNetwork === "boolean" ? params.input.allowPrivateNetwork : void 0,
550
+ proxy: normalizeOptionalString(params.input.proxy),
551
+ userId: password && !userId ? null : userId,
552
+ accessToken: accessToken || (password ? null : void 0),
553
+ password: password || (accessToken ? null : void 0),
554
+ deviceName: params.input.deviceName?.trim(),
555
+ avatarUrl,
556
+ initialSyncLimit: params.input.initialSyncLimit
557
+ });
558
+ }
559
+ //#endregion
560
+ //#region extensions/matrix/src/setup-dm-policy.ts
561
+ function resolveMatrixSetupDmAllowFrom(policy, allowFrom) {
562
+ if (policy === "open") return addWildcardAllowFrom(allowFrom);
563
+ return normalizeAllowFromEntries(allowFrom ?? []).filter((entry) => entry !== "*");
564
+ }
565
+ //#endregion
566
+ //#region extensions/matrix/src/setup-core.ts
567
+ const channel = "matrix";
568
+ function resolveMatrixSetupAccountId(params) {
569
+ return normalizeAccountId$2(params.accountId?.trim() || params.name?.trim() || DEFAULT_ACCOUNT_ID$2);
570
+ }
571
+ function resolveMatrixSetupWizardAccountId(cfg, accountId) {
572
+ return normalizeAccountId$2(accountId?.trim() || resolveDefaultMatrixAccountId(cfg) || DEFAULT_ACCOUNT_ID$2);
573
+ }
574
+ function setMatrixDmPolicy(cfg, policy, accountId) {
575
+ const resolvedAccountId = resolveMatrixSetupWizardAccountId(cfg, accountId);
576
+ const existing = resolveMatrixAccountConfig({
577
+ cfg,
578
+ accountId: resolvedAccountId
579
+ });
580
+ const allowFrom = resolveMatrixSetupDmAllowFrom(policy, existing.dm?.allowFrom);
581
+ return updateMatrixAccountConfig(cfg, resolvedAccountId, { dm: {
582
+ ...existing.dm,
583
+ policy,
584
+ allowFrom
585
+ } });
586
+ }
587
+ function createMatrixSetupWizardProxy(loadWizardModule) {
588
+ let wizardPromise = null;
589
+ const loadWizard = () => {
590
+ wizardPromise ??= loadWizardModule().then((module) => module.matrixSetupWizard);
591
+ return wizardPromise;
592
+ };
593
+ return {
594
+ channel,
595
+ getStatus: async (ctx) => await (await loadWizard()).getStatus(ctx),
596
+ configure: async (ctx) => await (await loadWizard()).configure(ctx),
597
+ configureInteractive: async (ctx) => {
598
+ const wizard = await loadWizard();
599
+ return await (wizard.configureInteractive ?? wizard.configure)(ctx);
600
+ },
601
+ configureWhenConfigured: async (ctx) => {
602
+ const wizard = await loadWizard();
603
+ return await (wizard.configureWhenConfigured ?? wizard.configureInteractive ?? wizard.configure)(ctx);
604
+ },
605
+ afterConfigWritten: async (ctx) => await (await loadWizard()).afterConfigWritten?.(ctx),
606
+ dmPolicy: {
607
+ label: "Matrix",
608
+ channel,
609
+ policyKey: "channels.matrix.dm.policy",
610
+ allowFromKey: "channels.matrix.dm.allowFrom",
611
+ resolveConfigKeys: (cfg, accountId) => {
612
+ const resolvedAccountId = resolveMatrixSetupWizardAccountId(cfg, accountId);
613
+ return {
614
+ policyKey: resolveMatrixConfigFieldPath(cfg, resolvedAccountId, "dm.policy"),
615
+ allowFromKey: resolveMatrixConfigFieldPath(cfg, resolvedAccountId, "dm.allowFrom")
616
+ };
617
+ },
618
+ getCurrent: (cfg, accountId) => resolveMatrixAccountConfig({
619
+ cfg,
620
+ accountId: resolveMatrixSetupWizardAccountId(cfg, accountId)
621
+ }).dm?.policy ?? "pairing",
622
+ setPolicy: (cfg, policy, accountId) => setMatrixDmPolicy(cfg, policy, accountId),
623
+ promptAllowFrom: async (params) => {
624
+ const promptAllowFrom = (await loadWizard()).dmPolicy?.promptAllowFrom;
625
+ return promptAllowFrom ? await promptAllowFrom(params) : params.cfg;
626
+ }
627
+ },
628
+ disable: (cfg) => ({
629
+ ...cfg,
630
+ channels: {
631
+ ...cfg.channels,
632
+ matrix: {
633
+ ...cfg.channels?.matrix,
634
+ enabled: false
635
+ }
636
+ }
637
+ })
638
+ };
639
+ }
640
+ const matrixSetupAdapter = {
641
+ resolveAccountId: ({ accountId, input }) => resolveMatrixSetupAccountId({
642
+ accountId,
643
+ name: input?.name
644
+ }),
645
+ resolveBindingAccountId: ({ accountId, agentId }) => resolveMatrixSetupAccountId({
646
+ accountId,
647
+ name: agentId
648
+ }),
649
+ applyAccountName: ({ cfg, accountId, name }) => prepareScopedSetupConfig({
650
+ cfg,
651
+ channelKey: channel,
652
+ accountId,
653
+ name
654
+ }),
655
+ validateInput: ({ accountId, input }) => validateMatrixSetupInput({
656
+ accountId,
657
+ input
658
+ }),
659
+ applyAccountConfig: ({ cfg, accountId, input }) => applyMatrixSetupAccountConfig({
660
+ cfg,
661
+ accountId,
662
+ input
663
+ }),
664
+ afterAccountConfigWritten: async ({ previousCfg, cfg, accountId, runtime }) => {
665
+ const { runMatrixSetupBootstrapAfterConfigWrite } = await import("./setup-bootstrap-krQU60Az.js");
666
+ await runMatrixSetupBootstrapAfterConfigWrite({
667
+ previousCfg,
668
+ cfg,
669
+ accountId,
670
+ runtime
671
+ });
672
+ }
673
+ };
674
+ //#endregion
675
+ export { profile_exports as a, resolveMatrixConfigPath as c, resolveSingleAccountPromotionTarget as d, singleAccountKeysToMove as f, resolveMatrixAccount as g, resolveDefaultMatrixAccountId as h, moveSingleMatrixAccountConfigToNamedAccount as i, updateMatrixAccountConfig as l, resolveConfiguredMatrixBotUserIds as m, matrixSetupAdapter as n, syncMatrixOwnProfile as o, listMatrixAccountIds as p, resolveMatrixSetupDmAllowFrom as r, config_update_exports as s, createMatrixSetupWizardProxy as t, namedAccountPromotionKeys as u };
@@ -1,6 +1,5 @@
1
- import { i as resolveMatrixAccount } from "./accounts-Bm90Rzvp.js";
2
- import { r as matrixConfigAdapter, t as MatrixChannelConfigSchema } from "./config-schema-B975BYl0.js";
3
- import { n as matrixSetupAdapter, t as createMatrixSetupWizardProxy } from "./setup-core-B5X7HxAP.js";
1
+ import { g as resolveMatrixAccount, n as matrixSetupAdapter, t as createMatrixSetupWizardProxy } from "./setup-core-CgOV8zmh.js";
2
+ import { r as matrixConfigAdapter, t as MatrixChannelConfigSchema } from "./config-schema-BPCzSyjT.js";
4
3
  import { describeAccountSnapshot } from "openclaw/plugin-sdk/account-helpers";
5
4
  const matrixSetupPlugin = {
6
5
  id: "matrix",
@@ -14,7 +13,7 @@ const matrixSetupPlugin = {
14
13
  order: 70,
15
14
  quickstartAllowFrom: true
16
15
  },
17
- setupWizard: createMatrixSetupWizardProxy(async () => ({ matrixSetupWizard: (await import("./setup-surface-DuRQrrpU.js").then((n) => n.t)).matrixSetupWizard })),
16
+ setupWizard: createMatrixSetupWizardProxy(async () => ({ matrixSetupWizard: (await import("./setup-surface-BgUaEySF.js").then((n) => n.t)).matrixSetupWizard })),
18
17
  setup: matrixSetupAdapter,
19
18
  capabilities: {
20
19
  chatTypes: [