From 1c6676cd57453ba8b29a9f908937df7b015beb95 Mon Sep 17 00:00:00 2001 From: Gustavo Madeira Santana Date: Wed, 18 Mar 2026 02:17:40 +0000 Subject: [PATCH] Plugins: remove first-party legacy message discovery shims --- extensions/discord/src/channel-actions.ts | 2 -- extensions/discord/src/channel.ts | 6 ---- extensions/feishu/src/channel.ts | 6 +--- extensions/mattermost/src/channel.ts | 32 +++++++++------------ extensions/msteams/src/channel.ts | 6 +--- extensions/telegram/src/channel-actions.ts | 2 -- extensions/telegram/src/channel.ts | 6 ---- src/channels/plugins/message-tool-legacy.ts | 13 --------- src/channels/plugins/slack.actions.ts | 2 -- src/commands/channels/capabilities.ts | 20 ++++++++++--- src/plugin-sdk/agent-runtime.ts | 12 -------- src/plugin-sdk/channel-runtime.ts | 1 - 12 files changed, 32 insertions(+), 76 deletions(-) delete mode 100644 src/channels/plugins/message-tool-legacy.ts diff --git a/extensions/discord/src/channel-actions.ts b/extensions/discord/src/channel-actions.ts index 960b08acdf6..c4be7728439 100644 --- a/extensions/discord/src/channel-actions.ts +++ b/extensions/discord/src/channel-actions.ts @@ -1,5 +1,4 @@ import { - createLegacyMessageToolDiscoveryMethods, createDiscordMessageToolComponentsSchema, createUnionActionGate, listTokenSourcedAccounts, @@ -133,7 +132,6 @@ function describeDiscordMessageTool({ export const discordMessageActions: ChannelMessageActionAdapter = { describeMessageTool: describeDiscordMessageTool, - ...createLegacyMessageToolDiscoveryMethods(describeDiscordMessageTool), extractToolSend: ({ args }) => { const action = typeof args.action === "string" ? args.action.trim() : ""; if (action === "sendMessage") { diff --git a/extensions/discord/src/channel.ts b/extensions/discord/src/channel.ts index c555ff89382..58076e1e67d 100644 --- a/extensions/discord/src/channel.ts +++ b/extensions/discord/src/channel.ts @@ -79,12 +79,6 @@ function formatDiscordIntents(intents?: { const discordMessageActions: ChannelMessageActionAdapter = { describeMessageTool: (ctx) => getDiscordRuntime().channel.discord.messageActions?.describeMessageTool?.(ctx) ?? null, - listActions: (ctx) => - getDiscordRuntime().channel.discord.messageActions?.listActions?.(ctx) ?? [], - getCapabilities: (ctx) => - getDiscordRuntime().channel.discord.messageActions?.getCapabilities?.(ctx) ?? [], - getToolSchema: (ctx) => - getDiscordRuntime().channel.discord.messageActions?.getToolSchema?.(ctx) ?? null, extractToolSend: (ctx) => getDiscordRuntime().channel.discord.messageActions?.extractToolSend?.(ctx) ?? null, handleAction: async (ctx) => { diff --git a/extensions/feishu/src/channel.ts b/extensions/feishu/src/channel.ts index da5cd8e4382..fda85f113e1 100644 --- a/extensions/feishu/src/channel.ts +++ b/extensions/feishu/src/channel.ts @@ -1,10 +1,7 @@ import { formatAllowFromLowercase } from "openclaw/plugin-sdk/allow-from"; import { mapAllowFromEntries } from "openclaw/plugin-sdk/channel-config-helpers"; import { collectAllowlistProviderRestrictSendersWarnings } from "openclaw/plugin-sdk/channel-policy"; -import { - createLegacyMessageToolDiscoveryMethods, - createMessageToolCardSchema, -} from "openclaw/plugin-sdk/channel-runtime"; +import { createMessageToolCardSchema } from "openclaw/plugin-sdk/channel-runtime"; import type { ChannelMessageActionAdapter, ChannelMessageToolDiscovery, @@ -453,7 +450,6 @@ export const feishuPlugin: ChannelPlugin = { }, actions: { describeMessageTool: describeFeishuMessageTool, - ...createLegacyMessageToolDiscoveryMethods(describeFeishuMessageTool), handleAction: async (ctx) => { const account = resolveFeishuAccount({ cfg: ctx.cfg, accountId: ctx.accountId ?? undefined }); if ( diff --git a/extensions/mattermost/src/channel.ts b/extensions/mattermost/src/channel.ts index 5688e13d8ae..4bc716ac27e 100644 --- a/extensions/mattermost/src/channel.ts +++ b/extensions/mattermost/src/channel.ts @@ -4,24 +4,8 @@ import { buildAccountScopedDmSecurityPolicy, collectAllowlistProviderRestrictSendersWarnings, } from "openclaw/plugin-sdk/channel-policy"; -import { - createLegacyMessageToolDiscoveryMethods, - createMessageToolButtonsSchema, -} from "openclaw/plugin-sdk/channel-runtime"; +import { createMessageToolButtonsSchema } from "openclaw/plugin-sdk/channel-runtime"; import type { ChannelMessageToolDiscovery } from "openclaw/plugin-sdk/channel-runtime"; -import { - buildComputedAccountStatusSnapshot, - buildChannelConfigSchema, - createAccountStatusSink, - DEFAULT_ACCOUNT_ID, - deleteAccountFromConfigSection, - resolveAllowlistProviderRuntimeGroupPolicy, - resolveDefaultGroupPolicy, - setAccountEnabledInConfigSection, - type ChannelMessageActionAdapter, - type ChannelMessageActionName, - type ChannelPlugin, -} from "./runtime-api.js"; import { buildPassiveProbedChannelStatusSummary } from "../../shared/channel-status-summary.js"; import { MattermostConfigSchema } from "./config-schema.js"; import { resolveMattermostGroupRequireMention } from "./group-mentions.js"; @@ -42,6 +26,19 @@ import { addMattermostReaction, removeMattermostReaction } from "./mattermost/re import { sendMessageMattermost } from "./mattermost/send.js"; import { resolveMattermostOpaqueTarget } from "./mattermost/target-resolution.js"; import { looksLikeMattermostTargetId, normalizeMattermostMessagingTarget } from "./normalize.js"; +import { + buildComputedAccountStatusSnapshot, + buildChannelConfigSchema, + createAccountStatusSink, + DEFAULT_ACCOUNT_ID, + deleteAccountFromConfigSection, + resolveAllowlistProviderRuntimeGroupPolicy, + resolveDefaultGroupPolicy, + setAccountEnabledInConfigSection, + type ChannelMessageActionAdapter, + type ChannelMessageActionName, + type ChannelPlugin, +} from "./runtime-api.js"; import { getMattermostRuntime } from "./runtime.js"; import { mattermostSetupAdapter } from "./setup-core.js"; import { mattermostSetupWizard } from "./setup-surface.js"; @@ -88,7 +85,6 @@ function describeMattermostMessageTool({ const mattermostMessageActions: ChannelMessageActionAdapter = { describeMessageTool: describeMattermostMessageTool, - ...createLegacyMessageToolDiscoveryMethods(describeMattermostMessageTool), supportsAction: ({ action }) => { return action === "send" || action === "react"; }, diff --git a/extensions/msteams/src/channel.ts b/extensions/msteams/src/channel.ts index 7458389efb1..5f3a6aa0b59 100644 --- a/extensions/msteams/src/channel.ts +++ b/extensions/msteams/src/channel.ts @@ -1,9 +1,6 @@ import { formatAllowFromLowercase } from "openclaw/plugin-sdk/allow-from"; import { collectAllowlistProviderRestrictSendersWarnings } from "openclaw/plugin-sdk/channel-policy"; -import { - createLegacyMessageToolDiscoveryMethods, - createMessageToolCardSchema, -} from "openclaw/plugin-sdk/channel-runtime"; +import { createMessageToolCardSchema } from "openclaw/plugin-sdk/channel-runtime"; import type { ChannelMessageActionAdapter, ChannelMessageToolDiscovery, @@ -398,7 +395,6 @@ export const msteamsPlugin: ChannelPlugin = { }, actions: { describeMessageTool: describeMSTeamsMessageTool, - ...createLegacyMessageToolDiscoveryMethods(describeMSTeamsMessageTool), handleAction: async (ctx) => { // Handle send action with card parameter if (ctx.action === "send" && ctx.params.card) { diff --git a/extensions/telegram/src/channel-actions.ts b/extensions/telegram/src/channel-actions.ts index cd757688835..56d27817921 100644 --- a/extensions/telegram/src/channel-actions.ts +++ b/extensions/telegram/src/channel-actions.ts @@ -7,7 +7,6 @@ import { import { readBooleanParam } from "openclaw/plugin-sdk/boolean-param"; import { resolveReactionMessageId } from "openclaw/plugin-sdk/channel-runtime"; import { - createLegacyMessageToolDiscoveryMethods, createMessageToolButtonsSchema, createTelegramPollExtraToolSchemas, createUnionActionGate, @@ -178,7 +177,6 @@ function readTelegramMessageIdParam(params: Record): number { export const telegramMessageActions: ChannelMessageActionAdapter = { describeMessageTool: describeTelegramMessageTool, - ...createLegacyMessageToolDiscoveryMethods(describeTelegramMessageTool), extractToolSend: ({ args }) => { return extractToolSend(args, "sendMessage"); }, diff --git a/extensions/telegram/src/channel.ts b/extensions/telegram/src/channel.ts index 6d536fb8513..56a2256f9c0 100644 --- a/extensions/telegram/src/channel.ts +++ b/extensions/telegram/src/channel.ts @@ -250,12 +250,6 @@ function hasTelegramExecApprovalDmRoute(cfg: OpenClawConfig): boolean { const telegramMessageActions: ChannelMessageActionAdapter = { describeMessageTool: (ctx) => getTelegramRuntime().channel.telegram.messageActions?.describeMessageTool?.(ctx) ?? null, - listActions: (ctx) => - getTelegramRuntime().channel.telegram.messageActions?.listActions?.(ctx) ?? [], - getCapabilities: (ctx) => - getTelegramRuntime().channel.telegram.messageActions?.getCapabilities?.(ctx) ?? [], - getToolSchema: (ctx) => - getTelegramRuntime().channel.telegram.messageActions?.getToolSchema?.(ctx) ?? null, extractToolSend: (ctx) => getTelegramRuntime().channel.telegram.messageActions?.extractToolSend?.(ctx) ?? null, handleAction: async (ctx) => { diff --git a/src/channels/plugins/message-tool-legacy.ts b/src/channels/plugins/message-tool-legacy.ts deleted file mode 100644 index 2c74213439f..00000000000 --- a/src/channels/plugins/message-tool-legacy.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { ChannelMessageActionAdapter } from "./types.js"; - -export function createLegacyMessageToolDiscoveryMethods( - describeMessageTool: NonNullable, -): Pick { - const describe = (ctx: Parameters[0]) => - describeMessageTool(ctx) ?? null; - return { - listActions: (ctx) => [...(describe(ctx)?.actions ?? [])], - getCapabilities: (ctx) => [...(describe(ctx)?.capabilities ?? [])], - getToolSchema: (ctx) => describe(ctx)?.schema ?? null, - }; -} diff --git a/src/channels/plugins/slack.actions.ts b/src/channels/plugins/slack.actions.ts index c9cf3e9d883..317b8a7d8db 100644 --- a/src/channels/plugins/slack.actions.ts +++ b/src/channels/plugins/slack.actions.ts @@ -10,7 +10,6 @@ import { resolveSlackChannelId, handleSlackMessageAction, } from "../../plugin-sdk/slack.js"; -import { createLegacyMessageToolDiscoveryMethods } from "./message-tool-legacy.js"; import { createSlackMessageToolBlocksSchema } from "./message-tool-schema.js"; import type { ChannelMessageActionAdapter, ChannelMessageToolDiscovery } from "./types.js"; @@ -52,7 +51,6 @@ export function createSlackActions( return { describeMessageTool, - ...createLegacyMessageToolDiscoveryMethods(describeMessageTool), extractToolSend: ({ args }) => extractSlackToolSend(args), handleAction: async (ctx) => { return await handleSlackMessageAction({ diff --git a/src/commands/channels/capabilities.ts b/src/commands/channels/capabilities.ts index acd28137b30..eccd96824da 100644 --- a/src/commands/channels/capabilities.ts +++ b/src/commands/channels/capabilities.ts @@ -1,5 +1,9 @@ import { resolveChannelDefaultAccountId } from "../../channels/plugins/helpers.js"; import { getChannelPlugin, listChannelPlugins } from "../../channels/plugins/index.js"; +import { + createMessageActionDiscoveryContext, + resolveMessageActionDiscoveryForPlugin, +} from "../../channels/plugins/message-action-discovery.js"; import type { ChannelCapabilities, ChannelCapabilitiesDiagnostics, @@ -133,10 +137,6 @@ async function resolveChannelReports(params: { : [resolveChannelDefaultAccountId({ plugin, cfg, accountIds: ids })]; })(); const reports: ChannelCapabilitiesReport[] = []; - const listedActions = plugin.actions?.listActions?.({ cfg }) ?? []; - const actions = Array.from( - new Set(["send", "broadcast", ...listedActions.map((action) => String(action))]), - ); for (const accountId of accountIds) { const resolvedAccount = plugin.config.resolveAccount(cfg, accountId); @@ -169,6 +169,18 @@ async function resolveChannelReports(params: { target: params.target, }) : undefined; + const discoveredActions = resolveMessageActionDiscoveryForPlugin({ + pluginId: plugin.id, + actions: plugin.actions, + context: createMessageActionDiscoveryContext({ + cfg, + accountId, + }), + includeActions: true, + }).actions; + const actions = Array.from( + new Set(["send", "broadcast", ...discoveredActions.map((action) => String(action))]), + ); reports.push({ channel: plugin.id, diff --git a/src/plugin-sdk/agent-runtime.ts b/src/plugin-sdk/agent-runtime.ts index 20ab0596a12..e267a458e16 100644 --- a/src/plugin-sdk/agent-runtime.ts +++ b/src/plugin-sdk/agent-runtime.ts @@ -23,15 +23,3 @@ export * from "../agents/vllm-defaults.js"; // Intentional public runtime surface: channel plugins use ingress agent helpers directly. export * from "../agents/agent-command.js"; export * from "../tts/tts.js"; -// Legacy channel action runtime re-exports. New bundled plugin code should use -// local extension-owned modules instead of adding more public SDK surface here. -export { - handleDiscordAction, - readDiscordParentIdParam, - isDiscordModerationAction, - readDiscordModerationCommand, -} from "../../extensions/discord/runtime-api.js"; -export { - handleTelegramAction, - readTelegramButtons, -} from "../../extensions/telegram/runtime-api.js"; diff --git a/src/plugin-sdk/channel-runtime.ts b/src/plugin-sdk/channel-runtime.ts index 1460acba87d..089e10609af 100644 --- a/src/plugin-sdk/channel-runtime.ts +++ b/src/plugin-sdk/channel-runtime.ts @@ -34,7 +34,6 @@ export type * from "../channels/plugins/types.js"; export * from "../channels/plugins/config-writes.js"; export * from "../channels/plugins/directory-config.js"; export * from "../channels/plugins/media-payload.js"; -export * from "../channels/plugins/message-tool-legacy.js"; export * from "../channels/plugins/message-tool-schema.js"; export * from "../channels/plugins/normalize/signal.js"; export * from "../channels/plugins/normalize/whatsapp.js";