Commit Graph

128 Commits

Author SHA1 Message Date
shaw
4789c03ea3 fix: 修复 Gemini token 刷新时的二次解密错误
- refreshAccountToken 中的 account.refreshToken 已经是解密后的值
- 移除多余的 decrypt() 调用,避免二次解密导致的错误

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-26 14:34:45 +08:00
shaw
25ab1575ed feat: 改进 Gemini token 刷新测试脚本和添加解密测试脚本
- 修正加密盐值为 'gemini-account-salt'(之前错误使用了其他值)
- 在 test-gemini-refresh.js 中添加详细的调试信息
  - 显示配置信息和加密参数
  - 显示原始加密数据
  - 尝试手动解密并显示结果
  - 更详细的错误信息
- 添加 test-gemini-decrypt.js 用于单独测试解密功能

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-26 13:56:52 +08:00
shaw
24858f7e51 chore: 删除调试加解密相关脚本
根据用户要求删除临时调试脚本,准备重新分析加密流程

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-26 13:47:34 +08:00
shaw
adb1868899 feat: 添加修复默认密钥加密的 Gemini 账户脚本
- 检测使用默认密钥加密的数据
- 尝试用默认密钥解密后重新用当前密钥加密
- 解决密钥变更导致的解密失败问题

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-26 12:37:41 +08:00
shaw
b3cd97ab18 feat: 添加 Gemini token 修复和更新脚本
- fix-gemini-encryption.js: 诊断和修复加密问题
- update-gemini-token.js: 手动更新 refresh token 的工具

解决线上环境加密密钥不一致导致的解密失败问题

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-26 12:27:06 +08:00
shaw
8f0da8e914 fix: 修复 Gemini 解密调试脚本的密钥生成逻辑
- 使用 config.security.encryptionKey 而不是直接读取环境变量
- 添加 crypto.scryptSync 和 ENCRYPTION_SALT 以匹配实际加密逻辑
- 显示实际使用的加密配置信息

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-26 12:18:57 +08:00
shaw
a939fcebac feat: 添加 Gemini refreshToken 解密调试脚本
- 检查环境变量中的 ENCRYPTION_KEY
- 显示加密数据的格式信息
- 尝试新旧两种解密方法
- 输出详细的调试信息帮助定位问题

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-26 12:16:08 +08:00
shaw
3d13542fff fix: 修复 Gemini 账户 refreshToken 解密错误
- 修复 updateAccount 中对已解密数据的二次解密问题
- 改进解密函数,使用固定长度的 IV 避免冒号分隔符问题
- 确保 refreshToken 能正确存储和使用

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-26 12:10:03 +08:00
shaw
71c2ef5d6d fix: 修复 Gemini token 刷新测试脚本的逻辑问题
- 移除错误的 refreshToken 占位符判断
- 直接使用 getAccount 获取解密后的完整账户信息
- 只有真正没有 refresh token 时才跳过测试

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-26 12:01:56 +08:00
shaw
dd73045223 feat: 改进 Gemini token 刷新机制和错误处理
- 修复 token 刷新时的错误处理逻辑
- 添加详细的错误日志记录
- 新增 test-gemini-refresh.js 测试脚本
- 更新 CLAUDE.md 文档,添加 Gemini token 刷新故障排除指南

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-26 11:41:17 +08:00
shaw
3eba158387 fix: 修复管理员登录在Redis缓存失效后无法登录的问题
- 在登录时如果Redis中没有管理员凭据,自动从init.json重新加载
- 重新加载时不设置过期时间,避免24小时后再次失效
- 保持init.json作为唯一真实数据源的设计原则

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-25 15:30:50 +08:00
shaw
521ba99f48 refactor: 重构GitHub Actions发布流程和修复管理界面问题
- 删除旧的auto-release.yml工作流,避免循环触发问题
- 新增auto-version-bump.yml:自动同步VERSION文件与release版本
- 新增release-on-version.yml:基于VERSION文件变更自动创建release
- 更新docker-publish.yml:简化触发条件,仅在tag推送时构建
- 添加RELEASE_PROCESS.md文档:详细说明新的发布流程
- 修复web管理界面:解决OAuth账户token刷新和代理配置相关问题

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-24 11:30:54 +08:00
Wesley Liddick
5aaf51d7e0 Merge pull request #57 from geminiwen/main
Update .dockerignore
2025-07-24 09:25:29 +08:00
Gemini Wen
ccd281ce6b Update .dockerignore
if use docker compose up --build

docker build will ignore .env file, this behavior is unexpected.
2025-07-24 09:18:18 +08:00
shaw
04c65da21f fix: 修复 GitHub Action 版本同步死循环问题
- 移除工作流开始时的VERSION同步步骤,避免产生新提交导致无限循环
- 修改变更检查逻辑,忽略仅修改VERSION文件的提交
- 在工作流结束时确保VERSION文件与最新release同步
- 解决了VERSION文件追不上releases版本的问题

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-24 00:02:29 +08:00
github-actions[bot]
0a291eb1fd chore: sync VERSION file with release v1.1.10 [skip ci] 2025-07-23 15:48:56 +00:00
shaw
1a3dd05ba3 fix: 修复 GitHub Action 版本同步问题
- 添加工作流开始时的 VERSION 文件同步步骤
- 确保 VERSION 文件始终与最新 release 保持一致
- 移除不存在的 CHANGELOG.md 更新逻辑
- 解决因分支合并导致的版本不同步问题

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-23 23:48:33 +08:00
Wesley Liddick
b67cf05f63 Merge pull request #52 from mouyong/patch-1
修复用户提供的 密钥太短导致无法保存授权的问题
2025-07-23 22:58:58 +08:00
Wesley Liddick
f3dd3d3c69 Merge pull request #51 from mouyong/patch-2
chore: 增加调试日志
2025-07-23 22:58:46 +08:00
mouyong
9c96f18a7c Update sessionHelper.js 2025-07-23 22:35:41 +08:00
mouyong
33561bcc80 修复用户提供的 密钥太短导致无法保存授权的问题 2025-07-23 22:34:26 +08:00
shaw
ef8e0eb1e1 Merge branch 'dev' 2025-07-23 16:25:12 +08:00
shaw
5392ee9799 更新 README.md 与 main 分支保持一致 2025-07-23 16:20:36 +08:00
shaw
3553f5cc1f fix: 修复流式响应的 Parse Error 和缓冲问题
主要修改:
1. 从 compression 中间件中排除 SSE 流式响应,避免压缩导致的缓冲
2. 移除导致 Parse Error 的 res.flushHeaders() 调用
3. 改进流式响应的错误处理,发送 SSE 错误事件而不是破坏流
4. 在写入数据前检查流状态,避免写入已销毁的流
5. 优化响应结束时的处理逻辑,确保缓冲区数据正确处理

这些修改确保了流式请求能够正常显示打字机效果,同时保留了 usage token 收集功能。

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-23 16:13:07 +08:00
shaw
1e372dd365 fix: 修复流式响应缓冲问题,实现真正的实时流传输
- 配置 compression 中间件排除 SSE 流式响应,避免压缩导致的缓冲
- 添加 X-Accel-Buffering: no 响应头,禁用 Nginx 等代理的缓冲
- 使用 res.flushHeaders() 立即发送响应头
- 禁用 Nagle 算法确保数据立即发送
- 在每次写入流数据后调用 flush() 确保实时传输

这些修复确保了流式请求能够正常显示打字机效果,数据从上游 Claude API 接收后能够立即转发给客户端。

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-23 15:56:27 +08:00
shaw
283f5303af feat 增加第三方工具API接入 2025-07-23 12:12:15 +08:00
shaw
67861caea0 Merge branch 'dev' 2025-07-23 11:20:36 +08:00
shaw
2f4730baba 优化: 替换第三方CDN资源以提升加载速度
- 将所有第三方资源从 bootcdn 迁移到 cdnjs.cloudflare.com
- 移除 SRI 完整性校验以避免哈希值不匹配问题
- 添加 DNS 预取和预连接以加速资源加载
- 调整脚本加载顺序,确保依赖关系正确
- 保持所有库版本号不变 (Vue 3.3.4, Element Plus 2.4.4, Chart.js 4.4.0)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-23 11:15:33 +08:00
shaw
d6675a4d8e feat: 添加 /claude/v1/messages 路由别名并优化非 Claude Code 客户端支持
- 添加 /claude 路由作为 /api 的别名,支持 /claude/v1/messages 端点
- 实现智能判断请求来源,通过 user-agent 和系统提示词识别真实的 Claude Code 请求
- 为非 Claude Code 客户端自动设置系统提示词和必要的 headers
- 优化 headers 更新逻辑,只有真实的 Claude Code 请求才更新缓存
- 确保 /api 和 /claude 路由功能完全一致

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-22 21:07:25 +08:00
shaw
e2cece6162 fix 修复x-request-id问题 2025-07-22 18:36:53 +08:00
shaw
a431778363 fix 修复openai格式流式响应的结束标记问题 2025-07-22 18:00:24 +08:00
shaw
e77945a3e3 fix: 修复 API Key 编辑时服务权限和 Gemini 专属账号字段不显示的问题
- 创建 API Key 时添加 permissions 和 geminiAccountId 字段发送到后端
- 编辑 API Key 时正确加载和保存 permissions 和 geminiAccountId 字段
- 更新 openEditApiKeyModal 函数以包含这两个字段
- 更新 updateApiKey 函数的请求体以发送这两个字段

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-22 17:10:04 +08:00
shaw
6150ed4258 fix openai兼容格式转发claude固定系统提示词 2025-07-22 16:26:17 +08:00
shaw
dabf3bf7ea feat: 实现 Claude Code headers 动态管理功能
- 创建 claudeCodeHeadersService 管理各账号的 Claude Code headers
- 自动捕获成功请求的 headers 并按账号存储在 Redis
- 智能版本管理,只保留最新版本的 headers
- OpenAI 转发时根据账号动态获取对应的 headers
- 添加管理端点查看和清除各账号的 headers 信息
- 完整支持 Claude Code 必需的 beta headers

解决了 "This credential is only authorized for use with Claude Code" 错误
避免了固定版本号带来的风控问题

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-22 16:03:31 +08:00
shaw
b2ad2a4a61 fix: 修复 OpenAI 兼容路由的 Claude API 认证和 Function Calling 支持
- 添加必需的系统消息 "You are Claude Code, Anthropic's official CLI for Claude."
- 修改 anthropic-beta header 为 OAuth-only 模式 (oauth-2025-04-20)
- 不再传递客户端 headers,使用固定的 4 个必需 headers
- 增强流式响应的 Function Calling 支持,正确处理 tool_use 事件
- 支持自定义 beta header 参数,允许不同路由使用不同的认证模式

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-22 14:38:30 +08:00
shaw
6ceed5c3ee fix 修复openai格式转发失败的问题 2025-07-22 13:55:14 +08:00
shaw
9ad7feb94c fix: 修复 OpenAI 路由中的 req.apiKeyData undefined 错误
- 将所有路由中的 req.apiKeyData 改为 req.apiKey(与中间件一致)
- 在 authenticateApiKey 中间件中添加缺失的字段(permissions, geminiAccountId, usage)
- 修复 openaiClaudeRoutes.js、openaiGeminiRoutes.js 和 geminiRoutes.js 中的引用错误
- 确保 API 权限检查正常工作

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-22 13:08:24 +08:00
shaw
6b0832bc2d fix: 修复 OpenAI 兼容路由中的 router.handle() 错误
- 移除了 openaiClaudeRoutes.js 中错误的 router.handle() 调用
- 提取 handleChatCompletion 函数作为共享处理逻辑
- 修复了 /v1/completions 端点的实现
- 确保 /openai/claude 和 /openai/gemini 路由正常工作

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-22 12:58:11 +08:00
shaw
12d68af421 update default redirectUri 2025-07-22 11:52:07 +08:00
shaw
11318c22b0 feat: 优化 Gemini OAuth 授权流程,使用固定的 localhost 回调地址
- 将 Gemini OAuth 回调地址固定为 http://localhost:45462
- 更新前端提示文字为"复制oauth后的链接"
- 实现自动提取 localhost:45462 链接中的 code 参数功能
- 删除不再需要的 web/auth_gemini 路由
- 添加详细的用户操作说明和错误处理提示
- 支持两种输入方式:完整链接或仅授权码

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-22 11:42:54 +08:00
shaw
ed99043127 fix: 修复 geminiAccountService 配置读取错误并添加 secret scanning 排除规则
- 直接使用硬编码的 Gemini OAuth 凭据,避免配置依赖
- 添加 .github/secret_scanning.yml 排除公开的 OAuth 凭据文件

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-22 10:37:43 +08:00
shaw
38c1fc4785 feat: 添加多模型支持和OpenAI兼容接口
- 新增 Gemini 模型支持和账户管理功能
- 实现 OpenAI 格式到 Claude/Gemini 的请求转换
- 添加自动 token 刷新服务,支持提前刷新策略
- 增强 Web 管理界面,支持 Gemini 账户管理
- 优化 token 显示,添加掩码功能
- 完善日志记录和错误处理

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-22 10:17:39 +08:00
shaw
22dcd4d171 Merge branch 'dev' 2025-07-20 22:45:56 +08:00
shaw
4f0d8db757 fix: 修复总Token消耗USD计算重复统计问题
- 将usage-costs的all模式改为只使用monthly数据,避免daily、monthly、hourly重复计算
- 更新正则表达式只匹配monthly格式的key
- 确保总消耗与模型统计表格的USD计算保持一致

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-20 21:36:51 +08:00
shaw
ff554d7c70 fix: 修复总Token消耗USD计算与模型统计不一致的问题
- 修正Redis key匹配模式从 'usage:model:*:*' 到 'usage:model:*:*:*'
- 更新正则表达式以支持hourly统计数据
- 确保所有模型都使用正确的价格计算费用

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-20 21:18:39 +08:00
shaw
ddf814526d Merge branch 'dev' into main 2025-07-20 20:38:10 +08:00
shaw
7e5fb514cb fix: 修复 Docker 镜像版本号与 Release 版本号不一致的问题
- 在 auto-release.yml 中集成 Docker 构建步骤,确保版本号一致性
- 优化 docker-publish.yml 的标签生成策略,添加 sha- 前缀避免混淆
- 现在每次自动发布时会同时构建对应版本的 Docker 镜像

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-20 20:33:00 +08:00
shaw
b77c600f05 fix: 修复更新日志链接,指向 GitHub Releases 页面 2025-07-20 17:36:45 +08:00
shaw
262ca74d19 chore: 移除手动维护的 CHANGELOG.md,使用自动生成方案 2025-07-20 17:30:49 +08:00
shaw
1348941cd6 docs: 添加完整的 CHANGELOG.md 文件 2025-07-20 17:24:23 +08:00