@openclaw/matrix 2026.3.12 → 2026.5.9-beta.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-config-D2W-V1eQ.js +96 -0
- package/dist/account-selection-BWwIruri.js +158 -0
- package/dist/accounts-Bm90Rzvp.js +130 -0
- package/dist/active-client-uhlxdhEy.js +20 -0
- package/dist/allowlist-sTzpCn5d.js +68 -0
- package/dist/api.js +12 -0
- package/dist/approval-handler.runtime-DWTQfd4m.js +370 -0
- package/dist/approval-ids-DoC2z7tR.js +7 -0
- package/dist/approval-reaction-auth-DbcA1gGd.js +27 -0
- package/dist/approval-reactions-o2_tuH8D.js +162 -0
- package/dist/async-lock-uQfhfQIY.js +19 -0
- package/dist/auth-presence.js +26 -0
- package/dist/backup-health-Cabu_WQC.js +60 -0
- package/dist/channel-DJNir3Rb.js +1116 -0
- package/dist/channel-plugin-api.js +2 -0
- package/dist/channel.runtime-BQu0hTih.js +246 -0
- package/dist/cli-BmfTmg7x.js +1340 -0
- package/dist/cli-metadata-B-PCEzrA.js +22 -0
- package/dist/cli-metadata.js +2 -0
- package/dist/client-DkcXnm0X.js +25 -0
- package/dist/client-_hckQNGW.js +31 -0
- package/dist/client-bootstrap-Rb8oHvhH.js +114 -0
- package/dist/config--5-S2Akv.js +452 -0
- package/dist/config-paths-nsVaysCu.js +19 -0
- package/dist/config-schema-nPLpEgHl.js +200 -0
- package/dist/config-secret-input.runtime-DiKFehsE.js +2 -0
- package/dist/config-update-wZX-HLMn.js +143 -0
- package/dist/contract-api.js +9 -0
- package/dist/create-client-DCnqDaqd.js +64 -0
- package/dist/credentials-DV6fWXhC.js +56 -0
- package/dist/credentials-read-cmHgousK.js +112 -0
- package/dist/credentials-write.runtime-zniTq-Gr.js +17 -0
- package/dist/crypto-node.runtime-pihzdpY7.js +12 -0
- package/dist/crypto-runtime-ZI0zAtn3.js +1214 -0
- package/dist/deps-C6WqKY7m.js +235 -0
- package/dist/device-health-UVYpbA_W.js +16 -0
- package/dist/direct-management-DMMMgtTB.js +249 -0
- package/dist/direct-room-XkutHjES.js +76 -0
- package/dist/directory-live-DmOtMhyr.js +150 -0
- package/dist/doctor-C4__7c-U.js +153 -0
- package/dist/doctor-contract-D4-64QuJ.js +246 -0
- package/dist/doctor-contract-api.js +2 -0
- package/dist/draft-stream-BE2QevQQ.js +144 -0
- package/dist/encryption-guidance-BPi3A_m3.js +15 -0
- package/dist/env-auth-BJqGI8M6.js +63 -0
- package/dist/env-vars-C7uQCTKn.js +63 -0
- package/dist/errors-CTcpEDq-.js +17 -0
- package/dist/exec-approval-resolver-Bza9Dhlm.js +15 -0
- package/dist/exec-approvals-Crnh543m.js +196 -0
- package/dist/helper-api.js +4 -0
- package/dist/http-client-C7AeVJay.js +319 -0
- package/dist/index.js +46 -0
- package/dist/legacy-crypto-inspector-poDWldgy.js +41 -0
- package/dist/legacy-crypto-restore-Biw-w2ng.js +85 -0
- package/dist/logger-CnZRVrux.js +78 -0
- package/dist/logging-DZHSPP5N.js +99 -0
- package/dist/matrix-migration.runtime-WY6ffcrf.js +525 -0
- package/dist/media-text-DU6nWZuj.js +146 -0
- package/dist/messages-BpihMh82.js +140 -0
- package/dist/migration-snapshot-backup-DaCHTp8C.js +69 -0
- package/dist/migration-snapshot.runtime-CKHE3xF9.js +2 -0
- package/dist/monitor-C_81r_Ck.js +4125 -0
- package/dist/plugin-entry.handlers.runtime.js +51 -0
- package/dist/probe.runtime-BvAzYAIe.js +3 -0
- package/dist/profile-BlHu0wDX.js +111 -0
- package/dist/profile-update-DjeBNgIV.js +69 -0
- package/dist/reaction-common-ejrL19w-.js +71 -0
- package/dist/reaction-events-CiARZfjk.js +121 -0
- package/dist/record-shared-CHWJCTWf.js +2 -0
- package/dist/recovery-key-store-BTJ6jz5v.js +294 -0
- package/dist/resolve-targets-YtJnw1Tb.js +140 -0
- package/dist/resolver.runtime-D9piiGEl.js +5 -0
- package/dist/rolldown-runtime-DUslC3ob.js +14 -0
- package/dist/route-D6rg-iXN.js +161 -0
- package/dist/runtime-C6X4h_SJ.js +6 -0
- package/dist/runtime-Dog86njy.js +8 -0
- package/dist/runtime-api-BXWBFIqm.js +25 -0
- package/dist/runtime-api.js +25 -0
- package/dist/runtime-heavy-api.js +3 -0
- package/dist/runtime-setter-api.js +2 -0
- package/dist/sdk-B2vZA27-.js +1416 -0
- package/dist/secret-contract-DcrJWCQI.js +120 -0
- package/dist/secret-contract-api.js +2 -0
- package/dist/send-Bo0DU1ca.js +1200 -0
- package/dist/session-store-metadata-DI5SCofx.js +77 -0
- package/dist/setup-bootstrap-ImenBsMt.js +62 -0
- package/dist/setup-core-CfZy05oW.js +116 -0
- package/dist/setup-dm-policy-2-r1FrQh.js +194 -0
- package/dist/setup-entry.js +19 -0
- package/dist/setup-plugin-api.js +44 -0
- package/dist/setup-surface-CqT_o61M.js +540 -0
- package/dist/shared-CpMoYKm1.js +195 -0
- package/dist/startup-abort-56edvmbM.js +32 -0
- package/dist/startup-verification-Demyp0bP.js +132 -0
- package/dist/storage-paths-BJLdnCjV.js +52 -0
- package/dist/storage-tC3ujLiW.js +281 -0
- package/dist/subagent-hooks-DQbyqq9V.js +149 -0
- package/dist/subagent-hooks-api.js +23 -0
- package/dist/sync-state-C_beeevA.js +12 -0
- package/dist/target-ids-80nQ2gql.js +77 -0
- package/dist/test-api.js +4 -0
- package/dist/thread-binding-api-Cq_E-E1K.js +17 -0
- package/dist/thread-binding-api.js +2 -0
- package/dist/thread-bindings-B9mesxXk.js +352 -0
- package/dist/thread-bindings-runtime.js +2 -0
- package/dist/thread-bindings-shared-DK-d-oYX.js +97 -0
- package/dist/timeout-abort-signal-CtaIaP1v.js +2 -0
- package/dist/tool-actions.runtime-BIH49vRr.js +532 -0
- package/dist/url-validation-DiK9j7jz.js +36 -0
- package/dist/verification-CZ2rDeHL.js +345 -0
- package/openclaw.plugin.json +788 -1
- package/package.json +82 -16
- package/CHANGELOG.md +0 -98
- package/index.ts +0 -22
- package/src/actions.ts +0 -195
- package/src/channel.directory.test.ts +0 -154
- package/src/channel.ts +0 -461
- package/src/config-schema.test.ts +0 -26
- package/src/config-schema.ts +0 -62
- package/src/directory-live.test.ts +0 -85
- package/src/directory-live.ts +0 -209
- package/src/group-mentions.ts +0 -52
- package/src/matrix/accounts.test.ts +0 -131
- package/src/matrix/accounts.ts +0 -114
- package/src/matrix/actions/client.ts +0 -47
- package/src/matrix/actions/limits.test.ts +0 -15
- package/src/matrix/actions/limits.ts +0 -6
- package/src/matrix/actions/messages.ts +0 -126
- package/src/matrix/actions/pins.test.ts +0 -74
- package/src/matrix/actions/pins.ts +0 -84
- package/src/matrix/actions/reactions.test.ts +0 -109
- package/src/matrix/actions/reactions.ts +0 -102
- package/src/matrix/actions/room.ts +0 -85
- package/src/matrix/actions/summary.ts +0 -75
- package/src/matrix/actions/types.ts +0 -85
- package/src/matrix/actions.ts +0 -15
- package/src/matrix/active-client.ts +0 -32
- package/src/matrix/client/config.ts +0 -245
- package/src/matrix/client/create-client.ts +0 -125
- package/src/matrix/client/logging.ts +0 -46
- package/src/matrix/client/runtime.ts +0 -4
- package/src/matrix/client/shared.test.ts +0 -85
- package/src/matrix/client/shared.ts +0 -210
- package/src/matrix/client/startup.test.ts +0 -49
- package/src/matrix/client/startup.ts +0 -29
- package/src/matrix/client/storage.ts +0 -131
- package/src/matrix/client/types.ts +0 -34
- package/src/matrix/client-bootstrap.ts +0 -47
- package/src/matrix/client.test.ts +0 -56
- package/src/matrix/client.ts +0 -14
- package/src/matrix/credentials.ts +0 -125
- package/src/matrix/deps.test.ts +0 -74
- package/src/matrix/deps.ts +0 -126
- package/src/matrix/format.test.ts +0 -33
- package/src/matrix/format.ts +0 -22
- package/src/matrix/index.ts +0 -11
- package/src/matrix/monitor/access-policy.ts +0 -126
- package/src/matrix/monitor/allowlist.test.ts +0 -45
- package/src/matrix/monitor/allowlist.ts +0 -100
- package/src/matrix/monitor/auto-join.ts +0 -72
- package/src/matrix/monitor/direct.test.ts +0 -400
- package/src/matrix/monitor/direct.ts +0 -152
- package/src/matrix/monitor/events.test.ts +0 -172
- package/src/matrix/monitor/events.ts +0 -168
- package/src/matrix/monitor/handler.body-for-agent.test.ts +0 -196
- package/src/matrix/monitor/handler.ts +0 -767
- package/src/matrix/monitor/inbound-body.test.ts +0 -73
- package/src/matrix/monitor/inbound-body.ts +0 -28
- package/src/matrix/monitor/index.test.ts +0 -18
- package/src/matrix/monitor/index.ts +0 -414
- package/src/matrix/monitor/location.ts +0 -100
- package/src/matrix/monitor/media.test.ts +0 -86
- package/src/matrix/monitor/media.ts +0 -118
- package/src/matrix/monitor/mentions.test.ts +0 -154
- package/src/matrix/monitor/mentions.ts +0 -62
- package/src/matrix/monitor/replies.test.ts +0 -184
- package/src/matrix/monitor/replies.ts +0 -124
- package/src/matrix/monitor/room-info.ts +0 -55
- package/src/matrix/monitor/rooms.test.ts +0 -124
- package/src/matrix/monitor/rooms.ts +0 -47
- package/src/matrix/monitor/threads.ts +0 -68
- package/src/matrix/monitor/types.ts +0 -39
- package/src/matrix/poll-types.test.ts +0 -21
- package/src/matrix/poll-types.ts +0 -167
- package/src/matrix/probe.ts +0 -69
- package/src/matrix/sdk-runtime.ts +0 -18
- package/src/matrix/send/client.ts +0 -99
- package/src/matrix/send/formatting.ts +0 -93
- package/src/matrix/send/media.ts +0 -230
- package/src/matrix/send/targets.test.ts +0 -98
- package/src/matrix/send/targets.ts +0 -150
- package/src/matrix/send/types.ts +0 -110
- package/src/matrix/send-queue.test.ts +0 -154
- package/src/matrix/send-queue.ts +0 -28
- package/src/matrix/send.test.ts +0 -326
- package/src/matrix/send.ts +0 -267
- package/src/onboarding.ts +0 -462
- package/src/outbound.test.ts +0 -159
- package/src/outbound.ts +0 -58
- package/src/resolve-targets.test.ts +0 -67
- package/src/resolve-targets.ts +0 -125
- package/src/runtime.ts +0 -6
- package/src/secret-input.ts +0 -13
- package/src/tool-actions.ts +0 -164
- package/src/types.ts +0 -118
package/package.json
CHANGED
|
@@ -1,20 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/matrix",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.5.9-beta.1",
|
|
4
4
|
"description": "OpenClaw Matrix channel plugin",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/openclaw/openclaw"
|
|
8
|
+
},
|
|
5
9
|
"type": "module",
|
|
6
10
|
"dependencies": {
|
|
7
|
-
"@
|
|
8
|
-
"@matrix-org/matrix-sdk-crypto-
|
|
9
|
-
"
|
|
11
|
+
"@matrix-org/matrix-sdk-crypto-nodejs": "^0.5.1",
|
|
12
|
+
"@matrix-org/matrix-sdk-crypto-wasm": "18.2.0",
|
|
13
|
+
"fake-indexeddb": "^6.2.5",
|
|
10
14
|
"markdown-it": "14.1.1",
|
|
15
|
+
"matrix-js-sdk": "41.5.0-rc.0",
|
|
11
16
|
"music-metadata": "^11.12.3",
|
|
12
|
-
"
|
|
17
|
+
"typebox": "1.1.38"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@openclaw/plugin-sdk": "workspace:*",
|
|
21
|
+
"openclaw": "workspace:*"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"openclaw": ">=2026.5.9-beta.1"
|
|
25
|
+
},
|
|
26
|
+
"peerDependenciesMeta": {
|
|
27
|
+
"openclaw": {
|
|
28
|
+
"optional": true
|
|
29
|
+
}
|
|
13
30
|
},
|
|
14
31
|
"openclaw": {
|
|
15
32
|
"extensions": [
|
|
16
33
|
"./index.ts"
|
|
17
34
|
],
|
|
35
|
+
"setupEntry": "./setup-entry.ts",
|
|
36
|
+
"setupFeatures": {
|
|
37
|
+
"configPromotion": true
|
|
38
|
+
},
|
|
18
39
|
"channel": {
|
|
19
40
|
"id": "matrix",
|
|
20
41
|
"label": "Matrix",
|
|
@@ -23,19 +44,64 @@
|
|
|
23
44
|
"docsLabel": "matrix",
|
|
24
45
|
"blurb": "open protocol; install the plugin to enable.",
|
|
25
46
|
"order": 70,
|
|
26
|
-
"quickstartAllowFrom": true
|
|
47
|
+
"quickstartAllowFrom": true,
|
|
48
|
+
"doctorCapabilities": {
|
|
49
|
+
"dmAllowFromMode": "nestedOnly",
|
|
50
|
+
"groupModel": "sender",
|
|
51
|
+
"groupAllowFromFallbackToAllowFrom": false,
|
|
52
|
+
"warnOnEmptyGroupSenderAllowlist": true
|
|
53
|
+
},
|
|
54
|
+
"cliAddOptions": [
|
|
55
|
+
{
|
|
56
|
+
"flags": "--homeserver <url>",
|
|
57
|
+
"description": "Matrix homeserver URL"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"flags": "--user-id <id>",
|
|
61
|
+
"description": "Matrix user ID"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"flags": "--access-token <token>",
|
|
65
|
+
"description": "Matrix access token"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"flags": "--device-name <name>",
|
|
69
|
+
"description": "Matrix device name"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"flags": "--initial-sync-limit <n>",
|
|
73
|
+
"description": "Matrix initial sync limit"
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
"persistedAuthState": {
|
|
77
|
+
"specifier": "./auth-presence",
|
|
78
|
+
"exportName": "hasAnyMatrixAuth"
|
|
79
|
+
}
|
|
27
80
|
},
|
|
28
81
|
"install": {
|
|
82
|
+
"clawhubSpec": "clawhub:@openclaw/matrix",
|
|
29
83
|
"npmSpec": "@openclaw/matrix",
|
|
30
|
-
"
|
|
31
|
-
"
|
|
84
|
+
"defaultChoice": "clawhub",
|
|
85
|
+
"minHostVersion": ">=2026.4.10",
|
|
86
|
+
"allowInvalidConfigRecovery": true
|
|
32
87
|
},
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
88
|
+
"compat": {
|
|
89
|
+
"pluginApi": ">=2026.5.9-beta.1"
|
|
90
|
+
},
|
|
91
|
+
"build": {
|
|
92
|
+
"openclawVersion": "2026.5.9-beta.1"
|
|
93
|
+
},
|
|
94
|
+
"release": {
|
|
95
|
+
"publishToClawHub": true,
|
|
96
|
+
"publishToNpm": true
|
|
97
|
+
},
|
|
98
|
+
"runtimeExtensions": [
|
|
99
|
+
"./dist/index.js"
|
|
100
|
+
],
|
|
101
|
+
"runtimeSetupEntry": "./dist/setup-entry.js"
|
|
102
|
+
},
|
|
103
|
+
"files": [
|
|
104
|
+
"dist/**",
|
|
105
|
+
"openclaw.plugin.json"
|
|
106
|
+
]
|
|
41
107
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
## 2026.3.12
|
|
4
|
-
|
|
5
|
-
### Changes
|
|
6
|
-
|
|
7
|
-
- Version alignment with core OpenClaw release numbers.
|
|
8
|
-
|
|
9
|
-
## 2026.3.11
|
|
10
|
-
|
|
11
|
-
### Changes
|
|
12
|
-
|
|
13
|
-
- Version alignment with core OpenClaw release numbers.
|
|
14
|
-
|
|
15
|
-
## 2026.3.10
|
|
16
|
-
|
|
17
|
-
### Changes
|
|
18
|
-
|
|
19
|
-
- Version alignment with core OpenClaw release numbers.
|
|
20
|
-
|
|
21
|
-
## 2026.3.9
|
|
22
|
-
|
|
23
|
-
### Changes
|
|
24
|
-
|
|
25
|
-
- Version alignment with core OpenClaw release numbers.
|
|
26
|
-
|
|
27
|
-
## 2026.3.8-beta.1
|
|
28
|
-
|
|
29
|
-
### Changes
|
|
30
|
-
|
|
31
|
-
- Version alignment with core OpenClaw release numbers.
|
|
32
|
-
|
|
33
|
-
## 2026.3.8
|
|
34
|
-
|
|
35
|
-
### Changes
|
|
36
|
-
|
|
37
|
-
- Version alignment with core OpenClaw release numbers.
|
|
38
|
-
|
|
39
|
-
## 2026.3.7
|
|
40
|
-
|
|
41
|
-
### Changes
|
|
42
|
-
|
|
43
|
-
- Version alignment with core OpenClaw release numbers.
|
|
44
|
-
|
|
45
|
-
## 2026.3.3
|
|
46
|
-
|
|
47
|
-
### Changes
|
|
48
|
-
|
|
49
|
-
- Version alignment with core OpenClaw release numbers.
|
|
50
|
-
|
|
51
|
-
## 2026.3.2
|
|
52
|
-
|
|
53
|
-
### Changes
|
|
54
|
-
|
|
55
|
-
- Version alignment with core OpenClaw release numbers.
|
|
56
|
-
|
|
57
|
-
## 2026.3.1
|
|
58
|
-
|
|
59
|
-
### Changes
|
|
60
|
-
|
|
61
|
-
- Version alignment with core OpenClaw release numbers.
|
|
62
|
-
|
|
63
|
-
## 2026.2.26
|
|
64
|
-
|
|
65
|
-
### Changes
|
|
66
|
-
|
|
67
|
-
- Version alignment with core OpenClaw release numbers.
|
|
68
|
-
|
|
69
|
-
## 2026.2.25
|
|
70
|
-
|
|
71
|
-
### Changes
|
|
72
|
-
|
|
73
|
-
- Version alignment with core OpenClaw release numbers.
|
|
74
|
-
|
|
75
|
-
## 2026.2.24
|
|
76
|
-
|
|
77
|
-
### Changes
|
|
78
|
-
|
|
79
|
-
- Version alignment with core OpenClaw release numbers.
|
|
80
|
-
|
|
81
|
-
## 2026.2.22
|
|
82
|
-
|
|
83
|
-
### Changes
|
|
84
|
-
|
|
85
|
-
- Version alignment with core OpenClaw release numbers.
|
|
86
|
-
|
|
87
|
-
## 2026.1.14
|
|
88
|
-
|
|
89
|
-
### Features
|
|
90
|
-
|
|
91
|
-
- Matrix channel plugin with homeserver + user ID auth (access token or password login with device name).
|
|
92
|
-
- Direct messages with pairing/allowlist/open/disabled policies and allowFrom support.
|
|
93
|
-
- Group/room controls: allowlist policy, per-room config, mention gating, auto-reply, per-room skills/system prompts.
|
|
94
|
-
- Threads: replyToMode controls and thread replies (off/inbound/always).
|
|
95
|
-
- Messaging: text chunking, media uploads with size caps, reactions, polls, typing, and message edits/deletes.
|
|
96
|
-
- Actions: read messages, list/remove reactions, pin/unpin/list pins, member info, room info.
|
|
97
|
-
- Auto-join invites with allowlist support.
|
|
98
|
-
- Status + probe reporting for health checks.
|
package/index.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { OpenClawPluginApi } from "openclaw/plugin-sdk/matrix";
|
|
2
|
-
import { emptyPluginConfigSchema } from "openclaw/plugin-sdk/matrix";
|
|
3
|
-
import { matrixPlugin } from "./src/channel.js";
|
|
4
|
-
import { ensureMatrixCryptoRuntime } from "./src/matrix/deps.js";
|
|
5
|
-
import { setMatrixRuntime } from "./src/runtime.js";
|
|
6
|
-
|
|
7
|
-
const plugin = {
|
|
8
|
-
id: "matrix",
|
|
9
|
-
name: "Matrix",
|
|
10
|
-
description: "Matrix channel plugin (matrix-js-sdk)",
|
|
11
|
-
configSchema: emptyPluginConfigSchema(),
|
|
12
|
-
register(api: OpenClawPluginApi) {
|
|
13
|
-
setMatrixRuntime(api.runtime);
|
|
14
|
-
void ensureMatrixCryptoRuntime({ log: api.logger.info }).catch((err) => {
|
|
15
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
16
|
-
api.logger.warn?.(`matrix: crypto runtime bootstrap failed: ${message}`);
|
|
17
|
-
});
|
|
18
|
-
api.registerChannel({ plugin: matrixPlugin });
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default plugin;
|
package/src/actions.ts
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createActionGate,
|
|
3
|
-
readNumberParam,
|
|
4
|
-
readStringParam,
|
|
5
|
-
type ChannelMessageActionAdapter,
|
|
6
|
-
type ChannelMessageActionContext,
|
|
7
|
-
type ChannelMessageActionName,
|
|
8
|
-
type ChannelToolSend,
|
|
9
|
-
} from "openclaw/plugin-sdk/matrix";
|
|
10
|
-
import { resolveMatrixAccount } from "./matrix/accounts.js";
|
|
11
|
-
import { handleMatrixAction } from "./tool-actions.js";
|
|
12
|
-
import type { CoreConfig } from "./types.js";
|
|
13
|
-
|
|
14
|
-
export const matrixMessageActions: ChannelMessageActionAdapter = {
|
|
15
|
-
listActions: ({ cfg }) => {
|
|
16
|
-
const account = resolveMatrixAccount({ cfg: cfg as CoreConfig });
|
|
17
|
-
if (!account.enabled || !account.configured) {
|
|
18
|
-
return [];
|
|
19
|
-
}
|
|
20
|
-
const gate = createActionGate((cfg as CoreConfig).channels?.matrix?.actions);
|
|
21
|
-
const actions = new Set<ChannelMessageActionName>(["send", "poll"]);
|
|
22
|
-
if (gate("reactions")) {
|
|
23
|
-
actions.add("react");
|
|
24
|
-
actions.add("reactions");
|
|
25
|
-
}
|
|
26
|
-
if (gate("messages")) {
|
|
27
|
-
actions.add("read");
|
|
28
|
-
actions.add("edit");
|
|
29
|
-
actions.add("delete");
|
|
30
|
-
}
|
|
31
|
-
if (gate("pins")) {
|
|
32
|
-
actions.add("pin");
|
|
33
|
-
actions.add("unpin");
|
|
34
|
-
actions.add("list-pins");
|
|
35
|
-
}
|
|
36
|
-
if (gate("memberInfo")) {
|
|
37
|
-
actions.add("member-info");
|
|
38
|
-
}
|
|
39
|
-
if (gate("channelInfo")) {
|
|
40
|
-
actions.add("channel-info");
|
|
41
|
-
}
|
|
42
|
-
return Array.from(actions);
|
|
43
|
-
},
|
|
44
|
-
supportsAction: ({ action }) => action !== "poll",
|
|
45
|
-
extractToolSend: ({ args }): ChannelToolSend | null => {
|
|
46
|
-
const action = typeof args.action === "string" ? args.action.trim() : "";
|
|
47
|
-
if (action !== "sendMessage") {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
const to = typeof args.to === "string" ? args.to : undefined;
|
|
51
|
-
if (!to) {
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
return { to };
|
|
55
|
-
},
|
|
56
|
-
handleAction: async (ctx: ChannelMessageActionContext) => {
|
|
57
|
-
const { action, params, cfg } = ctx;
|
|
58
|
-
const resolveRoomId = () =>
|
|
59
|
-
readStringParam(params, "roomId") ??
|
|
60
|
-
readStringParam(params, "channelId") ??
|
|
61
|
-
readStringParam(params, "to", { required: true });
|
|
62
|
-
|
|
63
|
-
if (action === "send") {
|
|
64
|
-
const to = readStringParam(params, "to", { required: true });
|
|
65
|
-
const content = readStringParam(params, "message", {
|
|
66
|
-
required: true,
|
|
67
|
-
allowEmpty: true,
|
|
68
|
-
});
|
|
69
|
-
const mediaUrl = readStringParam(params, "media", { trim: false });
|
|
70
|
-
const replyTo = readStringParam(params, "replyTo");
|
|
71
|
-
const threadId = readStringParam(params, "threadId");
|
|
72
|
-
return await handleMatrixAction(
|
|
73
|
-
{
|
|
74
|
-
action: "sendMessage",
|
|
75
|
-
to,
|
|
76
|
-
content,
|
|
77
|
-
mediaUrl: mediaUrl ?? undefined,
|
|
78
|
-
replyToId: replyTo ?? undefined,
|
|
79
|
-
threadId: threadId ?? undefined,
|
|
80
|
-
},
|
|
81
|
-
cfg as CoreConfig,
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (action === "react") {
|
|
86
|
-
const messageId = readStringParam(params, "messageId", { required: true });
|
|
87
|
-
const emoji = readStringParam(params, "emoji", { allowEmpty: true });
|
|
88
|
-
const remove = typeof params.remove === "boolean" ? params.remove : undefined;
|
|
89
|
-
return await handleMatrixAction(
|
|
90
|
-
{
|
|
91
|
-
action: "react",
|
|
92
|
-
roomId: resolveRoomId(),
|
|
93
|
-
messageId,
|
|
94
|
-
emoji,
|
|
95
|
-
remove,
|
|
96
|
-
},
|
|
97
|
-
cfg as CoreConfig,
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (action === "reactions") {
|
|
102
|
-
const messageId = readStringParam(params, "messageId", { required: true });
|
|
103
|
-
const limit = readNumberParam(params, "limit", { integer: true });
|
|
104
|
-
return await handleMatrixAction(
|
|
105
|
-
{
|
|
106
|
-
action: "reactions",
|
|
107
|
-
roomId: resolveRoomId(),
|
|
108
|
-
messageId,
|
|
109
|
-
limit,
|
|
110
|
-
},
|
|
111
|
-
cfg as CoreConfig,
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (action === "read") {
|
|
116
|
-
const limit = readNumberParam(params, "limit", { integer: true });
|
|
117
|
-
return await handleMatrixAction(
|
|
118
|
-
{
|
|
119
|
-
action: "readMessages",
|
|
120
|
-
roomId: resolveRoomId(),
|
|
121
|
-
limit,
|
|
122
|
-
before: readStringParam(params, "before"),
|
|
123
|
-
after: readStringParam(params, "after"),
|
|
124
|
-
},
|
|
125
|
-
cfg as CoreConfig,
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (action === "edit") {
|
|
130
|
-
const messageId = readStringParam(params, "messageId", { required: true });
|
|
131
|
-
const content = readStringParam(params, "message", { required: true });
|
|
132
|
-
return await handleMatrixAction(
|
|
133
|
-
{
|
|
134
|
-
action: "editMessage",
|
|
135
|
-
roomId: resolveRoomId(),
|
|
136
|
-
messageId,
|
|
137
|
-
content,
|
|
138
|
-
},
|
|
139
|
-
cfg as CoreConfig,
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (action === "delete") {
|
|
144
|
-
const messageId = readStringParam(params, "messageId", { required: true });
|
|
145
|
-
return await handleMatrixAction(
|
|
146
|
-
{
|
|
147
|
-
action: "deleteMessage",
|
|
148
|
-
roomId: resolveRoomId(),
|
|
149
|
-
messageId,
|
|
150
|
-
},
|
|
151
|
-
cfg as CoreConfig,
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (action === "pin" || action === "unpin" || action === "list-pins") {
|
|
156
|
-
const messageId =
|
|
157
|
-
action === "list-pins"
|
|
158
|
-
? undefined
|
|
159
|
-
: readStringParam(params, "messageId", { required: true });
|
|
160
|
-
return await handleMatrixAction(
|
|
161
|
-
{
|
|
162
|
-
action:
|
|
163
|
-
action === "pin" ? "pinMessage" : action === "unpin" ? "unpinMessage" : "listPins",
|
|
164
|
-
roomId: resolveRoomId(),
|
|
165
|
-
messageId,
|
|
166
|
-
},
|
|
167
|
-
cfg as CoreConfig,
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (action === "member-info") {
|
|
172
|
-
const userId = readStringParam(params, "userId", { required: true });
|
|
173
|
-
return await handleMatrixAction(
|
|
174
|
-
{
|
|
175
|
-
action: "memberInfo",
|
|
176
|
-
userId,
|
|
177
|
-
roomId: readStringParam(params, "roomId") ?? readStringParam(params, "channelId"),
|
|
178
|
-
},
|
|
179
|
-
cfg as CoreConfig,
|
|
180
|
-
);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if (action === "channel-info") {
|
|
184
|
-
return await handleMatrixAction(
|
|
185
|
-
{
|
|
186
|
-
action: "channelInfo",
|
|
187
|
-
roomId: resolveRoomId(),
|
|
188
|
-
},
|
|
189
|
-
cfg as CoreConfig,
|
|
190
|
-
);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
throw new Error(`Action ${action} is not supported for provider matrix.`);
|
|
194
|
-
},
|
|
195
|
-
};
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import type { PluginRuntime, RuntimeEnv } from "openclaw/plugin-sdk/matrix";
|
|
2
|
-
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
|
-
import { matrixPlugin } from "./channel.js";
|
|
4
|
-
import { setMatrixRuntime } from "./runtime.js";
|
|
5
|
-
import type { CoreConfig } from "./types.js";
|
|
6
|
-
|
|
7
|
-
vi.mock("@vector-im/matrix-bot-sdk", () => ({
|
|
8
|
-
ConsoleLogger: class {
|
|
9
|
-
trace = vi.fn();
|
|
10
|
-
debug = vi.fn();
|
|
11
|
-
info = vi.fn();
|
|
12
|
-
warn = vi.fn();
|
|
13
|
-
error = vi.fn();
|
|
14
|
-
},
|
|
15
|
-
MatrixClient: class {},
|
|
16
|
-
LogService: {
|
|
17
|
-
setLogger: vi.fn(),
|
|
18
|
-
warn: vi.fn(),
|
|
19
|
-
info: vi.fn(),
|
|
20
|
-
debug: vi.fn(),
|
|
21
|
-
},
|
|
22
|
-
SimpleFsStorageProvider: class {},
|
|
23
|
-
RustSdkCryptoStorageProvider: class {},
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
|
-
describe("matrix directory", () => {
|
|
27
|
-
const runtimeEnv: RuntimeEnv = {
|
|
28
|
-
log: vi.fn(),
|
|
29
|
-
error: vi.fn(),
|
|
30
|
-
exit: vi.fn((code: number): never => {
|
|
31
|
-
throw new Error(`exit ${code}`);
|
|
32
|
-
}),
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
beforeEach(() => {
|
|
36
|
-
setMatrixRuntime({
|
|
37
|
-
state: {
|
|
38
|
-
resolveStateDir: (_env, homeDir) => (homeDir ?? (() => "/tmp"))(),
|
|
39
|
-
},
|
|
40
|
-
} as PluginRuntime);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("lists peers and groups from config", async () => {
|
|
44
|
-
const cfg = {
|
|
45
|
-
channels: {
|
|
46
|
-
matrix: {
|
|
47
|
-
dm: { allowFrom: ["matrix:@alice:example.org", "bob"] },
|
|
48
|
-
groupAllowFrom: ["@dana:example.org"],
|
|
49
|
-
groups: {
|
|
50
|
-
"!room1:example.org": { users: ["@carol:example.org"] },
|
|
51
|
-
"#alias:example.org": { users: [] },
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
} as unknown as CoreConfig;
|
|
56
|
-
|
|
57
|
-
expect(matrixPlugin.directory).toBeTruthy();
|
|
58
|
-
expect(matrixPlugin.directory?.listPeers).toBeTruthy();
|
|
59
|
-
expect(matrixPlugin.directory?.listGroups).toBeTruthy();
|
|
60
|
-
|
|
61
|
-
await expect(
|
|
62
|
-
matrixPlugin.directory!.listPeers!({
|
|
63
|
-
cfg,
|
|
64
|
-
accountId: undefined,
|
|
65
|
-
query: undefined,
|
|
66
|
-
limit: undefined,
|
|
67
|
-
runtime: runtimeEnv,
|
|
68
|
-
}),
|
|
69
|
-
).resolves.toEqual(
|
|
70
|
-
expect.arrayContaining([
|
|
71
|
-
{ kind: "user", id: "user:@alice:example.org" },
|
|
72
|
-
{ kind: "user", id: "bob", name: "incomplete id; expected @user:server" },
|
|
73
|
-
{ kind: "user", id: "user:@carol:example.org" },
|
|
74
|
-
{ kind: "user", id: "user:@dana:example.org" },
|
|
75
|
-
]),
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
await expect(
|
|
79
|
-
matrixPlugin.directory!.listGroups!({
|
|
80
|
-
cfg,
|
|
81
|
-
accountId: undefined,
|
|
82
|
-
query: undefined,
|
|
83
|
-
limit: undefined,
|
|
84
|
-
runtime: runtimeEnv,
|
|
85
|
-
}),
|
|
86
|
-
).resolves.toEqual(
|
|
87
|
-
expect.arrayContaining([
|
|
88
|
-
{ kind: "group", id: "room:!room1:example.org" },
|
|
89
|
-
{ kind: "group", id: "#alias:example.org" },
|
|
90
|
-
]),
|
|
91
|
-
);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it("resolves replyToMode from account config", () => {
|
|
95
|
-
const cfg = {
|
|
96
|
-
channels: {
|
|
97
|
-
matrix: {
|
|
98
|
-
replyToMode: "off",
|
|
99
|
-
accounts: {
|
|
100
|
-
Assistant: {
|
|
101
|
-
replyToMode: "all",
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
} as unknown as CoreConfig;
|
|
107
|
-
|
|
108
|
-
expect(matrixPlugin.threading?.resolveReplyToMode).toBeTruthy();
|
|
109
|
-
expect(
|
|
110
|
-
matrixPlugin.threading?.resolveReplyToMode?.({
|
|
111
|
-
cfg,
|
|
112
|
-
accountId: "assistant",
|
|
113
|
-
chatType: "direct",
|
|
114
|
-
}),
|
|
115
|
-
).toBe("all");
|
|
116
|
-
expect(
|
|
117
|
-
matrixPlugin.threading?.resolveReplyToMode?.({
|
|
118
|
-
cfg,
|
|
119
|
-
accountId: "default",
|
|
120
|
-
chatType: "direct",
|
|
121
|
-
}),
|
|
122
|
-
).toBe("off");
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it("resolves group mention policy from account config", () => {
|
|
126
|
-
const cfg = {
|
|
127
|
-
channels: {
|
|
128
|
-
matrix: {
|
|
129
|
-
groups: {
|
|
130
|
-
"!room:example.org": { requireMention: true },
|
|
131
|
-
},
|
|
132
|
-
accounts: {
|
|
133
|
-
Assistant: {
|
|
134
|
-
groups: {
|
|
135
|
-
"!room:example.org": { requireMention: false },
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
} as unknown as CoreConfig;
|
|
142
|
-
|
|
143
|
-
expect(matrixPlugin.groups!.resolveRequireMention!({ cfg, groupId: "!room:example.org" })).toBe(
|
|
144
|
-
true,
|
|
145
|
-
);
|
|
146
|
-
expect(
|
|
147
|
-
matrixPlugin.groups!.resolveRequireMention!({
|
|
148
|
-
cfg,
|
|
149
|
-
accountId: "assistant",
|
|
150
|
-
groupId: "!room:example.org",
|
|
151
|
-
}),
|
|
152
|
-
).toBe(false);
|
|
153
|
-
});
|
|
154
|
-
});
|