@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
@@ -1,130 +0,0 @@
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 };
@@ -1,68 +0,0 @@
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 };
@@ -1,19 +0,0 @@
1
- import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
2
- //#region extensions/matrix/src/matrix/config-paths.ts
3
- function shouldStoreMatrixAccountAtTopLevel(cfg, accountId) {
4
- if (normalizeAccountId(accountId) !== DEFAULT_ACCOUNT_ID) return false;
5
- const accounts = cfg.channels?.matrix?.accounts;
6
- return !accounts || Object.keys(accounts).length === 0;
7
- }
8
- function resolveMatrixConfigPath(cfg, accountId) {
9
- const normalizedAccountId = normalizeAccountId(accountId);
10
- if (shouldStoreMatrixAccountAtTopLevel(cfg, normalizedAccountId)) return "channels.matrix";
11
- return `channels.matrix.accounts.${normalizedAccountId}`;
12
- }
13
- function resolveMatrixConfigFieldPath(cfg, accountId, fieldPath) {
14
- const suffix = fieldPath.trim().replace(/^\.+/, "");
15
- if (!suffix) return resolveMatrixConfigPath(cfg, accountId);
16
- return `${resolveMatrixConfigPath(cfg, accountId)}.${suffix}`;
17
- }
18
- //#endregion
19
- export { resolveMatrixConfigPath as n, shouldStoreMatrixAccountAtTopLevel as r, resolveMatrixConfigFieldPath as t };
@@ -1,143 +0,0 @@
1
- import { t as __exportAll } from "./rolldown-runtime-DUslC3ob.js";
2
- import { t as findMatrixAccountConfig } from "./account-config-D2W-V1eQ.js";
3
- import { n as resolveMatrixConfigPath$1, r as shouldStoreMatrixAccountAtTopLevel, t as resolveMatrixConfigFieldPath } from "./config-paths-nsVaysCu.js";
4
- import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
5
- import { normalizeSecretInputString } from "openclaw/plugin-sdk/setup";
6
- import { coerceSecretRef } from "openclaw/plugin-sdk/secret-ref-runtime";
7
- //#region extensions/matrix/src/matrix/config-update.ts
8
- var config_update_exports = /* @__PURE__ */ __exportAll({
9
- resolveMatrixConfigFieldPath: () => resolveMatrixConfigFieldPath,
10
- resolveMatrixConfigPath: () => resolveMatrixConfigPath,
11
- shouldStoreMatrixAccountAtTopLevel: () => shouldStoreMatrixAccountAtTopLevel,
12
- updateMatrixAccountConfig: () => updateMatrixAccountConfig
13
- });
14
- const resolveMatrixConfigPath = resolveMatrixConfigPath$1;
15
- function applyNullableStringField(target, key, value) {
16
- if (value === void 0) return;
17
- if (value === null) {
18
- delete target[key];
19
- return;
20
- }
21
- const trimmed = value.trim();
22
- if (!trimmed) {
23
- delete target[key];
24
- return;
25
- }
26
- target[key] = trimmed;
27
- }
28
- function applyNullableSecretInputField(target, key, value, defaults) {
29
- if (value === void 0) return;
30
- if (value === null) {
31
- delete target[key];
32
- return;
33
- }
34
- if (typeof value === "string") {
35
- const normalized = normalizeSecretInputString(value);
36
- if (normalized) target[key] = normalized;
37
- else delete target[key];
38
- return;
39
- }
40
- const ref = coerceSecretRef(value, defaults);
41
- if (!ref) throw new Error(`Invalid Matrix ${key} SecretInput.`);
42
- target[key] = ref;
43
- }
44
- function cloneMatrixDmConfig(dm) {
45
- if (!dm) return dm;
46
- return {
47
- ...dm,
48
- ...dm.allowFrom ? { allowFrom: [...dm.allowFrom] } : {}
49
- };
50
- }
51
- function cloneMatrixRoomMap(rooms) {
52
- if (!rooms) return rooms;
53
- return Object.fromEntries(Object.entries(rooms).map(([roomId, roomCfg]) => [roomId, roomCfg ? { ...roomCfg } : roomCfg]));
54
- }
55
- function applyNullableArrayField(target, key, value) {
56
- if (value === void 0) return;
57
- if (value === null) {
58
- delete target[key];
59
- return;
60
- }
61
- target[key] = [...value];
62
- }
63
- function updateMatrixAccountConfig(cfg, accountId, patch) {
64
- const matrix = cfg.channels?.matrix ?? {};
65
- const normalizedAccountId = normalizeAccountId(accountId);
66
- const nextAccount = { ...findMatrixAccountConfig(cfg, normalizedAccountId) ?? (normalizedAccountId === DEFAULT_ACCOUNT_ID ? matrix : {}) };
67
- if (patch.name !== void 0) if (patch.name === null) delete nextAccount.name;
68
- else {
69
- const trimmed = patch.name.trim();
70
- if (trimmed) nextAccount.name = trimmed;
71
- else delete nextAccount.name;
72
- }
73
- if (typeof patch.enabled === "boolean") nextAccount.enabled = patch.enabled;
74
- else if (typeof nextAccount.enabled !== "boolean") nextAccount.enabled = true;
75
- applyNullableStringField(nextAccount, "homeserver", patch.homeserver);
76
- applyNullableStringField(nextAccount, "proxy", patch.proxy);
77
- applyNullableStringField(nextAccount, "userId", patch.userId);
78
- applyNullableSecretInputField(nextAccount, "accessToken", patch.accessToken, cfg.secrets?.defaults);
79
- applyNullableSecretInputField(nextAccount, "password", patch.password, cfg.secrets?.defaults);
80
- applyNullableStringField(nextAccount, "deviceId", patch.deviceId);
81
- applyNullableStringField(nextAccount, "deviceName", patch.deviceName);
82
- applyNullableStringField(nextAccount, "avatarUrl", patch.avatarUrl);
83
- if (patch.allowPrivateNetwork !== void 0) {
84
- const nextNetwork = nextAccount.network && typeof nextAccount.network === "object" ? { ...nextAccount.network } : {};
85
- if (patch.allowPrivateNetwork === null) delete nextNetwork.dangerouslyAllowPrivateNetwork;
86
- else nextNetwork.dangerouslyAllowPrivateNetwork = patch.allowPrivateNetwork;
87
- if (Object.keys(nextNetwork).length > 0) nextAccount.network = nextNetwork;
88
- else delete nextAccount.network;
89
- }
90
- if (patch.initialSyncLimit !== void 0) if (patch.initialSyncLimit === null) delete nextAccount.initialSyncLimit;
91
- else nextAccount.initialSyncLimit = Math.max(0, Math.floor(patch.initialSyncLimit));
92
- if (patch.encryption !== void 0) if (patch.encryption === null) delete nextAccount.encryption;
93
- else nextAccount.encryption = patch.encryption;
94
- if (patch.allowBots !== void 0) if (patch.allowBots === null) delete nextAccount.allowBots;
95
- else nextAccount.allowBots = patch.allowBots;
96
- if (patch.autoJoin !== void 0) if (patch.autoJoin === null) delete nextAccount.autoJoin;
97
- else nextAccount.autoJoin = patch.autoJoin;
98
- applyNullableArrayField(nextAccount, "autoJoinAllowlist", patch.autoJoinAllowlist);
99
- if (patch.dm !== void 0) if (patch.dm === null) delete nextAccount.dm;
100
- else nextAccount.dm = cloneMatrixDmConfig({
101
- ...nextAccount.dm,
102
- ...patch.dm
103
- });
104
- if (patch.groupPolicy !== void 0) if (patch.groupPolicy === null) delete nextAccount.groupPolicy;
105
- else nextAccount.groupPolicy = patch.groupPolicy;
106
- applyNullableArrayField(nextAccount, "groupAllowFrom", patch.groupAllowFrom);
107
- if (patch.groups !== void 0) if (patch.groups === null) delete nextAccount.groups;
108
- else nextAccount.groups = cloneMatrixRoomMap(patch.groups);
109
- if (patch.rooms !== void 0) if (patch.rooms === null) delete nextAccount.rooms;
110
- else nextAccount.rooms = cloneMatrixRoomMap(patch.rooms);
111
- const nextAccounts = Object.fromEntries(Object.entries(matrix.accounts ?? {}).filter(([rawAccountId]) => rawAccountId === normalizedAccountId || normalizeAccountId(rawAccountId) !== normalizedAccountId));
112
- if (shouldStoreMatrixAccountAtTopLevel(cfg, normalizedAccountId)) {
113
- const { accounts: _ignoredAccounts, defaultAccount } = matrix;
114
- const { accounts: _ignoredNextAccounts, defaultAccount: _ignoredNextDefaultAccount, ...topLevelAccount } = nextAccount;
115
- return {
116
- ...cfg,
117
- channels: {
118
- ...cfg.channels,
119
- matrix: {
120
- ...defaultAccount ? { defaultAccount } : {},
121
- enabled: true,
122
- ...topLevelAccount
123
- }
124
- }
125
- };
126
- }
127
- return {
128
- ...cfg,
129
- channels: {
130
- ...cfg.channels,
131
- matrix: {
132
- ...matrix,
133
- enabled: true,
134
- accounts: {
135
- ...nextAccounts,
136
- [normalizedAccountId]: nextAccount
137
- }
138
- }
139
- }
140
- };
141
- }
142
- //#endregion
143
- export { resolveMatrixConfigPath as n, updateMatrixAccountConfig as r, config_update_exports as t };
@@ -1,251 +0,0 @@
1
- import { t as __exportAll } from "./rolldown-runtime-DUslC3ob.js";
2
- import { t as isMatrixQualifiedUserId } from "./target-ids-80nQ2gql.js";
3
- import { n as MATRIX_REACTION_EVENT_TYPE, t as MATRIX_ANNOTATION_RELATION_TYPE } from "./reaction-common-ejrL19w-.js";
4
- import { r as inspectMatrixDirectRoomEvidence } from "./direct-room-XkutHjES.js";
5
- import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
6
- import { KeyedAsyncQueue } from "openclaw/plugin-sdk/keyed-async-queue";
7
- //#region extensions/matrix/src/matrix/send/types.ts
8
- const MsgType = {
9
- Text: "m.text",
10
- Image: "m.image",
11
- Audio: "m.audio",
12
- Video: "m.video",
13
- File: "m.file",
14
- Notice: "m.notice"
15
- };
16
- const RelationType = {
17
- Annotation: MATRIX_ANNOTATION_RELATION_TYPE,
18
- Replace: "m.replace",
19
- Thread: "m.thread"
20
- };
21
- const EventType = {
22
- Direct: "m.direct",
23
- Reaction: MATRIX_REACTION_EVENT_TYPE,
24
- RoomMessage: "m.room.message"
25
- };
26
- const MATRIX_OPENCLAW_FINALIZED_PREVIEW_KEY = "com.openclaw.finalized_preview";
27
- /**
28
- * MSC4357 live marker key.
29
- * When present on event content, signals that the message is still being
30
- * streamed (e.g. an LLM generating a response). Supporting clients render
31
- * the message with a streaming animation until an edit without this marker
32
- * arrives, indicating the stream is complete.
33
- * @see https://github.com/matrix-org/matrix-spec-proposals/pull/4357
34
- */
35
- const MSC4357_LIVE_KEY = "org.matrix.msc4357.live";
36
- //#endregion
37
- //#region extensions/matrix/src/matrix/direct-management.ts
38
- var direct_management_exports = /* @__PURE__ */ __exportAll({
39
- inspectMatrixDirectRooms: () => inspectMatrixDirectRooms,
40
- persistMatrixDirectRoomMapping: () => persistMatrixDirectRoomMapping,
41
- promoteMatrixDirectRoomCandidate: () => promoteMatrixDirectRoomCandidate,
42
- repairMatrixDirectRooms: () => repairMatrixDirectRooms
43
- });
44
- const DIRECT_ACCOUNT_DATA_QUEUE_KEY = EventType.Direct;
45
- const directAccountDataWriteQueues = /* @__PURE__ */ new WeakMap();
46
- async function readMatrixDirectAccountData(client) {
47
- try {
48
- const direct = await client.getAccountData(EventType.Direct);
49
- return direct && typeof direct === "object" && !Array.isArray(direct) ? direct : {};
50
- } catch {
51
- return {};
52
- }
53
- }
54
- function normalizeRemoteUserId(remoteUserId) {
55
- const normalized = normalizeOptionalString(remoteUserId) ?? "";
56
- if (!isMatrixQualifiedUserId(normalized)) throw new Error(`Matrix user IDs must be fully qualified (got "${remoteUserId}")`);
57
- return normalized;
58
- }
59
- function normalizeMappedRoomIds(direct, remoteUserId) {
60
- const current = direct[remoteUserId];
61
- if (!Array.isArray(current)) return [];
62
- const seen = /* @__PURE__ */ new Set();
63
- const normalized = [];
64
- for (const value of current) {
65
- const roomId = normalizeOptionalString(value) ?? "";
66
- if (!roomId || seen.has(roomId)) continue;
67
- seen.add(roomId);
68
- normalized.push(roomId);
69
- }
70
- return normalized;
71
- }
72
- function normalizeRoomIdList(values) {
73
- const seen = /* @__PURE__ */ new Set();
74
- const normalized = [];
75
- for (const value of values) {
76
- const roomId = value.trim();
77
- if (!roomId || seen.has(roomId)) continue;
78
- seen.add(roomId);
79
- normalized.push(roomId);
80
- }
81
- return normalized;
82
- }
83
- function hasMatrixDirectRoomMappings(params) {
84
- const current = normalizeMappedRoomIds(params.directContent, params.remoteUserId);
85
- const next = normalizeRoomIdList([...params.roomIds, ...current]);
86
- return current.length === next.length && current.every((roomId, index) => roomId === next[index]);
87
- }
88
- function resolveDirectAccountDataWriteQueue(client) {
89
- const existing = directAccountDataWriteQueues.get(client);
90
- if (existing) return existing;
91
- const created = new KeyedAsyncQueue();
92
- directAccountDataWriteQueues.set(client, created);
93
- return created;
94
- }
95
- async function writeMatrixDirectRoomMappings(params) {
96
- return await resolveDirectAccountDataWriteQueue(params.client).enqueue(DIRECT_ACCOUNT_DATA_QUEUE_KEY, async () => {
97
- const directContentBefore = await readMatrixDirectAccountData(params.client);
98
- const directContentAfter = buildNextDirectContent({
99
- directContent: directContentBefore,
100
- remoteUserId: params.remoteUserId,
101
- roomIds: params.roomIds
102
- });
103
- const changed = !hasMatrixDirectRoomMappings({
104
- directContent: directContentBefore,
105
- remoteUserId: params.remoteUserId,
106
- roomIds: params.roomIds
107
- });
108
- if (changed) await params.client.setAccountData(EventType.Direct, directContentAfter);
109
- return {
110
- changed,
111
- directContentBefore,
112
- directContentAfter
113
- };
114
- });
115
- }
116
- async function classifyDirectRoomCandidate(params) {
117
- const evidence = await inspectMatrixDirectRoomEvidence({
118
- client: params.client,
119
- roomId: params.roomId,
120
- remoteUserId: params.remoteUserId,
121
- selfUserId: params.selfUserId
122
- });
123
- return {
124
- roomId: params.roomId,
125
- joinedMembers: evidence.joinedMembers,
126
- strict: evidence.strict && (params.source === "account-data" || evidence.memberStateFlag !== false),
127
- explicit: evidence.strict && (params.source === "account-data" || evidence.memberStateFlag !== false) && (params.source === "account-data" || evidence.viaMemberState),
128
- source: params.source
129
- };
130
- }
131
- function buildNextDirectContent(params) {
132
- const current = normalizeMappedRoomIds(params.directContent, params.remoteUserId);
133
- const nextRooms = normalizeRoomIdList([...params.roomIds, ...current]);
134
- return {
135
- ...params.directContent,
136
- [params.remoteUserId]: nextRooms
137
- };
138
- }
139
- async function persistMatrixDirectRoomMapping(params) {
140
- const remoteUserId = normalizeRemoteUserId(params.remoteUserId);
141
- return (await writeMatrixDirectRoomMappings({
142
- client: params.client,
143
- remoteUserId,
144
- roomIds: [params.roomId]
145
- })).changed;
146
- }
147
- async function promoteMatrixDirectRoomCandidate(params) {
148
- const remoteUserId = normalizeRemoteUserId(params.remoteUserId);
149
- const evidence = await inspectMatrixDirectRoomEvidence({
150
- client: params.client,
151
- roomId: params.roomId,
152
- remoteUserId,
153
- selfUserId: params.selfUserId
154
- });
155
- if (!evidence.strict) return {
156
- classifyAsDirect: false,
157
- repaired: false,
158
- reason: "not-strict"
159
- };
160
- if (evidence.memberStateFlag === false) return {
161
- classifyAsDirect: false,
162
- repaired: false,
163
- reason: "local-explicit-false"
164
- };
165
- try {
166
- const repaired = await persistMatrixDirectRoomMapping({
167
- client: params.client,
168
- remoteUserId,
169
- roomId: params.roomId
170
- });
171
- return {
172
- classifyAsDirect: true,
173
- repaired,
174
- roomId: params.roomId,
175
- reason: repaired ? "promoted" : "already-mapped"
176
- };
177
- } catch {
178
- return {
179
- classifyAsDirect: true,
180
- repaired: false,
181
- roomId: params.roomId,
182
- reason: "repair-failed"
183
- };
184
- }
185
- }
186
- async function inspectMatrixDirectRooms(params) {
187
- const remoteUserId = normalizeRemoteUserId(params.remoteUserId);
188
- const selfUserId = normalizeOptionalString(await params.client.getUserId().catch(() => null)) ?? null;
189
- const mappedRoomIds = normalizeMappedRoomIds(await readMatrixDirectAccountData(params.client), remoteUserId);
190
- const mappedRooms = await Promise.all(mappedRoomIds.map(async (roomId) => await classifyDirectRoomCandidate({
191
- client: params.client,
192
- roomId,
193
- remoteUserId,
194
- selfUserId,
195
- source: "account-data"
196
- })));
197
- const mappedStrict = mappedRooms.find((room) => room.strict);
198
- let joinedRooms = [];
199
- if (typeof params.client.getJoinedRooms === "function") try {
200
- const resolved = await params.client.getJoinedRooms();
201
- joinedRooms = Array.isArray(resolved) ? resolved : [];
202
- } catch {
203
- joinedRooms = [];
204
- }
205
- const discoveredStrictRooms = [];
206
- for (const roomId of normalizeRoomIdList(joinedRooms)) {
207
- if (mappedRoomIds.includes(roomId)) continue;
208
- const candidate = await classifyDirectRoomCandidate({
209
- client: params.client,
210
- roomId,
211
- remoteUserId,
212
- selfUserId,
213
- source: "joined"
214
- });
215
- if (candidate.strict) discoveredStrictRooms.push(candidate);
216
- }
217
- const discoveredStrictRoomIds = discoveredStrictRooms.map((room) => room.roomId);
218
- const discoveredExplicit = discoveredStrictRooms.find((room) => room.explicit);
219
- return {
220
- selfUserId,
221
- remoteUserId,
222
- mappedRoomIds,
223
- mappedRooms,
224
- discoveredStrictRoomIds,
225
- activeRoomId: mappedStrict?.roomId ?? discoveredExplicit?.roomId ?? discoveredStrictRoomIds[0] ?? null
226
- };
227
- }
228
- async function repairMatrixDirectRooms(params) {
229
- const remoteUserId = normalizeRemoteUserId(params.remoteUserId);
230
- const inspected = await inspectMatrixDirectRooms({
231
- client: params.client,
232
- remoteUserId
233
- });
234
- const activeRoomId = inspected.activeRoomId ?? await params.client.createDirectRoom(remoteUserId, { encrypted: params.encrypted === true });
235
- const createdRoomId = inspected.activeRoomId ? null : activeRoomId;
236
- const mappingWrite = await writeMatrixDirectRoomMappings({
237
- client: params.client,
238
- remoteUserId,
239
- roomIds: [activeRoomId, ...inspected.discoveredStrictRoomIds]
240
- });
241
- return {
242
- ...inspected,
243
- activeRoomId,
244
- createdRoomId,
245
- changed: mappingWrite.changed,
246
- directContentBefore: mappingWrite.directContentBefore,
247
- directContentAfter: mappingWrite.directContentAfter
248
- };
249
- }
250
- //#endregion
251
- export { repairMatrixDirectRooms as a, MSC4357_LIVE_KEY as c, promoteMatrixDirectRoomCandidate as i, MsgType as l, inspectMatrixDirectRooms as n, EventType as o, persistMatrixDirectRoomMapping as r, MATRIX_OPENCLAW_FINALIZED_PREVIEW_KEY as s, direct_management_exports as t, RelationType as u };
@@ -1,76 +0,0 @@
1
- import { t as __exportAll } from "./rolldown-runtime-DUslC3ob.js";
2
- //#region extensions/matrix/src/matrix/direct-room.ts
3
- var direct_room_exports = /* @__PURE__ */ __exportAll({
4
- hasDirectMatrixMemberFlag: () => hasDirectMatrixMemberFlag,
5
- inspectMatrixDirectRoomEvidence: () => inspectMatrixDirectRoomEvidence,
6
- isStrictDirectMembership: () => isStrictDirectMembership,
7
- isStrictDirectRoom: () => isStrictDirectRoom,
8
- normalizeJoinedMatrixMembers: () => normalizeJoinedMatrixMembers,
9
- readJoinedMatrixMembers: () => readJoinedMatrixMembers
10
- });
11
- function trimMaybeString(value) {
12
- if (typeof value !== "string") return null;
13
- const trimmed = value.trim();
14
- return trimmed.length > 0 ? trimmed : null;
15
- }
16
- function normalizeJoinedMatrixMembers(joinedMembers) {
17
- if (!Array.isArray(joinedMembers)) return [];
18
- return joinedMembers.map((entry) => trimMaybeString(entry)).filter((entry) => Boolean(entry));
19
- }
20
- function isStrictDirectMembership(params) {
21
- const selfUserId = trimMaybeString(params.selfUserId);
22
- const remoteUserId = trimMaybeString(params.remoteUserId);
23
- const joinedMembers = params.joinedMembers ?? [];
24
- return Boolean(selfUserId && remoteUserId && joinedMembers.length === 2 && joinedMembers.includes(selfUserId) && joinedMembers.includes(remoteUserId));
25
- }
26
- async function readJoinedMatrixMembers(client, roomId) {
27
- try {
28
- return normalizeJoinedMatrixMembers(await client.getJoinedRoomMembers(roomId));
29
- } catch {
30
- return null;
31
- }
32
- }
33
- async function hasDirectMatrixMemberFlag(client, roomId, userId) {
34
- const normalizedUserId = trimMaybeString(userId);
35
- if (!normalizedUserId) return null;
36
- try {
37
- const state = await client.getRoomStateEvent(roomId, "m.room.member", normalizedUserId);
38
- if (state?.is_direct === true) return true;
39
- if (state?.is_direct === false) return false;
40
- return null;
41
- } catch {
42
- return null;
43
- }
44
- }
45
- async function inspectMatrixDirectRoomEvidence(params) {
46
- const selfUserId = params.selfUserId !== void 0 ? trimMaybeString(params.selfUserId) : trimMaybeString(await params.client.getUserId().catch(() => null));
47
- const joinedMembers = await readJoinedMatrixMembers(params.client, params.roomId);
48
- const strict = isStrictDirectMembership({
49
- selfUserId,
50
- remoteUserId: params.remoteUserId,
51
- joinedMembers
52
- });
53
- if (!strict) return {
54
- joinedMembers,
55
- strict: false,
56
- viaMemberState: false,
57
- memberStateFlag: null
58
- };
59
- const memberStateFlag = await hasDirectMatrixMemberFlag(params.client, params.roomId, selfUserId);
60
- return {
61
- joinedMembers,
62
- strict,
63
- viaMemberState: memberStateFlag === true,
64
- memberStateFlag
65
- };
66
- }
67
- async function isStrictDirectRoom(params) {
68
- return (await inspectMatrixDirectRoomEvidence({
69
- client: params.client,
70
- roomId: params.roomId,
71
- remoteUserId: params.remoteUserId,
72
- selfUserId: params.selfUserId
73
- })).strict;
74
- }
75
- //#endregion
76
- export { isStrictDirectRoom as a, isStrictDirectMembership as i, hasDirectMatrixMemberFlag as n, readJoinedMatrixMembers as o, inspectMatrixDirectRoomEvidence as r, direct_room_exports as t };