mirror of https://github.com/openclaw/openclaw.git
fix: honor matrix action discovery account config
This commit is contained in:
parent
6ac5806a39
commit
d59d236a90
|
|
@ -166,4 +166,50 @@ describe("matrixMessageActions", () => {
|
|||
|
||||
expect(actions).toEqual([]);
|
||||
});
|
||||
|
||||
it("honors the selected Matrix account during discovery", () => {
|
||||
const cfg = {
|
||||
channels: {
|
||||
matrix: {
|
||||
defaultAccount: "assistant",
|
||||
accounts: {
|
||||
assistant: {
|
||||
homeserver: "https://matrix.example.org",
|
||||
userId: "@assistant:example.org",
|
||||
accessToken: "assistant-token",
|
||||
actions: {
|
||||
messages: true,
|
||||
reactions: false,
|
||||
},
|
||||
},
|
||||
ops: {
|
||||
homeserver: "https://matrix.example.org",
|
||||
userId: "@ops:example.org",
|
||||
accessToken: "ops-token",
|
||||
actions: {
|
||||
messages: true,
|
||||
reactions: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
} as CoreConfig;
|
||||
|
||||
const assistantActions =
|
||||
matrixMessageActions.describeMessageTool!({
|
||||
cfg,
|
||||
accountId: "assistant",
|
||||
} as never).actions;
|
||||
const opsActions =
|
||||
matrixMessageActions.describeMessageTool!({
|
||||
cfg,
|
||||
accountId: "ops",
|
||||
} as never).actions;
|
||||
|
||||
expect(assistantActions).not.toContain("react");
|
||||
expect(assistantActions).not.toContain("reactions");
|
||||
expect(opsActions).toContain("react");
|
||||
expect(opsActions).toContain("reactions");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -107,14 +107,14 @@ function buildMatrixProfileToolSchema(): NonNullable<ChannelMessageToolDiscovery
|
|||
}
|
||||
|
||||
export const matrixMessageActions: ChannelMessageActionAdapter = {
|
||||
describeMessageTool: ({ cfg }) => {
|
||||
describeMessageTool: ({ cfg, accountId }) => {
|
||||
const resolvedCfg = cfg as CoreConfig;
|
||||
if (requiresExplicitMatrixDefaultAccount(resolvedCfg)) {
|
||||
if (!accountId && requiresExplicitMatrixDefaultAccount(resolvedCfg)) {
|
||||
return { actions: [], capabilities: [] };
|
||||
}
|
||||
const account = resolveMatrixAccount({
|
||||
cfg: resolvedCfg,
|
||||
accountId: resolveDefaultMatrixAccountId(resolvedCfg),
|
||||
accountId: accountId ?? resolveDefaultMatrixAccountId(resolvedCfg),
|
||||
});
|
||||
if (!account.enabled || !account.configured) {
|
||||
return { actions: [], capabilities: [] };
|
||||
|
|
|
|||
Loading…
Reference in New Issue