@openclaw/matrix 2026.5.14-beta.1 → 2026.5.16-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 (98) hide show
  1. package/dist/api.js +4 -4
  2. package/dist/{approval-handler.runtime-DcgDdi8L.js → approval-handler.runtime--UYE3D2j.js} +5 -6
  3. package/dist/{approval-ids-DoC2z7tR.js → approval-ids-D6IQvvRE.js} +1 -1
  4. package/dist/{approval-reaction-auth-BY5VFY-q.js → approval-reaction-auth-99PRu7rF.js} +2 -2
  5. package/dist/{channel-eRrwLDE9.js → channel-CwN56Pko.js} +285 -26
  6. package/dist/channel-plugin-api.js +1 -1
  7. package/dist/{channel.runtime-CsQesLGI.js → channel.runtime-9qwvlUwp.js} +8 -8
  8. package/dist/{cli-DAMPUa3J.js → cli-BeWdjXLV.js} +15 -17
  9. package/dist/{cli-metadata-Bt5SrlLo.js → cli-metadata-B2_76YSe.js} +1 -1
  10. package/dist/cli-metadata.js +1 -1
  11. package/dist/{client-DrmLRQnw.js → client-D6fFVbNM.js} +2 -2
  12. package/dist/{client-bootstrap-Ba68NvZB.js → client-bootstrap-DBwUKgC3.js} +3 -3
  13. package/dist/{client-DBDvsx0D.js → client-oci1tD6-.js} +4 -5
  14. package/dist/{account-config-LVxGiX7e.js → config-paths-msaDGRh6.js} +18 -1
  15. package/dist/{config-schema-DOKrNEs_.js → config-schema-BPCzSyjT.js} +70 -4
  16. package/dist/contract-api.js +5 -6
  17. package/dist/{create-client-ChlpNpAA.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-BevaUxax.js → crypto-runtime-B-SPS5mv.js} +5 -5
  21. package/dist/{directory-live-Btsr0yok.js → directory-live-BCfx1C0G.js} +3 -3
  22. package/dist/{doctor-qL-bgDwE.js → doctor-KuNYX5N3.js} +3 -3
  23. package/dist/doctor-contract-api.js +1 -1
  24. package/dist/{draft-stream-B-hyLmMw.js → draft-stream-BayHVmtO.js} +1 -2
  25. package/dist/{encryption-guidance-BPi3A_m3.js → encryption-guidance-1QoIvd-g.js} +1 -1
  26. package/dist/{http-client-C7AeVJay.js → http-client-DS3UoC_p.js} +1 -1
  27. package/dist/index.js +2 -2
  28. package/dist/{legacy-crypto-inspector-C4VpBdDV.js → legacy-crypto-inspector-_gWJGVQ_.js} +1 -1
  29. package/dist/{legacy-crypto-restore-Biw-w2ng.js → legacy-crypto-restore-B9eF1gob.js} +1 -1
  30. package/dist/{logging-DZHSPP5N.js → logging-bJ8EEe1G.js} +1 -1
  31. package/dist/{matrix-migration.runtime-CDasos7a.js → matrix-migration.runtime-Cf_wX9mk.js} +3 -3
  32. package/dist/{media-text-BLL8-Dr3.js → media-text-4h4YwCGC.js} +1 -1
  33. package/dist/{messages-BJi_jdEA.js → messages-BKTEUSwJ.js} +5 -5
  34. package/dist/{migration-snapshot.runtime-CKHE3xF9.js → migration-snapshot.runtime-C7yiKWS7.js} +1 -1
  35. package/dist/{monitor-COvHRaUQ.js → monitor-DPJO3wS1.js} +35 -35
  36. package/dist/plugin-entry.handlers.runtime.js +2 -2
  37. package/dist/probe.runtime-zExLz3Ek.js +3 -0
  38. package/dist/{profile-update-DK5rfmA-.js → profile-update-BAAflurI.js} +2 -3
  39. package/dist/{reaction-events-Cfvkp-A-.js → reaction-events-Dimh8FUE.js} +6 -6
  40. package/dist/{resolve-targets-ZSM4KKln.js → resolve-targets-DPqngj4V.js} +1 -1
  41. package/dist/{resolver.runtime-m_D8JSm3.js → resolver.runtime-C0RDK0VW.js} +1 -1
  42. package/dist/{route-D6rg-iXN.js → route-R-ajT21_.js} +1 -1
  43. package/dist/{runtime-api-DTKcXOhp.js → runtime-api-C-QeChQj.js} +1 -1
  44. package/dist/runtime-api.js +1 -1
  45. package/dist/runtime-heavy-api.js +2 -2
  46. package/dist/{sdk-BLBGvKEe.js → sdk-BwfNtBhM.js} +301 -13
  47. package/dist/secret-contract-api.js +1 -1
  48. package/dist/{send-D651usmb.js → send-CdoJ1pZY.js} +323 -6
  49. package/dist/{setup-bootstrap-DT2Gj9hX.js → setup-bootstrap-krQU60Az.js} +4 -4
  50. package/dist/setup-core-CgOV8zmh.js +675 -0
  51. package/dist/setup-plugin-api.js +3 -4
  52. package/dist/{setup-surface-KzA9__US.js → setup-surface-BgUaEySF.js} +7 -10
  53. package/dist/{config-xD5Y8nFT.js → shared-BlXw87Kp.js} +199 -9
  54. package/dist/{logger-CnZRVrux.js → startup-abort-br7BZHJQ.js} +32 -1
  55. package/dist/{startup-verification-Demyp0bP.js → startup-verification-CTfhD7V_.js} +2 -2
  56. package/dist/{storage-tC3ujLiW.js → storage-HI1nL3im.js} +1 -1
  57. package/dist/{subagent-hooks-DQbyqq9V.js → subagent-hooks-api-BgQgDwAS.js} +22 -1
  58. package/dist/subagent-hooks-api.js +1 -22
  59. package/dist/test-api.js +2 -2
  60. package/dist/thread-binding-api.js +1 -1
  61. package/dist/{thread-bindings-DHUszTA0.js → thread-bindings-8AyQOYDT.js} +2 -2
  62. package/dist/{tool-actions.runtime-Bn8bvkQN.js → tool-actions.runtime-BuCnleVD.js} +9 -9
  63. package/dist/{verification-BJT2k9TI.js → verification-DvC37Z_y.js} +2 -2
  64. package/package.json +6 -6
  65. package/dist/accounts--0L_EuMK.js +0 -130
  66. package/dist/allowlist-sTzpCn5d.js +0 -68
  67. package/dist/config-paths-nsVaysCu.js +0 -19
  68. package/dist/config-update-BBkpLB9o.js +0 -143
  69. package/dist/direct-management--Y8ypgLv.js +0 -251
  70. package/dist/direct-room-XkutHjES.js +0 -76
  71. package/dist/exec-approvals-to3d_jMv.js +0 -196
  72. package/dist/probe.runtime-sh9piX22.js +0 -3
  73. package/dist/profile-BlHu0wDX.js +0 -111
  74. package/dist/recovery-key-store-BTJ6jz5v.js +0 -294
  75. package/dist/session-store-metadata-DQXjgNLt.js +0 -77
  76. package/dist/setup-core-C-uKN68n.js +0 -116
  77. package/dist/setup-dm-policy-0_kFUfW4.js +0 -195
  78. package/dist/shared-DarXfhzC.js +0 -195
  79. package/dist/startup-abort-56edvmbM.js +0 -32
  80. /package/dist/{active-client-uhlxdhEy.js → active-client-DUi-lumi.js} +0 -0
  81. /package/dist/{approval-reactions-o2_tuH8D.js → approval-reactions-Cwd1PMCC.js} +0 -0
  82. /package/dist/{async-lock-uQfhfQIY.js → async-lock-SsmtFXtt.js} +0 -0
  83. /package/dist/{backup-health-Cabu_WQC.js → backup-health-3BHbHxyd.js} +0 -0
  84. /package/dist/{config-secret-input.runtime-DiKFehsE.js → config-secret-input.runtime-nbLCnJq7.js} +0 -0
  85. /package/dist/{crypto-node.runtime-pihzdpY7.js → crypto-node.runtime-D9qxgRPa.js} +0 -0
  86. /package/dist/{deps-DR0MIYrW.js → deps-LqqGWPWt.js} +0 -0
  87. /package/dist/{device-health-UVYpbA_W.js → device-health-Di9MUzFj.js} +0 -0
  88. /package/dist/{doctor-contract-D4-64QuJ.js → doctor-contract-s4gUPmRN.js} +0 -0
  89. /package/dist/{errors-CTcpEDq-.js → errors-BpHgvm2o.js} +0 -0
  90. /package/dist/{exec-approval-resolver-Bza9Dhlm.js → exec-approval-resolver-C8faS0XB.js} +0 -0
  91. /package/dist/{migration-snapshot-backup-DaCHTp8C.js → migration-snapshot-backup-BWTIFXgQ.js} +0 -0
  92. /package/dist/{reaction-common-ejrL19w-.js → reaction-common-B-QgNfEs.js} +0 -0
  93. /package/dist/{runtime-C6X4h_SJ.js → runtime-lwTSy9Yt.js} +0 -0
  94. /package/dist/{secret-contract-DcrJWCQI.js → secret-contract-e4SdhUtT.js} +0 -0
  95. /package/dist/{sync-state-C_beeevA.js → sync-state-Bx0gPaGA.js} +0 -0
  96. /package/dist/{thread-binding-api-Cq_E-E1K.js → thread-binding-api-Bx55B6hm.js} +0 -0
  97. /package/dist/{timeout-abort-signal-CtaIaP1v.js → timeout-abort-signal-sT0wAxVn.js} +0 -0
  98. /package/dist/{url-validation-DiK9j7jz.js → url-validation-CBZBxN3F.js} +0 -0
@@ -1,116 +0,0 @@
1
- import { a as resolveMatrixAccountConfig } from "./account-config-LVxGiX7e.js";
2
- import { r as resolveDefaultMatrixAccountId } from "./accounts--0L_EuMK.js";
3
- import { i as validateMatrixSetupInput, n as applyMatrixSetupAccountConfig, t as resolveMatrixSetupDmAllowFrom } from "./setup-dm-policy-0_kFUfW4.js";
4
- import { t as resolveMatrixConfigFieldPath } from "./config-paths-nsVaysCu.js";
5
- import { r as updateMatrixAccountConfig } from "./config-update-BBkpLB9o.js";
6
- import { DEFAULT_ACCOUNT_ID, normalizeAccountId, prepareScopedSetupConfig } from "openclaw/plugin-sdk/setup";
7
- //#region extensions/matrix/src/setup-core.ts
8
- const channel = "matrix";
9
- function resolveMatrixSetupAccountId(params) {
10
- return normalizeAccountId(params.accountId?.trim() || params.name?.trim() || DEFAULT_ACCOUNT_ID);
11
- }
12
- function resolveMatrixSetupWizardAccountId(cfg, accountId) {
13
- return normalizeAccountId(accountId?.trim() || resolveDefaultMatrixAccountId(cfg) || DEFAULT_ACCOUNT_ID);
14
- }
15
- function setMatrixDmPolicy(cfg, policy, accountId) {
16
- const resolvedAccountId = resolveMatrixSetupWizardAccountId(cfg, accountId);
17
- const existing = resolveMatrixAccountConfig({
18
- cfg,
19
- accountId: resolvedAccountId
20
- });
21
- const allowFrom = resolveMatrixSetupDmAllowFrom(policy, existing.dm?.allowFrom);
22
- return updateMatrixAccountConfig(cfg, resolvedAccountId, { dm: {
23
- ...existing.dm,
24
- policy,
25
- allowFrom
26
- } });
27
- }
28
- function createMatrixSetupWizardProxy(loadWizardModule) {
29
- let wizardPromise = null;
30
- const loadWizard = () => {
31
- wizardPromise ??= loadWizardModule().then((module) => module.matrixSetupWizard);
32
- return wizardPromise;
33
- };
34
- return {
35
- channel,
36
- getStatus: async (ctx) => await (await loadWizard()).getStatus(ctx),
37
- configure: async (ctx) => await (await loadWizard()).configure(ctx),
38
- configureInteractive: async (ctx) => {
39
- const wizard = await loadWizard();
40
- return await (wizard.configureInteractive ?? wizard.configure)(ctx);
41
- },
42
- configureWhenConfigured: async (ctx) => {
43
- const wizard = await loadWizard();
44
- return await (wizard.configureWhenConfigured ?? wizard.configureInteractive ?? wizard.configure)(ctx);
45
- },
46
- afterConfigWritten: async (ctx) => await (await loadWizard()).afterConfigWritten?.(ctx),
47
- dmPolicy: {
48
- label: "Matrix",
49
- channel,
50
- policyKey: "channels.matrix.dm.policy",
51
- allowFromKey: "channels.matrix.dm.allowFrom",
52
- resolveConfigKeys: (cfg, accountId) => {
53
- const resolvedAccountId = resolveMatrixSetupWizardAccountId(cfg, accountId);
54
- return {
55
- policyKey: resolveMatrixConfigFieldPath(cfg, resolvedAccountId, "dm.policy"),
56
- allowFromKey: resolveMatrixConfigFieldPath(cfg, resolvedAccountId, "dm.allowFrom")
57
- };
58
- },
59
- getCurrent: (cfg, accountId) => resolveMatrixAccountConfig({
60
- cfg,
61
- accountId: resolveMatrixSetupWizardAccountId(cfg, accountId)
62
- }).dm?.policy ?? "pairing",
63
- setPolicy: (cfg, policy, accountId) => setMatrixDmPolicy(cfg, policy, accountId),
64
- promptAllowFrom: async (params) => {
65
- const promptAllowFrom = (await loadWizard()).dmPolicy?.promptAllowFrom;
66
- return promptAllowFrom ? await promptAllowFrom(params) : params.cfg;
67
- }
68
- },
69
- disable: (cfg) => ({
70
- ...cfg,
71
- channels: {
72
- ...cfg.channels,
73
- matrix: {
74
- ...cfg.channels?.matrix,
75
- enabled: false
76
- }
77
- }
78
- })
79
- };
80
- }
81
- const matrixSetupAdapter = {
82
- resolveAccountId: ({ accountId, input }) => resolveMatrixSetupAccountId({
83
- accountId,
84
- name: input?.name
85
- }),
86
- resolveBindingAccountId: ({ accountId, agentId }) => resolveMatrixSetupAccountId({
87
- accountId,
88
- name: agentId
89
- }),
90
- applyAccountName: ({ cfg, accountId, name }) => prepareScopedSetupConfig({
91
- cfg,
92
- channelKey: channel,
93
- accountId,
94
- name
95
- }),
96
- validateInput: ({ accountId, input }) => validateMatrixSetupInput({
97
- accountId,
98
- input
99
- }),
100
- applyAccountConfig: ({ cfg, accountId, input }) => applyMatrixSetupAccountConfig({
101
- cfg,
102
- accountId,
103
- input
104
- }),
105
- afterAccountConfigWritten: async ({ previousCfg, cfg, accountId, runtime }) => {
106
- const { runMatrixSetupBootstrapAfterConfigWrite } = await import("./setup-bootstrap-DT2Gj9hX.js");
107
- await runMatrixSetupBootstrapAfterConfigWrite({
108
- previousCfg,
109
- cfg,
110
- accountId,
111
- runtime
112
- });
113
- }
114
- };
115
- //#endregion
116
- export { matrixSetupAdapter as n, createMatrixSetupWizardProxy as t };
@@ -1,195 +0,0 @@
1
- import { r as resolveMatrixEnvAuthReadiness } from "./env-auth-BJqGI8M6.js";
2
- import { r as updateMatrixAccountConfig } from "./config-update-BBkpLB9o.js";
3
- import { t as isSupportedMatrixAvatarSource } from "./profile-BlHu0wDX.js";
4
- import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
5
- import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/routing";
6
- import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1, addWildcardAllowFrom, applyAccountNameToChannelSection, normalizeAccountId as normalizeAccountId$1, normalizeAllowFromEntries, normalizeSecretInputString } from "openclaw/plugin-sdk/setup";
7
- //#region extensions/matrix/src/setup-contract.ts
8
- const matrixSingleAccountKeysToMove = [
9
- "deviceId",
10
- "avatarUrl",
11
- "initialSyncLimit",
12
- "encryption",
13
- "allowlistOnly",
14
- "dangerouslyAllowNameMatching",
15
- "allowBots",
16
- "blockStreaming",
17
- "replyToMode",
18
- "threadReplies",
19
- "textChunkLimit",
20
- "chunkMode",
21
- "responsePrefix",
22
- "ackReaction",
23
- "ackReactionScope",
24
- "reactionNotifications",
25
- "threadBindings",
26
- "startupVerification",
27
- "startupVerificationCooldownHours",
28
- "mediaMaxMb",
29
- "autoJoin",
30
- "autoJoinAllowlist",
31
- "dm",
32
- "groups",
33
- "rooms",
34
- "actions"
35
- ];
36
- const matrixNamedAccountPromotionKeys = [
37
- "name",
38
- "homeserver",
39
- "userId",
40
- "accessToken",
41
- "password",
42
- "deviceId",
43
- "deviceName",
44
- "avatarUrl",
45
- "initialSyncLimit",
46
- "encryption"
47
- ];
48
- const singleAccountKeysToMove = [...matrixSingleAccountKeysToMove];
49
- const namedAccountPromotionKeys = [...matrixNamedAccountPromotionKeys];
50
- function resolveSingleAccountPromotionTarget(params) {
51
- const accounts = typeof params.channel.accounts === "object" && params.channel.accounts ? params.channel.accounts : {};
52
- const normalizedDefaultAccount = typeof params.channel.defaultAccount === "string" && params.channel.defaultAccount.trim() ? normalizeAccountId(params.channel.defaultAccount) : void 0;
53
- const matchedAccountId = normalizedDefaultAccount ? Object.entries(accounts).find(([accountId, value]) => accountId && value && typeof value === "object" && normalizeAccountId(accountId) === normalizedDefaultAccount)?.[0] : void 0;
54
- if (matchedAccountId) return matchedAccountId;
55
- if (normalizedDefaultAccount) return DEFAULT_ACCOUNT_ID;
56
- const namedAccounts = Object.entries(accounts).filter(([accountId, value]) => accountId && typeof value === "object" && value);
57
- if (namedAccounts.length === 1) return namedAccounts[0][0];
58
- if (namedAccounts.length > 1 && accounts[DEFAULT_ACCOUNT_ID] && typeof accounts[DEFAULT_ACCOUNT_ID] === "object") return DEFAULT_ACCOUNT_ID;
59
- return DEFAULT_ACCOUNT_ID;
60
- }
61
- //#endregion
62
- //#region extensions/matrix/src/setup-config.ts
63
- const channel = "matrix";
64
- const COMMON_SINGLE_ACCOUNT_KEYS_TO_MOVE = new Set([
65
- "name",
66
- "enabled",
67
- "httpPort",
68
- "webhookPath",
69
- "webhookUrl",
70
- "webhookSecret",
71
- "service",
72
- "region",
73
- "homeserver",
74
- "userId",
75
- "accessToken",
76
- "password",
77
- "deviceName",
78
- "url",
79
- "code",
80
- "dmPolicy",
81
- "allowFrom",
82
- "groupPolicy",
83
- "groupAllowFrom",
84
- "defaultTo"
85
- ]);
86
- const MATRIX_SINGLE_ACCOUNT_KEYS_TO_MOVE = new Set(matrixSingleAccountKeysToMove);
87
- const MATRIX_NAMED_ACCOUNT_PROMOTION_KEYS = new Set(matrixNamedAccountPromotionKeys);
88
- function cloneIfObject(value) {
89
- if (value && typeof value === "object") return structuredClone(value);
90
- return value;
91
- }
92
- function resolveSetupAvatarUrl(input) {
93
- const avatarUrl = input.avatarUrl;
94
- if (typeof avatarUrl !== "string") return;
95
- return avatarUrl.trim() || void 0;
96
- }
97
- function resolveExistingMatrixAccountKey(accounts, targetAccountId) {
98
- const normalizedTargetAccountId = normalizeAccountId$1(targetAccountId);
99
- return Object.keys(accounts).find((accountId) => normalizeAccountId$1(accountId) === normalizedTargetAccountId) ?? targetAccountId;
100
- }
101
- function moveSingleMatrixAccountConfigToNamedAccount(cfg) {
102
- const baseConfig = cfg.channels?.[channel];
103
- const base = typeof baseConfig === "object" && baseConfig ? baseConfig : void 0;
104
- if (!base) return cfg;
105
- const accounts = typeof base.accounts === "object" && base.accounts ? base.accounts : {};
106
- const hasNamedAccounts = Object.keys(accounts).some(Boolean);
107
- const keysToMove = Object.entries(base).filter(([key, value]) => {
108
- if (key === "accounts" || key === "enabled" || value === void 0) return false;
109
- if (!COMMON_SINGLE_ACCOUNT_KEYS_TO_MOVE.has(key) && !MATRIX_SINGLE_ACCOUNT_KEYS_TO_MOVE.has(key)) return false;
110
- if (hasNamedAccounts && !MATRIX_NAMED_ACCOUNT_PROMOTION_KEYS.has(key)) return false;
111
- return true;
112
- }).map(([key]) => key);
113
- if (keysToMove.length === 0) return cfg;
114
- const resolvedTargetAccountId = resolveExistingMatrixAccountKey(accounts, resolveSingleAccountPromotionTarget({ channel: base }));
115
- const nextAccount = { ...accounts[resolvedTargetAccountId] };
116
- for (const key of keysToMove) nextAccount[key] = cloneIfObject(base[key]);
117
- const nextChannel = { ...base };
118
- for (const key of keysToMove) delete nextChannel[key];
119
- return {
120
- ...cfg,
121
- channels: {
122
- ...cfg.channels,
123
- [channel]: {
124
- ...nextChannel,
125
- accounts: {
126
- ...accounts,
127
- [resolvedTargetAccountId]: nextAccount
128
- }
129
- }
130
- }
131
- };
132
- }
133
- function validateMatrixSetupInput(params) {
134
- const avatarUrl = resolveSetupAvatarUrl(params.input);
135
- if (avatarUrl && !isSupportedMatrixAvatarSource(avatarUrl)) return "Matrix avatar URL must be an mxc:// URI or an http(s) URL.";
136
- if (params.input.useEnv) {
137
- const envReadiness = resolveMatrixEnvAuthReadiness(params.accountId, process.env);
138
- return envReadiness.ready ? null : envReadiness.missingMessage;
139
- }
140
- if (!params.input.homeserver?.trim()) return "Matrix requires --homeserver";
141
- const accessToken = params.input.accessToken?.trim();
142
- const password = normalizeSecretInputString(params.input.password);
143
- const userId = params.input.userId?.trim();
144
- if (!accessToken && !password) return "Matrix requires --access-token or --password";
145
- if (!accessToken) {
146
- if (!userId) return "Matrix requires --user-id when using --password";
147
- if (!password) return "Matrix requires --password when using --user-id";
148
- }
149
- return null;
150
- }
151
- function applyMatrixSetupAccountConfig(params) {
152
- const normalizedAccountId = normalizeAccountId$1(params.accountId);
153
- const next = applyAccountNameToChannelSection({
154
- cfg: normalizedAccountId !== DEFAULT_ACCOUNT_ID$1 ? moveSingleMatrixAccountConfigToNamedAccount(params.cfg) : params.cfg,
155
- channelKey: channel,
156
- accountId: normalizedAccountId,
157
- name: params.input.name
158
- });
159
- const avatarUrl = resolveSetupAvatarUrl(params.input);
160
- if (params.input.useEnv) return updateMatrixAccountConfig(next, normalizedAccountId, {
161
- enabled: true,
162
- homeserver: null,
163
- allowPrivateNetwork: null,
164
- proxy: null,
165
- userId: null,
166
- accessToken: null,
167
- password: null,
168
- deviceId: null,
169
- deviceName: null,
170
- avatarUrl
171
- });
172
- const accessToken = params.input.accessToken?.trim();
173
- const password = normalizeSecretInputString(params.input.password);
174
- const userId = params.input.userId?.trim();
175
- return updateMatrixAccountConfig(next, normalizedAccountId, {
176
- enabled: true,
177
- homeserver: params.input.homeserver?.trim(),
178
- allowPrivateNetwork: typeof params.input.dangerouslyAllowPrivateNetwork === "boolean" ? params.input.dangerouslyAllowPrivateNetwork : typeof params.input.allowPrivateNetwork === "boolean" ? params.input.allowPrivateNetwork : void 0,
179
- proxy: normalizeOptionalString(params.input.proxy),
180
- userId: password && !userId ? null : userId,
181
- accessToken: accessToken || (password ? null : void 0),
182
- password: password || (accessToken ? null : void 0),
183
- deviceName: params.input.deviceName?.trim(),
184
- avatarUrl,
185
- initialSyncLimit: params.input.initialSyncLimit
186
- });
187
- }
188
- //#endregion
189
- //#region extensions/matrix/src/setup-dm-policy.ts
190
- function resolveMatrixSetupDmAllowFrom(policy, allowFrom) {
191
- if (policy === "open") return addWildcardAllowFrom(allowFrom);
192
- return normalizeAllowFromEntries(allowFrom ?? []).filter((entry) => entry !== "*");
193
- }
194
- //#endregion
195
- export { namedAccountPromotionKeys as a, validateMatrixSetupInput as i, applyMatrixSetupAccountConfig as n, resolveSingleAccountPromotionTarget as o, moveSingleMatrixAccountConfigToNamedAccount as r, singleAccountKeysToMove as s, resolveMatrixSetupDmAllowFrom as t };
@@ -1,195 +0,0 @@
1
- import { t as __exportAll } from "./rolldown-runtime-DUslC3ob.js";
2
- import { n as LogService } from "./logger-CnZRVrux.js";
3
- import { t as awaitMatrixStartupWithAbort } from "./startup-abort-56edvmbM.js";
4
- import { n as resolveMatrixAuth, r as resolveMatrixAuthContext } from "./config-xD5Y8nFT.js";
5
- import { normalizeOptionalAccountId } from "openclaw/plugin-sdk/account-id";
6
- //#region extensions/matrix/src/matrix/client/shared.ts
7
- var shared_exports = /* @__PURE__ */ __exportAll({
8
- acquireSharedMatrixClient: () => acquireSharedMatrixClient,
9
- releaseSharedClientInstance: () => releaseSharedClientInstance,
10
- removeSharedClientInstance: () => removeSharedClientInstance,
11
- resolveSharedMatrixClient: () => resolveSharedMatrixClient,
12
- stopSharedClient: () => stopSharedClient,
13
- stopSharedClientForAccount: () => stopSharedClientForAccount,
14
- stopSharedClientInstance: () => stopSharedClientInstance
15
- });
16
- let matrixCreateClientDepsPromise;
17
- async function loadMatrixCreateClientDeps() {
18
- matrixCreateClientDepsPromise ??= import("./create-client-ChlpNpAA.js").then((n) => n.n).then((runtime) => ({ createMatrixClient: runtime.createMatrixClient }));
19
- return await matrixCreateClientDepsPromise;
20
- }
21
- const sharedClientStates = /* @__PURE__ */ new Map();
22
- const sharedClientPromises = /* @__PURE__ */ new Map();
23
- function serializeDispatcherPolicyKey(auth) {
24
- return JSON.stringify(auth.dispatcherPolicy ?? null);
25
- }
26
- function buildSharedClientKey(auth) {
27
- return [
28
- auth.homeserver,
29
- auth.userId,
30
- auth.accessToken,
31
- auth.encryption ? "e2ee" : "plain",
32
- auth.allowPrivateNetwork ? "private-net" : "strict-net",
33
- serializeDispatcherPolicyKey(auth),
34
- auth.accountId
35
- ].join("|");
36
- }
37
- async function createSharedMatrixClient(params) {
38
- const { createMatrixClient } = await loadMatrixCreateClientDeps();
39
- return {
40
- client: await createMatrixClient({
41
- homeserver: params.auth.homeserver,
42
- userId: params.auth.userId,
43
- accessToken: params.auth.accessToken,
44
- password: params.auth.password,
45
- deviceId: params.auth.deviceId,
46
- encryption: params.auth.encryption,
47
- localTimeoutMs: params.timeoutMs,
48
- initialSyncLimit: params.auth.initialSyncLimit,
49
- accountId: params.auth.accountId,
50
- allowPrivateNetwork: params.auth.allowPrivateNetwork,
51
- ssrfPolicy: params.auth.ssrfPolicy,
52
- dispatcherPolicy: params.auth.dispatcherPolicy
53
- }),
54
- key: buildSharedClientKey(params.auth),
55
- started: false,
56
- cryptoReady: false,
57
- startPromise: null,
58
- leases: 0
59
- };
60
- }
61
- function findSharedClientStateByInstance(client) {
62
- for (const state of sharedClientStates.values()) if (state.client === client) return state;
63
- return null;
64
- }
65
- function deleteSharedClientState(state) {
66
- sharedClientStates.delete(state.key);
67
- sharedClientPromises.delete(state.key);
68
- }
69
- async function ensureSharedClientStarted(params) {
70
- const waitForStart = async (startPromise) => {
71
- await awaitMatrixStartupWithAbort(startPromise, params.abortSignal);
72
- };
73
- if (params.state.started) return;
74
- if (params.state.startPromise) {
75
- await waitForStart(params.state.startPromise);
76
- return;
77
- }
78
- const guardedStart = (async () => {
79
- const client = params.state.client;
80
- if (params.encryption && !params.state.cryptoReady) try {
81
- const joinedRooms = await client.getJoinedRooms();
82
- if (client.crypto) {
83
- await client.crypto.prepare(joinedRooms);
84
- params.state.cryptoReady = true;
85
- }
86
- } catch (err) {
87
- LogService.warn("MatrixClientLite", "Failed to prepare crypto:", err);
88
- }
89
- await client.start({ abortSignal: params.abortSignal });
90
- params.state.started = true;
91
- })().finally(() => {
92
- if (params.state.startPromise === guardedStart) params.state.startPromise = null;
93
- });
94
- params.state.startPromise = guardedStart;
95
- await waitForStart(guardedStart);
96
- }
97
- async function resolveSharedMatrixClientState(params = {}) {
98
- const requestedAccountId = normalizeOptionalAccountId(params.accountId);
99
- if (params.auth && requestedAccountId && requestedAccountId !== params.auth.accountId) throw new Error(`Matrix shared client account mismatch: requested ${requestedAccountId}, auth resolved ${params.auth.accountId}`);
100
- const authContext = (() => {
101
- if (params.auth) return null;
102
- if (!params.cfg) throw new Error("Matrix shared client requires a resolved runtime config. Load and resolve config at the command or gateway boundary, then pass cfg through the runtime path.");
103
- return resolveMatrixAuthContext({
104
- cfg: params.cfg,
105
- env: params.env,
106
- accountId: params.accountId
107
- });
108
- })();
109
- const auth = params.auth ?? await resolveMatrixAuth({
110
- cfg: authContext?.cfg ?? params.cfg,
111
- env: authContext?.env ?? params.env,
112
- accountId: authContext?.accountId
113
- });
114
- const key = buildSharedClientKey(auth);
115
- const shouldStart = params.startClient !== false;
116
- const existingState = sharedClientStates.get(key);
117
- if (existingState) {
118
- if (shouldStart) await ensureSharedClientStarted({
119
- state: existingState,
120
- encryption: auth.encryption,
121
- abortSignal: params.abortSignal
122
- });
123
- return existingState;
124
- }
125
- const existingPromise = sharedClientPromises.get(key);
126
- if (existingPromise) {
127
- const pending = await existingPromise;
128
- if (shouldStart) await ensureSharedClientStarted({
129
- state: pending,
130
- encryption: auth.encryption,
131
- abortSignal: params.abortSignal
132
- });
133
- return pending;
134
- }
135
- const creationPromise = createSharedMatrixClient({
136
- auth,
137
- timeoutMs: params.timeoutMs
138
- });
139
- sharedClientPromises.set(key, creationPromise);
140
- try {
141
- const created = await creationPromise;
142
- sharedClientStates.set(key, created);
143
- if (shouldStart) await ensureSharedClientStarted({
144
- state: created,
145
- encryption: auth.encryption,
146
- abortSignal: params.abortSignal
147
- });
148
- return created;
149
- } finally {
150
- sharedClientPromises.delete(key);
151
- }
152
- }
153
- async function resolveSharedMatrixClient(params = {}) {
154
- return (await resolveSharedMatrixClientState(params)).client;
155
- }
156
- async function acquireSharedMatrixClient(params = {}) {
157
- const state = await resolveSharedMatrixClientState(params);
158
- state.leases += 1;
159
- return state.client;
160
- }
161
- function stopSharedClient() {
162
- for (const state of sharedClientStates.values()) state.client.stop();
163
- sharedClientStates.clear();
164
- sharedClientPromises.clear();
165
- }
166
- function stopSharedClientForAccount(auth) {
167
- const key = buildSharedClientKey(auth);
168
- const state = sharedClientStates.get(key);
169
- if (!state) return;
170
- state.client.stop();
171
- deleteSharedClientState(state);
172
- }
173
- function removeSharedClientInstance(client) {
174
- const state = findSharedClientStateByInstance(client);
175
- if (!state) return false;
176
- deleteSharedClientState(state);
177
- return true;
178
- }
179
- function stopSharedClientInstance(client) {
180
- if (!removeSharedClientInstance(client)) return;
181
- client.stop();
182
- }
183
- async function releaseSharedClientInstance(client, mode = "stop") {
184
- const state = findSharedClientStateByInstance(client);
185
- if (!state) return false;
186
- state.leases = Math.max(0, state.leases - 1);
187
- if (state.leases > 0) return false;
188
- deleteSharedClientState(state);
189
- if (mode === "persist") await client.stopAndPersist();
190
- else if (mode === "discard") client.stopWithoutPersist();
191
- else client.stop();
192
- return true;
193
- }
194
- //#endregion
195
- export { shared_exports as a, resolveSharedMatrixClient as i, releaseSharedClientInstance as n, stopSharedClientForAccount as o, removeSharedClientInstance as r, stopSharedClientInstance as s, acquireSharedMatrixClient as t };
@@ -1,32 +0,0 @@
1
- //#region extensions/matrix/src/matrix/startup-abort.ts
2
- function createMatrixStartupAbortError() {
3
- const error = /* @__PURE__ */ new Error("Matrix startup aborted");
4
- error.name = "AbortError";
5
- return error;
6
- }
7
- function throwIfMatrixStartupAborted(abortSignal) {
8
- if (abortSignal?.aborted === true) throw createMatrixStartupAbortError();
9
- }
10
- function isMatrixStartupAbortError(error) {
11
- return error instanceof Error && error.name === "AbortError";
12
- }
13
- async function awaitMatrixStartupWithAbort(promise, abortSignal) {
14
- if (!abortSignal) return await promise;
15
- if (abortSignal.aborted) throw createMatrixStartupAbortError();
16
- return await new Promise((resolve, reject) => {
17
- const onAbort = () => {
18
- abortSignal.removeEventListener("abort", onAbort);
19
- reject(createMatrixStartupAbortError());
20
- };
21
- abortSignal.addEventListener("abort", onAbort, { once: true });
22
- promise.then((value) => {
23
- abortSignal.removeEventListener("abort", onAbort);
24
- resolve(value);
25
- }, (error) => {
26
- abortSignal.removeEventListener("abort", onAbort);
27
- reject(error);
28
- });
29
- });
30
- }
31
- //#endregion
32
- export { throwIfMatrixStartupAborted as i, createMatrixStartupAbortError as n, isMatrixStartupAbortError as r, awaitMatrixStartupWithAbort as t };
File without changes
File without changes