hkfires commited on
Commit ·
62a9086
1
Parent(s): 35ad87e
refactor(provider): remove Gemini Web cookie-based support
Browse files- MANAGEMENT_API.md +0 -13
- MANAGEMENT_API_CN.md +0 -13
- README.md +0 -29
- README_CN.md +0 -29
- cmd/server/main.go +0 -4
- config.example.yaml +0 -16
- internal/api/handlers/management/auth_files.go +0 -62
- internal/api/server.go +0 -1
- internal/config/config.go +0 -37
- internal/constant/constant.go +0 -3
- internal/translator/init.go +0 -3
- internal/watcher/watcher.go +0 -15
- sdk/api/handlers/handlers.go +0 -21
- sdk/auth/refresh_registry.go +0 -1
- sdk/cliproxy/auth/manager.go +0 -7
- sdk/cliproxy/auth/types.go +0 -18
- sdk/cliproxy/service.go +0 -24
MANAGEMENT_API.md
CHANGED
|
@@ -639,19 +639,6 @@ These endpoints initiate provider login flows and return a URL to open in a brow
|
|
| 639 |
{ "status": "ok", "url": "https://..." }
|
| 640 |
```
|
| 641 |
|
| 642 |
-
- POST `/gemini-web-token` — Save Gemini Web cookies directly
|
| 643 |
-
- Request:
|
| 644 |
-
```bash
|
| 645 |
-
curl -H 'Authorization: Bearer <MANAGEMENT_KEY>' \
|
| 646 |
-
-H 'Content-Type: application/json' \
|
| 647 |
-
-d '{"secure_1psid": "<__Secure-1PSID>", "secure_1psidts": "<__Secure-1PSIDTS>", "label": "<LABEL>"}' \
|
| 648 |
-
http://localhost:8317/v0/management/gemini-web-token
|
| 649 |
-
```
|
| 650 |
-
- Response:
|
| 651 |
-
```json
|
| 652 |
-
{ "status": "ok", "file": "gemini-web-<hash>.json" }
|
| 653 |
-
```
|
| 654 |
-
|
| 655 |
- GET `/qwen-auth-url` — Start Qwen login (device flow)
|
| 656 |
- Request:
|
| 657 |
```bash
|
|
|
|
| 639 |
{ "status": "ok", "url": "https://..." }
|
| 640 |
```
|
| 641 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 642 |
- GET `/qwen-auth-url` — Start Qwen login (device flow)
|
| 643 |
- Request:
|
| 644 |
```bash
|
MANAGEMENT_API_CN.md
CHANGED
|
@@ -639,19 +639,6 @@
|
|
| 639 |
{ "status": "ok", "url": "https://..." }
|
| 640 |
```
|
| 641 |
|
| 642 |
-
- POST `/gemini-web-token` — 直接保存 Gemini Web Cookie
|
| 643 |
-
- 请求:
|
| 644 |
-
```bash
|
| 645 |
-
curl -H 'Authorization: Bearer <MANAGEMENT_KEY>' \
|
| 646 |
-
-H 'Content-Type: application/json' \
|
| 647 |
-
-d '{"secure_1psid": "<__Secure-1PSID>", "secure_1psidts": "<__Secure-1PSIDTS>", "label": "<LABEL>"}' \
|
| 648 |
-
http://localhost:8317/v0/management/gemini-web-token
|
| 649 |
-
```
|
| 650 |
-
- 响应:
|
| 651 |
-
```json
|
| 652 |
-
{ "status": "ok", "file": "gemini-web-<hash>.json" }
|
| 653 |
-
```
|
| 654 |
-
|
| 655 |
- GET `/qwen-auth-url` — 开始 Qwen 登录(设备授权流程)
|
| 656 |
- 请求:
|
| 657 |
```bash
|
|
|
|
| 639 |
{ "status": "ok", "url": "https://..." }
|
| 640 |
```
|
| 641 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 642 |
- GET `/qwen-auth-url` — 开始 Qwen 登录(设备授权流程)
|
| 643 |
- 请求:
|
| 644 |
```bash
|
README.md
CHANGED
|
@@ -17,7 +17,6 @@ Chinese providers have now been added: [Qwen Code](https://github.com/QwenLM/qwe
|
|
| 17 |
- Claude Code support via OAuth login
|
| 18 |
- Qwen Code support via OAuth login
|
| 19 |
- iFlow support via OAuth login
|
| 20 |
-
- Gemini Web support via cookie-based login
|
| 21 |
- Streaming and non-streaming responses
|
| 22 |
- Function calling/tools support
|
| 23 |
- Multimodal input support (text and images)
|
|
@@ -99,13 +98,6 @@ You can authenticate for Gemini, OpenAI, Claude, Qwen, and/or iFlow. All can coe
|
|
| 99 |
|
| 100 |
Options: add `--no-browser` to print the login URL instead of opening a browser. The local OAuth callback uses port `8085`.
|
| 101 |
|
| 102 |
-
- Gemini Web (via Cookies):
|
| 103 |
-
This method authenticates by simulating a browser, using cookies obtained from the Gemini website.
|
| 104 |
-
```bash
|
| 105 |
-
./cli-proxy-api --gemini-web-auth
|
| 106 |
-
```
|
| 107 |
-
You will be prompted to enter your `__Secure-1PSID` and `__Secure-1PSIDTS` values. Please retrieve these cookies from your browser's developer tools.
|
| 108 |
-
|
| 109 |
- OpenAI (Codex/GPT via OAuth):
|
| 110 |
```bash
|
| 111 |
./cli-proxy-api --codex-login
|
|
@@ -334,11 +326,6 @@ The server uses a YAML configuration file (`config.yaml`) located in the project
|
|
| 334 |
| `openai-compatibility.*.models` | object[] | [] | The actual model name. |
|
| 335 |
| `openai-compatibility.*.models.*.name` | string | "" | The models supported by the provider. |
|
| 336 |
| `openai-compatibility.*.models.*.alias` | string | "" | The alias used in the API. |
|
| 337 |
-
| `gemini-web` | object | {} | Configuration specific to the Gemini Web client. |
|
| 338 |
-
| `gemini-web.context` | boolean | true | Enables conversation context reuse for continuous dialogue. |
|
| 339 |
-
| `gemini-web.gem-mode` | string | "" | Selects a predefined Gem to attach for Gemini Web requests; allowed values: `coding-partner`, `writing-editor`. When empty, no Gem is attached. |
|
| 340 |
-
| `gemini-web.max-chars-per-request` | integer | 1,000,000 | The maximum number of characters to send to Gemini Web in a single request. |
|
| 341 |
-
| `gemini-web.disable-continuation-hint` | boolean | false | Disables the continuation hint for split prompts. |
|
| 342 |
|
| 343 |
### Example Configuration File
|
| 344 |
|
|
@@ -388,12 +375,6 @@ quota-exceeded:
|
|
| 388 |
switch-project: true # Whether to automatically switch to another project when a quota is exceeded
|
| 389 |
switch-preview-model: true # Whether to automatically switch to a preview model when a quota is exceeded
|
| 390 |
|
| 391 |
-
# Gemini Web client configuration
|
| 392 |
-
gemini-web:
|
| 393 |
-
context: true # Enable conversation context reuse
|
| 394 |
-
gem-mode: "" # Select Gem: "coding-partner" or "writing-editor"; empty means no Gem
|
| 395 |
-
max-chars-per-request: 1000000 # Max characters per request
|
| 396 |
-
|
| 397 |
# API keys for official Generative Language API
|
| 398 |
generative-language-api-key:
|
| 399 |
- "AIzaSy...01"
|
|
@@ -604,12 +585,6 @@ Run the following command to login (Gemini OAuth on port 8085):
|
|
| 604 |
docker run --rm -p 8085:8085 -v /path/to/your/config.yaml:/CLIProxyAPI/config.yaml -v /path/to/your/auth-dir:/root/.cli-proxy-api eceasy/cli-proxy-api:latest /CLIProxyAPI/CLIProxyAPI --login
|
| 605 |
```
|
| 606 |
|
| 607 |
-
Run the following command to login (Gemini Web Cookies):
|
| 608 |
-
|
| 609 |
-
```bash
|
| 610 |
-
docker run -it --rm -v /path/to/your/config.yaml:/CLIProxyAPI/config.yaml -v /path/to/your/auth-dir:/root/.cli-proxy-api eceasy/cli-proxy-api:latest /CLIProxyAPI/CLIProxyAPI --gemini-web-auth
|
| 611 |
-
```
|
| 612 |
-
|
| 613 |
Run the following command to login (OpenAI OAuth on port 1455):
|
| 614 |
|
| 615 |
```bash
|
|
@@ -680,10 +655,6 @@ docker run --rm -p 8317:8317 -v /path/to/your/config.yaml:/CLIProxyAPI/config.ya
|
|
| 680 |
```bash
|
| 681 |
docker compose exec cli-proxy-api /CLIProxyAPI/CLIProxyAPI -no-browser --login
|
| 682 |
```
|
| 683 |
-
- **Gemini Web**:
|
| 684 |
-
```bash
|
| 685 |
-
docker compose exec cli-proxy-api /CLIProxyAPI/CLIProxyAPI --gemini-web-auth
|
| 686 |
-
```
|
| 687 |
- **OpenAI (Codex)**:
|
| 688 |
```bash
|
| 689 |
docker compose exec cli-proxy-api /CLIProxyAPI/CLIProxyAPI -no-browser --codex-login
|
|
|
|
| 17 |
- Claude Code support via OAuth login
|
| 18 |
- Qwen Code support via OAuth login
|
| 19 |
- iFlow support via OAuth login
|
|
|
|
| 20 |
- Streaming and non-streaming responses
|
| 21 |
- Function calling/tools support
|
| 22 |
- Multimodal input support (text and images)
|
|
|
|
| 98 |
|
| 99 |
Options: add `--no-browser` to print the login URL instead of opening a browser. The local OAuth callback uses port `8085`.
|
| 100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
- OpenAI (Codex/GPT via OAuth):
|
| 102 |
```bash
|
| 103 |
./cli-proxy-api --codex-login
|
|
|
|
| 326 |
| `openai-compatibility.*.models` | object[] | [] | The actual model name. |
|
| 327 |
| `openai-compatibility.*.models.*.name` | string | "" | The models supported by the provider. |
|
| 328 |
| `openai-compatibility.*.models.*.alias` | string | "" | The alias used in the API. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 329 |
|
| 330 |
### Example Configuration File
|
| 331 |
|
|
|
|
| 375 |
switch-project: true # Whether to automatically switch to another project when a quota is exceeded
|
| 376 |
switch-preview-model: true # Whether to automatically switch to a preview model when a quota is exceeded
|
| 377 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 378 |
# API keys for official Generative Language API
|
| 379 |
generative-language-api-key:
|
| 380 |
- "AIzaSy...01"
|
|
|
|
| 585 |
docker run --rm -p 8085:8085 -v /path/to/your/config.yaml:/CLIProxyAPI/config.yaml -v /path/to/your/auth-dir:/root/.cli-proxy-api eceasy/cli-proxy-api:latest /CLIProxyAPI/CLIProxyAPI --login
|
| 586 |
```
|
| 587 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 588 |
Run the following command to login (OpenAI OAuth on port 1455):
|
| 589 |
|
| 590 |
```bash
|
|
|
|
| 655 |
```bash
|
| 656 |
docker compose exec cli-proxy-api /CLIProxyAPI/CLIProxyAPI -no-browser --login
|
| 657 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
| 658 |
- **OpenAI (Codex)**:
|
| 659 |
```bash
|
| 660 |
docker compose exec cli-proxy-api /CLIProxyAPI/CLIProxyAPI -no-browser --codex-login
|
README_CN.md
CHANGED
|
@@ -37,7 +37,6 @@
|
|
| 37 |
- 新增 Claude Code 支持(OAuth 登录)
|
| 38 |
- 新增 Qwen Code 支持(OAuth 登录)
|
| 39 |
- 新增 iFlow 支持(OAuth 登录)
|
| 40 |
-
- 新增 Gemini Web 支持(通过 Cookie 登录)
|
| 41 |
- 支持流式与非流式响应
|
| 42 |
- 函数调用/工具支持
|
| 43 |
- 多模态输入(文本、图片)
|
|
@@ -113,13 +112,6 @@ CLIProxyAPI 的基于 Web 的管理中心。
|
|
| 113 |
|
| 114 |
选项:加上 `--no-browser` 可打印登录地址而不自动打开浏览器。本地 OAuth 回调端口为 `8085`。
|
| 115 |
|
| 116 |
-
- Gemini Web (通过 Cookie):
|
| 117 |
-
此方法通过模拟浏览器行为,使用从 Gemini 网站获取的 Cookie 进行身份验证。
|
| 118 |
-
```bash
|
| 119 |
-
./cli-proxy-api --gemini-web-auth
|
| 120 |
-
```
|
| 121 |
-
程序将提示您输入 `__Secure-1PSID` 和 `__Secure-1PSIDTS` 的值。请从您的浏览器开发者工具中获取这些 Cookie。
|
| 122 |
-
|
| 123 |
- OpenAI(Codex/GPT,OAuth):
|
| 124 |
```bash
|
| 125 |
./cli-proxy-api --codex-login
|
|
@@ -347,11 +339,6 @@ console.log(await claudeResponse.json());
|
|
| 347 |
| `openai-compatibility.*.models` | object[] | [] | 实际的模型名称。 |
|
| 348 |
| `openai-compatibility.*.models.*.name` | string | "" | 提供商支持的模型。 |
|
| 349 |
| `openai-compatibility.*.models.*.alias` | string | "" | 在API中使用的别名。 |
|
| 350 |
-
| `gemini-web` | object | {} | Gemini Web 客户端的特定配置。 |
|
| 351 |
-
| `gemini-web.context` | boolean | true | 是否启用会话上下文重用,以实现连续对话。 |
|
| 352 |
-
| `gemini-web.gem-mode` | string | "" | 选择要附加的预设 Gem(`coding-partner` 或 `writing-editor`);为空表示不附加。 |
|
| 353 |
-
| `gemini-web.max-chars-per-request` | integer | 1,000,000 | 单次请求发送给 Gemini Web 的最大字符数。 |
|
| 354 |
-
| `gemini-web.disable-continuation-hint` | boolean | false | 当提示被拆分时,是否禁用连续提示的暗示。 |
|
| 355 |
|
| 356 |
### 配置文件示例
|
| 357 |
|
|
@@ -401,12 +388,6 @@ quota-exceeded:
|
|
| 401 |
switch-project: true # 当配额超限时是否自动切换到另一个项目
|
| 402 |
switch-preview-model: true # 当配额超限时是否自动切换到预览模型
|
| 403 |
|
| 404 |
-
# Gemini Web 客户端配置
|
| 405 |
-
gemini-web:
|
| 406 |
-
context: true # 启用会话上下文重用
|
| 407 |
-
gem-mode: "" # 选择 Gem:"coding-partner" 或 "writing-editor";为空表示不附加
|
| 408 |
-
max-chars-per-request: 1000000 # 单次请求最大字符数
|
| 409 |
-
|
| 410 |
# AIStduio Gemini API 的 API 密钥
|
| 411 |
generative-language-api-key:
|
| 412 |
- "AIzaSy...01"
|
|
@@ -613,12 +594,6 @@ auth.json:
|
|
| 613 |
docker run --rm -p 8085:8085 -v /path/to/your/config.yaml:/CLIProxyAPI/config.yaml -v /path/to/your/auth-dir:/root/.cli-proxy-api eceasy/cli-proxy-api:latest /CLIProxyAPI/CLIProxyAPI --login
|
| 614 |
```
|
| 615 |
|
| 616 |
-
运行以下命令进行登录(Gemini Web Cookie):
|
| 617 |
-
|
| 618 |
-
```bash
|
| 619 |
-
docker run -it --rm -v /path/to/your/config.yaml:/CLIProxyAPI/config.yaml -v /path/to/your/auth-dir:/root/.cli-proxy-api eceasy/cli-proxy-api:latest /CLIProxyAPI/CLIProxyAPI --gemini-web-auth
|
| 620 |
-
```
|
| 621 |
-
|
| 622 |
运行以下命令进行登录(OpenAI OAuth,端口 1455):
|
| 623 |
|
| 624 |
```bash
|
|
@@ -690,10 +665,6 @@ docker run --rm -p 8317:8317 -v /path/to/your/config.yaml:/CLIProxyAPI/config.ya
|
|
| 690 |
```bash
|
| 691 |
docker compose exec cli-proxy-api /CLIProxyAPI/CLIProxyAPI -no-browser --login
|
| 692 |
```
|
| 693 |
-
- **Gemini Web**:
|
| 694 |
-
```bash
|
| 695 |
-
docker compose exec cli-proxy-api /CLIProxyAPI/CLIProxyAPI --gemini-web-auth
|
| 696 |
-
```
|
| 697 |
- **OpenAI (Codex)**:
|
| 698 |
```bash
|
| 699 |
docker compose exec cli-proxy-api /CLIProxyAPI/CLIProxyAPI -no-browser --codex-login
|
|
|
|
| 37 |
- 新增 Claude Code 支持(OAuth 登录)
|
| 38 |
- 新增 Qwen Code 支持(OAuth 登录)
|
| 39 |
- 新增 iFlow 支持(OAuth 登录)
|
|
|
|
| 40 |
- 支持流式与非流式响应
|
| 41 |
- 函数调用/工具支持
|
| 42 |
- 多模态输入(文本、图片)
|
|
|
|
| 112 |
|
| 113 |
选项:加上 `--no-browser` 可打印登录地址而不自动打开浏览器。本地 OAuth 回调端口为 `8085`。
|
| 114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
- OpenAI(Codex/GPT,OAuth):
|
| 116 |
```bash
|
| 117 |
./cli-proxy-api --codex-login
|
|
|
|
| 339 |
| `openai-compatibility.*.models` | object[] | [] | 实际的模型名称。 |
|
| 340 |
| `openai-compatibility.*.models.*.name` | string | "" | 提供商支持的模型。 |
|
| 341 |
| `openai-compatibility.*.models.*.alias` | string | "" | 在API中使用的别名。 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 342 |
|
| 343 |
### 配置文件示例
|
| 344 |
|
|
|
|
| 388 |
switch-project: true # 当配额超限时是否自动切换到另一个项目
|
| 389 |
switch-preview-model: true # 当配额超限时是否自动切换到预览模型
|
| 390 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 391 |
# AIStduio Gemini API 的 API 密钥
|
| 392 |
generative-language-api-key:
|
| 393 |
- "AIzaSy...01"
|
|
|
|
| 594 |
docker run --rm -p 8085:8085 -v /path/to/your/config.yaml:/CLIProxyAPI/config.yaml -v /path/to/your/auth-dir:/root/.cli-proxy-api eceasy/cli-proxy-api:latest /CLIProxyAPI/CLIProxyAPI --login
|
| 595 |
```
|
| 596 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 597 |
运行以下命令进行登录(OpenAI OAuth,端口 1455):
|
| 598 |
|
| 599 |
```bash
|
|
|
|
| 665 |
```bash
|
| 666 |
docker compose exec cli-proxy-api /CLIProxyAPI/CLIProxyAPI -no-browser --login
|
| 667 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
| 668 |
- **OpenAI (Codex)**:
|
| 669 |
```bash
|
| 670 |
docker compose exec cli-proxy-api /CLIProxyAPI/CLIProxyAPI -no-browser --codex-login
|
cmd/server/main.go
CHANGED
|
@@ -44,7 +44,6 @@ func main() {
|
|
| 44 |
var claudeLogin bool
|
| 45 |
var qwenLogin bool
|
| 46 |
var iflowLogin bool
|
| 47 |
-
var geminiWebAuth bool
|
| 48 |
var noBrowser bool
|
| 49 |
var projectID string
|
| 50 |
var configPath string
|
|
@@ -56,7 +55,6 @@ func main() {
|
|
| 56 |
flag.BoolVar(&claudeLogin, "claude-login", false, "Login to Claude using OAuth")
|
| 57 |
flag.BoolVar(&qwenLogin, "qwen-login", false, "Login to Qwen using OAuth")
|
| 58 |
flag.BoolVar(&iflowLogin, "iflow-login", false, "Login to iFlow using OAuth")
|
| 59 |
-
flag.BoolVar(&geminiWebAuth, "gemini-web-auth", false, "Auth Gemini Web using cookies")
|
| 60 |
flag.BoolVar(&noBrowser, "no-browser", false, "Don't open browser automatically for OAuth")
|
| 61 |
flag.StringVar(&projectID, "project_id", "", "Project ID (Gemini only, not required)")
|
| 62 |
flag.StringVar(&configPath, "config", DefaultConfigPath, "Configure File Path")
|
|
@@ -182,8 +180,6 @@ func main() {
|
|
| 182 |
cmd.DoQwenLogin(cfg, options)
|
| 183 |
} else if iflowLogin {
|
| 184 |
cmd.DoIFlowLogin(cfg, options)
|
| 185 |
-
} else if geminiWebAuth {
|
| 186 |
-
cmd.DoGeminiWebAuth(cfg)
|
| 187 |
} else {
|
| 188 |
// In cloud deploy mode without config file, just wait for shutdown signals
|
| 189 |
if isCloudDeploy && !configFileExists {
|
|
|
|
| 44 |
var claudeLogin bool
|
| 45 |
var qwenLogin bool
|
| 46 |
var iflowLogin bool
|
|
|
|
| 47 |
var noBrowser bool
|
| 48 |
var projectID string
|
| 49 |
var configPath string
|
|
|
|
| 55 |
flag.BoolVar(&claudeLogin, "claude-login", false, "Login to Claude using OAuth")
|
| 56 |
flag.BoolVar(&qwenLogin, "qwen-login", false, "Login to Qwen using OAuth")
|
| 57 |
flag.BoolVar(&iflowLogin, "iflow-login", false, "Login to iFlow using OAuth")
|
|
|
|
| 58 |
flag.BoolVar(&noBrowser, "no-browser", false, "Don't open browser automatically for OAuth")
|
| 59 |
flag.StringVar(&projectID, "project_id", "", "Project ID (Gemini only, not required)")
|
| 60 |
flag.StringVar(&configPath, "config", DefaultConfigPath, "Configure File Path")
|
|
|
|
| 180 |
cmd.DoQwenLogin(cfg, options)
|
| 181 |
} else if iflowLogin {
|
| 182 |
cmd.DoIFlowLogin(cfg, options)
|
|
|
|
|
|
|
| 183 |
} else {
|
| 184 |
// In cloud deploy mode without config file, just wait for shutdown signals
|
| 185 |
if isCloudDeploy && !configFileExists {
|
config.example.yaml
CHANGED
|
@@ -79,19 +79,3 @@ quota-exceeded:
|
|
| 79 |
# models: # The models supported by the provider.
|
| 80 |
# - name: "moonshotai/kimi-k2:free" # The actual model name.
|
| 81 |
# alias: "kimi-k2" # The alias used in the API.
|
| 82 |
-
|
| 83 |
-
# Gemini Web settings
|
| 84 |
-
#gemini-web:
|
| 85 |
-
# # Conversation reuse: set to true to enable (default), false to disable.
|
| 86 |
-
# context: true
|
| 87 |
-
# # Maximum characters per single request to Gemini Web. Requests exceeding this
|
| 88 |
-
# # size split into chunks. Only the last chunk carries files and yields the final answer.
|
| 89 |
-
# max-chars-per-request: 1000000
|
| 90 |
-
# # Disable the short continuation hint appended to intermediate chunks
|
| 91 |
-
# # when splitting long prompts. Default is false (hint enabled by default).
|
| 92 |
-
# disable-continuation-hint: false
|
| 93 |
-
# # Gem selection (Gem Mode):
|
| 94 |
-
# # - "coding-partner": attach the predefined Coding partner Gem
|
| 95 |
-
# # - "writing-editor": attach the predefined Writing editor Gem
|
| 96 |
-
# # - empty: do not attach any Gem
|
| 97 |
-
# gem-mode: ""
|
|
|
|
| 79 |
# models: # The models supported by the provider.
|
| 80 |
# - name: "moonshotai/kimi-k2:free" # The actual model name.
|
| 81 |
# alias: "kimi-k2" # The alias used in the API.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal/api/handlers/management/auth_files.go
CHANGED
|
@@ -3,8 +3,6 @@ package management
|
|
| 3 |
import (
|
| 4 |
"bytes"
|
| 5 |
"context"
|
| 6 |
-
"crypto/sha256"
|
| 7 |
-
"encoding/hex"
|
| 8 |
"encoding/json"
|
| 9 |
"errors"
|
| 10 |
"fmt"
|
|
@@ -25,7 +23,6 @@ import (
|
|
| 25 |
geminiAuth "github.com/router-for-me/CLIProxyAPI/v6/internal/auth/gemini"
|
| 26 |
iflowauth "github.com/router-for-me/CLIProxyAPI/v6/internal/auth/iflow"
|
| 27 |
"github.com/router-for-me/CLIProxyAPI/v6/internal/auth/qwen"
|
| 28 |
-
// legacy client removed
|
| 29 |
"github.com/router-for-me/CLIProxyAPI/v6/internal/interfaces"
|
| 30 |
"github.com/router-for-me/CLIProxyAPI/v6/internal/misc"
|
| 31 |
"github.com/router-for-me/CLIProxyAPI/v6/internal/util"
|
|
@@ -903,65 +900,6 @@ func (h *Handler) RequestGeminiCLIToken(c *gin.Context) {
|
|
| 903 |
c.JSON(200, gin.H{"status": "ok", "url": authURL, "state": state})
|
| 904 |
}
|
| 905 |
|
| 906 |
-
func (h *Handler) CreateGeminiWebToken(c *gin.Context) {
|
| 907 |
-
ctx := c.Request.Context()
|
| 908 |
-
|
| 909 |
-
var payload struct {
|
| 910 |
-
Secure1PSID string `json:"secure_1psid"`
|
| 911 |
-
Secure1PSIDTS string `json:"secure_1psidts"`
|
| 912 |
-
Label string `json:"label"`
|
| 913 |
-
}
|
| 914 |
-
if err := c.ShouldBindJSON(&payload); err != nil {
|
| 915 |
-
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid body"})
|
| 916 |
-
return
|
| 917 |
-
}
|
| 918 |
-
payload.Secure1PSID = strings.TrimSpace(payload.Secure1PSID)
|
| 919 |
-
payload.Secure1PSIDTS = strings.TrimSpace(payload.Secure1PSIDTS)
|
| 920 |
-
payload.Label = strings.TrimSpace(payload.Label)
|
| 921 |
-
if payload.Secure1PSID == "" {
|
| 922 |
-
c.JSON(http.StatusBadRequest, gin.H{"error": "secure_1psid is required"})
|
| 923 |
-
return
|
| 924 |
-
}
|
| 925 |
-
if payload.Secure1PSIDTS == "" {
|
| 926 |
-
c.JSON(http.StatusBadRequest, gin.H{"error": "secure_1psidts is required"})
|
| 927 |
-
return
|
| 928 |
-
}
|
| 929 |
-
if payload.Label == "" {
|
| 930 |
-
c.JSON(http.StatusBadRequest, gin.H{"error": "label is required"})
|
| 931 |
-
return
|
| 932 |
-
}
|
| 933 |
-
|
| 934 |
-
sha := sha256.New()
|
| 935 |
-
sha.Write([]byte(payload.Secure1PSID))
|
| 936 |
-
hash := hex.EncodeToString(sha.Sum(nil))
|
| 937 |
-
fileName := fmt.Sprintf("gemini-web-%s.json", hash[:16])
|
| 938 |
-
|
| 939 |
-
tokenStorage := &geminiAuth.GeminiWebTokenStorage{
|
| 940 |
-
Secure1PSID: payload.Secure1PSID,
|
| 941 |
-
Secure1PSIDTS: payload.Secure1PSIDTS,
|
| 942 |
-
Label: payload.Label,
|
| 943 |
-
}
|
| 944 |
-
// Provide a stable label (gemini-web-<hash>) for logging and identification
|
| 945 |
-
tokenStorage.Label = strings.TrimSuffix(fileName, ".json")
|
| 946 |
-
|
| 947 |
-
record := &coreauth.Auth{
|
| 948 |
-
ID: fileName,
|
| 949 |
-
Provider: "gemini-web",
|
| 950 |
-
FileName: fileName,
|
| 951 |
-
Storage: tokenStorage,
|
| 952 |
-
}
|
| 953 |
-
|
| 954 |
-
savedPath, errSave := h.saveTokenRecord(ctx, record)
|
| 955 |
-
if errSave != nil {
|
| 956 |
-
log.Errorf("Failed to save Gemini Web token: %v", errSave)
|
| 957 |
-
c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to save token"})
|
| 958 |
-
return
|
| 959 |
-
}
|
| 960 |
-
|
| 961 |
-
fmt.Printf("Successfully saved Gemini Web token to: %s\n", savedPath)
|
| 962 |
-
c.JSON(http.StatusOK, gin.H{"status": "ok", "file": filepath.Base(savedPath)})
|
| 963 |
-
}
|
| 964 |
-
|
| 965 |
func (h *Handler) RequestCodexToken(c *gin.Context) {
|
| 966 |
ctx := context.Background()
|
| 967 |
|
|
|
|
| 3 |
import (
|
| 4 |
"bytes"
|
| 5 |
"context"
|
|
|
|
|
|
|
| 6 |
"encoding/json"
|
| 7 |
"errors"
|
| 8 |
"fmt"
|
|
|
|
| 23 |
geminiAuth "github.com/router-for-me/CLIProxyAPI/v6/internal/auth/gemini"
|
| 24 |
iflowauth "github.com/router-for-me/CLIProxyAPI/v6/internal/auth/iflow"
|
| 25 |
"github.com/router-for-me/CLIProxyAPI/v6/internal/auth/qwen"
|
|
|
|
| 26 |
"github.com/router-for-me/CLIProxyAPI/v6/internal/interfaces"
|
| 27 |
"github.com/router-for-me/CLIProxyAPI/v6/internal/misc"
|
| 28 |
"github.com/router-for-me/CLIProxyAPI/v6/internal/util"
|
|
|
|
| 900 |
c.JSON(200, gin.H{"status": "ok", "url": authURL, "state": state})
|
| 901 |
}
|
| 902 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 903 |
func (h *Handler) RequestCodexToken(c *gin.Context) {
|
| 904 |
ctx := context.Background()
|
| 905 |
|
internal/api/server.go
CHANGED
|
@@ -419,7 +419,6 @@ func (s *Server) registerManagementRoutes() {
|
|
| 419 |
mgmt.GET("/anthropic-auth-url", s.mgmt.RequestAnthropicToken)
|
| 420 |
mgmt.GET("/codex-auth-url", s.mgmt.RequestCodexToken)
|
| 421 |
mgmt.GET("/gemini-cli-auth-url", s.mgmt.RequestGeminiCLIToken)
|
| 422 |
-
mgmt.POST("/gemini-web-token", s.mgmt.CreateGeminiWebToken)
|
| 423 |
mgmt.GET("/qwen-auth-url", s.mgmt.RequestQwenToken)
|
| 424 |
mgmt.GET("/iflow-auth-url", s.mgmt.RequestIFlowToken)
|
| 425 |
mgmt.GET("/get-auth-status", s.mgmt.GetAuthStatus)
|
|
|
|
| 419 |
mgmt.GET("/anthropic-auth-url", s.mgmt.RequestAnthropicToken)
|
| 420 |
mgmt.GET("/codex-auth-url", s.mgmt.RequestCodexToken)
|
| 421 |
mgmt.GET("/gemini-cli-auth-url", s.mgmt.RequestGeminiCLIToken)
|
|
|
|
| 422 |
mgmt.GET("/qwen-auth-url", s.mgmt.RequestQwenToken)
|
| 423 |
mgmt.GET("/iflow-auth-url", s.mgmt.RequestIFlowToken)
|
| 424 |
mgmt.GET("/get-auth-status", s.mgmt.GetAuthStatus)
|
internal/config/config.go
CHANGED
|
@@ -53,42 +53,6 @@ type Config struct {
|
|
| 53 |
|
| 54 |
// RemoteManagement nests management-related options under 'remote-management'.
|
| 55 |
RemoteManagement RemoteManagement `yaml:"remote-management" json:"-"`
|
| 56 |
-
|
| 57 |
-
// GeminiWeb groups configuration for Gemini Web client
|
| 58 |
-
GeminiWeb GeminiWebConfig `yaml:"gemini-web" json:"gemini-web"`
|
| 59 |
-
}
|
| 60 |
-
|
| 61 |
-
// GeminiWebConfig nests Gemini Web related options under 'gemini-web'.
|
| 62 |
-
type GeminiWebConfig struct {
|
| 63 |
-
// Context enables JSON-based conversation reuse.
|
| 64 |
-
// Defaults to true if not set in YAML (see LoadConfig).
|
| 65 |
-
Context bool `yaml:"context" json:"context"`
|
| 66 |
-
|
| 67 |
-
// GemMode selects a predefined Gem to attach for Gemini Web requests.
|
| 68 |
-
// Allowed values:
|
| 69 |
-
// - "coding-partner"
|
| 70 |
-
// - "writing-editor"
|
| 71 |
-
// When empty, no Gem is attached by configuration.
|
| 72 |
-
// This is independent from CodeMode below, which is kept for backwards compatibility.
|
| 73 |
-
GemMode string `yaml:"gem-mode" json:"gem-mode"`
|
| 74 |
-
|
| 75 |
-
// CodeMode enables legacy coding-mode behaviors for Gemini Web.
|
| 76 |
-
// Backwards compatibility: when true, the service behaves as before by
|
| 77 |
-
// attaching the predefined "Coding partner" Gem and enabling extra
|
| 78 |
-
// conveniences (e.g., XML wrapping hints). Prefer GemMode for selecting
|
| 79 |
-
// a Gem going forward.
|
| 80 |
-
CodeMode bool `yaml:"code-mode" json:"code-mode"`
|
| 81 |
-
|
| 82 |
-
// MaxCharsPerRequest caps the number of characters (runes) sent to
|
| 83 |
-
// Gemini Web in a single request. Long prompts will be split into
|
| 84 |
-
// multiple requests with a continuation hint, and only the final
|
| 85 |
-
// request will carry any files. When unset or <=0, a conservative
|
| 86 |
-
// default of 1,000,000 will be used.
|
| 87 |
-
MaxCharsPerRequest int `yaml:"max-chars-per-request" json:"max-chars-per-request"`
|
| 88 |
-
|
| 89 |
-
// DisableContinuationHint, when true, disables the continuation hint for split prompts.
|
| 90 |
-
// The hint is enabled by default.
|
| 91 |
-
DisableContinuationHint bool `yaml:"disable-continuation-hint,omitempty" json:"disable-continuation-hint,omitempty"`
|
| 92 |
}
|
| 93 |
|
| 94 |
// RemoteManagement holds management API configuration under 'remote-management'.
|
|
@@ -212,7 +176,6 @@ func LoadConfigOptional(configFile string, optional bool) (*Config, error) {
|
|
| 212 |
// Set defaults before unmarshal so that absent keys keep defaults.
|
| 213 |
cfg.LoggingToFile = true
|
| 214 |
cfg.UsageStatisticsEnabled = true
|
| 215 |
-
cfg.GeminiWeb.Context = true
|
| 216 |
if err = yaml.Unmarshal(data, &cfg); err != nil {
|
| 217 |
return nil, fmt.Errorf("failed to parse config file: %w", err)
|
| 218 |
}
|
|
|
|
| 53 |
|
| 54 |
// RemoteManagement nests management-related options under 'remote-management'.
|
| 55 |
RemoteManagement RemoteManagement `yaml:"remote-management" json:"-"`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
}
|
| 57 |
|
| 58 |
// RemoteManagement holds management API configuration under 'remote-management'.
|
|
|
|
| 176 |
// Set defaults before unmarshal so that absent keys keep defaults.
|
| 177 |
cfg.LoggingToFile = true
|
| 178 |
cfg.UsageStatisticsEnabled = true
|
|
|
|
| 179 |
if err = yaml.Unmarshal(data, &cfg); err != nil {
|
| 180 |
return nil, fmt.Errorf("failed to parse config file: %w", err)
|
| 181 |
}
|
internal/constant/constant.go
CHANGED
|
@@ -10,9 +10,6 @@ const (
|
|
| 10 |
// GeminiCLI represents the Google Gemini CLI provider identifier.
|
| 11 |
GeminiCLI = "gemini-cli"
|
| 12 |
|
| 13 |
-
// GeminiWeb represents the Google Gemini Web provider identifier.
|
| 14 |
-
GeminiWeb = "gemini-web"
|
| 15 |
-
|
| 16 |
// Codex represents the OpenAI Codex provider identifier.
|
| 17 |
Codex = "codex"
|
| 18 |
|
|
|
|
| 10 |
// GeminiCLI represents the Google Gemini CLI provider identifier.
|
| 11 |
GeminiCLI = "gemini-cli"
|
| 12 |
|
|
|
|
|
|
|
|
|
|
| 13 |
// Codex represents the OpenAI Codex provider identifier.
|
| 14 |
Codex = "codex"
|
| 15 |
|
internal/translator/init.go
CHANGED
|
@@ -23,9 +23,6 @@ import (
|
|
| 23 |
_ "github.com/router-for-me/CLIProxyAPI/v6/internal/translator/gemini/openai/chat-completions"
|
| 24 |
_ "github.com/router-for-me/CLIProxyAPI/v6/internal/translator/gemini/openai/responses"
|
| 25 |
|
| 26 |
-
_ "github.com/router-for-me/CLIProxyAPI/v6/internal/translator/gemini-web/openai/chat-completions"
|
| 27 |
-
_ "github.com/router-for-me/CLIProxyAPI/v6/internal/translator/gemini-web/openai/responses"
|
| 28 |
-
|
| 29 |
_ "github.com/router-for-me/CLIProxyAPI/v6/internal/translator/openai/claude"
|
| 30 |
_ "github.com/router-for-me/CLIProxyAPI/v6/internal/translator/openai/gemini"
|
| 31 |
_ "github.com/router-for-me/CLIProxyAPI/v6/internal/translator/openai/gemini-cli"
|
|
|
|
| 23 |
_ "github.com/router-for-me/CLIProxyAPI/v6/internal/translator/gemini/openai/chat-completions"
|
| 24 |
_ "github.com/router-for-me/CLIProxyAPI/v6/internal/translator/gemini/openai/responses"
|
| 25 |
|
|
|
|
|
|
|
|
|
|
| 26 |
_ "github.com/router-for-me/CLIProxyAPI/v6/internal/translator/openai/claude"
|
| 27 |
_ "github.com/router-for-me/CLIProxyAPI/v6/internal/translator/openai/gemini"
|
| 28 |
_ "github.com/router-for-me/CLIProxyAPI/v6/internal/translator/openai/gemini-cli"
|
internal/watcher/watcher.go
CHANGED
|
@@ -512,21 +512,6 @@ func (w *Watcher) reloadConfig() bool {
|
|
| 512 |
if oldConfig.RequestRetry != newConfig.RequestRetry {
|
| 513 |
log.Debugf(" request-retry: %d -> %d", oldConfig.RequestRetry, newConfig.RequestRetry)
|
| 514 |
}
|
| 515 |
-
if oldConfig.GeminiWeb.Context != newConfig.GeminiWeb.Context {
|
| 516 |
-
log.Debugf(" gemini-web.context: %t -> %t", oldConfig.GeminiWeb.Context, newConfig.GeminiWeb.Context)
|
| 517 |
-
}
|
| 518 |
-
if oldConfig.GeminiWeb.MaxCharsPerRequest != newConfig.GeminiWeb.MaxCharsPerRequest {
|
| 519 |
-
log.Debugf(" gemini-web.max-chars-per-request: %d -> %d", oldConfig.GeminiWeb.MaxCharsPerRequest, newConfig.GeminiWeb.MaxCharsPerRequest)
|
| 520 |
-
}
|
| 521 |
-
if oldConfig.GeminiWeb.DisableContinuationHint != newConfig.GeminiWeb.DisableContinuationHint {
|
| 522 |
-
log.Debugf(" gemini-web.disable-continuation-hint: %t -> %t", oldConfig.GeminiWeb.DisableContinuationHint, newConfig.GeminiWeb.DisableContinuationHint)
|
| 523 |
-
}
|
| 524 |
-
if oldConfig.GeminiWeb.GemMode != newConfig.GeminiWeb.GemMode {
|
| 525 |
-
log.Debugf(" gemini-web.gem-mode: %s -> %s", oldConfig.GeminiWeb.GemMode, newConfig.GeminiWeb.GemMode)
|
| 526 |
-
}
|
| 527 |
-
if oldConfig.GeminiWeb.CodeMode != newConfig.GeminiWeb.CodeMode {
|
| 528 |
-
log.Debugf(" gemini-web.code-mode: %t -> %t", oldConfig.GeminiWeb.CodeMode, newConfig.GeminiWeb.CodeMode)
|
| 529 |
-
}
|
| 530 |
if len(oldConfig.APIKeys) != len(newConfig.APIKeys) {
|
| 531 |
log.Debugf(" api-keys count: %d -> %d", len(oldConfig.APIKeys), len(newConfig.APIKeys))
|
| 532 |
}
|
|
|
|
| 512 |
if oldConfig.RequestRetry != newConfig.RequestRetry {
|
| 513 |
log.Debugf(" request-retry: %d -> %d", oldConfig.RequestRetry, newConfig.RequestRetry)
|
| 514 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 515 |
if len(oldConfig.APIKeys) != len(newConfig.APIKeys) {
|
| 516 |
log.Debugf(" api-keys count: %d -> %d", len(oldConfig.APIKeys), len(newConfig.APIKeys))
|
| 517 |
}
|
sdk/api/handlers/handlers.go
CHANGED
|
@@ -9,7 +9,6 @@ import (
|
|
| 9 |
|
| 10 |
"github.com/gin-gonic/gin"
|
| 11 |
"github.com/router-for-me/CLIProxyAPI/v6/internal/interfaces"
|
| 12 |
-
conversation "github.com/router-for-me/CLIProxyAPI/v6/internal/provider/gemini-web/conversation"
|
| 13 |
"github.com/router-for-me/CLIProxyAPI/v6/internal/util"
|
| 14 |
coreauth "github.com/router-for-me/CLIProxyAPI/v6/sdk/cliproxy/auth"
|
| 15 |
coreexecutor "github.com/router-for-me/CLIProxyAPI/v6/sdk/cliproxy/executor"
|
|
@@ -49,8 +48,6 @@ type BaseAPIHandler struct {
|
|
| 49 |
Cfg *config.SDKConfig
|
| 50 |
}
|
| 51 |
|
| 52 |
-
const geminiWebProvider = "gemini-web"
|
| 53 |
-
|
| 54 |
// NewBaseAPIHandlers creates a new API handlers instance.
|
| 55 |
// It takes a slice of clients and configuration as input.
|
| 56 |
//
|
|
@@ -140,7 +137,6 @@ func (h *BaseAPIHandler) ExecuteWithAuthManager(ctx context.Context, handlerType
|
|
| 140 |
if len(providers) == 0 {
|
| 141 |
return nil, &interfaces.ErrorMessage{StatusCode: http.StatusBadRequest, Error: fmt.Errorf("unknown provider for model %s", modelName)}
|
| 142 |
}
|
| 143 |
-
metadata := h.buildGeminiWebMetadata(handlerType, providers, rawJSON)
|
| 144 |
req := coreexecutor.Request{
|
| 145 |
Model: modelName,
|
| 146 |
Payload: cloneBytes(rawJSON),
|
|
@@ -150,7 +146,6 @@ func (h *BaseAPIHandler) ExecuteWithAuthManager(ctx context.Context, handlerType
|
|
| 150 |
Alt: alt,
|
| 151 |
OriginalRequest: cloneBytes(rawJSON),
|
| 152 |
SourceFormat: sdktranslator.FromString(handlerType),
|
| 153 |
-
Metadata: metadata,
|
| 154 |
}
|
| 155 |
resp, err := h.AuthManager.Execute(ctx, providers, req, opts)
|
| 156 |
if err != nil {
|
|
@@ -166,7 +161,6 @@ func (h *BaseAPIHandler) ExecuteCountWithAuthManager(ctx context.Context, handle
|
|
| 166 |
if len(providers) == 0 {
|
| 167 |
return nil, &interfaces.ErrorMessage{StatusCode: http.StatusBadRequest, Error: fmt.Errorf("unknown provider for model %s", modelName)}
|
| 168 |
}
|
| 169 |
-
metadata := h.buildGeminiWebMetadata(handlerType, providers, rawJSON)
|
| 170 |
req := coreexecutor.Request{
|
| 171 |
Model: modelName,
|
| 172 |
Payload: cloneBytes(rawJSON),
|
|
@@ -176,7 +170,6 @@ func (h *BaseAPIHandler) ExecuteCountWithAuthManager(ctx context.Context, handle
|
|
| 176 |
Alt: alt,
|
| 177 |
OriginalRequest: cloneBytes(rawJSON),
|
| 178 |
SourceFormat: sdktranslator.FromString(handlerType),
|
| 179 |
-
Metadata: metadata,
|
| 180 |
}
|
| 181 |
resp, err := h.AuthManager.ExecuteCount(ctx, providers, req, opts)
|
| 182 |
if err != nil {
|
|
@@ -195,7 +188,6 @@ func (h *BaseAPIHandler) ExecuteStreamWithAuthManager(ctx context.Context, handl
|
|
| 195 |
close(errChan)
|
| 196 |
return nil, errChan
|
| 197 |
}
|
| 198 |
-
metadata := h.buildGeminiWebMetadata(handlerType, providers, rawJSON)
|
| 199 |
req := coreexecutor.Request{
|
| 200 |
Model: modelName,
|
| 201 |
Payload: cloneBytes(rawJSON),
|
|
@@ -205,7 +197,6 @@ func (h *BaseAPIHandler) ExecuteStreamWithAuthManager(ctx context.Context, handl
|
|
| 205 |
Alt: alt,
|
| 206 |
OriginalRequest: cloneBytes(rawJSON),
|
| 207 |
SourceFormat: sdktranslator.FromString(handlerType),
|
| 208 |
-
Metadata: metadata,
|
| 209 |
}
|
| 210 |
chunks, err := h.AuthManager.ExecuteStream(ctx, providers, req, opts)
|
| 211 |
if err != nil {
|
|
@@ -241,18 +232,6 @@ func cloneBytes(src []byte) []byte {
|
|
| 241 |
return dst
|
| 242 |
}
|
| 243 |
|
| 244 |
-
func (h *BaseAPIHandler) buildGeminiWebMetadata(handlerType string, providers []string, rawJSON []byte) map[string]any {
|
| 245 |
-
if !util.InArray(providers, geminiWebProvider) {
|
| 246 |
-
return nil
|
| 247 |
-
}
|
| 248 |
-
meta := make(map[string]any)
|
| 249 |
-
msgs := conversation.ExtractMessages(handlerType, rawJSON)
|
| 250 |
-
if len(msgs) > 0 {
|
| 251 |
-
meta[conversation.MetadataMessagesKey] = msgs
|
| 252 |
-
}
|
| 253 |
-
return meta
|
| 254 |
-
}
|
| 255 |
-
|
| 256 |
// WriteErrorResponse writes an error message to the response writer using the HTTP status embedded in the message.
|
| 257 |
func (h *BaseAPIHandler) WriteErrorResponse(c *gin.Context, msg *interfaces.ErrorMessage) {
|
| 258 |
status := http.StatusInternalServerError
|
|
|
|
| 9 |
|
| 10 |
"github.com/gin-gonic/gin"
|
| 11 |
"github.com/router-for-me/CLIProxyAPI/v6/internal/interfaces"
|
|
|
|
| 12 |
"github.com/router-for-me/CLIProxyAPI/v6/internal/util"
|
| 13 |
coreauth "github.com/router-for-me/CLIProxyAPI/v6/sdk/cliproxy/auth"
|
| 14 |
coreexecutor "github.com/router-for-me/CLIProxyAPI/v6/sdk/cliproxy/executor"
|
|
|
|
| 48 |
Cfg *config.SDKConfig
|
| 49 |
}
|
| 50 |
|
|
|
|
|
|
|
| 51 |
// NewBaseAPIHandlers creates a new API handlers instance.
|
| 52 |
// It takes a slice of clients and configuration as input.
|
| 53 |
//
|
|
|
|
| 137 |
if len(providers) == 0 {
|
| 138 |
return nil, &interfaces.ErrorMessage{StatusCode: http.StatusBadRequest, Error: fmt.Errorf("unknown provider for model %s", modelName)}
|
| 139 |
}
|
|
|
|
| 140 |
req := coreexecutor.Request{
|
| 141 |
Model: modelName,
|
| 142 |
Payload: cloneBytes(rawJSON),
|
|
|
|
| 146 |
Alt: alt,
|
| 147 |
OriginalRequest: cloneBytes(rawJSON),
|
| 148 |
SourceFormat: sdktranslator.FromString(handlerType),
|
|
|
|
| 149 |
}
|
| 150 |
resp, err := h.AuthManager.Execute(ctx, providers, req, opts)
|
| 151 |
if err != nil {
|
|
|
|
| 161 |
if len(providers) == 0 {
|
| 162 |
return nil, &interfaces.ErrorMessage{StatusCode: http.StatusBadRequest, Error: fmt.Errorf("unknown provider for model %s", modelName)}
|
| 163 |
}
|
|
|
|
| 164 |
req := coreexecutor.Request{
|
| 165 |
Model: modelName,
|
| 166 |
Payload: cloneBytes(rawJSON),
|
|
|
|
| 170 |
Alt: alt,
|
| 171 |
OriginalRequest: cloneBytes(rawJSON),
|
| 172 |
SourceFormat: sdktranslator.FromString(handlerType),
|
|
|
|
| 173 |
}
|
| 174 |
resp, err := h.AuthManager.ExecuteCount(ctx, providers, req, opts)
|
| 175 |
if err != nil {
|
|
|
|
| 188 |
close(errChan)
|
| 189 |
return nil, errChan
|
| 190 |
}
|
|
|
|
| 191 |
req := coreexecutor.Request{
|
| 192 |
Model: modelName,
|
| 193 |
Payload: cloneBytes(rawJSON),
|
|
|
|
| 197 |
Alt: alt,
|
| 198 |
OriginalRequest: cloneBytes(rawJSON),
|
| 199 |
SourceFormat: sdktranslator.FromString(handlerType),
|
|
|
|
| 200 |
}
|
| 201 |
chunks, err := h.AuthManager.ExecuteStream(ctx, providers, req, opts)
|
| 202 |
if err != nil {
|
|
|
|
| 232 |
return dst
|
| 233 |
}
|
| 234 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
// WriteErrorResponse writes an error message to the response writer using the HTTP status embedded in the message.
|
| 236 |
func (h *BaseAPIHandler) WriteErrorResponse(c *gin.Context, msg *interfaces.ErrorMessage) {
|
| 237 |
status := http.StatusInternalServerError
|
sdk/auth/refresh_registry.go
CHANGED
|
@@ -13,7 +13,6 @@ func init() {
|
|
| 13 |
registerRefreshLead("iflow", func() Authenticator { return NewIFlowAuthenticator() })
|
| 14 |
registerRefreshLead("gemini", func() Authenticator { return NewGeminiAuthenticator() })
|
| 15 |
registerRefreshLead("gemini-cli", func() Authenticator { return NewGeminiAuthenticator() })
|
| 16 |
-
registerRefreshLead("gemini-web", func() Authenticator { return NewGeminiWebAuthenticator() })
|
| 17 |
}
|
| 18 |
|
| 19 |
func registerRefreshLead(provider string, factory func() Authenticator) {
|
|
|
|
| 13 |
registerRefreshLead("iflow", func() Authenticator { return NewIFlowAuthenticator() })
|
| 14 |
registerRefreshLead("gemini", func() Authenticator { return NewGeminiAuthenticator() })
|
| 15 |
registerRefreshLead("gemini-cli", func() Authenticator { return NewGeminiAuthenticator() })
|
|
|
|
| 16 |
}
|
| 17 |
|
| 18 |
func registerRefreshLead(provider string, factory func() Authenticator) {
|
sdk/cliproxy/auth/manager.go
CHANGED
|
@@ -285,9 +285,6 @@ func (m *Manager) executeWithProvider(ctx context.Context, provider string, req
|
|
| 285 |
log.Debugf("Use API key %s for model %s", util.HideAPIKey(accountInfo), req.Model)
|
| 286 |
} else if accountType == "oauth" {
|
| 287 |
log.Debugf("Use OAuth %s for model %s", accountInfo, req.Model)
|
| 288 |
-
} else if accountType == "cookie" {
|
| 289 |
-
// Only Gemini Web uses cookie; print stable account label as-is.
|
| 290 |
-
log.Debugf("Use Cookie %s for model %s", accountInfo, req.Model)
|
| 291 |
}
|
| 292 |
|
| 293 |
tried[auth.ID] = struct{}{}
|
|
@@ -333,8 +330,6 @@ func (m *Manager) executeCountWithProvider(ctx context.Context, provider string,
|
|
| 333 |
log.Debugf("Use API key %s for model %s", util.HideAPIKey(accountInfo), req.Model)
|
| 334 |
} else if accountType == "oauth" {
|
| 335 |
log.Debugf("Use OAuth %s for model %s", accountInfo, req.Model)
|
| 336 |
-
} else if accountType == "cookie" {
|
| 337 |
-
log.Debugf("Use Cookie %s for model %s", accountInfo, req.Model)
|
| 338 |
}
|
| 339 |
|
| 340 |
tried[auth.ID] = struct{}{}
|
|
@@ -380,8 +375,6 @@ func (m *Manager) executeStreamWithProvider(ctx context.Context, provider string
|
|
| 380 |
log.Debugf("Use API key %s for model %s", util.HideAPIKey(accountInfo), req.Model)
|
| 381 |
} else if accountType == "oauth" {
|
| 382 |
log.Debugf("Use OAuth %s for model %s", accountInfo, req.Model)
|
| 383 |
-
} else if accountType == "cookie" {
|
| 384 |
-
log.Debugf("Use Cookie %s for model %s", accountInfo, req.Model)
|
| 385 |
}
|
| 386 |
|
| 387 |
tried[auth.ID] = struct{}{}
|
|
|
|
| 285 |
log.Debugf("Use API key %s for model %s", util.HideAPIKey(accountInfo), req.Model)
|
| 286 |
} else if accountType == "oauth" {
|
| 287 |
log.Debugf("Use OAuth %s for model %s", accountInfo, req.Model)
|
|
|
|
|
|
|
|
|
|
| 288 |
}
|
| 289 |
|
| 290 |
tried[auth.ID] = struct{}{}
|
|
|
|
| 330 |
log.Debugf("Use API key %s for model %s", util.HideAPIKey(accountInfo), req.Model)
|
| 331 |
} else if accountType == "oauth" {
|
| 332 |
log.Debugf("Use OAuth %s for model %s", accountInfo, req.Model)
|
|
|
|
|
|
|
| 333 |
}
|
| 334 |
|
| 335 |
tried[auth.ID] = struct{}{}
|
|
|
|
| 375 |
log.Debugf("Use API key %s for model %s", util.HideAPIKey(accountInfo), req.Model)
|
| 376 |
} else if accountType == "oauth" {
|
| 377 |
log.Debugf("Use OAuth %s for model %s", accountInfo, req.Model)
|
|
|
|
|
|
|
| 378 |
}
|
| 379 |
|
| 380 |
tried[auth.ID] = struct{}{}
|
sdk/cliproxy/auth/types.go
CHANGED
|
@@ -134,24 +134,6 @@ func (a *Auth) AccountInfo() (string, string) {
|
|
| 134 |
if a == nil {
|
| 135 |
return "", ""
|
| 136 |
}
|
| 137 |
-
// For Gemini Web, prefer explicit cookie label for stability.
|
| 138 |
-
if strings.ToLower(a.Provider) == "gemini-web" {
|
| 139 |
-
// Prefer explicit label written into auth file (e.g., gemini-web-<hash>)
|
| 140 |
-
if a.Metadata != nil {
|
| 141 |
-
if v, ok := a.Metadata["label"].(string); ok && strings.TrimSpace(v) != "" {
|
| 142 |
-
return "cookie", strings.TrimSpace(v)
|
| 143 |
-
}
|
| 144 |
-
}
|
| 145 |
-
// Minimal fallback to cookie value for backward compatibility
|
| 146 |
-
if a.Metadata != nil {
|
| 147 |
-
if v, ok := a.Metadata["secure_1psid"].(string); ok && v != "" {
|
| 148 |
-
return "cookie", v
|
| 149 |
-
}
|
| 150 |
-
if v, ok := a.Metadata["__Secure-1PSID"].(string); ok && v != "" {
|
| 151 |
-
return "cookie", v
|
| 152 |
-
}
|
| 153 |
-
}
|
| 154 |
-
}
|
| 155 |
// For Gemini CLI, include project ID in the OAuth account info if present.
|
| 156 |
if strings.ToLower(a.Provider) == "gemini-cli" {
|
| 157 |
if a.Metadata != nil {
|
|
|
|
| 134 |
if a == nil {
|
| 135 |
return "", ""
|
| 136 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
// For Gemini CLI, include project ID in the OAuth account info if present.
|
| 138 |
if strings.ToLower(a.Provider) == "gemini-cli" {
|
| 139 |
if a.Metadata != nil {
|
sdk/cliproxy/service.go
CHANGED
|
@@ -14,8 +14,6 @@ import (
|
|
| 14 |
|
| 15 |
"github.com/router-for-me/CLIProxyAPI/v6/internal/api"
|
| 16 |
"github.com/router-for-me/CLIProxyAPI/v6/internal/config"
|
| 17 |
-
geminiwebclient "github.com/router-for-me/CLIProxyAPI/v6/internal/provider/gemini-web"
|
| 18 |
-
conversation "github.com/router-for-me/CLIProxyAPI/v6/internal/provider/gemini-web/conversation"
|
| 19 |
"github.com/router-for-me/CLIProxyAPI/v6/internal/registry"
|
| 20 |
"github.com/router-for-me/CLIProxyAPI/v6/internal/runtime/executor"
|
| 21 |
_ "github.com/router-for-me/CLIProxyAPI/v6/internal/usage"
|
|
@@ -207,23 +205,6 @@ func (s *Service) applyCoreAuthRemoval(ctx context.Context, id string) {
|
|
| 207 |
}
|
| 208 |
GlobalModelRegistry().UnregisterClient(id)
|
| 209 |
if existing, ok := s.coreManager.GetByID(id); ok && existing != nil {
|
| 210 |
-
if strings.EqualFold(existing.Provider, "gemini-web") {
|
| 211 |
-
// Prefer the stable cookie label stored in metadata when available.
|
| 212 |
-
var label string
|
| 213 |
-
if existing.Metadata != nil {
|
| 214 |
-
if v, ok := existing.Metadata["label"].(string); ok {
|
| 215 |
-
label = strings.TrimSpace(v)
|
| 216 |
-
}
|
| 217 |
-
}
|
| 218 |
-
if label == "" {
|
| 219 |
-
label = strings.TrimSpace(existing.Label)
|
| 220 |
-
}
|
| 221 |
-
if label != "" {
|
| 222 |
-
if err := conversation.RemoveMatchesByLabel(label); err != nil {
|
| 223 |
-
log.Debugf("failed to remove gemini web sticky entries for %s: %v", label, err)
|
| 224 |
-
}
|
| 225 |
-
}
|
| 226 |
-
}
|
| 227 |
existing.Disabled = true
|
| 228 |
existing.Status = coreauth.StatusDisabled
|
| 229 |
if _, err := s.coreManager.Update(ctx, existing); err != nil {
|
|
@@ -271,9 +252,6 @@ func (s *Service) ensureExecutorsForAuth(a *coreauth.Auth) {
|
|
| 271 |
s.coreManager.RegisterExecutor(executor.NewGeminiExecutor(s.cfg))
|
| 272 |
case "gemini-cli":
|
| 273 |
s.coreManager.RegisterExecutor(executor.NewGeminiCLIExecutor(s.cfg))
|
| 274 |
-
case "gemini-web":
|
| 275 |
-
s.coreManager.RegisterExecutor(executor.NewGeminiWebExecutor(s.cfg))
|
| 276 |
-
s.coreManager.EnableGeminiWebStickySelector()
|
| 277 |
case "claude":
|
| 278 |
s.coreManager.RegisterExecutor(executor.NewClaudeExecutor(s.cfg))
|
| 279 |
case "codex":
|
|
@@ -536,8 +514,6 @@ func (s *Service) registerModelsForAuth(a *coreauth.Auth) {
|
|
| 536 |
models = registry.GetGeminiModels()
|
| 537 |
case "gemini-cli":
|
| 538 |
models = registry.GetGeminiCLIModels()
|
| 539 |
-
case "gemini-web":
|
| 540 |
-
models = geminiwebclient.GetGeminiWebAliasedModels()
|
| 541 |
case "claude":
|
| 542 |
models = registry.GetClaudeModels()
|
| 543 |
case "codex":
|
|
|
|
| 14 |
|
| 15 |
"github.com/router-for-me/CLIProxyAPI/v6/internal/api"
|
| 16 |
"github.com/router-for-me/CLIProxyAPI/v6/internal/config"
|
|
|
|
|
|
|
| 17 |
"github.com/router-for-me/CLIProxyAPI/v6/internal/registry"
|
| 18 |
"github.com/router-for-me/CLIProxyAPI/v6/internal/runtime/executor"
|
| 19 |
_ "github.com/router-for-me/CLIProxyAPI/v6/internal/usage"
|
|
|
|
| 205 |
}
|
| 206 |
GlobalModelRegistry().UnregisterClient(id)
|
| 207 |
if existing, ok := s.coreManager.GetByID(id); ok && existing != nil {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
existing.Disabled = true
|
| 209 |
existing.Status = coreauth.StatusDisabled
|
| 210 |
if _, err := s.coreManager.Update(ctx, existing); err != nil {
|
|
|
|
| 252 |
s.coreManager.RegisterExecutor(executor.NewGeminiExecutor(s.cfg))
|
| 253 |
case "gemini-cli":
|
| 254 |
s.coreManager.RegisterExecutor(executor.NewGeminiCLIExecutor(s.cfg))
|
|
|
|
|
|
|
|
|
|
| 255 |
case "claude":
|
| 256 |
s.coreManager.RegisterExecutor(executor.NewClaudeExecutor(s.cfg))
|
| 257 |
case "codex":
|
|
|
|
| 514 |
models = registry.GetGeminiModels()
|
| 515 |
case "gemini-cli":
|
| 516 |
models = registry.GetGeminiCLIModels()
|
|
|
|
|
|
|
| 517 |
case "claude":
|
| 518 |
models = registry.GetClaudeModels()
|
| 519 |
case "codex":
|