shaw
a42a1f08e9
fix: 编辑error状态账号时保存报Status验证失败
...
后端UpdateAccountRequest.Status的oneof验证缺少error状态,
前端编辑表单也未处理error状态,导致编辑异常账号时无法保存
2026-03-07 13:47:08 +08:00
wioos
60fce4f1dc
fix: 修复 lite 模式跳过窗口费用查询导致 $0.00 显示的问题
...
commit 80ae592c 引入 lite 模式优化首次加载性能,但将窗口费用查询也一起跳过了。
commit 491a7444 尝试用 30 秒快照缓存修复,但缓存过期后问题复现。
移除窗口费用查询的 lite/非 lite 区分,始终执行 PostgreSQL 聚合查询。
同时删除不再需要的 account_window_cost_cache.go 文件。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-03-06 16:42:12 +08:00
shaw
491a744481
fix: 修复账号列表首次加载窗口费用显示 $0.00
...
lite 模式下从快照缓存读取窗口费用,非 lite 模式查询后写入缓存
2026-03-06 10:23:22 +08:00
Wesley Liddick
63a8c76946
Merge pull request #798 from touwaeriol/feature/account-load-factor
...
feat: add account load_factor for scheduling load calculation
2026-03-06 09:42:10 +08:00
erio
0d6c1c7790
feat: add independent load_factor field for scheduling load calculation
2026-03-06 05:07:10 +08:00
erio
05527b13db
feat: add quota limit for API key accounts
...
- Add configurable spending limit (quota_limit) for apikey-type accounts
- Atomic quota accumulation via PostgreSQL JSONB operations on TotalCost
- Scheduler filters out over-quota accounts with outbox-triggered snapshot refresh
- Display quota usage ($used / $limit) in account capacity column
- Add "Reset Quota" action in account menu to reset usage to zero
- Editing account settings preserves quota_used (no accidental reset)
- Covers all 3 billing paths: Anthropic, Gemini, OpenAI RecordUsage
chore: bump version to 0.1.90.4
2026-03-06 00:35:09 +08:00
shaw
078fefed03
fix: 修复账号管理页面容量列显示为0的bug
2026-03-05 09:48:00 +08:00
shaw
0819c8a51a
refactor: 消除重复的 normalizeAccountIDList,补充 PR#754 新增组件的单元测试
...
- 删除 account_today_stats_cache.go 中重复的 normalizeAccountIDList,统一使用 id_list_utils.go 的 normalizeInt64IDList
- 新增 snapshot_cache_test.go:覆盖 snapshotCache、buildETagFromAny、parseBoolQueryWithDefault
- 新增 id_list_utils_test.go:覆盖 normalizeInt64IDList、buildAccountTodayStatsBatchCacheKey
- 新增 ops_query_mode_test.go:覆盖 shouldFallbackOpsPreagg、cloneOpsFilterWithMode
2026-03-04 15:22:46 +08:00
xvhuan
80ae592c23
perf(admin): optimize large-dataset loading for dashboard/users/accounts/ops
2026-03-04 13:45:49 +08:00
erio
73089bbfdf
fix: display backend error message directly without i18n translation
2026-03-01 14:49:25 +08:00
erio
3a04552f98
fix: use i18n for mixed-channel warning messages and improve bulk pre-check
...
- BulkUpdate handler: add structured details to 409 response
- BulkUpdateAccounts: simplify to global pre-check before any DB write;
remove per-account snapshot tracking which is no longer needed
- MixedChannelError.Error(): restore English message for API compatibility
- BulkEditAccountModal: use t() with details for both pre-check and 409
fallback paths instead of displaying raw backend strings
- Update test to verify pre-check blocks on existing group conflicts
2026-03-01 14:39:07 +08:00
erio
7aa4c083a9
feat: bulk update accounts pre-check mixed channel risk with confirm dialog
...
- Move mixed channel check before any DB writes in BulkUpdateAccounts
- Return 409 from BulkUpdate handler for MixedChannelError
- Add ConfirmDialog to BulkEditAccountModal for mixed channel warning
- Update mixed channel warning message to Chinese
2026-03-01 14:25:02 +08:00
QTom
115d06edf0
fix: 修复 gofmt 格式问题
2026-02-28 20:38:35 +08:00
QTom
cd09adc3cc
fix: add sanitizeExtraBaseRPM to BatchCreate handler
...
Ensures base_rpm validation (clamp 0-10000) is consistent across
all four account mutation paths: Create, Update, BulkUpdate, BatchCreate.
2026-02-28 20:38:06 +08:00
QTom
2491e9b5ad
fix: round-3 review fixes for RPM limiting
...
- Add sanitizeExtraBaseRPM to BulkUpdate handler (was missing)
- Add WindowCost scheduling checks to legacy non-sticky selection
paths (4 sites), matching existing sticky + load-aware coverage
- Export ParseExtraInt from service package, remove duplicate
parseExtraIntForValidation from admin handler
2026-02-28 20:38:06 +08:00
QTom
e63c83955a
fix: address deep code review issues for RPM limiting
...
- Move IncrementRPM after Forward success to prevent phantom RPM
consumption during account switch retries
- Add base_rpm input sanitization (clamp to 0-10000) in Create/Update
- Add WindowCost scheduling checks to legacy path sticky sessions
(4 check sites + 4 prefetch sites), fixing pre-existing gap
- Clean up rpm_strategy/rpm_sticky_buffer when disabling RPM in
BulkEditModal (JSONB merge cannot delete keys, use empty values)
- Add json.Number test cases to TestGetBaseRPM/TestGetRPMStickyBuffer
- Document TOCTOU race as accepted soft-limit design trade-off
2026-02-28 20:38:06 +08:00
QTom
607237571f
fix: address code review issues for RPM limiting feature
...
- Use TxPipeline (MULTI/EXEC) instead of Pipeline for atomic INCR+EXPIRE
- Filter negative values in GetBaseRPM(), update test expectation
- Add RPM batch query (GetRPMBatch) to account List API
- Add warn logs for RPM increment failures in gateway handler
- Reset enableRpmLimit on BulkEditAccountModal close
- Use union type 'tiered' | 'sticky_exempt' for rpmStrategy refs
- Add design decision comments for rdb.Time() RTT trade-off
2026-02-28 20:37:37 +08:00
QTom
c1c31ed9b2
feat: wire RPMCache into GatewayService and AccountHandler
2026-02-28 20:35:38 +08:00
yangjianbo
bb664d9bbf
feat(sync): full code sync from release
2026-02-28 15:01:20 +08:00
cagedbird043
ba69736f55
refactor(admin): 测试连接模型列表改为复用 antigravity.DefaultModels,消除硬编码重复
2026-02-26 13:34:10 +08:00
cagedbird043
5d95e59742
fix(admin): 补全 antigravity 测试连接下拉框的 Gemini 模型列表
2026-02-25 18:51:47 +08:00
erio
aaac1aaca9
feat: add mixed-channel precheck API for account-group binding
...
Add a dedicated CheckMixedChannel endpoint that allows the frontend
to pre-validate mixed channel risk before submitting create/update
requests. This improves UX by showing warnings earlier in the flow
instead of only after form submission.
Backend changes:
- Add CheckMixedChannelRequest struct and CheckMixedChannel handler
- Register POST /check-mixed-channel route
- Expose CheckMixedChannelRisk as public method on AdminService
- Simplify Create/Update 409 responses (remove details/require_confirmation)
- Add comprehensive handler tests and stub methods
Frontend changes:
- Add checkMixedChannelRisk API function and TypeScript types
- Refactor CreateAccountModal to precheck before step transition and submission
- Refactor EditAccountModal to precheck before update submission
- Replace pendingPayload pattern with action-based dialog flow
2026-02-24 17:16:53 +08:00
yangjianbo
5fa45f3b8c
feat(idempotency): 为关键写接口接入幂等并完善并发容错
2026-02-23 12:45:37 +08:00
yangjianbo
987589eabc
Merge branch 'test' into release
2026-02-21 10:07:53 +08:00
yangjianbo
900cce20a1
feat(sora): 对齐 Sora OAuth 流程并隔离网关请求路径
...
- 新增并接通 Sora 专用 OAuth 接口与 ST/RT 换取能力
- 完成前端 Sora 授权、RT/ST 手动导入与账号创建流程
- 强化 Sora token 恢复、转发日志与网关路由隔离行为
- 补充后端服务层与路由层相关测试覆盖
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-19 08:02:56 +08:00
yangjianbo
41d0383fb7
merge(test): 合并 main 并解决前端筛选器冲突
2026-02-15 22:04:06 +08:00
程序猿MT
1cf51b14f7
Merge branch 'Wei-Shaw:main' into main
2026-02-15 20:49:14 +08:00
yangjianbo
06b0f62e79
feat(accounts): 自动刷新改为ETag增量同步并优化单账号更新体验
...
- 前端自动刷新改为 ETag/304 增量合并,减少全量重刷
- 单账号更新后增加静默窗口,避免刚更新即被自动刷新覆盖
- 列表筛选移除时改为待同步提示,不再立即触发全量补页
- 后端账号列表支持 If-None-Match,命中返回 304
- 单账号接口统一补充运行时容量字段并暴露 ETag 头
2026-02-14 13:22:51 +08:00
yangjianbo
9cafa46dd3
fix(accounts): 账号管理改为单行增量更新并避免全量刷新
...
- 将编辑与重新授权成功事件改为回传更新后的账号对象
- 在账号列表页按 id 就地补丁更新单行数据并保留运行时容量字段
- 单账号操作(刷新凭证/清错/清限流/临时不可调度重置)改为单行更新
- 后端增强 clear-rate-limit 接口,返回更新后的账号对象
- 同步前端 clearRateLimit API 类型定义
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-14 12:06:17 +08:00
kyx236
fe1d46a8ea
feat(admin): Add group filtering for account listings
...
- Add groupID parameter to ListAccounts and ListWithFilters methods
- Implement account filtering by group ID in repository query
- Add group query parameter parsing in account handler
- Update all ListAccounts/ListWithFilters call sites with groupID parameter
- Add group filter UI component to AccountTableFilters
- Add i18n translations for group filter label in English and Chinese
- Update API contract and test stubs to reflect new signature
- Enable filtering accounts by their assigned groups in admin panel
2026-02-12 03:47:06 +08:00
yangjianbo
d367d1cde6
Merge branch 'main' into test-sora
2026-02-09 20:40:09 +08:00
yangjianbo
16131c3d3f
Merge branch 'main' of https://github.com/mt21625457/aicodex2api
2026-02-09 20:26:03 +08:00
QTom
5e0d789440
feat(admin): 新增 CRS 同步预览和账号选择功能
...
- 后端新增 PreviewFromCRS 接口,允许用户先预览 CRS 中的账号
- 后端支持在同步时选择特定账号,不选中的账号将被跳过
- 前端重构 SyncFromCrsModal 为三步向导:输入凭据 → 预览账号 → 执行同步
- 改进表单无障碍性:添加 for/id 关联和 required 属性
- 修复 Back 按钮返回时的状态清理
- 新增 buildSelectedSet 和 shouldCreateAccount 的单元测试
- 完整的向后兼容性:旧客户端不发送 selected_account_ids 时行为不变
2026-02-09 10:39:09 +08:00
yangjianbo
4a20a2a8ba
fix: 修复批量更新凭证明细与缓存TTL抖动
...
- BatchUpdateCredentials 返回 success/failed/results 及 success_ids/failed_ids
- billing jitteredTTL 改为只减不增,确保TTL不超上界
- crypto/rand 失败时随机ID降级避免 panic
- OpenAI SelectAccount 失败日志去重并补充字段
- 修复两处类型断言以通过 errcheck
2026-02-07 21:18:03 +08:00
yangjianbo
a14dfb769a
Merge branch 'dev-release'
2026-02-07 19:58:00 +08:00
yangjianbo
2588fa6a8f
fix(audit): 第二批审计修复 — P0 生产 Bug、安全加固、性能优化、缓存一致性、代码质量
...
基于 backend-code-audit 审计报告,修复剩余 P0/P1/P2 共 34 项问题:
P0 生产 Bug:
- 修复 time.Since(time.Now()) 计时逻辑错误 (P0-03)
- generateRandomID 改用 crypto/rand 替代固定索引 (P0-04)
- IncrementQuotaUsed 重写为 Ent 原子操作消除 TOCTOU 竞态 (P0-05)
安全加固:
- gateway/openai handler 错误响应替换为泛化消息,防止内部信息泄露 (P1-14)
- usage_log_repo dateFormat 参数改用白名单映射,防止 SQL 注入 (P1-16)
- 默认配置安全加固:sslmode=prefer、response_headers=true、mode=release (P1-18/19, P2-15)
性能优化:
- gateway handler 循环内 defer 替换为显式 releaseWait 闭包 (P1-02)
- group_repo/promo_code_repo Count 前 Clone 查询避免状态污染 (P1-03)
- usage_log_repo 四个查询添加 LIMIT 10000 防止 OOM (P1-07)
- GetBatchUsageStats 添加时间范围参数,默认最近 30 天 (P1-10)
- ip.go CIDR 预编译为包级变量 (P1-11)
- BatchUpdateCredentials 重构为先验证后更新 (P1-13)
缓存一致性:
- billing_cache 添加 jitteredTTL 防止缓存雪崩 (P2-10)
- DeductUserBalance/UpdateSubscriptionUsage 错误传播修复 (P2-12)
- UserService.UpdateBalance 成功后异步失效 billingCache (P2-13)
代码质量:
- search 截断改为按 rune 处理,支持多字节字符 (P2-01)
- TLS Handshake 改为 HandshakeContext 支持 context 取消 (P2-07)
- CORS 预检添加 Access-Control-Max-Age: 86400 (P2-16)
测试覆盖:
- 新增 user_service_test.go(UpdateBalance 缓存失效 6 个用例)
- 新增 batch_update_credentials_test.go(fail-fast + 类型验证 7 个用例)
- 新增 response_transformer_test.go、ip_test.go、usage_log_repo_unit_test.go、search_truncate_test.go
- 集成测试:IncrementQuotaUsed 并发测试、billing_cache 错误传播测试
- config_test.go 补充 server.mode/sslmode 默认值断言
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-07 19:46:42 +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
LLLLLLiulei
b4bd46d067
feat: add data import/export bundle
2026-02-05 17:46:08 +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
song
64795a03e3
新增账号凭证邮箱查询接口
2026-01-20 14:17:10 +08:00
song
b9b4db3df5
Merge upstream/main
2026-01-17 18:00:07 +08:00
shaw
7379423325
feat: 添加5h窗口费用控制和会话数量限制
...
- 支持Anthropic OAuth/SetupToken账号的5h窗口费用阈值控制
- 支持账号级别的并发会话数量限制
- 使用Redis缓存窗口费用(30秒TTL)减少数据库压力
- 费用计算基于标准费用(不含账号倍率)
2026-01-16 23:36:52 +08:00
song
455576300c
fix(antigravity): 使用 Contains 匹配 missing_project_id 错误信息
2026-01-16 14:03:25 +08:00
song
821968903c
feat(antigravity): 手动刷新令牌时自动恢复 missing_project_id 错误账户状态
...
- 当手动刷新成功获取到 project_id,且之前错误为 missing_project_id 时,自动清除错误状态
- 后台自动刷新时同样支持状态恢复
2026-01-16 13:18:00 +08:00
song
95fe1e818f
fix: Antigravity 刷新 token 时检测 project_id 缺失
...
- 刷新 token 后调用 LoadCodeAssist 获取 project_id
- 如果获取失败,保留原有 project_id,标记账户为 error
- token 仍会正常更新,不影响凭证刷新
- 错误信息:账户缺少project id,可能无法使用Antigravity
2026-01-16 12:13:54 +08:00
墨颜
fb99ceacc7
feat(计费): 支持账号计费倍率快照与统计展示
...
- 新增 accounts.rate_multiplier(默认 1.0,允许 0)
- 使用 usage_logs.account_rate_multiplier 记录倍率快照,避免历史回算
- 统计/导出/管理端展示账号口径费用(total_cost * account_rate_multiplier)
2026-01-14 16:12:08 +08:00
IanShaw027
5e936fbf0e
feat(admin): 添加账号批量调度开关功能
...
- 后端:支持批量更新账号的 schedulable 字段
- 在 BulkUpdateAccountsRequest 中添加 schedulable 参数
- 在 AccountBulkUpdate 中添加 schedulable 字段支持
- 更新 repository 层批量更新 SQL 逻辑
- 前端:在账号管理页面添加批量调度控制
- 新增"批量启用调度"和"批量停止调度"按钮
- 添加 handleBulkToggleSchedulable 处理函数
- 显示具体的成功提示信息(包含操作账号数量)
- 国际化:添加批量调度相关中英文翻译
- 优化:添加 search 参数标准化和验证(account_handler)
2026-01-09 19:26:32 +08:00
LLLLLLiulei
2b528c5f81
feat: auto-pause expired accounts
2026-01-07 16:59:35 +08:00
song
195e227c04
merge: 合并 upstream/main 并保留本地图片计费功能
2026-01-06 10:49:26 +08:00