1. 23 Apr, 2026 1 commit
    • erio's avatar
      fix(channel-monitor): drop soft delete, refactor feature flag to declarative form · ef6ec8a1
      erio authored
      ### 后端修复:日志表不该用软删除
      
      channel_monitor_histories / channel_monitor_daily_rollups 都是日志/聚合表,
      没有恢复需求。110 里加的 SoftDeleteMixin 会让 DELETE 自动变成 UPDATE deleted_at,
      导致行和索引只增不减,徒增磁盘占用和查询成本。
      
      改回分批物理删(参考 OpsCleanupService.deleteOldRowsByID 模板):
      
      - ent schema 移除 SoftDeleteMixin,重新 go generate
      - repo 新增 deleteChannelMonitorBatched 辅助 + 两条 prune SQL 常量
        (WITH batch AS SELECT id LIMIT 5000 → DELETE IN batch)
      - DeleteHistoryBefore / DeleteRollupsBefore 改调分批 raw SQL
      - 移除 ComputeAvailability / ComputeAvailabilityForMonitors / UpsertDailyRollupsFor /
        ListLatestPerModel / ListLatestForMonitorIDs / ListRecentHistoryForMonitors 等
        raw SQL 中的 deleted_at IS NULL 过滤
      - UpsertDailyRollupsFor 的 ON CONFLICT 去掉 deleted_at = NULL 重置
      - migration 111 DROP COLUMN deleted_at + 对应索引(110 已部署但 maintenance
        首跑在次日 02:00,此时尚无业务数据在依赖软删除)
      
      ### 前端重构:feature flag 声明式 + 复用
      
      AppSidebar.vue 里 7 处 `...(flag ? [item] : [])` 样板代码删光,改为 NavItem 加
      featureFlag?: () => boolean | undefined 字段,加一个 applyFeatureFlags 递归
      过滤(含 children)。语义统一为 `!== false`(宽容策略,undefined 时默认显示,
      避免 public settings 未加载完成时菜单闪烁消失 — 对应用户反馈"刷新后菜单消失
      要去保存设置才回来")。
      
      - 集中声明 4 个 flag getter:flagChannelMonitor / flagPayment /
        flagOpsMonitoring / flagAdminPayment
      - 提取 buildSelfNavItems 复用用户端主菜单和管理员"我的账户"子菜单
      - 未来新增开关:在统一位置加一个 flag getter + 给对应 NavItem 加字段
        (不用再动渲染逻辑)
      
      bump 0.1.114.29
      ef6ec8a1
  2. 21 Apr, 2026 1 commit
    • erio's avatar
      feat(channel-monitor): aggregate history to daily rollups + soft delete · 8cf83c98
      erio authored
      明细只保留 1 天,超过 1 天聚合到新表 channel_monitor_daily_rollups(按
      monitor_id/model/bucket_date 维度),聚合保留 30 天。两张表都用 SoftDeleteMixin
      软删除(DELETE 自动改为 UPDATE deleted_at = NOW())。
      
      聚合 + 清理任务由 OpsCleanupService 的 cron 统一调度,与运维监控的清理共享
      schedule(默认 0 2 * * *)和 leader lock。ChannelMonitorRunner 的 cleanupLoop
      被移除,只保留 dueCheckLoop。
      
      读取路径 ComputeAvailability* 改为 UNION 明细(今天 deleted_at IS NULL)+
      聚合(过去 windowDays 天 deleted_at IS NULL),SUM(ok)/SUM(total) 自然加权
      计算可用率,AVG latency 用 SUM(sum_latency_ms)/SUM(count_latency)。
      
      watermark 表 channel_monitor_aggregation_watermark 单行(id=1),记录
      last_aggregated_date,重启后从该日期 +1 继续聚合,首次为 nil 则从
      today - 30d 开始回填,单次最多 35 天上限避免长事务。
      
      raw SQL 的 ListLatestPerModel / ListLatestForMonitorIDs / ListRecentHistoryForMonitors
      都补上 deleted_at IS NULL 过滤(SoftDeleteMixin interceptor 只对 ent query 生效)。
      
      bump version to 0.1.114.28
      
      GroupBadge 在 MonitorKeyPickerDialog 中复用平台主题色 + 倍率/专属倍率
      (顺手优化)。
      8cf83c98
  3. 20 Apr, 2026 1 commit
    • erio's avatar
      feat(monitor): admin channel monitor MVP with SSRF protection and batch aggregation · 20a4e418
      erio authored
      新增 admin「渠道监控」模块(参考 BingZi-233/check-cx),独立于现有 Channel 体系。
      admin 配置 + 后台定时调用上游 LLM chat completions 健康检查 + 所有登录用户只读可见。
      
      后端:
      - ent: channel_monitor + channel_monitor_history(AES-256-GCM 加密 api_key)
      - service 按职责拆分:service/aggregator/validate/checker/runner/ssrf
      - provider strategy map 替代 switch(openai/anthropic/gemini)
      - repository batch 聚合(ListLatestForMonitorIDs + ComputeAvailabilityForMonitors)消除 N+1
      - runner: ticker(5s) + pond worker pool(5) + inFlight 防并发 + TrySubmit 防雪崩
        + 凌晨 3 点 cron 清理 30 天历史
      - SSRF 防护:强制 https + 私网/loopback/云元数据 IP 拒绝(127/8、10/8、172.16/12、
        192.168/16、169.254/16、100.64/10、::1、fc00::/7、fe80::/10)+ DialContext
        在 socket 层防 DNS rebinding
      - API key sanitize:擦除 url.Error 与上游响应 body 中的 sk-/sk-ant-/AIza/JWT 模式
      - APIKeyDecryptFailed 标志位 + 单 monitor 路径检测,避免空 key 调用上游
      
      handler:
      - admin: CRUD + 手动触发 + 历史接口(api_key 脱敏)
      - user: 只读列表 + 状态详情(去除 api_key/endpoint)
      - ParseChannelMonitorID 共用 + dto.ChannelMonitorExtraModelStatus 共用
      
      前端:
      - 路由 /admin/channels/{pricing,monitor} + /monitor(用户只读)
      - AppSidebar 父项 expandOnly 支持
      - ChannelMonitorView 拆为 8 个子组件 + ChannelStatusView 拆出 detail dialog
      - composables/useChannelMonitorFormat + constants/channelMonitor 共享
      - i18n monitorCommon namespace 消除 admin/user 两 view 重复
      
      合规:所有文件符合 CLAUDE.md(Go ≤ 500 行 / Vue ≤ 300 行 / 函数 ≤ 30 行)
      CI: go build / gofmt / golangci-lint(0 issues) / make test-unit / pnpm build 全绿
      20a4e418
  4. 21 Apr, 2026 1 commit
  5. 20 Apr, 2026 2 commits
  6. 14 Apr, 2026 3 commits
    • erio's avatar
      feat: add per-provider allow_user_refund control and align wildcard matching · f1297a36
      erio authored
      allow_user_refund:
      - Add allow_user_refund field to PaymentProviderInstance ent schema
      - Migration 103: ALTER TABLE payment_provider_instances ADD COLUMN
      - Cascade logic: disabling refund_enabled auto-disables allow_user_refund
      - User refund validation: check provider instance allows user refund
      - Admin refund validation: check provider instance allows admin refund
      - Subscription refund: deduct days on refund, rollback on failure
      - New endpoint: GET /payment/orders/refund-eligible-providers
      - Frontend: ToggleSwitch in ProviderCard/Dialog, cascade in SettingsView
      
      Wildcard matching:
      - Change findPricingForModel from "longest prefix wins" to "config order
        priority (first match wins)", aligning with channel service behavior
      f1297a36
    • erio's avatar
      feat(notify): add percentage threshold type for balance low notification · f694afbb
      erio authored
      - Add threshold_type field (fixed/percentage) to system and user settings
      - Add total_recharged field to users table, auto-incremented on balance credit
      - Percentage mode: effective threshold = total_recharged × percentage / 100
      - User-level threshold_type inherits from system default when not set
      - Update admin settings UI with radio selector (fixed amount / percentage)
      - Migration: 102_add_balance_notify_threshold_type.sql
      f694afbb
    • erio's avatar
      feat(notify): add balance low & account quota notification system · b32d1a2c
      erio authored
      - User balance low notification: email alert when balance drops below
        configurable threshold (user email + verified extra emails)
      - Account quota notification: broadcast email to admin-configured
        recipients when daily/weekly/total quota usage exceeds alert threshold
      - Admin settings: global enable/disable, default threshold, quota
        notification email list (Email Settings tab)
      - User profile: enable/disable, custom threshold, add/remove extra
        notification emails with verification code flow
      - Account quota: per-dimension alert toggle and threshold in quota
        control card
      - Trigger logic: first-crossing only (old >= threshold && new < threshold
        for balance; old < threshold && new >= threshold for quota), naturally
        prevents duplicate notifications without Redis dedup
      b32d1a2c
  7. 11 Apr, 2026 1 commit
  8. 09 Apr, 2026 1 commit
  9. 05 Apr, 2026 1 commit
  10. 04 Apr, 2026 1 commit
  11. 31 Mar, 2026 1 commit
  12. 27 Mar, 2026 1 commit
    • shaw's avatar
      feat(tls-fingerprint): 新增 TLS 指纹 Profile 数据库管理及代码质量优化 · 1854050d
      shaw authored
      新增功能:
      - 新增 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 回调签名被错误替换的问题
      1854050d
  13. 20 Mar, 2026 1 commit
  14. 17 Mar, 2026 1 commit
    • Ethan0x0000's avatar
      feat(db): add upstream_model column to usage_logs · 51547fa2
      Ethan0x0000 authored
      Add nullable VARCHAR(100) column to record the actual model sent to upstream providers when model mapping is applied. NULL means no mapping — the requested model was used as-is.
      
      Includes migration, concurrent index for aggregation queries, Ent schema regeneration, and migration README correction (forward-only runner, not goose).
      51547fa2
  15. 07 Mar, 2026 2 commits
  16. 05 Mar, 2026 1 commit
  17. 03 Mar, 2026 1 commit
  18. 28 Feb, 2026 1 commit
  19. 22 Feb, 2026 1 commit
  20. 17 Feb, 2026 1 commit
  21. 12 Feb, 2026 1 commit
  22. 10 Feb, 2026 1 commit
  23. 08 Feb, 2026 1 commit
    • bayma888's avatar
      feat(admin): add drag-and-drop group sort order · bac9e2bf
      bayma888 authored
      - Add `sort_order` field to groups table with migration
      - Add `PUT /api/v1/admin/groups/sort-order` API for batch update
      - Implement drag-and-drop UI using vue-draggable-plus
      - All queries now order groups by sort_order
      - Add i18n support (en/zh) for sort-related UI text
      - Update test stubs to satisfy new interface methods
      bac9e2bf
  24. 05 Feb, 2026 1 commit
    • shaw's avatar
      feat: 新增全局错误透传规则功能 · 39e05a2d
      shaw authored
      支持管理员配置上游错误如何返回给客户端:
      - 新增 ErrorPassthroughRule 数据模型和 Ent Schema
      - 实现规则的 CRUD API(/admin/error-passthrough-rules)
      - 支持按错误码、关键词匹配,支持 any/all 匹配模式
      - 支持按平台过滤(anthropic/openai/gemini/antigravity)
      - 支持透传或自定义响应状态码和错误消息
      - 实现两级缓存(Redis + 本地内存)和多实例同步
      - 集成到 gateway_handler 的错误处理流程
      - 新增前端管理界面组件
      - 新增单元测试覆盖核心匹配逻辑
      
      优化:
      - 移除 refreshLocalCache 中的冗余排序(数据库已排序)
      - 后端 Validate() 增加匹配条件非空校验
      39e05a2d
  25. 03 Feb, 2026 1 commit
    • bayma888's avatar
      feat(api-key): add independent quota and expiration support · 6146be14
      bayma888 authored
      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
      6146be14
  26. 02 Feb, 2026 2 commits
  27. 31 Jan, 2026 1 commit
  28. 30 Jan, 2026 1 commit
    • ducky's avatar
      feat(announcements): add admin/user announcement system · b7f69844
      ducky authored
      Implements announcements end-to-end (admin CRUD + read status, user list + mark read) with OR-of-AND targeting. Also breaks the ent<->service import cycle by moving schema-facing constants/targeting into a new domain package.
      b7f69844
  29. 29 Jan, 2026 1 commit
    • yangjianbo's avatar
      feat(sora): 新增 Sora 平台支持并修复高危安全和性能问题 · 13262a56
      yangjianbo authored
      
      
      新增功能:
      - 新增 Sora 账号管理和 OAuth 认证
      - 新增 Sora 视频/图片生成 API 网关
      - 新增 Sora 任务调度和缓存机制
      - 新增 Sora 使用统计和计费支持
      - 前端增加 Sora 平台配置界面
      
      安全修复(代码审核):
      - [SEC-001] 限制媒体下载响应体大小(图片 20MB、视频 200MB),防止 DoS 攻击
      - [SEC-002] 限制 SDK API 响应大小(1MB),防止内存耗尽
      - [SEC-003] 修复 SSRF 风险,添加 URL 验证并强制使用代理配置
      
      BUG 修复(代码审核):
      - [BUG-001] 修复 for 循环内 defer 累积导致的资源泄漏
      - [BUG-002] 修复图片并发槽位获取失败时已持有锁未释放的永久泄漏
      
      性能优化(代码审核):
      - [PERF-001] 添加 Sentinel Token 缓存(3 分钟有效期),减少 PoW 计算开销
      
      技术细节:
      - 使用 io.LimitReader 限制所有外部输入的大小
      - 添加 urlvalidator 验证防止 SSRF 攻击
      - 使用 sync.Map 实现线程安全的包级缓存
      - 优化并发槽位管理,添加 releaseAll 模式防止泄漏
      
      影响范围:
      - 后端:新增 Sora 相关数据模型、服务、网关和管理接口
      - 前端:新增 Sora 平台配置、账号管理和监控界面
      - 配置:新增 Sora 相关配置项和环境变量
      Co-Authored-By: default avatarClaude Sonnet 4.5 <noreply@anthropic.com>
      13262a56
  30. 27 Jan, 2026 1 commit
    • song's avatar
      feat(group): 添加 MCP XML 注入开关 · 877c1725
      song authored
      - Group 新增 mcp_xml_inject 字段,控制 Antigravity 平台的 MCP XML 协议注入
      - 默认启用,可在分组设置中关闭
      - 修复 GetByKeyForAuth 遗漏查询 mcp_xml_inject 字段导致认证缓存值始终为 false 的问题
      877c1725
  31. 26 Jan, 2026 1 commit
    • shaw's avatar
      feat(auth): 实现 TOTP 双因素认证功能 · 1245f07a
      shaw authored
      新增功能:
      - 支持 Google Authenticator 等应用进行 TOTP 二次验证
      - 用户可在个人设置中启用/禁用 2FA
      - 登录时支持 TOTP 验证流程
      - 管理后台可全局开关 TOTP 功能
      
      安全增强:
      - TOTP 密钥使用 AES-256-GCM 加密存储
      - 添加 TOTP_ENCRYPTION_KEY 配置项,必须手动配置才能启用功能
      - 防止服务重启导致加密密钥变更使用户无法登录
      - 验证失败次数限制,防止暴力破解
      
      配置说明:
      - Docker 部署:在 .env 中设置 TOTP_ENCRYPTION_KEY
      - 非 Docker 部署:在 config.yaml 中设置 totp.encryption_key
      - 生成密钥命令:openssl rand -hex 32
      1245f07a
  32. 23 Jan, 2026 1 commit
  33. 18 Jan, 2026 1 commit
  34. 16 Jan, 2026 1 commit
    • longgexx's avatar
      feat(group): 添加分组级别模型路由配置功能 · 19865b86
      longgexx authored
        支持为分组配置模型路由规则,可以指定特定模型模式优先使用的账号列表。
      
        - 新增 model_routing 字段存储路由配置(JSONB格式,支持通配符匹配)
      
        - 新增 model_routing_enabled 字段控制是否启用路由
      
        - 更新后端 handler/service/repository 支持路由配置的增删改查
      
        - 更新前端 GroupsView 添加路由配置界面
      
        - 添加数据库迁移脚本 040/041
      19865b86
  35. 15 Jan, 2026 1 commit