@openclaw/matrix 2026.3.8-beta.1 → 2026.3.10
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/CHANGELOG.md +12 -0
- package/package.json +1 -1
- package/src/channel.ts +28 -41
- package/src/config-schema.ts +11 -15
- package/src/matrix/monitor/allowlist.ts +9 -5
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/channel.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
buildAccountScopedDmSecurityPolicy,
|
|
3
2
|
buildOpenGroupPolicyWarning,
|
|
4
3
|
collectAllowlistProviderGroupPolicyWarnings,
|
|
5
4
|
createScopedAccountConfigAccessors,
|
|
5
|
+
createScopedChannelConfigBase,
|
|
6
|
+
createScopedDmSecurityResolver,
|
|
6
7
|
} from "openclaw/plugin-sdk/compat";
|
|
7
8
|
import {
|
|
8
9
|
applyAccountNameToChannelSection,
|
|
@@ -10,10 +11,8 @@ import {
|
|
|
10
11
|
buildProbeChannelStatusSummary,
|
|
11
12
|
collectStatusIssuesFromLastError,
|
|
12
13
|
DEFAULT_ACCOUNT_ID,
|
|
13
|
-
deleteAccountFromConfigSection,
|
|
14
14
|
normalizeAccountId,
|
|
15
15
|
PAIRING_APPROVED_MESSAGE,
|
|
16
|
-
setAccountEnabledInConfigSection,
|
|
17
16
|
type ChannelPlugin,
|
|
18
17
|
} from "openclaw/plugin-sdk/matrix";
|
|
19
18
|
import { matrixMessageActions } from "./actions.js";
|
|
@@ -106,6 +105,30 @@ const matrixConfigAccessors = createScopedAccountConfigAccessors({
|
|
|
106
105
|
formatAllowFrom: (allowFrom) => normalizeMatrixAllowList(allowFrom),
|
|
107
106
|
});
|
|
108
107
|
|
|
108
|
+
const matrixConfigBase = createScopedChannelConfigBase<ResolvedMatrixAccount, CoreConfig>({
|
|
109
|
+
sectionKey: "matrix",
|
|
110
|
+
listAccountIds: listMatrixAccountIds,
|
|
111
|
+
resolveAccount: (cfg, accountId) => resolveMatrixAccount({ cfg, accountId }),
|
|
112
|
+
defaultAccountId: resolveDefaultMatrixAccountId,
|
|
113
|
+
clearBaseFields: [
|
|
114
|
+
"name",
|
|
115
|
+
"homeserver",
|
|
116
|
+
"userId",
|
|
117
|
+
"accessToken",
|
|
118
|
+
"password",
|
|
119
|
+
"deviceName",
|
|
120
|
+
"initialSyncLimit",
|
|
121
|
+
],
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
const resolveMatrixDmPolicy = createScopedDmSecurityResolver<ResolvedMatrixAccount>({
|
|
125
|
+
channelKey: "matrix",
|
|
126
|
+
resolvePolicy: (account) => account.config.dm?.policy,
|
|
127
|
+
resolveAllowFrom: (account) => account.config.dm?.allowFrom,
|
|
128
|
+
allowFromPathSuffix: "dm.",
|
|
129
|
+
normalizeEntry: (raw) => normalizeMatrixUserId(raw),
|
|
130
|
+
});
|
|
131
|
+
|
|
109
132
|
export const matrixPlugin: ChannelPlugin<ResolvedMatrixAccount> = {
|
|
110
133
|
id: "matrix",
|
|
111
134
|
meta,
|
|
@@ -127,32 +150,7 @@ export const matrixPlugin: ChannelPlugin<ResolvedMatrixAccount> = {
|
|
|
127
150
|
reload: { configPrefixes: ["channels.matrix"] },
|
|
128
151
|
configSchema: buildChannelConfigSchema(MatrixConfigSchema),
|
|
129
152
|
config: {
|
|
130
|
-
|
|
131
|
-
resolveAccount: (cfg, accountId) => resolveMatrixAccount({ cfg: cfg as CoreConfig, accountId }),
|
|
132
|
-
defaultAccountId: (cfg) => resolveDefaultMatrixAccountId(cfg as CoreConfig),
|
|
133
|
-
setAccountEnabled: ({ cfg, accountId, enabled }) =>
|
|
134
|
-
setAccountEnabledInConfigSection({
|
|
135
|
-
cfg: cfg as CoreConfig,
|
|
136
|
-
sectionKey: "matrix",
|
|
137
|
-
accountId,
|
|
138
|
-
enabled,
|
|
139
|
-
allowTopLevel: true,
|
|
140
|
-
}),
|
|
141
|
-
deleteAccount: ({ cfg, accountId }) =>
|
|
142
|
-
deleteAccountFromConfigSection({
|
|
143
|
-
cfg: cfg as CoreConfig,
|
|
144
|
-
sectionKey: "matrix",
|
|
145
|
-
accountId,
|
|
146
|
-
clearBaseFields: [
|
|
147
|
-
"name",
|
|
148
|
-
"homeserver",
|
|
149
|
-
"userId",
|
|
150
|
-
"accessToken",
|
|
151
|
-
"password",
|
|
152
|
-
"deviceName",
|
|
153
|
-
"initialSyncLimit",
|
|
154
|
-
],
|
|
155
|
-
}),
|
|
153
|
+
...matrixConfigBase,
|
|
156
154
|
isConfigured: (account) => account.configured,
|
|
157
155
|
describeAccount: (account) => ({
|
|
158
156
|
accountId: account.accountId,
|
|
@@ -164,18 +162,7 @@ export const matrixPlugin: ChannelPlugin<ResolvedMatrixAccount> = {
|
|
|
164
162
|
...matrixConfigAccessors,
|
|
165
163
|
},
|
|
166
164
|
security: {
|
|
167
|
-
resolveDmPolicy:
|
|
168
|
-
return buildAccountScopedDmSecurityPolicy({
|
|
169
|
-
cfg: cfg as CoreConfig,
|
|
170
|
-
channelKey: "matrix",
|
|
171
|
-
accountId,
|
|
172
|
-
fallbackAccountId: account.accountId ?? DEFAULT_ACCOUNT_ID,
|
|
173
|
-
policy: account.config.dm?.policy,
|
|
174
|
-
allowFrom: account.config.dm?.allowFrom ?? [],
|
|
175
|
-
allowFromPathSuffix: "dm.",
|
|
176
|
-
normalizeEntry: (raw) => normalizeMatrixUserId(raw),
|
|
177
|
-
});
|
|
178
|
-
},
|
|
165
|
+
resolveDmPolicy: resolveMatrixDmPolicy,
|
|
179
166
|
collectWarnings: ({ account, cfg }) => {
|
|
180
167
|
return collectAllowlistProviderGroupPolicyWarnings({
|
|
181
168
|
cfg: cfg as CoreConfig,
|
package/src/config-schema.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AllowFromListSchema,
|
|
3
|
+
buildNestedDmConfigSchema,
|
|
4
|
+
DmPolicySchema,
|
|
5
|
+
GroupPolicySchema,
|
|
6
|
+
} from "openclaw/plugin-sdk/compat";
|
|
1
7
|
import { MarkdownConfigSchema, ToolPolicySchema } from "openclaw/plugin-sdk/matrix";
|
|
2
8
|
import { z } from "zod";
|
|
3
9
|
import { buildSecretInputSchema } from "./secret-input.js";
|
|
4
10
|
|
|
5
|
-
const allowFromEntry = z.union([z.string(), z.number()]);
|
|
6
|
-
|
|
7
11
|
const matrixActionSchema = z
|
|
8
12
|
.object({
|
|
9
13
|
reactions: z.boolean().optional(),
|
|
@@ -14,14 +18,6 @@ const matrixActionSchema = z
|
|
|
14
18
|
})
|
|
15
19
|
.optional();
|
|
16
20
|
|
|
17
|
-
const matrixDmSchema = z
|
|
18
|
-
.object({
|
|
19
|
-
enabled: z.boolean().optional(),
|
|
20
|
-
policy: z.enum(["pairing", "allowlist", "open", "disabled"]).optional(),
|
|
21
|
-
allowFrom: z.array(allowFromEntry).optional(),
|
|
22
|
-
})
|
|
23
|
-
.optional();
|
|
24
|
-
|
|
25
21
|
const matrixRoomSchema = z
|
|
26
22
|
.object({
|
|
27
23
|
enabled: z.boolean().optional(),
|
|
@@ -29,7 +25,7 @@ const matrixRoomSchema = z
|
|
|
29
25
|
requireMention: z.boolean().optional(),
|
|
30
26
|
tools: ToolPolicySchema,
|
|
31
27
|
autoReply: z.boolean().optional(),
|
|
32
|
-
users:
|
|
28
|
+
users: AllowFromListSchema,
|
|
33
29
|
skills: z.array(z.string()).optional(),
|
|
34
30
|
systemPrompt: z.string().optional(),
|
|
35
31
|
})
|
|
@@ -49,7 +45,7 @@ export const MatrixConfigSchema = z.object({
|
|
|
49
45
|
initialSyncLimit: z.number().optional(),
|
|
50
46
|
encryption: z.boolean().optional(),
|
|
51
47
|
allowlistOnly: z.boolean().optional(),
|
|
52
|
-
groupPolicy:
|
|
48
|
+
groupPolicy: GroupPolicySchema.optional(),
|
|
53
49
|
replyToMode: z.enum(["off", "first", "all"]).optional(),
|
|
54
50
|
threadReplies: z.enum(["off", "inbound", "always"]).optional(),
|
|
55
51
|
textChunkLimit: z.number().optional(),
|
|
@@ -57,9 +53,9 @@ export const MatrixConfigSchema = z.object({
|
|
|
57
53
|
responsePrefix: z.string().optional(),
|
|
58
54
|
mediaMaxMb: z.number().optional(),
|
|
59
55
|
autoJoin: z.enum(["always", "allowlist", "off"]).optional(),
|
|
60
|
-
autoJoinAllowlist:
|
|
61
|
-
groupAllowFrom:
|
|
62
|
-
dm:
|
|
56
|
+
autoJoinAllowlist: AllowFromListSchema,
|
|
57
|
+
groupAllowFrom: AllowFromListSchema,
|
|
58
|
+
dm: buildNestedDmConfigSchema(),
|
|
63
59
|
groups: z.object({}).catchall(matrixRoomSchema).optional(),
|
|
64
60
|
rooms: z.object({}).catchall(matrixRoomSchema).optional(),
|
|
65
61
|
actions: matrixActionSchema,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
+
compileAllowlist,
|
|
2
3
|
normalizeStringEntries,
|
|
3
|
-
|
|
4
|
+
resolveAllowlistCandidates,
|
|
4
5
|
type AllowlistMatch,
|
|
5
6
|
} from "openclaw/plugin-sdk/matrix";
|
|
6
7
|
|
|
@@ -75,11 +76,11 @@ export function resolveMatrixAllowListMatch(params: {
|
|
|
75
76
|
allowList: string[];
|
|
76
77
|
userId?: string;
|
|
77
78
|
}): MatrixAllowListMatch {
|
|
78
|
-
const
|
|
79
|
-
if (
|
|
79
|
+
const compiledAllowList = compileAllowlist(params.allowList);
|
|
80
|
+
if (compiledAllowList.set.size === 0) {
|
|
80
81
|
return { allowed: false };
|
|
81
82
|
}
|
|
82
|
-
if (
|
|
83
|
+
if (compiledAllowList.wildcard) {
|
|
83
84
|
return { allowed: true, matchKey: "*", matchSource: "wildcard" };
|
|
84
85
|
}
|
|
85
86
|
const userId = normalizeMatrixUser(params.userId);
|
|
@@ -88,7 +89,10 @@ export function resolveMatrixAllowListMatch(params: {
|
|
|
88
89
|
{ value: userId ? `matrix:${userId}` : "", source: "prefixed-id" },
|
|
89
90
|
{ value: userId ? `user:${userId}` : "", source: "prefixed-user" },
|
|
90
91
|
];
|
|
91
|
-
return
|
|
92
|
+
return resolveAllowlistCandidates({
|
|
93
|
+
compiledAllowlist: compiledAllowList,
|
|
94
|
+
candidates,
|
|
95
|
+
});
|
|
92
96
|
}
|
|
93
97
|
|
|
94
98
|
export function resolveMatrixAllowListMatches(params: { allowList: string[]; userId?: string }) {
|