From 632a10cddcdcc2a0b06dee885763e194bf809f1f Mon Sep 17 00:00:00 2001 From: Tak Hoffman <781889+Takhoffman@users.noreply.github.com> Date: Fri, 3 Apr 2026 11:13:23 -0500 Subject: [PATCH] fix: honor googlechat action discovery account config --- extensions/googlechat/src/actions.test.ts | 21 +++++++++++++++++++++ extensions/googlechat/src/actions.ts | 20 +++++++++----------- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/extensions/googlechat/src/actions.test.ts b/extensions/googlechat/src/actions.test.ts index 79960f89341..419958c7e2f 100644 --- a/extensions/googlechat/src/actions.test.ts +++ b/extensions/googlechat/src/actions.test.ts @@ -69,6 +69,27 @@ describe("googlechat message actions", () => { }); }); + it("honors account-scoped reaction gates during discovery", () => { + resolveGoogleChatAccount.mockImplementation(({ accountId }: { accountId?: string | null }) => ({ + enabled: true, + credentialSource: "service-account", + config: { + actions: { reactions: accountId === "work" }, + }, + })); + + expect( + googlechatMessageActions.describeMessageTool?.({ cfg: {} as never, accountId: "default" }), + ).toEqual({ + actions: ["send", "upload-file"], + }); + expect( + googlechatMessageActions.describeMessageTool?.({ cfg: {} as never, accountId: "work" }), + ).toEqual({ + actions: ["send", "upload-file", "react", "reactions"], + }); + }); + it("sends messages with uploaded media through the resolved space", async () => { resolveGoogleChatAccount.mockReturnValue({ credentialSource: "service-account", diff --git a/extensions/googlechat/src/actions.ts b/extensions/googlechat/src/actions.ts index 647c344a106..cdac49620e8 100644 --- a/extensions/googlechat/src/actions.ts +++ b/extensions/googlechat/src/actions.ts @@ -31,15 +31,9 @@ function listEnabledAccounts(cfg: OpenClawConfig) { ); } -function isReactionsEnabled(accounts: ReturnType, cfg: OpenClawConfig) { +function isReactionsEnabled(accounts: Array<{ config: { actions?: unknown } }>) { for (const account of accounts) { - const gate = createActionGate( - (account.config.actions ?? - (cfg.channels?.["googlechat"] as { actions?: unknown })?.actions) as Record< - string, - boolean | undefined - >, - ); + const gate = createActionGate(account.config.actions as Record); if (gate("reactions")) { return true; } @@ -76,15 +70,19 @@ async function loadGoogleChatActionMedia(params: { } export const googlechatMessageActions: ChannelMessageActionAdapter = { - describeMessageTool: ({ cfg }) => { - const accounts = listEnabledAccounts(cfg); + describeMessageTool: ({ cfg, accountId }) => { + const accounts = accountId + ? [resolveGoogleChatAccount({ cfg, accountId })].filter( + (account) => account.enabled && account.credentialSource !== "none", + ) + : listEnabledAccounts(cfg); if (accounts.length === 0) { return null; } const actions = new Set([]); actions.add("send"); actions.add("upload-file"); - if (isReactionsEnabled(accounts, cfg)) { + if (isReactionsEnabled(accounts)) { actions.add("react"); actions.add("reactions"); }