@musistudio/claude-code-router 3.0.4 → 3.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +178 -369
- package/README_zh.md +178 -368
- package/dist/main/cli.js +2818 -343
- package/dist/main/fusion-vision-mcp.js +6 -6
- package/dist/renderer/assets/main.css +1 -1
- package/dist/renderer/assets/main.js +40 -40
- package/dist/renderer/assets/tray.js +8 -8
- package/package.json +2 -2
package/README_zh.md
CHANGED
|
@@ -1,374 +1,184 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
<td align="left">
|
|
31
|
-
<p>
|
|
32
|
-
<strong>感谢 Kimi 赞助本项目!</strong>Kimi K2.7 Code 是 Moonshot AI 推出的编程专用开源智能体模型,在真实长程编程与复杂软件工程工作流中显著提升端到端任务成功率,同时优化推理效率,相比 K2.6 平均减少约 30% 的推理 token 消耗。在 CCR 中,Kimi 已作为内置供应商预设开箱即用:无论按量付费 API 还是 Kimi Code 订阅,一键导入即可把你的编程 Agent 请求路由到 Kimi,订阅端点原生直通、无需协议转换,API 端点自动适配,账户余额与订阅用量也能直接在 CCR 面板中查看。
|
|
33
|
-
</p>
|
|
34
|
-
<p align="center">
|
|
35
|
-
CCR 已内置 Kimi 供应商预设。前往 Kimi 开放平台(<a href="https://platform.kimi.com?aff=ccr">中文站</a>|<a href="https://platform.kimi.ai?aff=ccr">Global</a>)体验 API,或了解高性价比 <a href="https://www.kimi.com/code?aff=ccr">Coding Plan</a> 套餐。
|
|
36
|
-
</p>
|
|
37
|
-
</td>
|
|
38
|
-
</tr>
|
|
39
|
-
</table>
|
|
40
|
-
|
|
41
|
-
</div>
|
|
42
|
-
|
|
43
|
-
Claude Code Router Desktop 是一个本地网关和桌面控制台,用来把 Claude Code、Codex、ZCode 以及兼容客户端的 Agent 请求路由到你真正想使用的模型服务。
|
|
44
|
-
|
|
45
|
-
<p align="center">
|
|
46
|
-
<img src="blog/images/claude-code-router.png" width="720" alt="Claude Code Router Desktop 项目截图" />
|
|
47
|
-
</p>
|
|
48
|
-
|
|
49
|
-
## 为什么使用 CCR
|
|
50
|
-
|
|
51
|
-
- 用一个本地入口连接多个 Agent 工具,不需要在每个客户端里重复配置 Provider。
|
|
52
|
-
- 在不改变工作流的情况下混用不同 Provider。CCR 支持 OpenAI 兼容 API、Anthropic Messages、Gemini Generate Content、OpenRouter、DeepSeek、SiliconFlow、Moonshot、Kimi Code、Mistral、Z.AI、百炼以及自定义 Provider。
|
|
53
|
-
- 通过 fallback 路由、API Key 轮换、用量统计和请求日志来控制成本和可靠性。
|
|
54
|
-
|
|
55
|
-
## 功能和特性
|
|
56
|
-
|
|
57
|
-
- **概览仪表盘**:查看系统状态、用量组件、账号余额、模型分布和分享卡片。
|
|
58
|
-
- **Provider 管理**:添加预设或自定义端点,探测协议支持,检测模型连通性,管理凭据,并在可用时查看账号余额。
|
|
59
|
-
- **路由规则**:配置条件路由、模型前缀规则、失败降级和请求改写。
|
|
60
|
-
- **Agent配置**:为 Claude Code、Codex 和 ZCode 配置启动入口、模型、作用范围和多开 App 配置。
|
|
61
|
-
- **网关兼容层**:通过本地 CCR 模型网关转换支持的客户端请求。
|
|
62
|
-
- **代理模式**:通过本地代理捕获支持的 API 流量,可选系统代理和网络捕获。
|
|
63
|
-
- **Fusion 组合模型**:把基础模型与视觉、联网搜索或 MCP 工具组合成新的可选模型。
|
|
64
|
-
|
|
65
|
-
## 文档
|
|
66
|
-
|
|
67
|
-
完整文档见 [ccrdesk.top](https://ccrdesk.top/)。
|
|
68
|
-
|
|
69
|
-
## 下载和安装
|
|
70
|
-
|
|
71
|
-
1. 打开 [GitHub Releases 页面](https://github.com/musistudio/claude-code-router/releases)。
|
|
72
|
-
2. 按系统下载对应安装包:
|
|
73
|
-
- macOS Apple 芯片:`Claude-Code-Router_<version>-mac-Apple-Silicon-arm64.dmg` 或 `.zip`
|
|
74
|
-
- macOS Intel 芯片:`Claude-Code-Router_<version>-mac-Intel-x64.dmg` 或 `.zip`
|
|
75
|
-
- Windows:`Claude Code Router_<version>.exe`
|
|
76
|
-
- Linux:`Claude Code Router_<version>.AppImage`
|
|
77
|
-
3. 安装并启动 **Claude Code Router**。
|
|
78
|
-
4. 首次启动后,CCR 会创建本地配置数据库:
|
|
79
|
-
- macOS/Linux:`~/.claude-code-router/config.sqlite`
|
|
80
|
-
- Windows:`%APPDATA%\Claude Code Router\config.sqlite`
|
|
81
|
-
|
|
82
|
-
CCR 的运行配置存储在 SQLite 中。旧版 `config.json` 只会在没有 SQLite 配置时作为迁移来源读取一次。
|
|
83
|
-
|
|
84
|
-
从 **服务** 页面启动后,CCR 默认监听 `http://localhost:8080`。**服务** 页面负责配置网关 `Host`、`Port`、代理模式、系统代理、网络捕获和 CA 证书状态。
|
|
1
|
+
# Claude Code Router CLI
|
|
2
|
+
|
|
3
|
+
[English](README.md) · [完整文档](https://ccrdesk.top/) · [GitHub](https://github.com/musistudio/claude-code-router)
|
|
4
|
+
|
|
5
|
+
`@musistudio/claude-code-router` 是 Claude Code Router 的 Node.js 发行版。它通过 `ccr` 命令提供浏览器管理界面、本地模型网关和 Agent 配置启动能力,不需要安装 Electron。
|
|
6
|
+
|
|
7
|
+
CLI 适合开发机和无桌面的服务器。如果你需要系统托盘、桌面通知、应用自动更新或桌面端专属的浏览器集成,请安装桌面应用。
|
|
8
|
+
|
|
9
|
+
## 环境要求与安装
|
|
10
|
+
|
|
11
|
+
- Node.js 22 或更高版本
|
|
12
|
+
- 一个可用的上游模型供应商,或 CCR 支持导入的本机 Agent 登录态
|
|
13
|
+
- 使用配置启动命令时,本机需要已经安装对应 Agent
|
|
14
|
+
|
|
15
|
+
全局安装:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm install -g @musistudio/claude-code-router
|
|
19
|
+
ccr --help
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
升级或卸载:
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
npm install -g @musistudio/claude-code-router@latest
|
|
26
|
+
npm uninstall -g @musistudio/claude-code-router
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
卸载 npm 包不会删除 CCR 的本地配置和数据库。
|
|
85
30
|
|
|
86
31
|
## 快速开始
|
|
87
32
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
<
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
<td align="center" width="220">@*说</td>
|
|
237
|
-
</tr>
|
|
238
|
-
<tr>
|
|
239
|
-
<td align="center" width="220">@*更</td>
|
|
240
|
-
<td align="center" width="220">@K*g</td>
|
|
241
|
-
<td align="center" width="220">@R*R</td>
|
|
242
|
-
<td align="center" width="220"><a href="https://github.com/bobleer">@bobleer</a></td>
|
|
243
|
-
<td align="center" width="220">@*苗</td>
|
|
244
|
-
<td align="center" width="220">@*划</td>
|
|
245
|
-
</tr>
|
|
246
|
-
<tr>
|
|
247
|
-
<td align="center" width="220"><a href="https://github.com/Clarence-pan">@Clarence-pan</a></td>
|
|
248
|
-
<td align="center" width="220"><a href="https://github.com/carter003">@carter003</a></td>
|
|
249
|
-
<td align="center" width="220">@S*r</td>
|
|
250
|
-
<td align="center" width="220">@*晖</td>
|
|
251
|
-
<td align="center" width="220">@*敏</td>
|
|
252
|
-
<td align="center" width="220">@Z*z</td>
|
|
253
|
-
</tr>
|
|
254
|
-
<tr>
|
|
255
|
-
<td align="center" width="220">@*然</td>
|
|
256
|
-
<td align="center" width="220"><a href="https://github.com/cluic">@cluic</a></td>
|
|
257
|
-
<td align="center" width="220">@*苗</td>
|
|
258
|
-
<td align="center" width="220"><a href="https://github.com/PromptExpert">@PromptExpert</a></td>
|
|
259
|
-
<td align="center" width="220">@*应</td>
|
|
260
|
-
<td align="center" width="220"><a href="https://github.com/yusnake">@yusnake</a></td>
|
|
261
|
-
</tr>
|
|
262
|
-
<tr>
|
|
263
|
-
<td align="center" width="220">@*飞</td>
|
|
264
|
-
<td align="center" width="220">@董*</td>
|
|
265
|
-
<td align="center" width="220">@*汀</td>
|
|
266
|
-
<td align="center" width="220">@*涯</td>
|
|
267
|
-
<td align="center" width="220">@*:-)</td>
|
|
268
|
-
<td align="center" width="220">@**磊</td>
|
|
269
|
-
</tr>
|
|
270
|
-
<tr>
|
|
271
|
-
<td align="center" width="220">@*琢</td>
|
|
272
|
-
<td align="center" width="220">@*成</td>
|
|
273
|
-
<td align="center" width="220">@Z*o</td>
|
|
274
|
-
<td align="center" width="220">@*琨</td>
|
|
275
|
-
<td align="center" width="220"><a href="https://github.com/congzhangzh">@congzhangzh</a></td>
|
|
276
|
-
<td align="center" width="220">@*_</td>
|
|
277
|
-
</tr>
|
|
278
|
-
<tr>
|
|
279
|
-
<td align="center" width="220">@Z*m</td>
|
|
280
|
-
<td align="center" width="220">@*鑫</td>
|
|
281
|
-
<td align="center" width="220">@c*y</td>
|
|
282
|
-
<td align="center" width="220">@*昕</td>
|
|
283
|
-
<td align="center" width="220"><a href="https://github.com/witsice">@witsice</a></td>
|
|
284
|
-
<td align="center" width="220">@b*g</td>
|
|
285
|
-
</tr>
|
|
286
|
-
<tr>
|
|
287
|
-
<td align="center" width="220">@*亿</td>
|
|
288
|
-
<td align="center" width="220">@*辉</td>
|
|
289
|
-
<td align="center" width="220">@JACK</td>
|
|
290
|
-
<td align="center" width="220">@*光</td>
|
|
291
|
-
<td align="center" width="220">@W*l</td>
|
|
292
|
-
<td align="center" width="220"><a href="https://github.com/kesku">@kesku</a></td>
|
|
293
|
-
</tr>
|
|
294
|
-
<tr>
|
|
295
|
-
<td align="center" width="220"><a href="https://github.com/biguncle">@biguncle</a></td>
|
|
296
|
-
<td align="center" width="220">@二吉吉</td>
|
|
297
|
-
<td align="center" width="220">@a*g</td>
|
|
298
|
-
<td align="center" width="220">@*林</td>
|
|
299
|
-
<td align="center" width="220">@*咸</td>
|
|
300
|
-
<td align="center" width="220">@*明</td>
|
|
301
|
-
</tr>
|
|
302
|
-
<tr>
|
|
303
|
-
<td align="center" width="220">@S*y</td>
|
|
304
|
-
<td align="center" width="220">@f*o</td>
|
|
305
|
-
<td align="center" width="220">@*智</td>
|
|
306
|
-
<td align="center" width="220">@F*t</td>
|
|
307
|
-
<td align="center" width="220">@r*c</td>
|
|
308
|
-
<td align="center" width="220"><a href="https://github.com/qierkang">@qierkang</a></td>
|
|
309
|
-
</tr>
|
|
310
|
-
<tr>
|
|
311
|
-
<td align="center" width="220">@*军</td>
|
|
312
|
-
<td align="center" width="220"><a href="https://github.com/snrise-z">@snrise-z</a></td>
|
|
313
|
-
<td align="center" width="220">@*王</td>
|
|
314
|
-
<td align="center" width="220"><a href="https://github.com/greatheart1000">@greatheart1000</a></td>
|
|
315
|
-
<td align="center" width="220">@*王</td>
|
|
316
|
-
<td align="center" width="220">@zcutlip</td>
|
|
317
|
-
</tr>
|
|
318
|
-
<tr>
|
|
319
|
-
<td align="center" width="220"><a href="https://github.com/Peng-YM">@Peng-YM</a></td>
|
|
320
|
-
<td align="center" width="220">@*更</td>
|
|
321
|
-
<td align="center" width="220">@*.</td>
|
|
322
|
-
<td align="center" width="220">@F*t</td>
|
|
323
|
-
<td align="center" width="220">@*政</td>
|
|
324
|
-
<td align="center" width="220">@*铭</td>
|
|
325
|
-
</tr>
|
|
326
|
-
<tr>
|
|
327
|
-
<td align="center" width="220">@*叶</td>
|
|
328
|
-
<td align="center" width="220">@七*o</td>
|
|
329
|
-
<td align="center" width="220">@*青</td>
|
|
330
|
-
<td align="center" width="220">@**晨</td>
|
|
331
|
-
<td align="center" width="220">@*远</td>
|
|
332
|
-
<td align="center" width="220">@*霄</td>
|
|
333
|
-
</tr>
|
|
334
|
-
<tr>
|
|
335
|
-
<td align="center" width="220">@**吉</td>
|
|
336
|
-
<td align="center" width="220">@**飞</td>
|
|
337
|
-
<td align="center" width="220">@**驰</td>
|
|
338
|
-
<td align="center" width="220">@x*g</td>
|
|
339
|
-
<td align="center" width="220">@**东</td>
|
|
340
|
-
<td align="center" width="220">@*落</td>
|
|
341
|
-
</tr>
|
|
342
|
-
<tr>
|
|
343
|
-
<td align="center" width="220">@哆*k</td>
|
|
344
|
-
<td align="center" width="220">@*涛</td>
|
|
345
|
-
<td align="center" width="220"><a href="https://github.com/WitMiao">@苗大</a></td>
|
|
346
|
-
<td align="center" width="220">@*呢</td>
|
|
347
|
-
<td align="center" width="220">@d*u</td>
|
|
348
|
-
<td align="center" width="220">@crizcraig</td>
|
|
349
|
-
</tr>
|
|
350
|
-
<tr>
|
|
351
|
-
<td align="center" width="220">s*s</td>
|
|
352
|
-
<td align="center" width="220">*火</td>
|
|
353
|
-
<td align="center" width="220">*勤</td>
|
|
354
|
-
<td align="center" width="220">**锟</td>
|
|
355
|
-
<td align="center" width="220">*涛</td>
|
|
356
|
-
<td align="center" width="220">**明</td>
|
|
357
|
-
</tr>
|
|
358
|
-
<tr>
|
|
359
|
-
<td align="center" width="220">*知</td>
|
|
360
|
-
<td align="center" width="220">*语</td>
|
|
361
|
-
<td align="center" width="220">*瓜</td>
|
|
362
|
-
<td align="center" width="220"></td>
|
|
363
|
-
<td align="center" width="220"></td>
|
|
364
|
-
<td align="center" width="220"></td>
|
|
365
|
-
</tr>
|
|
366
|
-
</table>
|
|
367
|
-
|
|
368
|
-
<sub>如果你的名字被打码,请通过我的主页邮箱联系我更新为 GitHub 用户名。</sub>
|
|
369
|
-
|
|
370
|
-
</div>
|
|
33
|
+
启动后台服务并打开管理界面:
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
ccr ui
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
然后按以下顺序配置:
|
|
40
|
+
|
|
41
|
+
1. 添加上游供应商和至少一个模型。
|
|
42
|
+
2. 在 **API 密钥** 页面创建 CCR 客户端密钥。
|
|
43
|
+
3. 如果默认供应商 / 模型不够用,再配置路由规则。
|
|
44
|
+
4. 在 **服务** 页面确认网关已经运行。
|
|
45
|
+
5. 把客户端指向界面显示的网关地址。网关默认是 `http://127.0.0.1:3456`,管理界面默认是 `http://127.0.0.1:3458`。
|
|
46
|
+
|
|
47
|
+
管理 Token 和 CCR 客户端 API Key 是两种不同凭据。管理 Token 保护浏览器 UI 和 RPC 接口,CCR 客户端 Key 用于验证发送到模型网关的请求。
|
|
48
|
+
|
|
49
|
+
## 服务命令
|
|
50
|
+
|
|
51
|
+
| 命令 | 行为 |
|
|
52
|
+
| --- | --- |
|
|
53
|
+
| `ccr start` | 在后台启动管理服务和网关,并打印带认证信息的管理 URL。 |
|
|
54
|
+
| `ccr ui` | 复用或启动后台服务,然后打开管理界面。 |
|
|
55
|
+
| `ccr stop` | 停止由 `ccr start` 或 `ccr ui` 启动的后台服务。 |
|
|
56
|
+
| `ccr serve` | 在前台运行管理服务和网关;`ccr web` 是别名。 |
|
|
57
|
+
| `ccr <配置>` | 按名称或 ID 打开一个已启用的 Agent 配置。 |
|
|
58
|
+
|
|
59
|
+
### `ccr start`
|
|
60
|
+
|
|
61
|
+
```text
|
|
62
|
+
ccr start [--host <host>] [--port <port>] [--open|--no-open] [--gateway|--no-gateway]
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
- `--host <host>`:管理服务监听地址,默认 `127.0.0.1`。
|
|
66
|
+
- `--port <port>`:管理服务首选端口,默认 `3458`。
|
|
67
|
+
- `--open` / `--no-open`:是否打开浏览器。
|
|
68
|
+
- `--gateway`:明确要求启动模型网关;这是默认行为。
|
|
69
|
+
- `--no-gateway`:只启动管理服务,不启动模型网关。
|
|
70
|
+
|
|
71
|
+
### `ccr ui`
|
|
72
|
+
|
|
73
|
+
```text
|
|
74
|
+
ccr ui [--host <host>] [--port <port>] [--open|--no-open] [--gateway|--no-gateway]
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
`ui` 默认会打开浏览器。在 SSH 或其他无桌面环境中使用 `--no-open`。
|
|
78
|
+
|
|
79
|
+
### `ccr serve`
|
|
80
|
+
|
|
81
|
+
```text
|
|
82
|
+
ccr serve [--host <host>] [--port <port>] [--open|--no-open] [--gateway|--no-gateway]
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
`serve` 会留在当前终端并处理 `SIGINT` / `SIGTERM`,适合交给进程管理器托管。`ccr stop` 只管理后台服务;前台服务需要在终端或进程管理器中停止。
|
|
86
|
+
|
|
87
|
+
如果首选管理端口已被占用,CCR 会继续尝试后续端口并打印实际 URL。`start` 或 `ui` 复用已运行服务时,新传入的 Host、Port 和 `--no-gateway` 不会重配该进程;要修改这些选项,请先运行 `ccr stop`。
|
|
88
|
+
|
|
89
|
+
## Agent 配置启动
|
|
90
|
+
|
|
91
|
+
先在 **Agent配置** 中创建并启用配置,然后按名称或 ID 启动:
|
|
92
|
+
|
|
93
|
+
```sh
|
|
94
|
+
ccr "Codex - Work"
|
|
95
|
+
ccr "Codex - Work" app
|
|
96
|
+
ccr "Claude - Review" cli -- --model sonnet
|
|
97
|
+
ccr profile-id -- --help
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
完整语法:
|
|
101
|
+
|
|
102
|
+
```text
|
|
103
|
+
ccr <配置名称或 ID> [cli|app] [-- <Agent 参数>]
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
- `--cli` 和 `--app` 也可以代替位置形式的入口类型。
|
|
107
|
+
- Agent 自己的参数建议统一放到 `--` 后,避免被识别为 CCR 参数。
|
|
108
|
+
- 省略入口类型时,Claude Code、Codex、Grok CLI 默认使用 CLI,ZCode 默认使用 App。
|
|
109
|
+
- Grok 只支持 CLI,ZCode 只支持 App。Claude App 和 ZCode App 不接受额外 Agent 参数。
|
|
110
|
+
- 启动桌面 App 时,本机必须已安装对应应用,并且当前环境必须有图形会话。
|
|
111
|
+
- 大多数配置需要先启动 CCR 服务。Grok CLI 配置可以自动启动一个临时共享服务,并在最后一个受管会话退出后停止。
|
|
112
|
+
|
|
113
|
+
桌面应用会安装一个相关命令 `ccr-app`。桌面 Agent配置卡片复制出来的命令使用 `ccr-app`;本文介绍的 npm 包安装的是 `ccr`。
|
|
114
|
+
|
|
115
|
+
## 配置与运行文件
|
|
116
|
+
|
|
117
|
+
| 平台 | 配置目录 |
|
|
118
|
+
| --- | --- |
|
|
119
|
+
| macOS / Linux | `~/.claude-code-router` |
|
|
120
|
+
| Windows | `%APPDATA%\claude-code-router` |
|
|
121
|
+
|
|
122
|
+
重要文件包括:
|
|
123
|
+
|
|
124
|
+
- `config.sqlite`:当前应用配置。
|
|
125
|
+
- `app-data/`:API Key、用量、请求日志、证书等运行数据库和文件。
|
|
126
|
+
- `service.json`:后台 CLI 服务的状态和私有 Token。
|
|
127
|
+
- `gateway.config.json`:生成的网关运行配置。
|
|
128
|
+
- `profiles/` 和 `bin/`:隔离的 Agent 配置和启动包装器。
|
|
129
|
+
|
|
130
|
+
CCR 写入 SQLite 时不要直接编辑或复制活跃数据库。优先使用 UI 导出;要做文件级备份,请先停止 CCR。
|
|
131
|
+
|
|
132
|
+
## 环境变量与安全
|
|
133
|
+
|
|
134
|
+
| 变量 | 说明 |
|
|
135
|
+
| --- | --- |
|
|
136
|
+
| `CCR_WEB_HOST` | 省略 `--host` 时使用的管理服务监听地址。 |
|
|
137
|
+
| `CCR_WEB_PORT` | 省略 `--port` 时使用的管理服务端口。 |
|
|
138
|
+
| `CCR_WEB_AUTH_TOKEN` | 固定管理 UI / RPC 的认证 Token;不设置时每个进程会生成随机 Token。 |
|
|
139
|
+
|
|
140
|
+
认证后的管理 URL 会在查询参数中包含 `ccr_web_token`。请把这个 URL 当作密码,不要复制到日志、工单或公开的 Shell 历史中。除非确实需要远程访问,否则监听地址应保持 `127.0.0.1`。远程访问时,应同时使用防火墙或私网,并在可信反向代理上启用 TLS。
|
|
141
|
+
|
|
142
|
+
不要在未创建 CCR 客户端 API Key 的情况下暴露网关。上游供应商凭据保存在 CCR 本地数据目录中,因此也要保护该目录及其备份。
|
|
143
|
+
|
|
144
|
+
## 常见问题
|
|
145
|
+
|
|
146
|
+
### 找不到 `ccr` 命令
|
|
147
|
+
|
|
148
|
+
确认 Node.js 不低于 22,并检查 npm 全局可执行目录是否在 `PATH`:
|
|
149
|
+
|
|
150
|
+
```sh
|
|
151
|
+
node --version
|
|
152
|
+
npm prefix -g
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
如果 Shell 缓存了命令路径,安装后请打开一个新终端。
|
|
156
|
+
|
|
157
|
+
### 管理 URL 的端口发生变化
|
|
158
|
+
|
|
159
|
+
首选端口已被占用。请使用 CCR 打印的实际 URL,或停止占用端口的进程后重启 CCR。
|
|
160
|
+
|
|
161
|
+
### UI 能打开,但网关不可用
|
|
162
|
+
|
|
163
|
+
管理服务可以在没有可用网关时单独运行。请添加供应商和模型、创建客户端 API Key,然后从 **服务** 页面启动或重启网关。排查启动错误时,可以使用 `ccr serve` 查看前台输出。
|
|
164
|
+
|
|
165
|
+
### 找不到 Agent 配置
|
|
166
|
+
|
|
167
|
+
只有已启用的配置才能启动。名称匹配不区分大小写,也接受清理后的名称;如果多个名称产生歧义,必须使用配置 ID。生成的启动器缺失时,请重新保存配置。
|
|
168
|
+
|
|
169
|
+
### 后台服务仍使用旧参数
|
|
170
|
+
|
|
171
|
+
停止并重新创建服务:
|
|
172
|
+
|
|
173
|
+
```sh
|
|
174
|
+
ccr stop
|
|
175
|
+
ccr start --host 127.0.0.1 --port 3458
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Docker
|
|
179
|
+
|
|
180
|
+
仓库还提供面向模型网关和浏览器 UI 的 Docker 镜像。运行时镜像不会安装 npm 的 `ccr` 命令。请参阅 [Docker 部署文档](https://github.com/musistudio/claude-code-router/blob/main/docker/README.md)。
|
|
371
181
|
|
|
372
182
|
## 许可证
|
|
373
183
|
|
|
374
|
-
|
|
184
|
+
[MIT](LICENSE)
|