"""运行时与 SSE 配置:事件流、超时、工具运行时开关等。""" from __future__ import annotations from pydantic_settings import BaseSettings class RuntimeConfig(BaseSettings): """SSE / 运行时 / 工具运行时配置。""" # ==================== SSE 配置 ==================== enable_sse: bool = True # 是否启用 SSE max_text_message_bytes: int = 32768 # 最大文本消息字节数 sse_poll_interval_seconds: float = 0.01 # SSE 轮询间隔(秒,10ms:前端逐段平滑增量) sse_heartbeat_seconds: float = 15.0 # SSE 心跳间隔(秒) run_timeout_seconds: int = 120 # 运行超时时间(秒) # ==================== 神识(模型网关,rewrite/1.0) ==================== shenshi_base_url: str = "" # 神识服务地址;为空时 Kernel 使用进程内回声桩(M0 骨架) shenshi_service_token: str = "" # 灵台→神识服务令牌(开发档可空) shenshi_timeout_seconds: float = 120.0 # 神识流式调用超时(秒) # ==================== 镜生域(rewrite/1.0 M1) ==================== identity_record_secret: str = "dev-identity-secret" # 魂籍签名密钥;正式部署必须改掉默认值 death_calm_period_hours: int = 72 # 死亡冷静期时长(小时),期内可撤销 seat_lease_ttl_seconds: int = 60 # 命台租约 TTL(秒) # Agent 循环最大轮数:模型每轮仍带工具调用则继续,超限截断返回(见 agent.runtime.DEFAULT_MAX_ITERATIONS) agent_max_iterations: int = 8 # 单次高风险工具确认挂起超时(秒):须小于 run_timeout_seconds,超时按拒绝处理; # 若 >= run_timeout_seconds,run 整体超时会先到,导致确认中的 run 直接 failed confirmation_timeout_seconds: int = 60 # 是否启用数据库持久化的确认存储(用于多 worker 部署);关闭则使用进程内 InMemoryConfirmationStore(默认) use_db_confirmation_store: bool = False run_max_events: int = 1000 # 最大事件数 event_payload_max_bytes: int = 65536 # 事件负载最大字节数 memory_injection_limit: int = 5 # 记忆注入条数上限 # ==================== 工具运行时配置 ==================== enable_tool_runtime: bool = True # 是否启用百工工具运行时(司命 + 沙箱) tool_timeout_seconds: int = 600 # 单个工具调用超时秒数 # ==================== 洛书规划器 ==================== enable_deliberative_planning: bool = False # 是否启用显式多步规划(§10.2 增强能力) # ==================== 大周天(长期演化循环) ==================== enable_big_cycle: bool = True # 是否启用大周天自动触发 big_cycle_memory_threshold: int = 20 # 触发大周天的记忆数阈值 big_cycle_min_interval_seconds: int = 300 # 两次大周天最小间隔(秒),避免频繁触发 big_cycle_model: str = "deepseek-v4-flash" # 大周天候选生成所用模型(models.yaml name 或 tag) big_cycle_max_candidates: int = 10 # 单次大周天生成的演化候选上限 big_cycle_token_budget: int = 64000 # 单次大周天的 token 预算上限(超限跳过非关键阶段) big_cycle_max_drift: float = 2.0 # 最大累积漂移值(超过后暂停自动演化) big_cycle_drift_threshold: float = 0.6 # 单次演化候选的漂移阈值(>= 此值不自动应用) # ==================== 内驱力(太一枢)[PLANNED] ==================== enable_intrinsic_drive: bool = False # 是否启用内驱力扫描(curiosity / exploration) drive_scan_interval_seconds: int = 3600 # 内驱力扫描间隔秒数 drive_max_curiosity_per_scan: int = 5 # 单次扫描最多好奇问题数 drive_allow_interrupt: bool = False # 是否允许内驱力中断当前任务 # ==================== 司命安全策略 ==================== # 工具策略 YAML 路径(相对 backend);未配置时 SafetyGovernor 使用内置默认空策略。 safety_policy_path: str = "" safety_always_confirm_high_risk: bool = True # 高风险动作是否总是确认 # ==================== MCP / 联网工具网络超时 ==================== mcp_list_timeout_seconds: float = 10.0 # MCP tools/list 请求超时(秒) mcp_call_timeout_seconds: float = 30.0 # MCP tools/call 请求超时(秒) tool_web_http_timeout_seconds: float = 15.0 # fetch_url 的 HTTP 超时(秒) # ==================== MCP stdio 子进程 ==================== mcp_stdio_start_timeout_seconds: float = 15.0 # stdio 子进程启动超时(秒) mcp_stdio_call_timeout_seconds: float = 30.0 # stdio 单次 tools/call 超时(秒) mcp_stdio_stop_timeout_seconds: float = 5.0 # SIGTERM → SIGKILL 等待(秒) # ==================== 向量记忆检索 ==================== vector_db_enabled: bool = False # 是否启用向量数据库(关则纯 SQL 检索) vector_db_type: str = "chroma" # 向量库类型:chroma / milvus chromadb_host: str = "" # ChromaDB HTTP 主机(空则内存模式) chromadb_port: int = 8000 # ChromaDB HTTP 端口 chroma_collection: str = "hunjing_memories" # ChromaDB collection 名 chroma_persist_directory: str = "../db/chroma" # ChromaDB 持久化目录(相对 backend) embedding_model_hint: str = "bge-m3" # embedding 模型逻辑名 # 叩心约束(PRD §6.6:总开关/静默窗口/频率/预算;候选默认不自动发送) knocking_enabled: bool = True knocking_quiet_start: str = "23:00" # HH:MM(本地时区) knocking_quiet_end: str = "07:00" knocking_daily_limit: int = 3 # 24 小时派发上限 knocking_timezone: str = "Asia/Shanghai" # 静默窗口判定时区 knocking_budget_total: int = 0 # 累计预算(0=不限) # 元炁本地推理引擎(ASR 语音转写;未配置=多模态关闭,文字链路不受影响) yuanqi_base_url: str = "" yuanqi_asr_model: str = "iic/SenseVoiceSmall" # ==================== 自动记忆候选 [PLANNED] ==================== enable_memory_candidates: bool = False # 是否启用自动记忆候选抽取 memory_candidate_min_importance: float = 0.7 # 候选记忆重要性阈值(0.0~1.0) # ==================== 审计日志(司命枢·起居注)[PLANNED] ==================== enable_audit_log: bool = True # 是否启用审计日志 # ==================== 感知(烛照枢)[PLANNED] ==================== enable_camera: bool = False # 是否启用摄像头(视觉感知) enable_microphone: bool = False # 是否启用麦克风(听觉感知) perception_save_raw_media: bool = False # 是否保存原始感知文件 perception_max_media_mb: int = 20 # 感知文件最大大小(MB) # ==================== 语音服务 [PLANNED] ==================== enable_asr: bool = False # 是否启用 ASR(语音转文字) enable_tts: bool = False # 是否启用 TTS(文字转语音) enable_voice_training: bool = False # 是否启用语音训练(微调 TTS 音色) enable_voice_chat: bool = False # 是否启用实时语音对话 # ==================== 导入限制 [PLANNED] ==================== import_max_file_mb: int = 20 # 人物资料导入文件最大大小(MB) import_audio_max_duration_seconds: int = 600 # 语音样本最大时长(秒) import_allowed_audio_mime_types: str = ( "audio/wav,audio/mpeg,audio/mp4,audio/flac" # 允许上传的语音样本 MIME 类型 )