Commit Graph

1298 Commits

Author SHA1 Message Date
shaw
2f0839c7da feat: 合并 PR #578 并接入统一定价服务 2025-10-16 14:12:25 +08:00
AAEE86
d3cf66e2c0 Update AccountsView.vue
移除 overflow-x: auto
2025-10-16 11:13:23 +08:00
github-actions[bot]
6c0f38f5e8 chore: sync VERSION file with release v1.1.177 [skip ci] 2025-10-16 02:47:50 +00:00
shaw
d606cb2e38 fix: 优化模型价格文件更新策略 2025-10-16 10:46:45 +08:00
liangjie.wanglj
b9d2e855f3 claude console类型中增加claude-haiku-4-5-20251001、GLM、Kimi、Qwen模型支持;增加计费消息通知;Claude console 及 ccr模型匹配大小写不敏感 2025-10-16 09:53:42 +08:00
shaw
d275b0d4b6 Merge branch 'new' into dev 2025-10-16 09:41:14 +08:00
shaw
0092c92196 Merge branch 'docs/update-claude-md-comprehensive' into dev 2025-10-16 09:40:24 +08:00
AAEE86
914c1b6120 Merge branch 'main' into new 2025-10-15 23:38:18 +08:00
github-actions[bot]
3cb674279a chore: sync VERSION file with release v1.1.176 [skip ci] 2025-10-15 12:49:09 +00:00
shaw
472fb535cf Merge branch 'bottotl/main' into dev 2025-10-15 19:27:13 +08:00
shaw
77124aa501 fix: droid去掉count_tokens端点 2025-10-15 15:50:04 +08:00
AAEE86
8ab3c76c6f feat: 新增 API Key 筛选和搜索功能
- 筛选key,新增支持筛选正常和异常状态的key
- 搜索key,新增支持模糊/精确搜索key
- 删除key,新增支持一键删除所有异常状态的key或者删除所有key
- 导出key,新增支持一键导出所有异常状态的key或者导出所有key
2025-10-15 15:35:59 +08:00
shaw
c2669da4b3 fix: 更新factory user-agent 2025-10-15 15:26:58 +08:00
shaw
d72897f835 fix: droid转发增加runtimeAddon调试插件 2025-10-15 15:17:20 +08:00
litongtongxue
1bd9002af9 docs: 全面更新 CLAUDE.md 文档以反映最新代码实现
## 更新概要

本次更新全面审查了代码库,将严重过期的 CLAUDE.md 文档更新到与当前实现一致。

## 主要更新内容

### 1. 项目概述和架构
- 更新为多平台支持(8种账户类型)
- 添加统一调度系统说明
- 补充权限控制、客户端限制、模型黑名单等新功能

### 2. 服务组件
- 从5个服务扩展到30+个服务的完整列表
- 新增核心转发服务(8个)
- 新增账户管理服务(10个)
- 新增统一调度器(4个)
- 新增核心功能服务(用户管理、定价、Webhook、LDAP等)

### 3. 环境变量配置
- 新增20+个重要环境变量说明
- 添加AWS Bedrock配置
- 添加用户管理、LDAP、Webhook配置说明

### 4. API端点
- 更新为多路由支持(Claude、Gemini、OpenAI、Droid、Azure)
- 新增用户管理端点
- 新增Webhook管理端点
- 新增系统指标端点

### 5. Redis数据结构
- 扩展为8种账户类型的数据结构
- 添加用户管理、粘性会话、并发控制相关键
- 添加成本统计、Webhook配置相关键

### 6. 故障排除
- 从4个问题扩展到13个常见问题
- 新增粘性会话、LDAP、Webhook、调度器等问题解决方案

### 7. CLI工具
- 添加数据导入导出命令
- 添加数据迁移和修复命令
- 添加成本初始化和定价更新命令

### 8. 新增功能概览章节
- 列出相比旧版本的所有新增功能
- 包括多平台支持、用户权限系统、统一调度、成本监控等

## 技术细节

- 保持所有现有章节结构
- 使用 Prettier 格式化确保代码风格一致
- 基于实际代码审查(src/services/、src/routes/、config/等)
- 确保所有端点、配置项、数据结构与代码实现一致

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-15 01:03:57 +08:00
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
b886012f97 Merge branch 'Wei-Shaw:main' into main 2025-10-14 22:39:30 +08: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
92712277db feat: droid的apikey页面增加一键复制全部 2025-10-14 20:44:14 +08:00
shaw
62aea5a4a8 fix: 修复tokenExpiresAt混淆问题 2025-10-14 19:19:33 +08:00
shaw
6c60478777 Merge branch 'feature/account-subscription-expiry-check' into dev 2025-10-14 17:47:37 +08:00
mrlitong
aaa2bda407 fix: 修复账户过期时间字段映射问题
## 问题描述
移除 formatSubscriptionExpiry 函数后,API返回的 expiresAt 字段变成了OAuth token过期时间(通常1小时)
而不是订阅过期时间,导致前端显示错误的过期时间,并可能将短期token过期时间错误保存为订阅过期时间。

## 修复方案
1. 添加 formatAccountExpiry 函数,正确映射字段:
   - expiresAt: 映射为 subscriptionExpiresAt(订阅过期时间)供前端使用
   - tokenExpiresAt: 保留OAuth token过期时间供内部使用

2. 在所有账户端点应用格式化:
   - 所有账户类型的GET端点(Claude, Claude Console, CCR, Bedrock, Gemini, OpenAI等)
   - 所有账户类型的POST创建端点
   - 错误处理分支也正确格式化

## 影响范围
- 修复了9种账户类型的所有相关端点
- 共应用了28处格式化调用
- 确保前端获取正确的订阅过期时间,而非token过期时间

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-14 09:26:56 +00:00
mrlitong
82433c3b8d chore: 移除代码评审报告文件
移除项目中的代码评审报告文件,此类文档不应纳入代码库管理。

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-14 08:58:33 +00:00
mrlitong
1f61478fbc refactor: 优化账户过期检查逻辑和代码一致性
## 主要改进

### 1. 添加缺失的过期检查方法
- 在 `claudeConsoleAccountService` 中添加 `isSubscriptionExpired()` 方法
- 在 `ccrAccountService` 中添加 `isSubscriptionExpired()` 方法
- 与其他 7 个账户服务保持一致的实现方式

### 2. 统一过期检查逻辑
- 重构 `unifiedClaudeScheduler` 中的 5 处手动日期检查代码
- 统一调用服务层的 `isSubscriptionExpired()` 方法
- 消除重复代码,提升可维护性

### 3. 统一字段映射顺序
- 调整 Claude 账户更新端点的 `mapExpiryField()` 调用时机
- 与其他账户类型保持一致的处理顺序
- 提升代码可读性和一致性

## 技术细节

**修改文件**:
- `src/services/claudeConsoleAccountService.js`: 添加 `isSubscriptionExpired()`
- `src/services/ccrAccountService.js`: 添加 `isSubscriptionExpired()`
- `src/services/unifiedClaudeScheduler.js`: 5 处调用统一为服务方法
- `src/routes/admin.js`: 统一字段映射顺序

**改进效果**:
-  代码一致性提升:所有账户服务统一实现
-  可维护性提升:过期逻辑集中管理
-  减少重复代码:消除 4 处重复实现

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-14 08:35:13 +00:00
mrlitong
cd5df4f76b Merge remote-tracking branch 'upstream/main' into feature/account-subscription-expiry-check 2025-10-14 08:04:12 +00:00
mrlitong
cbc3a83f11 refactor: 统一账户过期时间字段映射和检查逻辑
主要改进:
1. 创建 mapExpiryField() 工具函数统一处理前后端字段映射(expiresAt -> subscriptionExpiresAt)
2. 统一 subscriptionExpiresAt 初始值为 null(替代空字符串)
3. 规范过期检查方法名为 isSubscriptionExpired(),返回 true 表示已过期
4. 优化过期检查条件判断,只检查 null 而非空字符串
5. 补充 OpenAI-Responses 和调度器中缺失的过期检查逻辑
6. 添加代码评审文档记录未修复问题

影响范围:
- 所有 9 种账户服务的过期字段处理
- admin.js 中所有账户更新路由
- 统一调度器的过期账户过滤逻辑

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-14 08:04:05 +00:00
github-actions[bot]
b4658e5d5f chore: sync VERSION file with release v1.1.175 [skip ci] 2025-10-14 06:34:22 +00:00
Wesley Liddick
4b3ffa4136 Merge pull request #561 from AAEE86/new
feat: 添加Droid账户API Key管理功能
2025-10-14 14:34:07 +08:00
github-actions[bot]
86ccb0273e chore: sync VERSION file with release v1.1.174 [skip ci] 2025-10-14 06:24:00 +00:00
shaw
dfea5fe534 docs: 更新gemini配置教程 2025-10-14 11:40:07 +08:00
shaw
914142541a Revert "fix: 修复账户到期时间的时区偏差问题"
This reverts commit 46ba514801.
2025-10-14 11:29:33 +08:00
shaw
d6a9beff2f feat: 适配新版本gemini 2025-10-14 11:24:27 +08:00
mrlitong
ba60a2dcbb fix: 修复自定义过期时间的时区解析问题
修复 datetime-local 输入框在不同浏览器中时区解析不一致的问题。

## 问题
- datetime-local 返回无时区信息的字符串 (如: 2025-12-31T23:59)
- new Date(string) 在不同浏览器中解析行为不一致
- 部分浏览器错误地将其解释为 UTC,导致时区偏移

## 解决方案
- 手动解析日期时间字符串的各个部分
- 使用 Date 构造函数明确创建本地时间对象
- 统一转换为 UTC ISO 字符串存储
- 添加日期有效性验证和错误处理

## 影响范围
- 仅影响自定义过期时间设置功能
- 确保用户设置的时间与存储/显示一致
- 提升跨浏览器兼容性

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-14 02:52:18 +00:00
mrlitong
6e1ed12771 chore: 删除临时测试脚本和评审文档
- 删除 scripts/create-test-accounts.js
- 删除 scripts/add-claude-accounts.js
- 删除 scripts/list-test-accounts.js
- 删除 account_expire_bugfix.md

测试已完成,清理临时文件
2025-10-14 02:42:03 +00:00
litongtongxue
1e7465e533 feat: 为所有账户服务添加订阅过期检查功能
完成账户订阅到期时间功能的核心调度逻辑实现。

## 实现范围

 已添加订阅过期检查的服务(5个):
- Gemini 服务:添加 isSubscriptionExpired() 函数及调度过滤
- OpenAI 服务:添加 isSubscriptionExpired() 函数及调度过滤
- Droid 服务:添加 _isSubscriptionExpired() 方法及调度过滤
- Bedrock 服务:添加 _isSubscriptionExpired() 方法及调度过滤
- Azure OpenAI 服务:添加 isSubscriptionExpired() 函数及调度过滤

## 核心功能

- 账户调度时自动检查 subscriptionExpiresAt 字段
- 过期账户将不再被系统调度使用
- 未设置过期时间的账户视为永不过期(向后兼容)
- 使用 <= 比较判断过期(精确到过期时刻)
- 跳过过期账户时记录 debug 日志便于排查

## 技术实现

- 统一的实现模式:过期检查函数 + 账户选择逻辑集成
- 不影响现有功能,完全向后兼容
- 业务字段 subscriptionExpiresAt 与技术字段 expiresAt(OAuth token过期)独立管理

## 相关文档

参考 account_expire_bugfix.md 了解问题背景和实现细节

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-14 02:42:03 +00:00
AAEE86
8dd07919f4 fix: 修复 API Key 管理界面按钮的点击事件逻辑 2025-10-14 10:34:38 +08:00
AAEE86
582348d615 fix: 修正删除API Key时更新数据的字段名称 2025-10-14 10:09:47 +08:00
AAEE86
38c61e1018 refactor: 优化API Key状态过滤逻辑,增强代码可读性 2025-10-14 09:37:46 +08:00
AAEE86
8d84e2fa6e refactor: 优化API Key状态更新和日志记录格式 2025-10-14 09:33:17 +08:00
AAEE86
e051ade27e feat: 按最新使用时间排序API Keys 2025-10-14 01:05:22 +08:00
AAEE86
ea3ad2157f fix: 优化API Key错误状态码的显示方式 2025-10-14 00:53:19 +08:00
DokiDoki1103
46ba514801 fix: 修复账户到期时间的时区偏差问题
修复了在编辑账户到期时间时,保存后显示时间相差8小时的问题。

问题原因:
- datetime-local 输入框的值使用 new Date(string) 解析时
- 部分浏览器会错误地将其解释为 UTC 时间
- 导致保存和显示时出现时区转换不一致

解决方案:
- 手动解析日期时间字符串的各个部分
- 使用 Date 构造函数明确创建本地时间对象
- 然后统一转换为 UTC ISO 字符串存储
- 确保时区转换的一致性

修改文件:
- web/admin-spa/src/components/accounts/AccountExpiryEditModal.vue

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-13 19:04:11 +08:00
AAEE86
1f9afc788b feat: 添加Droid账户API Key管理功能
(cherry picked from commit 0cf3ca6c7eafcf28a2da7e8bfd6814b4883bb752)
2025-10-13 18:24:49 +08:00
github-actions[bot]
268f041588 chore: sync VERSION file with release v1.1.173 [skip ci] 2025-10-13 03:41:53 +00:00
Wesley Liddick
222b2862cc Merge pull request #560 from looksgood/main
优化Claude OAuth 账户的模型检查
2025-10-13 11:41:39 +08:00
Wesley Liddick
8ddb905213 Merge pull request #557 from bottotl/main [skip ci]
feat: 改善登录表单的可访问性和自动填充支持
2025-10-13 11:36:42 +08:00
jft0m
96eca07ff2 Merge branch 'Wei-Shaw:main' into main 2025-10-13 11:32:02 +08:00
Wesley Liddick
2215b0acd8 Merge pull request #555 from DokiDoki1103/fix/ccr-account-modal-dark-theme [skip ci]
fix: 修复 CCR 账户弹窗暗黑主题失效问题
2025-10-13 11:25:33 +08:00
shaw
43dee194f4 chore: 移除github参数 [skip-ci] 2025-10-13 11:23:32 +08:00