@aigne/afs-matrix 1.11.0-beta.12

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/LICENSE.md ADDED
@@ -0,0 +1,26 @@
1
+ # Proprietary License
2
+
3
+ Copyright (c) 2024-2025 ArcBlock, Inc. All Rights Reserved.
4
+
5
+ This software and associated documentation files (the "Software") are proprietary
6
+ and confidential. Unauthorized copying, modification, distribution, or use of
7
+ this Software, via any medium, is strictly prohibited.
8
+
9
+ The Software is provided for internal use only within ArcBlock, Inc. and its
10
+ authorized affiliates.
11
+
12
+ ## No License Granted
13
+
14
+ No license, express or implied, is granted to any party for any purpose.
15
+ All rights are reserved by ArcBlock, Inc.
16
+
17
+ ## Public Artifact Distribution
18
+
19
+ Portions of this Software may be released publicly under separate open-source
20
+ licenses (such as MIT License) through designated public repositories. Such
21
+ public releases are governed by their respective licenses and do not affect
22
+ the proprietary nature of this repository.
23
+
24
+ ## Contact
25
+
26
+ For licensing inquiries, contact: legal@arcblock.io
package/dist/index.cjs ADDED
@@ -0,0 +1,457 @@
1
+ let _aigne_afs_provider = require("@aigne/afs/provider");
2
+ let _aigne_afs_messaging = require("@aigne/afs-messaging");
3
+
4
+ //#region src/client.ts
5
+ /**
6
+ * MatrixClient — pure Matrix Client-Server API wrapper.
7
+ *
8
+ * Zero external dependencies (uses native fetch).
9
+ * No AFS or application-specific concepts.
10
+ */
11
+ const DEFAULT_TIMEOUT = 3e4;
12
+ let _txnCounter = 0;
13
+ var MatrixClient = class {
14
+ _accessToken;
15
+ _homeserver;
16
+ _timeout;
17
+ constructor(options) {
18
+ if (!options.accessToken) throw new Error("MatrixClient requires an accessToken");
19
+ if (!options.homeserver) throw new Error("MatrixClient requires a homeserver");
20
+ this._accessToken = options.accessToken;
21
+ this._homeserver = options.homeserver.replace(/\/+$/, "");
22
+ this._timeout = options.timeout ?? DEFAULT_TIMEOUT;
23
+ }
24
+ async sendMessage(roomId, text) {
25
+ const txnId = `m${Date.now()}.${_txnCounter++}`;
26
+ return this._call("PUT", `/_matrix/client/v3/rooms/${encodeURIComponent(roomId)}/send/m.room.message/${txnId}`, {
27
+ msgtype: "m.text",
28
+ body: text
29
+ });
30
+ }
31
+ async sendTyping(roomId, userId, timeout = 1e4) {
32
+ await this._call("PUT", `/_matrix/client/v3/rooms/${encodeURIComponent(roomId)}/typing/${encodeURIComponent(userId)}`, {
33
+ typing: true,
34
+ timeout
35
+ });
36
+ }
37
+ async sync(since, timeout) {
38
+ const params = new URLSearchParams();
39
+ if (since) params.set("since", since);
40
+ if (timeout !== void 0) params.set("timeout", String(timeout));
41
+ return this._call("GET", `/_matrix/client/v3/sync?${params.toString()}`);
42
+ }
43
+ async whoami() {
44
+ return this._call("GET", "/_matrix/client/v3/account/whoami");
45
+ }
46
+ async _call(method, path, body) {
47
+ const headers = { Authorization: `Bearer ${this._accessToken}` };
48
+ const init = {
49
+ method,
50
+ headers,
51
+ signal: AbortSignal.timeout(this._timeout)
52
+ };
53
+ if (body) {
54
+ headers["Content-Type"] = "application/json";
55
+ init.body = JSON.stringify(body);
56
+ }
57
+ const response = await fetch(`${this._homeserver}${path}`, init);
58
+ if (!response.ok) {
59
+ const desc = (await response.text().catch(() => "")).replace(this._accessToken, "***");
60
+ throw new Error(`Matrix API error ${response.status}: ${desc}`);
61
+ }
62
+ return response.json();
63
+ }
64
+ };
65
+
66
+ //#endregion
67
+ //#region \0@oxc-project+runtime@0.108.0/helpers/decorate.js
68
+ function __decorate(decorators, target, key, desc) {
69
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
70
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
71
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
72
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
73
+ }
74
+
75
+ //#endregion
76
+ //#region src/index.ts
77
+ var AFSMatrix = class extends _aigne_afs_messaging.BaseMessageProvider {
78
+ static manifest() {
79
+ return {
80
+ name: "matrix",
81
+ description: "Matrix messaging — decentralized, federated chat protocol.\n- Sync long-poll for real-time message reception\n- Multi-bot support with per-bot room monitoring\n- Path: /:bot/conversations/:roomId/messages/:eventId",
82
+ uriTemplate: "matrix://{homeserver}",
83
+ category: "messaging",
84
+ schema: {
85
+ type: "object",
86
+ properties: {
87
+ homeserver: {
88
+ type: "string",
89
+ description: "Matrix homeserver URL"
90
+ },
91
+ accessToken: {
92
+ type: "string",
93
+ description: "Matrix access token",
94
+ sensitive: true
95
+ },
96
+ rooms: {
97
+ type: "array",
98
+ items: { type: "string" },
99
+ description: "Room IDs to monitor"
100
+ }
101
+ },
102
+ required: ["homeserver", "accessToken"]
103
+ },
104
+ tags: [
105
+ "matrix",
106
+ "messaging",
107
+ "chat",
108
+ "decentralized",
109
+ "federated"
110
+ ],
111
+ capabilityTags: [
112
+ "read-write",
113
+ "crud",
114
+ "search",
115
+ "auth:token",
116
+ "remote",
117
+ "http",
118
+ "real-time"
119
+ ],
120
+ security: {
121
+ riskLevel: "external",
122
+ resourceAccess: ["internet"],
123
+ notes: ["Connects to Matrix homeserver — requires access token"]
124
+ },
125
+ capabilities: { network: { egress: true } }
126
+ };
127
+ }
128
+ static treeSchema() {
129
+ return {
130
+ operations: [
131
+ "list",
132
+ "read",
133
+ "exec",
134
+ "stat",
135
+ "explain"
136
+ ],
137
+ tree: {
138
+ "/": {
139
+ kind: "messaging:root",
140
+ operations: ["list", "exec"],
141
+ actions: [
142
+ "add-bot",
143
+ "remove-bot",
144
+ "start",
145
+ "stop",
146
+ "process-event"
147
+ ]
148
+ },
149
+ "/{bot}": {
150
+ kind: "messaging:bot",
151
+ operations: ["list", "read"]
152
+ },
153
+ "/{bot}/ctl": {
154
+ kind: "messaging:status",
155
+ operations: ["read"]
156
+ },
157
+ "/{bot}/conversations": {
158
+ kind: "messaging:conversations",
159
+ operations: ["list"]
160
+ },
161
+ "/{bot}/conversations/{convId}": {
162
+ kind: "messaging:conversation",
163
+ operations: ["list"]
164
+ },
165
+ "/{bot}/conversations/{convId}/messages": {
166
+ kind: "messaging:messages",
167
+ operations: ["list", "exec"],
168
+ actions: ["send"]
169
+ },
170
+ "/{bot}/conversations/{convId}/messages/{msgId}": {
171
+ kind: "messaging:message",
172
+ operations: ["read"]
173
+ }
174
+ },
175
+ auth: {
176
+ type: "token",
177
+ env: ["MATRIX_ACCESS_TOKEN"]
178
+ },
179
+ bestFor: [
180
+ "decentralized chat",
181
+ "federated messaging",
182
+ "privacy-focused comms"
183
+ ],
184
+ notFor: ["file storage", "database queries"]
185
+ };
186
+ }
187
+ providerName = "matrix";
188
+ eventPrefix = "matrix";
189
+ _syncStates = /* @__PURE__ */ new Map();
190
+ _userIds = /* @__PURE__ */ new Map();
191
+ constructor(options) {
192
+ let bots;
193
+ if (options.bots) {
194
+ bots = options.bots.map((b) => ({
195
+ name: b.name,
196
+ accessToken: b.token,
197
+ homeserver: b.homeserver,
198
+ conversations: b.conversations
199
+ }));
200
+ for (const bot of options.bots) {
201
+ if (!bot.token) throw new Error(`AFSMatrix bot "${bot.name}" requires a token`);
202
+ if (!bot.homeserver) throw new Error(`AFSMatrix bot "${bot.name}" requires a homeserver`);
203
+ }
204
+ } else {
205
+ if (!options.accessToken) throw new Error("AFSMatrix requires an accessToken");
206
+ if (!options.homeserver) throw new Error("AFSMatrix requires a homeserver");
207
+ bots = [{
208
+ name: "default",
209
+ accessToken: options.accessToken,
210
+ homeserver: options.homeserver,
211
+ conversations: options.rooms ?? []
212
+ }];
213
+ }
214
+ super({
215
+ bots,
216
+ bufferSize: options.bufferSize
217
+ });
218
+ for (const bot of bots) this._syncStates.set(bot.name, {
219
+ syncing: false,
220
+ disposed: false,
221
+ abort: null,
222
+ backoff: 1e3,
223
+ nextBatch: null
224
+ });
225
+ }
226
+ getMessageCapabilities() {
227
+ return {
228
+ formats: {
229
+ send: ["text", "markdown"],
230
+ receive: ["text"]
231
+ },
232
+ maxMessageLength: 65536,
233
+ features: {
234
+ edit: true,
235
+ delete: false,
236
+ reply: true,
237
+ thread: true,
238
+ reaction: true,
239
+ inlineKeyboard: false
240
+ },
241
+ limits: { messagesPerSecond: 10 }
242
+ };
243
+ }
244
+ createBotClient(config) {
245
+ return new MatrixClient({
246
+ accessToken: config.accessToken,
247
+ homeserver: config.homeserver
248
+ });
249
+ }
250
+ async sendMessage(client, convId, text, _opts) {
251
+ return { messageId: (await client.sendMessage(convId, text)).event_id };
252
+ }
253
+ async sendTypingIndicator(client, convId) {
254
+ const mc = client;
255
+ const botName = [...this._botClients.entries()].find(([, c]) => c === client)?.[0] ?? "";
256
+ let userId = this._userIds.get(botName);
257
+ if (!userId) {
258
+ userId = (await mc.whoami()).user_id;
259
+ this._userIds.set(botName, userId);
260
+ }
261
+ await mc.sendTyping(convId, userId);
262
+ }
263
+ normalizeMessage(raw) {
264
+ const evt = raw;
265
+ return {
266
+ id: String(evt.event_id ?? "0"),
267
+ text: String(evt.content?.body ?? ""),
268
+ from: this.normalizeSender({ sender: evt.sender }),
269
+ timestamp: evt.origin_server_ts ? Math.floor(evt.origin_server_ts / 1e3) : Math.floor(Date.now() / 1e3),
270
+ conversationId: String(evt.room_id ?? ""),
271
+ platform: { event_id: evt.event_id }
272
+ };
273
+ }
274
+ normalizeSender(raw) {
275
+ const sender = String(raw.sender ?? raw.id ?? "");
276
+ return {
277
+ id: sender,
278
+ name: sender.match(/^@([^:]+):/)?.[1] ?? sender
279
+ };
280
+ }
281
+ start(botName) {
282
+ const names = botName ? [botName] : [...this._syncStates.keys()];
283
+ for (const name of names) {
284
+ const state = this._syncStates.get(name);
285
+ if (!state || state.syncing || state.disposed) continue;
286
+ state.syncing = true;
287
+ this._syncLoop(name);
288
+ }
289
+ }
290
+ stop(botName) {
291
+ const names = botName ? [botName] : [...this._syncStates.keys()];
292
+ for (const name of names) {
293
+ const state = this._syncStates.get(name);
294
+ if (!state) continue;
295
+ state.syncing = false;
296
+ if (state.abort) {
297
+ state.abort.abort();
298
+ state.abort = null;
299
+ }
300
+ }
301
+ }
302
+ dispose() {
303
+ for (const [, state] of this._syncStates) {
304
+ state.syncing = false;
305
+ state.disposed = true;
306
+ if (state.abort) {
307
+ state.abort.abort();
308
+ state.abort = null;
309
+ }
310
+ }
311
+ }
312
+ async listRootActions(_ctx) {
313
+ return { data: [
314
+ this.buildEntry("/.actions/add-bot", { meta: { description: "Add a bot instance at runtime" } }),
315
+ this.buildEntry("/.actions/remove-bot", { meta: { description: "Remove a bot instance" } }),
316
+ this.buildEntry("/.actions/start", { meta: { description: "Start sync loop for updates" } }),
317
+ this.buildEntry("/.actions/stop", { meta: { description: "Stop sync loop" } }),
318
+ this.buildEntry("/.actions/process-event", { meta: { description: "Inject a Matrix event externally" } })
319
+ ] };
320
+ }
321
+ async execStart(_ctx) {
322
+ this.start();
323
+ return {
324
+ success: true,
325
+ data: {
326
+ ok: true,
327
+ syncing: true
328
+ }
329
+ };
330
+ }
331
+ async execStop(_ctx) {
332
+ this.stop();
333
+ return {
334
+ success: true,
335
+ data: {
336
+ ok: true,
337
+ syncing: false
338
+ }
339
+ };
340
+ }
341
+ async execProcessEvent(_ctx, args) {
342
+ this._processEvent(args);
343
+ return {
344
+ success: true,
345
+ data: { ok: true }
346
+ };
347
+ }
348
+ async _syncLoop(botName) {
349
+ const state = this._syncStates.get(botName);
350
+ const client = this._getClient(botName);
351
+ if (!state || !client) return;
352
+ while (state.syncing && !state.disposed) try {
353
+ state.abort = new AbortController();
354
+ const response = await client.sync(state.nextBatch ?? void 0, 3e4);
355
+ state.nextBatch = response.next_batch;
356
+ if (response.rooms?.join) for (const [roomId, room] of Object.entries(response.rooms.join)) {
357
+ const events = room.timeline?.events ?? [];
358
+ for (const evt of events) if (evt.type === "m.room.message" && evt.content?.msgtype === "m.text") {
359
+ const text = String(evt.content.body ?? "").trim();
360
+ if (!text) continue;
361
+ this.emitMessageReceived(botName, {
362
+ id: String(evt.event_id),
363
+ text,
364
+ from: this.normalizeSender({ sender: evt.sender }),
365
+ timestamp: evt.origin_server_ts ? Math.floor(evt.origin_server_ts / 1e3) : Math.floor(Date.now() / 1e3),
366
+ conversationId: roomId,
367
+ platform: { event_id: evt.event_id }
368
+ });
369
+ }
370
+ }
371
+ state.backoff = 1e3;
372
+ } catch (err) {
373
+ if (state.disposed) break;
374
+ const msg = err instanceof Error ? err.message : "";
375
+ if (/API error (401|403)/.test(msg)) {
376
+ state.syncing = false;
377
+ break;
378
+ }
379
+ await new Promise((r) => setTimeout(r, state.backoff));
380
+ state.backoff = Math.min(state.backoff * 2, 6e4);
381
+ }
382
+ }
383
+ /** Process an externally-provided Matrix event. Public for testing. */
384
+ _processEvent(payload) {
385
+ const botName = payload.botName ?? this._botOrder[0] ?? "default";
386
+ const evt = payload;
387
+ const eventId = String(evt.event_id ?? evt.id ?? Date.now());
388
+ const sender = String(evt.sender ?? "");
389
+ const body = String(evt.content?.body ?? evt.body ?? "").trim();
390
+ const roomId = String(evt.room_id ?? evt.roomId ?? "");
391
+ const originServerTs = evt.origin_server_ts ?? evt.timestamp;
392
+ if (!body) return;
393
+ this.emitMessageReceived(botName, {
394
+ id: eventId,
395
+ text: body,
396
+ from: this.normalizeSender({ sender }),
397
+ timestamp: originServerTs ? Math.floor(Number(originServerTs) / 1e3) : Math.floor(Date.now() / 1e3),
398
+ conversationId: roomId,
399
+ platform: { event_id: eventId }
400
+ });
401
+ }
402
+ /** Add a room to a bot. Defaults to first bot. */
403
+ addRoom(roomId, botName) {
404
+ const name = botName ?? this._botOrder[0];
405
+ if (!name) return;
406
+ const convs = this._botConversations.get(name);
407
+ if (!convs || convs.has(roomId)) return;
408
+ convs.add(roomId);
409
+ const buffers = this._botBuffers.get(name);
410
+ if (buffers && !buffers.has(roomId)) buffers.set(roomId, []);
411
+ }
412
+ /** Remove a room from a bot. */
413
+ removeRoom(roomId, botName) {
414
+ const name = botName ?? this._botOrder[0];
415
+ if (!name) return;
416
+ const convs = this._botConversations.get(name);
417
+ if (convs) convs.delete(roomId);
418
+ const buffers = this._botBuffers.get(name);
419
+ if (buffers) buffers.delete(roomId);
420
+ }
421
+ /** Add a message to the ring buffer directly. Public for testing/conformance. */
422
+ _addToBuffer(roomId, msg) {
423
+ const botName = this._botOrder[0] ?? "default";
424
+ const convs = this._botConversations.get(botName);
425
+ if (convs && !convs.has(roomId)) convs.add(roomId);
426
+ let botBuffers = this._botBuffers.get(botName);
427
+ if (!botBuffers) {
428
+ botBuffers = /* @__PURE__ */ new Map();
429
+ this._botBuffers.set(botName, botBuffers);
430
+ }
431
+ let buffer = botBuffers.get(roomId);
432
+ if (!buffer) {
433
+ buffer = [];
434
+ botBuffers.set(roomId, buffer);
435
+ }
436
+ const senderName = msg.sender.match(/^@([^:]+):/)?.[1] ?? msg.sender;
437
+ buffer.push({
438
+ id: msg.event_id,
439
+ text: msg.body,
440
+ from: {
441
+ id: msg.sender,
442
+ name: senderName
443
+ },
444
+ timestamp: msg.origin_server_ts ? Math.floor(msg.origin_server_ts / 1e3) : Math.floor(Date.now() / 1e3),
445
+ conversationId: roomId,
446
+ platform: { event_id: msg.event_id }
447
+ });
448
+ while (buffer.length > this._bufferSize) buffer.shift();
449
+ }
450
+ };
451
+ __decorate([(0, _aigne_afs_provider.Actions)("/")], AFSMatrix.prototype, "listRootActions", null);
452
+ __decorate([_aigne_afs_provider.Actions.Exec("/", "start")], AFSMatrix.prototype, "execStart", null);
453
+ __decorate([_aigne_afs_provider.Actions.Exec("/", "stop")], AFSMatrix.prototype, "execStop", null);
454
+ __decorate([_aigne_afs_provider.Actions.Exec("/", "process-event")], AFSMatrix.prototype, "execProcessEvent", null);
455
+
456
+ //#endregion
457
+ exports.AFSMatrix = AFSMatrix;
@@ -0,0 +1,156 @@
1
+ import { AFSExecResult, AFSListResult, ProviderTreeSchema } from "@aigne/afs";
2
+ import { RouteContext } from "@aigne/afs/provider";
3
+ import { BaseMessageProvider, BotConfig, BufferedMessage, MessageCapabilities, MessageSender, SendOptions } from "@aigne/afs-messaging";
4
+
5
+ //#region src/client.d.ts
6
+ /**
7
+ * MatrixClient — pure Matrix Client-Server API wrapper.
8
+ *
9
+ * Zero external dependencies (uses native fetch).
10
+ * No AFS or application-specific concepts.
11
+ */
12
+ interface MatrixClientOptions {
13
+ accessToken: string;
14
+ homeserver: string;
15
+ timeout?: number;
16
+ }
17
+ /** Matrix room message event (subset). */
18
+ interface MatrixEvent {
19
+ event_id: string;
20
+ type: string;
21
+ sender: string;
22
+ content: {
23
+ msgtype?: string;
24
+ body?: string;
25
+ [key: string]: unknown;
26
+ };
27
+ origin_server_ts: number;
28
+ room_id?: string;
29
+ }
30
+ /** Matrix sync response (subset). */
31
+ interface MatrixSyncResponse {
32
+ next_batch: string;
33
+ rooms?: {
34
+ join?: Record<string, {
35
+ timeline?: {
36
+ events?: MatrixEvent[];
37
+ };
38
+ }>;
39
+ };
40
+ }
41
+ /** Matrix whoami response. */
42
+ interface MatrixWhoamiResponse {
43
+ user_id: string;
44
+ device_id?: string;
45
+ }
46
+ declare class MatrixClient {
47
+ private readonly _accessToken;
48
+ private readonly _homeserver;
49
+ private readonly _timeout;
50
+ constructor(options: MatrixClientOptions);
51
+ sendMessage(roomId: string, text: string): Promise<{
52
+ event_id: string;
53
+ }>;
54
+ sendTyping(roomId: string, userId: string, timeout?: number): Promise<void>;
55
+ sync(since?: string, timeout?: number): Promise<MatrixSyncResponse>;
56
+ whoami(): Promise<MatrixWhoamiResponse>;
57
+ private _call;
58
+ }
59
+ //#endregion
60
+ //#region src/index.d.ts
61
+ interface AFSMatrixOptions {
62
+ /** Multi-bot config */
63
+ bots?: Array<{
64
+ name: string;
65
+ token: string;
66
+ homeserver: string;
67
+ conversations?: string[];
68
+ }>;
69
+ /** Single-bot shorthand: access token */
70
+ accessToken?: string;
71
+ /** Single-bot shorthand: homeserver URL */
72
+ homeserver?: string;
73
+ /** Single-bot shorthand: room IDs to monitor */
74
+ rooms?: string[];
75
+ bufferSize?: number;
76
+ }
77
+ declare class AFSMatrix extends BaseMessageProvider {
78
+ static manifest(): {
79
+ name: string;
80
+ description: string;
81
+ uriTemplate: string;
82
+ category: string;
83
+ schema: {
84
+ type: string;
85
+ properties: {
86
+ homeserver: {
87
+ type: string;
88
+ description: string;
89
+ };
90
+ accessToken: {
91
+ type: string;
92
+ description: string;
93
+ sensitive: boolean;
94
+ };
95
+ rooms: {
96
+ type: string;
97
+ items: {
98
+ type: string;
99
+ };
100
+ description: string;
101
+ };
102
+ };
103
+ required: string[];
104
+ };
105
+ tags: string[];
106
+ capabilityTags: string[];
107
+ security: {
108
+ riskLevel: string;
109
+ resourceAccess: string[];
110
+ notes: string[];
111
+ };
112
+ capabilities: {
113
+ network: {
114
+ egress: boolean;
115
+ };
116
+ };
117
+ };
118
+ static treeSchema(): ProviderTreeSchema;
119
+ readonly providerName = "matrix";
120
+ readonly eventPrefix = "matrix";
121
+ private readonly _syncStates;
122
+ private readonly _userIds;
123
+ constructor(options: AFSMatrixOptions);
124
+ getMessageCapabilities(): MessageCapabilities;
125
+ createBotClient(config: BotConfig): MatrixClient;
126
+ sendMessage(client: unknown, convId: string, text: string, _opts?: SendOptions): Promise<{
127
+ messageId: string;
128
+ }>;
129
+ sendTypingIndicator(client: unknown, convId: string): Promise<void>;
130
+ normalizeMessage(raw: Record<string, unknown>): BufferedMessage;
131
+ normalizeSender(raw: Record<string, unknown>): MessageSender;
132
+ start(botName?: string): void;
133
+ stop(botName?: string): void;
134
+ dispose(): void;
135
+ listRootActions(_ctx: RouteContext): Promise<AFSListResult>;
136
+ execStart(_ctx: RouteContext): Promise<AFSExecResult>;
137
+ execStop(_ctx: RouteContext): Promise<AFSExecResult>;
138
+ execProcessEvent(_ctx: RouteContext, args: Record<string, unknown>): Promise<AFSExecResult>;
139
+ private _syncLoop;
140
+ /** Process an externally-provided Matrix event. Public for testing. */
141
+ _processEvent(payload: Record<string, unknown>): void;
142
+ /** Add a room to a bot. Defaults to first bot. */
143
+ addRoom(roomId: string, botName?: string): void;
144
+ /** Remove a room from a bot. */
145
+ removeRoom(roomId: string, botName?: string): void;
146
+ /** Add a message to the ring buffer directly. Public for testing/conformance. */
147
+ _addToBuffer(roomId: string, msg: {
148
+ event_id: string;
149
+ sender: string;
150
+ body: string;
151
+ origin_server_ts?: number;
152
+ }): void;
153
+ }
154
+ //#endregion
155
+ export { AFSMatrix, AFSMatrixOptions, type MatrixClient, type MatrixEvent, type MatrixSyncResponse, type MatrixWhoamiResponse };
156
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/client.ts","../src/index.ts"],"mappings":";;;;;;;;;;AASA;UAAiB,mBAAA;EACf,WAAA;EACA,UAAA;EACA,OAAA;AAAA;;UAIe,WAAA;EACf,QAAA;EACA,IAAA;EACA,MAAA;EACA,OAAA;IACE,OAAA;IACA,IAAA;IAAA,CACC,GAAA;EAAA;EAEH,gBAAA;EACA,OAAA;AAAA;;UAIe,kBAAA;EACf,UAAA;EACA,KAAA;IACE,IAAA,GAAO,MAAA;MAGH,QAAA;QACE,MAAA,GAAS,WAAA;MAAA;IAAA;EAAA;AAAA;;UAQF,oBAAA;EACf,OAAA;EACA,SAAA;AAAA;AAAA,cAKW,YAAA;EAAA,iBACM,YAAA;EAAA,iBACA,WAAA;EAAA,iBACA,QAAA;cAEL,OAAA,EAAS,mBAAA;EAUf,WAAA,CAAY,MAAA,UAAgB,IAAA,WAAe,OAAA;IAAU,QAAA;EAAA;EASrD,UAAA,CAAW,MAAA,UAAgB,MAAA,UAAgB,OAAA,YAAkB,OAAA;EAQ7D,IAAA,CAAK,KAAA,WAAgB,OAAA,YAAmB,OAAA,CAAQ,kBAAA;EAOhD,MAAA,CAAA,GAAU,OAAA,CAAQ,oBAAA;EAAA,QAMV,KAAA;AAAA;;;UC1DC,gBAAA;EDbf;ECeA,IAAA,GAAO,KAAA;IACL,IAAA;IACA,KAAA;IACA,UAAA;IACA,aAAA;EAAA;EDdF;ECiBA,WAAA;EDfE;ECiBF,UAAA;EDdM;ECgBN,KAAA;EACA,UAAA;AAAA;AAAA,cAWW,SAAA,SAAkB,mBAAA;EAAA,OACtB,QAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SA6BA,UAAA,CAAA,GAAc,kBAAA;EAAA,SA6BZ,YAAA;EAAA,SACA,WAAA;EAAA,iBAEQ,WAAA;EAAA,iBACA,QAAA;cAEL,OAAA,EAAS,gBAAA;EAyCrB,sBAAA,CAAA,GAA0B,mBAAA;EAqB1B,eAAA,CAAgB,MAAA,EAAQ,SAAA,GAAY,YAAA;EAO9B,WAAA,CACJ,MAAA,WACA,MAAA,UACA,IAAA,UACA,KAAA,GAAQ,WAAA,GACP,OAAA;IAAU,SAAA;EAAA;EAMP,mBAAA,CAAoB,MAAA,WAAiB,MAAA,WAAiB,OAAA;EAa5D,gBAAA,CAAiB,GAAA,EAAK,MAAA,oBAA0B,eAAA;EAchD,eAAA,CAAgB,GAAA,EAAK,MAAA,oBAA0B,aAAA;EAa/C,KAAA,CAAM,OAAA;EAUN,IAAA,CAAK,OAAA;EAaL,OAAA,CAAA;EAcM,eAAA,CAAgB,IAAA,EAAM,YAAA,GAAe,OAAA,CAAQ,aAAA;EAuB7C,SAAA,CAAU,IAAA,EAAM,YAAA,GAAe,OAAA,CAAQ,aAAA;EAMvC,QAAA,CAAS,IAAA,EAAM,YAAA,GAAe,OAAA,CAAQ,aAAA;EAMtC,gBAAA,CACJ,IAAA,EAAM,YAAA,EACN,IAAA,EAAM,MAAA,oBACL,OAAA,CAAQ,aAAA;EAAA,QAOG,SAAA;EAtRJ;EA+UV,aAAA,CAAc,OAAA,EAAS,MAAA;EApUF;EAgWrB,OAAA,CAAQ,MAAA,UAAgB,OAAA;EAlUH;EA+UrB,UAAA,CAAW,MAAA,UAAgB,OAAA;EAnQD;EA6Q1B,YAAA,CACE,MAAA,UACA,GAAA;IACE,QAAA;IACA,MAAA;IACA,IAAA;IACA,gBAAA;EAAA;AAAA"}