typing fix
This commit is contained in:
@@ -346,67 +346,67 @@ class ComponentRegistry:
|
||||
|
||||
# === 状态管理方法 ===
|
||||
|
||||
def enable_component(self, component_name: str, component_type: ComponentType = None) -> bool:
|
||||
# -------------------------------- NEED REFACTORING --------------------------------
|
||||
# -------------------------------- LOGIC ERROR -------------------------------------
|
||||
"""启用组件,支持命名空间解析"""
|
||||
# 首先尝试找到正确的命名空间化名称
|
||||
component_info = self.get_component_info(component_name, component_type)
|
||||
if not component_info:
|
||||
return False
|
||||
# def enable_component(self, component_name: str, component_type: ComponentType = None) -> bool:
|
||||
# # -------------------------------- NEED REFACTORING --------------------------------
|
||||
# # -------------------------------- LOGIC ERROR -------------------------------------
|
||||
# """启用组件,支持命名空间解析"""
|
||||
# # 首先尝试找到正确的命名空间化名称
|
||||
# component_info = self.get_component_info(component_name, component_type)
|
||||
# if not component_info:
|
||||
# return False
|
||||
|
||||
# 根据组件类型构造正确的命名空间化名称
|
||||
if component_info.component_type == ComponentType.ACTION:
|
||||
namespaced_name = f"action.{component_name}" if "." not in component_name else component_name
|
||||
elif component_info.component_type == ComponentType.COMMAND:
|
||||
namespaced_name = f"command.{component_name}" if "." not in component_name else component_name
|
||||
else:
|
||||
namespaced_name = (
|
||||
f"{component_info.component_type.value}.{component_name}"
|
||||
if "." not in component_name
|
||||
else component_name
|
||||
)
|
||||
# # 根据组件类型构造正确的命名空间化名称
|
||||
# if component_info.component_type == ComponentType.ACTION:
|
||||
# namespaced_name = f"action.{component_name}" if "." not in component_name else component_name
|
||||
# elif component_info.component_type == ComponentType.COMMAND:
|
||||
# namespaced_name = f"command.{component_name}" if "." not in component_name else component_name
|
||||
# else:
|
||||
# namespaced_name = (
|
||||
# f"{component_info.component_type.value}.{component_name}"
|
||||
# if "." not in component_name
|
||||
# else component_name
|
||||
# )
|
||||
|
||||
if namespaced_name in self._components:
|
||||
self._components[namespaced_name].enabled = True
|
||||
# 如果是Action,更新默认动作集
|
||||
# ---- HERE ----
|
||||
# if isinstance(component_info, ActionInfo):
|
||||
# self._action_descriptions[component_name] = component_info.description
|
||||
logger.debug(f"已启用组件: {component_name} -> {namespaced_name}")
|
||||
return True
|
||||
return False
|
||||
# if namespaced_name in self._components:
|
||||
# self._components[namespaced_name].enabled = True
|
||||
# # 如果是Action,更新默认动作集
|
||||
# # ---- HERE ----
|
||||
# # if isinstance(component_info, ActionInfo):
|
||||
# # self._action_descriptions[component_name] = component_info.description
|
||||
# logger.debug(f"已启用组件: {component_name} -> {namespaced_name}")
|
||||
# return True
|
||||
# return False
|
||||
|
||||
def disable_component(self, component_name: str, component_type: ComponentType = None) -> bool:
|
||||
# -------------------------------- NEED REFACTORING --------------------------------
|
||||
# -------------------------------- LOGIC ERROR -------------------------------------
|
||||
"""禁用组件,支持命名空间解析"""
|
||||
# 首先尝试找到正确的命名空间化名称
|
||||
component_info = self.get_component_info(component_name, component_type)
|
||||
if not component_info:
|
||||
return False
|
||||
# def disable_component(self, component_name: str, component_type: ComponentType = None) -> bool:
|
||||
# # -------------------------------- NEED REFACTORING --------------------------------
|
||||
# # -------------------------------- LOGIC ERROR -------------------------------------
|
||||
# """禁用组件,支持命名空间解析"""
|
||||
# # 首先尝试找到正确的命名空间化名称
|
||||
# component_info = self.get_component_info(component_name, component_type)
|
||||
# if not component_info:
|
||||
# return False
|
||||
|
||||
# 根据组件类型构造正确的命名空间化名称
|
||||
if component_info.component_type == ComponentType.ACTION:
|
||||
namespaced_name = f"action.{component_name}" if "." not in component_name else component_name
|
||||
elif component_info.component_type == ComponentType.COMMAND:
|
||||
namespaced_name = f"command.{component_name}" if "." not in component_name else component_name
|
||||
else:
|
||||
namespaced_name = (
|
||||
f"{component_info.component_type.value}.{component_name}"
|
||||
if "." not in component_name
|
||||
else component_name
|
||||
)
|
||||
# # 根据组件类型构造正确的命名空间化名称
|
||||
# if component_info.component_type == ComponentType.ACTION:
|
||||
# namespaced_name = f"action.{component_name}" if "." not in component_name else component_name
|
||||
# elif component_info.component_type == ComponentType.COMMAND:
|
||||
# namespaced_name = f"command.{component_name}" if "." not in component_name else component_name
|
||||
# else:
|
||||
# namespaced_name = (
|
||||
# f"{component_info.component_type.value}.{component_name}"
|
||||
# if "." not in component_name
|
||||
# else component_name
|
||||
# )
|
||||
|
||||
if namespaced_name in self._components:
|
||||
self._components[namespaced_name].enabled = False
|
||||
# 如果是Action,从默认动作集中移除
|
||||
# ---- HERE ----
|
||||
# if component_name in self._action_descriptions:
|
||||
# del self._action_descriptions[component_name]
|
||||
logger.debug(f"已禁用组件: {component_name} -> {namespaced_name}")
|
||||
return True
|
||||
return False
|
||||
# if namespaced_name in self._components:
|
||||
# self._components[namespaced_name].enabled = False
|
||||
# # 如果是Action,从默认动作集中移除
|
||||
# # ---- HERE ----
|
||||
# # if component_name in self._action_descriptions:
|
||||
# # del self._action_descriptions[component_name]
|
||||
# logger.debug(f"已禁用组件: {component_name} -> {namespaced_name}")
|
||||
# return True
|
||||
# return False
|
||||
|
||||
def get_registry_stats(self) -> Dict[str, Any]:
|
||||
"""获取注册中心统计信息"""
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import subprocess
|
||||
import sys
|
||||
import importlib
|
||||
from typing import List, Dict, Tuple
|
||||
from typing import List, Dict, Tuple, Any
|
||||
|
||||
from src.common.logger import get_logger
|
||||
from src.plugin_system.base.component_types import PythonDependency
|
||||
@@ -176,7 +176,7 @@ class DependencyManager:
|
||||
logger.error(f"生成requirements文件失败: {str(e)}")
|
||||
return False
|
||||
|
||||
def get_install_summary(self) -> Dict[str, any]:
|
||||
def get_install_summary(self) -> Dict[str, Any]:
|
||||
"""获取安装摘要"""
|
||||
return {
|
||||
"install_log": self.install_log.copy(),
|
||||
|
||||
@@ -197,29 +197,29 @@ class PluginManager:
|
||||
"""获取所有启用的插件信息"""
|
||||
return list(component_registry.get_enabled_plugins().values())
|
||||
|
||||
def enable_plugin(self, plugin_name: str) -> bool:
|
||||
# -------------------------------- NEED REFACTORING --------------------------------
|
||||
"""启用插件"""
|
||||
if plugin_info := component_registry.get_plugin_info(plugin_name):
|
||||
plugin_info.enabled = True
|
||||
# 启用插件的所有组件
|
||||
for component in plugin_info.components:
|
||||
component_registry.enable_component(component.name)
|
||||
logger.debug(f"已启用插件: {plugin_name}")
|
||||
return True
|
||||
return False
|
||||
# def enable_plugin(self, plugin_name: str) -> bool:
|
||||
# # -------------------------------- NEED REFACTORING --------------------------------
|
||||
# """启用插件"""
|
||||
# if plugin_info := component_registry.get_plugin_info(plugin_name):
|
||||
# plugin_info.enabled = True
|
||||
# # 启用插件的所有组件
|
||||
# for component in plugin_info.components:
|
||||
# component_registry.enable_component(component.name)
|
||||
# logger.debug(f"已启用插件: {plugin_name}")
|
||||
# return True
|
||||
# return False
|
||||
|
||||
def disable_plugin(self, plugin_name: str) -> bool:
|
||||
# -------------------------------- NEED REFACTORING --------------------------------
|
||||
"""禁用插件"""
|
||||
if plugin_info := component_registry.get_plugin_info(plugin_name):
|
||||
plugin_info.enabled = False
|
||||
# 禁用插件的所有组件
|
||||
for component in plugin_info.components:
|
||||
component_registry.disable_component(component.name)
|
||||
logger.debug(f"已禁用插件: {plugin_name}")
|
||||
return True
|
||||
return False
|
||||
# def disable_plugin(self, plugin_name: str) -> bool:
|
||||
# # -------------------------------- NEED REFACTORING --------------------------------
|
||||
# """禁用插件"""
|
||||
# if plugin_info := component_registry.get_plugin_info(plugin_name):
|
||||
# plugin_info.enabled = False
|
||||
# # 禁用插件的所有组件
|
||||
# for component in plugin_info.components:
|
||||
# component_registry.disable_component(component.name)
|
||||
# logger.debug(f"已禁用插件: {plugin_name}")
|
||||
# return True
|
||||
# return False
|
||||
|
||||
def get_plugin_instance(self, plugin_name: str) -> Optional["PluginBase"]:
|
||||
"""获取插件实例
|
||||
|
||||
Reference in New Issue
Block a user