jft0m
6bb74376ca
fix: add /openai/v1/chat/completions route support
...
- Register unifiedRoutes under /openai prefix to enable /openai/v1/chat/completions
- Reuse existing intelligent routing logic from unified.js (no code duplication)
- Keep existing Codex API routes (/openai/responses, /openai/v1/responses) unchanged
Benefits:
- Fixes 404 error for /openai/v1/chat/completions endpoint
- Provides consistent API experience across /api and /openai prefixes
- Automatically routes to correct backend (Claude/OpenAI/Gemini) based on model
Tested:
- ✅ /openai/v1/chat/completions now returns authentication error (route works)
- ✅ /api/v1/chat/completions continues to work
- ✅ Existing Codex routes remain functional
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-10-14 16:17:12 +00:00
jft0m
344599f318
refactor: extract intelligent routing to unified.js
...
- Created new src/routes/unified.js (225 lines)
- detectBackendFromModel(): Detects backend from model name
- routeToBackend(): Routes to Claude/OpenAI/Gemini with permission checks
- POST /v1/chat/completions: OpenAI-compatible endpoint with intelligent routing
- POST /v1/completions: Legacy completions endpoint with intelligent routing
- Updated src/routes/api.js (reduced from 1185 to 968 lines)
- Removed ~217 lines of routing logic
- Kept Claude-specific endpoints (/api/v1/messages)
- Maintained all other Claude API functionality
- Updated src/app.js
- Added unifiedRoutes registration at /api prefix
Benefits:
- Single responsibility: api.js focuses on Claude API routes
- Better organization: routing logic isolated in unified.js
- Easier maintenance: changes to routing won't affect Claude code
- File size reduction: api.js reduced by 18%
Tested:
- ✅ Claude model routing via /v1/chat/completions
- ✅ OpenAI model routing (correct backend detection)
- ✅ Gemini model routing (correct backend detection)
- ✅ Legacy /v1/completions endpoint
- ✅ All tests pass, no regressions
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-10-14 14:30:23 +00:00
jft0m
e540ec3a52
feat: add intelligent backend routing and model service
...
- Add modelService for centralized model management
- Support dynamic model list from config file (data/supported_models.json)
- Include 2025 latest models: GPT-4.1, o3, o4-mini, Gemini 2.5, etc.
- File watcher for hot-reload configuration changes
- Improve model detection logic in api.js
- Priority: modelService lookup → prefix matching fallback
- Smart backend routing based on model provider
- Add intelligent routing endpoints
- /v1/chat/completions: unified OpenAI-compatible endpoint
- /v1/completions: legacy format support
- Auto-route to Claude/OpenAI/Gemini based on requested model
- Add Xcode system prompt support in openaiToClaude
- Detect and preserve Xcode-specific system messages
- Export handler functions for reuse
- openaiClaudeRoutes: export handleChatCompletion
- openaiRoutes: export handleResponses
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-10-14 14:12:44 +00:00
shaw
a58d67940c
fix: 优化并发计数过期清理
2025-10-12 13:14:15 +08:00
shaw
2fc84a6aca
feat: 新增Droid cli支持
2025-10-09 23:05:09 +08:00
shaw
7c4feec5aa
feat: 添加账户状态监控和自动恢复机制
...
- 实现账户健康度监控系统,支持30分钟内错误率检测
- 添加自动恢复机制,失败账户在30分钟后自动尝试恢复
- 优化账户选择策略,优先选择健康账户
- 增强Redis键管理,添加账户状态和错误追踪功能
- 改进Gemini服务错误处理和重试逻辑
- 新增standardGeminiRoutes标准化路由支持
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-09-11 22:02:53 +08:00
root
cd5573ecde
Fix Prettier formatting issues
...
- Remove trailing whitespace and fix indentation in src/app.js
- Format whitespace in src/middleware/auth.js
- Fix formatting and add missing newline in src/middleware/browserFallback.js
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-09-10 09:13:51 +00:00
root
bdae9d6ceb
feat: 添加Chrome插件兜底支持,解决第三方插件401错误问题
...
• 新增browserFallback中间件,自动识别并处理Chrome插件请求
• 增强CORS支持,明确允许chrome-extension://来源
• 优化请求头过滤,移除可能触发Claude CORS检查的浏览器头信息
• 完善401错误处理逻辑,避免因临时token问题导致账号被错误停用
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-09-10 07:48:41 +00:00
shaw
e824858d60
feat: claude账户支持使用统一的客户端标识
2025-09-08 11:35:44 +08:00
Feng Yue
68603bc046
Merge branch 'dev' into um-5
2025-09-01 12:19:53 +08:00
shaw
5cfa3cc72f
feat: 添加精确的账户费用计算和时区支持
...
- 实现基于模型使用量的精确每日费用计算
- 添加 dateHelper 工具支持时区转换
- 移除未使用的 webhook 配置代码
- 清理环境变量和配置文件中的 webhook 相关设置
- 优化前端费用显示,使用后端精确计算的数据
- 添加 DEBUG_HTTP_TRAFFIC 调试选项支持
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-09-01 11:29:16 +08:00
Feng Yue
50b372473c
Merge remote-tracking branch 'f3n9/main' into um-5
2025-08-31 23:12:46 +08:00
shaw
a54622e3d7
Revert "Merge pull request #292 from iRubbish/dev"
...
This reverts commit 9e8e74ce6b , reversing
changes made to 222f4e44fe .
2025-08-30 20:09:41 +08:00
Wesley Liddick
9e8e74ce6b
Merge pull request #292 from iRubbish/dev
...
feat: 新增AD域控用户认证系统
2025-08-28 08:43:21 +08:00
sczheng189
f4f88091c1
feat: 扩展熔断机制支持所有5xx错误码
...
- 扩展错误检测从单一500错误到所有5xx错误码(500-599)
- 新增temp_error状态,连续3次5xx错误触发临时熔断
- 支持流式和非流式请求的统一5xx错误处理
- 添加定时清理机制,60分钟后自动恢复temp_error状态
- 完善错误计数和清理逻辑,提高系统可靠性
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-08-25 19:14:14 +08:00
iRubbish
7624c383e8
feat: 完整实现AD域控用户认证系统
...
主要功能:
- 新增LDAP服务连接AD域控服务器
- 实现多格式AD用户认证(sAMAccountName, UPN, 域\用户名, DN)
- 支持中文显示名和拼音用户名搜索
- 添加用户账户状态检查(禁用账户检测)
- 实现JWT token认证和用户会话管理
新增文件:
- src/services/ldapService.js - LDAP核心服务
- src/routes/ldapRoutes.js - AD认证API路由
- src/services/userMappingService.js - 用户映射服务
- web/admin-spa/src/views/UserDashboardView.vue - 用户控制台
- web/admin-spa/src/components/user/ - 用户组件目录
修改功能:
- ApiStatsView.vue 增加用户登录按钮和模态框
- 路由系统增加用户专用页面
- 安装ldapjs和jsonwebtoken依赖
技术特性:
- 多种认证格式自动尝试
- LDAP referral错误处理
- 详细认证日志和错误码记录
- 前后端完整用户认证流程
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-08-25 18:03:55 +08:00
Feng Yue
d5f5e0f4dd
Merge branch 'main' into um-5
2025-08-25 17:19:24 +08:00
shaw
74bcb99142
feat: 新增支持Azure OpenAI账户
2025-08-23 10:30:29 +08:00
shaw
bd10032857
fix: 移除Unicode清理逻辑,恢复与main分支一致的转发流程
...
- 移除app.js中的JSON解析错误处理中间件
- 移除api.js中的cleanUnicodeString和cleanUnicodeInObject函数
- 移除handleMessagesRequest中的Unicode清理调用
- 确保转发逻辑与main远程分支完全一致
问题原因:
- Unicode清理逻辑会修改请求体,可能导致某些情况下的JSON解析错误
- Claude API本身能够处理Unicode问题,不需要在中转服务中预处理
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-08-21 09:29:27 +08:00
shaw
39a72e3e72
fix: 修复JSON解析错误导致的"Unexpected end of JSON input"问题
...
- 移除express.json()的verify函数中危险的buffer修改逻辑
- 该逻辑直接修改body-parser正在处理的原始buffer,导致数据损坏
- 改进JSON解析错误中间件,支持更多错误模式识别
- 将内部500错误改为用户友好的400错误响应
- 修复了Claude CLI客户端连接时的JSON解析问题
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-08-20 23:50:42 +08:00
iRubbish
1ee71ffbc9
feat: 完善 API Keys 批量删除功能并修复搜索跨选择问题
...
## 主要改进
### 🔧 核心修复
- 修复搜索时勾选状态无法保存的问题
- 优化全选/取消全选逻辑,支持跨搜索结果保持选择状态
- 改进批量删除的用户体验
- 添加 Unicode 字符处理中间件,提升请求体解析稳定性
### 🎯 具体变更
- **路由修复**: 解决批量删除路由匹配问题,调整路由顺序
- **API客户端**: 修复 DELETE 方法支持请求体数据传输
- **前端逻辑**: 分离筛选和搜索的监听器,搜索时保持已选中状态
- **全选优化**: 取消全选时只移除当前页选中项,保留其他页面选择
- **Unicode处理**: 添加无效 UTF-16 代理对清理和错误处理机制
- **配置管理**: 将 .mcp.json 添加到 .gitignore,避免本地配置被提交
### 🚀 用户体验提升
- 支持跨搜索结果批量选择和删除
- 批量删除按钮显示选中数量
- 智能的全选状态管理
- 更好的 Unicode 字符处理容错性
### 🧪 测试验证
- 验证搜索切换时选择状态保持
- 确认批量删除功能正常工作
- 检查 Redis 数据清理完整性
- 测试 Unicode 字符处理稳定性
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-08-19 09:59:54 +08:00
Feng Yue
77338276db
Merge remote-tracking branch 'f3n9/main' into user-management-new
2025-08-18 15:32:17 +08:00
shaw
3bcdb511fe
feat: 实现多服务账户缓存优化系统
...
- 添加通用LRU缓存工具类,支持过期时间和内存限制
- 实现缓存监控系统,提供统计和健康检查接口
- 为所有账户服务(Claude、Gemini、OpenAI、Bedrock、Claude Console)添加缓存层
- 优化账户选择性能,减少Redis查询频率
- 添加缓存统计监控端点 /admin/cache/stats
性能提升:
- 账户列表查询从O(n)优化到O(1)
- 减少90%以上的Redis查询
- 响应时间降低50ms以上
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-08-17 15:38:49 +08:00
iRubbish
2b77fdc06c
fix: 修复 ESLint 代码质量问题
...
- 修复正则表达式中不必要的转义字符
- 使用对象解构优化代码风格
- 修复未使用变量的命名规范
- 确保所有修改文件通过 ESLint 检查
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-08-14 14:14:01 +08:00
Feng Yue
eb150b4937
feat: 实现完整用户管理系统和LDAP认证集成
...
- 新增LDAP认证服务支持用户登录验证
- 实现用户服务包含会话管理和权限控制
- 添加用户专用路由和API端点
- 扩展认证中间件支持用户和管理员双重身份
- 新增用户仪表板、API密钥管理和使用统计界面
- 完善前端用户管理组件和路由配置
- 支持用户自助API密钥创建和管理
- 添加管理员用户管理功能包含角色权限控制
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-08-14 11:36:45 +08:00
weidian
e01e539108
feat: 添加账号异常状态 Webhook 通知功能
...
## 功能概述
- 新增账号禁用/异常状态的 Webhook 实时通知机制
- 支持 Claude OAuth、Claude Console、Gemini 三种平台的账号监控
- 提供完整的 Webhook 管理 API 和配置选项
## 主要变更
### 新增文件
- `src/utils/webhookNotifier.js`: Webhook 通知核心服务
- `src/routes/webhook.js`: Webhook 管理 API 路由
### 功能集成
- Claude OAuth 账号:unauthorized 状态 + token 刷新错误通知
- Claude Console 账号:blocked 状态通知
- Gemini 账号:token 刷新错误通知
### 配置支持
- 新增环境变量:WEBHOOK_ENABLED, WEBHOOK_URLS, WEBHOOK_TIMEOUT, WEBHOOK_RETRIES
- 支持多个 Webhook URL 并发通知
- 自动重试机制(指数退避)+ 超时保护
### 管理端点
- POST /admin/webhook/test: 测试连通性
- POST /admin/webhook/test-notification: 发送测试通知
- GET /admin/webhook/config: 查看配置信息
## 通知格式
```json
{
"type": "account_anomaly",
"data": {
"accountId": "uuid",
"accountName": "账号名称",
"platform": "claude-oauth|claude-console|gemini",
"status": "unauthorized|blocked|error",
"errorCode": "CLAUDE_OAUTH_UNAUTHORIZED",
"reason": "具体异常原因",
"timestamp": "2025-01-13T10:30:00.000Z"
}
}
```
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-08-13 17:52:46 +08:00
wt
8142c3356a
feat: 新增 Claude Console 账户限流机制开关 Lint format
2025-08-13 17:04:47 +08:00
千羽
5d9c8216ac
chore: commit all changes
2025-08-10 19:09:56 +09:00
mouyong
8bdf495ffa
feat: enhance monitoring and Gemini service functionality
...
- Add enhanced monitoring scripts (monitor-enhanced.sh, status-unified.sh)
- Improve Gemini relay service with better error handling and token management
- Update authentication middleware for better compatibility
- Add new package dependencies for enhanced functionality
- Update .gitignore and app configuration
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-08-09 14:06:56 +08:00
千羽
8a74bf5afe
refactor: standardize code formatting and linting configuration
...
- Replace .eslintrc.js with .eslintrc.cjs for better ES module compatibility
- Add .prettierrc configuration for consistent code formatting
- Update package.json with new lint and format scripts
- Add nodemon.json for development hot reloading configuration
- Standardize code formatting across all JavaScript and Vue files
- Update web admin SPA with improved linting rules and formatting
- Add prettier configuration to web admin SPA
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-08-07 18:19:31 +09:00
shaw
b1ea32caba
feat: 添加Gemini定价功能和界面优化
...
- 实现Gemini定价查询服务,支持实时计算token成本
- 改进API Key管理界面,添加模型快速选择功能
- 优化账户表单组件的渲染性能
- 更新Gemini账户服务,增强token刷新和错误处理
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-08-06 18:09:43 +08:00
shaw
9c9afe1528
feat: 实现账户分组管理功能和优化响应式设计
...
主要更新:
- 实现账户分组管理功能,支持创建、编辑、删除分组
- 支持将账户添加到分组进行统一调度
- 优化 API Keys 页面响应式设计,解决操作栏被隐藏的问题
- 优化账户管理页面布局,合并平台/类型列,改进操作按钮布局
- 修复代理信息显示溢出问题
- 改进表格列宽分配,充分利用屏幕空间
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-08-03 22:34:43 +08:00
shaw
414856f152
feat: 全新的Vue3管理后台(admin-spa)和路由重构
...
🎨 新增功能:
- 使用Vue3 + Vite构建的全新管理后台界面
- 支持Tab切换的API统计页面(统计查询/使用教程)
- 优雅的胶囊式Tab切换设计
- 同步了PR #106的会话窗口管理功能
- 完整的响应式设计和骨架屏加载状态
🔧 路由调整:
- 新版管理后台部署在 /admin-next/ 路径
- 将根路径 / 重定向到 /admin-next/api-stats
- 将 /web 页面路由重定向到新版,保留 /web/auth/* 认证路由
- 将 /apiStats 页面路由重定向到新版,保留API端点
🗑️ 清理工作:
- 删除旧版 web/admin/ 静态文件
- 删除旧版 web/apiStats/ 静态文件
- 清理相关的文件服务代码
🐛 修复问题:
- 修复重定向循环问题
- 修复环境变量配置
- 修复路由404错误
- 优化构建配置
🚀 生成方式:使用 Claude Code
Co-Authored-By: Claude <noreply@anthropic.com >
2025-07-29 12:40:51 +08:00
KevinLiao
718733b78b
feat: 增加账号session窗口管理与显示。后续可以据此优化账号轮转逻辑。
...
scripts目录有相关管理脚本,请自行探索
2025-07-28 15:51:38 +08:00
KevinLiao
85a8cae5ab
feat: 新增用户统计页面,并作为默认路由
2025-07-27 18:12:50 +08:00
KevinLiao
ac1e367a69
feat: 增加每日费用限制
2025-07-27 14:47:59 +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
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
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
f5968e518e
feat: 改进管理界面弹窗体验和滚动条美化
...
- 修复API Key创建/编辑弹窗和账户信息修改弹窗在低高度屏幕上被遮挡的问题
- 为所有弹窗添加自适应高度支持,最大高度限制为90vh
- 美化Claude账户弹窗的滚动条样式,使用紫蓝渐变色与主题保持一致
- 添加响应式适配,移动设备上弹窗高度调整为85vh
- 优化滚动条交互体验,支持悬停和激活状态
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-07-18 23:49:55 +08:00
shaw
6988be0806
fix: 修复长上下文请求超时问题
...
- 设置HTTP服务器超时时间与代理超时时间一致
- 默认超时时间为5分钟(可通过DEFAULT_PROXY_TIMEOUT环境变量配置)
- 同时设置keepAliveTimeout避免连接过早断开
- 解决了Node.js默认2分钟超时导致的长上下文处理中断问题
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-07-18 14:04:51 +08:00
shaw
11873ed78b
fix: 统一管理员密码管理机制,以init.json为唯一数据源
...
- app.js: 每次启动强制从init.json加载管理员凭据到Redis,确保数据一致性
- web.js: 修改密码时先更新init.json,成功后再更新Redis缓存
- cli/index.js: CLI创建管理员时同时更新init.json和Redis
- setup.js: 优化提示信息,明确重置密码需要重启服务
- admin.js: 修复Claude账户专属绑定功能的验证逻辑
解决了之前存在的双重存储同步问题,现在init.json是唯一真实数据源。
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-07-17 20:57:31 +08:00
shaw
b1ca3f307e
first commit
2025-07-14 18:14:13 +08:00