# =============================================================================
# ClawBench Configuration Example / 配置示例
# =============================================================================
#
# All settings have sensible defaults — config/config.yaml is entirely optional.
# 所有配置项均有默认值，config/config.yaml 完全可选，无需配置即可启动。
#
# Without a config file:
# 无配置文件启动时：
#   - Password: auto-generated UUID, printed to console at startup
#     密码自动生成为 UUID，启动时打印到控制台
#   - File access: entire filesystem (Linux/macOS: /, Windows: all drives)
#     文件访问范围：整个文件系统（Linux/macOS: /, Windows: 所有盘符）
#   - Port: 20000, Proxy & SSH: enabled
#     端口: 20000，端口转发与 SSH 隧道: 默认启用
#
# Usage / 使用方法：
#   Linux/macOS:
#     1. (Optional) Copy this file as config.yaml: cp config/config.example.yaml config/config.yaml
#        （可选）复制此文件为 config.yaml：cp config/config.example.yaml config/config.yaml
#     2. Modify values to match your environment
#        根据实际情况修改配置项
#     3. Start the server: ./clawbench
#        启动服务：./clawbench
#   Windows:
#     1. (Optional) Copy this file as config.yaml: copy config\config.example.yaml config\config.yaml
#        （可选）复制此文件为 config.yaml：copy config\config.example.yaml config\config.yaml
#     2. Modify values to match your environment
#        根据实际情况修改配置项
#     3. Start the server: ./clawbench
#        启动服务：./clawbench
# =============================================================================

# Server port (default: 20000) / 服务端口（默认: 20000）
# port: 20000

# Bind address (default: "" = 0.0.0.0, all interfaces; "localhost" = 127.0.0.1 only)
# 绑定地址（默认: 空 = 0.0.0.0 所有接口; "localhost" = 仅 127.0.0.1）
# host: ""

# Log level: "debug", "info", "warn", "error" (default: "info")
# 日志级别：debug / info / warn / error（默认: info）
# log_level: "info"

# Access password (default: auto-generated UUID, printed to console at startup).
# 访问密码（默认：自动生成 UUID，启动时打印到控制台）
# It is strongly recommended to set a strong password for public deployments.
# 建议设置强密码保护服务安全。
# Uncomment to set a fixed password / 取消注释以设置固定密码
# password: "your-password-here"
# Password can also be set via Settings UI, which stores it as SHA-256 hash:
# 也可通过设置面板修改密码，将以 SHA-256 哈希存储：
# password: "sha256:<64-char-hex-hash>"

# Upload limits / 文件上传限制
# upload:
#   max_size_mb: 100   # Maximum single file upload size in MB (default: 100) / 单文件上传大小上限（MB，默认: 100）
#   max_files: 20      # Maximum number of files per upload (default: 20) / 单次上传文件数上限（默认: 20）

# TLS (HTTPS) configuration / TLS (HTTPS) 配置
# Strongly recommended for public deployments / 公网部署时强烈建议启用 HTTPS
# tls:
#   enabled: false     # Enable HTTPS; requires cert_file and key_file when true / 启用后需配置证书路径
#   # Linux/macOS example / Linux/macOS 示例：
#   cert_file: "/path/to/fullchain.pem"   # Certificate file, e.g. Let's Encrypt / 证书文件，如 Let's Encrypt
#   key_file: "/path/to/privkey.pem"      # Private key file / 私钥文件
#   # Windows example / Windows 示例：
#   # cert_file: "C:\certs\fullchain.pem"
#   # key_file: "C:\certs\privkey.pem"

# Chat UI settings / 聊天界面设置
# chat:
#   initial_messages: 20    # Number of messages loaded initially (default: 20) / 初始加载的消息条数（默认: 20）
#   page_size: 20           # Number of messages per lazy-load batch (default: 20) / 每次懒加载追加的消息条数（默认: 20）
#   system_prompt_interval: 10  # Re-inject system prompt every N assistant turns for CLI backends without --system-prompt (0=never, default: 10) / 每N轮助手回复重新注入系统提示词（0=不重注入，默认: 10）

# Session limit / 会话数量限制
# session:
#   max_count: 10  # Maximum chat sessions per project (default: 10) / 会话数量上限（默认: 10）

# Recent projects limit / 最近项目数量限制
# recent_projects:
#   max_count: 10  # Maximum recent projects shown in the header dropdown (default: 10) / 标题栏下拉显示的最近项目数量上限（默认: 10）

# TTS (Text-to-Speech) configuration / 语音合成配置
# Supported engines / 支持的引擎：
#   edge      — Microsoft Edge TTS, free and unlimited (default) / 微软 Edge TTS，免费无限制（默认）
#   piper     — Local offline, ultra-fast / 本地离线，极速
#   kokoro    — Local offline, high-quality Chinese / 本地离线，高质量中文
#   moss-nano — Local offline, multilingual, voice cloning / 本地离线，多语言，音色克隆
# Full installation & deployment guide: docs/TTS.md / 完整安装部署指南：docs/TTS.md
tts:
  engine: "edge"                                          # TTS engine / TTS引擎: "edge" (default/默认), "piper", "kokoro", "moss-nano"

  # --- Speed & Voice (shared across all engines) ---
  # --- 语速与音色（所有引擎共享） ---
  speed: 1                                             # Speed multiplier (1.0 = normal; edge auto-converts to % rate, e.g. 1.2 → +20%)
                                                       # 语速倍率（1.0=正常速度；edge 会转为百分比速率如 +0%）
  # voice: See engine-specific examples below / 见下方各引擎样例

  # --- Text Processing for TTS ---
  # --- TTS 文本处理 ---
  # inline_code_max_len: 100                            # Max inline code content length (runes) to preserve; longer code is removed (default: 100)
                                                       # 行内代码保留的最大字符数（rune）；超出则整段删除（默认: 100）
  # max_summarize_runes: 10000                          # Max runes for summarization input; longer text is truncated to the tail (default: 10000; simple mode: 1000)
                                                       # 总结输入的最大字符数；超出则截取尾部（默认: 10000；simple 模式: 1000）
  # max_cache_files: 100                               # Max cached TTS audio files to keep; oldest auto-deleted (-1=unlimited, default: 100)
                                                       # TTS 语音缓存文件最大数量；超出时自动删除最旧的（-1=不限，默认: 100）

  # ============================================================
  # TTS Engine + Summarization Backend Combination Examples
  # TTS引擎 + 总结后端 组合样例 —— 取消注释对应的一组即可
  # For installation instructions, see docs/TTS.md
  # 安装部署步骤请参阅 docs/TTS.md
  # ============================================================

  # --- Combo 1: Edge TTS + simple summarization (free, no AI summarizer needed) ---
  # --- 组合1: Edge TTS + simple总结（免费，无需AI总结） ---
  # engine: "edge"
  # voice: "zh-CN-XiaoxiaoNeural"                       # Voice ID / 音色ID
  # speed: 1

  # --- Combo 2: Piper (local offline, ultra-fast) ---
  # --- 组合2: Piper（本地离线，极速） ---
  # engine: "piper"
  # voice: "zh_CN-huayan-medium"
  # speed: 1
  # piper:
  #   model_path: ""
  #   noise_scale: 0.667
  #   length_scale: 1.0
  #   sentence_silence: 0.2

  # --- Combo 3: Kokoro (local offline, high-quality Chinese) ---
  # --- 组合3: Kokoro（本地离线，高质量中文） ---
  # engine: "kokoro"
  # voice: "zf_001"
  # speed: 1
  # kokoro:
  #   model_path: ""
  #   voices_path: ""
  #   lang: "cmn"

  # --- Combo 4: MOSS-TTS-Nano (local offline, multilingual) ---
  # --- 组合4: MOSS-TTS-Nano（本地离线，多语言） ---
  # engine: "moss-nano"
  # moss_nano:
  #   model_dir: ""
  #   backend: "onnx"

# Summarization configuration / 总结配置
# Shared by TTS voice summarization and scheduled task summarization.
# TTS 语音总结和定时任务总结共用。
# Backends / 总结后端：
#   "simple"    — Pure text cleaning only (default) / 纯文本清洗（默认），零延迟
#   "api"       — Remote AI API (OpenAI/Anthropic format) / 远程AI API（OpenAI/Anthropic格式）
#   ""         — Disabled, no summarization / 关闭，不生成摘要
#   "simple"   — Extract final answer (no AI call) / 提取最终回答（无 AI 调用）
#   "claude"    — Claude CLI / 使用 Claude CLI
#   "codebuddy" — CodeBuddy CLI / 使用 CodeBuddy CLI
#   "gemini"    — Gemini CLI / 使用 Gemini CLI
#   "opencode"  — OpenCode CLI / 使用 OpenCode CLI
#   "codex"     — Codex CLI / 使用 Codex CLI
#   "qoder"     — Qoder CLI (Alibaba) / 使用 Qoder CLI（阿里编码智能体）
#   "vecli"     — VeCLI (Volcengine Doubao) / 使用 VeCLI（火山引擎 Doubao）
#   "deepseek"  — CodeWhale (formerly DeepSeek TUI, requires v0.8.33+) / 使用 CodeWhale（原 DeepSeek TUI，需 v0.8.33+）
#   "pi"        — Pi CLI (minimalist coding agent) / 使用 Pi CLI（极简编程智能体）
summarize:
  backend: "simple"                                     # Summarization backend (default: "simple") / 总结后端（默认: simple）
  # model: ""                                           # Summarization model (leave empty for backend default) / 总结模型（留空使用后端默认）
  # API sub-config (only used when backend is "api") / API子配置（backend为api时使用）
  # api:
  #   base_url: "https://api.openai.com/v1/chat/completions"  # Full endpoint URL / 完整端点URL
  #   key: "sk-xxx"                                         # API key / API密钥
  #   format: "openai"                                      # "openai" (default) or "anthropic" / "openai"（默认）或 "anthropic"

# Default agent (optional; leave empty to use the first agent in database)
# 默认智能体（可选，留空则使用数据库中的第一个智能体）
# Available agents depend on your database / 可用智能体取决于数据库
default_agent: "codebuddy"

# Logging configuration (optional) / 日志配置（可选）
# Default: .clawbench/logs under the binary directory / 默认：二进制同级目录下的 .clawbench/logs/
log_dir: ".clawbench/logs"
log_max_days: 7            # Log retention in days (default/默认: 7) / 日志保留天数，默认 7

# SSH tunnel configuration for remote port forwarding
# SSH 隧道远程端口转发配置
# When enabled, Android app connects via SSH tunnel to access server local ports transparently.
# The proxy section has been merged into port_forward — proxy.enabled is no longer used.
# 启用后，Android App 通过 SSH 隧道访问服务器本地端口，对应用完全透明。
# 旧版 proxy 配置已合并到 port_forward，proxy.enabled 不再生效。
# Default: enabled / 默认：启用
port_forward:
  enabled: true             # Enable SSH tunnel server (default: true) / 启用 SSH 隧道服务（默认: true）
  port: 0                   # SSH port (0 = auto = main_port + 1, e.g. production 20001; or specify like 20020)
                            # SSH 端口（0 = 自动 = 主端口+1，如生产环境 20001；也可指定如 20020）
  host_key: ""              # Host key file path (empty = auto-generate ephemeral key; set a path for persistence across restarts)
                            # Host key 文件路径（空 = 自动生成临时密钥，重启后变更；建议指定路径以持久化）
  allowed_ports: ""  # Allowed port range for SSH tunnel forwarding (empty = allow all; supports ranges and discrete ports, e.g. "1024-65535", "80,443,8080")
                     # 允许通过 SSH 隧道转发的端口范围（空 = 允许所有端口；支持范围和离散端口，如 "1024-65535", "80,443,8080"）

# RAG history memory configuration / RAG 历史记忆配置
# When enabled, chat messages are automatically indexed into a vector database (DuckDB),
# and AI agents can search historical conversations via the RAG API.
# 启用后，聊天消息自动索引到向量数据库（DuckDB），AI 智能体可通过 RAG API 搜索历史对话。
# RAG history memory — always enabled. Without embedding API, uses FTS-only search.
# When embedding API is available, uses hybrid vector + FTS search with RRF fusion.
# RAG 历史记忆 — 始终启用。无嵌入 API 时使用纯全文检索。
# 嵌入 API 可用时，使用向量 + 全文混合检索（RRF 融合）。
# Compatible with any OpenAI /v1/embeddings endpoint: Ollama, vLLM, LM Studio, LocalAI,
# LiteLLM, OpenAI, Azure OpenAI, etc.
# 兼容任何 OpenAI /v1/embeddings 端点：Ollama、vLLM、LM Studio、LocalAI、LiteLLM、OpenAI、Azure OpenAI 等。
# Prerequisite for vector search: an embedding service must be running with the model loaded
# (e.g., for Ollama: ollama pull bge-m3)
# 向量搜索前提条件：嵌入服务需运行并加载模型（如 Ollama: ollama pull bge-m3）
# rag:
#   base_url: "http://localhost:11434"     # OpenAI-compatible API base URL / OpenAI 兼容 API 地址
#   model: "bge-m3"                        # Embedding model name / Embedding 模型名
#   api_key: ""                            # API key (optional, for cloud providers like OpenAI) / API 密钥（可选，云服务如 OpenAI 需要）
#   chunk_size: 512                        # Chunk size in tokens (default: 512) / 分块大小（token，默认: 512）
#   chunk_overlap: 64                      # Overlap between chunks in tokens (default: 64) / 分块重叠（token，默认: 64）
#   poll_interval: "10s"                   # Indexer poll interval (default: 10s) / 索引轮询间隔（默认: 10s）
#   batch_size: 10                         # Messages per indexer batch (default: 10) / 每轮索引消息数（默认: 10）
#   search_limit: 5                        # Default search result limit (default: 5) / 默认搜索结果数量（默认: 5）
#   search_pool_size: 20                   # RRF candidate pool size per source (default: 20) / RRF 候选池大小（默认: 20）
#   retention_days: 90                     # Soft-deleted data retention days, 0=keep forever (default: 90) / 软删除数据保留天数，0=永久保留（默认: 90）

# Terminal configuration / 终端配置
# Interactive web terminal with PTY + WebSocket + xterm.js
# 交互式 Web 终端，基于 PTY + WebSocket + xterm.js
# Default: enabled / 默认：启用
# terminal:
#   enabled: true             # Enable terminal (default: true) / 启用终端（默认: true）
#   idle_timeout: "0"        # Close PTY after no WS connections (default: "0" = never, e.g. "10m") / 无连接超时关闭（默认: "0" = 永不超时，如 "10m"）
#   buffer_lines: 2000        # Replay buffer line count (default: 2000) / 回放缓冲行数（默认: 2000）
#   max_line_bytes: 65536     # Per-line byte cap to prevent memory bloat (default: 64KB) / 单行字节上限（默认: 64KB）
#   max_buffer_mb: 4          # Total buffer memory cap in MB (default: 4) / 缓冲总内存上限 MB（默认: 4）
#   max_sessions: 10          # Max concurrent terminal sessions (default: 10) / 最大并发终端会话数（默认: 10）

# System events configuration (read-only, for reference) / 系统事件配置（只读参考）
# The EventBus provides real-time state-change notifications via SSE at GET /api/events.
# EventBus 通过 SSE 端点 GET /api/events 提供实时状态变更通知。
# No configuration needed — all values are hardcoded defaults / 无需配置 — 所有值为硬编码默认值：
#   - Max SSE subscribers: 20 (HTTP 429 when exceeded) / 最大 SSE 订阅数: 20（超出返回 HTTP 429）
#   - Per-subscriber channel buffer: 256 events / 每个订阅者通道缓冲: 256 个事件
#   - Heartbeat interval: 15 seconds / 心跳间隔: 15 秒
#   - Auth: cookie or ?token= query param (same as other /api/ endpoints) / 认证: cookie 或 ?token= 查询参数
#
# Event types / 事件类型:
#   session_start    — AI chat session begins / AI 对话会话开始
#   session_complete  — AI chat session ends (payload: reason: done/user_cancel/disconnect/cancelled/error) / 对话结束（reason 字段）
#   message_new       — Non-streaming message persisted / 非流式消息已持久化
#   task_update       — Scheduled task CRUD (create/pause/resume/update/delete) / 定时任务增删改
#   task_exec_update  — Task execution lifecycle (running/completed/failed/cancelled) / 任务执行生命周期
#   tunnel_status     — SSH tunnel client connect/disconnect / SSH 隧道客户端连接/断开
#
# Frontend: useSystemEvents composable connects automatically (cookie auth).
# 前端: useSystemEvents composable 自动连接（cookie 认证）。
# Android: PortForwardService native SSE listener uses ?token= auth; shows system notifications when backgrounded.
# 安卓: PortForwardService 原生 SSE 监听器使用 ?token= 认证；后台时弹出系统通知。


