@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.
- package/dist/account-selection-Y50DNJ2l.js +158 -0
- package/dist/active-client-CmFdvPdO.js +20 -0
- package/dist/api.js +12 -0
- package/dist/approval-handler.runtime-BIi4fL0R.js +377 -0
- package/dist/approval-ids-BGHK7PnZ.js +7 -0
- package/dist/approval-reaction-auth-CL0-nCNV.js +27 -0
- package/dist/approval-reactions-nDm2x-K5.js +162 -0
- package/dist/async-lock-SsmtFXtt.js +19 -0
- package/dist/auth-presence.js +26 -0
- package/dist/backup-health-3BHbHxyd.js +60 -0
- package/dist/channel-C0kCyTNB.js +1380 -0
- package/dist/channel-plugin-api.js +2 -0
- package/dist/channel.runtime-CdrdEN-0.js +250 -0
- package/dist/cli-FtY6Nuzw.js +1338 -0
- package/dist/cli-metadata-Dkwua7CB.js +22 -0
- package/dist/cli-metadata.js +2 -0
- package/dist/client-BnohYygh.js +25 -0
- package/dist/client-PhrTwuC4.js +30 -0
- package/dist/client-bootstrap-Mcj8ChJ5.js +114 -0
- package/dist/config-paths-DVvt6vM3.js +114 -0
- package/dist/config-schema-BMGOlhdI.js +308 -0
- package/dist/config-secret-input.runtime-Dv_4Br_f.js +2 -0
- package/dist/contract-api.js +8 -0
- package/dist/create-client-J0htTaRj.js +64 -0
- package/dist/credentials-B7GsBbgQ.js +56 -0
- package/dist/credentials-read-8fE4qoWs.js +112 -0
- package/dist/credentials-write.runtime-BibplB4Y.js +17 -0
- package/dist/crypto-node.runtime-D9qxgRPa.js +12 -0
- package/dist/crypto-runtime-1pKW4O2F.js +1214 -0
- package/dist/deps-DVpDS81G.js +208 -0
- package/dist/device-health-Ct2wDSPG.js +16 -0
- package/dist/directory-live-i3T8uORc.js +150 -0
- package/dist/doctor-contract-BLzYHl_9.js +246 -0
- package/dist/doctor-contract-api.js +2 -0
- package/dist/doctor-diR5gE7D.js +153 -0
- package/dist/draft-stream-HpPJ_VJt.js +143 -0
- package/dist/encryption-guidance-BNEgckrZ.js +15 -0
- package/dist/env-auth-UFiTGkDM.js +63 -0
- package/dist/env-vars-EQKQv-FE.js +63 -0
- package/dist/errors-BETj3zr9.js +17 -0
- package/dist/exec-approval-resolver-BxPorU_t.js +15 -0
- package/dist/helper-api.js +4 -0
- package/dist/http-client-DoQgbQsU.js +331 -0
- package/dist/index.js +46 -0
- package/dist/legacy-crypto-inspector-zK0hDCbt.js +41 -0
- package/dist/legacy-crypto-restore-DSFIXuDo.js +85 -0
- package/dist/logging-Df7aPD1z.js +99 -0
- package/dist/matrix-migration.runtime-BNoT1Prt.js +525 -0
- package/dist/media-text-ZhGA8Pcs.js +146 -0
- package/dist/messages-CRA9WGg0.js +140 -0
- package/dist/migration-snapshot-backup-BR-xD7Ew.js +69 -0
- package/dist/migration-snapshot.runtime-BLcy_Nvw.js +2 -0
- package/dist/monitor-DQm7_13y.js +4331 -0
- package/dist/plugin-entry.handlers.runtime.js +51 -0
- package/dist/probe.runtime-CjJS53Kz.js +3 -0
- package/dist/profile-update-DqkPgZ1P.js +68 -0
- package/dist/reaction-common-CmVLzP-u.js +71 -0
- package/dist/reaction-events-D0nUJuZV.js +121 -0
- package/dist/record-shared-DGvSFn5M.js +2 -0
- package/dist/resolve-targets-ChECUzD2.js +140 -0
- package/dist/resolver.runtime-hdY3n0GO.js +5 -0
- package/dist/rolldown-runtime-DUslC3ob.js +14 -0
- package/dist/route-xRKj_ESW.js +161 -0
- package/dist/runtime-B-Fyrmxo.js +8 -0
- package/dist/runtime-api-BYXXkxq2.js +24 -0
- package/dist/runtime-api.js +25 -0
- package/dist/runtime-heavy-api.js +3 -0
- package/dist/runtime-lwTSy9Yt.js +6 -0
- package/dist/runtime-setter-api.js +2 -0
- package/dist/sdk-Jhq7mLtD.js +1704 -0
- package/dist/secret-contract-DEMcDsjl.js +120 -0
- package/dist/secret-contract-api.js +2 -0
- package/dist/send-CJunc6QM.js +1517 -0
- package/dist/setup-bootstrap-rJ0qZWPe.js +62 -0
- package/dist/setup-core-BEYoXF3J.js +677 -0
- package/dist/setup-entry.js +19 -0
- package/dist/setup-plugin-api.js +43 -0
- package/dist/setup-surface-c28ON6jq.js +537 -0
- package/dist/shared-D6MFMnpG.js +642 -0
- package/dist/startup-abort-B2J3MU_h.js +109 -0
- package/dist/startup-verification-CkD4Cwce.js +132 -0
- package/dist/storage-nyO0DOFE.js +281 -0
- package/dist/storage-paths-BTAketfg.js +52 -0
- package/dist/subagent-hooks-api-Dr_xnMRG.js +170 -0
- package/dist/subagent-hooks-api.js +2 -0
- package/dist/sync-state-Bx0gPaGA.js +12 -0
- package/dist/target-ids-Bsazo8si.js +77 -0
- package/dist/test-api.js +4 -0
- package/dist/thread-binding-api-IGU0-L70.js +17 -0
- package/dist/thread-binding-api.js +2 -0
- package/dist/thread-bindings-FjAZmDUP.js +352 -0
- package/dist/thread-bindings-runtime.js +2 -0
- package/dist/thread-bindings-shared-fvfP7jVs.js +97 -0
- package/dist/timeout-abort-signal-DpSHDHhR.js +2 -0
- package/dist/tool-actions.runtime-Cbo7YcYZ.js +532 -0
- package/dist/url-validation-DlrXNjAE.js +36 -0
- package/dist/verification-7tDPRpJU.js +345 -0
- package/package.json +19 -7
- package/api.js +0 -7
- package/auth-presence.js +0 -7
- package/channel-plugin-api.js +0 -7
- package/cli-metadata.js +0 -7
- package/contract-api.js +0 -7
- package/doctor-contract-api.js +0 -7
- package/helper-api.js +0 -7
- package/index.js +0 -7
- package/plugin-entry.handlers.runtime.js +0 -7
- package/runtime-api.js +0 -7
- package/runtime-heavy-api.js +0 -7
- package/runtime-setter-api.js +0 -7
- package/secret-contract-api.js +0 -7
- package/setup-entry.js +0 -7
- package/setup-plugin-api.js +0 -7
- package/subagent-hooks-api.js +0 -7
- package/test-api.js +0 -7
- package/thread-binding-api.js +0 -7
- package/thread-bindings-runtime.js +0 -7
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { a as sendMessageMatrix, c as sendTypingMatrix, o as sendPollMatrix } from "./send-CJunc6QM.js";
|
|
2
|
+
import { t as isBunRuntime } from "./runtime-lwTSy9Yt.js";
|
|
3
|
+
import { l as resolveMatrixAuth } from "./shared-D6MFMnpG.js";
|
|
4
|
+
import "./client-PhrTwuC4.js";
|
|
5
|
+
import { n as listMatrixDirectoryGroupsLive, r as listMatrixDirectoryPeersLive } from "./directory-live-i3T8uORc.js";
|
|
6
|
+
import { f as resolveOutboundSendDep, n as chunkTextForOutbound } from "./runtime-api-BYXXkxq2.js";
|
|
7
|
+
import { t as resolveMatrixTargets } from "./resolve-targets-ChECUzD2.js";
|
|
8
|
+
import { normalizeOptionalString } from "klaw/plugin-sdk/string-coerce-runtime";
|
|
9
|
+
import { createReplyToFanout } from "klaw/plugin-sdk/outbound-runtime";
|
|
10
|
+
import { formatErrorMessage } from "klaw/plugin-sdk/error-runtime";
|
|
11
|
+
import { renderMessagePresentationFallbackText } from "klaw/plugin-sdk/interactive-runtime";
|
|
12
|
+
import { resolvePayloadMediaUrls } from "klaw/plugin-sdk/reply-payload";
|
|
13
|
+
//#region extensions/matrix/src/matrix/probe.ts
|
|
14
|
+
let matrixProbeRuntimeDepsPromise;
|
|
15
|
+
async function loadMatrixProbeRuntimeDeps() {
|
|
16
|
+
matrixProbeRuntimeDepsPromise ??= import("./probe.runtime-CjJS53Kz.js").then((runtimeModule) => ({ createMatrixClient: runtimeModule.createMatrixClient }));
|
|
17
|
+
return await matrixProbeRuntimeDepsPromise;
|
|
18
|
+
}
|
|
19
|
+
async function probeMatrix(params) {
|
|
20
|
+
const started = Date.now();
|
|
21
|
+
const result = {
|
|
22
|
+
ok: false,
|
|
23
|
+
status: null,
|
|
24
|
+
error: null,
|
|
25
|
+
elapsedMs: 0
|
|
26
|
+
};
|
|
27
|
+
if (isBunRuntime()) return {
|
|
28
|
+
...result,
|
|
29
|
+
error: "Matrix probe requires Node (bun runtime not supported)",
|
|
30
|
+
elapsedMs: Date.now() - started
|
|
31
|
+
};
|
|
32
|
+
if (!params.homeserver?.trim()) return {
|
|
33
|
+
...result,
|
|
34
|
+
error: "missing homeserver",
|
|
35
|
+
elapsedMs: Date.now() - started
|
|
36
|
+
};
|
|
37
|
+
if (!params.accessToken?.trim()) return {
|
|
38
|
+
...result,
|
|
39
|
+
error: "missing access token",
|
|
40
|
+
elapsedMs: Date.now() - started
|
|
41
|
+
};
|
|
42
|
+
try {
|
|
43
|
+
const { createMatrixClient } = await loadMatrixProbeRuntimeDeps();
|
|
44
|
+
const inputUserId = normalizeOptionalString(params.userId);
|
|
45
|
+
const userId = await (await createMatrixClient({
|
|
46
|
+
homeserver: params.homeserver,
|
|
47
|
+
userId: inputUserId,
|
|
48
|
+
accessToken: params.accessToken,
|
|
49
|
+
deviceId: params.deviceId,
|
|
50
|
+
persistStorage: false,
|
|
51
|
+
localTimeoutMs: params.timeoutMs,
|
|
52
|
+
accountId: params.accountId,
|
|
53
|
+
allowPrivateNetwork: params.allowPrivateNetwork,
|
|
54
|
+
ssrfPolicy: params.ssrfPolicy,
|
|
55
|
+
dispatcherPolicy: params.dispatcherPolicy
|
|
56
|
+
})).getUserId();
|
|
57
|
+
result.ok = true;
|
|
58
|
+
result.userId = userId ?? null;
|
|
59
|
+
result.elapsedMs = Date.now() - started;
|
|
60
|
+
return result;
|
|
61
|
+
} catch (err) {
|
|
62
|
+
return {
|
|
63
|
+
...result,
|
|
64
|
+
status: typeof err === "object" && err && "statusCode" in err ? Number(err.statusCode) : result.status,
|
|
65
|
+
error: formatErrorMessage(err),
|
|
66
|
+
elapsedMs: Date.now() - started
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region extensions/matrix/src/outbound.ts
|
|
72
|
+
const MATRIX_KLAW_PRESENTATION_KEY = "com.klaw.presentation";
|
|
73
|
+
const MATRIX_KLAW_PRESENTATION_TYPE = "message.presentation";
|
|
74
|
+
const MATRIX_EMPTY_PRESENTATION_FALLBACK_TEXT = "---";
|
|
75
|
+
function toRecord(value) {
|
|
76
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
77
|
+
}
|
|
78
|
+
function resolveMatrixChannelData(payload) {
|
|
79
|
+
const raw = toRecord(payload.channelData)?.matrix;
|
|
80
|
+
return toRecord(raw) ?? {};
|
|
81
|
+
}
|
|
82
|
+
function buildMatrixPresentationContent(presentation) {
|
|
83
|
+
return {
|
|
84
|
+
...presentation,
|
|
85
|
+
version: 1,
|
|
86
|
+
type: MATRIX_KLAW_PRESENTATION_TYPE
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function resolveMatrixPresentationContent(payload) {
|
|
90
|
+
const presentation = toRecord(toRecord(resolveMatrixChannelData(payload).extraContent)?.[MATRIX_KLAW_PRESENTATION_KEY]);
|
|
91
|
+
if (!presentation || presentation.version !== 1 || presentation.type !== MATRIX_KLAW_PRESENTATION_TYPE) return;
|
|
92
|
+
return presentation;
|
|
93
|
+
}
|
|
94
|
+
function renderMatrixPresentationPayload(params) {
|
|
95
|
+
const matrixData = resolveMatrixChannelData(params.payload);
|
|
96
|
+
const fallbackText = renderMessagePresentationFallbackText({
|
|
97
|
+
text: params.payload.text,
|
|
98
|
+
presentation: params.presentation,
|
|
99
|
+
emptyFallback: MATRIX_EMPTY_PRESENTATION_FALLBACK_TEXT
|
|
100
|
+
});
|
|
101
|
+
return {
|
|
102
|
+
...params.payload,
|
|
103
|
+
text: fallbackText,
|
|
104
|
+
channelData: {
|
|
105
|
+
...params.payload.channelData,
|
|
106
|
+
matrix: {
|
|
107
|
+
...matrixData,
|
|
108
|
+
extraContent: { [MATRIX_KLAW_PRESENTATION_KEY]: buildMatrixPresentationContent(params.presentation) }
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function resolveMatrixPayloadText(payload) {
|
|
114
|
+
const text = payload.text ?? "";
|
|
115
|
+
if (text.trim() || !resolveMatrixPresentationContent(payload)) return text;
|
|
116
|
+
return MATRIX_EMPTY_PRESENTATION_FALLBACK_TEXT;
|
|
117
|
+
}
|
|
118
|
+
function resolveMatrixExtraContent(payload) {
|
|
119
|
+
const presentation = resolveMatrixPresentationContent(payload);
|
|
120
|
+
return presentation ? { [MATRIX_KLAW_PRESENTATION_KEY]: presentation } : void 0;
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region extensions/matrix/src/channel.runtime.ts
|
|
124
|
+
const matrixChannelRuntime = {
|
|
125
|
+
listMatrixDirectoryGroupsLive,
|
|
126
|
+
listMatrixDirectoryPeersLive,
|
|
127
|
+
matrixOutbound: {
|
|
128
|
+
deliveryMode: "direct",
|
|
129
|
+
chunker: chunkTextForOutbound,
|
|
130
|
+
chunkerMode: "markdown",
|
|
131
|
+
textChunkLimit: 4e3,
|
|
132
|
+
presentationCapabilities: {
|
|
133
|
+
supported: true,
|
|
134
|
+
buttons: true,
|
|
135
|
+
selects: true,
|
|
136
|
+
context: true,
|
|
137
|
+
divider: true,
|
|
138
|
+
limits: { text: {
|
|
139
|
+
markdownDialect: "markdown",
|
|
140
|
+
supportsEdit: true
|
|
141
|
+
} }
|
|
142
|
+
},
|
|
143
|
+
renderPresentation: ({ payload, presentation }) => renderMatrixPresentationPayload({
|
|
144
|
+
payload,
|
|
145
|
+
presentation
|
|
146
|
+
}),
|
|
147
|
+
sendPayload: async ({ cfg, to, payload, mediaLocalRoots, mediaReadFile, mediaAccess, deps, replyToId, replyToIdSource, replyToMode, threadId, accountId, audioAsVoice }) => {
|
|
148
|
+
const send = resolveOutboundSendDep(deps, "matrix") ?? sendMessageMatrix;
|
|
149
|
+
const resolvedThreadId = threadId !== void 0 && threadId !== null ? String(threadId) : void 0;
|
|
150
|
+
const resolveReplyToId = createReplyToFanout({
|
|
151
|
+
...replyToId != null ? { replyToId } : {},
|
|
152
|
+
...replyToIdSource !== void 0 ? { replyToIdSource } : {},
|
|
153
|
+
...replyToMode !== void 0 ? { replyToMode } : {}
|
|
154
|
+
});
|
|
155
|
+
const urls = resolvePayloadMediaUrls(payload);
|
|
156
|
+
const payloadText = resolveMatrixPayloadText(payload);
|
|
157
|
+
if (urls.length > 0) {
|
|
158
|
+
let lastResult;
|
|
159
|
+
for (let i = 0; i < urls.length; i++) {
|
|
160
|
+
const isFirst = i === 0;
|
|
161
|
+
lastResult = await send(to, isFirst ? payloadText : "", {
|
|
162
|
+
cfg,
|
|
163
|
+
mediaUrl: urls[i],
|
|
164
|
+
mediaAccess,
|
|
165
|
+
mediaLocalRoots,
|
|
166
|
+
mediaReadFile,
|
|
167
|
+
replyToId: resolveReplyToId(),
|
|
168
|
+
threadId: resolvedThreadId,
|
|
169
|
+
accountId: accountId ?? void 0,
|
|
170
|
+
audioAsVoice: payload.audioAsVoice ?? audioAsVoice,
|
|
171
|
+
extraContent: isFirst ? resolveMatrixExtraContent(payload) : void 0
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
channel: "matrix",
|
|
176
|
+
messageId: lastResult.messageId,
|
|
177
|
+
roomId: lastResult.roomId
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
const result = await send(to, payloadText, {
|
|
181
|
+
cfg,
|
|
182
|
+
mediaUrl: payload.mediaUrl,
|
|
183
|
+
mediaAccess,
|
|
184
|
+
mediaLocalRoots,
|
|
185
|
+
mediaReadFile,
|
|
186
|
+
replyToId: resolveReplyToId(),
|
|
187
|
+
threadId: resolvedThreadId,
|
|
188
|
+
accountId: accountId ?? void 0,
|
|
189
|
+
audioAsVoice: payload.audioAsVoice ?? audioAsVoice,
|
|
190
|
+
extraContent: resolveMatrixExtraContent(payload)
|
|
191
|
+
});
|
|
192
|
+
return {
|
|
193
|
+
channel: "matrix",
|
|
194
|
+
messageId: result.messageId,
|
|
195
|
+
roomId: result.roomId
|
|
196
|
+
};
|
|
197
|
+
},
|
|
198
|
+
sendText: async ({ cfg, to, text, deps, replyToId, threadId, accountId, audioAsVoice }) => {
|
|
199
|
+
const result = await (resolveOutboundSendDep(deps, "matrix") ?? sendMessageMatrix)(to, text, {
|
|
200
|
+
cfg,
|
|
201
|
+
replyToId: replyToId ?? void 0,
|
|
202
|
+
threadId: threadId !== void 0 && threadId !== null ? String(threadId) : void 0,
|
|
203
|
+
accountId: accountId ?? void 0,
|
|
204
|
+
audioAsVoice
|
|
205
|
+
});
|
|
206
|
+
return {
|
|
207
|
+
channel: "matrix",
|
|
208
|
+
messageId: result.messageId,
|
|
209
|
+
roomId: result.roomId
|
|
210
|
+
};
|
|
211
|
+
},
|
|
212
|
+
sendMedia: async ({ cfg, to, text, mediaUrl, mediaLocalRoots, mediaReadFile, deps, replyToId, threadId, accountId, audioAsVoice }) => {
|
|
213
|
+
const result = await (resolveOutboundSendDep(deps, "matrix") ?? sendMessageMatrix)(to, text, {
|
|
214
|
+
cfg,
|
|
215
|
+
mediaUrl,
|
|
216
|
+
mediaLocalRoots,
|
|
217
|
+
mediaReadFile,
|
|
218
|
+
replyToId: replyToId ?? void 0,
|
|
219
|
+
threadId: threadId !== void 0 && threadId !== null ? String(threadId) : void 0,
|
|
220
|
+
accountId: accountId ?? void 0,
|
|
221
|
+
audioAsVoice
|
|
222
|
+
});
|
|
223
|
+
return {
|
|
224
|
+
channel: "matrix",
|
|
225
|
+
messageId: result.messageId,
|
|
226
|
+
roomId: result.roomId
|
|
227
|
+
};
|
|
228
|
+
},
|
|
229
|
+
sendPoll: async ({ cfg, to, poll, threadId, accountId }) => {
|
|
230
|
+
const result = await sendPollMatrix(to, poll, {
|
|
231
|
+
cfg,
|
|
232
|
+
threadId: threadId !== void 0 && threadId !== null ? threadId : void 0,
|
|
233
|
+
accountId: accountId ?? void 0
|
|
234
|
+
});
|
|
235
|
+
return {
|
|
236
|
+
channel: "matrix",
|
|
237
|
+
messageId: result.eventId,
|
|
238
|
+
roomId: result.roomId,
|
|
239
|
+
pollId: result.eventId
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
probeMatrix,
|
|
244
|
+
resolveMatrixAuth,
|
|
245
|
+
resolveMatrixTargets,
|
|
246
|
+
sendMessageMatrix,
|
|
247
|
+
sendTypingMatrix
|
|
248
|
+
};
|
|
249
|
+
//#endregion
|
|
250
|
+
export { matrixChannelRuntime };
|