1. 04 Apr, 2026 2 commits
    • erio's avatar
      fix: resolve cherry-pick compilation and test issues · e59fa863
      erio authored
      - Add int64(0) param to SelectAccountWithLoadAwareness callers (signature change from channel scheduling refactor)
      - Add UsageMapHook type and struct field to StreamingProcessor
      - Revert Claude Max cache billing code to upstream/main (not part of channel feature)
      - Revert credits overages logic to upstream/main (non-channel change)
      - Remove Instructions field reference (non-channel OpenAI feature)
      - Restore sora_client_handler_test.go from upstream + add channel service nil params
      e59fa863
    • erio's avatar
      feat(channel): 渠道管理全链路集成 — 模型映射、定价、限制、用量统计 · 2555951b
      erio authored
      - 渠道模型映射:支持精确匹配和通配符映射,按平台隔离
      - 渠道模型定价:支持 token/按次/图片三种计费模式,区间分层定价
      - 模型限制:渠道可限制仅允许定价列表中的模型
      - 计费模型来源:支持 requested/upstream 两种计费模型选择
      - 用量统计:usage_logs 新增 channel_id/model_mapping_chain/billing_tier/billing_mode 字段
      - Dashboard 支持 model_source 维度(requested/upstream/mapping)查看模型统计
      - 全部 gateway handler 统一接入 ResolveChannelMappingAndRestrict
      - 修复测试:同步 SoraGenerationRepository 接口、SQL INSERT 参数、scan 字段
      2555951b
  2. 21 Mar, 2026 1 commit
  3. 19 Mar, 2026 1 commit
  4. 15 Mar, 2026 1 commit
  5. 12 Mar, 2026 1 commit
  6. 28 Feb, 2026 1 commit
  7. 22 Feb, 2026 1 commit
  8. 19 Feb, 2026 6 commits
  9. 12 Feb, 2026 2 commits
  10. 10 Feb, 2026 2 commits
    • yangjianbo's avatar
      fix(handler): 修复 gjson 迁移后的请求校验语义回退 · 5d1c51a3
      yangjianbo authored
      
      
      - OpenAI handler: 添加 gjson.ValidBytes 校验 JSON 合法性;model 校验改为
        检查 gjson.String 类型而非仅判断非空(拒绝 model:123 等非法类型);stream
        字段添加 True/False 类型检查;sjson.SetBytes 返回值显式处理错误
      - Sora handler: 添加 gjson.ValidBytes 校验;model 校验同上改为类型检查;
        messages 校验从 Exists+Type==JSON 改为 IsArray+len>0(拒绝空数组和对象)
      - 补充 TestOpenAIHandler_GjsonValidation 和更新 TestSoraHandler_ValidationExtraction
        覆盖新增的边界校验场景
      Co-Authored-By: default avatarClaude Opus 4.6 <noreply@anthropic.com>
      5d1c51a3
    • yangjianbo's avatar
      perf(backend): 使用 gjson/sjson 优化热路径 JSON 处理 · 58912d4a
      yangjianbo authored
      
      
      将 API 网关热路径中的 json.Unmarshal+json.Marshal 替换为 gjson 零拷贝查询和 sjson 精准写入:
      - unwrapV1InternalResponse 性能提升 22x(4009ns→182ns),内存分配减少 28.5x
      - unwrapGeminiResponse、extractGeminiUsage、estimateGeminiCountTokens、ParseGeminiRateLimitResetTime 改为接收 []byte 使用 gjson 提取
      - ParseGatewayRequest 的 model/stream/metadata/thinking/max_tokens 改用 gjson 类型安全提取
      - Handler 层(sora/openai)改用 gjson 提取字段、sjson 注入/修改字段,移除 map[string]any 中间变量
      - Sora Client 响应解析改用 gjson ForEach 遍历,减少内存分配
      - 新增约 100 个单元测试用例,所有改动函数覆盖率 >85%
      Co-Authored-By: default avatarClaude Opus 4.6 <noreply@anthropic.com>
      58912d4a
  11. 01 Feb, 2026 1 commit
    • yangjianbo's avatar
      feat(Sora): 直连生成并移除sora2api依赖 · 399dd78b
      yangjianbo authored
      实现直连 Sora 客户端、媒体落地与清理策略\n更新网关与前端配置以支持 Sora 平台\n补齐单元测试与契约测试,新增 curl 测试脚本\n\n测试: go test ./... -tags=unit
      399dd78b
  12. 31 Jan, 2026 2 commits
  13. 16 Jan, 2026 2 commits
    • IanShaw027's avatar
      fix(openai): 使用 prompt_cache_key 兜底粘性会话 · ae21db77
      IanShaw027 authored
      opencode 请求不带 session_id/conversation_id,导致粘性会话失效。现在按 header 优先、prompt_cache_key 兜底生成 session hash,并补充单测验证优先级。
      ae21db77
    • song's avatar
      feat(gateway): 账户切换次数和 Antigravity 限流时间可配置 · 34d6b0a6
      song authored
      - gateway.max_account_switches: 账户切换最大次数,默认 10
      - gateway.max_account_switches_gemini: Gemini 账户切换次数,默认 3
      - gateway.antigravity_fallback_cooldown_minutes: Antigravity 429 fallback 限流时间,默认 5 分钟
      - Antigravity 429 不再重试,直接标记账户限流
      34d6b0a6
  14. 13 Jan, 2026 3 commits
    • yangjianbo's avatar
      fix(网关): 修复工具续链校验与存储策略 · 70eaa450
      yangjianbo authored
      完善 function_call_output 续链校验与引用匹配
      续链场景强制 store=true,过滤 input 时避免副作用
      补充续链判断与过滤相关单元测试
      
      测试: go test ./...
      70eaa450
    • ianshaw's avatar
    • ianshaw's avatar
      fix(openai): 增强 OpenCode 兼容性和模型规范化 · 3d6e01a5
      ianshaw authored
      ## 主要改动
      
      1. **模型规范化扩展到所有账号**
         - 将 Codex 模型规范化(如 gpt-5-nano → gpt-5.1)应用到所有 OpenAI 账号类型
         - 不再仅限于 OAuth 非 CLI 请求
         - 解决 Codex CLI 使用 ChatGPT 账号时的模型兼容性问题
      
      2. **reasoning.effort 参数规范化**
         - 自动将 `minimal` 转换为 `none`
         - 解决 gpt-5.1 模型不支持 `minimal` 值的问题
      
      3. **Session/Conversation ID fallback 机制**
         - 从请求体多个字段提取 session_id/conversation_id
         - 优先级:prompt_cache_key → session_id → conversation_id → previous_response_id
         - 支持 Codex CLI 的会话保持
      
      4. **Tool Call ID fallback**
         - 当 call_id 为空时使用 id 字段作为 fallback
         - 确保 tool call 输出能正确匹配
         - 保留 item_reference 类型的 items
      
      5. **Header 优化**
         - 添加 conversation_id 到允许的 headers
         - 移除删除 session headers 的逻辑
      
      ## 相关 Issue
      - 参考 OpenCode issue #3118 关于 item_reference 的讨论
      3d6e01a5
  15. 12 Jan, 2026 2 commits
  16. 11 Jan, 2026 1 commit
    • IanShaw027's avatar
      fix: 临时保存编译错误修复 · fc4ea659
      IanShaw027 authored
      - 添加 LinuxDo 和 Update 配置(从 main 分支缺失)
      - 添加 LinuxDoConnectSyntheticEmailDomain 常量
      - 添加 IsClaudeCodeClient context key
      - 添加 GetLinuxDoConnectOAuthConfig 方法
      - 修复 BindStickySession 调用签名
      - 修复前端 i18n 重复属性
      - 重新生成 wire 依赖注入代码
      
      这个提交准备被合并替换,先保存以防丢失。
      fc4ea659
  17. 09 Jan, 2026 4 commits
    • cyhhao's avatar
      Make Codex CLI passthrough · eb06006d
      cyhhao authored
      eb06006d
    • 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(网关): 集成运维监控到 API 网关处理器 · fcdf839b
      IanShaw027 authored
      - 在 gateway_handler 中添加请求监控和错误追踪
      - 在 openai_gateway_handler 中集成 ops 指标采集
      - 在 gemini_v1beta_handler 中集成 ops 指标采集
      - 更新 handler 基类支持 ops 错误日志记录
      fcdf839b
  18. 08 Jan, 2026 1 commit
    • Edric Li's avatar
      feat(groups): add Claude Code client restriction and session isolation · a4210588
      Edric Li authored
      - Add claude_code_only field to restrict groups to Claude Code clients only
      - Add fallback_group_id for non-Claude Code requests to use alternate group
      - Implement ClaudeCodeValidator for User-Agent detection
      - Add group-level session binding isolation (groupID in Redis key)
      - Prevent cross-group sticky session pollution
      - Update frontend with Claude Code restriction controls
      a4210588
  19. 07 Jan, 2026 1 commit
    • Edric Li's avatar
      feat(usage-log): 增加请求 User-Agent 记录 · 1ada6cf7
      Edric Li authored
      在使用记录中添加 user_agent 字段,用于记录 API 请求的 User-Agent 头信息,
      便于分析客户端类型和调试。
      
      变更内容:
      - 新增数据库迁移 028_add_usage_logs_user_agent.sql
      - 更新 UsageLog 模型和 Ent Schema 添加 user_agent 字段
      - 更新 Repository 层的 Create 和 scanUsageLog 方法
      - 更新 RecordUsageInput 结构体支持传入 UserAgent
      - 更新 Claude/OpenAI/Gemini 三个网关 Handler 传递 UserAgent
      
      🤖 Generated with [Claude Code](https://claude.com/claude-code
      
      )
      Co-Authored-By: default avatarClaude Opus 4.5 <noreply@anthropic.com>
      1ada6cf7
  20. 04 Jan, 2026 3 commits
    • yangjianbo's avatar
      fix(流式): 提升SSE稳定性并统一超时配置 · 73ffb585
      yangjianbo authored
      - 扩展SSE行长与间隔超时处理,补充keepalive
      
      - 写入失败与超长行时发送错误事件,修复并发释放
      
      - 同步默认配置与示例配置,更新Caddy超时/压缩规则
      
      - 新增OpenAI流式超时与超长行测试
      
      测试: go test ./...
      73ffb585
    • IanShaw027's avatar
      fix(lint): 修复所有 Go 命名规范问题 · a4953785
      IanShaw027 authored
      - 全局替换 ApiKey → APIKey(类型、字段、方法、变量)
      - 修复所有 initialism 命名(API, SMTP, HTML, URL 等)
      - 添加所有缺失的包注释
      - 修复导出符号的注释格式
      
      主要修改:
      - ApiKey → APIKey(所有出现的地方)
      - ApiKeyID → APIKeyID
      - ApiKeyIDs → APIKeyIDs
      - TestSmtpConnection → TestSMTPConnection
      - HtmlURL → HTMLURL
      - 添加 20+ 个包注释
      - 修复 10+ 个导出符号注释格式
      
      验证结果:
      - ✓ golangci-lint: 0 issues
      - ✓ 单元测试: 通过
      - ✓ 集成测试: 通过
      a4953785
    • song's avatar
      fix: 转发失败日志添加账户ID信息 · 3932bf03
      song authored
      3932bf03
  21. 03 Jan, 2026 1 commit
    • ianshaw's avatar
      chore: 更新依赖、配置和代码生成 · 112a2d08
      ianshaw authored
      主要更新:
      - 更新 go.mod/go.sum 依赖
      - 重新生成 Ent ORM 代码
      - 更新 Wire 依赖注入配置
      - 添加 docker-compose.override.yml 到 .gitignore
      - 更新 README 文档(Simple Mode 说明和已知问题)
      - 清理调试日志
      - 其他代码优化和格式修复
      112a2d08
  22. 02 Jan, 2026 1 commit
    • IanShaw's avatar
      运维监控系统安全加固和功能优化 (#21) · 45bd9ac7
      IanShaw authored
      * fix(ops): 修复运维监控系统的关键安全和稳定性问题
      
      ## 修复内容
      
      ### P0 严重问题
      1. **DNS Rebinding防护** (ops_alert_service.go)
         - 实现IP钉住机制防止验证后的DNS rebinding攻击
         - 自定义Transport.DialContext强制只允许拨号到验证过的公网IP
         - 扩展IP黑名单,包括云metadata地址(169.254.169.254)
         - 添加完整的单元测试覆盖
      
      2. **OpsAlertService生命周期管理** (wire.go)
         - 在ProvideOpsMetricsCollector中添加opsAlertService.Start()调用
         - 确保stopCtx正确初始化,避免nil指针问题
         - 实现防御式启动,保证服务启动顺序
      
      3. **数据库查询排序** (ops_repo.go)
         - 在ListRecentSystemMetrics中添加显式ORDER BY updated_at DESC, id DESC
         - 在GetLatestSystemMetric中添加排序保证
         - 避免数据库返回顺序不确定导致告警误判
      
      ### P1 重要问题
      4. **并发安全** (ops_metrics_collector.go)
         - 为lastGCPauseTotal字段添加sync.Mutex保护
         - 防止数据竞争
      
      5. **Goroutine泄漏** (ops_error_logger.go)
         - 实现worker pool模式限制并发goroutine数量
         - 使用256容量缓冲队列和10个固定worker
         - 非阻塞投递,队列满时丢弃任务
      
      6. **生命周期控制** (ops_alert_service.go)
         - 添加Start/Stop方法实现优雅关闭
         - 使用context控制goroutine生命周期
         - 实现WaitGroup等待后台任务完成
      
      7. **Webhook URL验证** (ops_alert_service.go)
         - 防止SSRF攻击:验证scheme、禁止内网IP
         - DNS解析验证,拒绝解析到私有IP的域名
         - 添加8个单元测试覆盖各种攻击场景
      
      8. **资源泄漏** (ops_repo.go)
         - 修复多处defer rows.Close()问题
         - 简化冗余的defer func()包装
      
      9. **HTTP超时控制** (ops_alert_service.go)
         - 创建带10秒超时的http.Client
         - 添加buildWebhookHTTPClient辅助函数
         - 防止HTTP请求无限期挂起
      
      10. **数据库查询优化** (ops_repo.go)
          - 将GetWindowStats的4次独立查询合并为1次CTE查询
          - 减少网络往返和表扫描次数
          - 显著提升性能
      
      11. **重试机制** (ops_alert_service.go)
          - 实现邮件发送重试:最多3次,指数退避(1s/2s/4s)
          - 添加webhook备用通道
          - 实现完整的错误处理和日志记录
      
      12. **魔法数字** (ops_repo.go, ops_metrics_collector.go)
          - 提取硬编码数字为有意义的常量
          - 提高代码可读性和可维护性
      
      ## 测试验证
      -  go test ./internal/service -tags opsalert_unit 通过
      -  所有webhook验证测试通过
      -  重试机制测试通过
      
      ## 影响范围
      - 运维监控系统安全性显著提升
      - 系统稳定性和性能优化
      - 无破坏性变更,向后兼容
      
      * feat(ops): 运维监控系统V2 - 完整实现
      
      ## 核心功能
      - 运维监控仪表盘V2(实时监控、历史趋势、告警管理)
      - WebSocket实时QPS/TPS监控(30s心跳,自动重连)
      - 系统指标采集(CPU、内存、延迟、错误率等)
      - 多维度统计分析(按provider、model、user等维度)
      - 告警规则管理(阈值配置、通知渠道)
      - 错误日志追踪(详细错误信息、堆栈跟踪)
      
      ## 数据库Schema (Migration 025)
      ### 扩展现有表
      - ops_system_metrics: 新增RED指标、错误分类、延迟指标、资源指标、业务指标
      - ops_alert_rules: 新增JSONB字段(dimension_filters, notify_channels, notify_config)
      
      ### 新增表
      - ops_dimension_stats: 多维度统计数据
      - ops_data_retention_config: 数据保留策略配置
      
      ### 新增视图和函数
      - ops_latest_metrics: 最新1分钟窗口指标(已修复字段名和window过滤)
      - ops_active_alerts: 当前活跃告警(已修复字段名和状态值)
      - calculate_health_score: 健康分数计算函数
      
      ## 一致性修复(98/100分)
      ### P0级别(阻塞Migration)
      -  修复ops_latest_metrics视图字段名(latency_p99→p99_latency_ms, cpu_usage→cpu_usage_percent)
      -  修复ops_active_alerts视图字段名(metric→metric_type, triggered_at→fired_at, trigger_value→metric_value, threshold→threshold_value)
      -  统一告警历史表名(删除ops_alert_history,使用ops_alert_events)
      -  统一API参数限制(ListMetricsHistory和ListErrorLogs的limit改为5000)
      
      ### P1级别(功能完整性)
      -  修复ops_latest_metrics视图未过滤window_minutes(添加WHERE m.window_minutes = 1)
      -  修复数据回填UPDATE逻辑(QPS计算改为request_count/(window_minutes*60.0))
      -  添加ops_alert_rules JSONB字段后端支持(Go结构体+序列化)
      
      ### P2级别(优化)
      -  前端WebSocket自动重连(指数退避1s→2s→4s→8s→16s,最大5次)
      -  后端WebSocket心跳检测(30s ping,60s pong超时)
      
      ## 技术实现
      ### 后端 (Go)
      - Handler层: ops_handler.go(REST API), ops_ws_handler.go(WebSocket)
      - Service层: ops_service.go(核心逻辑), ops_cache.go(缓存), ops_alerts.go(告警)
      - Repository层: ops_repo.go(数据访问), ops.go(模型定义)
      - 路由: admin.go(新增ops相关路由)
      - 依赖注入: wire_gen.go(自动生成)
      
      ### 前端 (Vue3 + TypeScript)
      - 组件: OpsDashboardV2.vue(仪表盘主组件)
      - API: ops.ts(REST API + WebSocket封装)
      - 路由: index.ts(新增/admin/ops路由)
      - 国际化: en.ts, zh.ts(中英文支持)
      
      ## 测试验证
      -  所有Go测试通过
      -  Migration可正常执行
      -  WebSocket连接稳定
      -  前后端数据结构对齐
      
      * refactor: 代码清理和测试优化
      
      ## 测试文件优化
      - 简化integration test fixtures和断言
      - 优化test helper函数
      - 统一测试数据格式
      
      ## 代码清理
      - 移除未使用的代码和注释
      - 简化concurrency_cache实现
      - 优化middleware错误处理
      
      ## 小修复
      - 修复gateway_handler和openai_gateway_handler的小问题
      - 统一代码风格和格式
      
      变更统计: 27个文件,292行新增,322行删除(净减少30行)
      
      * fix(ops): 运维监控系统安全加固和功能优化
      
      ## 安全增强
      - feat(security): WebSocket日志脱敏机制,防止token/api_key泄露
      - feat(security): X-Forwarded-Host白名单验证,防止CSRF绕过
      - feat(security): Origin策略配置化,支持strict/permissive模式
      - feat(auth): WebSocket认证支持query参数传递token
      
      ## 配置优化
      - feat(config): 支持环境变量配置代理信任和Origin策略
        - OPS_WS_TRUST_PROXY
        - OPS_WS_TRUSTED_PROXIES
        - OPS_WS_ORIGIN_POLICY
      - fix(ops): 错误日志查询限流从5000降至500,优化内存使用
      
      ## 架构改进
      - refactor(ops): 告警服务解耦,独立运行评估定时器
      - refactor(ops): OpsDashboard统一版本,移除V2分离
      
      ## 测试和文档
      - test(ops): 添加WebSocket安全验证单元测试(8个测试用例)
      - test(ops): 添加告警服务集成测试
      - docs(api): 更新API文档,标注限流变更
      - docs: 添加CHANGELOG记录breaking changes
      
      ## 修复文件
      Backend:
      - backend/internal/server/middleware/logger.go
      - backend/internal/handler/admin/ops_handler.go
      - backend/internal/handler/admin/ops_ws_handler.go
      - backend/internal/server/middleware/admin_auth.go
      - backend/internal/service/ops_alert_service.go
      - backend/internal/service/ops_metrics_collector.go
      - backend/internal/service/wire.go
      
      Frontend:
      - frontend/src/views/admin/ops/OpsDashboard.vue
      - frontend/src/router/index.ts
      - frontend/src/api/admin/ops.ts
      
      Tests:
      - backend/internal/handler/admin/ops_ws_handler_test.go (新增)
      - backend/internal/service/ops_alert_service_integration_test.go (新增)
      
      Docs:
      - CHANGELOG.md (新增)
      - docs/API-运维监控中心2.0.md (更新)
      
      * fix(migrations): 修复calculate_health_score函数类型匹配问题
      
      在ops_latest_metrics视图中添加显式类型转换,确保参数类型与函数签名匹配
      
      * fix(lint): 修复golangci-lint检查发现的所有问题
      
      - 将Redis依赖从service层移到repository层
      - 添加错误检查(WebSocket连接和读取超时)
      - 运行gofmt格式化代码
      - 添加nil指针检查
      - 删除未使用的alertService字段
      
      修复问题:
      - depguard: 3个(service层不应直接import redis)
      - errcheck: 3个(未检查错误返回值)
      - gofmt: 2个(代码格式问题)
      - staticcheck: 4个(nil指针解引用)
      - unused: 1个(未使用字段)
      
      代码统计:
      - 修改文件:11个
      - 删除代码:490行
      - 新增代码:105行
      - 净减少:385行
      45bd9ac7