fix(feishu): expose chat account override

This commit is contained in:
gaohongxiang 2026-03-18 09:52:33 +00:00
parent af2c7fc171
commit 7b9351f5ad
2 changed files with 22 additions and 0 deletions

View File

@ -9,6 +9,11 @@ export const FeishuChatSchema = Type.Object({
enum: [...CHAT_ACTION_VALUES],
description: "Action to run: members | info | member_info",
}),
accountId: Type.Optional(
Type.String({
description: "Optional Feishu account override for multi-account setups",
}),
),
chat_id: Type.Optional(Type.String({ description: "Chat ID (from URL or event payload)" })),
member_id: Type.Optional(Type.String({ description: "Member ID for member_info lookups" })),
page_size: Type.Optional(Type.Number({ description: "Page size (1-100, default 50)" })),

View File

@ -140,6 +140,23 @@ describe("feishu tool account routing", () => {
expect(createFeishuClientMock.mock.calls.at(-1)?.[0]?.appId).toBe("app-b");
});
test("chat tool allows explicit accountId override when defaultAccount disables chat", async () => {
chatGetMock.mockResolvedValue({ code: 0, data: { name: "chat", user_count: 1 } });
const { api, resolveTool } = createToolFactoryHarness(
createConfig({
defaultAccount: "b",
toolsA: { chat: true },
toolsB: { chat: false },
}),
);
registerFeishuChatTools(api);
const tool = resolveTool("feishu_chat", { agentAccountId: "a" });
await tool.execute("call", { action: "info", chat_id: "oc_a", accountId: "a" });
expect(createFeishuClientMock.mock.calls.at(-1)?.[0]?.appId).toBe("app-a");
});
test("chat tool blocks execution when the routed account disables chat", async () => {
const { api, resolveTool } = createToolFactoryHarness(
createConfig({