Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 设置每模型并发度。
Expand Down
113 changes: 33 additions & 80 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

<div align="center">

# <img src="assets/logo.svg" alt="coding-proxy" width="32" height="32" align="absmiddle"> coding-proxy

**A High-Availability, Transparent, and Smart Multi-Vendor Proxy for Claude Code**

[![Python Version](https://img.shields.io/badge/python-3.12%2B-blue?style=flat-square&logo=python)](https://www.python.org/)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue?style=flat-square)](#)
[![Package Manager](https://img.shields.io/badge/pkg-uv-purple?style=flat-square)](https://github.com/astral-sh/uv)
[![Architecture](https://img.shields.io/badge/architecture-N--tier-orange?style=flat-square)](#)

</div>
| 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/) |

---

Expand All @@ -33,10 +27,10 @@ When you're deeply immersed in your coding "zone" with **Claude Code** (or any A
<img src="https://raw.githubusercontent.com/ThreeFish-AI/coding-proxy/master/assets/dashboard/overview.png" alt="coding-proxy Dashboard Overview">
</div>

- **⛓️ 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.

Expand All @@ -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):
Expand All @@ -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

Expand Down Expand Up @@ -109,79 +106,35 @@ 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 |
|:---:|:---:|:---:|
| ![Config tab](./assets/dashboard/config-tab.png) | ![Sessions](./assets/session-v0.4.0.png) | ![Model Calling](./assets/model-calling-v0.5.0.png) |

---

## 🛠️ The CLI Console Guide

`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` |

---

## 📐 Architectural Panorama

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["💻<br/>Client (Claude Code)"]:::client

subgraph CodingProxy["coding-proxy"]
direction RL

Router["RequestRouter<br/><code>routing/router.py</code>"]:::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
```
![N-tier 链式路由:一次 /v1/messages 请求怎么选 vendor](docs/diagrams/routing-n-tier/routing-n-tier.svg)

*For a deep dive into the architecture and under-the-hood wizardry, consult [framework.md](./docs/framework.md) (Currently in Chinese).*

Expand Down
Loading
Loading