新增大量渠道适配器相关的协议、策略、工具类与基础设施代码,包括: 1. 多协议定义:认证、消息、配置、网关等核心接口 2. 策略模块:上下文、群聊、去重、防抖等业务策略 3. 工具集:重试、去重、文本分块、消息格式化等SDK工具 4. 基础设施:外部进程管理、事件广播、熔断机制等 5. 账户与管道系统:账户管理、消息处理管道实现 6. 运行时服务:状态收集、维护任务、日志等后台服务
37 lines
1.0 KiB
Python
37 lines
1.0 KiB
Python
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
|