erio
d616f8c854
refactor: remove unused ClientSecret constant
...
The ClientSecret constant was left as an empty string after
getClientSecret() was refactored to use defaultClientSecret.
Remove the dead constant and update the test accordingly.
2026-02-24 21:09:46 +08:00
erio
b6fa8b8eec
fix: update tests for defaultClientSecret and align migration 058
...
- Fix oauth_test.go and client_test.go to use defaultClientSecret
variable instead of env var (init() already sets the default)
- Align migration 058 gemini-3-pro-high/low/preview mappings with
constants.go (map to 3.1 versions)
2026-02-24 21:06:10 +08:00
erio
36d2e6999b
feat: add default value for Antigravity OAuth client secret
...
Add a built-in default for ANTIGRAVITY_OAUTH_CLIENT_SECRET so the
service works out of the box without requiring environment variable
configuration. The env var can still override the default.
2026-02-24 20:54:28 +08:00
erio
ca3e9336e1
test: update UserAgent version assertion to match 1.18.4 default
2026-02-24 20:31:02 +08:00
erio
483c8f246d
chore: update default Antigravity UserAgent version to 1.18.4
...
Update the default ANTIGRAVITY_USER_AGENT_VERSION from 1.84.2 to
1.18.4 to match the current Antigravity-Manager desktop client.
2026-02-24 19:39:15 +08:00
erio
645f283108
feat: add claude-sonnet-4-6 and gemini-3.1-pro model support
...
Add claude-sonnet-4-6 to identity injection modelInfoMap and
Antigravity model selector. Add gemini-3.1-pro-high/low to
Antigravity model list and Sonnet 4.6 preset mapping.
2026-02-24 19:30:01 +08:00
shaw
7be5e1734c
fix: 修复 CI 集成测试因 context deadline exceeded 未被跳过而失败
...
skipIfExternalServiceUnavailable 检查了 "timeout" 但 Go 的
context.DeadlineExceeded 错误信息是 "context deadline exceeded",
不包含 "timeout" 子串,导致外部服务不可达时测试直接失败而非跳过。
2026-02-24 15:04:04 +08:00
shaw
e435a46db5
fix: 修复 antigravity UserAgent 重构遗留的编译错误和测试不匹配
...
- oauth.go: GetUserAgent() 缺少闭合大括号导致语法错误
- client_test.go/oauth_test.go: UserAgent 变量已重构为 GetUserAgent(),更新测试引用
- model_rate_limit_test.go: gemini-3-pro-preview 映射目标已更新为 gemini-3.1-pro-high,同步测试
2026-02-24 14:44:57 +08:00
Wesley Liddick
6bccb8a8a6
Merge branch 'main' into feature/antigravity-user-agent-configurable
2026-02-24 14:01:43 +08:00
Wesley Liddick
3de1e0e485
Merge pull request #597 from 0-don/feat/add-gemini-3.1-pro-preview
...
feat: add gemini-3.1-pro-preview to model lists
2026-02-24 12:25:17 +08:00
shaw
980fc9608f
fix: 修复日志重复输出及清理冗余迁移逻辑
...
- logger: sinkCore 包装 tee core 时绕过了子 core 的 Check 级别过滤,
导致每条日志同时写入 stdout 和 stderr,表现为启动日志重复显示。
修复为正确委托 Check 给内部 tee core,sinkCore.Write 仅负责 sink 转发。
- migration 054: 移除冗余的遗留列回填逻辑,migration 009 已完成数据迁移,
直接删除遗留列即可。
2026-02-24 11:31:19 +08:00
cagedbird043
1fc6ef3d4f
feat: 让 User-Agent 版本可通过环境变量 ANTIGRAVITY_USER_AGENT_VERSION 配置,默认 1.84.2
2026-02-23 21:17:35 +08:00
yangjianbo
2ee6c26676
fix(gateway): 修复粘性会话预取分组错配并优化并发等待热路径
2026-02-22 16:43:33 +08:00
yangjianbo
a89477ddf5
perf(gateway): 优化热点路径并补齐高覆盖测试
2026-02-22 13:31:30 +08:00
yangjianbo
f323174d07
fix(openai): 修复 codex_cli_only 误拦截并补充 codex 家族识别
...
- 为 codex_cli_only 增加 originator 判定通道,避免仅依赖 User-Agent 误拦截
- 扩展官方客户端家族标识,补充 codex_chatgpt_desktop 等常见前缀
- 新增并更新单元测试与网关透传回归测试,覆盖 UA 与 originator 组合场景
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-21 12:06:24 +08:00
0-don
1004bd86ac
feat: add gemini-3.1-pro-preview to model lists
...
Add the newly released Gemini 3.1 Pro model to both the
native API fallback list and the admin UI test model dropdown.
2026-02-20 23:27:30 +01:00
yangjianbo
900cce20a1
feat(sora): 对齐 Sora OAuth 流程并隔离网关请求路径
...
- 新增并接通 Sora 专用 OAuth 接口与 ST/RT 换取能力
- 完成前端 Sora 授权、RT/ST 手动导入与账号创建流程
- 强化 Sora token 恢复、转发日志与网关路由隔离行为
- 补充后端服务层与路由层相关测试覆盖
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-19 08:02:56 +08:00
yangjianbo
5d9667d27a
Merge branch 'main' into test
...
# Conflicts:
# backend/cmd/server/VERSION
# backend/ent/migrate/schema.go
# backend/ent/mutation.go
# backend/ent/runtime/runtime.go
# backend/ent/usagelog.go
# backend/ent/usagelog/usagelog.go
# backend/ent/usagelog/where.go
# backend/ent/usagelog_create.go
# backend/ent/usagelog_update.go
# backend/internal/repository/usage_log_repo.go
# backend/internal/server/api_contract_test.go
# backend/internal/server/middleware/cors.go
# backend/internal/service/gateway_service.go
2026-02-18 20:16:31 +08:00
yangjianbo
fad04ca995
Merge branch 'main' of https://github.com/mt21625457/aicodex2api
2026-02-18 20:10:32 +08:00
shaw
074bd0dfda
fix: 临时移除context-1m-2025-08-07以确保避免sonnet1m触发429
2026-02-18 18:41:30 +08:00
shaw
b41fa5e15f
feat: 前端新增sonnet4.6快捷映射按钮
2026-02-18 17:06:37 +08:00
yangjianbo
d04b47b3ca
feat(backend): 提交后端审计修复与配套测试改动
2026-02-14 11:23:10 +08:00
yangjianbo
3734abed4c
feat(openai): 支持 gpt-5.3-codex-spark 并统一 gpt-5.3 到 codex 计费
2026-02-13 09:28:07 +08:00
yangjianbo
abf5de69fb
Merge branch 'main' into test
2026-02-12 23:43:47 +08:00
程序猿MT
174d7c774d
Merge branch 'Wei-Shaw:main' into main
2026-02-12 23:12:41 +08:00
yangjianbo
a9518cc5be
feat(openai): 增加 OAuth 账号 Codex 官方客户端限制开关
...
新增 codex_cli_only 开关并默认关闭,关闭时完全绕过限制逻辑。
在 OpenAI 网关引入统一检测入口,集中判定账号类型、开关与客户端族。
开启后仅放行 codex_cli_rs、codex_vscode、codex_app 客户端家族。
补充后端判定与网关分支测试,并在前端创建/编辑页增加开关配置与回显。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-12 22:32:59 +08:00
yangjianbo
2f190d812a
fix(openai): 透传OAuth强制store/stream并修复Codex识别
2026-02-12 21:02:52 +08:00
yangjianbo
b6aaee01ce
fix(logging): 修复 warn 级别下系统日志空白问题
...
- 新增 logger.WriteSinkEvent,支持旁路写入 sink,不受全局级别门控影响\n- 在 http.access 中间件中,当 info 被门控时补写 sink,保障 Ops 系统日志可索引\n- 增加 level=warn 场景回归测试,验证访问日志仍可入库
2026-02-12 19:19:11 +08:00
yangjianbo
3511376c2c
chore(logging): 默认使用 console 普通日志输出
...
- 将配置默认 log.format 从 json 调整为 console\n- 将 logger 初始化兜底默认格式调整为 console\n- 同步更新 deploy 配置示例
2026-02-12 19:07:16 +08:00
yangjianbo
584cfc3db2
chore(logging): 完成后端日志审计与结构化迁移
...
- 将高密度服务与处理器日志迁移到新日志系统(LegacyPrintf/结构化日志)
- 增加 stdlog bridge 与兼容测试,保留旧日志捕获能力
- 将 OpenAI 断流告警改为结构化 Warn 并改造对应测试为 sink 捕获
- 补齐后端相关文件 logger 引用并通过全量 go test
2026-02-12 19:01:09 +08:00
yangjianbo
84cc651b46
fix(logger): 修复 caller 字段与 OpsSystemLogSink 停止刷盘
...
修复点:
- zap logger 不再强制 AddCallerSkip(1),确保 caller 指向真实调用点
- slog handler 避免重复写 time 字段
- OpsSystemLogSink 优先从字段 component 识别业务组件;停止时 drain 队列并用可用 ctx 刷盘
补充:新增/完善对应单测
2026-02-12 17:42:29 +08:00
yangjianbo
fff1d54858
feat(log): 落地统一日志底座与系统日志运维能力
2026-02-12 16:27:29 +08:00
Wesley Liddick
d307d48def
Merge pull request #551 from SilentFlower/opus4.6-think
...
[UPDATE] 增强 Claude Thinking 模式支持与 Opus 4.6 动态预算适配
2026-02-11 20:00:22 +08:00
Wesley Liddick
8f0efa16ca
Merge pull request #555 from sususu98/fix/gemini-thoughts-token-billing
...
fix: include Gemini thoughtsTokenCount in output token billing
2026-02-11 19:53:43 +08:00
程序猿MT
8da5fac69e
Merge branch 'Wei-Shaw:main' into main
2026-02-11 18:39:52 +08:00
sususu98
d21d70a5cf
fix: include Gemini thoughtsTokenCount in output token billing
...
Gemini 2.5 Pro/Flash thinking models return thoughtsTokenCount separately
from candidatesTokenCount in usageMetadata, but this field was not parsed
or included in billing calculations, causing thinking tokens to be
unbilled.
- Add ThoughtsTokenCount field to GeminiUsageMetadata struct
- Include thoughtsTokenCount in OutputTokens across all 3 Gemini usage
parsing paths (non-streaming, streaming, compat layer)
- Add tests covering thinking token scenarios
Closes #554
2026-02-11 15:41:54 +08:00
SilentFlower
e73b778d2b
Merge branch 'main' into opus4.6-think
2026-02-11 13:56:30 +08:00
Edric Li
a4a46a8618
✨ feat(antigravity): 添加 onboardUser 支持并修复 project_id 补齐逻辑
...
- 新增 OnboardUser API 客户端方法,支持账号 onboarding 获取 project_id
- loadProjectIDWithRetry 增加 onboard 回退:LoadCodeAssist 未返回 project_id 时自动触发 onboarding
- GetAccessToken 中 project_id 补齐改用轻量 FillProjectID 替代全量 RefreshAccountToken
- 补齐逻辑增加 5 分钟冷却机制,防止频繁重试
- OnboardUser 轮询等待改为 context 感知,支持提前取消
- 提取 mergeCredentials 辅助方法消除重复代码
- 新增 extractProjectIDFromOnboardResponse 和 resolveDefaultTierID 单元测试
2026-02-11 13:41:55 +08:00
SilentFlower
6ae82e04d5
[UPDATE] 优化思考预算逻辑与代码结构
...
🧠 refactor(antigravity): 完善 thinking 预算分配策略并重构工具构建逻辑
2026-02-11 10:39:54 +08:00
SilentFlower
19cca11e00
[UPDATE] 增强 Claude Thinking 模式支持与 Opus 4.6 动态预算适配
...
✨ feat(antigravity): 支持 thinking adaptive 类型并适配 Opus 4.6 动态预算
🧪 test(gateway): 增加 thinking 模式解析与签名块过滤的边界用例测试
2026-02-11 10:31:16 +08:00
yangjianbo
3b0910f664
Merge branch 'main' into test-sora
2026-02-10 18:01:17 +08:00
程序猿MT
1dd3158c7e
Merge branch 'Wei-Shaw:main' into main
2026-02-10 13:55:51 +08:00
shaw
5dd83d3cf2
fix: 移除特定system以适配新版cc客户端缓存失效的bug
2026-02-10 10:28:34 +08:00
yangjianbo
29ca1290b3
chore(test): 清理测试用例与类型导入
2026-02-10 00:37:56 +08:00
Rose Ding
f6cfab9901
feat: 添加 Antigravity 单账号 503 退避重试机制
...
当分组内只有一个可用账号且上游返回 503 (MODEL_CAPACITY_EXHAUSTED) 时,
不再设置模型限流+切换账号(因为切换回来还是同一个账号),而是在 Service 层
原地等待+重试,避免双重等待问题。
主要变更:
- Handler 层:检测单账号 503 场景,清除排除列表并设置 SingleAccountRetry 标记
- Service 层:新增 handleSingleAccountRetryInPlace 原地重试逻辑
- Service 层:预检查跳过单账号模式下的限流检查
- 新增 ctxkey.SingleAccountRetry 上下文标记
2026-02-09 14:26:01 +08:00
yangjianbo
d7011163b8
fix: 修复代码审核发现的安全和质量问题
...
安全修复(P0):
- 移除硬编码的 OAuth client_secret(Antigravity、Gemini CLI),
改为通过环境变量注入(ANTIGRAVITY_OAUTH_CLIENT_SECRET、
GEMINI_CLI_OAUTH_CLIENT_SECRET)
- 新增 logredact.RedactText() 对非结构化文本做敏感信息脱敏,
覆盖 GOCSPX-*/AIza* 令牌和常见 key=value 模式
- 日志中不再打印 org_uuid、account_uuid、email_address 等敏感值
安全修复(P1):
- URL 验证增强:新增 ValidateHTTPURL 统一入口,支持 allowlist 和
私网地址阻断(localhost/内网 IP)
- 代理回退安全:代理初始化失败时默认阻止直连回退,防止 IP 泄露,
可通过 security.proxy_fallback.allow_direct_on_error 显式开启
- Gemini OAuth 配置校验:client_id 与 client_secret 必须同时
设置或同时留空
其他改进:
- 新增 tools/secret_scan.py 密钥扫描工具和 Makefile secret-scan 目标
- 更新所有 docker-compose 和部署配置,传递 OAuth secret 环境变量
- google_one OAuth 类型使用固定 redirectURI,与 code_assist 对齐
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-09 09:58:13 +08:00
yangjianbo
fc8a39e0f5
test: 删除CI工作流,大幅提升后端单元测试覆盖率至50%+
...
删除因GitHub计费锁定而失败的CI工作流。
为6个核心Go源文件补充单元测试,全部达到50%以上覆盖率:
- response/response.go: 97.6%
- antigravity/oauth.go: 90.1%
- antigravity/client.go: 88.6% (新增27个HTTP客户端测试)
- geminicli/oauth.go: 91.8%
- service/oauth_service.go: 61.2%
- service/gemini_oauth_service.go: 51.9%
新增/增强8个测试文件,共计5600+行测试代码。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-09 09:07:58 +08:00
yangjianbo
bb5a5dd65e
test: 完善自动化测试体系(7个模块,73个任务)
...
系统性地修复、补充和强化项目的自动化测试能力:
1. 测试基础设施修复
- 修复 stubConcurrencyCache 缺失方法和构造函数参数不匹配
- 创建 testutil 共享包(stubs.go, fixtures.go, httptest.go)
- 为所有 Stub 添加编译期接口断言
2. 中间件测试补充
- 新增 JWT 认证中间件测试(有效/过期/篡改/缺失 Token)
- 补充 rate_limiter 和 recovery 中间件测试场景
3. 网关核心路径测试
- 新增账户选择、等待队列、流式响应、并发控制、计费、Claude Code 检测测试
- 覆盖负载均衡、粘性会话、SSE 转发、槽位管理等关键逻辑
4. 前端测试体系(11个新测试文件,163个测试用例)
- Pinia stores: auth, app, subscriptions
- API client: 请求拦截器、响应拦截器、401 刷新
- Router guards: 认证重定向、管理员权限、简易模式限制
- Composables: useForm, useTableLoader, useClipboard
- Components: LoginForm, ApiKeyCreate, Dashboard
5. CI/CD 流水线重构
- 重构 backend-ci.yml 为统一的 ci.yml
- 前后端 4 个并行 Job + Postgres/Redis services
- Race 检测、覆盖率收集与门禁、Docker 构建验证
6. E2E 自动化测试
- e2e-test.sh 自动化脚本(Docker 启动→健康检查→测试→清理)
- 用户注册→登录→API Key→网关调用完整链路测试
- Mock 模式和 API Key 脱敏支持
7. 修复预存问题
- tlsfingerprint dialer_test.go 缺失 build tag 导致集成测试编译冲突
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-08 12:05:39 +08:00
yangjianbo
00caf0bcd8
test: 为代码审核修复添加详细单元测试(7个测试文件,50+测试用例)
...
新增测试文件:
- cors_test.go: CORS 条件化头部测试(12个测试,覆盖白名单/黑名单/通配符/凭证/多源/Vary)
- gateway_helper_backoff_test.go: nextBackoff 退避测试(6个测试+基准,验证指数增长/边界/抖动/收敛)
- billing_cache_jitter_test.go: jitteredTTL 抖动测试(5个测试+基准,验证范围/上界/方差/均值)
- subscription_calculate_progress_test.go: calculateProgress 纯函数测试(9个测试,覆盖日/周/月限额/超限截断/过期)
- openai_gateway_handler_test.go: SSE JSON 转义测试(7个子用例,验证双引号/反斜杠/换行符安全)
更新测试文件:
- response_transformer_test.go: 增强 generateRandomID 测试(7个测试,含并发/字符集/降级计数器)
- security_headers_test.go: 适配 GenerateNonce 新签名
- api_key_auth_test.go: 适配 NewSubscriptionService 新参数
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-07 22:14:07 +08:00
yangjianbo
9634494ba9
fix: 修复代码审核发现的10个问题(P0安全+P1数据一致性+P2性能优化)
...
P0: OpenAI SSE 错误消息 JSON 注入 — 使用 json.Marshal 替代 fmt.Sprintf
P1: subscription 续期包裹 Ent 事务确保原子性
P1: CSP nonce 生成处理 crypto/rand 错误,失败降级为 unsafe-inline
P1: singleflight 透传数据库真实错误,不再吞没为 not found
P1: GetUserSubscriptionsWithProgress 提取 calculateProgress 消除 N+1
P2: billing_cache/gateway_helper 迁移到 math/rand/v2 消除全局锁争用
P2: generateRandomID 降级分支增加原子计数器防碰撞
P2: CORS 非白名单 origin 不再设置 Allow-Headers/Methods/Max-Age
P2: Turnstile 验证移除 VerifyCode 空值跳过条件防绕过
P2: Redis Cluster Lua 脚本空 KEYS 添加兼容性警告注释
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-07 22:13:45 +08:00