refactor: share channel action params

This commit is contained in:
Peter Steinberger
2026-04-19 04:03:16 +01:00
parent 1908967cfa
commit 04697eca88

View File

@@ -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<ChannelAgentTool, ChannelAgentToolMeta>();
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<ChannelMessageActionName>();
for (const plugin of listChannelPlugins()) {
const channelActions = resolveMessageActionDiscoveryForPlugin({