"""Pydantic Settings — 配置管理。"""
from __future__ import annotations
from pydantic import Field, field_validator
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
app_name: str = "MoFix Backend"
app_version: str = "0.2.1"
port: int = 18003
host: str = "0.0.0.0"
anthropic_auth_token: str = ""
anthropic_base_url: str = ""
anthropic_model: str = ""
anthropic_request_timeout: float = 0.0
llm_max_tokens: int = 8192
chat_stream_max_seconds: float = 0.0
chat_stream_idle_timeout_seconds: float = 0.0
chat_stream_command_max_seconds: float = 0.0
direct_command_resume_ttl_seconds: float = Field(default=24 * 3600.0, gt=0)
hw_access_key_id: str = ""
hw_secret_access_key: str = ""
hw_region: str = ""
hw_lts_project_id: str = ""
hw_lts_log_group_id: str = ""
hw_lts_log_stream_id: str = ""
claude_allowed_tools: list[str] = ["Bash", "Read", "Edit", "Write", "Glob", "Grep"]
claude_permission_mode: str = "auto"
agent_workspace_root: str = ""
workflow_llm_model: str = ""
workflow_max_steps: int = 6
workflow_max_concurrency: int = 3
workflow_checkpoint_dir: str = ""
workflow_verify_enabled: bool = True
workflow_mcp_tool_timeout_seconds: int = Field(default=6 * 3600, gt=0)
workflow_claude_skill_timeout_seconds: int = Field(default=6 * 3600, gt=0)
workflow_skill_timeout_seconds: float = Field(default=6 * 3600.0, gt=0)
adapt_startup_timeout: float = Field(default=3600.0, gt=0)
deploy_timeout: int = Field(default=3600, gt=0)
claude_skill_log_dir: str = ""
workflow_sandbox_untrusted_steps: bool = False
workflow_dashboard_enabled: bool = True
@field_validator("workflow_dashboard_enabled", mode="before")
@classmethod
def _dashboard_flag_defaults_to_enabled(cls, value):
from app.model_agent.dashboard.config import dashboard_enabled
if value is None:
return True
if isinstance(value, str):
return dashboard_enabled()
return value
workflow_dashboard_host: str = "127.0.0.1"
workflow_dashboard_http_port: int = 9300
workflow_dashboard_ws_port: int = 9301
workflow_dashboard_token: str = ""
workflow_dashboard_ws_connect: str = ""
workflow_dashboard_max_snapshot: int = Field(default=500, gt=0)
workflow_dashboard_history_dir: str = ""
mcp_servers: list[dict] = [
{
"name": "cannbot",
"transport": "stdio",
"command": "python3",
"args": ["-m", "app.tools.mcp_servers.cannbot_server"],
"enabled": True,
"timeout": 300,
},
{
"name": "ms_agent",
"transport": "stdio",
"command": "python3",
"args": ["-m", "app.tools.mcp_servers.ms_agent_server"],
"enabled": True,
"timeout": 300,
},
]
mcp_auto_start: bool = True
hermes_enabled: bool = True
hermes_data_dir: str = ""
hermes_memory_capacity: int = 500
hermes_skill_capacity: int = 50
hermes_insight_capacity: int = 200
hermes_nudge_interval: int = 3600
claude_history_enabled: bool = False
claude_history_project_dir: str = ""
claude_history_upload_url: str = ""
model_agent_eval_enabled: bool = False
model_agent_eval_path: str = ""
model_agent_eval_no_llm: bool = True
model_agent_eval_pass_threshold: float = 60.0
model_agent_eval_veto_dimensions: list[str] = ["internal_error_exposure"]
realtime_eval_enabled: bool = True
realtime_eval_core_path: str = ""
realtime_eval_llm_enabled: bool = False
realtime_eval_llm_api_key: str = ""
realtime_eval_llm_base_url: str = ""
realtime_eval_llm_model: str = ""
realtime_eval_llm_rate_limit_rpm: int = 0
realtime_eval_report_url: str = ""
realtime_eval_report_token: str = ""
realtime_eval_report_timeout_seconds: float = 5.0
realtime_eval_report_max_attempts: int = 2
realtime_eval_report_retry_backoff_seconds: float = 1.0
realtime_eval_container_id: str = ""
realtime_eval_history_max_messages: int = 40
realtime_eval_progress_interval_seconds: float = 5.0
atomgit_user_token: str = ""
gitcode_token: str = ""
realtime_eval_expected_user_id: str = ""
request_replay_ttl_seconds: int = 7200
request_replay_max_entries: int = 20000
request_replay_max_response_bytes: int = 4 * 1024 * 1024
request_replay_max_total_response_bytes: int = 64 * 1024 * 1024
request_replay_max_chunks: int = 20000
model_config = SettingsConfigDict(
env_file=".env",
env_file_encoding="utf-8",
extra="ignore",
)
settings = Settings()