@andyzheung/ccmr 1.2.0
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 +321 -0
- package/dist/cli.d.ts +6 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +270 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +24 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +292 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/router.d.ts +22 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.js +234 -0
- package/dist/router.js.map +1 -0
- package/dist/server.d.ts +7 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +186 -0
- package/dist/server.js.map +1 -0
- package/dist/types.d.ts +86 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +67 -0
package/README.md
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
[](https://www.npmjs.com/package/@andyzheung/ccmr)
|
|
2
|
+
[](https://www.npmjs.com/package/@andyzheung/ccmr)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
# CCMR-Plus (Claude Code Model Router Plus)
|
|
6
|
+
|
|
7
|
+
一个轻量级 API 网关,让你在使用 Claude Code 时可以切换到第三方 AI 模型。
|
|
8
|
+
|
|
9
|
+
> 这是 [claude-code-model-router](https://github.com/luwill/Claude-Code-Model-Router) 的增强版本,支持最新的 GLM-5 和 MiniMax M2.5 模型。
|
|
10
|
+
|
|
11
|
+
支持 Windows、macOS、Linux 跨平台使用。
|
|
12
|
+
|
|
13
|
+
## 快速开始
|
|
14
|
+
|
|
15
|
+
### 方式一:使用 npx(推荐)
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# 1. 初始化配置文件
|
|
19
|
+
npx @andyzheung/ccmr init
|
|
20
|
+
|
|
21
|
+
# 2. 编辑 .env 文件,填入 API Keys
|
|
22
|
+
|
|
23
|
+
# 3. 启动网关
|
|
24
|
+
npx @andyzheung/ccmr start
|
|
25
|
+
|
|
26
|
+
# 4. 新开终端,启动 Claude Code
|
|
27
|
+
# 第三方模型(网关模式):
|
|
28
|
+
npx @andyzheung/ccmr claude
|
|
29
|
+
|
|
30
|
+
# 官方订阅(默认模式):
|
|
31
|
+
claude
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### 方式二:全局安装
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm install -g @andyzheung/ccmr
|
|
38
|
+
|
|
39
|
+
# 然后使用 ccmr-plus 命令
|
|
40
|
+
ccmr-plus init
|
|
41
|
+
ccmr-plus start
|
|
42
|
+
|
|
43
|
+
# 启动 Claude Code
|
|
44
|
+
ccmr-plus claude # 第三方模型(网关模式)
|
|
45
|
+
claude # 官方订阅(默认模式)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## 命令说明
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# 初始化配置文件
|
|
52
|
+
npx @andyzheung/ccmr init
|
|
53
|
+
|
|
54
|
+
# 启动网关
|
|
55
|
+
npx @andyzheung/ccmr start
|
|
56
|
+
npx @andyzheung/ccmr start --port 9000 # 指定端口
|
|
57
|
+
|
|
58
|
+
# 查看可用模型
|
|
59
|
+
npx @andyzheung/ccmr models
|
|
60
|
+
|
|
61
|
+
# 启动 Claude Code(网关模式,使用第三方模型)
|
|
62
|
+
npx @andyzheung/ccmr claude
|
|
63
|
+
npx @andyzheung/ccmr claude --gateway-port 9000 # 自定义网关端口
|
|
64
|
+
|
|
65
|
+
# 启动 Claude Code(官方订阅)
|
|
66
|
+
claude
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Claude Code 原生参数支持
|
|
70
|
+
|
|
71
|
+
`ccmr-plus claude` 命令完整支持 Claude Code 的原生启动参数:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# YOLO 模式(跳过所有权限确认)
|
|
75
|
+
ccmr-plus claude --dangerously-skip-permissions
|
|
76
|
+
|
|
77
|
+
# 继续上一次会话
|
|
78
|
+
ccmr-plus claude --continue
|
|
79
|
+
ccmr-plus claude -c
|
|
80
|
+
|
|
81
|
+
# YOLO 模式 + 继续上一次会话
|
|
82
|
+
ccmr-plus claude --dangerously-skip-permissions --continue
|
|
83
|
+
|
|
84
|
+
# 恢复指定会话(交互式选择)
|
|
85
|
+
ccmr-plus claude --resume
|
|
86
|
+
ccmr-plus claude -r
|
|
87
|
+
|
|
88
|
+
# 恢复指定会话 ID
|
|
89
|
+
ccmr-plus claude --resume <session-id>
|
|
90
|
+
|
|
91
|
+
# 调试模式
|
|
92
|
+
ccmr-plus claude --debug
|
|
93
|
+
ccmr-plus claude --verbose
|
|
94
|
+
|
|
95
|
+
# 连接 IDE
|
|
96
|
+
ccmr-plus claude --ide
|
|
97
|
+
|
|
98
|
+
# 指定权限模式
|
|
99
|
+
ccmr-plus claude --permission-mode bypassPermissions
|
|
100
|
+
|
|
101
|
+
# 打印模式(非交互式)
|
|
102
|
+
ccmr-plus claude -p "你的问题"
|
|
103
|
+
ccmr-plus claude --print --output-format json "你的问题"
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**支持的完整参数列表:**
|
|
107
|
+
|
|
108
|
+
| 参数 | 说明 |
|
|
109
|
+
|------|------|
|
|
110
|
+
| `-c, --continue` | 继续最近的会话 |
|
|
111
|
+
| `-r, --resume [id]` | 恢复指定会话或打开会话选择器 |
|
|
112
|
+
| `--fork-session` | 恢复时创建新会话 ID |
|
|
113
|
+
| `--dangerously-skip-permissions` | 跳过所有权限检查(YOLO 模式) |
|
|
114
|
+
| `--permission-mode <mode>` | 权限模式:acceptEdits, bypassPermissions, default, dontAsk, plan |
|
|
115
|
+
| `-p, --print` | 打印模式(非交互式) |
|
|
116
|
+
| `--output-format <format>` | 输出格式:text, json, stream-json |
|
|
117
|
+
| `--model <model>` | 指定模型(覆盖网关路由) |
|
|
118
|
+
| `--system-prompt <prompt>` | 自定义系统提示 |
|
|
119
|
+
| `--add-dir <dirs...>` | 添加额外目录权限 |
|
|
120
|
+
| `-d, --debug` | 调试模式 |
|
|
121
|
+
| `--verbose` | 详细输出 |
|
|
122
|
+
| `--ide` | 自动连接 IDE |
|
|
123
|
+
| `--gateway-port <port>` | 指定网关端口(默认 8080) |
|
|
124
|
+
|
|
125
|
+
> **提示:** 任何 Claude Code 原生支持的参数都可以直接传递给 `ccmr-plus claude`
|
|
126
|
+
|
|
127
|
+
## 支持的模型
|
|
128
|
+
|
|
129
|
+
| 短名称 | 版本别名 | 模型 | 提供商 |
|
|
130
|
+
|--------|----------|------|--------|
|
|
131
|
+
| `deepseek` | `deepseek-v3.2`, `ds` | DeepSeek V3.2 | DeepSeek |
|
|
132
|
+
| `kimi` | `kimi-k2`, `kimi-k2-thinking` | Kimi K2 Thinking | Moonshot |
|
|
133
|
+
| `minimax` | `minimax-m2.5`, `minimax-m2.1`, `mm` | MiniMax M2.5 | MiniMax |
|
|
134
|
+
| `qwen` | `qwen3-max`, `qwen3` | Qwen3 Max | 阿里云 |
|
|
135
|
+
| `glm` | `glm-5`, `glm-4.7`, `zhipu` | GLM 5.0 | 智谱 AI |
|
|
136
|
+
|
|
137
|
+
### 模型参数
|
|
138
|
+
|
|
139
|
+
| 模型 | Context Window | Max Output Tokens |
|
|
140
|
+
|------|----------------|-------------------|
|
|
141
|
+
| DeepSeek V3.2 | 128K | 128K |
|
|
142
|
+
| Kimi K2 Thinking | 256K | 32K |
|
|
143
|
+
| MiniMax M2.5 | 200K | 128K |
|
|
144
|
+
| Qwen3 Max | 256K | 32K |
|
|
145
|
+
| GLM 5.0 | 200K | 128K |
|
|
146
|
+
|
|
147
|
+
## 配置
|
|
148
|
+
|
|
149
|
+
### 环境变量 (.env)
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
DEEPSEEK_API_KEY=sk-xxx # https://platform.deepseek.com/
|
|
153
|
+
KIMI_API_KEY=sk-xxx # https://www.kimi.com/
|
|
154
|
+
MINIMAX_API_KEY=xxx # https://platform.minimax.io/
|
|
155
|
+
QWEN_API_KEY=sk-xxx # https://dashscope.console.aliyun.com/
|
|
156
|
+
GLM_API_KEY=xxx # https://open.bigmodel.cn/
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### 配置文件 (models.yaml)
|
|
160
|
+
|
|
161
|
+
可以自定义模型配置、添加别名等。运行 `ccmr-plus init` 命令会生成模板。
|
|
162
|
+
|
|
163
|
+
## 使用场景
|
|
164
|
+
|
|
165
|
+
### 双模式使用(配置完全隔离)
|
|
166
|
+
|
|
167
|
+
本工具通过独立的配置目录实现完全隔离,让你可以同时使用官方订阅和第三方模型:
|
|
168
|
+
|
|
169
|
+
```
|
|
170
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
171
|
+
│ 模式1: 官方订阅(默认) │
|
|
172
|
+
│ 命令: claude │
|
|
173
|
+
│ 配置: ~/.claude/settings.json │
|
|
174
|
+
│ 用途: 使用 Claude 官方模型(订阅额度) │
|
|
175
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
176
|
+
|
|
177
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
178
|
+
│ 模式2: 第三方模型(网关) │
|
|
179
|
+
│ 命令: npx @andyzheung/ccmr claude │
|
|
180
|
+
│ 配置: ~/.ccmr-plus/settings.json │
|
|
181
|
+
│ 用途: 使用第三方 AI 模型(GLM-5, MiniMax M2.5 等) │
|
|
182
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
#### 为什么配置是隔离的?
|
|
186
|
+
|
|
187
|
+
- **官方模式**使用 `~/.claude/` 配置目录(Claude Code 默认)
|
|
188
|
+
- **网关模式**使用 `~/.ccmr-plus/` 配置目录(独立隔离)
|
|
189
|
+
- 两个配置目录完全独立,互不干扰
|
|
190
|
+
- 在网关模式切换模型不会影响官方模式
|
|
191
|
+
|
|
192
|
+
#### 使用步骤
|
|
193
|
+
|
|
194
|
+
**第一步:启动网关**
|
|
195
|
+
```bash
|
|
196
|
+
npx @andyzheung/ccmr start
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
**第二步:选择使用模式**
|
|
200
|
+
|
|
201
|
+
**使用官方订阅(终端 A):**
|
|
202
|
+
```bash
|
|
203
|
+
claude
|
|
204
|
+
```
|
|
205
|
+
- 使用官方 Claude 模型(Sonnet, Opus, Haiku)
|
|
206
|
+
- 消耗订阅额度
|
|
207
|
+
- 配置存储在 `~/.claude/`
|
|
208
|
+
|
|
209
|
+
**使用第三方模型(终端 B):**
|
|
210
|
+
```bash
|
|
211
|
+
npx @andyzheung/ccmr claude
|
|
212
|
+
```
|
|
213
|
+
- 使用第三方 AI 模型(GLM-5, MiniMax M2.5 等)
|
|
214
|
+
- 按 API 使用量付费
|
|
215
|
+
- 配置存储在 `~/.ccmr-plus/`
|
|
216
|
+
|
|
217
|
+
#### 跨平台支持
|
|
218
|
+
|
|
219
|
+
所有命令在 Windows、macOS、Linux 上完全相同,无需修改。
|
|
220
|
+
|
|
221
|
+
### 在 Claude Code 中切换模型
|
|
222
|
+
|
|
223
|
+
#### 官方模式(直接 `claude` 启动)
|
|
224
|
+
|
|
225
|
+
```
|
|
226
|
+
/model sonnet # Claude Sonnet 4.5
|
|
227
|
+
/model opus # Claude Opus 4.5
|
|
228
|
+
/model haiku # Claude Haiku 3.5
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
#### 网关模式(`npx ... claude` 启动)
|
|
232
|
+
|
|
233
|
+
使用短名称或版本别名切换模型:
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
# 使用短名称(向后兼容)
|
|
237
|
+
/model deepseek # 切换到 DeepSeek V3.2
|
|
238
|
+
/model qwen # 切换到 Qwen3 Max
|
|
239
|
+
/model glm # 切换到 GLM 4.7
|
|
240
|
+
/model kimi # 切换到 Kimi K2 Thinking
|
|
241
|
+
/model minimax # 切换到 MiniMax M2.1
|
|
242
|
+
|
|
243
|
+
# 使用版本别名(明确指定版本)
|
|
244
|
+
/model deepseek-v3.2 # DeepSeek V3.2
|
|
245
|
+
/model glm-5 # GLM 5.0
|
|
246
|
+
/model minimax-m2.5 # MiniMax M2.5
|
|
247
|
+
/model kimi-k2 # Kimi K2 Thinking
|
|
248
|
+
/model qwen3-max # Qwen3 Max
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
**重要:** 两个模式的配置完全独立,在网关模式切换模型不会影响官方模式!
|
|
252
|
+
|
|
253
|
+
## API 端点
|
|
254
|
+
|
|
255
|
+
| 端点 | 方法 | 说明 |
|
|
256
|
+
|------|------|------|
|
|
257
|
+
| `/v1/messages` | POST | Anthropic Messages API |
|
|
258
|
+
| `/v1/models` | GET | 列出可用模型 |
|
|
259
|
+
| `/health` | GET | 健康检查 |
|
|
260
|
+
|
|
261
|
+
## 开发
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
# 克隆项目
|
|
265
|
+
git clone https://github.com/andyzheung/Claude-Code-Model-Router.git
|
|
266
|
+
cd Claude-Code-Model-Router
|
|
267
|
+
|
|
268
|
+
# 安装依赖
|
|
269
|
+
npm install
|
|
270
|
+
|
|
271
|
+
# 开发模式
|
|
272
|
+
npm run dev
|
|
273
|
+
|
|
274
|
+
# 构建
|
|
275
|
+
npm run build
|
|
276
|
+
|
|
277
|
+
# 本地测试
|
|
278
|
+
npm link
|
|
279
|
+
ccmr-plus start
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
## 故障排除
|
|
283
|
+
|
|
284
|
+
### 端口被占用
|
|
285
|
+
|
|
286
|
+
```bash
|
|
287
|
+
# 使用其他端口
|
|
288
|
+
npx @andyzheung/ccmr start --port 9000
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### API Key 错误
|
|
292
|
+
|
|
293
|
+
1. 检查 .env 文件中的 Key 是否正确
|
|
294
|
+
2. 确认账户有余额
|
|
295
|
+
3. 运行 `npx @andyzheung/ccmr models` 查看状态
|
|
296
|
+
|
|
297
|
+
## 更新日志
|
|
298
|
+
|
|
299
|
+
### v1.2.0
|
|
300
|
+
- 更新 MiniMax 模型至 M2.5 版本
|
|
301
|
+
- 更新 GLM 模型至 5.0 版本(model_id: glm-5)
|
|
302
|
+
- 新增版本别名 `glm-5` 和 `minimax-m2.5`
|
|
303
|
+
- 保留旧版本别名向后兼容
|
|
304
|
+
|
|
305
|
+
### v1.1.0
|
|
306
|
+
- 更新 MiniMax 模型至 M2.1 版本
|
|
307
|
+
- 更新 GLM 模型至 4.7 版本
|
|
308
|
+
- 更新 GLM API 端点至 `https://open.bigmodel.cn/api/anthropic`
|
|
309
|
+
- 新增版本别名支持(如 `glm-4.7`、`minimax-m2.1`)
|
|
310
|
+
- 优化日志显示,显示具体模型版本
|
|
311
|
+
- 更新各模型的 context window 和 max tokens 参数
|
|
312
|
+
|
|
313
|
+
### v1.0.1
|
|
314
|
+
- 添加 Claude Code 原生参数支持
|
|
315
|
+
|
|
316
|
+
### v1.0.0
|
|
317
|
+
- 初始版本发布
|
|
318
|
+
|
|
319
|
+
## License
|
|
320
|
+
|
|
321
|
+
MIT
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;GAEG"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* CLI for Claude Code Model Router
|
|
5
|
+
*/
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
const commander_1 = require("commander");
|
|
11
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
12
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
13
|
+
const config_js_1 = require("./config.js");
|
|
14
|
+
const server_js_1 = require("./server.js");
|
|
15
|
+
const VERSION = '1.1.0';
|
|
16
|
+
commander_1.program
|
|
17
|
+
.name('ccmr')
|
|
18
|
+
.description('Claude Code Model Router - A lightweight API gateway for multi-model switching')
|
|
19
|
+
.version(VERSION);
|
|
20
|
+
// Start command
|
|
21
|
+
commander_1.program
|
|
22
|
+
.command('start')
|
|
23
|
+
.description('Start the model router gateway')
|
|
24
|
+
.option('-p, --port <port>', 'Port to listen on', '8080')
|
|
25
|
+
.option('-c, --config <path>', 'Path to config file')
|
|
26
|
+
.option('--host <host>', 'Host to bind to', '0.0.0.0')
|
|
27
|
+
.action((options) => {
|
|
28
|
+
// Set port from option
|
|
29
|
+
if (options.port) {
|
|
30
|
+
process.env.GATEWAY_PORT = options.port;
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
const configManager = new config_js_1.ConfigManager(options.config);
|
|
34
|
+
// Override port if specified
|
|
35
|
+
if (options.port) {
|
|
36
|
+
configManager.getConfig().gateway.port = parseInt(options.port, 10);
|
|
37
|
+
}
|
|
38
|
+
if (options.host) {
|
|
39
|
+
configManager.getConfig().gateway.host = options.host;
|
|
40
|
+
}
|
|
41
|
+
(0, server_js_1.startServer)(configManager);
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
console.error('Failed to start server:', error);
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
// Init command
|
|
49
|
+
commander_1.program
|
|
50
|
+
.command('init')
|
|
51
|
+
.description('Initialize configuration files in current directory')
|
|
52
|
+
.option('-f, --force', 'Overwrite existing files')
|
|
53
|
+
.action((options) => {
|
|
54
|
+
const configPath = node_path_1.default.join(process.cwd(), 'models.yaml');
|
|
55
|
+
const envPath = node_path_1.default.join(process.cwd(), '.env');
|
|
56
|
+
console.log('');
|
|
57
|
+
console.log('Initializing Claude Code Model Router...');
|
|
58
|
+
console.log('');
|
|
59
|
+
// Create config file
|
|
60
|
+
if (node_fs_1.default.existsSync(configPath) && !options.force) {
|
|
61
|
+
console.log(`[SKIP] ${configPath} already exists (use --force to overwrite)`);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
node_fs_1.default.writeFileSync(configPath, (0, config_js_1.generateConfigFile)());
|
|
65
|
+
console.log(`[CREATE] ${configPath}`);
|
|
66
|
+
}
|
|
67
|
+
// Create .env file
|
|
68
|
+
if (node_fs_1.default.existsSync(envPath) && !options.force) {
|
|
69
|
+
console.log(`[SKIP] ${envPath} already exists (use --force to overwrite)`);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
node_fs_1.default.writeFileSync(envPath, (0, config_js_1.generateEnvFile)());
|
|
73
|
+
console.log(`[CREATE] ${envPath}`);
|
|
74
|
+
}
|
|
75
|
+
console.log('');
|
|
76
|
+
console.log('Next steps:');
|
|
77
|
+
console.log(' 1. Edit .env and add your API keys');
|
|
78
|
+
console.log(' 2. Run: npx claude-code-model-router start');
|
|
79
|
+
console.log(' 3. In a new terminal, start Claude Code:');
|
|
80
|
+
console.log('');
|
|
81
|
+
console.log(' # For third-party models (gateway mode):');
|
|
82
|
+
console.log(' npx claude-code-model-router claude');
|
|
83
|
+
console.log('');
|
|
84
|
+
console.log(' # For official subscription (default mode):');
|
|
85
|
+
console.log(' claude');
|
|
86
|
+
console.log('');
|
|
87
|
+
});
|
|
88
|
+
// Models command
|
|
89
|
+
commander_1.program
|
|
90
|
+
.command('models')
|
|
91
|
+
.description('List available models')
|
|
92
|
+
.option('-c, --config <path>', 'Path to config file')
|
|
93
|
+
.action((options) => {
|
|
94
|
+
try {
|
|
95
|
+
const configManager = new config_js_1.ConfigManager(options.config);
|
|
96
|
+
const models = configManager.listModels();
|
|
97
|
+
console.log('');
|
|
98
|
+
console.log('Available models:');
|
|
99
|
+
console.log('');
|
|
100
|
+
for (const [name, info] of Object.entries(models)) {
|
|
101
|
+
const status = info.available
|
|
102
|
+
? '\x1b[32m[Ready]\x1b[0m'
|
|
103
|
+
: '\x1b[33m[No API Key]\x1b[0m';
|
|
104
|
+
console.log(` ${name.padEnd(12)} ${info.displayName.padEnd(20)} ${status}`);
|
|
105
|
+
}
|
|
106
|
+
console.log('');
|
|
107
|
+
console.log('Aliases:');
|
|
108
|
+
const config = configManager.getConfig();
|
|
109
|
+
for (const [alias, target] of Object.entries(config.aliases)) {
|
|
110
|
+
console.log(` ${alias} -> ${target}`);
|
|
111
|
+
}
|
|
112
|
+
console.log('');
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
console.error('Error:', error);
|
|
116
|
+
process.exit(1);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
// Claude command - launches Claude Code connected to the gateway
|
|
120
|
+
// Supports all Claude Code native arguments
|
|
121
|
+
commander_1.program
|
|
122
|
+
.command('claude')
|
|
123
|
+
.description('Launch Claude Code connected to the gateway (for third-party models)')
|
|
124
|
+
.argument('[prompt]', 'Your prompt (optional)')
|
|
125
|
+
.option('--gateway-port <port>', 'Gateway port (default: 8080)', '8080')
|
|
126
|
+
// Session options
|
|
127
|
+
.option('-c, --continue', 'Continue the most recent conversation')
|
|
128
|
+
.option('-r, --resume [value]', 'Resume a conversation by session ID, or open interactive picker')
|
|
129
|
+
.option('--fork-session', 'When resuming, create a new session ID instead of reusing the original')
|
|
130
|
+
// Permission options
|
|
131
|
+
.option('--dangerously-skip-permissions', 'Bypass all permission checks (YOLO mode)')
|
|
132
|
+
.option('--permission-mode <mode>', 'Permission mode: acceptEdits, bypassPermissions, default, dontAsk, plan')
|
|
133
|
+
// Output options
|
|
134
|
+
.option('-p, --print', 'Print response and exit (useful for pipes)')
|
|
135
|
+
.option('--output-format <format>', 'Output format: text, json, stream-json')
|
|
136
|
+
.option('--input-format <format>', 'Input format: text, stream-json')
|
|
137
|
+
// Tool options
|
|
138
|
+
.option('--allowedTools, --allowed-tools <tools...>', 'Comma or space-separated list of tool names to allow')
|
|
139
|
+
.option('--disallowedTools, --disallowed-tools <tools...>', 'Comma or space-separated list of tool names to deny')
|
|
140
|
+
// Other options
|
|
141
|
+
.option('--model <model>', 'Model for the current session (overrides gateway routing)')
|
|
142
|
+
.option('--system-prompt <prompt>', 'System prompt to use for the session')
|
|
143
|
+
.option('--append-system-prompt <prompt>', 'Append a system prompt to the default')
|
|
144
|
+
.option('--add-dir <directories...>', 'Additional directories to allow tool access to')
|
|
145
|
+
.option('-d, --debug [filter]', 'Enable debug mode')
|
|
146
|
+
.option('--verbose', 'Enable verbose mode')
|
|
147
|
+
.option('--ide', 'Automatically connect to IDE on startup')
|
|
148
|
+
.allowUnknownOption(true) // Allow any other Claude Code options
|
|
149
|
+
.action(async (prompt, options, command) => {
|
|
150
|
+
const { spawn } = await import('node:child_process');
|
|
151
|
+
const os = await import('node:os');
|
|
152
|
+
const homeDir = os.homedir();
|
|
153
|
+
const gatewayPort = options.gatewayPort || '8080';
|
|
154
|
+
// Set up environment for gateway
|
|
155
|
+
const env = {
|
|
156
|
+
...process.env,
|
|
157
|
+
CLAUDE_CONFIG_DIR: node_path_1.default.join(homeDir, '.ccmr-plus'),
|
|
158
|
+
ANTHROPIC_BASE_URL: `http://localhost:${gatewayPort}`,
|
|
159
|
+
};
|
|
160
|
+
// Build Claude Code arguments
|
|
161
|
+
const claudeArgs = [];
|
|
162
|
+
// Add prompt if provided
|
|
163
|
+
if (prompt) {
|
|
164
|
+
claudeArgs.push(prompt);
|
|
165
|
+
}
|
|
166
|
+
// Session options
|
|
167
|
+
if (options.continue)
|
|
168
|
+
claudeArgs.push('--continue');
|
|
169
|
+
if (options.resume !== undefined) {
|
|
170
|
+
if (options.resume === true) {
|
|
171
|
+
claudeArgs.push('--resume');
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
claudeArgs.push('--resume', options.resume);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (options.forkSession)
|
|
178
|
+
claudeArgs.push('--fork-session');
|
|
179
|
+
// Permission options
|
|
180
|
+
if (options.dangerouslySkipPermissions)
|
|
181
|
+
claudeArgs.push('--dangerously-skip-permissions');
|
|
182
|
+
if (options.permissionMode)
|
|
183
|
+
claudeArgs.push('--permission-mode', options.permissionMode);
|
|
184
|
+
// Output options
|
|
185
|
+
if (options.print)
|
|
186
|
+
claudeArgs.push('--print');
|
|
187
|
+
if (options.outputFormat)
|
|
188
|
+
claudeArgs.push('--output-format', options.outputFormat);
|
|
189
|
+
if (options.inputFormat)
|
|
190
|
+
claudeArgs.push('--input-format', options.inputFormat);
|
|
191
|
+
// Tool options
|
|
192
|
+
if (options.allowedTools)
|
|
193
|
+
claudeArgs.push('--allowed-tools', ...options.allowedTools);
|
|
194
|
+
if (options.disallowedTools)
|
|
195
|
+
claudeArgs.push('--disallowed-tools', ...options.disallowedTools);
|
|
196
|
+
// Other options
|
|
197
|
+
if (options.model)
|
|
198
|
+
claudeArgs.push('--model', options.model);
|
|
199
|
+
if (options.systemPrompt)
|
|
200
|
+
claudeArgs.push('--system-prompt', options.systemPrompt);
|
|
201
|
+
if (options.appendSystemPrompt)
|
|
202
|
+
claudeArgs.push('--append-system-prompt', options.appendSystemPrompt);
|
|
203
|
+
if (options.addDir)
|
|
204
|
+
claudeArgs.push('--add-dir', ...options.addDir);
|
|
205
|
+
if (options.debug !== undefined) {
|
|
206
|
+
if (options.debug === true) {
|
|
207
|
+
claudeArgs.push('--debug');
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
claudeArgs.push('--debug', options.debug);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (options.verbose)
|
|
214
|
+
claudeArgs.push('--verbose');
|
|
215
|
+
if (options.ide)
|
|
216
|
+
claudeArgs.push('--ide');
|
|
217
|
+
// Pass through any unknown options (collected by allowUnknownOption)
|
|
218
|
+
const unknownArgs = command.args.slice(prompt ? 1 : 0);
|
|
219
|
+
claudeArgs.push(...unknownArgs);
|
|
220
|
+
// Show startup info (unless in print mode)
|
|
221
|
+
if (!options.print) {
|
|
222
|
+
console.log('');
|
|
223
|
+
console.log('========================================');
|
|
224
|
+
console.log('Starting Claude Code (Third-party Models)');
|
|
225
|
+
console.log('Configuration: ' + env.CLAUDE_CONFIG_DIR);
|
|
226
|
+
console.log('Gateway: ' + env.ANTHROPIC_BASE_URL);
|
|
227
|
+
if (claudeArgs.length > 0) {
|
|
228
|
+
console.log('Arguments: ' + claudeArgs.join(' '));
|
|
229
|
+
}
|
|
230
|
+
console.log('========================================');
|
|
231
|
+
console.log('');
|
|
232
|
+
}
|
|
233
|
+
const child = spawn('claude', claudeArgs, {
|
|
234
|
+
stdio: 'inherit',
|
|
235
|
+
env,
|
|
236
|
+
shell: true,
|
|
237
|
+
});
|
|
238
|
+
child.on('error', (error) => {
|
|
239
|
+
console.error('Failed to start Claude Code:', error.message);
|
|
240
|
+
console.error('');
|
|
241
|
+
console.error('Make sure Claude Code is installed:');
|
|
242
|
+
console.error(' npm install -g @anthropic-ai/claude-code');
|
|
243
|
+
process.exit(1);
|
|
244
|
+
});
|
|
245
|
+
child.on('exit', (code) => {
|
|
246
|
+
process.exit(code ?? 0);
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
// Parse arguments
|
|
250
|
+
commander_1.program.parse();
|
|
251
|
+
// Show help if no command provided
|
|
252
|
+
if (!process.argv.slice(2).length) {
|
|
253
|
+
console.log('');
|
|
254
|
+
console.log('Claude Code Model Router v' + VERSION);
|
|
255
|
+
console.log('');
|
|
256
|
+
console.log('Quick Start:');
|
|
257
|
+
console.log(' 1. npx claude-code-model-router init # Create config files');
|
|
258
|
+
console.log(' 2. Edit .env with your API keys');
|
|
259
|
+
console.log(' 3. npx claude-code-model-router start # Start gateway');
|
|
260
|
+
console.log('');
|
|
261
|
+
console.log('Commands:');
|
|
262
|
+
console.log(' init Create configuration files');
|
|
263
|
+
console.log(' start Start the gateway server');
|
|
264
|
+
console.log(' models List available models');
|
|
265
|
+
console.log(' claude Launch Claude Code with gateway');
|
|
266
|
+
console.log('');
|
|
267
|
+
console.log('Use --help for more information.');
|
|
268
|
+
console.log('');
|
|
269
|
+
}
|
|
270
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;AAEA;;GAEG;;;;;AAEH,yCAAoC;AACpC,sDAAyB;AACzB,0DAA6B;AAC7B,2CAAiF;AACjF,2CAA0C;AAE1C,MAAM,OAAO,GAAG,OAAO,CAAC;AAExB,mBAAO;KACJ,IAAI,CAAC,MAAM,CAAC;KACZ,WAAW,CAAC,gFAAgF,CAAC;KAC7F,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,gBAAgB;AAChB,mBAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,gCAAgC,CAAC;KAC7C,MAAM,CAAC,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,CAAC;KACxD,MAAM,CAAC,qBAAqB,EAAE,qBAAqB,CAAC;KACpD,MAAM,CAAC,eAAe,EAAE,iBAAiB,EAAE,SAAS,CAAC;KACrD,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE;IAClB,uBAAuB;IACvB,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,OAAO,CAAC,GAAG,CAAC,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAC1C,CAAC;IAED,IAAI,CAAC;QACH,MAAM,aAAa,GAAG,IAAI,yBAAa,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAExD,6BAA6B;QAC7B,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YACjB,aAAa,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACtE,CAAC;Q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B,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;IAChD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration management for Claude Code Model Router
|
|
3
|
+
*/
|
|
4
|
+
import type { RouterConfig, ModelConfig } from './types.js';
|
|
5
|
+
export declare class ConfigManager {
|
|
6
|
+
private config;
|
|
7
|
+
private apiKeys;
|
|
8
|
+
constructor(configPath?: string);
|
|
9
|
+
private loadConfig;
|
|
10
|
+
private mergeConfig;
|
|
11
|
+
private loadApiKeys;
|
|
12
|
+
getConfig(): RouterConfig;
|
|
13
|
+
getModel(name: string): ModelConfig | undefined;
|
|
14
|
+
resolveModelName(name: string): string;
|
|
15
|
+
getApiKey(modelName: string): string | undefined;
|
|
16
|
+
listModels(): Record<string, {
|
|
17
|
+
displayName: string;
|
|
18
|
+
provider: string;
|
|
19
|
+
available: boolean;
|
|
20
|
+
}>;
|
|
21
|
+
}
|
|
22
|
+
export declare function generateConfigFile(): string;
|
|
23
|
+
export declare function generateEnvFile(): string;
|
|
24
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAiB,MAAM,YAAY,CAAC;AAmG3E,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,OAAO,CAAkC;gBAErC,UAAU,CAAC,EAAE,MAAM;IAK/B,OAAO,CAAC,UAAU;IAyBlB,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,WAAW;IASnB,SAAS,IAAI,YAAY;IAIzB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAe/C,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAUtC,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAKhD,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC;CAa5F;AAGD,wBAAgB,kBAAkB,IAAI,MAAM,CAwE3C;AAED,wBAAgB,eAAe,IAAI,MAAM,CAmBxC"}
|