diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 000000000..61f97efc9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,92 @@ +name: Bug 报告 +description: 报告项目使用中遇到的问题 +title: "[Bug]: " +labels: ["bug", "待处理"] +body: + - type: markdown + attributes: + value: | + ## 感谢你的反馈! + 请填写以下信息以帮助我们更快定位问题。 + + - type: checkboxes + id: checklist + attributes: + label: 提交前确认 + options: + - label: 我已经搜索过现有的 issues,确认这不是重复问题 + required: true + - label: 我已经阅读过项目文档 + required: true + + - type: dropdown + id: latest-version + attributes: + label: 是否是最新版 + description: 请确认你使用的是否是最新版本 + options: + - 是,使用最新版 + - 否,使用旧版本 + validations: + required: true + + - type: input + id: channel + attributes: + label: 调用的是哪个渠道 + description: 例如 geminicli 或者 antigravity + placeholder: "例如: geminicli" + validations: + required: true + + - type: input + id: model + attributes: + label: 调用的是哪个模型 + description: 例如 gemini-2.5-flash + placeholder: "例如: gemini-2.5-flash" + validations: + required: true + + - type: dropdown + id: format + attributes: + label: 调用的是哪个格式 + description: 选择你使用的 API 格式 + options: + - gemini 格式 + - openai 格式 + - claude 格式 + - 其他格式 + validations: + required: true + + - type: textarea + id: error-content + attributes: + label: 具体报错内容 + description: 请粘贴完整的错误信息或截图 + placeholder: | + 请在这里粘贴完整的错误日志或堆栈信息 + render: shell + validations: + required: true + + - type: textarea + id: error-description + attributes: + label: 错误描述 + description: 详细描述问题的发生场景、预期行为和实际行为 + placeholder: | + 1. 我在做什么操作时遇到了这个问题 + 2. 我期望的结果是... + 3. 但实际上发生了... + validations: + required: true + + - type: textarea + id: additional-context + attributes: + label: 补充信息(可选) + description: 其他任何有助于解决问题的信息 + placeholder: 例如:操作系统、Python 版本、相关配置等 \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 000000000..ceaef7e89 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,8 @@ +blank_issues_enabled: false +contact_links: + - name: 使用问题讨论 + url: https://github.com/su-kaka/gcli2api/issues + about: 如果是使用方面的问题,请在 issues 中提问 + - name: 项目文档 + url: https://github.com/su-kaka/gcli2api + about: 查看完整文档和使用指南 \ No newline at end of file diff --git a/.gitignore b/.gitignore index d1a9d3b92..c1fab8d85 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ GEMINI.md # Python uv.lock +.python-version __pycache__/ *.py[cod] *$py.class diff --git a/.python-version b/.python-version deleted file mode 100644 index e4fba2183..000000000 --- a/.python-version +++ /dev/null @@ -1 +0,0 @@ -3.12 diff --git a/README.md b/README.md index d0b4ac131..d9bc4012d 100644 --- a/README.md +++ b/README.md @@ -319,7 +319,7 @@ ghcr.io/su-kaka/gcli2api:latest ## ⚠️ 注意事项 -- 当前 OAuth 验证流程**仅支持本地主机(localhost)访问**,即须通过 `http://127.0.0.1:7861/auth` 完成认证(默认端口 7861,可通过 PORT 环境变量修改)。 +- 当前 OAuth 验证流程**仅支持本地主机(localhost)访问**,即须通过 `http://127.0.0.1:7861` 完成认证(默认端口 7861,可通过 PORT 环境变量修改)。 - **如需在云服务器或其他远程环境部署,请先在本地运行服务并完成 OAuth 验证,获得生成的 json 凭证文件(位于 `./geminicli/creds` 目录)后,再在auth面板将该文件上传即可。** - **请严格遵守使用限制,仅用于个人学习和非商业用途** @@ -327,7 +327,7 @@ ghcr.io/su-kaka/gcli2api:latest ## 配置说明 -1. 访问 `http://127.0.0.1:7861/auth` (默认端口,可通过 PORT 环境变量修改) +1. 访问 `http://127.0.0.1:7861` (默认端口,可通过 PORT 环境变量修改) 2. 完成 OAuth 认证流程(默认密码:`pwd`,可通过环境变量修改) - **GCLI 模式**:用于获取 Google Cloud Gemini API 凭证 - **Antigravity 模式**:用于获取 Google Antigravity API 凭证 @@ -833,51 +833,36 @@ for part in response.candidates[0].content.parts: **认证端点** - `POST /auth/login` - 用户登录 -- `POST /auth/start` - 开始 GCLI OAuth 认证 -- `POST /auth/antigravity/start` - 开始 Antigravity OAuth 认证 +- `POST /auth/start` - 开始 OAuth 认证(支持 GCLI 和 Antigravity 模式) - `POST /auth/callback` - 处理 OAuth 回调 +- `POST /auth/callback-url` - 从回调 URL 直接完成认证 - `GET /auth/status/{project_id}` - 检查认证状态 -- `GET /auth/antigravity/credentials` - 获取 Antigravity 凭证 - -**GCLI 凭证管理端点** -- `GET /creds/status` - 获取所有 GCLI 凭证状态 -- `POST /creds/action` - 单个 GCLI 凭证操作(启用/禁用/删除) -- `POST /creds/batch-action` - 批量 GCLI 凭证操作 -- `POST /auth/upload` - 批量上传 GCLI 凭证文件(支持 ZIP) -- `GET /creds/download/{filename}` - 下载 GCLI 凭证文件 -- `GET /creds/download-all` - 打包下载所有 GCLI 凭证 -- `POST /creds/fetch-email/{filename}` - 获取 GCLI 用户邮箱 -- `POST /creds/refresh-all-emails` - 批量刷新 GCLI 用户邮箱 - -**Antigravity 凭证管理端点** -- `GET /antigravity/creds/status` - 获取所有 Antigravity 凭证状态 -- `POST /antigravity/creds/action` - 单个 Antigravity 凭证操作(启用/禁用/删除) -- `POST /antigravity/creds/batch-action` - 批量 Antigravity 凭证操作 -- `POST /antigravity/auth/upload` - 批量上传 Antigravity 凭证文件(支持 ZIP) -- `GET /antigravity/creds/download/{filename}` - 下载 Antigravity 凭证文件 -- `GET /antigravity/creds/download-all` - 打包下载所有 Antigravity 凭证 -- `POST /antigravity/creds/fetch-email/{filename}` - 获取 Antigravity 用户邮箱 -- `POST /antigravity/creds/refresh-all-emails` - 批量刷新 Antigravity 用户邮箱 + +**凭证管理端点**(支持 `mode=geminicli` 或 `mode=antigravity` 参数) +- `POST /creds/upload` - 批量上传凭证文件(支持 JSON 和 ZIP) +- `GET /creds/status` - 获取凭证状态列表(支持分页和筛选) +- `GET /creds/detail/{filename}` - 获取单个凭证详情 +- `POST /creds/action` - 单个凭证操作(启用/禁用/删除) +- `POST /creds/batch-action` - 批量凭证操作 +- `GET /creds/download/{filename}` - 下载单个凭证文件 +- `GET /creds/download-all` - 打包下载所有凭证 +- `POST /creds/fetch-email/{filename}` - 获取用户邮箱 +- `POST /creds/refresh-all-emails` - 批量刷新用户邮箱 +- `POST /creds/deduplicate-by-email` - 按邮箱去重凭证 +- `POST /creds/verify-project/{filename}` - 检验凭证 Project ID +- `GET /creds/quota/{filename}` - 获取凭证额度信息(仅 Antigravity) **配置管理端点** - `GET /config/get` - 获取当前配置 - `POST /config/save` - 保存配置 -**环境变量凭证端点** -- `POST /auth/load-env-creds` - 加载环境变量凭证 -- `DELETE /auth/env-creds` - 清除环境变量凭证 -- `GET /auth/env-creds-status` - 获取环境变量凭证状态 - **日志管理端点** -- `POST /auth/logs/clear` - 清空日志 -- `GET /auth/logs/download` - 下载日志文件 -- `WebSocket /auth/logs/stream` - 实时日志流 - -**使用统计端点** -- `GET /usage/stats` - 获取使用统计 -- `GET /usage/aggregated` - 获取聚合统计 -- `POST /usage/update-limits` - 更新使用限制 -- `POST /usage/reset` - 重置使用统计 +- `POST /logs/clear` - 清空日志 +- `GET /logs/download` - 下载日志文件 +- `WebSocket /logs/stream` - 实时日志流 + +**版本信息端点** +- `GET /version/info` - 获取版本信息(可选 `check_update=true` 参数检查更新) ### 聊天 API 功能特性 diff --git a/docs/README_EN.md b/docs/README_EN.md index 413fda2b9..88495ce00 100644 --- a/docs/README_EN.md +++ b/docs/README_EN.md @@ -282,7 +282,7 @@ docker run -d --name gcli2api --network host -e API_PASSWORD=api_pwd -e PANEL_PA ## ⚠️ Important Notes -- The current OAuth authentication process **only supports localhost access**, meaning authentication must be completed through `http://127.0.0.1:7861/auth` (default port 7861, modifiable via PORT environment variable). +- The current OAuth authentication process **only supports localhost access**, meaning authentication must be completed through `http://127.0.0.1:7861/` (default port 7861, modifiable via PORT environment variable). - **For deployment on cloud servers or other remote environments, please first run the service locally and complete OAuth authentication to obtain the generated json credential files (located in the `./geminicli/creds` directory), then upload these files via the auth panel.** - **Please strictly comply with usage restrictions, only for personal learning and non-commercial purposes** @@ -290,7 +290,7 @@ docker run -d --name gcli2api --network host -e API_PASSWORD=api_pwd -e PANEL_PA ## Configuration Instructions -1. Visit `http://127.0.0.1:7861/auth` (default port, modifiable via PORT environment variable) +1. Visit `http://127.0.0.1:7861/` (default port, modifiable via PORT environment variable) 2. Complete OAuth authentication flow (default password: `pwd`, modifiable via environment variables) - **GCLI Mode**: For obtaining Google Cloud Gemini API credentials - **Antigravity Mode**: For obtaining Google Antigravity API credentials diff --git a/front/common.js b/front/common.js index 0988f7d72..2d0416be9 100644 --- a/front/common.js +++ b/front/common.js @@ -57,6 +57,7 @@ function createCredsManager(type) { currentStatusFilter: 'all', currentErrorCodeFilter: 'all', currentCooldownFilter: 'all', + currentPreviewFilter: 'all', statsData: { total: 0, normal: 0, disabled: 0 }, // API端点 @@ -102,8 +103,9 @@ function createCredsManager(type) { const offset = (this.currentPage - 1) * this.pageSize; const errorCodeFilter = this.currentErrorCodeFilter || 'all'; const cooldownFilter = this.currentCooldownFilter || 'all'; + const previewFilter = this.currentPreviewFilter || 'all'; const response = await fetch( - `${this.getEndpoint('status')}?offset=${offset}&limit=${this.pageSize}&status_filter=${this.currentStatusFilter}&error_code_filter=${errorCodeFilter}&cooldown_filter=${cooldownFilter}&${this.getModeParam()}`, + `${this.getEndpoint('status')}?offset=${offset}&limit=${this.pageSize}&status_filter=${this.currentStatusFilter}&error_code_filter=${errorCodeFilter}&cooldown_filter=${cooldownFilter}&preview_filter=${previewFilter}&${this.getModeParam()}`, { headers: getAuthHeaders() } ); @@ -120,7 +122,8 @@ function createCredsManager(type) { last_success: item.last_success, }, user_email: item.user_email, - model_cooldowns: item.model_cooldowns || {} + model_cooldowns: item.model_cooldowns || {}, + preview: item.preview // 保存preview字段 }; }); @@ -233,8 +236,10 @@ function createCredsManager(type) { this.currentStatusFilter = document.getElementById(this.getElementId('StatusFilter')).value; const errorCodeFilterEl = document.getElementById(this.getElementId('ErrorCodeFilter')); const cooldownFilterEl = document.getElementById(this.getElementId('CooldownFilter')); + const previewFilterEl = document.getElementById(this.getElementId('PreviewFilter')); this.currentErrorCodeFilter = errorCodeFilterEl ? errorCodeFilterEl.value : 'all'; this.currentCooldownFilter = cooldownFilterEl ? cooldownFilterEl.value : 'all'; + this.currentPreviewFilter = previewFilterEl ? previewFilterEl.value : 'all'; this.currentPage = 1; this.refresh(); }, @@ -244,7 +249,7 @@ function createCredsManager(type) { const selectedCount = this.selectedFiles.size; document.getElementById(this.getElementId('SelectedCount')).textContent = `已选择 ${selectedCount} 项`; - const batchBtns = ['Enable', 'Disable', 'Delete', 'Verify'].map(action => + const batchBtns = ['Enable', 'Disable', 'Delete', 'Verify', 'Preview'].map(action => document.getElementById(this.getElementId(`Batch${action}Btn`)) ); batchBtns.forEach(btn => btn && (btn.disabled = selectedCount === 0)); @@ -341,7 +346,7 @@ function createCredsManager(type) { // ===================================================================== function createUploadManager(type) { const modeParam = type === 'antigravity' ? 'mode=antigravity' : 'mode=geminicli'; - const endpoint = `./auth/upload?${modeParam}`; + const endpoint = `./creds/upload?${modeParam}`; return { type: type, @@ -573,6 +578,15 @@ function createCredCard(credInfo, manager) { statusBadges += '无错误'; } + // Preview状态显示 (仅对geminicli模式显示) + if (managerType !== 'antigravity' && credInfo.preview !== undefined) { + if (credInfo.preview) { + statusBadges += '🔬 Preview'; + } else { + statusBadges += '❌ Preview'; + } + } + // 模型级冷却状态 if (credInfo.model_cooldowns && Object.keys(credInfo.model_cooldowns).length > 0) { const currentTime = Date.now() / 1000; @@ -614,7 +628,10 @@ function createCredCard(credInfo, manager) { ${managerType === 'antigravity' ? `` : ''} + ${managerType !== 'antigravity' ? `` : ''} + + `; @@ -640,6 +657,9 @@ function createCredCard(credInfo, manager) {
点击"查看内容"按钮加载文件详情...
+
+
点击"查看报错"按钮加载报错信息...
+
${managerType === 'antigravity' ? `