Refactor anti-injection system and remove command skip list

Removed the command skip list feature and related code from the anti-injection system, including configuration options, plugin command collection, and management commands. Refactored anti-injector logic to operate directly on message dictionaries and simplified whitelist and message content extraction. Updated response handling to perform anti-injection checks before reply generation, and removed skip list refresh logic from the plugin manager.
This commit is contained in:
雅诺狐
2025-08-22 15:48:21 +08:00
parent 08755ae7d1
commit 8d8d9fbda1
10 changed files with 301 additions and 486 deletions

View File

@@ -13,7 +13,6 @@ from src.plugin_system.base.plugin_base import PluginBase
from src.plugin_system.base.component_types import ComponentType
from src.plugin_system.utils.manifest_utils import VersionComparator
from .component_registry import component_registry
from src.chat.antipromptinjector.processors.command_skip_list import skip_list_manager
logger = get_logger("plugin_manager")
@@ -86,9 +85,6 @@ class PluginManager:
self._show_stats(total_registered, total_failed_registration)
# 插件加载完成后,刷新反注入跳过列表
self._refresh_anti_injection_skip_list()
return total_registered, total_failed_registration
def load_registered_plugin_classes(self, plugin_name: str) -> Tuple[bool, int]:
@@ -594,20 +590,6 @@ class PluginManager:
logger.debug("详细错误信息: ", exc_info=True)
return False
def _refresh_anti_injection_skip_list(self):
"""插件加载完成后刷新反注入跳过列表"""
try:
try:
loop = asyncio.get_running_loop()
# 在后台任务中执行刷新
loop.create_task(skip_list_manager.refresh_plugin_commands())
logger.debug("已触发反注入跳过列表刷新")
except RuntimeError:
# 没有运行的事件循环,稍后刷新
logger.debug("当前无事件循环,反注入跳过列表将在首次使用时刷新")
except Exception as e:
logger.warning(f"刷新反注入跳过列表失败: {e}")
# 全局插件管理器实例
plugin_manager = PluginManager()