1. 08 Jan, 2026 18 commits
    • Call White's avatar
      Merge pull request #1 from cyhhao/feat/ai-sdk-compatibility · f6a9a0a4
      Call White authored
      feat(openai): add AI SDK content format compatibility for OAuth accounts
      f6a9a0a4
    • cyhhao's avatar
      feat(openai): add AI SDK content format compatibility for OAuth accounts · 5b8d4fb0
      cyhhao authored
      - Add normalizeInputForCodexAPI function to convert AI SDK multi-part
        content format to simplified format expected by ChatGPT Codex API
      - AI SDK sends: {"content": [{"type": "input_text", "text": "..."}]}
      - Codex API expects: {"content": "..."}
      - Only applies to OAuth accounts (ChatGPT internal API)
      - API Key accounts remain unchanged (OpenAI Platform API supports both)
      5b8d4fb0
    • IanShaw's avatar
      fix(gemini): Google One 强制使用内置 OAuth client + 自动获取 project_id + UI 优化 (#212) · afcfbb45
      IanShaw authored
      * fix(gemini): Google One 强制使用内置 OAuth client + 自动获取 project_id + UI 优化
      
      ## 后端改动
      
      ### 1. Google One 强制使用内置 Gemini CLI OAuth Client
      **问题**:
      - Google One 之前允许使用自定义 OAuth client,导致认证流程不稳定
      - 与 Code Assist 的行为不一致
      
      **解决方案**:
      - 修改 `gemini_oauth_service.go`: Google One 现在与 Code Assist 一样强制使用内置 client (L122-135)
      - 更新 `gemini_oauth_client.go`: ExchangeCode 和 RefreshToken 方法支持强制内置 client (L31-44, L77-86)
      - 简化 `geminicli/oauth.go`: Google One scope 选择逻辑 (L187-190)
      - 标记 `geminicli/constants.go`: DefaultGoogleOneScopes 为 DEPRECATED (L30-33)
      - 更新测试用例以反映新行为
      
      **OAuth 类型对比**:
      | OAuth类型 | Client来源 | Scopes | Redirect URI |
      |-----------|-----------|--------|-----------------|
      | code_assist | 内置 Gemini CLI | DefaultCodeAssistScopes | https://codeassist.google.com/authcode |
      | google_one | 内置 Gemini CLI (新) | DefaultCodeAssistScopes | https://codeassist.google.com/authcode |
      | ai_studio | 必须自定义 | DefaultAIStudioScopes | http://localhost:1455/auth/callback |
      
      ### 2. Google One 自动获取 project_id
      **问题**:
      - Google One 个人账号测试模型时返回 403/404 错误
      - 原因:cloudaicompanion API 需要 project_id,但个人账号无需手动创建 GCP 项目
      
      **解决方案**:
      - 修改 `gemini_oauth_service.go`: OAuth 流程中自动调用 fetchProjectID
      - Google 通过 LoadCodeAssist API 自动分配 project_id
      - 与 Gemini CLI 行为保持一致
      - 后端根据 project_id 自动选择正确的 API 端点
      
      **影响**:
      - Google One 账号现在可以正常使用(需要重新授权)
      - Code Assist 和 AI Studio 账号不受影响
      
      ### 3. 修复 Gemini 测试账号无内容输出问题
      **问题**:
      - 测试 Gemini 账号时只显示"测试成功",没有显示 AI 响应内容
      - 原因:processGeminiStream 在检查到 finishReason 时立即返回,跳过了内容提取
      
      **解决方案**:
      - 修改 `account_test_service.go`: 调整逻辑顺序,先提取内容再检查是否完成
      - 确保最后一个 chunk 的内容也能被正确显示
      
      **影响**:
      - 所有 Gemini 账号类型(API Key、OAuth)的测试现在都会显示完整响应内容
      - 用户可以看到流式输出效果
      
      ## 前端改动
      
      ### 1. 修复图标宽度压缩问题
      **问题**:
      - 账户类型选择按钮中的图标在某些情况下会被压缩变形
      
      **解决方案**:
      - 修改 `CreateAccountModal.vue`: 为所有平台图标容器添加 `shrink-0` 类
      - 确保 Anthropic、OpenAI、Gemini、Antigravity 图标保持固定 8×8 尺寸 (32px × 32px)
      
      ### 2. 优化重新授权界面
      **问题**:
      - 重新授权时显示三个可点击的授权类型选择按钮,可能导致用户误切换到不兼容的授权方式
      
      **解决方案**:
      - 修改 `ReAuthAccountModal.vue` (admin 和普通用户版本):
        - 将可点击的授权类型选择按钮改为只读信息展示框
        - 根据账号的 `credentials.oauth_type` 动态显示对应图标和文本
        - 删除 `geminiAIStudioOAuthEnabled` 状态和 `handleSelectGeminiOAuthType` 方法
        - 防止用户误操作
      
      ## 测试验证
      -  所有后端单元测试通过
      -  OAuth client 选择逻辑正确
      -  Google One 和 Code Assist 行为一致
      -  测试账号显示完整响应内容
      -  UI 图标显示正常
      -  重新授权界面只读展示正确
      
      * fix(lint): 修复 golangci-lint 错误信息格式问题
      
      - 将错误信息改为小写开头以符合 Go 代码规范
      - 修复 ST1005: error strings should not be capitalized
      afcfbb45
    • Edric Li's avatar
    • Edric Li's avatar
      fix: update mock interfaces and fix gofmt issues for CI · b7a29a4b
      Edric Li authored
      - Update mockGatewayCacheForPlatform and mockGatewayCacheForGemini
        to match new GatewayCache interface with groupID parameter
      - Fix gofmt formatting in group_handler.go and admin_service.go
      b7a29a4b
    • 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
    • Edric Li's avatar
      test: fix unit tests for user_agent and proxy repo interface · 958ffe7a
      Edric Li authored
      - Add user_agent field to API contract test expectation
      - Add ListWithFiltersAndAccountCount stub to proxyRepoStub
      958ffe7a
    • Edric Li's avatar
      Merge remote-tracking branch 'upstream/main' · b46b3c5c
      Edric Li authored
      b46b3c5c
    • Edric Li's avatar
      feat(home): redirect admin users to admin dashboard · fd1b14fd
      Edric Li authored
      When clicking "Enter Console" button on home page, admin users are now
      redirected to /admin/dashboard instead of /dashboard.
      fd1b14fd
    • Edric Li's avatar
      feat(proxies): add account count column to proxy list · eb198e59
      Edric Li authored
      Display the number of accounts bound to each proxy in the admin proxy
      management page, similar to the groups list view.
      eb198e59
    • Edric Li's avatar
      feat(usage): add User-Agent column to usage logs · 70fcbd70
      Edric Li authored
      - Add user_agent field to UsageLog DTO and mapper
      - Display User-Agent column in admin and user usage tables
      - Add formatUserAgent helper to show friendly client names
      - Include user_agent in Excel export
      - Remove request_id column from admin usage table
      70fcbd70
    • shaw's avatar
      b015a3bd
    • shaw's avatar
      3fb43b91
    • shaw's avatar
      fix(antigravity): 修复请求频繁429的问题 · 6e8188ed
      shaw authored
      6e8188ed
    • shaw's avatar
      fix(billing): 修复客户端取消请求时计费丢失问题 · db6f53e2
      shaw authored
      检测 context.Canceled 作为客户端断开信号,返回已收集的 usage 而非错误
      db6f53e2
    • shaw's avatar
    • shaw's avatar
      Merge branch 'feature/account-expires-at' into main: feat: add account... · 169aa471
      shaw authored
      Merge branch 'feature/account-expires-at' into main: feat: add account expires-at field and auto-pause expired accounts
      169aa471
    • shaw's avatar
      Merge branch 'feat/usage-log-user-agent' · c0753320
      shaw authored
      c0753320
  2. 07 Jan, 2026 9 commits
    • Edric Li's avatar
      feat(update): 添加在线更新和定价数据获取的代理支持 · 38d875b0
      Edric Li authored
      针对国内服务器访问 GitHub 困难的问题,为在线更新和定价数据获取功能添加代理支持。
      
      主要变更:
      - 新增 update.proxy_url 配置项,支持 http/https/socks5/socks5h 协议
      - 修改 GitHubReleaseClient 和 PricingRemoteClient 支持代理配置
      - 更新 Wire 依赖注入,通过 Provider 函数传递配置
      - 更新 Docker 配置文件,支持通过 UPDATE_PROXY_URL 环境变量设置代理
      
      配置示例:
        update:
          proxy_url: "http://127.0.0.1:7890"
      
      Docker 环境变量:
        UPDATE_PROXY_URL=http://host.docker.internal:7890
      
      🤖 Generated with [Claude Code](https://claude.com/claude-code
      
      )
      Co-Authored-By: default avatarClaude Opus 4.5 <noreply@anthropic.com>
      38d875b0
    • 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
    • LLLLLLiulei's avatar
      feat: auto-pause expired accounts · 2b528c5f
      LLLLLLiulei authored
      2b528c5f
    • Xu Kang's avatar
      fix: 修复 Go 版本、包管理器和技术栈文档 (#195) · f6dd4752
      Xu Kang authored
      - backend/Dockerfile: Go 版本从 1.21 更新到 1.25.5(与 go.mod 一致)
      
      - Makefile: 使用 pnpm 替代 npm(与 pnpm-lock.yaml 和 CI 一致)
      
      - README.md/README_CN.md: 技术栈从 GORM 修正为 Ent
      f6dd4752
    • Xu Kang's avatar
      fix(i18n): use correct translation key for dashboard redeem code description (#194) · b19c7875
      Xu Kang authored
      Changed dashboard.addBalance to dashboard.addBalanceWithCode to match the existing translation key in locale files.
      b19c7875
    • shaw's avatar
      fix(gateway): 修复账号跨分组调度问题 · d99a3ef1
      shaw authored
      问题:账号可能被调度到未分配的分组(如 simon 账号被调度到 claude_default)
      
      根因:
      - 强制平台模式下分组查询失败时回退到全平台查询
      - listSchedulableAccounts 中分组为空时回退到无分组查询
      - 粘性会话只检查平台匹配,未校验账号分组归属
      
      修复:
      - 移除强制平台模式的回退逻辑,分组内无账号时返回错误
      - 移除 listSchedulableAccounts 的回退逻辑
      - 新增 isAccountInGroup 方法用于分组校验
      - 在三处粘性会话检查中增加分组归属验证
      d99a3ef1
    • shaw's avatar
      fix(keys): 修复代码框第一行多余空格问题 · fc8fa83f
      shaw authored
      pre 标签会原样保留内部空白字符,导致 code 标签前的模板缩进
      被渲染为实际空格。将 pre/code 标签写在同一行消除此问题。
      fc8fa83f
    • shaw's avatar
      fix(gateway): 修复 cache_control 块超限问题并优化 Claude Code 检测 · 6dcd9946
      shaw authored
      问题:
      - OAuth/SetupToken 账号注入 system prompt 后可能导致 cache_control
        块超过 Anthropic API 的 4 个限制
      - Claude Code 检测使用精确匹配,无法识别 Agent SDK 等变体
      
      修复:
      - 新增 enforceCacheControlLimit 函数,强制执行 4 个块限制
      - 优先从 messages 移除,再从 system 尾部移除(保护注入的 prompt)
      - 改用前缀匹配检测 Claude Code 系统提示词,支持多种变体:
        - 标准版、Agent SDK 版、Explore Agent 版、Compact 版
      6dcd9946
    • shaw's avatar
      fix(admin/usage): 恢复成本 Tooltip 明细并优化账号筛选 · d5ba7b80
      shaw authored
      问题修复:
      - 恢复 Cost Tooltip 的成本分项明细 (input_cost, output_cost, cache 成本)
      - 修复 Token Tooltip 双分隔线显示问题
      - 修复 Tooltip 翻译键缺失问题,新增 costDetails/tokenDetails
      - 恢复 Excel 导出格式化 (aoa_to_sheet + 翻译列头)
      
      功能优化:
      - 账号筛选从前端搜索改为后端搜索,避免一次加载 1000 条数据
      - 行为与用户/API Key 筛选保持一致 (debounce + 后端分页)
      d5ba7b80
  3. 06 Jan, 2026 13 commits
    • shaw's avatar
    • shaw's avatar
      feat(admin/usage): 优化管理员用量页面功能和体验 · 015974a2
      shaw authored
      后端改进:
      - 新增 GetStatsWithFilters 方法支持完整筛选条件
      - Stats 端点支持 account_id, group_id, model, stream, billing_type 参数
      - 统一使用 filters 结构体,移除冗余的分支逻辑
      
      前端改进:
      - 统计卡片添加"所选范围内"文字提示
      - 优化总消费显示格式,清晰展示实际费用和标准计费
      - Token 和费用列添加问号图标 tooltip 显示详细信息
      - API Key 搜索框体验优化:点击即显示下拉选项
      - 选择用户后自动加载该用户的所有 API Key
      015974a2
    • 程序猿MT's avatar
      Merge branch 'Wei-Shaw:main' into main · 4cf756eb
      程序猿MT authored
      4cf756eb
    • yangjianbo's avatar
      fix(并发): 修复 wrapReleaseOnDone goroutine 泄露问题 · 823497a2
      yangjianbo authored
      问题描述:
      - wrapReleaseOnDone 函数创建的 goroutine 会持续等待 ctx.Done()
      - 即使 release() 已被调用,goroutine 仍不会退出
      - 高并发场景下(1000 req/s)会产生 3000+ 个泄露 goroutine
      
      修复方案:
      - 添加 quit channel 作为退出信号
      - 正常释放时 close(quit) 通知 goroutine 立即退出
      - 使用 select 监听 ctx.Done() 和 quit 两个信号
      - 确保 goroutine 在正常流程中及时退出
      
      测试覆盖:
      - 新增 5 个单元测试验证修复效果
      - 验证 goroutine 不泄露
      - 验证并发安全性和多次调用保护
      - 性能影响:471.9 ns/op, 208 B/op
      
      影响范围:
      - gateway_handler.go: 每请求调用 2-4 次
      - openai_gateway_handler.go: 每请求调用 2-3 次
      - 修复后 goroutine 泄露数量从 3/req 降至 0
      
      🤖 Generated with [Claude Code](https://claude.com/claude-code
      
      )
      Co-Authored-By: default avatarClaude Sonnet 4.5 <noreply@anthropic.com>
      823497a2
    • yangjianbo's avatar
      chore: 删除依赖安全文档 · 66fe484f
      yangjianbo authored
      66fe484f
    • shaw's avatar
    • yangjianbo's avatar
      fix(前端): 修复账号管理页面平台过滤不生效的问题 · 5a52cb60
      yangjianbo authored
      添加 @update:filters 事件监听,使过滤器参数能正确同步到数据请求中。
      修复了平台、类型、状态三个过滤器全部失效的问题。
      
      🤖 Generated with [Claude Code](https://claude.com/claude-code
      
      )
      Co-Authored-By: default avatarClaude Sonnet 4.5 <noreply@anthropic.com>
      5a52cb60
    • yangjianbo's avatar
      fix(前端): 修复编辑账号错误提示无法显示具体原因的问题 · 1181b332
      yangjianbo authored
      后端 API 返回 message 字段,但前端读取 detail 字段,导致无法显示具体错误信息。
      现在优先读取 message 字段,兼容 detail 字段。
      
      🤖 Generated with [Claude Code](https://claude.com/claude-code
      
      )
      Co-Authored-By: default avatarClaude Opus 4.5 <noreply@anthropic.com>
      1181b332
    • yangjianbo's avatar
      fix(ci): 修复 frontend-security job 中的 pnpm 安装顺序问题 · 58b17771
      yangjianbo authored
      **问题描述:**
      GitHub Actions 在 frontend-security job 中报错:
      "Error: Unable to locate executable file: pnpm"
      
      **根本原因:**
      setup-node@v4 在尝试使用 pnpm cache 时,pnpm 还未安装
      
      **解决方案:**
      1. 调整步骤顺序:先安装 pnpm,再设置 Node.js
      2. 升级 pnpm/action-setup 从 v2 到 v4
      3. 明确指定 pnpm version: 9
      
      **修改内容:**
      - 将 "Set up pnpm" 步骤移到 "Set up Node.js" 之前
      - 更新 pnpm/action-setup@v2 → pnpm/action-setup@v4
      - 添加 version: 9 配置
      
      **正确的步骤顺序:**
      1. Checkout 代码
      2. Set up pnpm (指定版本)
      3. Set up Node.js (可以使用 pnpm cache)
      4. Install dependencies
      
      相关 Issue: #174
      
      🤖 Generated with [Claude Code](https://claude.com/claude-code
      
      )
      Co-Authored-By: default avatarClaude Opus 4.5 <noreply@anthropic.com>
      58b17771
    • yangjianbo's avatar
      fix(配置): 修改 URL 安全配置默认值为开发友好模式 · 0c7a58fc
      yangjianbo authored
      调整以下配置的默认值以匹配 .env.example:
      - allow_insecure_http: false → true (允许 HTTP URL)
      - allow_private_hosts: false → true (允许本地/私有 IP)
      
      **改动说明:**
      - 默认允许 HTTP URL,方便开发测试环境使用
      - 默认允许本地和私有 IP 地址
      - 与 deploy/.env.example 中的推荐配置保持一致
      - 更新相应的单元测试以验证新的默认值
      
      **安全提示:**
      ️ 这些默认值适合开发/测试环境
      ️ 生产环境建议显式配置更严格的安全策略
      ️ HTTP 存在明文传输风险,仅在可信网络中使用
      
      **测试结果:**
      -  所有单元测试通过
      -  golangci-lint 无问题
      
      相关文件:
      - backend/internal/config/config.go:451-452
      - backend/internal/config/config_test.go:83-88
      
      🤖 Generated with [Claude Code](https://claude.com/claude-code
      
      )
      Co-Authored-By: default avatarClaude Opus 4.5 <noreply@anthropic.com>
      0c7a58fc
    • yangjianbo's avatar
      merge: 合并远程分支并修复代码冲突 · 17ae51c0
      yangjianbo authored
      合并了远程分支 cb72262a 的功能更新,同时保留了 ESLint 修复:
      
      **冲突解决详情:**
      
      1. AccountTableFilters.vue
         -  保留 emit 模式修复(避免 vue/no-mutating-props 错误)
         -  添加第三个筛选器 type(账户类型)
         -  新增 antigravity 平台和 inactive 状态选项
      
      2. UserBalanceModal.vue
         -  保留 console.error 错误日志
         -  添加输入验证(金额校验、余额不足检查)
         -  使用 appStore.showError 向用户显示友好错误
      
      3. AccountsView.vue
         -  保留所有 console.error 错误日志(避免 no-empty 错误)
         -  使用新 API:clearRateLimit 和 setSchedulable
      
      4. UsageView.vue
         -  添加 console.error 错误日志
         -  添加图表功能(模型分布、使用趋势)
         -  添加粒度选择(按天/按小时)
         -  保留 XLSX 动态导入优化
      
      **测试结果:**
      -  Go tests: PASS
      -  golangci-lint: 0 issues
      -  ESLint: 0 errors
      -  TypeScript: PASS
      
      🤖 Generated with [Claude Code](https://claude.com/claude-code
      
      )
      Co-Authored-By: default avatarClaude Opus 4.5 <noreply@anthropic.com>
      17ae51c0
    • yangjianbo's avatar
      fix(前端): 修复 ESLint 代码规范问题 · 4790aced
      yangjianbo authored
      - 修复 AccountTableFilters.vue 中的 vue/no-mutating-props 错误,使用 emit 模式替代直接修改 props
      - 修复 TypeScript 类型错误,支持 Select 组件的 null 值类型
      - 为所有空 catch 块添加错误日志,提升代码可维护性和调试能力
      - 涉及文件:AccountTableFilters.vue, UserAllowedGroupsModal.vue, UserApiKeysModal.vue, UserBalanceModal.vue, AccountsView.vue, UsageView.vue, DashboardView.vue, ProfileView.vue
      
      🤖 Generated with [Claude Code](https://claude.com/claude-code
      
      )
      Co-Authored-By: default avatarClaude Opus 4.5 <noreply@anthropic.com>
      4790aced
    • yangjianbo's avatar
      fix(安全): 修复依赖漏洞并强化安全扫描 · 3f0017d1
      yangjianbo authored
      主要改动:
      - 固定 Go 1.25.5 与 CI 校验并更新扫描流程
      - 升级 quic-go、x/crypto、req 等依赖并通过 govulncheck
      - 强化 JWT 校验、TLS 配置与 xlsx 动态加载
      - 新增审计豁免清单与校验脚本
      3f0017d1