refactor: route agent settings tools through runtime

This commit is contained in:
jxxghp
2026-08-23 02:38:39 +08:00
parent ca66b39b7e
commit e17e83bca3
6 changed files with 12 additions and 13 deletions
@@ -15,10 +15,10 @@ from app.agent.tools.impl._system_setting_utils import (
resolve_setting_spec,
should_redact_setting,
)
from app.runtime.config import settings
from app.application.configuration import (
SystemConfigReader,
get_configured_system_config as SystemConfigOper,
get_runtime_settings,
)
from app.runtime.log import logger
@@ -128,7 +128,7 @@ class QuerySystemSettingsTool(MoviePilotTool):
def _load_setting_value(self, spec: SettingSpec):
"""读取指定设置项的当前值。"""
if spec.source == "settings":
return getattr(settings, spec.key)
return get_runtime_settings().get(spec.key)
return self._get_system_config().get(spec.systemconfig_key)
@staticmethod
@@ -16,11 +16,11 @@ from app.agent.tools.impl._system_setting_utils import (
resolve_setting_spec,
should_redact_setting,
)
from app.runtime.config import settings
from app.runtime.events import eventmanager
from app.application.configuration import (
SystemConfigService,
get_configured_system_config as SystemConfigOper,
get_runtime_settings,
)
from app.runtime.log import logger
from app.schemas.event import ConfigChangeEventData
@@ -126,7 +126,7 @@ class UpdateSystemSettingsTool(MoviePilotTool):
def _load_setting_value(self, spec: SettingSpec):
"""读取指定设置项的当前值。"""
if spec.source == "settings":
return getattr(settings, spec.key)
return get_runtime_settings().get(spec.key)
return self._get_system_config().get(spec.systemconfig_key)
@staticmethod
@@ -274,7 +274,7 @@ class UpdateSystemSettingsTool(MoviePilotTool):
changed = False
message = ""
if spec.source == "settings":
success, message = settings.update_setting(spec.key, next_value)
success, message = get_runtime_settings().update(spec.key, next_value)
if success is False:
return json.dumps(
{
+1 -1
View File
@@ -284,7 +284,7 @@ class RuntimeSettingsService:
def update(self, key: str, value: Any) -> tuple[Optional[bool], str]:
"""更新单个部署设置。"""
return self._settings.update_setting(key=key, value=value)
return self._settings.update_setting(key, value)
class SystemConfigService:
@@ -1040,6 +1040,8 @@ runtime provider,旧插件或测试替换模块级 `settings` 时仍保持原
服务端和评分专项 184 项测试与 Pylint 通过,配置债务由 107 个文件降至 105 个文件。
用户模型的 `get_by_name``get_by_id` 同步查询改为显式 Session 执行,并以一次性短会话保留旧插件
无 Session ABI;用户查询与兼容专项 75 项测试、Pylint 及架构基线通过,查询装饰器由 119 个降至 117 个。
随后将 Agent 系统设置查询/更新工具切换到已装配的 `RuntimeSettingsService` 窄端口,保留工具构造和
设置更新返回 ABI;配置债务由 103 个文件降至 101 个文件,系统设置工具专项测试与架构基线通过。
同日修正适配器配置下沉边界:OCR、CookieCloud、DoH、Rust 和资源签名等低层实现不再直接依赖
`app.application`,由 `app.runtime.settings` 端口承接组合根注入;未启动装配时仍回退旧 Settings ABI
@@ -9,7 +9,7 @@
"root": "app"
},
"settings_imports": {
"count": 103,
"count": 101,
"files": [
"app/adapters/system/fsproxy.py",
"app/agent/capabilities/adapter.py",
@@ -26,13 +26,11 @@
"app/agent/tools/impl/add_download_tasks.py",
"app/agent/tools/impl/create_agent_task.py",
"app/agent/tools/impl/query_agent_tasks.py",
"app/agent/tools/impl/query_system_settings.py",
"app/agent/tools/impl/recognize_media.py",
"app/agent/tools/impl/scrape_metadata.py",
"app/agent/tools/impl/search_web.py",
"app/agent/tools/impl/send_voice_message.py",
"app/agent/tools/impl/update_agent_task.py",
"app/agent/tools/impl/update_system_settings.py",
"app/cli.py",
"app/db/base.py",
"app/db/engine.py",
+3 -4
View File
@@ -13,8 +13,8 @@
"runtime_to_db": [],
"workflow_to_db": []
},
"edge_count": 6421,
"edge_sha256": "889385bbfbe3634711d921dc76afe38bbfc3ea7c672663e67ae6453aad19af4c",
"edge_count": 6420,
"edge_sha256": "7c586d713c6014eb485763f8b7704d9421d95ba7d145910a33163dcb36882914",
"edges": [
"app -> app.runtime",
"app -> app.runtime.compat",
@@ -1096,7 +1096,6 @@
"app.agent.tools.impl.query_system_settings -> app.application",
"app.agent.tools.impl.query_system_settings -> app.application.configuration",
"app.agent.tools.impl.query_system_settings -> app.runtime",
"app.agent.tools.impl.query_system_settings -> app.runtime.config",
"app.agent.tools.impl.query_system_settings -> app.runtime.log",
"app.agent.tools.impl.query_transfer_history -> app.agent",
"app.agent.tools.impl.query_transfer_history -> app.agent.tools",
@@ -1469,7 +1468,6 @@
"app.agent.tools.impl.update_system_settings -> app.application",
"app.agent.tools.impl.update_system_settings -> app.application.configuration",
"app.agent.tools.impl.update_system_settings -> app.runtime",
"app.agent.tools.impl.update_system_settings -> app.runtime.config",
"app.agent.tools.impl.update_system_settings -> app.runtime.events",
"app.agent.tools.impl.update_system_settings -> app.runtime.log",
"app.agent.tools.impl.update_system_settings -> app.schemas",
@@ -3256,6 +3254,7 @@
"app.chain.subscribe -> app.application.configuration",
"app.chain.subscribe -> app.application.mediaserver",
"app.chain.subscribe -> app.application.messaging",
"app.chain.subscribe -> app.application.messaging.message",
"app.chain.subscribe -> app.application.messaging.subscribe",
"app.chain.subscribe -> app.application.subscription",
"app.chain.subscribe -> app.application.subscription.complete",