Commit Graph

724 Commits

Author SHA1 Message Date
shaw
42db271848 feat: droid平台账户数据统计及调度能力 2025-10-10 15:13:45 +08:00
shaw
2fc84a6aca feat: 新增Droid cli支持 2025-10-09 23:05:09 +08:00
於林涛
8f9286c30e fix: 修复 ESLint 代码规范问题 2025-10-08 19:49:36 +08:00
於林涛
705bd7611c Merge remote-tracking branch 'upstream/main'
# Conflicts:
#	src/routes/api.js
2025-10-08 19:34:17 +08:00
shaw
eb304c7e70 feat: openai转发增加apikey速率限制 2025-10-08 08:36:43 +08:00
shaw
6e770146fd fix: 优化cache control问题2 2025-10-07 15:14:08 +08:00
shaw
9c022e6642 Merge branch 'fix-daily-average-calculation' into dev 2025-10-07 15:06:11 +08:00
shaw
88429e1a24 fix: 优化cache control问题 2025-10-07 14:37:28 +08:00
shaw
52af60b3c9 fix: 适配Claude agent-sdk转发 2025-10-07 14:00:29 +08:00
litongtongxue
454f366c50 fix: 修复日均费用计算逻辑
问题描述:
- 之前的日均费用计算是基于固定的30天窗口,而不是账户实际使用的天数
- 这导致新创建的账户显示的日均费用不准确

修复方案:
- 获取账户的创建时间(createdAt字段)
- 计算从账户创建到当前时间的实际天数
- 使用实际天数来计算日均费用(30天总费用 / 实际天数)
- 在前端显示实际使用天数,让用户了解计算基准

修改内容:
- 后端:在 /accounts/:accountId/usage-history 端点中添加实际天数计算逻辑
- 前端:在详情弹窗中显示基于实际使用天数的提示信息

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-07 11:27:29 +08:00
jft0m
bb95c0b7d5 fix: 修复 ESLint 代码规范问题
- 移除正则表达式中不必要的转义字符
- 添加 if 语句的花括号

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-06 15:57:09 +00:00
jft0m
5d7225b2eb feat: 添加 Opus 限流状态显示
- 在账户列表中显示 Opus 限流状态徽章
- 显示限流剩余时间(天/小时)
- 后端 API 添加 opusRateLimitedAt 和 opusRateLimitEndAt 字段
- 优化徽章样式,防止文字溢出
2025-10-06 15:49:28 +00:00
jft0m
61e5cb4584 refactor: 重构 handleChatCompletions 函数模块化
- 使用策略模式处理不同后端(Claude/OpenAI/Gemini)
- 添加 OpenAI chat/completions 兼容支持
- 修复代码缩进符合 ESLint 规范
2025-10-06 14:00:46 +00:00
jft0m
530dac0e7f refactor: 重构 handleChatCompletions 函数模块化
- 使用策略模式处理不同后端(Claude/OpenAI/Gemini)
- 添加 OpenAI chat/completions 兼容支持
2025-10-04 14:11:13 +08:00
shaw
2872198259 chore: claude绑定账号响应限流提示 2025-10-04 11:31:21 +08:00
shaw
cd72a29674 chore: opus周限提示增加重置时间 2025-10-04 11:10:55 +08:00
shaw
d44582dc31 feat: 适配claude新opus周限规则 2025-10-04 10:49:40 +08:00
shaw
bda1875466 Merge PR #507: add rate limit recovery notifications 2025-10-03 22:25:46 +08:00
wfunc
a3666e3a3e feat: add rate limit recovery webhook notifications
添加限流恢复的 webhook 通知功能,当账户从限流状态自动恢复时发送通知。

主要改进:

1. **新增通知类型** (webhookConfigService.js)
   - 添加 `rateLimitRecovery` 通知类型
   - 在配置获取和保存时自动合并默认通知类型
   - 确保新增的通知类型有默认值

2. **增强限流清理服务** (rateLimitCleanupService.js)
   - 改进自动停止账户的检测逻辑
   - 在 `finally` 块中确保 `clearedAccounts` 列表被重置,避免重复通知
   - 对自动停止的账户显式调用 `removeAccountRateLimit`
   - 为 Claude 和 Claude Console 账户添加 `autoStopped` 和 `needsAutoStopRecovery` 检测

3. **改进 Claude Console 限流移除** (claudeConsoleAccountService.js)
   - 检测并恢复因自动停止而禁用调度的账户
   - 清理过期的 `rateLimitAutoStopped` 标志
   - 增加详细的日志记录

4. **前端 UI 支持** (SettingsView.vue)
   - 在 Webhook 设置中添加"限流恢复"通知类型选项
   - 更新默认通知类型配置

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-02 23:54:30 +08:00
wfunc
ea0f818251 feat(claude): limit 5-hour warning notifications to prevent spam
## Problem
- Original implementation sends webhook notification on EVERY request when
  account reaches 5-hour limit warning status
- Users receive hundreds of duplicate notifications within same 5-hour window

## Solution
- Add `maxFiveHourWarningsPerWindow` config (default: 1, max: 10)
- Track warning count per session window with metadata:
  - fiveHourWarningWindow: identifies current window
  - fiveHourWarningCount: tracks notifications sent
  - fiveHourWarningLastSentAt: last notification timestamp
- Only send notification if count < max limit
- Auto-reset counters when entering new 5-hour window

## Changes
- Add warning limit control in constructor
- Add `_clearFiveHourWarningMetadata()` helper method
- Update `updateSessionWindowStatus()` with notification throttling
- Clear warning metadata on window refresh and manual schedule recovery

## Configuration
- Environment: CLAUDE_5H_WARNING_MAX_NOTIFICATIONS (1-10)
- Config: config.claude.fiveHourWarning.maxNotificationsPerWindow
- Default: 1 notification per window

## Testing
- Tested with accounts reaching 5h limit
- Verified single notification per window
- Confirmed counter reset on new window
2025-10-02 23:31:52 +08:00
shaw
3f79e56209 Merge remote-tracking branch 'origin/dev' into dev 2025-10-02 18:37:26 +08:00
shaw
9148913ca4 feat: 增加Oauth Claude账户usage接口缓存 2025-10-02 18:35:41 +08:00
shaw
5024628fa6 Merge branch 'pr-503' into dev 2025-10-02 18:04:11 +08:00
duyaoguang
7fd5224e0a fix: 🐛 fee calc fix 2025-10-02 13:09:19 +08:00
iaineng
782e912a0d fix(oauth): auto-refresh expired tokens in fetchOAuthUsage
Replace direct token decryption with getValidAccessToken call to
enable automatic token expiration check and refresh. This fixes
authentication_error when fetching OAuth usage data with expired
access tokens.
2025-10-01 11:59:03 +08:00
iaineng
11c214449f feat(api): add Claude OAuth usage endpoint with async loading
Add dedicated API endpoint to fetch Claude account OAuth usage data
asynchronously, improving user experience by eliminating the need for
multiple page refreshes to view session window statistics.

Backend changes:
- Add GET /admin/claude-accounts/usage endpoint for batch fetching
- Implement fetchOAuthUsage() to call Claude API /api/oauth/usage
- Add buildClaudeUsageSnapshot() to construct frontend data structure
- Add updateClaudeUsageSnapshot() to persist data to Redis
- Add _toNumberOrNull() helper for safe type conversion
- Update getAllAccounts() to return claudeUsage from Redis cache

Data structure:
- Store three window types: 5h, 7d, 7d-Opus
- Track utilization percentage and reset timestamps
- Calculate remaining seconds for each window

Performance optimizations:
- Concurrent batch requests using Promise.allSettled
- Graceful error handling per account
- Non-blocking async execution
2025-09-30 22:51:54 +08:00
Gemini Wen
87bd54d9ea fix: 修复统一客户端标识的布尔值判断
将 useUnifiedClientId 的判断从直接布尔值比较改为字符串 'true' 比较,修复配置值为字符串时的判断问题。

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-30 13:01:54 +08:00
shaw
fcf54565ec chore: 其他文件修改
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-30 11:25:43 +08:00
shaw
4ab91f233f refactor: 使用 claudeCodeValidator 统一验证逻辑
替换 _hasClaudeCodeSystemPrompt 方法,改用 claudeCodeValidator

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-30 11:25:35 +08:00
shaw
66b9b391d9 feat: 添加 Claude Agent SDK 系统提示词
新增 claudeOtherSystemPrompt3 支持 Agent SDK 格式

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-30 11:25:26 +08:00
shaw
4ad1ccc22c fix: 适配 claude-vscode 客户端
扩展正则表达式以支持 claude-cli/2.0.0 (external, claude-vscode)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-30 11:25:18 +08:00
shaw
c19acf2b01 fix: contents.js依赖改为CommonJS 2025-09-29 14:48:43 +08:00
千羽
3e69f17330 feat: 重构和更新 Claude Code 验证器组件
- 重构 src/utils/contents.js,添加完整的 prompt 定义和相似度检测功能
- 删除重复的 src/utils/text-similarity.js 文件
- 更新 claudeCodeValidator.js 中的验证逻辑和错误处理

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-29 14:39:29 +09:00
shaw
b4d7ed06c5 fix: 修复5小时限制被停止调度未恢复的问题 2025-09-28 23:30:41 +08:00
shaw
aca2b1cccb feat: 账号列表支持批量删除 2025-09-28 21:43:57 +08:00
shaw
5e015e87e0 style: 优化api-stats布局 2025-09-28 14:54:24 +08:00
shaw
b123cc35c1 feat: api-stats页面查询专属账号会话窗口 2025-09-28 14:36:38 +08:00
shaw
90dce32cfc fix: 优化并发限制数的控制逻辑 2025-09-28 13:58:59 +08:00
shaw
5ce385d2bc fix: 修复账号筛选平台是oai显示异常 2025-09-28 11:53:46 +08:00
shaw
e197fbdf80 Merge branch 'pr-485' into dev 2025-09-28 09:45:03 +08:00
shaw
e675c5878e style: 仪表板组件样式优化 2025-09-27 23:07:39 +08:00
shaw
ea28222c71 feat: 支持账号维度的数据统计 2025-09-27 22:55:06 +08:00
yaogdu
d1bbc71796 feat: 🎸 export csv from web and support hourly TTL of key 2025-09-27 14:11:54 +08:00
shaw
0e724c9901 feat: oai账号增加402适配 2025-09-26 17:29:50 +08:00
shaw
f97db927c0 style: 调整standardGeminiRoutes缩进格式 2025-09-26 10:47:07 +08:00
shaw
25d1c3f74e fix: apikey的服务权限问题修复 2025-09-25 22:51:39 +08:00
shaw
66bb3419b7 fix: 修复oai专属绑定401导致重复触发通知的bug 2025-09-25 22:32:04 +08:00
shaw
c15ef0b6ae feat: 适配codex用量数据 2025-09-25 17:23:52 +08:00
shaw
991dd1436f fix: 修复apikey的服务权限失效问题 2025-09-25 17:23:52 +08:00
shaw
f105b1cc31 fix: 修复codex调度问题 2025-09-25 16:05:56 +08:00