Commit Graph
377 Commits
Author SHA1 Message Date
erio 1d946b3847 Merge upstream v0.1.102 into release/custom-0.1.102 2026-03-18 12:11:03 +08:00
QTomandClaude Opus 4.6 d4cc9871c4 feat(admin): 分组管理新增容量列(并发/会话/RPM 实时聚合)
复用 GroupCapacityService,在 admin 分组列表中添加容量列,
显示每个分组的实时并发/会话/RPM 使用量和上限。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-18 10:06:35 +08:00
QTomandClaude Opus 4.6 961c30e7c0 feat(admin): 分组管理列表新增用量列与账号数分类
分组管理列表增强:

1. 今日/累计用量列:
   - 新增独立端点 GET /admin/groups/usage-summary
   - 一次查询返回所有分组的今日费用和累计费用(actual_cost)
   - 前端异步加载后合并显示在分组列表中

2. 账号数区分可用/限流/总量:
   - 将账号数列从单一总量改为 badge 内多行展示
   - 可用: active + schedulable 的账号数(绿色)
   - 限流: rate_limit/overload/temp_unschedulable 的账号数(橙色,无限流时隐藏)
   - 总量: 全部关联账号数

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-18 10:06:35 +08:00
erio 44ec2626cf feat: add affinity scheduling controls 2026-03-18 04:08:45 +08:00
erio 338e3df8d9 chore: bump version to 0.1.101.3 2026-03-17 01:17:07 +08:00
erio d79ec88d9c chore: bump version to 0.1.101.2 2026-03-16 22:12:54 +08:00
erio 5fd19b856b chore: bump version to 0.1.101.1 2026-03-16 18:19:43 +08:00
erio 897c93528d feat: optimize Antigravity AI Credits scheduling - use AICredits rate limit key
Replace sync.Map + per-model runtime state with a single AICredits key in
model_rate_limits. Rate-limited accounts with available credits are now
scheduled directly and credits injected without a 429 round trip.

- Scheduler: rate-limited + overages + credits available = allow scheduling
- Forwarding: inject credits proactively when model rate limited
- Storage: credits exhaustion stored as model_rate_limits["AICredits"]
- Frontend: show credits_active (yellow ⚡) vs credits_exhausted states
- Bump version to 0.1.100.4
2026-03-16 03:51:34 +08:00
erio 0158cb8aa8 chore: bump version to 0.1.100.3 2026-03-16 02:11:09 +08:00
erio 1fc9dd7b68 feat: unified OAuth token refresh API with distributed locking
Introduce OAuthRefreshAPI as the single entry point for all OAuth token
refresh operations, eliminating the race condition where background
refresh and inline refresh could simultaneously use the same
refresh_token (fixes #1035).

Key changes:
- Add OAuthRefreshExecutor interface extending TokenRefresher with CacheKey
- Add OAuthRefreshAPI.RefreshIfNeeded with lock → DB re-read → double-check flow
- Add ProviderRefreshPolicy / BackgroundRefreshPolicy strategy types
- Simplify all 4 TokenProviders to delegate to OAuthRefreshAPI
- Rewrite TokenRefreshService.refreshWithRetry to use unified API path
- Add MergeCredentials and BuildClaudeAccountCredentials helpers
- Add 40 unit tests covering all new and modified code paths
2026-03-16 01:31:54 +08:00
erio d844f3b6b5 feat: unified OAuth token refresh API to fix refresh_token race condition (#1035)
Introduce OAuthRefreshAPI as the single entry point for all OAuth token
refresh operations (both background TokenRefreshService and inline
TokenProvider), eliminating the race condition where two independent
refresh paths consume the same one-time-use refresh_token.

Key changes:
- New OAuthRefreshAPI with distributed lock + DB re-read + double-check
- All 4 platform refreshers implement OAuthRefreshExecutor (CacheKey)
- TokenRefreshService and TokenProviders share the same lock key
- Add errRefreshSkipped sentinel for accurate refresh statistics
- 7 new Path A unit tests covering all RefreshIfNeeded branches

chore: bump version to 0.1.100.2
2026-03-16 01:00:20 +08:00
erio fa7d5be25b chore: bump version to 0.1.100.1 2026-03-15 20:08:25 +08:00
erio 8688e4b78e chore: bump version to 0.1.99.7 2026-03-15 19:26:04 +08:00
erio ccffa0640a chore: bump version to 0.1.99.6 2026-03-15 19:05:13 +08:00
erio 3caa91985c chore: bump version to 0.1.99.5 2026-03-15 18:44:38 +08:00
erio 9f573fed55 chore: bump version to 0.1.99.4 2026-03-15 17:42:18 +08:00
erio 77a9b4f420 chore: bump version to 0.1.99.3 2026-03-15 17:35:10 +08:00
erio 7a5b9cffe5 chore: bump version to 0.1.99.2 2026-03-14 22:51:41 +08:00
erio 085c0d7e17 chore: bump version to 0.1.99.1 2026-03-14 21:03:20 +08:00
erio 25a0030450 Merge branch 'main' into release/custom-0.1.99
# Conflicts:
#	backend/cmd/server/wire_gen.go
#	backend/cmd/server/wire_gen_test.go
#	backend/internal/handler/dto/mappers.go
#	backend/internal/service/ratelimit_service.go
#	backend/internal/service/ratelimit_service_401_db_fallback_test.go
#	backend/internal/service/ratelimit_service_401_test.go
#	frontend/src/components/account/AccountCapacityCell.vue
#	frontend/src/components/account/CreateAccountModal.vue
#	frontend/src/components/account/EditAccountModal.vue
#	frontend/src/views/admin/DataManagementView.vue
2026-03-14 21:03:09 +08:00
Wesley Liddick aa4e37d085 Merge pull request #966 from GuangYiDing/feat/db-backup-restore
feat: 数据库定时备份与恢复(S3 兼容存储,支持 Cloudflare R2)
2026-03-14 18:58:56 +08:00
Rose DingandClaude Opus 4.6 1047f973d5 fix: 按 review 意见重构数据库备份服务(安全性 + 架构 + 健壮性)
1. S3 凭证加密存储:使用 SecretEncryptor (AES-256-GCM) 加密 SecretAccessKey,
   防止备份文件中泄露 S3 凭证,兼容旧的未加密数据
2. 修复 saveRecord 竞态条件:添加 recordsMu 互斥锁保护 records 的 load/save
3. 恢复操作增加服务端验证:handler 层要求重新输入管理员密码,通过 bcrypt
   校验,前端弹出密码输入框
4. pg_dump/psql/S3 操作抽象为接口:定义 DBDumper 和 BackupObjectStore 接口,
   实现放入 repository 层,遵循项目依赖注入架构规范
5. 改为流式处理避免大数据库 OOM:备份时 pg_dump stdout -> gzip -> io.Pipe ->
   S3 upload;恢复时 S3 download -> gzip reader -> psql stdin,不再全量加载
6. loadRecords 区分"无数据"和"数据损坏"场景:JSON 解析失败返回明确错误
7. 添加 18 个核心逻辑单元测试:覆盖加密、并发、流式备份/恢复、错误处理等

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-14 17:48:21 +08:00
erio 11cb34e56e chore: bump version to 0.1.98.1 2026-03-14 14:10:40 +08:00
erio 4e149109de chore: bump version to 0.1.97.1 2026-03-14 14:07:42 +08:00
erio 5e0a508eca Merge branch 'main' into release/custom-0.1.97
# Conflicts:
#	README.md
#	README_CN.md
#	backend/internal/handler/gateway_handler.go
#	backend/internal/repository/user_group_rate_repo.go
#	backend/internal/service/admin_service_group_rate_test.go
#	backend/internal/service/gateway_service.go
#	frontend/src/components/account/CreateAccountModal.vue
#	frontend/src/views/admin/AccountsView.vue
2026-03-14 14:07:05 +08:00
Wesley Liddick 07bb2a5f3f Merge pull request #952 from xvhuan/feat/billing-ledger-decouple-usage-log-20260312
feat: 解耦计费正确性与 usage_logs 批量写压
2026-03-13 22:46:09 +08:00
erio 7ab8181436 feat(redeem): support subscription type in create-and-redeem API
Add group_id and validity_days fields to CreateAndRedeemCodeRequest for
subscription redemption. Type defaults to "balance" for backward
compatibility with existing callers that don't send the type field.
2026-03-13 21:16:00 +08:00
erio 9618518680 chore: bump version to 0.1.96.10 2026-03-13 19:37:14 +08:00
Rose DingandClaude Opus 4.6 875b417fde fix: 补充 wire_gen_test.go 中 provideCleanup 缺少的 backupSvc 参数
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 11:53:46 +08:00
Rose DingandClaude Opus 4.6 53ad1645cf feat: 数据库定时备份与恢复(S3 兼容存储,支持 Cloudflare R2)
新增管理员专属的数据库备份与恢复功能:
- 全量 PostgreSQL 备份(pg_dump),gzip 压缩后上传到 S3 兼容存储
- 支持手动备份和 cron 定时备份
- 支持从备份恢复(psql --single-transaction)
- 备份文件自动过期清理(默认 14 天)
- 前端完整管理页面(S3 配置、定时配置、备份列表、恢复/下载/删除)
- 内置 Cloudflare R2 配置教程弹窗
- Dockerfile 从 postgres 镜像多阶段复制 pg_dump/psql,确保版本一致

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 10:38:19 +08:00
erio bf91dfe2fe chore: remove clear-all confirm dialog, bump to 0.1.96.9 2026-03-12 23:00:16 +08:00
erio 0c5ddb127b feat(groups): improve rate modal bottom bar with revert and close buttons
- Always show close button at bottom
- Add "revert changes" link when dirty
- Save now closes dialog on success
- Button styles match group edit dialog

chore: bump version to 0.1.96.8
2026-03-12 22:36:43 +08:00
erio 045e1eb50d chore: bump version to 0.1.96.7 2026-03-12 22:26:51 +08:00
erio c226438a04 merge: integrate release/custom-0.1.94 customizations into 0.1.96
Recovers features lost during 0.1.91->0.1.95 merge (0.1.92-0.1.94
customizations were skipped because main branch was not updated).

Recovered features:
- Antigravity 403 forbidden/validation/ban status detection and display
- Subscription tier badge in account list
- Client affinity scheduling for Anthropic accounts
- Sora async task API and GDrive storage backend
- Swipe-to-select for admin tables
- OpenAI passthrough account selection fix
- Various quota and usage enhancements
2026-03-12 22:23:31 +08:00
QTom a63de12182 feat: GPT 隐私模式 + no-train 前端展示优化 2026-03-12 21:24:01 +08:00
erio 034deebb2f feat(groups): add platform brand colors to rate multipliers modal icon
chore: bump version to 0.1.96.6
2026-03-12 20:51:56 +08:00
erio fe4468516f feat(groups): local edit mode with cancel/save for rate multipliers
- Rate column is now editable input (local state, not auto-saved)
- Add/delete/clear-all are local operations until Save is clicked
- Batch adjust shows "最终倍率" preview column before applying
- Bottom cancel/save bar appears when there are unsaved changes
- Save sends all entries at once via batch API
2026-03-12 20:24:37 +08:00
erio 979e1c1bf5 feat(groups): batch adjust rate multipliers with global factor
- Add PUT /admin/groups/:id/rate-multipliers batch endpoint
- Add batch adjust UI: multiply all rates by a factor (e.g., ×0.5 to halve, ×2 to restore)
- Remove inline rate editing (blur-save), rates now display as read-only
- Backend: SyncGroupRateMultipliers repo method (delete + batch upsert)
2026-03-12 19:57:12 +08:00
erio 5e98771cf7 feat(groups): move clear-all button, always show pagination
- Move clear-all button next to add button
- Always show pagination bar (not hidden when entries <= pageSize)
- Change page size options to 10/20/50, default 10
2026-03-12 19:25:28 +08:00
erio b148e11d6c feat(groups): improve rate multipliers modal UI
- Move email column to first position
- Add sticky table header with scrollable body
- Add page size selector (20/50/100)
- Use ConfirmDialog for clear all confirmation
- Disable browser autocomplete on inputs
- Enlarge clear all button styling
2026-03-12 19:16:03 +08:00
erio cdddbec629 chore: bump version to 0.1.96.1 2026-03-12 18:13:28 +08:00
ius 611fd884bd feat: decouple billing correctness from usage log batching 2026-03-12 16:53:18 +08:00
erio 5f6e929d61 chore: bump version to 0.1.95.1 2026-03-11 03:24:05 +08:00
erio 4caa3c2701 merge: integrate upstream v0.1.95 with our customizations
Merge main (custom features) into release/custom-0.1.95 (upstream v0.1.95).
New upstream features: group subscription binding, multi-dimension quota (daily/weekly/total),
allow_messages_dispatch, default_mapped_model, recover state API.
Our customizations: simulate_claude_max_enabled, usage status detection, 403 validation handling.
2026-03-11 03:23:44 +08:00
erio d67b560c57 chore: bump version to 0.1.94.6 2026-03-10 18:23:40 +08:00
erio 7b3df5b807 chore: bump version to 0.1.94.5 2026-03-10 18:09:11 +08:00
erio e2b9c40093 feat(antigravity): add usage status detection and 403 validation block
- Add needs_verify, is_banned, needs_reauth, error_code fields to UsageInfo
  for Antigravity accounts (omitempty ensures zero impact on other platforms)
- Add singleflight dedup for Antigravity usage requests with independent
  context to prevent caller cancel cascade
- Return degraded UsageInfo with error_code instead of HTTP 500 on errors
- Differentiate cache TTL: success/403 → 3min, recoverable errors → 1min
- Add 403 validation_block: Antigravity validation-type 403 triggers
  temp_unschedulable (10min auto-recovery) instead of permanent SetError
- Frontend: display needs_reauth and degraded error states in usage cell
- Bump version to 0.1.94.4
2026-03-10 14:01:03 +08:00
Wesley Liddick 3cc407bc0e Merge pull request #900 from ischanx/feat/admin-bind-subscription-group
feat: 允许管理员为持有有效订阅的用户绑定订阅类型分组
2026-03-10 11:20:47 +08:00
Wesley Liddick ac6bde7a98 Merge pull request #872 from StarryKira/fix/oauth-linuxdo-invitation-required
fix: Linux.do OAuth 注册支持邀请码两步流程 (fix #836)
2026-03-10 09:10:35 +08:00
ischanxandClaude Opus 4.6 767a41e263 feat: 允许管理员为持有有效订阅的用户绑定订阅类型分组
之前管理员无法通过 API 密钥管理将用户绑定到订阅类型分组(直接返回错误)。
现在改为检查用户是否持有该分组的有效订阅,有则允许绑定,无则拒绝。

- admin_service: 新增 userSubRepo 依赖,替换硬拒绝为订阅校验
- admin_service: 区分 ErrSubscriptionNotFound 和内部错误,避免 DB 故障被误报
- wire_gen/api_contract_test: 同步新增参数
- UserApiKeysModal: 管理员分组下拉不再过滤订阅类型分组

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 00:51:43 +08:00