Files
NebulaShell/oss/plugin/manager.py
Falck 3a096f59a9 重构:核心迁移至 oss/core + NBPF 多重签名加密 + NIR 编译器 + README 全面升级
- 核心功能从 store/ 迁移至 oss/core/ 框架层
- 实现 NBPF 包格式:多重签名(Ed25519+RSA-PSS+HMAC)+ 多重加密(AES-256-GCM)
- 实现 NIR 编译器:基于 compile()+marshal 的跨平台中间表示
- 新增 nebula nbpf CLI 命令组(pack/unpack/verify/sign/keygen)
- 新增 19 个 NBPF 测试用例,覆盖全链路
- 彻底重写 README,大型项目标准框架风格,所有图表使用 SVG
- 更新 LICENSE 版权声明
- 清理旧版 store 插件目录(已迁移至 oss/core)
2026-05-05 07:29:43 +08:00

83 lines
2.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""插件管理器 - 直接使用框架层的 Core Engine"""
from typing import Any, Optional
from oss.core.engine import PluginManager as CorePluginManager
# 深度隐藏的成就系统导入
try:
from oss.core.achievements import get_validator
_ACHIEVEMENTS_ENABLED = True
except ImportError:
_ACHIEVEMENTS_ENABLED = False
class PluginManager:
"""极简插件管理器
直接使用框架层的 CorePluginManager原 Core 插件功能)
- 不再通过插件加载器加载 Core
- 所有核心功能直接集成在 oss.core.engine 中
"""
def __init__(self):
self.core = CorePluginManager()
def load(self):
"""加载所有插件(由 CorePluginManager 管理)"""
self.core.load_all()
# 隐藏成就:深海潜水员
if _ACHIEVEMENTS_ENABLED:
try:
validator = get_validator()
validator.unlock("deep_diver")
except Exception:
pass
def start(self):
"""启动 Core它会初始化并启动所有其他插件"""
import time
start_time = time.time()
self.core.init_and_start_all()
# 启动 HTTP 服务
self.core.start_http_server()
# 启动防篡改监控
self.core.start_tamper_monitor()
# 计算启动时间并检查速度成就
elapsed_ms = (time.time() - start_time) * 1000
if _ACHIEVEMENTS_ENABLED:
try:
validator = get_validator()
validator.check_startup_speed(elapsed_ms)
# 检查插件数量成就
plugin_count = len(self.core.plugins)
validator.check_plugin_count(plugin_count)
except Exception:
pass
def stop(self):
"""停止所有插件"""
try:
self.core.stop_tamper_monitor()
self.core.stop_http_server()
self.core.stop_all()
except KeyboardInterrupt:
print("[PluginManager] 用户中断停止过程")
except Exception as e:
import traceback
print(f"[PluginManager] 停止插件时出错:{type(e).__name__}: {e}")
traceback.print_exc()
# 隐藏成就:崩溃幸存者
if _ACHIEVEMENTS_ENABLED:
try:
validator = get_validator()
validator.track_progress("session_end")
except Exception:
pass