@elizaos/plugin-matrix 2.0.0-beta.1 → 2.0.3-beta.3

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Shaw Walters and elizaOS Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,36 +1,15 @@
1
1
  # @elizaos/plugin-matrix
2
2
 
3
- Matrix messaging integration plugin for ElizaOS agents.
3
+ Matrix messaging integration plugin for elizaOS agents.
4
4
 
5
5
  ## Features
6
6
 
7
- - **Decentralized Messaging**: Connect to any Matrix homeserver
8
- - **End-to-End Encryption**: Optional E2EE support for secure communications
9
- - **Room Support**: Join, leave, and manage Matrix rooms
10
- - **Reactions**: React to messages with emoji
11
- - **Threading**: Support for Matrix threads
12
- - **Direct Messages**: Handle DMs and group rooms
13
- - **Typing Indicators**: Send typing notifications
14
- - **Read Receipts**: Mark messages as read
15
-
16
- ## Installation
17
-
18
- ```bash
19
- npm install @elizaos/plugin-matrix
20
- ```
21
-
22
- ## Prerequisites
23
-
24
- 1. **Matrix Account**: A Matrix account on any homeserver
25
- 2. **Access Token**: Generate an access token for your account
26
-
27
- ### Getting an Access Token
28
-
29
- You can get an access token by:
30
-
31
- 1. **Element/Web Client**: Settings -> Help & About -> Access Token
32
- 2. **API Login**: Use the Matrix login API with your password
33
- 3. **Command Line**: Use `curl` or a tool like `matrix-commander`
7
+ - Connect to any Matrix homeserver via `matrix-js-sdk`
8
+ - Receive and send messages in Matrix rooms
9
+ - Room membership: join, leave, auto-join on invite
10
+ - Reactions, threading, typing indicators, read receipts
11
+ - Optional E2EE support
12
+ - Multi-account configuration
34
13
 
35
14
  ## Configuration
36
15
 
@@ -46,110 +25,58 @@ Set the following environment variables:
46
25
 
47
26
  ### Optional
48
27
 
49
- | Variable | Description | Default |
50
- |----------|-------------|---------|
51
- | `MATRIX_DEVICE_ID` | Device ID for this session | Auto-generated |
52
- | `MATRIX_ROOMS` | Comma-separated room IDs/aliases to auto-join | - |
53
- | `MATRIX_AUTO_JOIN` | Auto-accept room invites | `false` |
54
- | `MATRIX_ENCRYPTION` | Enable E2EE support | `false` |
55
- | `MATRIX_REQUIRE_MENTION` | Only respond when mentioned in rooms | `false` |
28
+ | Variable | Default | Description |
29
+ |----------|---------|-------------|
30
+ | `MATRIX_DEVICE_ID` | Auto-generated | Device ID for this session |
31
+ | `MATRIX_ROOMS` | — | Comma-separated room IDs/aliases to auto-join |
32
+ | `MATRIX_AUTO_JOIN` | `false` | Auto-accept room invites |
33
+ | `MATRIX_ENCRYPTION` | `false` | Enable E2EE support |
34
+ | `MATRIX_REQUIRE_MENTION` | `false` | Only respond when mentioned in rooms |
35
+ | `MATRIX_ACCOUNTS` | — | JSON array/object of per-account configs for multi-account setups |
36
+ | `MATRIX_DEFAULT_ACCOUNT_ID` | — | Which account is the default when multiple are configured |
37
+ | `MATRIX_ACCOUNT_ID` | — | Alias for `MATRIX_DEFAULT_ACCOUNT_ID` |
56
38
 
57
39
  ## Usage
58
40
 
59
- ### Basic Setup
60
-
61
41
  ```typescript
62
42
  import matrixPlugin from "@elizaos/plugin-matrix";
63
-
64
- const agent = new Agent({
65
- plugins: [matrixPlugin],
66
- });
43
+ // Pass to the plugin list when constructing an AgentRuntime or character config.
67
44
  ```
68
45
 
69
- ### Actions
70
-
71
- Matrix messaging is exposed through the canonical message connector actions.
72
- Use `source: "matrix"` when a request needs to target Matrix explicitly.
73
-
74
- | Primary action | Operation | Description |
75
- |----------------|-----------|-------------|
76
- | `MESSAGE` | `send` | Send a message to a Matrix room, channel, thread, or DM |
77
- | `MESSAGE` | `react` | React to a Matrix message with an emoji |
78
- | `MESSAGE` | `list_channels` | List joined Matrix rooms |
79
- | `MESSAGE` | `join` | Join a Matrix room by ID or alias |
80
- | `MESSAGE` | `leave` | Leave a Matrix room |
46
+ ## Connector actions
81
47
 
82
- ### Providers
48
+ Matrix messaging is exposed through the canonical message connector. Use `source: "matrix"` when a request needs to target Matrix explicitly.
83
49
 
84
- #### matrixRoomState
50
+ | Operation | Description |
51
+ |-----------|-------------|
52
+ | `send` | Send a message to a Matrix room, channel, thread, or DM |
53
+ | `react` | React to a Matrix message with an emoji |
54
+ | `list_channels` | List joined Matrix rooms |
55
+ | `join` | Join a Matrix room by ID or alias |
56
+ | `leave` | Leave a Matrix room |
85
57
 
86
- Provides context about the current Matrix room:
87
- - Room ID and name
88
- - Member count
89
- - Encryption status
90
- - Whether it's a DM
58
+ There are no registered `Provider` objects. Room context is surfaced through the connector's `getChatContext` and `listRooms` hooks.
91
59
 
92
- #### matrixUserContext
60
+ ## Events
93
61
 
94
- Provides context about the user in the conversation:
95
- - User ID
96
- - Display name
97
- - Avatar URL
62
+ The service emits these events via `runtime.emitEvent`:
98
63
 
99
- ### Events
64
+ | Event | Trigger |
65
+ |-------|---------|
66
+ | `MATRIX_MESSAGE_RECEIVED` | Incoming `m.room.message` (text only; filtered by `requireMention` if set) |
67
+ | `MATRIX_MESSAGE_SENT` | Message sent via `sendMessage` |
68
+ | `MATRIX_ROOM_JOINED` | `joinRoom` succeeds |
69
+ | `MATRIX_ROOM_LEFT` | `leaveRoom` succeeds |
70
+ | `MATRIX_SYNC_COMPLETE` | Matrix `PREPARED` sync state |
100
71
 
101
- The plugin emits the following events:
72
+ Additional constants (`MATRIX_INVITE_RECEIVED`, `MATRIX_REACTION_RECEIVED`, `MATRIX_TYPING_RECEIVED`, `MATRIX_CONNECTION_READY`, `MATRIX_CONNECTION_LOST`) are defined in `MatrixEventTypes` but not currently emitted by the service.
102
73
 
103
- | Event | Description |
104
- |-------|-------------|
105
- | `MATRIX_MESSAGE_RECEIVED` | A message was received |
106
- | `MATRIX_MESSAGE_SENT` | A message was sent |
107
- | `MATRIX_ROOM_JOINED` | Joined a room |
108
- | `MATRIX_ROOM_LEFT` | Left a room |
109
- | `MATRIX_INVITE_RECEIVED` | Received a room invite |
110
- | `MATRIX_REACTION_RECEIVED` | Received a reaction |
111
- | `MATRIX_SYNC_COMPLETE` | Initial sync completed |
112
- | `MATRIX_CONNECTION_READY` | Client connected |
113
- | `MATRIX_CONNECTION_LOST` | Connection lost |
74
+ ## Message limits
114
75
 
115
- ## Message Limits
76
+ Maximum message length: `MAX_MATRIX_MESSAGE_LENGTH = 4000` characters (exported from `src/types.ts`). The service does not auto-split; callers must chunk before calling `sendMessage`.
116
77
 
117
- - Maximum message length: 4000 characters
118
- - Longer messages are split automatically
119
-
120
- ## Matrix ID Formats
78
+ ## Matrix ID formats
121
79
 
122
80
  - **User ID**: `@localpart:homeserver.org`
123
81
  - **Room ID**: `!opaque_id:homeserver.org`
124
82
  - **Room Alias**: `#human_readable:homeserver.org`
125
-
126
- ## Security Considerations
127
-
128
- 1. **Token Security**: Never expose your access token
129
- 2. **Homeserver Trust**: Only connect to trusted homeservers
130
- 3. **E2EE**: Enable encryption for sensitive communications
131
- 4. **Room Verification**: Verify room members when using E2EE
132
-
133
- ## Troubleshooting
134
-
135
- ### Connection Issues
136
-
137
- 1. Verify your homeserver URL is correct
138
- 2. Check that your access token is valid
139
- 3. Ensure your homeserver is reachable
140
-
141
- ### Sync Issues
142
-
143
- 1. The initial sync may take time for accounts with many rooms
144
- 2. Check homeserver rate limits
145
- 3. Verify network connectivity
146
-
147
- ### Encryption Issues
148
-
149
- 1. Ensure E2EE is enabled on both ends
150
- 2. Verify device is properly set up
151
- 3. Check for key verification requirements
152
-
153
- ## License
154
-
155
- MIT
package/package.json CHANGED
@@ -1,17 +1,34 @@
1
1
  {
2
2
  "name": "@elizaos/plugin-matrix",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.3-beta.3",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
8
8
  ".": {
9
9
  "types": "./dist/index.d.ts",
10
+ "eliza-source": {
11
+ "types": "./src/index.ts",
12
+ "import": "./src/index.ts",
13
+ "default": "./src/index.ts"
14
+ },
10
15
  "import": "./dist/index.js",
11
16
  "default": "./dist/index.js"
17
+ },
18
+ "./*.css": "./dist/*.css",
19
+ "./*": {
20
+ "types": "./dist/*.d.ts",
21
+ "eliza-source": {
22
+ "types": "./src/*.ts",
23
+ "import": "./src/*.ts",
24
+ "default": "./src/*.ts"
25
+ },
26
+ "import": "./dist/*.js",
27
+ "default": "./dist/*.js"
12
28
  }
13
29
  },
14
30
  "files": [
31
+ "registry-entry.json",
15
32
  "dist",
16
33
  "auto-enable.ts"
17
34
  ],
@@ -30,14 +47,14 @@
30
47
  "lint:check": "bunx @biomejs/biome check .",
31
48
  "format": "bunx @biomejs/biome format --write .",
32
49
  "format:check": "bunx @biomejs/biome format .",
33
- "typecheck": "tsc --noEmit"
50
+ "typecheck": "tsgo --noEmit"
34
51
  },
35
52
  "dependencies": {
36
- "matrix-js-sdk": "^41.4.0",
37
- "zod": "^4.4.3"
53
+ "fake-indexeddb": "^6.2.5",
54
+ "matrix-js-sdk": "^41.4.0"
38
55
  },
39
56
  "peerDependencies": {
40
- "@elizaos/core": "2.0.0-beta.1"
57
+ "@elizaos/core": "2.0.3-beta.3"
41
58
  },
42
59
  "devDependencies": {
43
60
  "@biomejs/biome": "^2.4.14",
@@ -108,5 +125,6 @@
108
125
  "sensitive": false
109
126
  }
110
127
  }
111
- }
128
+ },
129
+ "gitHead": "f54b0f4eaed317d59fa7dbcdce20f4cdb0734420"
112
130
  }
@@ -0,0 +1,95 @@
1
+ {
2
+ "id": "matrix",
3
+ "name": "Matrix",
4
+ "description": "Matrix connector for rooms, bots, and federated chat workflows.",
5
+ "npmName": "@elizaos/plugin-matrix",
6
+ "version": "2.0.0-beta.0",
7
+ "source": "bundled",
8
+ "tags": ["connector", "messaging", "matrix", "chat", "social", "social-chat"],
9
+ "config": {
10
+ "MATRIX_ROOMS": {
11
+ "type": "string",
12
+ "required": false,
13
+ "sensitive": false,
14
+ "label": "Rooms",
15
+ "help": "Comma-separated room/channel list",
16
+ "advanced": false
17
+ },
18
+ "MATRIX_USER_ID": {
19
+ "type": "string",
20
+ "required": false,
21
+ "sensitive": false,
22
+ "label": "User Id",
23
+ "help": "User identifier",
24
+ "advanced": false
25
+ },
26
+ "MATRIX_AUTO_JOIN": {
27
+ "type": "boolean",
28
+ "required": false,
29
+ "sensitive": false,
30
+ "label": "Auto Join",
31
+ "help": "Automatically join/discover channels",
32
+ "advanced": false
33
+ },
34
+ "MATRIX_DEVICE_ID": {
35
+ "type": "string",
36
+ "required": false,
37
+ "sensitive": false,
38
+ "label": "Device Id",
39
+ "help": "Device identifier",
40
+ "advanced": false
41
+ },
42
+ "MATRIX_ENCRYPTION": {
43
+ "type": "boolean",
44
+ "required": false,
45
+ "sensitive": false,
46
+ "label": "Encryption",
47
+ "help": "Enable encryption",
48
+ "advanced": false
49
+ },
50
+ "MATRIX_HOMESERVER": {
51
+ "type": "string",
52
+ "required": false,
53
+ "sensitive": false,
54
+ "label": "Homeserver",
55
+ "help": "Homeserver URL",
56
+ "advanced": false
57
+ },
58
+ "MATRIX_ACCESS_TOKEN": {
59
+ "type": "secret",
60
+ "required": true,
61
+ "sensitive": true,
62
+ "label": "Access Token",
63
+ "help": "Access token for Matrix",
64
+ "advanced": false
65
+ },
66
+ "MATRIX_REQUIRE_MENTION": {
67
+ "type": "boolean",
68
+ "required": false,
69
+ "sensitive": false,
70
+ "label": "Require Mention",
71
+ "help": "Only respond when mentioned",
72
+ "advanced": false
73
+ }
74
+ },
75
+ "render": {
76
+ "visible": false,
77
+ "pinTo": [],
78
+ "style": "setup-panel",
79
+ "icon": "Link",
80
+ "group": "connector",
81
+ "groupOrder": 1,
82
+ "actions": ["enable", "configure", "setup-guide"]
83
+ },
84
+ "resources": {
85
+ "setupGuideUrl": "https://docs.eliza.ai/plugin-setup-guide#matrix"
86
+ },
87
+ "dependsOn": [],
88
+ "kind": "connector",
89
+ "subtype": "messaging",
90
+ "auth": {
91
+ "kind": "token",
92
+ "credentialKeys": ["MATRIX_ACCESS_TOKEN"]
93
+ },
94
+ "channels": ["matrix"]
95
+ }
@@ -1,14 +0,0 @@
1
- import type { IAgentRuntime } from "@elizaos/core";
2
- import type { MatrixSettings } from "./types.js";
3
- export declare const DEFAULT_MATRIX_ACCOUNT_ID = "default";
4
- export type MatrixAccountConfig = Partial<Omit<MatrixSettings, "rooms" | "accountId">> & {
5
- accountId?: string;
6
- id?: string;
7
- rooms?: string[] | string;
8
- };
9
- export declare function normalizeMatrixAccountId(accountId?: unknown): string;
10
- export declare function listMatrixAccountIds(runtime: IAgentRuntime): string[];
11
- export declare function resolveDefaultMatrixAccountId(runtime: IAgentRuntime): string;
12
- export declare function readMatrixAccountId(...sources: unknown[]): string | undefined;
13
- export declare function resolveMatrixAccountSettings(runtime: IAgentRuntime, requestedAccountId?: string | null): MatrixSettings;
14
- //# sourceMappingURL=accounts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../src/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,eAAO,MAAM,yBAAyB,YAAY,CAAC;AAEnD,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,OAAO,GAAG,WAAW,CAAC,CAAC,GAAG;IACvF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;CAC3B,CAAC;AAqEF,wBAAgB,wBAAwB,CAAC,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAIpE;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,EAAE,CAkBrE;AAED,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAQ5E;AAED,wBAAgB,mBAAmB,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,GAAG,SAAS,CA6B7E;AAED,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,aAAa,EACtB,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,GACjC,cAAc,CAiDhB"}
@@ -1,18 +0,0 @@
1
- /**
2
- * Matrix ConnectorAccountManager provider.
3
- *
4
- * Adapts the multi-account scaffolding in `accounts.ts` to the
5
- * `ConnectorAccountProvider` contract from
6
- * `@elizaos/core/connectors/account-manager`.
7
- *
8
- * Source of truth for accounts is character settings (`character.settings.matrix`)
9
- * + MATRIX_ACCOUNTS JSON env var + single-account env vars (MATRIX_HOMESERVER,
10
- * MATRIX_USER_ID, MATRIX_ACCESS_TOKEN). AccountKey is `<homeserver>/<userId>`
11
- * by convention; role is `OWNER` since matrix access tokens authenticate the
12
- * user, not a bot. E2EE keys are scoped per account by the matrix client and
13
- * are NOT shared between accounts.
14
- */
15
- import type { ConnectorAccountProvider, IAgentRuntime } from "@elizaos/core";
16
- export declare const MATRIX_PROVIDER_ID = "matrix";
17
- export declare function createMatrixConnectorAccountProvider(runtime: IAgentRuntime): ConnectorAccountProvider;
18
- //# sourceMappingURL=connector-account-provider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connector-account-provider.d.ts","sourceRoot":"","sources":["../src/connector-account-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAIV,wBAAwB,EACxB,aAAa,EACd,MAAM,eAAe,CAAC;AASvB,eAAO,MAAM,kBAAkB,WAAW,CAAC;AAmC3C,wBAAgB,oCAAoC,CAClD,OAAO,EAAE,aAAa,GACrB,wBAAwB,CAmC1B"}
package/dist/index.d.ts DELETED
@@ -1,15 +0,0 @@
1
- /**
2
- * Matrix messaging integration plugin for ElizaOS.
3
- *
4
- * This plugin provides Matrix protocol integration using matrix-js-sdk.
5
- */
6
- import type { Plugin } from "@elizaos/core";
7
- export * from "./accounts.js";
8
- export { MatrixService } from "./service.js";
9
- export * from "./types.js";
10
- /**
11
- * Matrix plugin definition.
12
- */
13
- declare const matrixPlugin: Plugin;
14
- export default matrixPlugin;
15
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAiB,MAAM,EAAE,MAAM,eAAe,CAAC;AAG3D,cAAc,eAAe,CAAC;AAE9B,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,cAAc,YAAY,CAAC;AAO3B;;GAEG;AACH,QAAA,MAAM,YAAY,EAAE,MAmFnB,CAAC;AAEF,eAAe,YAAY,CAAC"}