diff --git a/CHANGELOG.md b/CHANGELOG.md
index 30587ae..7620fb8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,13 @@
本文件基于 [Keep a Changelog](https://keepachangelog.com/zh-CN/) 规范维护,版本号遵循 [语义化版本](https://semver.org/lang/zh-CN/)。
+## [v0.6.21](https://github.com/ThreeFish-AI/coding-proxy/releases/tag/v0.6.21) - 2026-12-06
+
+> 本版主轴:Sessions 页默认折叠 harness 注入式辅助会话(会话命名 / 分支命名等),主对话不再被同标题的辅助调用混淆;中英 README 按实现校准,架构全景图换为 Archify 图。
+
+- feat(dashboard): **Sessions 页默认折叠辅助会话**:harness 注入式调用(会话命名 / 分支命名 / 记忆压缩 / 单命令等)各自成会话,标题与用户主对话同源,排查时极易误认(如 Orca 的分支命名走 Claude Code、主对话走 PI,同一 id 下模型对不上);现 `/api/dashboard/sessions` 每行增 `auxiliary` 标记(按标题家族标签判定,与标题提取共用 `session_title` 家族表),Sessions 页默认隐藏并提示「已隐藏 N 个辅助会话」,分页栏勾选「显示辅助会话」后带「辅助」tag 展示;
+- docs(readme): 中英 README 按实现校准:安装改 `uv tool install`、OAuth provider 写法修正(`github` / `google`)、CLI 表补 `session` 命令与 `config` / `usage` / `reset` 参数、Config 分区与文档地图同步;架构全景图由 mermaid 换为 Archify 图([docs/diagrams/routing-n-tier/](docs/diagrams/routing-n-tier/));
+
## [v0.6.20](https://github.com/ThreeFish-AI/coding-proxy/releases/tag/v0.6.20) - 2026-12-05
> 本版主轴:Models 页配价即进 Model Bind 下拉(anthropic 新型号不再需要改内置目录或 `bindable_models`),Models 页新增 Label 列美化下拉展示名,下拉按 vendor 分组排序;Model Mapping 子页签按 target 设置每模型并发度。
diff --git a/README.md b/README.md
index 57ec849..7138599 100644
--- a/README.md
+++ b/README.md
@@ -1,17 +1,11 @@
-[English](./README.md) | [简体中文](./docs/zh-CN/README.md)
+- 📖 **[User Guide](./docs/user-guide.md)** — Installation, minimal setup, the semantics of every config field and troubleshooting. (Currently in Chinese)
+- 🏗️ **[Architecture Framework](./docs/framework.md)** — The design patterns underneath (Template Method, Circuit Breaker, State Machine, etc.), for anyone who wants to peek under the hood or contribute a vendor. (Currently in Chinese)
-
-
-#
coding-proxy
-
-**A High-Availability, Transparent, and Smart Multi-Vendor Proxy for Claude Code**
-
-[](https://www.python.org/)
-[](#)
-[](https://github.com/astral-sh/uv)
-[](#)
-
-
+| Topic | Documents |
+| :--- | :--- |
+| Hands-on guides | [Quick Start](./docs/guide/quickstart.md) · [Vendors](./docs/guide/vendors.md) · [CLI Reference](./docs/guide/cli-reference.md) · [HTTP API](./docs/guide/api-reference.md) · [Dashboard](./docs/guide/dashboard.md) · [Monitoring & Troubleshooting](./docs/guide/monitoring.md) |
+| Architecture | [Design Patterns](./docs/arch/design-patterns.md) · [Routing](./docs/arch/routing.md) · [Vendors](./docs/arch/vendors.md) · [Protocol Conversion](./docs/arch/convert.md) · [Config Reference](./docs/arch/config-reference.md) · [Session Model Bind](./docs/arch/session-model-bind.md) · [Subscription Status](./docs/arch/subscription-status.md) · [Testing](./docs/arch/testing.md) |
+| Operations & design | [CI/CD](./docs/ops/ci-cd.md) · [Config Tab UX](./docs/design/config-tab-ux-batch1.md) · [Diagrams](./docs/diagrams/) |
---
@@ -33,10 +27,10 @@ When you're deeply immersed in your coding "zone" with **Claude Code** (or any A
-- **⛓️ N-tier Chained Failover**: Autonomous descending sequence, supporting Claude's official plans, as well as Coding Plans from GitHub Copilot, Google Antigravity, Z AI, MiniMax, Alibaba Qwen, Xiaomi, Kimi, Doubao, etc.
+- **⛓️ N-tier Chained Failover**: Autonomous descending sequence, supporting Claude's official plans, as well as Coding Plans from GitHub Copilot, Google Antigravity, Z AI, MiniMax, Alibaba Qwen, Xiaomi, Kimi, Doubao, etc. Reorder the chain at runtime from the Dashboard, the CLI (`reset -v`, `session bind`) or per-session policies.
- **🛡️ Smart Resilience & Quota Guardians**: Every single vendor node comes fully armed with an independent **Circuit Breaker** and **Quota Guard** to proactively dodge avalanches without breaking a sweat.
- **👻 Phantom-like Transparency**: **100% transparent** to the client! No code tweaks required. Overwrite `ANTHROPIC_BASE_URL` with a single line, and you're good to go.
-- **🔄 Universal Alchemy (Formats & Models)**: Native support for two-way request/streaming (SSE) translations between Anthropic ←→ Gemini and Anthropic ←→ OpenAI. Plus, auto/DIY model name mapping (e.g., effortlessly morphing `claude-*` into `glm-*`).
+- **🔄 Universal Alchemy (Formats & Models)**: Native support for two-way request/streaming (SSE) translation between Anthropic ←→ Gemini and Anthropic ←→ OpenAI, plus a native Gemini-protocol pass-through gateway for Antigravity clients. Session affinity and tool-call mapping are preserved across vendors, and model names map automatically or by hand (e.g., `claude-*` → `glm-*`).
- **📊 Extreme Observability**: Built-in, zero-BS local monitoring powered by a `SQLite WAL`. The CLI provides a one-click detailed Token usage dashboard (`coding-proxy usage`).
- **⚡ Featherweight Standalone Deployment**: A fully asynchronous architecture (`FastAPI` + `httpx`). Zero dependency on Redis, message queues, or other heavy machinery—absolutely no extra baggage for your dev rig.
@@ -51,9 +45,11 @@ Make sure your rig has **Python 3.12+** and the **`uv`** package manager install
### 2. Lightning Install
```bash
-uv add coding-proxy
+uv tool install coding-proxy
```
+(From source: `uv sync` inside the repository, then prefix the commands below with `uv run`.)
+
### 3. Configure a Vendor & Start
The default chain is `zhipu → anthropic → copilot → antigravity`; the Zhipu key is read from `${ZHIPU_API_KEY}`. Inject it via env var, or store it encrypted in the config store (never echoed back):
@@ -62,21 +58,22 @@ The default chain is `zhipu → anthropic → copilot → antigravity`; the Zhip
# Option A: env var
export ZHIPU_API_KEY="sk-..."
# Option B: encrypted config store
-# echo -n "sk-..." | uv run coding-proxy config set-secret vendors.zhipu.api_key --stdin
-# anthropic works with your Claude Code / PI login token (passed through); Copilot / Antigravity need a one-time OAuth login:
-# uv run coding-proxy auth login -p copilot
+# echo -n "sk-..." | coding-proxy config set-secret vendors.zhipu.api_key --stdin
+# anthropic works with your Claude Code / PI login token (passed through); Copilot and Antigravity need a one-time OAuth login
+# (provider is `github` for Copilot, `google` for Antigravity; omit -p to log in to both):
+# coding-proxy auth login -p github
```
Start the proxy:
```bash
-uv run coding-proxy start
+coding-proxy start
# INFO: coding-proxy started: host=127.0.0.1 port=3392
# INFO: Uvicorn running on http://127.0.0.1:3392 (Press CTRL+C to quit)
```
-Runtime config lives in `~/.coding-proxy/config.db` (SQLite, secrets encrypted) — edit it via the Dashboard → Config page or the `coding-proxy config` CLI; there is no YAML to manage. An existing `~/.coding-proxy/config.yaml` from older versions is imported once on first start (`start -c ./coding-proxy.yaml` to pick a specific file).
+Runtime config lives in `~/.coding-proxy/config.db` (SQLite, secrets encrypted) — edit it via the Dashboard → Config page or the `coding-proxy config` CLI; there is no YAML to manage (`config path` lists every file in play, `config export` dumps the effective config as redacted YAML). An existing `~/.coding-proxy/config.yaml` from older versions is imported once on first start (`start -c ./coding-proxy.yaml` to pick a specific file).
### 4. Point Your Coding Agent at It
@@ -109,7 +106,11 @@ If you previously ran `/login` for Anthropic inside PI, run `/logout anthropic`
### 5. Peek at the Dashboard
-Open `http://127.0.0.1:3392/dashboard` for real-time token spend, latency and circuit-breaker state. The **Config** tab edits the whole configuration online (vendors, models, clients, session policies, failover, system); saves hot-swap the running proxy with zero restarts. Unlock it once with the admin token printed by `coding-proxy config token`.
+Open `http://127.0.0.1:3392/dashboard` for real-time token spend, latency and circuit-breaker state. The **Config** tab edits the whole configuration online (vendors, tier order, failover, model mapping, pricing, native API, session policies, Antigravity gateway, clients, system); saves hot-swap the running proxy with zero restarts. Unlock it once with the admin token printed by `coding-proxy config token`.
+
+| Config tab | Sessions | Model Calling |
+|:---:|:---:|:---:|
+|  |  |  |
---
@@ -117,14 +118,15 @@ Open `http://127.0.0.1:3392/dashboard` for real-time token spend, latency and ci
`coding-proxy` comes equipped with a badass suite of CLI tools to help you boss around your proxy state.
-| Command | Description | Example Usage |
-| :------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------- |
-| `start` | **Fire up the proxy server.** Supports custom ports and a one-time legacy YAML import via `-c`. | `coding-proxy start -p 8080` |
-| `config` | **Manage the config store** (`~/.coding-proxy/config.db`). Sub-commands: `set`, `reset`, `set-secret` (encrypted keys), `import`/`export`, `token`. | `coding-proxy config set vendors.zhipu.timeout_ms 60000` |
-| `auth` | **Manage OAuth credentials.** Sub-commands: `login` (browser OAuth), `status` (token validity), `reauth` (re-authenticate), `logout` (clear tokens). | `coding-proxy auth login -p github` |
-| `status` | **Check proxy health.** Shows circuit breaker states (OPEN/CLOSED) and quota status across all tiers. | `coding-proxy status` |
-| `usage` | **Token Stats Dashboard.** Stalks every single token consumed, failovers triggered, and latency across day/vendor/model dimensions. | `coding-proxy usage -d 7 -v anthropic` |
-| `reset` | **The emergency flush button.** Force-reset all circuit breakers and quotas instantly when you've confirmed the main vendor is back from the dead. | `coding-proxy reset` |
+| Command | Description | Example Usage |
+| :------- | :---------- | :------------ |
+| `start` | **Fire up the proxy server.** `-p` / `-h` for port and bind address; `-c` for a one-time legacy YAML import. | `coding-proxy start -p 8080` |
+| `config` | **Manage the config store** (`~/.coding-proxy/config.db`). Sub-commands: `set`, `reset`, `set-secret` (encrypted; `--stdin`, `--env`, `--clear`, `--default-env`), `import` / `export` (YAML, secrets redacted), `path`, `token` (Dashboard admin token). | `coding-proxy config set vendors.zhipu.timeout_ms 60000` |
+| `auth` | **Manage OAuth credentials.** Sub-commands: `login` (browser OAuth; `-p github` for Copilot, `-p google` for Antigravity, both when omitted), `status`, `reauth`, `logout`. | `coding-proxy auth login -p github` |
+| `status` | **Check proxy health.** Shows circuit-breaker states (OPEN/CLOSED) and quota status across all tiers. | `coding-proxy status` |
+| `session`| **Session-level routing overrides.** `bind` pins vendor order (and optionally a model) to a session key, `unbind` releases it, `list` shows what is bound. Same data as the Model Bind column on the Dashboard. | `coding-proxy session bind --help` |
+| `usage` | **Token stats dashboard.** Tokens, failovers and latency by day (`-d`), week (`-w`), month (`-m`) or all history (`-t`), filtered by vendor (`-v`) or served model (`--model`). | `coding-proxy usage -d 7 -v anthropic` |
+| `reset` | **The emergency flush button.** Force-reset all circuit breakers and quotas; `-v` additionally promotes / reorders vendors so the recovered one is tried first. | `coding-proxy reset -v zhipu` |
---
@@ -132,56 +134,7 @@ Open `http://127.0.0.1:3392/dashboard` for real-time token spend, latency and ci
When a request inevitably hits the fan, the `RequestRouter` slides gracefully down the N-tier tree, juggling circuit breakers and token quotas to decide the ultimate destination:
-```mermaid
-graph RL
- %% 样式定义 (支持明暗双色模式的高对比色彩)
- classDef client fill:#1E3A8A,stroke:#60A5FA,stroke-width:2px,color:#EFF6FF,rx:8,ry:8
- classDef router fill:#4C1D95,stroke:#A78BFA,stroke-width:2px,color:#F5F3FF,rx:8,ry:8
- classDef gateway fill:#7C2D12,stroke:#FB923C,stroke-width:2px,color:#FFF7ED
- classDef api fill:#14532D,stroke:#4ADE80,stroke-width:2px,color:#F0FDF4
- classDef fallback fill:#27272A,stroke:#A1A1AA,stroke-width:2px,color:#F4F4F5
-
- Client["💻 Client (Claude Code)"]:::client
-
- subgraph CodingProxy["coding-proxy"]
- direction RL
-
- Router["RequestRouterrouting/router.py"]:::router
-
- Router -->NTier
-
- subgraph NTier["N-tier"]
- direction TB
-
- subgraph Tier0 ["Tier 0: Zhipu"]
- direction RL
- G0{"CB / Quota"}:::gateway -- "✅ Pass" --> API0(("GLM API")):::api
- end
-
- subgraph Tier1 ["Tier 1: Anthropic"]
- direction RL
- G1{"CB / Quota"}:::gateway -- "✅ Pass" --> API1(("Anthropic API")):::api
- end
-
- subgraph Tier2 ["Tier 2: GitHub Copilot"]
- direction RL
- G2{"CB / Quota"}:::gateway -- "✅ Pass" --> API2(("Copilot API")):::api
- end
-
- subgraph Tier3 ["Tier 3: Google Antigravity"]
- direction RL
- API3(("Gemini API")):::fallback
- end
-
- Tier0 -. "❌ Blocked / API Error" .-> Tier1
- Tier1 -. "❌ Blocked / API Error" .-> Tier2
- Tier2 -. "🆘 Safety Net Downgrade" .-> Tier3
- end
-
- end
-
- Client -->|"POST /v1/messages"| CodingProxy
-```
+
*For a deep dive into the architecture and under-the-hood wizardry, consult [framework.md](./docs/framework.md) (Currently in Chinese).*
diff --git a/docs/diagrams/routing-n-tier/routing-n-tier.html b/docs/diagrams/routing-n-tier/routing-n-tier.html
new file mode 100644
index 0000000..49f6a76
--- /dev/null
+++ b/docs/diagrams/routing-n-tier/routing-n-tier.html
@@ -0,0 +1,13781 @@
+
+
+
+
+
+
+
+ N-tier 链式路由:一次 /v1/messages 请求怎么选 vendor
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ N-tier 链式路由:一次 /v1/messages 请求怎么选 vendor
+ 由 Archify 生成的架构图。
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Client (Claude Code) · Anthropic 协议客户端 · 架构组件
+
+
+
+
+
+
+ Client (Claude Code)
+ Anthropic 协议客户端
+
+
+
+ RequestRouter · routing/router.py · coding-proxy 进程内
+
+
+
+
+
+ RequestRouter
+ routing/router.py
+
+
+
+ CB / Quota · Tier 0 · Zhipu · coding-proxy 进程内
+
+
+
+
+
+
+ CB / Quota
+ Tier 0 · Zhipu
+
+
+
+ CB / Quota · Tier 1 · Anthropic · coding-proxy 进程内
+
+
+
+
+
+
+ CB / Quota
+ Tier 1 · Anthropic
+
+
+
+ CB / Quota · Tier 2 · GitHub Copilot · coding-proxy 进程内
+
+
+
+
+
+
+ CB / Quota
+ Tier 2 · GitHub Copilot
+
+
+
+ GLM API · Zhipu · 架构组件
+
+
+
+
+
+ GLM API
+ Zhipu
+
+
+
+ Anthropic API · 官方端点 · 架构组件
+
+
+
+
+
+ Anthropic API
+ 官方端点
+
+
+
+ Copilot API · GitHub · 架构组件
+
+
+
+
+
+ Copilot API
+ GitHub
+
+
+
+ Gemini API · Tier 3 · Google Antigravity · 架构组件 · 无门控 · 兜底
+
+
+
+
+
+ Gemini API
+ Tier 3 · Google Antigravity
+ 无门控 · 兜底
+
+
+
+
+
+ POST /v1/messages
+
+
+
+
+
+
+ ✅ Pass
+
+
+
+ ✅ Pass
+
+
+
+ ✅ Pass
+
+
+
+ ❌ Blocked / API Error
+
+
+
+ ❌ Blocked / API Error
+
+
+
+ 🆘 Safety Net Downgrade
+
+
+
+
+
+ coding-proxy 进程内
+
+
+
+
+ 图例
+
+
+ 后端
+
+
+
+ 云服务
+
+
+
+ 安全
+
+
+
+ 外部系统
+
+
+
+
+
+
+
+ 图表指南
+ 探索此系统
+
+ ×
+
+
正在检查已编译语义
+
+
+ 01
+ 查找任意节点 搜索标签、职责、类型和稳定 ID。
+ /
+
+
+ 02
+ 追踪路径 查看两个语义节点如何按编写方向连接。
+ R
+
+
+ 03
+ 查看完整系统 打开带实时视口和稳定节点的语义雷达。
+ M
+
+
+ 04
+ 比较语义类型 统计角色、显示流量并比较直接编写的连接。
+ L
+
+
+ 05
+ 进入演示模式 让实时图表占满视口,同时不改变导出。
+ F
+
+
+
+ E 导出T 主题S 风格0 重置+ 放大- 缩小Esc 关闭
+
+
+
+
+
+ 查找节点
+ ×
+
+
+ ⌕
+
+ /
+
+
+
没有匹配的节点
+
+
+
+
+
+
+
语义护照
+
+
+
+
+
+
+
+
+
+
+
+
+
编写可达范围
+
+
+ 上游 0
+
+
+ 下游 0
+
+
+
+
+
+
+ ×
+ 复制链接
+ 关系
+
+
+
+
+
+
+
+ 路径
+ 点击路径的起点
+
+
+ 查找起点
+ 复制链接
+ 清除
+
+
+
+ 在图上点两个节点
+
+
+ ←
+
+ ▶
+ 旅程
+
+ →
+ 总览
+
+
先点起点,再点终点,沿箭头方向找路。
+
+
+
+
+ 语义透镜
+ 比较系统角色
+
+ ×
+
+
最多选择两种语义类型。选择一种可显示其真实流量;选择两种只比较直接编写的关系。
+
+
选择一种类型以检查其节点和相连关系。
+
+ 复制链接
+ 清除
+
+
+
+
+
+
+ 语义雷达
+ 正在构建总览
+
+ 打开雷达
+ ×
+
+
+
点击节点 拖动平移
+
+
语义雷达需要更多地图可见空间。
+
要点与索引
+
+ 路径
+ 地图
+ 透镜
+
+
+
+ 阅读 100%
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ RequestRouter 按 tier 顺序逐级尝试,是所有 /v1/messages 请求的唯一入口
+
+
+
+
+
+
+ 每个非末位 tier 挂 CircuitBreaker 与 QuotaGuard
+ 任一不放行或上游报错,即跳到下一 tier
+
+
+
+
+
+
+ 末位 tier 不挂门控(is_terminal)
+ 作为 Safety Net 接住全部降级流量
+
+
+
+
+
+ 节点索引
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/diagrams/routing-n-tier/routing-n-tier.json b/docs/diagrams/routing-n-tier/routing-n-tier.json
new file mode 100644
index 0000000..aec4a64
--- /dev/null
+++ b/docs/diagrams/routing-n-tier/routing-n-tier.json
@@ -0,0 +1,46 @@
+{
+ "schema_version": 1,
+ "diagram_type": "architecture",
+ "meta": {
+ "title": "N-tier 链式路由:一次 /v1/messages 请求怎么选 vendor",
+ "locale": "zh-CN",
+ "output": "routing-n-tier.html",
+ "quality_profile": "showcase",
+ "repository": {
+ "url": "https://github.com/ThreeFish-AI/coding-proxy",
+ "provider": "github",
+ "revision": "b10fceca081cf130e22235cd6d380f6a8c0cebb8"
+ }
+ },
+ "components": [
+ { "id": "client", "type": "external", "label": "Client (Claude Code)", "sublabel": "Anthropic 协议客户端", "pos": [40, 300], "size": [150, 60] },
+ { "id": "router", "type": "backend", "label": "RequestRouter", "sublabel": "routing/router.py", "pos": [330, 285], "size": [150, 90], "sources": [{ "path": "src/coding/proxy/routing/router.py", "line": 32 }, { "path": "src/coding/proxy/server/routes.py", "line": 74 }] },
+ { "id": "g0", "type": "security", "label": "CB / Quota", "sublabel": "Tier 0 · Zhipu", "pos": [620, 90], "size": [150, 60], "sources": [{ "path": "src/coding/proxy/routing/tier.py", "line": 49 }] },
+ { "id": "g1", "type": "security", "label": "CB / Quota", "sublabel": "Tier 1 · Anthropic", "pos": [620, 230], "size": [150, 60], "sources": [{ "path": "src/coding/proxy/routing/tier.py", "line": 49 }] },
+ { "id": "g2", "type": "security", "label": "CB / Quota", "sublabel": "Tier 2 · GitHub Copilot", "pos": [620, 370], "size": [150, 60], "sources": [{ "path": "src/coding/proxy/routing/tier.py", "line": 49 }] },
+ { "id": "api0", "type": "cloud", "label": "GLM API", "sublabel": "Zhipu", "pos": [860, 90], "size": [150, 60] },
+ { "id": "api1", "type": "cloud", "label": "Anthropic API", "sublabel": "官方端点", "pos": [860, 230], "size": [150, 60] },
+ { "id": "api2", "type": "cloud", "label": "Copilot API", "sublabel": "GitHub", "pos": [860, 370], "size": [150, 60] },
+ { "id": "api3", "type": "cloud", "label": "Gemini API", "sublabel": "Tier 3 · Google Antigravity", "tag": "无门控 · 兜底", "pos": [860, 510], "size": [150, 60], "sources": [{ "path": "src/coding/proxy/routing/tier.py", "line": 35 }] }
+ ],
+ "boundaries": [
+ { "kind": "region", "label": "coding-proxy 进程内", "wraps": ["router", "g0", "g1", "g2"] }
+ ],
+ "connections": [
+ { "id": "client-in", "from": "client", "to": "router", "label": "POST /v1/messages", "variant": "emphasis" },
+ { "id": "router-g0", "from": "router", "to": "g0", "fromSide": "top", "toSide": "left", "via": [[405, 120]] },
+ { "id": "router-g1", "from": "router", "to": "g1", "fromSide": "right", "toSide": "left" },
+ { "id": "router-g2", "from": "router", "to": "g2", "fromSide": "right", "toSide": "left", "via": [[550, 330], [550, 400]] },
+ { "id": "pass0", "from": "g0", "to": "api0", "label": "✅ Pass", "variant": "emphasis" },
+ { "id": "pass1", "from": "g1", "to": "api1", "label": "✅ Pass", "variant": "emphasis" },
+ { "id": "pass2", "from": "g2", "to": "api2", "label": "✅ Pass", "variant": "emphasis" },
+ { "id": "fo0", "from": "g0", "to": "g1", "label": "❌ Blocked / API Error", "variant": "dashed", "fromSide": "bottom", "toSide": "top" },
+ { "id": "fo1", "from": "g1", "to": "g2", "label": "❌ Blocked / API Error", "variant": "dashed", "fromSide": "bottom", "toSide": "top" },
+ { "id": "fo2", "from": "g2", "to": "api3", "label": "🆘 Safety Net Downgrade", "variant": "dashed", "fromSide": "bottom", "toSide": "left" }
+ ],
+ "cards": [
+ { "dot": "violet", "title": "路由", "items": ["RequestRouter 按 tier 顺序逐级尝试,是所有 /v1/messages 请求的唯一入口"] },
+ { "dot": "amber", "title": "门控", "items": ["每个非末位 tier 挂 CircuitBreaker 与 QuotaGuard", "任一不放行或上游报错,即跳到下一 tier"] },
+ { "dot": "slate", "title": "兜底", "items": ["末位 tier 不挂门控(is_terminal)", "作为 Safety Net 接住全部降级流量"] }
+ ]
+}
diff --git a/docs/diagrams/routing-n-tier/routing-n-tier.svg b/docs/diagrams/routing-n-tier/routing-n-tier.svg
new file mode 100644
index 0000000..14c1172
--- /dev/null
+++ b/docs/diagrams/routing-n-tier/routing-n-tier.svg
@@ -0,0 +1,638 @@
+
+
+ N-tier 链式路由:一次 /v1/messages 请求怎么选 vendor
+ 由 Archify 生成的架构图。
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Client (Claude Code) · Anthropic 协议客户端 · 架构组件
+
+
+
+
+
+
+ Client (Claude Code)
+ Anthropic 协议客户端
+
+
+
+ RequestRouter · routing/router.py · coding-proxy 进程内
+
+
+
+
+
+ RequestRouter
+ routing/router.py
+
+
+
+ CB / Quota · Tier 0 · Zhipu · coding-proxy 进程内
+
+
+
+
+
+
+ CB / Quota
+ Tier 0 · Zhipu
+
+
+
+ CB / Quota · Tier 1 · Anthropic · coding-proxy 进程内
+
+
+
+
+
+
+ CB / Quota
+ Tier 1 · Anthropic
+
+
+
+ CB / Quota · Tier 2 · GitHub Copilot · coding-proxy 进程内
+
+
+
+
+
+
+ CB / Quota
+ Tier 2 · GitHub Copilot
+
+
+
+ GLM API · Zhipu · 架构组件
+
+
+
+
+
+ GLM API
+ Zhipu
+
+
+
+ Anthropic API · 官方端点 · 架构组件
+
+
+
+
+
+ Anthropic API
+ 官方端点
+
+
+
+ Copilot API · GitHub · 架构组件
+
+
+
+
+
+ Copilot API
+ GitHub
+
+
+
+ Gemini API · Tier 3 · Google Antigravity · 架构组件 · 无门控 · 兜底
+
+
+
+
+
+ Gemini API
+ Tier 3 · Google Antigravity
+ 无门控 · 兜底
+
+
+
+
+
+ POST /v1/messages
+
+
+
+
+
+
+ ✅ Pass
+
+
+
+ ✅ Pass
+
+
+
+ ✅ Pass
+
+
+
+ ❌ Blocked / API Error
+
+
+
+ ❌ Blocked / API Error
+
+
+
+ 🆘 Safety Net Downgrade
+
+
+
+
+
+ coding-proxy 进程内
+
+
+
+
+ 图例
+
+
+ 后端
+
+
+
+ 云服务
+
+
+
+ 安全
+
+
+
+ 外部系统
+
+
+
\ No newline at end of file
diff --git a/docs/diagrams/routing-n-tier/routing-n-tier.visual-check.json b/docs/diagrams/routing-n-tier/routing-n-tier.visual-check.json
new file mode 100644
index 0000000..60137ec
--- /dev/null
+++ b/docs/diagrams/routing-n-tier/routing-n-tier.visual-check.json
@@ -0,0 +1,962 @@
+{
+ "schemaVersion": 1,
+ "ok": true,
+ "command": "visual-check",
+ "evidenceKind": "automated-browser",
+ "status": "pass",
+ "visualReview": "pending",
+ "provenance": "current",
+ "deliveryReceiptId": "3daeeba6-7760-4085-bbf5-8cc140f2ab4a",
+ "artifact": {
+ "path": "/Users/cm.huang/orca/workspaces/coding-proxy/redhorse/docs/diagrams/routing-n-tier/routing-n-tier.html",
+ "sha256": "4bf28f2cd2b879a93e59b1e11792ac3345123aceeef1fec916d025de2e875a3c",
+ "bytes": 762030
+ },
+ "state": {
+ "detail": "read",
+ "motion": "still"
+ },
+ "chrome": {
+ "status": "available",
+ "executable": "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
+ },
+ "diagnostics": [],
+ "containment": {
+ "status": "pass",
+ "policy": "fit-or-reader-declared-readable-vertical-scroll",
+ "viewports": [
+ {
+ "width": 1440,
+ "height": 900,
+ "theme": "light",
+ "innerWidth": 1440,
+ "innerHeight": 900,
+ "scrollWidth": 1440,
+ "scrollHeight": 900,
+ "overflowX": false,
+ "overflowY": false,
+ "verticalScrollAccepted": false,
+ "overflowDisposition": "contained",
+ "readerLayout": "adaptive",
+ "readerOverflow": null,
+ "readerFit": "intrinsic-height",
+ "ok": true,
+ "readerWidth": 1258,
+ "diagramWidth": 1228,
+ "pageComposition": {
+ "bodyPaddingPx": 12,
+ "headerPx": 52,
+ "diagramChromePx": 78,
+ "svgPx": 746,
+ "cardsPx": 0,
+ "viewBoxHeight": 638
+ },
+ "viewBoxWidth": 1050,
+ "minimumProjectedNodeTextPx": 8,
+ "minimumProjectedNonEdgeTextPx": 8.7,
+ "minimumProjectedEdgeTextPx": 8,
+ "minimumProjectedNodeText": "POST /v1/messages",
+ "minimumProjectedNodeTextDetail": "edge",
+ "minimumProjectedNodeTextOwner": {
+ "kind": "edge",
+ "id": "client-in",
+ "from": "client",
+ "to": "router"
+ },
+ "minimumRequiredNodeTextPx": 6,
+ "readabilityOk": true,
+ "hasLegend": true,
+ "hasNavigationDock": true,
+ "legendDockIntersectionArea": 0,
+ "dockStageIntersectionArea": 0,
+ "dockStageGap": 10,
+ "requiredDockStageGap": 10,
+ "viewerChromeStageOk": true,
+ "viewerChromeReserve": 54,
+ "viewerChromeActive": true,
+ "viewerChromeOk": true,
+ "resolvedTheme": "light"
+ },
+ {
+ "width": 1600,
+ "height": 1000,
+ "theme": "light",
+ "innerWidth": 1600,
+ "innerHeight": 1000,
+ "scrollWidth": 1600,
+ "scrollHeight": 1000,
+ "overflowX": false,
+ "overflowY": false,
+ "verticalScrollAccepted": false,
+ "overflowDisposition": "contained",
+ "readerLayout": "adaptive",
+ "readerOverflow": null,
+ "readerFit": "intrinsic-height",
+ "ok": true,
+ "readerWidth": 1314,
+ "diagramWidth": 1284,
+ "pageComposition": {
+ "bodyPaddingPx": 64,
+ "headerPx": 60,
+ "diagramChromePx": 84,
+ "svgPx": 780,
+ "cardsPx": 0,
+ "viewBoxHeight": 638
+ },
+ "viewBoxWidth": 1050,
+ "minimumProjectedNodeTextPx": 8,
+ "minimumProjectedNonEdgeTextPx": 8.7,
+ "minimumProjectedEdgeTextPx": 8,
+ "minimumProjectedNodeText": "POST /v1/messages",
+ "minimumProjectedNodeTextDetail": "edge",
+ "minimumProjectedNodeTextOwner": {
+ "kind": "edge",
+ "id": "client-in",
+ "from": "client",
+ "to": "router"
+ },
+ "minimumRequiredNodeTextPx": 6,
+ "readabilityOk": true,
+ "hasLegend": true,
+ "hasNavigationDock": true,
+ "legendDockIntersectionArea": 0,
+ "dockStageIntersectionArea": 0,
+ "dockStageGap": 10,
+ "requiredDockStageGap": 10,
+ "viewerChromeStageOk": true,
+ "viewerChromeReserve": 54,
+ "viewerChromeActive": true,
+ "viewerChromeOk": true,
+ "resolvedTheme": "light"
+ },
+ {
+ "width": 1920,
+ "height": 1080,
+ "theme": "light",
+ "innerWidth": 1920,
+ "innerHeight": 1080,
+ "scrollWidth": 1920,
+ "scrollHeight": 1080,
+ "overflowX": false,
+ "overflowY": false,
+ "verticalScrollAccepted": false,
+ "overflowDisposition": "contained",
+ "readerLayout": "adaptive",
+ "readerOverflow": null,
+ "readerFit": "intrinsic-height",
+ "ok": true,
+ "readerWidth": 1445,
+ "diagramWidth": 1415,
+ "pageComposition": {
+ "bodyPaddingPx": 64,
+ "headerPx": 60,
+ "diagramChromePx": 84,
+ "svgPx": 860,
+ "cardsPx": 0,
+ "viewBoxHeight": 638
+ },
+ "viewBoxWidth": 1050,
+ "minimumProjectedNodeTextPx": 8,
+ "minimumProjectedNonEdgeTextPx": 8.7,
+ "minimumProjectedEdgeTextPx": 8,
+ "minimumProjectedNodeText": "POST /v1/messages",
+ "minimumProjectedNodeTextDetail": "edge",
+ "minimumProjectedNodeTextOwner": {
+ "kind": "edge",
+ "id": "client-in",
+ "from": "client",
+ "to": "router"
+ },
+ "minimumRequiredNodeTextPx": 6,
+ "readabilityOk": true,
+ "hasLegend": true,
+ "hasNavigationDock": true,
+ "legendDockIntersectionArea": 0,
+ "dockStageIntersectionArea": 0,
+ "dockStageGap": 10,
+ "requiredDockStageGap": 10,
+ "viewerChromeStageOk": true,
+ "viewerChromeReserve": 54,
+ "viewerChromeActive": true,
+ "viewerChromeOk": true,
+ "resolvedTheme": "light"
+ },
+ {
+ "width": 2048,
+ "height": 1320,
+ "theme": "light",
+ "innerWidth": 2048,
+ "innerHeight": 1320,
+ "scrollWidth": 2048,
+ "scrollHeight": 1320,
+ "overflowX": false,
+ "overflowY": false,
+ "verticalScrollAccepted": false,
+ "overflowDisposition": "contained",
+ "readerLayout": "adaptive",
+ "readerOverflow": null,
+ "readerFit": "intrinsic-height",
+ "ok": true,
+ "readerWidth": 1831,
+ "diagramWidth": 1781,
+ "pageComposition": {
+ "bodyPaddingPx": 64,
+ "headerPx": 68,
+ "diagramChromePx": 94,
+ "svgPx": 1082,
+ "cardsPx": 0,
+ "viewBoxHeight": 638
+ },
+ "viewBoxWidth": 1050,
+ "minimumProjectedNodeTextPx": 8,
+ "minimumProjectedNonEdgeTextPx": 8.7,
+ "minimumProjectedEdgeTextPx": 8,
+ "minimumProjectedNodeText": "POST /v1/messages",
+ "minimumProjectedNodeTextDetail": "edge",
+ "minimumProjectedNodeTextOwner": {
+ "kind": "edge",
+ "id": "client-in",
+ "from": "client",
+ "to": "router"
+ },
+ "minimumRequiredNodeTextPx": 6,
+ "readabilityOk": true,
+ "hasLegend": true,
+ "hasNavigationDock": true,
+ "legendDockIntersectionArea": 0,
+ "dockStageIntersectionArea": 0,
+ "dockStageGap": 10,
+ "requiredDockStageGap": 10,
+ "viewerChromeStageOk": true,
+ "viewerChromeReserve": 44,
+ "viewerChromeActive": true,
+ "viewerChromeOk": true,
+ "resolvedTheme": "light"
+ }
+ ]
+ },
+ "themeStates": {
+ "status": "pass",
+ "viewports": [
+ {
+ "width": 1440,
+ "height": 900,
+ "requestedTheme": "light",
+ "resolvedTheme": "light",
+ "ok": true
+ },
+ {
+ "width": 1600,
+ "height": 1000,
+ "requestedTheme": "light",
+ "resolvedTheme": "light",
+ "ok": true
+ },
+ {
+ "width": 1920,
+ "height": 1080,
+ "requestedTheme": "light",
+ "resolvedTheme": "light",
+ "ok": true
+ },
+ {
+ "width": 2048,
+ "height": 1320,
+ "requestedTheme": "light",
+ "resolvedTheme": "light",
+ "ok": true
+ },
+ {
+ "width": 1440,
+ "height": 900,
+ "requestedTheme": "dark",
+ "resolvedTheme": "dark",
+ "ok": true
+ },
+ {
+ "width": 2048,
+ "height": 1320,
+ "requestedTheme": "dark",
+ "resolvedTheme": "dark",
+ "ok": true
+ }
+ ]
+ },
+ "readability": {
+ "status": "pass",
+ "minimumProjectedNodeTextPx": 6,
+ "viewports": [
+ {
+ "width": 1440,
+ "height": 900,
+ "theme": "light",
+ "innerWidth": 1440,
+ "innerHeight": 900,
+ "scrollWidth": 1440,
+ "scrollHeight": 900,
+ "overflowX": false,
+ "overflowY": false,
+ "verticalScrollAccepted": false,
+ "overflowDisposition": "contained",
+ "readerLayout": "adaptive",
+ "readerOverflow": null,
+ "readerFit": "intrinsic-height",
+ "ok": true,
+ "readerWidth": 1258,
+ "diagramWidth": 1228,
+ "pageComposition": {
+ "bodyPaddingPx": 12,
+ "headerPx": 52,
+ "diagramChromePx": 78,
+ "svgPx": 746,
+ "cardsPx": 0,
+ "viewBoxHeight": 638
+ },
+ "viewBoxWidth": 1050,
+ "minimumProjectedNodeTextPx": 8,
+ "minimumProjectedNonEdgeTextPx": 8.7,
+ "minimumProjectedEdgeTextPx": 8,
+ "minimumProjectedNodeText": "POST /v1/messages",
+ "minimumProjectedNodeTextDetail": "edge",
+ "minimumProjectedNodeTextOwner": {
+ "kind": "edge",
+ "id": "client-in",
+ "from": "client",
+ "to": "router"
+ },
+ "minimumRequiredNodeTextPx": 6,
+ "readabilityOk": true,
+ "hasLegend": true,
+ "hasNavigationDock": true,
+ "legendDockIntersectionArea": 0,
+ "dockStageIntersectionArea": 0,
+ "dockStageGap": 10,
+ "requiredDockStageGap": 10,
+ "viewerChromeStageOk": true,
+ "viewerChromeReserve": 54,
+ "viewerChromeActive": true,
+ "viewerChromeOk": true,
+ "resolvedTheme": "light"
+ },
+ {
+ "width": 1600,
+ "height": 1000,
+ "theme": "light",
+ "innerWidth": 1600,
+ "innerHeight": 1000,
+ "scrollWidth": 1600,
+ "scrollHeight": 1000,
+ "overflowX": false,
+ "overflowY": false,
+ "verticalScrollAccepted": false,
+ "overflowDisposition": "contained",
+ "readerLayout": "adaptive",
+ "readerOverflow": null,
+ "readerFit": "intrinsic-height",
+ "ok": true,
+ "readerWidth": 1314,
+ "diagramWidth": 1284,
+ "pageComposition": {
+ "bodyPaddingPx": 64,
+ "headerPx": 60,
+ "diagramChromePx": 84,
+ "svgPx": 780,
+ "cardsPx": 0,
+ "viewBoxHeight": 638
+ },
+ "viewBoxWidth": 1050,
+ "minimumProjectedNodeTextPx": 8,
+ "minimumProjectedNonEdgeTextPx": 8.7,
+ "minimumProjectedEdgeTextPx": 8,
+ "minimumProjectedNodeText": "POST /v1/messages",
+ "minimumProjectedNodeTextDetail": "edge",
+ "minimumProjectedNodeTextOwner": {
+ "kind": "edge",
+ "id": "client-in",
+ "from": "client",
+ "to": "router"
+ },
+ "minimumRequiredNodeTextPx": 6,
+ "readabilityOk": true,
+ "hasLegend": true,
+ "hasNavigationDock": true,
+ "legendDockIntersectionArea": 0,
+ "dockStageIntersectionArea": 0,
+ "dockStageGap": 10,
+ "requiredDockStageGap": 10,
+ "viewerChromeStageOk": true,
+ "viewerChromeReserve": 54,
+ "viewerChromeActive": true,
+ "viewerChromeOk": true,
+ "resolvedTheme": "light"
+ },
+ {
+ "width": 1920,
+ "height": 1080,
+ "theme": "light",
+ "innerWidth": 1920,
+ "innerHeight": 1080,
+ "scrollWidth": 1920,
+ "scrollHeight": 1080,
+ "overflowX": false,
+ "overflowY": false,
+ "verticalScrollAccepted": false,
+ "overflowDisposition": "contained",
+ "readerLayout": "adaptive",
+ "readerOverflow": null,
+ "readerFit": "intrinsic-height",
+ "ok": true,
+ "readerWidth": 1445,
+ "diagramWidth": 1415,
+ "pageComposition": {
+ "bodyPaddingPx": 64,
+ "headerPx": 60,
+ "diagramChromePx": 84,
+ "svgPx": 860,
+ "cardsPx": 0,
+ "viewBoxHeight": 638
+ },
+ "viewBoxWidth": 1050,
+ "minimumProjectedNodeTextPx": 8,
+ "minimumProjectedNonEdgeTextPx": 8.7,
+ "minimumProjectedEdgeTextPx": 8,
+ "minimumProjectedNodeText": "POST /v1/messages",
+ "minimumProjectedNodeTextDetail": "edge",
+ "minimumProjectedNodeTextOwner": {
+ "kind": "edge",
+ "id": "client-in",
+ "from": "client",
+ "to": "router"
+ },
+ "minimumRequiredNodeTextPx": 6,
+ "readabilityOk": true,
+ "hasLegend": true,
+ "hasNavigationDock": true,
+ "legendDockIntersectionArea": 0,
+ "dockStageIntersectionArea": 0,
+ "dockStageGap": 10,
+ "requiredDockStageGap": 10,
+ "viewerChromeStageOk": true,
+ "viewerChromeReserve": 54,
+ "viewerChromeActive": true,
+ "viewerChromeOk": true,
+ "resolvedTheme": "light"
+ },
+ {
+ "width": 2048,
+ "height": 1320,
+ "theme": "light",
+ "innerWidth": 2048,
+ "innerHeight": 1320,
+ "scrollWidth": 2048,
+ "scrollHeight": 1320,
+ "overflowX": false,
+ "overflowY": false,
+ "verticalScrollAccepted": false,
+ "overflowDisposition": "contained",
+ "readerLayout": "adaptive",
+ "readerOverflow": null,
+ "readerFit": "intrinsic-height",
+ "ok": true,
+ "readerWidth": 1831,
+ "diagramWidth": 1781,
+ "pageComposition": {
+ "bodyPaddingPx": 64,
+ "headerPx": 68,
+ "diagramChromePx": 94,
+ "svgPx": 1082,
+ "cardsPx": 0,
+ "viewBoxHeight": 638
+ },
+ "viewBoxWidth": 1050,
+ "minimumProjectedNodeTextPx": 8,
+ "minimumProjectedNonEdgeTextPx": 8.7,
+ "minimumProjectedEdgeTextPx": 8,
+ "minimumProjectedNodeText": "POST /v1/messages",
+ "minimumProjectedNodeTextDetail": "edge",
+ "minimumProjectedNodeTextOwner": {
+ "kind": "edge",
+ "id": "client-in",
+ "from": "client",
+ "to": "router"
+ },
+ "minimumRequiredNodeTextPx": 6,
+ "readabilityOk": true,
+ "hasLegend": true,
+ "hasNavigationDock": true,
+ "legendDockIntersectionArea": 0,
+ "dockStageIntersectionArea": 0,
+ "dockStageGap": 10,
+ "requiredDockStageGap": 10,
+ "viewerChromeStageOk": true,
+ "viewerChromeReserve": 44,
+ "viewerChromeActive": true,
+ "viewerChromeOk": true,
+ "resolvedTheme": "light"
+ }
+ ]
+ },
+ "viewerChrome": {
+ "status": "pass",
+ "viewports": [
+ {
+ "width": 1440,
+ "height": 900,
+ "theme": "light",
+ "innerWidth": 1440,
+ "innerHeight": 900,
+ "scrollWidth": 1440,
+ "scrollHeight": 900,
+ "overflowX": false,
+ "overflowY": false,
+ "verticalScrollAccepted": false,
+ "overflowDisposition": "contained",
+ "readerLayout": "adaptive",
+ "readerOverflow": null,
+ "readerFit": "intrinsic-height",
+ "ok": true,
+ "readerWidth": 1258,
+ "diagramWidth": 1228,
+ "pageComposition": {
+ "bodyPaddingPx": 12,
+ "headerPx": 52,
+ "diagramChromePx": 78,
+ "svgPx": 746,
+ "cardsPx": 0,
+ "viewBoxHeight": 638
+ },
+ "viewBoxWidth": 1050,
+ "minimumProjectedNodeTextPx": 8,
+ "minimumProjectedNonEdgeTextPx": 8.7,
+ "minimumProjectedEdgeTextPx": 8,
+ "minimumProjectedNodeText": "POST /v1/messages",
+ "minimumProjectedNodeTextDetail": "edge",
+ "minimumProjectedNodeTextOwner": {
+ "kind": "edge",
+ "id": "client-in",
+ "from": "client",
+ "to": "router"
+ },
+ "minimumRequiredNodeTextPx": 6,
+ "readabilityOk": true,
+ "hasLegend": true,
+ "hasNavigationDock": true,
+ "legendDockIntersectionArea": 0,
+ "dockStageIntersectionArea": 0,
+ "dockStageGap": 10,
+ "requiredDockStageGap": 10,
+ "viewerChromeStageOk": true,
+ "viewerChromeReserve": 54,
+ "viewerChromeActive": true,
+ "viewerChromeOk": true,
+ "resolvedTheme": "light"
+ },
+ {
+ "width": 1600,
+ "height": 1000,
+ "theme": "light",
+ "innerWidth": 1600,
+ "innerHeight": 1000,
+ "scrollWidth": 1600,
+ "scrollHeight": 1000,
+ "overflowX": false,
+ "overflowY": false,
+ "verticalScrollAccepted": false,
+ "overflowDisposition": "contained",
+ "readerLayout": "adaptive",
+ "readerOverflow": null,
+ "readerFit": "intrinsic-height",
+ "ok": true,
+ "readerWidth": 1314,
+ "diagramWidth": 1284,
+ "pageComposition": {
+ "bodyPaddingPx": 64,
+ "headerPx": 60,
+ "diagramChromePx": 84,
+ "svgPx": 780,
+ "cardsPx": 0,
+ "viewBoxHeight": 638
+ },
+ "viewBoxWidth": 1050,
+ "minimumProjectedNodeTextPx": 8,
+ "minimumProjectedNonEdgeTextPx": 8.7,
+ "minimumProjectedEdgeTextPx": 8,
+ "minimumProjectedNodeText": "POST /v1/messages",
+ "minimumProjectedNodeTextDetail": "edge",
+ "minimumProjectedNodeTextOwner": {
+ "kind": "edge",
+ "id": "client-in",
+ "from": "client",
+ "to": "router"
+ },
+ "minimumRequiredNodeTextPx": 6,
+ "readabilityOk": true,
+ "hasLegend": true,
+ "hasNavigationDock": true,
+ "legendDockIntersectionArea": 0,
+ "dockStageIntersectionArea": 0,
+ "dockStageGap": 10,
+ "requiredDockStageGap": 10,
+ "viewerChromeStageOk": true,
+ "viewerChromeReserve": 54,
+ "viewerChromeActive": true,
+ "viewerChromeOk": true,
+ "resolvedTheme": "light"
+ },
+ {
+ "width": 1920,
+ "height": 1080,
+ "theme": "light",
+ "innerWidth": 1920,
+ "innerHeight": 1080,
+ "scrollWidth": 1920,
+ "scrollHeight": 1080,
+ "overflowX": false,
+ "overflowY": false,
+ "verticalScrollAccepted": false,
+ "overflowDisposition": "contained",
+ "readerLayout": "adaptive",
+ "readerOverflow": null,
+ "readerFit": "intrinsic-height",
+ "ok": true,
+ "readerWidth": 1445,
+ "diagramWidth": 1415,
+ "pageComposition": {
+ "bodyPaddingPx": 64,
+ "headerPx": 60,
+ "diagramChromePx": 84,
+ "svgPx": 860,
+ "cardsPx": 0,
+ "viewBoxHeight": 638
+ },
+ "viewBoxWidth": 1050,
+ "minimumProjectedNodeTextPx": 8,
+ "minimumProjectedNonEdgeTextPx": 8.7,
+ "minimumProjectedEdgeTextPx": 8,
+ "minimumProjectedNodeText": "POST /v1/messages",
+ "minimumProjectedNodeTextDetail": "edge",
+ "minimumProjectedNodeTextOwner": {
+ "kind": "edge",
+ "id": "client-in",
+ "from": "client",
+ "to": "router"
+ },
+ "minimumRequiredNodeTextPx": 6,
+ "readabilityOk": true,
+ "hasLegend": true,
+ "hasNavigationDock": true,
+ "legendDockIntersectionArea": 0,
+ "dockStageIntersectionArea": 0,
+ "dockStageGap": 10,
+ "requiredDockStageGap": 10,
+ "viewerChromeStageOk": true,
+ "viewerChromeReserve": 54,
+ "viewerChromeActive": true,
+ "viewerChromeOk": true,
+ "resolvedTheme": "light"
+ },
+ {
+ "width": 2048,
+ "height": 1320,
+ "theme": "light",
+ "innerWidth": 2048,
+ "innerHeight": 1320,
+ "scrollWidth": 2048,
+ "scrollHeight": 1320,
+ "overflowX": false,
+ "overflowY": false,
+ "verticalScrollAccepted": false,
+ "overflowDisposition": "contained",
+ "readerLayout": "adaptive",
+ "readerOverflow": null,
+ "readerFit": "intrinsic-height",
+ "ok": true,
+ "readerWidth": 1831,
+ "diagramWidth": 1781,
+ "pageComposition": {
+ "bodyPaddingPx": 64,
+ "headerPx": 68,
+ "diagramChromePx": 94,
+ "svgPx": 1082,
+ "cardsPx": 0,
+ "viewBoxHeight": 638
+ },
+ "viewBoxWidth": 1050,
+ "minimumProjectedNodeTextPx": 8,
+ "minimumProjectedNonEdgeTextPx": 8.7,
+ "minimumProjectedEdgeTextPx": 8,
+ "minimumProjectedNodeText": "POST /v1/messages",
+ "minimumProjectedNodeTextDetail": "edge",
+ "minimumProjectedNodeTextOwner": {
+ "kind": "edge",
+ "id": "client-in",
+ "from": "client",
+ "to": "router"
+ },
+ "minimumRequiredNodeTextPx": 6,
+ "readabilityOk": true,
+ "hasLegend": true,
+ "hasNavigationDock": true,
+ "legendDockIntersectionArea": 0,
+ "dockStageIntersectionArea": 0,
+ "dockStageGap": 10,
+ "requiredDockStageGap": 10,
+ "viewerChromeStageOk": true,
+ "viewerChromeReserve": 44,
+ "viewerChromeActive": true,
+ "viewerChromeOk": true,
+ "resolvedTheme": "light"
+ }
+ ]
+ },
+ "captures": {
+ "status": "pass",
+ "screenshots": [
+ {
+ "width": 1440,
+ "height": 900,
+ "theme": "light",
+ "innerWidth": 1440,
+ "innerHeight": 900,
+ "scrollWidth": 1440,
+ "scrollHeight": 900,
+ "overflowX": false,
+ "overflowY": false,
+ "verticalScrollAccepted": false,
+ "overflowDisposition": "contained",
+ "readerLayout": "adaptive",
+ "readerOverflow": null,
+ "readerFit": "intrinsic-height",
+ "ok": true,
+ "readerWidth": 1258,
+ "diagramWidth": 1228,
+ "pageComposition": {
+ "bodyPaddingPx": 12,
+ "headerPx": 52,
+ "diagramChromePx": 78,
+ "svgPx": 746,
+ "cardsPx": 0,
+ "viewBoxHeight": 638
+ },
+ "viewBoxWidth": 1050,
+ "minimumProjectedNodeTextPx": 8,
+ "minimumProjectedNonEdgeTextPx": 8.7,
+ "minimumProjectedEdgeTextPx": 8,
+ "minimumProjectedNodeText": "POST /v1/messages",
+ "minimumProjectedNodeTextDetail": "edge",
+ "minimumProjectedNodeTextOwner": {
+ "kind": "edge",
+ "id": "client-in",
+ "from": "client",
+ "to": "router"
+ },
+ "minimumRequiredNodeTextPx": 6,
+ "readabilityOk": true,
+ "hasLegend": true,
+ "hasNavigationDock": true,
+ "legendDockIntersectionArea": 0,
+ "dockStageIntersectionArea": 0,
+ "dockStageGap": 10,
+ "requiredDockStageGap": 10,
+ "viewerChromeStageOk": true,
+ "viewerChromeReserve": 54,
+ "viewerChromeActive": true,
+ "viewerChromeOk": true,
+ "resolvedTheme": "light",
+ "file": "routing-n-tier.visual-check.1440x900.light.png"
+ },
+ {
+ "width": 1440,
+ "height": 900,
+ "theme": "dark",
+ "innerWidth": 1440,
+ "innerHeight": 900,
+ "scrollWidth": 1440,
+ "scrollHeight": 900,
+ "overflowX": false,
+ "overflowY": false,
+ "verticalScrollAccepted": false,
+ "overflowDisposition": "contained",
+ "readerLayout": "adaptive",
+ "readerOverflow": null,
+ "readerFit": "intrinsic-height",
+ "ok": true,
+ "readerWidth": 1258,
+ "diagramWidth": 1228,
+ "pageComposition": {
+ "bodyPaddingPx": 12,
+ "headerPx": 52,
+ "diagramChromePx": 78,
+ "svgPx": 746,
+ "cardsPx": 0,
+ "viewBoxHeight": 638
+ },
+ "viewBoxWidth": 1050,
+ "minimumProjectedNodeTextPx": 8,
+ "minimumProjectedNonEdgeTextPx": 8.7,
+ "minimumProjectedEdgeTextPx": 8,
+ "minimumProjectedNodeText": "POST /v1/messages",
+ "minimumProjectedNodeTextDetail": "edge",
+ "minimumProjectedNodeTextOwner": {
+ "kind": "edge",
+ "id": "client-in",
+ "from": "client",
+ "to": "router"
+ },
+ "minimumRequiredNodeTextPx": 6,
+ "readabilityOk": true,
+ "hasLegend": true,
+ "hasNavigationDock": true,
+ "legendDockIntersectionArea": 0,
+ "dockStageIntersectionArea": 0,
+ "dockStageGap": 10,
+ "requiredDockStageGap": 10,
+ "viewerChromeStageOk": true,
+ "viewerChromeReserve": 54,
+ "viewerChromeActive": true,
+ "viewerChromeOk": true,
+ "resolvedTheme": "dark",
+ "file": "routing-n-tier.visual-check.1440x900.dark.png"
+ },
+ {
+ "width": 2048,
+ "height": 1320,
+ "theme": "light",
+ "innerWidth": 2048,
+ "innerHeight": 1320,
+ "scrollWidth": 2048,
+ "scrollHeight": 1320,
+ "overflowX": false,
+ "overflowY": false,
+ "verticalScrollAccepted": false,
+ "overflowDisposition": "contained",
+ "readerLayout": "adaptive",
+ "readerOverflow": null,
+ "readerFit": "intrinsic-height",
+ "ok": true,
+ "readerWidth": 1831,
+ "diagramWidth": 1781,
+ "pageComposition": {
+ "bodyPaddingPx": 64,
+ "headerPx": 68,
+ "diagramChromePx": 94,
+ "svgPx": 1082,
+ "cardsPx": 0,
+ "viewBoxHeight": 638
+ },
+ "viewBoxWidth": 1050,
+ "minimumProjectedNodeTextPx": 8,
+ "minimumProjectedNonEdgeTextPx": 8.7,
+ "minimumProjectedEdgeTextPx": 8,
+ "minimumProjectedNodeText": "POST /v1/messages",
+ "minimumProjectedNodeTextDetail": "edge",
+ "minimumProjectedNodeTextOwner": {
+ "kind": "edge",
+ "id": "client-in",
+ "from": "client",
+ "to": "router"
+ },
+ "minimumRequiredNodeTextPx": 6,
+ "readabilityOk": true,
+ "hasLegend": true,
+ "hasNavigationDock": true,
+ "legendDockIntersectionArea": 0,
+ "dockStageIntersectionArea": 0,
+ "dockStageGap": 10,
+ "requiredDockStageGap": 10,
+ "viewerChromeStageOk": true,
+ "viewerChromeReserve": 44,
+ "viewerChromeActive": true,
+ "viewerChromeOk": true,
+ "resolvedTheme": "light",
+ "file": "routing-n-tier.visual-check.2048x1320.light.png"
+ },
+ {
+ "width": 2048,
+ "height": 1320,
+ "theme": "dark",
+ "innerWidth": 2048,
+ "innerHeight": 1320,
+ "scrollWidth": 2048,
+ "scrollHeight": 1320,
+ "overflowX": false,
+ "overflowY": false,
+ "verticalScrollAccepted": false,
+ "overflowDisposition": "contained",
+ "readerLayout": "adaptive",
+ "readerOverflow": null,
+ "readerFit": "intrinsic-height",
+ "ok": true,
+ "readerWidth": 1831,
+ "diagramWidth": 1781,
+ "pageComposition": {
+ "bodyPaddingPx": 64,
+ "headerPx": 68,
+ "diagramChromePx": 94,
+ "svgPx": 1082,
+ "cardsPx": 0,
+ "viewBoxHeight": 638
+ },
+ "viewBoxWidth": 1050,
+ "minimumProjectedNodeTextPx": 8,
+ "minimumProjectedNonEdgeTextPx": 8.7,
+ "minimumProjectedEdgeTextPx": 8,
+ "minimumProjectedNodeText": "POST /v1/messages",
+ "minimumProjectedNodeTextDetail": "edge",
+ "minimumProjectedNodeTextOwner": {
+ "kind": "edge",
+ "id": "client-in",
+ "from": "client",
+ "to": "router"
+ },
+ "minimumRequiredNodeTextPx": 6,
+ "readabilityOk": true,
+ "hasLegend": true,
+ "hasNavigationDock": true,
+ "legendDockIntersectionArea": 0,
+ "dockStageIntersectionArea": 0,
+ "dockStageGap": 10,
+ "requiredDockStageGap": 10,
+ "viewerChromeStageOk": true,
+ "viewerChromeReserve": 44,
+ "viewerChromeActive": true,
+ "viewerChromeOk": true,
+ "resolvedTheme": "dark",
+ "file": "routing-n-tier.visual-check.2048x1320.dark.png"
+ }
+ ],
+ "contactSheet": "routing-n-tier.visual-check.html"
+ },
+ "sidecars": {
+ "directory": "/tmp/rnt-vc",
+ "receipt": "routing-n-tier.visual-check.json",
+ "contactSheet": "routing-n-tier.visual-check.html",
+ "files": [
+ {
+ "sha256": "66df26beefaa888ecef7d4425e89c4b9b148f309fd42e6159cc292c5c562d4d8",
+ "bytes": 1928,
+ "file": "routing-n-tier.visual-check.html"
+ },
+ {
+ "sha256": "59168cac2790d9043dca834bb431b9c9d3c017d3039ef47c3d9be05dd9ac17b1",
+ "bytes": 116528,
+ "file": "routing-n-tier.visual-check.1440x900.light.png"
+ },
+ {
+ "sha256": "b68694b48d61666ff6974b79783247b61d0489fff21968772f656c4c631c3fcb",
+ "bytes": 123186,
+ "file": "routing-n-tier.visual-check.1440x900.dark.png"
+ },
+ {
+ "sha256": "8924b4b906df03fd478ca2aa545503bd5ce2237e5e4ffd12e911849a4769e081",
+ "bytes": 169842,
+ "file": "routing-n-tier.visual-check.2048x1320.light.png"
+ },
+ {
+ "sha256": "2ad64b91dc9c49bde909066b12edb99d6ea0b46521ef92f79472d3ebbf9201ee",
+ "bytes": 182962,
+ "file": "routing-n-tier.visual-check.2048x1320.dark.png"
+ }
+ ]
+ }
+}
diff --git a/docs/zh-CN/README.md b/docs/zh-CN/README.md
index c5a5e5d..7bc689e 100644
--- a/docs/zh-CN/README.md
+++ b/docs/zh-CN/README.md
@@ -1,17 +1,11 @@
-[English](../../README.md) | [简体中文](./README.md)
-
-
-
-#
coding-proxy
-
-**面向 Claude Code 的多供应商高可用透明智能代理**
-
-[](https://www.python.org/)
-[](#)
-[](https://github.com/astral-sh/uv)
-[](#)
+- 📖 **[用户操作指引 (User Guide)](../user-guide.md)** — 从安装、最小配置要求,到每一项配置字段的具体语义和常见排障指南。
+- 🏗️ **[架构设计与工程方案 (Architecture Framework)](../framework.md)** — 详细解码底层设计模式(Template Method、Circuit Breaker、State Machine 等),面向想深入了解或贡献新供应商的开发者。
-
+| 分类 | 文档 |
+| :--- | :--- |
+| 实操指引 | [快速开始](../guide/quickstart.md) · [供应商配置](../guide/vendors.md) · [CLI 参考](../guide/cli-reference.md) · [HTTP API](../guide/api-reference.md) · [Dashboard](../guide/dashboard.md) · [监控与排障](../guide/monitoring.md) |
+| 架构 | [设计模式](../arch/design-patterns.md) · [请求路由](../arch/routing.md) · [供应商模块](../arch/vendors.md) · [协议转换](../arch/convert.md) · [配置字段参考](../arch/config-reference.md) · [Session Model Bind](../arch/session-model-bind.md) · [订阅状态](../arch/subscription-status.md) · [测试](../arch/testing.md) |
+| 运维与设计 | [CI/CD](../ops/ci-cd.md) · [Config 页 UX](../design/config-tab-ux-batch1.md) · [架构图](../diagrams/) |
---
@@ -33,10 +27,10 @@
-- **⛓️ N-tier 链式故障转移 (Failover)**:自主降序序列,支持 Claude 官方 Plans,以及 GitHub Copilot、Google Antigravity、智谱、MiniMax、阿里千问、小米、Kimi、豆包等的 Coding Plan。
+- **⛓️ N-tier 链式故障转移 (Failover)**:自主降序序列,支持 Claude 官方 Plans,以及 GitHub Copilot、Google Antigravity、智谱、MiniMax、阿里千问、小米、Kimi、豆包等的 Coding Plan。。链路顺序可在 Dashboard、CLI(`reset -v`、`session bind`)或会话级策略里运行时调整
- **🛡️ 智能弹性与容灾守卫**:每个供应商节点独立配备 **熔断器 (Circuit Breaker)** 与 **配额守卫 (Quota Guard)**,防雪崩、主动避险。
- **👻 透明无感代理机制**:对客户端 **100% 透明**!无需修改任何代码,仅需一行配置覆盖 `ANTHROPIC_BASE_URL` 即可接入。
-- **🔄 跨模型与全格式转换**:原生支持 Anthropic ←→ Gemini、Anthropic ←→ OpenAI 的请求与流式响应(SSE)双向转换,并支持自动/自助映射模型名称(如 `claude-*` 至 `glm-*`)。
+- **🔄 跨模型与全格式转换**:原生支持 Anthropic ←→ Gemini、Anthropic ←→ OpenAI 的请求与流式响应(SSE)双向转换,并支持自动/自助映射模型名称(如 `claude-*` 至 `glm-*`);另有面向 Antigravity 客户端的原生 Gemini 协议透传网关。跨供应商切换时会话亲和与 tool_call 映射保持不变。
- **📊 极致可观测性 (Observability)**:内置基于 `SQLite WAL` 的本地监控追踪,CLI 提供一键输出详细的 Token 用量统计面板(`coding-proxy usage`)。
- **⚡ 超轻量单机部署**:全异步架构 (`FastAPI` + `httpx`),无需依赖 Redis、消息队列等外部组件,对开发者机器无额外负担。
@@ -51,25 +45,27 @@
### 2. 闪电安装
```bash
-uv add coding-proxy
+uv tool install coding-proxy
```
+(源码运行:在仓库内 `uv sync`,下文命令加 `uv run` 前缀。)
+
### 3. 点火启动
```bash
## (可选)推荐启用智谱 GLM,使用环境变量防御性地注入密钥
# export ZHIPU_API_KEY="your-api-key-here"
## 也可把密钥加密写入配置存储(值不回显)
-# echo -n "sk-..." | uv run coding-proxy config set-secret vendors.zhipu.api_key --stdin
+# echo -n "sk-..." | coding-proxy config set-secret vendors.zhipu.api_key --stdin
# 以存储的配置启动 coding-proxy
# 运行时配置存于 ~/.coding-proxy/config.db(SQLite,密钥加密);
# 经 Dashboard → Config 页或 `coding-proxy config` 命令在线修改,无需编辑 YAML。
# 旧版 ~/.coding-proxy/config.yaml 会在首次启动时自动一次性导入。
-uv run coding-proxy start
+coding-proxy start
## 参数 `-c` 指定旧 YAML 作为一次性迁移导入源
-# uv run coding-proxy start -c ./coding-proxy.yaml
+# coding-proxy start -c ./coding-proxy.yaml
# INFO: Started server process [1403]
# INFO: Waiting for application startup.
@@ -90,6 +86,28 @@ export ANTHROPIC_BASE_URL=http://127.0.0.1:3392
claude
```
+### 4.1 接入 PI
+
+PI 没有 env 重定向入口,内置的 `anthropic` provider 必须指向代理。打开 **Dashboard → Config → Clients → PI → 「写入 models.json」** 一键合并写入 `~/.pi/agent/models.json`(也可以自己粘贴):
+
+```bash
+export CODING_PROXY_TOKEN="coding-proxy" # PI 要求 apiKey 非空,代理不校验该值
+```
+
+```json
+{
+ "providers": {
+ "anthropic": {
+ "baseUrl": "http://127.0.0.1:3392",
+ "apiKey": "$CODING_PROXY_TOKEN",
+ "compat": { "sendSessionAffinityHeaders": true, "sessionAffinityFormat": "openrouter" }
+ }
+ }
+}
+```
+
+之前在 PI 里对 Anthropic 执行过 `/login` 的,先 `/logout anthropic`(`auth.json` 优先级更高)。Claude Code 与 PI 共用同一条供应商链:模型映射、故障转移、Model Bind 与用量/费用统计对两者一视同仁,用 `coding-proxy status`(熔断器 / 配额状态)和 `coding-proxy usage`(按客户端 / 供应商 / 模型的 Token 开销)核对。
+
### 5. 打开监控看板
想实时观测 Token 消耗、延迟以及各层熔断状态?在浏览器中打开:
@@ -98,7 +116,12 @@ claude
open http://127.0.0.1:3392/dashboard
```
-**Config** 页签支持在线编辑全部配置(vendors、tiers、故障转移、模型映射、定价、native_api、会话策略),保存即热切换生效、无需重启;首次进入用 `coding-proxy config token` 输出的 admin token 解锁。
+**Config** 页签支持在线编辑全部配置(vendors、tiers 链序、故障转移、模型映射、定价、native_api、会话策略、Antigravity 网关、客户端接入、系统),保存即热切换生效、无需重启;首次进入用 `coding-proxy config token` 输出的 admin token 解锁。
+
+| Config 页 | Sessions | Model Calling |
+|:---:|:---:|:---:|
+|  |  |  |
+
---
@@ -106,14 +129,15 @@ open http://127.0.0.1:3392/dashboard
`coding-proxy` 附带了强大的 CLI 工具套件,帮助您全面掌控代理状态。
-| 指令 | 说明 | 示例用法 |
-| :------- | :------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------- |
-| `start` | **启动代理服务器**。支持自定义端口;`-c` 指定旧 YAML 作为一次性迁移导入源。 | `coding-proxy start -p 8080` |
-| `config` | **管理配置存储**(`~/.coding-proxy/config.db`)。子命令:`set`、`reset`、`set-secret`(加密写入密钥)、`import` / `export`、`token`。 | `coding-proxy config set vendors.zhipu.timeout_ms 60000` |
-| `auth` | **管理 OAuth 登录凭证**。子命令:`login`(浏览器 OAuth 登录)、`status`(令牌状态)、`reauth`(重认证)、`logout`(清除令牌)。 | `coding-proxy auth login -p github` |
-| `status` | **查看代理健康状态**。展示各层级熔断器(OPEN/CLOSED)与配额状态。 | `coding-proxy status` |
-| `usage` | **Token 统计看板**。按天/供应商/模型维度追踪每一次的 Token 消耗、故障转移及耗时。 | `coding-proxy usage -d 7 -v anthropic` |
-| `reset` | **强制一键重置**。人工确认主供应商恢复可用后,立刻初始化所有熔断器和配额状态。 | `coding-proxy reset` |
+| Command | Description | Example Usage |
+| :------- | :---------- | :------------ |
+| `start` | **启动代理服务器**。`-p` / `-h` 指定端口与监听地址;`-c` 指定旧 YAML 作为一次性迁移导入源。 | `coding-proxy start -p 8080` |
+| `config` | **管理配置存储**(`~/.coding-proxy/config.db`)。子命令:`set`、`reset`、`set-secret`(加密写入;`--stdin`、`--env`、`--clear`、`--default-env`)、`import` / `export`(YAML,密钥脱敏)、`path`、`token`(Dashboard admin token)。 | `coding-proxy config set vendors.zhipu.timeout_ms 60000` |
+| `auth` | **管理 OAuth 登录凭证**。子命令:`login`(浏览器 OAuth;`-p github` 对应 Copilot、`-p google` 对应 Antigravity,省略则两者都登)、`status`、`reauth`、`logout`。 | `coding-proxy auth login -p github` |
+| `status` | **查看代理健康状态**。展示各层级熔断器(OPEN/CLOSED)与配额状态。 | `coding-proxy status` |
+| `session`| **会话级路由覆盖**。`bind` 为指定会话钉住 vendor 优先级(可选会话级模型),`unbind` 解除,`list` 查看全部绑定;与 Dashboard 的 Model Bind 列是同一份数据。 | `coding-proxy session bind --help` |
+| `usage` | **Token 统计看板**。按天(`-d`)、周(`-w`)、月(`-m`)或全部历史(`-t`)统计 Token、故障转移与耗时,可按供应商(`-v`)或实际服务模型(`--model`)过滤。 | `coding-proxy usage -d 7 -v anthropic` |
+| `reset` | **强制一键重置**。重置所有熔断器和配额状态;加 `-v` 同时提升 / 重排 vendor 优先级,让已恢复的供应商优先被尝试。 | `coding-proxy reset -v zhipu` |
---
@@ -121,56 +145,7 @@ open http://127.0.0.1:3392/dashboard
当请求到达时,`RequestRouter` 会顺着 N-tier 树形层级,结合熔断与计算配额,决定发往哪一具体通道:
-```mermaid
-graph RL
- %% 样式定义 (支持明暗双色模式的高对比色彩)
- classDef client fill:#1E3A8A,stroke:#60A5FA,stroke-width:2px,color:#EFF6FF,rx:8,ry:8
- classDef router fill:#4C1D95,stroke:#A78BFA,stroke-width:2px,color:#F5F3FF,rx:8,ry:8
- classDef gateway fill:#7C2D12,stroke:#FB923C,stroke-width:2px,color:#FFF7ED
- classDef api fill:#14532D,stroke:#4ADE80,stroke-width:2px,color:#F0FDF4
- classDef fallback fill:#27272A,stroke:#A1A1AA,stroke-width:2px,color:#F4F4F5
-
- Client["💻 Client (Claude Code)"]:::client
-
- subgraph CodingProxy["coding-proxy"]
- direction RL
-
- Router["RequestRouterrouting/router.py"]:::router
-
- Router -->NTier
-
- subgraph NTier["N-tier"]
- direction TB
-
- subgraph Tier0 ["Tier 0: Zhipu"]
- direction RL
- G0{"CB / Quota"}:::gateway -- "✅ Pass" --> API0(("GLM API")):::api
- end
-
- subgraph Tier1 ["Tier 1: Anthropic"]
- direction RL
- G1{"CB / Quota"}:::gateway -- "✅ Pass" --> API1(("Anthropic API")):::api
- end
-
- subgraph Tier2 ["Tier 2: GitHub Copilot"]
- direction RL
- G2{"CB / Quota"}:::gateway -- "✅ Pass" --> API2(("Copilot API")):::api
- end
-
- subgraph Tier3 ["Tier 3: Google Antigravity"]
- direction RL
- API3(("Gemini API")):::fallback
- end
-
- Tier0 -. "❌ Blocked / API Error" .-> Tier1
- Tier1 -. "❌ Blocked / API Error" .-> Tier2
- Tier2 -. "🆘 Safety Net Downgrade" .-> Tier3
- end
-
- end
-
- Client -->|"POST /v1/messages"| CodingProxy
-```
+
*详细架构设计与机制,请深入阅读 [framework.md](../framework.md)*
diff --git a/pyproject.toml b/pyproject.toml
index 1584622..2c60a8d 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[project]
name = "coding-proxy"
-version = "0.6.20"
+version = "0.6.21"
description = "A High-Availability, Transparent, and Smart Multi-Vendor Proxy for Claude Code. Support Claude Plans, GitHub Copilot, Google Antigravity, ZAI/GLM, MiniMax, Qwen, Xiaomi, Kimi, Doubao..."
readme = "README.md"
requires-python = ">=3.12"
diff --git a/src/coding/proxy/routing/session_title.py b/src/coding/proxy/routing/session_title.py
index f369a74..1467b82 100644
--- a/src/coding/proxy/routing/session_title.py
+++ b/src/coding/proxy/routing/session_title.py
@@ -171,6 +171,14 @@ def sanitize_user_text(raw: str) -> str:
True,
),
)
+AUXILIARY_TITLE_TAGS: tuple[str, ...] = tuple(
+ tag for _, tag, _, _, _ in _INJECTED_PROMPT_FAMILIES
+)
+
+
+def is_auxiliary_title(title: str) -> bool:
+ """标题是否为 harness 注入式辅助调用(会话命名、分支命名、记忆压缩等)的产物."""
+ return any(title.startswith(f"{tag} ") for tag in AUXILIARY_TITLE_TAGS)
# task-notification 载荷凝缩:注入载荷常为 harness 的任务通知 XML 块,
diff --git a/src/coding/proxy/server/dashboard.py b/src/coding/proxy/server/dashboard.py
index 0e30642..a9c148d 100644
--- a/src/coding/proxy/server/dashboard.py
+++ b/src/coding/proxy/server/dashboard.py
@@ -27,6 +27,7 @@
from ..config.schema import ProxyConfig
from ..config.ui_registry import REGISTRY
from ..logging.db import TimePeriod
+from ..routing.session_title import is_auxiliary_title
from .security import ADMIN_TOKEN_HEADER, admin_token_matches
# ── 品牌图标:Tabler prompt 核心笔划(> 与 _)+ 通透青绿圆环 ──────────────
@@ -1298,6 +1299,9 @@ def file_response(self, *args: Any, **kwargs: Any) -> Response:
'), agDetail);
assert.ok(agDetail.includes('Clientantigravity'), agDetail);
+ // 辅助会话:默认隐藏、计数提示;开关打开后带「辅助」tag 显示
+ allSessions = [
+ { session_key: 'aux-1', client_categories: 'pi', title: '[分支命名] File: README.md', auxiliary: true },
+ { session_key: 'main-1', client_categories: 'pi', title: 'File: README.md', auxiliary: false },
+ ];
+ var info; document.getElementById = (id) => id === 'sessions-tbody' ? { set innerHTML(v) { out = v; } } : { set textContent(v) { if (id === 'page-info') info = v; } };
+ sessionPage = 0; renderSessionPage();
+ assert.ok(!out.includes('aux-1'), out);
+ assert.ok(info.includes('已隐藏 1 个辅助会话'), info);
+ sessionShowAux = true; renderSessionPage();
+ assert.ok(out.includes('aux-1') && out.includes('>辅助'), out);
+ assert.ok(!info.includes('已隐藏'), info);
console.log('SESSIONS_OK');
"""
)
@@ -139,3 +152,39 @@ def test_sessions_render_non_cc_rows(client: TestClient, tmp_path):
)
assert result.returncode == 0, f"node harness failed:\n{result.stderr}"
assert "SESSIONS_OK" in result.stdout
+
+
+def test_sessions_api_marks_auxiliary(tmp_path):
+ """API 层按标题族给 auxiliary 标记(db 层保持纯数据,避免 routing 逆向依赖)."""
+ import asyncio
+ from pathlib import Path
+
+ from coding.proxy.logging.db import TokenLogger
+
+ async def seed() -> TokenLogger:
+ tl = TokenLogger(Path(tmp_path) / "api.db")
+ await tl.init()
+ await tl.log(
+ vendor="zhipu", model_requested="m", model_served="m", session_key="aux"
+ )
+ await tl.log(
+ vendor="zhipu", model_requested="m", model_served="m", session_key="main"
+ )
+ await tl.set_session_title("aux", "[分支命名] File: README.md")
+ return tl
+
+ tl = asyncio.run(seed())
+ app = FastAPI()
+ app.state.token_logger = tl
+ register_dashboard_routes(app)
+ try:
+ data = (
+ TestClient(app, base_url="http://127.0.0.1:3392")
+ .get("/api/dashboard/sessions")
+ .json()
+ )
+ finally:
+ asyncio.run(tl.close())
+ sessions = {s["session_key"]: s for s in data["sessions"]}
+ assert sessions["aux"]["auxiliary"] is True
+ assert sessions["main"]["auxiliary"] is False
diff --git a/tests/test_session_title_auxiliary.py b/tests/test_session_title_auxiliary.py
new file mode 100644
index 0000000..576f99e
--- /dev/null
+++ b/tests/test_session_title_auxiliary.py
@@ -0,0 +1,43 @@
+"""辅助会话标题判定:标签族与标题提取共用同一份家族表."""
+
+from __future__ import annotations
+
+import pytest
+
+from coding.proxy.routing.session_title import (
+ _INJECTED_PROMPT_FAMILIES,
+ AUXILIARY_TITLE_TAGS,
+ derive_title_from_user_texts,
+ is_auxiliary_title,
+)
+
+
+def test_tags_derived_from_prompt_families():
+ assert AUXILIARY_TITLE_TAGS == tuple(
+ tag for _, tag, _, _, _ in _INJECTED_PROMPT_FAMILIES
+ )
+
+
+@pytest.mark.parametrize(
+ "title, expected",
+ [
+ ("[分支命名] File: README.md", True),
+ ("[会话命名] 修一下登录", True),
+ ("[记忆压缩] ", True),
+ ("File: README.md", False),
+ ("", False),
+ ("[分支命名]无空格", False),
+ ("xx [分支命名] ", False),
+ ],
+)
+def test_is_auxiliary_title(title: str, expected: bool):
+ assert is_auxiliary_title(title) is expected
+
+
+def test_extracted_injected_title_is_auxiliary():
+ title = derive_title_from_user_texts(
+ [
+ "Generate a short git branch name that summarizes the task.\nUser request: 重制 README 架构图"
+ ]
+ )
+ assert title and is_auxiliary_title(title)
diff --git a/uv.lock b/uv.lock
index 385f019..4edf920 100644
--- a/uv.lock
+++ b/uv.lock
@@ -159,7 +159,7 @@ wheels = [
[[package]]
name = "coding-proxy"
-version = "0.6.20"
+version = "0.6.21"
source = { editable = "." }
dependencies = [
{ name = "aiosqlite" },