fix: honor matrix action discovery account config

This commit is contained in:
Tak Hoffman 2026-04-03 11:23:04 -05:00
parent 6ac5806a39
commit d59d236a90
No known key found for this signature in database
2 changed files with 49 additions and 3 deletions

View File

@ -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");
});
});

View File

@ -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: [] };