@elizaos/plugin-matrix 2.0.3-beta.5 → 2.0.3-beta.7

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.
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,205 @@
1
+ /**
2
+ * Matrix service implementation for ElizaOS.
3
+ *
4
+ * This service provides Matrix messaging capabilities using matrix-js-sdk.
5
+ */
6
+ import { type Content, type IAgentRuntime, type Memory, Service } from "@elizaos/core";
7
+ import { type IMatrixService, type MatrixMessageSendOptions, type MatrixRoom, type MatrixSendResult } from "./types.js";
8
+ /**
9
+ * Serialized form of an IndexedDB database: object-store schemas plus their
10
+ * records. v8.serialize handles the structured-clone values (typed arrays,
11
+ * Maps, etc.) the rust-crypto store writes, so this shape round-trips losslessly.
12
+ */
13
+ export type CryptoStoreSnapshot = {
14
+ version: number;
15
+ stores: Record<string, {
16
+ schema: {
17
+ keyPath: IDBObjectStore["keyPath"];
18
+ autoIncrement: boolean;
19
+ indexes: {
20
+ name: string;
21
+ keyPath: IDBIndex["keyPath"];
22
+ unique: boolean;
23
+ multiEntry: boolean;
24
+ }[];
25
+ };
26
+ records: {
27
+ key: IDBValidKey;
28
+ value: unknown;
29
+ }[];
30
+ }>;
31
+ };
32
+ /**
33
+ * Read every object store of an IndexedDB database into a serializable snapshot:
34
+ * each store's schema (keyPath, autoIncrement, indexes) plus all of its records.
35
+ * Pure over the global `indexedDB`, so it is unit-testable with fake-indexeddb.
36
+ */
37
+ export declare function snapshotDb(name: string): Promise<CryptoStoreSnapshot>;
38
+ /**
39
+ * Recreate an IndexedDB database from a snapshot: delete any existing db, build
40
+ * the stores + indexes in an upgrade transaction, then replay the records.
41
+ * Keyless stores re-supply the out-of-line key; keyPath stores derive it.
42
+ * Pure over the global `indexedDB`, so it is unit-testable with fake-indexeddb.
43
+ */
44
+ export declare function restoreDb(name: string, snapshot: CryptoStoreSnapshot): Promise<void>;
45
+ /**
46
+ * Matrix messaging service for ElizaOS agents.
47
+ */
48
+ export declare class MatrixService extends Service implements IMatrixService {
49
+ static serviceType: string;
50
+ capabilityDescription: string;
51
+ protected runtime: IAgentRuntime;
52
+ private states;
53
+ private defaultAccountId;
54
+ /**
55
+ * Start the Matrix service.
56
+ */
57
+ static start(runtime: IAgentRuntime): Promise<MatrixService>;
58
+ /**
59
+ * Stop the Matrix service.
60
+ */
61
+ static stopRuntime(runtime: IAgentRuntime): Promise<void>;
62
+ static registerSendHandlers(runtime: IAgentRuntime, service: MatrixService, accountId?: string): void;
63
+ /**
64
+ * Initialize the Matrix service.
65
+ */
66
+ private initialize;
67
+ /**
68
+ * Load settings from runtime.
69
+ */
70
+ private loadSettings;
71
+ /**
72
+ * Validate the settings.
73
+ */
74
+ private validateSettings;
75
+ /**
76
+ * Initialize end-to-end encryption for an account when MATRIX_ENCRYPTION is
77
+ * enabled. Most homeservers (including Continuwuity) encrypt rooms by
78
+ * default, so without crypto the client can neither decrypt inbound nor
79
+ * encrypt outbound messages — it would silently drop everything.
80
+ *
81
+ * The rust-crypto store persists in IndexedDB. This runtime (Bun/Node) has no
82
+ * native IndexedDB, so `fake-indexeddb/auto` installs a global one and the
83
+ * whole crypto state — device identity, cross-signing, and inbound megolm
84
+ * sessions — is snapshotted to an encrypted file via saveCryptoStore and
85
+ * restored before init via restoreCryptoStore. A stable device keeps the
86
+ * curve25519/ed25519 identity across restarts, so senders treat it as the
87
+ * same trusted device and keep sharing room keys (including forwarded history
88
+ * keys at join), which is what makes history decryptable.
89
+ *
90
+ * Non-fatal by construction: if anything in the persistence path fails we fall
91
+ * back to an in-memory store so the Matrix connection still comes up. Never
92
+ * throws.
93
+ */
94
+ private initCrypto;
95
+ /**
96
+ * Self-cross-sign this device so cohort senders running "exclude insecure
97
+ * devices" (MSC4153) share megolm room keys to it — the thing that makes
98
+ * encrypted cohort messages decryptable. The device otherwise carries an empty
99
+ * cross-signing identity and is structurally skipped by those senders.
100
+ *
101
+ * Works with only an access token: MSC3967 (implemented by the homeserver) lets
102
+ * the FIRST device-signing-key upload through with no UIA, so we send auth=null
103
+ * and soft-fail (log, never throw) if the server still demands a password we
104
+ * don't have. Idempotent + non-fatal: the signing keys persist in the
105
+ * snapshotted rust store, so isCrossSigningReady() short-circuits this on every
106
+ * later boot, and any failure leaves the Matrix connection untouched.
107
+ */
108
+ private ensureCrossSigning;
109
+ /**
110
+ * Restore the persisted rust-crypto IndexedDB store from the encrypted at-rest
111
+ * file into the live (fake-indexeddb) global, replacing whatever is there.
112
+ * Must run BEFORE initRustCrypto so the store is populated when the crypto
113
+ * stack opens it.
114
+ *
115
+ * Strictly additive and non-fatal: any failure (missing file, corrupt data,
116
+ * token rotation making decrypt impossible) only warns and returns, leaving an
117
+ * empty store so the device starts fresh.
118
+ */
119
+ private restoreCryptoStore;
120
+ /**
121
+ * Snapshot the live rust-crypto IndexedDB store and persist it, encrypted at
122
+ * rest, so the device identity and room keys survive a process restart. The
123
+ * snapshot contains PRIVATE device keys, so it is written 0600 and encrypted
124
+ * under a token-derived key. Atomic (tmp + rename) so a crash mid-write can
125
+ * never truncate the live file. Strictly additive and non-fatal: failures only
126
+ * warn and never affect the Matrix connection.
127
+ */
128
+ private saveCryptoStore;
129
+ /**
130
+ * Start the periodic crypto-store snapshot for an account. The interval is
131
+ * unref'd so it never keeps the process alive on its own, and its handle is
132
+ * stored on the account state so stop() can clear it.
133
+ */
134
+ private startCryptoSnapshot;
135
+ /**
136
+ * Set up event handlers for the Matrix client.
137
+ */
138
+ private setupEventHandlers;
139
+ /**
140
+ * Let allow-listed users verify this device via SAS (emoji) verification from
141
+ * their own Matrix client. On homeservers where the bot can't self-cross-sign
142
+ * (no MSC3967 + no password), this is how senders come to trust the device and
143
+ * start sharing megolm keys to it — and the verifying user's client also
144
+ * gossips the room keys it already holds, backfilling history.
145
+ *
146
+ * Fail-closed: with no MATRIX_VERIFY_ALLOWLIST nothing is accepted, so this is
147
+ * inert unless explicitly configured. The verified trust persists in the
148
+ * snapshotted crypto store, so it is a one-time action per user.
149
+ */
150
+ private setupVerificationAutoAccept;
151
+ private handleVerificationRequest;
152
+ /**
153
+ * Wait for the verifier to materialize. The bot is a pure responder: the
154
+ * initiator (e.g. Element) sends the m.key.verification.start, which creates
155
+ * the verifier on our side. We only start SAS ourselves as a fallback, after a
156
+ * short grace period, for the rare initiator that waits for the responder to
157
+ * start — starting eagerly would race the initiator's start ("glare") and the
158
+ * two sides would compute the SAS over different start events, failing the
159
+ * match. Resolves undefined if the request is cancelled or completes first.
160
+ */
161
+ private awaitVerifier;
162
+ /**
163
+ * Handle an incoming room message.
164
+ */
165
+ private handleRoomMessage;
166
+ /**
167
+ * Feed an inbound Matrix message into the core message loop and wire a
168
+ * callback that posts the agent's reply back to the same room. Mirrors the
169
+ * connector pattern used by plugin-discord: emit EventType.MESSAGE_RECEIVED
170
+ * with a core Memory and a HandlerCallback. The bootstrap message handler
171
+ * runs the agent, decides whether to respond, and invokes the callback.
172
+ */
173
+ private dispatchToAgent;
174
+ /**
175
+ * Connect to Matrix.
176
+ */
177
+ private connect;
178
+ /**
179
+ * Shutdown the service.
180
+ */
181
+ stop(): Promise<void>;
182
+ isConnected(): boolean;
183
+ getAccountId(runtime?: IAgentRuntime): string;
184
+ getUserId(): string;
185
+ getHomeserver(): string;
186
+ getJoinedRooms(accountId?: string): Promise<MatrixRoom[]>;
187
+ /**
188
+ * Read recent messages straight from the SDK's live room timeline (kept in
189
+ * sync by the RoomEvent.Timeline listener), newest-first. Unlike the agent's
190
+ * own memory DB, this surfaces room activity the agent never persisted —
191
+ * e.g. a busy room where the bot was never mentioned.
192
+ */
193
+ getRoomMessages(matrixRoomId: string, limit: number, accountId?: string): Promise<Memory[]>;
194
+ sendMessage(text: string, options?: MatrixMessageSendOptions): Promise<MatrixSendResult>;
195
+ sendReaction(roomId: string, eventId: string, emoji: string, accountId?: string): Promise<MatrixSendResult>;
196
+ joinRoom(roomIdOrAlias: string, accountId?: string): Promise<string>;
197
+ leaveRoom(roomId: string, accountId?: string): Promise<void>;
198
+ sendTyping(roomId: string, typing: boolean, timeout?: number, accountId?: string): Promise<void>;
199
+ sendReadReceipt(roomId: string, eventId: string, accountId?: string): Promise<void>;
200
+ sendRoomMessage(roomIdOrAlias: string, content: Content): Promise<void>;
201
+ sendDirectMessage(roomIdOrAlias: string, content: Content): Promise<void>;
202
+ private handleSendMessage;
203
+ private getState;
204
+ }
205
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,EAEL,KAAK,OAAO,EAKZ,KAAK,aAAa,EAGlB,KAAK,MAAM,EAGX,OAAO,EAGR,MAAM,eAAe,CAAC;AAqBvB,OAAO,EAEL,KAAK,cAAc,EAOnB,KAAK,wBAAwB,EAE7B,KAAK,UAAU,EACf,KAAK,gBAAgB,EAGtB,MAAM,YAAY,CAAC;AAwHpB;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CACZ,MAAM,EACN;QACE,MAAM,EAAE;YACN,OAAO,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC;YACnC,aAAa,EAAE,OAAO,CAAC;YACvB,OAAO,EAAE;gBACP,IAAI,EAAE,MAAM,CAAC;gBACb,OAAO,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;gBAC7B,MAAM,EAAE,OAAO,CAAC;gBAChB,UAAU,EAAE,OAAO,CAAC;aACrB,EAAE,CAAC;SACL,CAAC;QACF,OAAO,EAAE;YAAE,GAAG,EAAE,WAAW,CAAC;YAAC,KAAK,EAAE,OAAO,CAAA;SAAE,EAAE,CAAC;KACjD,CACF,CAAC;CACH,CAAC;AA6GF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IAAI,CAAC;IAWvE,iBAAiB,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;YAIjE,iBAAiB;IAoC/B,OAAO,CAAC,QAAQ;CA0BjB"}
@@ -0,0 +1,241 @@
1
+ /**
2
+ * Type definitions for the Matrix plugin.
3
+ */
4
+ import type { IAgentRuntime, Service } from "@elizaos/core";
5
+ /** Maximum message length for Matrix */
6
+ export declare const MAX_MATRIX_MESSAGE_LENGTH = 4000;
7
+ /** Service name constant */
8
+ export declare const MATRIX_SERVICE_NAME = "matrix";
9
+ /** Event types emitted by the Matrix plugin */
10
+ export declare enum MatrixEventTypes {
11
+ MESSAGE_RECEIVED = "MATRIX_MESSAGE_RECEIVED",
12
+ MESSAGE_SENT = "MATRIX_MESSAGE_SENT",
13
+ ROOM_JOINED = "MATRIX_ROOM_JOINED",
14
+ ROOM_LEFT = "MATRIX_ROOM_LEFT",
15
+ INVITE_RECEIVED = "MATRIX_INVITE_RECEIVED",
16
+ REACTION_RECEIVED = "MATRIX_REACTION_RECEIVED",
17
+ TYPING_RECEIVED = "MATRIX_TYPING_RECEIVED",
18
+ SYNC_COMPLETE = "MATRIX_SYNC_COMPLETE",
19
+ CONNECTION_READY = "MATRIX_CONNECTION_READY",
20
+ CONNECTION_LOST = "MATRIX_CONNECTION_LOST"
21
+ }
22
+ /** Configuration settings for the Matrix plugin */
23
+ export interface MatrixSettings {
24
+ /** Connector account identifier for this Matrix bot instance */
25
+ accountId?: string;
26
+ /** Matrix homeserver URL */
27
+ homeserver: string;
28
+ /** Matrix user ID (@user:homeserver) */
29
+ userId: string;
30
+ /** Access token for authentication */
31
+ accessToken: string;
32
+ /**
33
+ * Account password — only used to satisfy user-interactive auth when
34
+ * self-cross-signing on homeservers that require it for the device-signing-key
35
+ * upload (i.e. no MSC3967). Absent ⇒ cross-signing is attempted token-only and
36
+ * skipped if the server demands a password.
37
+ */
38
+ password?: string;
39
+ /** Device ID for this session */
40
+ deviceId?: string;
41
+ /** Rooms to auto-join */
42
+ rooms: string[];
43
+ /** Whether to auto-accept invites */
44
+ autoJoin: boolean;
45
+ /** Enable end-to-end encryption */
46
+ encryption: boolean;
47
+ /** Require mention to respond in rooms */
48
+ requireMention: boolean;
49
+ /**
50
+ * Matrix user IDs allowed to verify this device via SAS (emoji) verification.
51
+ * When one of them starts a verification from their own client, the bot auto-
52
+ * accepts and auto-confirms, so their client then shares megolm room keys to
53
+ * this now-trusted device. Fail-closed: empty ⇒ no verification is accepted.
54
+ */
55
+ verifyAllowlist: string[];
56
+ /**
57
+ * Whether this account is the HUMAN owner's personal account (acting as the
58
+ * user) rather than the agent's own identity. A personal account is exposed as
59
+ * an OWNER connector behind the owner_binding access gate (acting as the user
60
+ * requires a verified binding); the default account — the agent's own Matrix
61
+ * identity — is an AGENT connector with the open gate (acting as the bot is
62
+ * frictionless).
63
+ */
64
+ personal: boolean;
65
+ /** Whether this configuration is enabled */
66
+ enabled: boolean;
67
+ }
68
+ /** Information about a Matrix user */
69
+ export interface MatrixUserInfo {
70
+ /** Matrix user ID (@user:homeserver) */
71
+ userId: string;
72
+ /** Display name */
73
+ displayName?: string;
74
+ /** Avatar URL */
75
+ avatarUrl?: string;
76
+ }
77
+ /** Represents a Matrix room */
78
+ export interface MatrixRoom {
79
+ /** Room ID (!room:homeserver) */
80
+ roomId: string;
81
+ /** Room name */
82
+ name?: string;
83
+ /** Room topic */
84
+ topic?: string;
85
+ /** Room alias (#alias:homeserver) */
86
+ canonicalAlias?: string;
87
+ /** Whether room is encrypted */
88
+ isEncrypted: boolean;
89
+ /** Whether this is a direct message room */
90
+ isDirect: boolean;
91
+ /** Member count */
92
+ memberCount: number;
93
+ }
94
+ /** Represents a Matrix message */
95
+ export interface MatrixMessage {
96
+ /** Event ID */
97
+ eventId: string;
98
+ /** Room ID */
99
+ roomId: string;
100
+ /** Sender user ID */
101
+ sender: string;
102
+ /** Sender info */
103
+ senderInfo: MatrixUserInfo;
104
+ /** Message content */
105
+ content: string;
106
+ /** Message type (m.text, m.image, etc.) */
107
+ msgType: string;
108
+ /** Formatted body (HTML) */
109
+ formattedBody?: string;
110
+ /** Timestamp */
111
+ timestamp: number;
112
+ /** Thread root event ID */
113
+ threadId?: string;
114
+ /** Reply-to event ID */
115
+ replyTo?: string;
116
+ /** Whether this is an edit */
117
+ isEdit: boolean;
118
+ /** Original event ID if this is an edit */
119
+ replacesEventId?: string;
120
+ }
121
+ /** Options for sending a message */
122
+ export interface MatrixMessageSendOptions {
123
+ /** Connector account identifier */
124
+ accountId?: string;
125
+ /** Room ID or alias to send to */
126
+ roomId?: string;
127
+ /** Event ID to reply to */
128
+ replyTo?: string;
129
+ /** Thread root event ID */
130
+ threadId?: string;
131
+ /** Format as HTML */
132
+ formatted?: boolean;
133
+ /** Media URL to attach */
134
+ mediaUrl?: string;
135
+ }
136
+ /** Result from sending a message */
137
+ export interface MatrixSendResult {
138
+ /** Whether the send succeeded */
139
+ success: boolean;
140
+ /** Event ID of the sent message */
141
+ eventId?: string;
142
+ /** Room ID */
143
+ roomId?: string;
144
+ /** Error message if failed */
145
+ error?: string;
146
+ }
147
+ /** Interface for the Matrix service */
148
+ export interface IMatrixService extends Service {
149
+ /** Check if the service is connected */
150
+ isConnected(): boolean;
151
+ /** Get the user ID */
152
+ getUserId(): string;
153
+ /** Get the homeserver URL */
154
+ getHomeserver(): string;
155
+ /** Get joined rooms */
156
+ getJoinedRooms(): Promise<MatrixRoom[]>;
157
+ /** Send a message */
158
+ sendMessage(text: string, options?: MatrixMessageSendOptions): Promise<MatrixSendResult>;
159
+ /** Send a reaction */
160
+ sendReaction(roomId: string, eventId: string, emoji: string): Promise<MatrixSendResult>;
161
+ /** Join a room */
162
+ joinRoom(roomIdOrAlias: string): Promise<string>;
163
+ /** Leave a room */
164
+ leaveRoom(roomId: string): Promise<void>;
165
+ /** Send typing indicator */
166
+ sendTyping(roomId: string, typing: boolean, timeout?: number): Promise<void>;
167
+ /** Send read receipt */
168
+ sendReadReceipt(roomId: string, eventId: string): Promise<void>;
169
+ }
170
+ /** Payload for MESSAGE_RECEIVED event */
171
+ export interface MatrixMessageReceivedPayload {
172
+ message: MatrixMessage;
173
+ room: MatrixRoom;
174
+ runtime: IAgentRuntime;
175
+ }
176
+ /** Payload for MESSAGE_SENT event */
177
+ export interface MatrixMessageSentPayload {
178
+ roomId: string;
179
+ eventId: string;
180
+ content: string;
181
+ }
182
+ /** Payload for ROOM_JOINED event */
183
+ export interface MatrixRoomJoinedPayload {
184
+ room: MatrixRoom;
185
+ }
186
+ /** Payload for INVITE_RECEIVED event */
187
+ export interface MatrixInviteReceivedPayload {
188
+ roomId: string;
189
+ inviter: string;
190
+ }
191
+ /**
192
+ * Check if a string is a valid Matrix user ID.
193
+ */
194
+ export declare function isValidMatrixUserId(userId: string): boolean;
195
+ /**
196
+ * Check if a string is a valid Matrix room ID.
197
+ */
198
+ export declare function isValidMatrixRoomId(roomId: string): boolean;
199
+ /**
200
+ * Check if a string is a valid Matrix room alias.
201
+ */
202
+ export declare function isValidMatrixRoomAlias(alias: string): boolean;
203
+ /**
204
+ * Extract the localpart from a Matrix ID.
205
+ */
206
+ export declare function getMatrixLocalpart(matrixId: string): string;
207
+ /**
208
+ * Extract the server part from a Matrix ID.
209
+ */
210
+ export declare function getMatrixServerpart(matrixId: string): string;
211
+ /**
212
+ * Get the best display name for a Matrix user.
213
+ */
214
+ export declare function getMatrixUserDisplayName(user: MatrixUserInfo): string;
215
+ /**
216
+ * Convert a media URL to an HTTP URL via homeserver.
217
+ */
218
+ export declare function matrixMxcToHttp(mxcUrl: string, homeserver: string): string | undefined;
219
+ /** Base error class for Matrix plugin errors */
220
+ export declare class MatrixPluginError extends Error {
221
+ constructor(message: string);
222
+ }
223
+ /** Error when the Matrix service is not initialized */
224
+ export declare class MatrixServiceNotInitializedError extends MatrixPluginError {
225
+ constructor(message?: string);
226
+ }
227
+ /** Error when the Matrix client is not connected */
228
+ export declare class MatrixNotConnectedError extends MatrixPluginError {
229
+ constructor(message?: string);
230
+ }
231
+ /** Error when there is a configuration problem */
232
+ export declare class MatrixConfigurationError extends MatrixPluginError {
233
+ settingName?: string;
234
+ constructor(message: string, settingName?: string);
235
+ }
236
+ /** Error when an API call fails */
237
+ export declare class MatrixApiError extends MatrixPluginError {
238
+ errcode?: string;
239
+ constructor(message: string, errcode?: string);
240
+ }
241
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAM5D,wCAAwC;AACxC,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAE9C,4BAA4B;AAC5B,eAAO,MAAM,mBAAmB,WAAW,CAAC;AAM5C,+CAA+C;AAC/C,oBAAY,gBAAgB;IAC1B,gBAAgB,4BAA4B;IAC5C,YAAY,wBAAwB;IACpC,WAAW,uBAAuB;IAClC,SAAS,qBAAqB;IAC9B,eAAe,2BAA2B;IAC1C,iBAAiB,6BAA6B;IAC9C,eAAe,2BAA2B;IAC1C,aAAa,yBAAyB;IACtC,gBAAgB,4BAA4B;IAC5C,eAAe,2BAA2B;CAC3C;AAMD,mDAAmD;AACnD,MAAM,WAAW,cAAc;IAC7B,gEAAgE;IAChE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4BAA4B;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,sCAAsC;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yBAAyB;IACzB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,qCAAqC;IACrC,QAAQ,EAAE,OAAO,CAAC;IAClB,m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AM,GAAG,MAAM,CAG3D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAG5D;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CAErE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAUtF;AAMD,gDAAgD;AAChD,qBAAa,iBAAkB,SAAQ,KAAK;gBAC9B,OAAO,EAAE,MAAM;CAI5B;AAED,uDAAuD;AACvD,qBAAa,gCAAiC,SAAQ,iBAAiB;gBACzD,OAAO,GAAE,MAA4C;CAIlE;AAED,oDAAoD;AACpD,qBAAa,uBAAwB,SAAQ,iBAAiB;gBAChD,OAAO,GAAE,MAAyC;CAI/D;AAED,kDAAkD;AAClD,qBAAa,wBAAyB,SAAQ,iBAAiB;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;gBAET,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM;CAKlD;AAED,mCAAmC;AACnC,qBAAa,cAAe,SAAQ,iBAAiB;IACnD,OAAO,CAAC,EAAE,MAAM,CAAC;gBAEL,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;CAK9C"}
@@ -0,0 +1,21 @@
1
+ import { type IAgentRuntime, Service } from "@elizaos/core";
2
+ type CredentialProviderResult = {
3
+ status: "credential_data";
4
+ data: Record<string, unknown>;
5
+ } | {
6
+ status: "needs_auth";
7
+ authUrl: string;
8
+ } | null;
9
+ export declare class MatrixWorkflowCredentialProvider extends Service {
10
+ static readonly serviceType = "workflow_credential_provider";
11
+ capabilityDescription: string;
12
+ static start(runtime: IAgentRuntime): Promise<MatrixWorkflowCredentialProvider>;
13
+ stop(): Promise<void>;
14
+ resolve(_userId: string, credType: string): Promise<CredentialProviderResult>;
15
+ checkCredentialTypes(credTypes: string[]): {
16
+ supported: string[];
17
+ unsupported: string[];
18
+ };
19
+ }
20
+ export {};
21
+ //# sourceMappingURL=workflow-credential-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-credential-provider.d.ts","sourceRoot":"","sources":["../src/workflow-credential-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAK5D,KAAK,wBAAwB,GACzB;IAAE,MAAM,EAAE,iBAAiB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GAC5D;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACzC,IAAI,CAAC;AAIT,qBAAa,gCAAiC,SAAQ,OAAO;IAC3D,gBAAyB,WAAW,kCAAqC;IAChE,qBAAqB,SAAyD;WAE1E,KAAK,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,gCAAgC,CAAC;IAI/E,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAErB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAWnF,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG;QAAE,SAAS,EAAE,MAAM,EAAE,CAAC;QAAC,WAAW,EAAE,MAAM,EAAE,CAAA;KAAE;CAM1F"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elizaos/plugin-matrix",
3
- "version": "2.0.3-beta.5",
3
+ "version": "2.0.3-beta.7",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -54,7 +54,7 @@
54
54
  "matrix-js-sdk": "^41.4.0"
55
55
  },
56
56
  "peerDependencies": {
57
- "@elizaos/core": "2.0.3-beta.5"
57
+ "@elizaos/core": "2.0.3-beta.7"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@biomejs/biome": "^2.4.14",
@@ -126,5 +126,5 @@
126
126
  }
127
127
  }
128
128
  },
129
- "gitHead": "ff6157011c9459670021cc28a6797592a78b8817"
129
+ "gitHead": "61094f10458d11055c75b3dd0bae374e3f66bac5"
130
130
  }