style(log): 移除日志输出中的 emoji 符号
为了在不同终端和环境中保持日志输出的整洁与一致性,统一移除了日志信息中的 emoji 符号。 此举旨在避免潜在的渲染问题,并使日志更易于程序化解析和人工阅读。同时,对部分代码进行了微小的类型标注优化。
This commit is contained in:
@@ -146,9 +146,9 @@ class MCPClientManager:
|
||||
try:
|
||||
client = await self._create_client(server_config)
|
||||
self.clients[server_name] = client
|
||||
logger.info(f"✅ MCP 服务器 '{server_name}' 连接成功")
|
||||
logger.info(f" MCP 服务器 '{server_name}' 连接成功")
|
||||
except Exception as e:
|
||||
logger.error(f"❌ 连接 MCP 服务器 '{server_name}' 失败: {e}")
|
||||
logger.error(f" 连接 MCP 服务器 '{server_name}' 失败: {e}")
|
||||
continue
|
||||
|
||||
self._initialized = True
|
||||
|
||||
@@ -47,7 +47,7 @@ class MCPToolAdapter(BaseTool):
|
||||
self.available_for_llm = True # MCP 工具默认可供 LLM 使用
|
||||
|
||||
# 转换参数定义
|
||||
self.parameters = self._convert_parameters(mcp_tool.inputSchema)
|
||||
self.parameters: list[tuple[str, ToolParamType, str, bool, list[str] | None]] = self._convert_parameters(mcp_tool.inputSchema)
|
||||
|
||||
logger.debug(f"创建 MCP 工具适配器: {self.name}")
|
||||
|
||||
@@ -238,9 +238,9 @@ async def load_mcp_tools_as_adapters() -> list[MCPToolAdapter]:
|
||||
try:
|
||||
adapter = MCPToolAdapter.from_mcp_tool(server_name, mcp_tool)
|
||||
adapters.append(adapter)
|
||||
logger.debug(f" ✓ 加载工具: {adapter.name}")
|
||||
logger.debug(f" 加载工具: {adapter.name}")
|
||||
except Exception as e:
|
||||
logger.error(f" ✗ 创建工具适配器失败: {mcp_tool.name} | 错误: {e}")
|
||||
logger.error(f" 创建工具适配器失败: {mcp_tool.name} | 错误: {e}")
|
||||
continue
|
||||
|
||||
logger.info(f"MCP 工具加载完成: 成功 {len(adapters)}/{total_tools} 个")
|
||||
|
||||
@@ -109,7 +109,7 @@ class PluginManager:
|
||||
|
||||
if not module or not hasattr(module, "__plugin_meta__"):
|
||||
self.failed_plugins[plugin_name] = "插件模块中缺少 __plugin_meta__"
|
||||
logger.error(f"❌ 插件加载失败: {plugin_name} - 缺少 __plugin_meta__")
|
||||
logger.error(f" 插件加载失败: {plugin_name} - 缺少 __plugin_meta__")
|
||||
return False, 1
|
||||
|
||||
metadata: PluginMetadata = getattr(module, "__plugin_meta__")
|
||||
@@ -154,14 +154,14 @@ class PluginManager:
|
||||
return True, 1
|
||||
else:
|
||||
self.failed_plugins[plugin_name] = "插件注册失败"
|
||||
logger.error(f"❌ 插件注册失败: {plugin_name}")
|
||||
logger.error(f" 插件注册失败: {plugin_name}")
|
||||
return False, 1
|
||||
|
||||
except Exception as e:
|
||||
# 其他错误
|
||||
error_msg = f"未知错误: {e!s}"
|
||||
self.failed_plugins[plugin_name] = error_msg
|
||||
logger.error(f"❌ 插件加载失败: {plugin_name} - {error_msg}")
|
||||
logger.error(f" 插件加载失败: {plugin_name} - {error_msg}")
|
||||
logger.debug("详细错误信息: ", exc_info=True)
|
||||
return False, 1
|
||||
|
||||
@@ -340,14 +340,14 @@ class PluginManager:
|
||||
if not success:
|
||||
error_msg = f"Python依赖检查失败: {', '.join(errors)}"
|
||||
self.failed_plugins[plugin_name] = error_msg
|
||||
logger.error(f"❌ 插件加载失败: {plugin_name} - {error_msg}")
|
||||
logger.error(f" 插件加载失败: {plugin_name} - {error_msg}")
|
||||
return None # 依赖检查失败,不加载该模块
|
||||
|
||||
# 2. 检查插件依赖
|
||||
if not self._check_plugin_dependencies(metadata):
|
||||
error_msg = f"插件依赖检查失败: 请确保依赖 {metadata.dependencies} 已正确安装并加载。"
|
||||
self.failed_plugins[plugin_name] = error_msg
|
||||
logger.error(f"❌ 插件加载失败: {plugin_name} - {error_msg}")
|
||||
logger.error(f" 插件加载失败: {plugin_name} - {error_msg}")
|
||||
return None # 插件依赖检查失败
|
||||
|
||||
# --- 依赖检查逻辑结束 ---
|
||||
@@ -408,7 +408,7 @@ class PluginManager:
|
||||
|
||||
# 📋 显示插件加载总览
|
||||
if total_registered > 0:
|
||||
logger.info("🎉 插件系统加载完成!")
|
||||
logger.info(" 插件系统加载完成!")
|
||||
logger.info(
|
||||
f"📊 总览: {total_registered}个插件, {total_components}个组件 (Action: {action_count}, Command: {command_count}, Tool: {tool_count}, PlusCommand: {plus_command_count}, EventHandler: {event_handler_count}, Chatter: {chatter_count}, Prompt: {prompt_count}, Router: {router_count})"
|
||||
)
|
||||
@@ -616,7 +616,7 @@ class PluginManager:
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"❌ 插件卸载失败: {plugin_name} - {e!s}", exc_info=True)
|
||||
logger.error(f" 插件卸载失败: {plugin_name} - {e!s}", exc_info=True)
|
||||
return False
|
||||
|
||||
|
||||
|
||||
@@ -245,7 +245,7 @@ class StreamToolHistoryManager:
|
||||
|
||||
lines = ["## 🔧 最近工具调用记录"]
|
||||
for i, record in enumerate(recent_records, 1):
|
||||
status_icon = "✅" if record.status == "success" else "❌" if record.status == "error" else "⏳"
|
||||
status_icon = "success" if record.status == "success" else "error" if record.status == "error" else "pending"
|
||||
|
||||
# 格式化参数
|
||||
args_preview = self._format_args_preview(record.args)
|
||||
|
||||
Reference in New Issue
Block a user