fix: honor feishu action discovery account config

This commit is contained in:
Tak Hoffman
2026-04-03 11:28:42 -05:00
parent 570ed4285e
commit c22f2a0cab
2 changed files with 68 additions and 6 deletions

View File

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

View File

@@ -141,13 +141,19 @@ const collectFeishuSecurityWarnings = createAllowlistProviderGroupPolicyWarningC
function describeFeishuMessageTool({
cfg,
accountId,
}: Parameters<
NonNullable<ChannelMessageActionAdapter["describeMessageTool"]>
>[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");
}