From c22f2a0cab8c006fa4e32991065fb1680970010e Mon Sep 17 00:00:00 2001 From: Tak Hoffman <781889+Takhoffman@users.noreply.github.com> Date: Fri, 3 Apr 2026 11:28:42 -0500 Subject: [PATCH] fix: honor feishu action discovery account config --- extensions/feishu/src/channel.test.ts | 56 ++++++++++++++++++++++++++- extensions/feishu/src/channel.ts | 18 +++++++-- 2 files changed, 68 insertions(+), 6 deletions(-) diff --git a/extensions/feishu/src/channel.test.ts b/extensions/feishu/src/channel.test.ts index 89f086b0eae..32e1f9101a6 100644 --- a/extensions/feishu/src/channel.test.ts +++ b/extensions/feishu/src/channel.test.ts @@ -62,8 +62,8 @@ vi.mock("../../../src/channels/plugins/bundled.js", () => ({ let feishuPlugin: typeof import("./channel.js").feishuPlugin; -function getDescribedActions(cfg: OpenClawConfig): string[] { - return [...(feishuPlugin.actions?.describeMessageTool?.({ cfg })?.actions ?? [])]; +function getDescribedActions(cfg: OpenClawConfig, accountId?: string): string[] { + return [...(feishuPlugin.actions?.describeMessageTool?.({ cfg, accountId })?.actions ?? [])]; } function createLegacyFeishuButtonCard(value: { command?: string; text?: string }) { @@ -279,6 +279,58 @@ describe("feishuPlugin actions", () => { ]); }); + it("honors the selected Feishu account during discovery", () => { + const cfg = { + channels: { + feishu: { + enabled: true, + actions: { reactions: false }, + accounts: { + default: { + enabled: true, + appId: "cli_main", + appSecret: "secret_main", + actions: { reactions: false }, + }, + work: { + enabled: true, + appId: "cli_work", + appSecret: "secret_work", + actions: { reactions: true }, + }, + }, + }, + }, + } as OpenClawConfig; + + expect(getDescribedActions(cfg, "default")).toEqual([ + "send", + "read", + "edit", + "thread-reply", + "pin", + "list-pins", + "unpin", + "member-info", + "channel-info", + "channel-list", + ]); + expect(getDescribedActions(cfg, "work")).toEqual([ + "send", + "read", + "edit", + "thread-reply", + "pin", + "list-pins", + "unpin", + "member-info", + "channel-info", + "channel-list", + "react", + "reactions", + ]); + }); + it("sends text messages", async () => { sendMessageFeishuMock.mockResolvedValueOnce({ messageId: "om_sent", chatId: "oc_group_1" }); diff --git a/extensions/feishu/src/channel.ts b/extensions/feishu/src/channel.ts index 88339ec5d23..7bf1383e593 100644 --- a/extensions/feishu/src/channel.ts +++ b/extensions/feishu/src/channel.ts @@ -141,13 +141,19 @@ const collectFeishuSecurityWarnings = createAllowlistProviderGroupPolicyWarningC function describeFeishuMessageTool({ cfg, + accountId, }: Parameters< NonNullable >[0]): ChannelMessageToolDiscovery { + const enabledAccounts = accountId + ? [resolveFeishuAccount({ cfg, accountId })].filter((account) => account.enabled && account.configured) + : listEnabledFeishuAccounts(cfg); const enabled = - cfg.channels?.feishu?.enabled !== false && - Boolean(inspectFeishuCredentials(cfg.channels?.feishu as FeishuConfig | undefined)); - if (listEnabledFeishuAccounts(cfg).length === 0) { + enabledAccounts.length > 0 || + (!accountId && + cfg.channels?.feishu?.enabled !== false && + Boolean(inspectFeishuCredentials(cfg.channels?.feishu as FeishuConfig | undefined))); + if (enabledAccounts.length === 0) { return { actions: [], capabilities: enabled ? ["cards"] : [], @@ -172,7 +178,11 @@ function describeFeishuMessageTool({ "channel-info", "channel-list", ]); - if (areAnyFeishuReactionActionsEnabled(cfg)) { + if ( + (accountId + ? enabledAccounts.some((account) => isFeishuReactionsActionEnabled({ cfg, account })) + : areAnyFeishuReactionActionsEnabled(cfg)) + ) { actions.add("react"); actions.add("reactions"); }