refactor: unify agent data port access

This commit is contained in:
jxxghp
2026-08-24 04:56:11 +08:00
parent c8ad54a190
commit ae38e61880
37 changed files with 217 additions and 87 deletions
+4 -4
View File
@@ -79,8 +79,8 @@ from app.application.plugin.runtime import get_plugin_manager
def _get_plugin_tools_revision() -> int:
"""读取插件工具目录修订号,避免 Agent 编排依赖具体管理器类型。"""
return get_plugin_manager().get_plugin_agent_tools_revision()
from app.application.agentdata import AgentTaskPort as AgentTaskOper
from app.application.agentdata import UserPort as UserOper
from app.application.agentdata import get_agent_task_port
from app.application.agentdata import get_agent_user_port
from app.application.messaging.chat import (
get_configured_agent_chat_service,
get_configured_agent_chat_persistence,
@@ -977,7 +977,7 @@ class MoviePilotAgent:
if not self.username:
return False
try:
user = await UserOper().async_get_by_name(self.username)
user = await get_agent_user_port().async_get_by_name(self.username)
except Exception as e:
logger.error(f"检查 Agent 用户管理员身份失败: {e}")
return False
@@ -3514,7 +3514,7 @@ class AgentManager:
"""
if not settings.AI_AGENT_ENABLE:
return False, "AI Agent 未启用"
oper = AgentTaskOper()
oper = get_agent_task_port()
task = oper.get(task_id)
if not task or not task.enabled:
return False, "Agent 定时任务不存在或已停用"