huangzhenpc
d66394c0b8
同步上游v0.1.74并禁用更新模块显示和后台检查
...
CI / test (push) Has been cancelled
CI / golangci-lint (push) Has been cancelled
Security Scan / backend-security (push) Has been cancelled
Security Scan / frontend-security (push) Has been cancelled
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-08 00:37:57 +08:00
shaw
6aaa4aee6a
fix: 收敛 Claude Code 探测拦截并补齐回归测试
2026-02-07 19:04:08 +08:00
shaw
1439eb39a9
fix(gateway): harden digest logging and align antigravity ops
...
- avoid panic by using safe UUID prefix truncation in Gemini digest fallback logs\n- remove unconditional Antigravity 429 full-body debug logs and honor log truncation config\n- align Antigravity quick preset mappings to opus 4.6-thinking targets only\n- restore scope rate-limit aggregation/output in ops availability stats
2026-02-07 17:12:15 +08:00
erio
edb0937024
fix: restore non-failover error passthrough from 7b156489
2026-02-07 14:24:55 +08:00
erio
5e98445b22
feat(antigravity): comprehensive enhancements - model mapping, rate limiting, scheduling & ops
...
Key changes:
- Upgrade model mapping: Opus 4.5 → Opus 4.6-thinking with precise matching
- Unified rate limiting: scope-level → model-level with Redis snapshot sync
- Load-balanced scheduling by call count with smart retry mechanism
- Force cache billing support
- Model identity injection in prompts with leak prevention
- Thinking mode auto-handling (max_tokens/budget_tokens fix)
- Frontend: whitelist mode toggle, model mapping validation, status indicators
- Gemini session fallback with Redis Trie O(L) matching
- Ops: enhanced concurrency monitoring, account availability, retry logic
- Migration scripts: 049-051 for model mapping unification
2026-02-07 12:31:10 +08:00
shaw
7b1564898b
fix: make error passthrough effective for non-failover upstream errors
2026-02-07 10:25:56 +08:00
LLLLLLiulei
7319122e92
merge upstream/main
2026-02-06 11:33:45 +08:00
shaw
39e05a2dad
feat: 新增全局错误透传规则功能
...
支持管理员配置上游错误如何返回给客户端:
- 新增 ErrorPassthroughRule 数据模型和 Ent Schema
- 实现规则的 CRUD API(/admin/error-passthrough-rules)
- 支持按错误码、关键词匹配,支持 any/all 匹配模式
- 支持按平台过滤(anthropic/openai/gemini/antigravity)
- 支持透传或自定义响应状态码和错误消息
- 实现两级缓存(Redis + 本地内存)和多实例同步
- 集成到 gateway_handler 的错误处理流程
- 新增前端管理界面组件
- 新增单元测试覆盖核心匹配逻辑
优化:
- 移除 refreshLocalCache 中的冗余排序(数据库已排序)
- 后端 Validate() 增加匹配条件非空校验
2026-02-05 21:52:54 +08:00
LLLLLLiulei
029994a83b
fix: remove unused listAllAccounts
2026-02-05 19:13:00 +08:00
LLLLLLiulei
37047919ab
fix: harden import/export flow
2026-02-05 18:59:30 +08:00
LLLLLLiulei
0b45d48e85
perf: batch fetch proxies for account export
2026-02-05 18:40:49 +08:00
LLLLLLiulei
0c660f8335
feat: refine proxy export and toolbar layout
2026-02-05 18:35:00 +08:00
LLLLLLiulei
ce9a247a9d
feat: add proxy import flow
2026-02-05 18:23:49 +08:00
LLLLLLiulei
b4bd46d067
feat: add data import/export bundle
2026-02-05 17:46:08 +08:00
shaw
2b192f7dca
feat: 支持用户专属分组倍率配置
2026-02-05 16:05:42 +08:00
Wesley Liddick
dabed96af4
Merge pull request #486 from s-Joshua-s/feat/usage-filter-by-apikey
...
feat(gateway): filter /v1/usage stats by API Key instead of UserID
2026-02-05 13:37:31 +08:00
shaw
49a3c43741
feat(auth): 实现 Refresh Token 机制
...
- 新增 Access Token + Refresh Token 双令牌认证
- 支持 Token 自动刷新和轮转
- 添加登出和撤销所有会话接口
- 前端实现无感刷新和主动刷新定时器
2026-02-05 12:42:54 +08:00
JIA-ss
fa3ea5ee4d
feat(gateway): filter /v1/usage stats by API Key instead of UserID
...
Previously the /v1/usage endpoint aggregated usage stats (today/total
tokens, cost, RPM/TPM) across all API Keys belonging to the user.
This made it impossible to distinguish usage from different API Keys
(e.g. balance vs subscription keys).
Now the usage stats are filtered by the current request's API Key ID,
so each key only sees its own usage data. The balance/remaining fields
are unaffected and still reflect the user-level wallet balance.
Changes:
- Add GetAPIKeyDashboardStats to repository interface and implementation
- Add getPerformanceStatsByAPIKey helper (also fixes TPM to include
cache_creation_tokens and cache_read_tokens)
- Add GetAPIKeyDashboardStats to UsageService
- Update Usage handler to call GetAPIKeyDashboardStats(apiKey.ID)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2026-02-05 11:45:54 +08:00
shaw
df1c2383da
chore: fix gofmt formatting
2026-02-03 21:52:49 +08:00
Wesley Liddick
4cce21b125
Merge branch 'main' into main
2026-02-03 21:43:41 +08:00
Wesley Liddick
c0c9c984d1
Merge pull request #471 from bayma888/feature/api-key-quota-expiration
...
feat(api-key): 添加API密钥独立配额和过期时间功能
2026-02-03 21:11:17 +08:00
bayma888
be7bc658fc
fix(test): add IncrementQuotaUsed to all APIKeyRepository test stubs
...
- Add missing IncrementQuotaUsed method to stubApiKeyRepo in api_contract_test.go
- Fix gofmt formatting issues in api_key_service.go, dto/types.go, api_key_handler.go
2026-02-03 20:49:58 +08:00
Wesley Liddick
c89bbf5130
Merge pull request #458 from bayma888/feature/admin-user-balance-history
...
feat(admin): 管理员可查看每个用户充值和并发变动记录、点击余额可直接查看、优化弹框UI
2026-02-03 20:37:30 +08:00
bayma888
6146be1474
feat(api-key): add independent quota and expiration support
...
This feature allows API Keys to have their own quota limits and expiration
times, independent of the user's balance.
Backend:
- Add quota, quota_used, expires_at fields to api_key schema
- Implement IsExpired() and IsQuotaExhausted() checks in middleware
- Add ResetQuota and ClearExpiration API endpoints
- Integrate quota billing in gateway handlers (OpenAI, Anthropic, Gemini)
- Include quota/expiration fields in auth cache for performance
- Expiration check returns 403, quota exhausted returns 429
Frontend:
- Add quota and expiration inputs to key create/edit dialog
- Add quick-select buttons for expiration (+7, +30, +90 days)
- Add reset quota confirmation dialog
- Add expires_at column to keys list
- Add i18n translations for new features (en/zh)
Migration:
- Add 045_add_api_key_quota.sql for new columns
2026-02-03 19:49:31 +08:00
bayma888
d008941cb3
fix(test): add missing stub methods for RedeemCodeRepository and AdminService
...
Add ListByUserPaginated and SumPositiveBalanceByUser to redeemRepoStub
Add GetUserBalanceHistory to stubAdminService
Fixes CI test compilation errors
2026-02-03 19:29:39 +08:00
song
f1aafbc06f
chore: gofmt
2026-02-03 16:55:13 +08:00
song
7cb5444dbb
fix: update tests for group fallback
2026-02-03 16:48:52 +08:00
song
2220fd18ca
merge upstream main
2026-02-03 15:36:17 +08:00
Wesley Liddick
6e54eda41f
Merge pull request #464 from touwaeriol/pr/antigravity-scope-ratelimit
...
feat(antigravity): 支持按配额域(scope)级别限流
2026-02-03 15:02:15 +08:00
Wesley Liddick
df4c0adf0b
Merge pull request #463 from DuckyProject/feat/usage-records-codex-reasoning-effort
...
feat(usage): add reasoning effort column
2026-02-03 14:57:45 +08:00
Wesley Liddick
7229b41fc7
Merge pull request #420 from shuike/feat-invitation-code
...
feat: 增加邀请码注册功能
2026-02-03 14:44:15 +08:00
ducky
53ee6383db
feat(usage): add reasoning effort column
2026-02-03 14:36:29 +08:00
Wesley Liddick
a09478f374
Merge pull request #316 from cyhhao/fix/claude-oauth-compat
...
fix(网关): 完善 Claude OAuth/Claude Code 兼容
2026-02-03 14:26:19 +08:00
liuxiongfeng
8824400c3e
feat(accounts): 账号列表显示 Antigravity scope 级别限流状态
...
- 后端 DTO 新增 scope_rate_limits 字段,从 extra 提取限流信息
- 前端状态列显示 scope 级限流徽章(Claude/Gemini/Image)
- 清除速率限制时同时清除账号级和 scope 级限流(已有实现)
Cherry-picked from slovx2/sub2api: 66f49b67
2026-02-03 14:25:30 +08:00
shuike
6c86501d11
feat: 增加邀请码注册功能
2026-02-03 13:38:44 +08:00
Wesley Liddick
2f92b06869
Merge pull request #457 from touwaeriol/pr/group-copy-accounts
...
feat(groups): 添加从其他分组复制账号功能
2026-02-03 08:45:13 +08:00
bayma888
606e29d390
feat(admin): add user balance/concurrency history modal
...
- Add new API endpoint GET /admin/users/:id/balance-history with pagination and type filter
- Add SumPositiveBalanceByUser for calculating total recharged amount
- Create UserBalanceHistoryModal component with:
- User info header (email, username, created_at, current balance, notes, total recharged)
- Type filter dropdown (all/balance/admin_balance/concurrency/admin_concurrency/subscription)
- Quick deposit/withdraw buttons
- Paginated history list with icons and colored values
- Add instant tooltip on balance column for better UX
- Add z-index prop to BaseDialog for modal stacking control
- Update i18n translations (zh/en)
2026-02-03 00:16:10 +08:00
song
3ecadf4aad
chore: apply stashed changes
2026-02-02 22:20:08 +08:00
song
0170d19fa7
merge upstream main
2026-02-02 22:13:50 +08:00
liuxiongfeng
e1a4a7b8c0
feat(groups): 添加从其他分组复制账号功能
...
- 创建分组时可选择从已有分组复制账号
- 编辑分组时支持同步账号(全量替换操作)
- 仅允许选择相同平台的源分组
- 添加完整的数据校验:去重、自引用检查、平台一致性检查
- 前端支持多选源分组,带提示说明操作行为
2026-02-02 21:47:47 +08:00
liuxiongfeng
45e1429ae8
feat(billing): 添加 Gemini 200K 长上下文双倍计费功能
...
- 新增 CalculateCostWithLongContext 方法支持阈值双倍计费
- 新增 RecordUsageWithLongContext 方法专用于 Gemini 计费
- Gemini 超过 200K token 的部分按 2 倍费率计算
- 其他平台(Claude/OpenAI)完全不受影响
2026-02-02 21:47:02 +08:00
Wesley Liddick
e204b4d81f
Merge pull request #452 from s-Joshua-s/feat/enhance-usage-endpoint
...
feat(gateway): 增强 /v1/usage 端点返回完整用量统计
2026-02-02 20:35:00 +08:00
Wesley Liddick
325ed747d8
Merge pull request #455 from ZeroClover/feat/ops-ignore-invalid-api-key-errors
...
feat(ops): 支持过滤无效 API Key 错误,不写入错误日志
2026-02-02 20:28:00 +08:00
Wesley Liddick
cbf3dba28d
Merge pull request #454 from ZeroClover/feat-exclude-user-inactive-errors
...
feat(ops): 将 USER_INACTIVE 错误排除在 SLA 统计之外
2026-02-02 20:19:48 +08:00
Wesley Liddick
4329f72abf
Merge pull request #450 from bayma888/feature/show-admin-adjustment-notes
...
feat: 向用户显示管理员调整余额的备注
2026-02-02 20:19:23 +08:00
Zero Clover
ad1cdba338
feat(ops): 支持过滤无效 API Key 错误,不写入错误日志
...
新增 IgnoreInvalidApiKeyErrors 开关,启用后 INVALID_API_KEY 和
API_KEY_REQUIRED 错误将被完全跳过,不写入 Ops 错误日志。
这些错误由用户错误配置导致,与服务质量无关。
2026-02-02 20:16:17 +08:00
Zero Clover
673caf41a0
feat(ops): 将 USER_INACTIVE 错误排除在 SLA 统计之外
...
将账户停用 (USER_INACTIVE) 导致的请求失败视为业务限制类错误,不计入 SLA 和错误率统计。
账户停用是预期内的业务结果,不应被视为系统错误或服务质量问题。此改动使错误分类更加准确,避免将预期的业务限制误报为系统故障。
修改内容:
- 在 classifyOpsIsBusinessLimited 函数中添加 USER_INACTIVE 错误码
- 该类错误不再触发错误率告警
Fixes Wei-Shaw/sub2api#453
2026-02-02 18:50:54 +08:00
JIA-ss
c441638fc0
feat(gateway): 增强 /v1/usage 端点返回完整用量统计
...
为 CC Switch 集成增强 /v1/usage 网关端点,在保持原有 4 字段
(isValid, planName, remaining, unit) 向后兼容的基础上,新增:
- usage 对象:今日/累计的请求数、token 用量、费用,以及 RPM/TPM
- subscription 对象(订阅模式):日/周/月用量和限额、过期时间
- balance 字段(余额模式):当前钱包余额
用量数据获取采用 best-effort 策略,失败不影响基础响应。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2026-02-02 18:30:06 +08:00
小北
ae18397ca6
feat: 向用户显示管理员调整余额的备注
...
- 为RedeemCode DTO添加notes字段(仅用于admin_balance/admin_concurrency类型)
- 更新mapper使其有条件地包含备注信息
- 在用户兑换历史UI中显示备注
- 备注以斜体显示,悬停时显示完整内容
用户现在可以看到管理员调整其余额的原因说明。
Changes:
- backend/internal/handler/dto/types.go: RedeemCode添加notes字段
- backend/internal/handler/dto/mappers.go: 条件性填充notes
- frontend/src/api/redeem.ts: TypeScript接口添加notes
- frontend/src/views/user/RedeemView.vue: UI显示备注信息
2026-02-02 17:44:50 +08:00
ducky
9bee0a2071
chore: gofmt for golangci-lint
2026-01-30 17:28:53 +08:00