@chenpu17/cc-gw 0.3.10 → 0.3.12
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 +27 -2
- package/package.json +17 -27
- package/src/server/dist/index.js +2536 -253
- package/src/web/dist/assets/{About-lwVAsqMu.js → About-DnWkOgAf.js} +2 -2
- package/src/web/dist/assets/{ApiKeys-C9KFsUMQ.js → ApiKeys-CBe66hEA.js} +1 -1
- package/src/web/dist/assets/{Button-BF9GpvYa.js → Button-C-i-DISc.js} +1 -1
- package/src/web/dist/assets/{Dashboard-BUKxNPQR.js → Dashboard-D8pCuP6p.js} +1 -1
- package/src/web/dist/assets/{FormField-BBlxSg9a.js → FormField-1cnBcVyy.js} +1 -1
- package/src/web/dist/assets/{Help-yYuyDHMA.js → Help-BxOmZMMV.js} +1 -1
- package/src/web/dist/assets/{Input-DdO84aXo.js → Input-BZ6K0tyW.js} +1 -1
- package/src/web/dist/assets/{Login-D9r73MBo.js → Login-Dv9uSd3D.js} +1 -1
- package/src/web/dist/assets/{Logs-CriMtwWk.js → Logs-CPHSNLlA.js} +1 -1
- package/src/web/dist/assets/ModelManagement-Cf-NV2X0.js +1 -0
- package/src/web/dist/assets/{PageSection-Nop6p7eX.js → PageSection-BdauTwx0.js} +1 -1
- package/src/web/dist/assets/{Settings-DKDjawCK.js → Settings-BG-7LB6a.js} +1 -1
- package/src/web/dist/assets/{StatusBadge-CZGD7No1.js → StatusBadge-BCWow-Yk.js} +1 -1
- package/src/web/dist/assets/{copy-Bv68tIyy.js → copy-BhWxP215.js} +1 -1
- package/src/web/dist/assets/{index-CQzd1dOI.js → index-DCeJcrH5.js} +1 -1
- package/src/web/dist/assets/{index-DggPstk7.js → index-Jd5giEeS.js} +4 -4
- package/src/web/dist/assets/{info-oTKmY9Oy.js → info-BLq7flU9.js} +1 -1
- package/src/web/dist/assets/{useApiQuery-C6-ZfYVn.js → useApiQuery-DByVsawz.js} +1 -1
- package/src/web/dist/index.html +1 -1
- package/src/web/dist/assets/ModelManagement-BgCUHomS.js +0 -1
package/README.md
CHANGED
|
@@ -8,6 +8,9 @@ cc-gw 是一个面向 Claude Code 与同类客户端的本地多模型网关,
|
|
|
8
8
|
- 复刻 Claude API 的流式与工具调用语义
|
|
9
9
|
- 记录请求日志、Token(含缓存命中)、TTFT/TPOT 等运行指标
|
|
10
10
|
- 提供可视化 Web 管理台与守护进程 CLI
|
|
11
|
+
- 在同一个 OpenAI 接入点聚合多 Provider / 多模型,兼容 Responses 与 Chat Completions 双协议
|
|
12
|
+
|
|
13
|
+
> **提示(2025-10)**:OpenAI 接入点仍为实验特性,我们会尝试将请求转换为 Anthropic `/v1/messages` 并推断所需 beta 头,但部分专为 Claude Code 适配的代理可能仍返回“暂不支持”。此类模型请直接使用 `/anthropic/v1/messages` 端点。
|
|
11
14
|
|
|
12
15
|
核心组件:
|
|
13
16
|
|
|
@@ -51,6 +54,7 @@ pnpm --filter @cc-gw/cli exec tsx index.ts start --daemon --port 4100
|
|
|
51
54
|
API Key: sk-ant-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
52
55
|
默认模型: claude-3-5-sonnet-20241022
|
|
53
56
|
```
|
|
57
|
+
Roo Code / Claude CLI 可通过 OpenAI 接入点访问 Anthropic 模型,但部分第三方代理可能拒绝该路径;若收到“暂不支持”或类似错误,请改用 `/anthropic/v1/messages`。
|
|
54
58
|
- **Moonshot Kimi**:
|
|
55
59
|
```
|
|
56
60
|
Base URL: https://api.moonshot.cn/v1
|
|
@@ -82,10 +86,14 @@ pnpm --filter @cc-gw/cli exec tsx index.ts start --daemon --port 4100
|
|
|
82
86
|
export ANTHROPIC_BASE_URL=http://127.0.0.1:4100/anthropic
|
|
83
87
|
export ANTHROPIC_API_KEY=sk-gw-ide-xxxxxxxxxxxxxxxx
|
|
84
88
|
|
|
85
|
-
# Codex CLI
|
|
89
|
+
# Codex CLI(Responses API)
|
|
86
90
|
export OPENAI_BASE_URL=http://127.0.0.1:4100/openai/v1
|
|
87
91
|
export OPENAI_API_KEY=sk-gw-codex-xxxxxxxxxxxxxxxx
|
|
88
92
|
export CC_GW_KEY=sk-gw-codex-xxxxxxxxxxxxxxxx
|
|
93
|
+
|
|
94
|
+
# Roo Code / 旧式 OpenAI Chat Completions
|
|
95
|
+
export OPENAI_CHAT_BASE_URL=http://127.0.0.1:4100/openai/v1
|
|
96
|
+
export OPENAI_CHAT_PATH=/chat/completions
|
|
89
97
|
```
|
|
90
98
|
|
|
91
99
|
更新完毕后执行 `source ~/.bashrc`(或 `source ~/.zshrc`)让环境变量立即生效。完成后可以马上做一次快速连通性测试:
|
|
@@ -117,6 +125,14 @@ codex ask "你好,请介绍一下自己"
|
|
|
117
125
|
|
|
118
126
|
配置完成后,建议运行 `codex status` 或 `codex chat "测试"` 再确认一次终端输出。
|
|
119
127
|
|
|
128
|
+
##### 5.1 OpenAI 接入点接入说明
|
|
129
|
+
|
|
130
|
+
- **Responses API**:推荐给支持新版 OpenAI Responses(例如 Codex CLI、最新 Agent 工具)的客户端,直接指向 `http://127.0.0.1:4100/openai/v1/responses`,即可自动在下游 Provider 间路由并返回标准 `response` 结构。
|
|
131
|
+
- **Chat Completions API**:针对 Roo Code、OpenAI CLI 等仍使用传统 `POST /v1/chat/completions` 的客户端,现可通过 `http://127.0.0.1:4100/openai/v1/chat/completions` 接入;工具仅需设置 Base URL(例如 Roo Code 的 “OpenAI Compatible” 配置)和 API Key 即可。
|
|
132
|
+
- **注意兼容性**:OpenAI 入口为实验性最佳实践。若下游服务只支持 Claude Code 专用头部,可能仍返回“暂不支持”,此时改用 `/anthropic/v1/messages`。
|
|
133
|
+
- **Anthropic Beta Header**:若上游模型需要 beta 头(例如 Claude 4.5 预览),可设置环境变量 `CC_GW_ANTHROPIC_BETA_<MODEL>`(如 `CC_GW_ANTHROPIC_BETA_CLAUDE_SONNET_4_5_20250929`)或全局 `CC_GW_ANTHROPIC_BETA_ALL`;网关会在转发至 Anthropic 时尝试附加,也会针对 4.5 系列模型进行默认推断。
|
|
134
|
+
- **多模型聚合**:无论使用 Responses 还是 Chat Completions,两种接口都会按配置聚合所有 Provider 模型,`GET /openai/v1/models` 将返回当前可用模型列表及默认 Provider。
|
|
135
|
+
|
|
120
136
|
#### 步骤 6: 高级配置(可选)
|
|
121
137
|
|
|
122
138
|
##### 6.1 模型路由配置
|
|
@@ -139,10 +155,19 @@ export ANTHROPIC_API_KEY=sk-gw-ide-xxxxxxxxxxxxxxxx
|
|
|
139
155
|
export OPENAI_BASE_URL=http://127.0.0.1:4100/openai/v1
|
|
140
156
|
export OPENAI_API_KEY=sk-gw-codex-xxxxxxxxxxxxxxxx
|
|
141
157
|
export CC_GW_KEY=sk-gw-codex-xxxxxxxxxxxxxxxx
|
|
158
|
+
# 若需兼容旧版 Chat Completions,可继续暴露聊天端点
|
|
159
|
+
export OPENAI_CHAT_BASE_URL=http://127.0.0.1:4100/openai/v1
|
|
160
|
+
export OPENAI_CHAT_PATH=/chat/completions
|
|
161
|
+
# 针对 Anthropic 新模型可设置 Beta Header(示例)
|
|
162
|
+
export CC_GW_ANTHROPIC_BETA_CLAUDE_SONNET_4_5_20250929=claude-code-20250219,interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14
|
|
163
|
+
export CC_GW_ANTHROPIC_BETA_ALL=claude-code-20250219,interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14
|
|
164
|
+
|
|
142
165
|
```
|
|
143
166
|
|
|
144
167
|
然后运行 `direnv allow` 自动加载。
|
|
145
168
|
|
|
169
|
+
> ⚠️ 如果 OpenAI 接入点仍返回“暂不支持”,请将客户端改用 `/anthropic/v1/messages` 端点并直接配置 Anthropic Provider。
|
|
170
|
+
|
|
146
171
|
#### 常见问题排查
|
|
147
172
|
|
|
148
173
|
1. **连接失败**:
|
|
@@ -292,7 +317,7 @@ UI 支持中英文、深色/浅色主题以及移动端响应式布局,提供
|
|
|
292
317
|
|
|
293
318
|
- `providers`:定义上游服务;`type` 支持 `openai | anthropic | kimi | deepseek | custom`。
|
|
294
319
|
- 模型标识使用 `providerId:modelId` 形式供路由引用。
|
|
295
|
-
- `modelRoutes`:将 Claude
|
|
320
|
+
- `modelRoutes`:将 Claude 发起的模型名映射到上游模型;支持在源模型名中使用 `*` 通配符匹配,匹配度更高(字符更多)的规则优先,同等情况下按配置顺序取第一条;若希望直接透传请求的模型名,可将目标写成 `providerId:*`,此时会将源请求中的模型名原样发送给对应 Provider。
|
|
296
321
|
- `routingPresets`:可选字段,保存多个 `anthropic`(或其他端点)路由模板,供 Web UI “一键切换”;每个模板仅包含 `name` 与 `modelRoutes`。
|
|
297
322
|
- `storeRequestPayloads` / `storeResponsePayloads`:是否分别在 SQLite 中压缩保存请求原文与响应内容;关闭可减少敏感数据落盘。
|
|
298
323
|
- `bodyLimit`:单次请求允许的最大请求体大小(字节),默认 10 MiB。`/compact` 等场景会发送较大上下文,如遇 413 可按需增大。
|
package/package.json
CHANGED
|
@@ -1,24 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chenpu17/cc-gw",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.12",
|
|
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
|
-
},
|
|
22
6
|
"bin": {
|
|
23
7
|
"cc-gw": "src/cli/dist/index.js"
|
|
24
8
|
},
|
|
@@ -29,15 +13,6 @@
|
|
|
29
13
|
"README.md",
|
|
30
14
|
"LICENSE"
|
|
31
15
|
],
|
|
32
|
-
"pnpm": {
|
|
33
|
-
"peerDependencyRules": {
|
|
34
|
-
"ignoreMissing": [
|
|
35
|
-
"react",
|
|
36
|
-
"react-dom"
|
|
37
|
-
]
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
"packageManager": "pnpm@9.0.0",
|
|
41
16
|
"engines": {
|
|
42
17
|
"node": ">=18.18.0"
|
|
43
18
|
},
|
|
@@ -75,5 +50,20 @@
|
|
|
75
50
|
"typescript": "^5.4.3",
|
|
76
51
|
"typescript-eslint": "^7.5.0",
|
|
77
52
|
"vitest": "^1.6.0"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"dev": "pnpm --filter server dev",
|
|
56
|
+
"build": "pnpm run build:server && pnpm run build:web",
|
|
57
|
+
"build:server": "pnpm --filter @cc-gw/server build",
|
|
58
|
+
"build:cli": "pnpm --filter @cc-gw/cli build",
|
|
59
|
+
"build:web": "pnpm --filter @cc-gw/web build",
|
|
60
|
+
"build:all": "pnpm run build:server && pnpm run build:cli && pnpm run build:web",
|
|
61
|
+
"release:bundle": "pnpm run build:all && node scripts/build-release.mjs",
|
|
62
|
+
"lint": "pnpm exec eslint .",
|
|
63
|
+
"format": "pnpm exec prettier --check .",
|
|
64
|
+
"format:write": "pnpm exec prettier --write .",
|
|
65
|
+
"typecheck": "pnpm -r exec tsc --noEmit",
|
|
66
|
+
"test": "pnpm exec vitest run",
|
|
67
|
+
"test:playwright": "playwright test"
|
|
78
68
|
}
|
|
79
|
-
}
|
|
69
|
+
}
|