1. 14 Jan, 2026 4 commits
    • IanShaw027's avatar
      2ca6c631
    • IanShaw027's avatar
      refactor(ops): 移除duration相关告警指标,简化监控配置 · 18268381
      IanShaw027 authored
      主要改动:
      - 移除 p95_latency_ms 和 p99_latency_ms 告警指标类型
      - 移除配置中的 latency_p99_ms_max 阈值设置
      - 简化健康分数计算(移除latency权重,重新归一化SLA和错误率)
      - 移除duration相关的诊断规则和阈值检查
      - 统一术语:延迟 → 请求时长
      - 保留duration数据展示,但不再用于告警判断
      - 聚焦TTFT作为主要的响应速度告警指标
      
      影响范围:
      - Backend: handler, service, models, tests
      - Frontend: API types, i18n, components
      18268381
    • IanShaw027's avatar
      fix(ops): 修复告警状态验证和错误处理逻辑 · 33f58d58
      IanShaw027 authored
      - 增强告警事件状态验证,添加合法状态值检查
      - 移除重试逻辑中的遗留字段赋值
      - 修正仓库不可用时的错误类型
      - 格式化测试文件代码
      33f58d58
    • IanShaw027's avatar
      feat(handler): 新增ops管理接口和路由 · 659df6e2
      IanShaw027 authored
      - 添加告警静默管理接口
      - 扩展错误日志查询和操作接口
      - 新增重试和解决状态相关端点
      - 完善错误日志记录功能
      659df6e2
  2. 12 Jan, 2026 11 commits
    • xiluo's avatar
      feat(gateway): 优化 Antigravity/Gemini 思考块处理 · 524d80ae
      xiluo authored
      此提交解决了思考块 (thinking blocks) 在转发过程中的兼容性问题。
      
      主要变更:
      
      1. **思考块优化 (Thinking Blocks)**:
         - 在 AntigravityGatewayService 中增加了 sanitizeThinkingBlocks 处理,强制移除思考块中不支持的 cache_control 字段(避免 Anthropic/Vertex AI 报错)
         - 实现历史思考块展平 (Flattening):将非最后一条消息中的思考块转换为普通文本块,以绕过上游对历史思考块签名的严格校验
         - 增加 cleanCacheControlFromGeminiJSON 作为最后一道防线,确保转换后的 Gemini 请求中不残留非法的 cache_control
      
      2. **GatewayService 缓存控制优化**:
         - 更新缓存控制逻辑,跳过 thinking 块(thinking 块不支持 cache_control 字段)
         - 增加 removeCacheControlFromThinkingBlocks 函数强制清理
      
      关联 Issue: #225
      524d80ae
    • shaw's avatar
      fix: 修复反向代理下客户端 IP 获取错误 · 22ef9534
      shaw authored
      22ef9534
    • IanShaw027's avatar
      feat(ops): 添加 count_tokens 错误过滤功能 · 345a965f
      IanShaw027 authored
      功能特性:
      - 自动识别并标记 count_tokens 请求的错误
      - 支持配置是否在统计中忽略 count_tokens 错误
      - 错误数据完整保留,仅在统计时动态过滤
      
      技术实现:
      - ops_error_logger.go: 自动标记 count_tokens 请求
      - ops_repo.go: INSERT 语句添加 is_count_tokens 字段
      - ops_repo_dashboard.go: buildErrorWhere 核心过滤函数
      - ops_repo_preagg.go: 预聚合统计中添加过滤
      - ops_repo_trends.go: 趋势统计查询添加过滤(2 处)
      - ops_settings_models.go: 添加 ignore_count_tokens_errors 配置
      - ops_settings.go: 配置验证和默认值设置
      - ops_port.go: 错误日志模型添加 IsCountTokens 字段
      
      业务价值:
      - count_tokens 是探测性请求,其错误不影响真实业务 SLA
      - 用户可根据需求灵活控制是否计入统计
      - 提升错误率、告警等运维指标的准确性
      
      影响范围:
      - Dashboard 概览统计
      - 错误趋势图表
      - 告警规则评估
      - 预聚合指标(hourly/daily)
      - 健康分数计算
      345a965f
    • shaw's avatar
      fix(gateway): 修复 usage_logs 记录 IP 不正确的问题 · 8363663e
      shaw authored
      在 nginx 反向代理场景下,使用 ip.GetClientIP() 替代 c.ClientIP()
      以正确获取客户端真实 IP 地址
      8363663e
    • shaw's avatar
      fix(gateway): 修复 Claude Code 客户端检测和请求信息记录 · cf313d57
      shaw authored
      - 在 Messages 方法中调用 SetClaudeCodeClientContext 启用客户端检测
      - 修复 RecordUsageInput 未传递 UserAgent 和 IPAddress 的问题
      cf313d57
    • IanShaw027's avatar
      fix(ops): 修复Go代码格式问题 · e0cccf6e
      IanShaw027 authored
      e0cccf6e
    • IanShaw027's avatar
      feat(ops): 集成实时流量API接口 · 62771583
      IanShaw027 authored
      - 添加实时流量handler处理逻辑
      - 注册实时流量路由
      - 扩展ops service接口定义
      62771583
    • ianshaw's avatar
      refactor(settings): 简化流超时配置,移除冗余字段 · 0c528095
      ianshaw authored
      - 移除 TimeoutSeconds 字段,超时判定由网关配置控制
      - 默认禁用流超时处理功能
      0c528095
    • ianshaw's avatar
      feat(gateway): 添加流超时处理机制 · 2a0758bd
      ianshaw authored
      - 添加 StreamTimeoutSettings 配置结构体和系统设置
      - 实现 TimeoutCounterCache Redis 计数器用于累计超时次数
      - 在 RateLimitService 添加 HandleStreamTimeout 方法
      - 在 gateway_service、openai_gateway_service、antigravity_gateway_service 中调用超时处理
      - 添加后端 API 端点 GET/PUT /admin/settings/stream-timeout
      - 添加前端配置界面到系统设置页面
      - 支持配置:启用开关、超时阈值、处理方式、暂停时长、触发阈值、阈值窗口
      
      默认配置:
      - 启用:true
      - 超时阈值:60秒
      - 处理方式:临时不可调度
      - 暂停时长:5分钟
      - 触发阈值:3次
      - 阈值窗口:10分钟
      2a0758bd
    • IanShaw027's avatar
      feat(ops): 后端添加指标阈值管理API · 7536dbfe
      IanShaw027 authored
      - 新增GetMetricThresholds和UpdateMetricThresholds接口
      - 支持配置SLA、延迟P99、TTFT P99、请求错误率、上游错误率阈值
      - 添加参数验证逻辑
      - 提供默认阈值配置
      7536dbfe
    • shaw's avatar
      50de5d05
  3. 11 Jan, 2026 11 commits
    • IanShaw027's avatar
      fix(ci): 修复所有CI失败问题 · f017fd97
      IanShaw027 authored
      - 修复 ops_ws_handler.go 代码格式问题
      - 修复所有未检查的错误返回值(Rows.Close 和 WriteString)
      - 更新 .golangci.yml 排除 ops 相关服务文件的 redis 导入检查
      f017fd97
    • IanShaw027's avatar
      fix(lint): 修复代码格式和未使用变量问题 · ce3336e3
      IanShaw027 authored
      - 修复 ops_ws_handler.go 中的代码格式和返回值
      - 移除 ops_repo_latency_histogram_buckets.go 中不必要的错误检查
      - 修复 api_contract_test.go 缩进并添加运维监控配置项测试
      - 移除 ops_cleanup_service.go 中未使用的变量
      - 添加 ops_retry.go 中缺失的 status 字段
      ce3336e3
    • IanShaw027's avatar
      fix(lint): 修复所有golangci-lint错误 · 54c5788b
      IanShaw027 authored
      - 修复depguard错误:为ops service文件添加redis导入例外
      - 修复errcheck错误:添加错误检查和类型断言检查
      - 修复gofmt错误:格式化代码
      - 修复ineffassign错误:移除无效的idx++赋值
      - 修复staticcheck错误:合并条件赋值
      - 修复unused错误:移除未使用的字段和函数
        - ops_cleanup_service.go: entryID字段
        - ops_retry.go: status字段
        - ops_upstream_context.go: getOpsUpstreamErrors函数
      54c5788b
    • IanShaw027's avatar
      feat(ops): 增强上游错误追踪和新增定时报告服务 · 73b62bb1
      IanShaw027 authored
      - 优化错误日志中间件,即使请求成功也记录上游重试/故障转移事件
      - 新增OpsScheduledReportService支持定时报告功能
      - 使用Redis分布式锁确保定时任务单实例执行
      - 完善依赖注入配置
      - 优化前端错误趋势图表展示
      73b62bb1
    • IanShaw027's avatar
      feat(ops): 添加运维监控配置开关 · c1a3dd41
      IanShaw027 authored
      - 在 .env.example 和 config.example.yaml 中添加 ops.enabled 配置项
      - 默认值为 true,保持现有行为
      - 当设置为 false 时,左侧栏隐藏运维监控菜单并禁用所有运维监控功能
      - 修改后端 GetSettings API,让 ops_monitoring_enabled 受 config.ops.enabled 控制
      - 数据清理和预聚合任务默认保持开启状态(通过运维监控设置对话框配置)
      c1a3dd41
    • IanShaw027's avatar
      feat(ops): 添加高级设置API支持 · 988b4d02
      IanShaw027 authored
      - 新增OpsAdvancedSettings数据模型
      - 支持数据保留策略配置(错误日志、分钟级指标、小时级指标)
      - 支持数据聚合开关配置
      - 添加GET/PUT /admin/ops/advanced-settings接口
      - 添加配置校验和默认值处理
      
      相关文件:
      - backend/internal/service/ops_settings_models.go
      - backend/internal/service/ops_settings.go
      - backend/internal/handler/admin/ops_settings_handler.go
      - backend/internal/server/routes/admin.go
      - backend/internal/service/domain_constants.go
      988b4d02
    • yangjianbo's avatar
      6271a33d
    • yangjianbo's avatar
      1a869547
    • IanShaw027's avatar
      feat(ops): 实现上游错误事件记录与查询功能 · 7ebca553
      IanShaw027 authored
      **新增功能**:
      - 新建ops_upstream_error_events表存储上游服务错误详情
      - 支持记录上游429/529/5xx错误的详细上下文信息
      - 提供按时间范围查询上游错误事件的API
      
      **后端改动**:
      1. 模型层(ops_models.go, ops_port.go):
         - 新增UpstreamErrorEvent结构体
         - 扩展Repository接口支持上游错误事件CRUD
      
      2. 仓储层(ops_repo.go):
         - 实现InsertUpstreamErrorEvent写入上游错误
         - 实现GetUpstreamErrorEvents按时间范围查询
      
      3. 服务层(ops_service.go, ops_upstream_context.go):
         - ops_service: 新增GetUpstreamErrorEvents查询方法
         - ops_upstream_context: 封装上游错误上下文构建逻辑
      
      4. Handler层(ops_error_logger.go):
         - 新增GetUpstreamErrorsHandler处理上游错误查询请求
      
      5. Gateway层集成:
         - antigravity_gateway_service.go: 429/529错误时记录上游事件
         - gateway_service.go: OpenAI 429/5xx错误时记录
         - gemini_messages_compat_service.go: Gemini 429/5xx错误时记录
         - openai_gateway_service.go: OpenAI 429/5xx错误时记录
         - ratelimit_service.go: 429限流错误时记录
      
      **数据记录字段**:
      - request_id: 关联ops_logs主记录
      - platform/model: 上游服务标识
      - status_code/error_message: 错误详情
      - request_headers/response_body: 调试信息(可选)
      - created_at: 错误发生时间
      7ebca553
    • IanShaw027's avatar
      feat(ops): 添加QPS脉搏线图并优化指标布局 · 89a725a4
      IanShaw027 authored
      - 添加实时QPS/TPS历史数据追踪(最近60个数据点)
      - 在平均QPS/TPS上方添加SVG脉搏线图(sparkline)
      - 将延迟和TTFT卡片的指标布局从2列改为3列
      - 恢复Max指标显示(P95/P90/P50/Avg/Max)
      89a725a4
    • IanShaw027's avatar
      fix: 临时保存编译错误修复 · fc4ea659
      IanShaw027 authored
      - 添加 LinuxDo 和 Update 配置(从 main 分支缺失)
      - 添加 LinuxDoConnectSyntheticEmailDomain 常量
      - 添加 IsClaudeCodeClient context key
      - 添加 GetLinuxDoConnectOAuthConfig 方法
      - 修复 BindStickySession 调用签名
      - 修复前端 i18n 重复属性
      - 重新生成 wire 依赖注入代码
      
      这个提交准备被合并替换,先保存以防丢失。
      fc4ea659
  4. 10 Jan, 2026 3 commits
    • Edric Li's avatar
      feat(settings): add home content customization and config injection · 5265b12c
      Edric Li authored
      - Add home_content setting for custom homepage (HTML or iframe URL)
      - Inject public settings into index.html to eliminate page flash
      - Support ETag caching with automatic invalidation on settings update
      - Add Vite plugin for dev mode settings injection
      - Refactor HomeView to use appStore instead of local API calls
      5265b12c
    • long's avatar
      feat: 实现注册优惠码功能 · 9f4d4e5a
      long authored
        - 支持创建/编辑/删除优惠码,设置赠送金额和使用限制
        - 注册页面实时验证优惠码并显示赠送金额
        - 支持 URL 参数自动填充 (?promo=CODE)
        - 添加优惠码验证接口速率限制
        - 使用数据库行锁防止并发超限
        - 新增后台优惠码管理页面,支持复制注册链接
      9f4d4e5a
    • long's avatar
      feat: 实现注册优惠码功能 · d2fc14fb
      long authored
        - 支持创建/编辑/删除优惠码,设置赠送金额和使用限制
        - 注册页面实时验证优惠码并显示赠送金额
        - 支持 URL 参数自动填充 (?promo=CODE)
        - 添加优惠码验证接口速率限制
        - 使用数据库行锁防止并发超限
        - 新增后台优惠码管理页面,支持复制注册链接
      d2fc14fb
  5. 09 Jan, 2026 11 commits
    • cyhhao's avatar
      Make Codex CLI passthrough · eb06006d
      cyhhao authored
      eb06006d
    • IanShaw027's avatar
      feat(运维监控): 增强监控功能和健康评分系统 · 585257d3
      IanShaw027 authored
      后端改进:
      - 新增健康评分计算服务(ops_health_score.go)
      - 添加分布式锁支持(ops_advisory_lock.go)
      - 优化指标采集和聚合逻辑
      - 新增运维指标采集间隔配置(60-3600秒)
      - 移除未使用的WebSocket查询token认证中间件
      - 改进清理服务和告警评估逻辑
      
      前端改进:
      - 简化OpsDashboard组件结构
      - 完善国际化文本(中英文)
      - 新增运维监控相关API类型定义
      - 添加运维指标采集间隔设置界面
      - 优化错误详情模态框
      
      测试:
      - 添加健康评分单元测试
      - 更新API契约测试
      585257d3
    • Edric.Li's avatar
      feat(api-key): 添加 IP 白名单/黑名单限制功能 (#221) · 0a4641c2
      Edric.Li authored
      * feat(api-key): add IP whitelist/blacklist restriction and usage log IP tracking
      
      - Add IP restriction feature for API keys (whitelist/blacklist with CIDR support)
      - Add IP address logging to usage logs (admin-only visibility)
      - Remove billing_type column from usage logs UI (redundant)
      - Use generic "Access denied" error message for security
      
      Backend:
      - New ip package with IP/CIDR validation and matching utilities
      - Database migrations for ip_whitelist, ip_blacklist (api_keys) and ip_address (usage_logs)
      - Middleware IP restriction check after API key validation
      - Input validation for IP/CIDR patterns on create/update
      
      Frontend:
      - API key form with enable toggle for IP restriction
      - Shield icon indicator in table for keys with IP restriction
      - Removed billing_type filter and column from usage views
      
      * fix: update API contract tests for ip_whitelist/ip_blacklist fields
      
      Add ip_whitelist and ip_blacklist fields to expected JSON responses
      in API contract tests to match the new API key schema.
      0a4641c2
    • Edric Li's avatar
      feat(api-key): add IP whitelist/blacklist restriction and usage log IP tracking · 90798f14
      Edric Li authored
      - Add IP restriction feature for API keys (whitelist/blacklist with CIDR support)
      - Add IP address logging to usage logs (admin-only visibility)
      - Remove billing_type column from usage logs UI (redundant)
      - Use generic "Access denied" error message for security
      
      Backend:
      - New ip package with IP/CIDR validation and matching utilities
      - Database migrations for ip_whitelist, ip_blacklist (api_keys) and ip_address (usage_logs)
      - Middleware IP restriction check after API key validation
      - Input validation for IP/CIDR patterns on create/update
      
      Frontend:
      - API key form with enable toggle for IP restriction
      - Shield icon indicator in table for keys with IP restriction
      - Removed billing_type filter and column from usage views
      90798f14
    • IanShaw027's avatar
      feat(设置): 集成运维监控配置到系统设置 · 2d123a11
      IanShaw027 authored
      - 扩展 setting_handler 支持 ops 配置管理
      - 扩展 setting_service 支持 ops 配置持久化
      - 更新 settings_view 包含 ops 配置视图
      2d123a11
    • IanShaw027's avatar
      feat(网关): 集成运维监控到 API 网关处理器 · fcdf839b
      IanShaw027 authored
      - 在 gateway_handler 中添加请求监控和错误追踪
      - 在 openai_gateway_handler 中集成 ops 指标采集
      - 在 gemini_v1beta_handler 中集成 ops 指标采集
      - 更新 handler 基类支持 ops 错误日志记录
      fcdf839b
    • IanShaw027's avatar
      feat(handler): 实现运维监控 API 处理器和中间件 · f3ed95d4
      IanShaw027 authored
      - 新增 ops 错误日志记录器(ops_error_logger.go)
      - 新增 ops 主处理器(ops_handler.go)
      - 新增告警管理处理器(ops_alerts_handler.go)
      - 新增仪表板处理器(ops_dashboard_handler.go)
      - 新增实时监控处理器(ops_realtime_handler.go)
      - 新增配置管理处理器(ops_settings_handler.go)
      - 新增 WebSocket 处理器(ops_ws_handler.go)
      - 扩展设置 DTO 支持 ops 配置
      - 新增客户端请求 ID 中间件(client_request_id.go)
      - 新增 WebSocket 查询令牌认证中间件(ws_query_token_auth.go)
      - 更新管理员认证中间件支持 ops 路由
      - 注册 handler 依赖注入
      f3ed95d4
    • IanShaw027's avatar
      fix(admin): 代码审查修复 - 输入验证和测试完善 · 7c3d5cad
      IanShaw027 authored
      根据 Codex 代码审查报告,修复所有 P0 和 P1 优先级问题。
      
      ## P0 紧急修复
      
      ### 1. 修复集成测试编译错误
      - 更新 group_repo_integration_test.go 中所有 ListWithFilters 调用
      - 添加缺失的 search 参数(传入空字符串)
      - 修复 4 处旧签名调用,避免 CI 编译失败
      
      ### 2. 添加统一的 search 参数输入验证
      为所有 admin handler 添加一致的输入验证逻辑:
      - group_handler.go: 添加 TrimSpace + 长度限制
      - proxy_handler.go: 添加 TrimSpace + 长度限制
      - redeem_handler.go: 添加 TrimSpace + 长度限制
      - user_handler.go: 添加 TrimSpace + 长度限制
      
      验证规则:
      - TrimSpace() 去除首尾空格
      - 最大长度 100 字符(防止 DoS 攻击)
      - 超长输入自动截断
      
      ## P1 改进
      
      ### 3. 补充 search 功能的单元测试
      新增 admin_service_group_test.go 中的测试:
      - TestAdminService_ListGroups_WithSearch
        - search 参数正常传递到 repository 层
        - search 为空字符串时的行为
        - search 与其他过滤条件组合使用
      
      新增 admin_service_search_test.go 文件:
      - 为其他 admin API 添加 search 测试覆盖
      - 统一的测试模式和断言
      
      ### 4. 补充 search 功能的集成测试
      新增 group_repo_integration_test.go 测试场景:
      - TestListWithFilters_Search
        - 搜索 name 字段匹配
        - 搜索 description 字段匹配
        - 搜索不存在内容(返回空)
        - 大小写不敏感测试
        - 特殊字符转义测试(%、_)
        - 与其他过滤条件组合
      
      ## 测试结果
      
      -  编译检查通过
      -  单元测试全部通过 (3/3)
      -  集成测试编译通过
      -  所有 service 测试通过
      
      ## 影响范围
      
      修改文件: 8 个
      代码变更: +234 行 / -8 行
      
      ## 相关 Issue
      
      解决代码审查中的安全性和稳定性问题:
      - 防止 DoS 攻击(超长搜索字符串)
      - 修复测试编译错误(CI 阻塞问题)
      - 提升测试覆盖率
      7c3d5cad
    • shaw's avatar
      f060db0b
    • IanShaw027's avatar
      feat(admin): 添加账号批量调度开关功能 · 5e936fbf
      IanShaw027 authored
      - 后端:支持批量更新账号的 schedulable 字段
        - 在 BulkUpdateAccountsRequest 中添加 schedulable 参数
        - 在 AccountBulkUpdate 中添加 schedulable 字段支持
        - 更新 repository 层批量更新 SQL 逻辑
      - 前端:在账号管理页面添加批量调度控制
        - 新增"批量启用调度"和"批量停止调度"按钮
        - 添加 handleBulkToggleSchedulable 处理函数
        - 显示具体的成功提示信息(包含操作账号数量)
      - 国际化:添加批量调度相关中英文翻译
      - 优化:添加 search 参数标准化和验证(account_handler)
      5e936fbf
    • IanShaw027's avatar
      fix(admin): 修复表格批量操作和搜索功能问题 · 38202322
      IanShaw027 authored
      1. 恢复账号管理批量操作栏缺失的功能按钮
         - 添加"本页全选"按钮支持批量选择当前页所有账号
         - 添加"清除已选"按钮快速清空已选账号列表
         - 在重构拆分组件时遗漏,现已恢复
      
      2. 修复分组管理搜索功能仅搜索当前页的问题
         - 前端:移除本地过滤逻辑,改用后端搜索
         - 后端:添加 search 参数支持,搜索名称和描述字段
         - 支持不区分大小写的模糊匹配
         - 统一所有管理页面的搜索体验
      38202322