From 28ab5061bf3dac078be2a4d0bd308c93e38339df Mon Sep 17 00:00:00 2001 From: Gustavo Madeira Santana Date: Wed, 18 Mar 2026 00:07:01 +0000 Subject: [PATCH] Mattermost: consolidate message tool discovery --- extensions/mattermost/src/channel.ts | 35 ++++++++++++---------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/extensions/mattermost/src/channel.ts b/extensions/mattermost/src/channel.ts index 5bec217aa3b..964310bcbdd 100644 --- a/extensions/mattermost/src/channel.ts +++ b/extensions/mattermost/src/channel.ts @@ -43,7 +43,9 @@ import { mattermostSetupAdapter } from "./setup-core.js"; import { mattermostSetupWizard } from "./setup-surface.js"; const mattermostMessageActions: ChannelMessageActionAdapter = { - listActions: ({ cfg }) => { + describeMessageTool: ({ + cfg, + }: Parameters>[0]) => { const enabledAccounts = listMattermostAccountIds(cfg) .map((accountId) => resolveMattermostAccount({ cfg, accountId })) .filter((account) => account.enabled) @@ -67,29 +69,22 @@ const mattermostMessageActions: ChannelMessageActionAdapter = { actions.push("react"); } - return actions; + return { + actions, + capabilities: enabledAccounts.length > 0 ? ["buttons"] : [], + schema: + enabledAccounts.length > 0 + ? { + properties: { + buttons: createMessageToolButtonsSchema(), + }, + } + : null, + }; }, supportsAction: ({ action }) => { return action === "send" || action === "react"; }, - getCapabilities: ({ cfg }) => { - const accounts = listMattermostAccountIds(cfg) - .map((id) => resolveMattermostAccount({ cfg, accountId: id })) - .filter((a) => a.enabled && a.botToken?.trim() && a.baseUrl?.trim()); - return accounts.length > 0 ? (["buttons"] as const) : []; - }, - getToolSchema: ({ cfg }) => { - const accounts = listMattermostAccountIds(cfg) - .map((id) => resolveMattermostAccount({ cfg, accountId: id })) - .filter((a) => a.enabled && a.botToken?.trim() && a.baseUrl?.trim()); - return accounts.length > 0 - ? { - properties: { - buttons: createMessageToolButtonsSchema(), - }, - } - : null; - }, handleAction: async ({ action, params, cfg, accountId }) => { if (action === "react") { // Check reactions gate: per-account config takes precedence over base config