from __future__ import annotations from typing import TYPE_CHECKING if TYPE_CHECKING: from yuxi.channels.message_actions import ActionRegistry, ActionRouter class MessageActionTool: name: str description: str action: str parameters: dict async def execute(self, action_router: ActionRouter, **kwargs) -> dict: result = await action_router.dispatch( action=self.action, chat_id=kwargs["chat_id"], msg_id=kwargs.get("msg_id", ""), args=kwargs.get("args", {}), session_key=kwargs.get("session_key"), ) return result.model_dump() def discover_message_action_tools(registry: ActionRegistry, router: ActionRouter) -> list[dict]: tools = [] for action_name, action_info in registry._capabilities.items(): tools.append( { "name": str(action_name), "description": f"Message action: {action_name}", "parameters": {}, } ) return tools