mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-04 23:17:20 +08:00
refactor: inject plugin interaction event publisher
This commit is contained in:
+2
-4
@@ -13,8 +13,8 @@
|
||||
"runtime_to_db": [],
|
||||
"workflow_to_db": []
|
||||
},
|
||||
"edge_count": 6547,
|
||||
"edge_sha256": "66726be779aae9069c32e8ccba1e7371eb99cfcc459666bc9805ddc25061ac63",
|
||||
"edge_count": 6545,
|
||||
"edge_sha256": "e74daad54d04652df3946334297eac0dd9a4560ca87f84365b25dc9f553436da",
|
||||
"edges": [
|
||||
"app -> app.runtime",
|
||||
"app -> app.runtime.compat",
|
||||
@@ -2651,8 +2651,6 @@
|
||||
"app.application.messaging.plugin -> app.application",
|
||||
"app.application.messaging.plugin -> app.application.messaging",
|
||||
"app.application.messaging.plugin -> app.application.messaging.interaction",
|
||||
"app.application.messaging.plugin -> app.runtime",
|
||||
"app.application.messaging.plugin -> app.runtime.events",
|
||||
"app.application.messaging.plugin -> app.schemas",
|
||||
"app.application.messaging.plugin -> app.schemas.message",
|
||||
"app.application.messaging.plugin -> app.schemas.types",
|
||||
|
||||
@@ -1221,6 +1221,17 @@ def test_host_consumers_use_agent_audio_capability_application_port():
|
||||
assert violations == {}
|
||||
|
||||
|
||||
def test_application_services_do_not_resolve_event_manager_singleton():
|
||||
"""Application 服务必须接收事件端口,不得自行定位进程级事件单例。"""
|
||||
violations = {
|
||||
module_name: dependencies & {"app.runtime.events"}
|
||||
for module_name, dependencies in _build_module_graph().items()
|
||||
if module_name.startswith("app.application")
|
||||
and "app.runtime.events" in dependencies
|
||||
}
|
||||
assert violations == {}
|
||||
|
||||
|
||||
def test_agent_tools_do_not_import_entrypoint_internals():
|
||||
"""Agent 工具不得穿透导入 HTTP 端点、调度器与命令注册表内部实现。
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ from app.application.messaging.plugin import (
|
||||
PluginInputInteractionHandler,
|
||||
plugin_input_interaction_manager,
|
||||
)
|
||||
from app.schemas import IncomingMessage, TransferDirectoryConf
|
||||
from app.schemas import IncomingMessage, TransferDirectoryConf # pylint: disable=no-name-in-module
|
||||
from app.schemas.types import EventType, MediaSource, MediaType, NotificationChannel
|
||||
|
||||
|
||||
@@ -531,7 +531,10 @@ def test_plugin_input_session_ignores_none_text_messages():
|
||||
)
|
||||
image = IncomingMessage.MessageImage(ref="https://example.invalid/image.jpg")
|
||||
|
||||
handled = PluginInputInteractionHandler(messenger=chain).handle_text(
|
||||
handled = PluginInputInteractionHandler(
|
||||
messenger=chain,
|
||||
event_publisher=chain.eventmanager,
|
||||
).handle_text(
|
||||
context=InteractionContext(
|
||||
channel=NotificationChannel.Telegram,
|
||||
source="telegram-test",
|
||||
|
||||
@@ -7,10 +7,14 @@ from types import SimpleNamespace
|
||||
from unittest.mock import AsyncMock, Mock, patch
|
||||
|
||||
|
||||
from app.agent import AgentManager, _MessageTask, _async_start_processing_status
|
||||
from app.agent import ( # pylint: disable=no-name-in-module
|
||||
AgentManager,
|
||||
_MessageTask,
|
||||
_async_start_processing_status,
|
||||
)
|
||||
from app.chain.message import MessageChain
|
||||
from app.command import Command, _finish_command_processing_status
|
||||
from app.modules.telegram import TelegramModule
|
||||
from app.modules.telegram import TelegramModule # pylint: disable=no-name-in-module
|
||||
from app.modules.telegram.telegram import Telegram
|
||||
from app.runtime.config import global_vars
|
||||
from app.schemas.types import NotificationChannel
|
||||
@@ -259,6 +263,7 @@ class TestTelegramTypingLifecycle(unittest.TestCase):
|
||||
|
||||
def test_async_agent_leaves_processing_status_to_worker(self):
|
||||
chain = MessageChain.__new__(MessageChain)
|
||||
chain.eventmanager = Mock()
|
||||
chain.runtime_config = replace(
|
||||
chain.runtime_config,
|
||||
ai_agent_enable=True,
|
||||
@@ -373,6 +378,7 @@ class TestTelegramTypingLifecycle(unittest.TestCase):
|
||||
|
||||
def test_callback_stops_typing_when_message_handler_returns(self):
|
||||
chain = MessageChain.__new__(MessageChain)
|
||||
chain.eventmanager = Mock()
|
||||
status = MessageChain._ProcessingStatus(
|
||||
channel=NotificationChannel.Telegram,
|
||||
source="telegram-test",
|
||||
|
||||
Reference in New Issue
Block a user