@kodelyth/matrix 2026.5.39 → 2026.6.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 (117) hide show
  1. package/dist/account-selection-Y50DNJ2l.js +158 -0
  2. package/dist/active-client-CmFdvPdO.js +20 -0
  3. package/dist/api.js +12 -0
  4. package/dist/approval-handler.runtime-BIi4fL0R.js +377 -0
  5. package/dist/approval-ids-BGHK7PnZ.js +7 -0
  6. package/dist/approval-reaction-auth-CL0-nCNV.js +27 -0
  7. package/dist/approval-reactions-nDm2x-K5.js +162 -0
  8. package/dist/async-lock-SsmtFXtt.js +19 -0
  9. package/dist/auth-presence.js +26 -0
  10. package/dist/backup-health-3BHbHxyd.js +60 -0
  11. package/dist/channel-C0kCyTNB.js +1380 -0
  12. package/dist/channel-plugin-api.js +2 -0
  13. package/dist/channel.runtime-CdrdEN-0.js +250 -0
  14. package/dist/cli-FtY6Nuzw.js +1338 -0
  15. package/dist/cli-metadata-Dkwua7CB.js +22 -0
  16. package/dist/cli-metadata.js +2 -0
  17. package/dist/client-BnohYygh.js +25 -0
  18. package/dist/client-PhrTwuC4.js +30 -0
  19. package/dist/client-bootstrap-Mcj8ChJ5.js +114 -0
  20. package/dist/config-paths-DVvt6vM3.js +114 -0
  21. package/dist/config-schema-BMGOlhdI.js +308 -0
  22. package/dist/config-secret-input.runtime-Dv_4Br_f.js +2 -0
  23. package/dist/contract-api.js +8 -0
  24. package/dist/create-client-J0htTaRj.js +64 -0
  25. package/dist/credentials-B7GsBbgQ.js +56 -0
  26. package/dist/credentials-read-8fE4qoWs.js +112 -0
  27. package/dist/credentials-write.runtime-BibplB4Y.js +17 -0
  28. package/dist/crypto-node.runtime-D9qxgRPa.js +12 -0
  29. package/dist/crypto-runtime-1pKW4O2F.js +1214 -0
  30. package/dist/deps-DVpDS81G.js +208 -0
  31. package/dist/device-health-Ct2wDSPG.js +16 -0
  32. package/dist/directory-live-i3T8uORc.js +150 -0
  33. package/dist/doctor-contract-BLzYHl_9.js +246 -0
  34. package/dist/doctor-contract-api.js +2 -0
  35. package/dist/doctor-diR5gE7D.js +153 -0
  36. package/dist/draft-stream-HpPJ_VJt.js +143 -0
  37. package/dist/encryption-guidance-BNEgckrZ.js +15 -0
  38. package/dist/env-auth-UFiTGkDM.js +63 -0
  39. package/dist/env-vars-EQKQv-FE.js +63 -0
  40. package/dist/errors-BETj3zr9.js +17 -0
  41. package/dist/exec-approval-resolver-BxPorU_t.js +15 -0
  42. package/dist/helper-api.js +4 -0
  43. package/dist/http-client-DoQgbQsU.js +331 -0
  44. package/dist/index.js +46 -0
  45. package/dist/legacy-crypto-inspector-zK0hDCbt.js +41 -0
  46. package/dist/legacy-crypto-restore-DSFIXuDo.js +85 -0
  47. package/dist/logging-Df7aPD1z.js +99 -0
  48. package/dist/matrix-migration.runtime-BNoT1Prt.js +525 -0
  49. package/dist/media-text-ZhGA8Pcs.js +146 -0
  50. package/dist/messages-CRA9WGg0.js +140 -0
  51. package/dist/migration-snapshot-backup-BR-xD7Ew.js +69 -0
  52. package/dist/migration-snapshot.runtime-BLcy_Nvw.js +2 -0
  53. package/dist/monitor-DQm7_13y.js +4331 -0
  54. package/dist/plugin-entry.handlers.runtime.js +51 -0
  55. package/dist/probe.runtime-CjJS53Kz.js +3 -0
  56. package/dist/profile-update-DqkPgZ1P.js +68 -0
  57. package/dist/reaction-common-CmVLzP-u.js +71 -0
  58. package/dist/reaction-events-D0nUJuZV.js +121 -0
  59. package/dist/record-shared-DGvSFn5M.js +2 -0
  60. package/dist/resolve-targets-ChECUzD2.js +140 -0
  61. package/dist/resolver.runtime-hdY3n0GO.js +5 -0
  62. package/dist/rolldown-runtime-DUslC3ob.js +14 -0
  63. package/dist/route-xRKj_ESW.js +161 -0
  64. package/dist/runtime-B-Fyrmxo.js +8 -0
  65. package/dist/runtime-api-BYXXkxq2.js +24 -0
  66. package/dist/runtime-api.js +25 -0
  67. package/dist/runtime-heavy-api.js +3 -0
  68. package/dist/runtime-lwTSy9Yt.js +6 -0
  69. package/dist/runtime-setter-api.js +2 -0
  70. package/dist/sdk-Jhq7mLtD.js +1704 -0
  71. package/dist/secret-contract-DEMcDsjl.js +120 -0
  72. package/dist/secret-contract-api.js +2 -0
  73. package/dist/send-CJunc6QM.js +1517 -0
  74. package/dist/setup-bootstrap-rJ0qZWPe.js +62 -0
  75. package/dist/setup-core-BEYoXF3J.js +677 -0
  76. package/dist/setup-entry.js +19 -0
  77. package/dist/setup-plugin-api.js +43 -0
  78. package/dist/setup-surface-c28ON6jq.js +537 -0
  79. package/dist/shared-D6MFMnpG.js +642 -0
  80. package/dist/startup-abort-B2J3MU_h.js +109 -0
  81. package/dist/startup-verification-CkD4Cwce.js +132 -0
  82. package/dist/storage-nyO0DOFE.js +281 -0
  83. package/dist/storage-paths-BTAketfg.js +52 -0
  84. package/dist/subagent-hooks-api-Dr_xnMRG.js +170 -0
  85. package/dist/subagent-hooks-api.js +2 -0
  86. package/dist/sync-state-Bx0gPaGA.js +12 -0
  87. package/dist/target-ids-Bsazo8si.js +77 -0
  88. package/dist/test-api.js +4 -0
  89. package/dist/thread-binding-api-IGU0-L70.js +17 -0
  90. package/dist/thread-binding-api.js +2 -0
  91. package/dist/thread-bindings-FjAZmDUP.js +352 -0
  92. package/dist/thread-bindings-runtime.js +2 -0
  93. package/dist/thread-bindings-shared-fvfP7jVs.js +97 -0
  94. package/dist/timeout-abort-signal-DpSHDHhR.js +2 -0
  95. package/dist/tool-actions.runtime-Cbo7YcYZ.js +532 -0
  96. package/dist/url-validation-DlrXNjAE.js +36 -0
  97. package/dist/verification-7tDPRpJU.js +345 -0
  98. package/package.json +19 -7
  99. package/api.js +0 -7
  100. package/auth-presence.js +0 -7
  101. package/channel-plugin-api.js +0 -7
  102. package/cli-metadata.js +0 -7
  103. package/contract-api.js +0 -7
  104. package/doctor-contract-api.js +0 -7
  105. package/helper-api.js +0 -7
  106. package/index.js +0 -7
  107. package/plugin-entry.handlers.runtime.js +0 -7
  108. package/runtime-api.js +0 -7
  109. package/runtime-heavy-api.js +0 -7
  110. package/runtime-setter-api.js +0 -7
  111. package/secret-contract-api.js +0 -7
  112. package/setup-entry.js +0 -7
  113. package/setup-plugin-api.js +0 -7
  114. package/subagent-hooks-api.js +0 -7
  115. package/test-api.js +0 -7
  116. package/thread-binding-api.js +0 -7
  117. package/thread-bindings-runtime.js +0 -7
@@ -0,0 +1,208 @@
1
+ import { createRequire } from "node:module";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import { formatErrorMessage } from "klaw/plugin-sdk/error-runtime";
5
+ import { spawn } from "node:child_process";
6
+ //#region extensions/matrix/src/matrix/deps.ts
7
+ const REQUIRED_MATRIX_PACKAGES = [
8
+ "matrix-js-sdk",
9
+ "@matrix-org/matrix-sdk-crypto-nodejs",
10
+ "@matrix-org/matrix-sdk-crypto-wasm"
11
+ ];
12
+ const MIN_MATRIX_CRYPTO_NATIVE_BINDING_BYTES = 1e6;
13
+ function resolveMissingMatrixPackages(resolveFn) {
14
+ const resolve = resolveFn ?? defaultResolveFn;
15
+ return REQUIRED_MATRIX_PACKAGES.filter((pkg) => {
16
+ try {
17
+ resolve(pkg);
18
+ return false;
19
+ } catch {
20
+ return true;
21
+ }
22
+ });
23
+ }
24
+ function isMatrixSdkAvailable() {
25
+ return resolveMissingMatrixPackages().length === 0;
26
+ }
27
+ function buildMatrixDepsMissingMessage(missing) {
28
+ return [`Matrix plugin dependencies are missing: ${missing.join(", ")}.`, "Repair this plugin with `klaw plugins update matrix` or run `klaw doctor --fix`."].join(" ");
29
+ }
30
+ let defaultMatrixCryptoRuntimeEnsurePromise = null;
31
+ async function runFixedCommandWithTimeout(params) {
32
+ return await new Promise((resolve) => {
33
+ const [command, ...args] = params.argv;
34
+ if (!command) {
35
+ resolve({
36
+ code: 1,
37
+ stdout: "",
38
+ stderr: "command is required"
39
+ });
40
+ return;
41
+ }
42
+ const proc = spawn(command, args, {
43
+ cwd: params.cwd,
44
+ env: {
45
+ ...process.env,
46
+ ...params.env
47
+ },
48
+ stdio: [
49
+ "ignore",
50
+ "pipe",
51
+ "pipe"
52
+ ]
53
+ });
54
+ let stdout = "";
55
+ let stderr = "";
56
+ let settled = false;
57
+ let timer = null;
58
+ const killChildOnExit = () => {
59
+ if (!settled && proc.exitCode === null) proc.kill("SIGTERM");
60
+ };
61
+ const finalize = (result) => {
62
+ if (settled) return;
63
+ settled = true;
64
+ if (timer) clearTimeout(timer);
65
+ process.off("exit", killChildOnExit);
66
+ resolve(result);
67
+ };
68
+ process.once("exit", killChildOnExit);
69
+ proc.stdout?.on("data", (chunk) => {
70
+ stdout += chunk.toString();
71
+ });
72
+ proc.stderr?.on("data", (chunk) => {
73
+ stderr += chunk.toString();
74
+ });
75
+ timer = setTimeout(() => {
76
+ proc.kill("SIGKILL");
77
+ finalize({
78
+ code: 124,
79
+ stdout,
80
+ stderr: stderr || `command timed out after ${params.timeoutMs}ms`
81
+ });
82
+ }, params.timeoutMs);
83
+ proc.on("error", (err) => {
84
+ finalize({
85
+ code: 1,
86
+ stdout,
87
+ stderr: err.message
88
+ });
89
+ });
90
+ proc.on("close", (code) => {
91
+ finalize({
92
+ code: code ?? 1,
93
+ stdout,
94
+ stderr
95
+ });
96
+ });
97
+ });
98
+ }
99
+ function defaultRequireFn(id) {
100
+ return createRequire(import.meta.url)(id);
101
+ }
102
+ function defaultResolveFn(id) {
103
+ return createRequire(import.meta.url).resolve(id);
104
+ }
105
+ function isMissingMatrixCryptoRuntimeError(error) {
106
+ const message = formatErrorMessage(error);
107
+ return message.includes("@matrix-org/matrix-sdk-crypto-nodejs-") || message.includes("matrix-sdk-crypto-nodejs") || message.includes("download-lib.js");
108
+ }
109
+ function isMuslRuntime() {
110
+ try {
111
+ return !(process.report?.getReport?.())?.header?.glibcVersionRuntime;
112
+ } catch {
113
+ return true;
114
+ }
115
+ }
116
+ function resolveMatrixCryptoNativeBindingFilename() {
117
+ switch (process.platform) {
118
+ case "darwin": return process.arch === "arm64" ? "matrix-sdk-crypto.darwin-arm64.node" : process.arch === "x64" ? "matrix-sdk-crypto.darwin-x64.node" : null;
119
+ case "linux":
120
+ if (process.arch === "x64") return isMuslRuntime() ? "matrix-sdk-crypto.linux-x64-musl.node" : "matrix-sdk-crypto.linux-x64-gnu.node";
121
+ if (process.arch === "arm64" && !isMuslRuntime()) return "matrix-sdk-crypto.linux-arm64-gnu.node";
122
+ if (process.arch === "arm") return "matrix-sdk-crypto.linux-arm-gnueabihf.node";
123
+ if (process.arch === "s390x") return "matrix-sdk-crypto.linux-s390x-gnu.node";
124
+ return null;
125
+ case "win32": return process.arch === "x64" ? "matrix-sdk-crypto.win32-x64-msvc.node" : process.arch === "ia32" ? "matrix-sdk-crypto.win32-ia32-msvc.node" : process.arch === "arm64" ? "matrix-sdk-crypto.win32-arm64-msvc.node" : null;
126
+ default: return null;
127
+ }
128
+ }
129
+ function resolveMatrixCryptoNativeBindingPath(resolveFn) {
130
+ const filename = resolveMatrixCryptoNativeBindingFilename();
131
+ if (!filename) return null;
132
+ try {
133
+ return path.join(path.dirname(resolveFn("@matrix-org/matrix-sdk-crypto-nodejs/download-lib.js")), filename);
134
+ } catch {
135
+ return null;
136
+ }
137
+ }
138
+ function removeIncompleteMatrixCryptoNativeBinding(params) {
139
+ const bindingPath = params.bindingPath;
140
+ if (!bindingPath) return;
141
+ try {
142
+ const stat = fs.statSync(bindingPath);
143
+ if (!stat.isFile() || stat.size >= MIN_MATRIX_CRYPTO_NATIVE_BINDING_BYTES) return;
144
+ fs.unlinkSync(bindingPath);
145
+ params.log?.(`matrix: removed incomplete native crypto runtime (${stat.size} bytes); it will be downloaded again`);
146
+ } catch (error) {
147
+ if (error.code !== "ENOENT") throw error;
148
+ }
149
+ }
150
+ async function ensureMatrixCryptoRuntime(params = {}) {
151
+ const usesDefaultRuntime = !params.requireFn && !params.runCommand && !params.resolveFn && !params.nodeExecutable;
152
+ if (usesDefaultRuntime && defaultMatrixCryptoRuntimeEnsurePromise) {
153
+ await defaultMatrixCryptoRuntimeEnsurePromise;
154
+ return;
155
+ }
156
+ const ensurePromise = ensureMatrixCryptoRuntimeOnce(params);
157
+ if (!usesDefaultRuntime) {
158
+ await ensurePromise;
159
+ return;
160
+ }
161
+ defaultMatrixCryptoRuntimeEnsurePromise = ensurePromise.catch((error) => {
162
+ defaultMatrixCryptoRuntimeEnsurePromise = null;
163
+ throw error;
164
+ });
165
+ await defaultMatrixCryptoRuntimeEnsurePromise;
166
+ }
167
+ async function ensureMatrixCryptoRuntimeOnce(params) {
168
+ const resolveFn = params.resolveFn ?? defaultResolveFn;
169
+ const nativeBindingPath = resolveMatrixCryptoNativeBindingPath(resolveFn);
170
+ removeIncompleteMatrixCryptoNativeBinding({
171
+ bindingPath: nativeBindingPath,
172
+ log: params.log
173
+ });
174
+ const requireFn = params.requireFn ?? defaultRequireFn;
175
+ try {
176
+ requireFn("@matrix-org/matrix-sdk-crypto-nodejs");
177
+ return;
178
+ } catch (err) {
179
+ if (!isMissingMatrixCryptoRuntimeError(err)) throw err;
180
+ }
181
+ const scriptPath = resolveFn("@matrix-org/matrix-sdk-crypto-nodejs/download-lib.js");
182
+ params.log?.("matrix: bootstrapping native crypto runtime");
183
+ const result = await (params.runCommand ?? runFixedCommandWithTimeout)({
184
+ argv: [params.nodeExecutable ?? process.execPath, scriptPath],
185
+ cwd: path.dirname(scriptPath),
186
+ timeoutMs: 3e5,
187
+ env: { COREPACK_ENABLE_DOWNLOAD_PROMPT: "0" }
188
+ });
189
+ if (result.code !== 0) {
190
+ removeIncompleteMatrixCryptoNativeBinding({
191
+ bindingPath: nativeBindingPath,
192
+ log: params.log
193
+ });
194
+ throw new Error(result.stderr.trim() || result.stdout.trim() || "Matrix crypto runtime bootstrap failed.");
195
+ }
196
+ removeIncompleteMatrixCryptoNativeBinding({
197
+ bindingPath: nativeBindingPath,
198
+ log: params.log
199
+ });
200
+ requireFn("@matrix-org/matrix-sdk-crypto-nodejs");
201
+ }
202
+ async function ensureMatrixSdkInstalled(params) {
203
+ const missing = resolveMissingMatrixPackages(params?.resolveFn);
204
+ if (missing.length === 0) return;
205
+ throw new Error(buildMatrixDepsMissingMessage(missing));
206
+ }
207
+ //#endregion
208
+ export { ensureMatrixSdkInstalled as n, isMatrixSdkAvailable as r, ensureMatrixCryptoRuntime as t };
@@ -0,0 +1,16 @@
1
+ //#region extensions/matrix/src/matrix/device-health.ts
2
+ const KLAW_DEVICE_NAME_PREFIX = "Klaw ";
3
+ function isKlawManagedMatrixDevice(displayName) {
4
+ return displayName?.startsWith(KLAW_DEVICE_NAME_PREFIX) === true;
5
+ }
6
+ function summarizeMatrixDeviceHealth(devices) {
7
+ const currentDeviceId = devices.find((device) => device.current)?.deviceId ?? null;
8
+ const openClawDevices = devices.filter((device) => isKlawManagedMatrixDevice(device.displayName));
9
+ return {
10
+ currentDeviceId,
11
+ staleKlawDevices: openClawDevices.filter((device) => !device.current),
12
+ currentKlawDevices: openClawDevices.filter((device) => device.current)
13
+ };
14
+ }
15
+ //#endregion
16
+ export { isKlawManagedMatrixDevice, summarizeMatrixDeviceHealth };
@@ -0,0 +1,150 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-DUslC3ob.js";
2
+ import { n as normalizeMatrixMessagingTarget, t as isMatrixQualifiedUserId } from "./target-ids-Bsazo8si.js";
3
+ import { t as MatrixAuthedHttpClient } from "./http-client-DoQgbQsU.js";
4
+ import { l as resolveMatrixAuth } from "./shared-D6MFMnpG.js";
5
+ import "./client-PhrTwuC4.js";
6
+ import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "klaw/plugin-sdk/string-coerce-runtime";
7
+ //#region extensions/matrix/src/directory-live.ts
8
+ var directory_live_exports = /* @__PURE__ */ __exportAll({
9
+ listMatrixDirectoryGroupsLive: () => listMatrixDirectoryGroupsLive,
10
+ listMatrixDirectoryPeersLive: () => listMatrixDirectoryPeersLive
11
+ });
12
+ const MATRIX_DIRECTORY_TIMEOUT_MS = 1e4;
13
+ function resolveMatrixDirectoryLimit(limit) {
14
+ return typeof limit === "number" && Number.isFinite(limit) && limit > 0 ? Math.max(1, Math.floor(limit)) : 20;
15
+ }
16
+ function createMatrixDirectoryClient(auth) {
17
+ return new MatrixAuthedHttpClient({
18
+ homeserver: auth.homeserver,
19
+ accessToken: auth.accessToken,
20
+ ssrfPolicy: auth.ssrfPolicy,
21
+ dispatcherPolicy: auth.dispatcherPolicy
22
+ });
23
+ }
24
+ async function resolveMatrixDirectoryContext(params) {
25
+ const query = normalizeOptionalString(params.query) ?? "";
26
+ if (!query) return null;
27
+ const auth = await resolveMatrixAuth({
28
+ cfg: params.cfg,
29
+ accountId: params.accountId
30
+ });
31
+ return {
32
+ auth,
33
+ client: createMatrixDirectoryClient(auth),
34
+ query,
35
+ queryLower: normalizeLowercaseStringOrEmpty(query)
36
+ };
37
+ }
38
+ function createGroupDirectoryEntry(params) {
39
+ return {
40
+ kind: "group",
41
+ id: params.id,
42
+ name: params.name,
43
+ handle: params.handle
44
+ };
45
+ }
46
+ async function requestMatrixJson(client, params) {
47
+ return await client.requestJson({
48
+ method: params.method,
49
+ endpoint: params.endpoint,
50
+ body: params.body,
51
+ timeoutMs: MATRIX_DIRECTORY_TIMEOUT_MS
52
+ });
53
+ }
54
+ async function listMatrixDirectoryPeersLive(params) {
55
+ const query = normalizeOptionalString(params.query) ?? "";
56
+ if (!query) return [];
57
+ const directUserId = normalizeMatrixMessagingTarget(query);
58
+ if (directUserId && isMatrixQualifiedUserId(directUserId)) return [{
59
+ kind: "user",
60
+ id: directUserId
61
+ }];
62
+ const context = await resolveMatrixDirectoryContext({
63
+ ...params,
64
+ query
65
+ });
66
+ if (!context) return [];
67
+ return ((await requestMatrixJson(context.client, {
68
+ method: "POST",
69
+ endpoint: "/_matrix/client/v3/user_directory/search",
70
+ body: {
71
+ search_term: context.query,
72
+ limit: resolveMatrixDirectoryLimit(params.limit)
73
+ }
74
+ })).results ?? []).map((entry) => {
75
+ const userId = normalizeOptionalString(entry.user_id);
76
+ if (!userId) return null;
77
+ const displayName = normalizeOptionalString(entry.display_name);
78
+ return {
79
+ kind: "user",
80
+ id: userId,
81
+ name: displayName,
82
+ handle: displayName ? `@${displayName}` : void 0,
83
+ raw: entry
84
+ };
85
+ }).filter(Boolean);
86
+ }
87
+ async function resolveMatrixRoomAlias(client, alias) {
88
+ try {
89
+ return normalizeOptionalString((await requestMatrixJson(client, {
90
+ method: "GET",
91
+ endpoint: `/_matrix/client/v3/directory/room/${encodeURIComponent(alias)}`
92
+ })).room_id) ?? null;
93
+ } catch {
94
+ return null;
95
+ }
96
+ }
97
+ async function fetchMatrixRoomName(client, roomId) {
98
+ try {
99
+ return normalizeOptionalString((await requestMatrixJson(client, {
100
+ method: "GET",
101
+ endpoint: `/_matrix/client/v3/rooms/${encodeURIComponent(roomId)}/state/m.room.name`
102
+ })).name) ?? null;
103
+ } catch {
104
+ return null;
105
+ }
106
+ }
107
+ async function listMatrixDirectoryGroupsLive(params) {
108
+ const query = normalizeOptionalString(params.query) ?? "";
109
+ if (!query) return [];
110
+ const directTarget = normalizeMatrixMessagingTarget(query);
111
+ if (directTarget?.startsWith("!")) return [createGroupDirectoryEntry({
112
+ id: directTarget,
113
+ name: directTarget
114
+ })];
115
+ const context = await resolveMatrixDirectoryContext({
116
+ ...params,
117
+ query
118
+ });
119
+ if (!context) return [];
120
+ const { client, queryLower } = context;
121
+ const limit = resolveMatrixDirectoryLimit(params.limit);
122
+ if (directTarget?.startsWith("#")) {
123
+ const roomId = await resolveMatrixRoomAlias(client, directTarget);
124
+ if (!roomId) return [];
125
+ return [createGroupDirectoryEntry({
126
+ id: roomId,
127
+ name: directTarget,
128
+ handle: directTarget
129
+ })];
130
+ }
131
+ const rooms = ((await requestMatrixJson(client, {
132
+ method: "GET",
133
+ endpoint: "/_matrix/client/v3/joined_rooms"
134
+ })).joined_rooms ?? []).map((roomId) => normalizeOptionalString(roomId)).filter((roomId) => Boolean(roomId));
135
+ const results = [];
136
+ for (const roomId of rooms) {
137
+ const name = await fetchMatrixRoomName(client, roomId);
138
+ if (!name || !normalizeLowercaseStringOrEmpty(name).includes(queryLower)) continue;
139
+ results.push({
140
+ kind: "group",
141
+ id: roomId,
142
+ name,
143
+ handle: `#${name}`
144
+ });
145
+ if (results.length >= limit) break;
146
+ }
147
+ return results;
148
+ }
149
+ //#endregion
150
+ export { listMatrixDirectoryGroupsLive as n, listMatrixDirectoryPeersLive as r, directory_live_exports as t };
@@ -0,0 +1,246 @@
1
+ import { t as isRecord } from "./record-shared-DGvSFn5M.js";
2
+ import { hasLegacyFlatAllowPrivateNetworkAlias, migrateLegacyFlatAllowPrivateNetworkAlias } from "klaw/plugin-sdk/ssrf-runtime";
3
+ //#region extensions/matrix/src/doctor-contract.ts
4
+ function hasLegacyMatrixRoomAllowAlias(value) {
5
+ const room = isRecord(value) ? value : null;
6
+ return Boolean(room && typeof room.allow === "boolean");
7
+ }
8
+ function hasLegacyMatrixRoomMapAllowAliases(value) {
9
+ const rooms = isRecord(value) ? value : null;
10
+ return Boolean(rooms && Object.values(rooms).some((room) => hasLegacyMatrixRoomAllowAlias(room)));
11
+ }
12
+ function hasLegacyMatrixAccountRoomAllowAliases(value) {
13
+ const accounts = isRecord(value) ? value : null;
14
+ if (!accounts) return false;
15
+ return Object.values(accounts).some((account) => {
16
+ if (!isRecord(account)) return false;
17
+ return hasLegacyMatrixRoomMapAllowAliases(account.groups) || hasLegacyMatrixRoomMapAllowAliases(account.rooms);
18
+ });
19
+ }
20
+ function hasLegacyMatrixAccountPrivateNetworkAliases(value) {
21
+ const accounts = isRecord(value) ? value : null;
22
+ if (!accounts) return false;
23
+ return Object.values(accounts).some((account) => hasLegacyFlatAllowPrivateNetworkAlias(isRecord(account) ? account : {}));
24
+ }
25
+ function hasLegacyTrustedDmPolicy(value) {
26
+ const root = isRecord(value) ? value : null;
27
+ if (!root) return false;
28
+ return (isRecord(root.dm) ? root.dm : null)?.policy === "trusted";
29
+ }
30
+ function hasLegacyMatrixAccountTrustedDmPolicies(value) {
31
+ const accounts = isRecord(value) ? value : null;
32
+ if (!accounts) return false;
33
+ return Object.values(accounts).some((account) => hasLegacyTrustedDmPolicy(account));
34
+ }
35
+ function migrateLegacyTrustedDmPolicy(params) {
36
+ const dm = isRecord(params.entry.dm) ? params.entry.dm : null;
37
+ if (!dm || dm.policy !== "trusted") return {
38
+ entry: params.entry,
39
+ changed: false
40
+ };
41
+ const allowFromRaw = dm.allowFrom;
42
+ const allowFromEntries = Array.isArray(allowFromRaw) ? allowFromRaw.filter((entry) => typeof entry === "string" && entry.trim().length > 0).length : 0;
43
+ const nextPolicy = allowFromEntries > 0 ? "allowlist" : "pairing";
44
+ const nextDm = {
45
+ ...dm,
46
+ policy: nextPolicy
47
+ };
48
+ params.changes.push(`Migrated ${params.pathPrefix}.dm.policy "trusted" → "${nextPolicy}" (legacy alias removed; ${allowFromEntries > 0 ? `preserved ${allowFromEntries} ${params.pathPrefix}.dm.allowFrom ${allowFromEntries === 1 ? "entry" : "entries"}` : "no allowFrom entries present, defaulting to pairing for safety"}).`);
49
+ return {
50
+ entry: {
51
+ ...params.entry,
52
+ dm: nextDm
53
+ },
54
+ changed: true
55
+ };
56
+ }
57
+ function normalizeMatrixRoomAllowAliases(params) {
58
+ let changed = false;
59
+ const nextRooms = { ...params.rooms };
60
+ for (const [roomId, roomValue] of Object.entries(params.rooms)) {
61
+ const room = isRecord(roomValue) ? roomValue : null;
62
+ if (!room || typeof room.allow !== "boolean") continue;
63
+ const nextRoom = { ...room };
64
+ if (typeof nextRoom.enabled !== "boolean") nextRoom.enabled = room.allow;
65
+ delete nextRoom.allow;
66
+ nextRooms[roomId] = nextRoom;
67
+ changed = true;
68
+ params.changes.push(`Moved ${params.pathPrefix}.${roomId}.allow → ${params.pathPrefix}.${roomId}.enabled (${String(nextRoom.enabled)}).`);
69
+ }
70
+ return {
71
+ rooms: nextRooms,
72
+ changed
73
+ };
74
+ }
75
+ const legacyConfigRules = [
76
+ {
77
+ path: ["channels", "matrix"],
78
+ message: "channels.matrix.allowPrivateNetwork is legacy; use channels.matrix.network.dangerouslyAllowPrivateNetwork instead. Run \"klaw doctor --fix\".",
79
+ match: (value) => hasLegacyFlatAllowPrivateNetworkAlias(isRecord(value) ? value : {})
80
+ },
81
+ {
82
+ path: [
83
+ "channels",
84
+ "matrix",
85
+ "accounts"
86
+ ],
87
+ message: "channels.matrix.accounts.<id>.allowPrivateNetwork is legacy; use channels.matrix.accounts.<id>.network.dangerouslyAllowPrivateNetwork instead. Run \"klaw doctor --fix\".",
88
+ match: hasLegacyMatrixAccountPrivateNetworkAliases
89
+ },
90
+ {
91
+ path: [
92
+ "channels",
93
+ "matrix",
94
+ "groups"
95
+ ],
96
+ message: "channels.matrix.groups.<room>.allow is legacy; use channels.matrix.groups.<room>.enabled instead. Run \"klaw doctor --fix\".",
97
+ match: hasLegacyMatrixRoomMapAllowAliases
98
+ },
99
+ {
100
+ path: [
101
+ "channels",
102
+ "matrix",
103
+ "rooms"
104
+ ],
105
+ message: "channels.matrix.rooms.<room>.allow is legacy; use channels.matrix.rooms.<room>.enabled instead. Run \"klaw doctor --fix\".",
106
+ match: hasLegacyMatrixRoomMapAllowAliases
107
+ },
108
+ {
109
+ path: [
110
+ "channels",
111
+ "matrix",
112
+ "accounts"
113
+ ],
114
+ message: "channels.matrix.accounts.<id>.{groups,rooms}.<room>.allow is legacy; use channels.matrix.accounts.<id>.{groups,rooms}.<room>.enabled instead. Run \"klaw doctor --fix\".",
115
+ match: hasLegacyMatrixAccountRoomAllowAliases
116
+ },
117
+ {
118
+ path: ["channels", "matrix"],
119
+ message: "channels.matrix.dm.policy \"trusted\" is legacy; use \"allowlist\" (with allowFrom entries) or \"pairing\" instead. Run \"klaw doctor --fix\".",
120
+ match: hasLegacyTrustedDmPolicy
121
+ },
122
+ {
123
+ path: [
124
+ "channels",
125
+ "matrix",
126
+ "accounts"
127
+ ],
128
+ message: "channels.matrix.accounts.<id>.dm.policy \"trusted\" is legacy; use \"allowlist\" (with allowFrom entries) or \"pairing\" instead. Run \"klaw doctor --fix\".",
129
+ match: hasLegacyMatrixAccountTrustedDmPolicies
130
+ }
131
+ ];
132
+ function normalizeCompatibilityConfig({ cfg }) {
133
+ const channels = isRecord(cfg.channels) ? cfg.channels : null;
134
+ const matrix = isRecord(channels?.matrix) ? channels.matrix : null;
135
+ if (!matrix) return {
136
+ config: cfg,
137
+ changes: []
138
+ };
139
+ const changes = [];
140
+ let updatedMatrix = matrix;
141
+ let changed = false;
142
+ const topLevelPrivateNetwork = migrateLegacyFlatAllowPrivateNetworkAlias({
143
+ entry: updatedMatrix,
144
+ pathPrefix: "channels.matrix",
145
+ changes
146
+ });
147
+ updatedMatrix = topLevelPrivateNetwork.entry;
148
+ changed = changed || topLevelPrivateNetwork.changed;
149
+ const topLevelTrustedDmPolicy = migrateLegacyTrustedDmPolicy({
150
+ entry: updatedMatrix,
151
+ pathPrefix: "channels.matrix",
152
+ changes
153
+ });
154
+ updatedMatrix = topLevelTrustedDmPolicy.entry;
155
+ changed = changed || topLevelTrustedDmPolicy.changed;
156
+ const normalizeTopLevelRoomScope = (key) => {
157
+ const rooms = isRecord(updatedMatrix[key]) ? updatedMatrix[key] : null;
158
+ if (!rooms) return;
159
+ const normalized = normalizeMatrixRoomAllowAliases({
160
+ rooms,
161
+ pathPrefix: `channels.matrix.${key}`,
162
+ changes
163
+ });
164
+ if (normalized.changed) {
165
+ updatedMatrix = {
166
+ ...updatedMatrix,
167
+ [key]: normalized.rooms
168
+ };
169
+ changed = true;
170
+ }
171
+ };
172
+ normalizeTopLevelRoomScope("groups");
173
+ normalizeTopLevelRoomScope("rooms");
174
+ const accounts = isRecord(updatedMatrix.accounts) ? updatedMatrix.accounts : null;
175
+ if (accounts) {
176
+ let accountsChanged = false;
177
+ const nextAccounts = { ...accounts };
178
+ for (const [accountId, accountValue] of Object.entries(accounts)) {
179
+ const account = isRecord(accountValue) ? accountValue : null;
180
+ if (!account) continue;
181
+ let nextAccount = account;
182
+ let accountChanged = false;
183
+ const privateNetworkMigration = migrateLegacyFlatAllowPrivateNetworkAlias({
184
+ entry: nextAccount,
185
+ pathPrefix: `channels.matrix.accounts.${accountId}`,
186
+ changes
187
+ });
188
+ if (privateNetworkMigration.changed) {
189
+ nextAccount = privateNetworkMigration.entry;
190
+ accountChanged = true;
191
+ }
192
+ const accountTrustedDmPolicy = migrateLegacyTrustedDmPolicy({
193
+ entry: nextAccount,
194
+ pathPrefix: `channels.matrix.accounts.${accountId}`,
195
+ changes
196
+ });
197
+ if (accountTrustedDmPolicy.changed) {
198
+ nextAccount = accountTrustedDmPolicy.entry;
199
+ accountChanged = true;
200
+ }
201
+ for (const key of ["groups", "rooms"]) {
202
+ const rooms = isRecord(nextAccount[key]) ? nextAccount[key] : null;
203
+ if (!rooms) continue;
204
+ const normalized = normalizeMatrixRoomAllowAliases({
205
+ rooms,
206
+ pathPrefix: `channels.matrix.accounts.${accountId}.${key}`,
207
+ changes
208
+ });
209
+ if (normalized.changed) {
210
+ nextAccount = {
211
+ ...nextAccount,
212
+ [key]: normalized.rooms
213
+ };
214
+ accountChanged = true;
215
+ }
216
+ }
217
+ if (accountChanged) {
218
+ nextAccounts[accountId] = nextAccount;
219
+ accountsChanged = true;
220
+ }
221
+ }
222
+ if (accountsChanged) {
223
+ updatedMatrix = {
224
+ ...updatedMatrix,
225
+ accounts: nextAccounts
226
+ };
227
+ changed = true;
228
+ }
229
+ }
230
+ if (!changed) return {
231
+ config: cfg,
232
+ changes: []
233
+ };
234
+ return {
235
+ config: {
236
+ ...cfg,
237
+ channels: {
238
+ ...cfg.channels,
239
+ matrix: updatedMatrix
240
+ }
241
+ },
242
+ changes
243
+ };
244
+ }
245
+ //#endregion
246
+ export { normalizeCompatibilityConfig as n, legacyConfigRules as t };
@@ -0,0 +1,2 @@
1
+ import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-BLzYHl_9.js";
2
+ export { legacyConfigRules, normalizeCompatibilityConfig };