From 04697eca88c44a19b5043a4d4f11436b5e9d94f8 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 19 Apr 2026 04:03:16 +0100 Subject: [PATCH] refactor: share channel action params --- src/agents/channel-tools.ts | 46 +++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/src/agents/channel-tools.ts b/src/agents/channel-tools.ts index aad6d103f0c..b6c36682a1f 100644 --- a/src/agents/channel-tools.ts +++ b/src/agents/channel-tools.ts @@ -17,6 +17,19 @@ type ChannelAgentToolMeta = { channelId: string; }; +type ChannelMessageActionDiscoveryParams = { + cfg?: OpenClawConfig; + currentChannelId?: string | null; + currentThreadTs?: string | null; + currentMessageId?: string | number | null; + accountId?: string | null; + sessionKey?: string | null; + sessionId?: string | null; + agentId?: string | null; + requesterSenderId?: string | null; + senderIsOwner?: boolean; +}; + const channelAgentToolMeta = new WeakMap(); export function getChannelAgentToolMeta(tool: ChannelAgentTool): ChannelAgentToolMeta | undefined { @@ -34,19 +47,11 @@ export function copyChannelAgentToolMeta(source: ChannelAgentTool, target: Chann * Get the list of supported message actions for a specific channel. * Returns an empty array if channel is not found or has no actions configured. */ -export function listChannelSupportedActions(params: { - cfg?: OpenClawConfig; - channel?: string; - currentChannelId?: string | null; - currentThreadTs?: string | null; - currentMessageId?: string | number | null; - accountId?: string | null; - sessionKey?: string | null; - sessionId?: string | null; - agentId?: string | null; - requesterSenderId?: string | null; - senderIsOwner?: boolean; -}): ChannelMessageActionName[] { +export function listChannelSupportedActions( + params: ChannelMessageActionDiscoveryParams & { + channel?: string; + }, +): ChannelMessageActionName[] { const channelId = resolveMessageActionDiscoveryChannelId(params.channel); if (!channelId) { return []; @@ -66,18 +71,9 @@ export function listChannelSupportedActions(params: { /** * Get the list of all supported message actions across all configured channels. */ -export function listAllChannelSupportedActions(params: { - cfg?: OpenClawConfig; - currentChannelId?: string | null; - currentThreadTs?: string | null; - currentMessageId?: string | number | null; - accountId?: string | null; - sessionKey?: string | null; - sessionId?: string | null; - agentId?: string | null; - requesterSenderId?: string | null; - senderIsOwner?: boolean; -}): ChannelMessageActionName[] { +export function listAllChannelSupportedActions( + params: ChannelMessageActionDiscoveryParams, +): ChannelMessageActionName[] { const actions = new Set(); for (const plugin of listChannelPlugins()) { const channelActions = resolveMessageActionDiscoveryForPlugin({