# Claude Trigger Router 完整配置示例 # 这是偏进阶的参考模板,不是新用户的最小起步配置。 # 如果你是首次使用,优先运行 `ctr setup`,或先参考 README 中的最小配置。 # 复制到 ~/.claude-trigger-router/config.yaml 后,先替换 API Key 和模型名。 # # 常见 provider preset(与 `ctr setup` 保持一致): # - openrouter: https://openrouter.ai/api/v1/chat/completions # - deepseek: https://api.deepseek.com/chat/completions # - openai-compatible: https://api.openai.com/v1/chat/completions # - anthropic: https://api.anthropic.com/v1/messages # - siliconflow: https://api.siliconflow.cn/v1/chat/completions # - custom/local: 自定义兼容地址,例如 Ollama / vLLM / one-api HOST: "127.0.0.1" PORT: 5678 LOG: true LOG_LEVEL: "debug" # 1) Models:主入口。每个模型直接配置成一个可引用的接入项 Models: - id: sonnet api: "https://openrouter.ai/api/v1/chat/completions" key: "sk-xxx" interface: "openai" model: "anthropic/claude-sonnet-4" thinking: "auto" metadata: context_window_tokens: 200000 safe_input_tokens: 180000 - id: opus api: "https://openrouter.ai/api/v1/chat/completions" key: "sk-xxx" interface: "openai" model: "anthropic/claude-opus-4" metadata: context_window_tokens: 200000 safe_input_tokens: 180000 - id: deepseek_reasoner api: "https://api.deepseek.com/chat/completions" key: "sk-xxx" interface: "openai" model: "deepseek-reasoner" thinking: "high" metadata: context_window_tokens: 64000 safe_input_tokens: 56000 - id: ollama_qwen api: "http://localhost:11434/v1/chat/completions" key: "ollama" interface: "openai" model: "qwen2.5-coder:latest" thinking: "off" # 2) Router:基础路由,统一直接引用 model id Router: default: "sonnet" background: "ollama_qwen" think: "deepseek_reasoner" longContext: "opus" longContextThreshold: 60000 webSearch: "sonnet" # 3) SmartRouter:统一路由入口。先走高确定性规则,再用候选模型智能兜底 SmartRouter: enabled: true analysis_scope: "last_message" rules: - name: "architecture" priority: 90 enabled: true description: "架构设计与系统方案任务" patterns: - type: exact keywords: - "架构设计" - "系统设计" - "技术方案" - "architecture" - "system design" - type: regex pattern: "(架构|系统设计|技术方案)" model: "opus" - name: "code_review" priority: 80 enabled: true description: "代码审查与风险评估任务" patterns: - type: exact keywords: - "代码审查" - "code review" - "review code" - "检查代码" - type: regex pattern: "(代码|code).{0,5}(审查|review|检查|审核)" model: "sonnet" - name: "complex_reasoning" priority: 70 enabled: true description: "复杂推理与严谨分析任务" patterns: - type: exact keywords: - "深入分析" - "复杂推理" - "逻辑推理" - "deep analysis" - "reasoning" - type: regex pattern: "(深入|复杂|详细).{0,5}(分析|推理|解析)" model: "deepseek_reasoner" - name: "simple_task" priority: 10 enabled: true description: "快速简单任务" patterns: - type: exact keywords: - "快速" - "简单" - "quick" - "simple" model: "ollama_qwen" router_model: "sonnet" candidates: - model: "sonnet" description: "通用编程、代码生成、日常调试、多轮对话" - model: "deepseek_reasoner" description: "复杂推理、逻辑分析、需要严谨思考的任务" - model: "opus" description: "架构设计、系统规划、长文档与复杂评审任务" cache_ttl: 600000 max_tokens: 256 fallback: "default" sticky: enabled: true session_ttl_ms: 3600000 fingerprint_similarity_threshold: 0.82 break_on_explicit_route: true # Alignment 为显式开启项:Claude Code 已经携带会话上下文。 # 只有跨模型交接摘要值得额外一次调用成本时再开启。 alignment: enabled: true summarizer_model: "sonnet" max_summary_tokens: 256 semantic: enabled: true mode: "embedding" threshold: 0.2 prototypes: architecture: "重构 系统 结构 模块 拆分 架构 设计" code_review: "代码 审查 风险 评审 review" complex_reasoning: "复杂 推理 分析 严谨 逻辑 reasoning" # 4) Governance:保留响应治理、级联与观测能力;semantic / sticky 已归入 SmartRouter Governance: enabled: true cascade: enabled: true max_attempts: 2 triggers: compile_failure: true test_failure: true placeholder_patterns: - "TODO" - "...rest of code" - "placeholder" levels: - from: "sonnet" to: "opus" reasoning: "high" shadow: enabled: true mode: "async_audit" verifier_model: "sonnet" sample_rate: 0.2 checks: placeholder_patterns: true length_anomaly: true missing_code_block: true observability: anomaly_thresholds: min_sample_size: 3 cascade_warn_rate: 0.4 cascade_critical_rate: 0.6 shadow_warn_rate: 0.5 shadow_critical_rate: 0.7 latency_warn_ms: 1500 latency_critical_ms: 3000 spike_warn_rate: 0.5 spike_delta_rate: 0.3 # 5) Legacy 兼容:旧 `Providers` 仅作为兼容层保留,不建议新配置继续扩展 # Providers: # - name: openrouter # api_base_url: "https://openrouter.ai/api/v1/chat/completions" # api_key: "sk-xxx" # models: # - "anthropic/claude-sonnet-4" # transformer: # use: ["openrouter"]