@chenpu17/cc-gw 0.2.5 → 0.3.1
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 +37 -6
- package/package.json +33 -21
- package/src/cli/dist/index.js +18 -6
- package/src/server/dist/index.js +1682 -149
- package/src/web/dist/assets/{About-B7UuxVKg.js → About-DCfrDx9y.js} +1 -1
- package/src/web/dist/assets/ApiKeys-Y5poBRw3.js +21 -0
- package/src/web/dist/assets/Dashboard-D7fExA3T.js +1 -0
- package/src/web/dist/assets/Help-B8VUq1V5.js +1 -0
- package/src/web/dist/assets/Logs-BakQuwan.js +1 -0
- package/src/web/dist/assets/ModelManagement-CHoJhtWK.js +1 -0
- package/src/web/dist/assets/Settings-BM0caEUh.js +1 -0
- package/src/web/dist/assets/index-BekAYLv4.js +133 -0
- package/src/web/dist/assets/index-D14cSZuL.js +61 -0
- package/src/web/dist/assets/index-DTby9g2A.css +1 -0
- package/src/web/dist/assets/{useApiQuery-DZqtpbk3.js → useApiQuery-CUC2GmXO.js} +1 -1
- package/src/web/dist/index.html +2 -2
- package/src/web/dist/assets/Dashboard-Bvkc9Nqm.js +0 -61
- package/src/web/dist/assets/Logs-D1s40rEu.js +0 -1
- package/src/web/dist/assets/ModelManagement-j5J5TDOy.js +0 -1
- package/src/web/dist/assets/Settings-CgAFUZes.js +0 -1
- package/src/web/dist/assets/index-B_Unl5wz.js +0 -123
- package/src/web/dist/assets/index-Bym_WpRV.css +0 -1
package/README.md
CHANGED
|
@@ -53,6 +53,7 @@ pnpm --filter @cc-gw/cli exec tsx index.ts start --daemon --port 4100
|
|
|
53
53
|
- **请求日志**:多条件筛选(时间、Provider、模型、状态),查看压缩日志详情,支持分页导出与清理。
|
|
54
54
|
- **模型管理**:维护 Provider 列表、预置模型、路由策略;一键测试连通性(发送诊断 PROMPT)。
|
|
55
55
|
- **系统设置**:端口、日志保留策略、是否存储请求 payload、日志级别与访问日志开关、日志清理工具。
|
|
56
|
+
- **使用指南**:提供图文步骤、常见问题与排查提示,帮助团队成员快速熟悉配置流程。
|
|
56
57
|
|
|
57
58
|
UI 支持中英文、深色/浅色主题以及移动端响应式布局,提供键盘可达性(Skip Link、焦点管理)。
|
|
58
59
|
|
|
@@ -66,10 +67,24 @@ UI 支持中英文、深色/浅色主题以及移动端响应式布局,提供
|
|
|
66
67
|
1. 启动 cc-gw 并确认配置中 `host` 为 `127.0.0.1`,`port` 与 CLI 启动一致。
|
|
67
68
|
2. 在安装了 Claude Code 的终端设置环境变量:
|
|
68
69
|
```bash
|
|
69
|
-
export ANTHROPIC_BASE_URL=http://127.0.0.1:4100
|
|
70
|
+
export ANTHROPIC_BASE_URL=http://127.0.0.1:4100/anthropic
|
|
70
71
|
claude "help me review this file"
|
|
71
72
|
```
|
|
72
|
-
3. cc-gw
|
|
73
|
+
3. 如果使用 VS Code 插件(Claude Code),在“自定义 API”中同样填写 `http://127.0.0.1:4100/anthropic`,插件会自动追加 `/v1/messages` 与 `?beta=true`,最后粘贴 cc-gw Web UI 或 CLI 创建的 API Key。
|
|
74
|
+
4. cc-gw 会根据 `modelRoutes`/默认策略将 Claude 请求路由到已配置的目标模型(如 Kimi、火山 DeepSeek、OpenAI 或自建模型)。
|
|
75
|
+
|
|
76
|
+
### 连接 Codex(原 Claude Code for Repo)
|
|
77
|
+
1. 在 Web UI 的“模型管理 → 路由配置”中为 `/openai` 端点选择目标模型,默认会映射至配置中的 `defaults.completion`。
|
|
78
|
+
2. 在 Codex 或其他需要 OpenAI 风格接口的客户端中,将 Base URL 设置为 `http://127.0.0.1:4100/openai/v1`;若需手动指定路径,请调用 `POST /openai/v1/responses`。
|
|
79
|
+
3. 将 API Key 设置为 cc-gw 生成的密钥(支持 Bearer Header 或 `x-api-key` Header)。
|
|
80
|
+
4. 触发一次 `hello` 或最小请求检查 Streaming 是否正常;若遇到 `Unsupported parameter: thinking` 等提示,说明 cc-gw 已自动剥离该字段并兼容上游。
|
|
81
|
+
|
|
82
|
+
### 使用场景 / Usage Scenarios
|
|
83
|
+
|
|
84
|
+
1. **双端点适配 / Dual Endpoint Support**:通过 `/anthropic` 与 `/openai` 端点,分别兼容 Claude Code 与 Codex 客户端。无需重启 cc-gw,即可在 Web UI 中为两个端点配置独立的默认模型与路由策略。
|
|
85
|
+
2. **日志追踪 / Request Auditing**:在“请求日志”页按端点、Provider、API Key 等维度筛选记录,可直接查看和复制完整的请求/响应 payload,辅助排查联调问题。
|
|
86
|
+
3. **模型切换 / Cross-Provider Routing**:利用“模型管理”页的路由映射,将 Claude Code 请求透明地转发到 GLM、Kimi K2、DeepSeek 等任意 OpenAI 兼容模型,实现一套 IDE 客户端、多家大模型的快速切换。
|
|
87
|
+
4. **操作指引 / Built-in Guidance**:左侧“Help”导航提供分步配置、日常运维建议及 FAQ,可作为新人上手或问题排查的快速参考。
|
|
73
88
|
|
|
74
89
|
## 配置说明
|
|
75
90
|
|
|
@@ -114,7 +129,8 @@ UI 支持中英文、深色/浅色主题以及移动端响应式布局,提供
|
|
|
114
129
|
"logRetentionDays": 30,
|
|
115
130
|
"storePayloads": true,
|
|
116
131
|
"logLevel": "info",
|
|
117
|
-
"requestLogging": true
|
|
132
|
+
"requestLogging": true,
|
|
133
|
+
"responseLogging": true
|
|
118
134
|
}
|
|
119
135
|
```
|
|
120
136
|
|
|
@@ -125,7 +141,9 @@ UI 支持中英文、深色/浅色主题以及移动端响应式布局,提供
|
|
|
125
141
|
- `modelRoutes`:将 Claude 发起的模型名映射到上游模型;未命中时使用 `defaults`。
|
|
126
142
|
- `storePayloads`:是否在 SQLite 中压缩保存原始请求/响应(Brotli),关闭后仅保留元信息。
|
|
127
143
|
- `logLevel`:控制 Fastify/Pino 控制台日志级别(`fatal`/`error`/`warn`/`info`/`debug`/`trace`)。
|
|
128
|
-
- `
|
|
144
|
+
- `providers[].authMode`:仅在 `type: "anthropic"` 时生效,可选 `apiKey`(默认,发送 `x-api-key`)或 `authToken`(发送 `Authorization: Bearer`)。配置 Claude Code 使用 `ANTHROPIC_AUTH_TOKEN` 时,请选择 `authToken` 并在 `apiKey` 输入框填入该值。
|
|
145
|
+
- `requestLogging`:是否输出每个 HTTP 请求的进入日志。
|
|
146
|
+
- `responseLogging`:是否输出每个 HTTP 请求完成的日志,可独立于 `requestLogging` 控制。
|
|
129
147
|
- 推荐通过 Web UI 的“模型管理 / 系统设置”在线编辑并热加载,无需手工修改文件。
|
|
130
148
|
|
|
131
149
|
#### Anthropic Provider 额外说明
|
|
@@ -204,13 +222,24 @@ pnpm --filter @cc-gw/web build
|
|
|
204
222
|
pnpm --filter @cc-gw/cli exec tsx index.ts start --daemon --port 4100
|
|
205
223
|
```
|
|
206
224
|
|
|
207
|
-
Connect Claude Code by pointing `ANTHROPIC_BASE_URL` to
|
|
225
|
+
Connect Claude Code by pointing `ANTHROPIC_BASE_URL` to the Anthropic namespace on cc-gw. Both the CLI and editor clients append `/v1/messages` automatically:
|
|
208
226
|
|
|
209
227
|
```bash
|
|
210
|
-
export ANTHROPIC_BASE_URL=http://127.0.0.1:4100
|
|
228
|
+
export ANTHROPIC_BASE_URL=http://127.0.0.1:4100/anthropic
|
|
211
229
|
claude "help me review this file"
|
|
212
230
|
```
|
|
213
231
|
|
|
232
|
+
Using the Claude Code VS Code extension? Open the extension settings, enable the custom API mode, set the Base URL to the same `http://127.0.0.1:4100/anthropic`, and paste an API key generated from the cc-gw Web UI or CLI—the extension appends `/v1/messages?beta=true` automatically and cc-gw now forwards the query string upstream.
|
|
233
|
+
|
|
234
|
+
Connect Codex (or any OpenAI-compatible IDE integration) by targeting the OpenAI endpoint exposed by cc-gw:
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
export OPENAI_BASE_URL=http://127.0.0.1:4100/openai/v1
|
|
238
|
+
export OPENAI_API_KEY="<your cc-gw api key>"
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
If the client expects a full path, call `POST /openai/v1/responses`. The gateway strips unsupported fields (such as `thinking`) before forwarding to the upstream provider, so health checks like `hello` should stream back correctly.
|
|
242
|
+
|
|
214
243
|
### Configuration Snapshot
|
|
215
244
|
|
|
216
245
|
- Providers include `type`, `baseUrl`, `apiKey`, and `models` descriptions.
|
|
@@ -219,6 +248,7 @@ claude "help me review this file"
|
|
|
219
248
|
- `storePayloads` toggles compressed body retention; disable to keep only metadata.
|
|
220
249
|
- `logLevel` adjusts Fastify/Pino verbosity (`fatal` → `trace`).
|
|
221
250
|
- `requestLogging` controls whether per-request access logs are emitted to the console.
|
|
251
|
+
- `responseLogging` toggles completion logs separately so you can keep the console quieter while preserving metrics.
|
|
222
252
|
- Web UI allows editing without restarting; CLI restart will pick up bundle changes after rebuilds.
|
|
223
253
|
|
|
224
254
|
### Observability & Storage
|
|
@@ -249,6 +279,7 @@ claude "help me review this file"
|
|
|
249
279
|
- Always rebuild `@cc-gw/server` and `@cc-gw/web` before restarts to ensure the daemon picks up new code.
|
|
250
280
|
- If cache statistics remain zero, verify whether the upstream provider exposes `cached_tokens` or equivalent details.
|
|
251
281
|
- Back up `~/.cc-gw/` (config, logs, SQLite DB) for migrations or disaster recovery.
|
|
282
|
+
- Use the **Help** page in the Web UI to review setup steps, troubleshooting tips, and FAQs whenever a teammate needs a refresher.
|
|
252
283
|
|
|
253
284
|
---
|
|
254
285
|
|
package/package.json
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chenpu17/cc-gw",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "pnpm --filter server dev",
|
|
8
|
+
"build": "pnpm run build:server && pnpm run build:web",
|
|
9
|
+
"build:server": "pnpm --filter @cc-gw/server build",
|
|
10
|
+
"build:cli": "pnpm --filter @cc-gw/cli build",
|
|
11
|
+
"build:web": "pnpm --filter @cc-gw/web build",
|
|
12
|
+
"build:all": "pnpm run build:server && pnpm run build:cli && pnpm run build:web",
|
|
13
|
+
"release:bundle": "pnpm run build:all && node scripts/build-release.mjs",
|
|
14
|
+
"prepack": "pnpm run build:all",
|
|
15
|
+
"lint": "pnpm exec eslint .",
|
|
16
|
+
"format": "pnpm exec prettier --check .",
|
|
17
|
+
"format:write": "pnpm exec prettier --write .",
|
|
18
|
+
"typecheck": "pnpm -r exec tsc --noEmit",
|
|
19
|
+
"test": "pnpm exec vitest run",
|
|
20
|
+
"test:playwright": "playwright test"
|
|
21
|
+
},
|
|
6
22
|
"bin": {
|
|
7
23
|
"cc-gw": "src/cli/dist/index.js"
|
|
8
24
|
},
|
|
@@ -13,6 +29,15 @@
|
|
|
13
29
|
"README.md",
|
|
14
30
|
"LICENSE"
|
|
15
31
|
],
|
|
32
|
+
"pnpm": {
|
|
33
|
+
"peerDependencyRules": {
|
|
34
|
+
"ignoreMissing": [
|
|
35
|
+
"react",
|
|
36
|
+
"react-dom"
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"packageManager": "pnpm@9.0.0",
|
|
16
41
|
"engines": {
|
|
17
42
|
"node": ">=18.18.0"
|
|
18
43
|
},
|
|
@@ -26,42 +51,29 @@
|
|
|
26
51
|
],
|
|
27
52
|
"repository": {
|
|
28
53
|
"type": "git",
|
|
29
|
-
"url": "https://github.com/chenpu17/cc-gw.git"
|
|
54
|
+
"url": "git+https://github.com/chenpu17/cc-gw.git"
|
|
30
55
|
},
|
|
31
56
|
"dependencies": {
|
|
32
57
|
"@fastify/cors": "^9.0.1",
|
|
33
58
|
"@fastify/static": "^7.0.4",
|
|
34
|
-
"sqlite3": "^5.1.7",
|
|
35
|
-
"commander": "^12.0.0",
|
|
36
59
|
"colorette": "^2.0.20",
|
|
60
|
+
"commander": "^12.0.0",
|
|
37
61
|
"fastify": "^4.26.2",
|
|
38
62
|
"open": "^10.1.0",
|
|
63
|
+
"sqlite3": "^5.1.7",
|
|
39
64
|
"tiktoken": "^1.0.21",
|
|
40
65
|
"undici": "^6.11.1"
|
|
41
66
|
},
|
|
42
67
|
"devDependencies": {
|
|
43
68
|
"@eslint/js": "^9.5.0",
|
|
69
|
+
"@playwright/test": "^1.55.1",
|
|
44
70
|
"@types/node": "^20.12.7",
|
|
71
|
+
"@types/sqlite3": "^3.1.11",
|
|
45
72
|
"eslint": "^8.57.0",
|
|
46
73
|
"globals": "^15.0.0",
|
|
47
74
|
"prettier": "^3.2.5",
|
|
48
75
|
"typescript": "^5.4.3",
|
|
49
76
|
"typescript-eslint": "^7.5.0",
|
|
50
|
-
"vitest": "^1.6.0"
|
|
51
|
-
"@types/sqlite3": "^3.1.11"
|
|
52
|
-
},
|
|
53
|
-
"scripts": {
|
|
54
|
-
"dev": "pnpm --filter server dev",
|
|
55
|
-
"build": "pnpm run build:server && pnpm run build:web",
|
|
56
|
-
"build:server": "pnpm --filter @cc-gw/server build",
|
|
57
|
-
"build:cli": "pnpm --filter @cc-gw/cli build",
|
|
58
|
-
"build:web": "pnpm --filter @cc-gw/web build",
|
|
59
|
-
"build:all": "pnpm run build:server && pnpm run build:cli && pnpm run build:web",
|
|
60
|
-
"release:bundle": "pnpm run build:all && node scripts/build-release.mjs",
|
|
61
|
-
"lint": "pnpm exec eslint .",
|
|
62
|
-
"format": "pnpm exec prettier --check .",
|
|
63
|
-
"format:write": "pnpm exec prettier --write .",
|
|
64
|
-
"typecheck": "pnpm -r exec tsc --noEmit",
|
|
65
|
-
"test": "pnpm exec vitest run"
|
|
77
|
+
"vitest": "^1.6.0"
|
|
66
78
|
}
|
|
67
|
-
}
|
|
79
|
+
}
|
package/src/cli/dist/index.js
CHANGED
|
@@ -57,21 +57,33 @@ async function ensureConfigTemplate(port) {
|
|
|
57
57
|
return false;
|
|
58
58
|
} catch {
|
|
59
59
|
const selectedPort = port ? Number.parseInt(port, 10) || DEFAULT_PORT : DEFAULT_PORT;
|
|
60
|
+
const baseDefaults = {
|
|
61
|
+
completion: null,
|
|
62
|
+
reasoning: null,
|
|
63
|
+
background: null,
|
|
64
|
+
longContextThreshold: 6e4
|
|
65
|
+
};
|
|
60
66
|
const template = {
|
|
61
67
|
host: "127.0.0.1",
|
|
62
68
|
port: selectedPort,
|
|
63
69
|
providers: [],
|
|
64
|
-
defaults: {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
70
|
+
defaults: { ...baseDefaults },
|
|
71
|
+
endpointRouting: {
|
|
72
|
+
anthropic: {
|
|
73
|
+
defaults: { ...baseDefaults },
|
|
74
|
+
modelRoutes: {}
|
|
75
|
+
},
|
|
76
|
+
openai: {
|
|
77
|
+
defaults: { ...baseDefaults },
|
|
78
|
+
modelRoutes: {}
|
|
79
|
+
}
|
|
69
80
|
},
|
|
70
81
|
logRetentionDays: 30,
|
|
71
82
|
modelRoutes: {},
|
|
72
83
|
storePayloads: true,
|
|
73
84
|
logLevel: "info",
|
|
74
|
-
requestLogging: true
|
|
85
|
+
requestLogging: true,
|
|
86
|
+
responseLogging: true
|
|
75
87
|
};
|
|
76
88
|
await fsp.mkdir(path.dirname(CONFIG_FILE), { recursive: true });
|
|
77
89
|
await fsp.writeFile(CONFIG_FILE, JSON.stringify(template, null, 2), "utf-8");
|