- 天工阁域 domains/tiangong:backstage_tasks(委托包+验收标准+结果证据);有限分解(parent 链)与受控并行(各自后台 Run);子任务全终态级联父任务进入待验收;按证据 accept/reject - kernel.start_backstage_run(kind=background_task):loop 后台分支不占前台席位、与前台对话并行;断言放宽容纳无人物功能任务;结果只经回调回呈任务——无身份写入路径 - 叩心域 domains/kouxin:knocking_candidates(event/time_anchor/manual 触发 + 草稿 + 裁决快照);四约束裁决(总开关→静默窗口【本地时区判定】→24h 频率→预算),dispatch 未过 429 且快照留痕;候选默认不自动发送;expire_stale 过期推进不触碰缘契 - 辰正 domains/zhengchen:temporal_context() 复用 time_sense 计算核(快照/农历/季节),产出【时态感知】投影段接入镜树生成 prompt(客观时间语境,不附情绪臆测——守一纪律) - 退役:modules/goal_orchestrator|planner|perception|big_cycle、application/planning、services/governance|goal_persist、candidates 表链(imports 候选抽取 API 面)、goals/plans/agent_roster/perception_channels/big_cycles/旧候选表(迁移 009);前端 admin goals/plans/agents/perception/world 页与六组件;governance 只留 GenerationPreferences;admin 治理面收敛为司命+百工两枢;pivots 健康以域表计数重建 - 验收(test_m8_tiangong 五用例):后台任务无身份写入(记忆/魂籍/缘契零新增);后台与前台并行;分解级联;叩心四约束逐项;不回应不降低关系(缘契维度/状态/版本零变化) - 四套件:后端 345、前端 203、BFF 4、神识 5 包全绿(2 个预存环境失败不变);迁移 009 净库干净
121 lines
7.5 KiB
Python
121 lines
7.5 KiB
Python
"""运行时与 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 类型
|
||
)
|