@openclaw/matrix 2026.9.1-beta.1 → 2026.9.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 (103) hide show
  1. package/dist/{account-config-BZWN9tGS.js → account-config-CRsKoMqJ.js} +1 -1
  2. package/dist/{account-selection-CWuhuFn1.js → account-selection-DA-jfx22.js} +74 -36
  3. package/dist/{accounts-BCzyubQt.js → accounts-DR1c4xF_.js} +4 -5
  4. package/dist/api.js +5 -5
  5. package/dist/{approval-handler.runtime-G9fLHUWe.js → approval-handler.runtime-BJCD4dLf.js} +34 -11
  6. package/dist/{approval-ids-C6FD3pVY.js → approval-ids-Bst7HM_o.js} +1 -1
  7. package/dist/{approval-reaction-auth-60xHiDtQ.js → approval-reaction-auth-DhH8QOSe.js} +2 -2
  8. package/dist/{approval-reactions-tXh9KYrW.js → approval-reactions-1fwEhoK9.js} +1 -1
  9. package/dist/{channel-CBEvelTE.js → channel-Bs8VLb6q.js} +63 -58
  10. package/dist/channel-plugin-api.js +1 -1
  11. package/dist/channel.runtime-CCJRhdH5.js +76 -0
  12. package/dist/{channel.setup-sWPOGyQG.js → channel.setup-DhmDXwPp.js} +32 -22
  13. package/dist/{cli-DrTD2a_q.js → cli-IvDUuiDH.js} +179 -135
  14. package/dist/{cli-metadata-DrYVwQ_r.js → cli-metadata-BGryAl2e.js} +1 -1
  15. package/dist/cli-metadata.js +1 -1
  16. package/dist/{client-hs1ePy2O.js → client-Dj4mcf-s.js} +73 -22
  17. package/dist/{client-bootstrap-BxdxjCwA.js → client-bootstrap-n1Rqc8Go.js} +1 -1
  18. package/dist/{client-BUtHbzib.js → client-oNOlldJI.js} +2 -2
  19. package/dist/{config-update-Bor_Pjsv.js → config-update-BnX26jCO.js} +48 -31
  20. package/dist/contract-api.js +2 -2
  21. package/dist/{credentials-BdAaWuiR.js → credentials-DJj2xs3q.js} +4 -8
  22. package/dist/{credentials-read-B37cQknZ.js → credentials-read-mexhw-Ur.js} +7 -5
  23. package/dist/{credentials-write.runtime-nAV2-5uR.js → credentials-write.runtime-DQt-kgJq.js} +1 -1
  24. package/dist/{crypto-runtime-C4WDYxlP.js → crypto-runtime-m1eplj3b.js} +7 -7
  25. package/dist/crypto-snapshot-doctor.runtime-D0v841D_.js +91 -0
  26. package/dist/{deps-CcVJfvRM.js → deps-mtxF2mHI.js} +1 -1
  27. package/dist/{directory-live-D0KfJlby.js → directory-live-DLUgWBhA.js} +8 -6
  28. package/dist/{doctor-EWf9CDso.js → doctor-CJE8wO6y.js} +1 -1
  29. package/dist/{doctor-contract-DEt4O4Zt.js → doctor-contract-HyWFZQVG.js} +5 -4
  30. package/dist/doctor-contract-api.js +89 -109
  31. package/dist/{draft-stream-B_m79Ynb.js → draft-stream-DglwxWzJ.js} +1 -1
  32. package/dist/{encryption-guidance-DmLY8NiO.js → encryption-guidance-BNcZNQZI.js} +3 -2
  33. package/dist/helper-api.js +1 -1
  34. package/dist/{http-client-D8o8b9u6.js → http-client-DOmFvKvB.js} +10 -7
  35. package/dist/{idb-persistence-DfgW720p.js → idb-persistence-CU7CNLlX.js} +2 -2
  36. package/dist/{idb-persistence-lock-DAJ49nZX.js → idb-persistence-lock-B3fZXyF_.js} +1 -1
  37. package/dist/{inbound-dedupe-RvSLqdsz.js → inbound-dedupe-Ch33GU06.js} +1 -1
  38. package/dist/index.js +1 -1
  39. package/dist/{messages-Dow9EOoJ.js → messages-Czn8lNEh.js} +154 -5
  40. package/dist/{monitor-DBB47wTy.js → monitor-DouG43FJ.js} +200 -156
  41. package/dist/outbound-Co_tJyE6.js +220 -0
  42. package/dist/plugin-entry.handlers.runtime.js +1 -1
  43. package/dist/probe.runtime-B1YPxG9x.js +2 -0
  44. package/dist/{profile-update-C61NR24_.js → profile-update-CAl8nZNG.js} +5 -4
  45. package/dist/{profile-D-Wubo0A.js → profile-vmjsmhh4.js} +1 -1
  46. package/dist/{reaction-events-BZUgLIZI.js → reaction-events-C_7G7bvI.js} +9 -7
  47. package/dist/{resolve-targets-DXzZwsIY.js → resolve-targets-B64O69Nd.js} +1 -1
  48. package/dist/{resolver.runtime-p5qJ3Kst.js → resolver.runtime-TRmePJDV.js} +1 -1
  49. package/dist/{room-info-BXQA7y10.js → room-info-6viLR3NH.js} +55 -1
  50. package/dist/runtime-api.js +2 -2
  51. package/dist/{sdk-CljOKEvc.js → sdk-C1yfda1L.js} +534 -26
  52. package/dist/{send-BKu9Ghi4.js → send-B5XChnvB.js} +31 -33
  53. package/dist/session-binding-contract-api.js +1 -1
  54. package/dist/{setup-bootstrap-CpE6C3qV.js → setup-bootstrap-S_loyUyM.js} +3 -3
  55. package/dist/{setup-core-CyvaCOOr.js → setup-core-XkIfQ65J.js} +8 -7
  56. package/dist/setup-plugin-api.js +1 -1
  57. package/dist/{setup-surface-DtRvRcCT.js → setup-surface-B2yZ8KGc.js} +84 -79
  58. package/dist/{startup-verification-Cs08ca8u.js → startup-verification-1Ney1mmI.js} +2 -2
  59. package/dist/{storage-BsGuHngK.js → storage-BVf4uucD.js} +5 -4
  60. package/dist/{subagent-hooks-CMoZaARG.js → subagent-hooks-DeICLbU5.js} +5 -1
  61. package/dist/subagent-hooks-api.js +1 -1
  62. package/dist/sync-cache-state-d-A_OhbU.js +234 -0
  63. package/dist/{thread-bindings-BvyU66kE.js → thread-bindings-BkBnn4te.js} +4 -4
  64. package/dist/{tool-actions.runtime-DD6jUxFK.js → tool-actions.runtime-a5L5xGSP.js} +226 -215
  65. package/dist/{verification-BP-3-XYn.js → verification-XJtTc5DI.js} +2 -2
  66. package/node_modules/markdown-it/dist/browser/markdown-it.esm.min.mjs +216 -183
  67. package/node_modules/markdown-it/dist/browser/markdown-it.esm.min.mjs.map +1 -1
  68. package/node_modules/markdown-it/dist/browser/markdown-it.umd.min.js +7 -7
  69. package/node_modules/markdown-it/dist/browser/markdown-it.umd.min.js.map +1 -1
  70. package/node_modules/markdown-it/dist/markdown-it.cjs.js +98 -106
  71. package/node_modules/markdown-it/dist/markdown-it.cjs.js.map +1 -1
  72. package/node_modules/markdown-it/dist/markdown-it.d.mts +42 -71
  73. package/node_modules/markdown-it/dist/markdown-it.mjs +98 -106
  74. package/node_modules/markdown-it/dist/markdown-it.mjs.map +1 -1
  75. package/node_modules/markdown-it/package.json +1 -2
  76. package/node_modules/matrix-js-sdk/lib/client.d.ts +2 -1
  77. package/node_modules/matrix-js-sdk/lib/client.js +6 -2
  78. package/node_modules/matrix-js-sdk/lib/sync.js +8 -8
  79. package/node_modules/matrix-js-sdk/src/client.ts +7 -3
  80. package/node_modules/matrix-js-sdk/src/sync.ts +8 -8
  81. package/node_modules/typebox/build/format/email.mjs +1 -1
  82. package/node_modules/typebox/build/format/idna/idn-hostname.mjs +19 -1
  83. package/node_modules/typebox/build/format/json_pointer.d.mts +2 -2
  84. package/node_modules/typebox/build/format/json_pointer.mjs +2 -2
  85. package/node_modules/typebox/build/format/json_pointer_uri_fragment.d.mts +2 -2
  86. package/node_modules/typebox/build/format/json_pointer_uri_fragment.mjs +2 -2
  87. package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
  88. package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
  89. package/node_modules/typebox/build/system/memory/assign.mjs +2 -1
  90. package/node_modules/typebox/build/system/memory/create.mjs +3 -4
  91. package/node_modules/typebox/build/system/memory/discard.mjs +2 -2
  92. package/node_modules/typebox/build/system/memory/freeze.d.mts +4 -0
  93. package/node_modules/typebox/build/system/memory/freeze.mjs +6 -0
  94. package/node_modules/typebox/build/system/memory/update.mjs +3 -2
  95. package/node_modules/typebox/package.json +1 -1
  96. package/openclaw.plugin.json +17 -3
  97. package/package.json +8 -7
  98. package/dist/channel.runtime-CiDl9deX.js +0 -276
  99. package/dist/env-auth-MVS-Vv41.js +0 -64
  100. package/dist/file-sync-store-DjskBX2o.js +0 -436
  101. package/dist/media-text-OR9uoC4W.js +0 -153
  102. package/dist/probe.runtime-CRM7RIrB.js +0 -2
  103. package/dist/recovery-key-store-CognuDys.js +0 -276
@@ -1,276 +0,0 @@
1
- import { b as reconcileMatrixUnknownSend, i as sendPollMatrix, o as sendTypingMatrix, r as sendMessageMatrix, y as cleanupMatrixDeliveryPlans } from "./send-BKu9Ghi4.js";
2
- import { t as isBunRuntime } from "./runtime-BefyhPWv.js";
3
- import { c as resolveMatrixAuth } from "./client-hs1ePy2O.js";
4
- import { n as listMatrixDirectoryGroupsLive, r as listMatrixDirectoryPeersLive } from "./directory-live-D0KfJlby.js";
5
- import { t as resolveMatrixTargets } from "./resolve-targets-DXzZwsIY.js";
6
- import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
7
- import { createMessageReceiptFromOutboundResults, createReplyToFanout, resolveOutboundSendDep } from "openclaw/plugin-sdk/channel-outbound";
8
- import { asOptionalRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
9
- import { chunkTextForOutbound } from "openclaw/plugin-sdk/text-chunking";
10
- import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
11
- import { runChannelProbe } from "openclaw/plugin-sdk/text-utility-runtime";
12
- import { attachChannelToResult } from "openclaw/plugin-sdk/channel-send-result";
13
- import { renderMessagePresentationFallbackText } from "openclaw/plugin-sdk/interactive-runtime";
14
- import { resolveSendableOutboundReplyParts, sendPayloadMediaSequence } from "openclaw/plugin-sdk/reply-payload";
15
- //#region extensions/matrix/src/matrix/probe.ts
16
- const loadMatrixProbeRuntimeDeps = createLazyRuntimeModule(() => import("./probe.runtime-CRM7RIrB.js").then((runtimeModule) => ({ createMatrixClient: runtimeModule.createMatrixClient })));
17
- async function probeMatrix(params) {
18
- return await runChannelProbe(void 0, async () => {
19
- const result = {
20
- ok: false,
21
- status: null,
22
- error: null
23
- };
24
- if (isBunRuntime()) return {
25
- ...result,
26
- error: "Matrix probe requires Node (bun runtime not supported)"
27
- };
28
- if (!params.homeserver?.trim()) return {
29
- ...result,
30
- error: "missing homeserver"
31
- };
32
- if (!params.accessToken?.trim()) return {
33
- ...result,
34
- error: "missing access token"
35
- };
36
- const { createMatrixClient } = await loadMatrixProbeRuntimeDeps();
37
- const inputUserId = normalizeOptionalString(params.userId);
38
- const userId = await (await createMatrixClient({
39
- homeserver: params.homeserver,
40
- userId: void 0,
41
- accessToken: params.accessToken,
42
- deviceId: params.deviceId,
43
- persistStorage: false,
44
- localTimeoutMs: params.timeoutMs,
45
- accountId: params.accountId,
46
- allowPrivateNetwork: params.allowPrivateNetwork,
47
- ssrfPolicy: params.ssrfPolicy,
48
- dispatcherPolicy: params.dispatcherPolicy
49
- })).getUserId();
50
- if (inputUserId && inputUserId !== userId) return {
51
- ...result,
52
- error: "Matrix access token user does not match configured userId"
53
- };
54
- return {
55
- ...result,
56
- ok: true,
57
- userId
58
- };
59
- }, (error) => ({
60
- ok: false,
61
- status: typeof error === "object" && error && "statusCode" in error ? Number(error.statusCode) : null,
62
- error: formatErrorMessage(error)
63
- }));
64
- }
65
- //#endregion
66
- //#region extensions/matrix/src/outbound.ts
67
- const MATRIX_OPENCLAW_PRESENTATION_KEY = "com.openclaw.presentation";
68
- const MATRIX_OPENCLAW_PRESENTATION_TYPE = "message.presentation";
69
- const MATRIX_EMPTY_PRESENTATION_FALLBACK_TEXT = "---";
70
- function toMatrixOutboundResult(result) {
71
- const { roomId, ...delivery } = result;
72
- return {
73
- ...delivery,
74
- target: {
75
- kind: "room",
76
- id: roomId
77
- }
78
- };
79
- }
80
- function resolveMatrixChannelData(payload) {
81
- const raw = asOptionalRecord(payload.channelData)?.matrix;
82
- return asOptionalRecord(raw) ?? {};
83
- }
84
- function buildMatrixPresentationContent(presentation) {
85
- return {
86
- ...presentation,
87
- version: 1,
88
- type: MATRIX_OPENCLAW_PRESENTATION_TYPE
89
- };
90
- }
91
- function resolveMatrixPresentationContent(payload) {
92
- const presentation = asOptionalRecord(asOptionalRecord(resolveMatrixChannelData(payload).extraContent)?.[MATRIX_OPENCLAW_PRESENTATION_KEY]);
93
- if (!presentation || presentation.version !== 1 || presentation.type !== MATRIX_OPENCLAW_PRESENTATION_TYPE) return;
94
- return presentation;
95
- }
96
- function renderMatrixPresentationPayload(params) {
97
- const matrixData = resolveMatrixChannelData(params.payload);
98
- const fallbackText = renderMessagePresentationFallbackText({
99
- text: params.payload.text,
100
- presentation: params.presentation,
101
- emptyFallback: MATRIX_EMPTY_PRESENTATION_FALLBACK_TEXT
102
- });
103
- return {
104
- ...params.payload,
105
- text: fallbackText,
106
- channelData: {
107
- ...params.payload.channelData,
108
- matrix: {
109
- ...matrixData,
110
- extraContent: { [MATRIX_OPENCLAW_PRESENTATION_KEY]: buildMatrixPresentationContent(params.presentation) }
111
- }
112
- }
113
- };
114
- }
115
- function resolveMatrixPayloadText(payload) {
116
- const text = payload.text ?? "";
117
- if (text.trim() || !resolveMatrixPresentationContent(payload)) return text;
118
- return MATRIX_EMPTY_PRESENTATION_FALLBACK_TEXT;
119
- }
120
- function resolveMatrixExtraContent(payload) {
121
- const presentation = resolveMatrixPresentationContent(payload);
122
- return presentation ? { [MATRIX_OPENCLAW_PRESENTATION_KEY]: presentation } : void 0;
123
- }
124
- function resolveMatrixDeliveryProgress(onDeliveryResult) {
125
- return onDeliveryResult ? async (result) => {
126
- await onDeliveryResult(attachChannelToResult("matrix", toMatrixOutboundResult(result)));
127
- } : void 0;
128
- }
129
- //#endregion
130
- //#region extensions/matrix/src/channel.runtime.ts
131
- const matrixChannelRuntime = {
132
- cleanupMatrixDeliveryPlans,
133
- listMatrixDirectoryGroupsLive,
134
- listMatrixDirectoryPeersLive,
135
- matrixOutbound: {
136
- deliveryMode: "direct",
137
- chunker: chunkTextForOutbound,
138
- chunkerMode: "markdown",
139
- textChunkLimit: 4e3,
140
- presentationCapabilities: {
141
- supported: true,
142
- buttons: true,
143
- selects: true,
144
- context: true,
145
- divider: true,
146
- limits: { text: {
147
- markdownDialect: "markdown",
148
- supportsEdit: true
149
- } }
150
- },
151
- renderPresentation: ({ payload, presentation }) => renderMatrixPresentationPayload({
152
- payload,
153
- presentation
154
- }),
155
- sendPayload: async ({ cfg, to, payload, mediaLocalRoots, mediaReadFile, mediaAccess, deps, replyToId, replyToIdSource, replyToMode, threadId, accountId, audioAsVoice, deliveryQueueId, onPlatformSendDispatch, onDeliveryResult }) => {
156
- const send = resolveOutboundSendDep(deps, "matrix") ?? sendMessageMatrix;
157
- const resolvedThreadId = threadId !== void 0 && threadId !== null ? String(threadId) : void 0;
158
- const resolveReplyToId = createReplyToFanout({
159
- ...replyToId != null ? { replyToId } : {},
160
- ...replyToIdSource !== void 0 ? { replyToIdSource } : {},
161
- ...replyToMode !== void 0 ? { replyToMode } : {}
162
- });
163
- const urls = resolveSendableOutboundReplyParts(payload).mediaUrls;
164
- const payloadText = resolveMatrixPayloadText(payload);
165
- if (urls.length > 0) {
166
- const sentResults = [];
167
- const lastResult = await sendPayloadMediaSequence({
168
- text: payloadText,
169
- mediaUrls: urls,
170
- send: async ({ text, mediaUrl, index, isFirst }) => await send(to, text, {
171
- cfg,
172
- mediaUrl,
173
- mediaAccess,
174
- mediaLocalRoots,
175
- mediaReadFile,
176
- replyToId: resolveReplyToId(),
177
- threadId: resolvedThreadId,
178
- accountId: accountId ?? void 0,
179
- audioAsVoice: payload.audioAsVoice ?? audioAsVoice,
180
- deliveryQueueId,
181
- deliveryPartIndex: index,
182
- deliveryPartCount: urls.length,
183
- onPlatformSendDispatch,
184
- extraContent: isFirst ? resolveMatrixExtraContent(payload) : void 0,
185
- onDeliveryResult: resolveMatrixDeliveryProgress(onDeliveryResult)
186
- }),
187
- onResult: (result) => {
188
- sentResults.push(result);
189
- }
190
- });
191
- if (lastResult !== void 0) {
192
- const receipt = createMessageReceiptFromOutboundResults({ results: sentResults });
193
- receipt.parts = receipt.parts.map((part, index) => ({
194
- ...part,
195
- index
196
- }));
197
- return attachChannelToResult("matrix", toMatrixOutboundResult({
198
- ...lastResult,
199
- primaryMessageId: receipt.primaryPlatformMessageId,
200
- receipt,
201
- content: sentResults.map((result) => result.content).join("\n")
202
- }));
203
- }
204
- }
205
- return attachChannelToResult("matrix", toMatrixOutboundResult(await send(to, payloadText, {
206
- cfg,
207
- mediaAccess,
208
- mediaLocalRoots,
209
- mediaReadFile,
210
- replyToId: resolveReplyToId(),
211
- threadId: resolvedThreadId,
212
- accountId: accountId ?? void 0,
213
- audioAsVoice: payload.audioAsVoice ?? audioAsVoice,
214
- deliveryQueueId,
215
- deliveryPartIndex: 0,
216
- deliveryPartCount: 1,
217
- onPlatformSendDispatch,
218
- extraContent: resolveMatrixExtraContent(payload),
219
- onDeliveryResult: resolveMatrixDeliveryProgress(onDeliveryResult)
220
- })));
221
- },
222
- sendText: async ({ cfg, to, text, deps, replyToId, threadId, accountId, audioAsVoice, deliveryQueueId, deliveryPartIndex, deliveryPartCount, onPlatformSendDispatch, onDeliveryResult }) => {
223
- return attachChannelToResult("matrix", toMatrixOutboundResult(await (resolveOutboundSendDep(deps, "matrix") ?? sendMessageMatrix)(to, text, {
224
- cfg,
225
- replyToId: replyToId ?? void 0,
226
- threadId: threadId !== void 0 && threadId !== null ? String(threadId) : void 0,
227
- accountId: accountId ?? void 0,
228
- audioAsVoice,
229
- deliveryQueueId,
230
- deliveryPartIndex,
231
- ...deliveryQueueId !== void 0 ? { deliveryPartCount } : {},
232
- onPlatformSendDispatch,
233
- onDeliveryResult: resolveMatrixDeliveryProgress(onDeliveryResult)
234
- })));
235
- },
236
- sendMedia: async ({ cfg, to, text, mediaUrl, mediaLocalRoots, mediaReadFile, mediaAccess, deps, replyToId, threadId, accountId, audioAsVoice, deliveryQueueId, deliveryPartIndex, deliveryPartCount, onPlatformSendDispatch, onDeliveryResult }) => {
237
- return attachChannelToResult("matrix", toMatrixOutboundResult(await (resolveOutboundSendDep(deps, "matrix") ?? sendMessageMatrix)(to, text, {
238
- cfg,
239
- mediaUrl,
240
- mediaLocalRoots,
241
- mediaReadFile,
242
- mediaAccess,
243
- replyToId: replyToId ?? void 0,
244
- threadId: threadId !== void 0 && threadId !== null ? String(threadId) : void 0,
245
- accountId: accountId ?? void 0,
246
- audioAsVoice,
247
- deliveryQueueId,
248
- deliveryPartIndex,
249
- ...deliveryQueueId !== void 0 ? { deliveryPartCount } : {},
250
- onPlatformSendDispatch,
251
- onDeliveryResult: resolveMatrixDeliveryProgress(onDeliveryResult)
252
- })));
253
- },
254
- sendPoll: async ({ cfg, to, poll, threadId, accountId }) => {
255
- const result = await sendPollMatrix(to, poll, {
256
- cfg,
257
- threadId: threadId !== void 0 && threadId !== null ? threadId : void 0,
258
- accountId: accountId ?? void 0
259
- });
260
- return {
261
- channel: "matrix",
262
- messageId: result.eventId,
263
- roomId: result.roomId,
264
- pollId: result.eventId
265
- };
266
- }
267
- },
268
- probeMatrix,
269
- resolveMatrixAuth,
270
- resolveMatrixTargets,
271
- reconcileMatrixUnknownSend,
272
- sendMessageMatrix,
273
- sendTypingMatrix
274
- };
275
- //#endregion
276
- export { matrixChannelRuntime };
@@ -1,64 +0,0 @@
1
- import { t as getMatrixScopedEnvVarNames } from "./env-vars-dGqak9dN.js";
2
- import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
3
- import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
4
- //#region extensions/matrix/src/matrix/client/env-auth.ts
5
- function cleanEnv(value) {
6
- return normalizeOptionalString(value) ?? "";
7
- }
8
- function resolveGlobalMatrixEnvConfig(env) {
9
- return {
10
- homeserver: cleanEnv(env.MATRIX_HOMESERVER),
11
- userId: cleanEnv(env.MATRIX_USER_ID),
12
- accessToken: cleanEnv(env.MATRIX_ACCESS_TOKEN) || void 0,
13
- password: cleanEnv(env.MATRIX_PASSWORD) || void 0,
14
- deviceId: cleanEnv(env.MATRIX_DEVICE_ID) || void 0,
15
- deviceName: cleanEnv(env.MATRIX_DEVICE_NAME) || void 0
16
- };
17
- }
18
- function hasReadyMatrixEnvAuth(config) {
19
- const homeserver = cleanEnv(config.homeserver);
20
- const userId = cleanEnv(config.userId);
21
- const accessToken = cleanEnv(config.accessToken);
22
- const password = cleanEnv(config.password);
23
- return Boolean(homeserver && (accessToken || userId && password));
24
- }
25
- function resolveScopedMatrixEnvConfig(accountId, env = process.env) {
26
- const keys = getMatrixScopedEnvVarNames(accountId);
27
- return {
28
- homeserver: cleanEnv(env[keys.homeserver]),
29
- userId: cleanEnv(env[keys.userId]),
30
- accessToken: cleanEnv(env[keys.accessToken]) || void 0,
31
- password: cleanEnv(env[keys.password]) || void 0,
32
- deviceId: cleanEnv(env[keys.deviceId]) || void 0,
33
- deviceName: cleanEnv(env[keys.deviceName]) || void 0
34
- };
35
- }
36
- function resolveMatrixEnvAuthReadiness(accountId, env = process.env) {
37
- const normalizedAccountId = normalizeAccountId(accountId);
38
- const scoped = resolveScopedMatrixEnvConfig(normalizedAccountId, env);
39
- const scopedReady = hasReadyMatrixEnvAuth(scoped);
40
- if (normalizedAccountId !== DEFAULT_ACCOUNT_ID) {
41
- const keys = getMatrixScopedEnvVarNames(normalizedAccountId);
42
- return {
43
- ready: scopedReady,
44
- homeserver: scoped.homeserver || void 0,
45
- userId: scoped.userId || void 0,
46
- sourceHint: `${keys.homeserver} (+ auth vars)`,
47
- missingMessage: `Set per-account env vars for "${normalizedAccountId}" (for example ${keys.homeserver} + ${keys.accessToken} or ${keys.userId} + ${keys.password}).`
48
- };
49
- }
50
- const defaultScoped = resolveScopedMatrixEnvConfig(DEFAULT_ACCOUNT_ID, env);
51
- const global = resolveGlobalMatrixEnvConfig(env);
52
- const defaultScopedReady = hasReadyMatrixEnvAuth(defaultScoped);
53
- const globalReady = hasReadyMatrixEnvAuth(global);
54
- const defaultKeys = getMatrixScopedEnvVarNames(DEFAULT_ACCOUNT_ID);
55
- return {
56
- ready: defaultScopedReady || globalReady,
57
- homeserver: defaultScoped.homeserver || global.homeserver || void 0,
58
- userId: defaultScoped.userId || global.userId || void 0,
59
- sourceHint: "MATRIX_* or MATRIX_DEFAULT_*",
60
- missingMessage: `Set Matrix env vars for the default account (for example MATRIX_HOMESERVER + MATRIX_ACCESS_TOKEN, MATRIX_USER_ID + MATRIX_PASSWORD, or ${defaultKeys.homeserver} + ${defaultKeys.accessToken}).`
61
- };
62
- }
63
- //#endregion
64
- export { resolveMatrixEnvAuthReadiness as n, resolveScopedMatrixEnvConfig as r, resolveGlobalMatrixEnvConfig as t };