@elizaos/plugin-matrix 2.0.0-alpha.8 → 2.0.11-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.
- package/LICENSE +21 -0
- package/README.md +82 -0
- package/auto-enable.ts +20 -0
- package/package.json +38 -12
- package/dist/actions/joinRoom.d.ts +0 -6
- package/dist/actions/joinRoom.d.ts.map +0 -1
- package/dist/actions/listRooms.d.ts +0 -6
- package/dist/actions/listRooms.d.ts.map +0 -1
- package/dist/actions/sendMessage.d.ts +0 -6
- package/dist/actions/sendMessage.d.ts.map +0 -1
- package/dist/actions/sendReaction.d.ts +0 -6
- package/dist/actions/sendReaction.d.ts.map +0 -1
- package/dist/index.d.ts +0 -22
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -1031
- package/dist/index.js.map +0 -18
- package/dist/providers/roomState.d.ts +0 -9
- package/dist/providers/roomState.d.ts.map +0 -1
- package/dist/providers/userContext.d.ts +0 -9
- package/dist/providers/userContext.d.ts.map +0 -1
- package/dist/service.d.ts +0 -66
- package/dist/service.d.ts.map +0 -1
- package/dist/types.d.ts +0 -214
- package/dist/types.d.ts.map +0 -1
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
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# @elizaos/plugin-matrix
|
|
2
|
+
|
|
3
|
+
Matrix messaging integration plugin for elizaOS agents.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
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
|
|
13
|
+
|
|
14
|
+
## Configuration
|
|
15
|
+
|
|
16
|
+
Set the following environment variables:
|
|
17
|
+
|
|
18
|
+
### Required
|
|
19
|
+
|
|
20
|
+
| Variable | Description |
|
|
21
|
+
|----------|-------------|
|
|
22
|
+
| `MATRIX_HOMESERVER` | Homeserver URL (e.g., https://matrix.org) |
|
|
23
|
+
| `MATRIX_USER_ID` | Full Matrix user ID (@user:homeserver.org) |
|
|
24
|
+
| `MATRIX_ACCESS_TOKEN` | Access token for authentication |
|
|
25
|
+
|
|
26
|
+
### Optional
|
|
27
|
+
|
|
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` |
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import matrixPlugin from "@elizaos/plugin-matrix";
|
|
43
|
+
// Pass to the plugin list when constructing an AgentRuntime or character config.
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Connector actions
|
|
47
|
+
|
|
48
|
+
Matrix messaging is exposed through the canonical message connector. Use `source: "matrix"` when a request needs to target Matrix explicitly.
|
|
49
|
+
|
|
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 |
|
|
57
|
+
|
|
58
|
+
There are no registered `Provider` objects. Room context is surfaced through the connector's `getChatContext` and `listRooms` hooks.
|
|
59
|
+
|
|
60
|
+
## Events
|
|
61
|
+
|
|
62
|
+
The service emits these events via `runtime.emitEvent`:
|
|
63
|
+
|
|
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 |
|
|
71
|
+
|
|
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.
|
|
73
|
+
|
|
74
|
+
## Message limits
|
|
75
|
+
|
|
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`.
|
|
77
|
+
|
|
78
|
+
## Matrix ID formats
|
|
79
|
+
|
|
80
|
+
- **User ID**: `@localpart:homeserver.org`
|
|
81
|
+
- **Room ID**: `!opaque_id:homeserver.org`
|
|
82
|
+
- **Room Alias**: `#human_readable:homeserver.org`
|
package/auto-enable.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Auto-enable check for @elizaos/plugin-matrix.
|
|
2
|
+
//
|
|
3
|
+
// Plugin manifest entry-point — referenced by package.json's
|
|
4
|
+
// `elizaos.plugin.autoEnableModule`. Keep this module light: env reads only,
|
|
5
|
+
// no service init, no transitive imports of the full plugin runtime. The
|
|
6
|
+
// auto-enable engine loads dozens of these per boot.
|
|
7
|
+
import type { PluginAutoEnableContext } from "@elizaos/core";
|
|
8
|
+
|
|
9
|
+
/** Enable when a `matrix` connector block is present and not explicitly disabled. */
|
|
10
|
+
export function shouldEnable(ctx: PluginAutoEnableContext): boolean {
|
|
11
|
+
const c = (ctx.config?.connectors as Record<string, unknown> | undefined)?.matrix;
|
|
12
|
+
if (!c || typeof c !== "object") return false;
|
|
13
|
+
const config = c as Record<string, unknown>;
|
|
14
|
+
if (config.enabled === false) return false;
|
|
15
|
+
// The full per-connector field check (homeserver/accessToken/userId) lives
|
|
16
|
+
// in the central engine's isConnectorConfigured. We delegate to a simple
|
|
17
|
+
// "block present + not explicitly disabled" check here; the central
|
|
18
|
+
// engine's stricter check remains as a fallback during migration.
|
|
19
|
+
return true;
|
|
20
|
+
}
|
package/package.json
CHANGED
|
@@ -1,42 +1,67 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elizaos/plugin-matrix",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.11-beta.7",
|
|
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": [
|
|
15
|
-
"dist"
|
|
31
|
+
"dist",
|
|
32
|
+
"auto-enable.ts"
|
|
16
33
|
],
|
|
34
|
+
"elizaos": {
|
|
35
|
+
"plugin": {
|
|
36
|
+
"autoEnableModule": "./auto-enable.ts",
|
|
37
|
+
"capabilities": [
|
|
38
|
+
"messaging"
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
},
|
|
17
42
|
"scripts": {
|
|
18
43
|
"build": "bun run build.ts",
|
|
19
|
-
"test": "vitest run --config vitest.config.ts
|
|
44
|
+
"test": "vitest run --config vitest.config.ts",
|
|
20
45
|
"lint": "bunx @biomejs/biome check --write --unsafe .",
|
|
21
46
|
"lint:check": "bunx @biomejs/biome check .",
|
|
22
47
|
"format": "bunx @biomejs/biome format --write .",
|
|
23
48
|
"format:check": "bunx @biomejs/biome format .",
|
|
24
|
-
"typecheck": "
|
|
49
|
+
"typecheck": "tsgo --noEmit"
|
|
25
50
|
},
|
|
26
51
|
"dependencies": {
|
|
27
|
-
"
|
|
28
|
-
"
|
|
52
|
+
"fake-indexeddb": "^6.2.5",
|
|
53
|
+
"matrix-js-sdk": "^41.4.0"
|
|
29
54
|
},
|
|
30
55
|
"peerDependencies": {
|
|
31
|
-
"@elizaos/core": "2.0.
|
|
56
|
+
"@elizaos/core": "2.0.11-beta.7"
|
|
32
57
|
},
|
|
33
58
|
"devDependencies": {
|
|
59
|
+
"@biomejs/biome": "^2.4.14",
|
|
34
60
|
"@types/bun": "^1.1.0",
|
|
35
|
-
"typescript": "^
|
|
36
|
-
"
|
|
37
|
-
"vitest": "^3.2.4"
|
|
61
|
+
"typescript": "^6.0.3",
|
|
62
|
+
"vitest": "^4.0.0"
|
|
38
63
|
},
|
|
39
|
-
"
|
|
64
|
+
"eliza": {
|
|
40
65
|
"platforms": [
|
|
41
66
|
"node"
|
|
42
67
|
],
|
|
@@ -99,5 +124,6 @@
|
|
|
99
124
|
"sensitive": false
|
|
100
125
|
}
|
|
101
126
|
}
|
|
102
|
-
}
|
|
127
|
+
},
|
|
128
|
+
"gitHead": "cdbc876f793d96073d7eb0d09715a031ce0cd32e"
|
|
103
129
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"joinRoom.d.ts","sourceRoot":"","sources":["../../src/actions/joinRoom.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,MAAM,EAOP,MAAM,eAAe,CAAC;AA2BvB,eAAO,MAAM,QAAQ,EAAE,MA4GtB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"listRooms.d.ts","sourceRoot":"","sources":["../../src/actions/listRooms.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,MAAM,EAOP,MAAM,eAAe,CAAC;AAIvB,eAAO,MAAM,SAAS,EAAE,MA6EvB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sendMessage.d.ts","sourceRoot":"","sources":["../../src/actions/sendMessage.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,MAAM,EAOP,MAAM,eAAe,CAAC;AA6BvB,eAAO,MAAM,WAAW,EAAE,MAqIzB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sendReaction.d.ts","sourceRoot":"","sources":["../../src/actions/sendReaction.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,MAAM,EAOP,MAAM,eAAe,CAAC;AAwBvB,eAAO,MAAM,YAAY,EAAE,MA6H1B,CAAC"}
|
package/dist/index.d.ts
DELETED
|
@@ -1,22 +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 { MatrixService } from "./service.js";
|
|
8
|
-
export * from "./types.js";
|
|
9
|
-
import { joinRoom } from "./actions/joinRoom.js";
|
|
10
|
-
import { listRooms } from "./actions/listRooms.js";
|
|
11
|
-
import { sendMessage } from "./actions/sendMessage.js";
|
|
12
|
-
import { sendReaction } from "./actions/sendReaction.js";
|
|
13
|
-
export { sendMessage, sendReaction, listRooms, joinRoom };
|
|
14
|
-
import { roomStateProvider } from "./providers/roomState.js";
|
|
15
|
-
import { userContextProvider } from "./providers/userContext.js";
|
|
16
|
-
export { roomStateProvider, userContextProvider };
|
|
17
|
-
/**
|
|
18
|
-
* Matrix plugin definition.
|
|
19
|
-
*/
|
|
20
|
-
declare const matrixPlugin: Plugin;
|
|
21
|
-
export default matrixPlugin;
|
|
22
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -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;AAI3D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;AAG1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,CAAC;AAKlD;;GAEG;AACH,QAAA,MAAM,YAAY,EAAE,MA8DnB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|