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
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
b4d7ed06c5
fix: 修复5小时限制被停止调度未恢复的问题
2025-09-28 23:30:41 +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
e197fbdf80
Merge branch 'pr-485' into dev
2025-09-28 09:45:03 +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
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
f105b1cc31
fix: 修复codex调度问题
2025-09-25 16:05:56 +08:00
shaw
ad672c3c4c
fix: 修复openai-respons计费问题
2025-09-25 11:31:30 +08:00
shaw
0a66609c1b
fix: 修复codex限流自动恢复问题
2025-09-24 16:47:55 +08:00
shaw
8b8e9703a1
fix: claude遇到5xx错误不再停止调度
2025-09-24 14:37:33 +08:00
shaw
f56d1edce0
feat: openai账号401自动停止调度
2025-09-24 11:35:48 +08:00
shaw
00faa21e4b
fix: 修复claude账号限流不会自动恢复的bug
2025-09-24 09:36:42 +08:00
shaw
24d1f0a494
fix: 修复统一user-agent问题
2025-09-23 17:35:10 +08:00
shaw
5a2199f9a9
fix: claude提示词检测逻辑修复
2025-09-23 16:29:17 +08:00
shaw
0ba048aced
feat: 优化专属账号删除逻辑
2025-09-23 15:48:38 +08:00
shaw
ff73375f0a
fix: 优化codex错误抛出 增强客户端限制条件
2025-09-22 11:56:54 +08:00
shaw
3628bb2b7a
fix: 修复openai输入token计算问题
2025-09-20 21:43:48 +08:00
shaw
08c2b7a444
fix: 修复PR #458中的totalCostLimit功能问题
...
主要修复:
- 移除重复的totalUsageLimit字段,统一使用totalCostLimit
- 删除auth.js中重复的总费用限制检查逻辑
- 删除admin.js中重复的totalCostLimit验证代码
- 更新所有前端组件,移除totalUsageLimit引用
功能改进:
- 确保totalCostLimit作为永久累计费用限制正常工作
- 与dailyCostLimit(每日重置)功能互补
- 适用于预付费、一次性API Key场景
测试:
- 删除有逻辑错误的test-total-usage-limit.js
- 创建新的test-total-cost-limit.js验证功能正确性
- 所有测试通过,功能正常工作
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-09-20 17:37:20 +08:00
itzhan
200149b9ee
chore: fix prettier formatting
2025-09-19 22:41:46 +08:00
itzhan
ec28b66e7f
feat: 给key增加总用量限制
2025-09-19 21:57:24 +08:00
shaw
6e98c46371
fix: 修复oai代理密码保存问题
2025-09-18 19:47:09 +08:00
shaw
43cfb0f4f3
fix: 修复openai账号代理问题
2025-09-18 17:39:45 +08:00
shaw
f70c3babc9
fix: 修复编辑oai账号是代理IP被错误保存的问题
2025-09-18 10:22:41 +08:00
wfunc
f2dc834bba
feat: 新增 telegram 通知
2025-09-16 11:44:39 +08:00
shaw
ae4bbe8253
docs: 更新codex默认模型示例
2025-09-16 10:40:58 +08:00
shaw
51cb92d395
feat: 适配gpt-5-codex模型
2025-09-16 09:01:41 +08:00
shaw
c0d6ecefac
fix: 修复限流状态判断逻辑,兼容对象和字符串格式
...
- 修复 cleanupOpenAIAccounts 方法中 rateLimitStatus 判断问题
- 修复 cleanupClaudeConsoleAccounts 方法中的判断逻辑
- 优化 unifiedOpenAIScheduler 的 _isRateLimited 辅助方法
- 保持原始服务层数据获取方式,通过判断逻辑适配不同数据格式
问题原因:服务层返回的 rateLimitStatus 是对象格式,但清理逻辑使用字符串比较,
导致限流账户无法被正确检测和自动恢复。
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-09-14 12:20:10 +08:00
shaw
158a9b9a31
feat: 优化API Key批量创建和账户限流状态显示
...
- 添加 bedrockAccountId 和 rateLimitCost 字段到批量创建 API Key 功能
- 格式化 claudeAccountService 中的日志输出
- 改进账户视图中会话进度条样式,限流状态显示红色
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-09-14 11:59:09 +08:00
shaw
aabf909c61
fix:修复限流后未自动恢复调度的问题
2025-09-13 22:24:56 +08:00
shaw
b7da43f615
fix: 修复部分账号转发gemini api失败的问题
2025-09-12 11:41:14 +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
shaw
0eb95b3b06
refactor: 清理模型限制检查的冗余代码
...
优化内容:
- 删除 claudeRelayService.js 中的重复模型限制检查(82行代码)
- 保留 api.js 中的统一检查,覆盖所有服务类型(claude/console/ccr)
- 移除 /v1/messages/count_tokens 端点的模型限制(计数接口不需要限制)
架构改进:
- 模型限制逻辑现在集中在 api.js 的 handleMessagesRequest 函数中
- 避免了每个服务各自实现一遍的重复代码
- 提高了代码的可维护性和一致性
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-09-11 09:43:15 +08:00
shaw
f667a95d88
fix: 修复模型限制功能逻辑错误(从白名单改回黑名单)
...
问题原因:
- 在提交 7f9869ae 添加CCR支持时,错误地将模型限制从黑名单改成了白名单
- 前端UI显示"设置此API Key无法访问的模型",明确表示这是黑名单
- 后端却将其当作白名单处理,导致逻辑完全相反
修复内容:
- 将判断逻辑从 !includes 改回 includes(黑名单逻辑)
- 更新注释和日志消息,明确这是"限制列表"而非"允许列表"
- 同时修复了 api.js 和 claudeRelayService.js 中的所有相关判断
影响范围:
- src/routes/api.js: 修复 /v1/messages 和 /v1/messages/count_tokens 端点的模型限制判断
- src/services/claudeRelayService.js: 修复流式和非流式请求的模型限制判断
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-09-11 09:35:04 +08:00
shaw
2fcfccb2fc
Merge branch 'dev' of github.com:Wei-Shaw/claude-relay-service into dev
2025-09-10 22:46:18 +08:00
Wesley Liddick
fe1f05fadd
Merge pull request #411 from bottotl/main
...
兼容 sider 自定义 API
2025-09-10 22:36:54 +08:00
root
4fd4dbfa51
fix: 回退401错误处理逻辑到原始版本
...
- 恢复"遇到1次401就停止调度"的原始逻辑
- 移除"记录401错误但不停用账号"的临时修改
- 修复非流式和流式请求中的401处理逻辑
- 确保401错误会立即标记账号为异常状态
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-09-10 08:20:17 +00:00
sususu98
d3fcd95b94
refactor: improve readability of conditional statements
2025-09-10 15:55:34 +08:00
sususu98
433f0c5f23
fix: 更新会话续期逻辑,调整续期阈值和TTL设置,确保统一调度会话映射按配置正确续期
2025-09-10 15:53:23 +08:00
shaw
7712d5516c
merge: 合并远程 dev 分支,整合 CCR 和 OpenAI-Responses 功能
...
## 合并内容
- 成功合并远程 dev 分支的 CCR (Claude Connector) 功能
- 保留本地的 OpenAI-Responses 账户管理功能
- 解决所有合并冲突,保留双方功能
## UI 调整
- 将 CCR 平台归类到 Claude 分组中
- 保留新的平台分组选择器设计
- 支持所有平台类型:Claude、CCR、OpenAI、OpenAI-Responses、Gemini、Azure OpenAI、Bedrock
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-09-10 15:49:52 +08:00