feat: 增强插件管理和连接稳定性,添加会话令牌重置和组件清理功能

This commit is contained in:
DrSmoothl
2026-03-12 22:51:14 +08:00
parent 793dee08d4
commit 688b53ee24
8 changed files with 137 additions and 15 deletions

View File

@@ -93,6 +93,14 @@ class ComponentRegistry:
comp = RegisteredComponent(name, component_type, plugin_id, metadata)
if comp.full_name in self._components:
logger.warning(f"组件 {comp.full_name} 已存在,覆盖")
# 从 _by_plugin 列表中移除旧条目,防止幽灵组件堆积
old_comp = self._components[comp.full_name]
old_list = self._by_plugin.get(old_comp.plugin_id)
if old_list is not None:
try:
old_list.remove(old_comp)
except ValueError:
pass
self._components[comp.full_name] = comp