@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,162 @@
1
+ import { n as getOptionalMatrixRuntime } from "./runtime-B-Fyrmxo.js";
2
+ //#region extensions/matrix/src/approval-reactions.ts
3
+ const MATRIX_APPROVAL_REACTION_META = {
4
+ "allow-once": {
5
+ emoji: "✅",
6
+ label: "Allow once"
7
+ },
8
+ "allow-always": {
9
+ emoji: "♾️",
10
+ label: "Allow always"
11
+ },
12
+ deny: {
13
+ emoji: "❌",
14
+ label: "Deny"
15
+ }
16
+ };
17
+ const MATRIX_APPROVAL_REACTION_ORDER = [
18
+ "allow-once",
19
+ "allow-always",
20
+ "deny"
21
+ ];
22
+ const PERSISTENT_NAMESPACE = "matrix.approval-reactions";
23
+ const PERSISTENT_MAX_ENTRIES = 1e3;
24
+ const DEFAULT_REACTION_TARGET_TTL_MS = 1440 * 60 * 1e3;
25
+ const matrixApprovalReactionTargets = /* @__PURE__ */ new Map();
26
+ let persistentStore;
27
+ let persistentStoreDisabled = false;
28
+ function buildReactionTargetKey(roomId, eventId) {
29
+ const normalizedRoomId = roomId.trim();
30
+ const normalizedEventId = eventId.trim();
31
+ if (!normalizedRoomId || !normalizedEventId) return null;
32
+ return `${normalizedRoomId}:${normalizedEventId}`;
33
+ }
34
+ function reportPersistentApprovalReactionError(error) {
35
+ try {
36
+ getOptionalMatrixRuntime()?.logging.getChildLogger({
37
+ plugin: "matrix",
38
+ feature: "approval-reaction-state"
39
+ }).warn("Matrix persistent approval reaction state failed", { error: String(error) });
40
+ } catch {}
41
+ }
42
+ function disablePersistentApprovalReactionStore(error) {
43
+ persistentStoreDisabled = true;
44
+ persistentStore = void 0;
45
+ reportPersistentApprovalReactionError(error);
46
+ }
47
+ function getPersistentApprovalReactionStore() {
48
+ if (persistentStoreDisabled) return;
49
+ if (persistentStore) return persistentStore;
50
+ const runtime = getOptionalMatrixRuntime();
51
+ if (!runtime) return;
52
+ try {
53
+ persistentStore = runtime.state.openKeyedStore({
54
+ namespace: PERSISTENT_NAMESPACE,
55
+ maxEntries: PERSISTENT_MAX_ENTRIES,
56
+ defaultTtlMs: DEFAULT_REACTION_TARGET_TTL_MS
57
+ });
58
+ return persistentStore;
59
+ } catch (error) {
60
+ disablePersistentApprovalReactionStore(error);
61
+ return;
62
+ }
63
+ }
64
+ function readPersistedTarget(value) {
65
+ const persisted = value;
66
+ if (persisted?.version !== 1 || !persisted.target || typeof persisted.target.approvalId !== "string" || !Array.isArray(persisted.target.allowedDecisions)) return null;
67
+ return persisted.target;
68
+ }
69
+ function rememberPersistentApprovalReactionTarget(params) {
70
+ const ttlMs = params.ttlMs == null ? DEFAULT_REACTION_TARGET_TTL_MS : Math.max(1, params.ttlMs);
71
+ const store = getPersistentApprovalReactionStore();
72
+ if (!store) return;
73
+ store.register(params.key, {
74
+ version: 1,
75
+ target: params.target
76
+ }, { ttlMs }).catch(disablePersistentApprovalReactionStore);
77
+ }
78
+ function forgetPersistentApprovalReactionTarget(key) {
79
+ const store = getPersistentApprovalReactionStore();
80
+ if (!store) return;
81
+ store.delete(key).catch(disablePersistentApprovalReactionStore);
82
+ }
83
+ async function lookupPersistentApprovalReactionTarget(key) {
84
+ const store = getPersistentApprovalReactionStore();
85
+ if (!store) return null;
86
+ try {
87
+ return readPersistedTarget(await store.lookup(key));
88
+ } catch (error) {
89
+ disablePersistentApprovalReactionStore(error);
90
+ return null;
91
+ }
92
+ }
93
+ function listMatrixApprovalReactionBindings(allowedDecisions) {
94
+ const allowed = new Set(allowedDecisions);
95
+ return MATRIX_APPROVAL_REACTION_ORDER.filter((decision) => allowed.has(decision)).map((decision) => ({
96
+ decision,
97
+ emoji: MATRIX_APPROVAL_REACTION_META[decision].emoji,
98
+ label: MATRIX_APPROVAL_REACTION_META[decision].label
99
+ }));
100
+ }
101
+ function buildMatrixApprovalReactionHint(allowedDecisions) {
102
+ const bindings = listMatrixApprovalReactionBindings(allowedDecisions);
103
+ if (bindings.length === 0) return null;
104
+ return `React here: ${bindings.map((binding) => `${binding.emoji} ${binding.label}`).join(", ")}`;
105
+ }
106
+ function resolveMatrixApprovalReactionDecision(reactionKey, allowedDecisions) {
107
+ const normalizedReaction = reactionKey.trim();
108
+ if (!normalizedReaction) return null;
109
+ const allowed = new Set(allowedDecisions);
110
+ for (const decision of MATRIX_APPROVAL_REACTION_ORDER) {
111
+ if (!allowed.has(decision)) continue;
112
+ if (MATRIX_APPROVAL_REACTION_META[decision].emoji === normalizedReaction) return decision;
113
+ }
114
+ return null;
115
+ }
116
+ function registerMatrixApprovalReactionTarget(params) {
117
+ const key = buildReactionTargetKey(params.roomId, params.eventId);
118
+ const approvalId = params.approvalId.trim();
119
+ const allowedDecisions = Array.from(new Set(params.allowedDecisions.filter((decision) => decision === "allow-once" || decision === "allow-always" || decision === "deny")));
120
+ if (!key || !approvalId || allowedDecisions.length === 0) return;
121
+ const target = {
122
+ approvalId,
123
+ allowedDecisions
124
+ };
125
+ matrixApprovalReactionTargets.set(key, target);
126
+ rememberPersistentApprovalReactionTarget({
127
+ key,
128
+ target,
129
+ ttlMs: params.ttlMs
130
+ });
131
+ }
132
+ function unregisterMatrixApprovalReactionTarget(params) {
133
+ const key = buildReactionTargetKey(params.roomId, params.eventId);
134
+ if (!key) return;
135
+ matrixApprovalReactionTargets.delete(key);
136
+ forgetPersistentApprovalReactionTarget(key);
137
+ }
138
+ function resolveTarget(params) {
139
+ const target = params.target;
140
+ if (!target) return null;
141
+ const decision = resolveMatrixApprovalReactionDecision(params.reactionKey, target.allowedDecisions);
142
+ if (!decision) return null;
143
+ return {
144
+ approvalId: target.approvalId,
145
+ decision
146
+ };
147
+ }
148
+ async function resolveMatrixApprovalReactionTargetWithPersistence(params) {
149
+ const key = buildReactionTargetKey(params.roomId, params.eventId);
150
+ if (!key) return null;
151
+ const inMemory = resolveTarget({
152
+ target: matrixApprovalReactionTargets.get(key),
153
+ reactionKey: params.reactionKey
154
+ });
155
+ if (inMemory) return inMemory;
156
+ return resolveTarget({
157
+ target: await lookupPersistentApprovalReactionTarget(key),
158
+ reactionKey: params.reactionKey
159
+ });
160
+ }
161
+ //#endregion
162
+ export { unregisterMatrixApprovalReactionTarget as a, resolveMatrixApprovalReactionTargetWithPersistence as i, listMatrixApprovalReactionBindings as n, registerMatrixApprovalReactionTarget as r, buildMatrixApprovalReactionHint as t };
@@ -0,0 +1,19 @@
1
+ //#region extensions/matrix/src/matrix/async-lock.ts
2
+ function createAsyncLock() {
3
+ let lock = Promise.resolve();
4
+ return async function withLock(fn) {
5
+ const previous = lock;
6
+ let release;
7
+ lock = new Promise((resolve) => {
8
+ release = resolve;
9
+ });
10
+ await previous;
11
+ try {
12
+ return await fn();
13
+ } finally {
14
+ release?.();
15
+ }
16
+ };
17
+ }
18
+ //#endregion
19
+ export { createAsyncLock as t };
@@ -0,0 +1,26 @@
1
+ import { i as resolveMatrixCredentialsFilename, r as resolveMatrixCredentialsDir } from "./storage-paths-BTAketfg.js";
2
+ import fs from "node:fs";
3
+ import os from "node:os";
4
+ import path from "node:path";
5
+ import { resolveStateDir } from "klaw/plugin-sdk/state-paths";
6
+ //#region extensions/matrix/auth-presence.ts
7
+ function listMatrixCredentialPaths(_cfg, env = process.env) {
8
+ const credentialsDir = resolveMatrixCredentialsDir(resolveStateDir(env, os.homedir));
9
+ const paths = new Set([resolveMatrixCredentialsFilename(), resolveMatrixCredentialsFilename("default")]);
10
+ try {
11
+ const entries = fs.readdirSync(credentialsDir, { withFileTypes: true });
12
+ for (const entry of entries) if (entry.isFile() && /^credentials(?:-[a-z0-9._-]+)?\.json$/i.test(entry.name)) paths.add(entry.name);
13
+ } catch {}
14
+ return [...paths].map((filename) => path.join(credentialsDir, filename));
15
+ }
16
+ function hasAnyMatrixAuth(params, env = process.env) {
17
+ return listMatrixCredentialPaths(params && typeof params === "object" && "cfg" in params ? params.cfg : params, params && typeof params === "object" && "cfg" in params ? params.env ?? env : env).some((filePath) => {
18
+ try {
19
+ return fs.existsSync(filePath);
20
+ } catch {
21
+ return false;
22
+ }
23
+ });
24
+ }
25
+ //#endregion
26
+ export { hasAnyMatrixAuth };
@@ -0,0 +1,60 @@
1
+ //#region extensions/matrix/src/matrix/backup-health.ts
2
+ function resolveMatrixRoomKeyBackupIssue(backup) {
3
+ if (!backup.serverVersion) return {
4
+ code: "missing-server-backup",
5
+ summary: "missing on server",
6
+ message: "no room-key backup exists on the homeserver"
7
+ };
8
+ if (backup.decryptionKeyCached === false) {
9
+ if (backup.keyLoadError) return {
10
+ code: "key-load-failed",
11
+ summary: "present but backup key unavailable on this device",
12
+ message: `backup decryption key could not be loaded from secret storage (${backup.keyLoadError})`
13
+ };
14
+ if (backup.keyLoadAttempted) return {
15
+ code: "key-not-loaded",
16
+ summary: "present but backup key unavailable on this device",
17
+ message: "backup decryption key is not loaded on this device (secret storage did not return a key)"
18
+ };
19
+ return {
20
+ code: "key-not-loaded",
21
+ summary: "present but backup key unavailable on this device",
22
+ message: "backup decryption key is not loaded on this device"
23
+ };
24
+ }
25
+ if (backup.matchesDecryptionKey === false) return {
26
+ code: "key-mismatch",
27
+ summary: "present but backup key mismatch on this device",
28
+ message: "backup key mismatch (this device does not have the matching backup decryption key)"
29
+ };
30
+ if (backup.trusted === false) return {
31
+ code: "untrusted-signature",
32
+ summary: "present but not trusted on this device",
33
+ message: "backup signature chain is not trusted by this device"
34
+ };
35
+ if (!backup.activeVersion) return {
36
+ code: "inactive",
37
+ summary: "present on server but inactive on this device",
38
+ message: "backup exists but is not active on this device"
39
+ };
40
+ if (backup.trusted === null || backup.matchesDecryptionKey === null || backup.decryptionKeyCached === null) return {
41
+ code: "indeterminate",
42
+ summary: "present but trust state unknown",
43
+ message: "backup trust state could not be fully determined"
44
+ };
45
+ return {
46
+ code: "ok",
47
+ summary: "active and trusted on this device",
48
+ message: null
49
+ };
50
+ }
51
+ function resolveMatrixRoomKeyBackupReadinessError(backup, opts) {
52
+ const issue = resolveMatrixRoomKeyBackupIssue(backup);
53
+ if (issue.code === "missing-server-backup") return opts.requireServerBackup ? "Matrix room key backup is missing on the homeserver." : null;
54
+ if (issue.code === "ok") return null;
55
+ if (issue.code === "untrusted-signature" && opts.allowUntrustedMatchingKey === true && backup.matchesDecryptionKey === true && backup.decryptionKeyCached === true) return null;
56
+ if (issue.message) return `Matrix room key backup is not usable: ${issue.message}.`;
57
+ return "Matrix room key backup is not usable on this device.";
58
+ }
59
+ //#endregion
60
+ export { resolveMatrixRoomKeyBackupReadinessError as n, resolveMatrixRoomKeyBackupIssue as t };