feat: 集成新版本插件运行时,支持事件桥接与命令处理

This commit is contained in:
DrSmoothl
2026-03-06 16:37:56 +08:00
parent d5cf4c9b8b
commit baae2df154
15 changed files with 385 additions and 25 deletions

View File

@@ -6,7 +6,7 @@ Host 端实现的能力服务,处理来自插件的 cap.* 请求。
from typing import Any, Callable, Awaitable
import logging
from src.common.logger import get_logger
from src.plugin_runtime.protocol.envelope import (
CapabilityRequestPayload,
@@ -16,7 +16,7 @@ from src.plugin_runtime.protocol.envelope import (
from src.plugin_runtime.protocol.errors import ErrorCode, RPCError
from src.plugin_runtime.host.policy_engine import PolicyEngine
logger = logging.getLogger("plugin_runtime.host.capability_service")
logger = get_logger("plugin_runtime.host.capability_service")
# 能力实现函数类型: (plugin_id, capability, args) -> result
CapabilityImpl = Callable[[str, str, dict[str, Any]], Awaitable[Any]]

View File

@@ -11,10 +11,10 @@
from typing import Any
import logging
from src.common.logger import get_logger
import re
logger = logging.getLogger("plugin_runtime.host.component_registry")
logger = get_logger("plugin_runtime.host.component_registry")
class RegisteredComponent:

View File

@@ -10,11 +10,11 @@
from typing import Any, Awaitable, Callable
import asyncio
import logging
from src.common.logger import get_logger
from src.plugin_runtime.host.component_registry import ComponentRegistry, RegisteredComponent
logger = logging.getLogger("plugin_runtime.host.event_dispatcher")
logger = get_logger("plugin_runtime.host.event_dispatcher")
# invoke_fn 类型: async (plugin_id, component_name, args) -> response_payload dict
InvokeFn = Callable[[str, str, dict[str, Any]], Awaitable[dict[str, Any]]]

View File

@@ -10,9 +10,9 @@
from typing import Any, Callable, Awaitable
import asyncio
import logging
import secrets
from src.common.logger import get_logger
from src.plugin_runtime.protocol.codec import Codec, MsgPackCodec
from src.plugin_runtime.protocol.envelope import (
PROTOCOL_VERSION,
@@ -27,7 +27,7 @@ from src.plugin_runtime.protocol.envelope import (
from src.plugin_runtime.protocol.errors import ErrorCode, RPCError
from src.plugin_runtime.transport.base import Connection, TransportServer
logger = logging.getLogger("plugin_runtime.host.rpc_server")
logger = get_logger("plugin_runtime.host.rpc_server")
# RPC 方法处理器类型
MethodHandler = Callable[[Envelope], Awaitable[Envelope]]

View File

@@ -10,10 +10,10 @@
from typing import Any
import asyncio
import logging
import os
import sys
from src.common.logger import get_logger
from src.plugin_runtime.host.capability_service import CapabilityService
from src.plugin_runtime.host.component_registry import ComponentRegistry
from src.plugin_runtime.host.event_dispatcher import EventDispatcher
@@ -29,7 +29,7 @@ from src.plugin_runtime.protocol.envelope import (
from src.plugin_runtime.protocol.errors import ErrorCode, RPCError
from src.plugin_runtime.transport.factory import create_transport_server
logger = logging.getLogger("plugin_runtime.host.supervisor")
logger = get_logger("plugin_runtime.host.supervisor")
class PluginSupervisor:

View File

@@ -20,13 +20,13 @@
from typing import Any, Awaitable, Callable
import asyncio
import logging
import time
import uuid
from src.common.logger import get_logger
from src.plugin_runtime.host.component_registry import ComponentRegistry, RegisteredComponent
logger = logging.getLogger("plugin_runtime.host.workflow_executor")
logger = get_logger("plugin_runtime.host.workflow_executor")
# 阶段顺序
STAGE_SEQUENCE: list[str] = [