QTom
47a544230a
fix(privacy): 刷新令牌失败时也尝试设置 OpenAI 隐私模式
...
刷新失败不代表 access_token 无效,在后台定时刷新(不可重试错误 +
重试耗尽)和前端批量/单次刷新的失败路径中,均利用可能仍有效的
access_token 调用隐私设置。
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-03-27 14:51:36 +08:00
QTom
c13c81f09d
feat(privacy): 为 OpenAI OAuth 账号添加前端手动设置隐私按钮
...
复用已有的 set-privacy API 端点,Handler 通过 platform 分发到
ForceOpenAIPrivacy / ForceAntigravityPrivacy,前端 AccountActionMenu
扩展隐私按钮支持 OpenAI OAuth 账号。
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-03-27 14:51:36 +08:00
shaw
1854050df3
feat(tls-fingerprint): 新增 TLS 指纹 Profile 数据库管理及代码质量优化
...
新增功能:
- 新增 TLS 指纹 Profile CRUD 管理(Ent schema + 迁移 + Admin API + 前端管理界面)
- 支持账号绑定数据库中的自定义 TLS Profile,或随机选择(profile_id=-1)
- HTTPUpstream.DoWithTLS 接口从 bool 改为 *tlsfingerprint.Profile,支持按账号指定 Profile
- AccountUsageService 注入 TLSFingerprintProfileService,统一 usage 场景与网关的 Profile 解析逻辑
代码优化:
- 删除已被 TLSFingerprintProfileService 完全取代的 registry.go 死代码(418 行)
- 提取 3 个 dialer 的重复 TLS 握手逻辑为 performTLSHandshake() 共用函数
- 修复 GetTLSFingerprintProfileID 缺少 json.Number 处理的 bug
- gateway_service.Forward 中 ResolveTLSProfile 从重试循环内重复调用改为预解析局部变量
- 删除冗余的 buildClientHelloSpec() 单行 wrapper 和 int64(e.ID) 无效转换
- tls_fingerprint_profile_cache.go 日志从 log.Printf 改为 slog 结构化日志
- dialer_capture_test.go 添加 //go:build integration 标签,防止 CI 失败
- 去重 TestProfileExpectation 类型至共享 test_types_test.go
- 修复 9 个测试文件缺少 tlsfingerprint import 的编译错误
- 修复 error_policy_integration_test.go 中 handleError 回调签名被错误替换的问题
2026-03-27 14:33:05 +08:00
shaw
d571f300e5
feat(rectifier): 请求整流器增加 API Key 账号签名整流支持
...
新增独立开关控制 API Key 账号的签名整流功能,支持配置自定义
匹配关键词以捕获不同格式的上游错误响应。
- 新增 apikey_signature_enabled 开关(默认关闭)
- 新增 apikey_signature_patterns 自定义关键词配置
- 内置签名检测规则对 API Key 账号同样生效
- 自定义关键词对完整响应体做不区分大小写匹配
- 重试二阶段检测仅做模式匹配,不重复校验开关
- Handler 层校验关键词数量(≤50)和长度(≤500)
- API 响应 nil patterns 统一序列化为空数组
- OAuth/SetupToken/Upstream/Bedrock 账号行为不变
2026-03-26 16:43:38 +08:00
Wesley Liddick
f8b8b53985
Merge pull request #1299 from DaydreamCoding/feat/antigravity-privacy-and-subscription
...
feat(antigravity): 自动隐私设置 + 订阅状态检测
2026-03-26 11:30:24 +08:00
shaw
b20e142249
feat: 网关请求头 wire casing 保持、转发行为开关、调试日志增强及 accept-encoding 恢复
...
- 新增 header_util.go,通过 setHeaderRaw/getHeaderRaw/addHeaderRaw 绕过
Go 的 canonical-case 规范化,保持真实 Claude CLI 抓包的请求头大小写
(如 "x-app" 而非 "X-App","X-Stainless-OS" 而非 "X-Stainless-Os")
- 新增管理后台开关:指纹统一化(默认开启)和 metadata 透传(默认关闭),
使用 atomic.Value + singleflight 缓存模式,60s TTL
- 调试日志从控制台 body 打印升级为文件级完整快照
(按真实 wire 顺序输出 headers + 格式化 JSON body + 上下文元数据)
- 恢复 accept-encoding 到白名单,在 http_upstream.go 新增 decompressResponseBody
处理 gzip/brotli/deflate 解压(Go 显式设置 Accept-Encoding 时不会自动解压)
- OAuth 服务 axios UA 从 1.8.4 更新至 1.13.6
- 测试断言改用 getHeaderRaw 适配 raw header 存储方式
2026-03-26 11:17:25 +08:00
QTom
c2965c0fb0
feat(antigravity): 自动设置隐私并支持后台手动重试
...
新增 Antigravity OAuth 隐私设置能力,在账号创建、刷新、导入和后台
Token 刷新路径自动调用 setUserSettings + fetchUserInfo 关闭遥测;
持久化后同步内存 Extra,错误处理改为日志记录。
Made-with: Cursor
2026-03-25 17:38:41 +08:00
Wesley Liddick
8e834fd9f5
Merge pull request #1204 from Eilen6316/fix/smtp-config-stability-and-refresh-test
...
fix(settings): prevent SMTP config overwrite and stabilize SMTP test after refresh
2026-03-24 15:19:24 +08:00
Wesley Liddick
68d7ec9155
Merge pull request #1220 from weak-fox/feat/account-privacy-mode-filter
...
feat: 管理员账号列表支持按 Privacy 状态筛选
2026-03-24 15:18:30 +08:00
shaw
995bee143a
feat: 支持自定义端点配置与展示
2026-03-24 10:22:08 +08:00
weak-fox
4838ab74b3
feat(admin): add account privacy mode filter
2026-03-23 10:16:52 +08:00
Eilen6316
1fb29d59b7
fix(settings): prevent SMTP config overwrite and stabilize test after refresh
2026-03-21 23:36:30 +08:00
Wesley Liddick
3529148455
Merge pull request #1151 from DaydreamCoding/feat/admin-user-group-filter
...
feat(admin): 用户管理新增分组列、分组筛选与专属分组一键替换
2026-03-20 09:10:38 +08:00
shaw
01d8286bd9
feat: add max_claude_code_version setting and disable auto-upgrade env var
...
Add maximum Claude Code version limit to complement the existing minimum
version check. Refactor the version cache from single-value to unified
bounds struct (min+max) with a single atomic.Value and singleflight group.
- Backend: new constant, struct field, cache refactor, validation (semver
format + cross-validation max >= min), gateway enforcement, audit diff
- Frontend: settings UI input, TypeScript types, zh/en i18n
- Add CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 to all Claude Code
tutorials on /keys page (unix/cmd/powershell/vscode settings.json)
2026-03-20 09:10:01 +08:00
QTom
ba7d2aecbb
feat(admin): 用户管理新增分组列、分组筛选与专属分组一键替换
...
- 新增分组列:展示用户的专属/公开分组,支持 hover 查看详情
- 新增分组筛选:下拉选择或模糊搜索分组名过滤用户
- 专属分组替换:点击专属分组弹出操作菜单,选择目标分组后
自动授予新分组权限、迁移绑定的 Key、移除旧分组权限
- 后端新增 POST /admin/users/:id/replace-group 端点,事务内
完成分组替换并失效认证缓存
2026-03-19 22:27:55 +08:00
Wesley Liddick
dc447ccebe
Merge pull request #1153 from hging/main
...
feat: add ungrouped filter to account
2026-03-19 21:55:28 +08:00
shaw
525cdb8830
feat: Anthropic 账号被动用量采样,页面默认展示被动数据
...
从上游 /v1/messages 响应头被动采集 5h/7d utilization 并存储到
Account.Extra,页面加载时直接读取本地数据而非调用外部 Usage API。
用户可点击"查询"按钮主动拉取最新数据,主动查询结果自动回写被动缓存。
后端:
- UpdateSessionWindow 合并采集 5h + 7d headers 为单次 DB 写入
- 新增 GetPassiveUsage 从 Extra 构建 UsageInfo (复用 estimateSetupTokenUsage)
- GetUsage 主动查询后 syncActiveToPassive 回写被动缓存
- passive_usage_ 前缀注册为 scheduler-neutral
前端:
- Anthropic 账号 mount/refresh 默认 source=passive
- 新增"被动采样"标签和"查询"按钮 (带 loading 动画)
2026-03-19 17:42:59 +08:00
Hg
8027531d07
feat: add ungrouped filter to account
2026-03-19 15:42:21 +08:00
shaw
bf3d6c0e6e
feat: add 529 overload cooldown toggle and duration settings in admin gateway page
...
Move 529 overload cooldown configuration from config file to admin
settings UI. Adds an enable/disable toggle and configurable cooldown
duration (1-120 min) under /admin/settings gateway tab, stored as
JSON in the settings table.
When disabled, 529 errors are logged but accounts are no longer
paused from scheduling. Falls back to config file value when DB
is unreachable or settingService is nil.
2026-03-18 16:22:19 +08:00
Ethan0x0000
cfaac12af1
Merge upstream/main into pr/upstream-model-tracking
...
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent )
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai >
2026-03-18 14:16:50 +08:00
Wesley Liddick
6c02076333
Merge pull request #1106 from geminiwen/feat/subscription-platform-filter
...
feat: add platform type filter to subscription management
2026-03-18 11:32:35 +08:00
QTom
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
QTom
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
Gemini Wen
50a3c7fa0b
feat: add platform type filter to subscription management page
...
Add a platform filter dropdown to the admin subscriptions view, allowing
filtering subscriptions by platform (Anthropic, OpenAI, Gemini, etc.)
through the group association.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-03-18 09:23:19 +08:00
Ethan0x0000
eeff451bc5
test(backend): add tests for upstream model tracking and model source filtering
...
Cover IsValidModelSource/NormalizeModelSource, resolveModelDimensionExpression SQL expressions, invalid model_source 400 responses on both GetModelStats and GetUserBreakdown, upstream_model in scan/insert SQL mock expectations, and updated passthrough/billing test signatures.
2026-03-17 19:26:30 +08:00
Ethan0x0000
56fcb20f94
feat(api): expose model_source filter in dashboard endpoints
...
Add model_source query parameter to GetModelStats and GetUserBreakdown handlers with explicit IsValidModelSource validation. Include model_source in cache key to prevent cross-source cache hits. Expose upstream_model in usage log DTO with omitempty semantics.
2026-03-17 19:26:11 +08:00
Wesley Liddick
6cf77040e7
Merge pull request #1075 from touwaeriol/feat/dashboard-user-breakdown
...
feat(dashboard): add per-user drill-down for distribution charts
2026-03-17 09:25:43 +08:00
erio
e0286e5085
test(dashboard): add unit tests for user-breakdown API
...
Handler tests (9 cases): group_id/model/endpoint filters, default
endpoint_type, custom limit, limit clamping, response format,
empty result, no-filter pass-through.
Repository test: resolveEndpointColumn mapping for inbound/upstream/path.
2026-03-17 00:47:33 +08:00
erio
4b41e898a4
feat(dashboard): add per-user drill-down for group, model, and endpoint distributions
...
Click on a group name, model name, or endpoint name in the distribution
tables to expand and show per-user usage breakdown (requests, tokens,
actual cost, standard cost).
Backend: new GET /admin/dashboard/user-breakdown API with group_id,
model, endpoint, endpoint_type filters.
Frontend: clickable rows with expand/collapse sub-table in all three
distribution charts.
2026-03-17 00:47:20 +08:00
QTom
c1fab7f8d8
feat(backup): 备份/恢复异步化,解决 504 超时
...
POST /backups 和 POST /backups/:id/restore 改为异步:立即返回 HTTP 202,
后台 goroutine 独立执行 pg_dump → gzip → S3 上传,前端每 2s 轮询状态。
后端:
- 新增 StartBackup/StartRestore 方法,后台 goroutine 不依赖 HTTP 连接
- Graceful shutdown 等待活跃操作完成,启动时清理孤立 running 记录
- BackupRecord 新增 progress/restore_status 字段支持进度和恢复状态追踪
前端:
- 创建备份/恢复后轮询 GET /backups/:id 直到完成或失败
- 标签页切换暂停/恢复轮询,组件卸载清理定时器
- 正确处理 409(备份进行中)和轮询超时
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-03-16 20:22:10 +08:00
Wesley Liddick
94e067a2e2
Merge pull request #1040 from 0xObjc/codex/fix-user-spending-ranking-others
...
fix(admin): polish spending ranking and usage defaults
2026-03-16 09:19:46 +08:00
Peter
8147866c09
fix(admin): polish spending ranking and usage defaults
2026-03-16 00:17:47 +08:00
Ethan0x0000
c637e6cf31
fix: use half-open date ranges for DST-safe usage queries
...
Replace t.Add(24*time.Hour - time.Nanosecond) with t.AddDate(0, 0, 1) and use SQL < instead of <= for end-of-day boundaries. This avoids edge-case misses around DST transitions.
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode )
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai >
2026-03-15 22:13:12 +08:00
Wesley Liddick
7eb0415a8a
Merge pull request #1028 from IanShaw027/fix/open-issues-cleanup
...
fix: 修复多个issues - Gemini schema 兼容性、批量编辑白名单、Docker 工具支持和限额字段处理Fix/open issues cleanup
2026-03-15 19:09:49 +08:00
IanShaw027
686f890fbf
style: 修复 gofmt 格式问题
2026-03-15 18:42:32 +08:00
shaw
ae44a94325
fix: 重置密码功能新增UI配置发送邮件域名
2026-03-15 17:52:29 +08:00
IanShaw027
c31974c913
fix: 兼容部分限额字段为空的情况 #1021
...
修复在填写限额时,如果不填写完整的三个限额额度(日限额、周限额、月限额)就会报错的问题。
变更内容:
- 后端:添加 optionalLimitField 类型处理空值和空字符串,兼容部分限额字段为空的情况
- 前端:添加 normalizeOptionalLimit 函数规范化限额输入,将空值、空字符串和无效数字统一处理为 null
2026-03-15 17:46:58 +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
Wesley Liddick
a1dc00890e
Merge pull request #944 from miraserver/feat/backend-mode
...
feat: add Backend Mode toggle to disable user self-service
2026-03-14 17:53:54 +08:00
Rose Ding
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
SsageParuders
4644af2ccc
refactor: merge bedrock-apikey into bedrock with auth_mode credential
...
Consolidate two separate channel types (bedrock + bedrock-apikey) into
a single "AWS Bedrock" channel. Authentication mode is now distinguished
by credentials.auth_mode ("sigv4" | "apikey") instead of separate types.
Backend:
- Remove AccountTypeBedrockAPIKey constant
- IsBedrock() simplified; IsBedrockAPIKey() checks auth_mode
- Add IsAPIKeyOrBedrock() helper to eliminate repeated type checks
- Extend pool mode, quota scheduling, and billing to bedrock
- Add RetryableOnSameAccount to handleBedrockUpstreamErrors
- Add "bedrock" scope to Beta Policy for independent control
Frontend:
- Merge two buttons into one "AWS Bedrock" with auth mode radio
- Badge displays "Anthropic | AWS"
- Pool mode and quota limit UI available for bedrock
- Quota display in account list (usage bars, capacity badges, reset)
- Remove all bedrock-apikey type references
2026-03-14 17:13:30 +08:00
Wang Lvyuan
1d3d7a3033
fix: respect OpenAI model mapping in admin available models
2026-03-14 12:45:10 +08:00
Wesley Liddick
e6d59216d4
Merge pull request #975 from Ylarod/aws-bedrock
...
sub2api: add bedrock support
2026-03-14 10:52:24 +08:00
Wesley Liddick
4588258d80
Merge pull request #960 from 0xObjc/codex/user-spending-ranking
...
feat(admin): add user spending ranking dashboard view
2026-03-13 23:06:30 +08:00
erio
05edb5514b
feat(redeem): support subscription type in create-and-redeem API
...
Add group_id and validity_days fields to CreateAndRedeemCodeRequest,
enabling subscription-type redemption codes to be created and redeemed
in a single API call.
- Type defaults to "balance" when omitted for backward compatibility
- Subscription type requires group_id (non-nil) and validity_days (>0)
- Existing balance/concurrency callers are unaffected
2026-03-13 21:26:46 +08:00
Ylarod
11f7b83522
sub2api: add bedrock support
2026-03-13 17:00:16 +08:00
Wesley Liddick
1ee984478f
Merge pull request #957 from touwaeriol/feat/group-rate-multipliers-modal
...
feat(groups): add rate multipliers management modal
2026-03-13 11:11:13 +08:00
haruka
e73531ce9b
fix: 管理员重置配额补全 monthly 字段并修复 ristretto 缓存异步问题
...
- 后端 handler:ResetSubscriptionQuotaRequest 新增 Monthly 字段,
验证逻辑扩展为 daily/weekly/monthly 至少一项为 true
- 后端 service:AdminResetQuota 新增 resetMonthly 参数,
调用 ResetMonthlyUsage;重置后追加 subCacheL1.Wait(),
保证 ristretto Del() 的异步删除立即生效,消除重置后
/v1/usage 返回旧用量数据的竞态窗口
- 后端测试:更新存量测试用例匹配新签名,补充
TestAdminResetQuota_ResetMonthlyOnly /
TestAdminResetQuota_ResetMonthlyUsageError 两个新用例
- 前端 API:resetQuota options 类型新增 monthly: boolean
- 前端视图:confirmResetQuota 改为同时重置 daily/weekly/monthly
- i18n:中英文确认提示文案更新,提及每月配额
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-03-13 10:39:35 +08:00
Rose Ding
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
Peter
80d8d6c3bc
feat(admin): add user spending ranking dashboard view
2026-03-13 03:43:03 +08:00