refactor: 收口 V3 分层架构与插件兼容边界

This commit is contained in:
jxxghp
2026-08-18 13:22:02 +08:00
parent cca99bd421
commit 8472bcff43
274 changed files with 10730 additions and 6130 deletions
+35
View File
@@ -0,0 +1,35 @@
"""插件运行时目录的应用层端口。"""
from __future__ import annotations
from collections.abc import Callable
from typing import Any, Protocol
class PluginRuntime(Protocol):
"""声明入口层消费的插件宿主能力。"""
def __getattr__(self, name: str) -> Any:
"""允许兼容门面按既有 V3 方法名访问插件宿主能力。"""
PluginRuntimeProvider = Callable[[], PluginRuntime]
def _unconfigured_runtime() -> PluginRuntime:
"""拒绝在启动组合根完成前隐式创建 Runtime 管理器。"""
raise RuntimeError("插件运行时尚未由启动组合根装配")
_runtime_provider: PluginRuntimeProvider = _unconfigured_runtime
def configure_plugin_runtime(provider: PluginRuntimeProvider) -> None:
"""由启动组合根注册插件运行时实例提供器。"""
global _runtime_provider
_runtime_provider = provider
def get_plugin_manager() -> PluginRuntime:
"""返回当前组合根提供的插件运行时能力。"""
return _runtime_provider()