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
liuxiongfeng
b368bb6ea1
chore: bump version to 0.1.79.4
2026-02-11 04:55:17 +08:00
liuxiongfeng
9ecb6211d6
docs: update CLAUDE.md and .gitignore
2026-02-11 04:54:11 +08:00
liuxiongfeng
79fba9c8d3
refactor: consolidate failover logic into FailoverState
...
- Merge FailoverRetry/FailoverSwitch into single FailoverContinue action
- Extract HandleSelectionExhausted into FailoverState (was duplicated 3×)
- Move helper functions (needForceCacheBilling, sleepWithContext) into failover_loop.go
- Inline sleepFailoverDelay, replace sleepAntigravitySingleAccountBackoff with constant
- Delete gateway_handler_single_account_retry_test.go (tested removed function)
- Add 6 test cases for HandleSelectionExhausted
2026-02-11 04:54:05 +08:00
liuxiongfeng
37c76a93ab
chore: bump version to 0.1.79.3
2026-02-11 01:56:52 +08:00
liuxiongfeng
86e600aa52
fix: 并发/排队面板支持 platform/group 过滤
...
- 添加 platformFilter/groupIdFilter props 变化监听器,过滤条件变化时
立即重新加载数据(修复选择平台后显示"暂无数据"的问题)
- 全栈为 getUserConcurrencyStats 添加 platform/group_id 过滤支持:
前端 API → Handler 解析 query params → Service 层过滤逻辑
- Service 层通过账号的 group 关联反查用户的 AllowedGroups,
与 GetConcurrencyStats 的过滤模式保持一致
2026-02-11 01:41:34 +08:00
Tian
c8f87a9c92
feat(antigravity): 支持 Refresh Token 批量导入创建 OAuth 账号
...
后端新增 ValidateRefreshToken service 方法和 POST /oauth/refresh-token 端点,
前端新增 API/Composable/UI 集成,OAuthAuthorizationFlow i18n 动态化,
支持在 Antigravity 创建账号时批量粘贴 Refresh Token 自动验证并创建账号。
2026-02-11 01:23:21 +08:00
yangjianbo
f1e884ce2b
feat(openai): 增加 OAuth 透传开关
...
- 仅对 Codex CLI 且账号开启时走原样透传(只替换认证)
- 透传模式禁用工具修正/模型替换,并旁路解析 usage 用于计费
- 管理后台增加开关与文案,ops upstream error 记录 passthrough 标记
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-11 00:59:39 +08:00
yangjianbo
86f3124720
perf(service): 优化重试场景 thinking 过滤性能
...
- 避免全量 Unmarshal 请求体,改为仅解析 messages 子树
- 顶层 thinking 使用 sjson 直接删除,减少整体重写
- content 仅在需要修改时延迟分配 new slice
- 增加 FilterThinkingBlocksForRetry 基准测试
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-11 00:47:26 +08:00
liuxiongfeng
6a1c28b70e
docs: 优化 beta 部署流程,构建服务器共用仓库
...
- beta 和正式共用构建服务器 /root/sub2api 仓库,通过镜像标签区分
- 首次部署和更新 beta 流程统一使用共用仓库 + 分支切换
- 各步骤增加检查点和验证说明
2026-02-11 00:41:05 +08:00
liuxiongfeng
9375f1809c
docs: 部署步骤增加前置检查和验证环节
...
- 各步骤增加检查点说明,确保每步执行成功后再继续
- 步骤 0 强调推送成功确认和未提交改动检查
- 步骤 1 增加版本号验证
- 步骤 2 增加常见构建问题排查(buildx 版本、磁盘空间)
- 步骤 4 增加生产服务器代码同步步骤
- 新增「构建服务器首次初始化」章节
2026-02-11 00:34:48 +08:00
liuxiongfeng
f176150c93
Merge branch 'release/custom-0.1.79'
...
# Conflicts:
# AGENTS.md
# CLAUDE.md
# backend/cmd/server/VERSION
# backend/internal/handler/gateway_handler.go
# backend/internal/handler/gemini_v1beta_handler.go
# backend/internal/service/antigravity_gateway_service.go
# backend/internal/service/antigravity_rate_limit_test.go
# backend/internal/service/antigravity_single_account_retry_test.go
# backend/internal/service/antigravity_smart_retry_test.go
2026-02-11 00:32:11 +08:00
liuxiongfeng
30d25084f0
chore: bump version to 0.1.79.2
2026-02-11 00:22:19 +08:00
liuxiongfeng
91ad94d941
docs: 部署流程改为构建服务器与生产服务器分离
...
镜像构建从生产服务器(clicodeplus)迁移到构建服务器(us-asaki-root),
通过 docker save/load 管道传输,避免编译时资源占用影响线上服务。
2026-02-11 00:20:35 +08:00
liuxiongfeng
57a778dccf
chore: bump version to 0.1.79.1
2026-02-10 23:48:23 +08:00
liuxiongfeng
f702c66659
fix: resolve gofmt alignment issue in failover_loop_test.go
...
Move inline comments to separate lines to avoid gofmt
consecutive-line comment alignment requirements.
2026-02-10 23:40:37 +08:00
liuxiongfeng
a095468850
fix: correct import path in failover_loop.go and failover_loop_test.go
...
Use github.com/Wei-Shaw/sub2api/internal/service instead of
sub2api/internal/service to match the module path in go.mod.
2026-02-10 23:35:21 +08:00
liuxiongfeng
f9b6a20995
Merge tag 'v0.1.79' into develop
...
增强错误处理与重试机制,新增 MODEL_CAPACITY_EXHAUSTED 同账号固定间隔重试、瞬态错误同账号重试优先于故障转移,并大幅优化错误匹配性能。
- MODEL_CAPACITY_EXHAUSTED (503) 使用固定 1s 间隔重试最多 60 次,不切换账号
- 瞬态错误(Google 400、空流响应)同账号重试 2 次后再触发故障转移
- 空流响应触发 failover 自动换号重试,不再直接返回 502
- Google "Invalid project resource name" 400 错误触发 failover 并临时封禁账号 1 小时
- 错误透传规则新增 skip_monitoring 选项,匹配的错误不记录到运维监控日志
- Antigravity 转发支持 daily/prod 单 URL 切换
- 错误匹配性能优化:延迟/限制 body ToLower,预计算规则关键词和平台集合
- MODEL_CAPACITY_EXHAUSTED 全局去重,避免并发请求重复重试
- 503 重试 body 读取限制从 2MB 降至 8KB
- time.After 替换为 time.NewTimer,防止 context 取消时 timer 泄漏
- 临时封禁冷却时间从 30 分钟缩短至 1 分钟(同账号重试耗尽后)
- 修复错误透传规则 skip_monitoring 未生效的问题
- 修复 CI 检查失败(gofmt、errcheck、staticcheck)
# Conflicts:
# backend/internal/service/error_passthrough_runtime_test.go
2026-02-10 23:25:51 +08:00
liuxiongfeng
f2770da880
refactor: extract failover error handling into shared HandleFailoverError
...
- Extract duplicated failover error handling from gateway_handler.go (Gemini-compat & Claude paths) and gemini_v1beta_handler.go into shared failover_loop.go
- Introduce TempUnscheduler interface for testability (GatewayService implicitly satisfies it)
- Add comprehensive unit tests for HandleFailoverError (32 test cases covering all paths)
- Fix golangci-lint issues: errcheck in test type assertion, staticcheck QF1003 if/else→switch
2026-02-10 23:13:37 +08:00
Wesley Liddick
ae6fed15cc
Merge pull request #548 from Edric-Li/main
...
feat: 错误处理增强、重试优化与性能改进
v0.1.79
2026-02-10 22:46:58 +08:00
yangjianbo
4b309fa8b5
fix(gateway): 优化 ParseGatewayRequest 函数,使用 unsafe 提高性能并增加 JSON 校验
2026-02-10 22:12:24 +08:00
Edric Li
378e476e48
fix: 修复 CI 检查失败
...
- gofmt: 修复 error_passthrough_service.go 格式问题
- errcheck: 修复 error_passthrough_runtime_test.go 类型断言未检查
- staticcheck: if-else 改为 switch (gateway_service.go)
- test: 修复两个测试用例错误使用 MODEL_CAPACITY_EXHAUSTED 导致走错路径
2026-02-10 22:08:49 +08:00
Edric Li
2a1067c82b
Merge remote-tracking branch 'upstream/main'
2026-02-10 21:52:33 +08:00
Edric Li
a54b81cf74
perf: 错误处理性能优化
...
- MatchRule 延迟/限制 body ToLower,先用 statusCode 短路,只在需要关键词匹配时转换且限制 8KB
- 预计算规则的小写关键词/平台和 error code set,消除运行时重复 ToLower 和线性扫描
- MODEL_CAPACITY_EXHAUSTED 全局去重,避免并发请求重复重试同一模型
- 503 重试 body 读取限制从 2MB 降至 8KB
- time.After 替换为 time.NewTimer,防止 context 取消时 timer 泄漏
2026-02-10 21:40:31 +08:00
liuxiongfeng
d269659e61
chore: bump version to 0.1.78.2
2026-02-10 21:28:52 +08:00
liuxiongfeng
c4d6715443
chore: squash merge customizations from develop-old-0.1.77
...
- 定制文档: CLAUDE.md, AGENTS.md
- UI定制: 微信客服按钮, 首页改造, 移除GitHub链接
- 部署运维: docker-compose.yml, 压测脚本
- CI/gitignore 小改动
2026-02-10 20:59:54 +08:00
Edric Li
2d4236f76e
fix: 修复错误透传规则 skip_monitoring 未生效的问题
...
- ops_error_logger: status < 400 分支增加 OpsSkipPassthroughKey 检查
- ops_upstream_context: 新增 checkSkipMonitoringForUpstreamEvent,中间重试/故障转移事件也能触发跳过标记
- gateway_handler/openai_gateway_handler/gemini_v1beta_handler: handleFailoverExhausted 匹配规则后设置 OpsSkipPassthroughKey
- antigravity_gateway_service: writeMappedClaudeError 增加 applyErrorPassthroughRule 调用
2026-02-10 20:56:01 +08:00
yangjianbo
166080b29c
chore: 更新版本号至 0.1.74.3
2026-02-10 18:02:02 +08:00
yangjianbo
3b0910f664
Merge branch 'main' into test-sora
2026-02-10 18:01:17 +08:00
yangjianbo
e489996713
test(backend): 补充改动代码单元测试覆盖率至 85%+
...
新增 48 个测试用例覆盖修复代码的各分支路径:
- subscription_maintenance_queue: nil receiver/task、Stop 幂等、零值参数 (+6)
- billing_service: CalculateCostWithConfig、错误传播、SoraImageCost 等 (+12)
- timing_wheel_service: Schedule/ScheduleRecurring after Stop (+3)
- sora_media_cleanup_service: nil guard、Start/Stop 各分支、timezone (+10)
- sora_gateway_service: normalizeSoraMediaURLs、buildSoraContent 等辅助函数 (+17)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-10 17:52:10 +08:00
yangjianbo
54fe363257
fix(backend): 修复代码审核发现的 8 个确认问题
...
- P0-1: subscription_maintenance_queue 使用 RWMutex 防止 channel close/send 竞态
- P0-2: billing_service CalculateCostWithLongContext 修复被吞没的 out-range 错误
- P1-1: timing_wheel_service Schedule/ScheduleRecurring 添加 SetTimer 错误日志
- P1-2: sora_gateway_service StoreFromURLs 失败时降级使用原始 URL
- P1-3: concurrency_cache 用 Pipeline 替代 Lua 脚本兼容 Redis Cluster
- P1-6: sora_media_cleanup_service runCleanup 添加 nil cfg/storage 防护
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-10 17:51:49 +08:00
Wesley Liddick
84ced1c497
Merge pull request #543 from slovx2/upstream_main
...
feat(antigravity): 转发与测试支持 daily/prod 单 URL 切换
2026-02-10 14:57:46 +08:00
song
b161312183
test(antigravity): 更新单URL策略下的重试断言
2026-02-10 14:36:09 +08:00
程序猿MT
1dd3158c7e
Merge branch 'Wei-Shaw:main' into main
2026-02-10 13:55:51 +08:00
song
1f647b120a
feat(antigravity): 转发与测试支持daily/prod单URL切换
2026-02-10 13:51:29 +08:00
Edric Li
7d0a30fa8f
merge: sync upstream main (antigravity single-account 503 retry)
...
合并上游新增的 Antigravity 单账号 503 退避重试机制,
解决与本地 MODEL_CAPACITY_EXHAUSTED 逻辑的冲突,两者共存。
2026-02-10 12:00:21 +08:00
Edric Li
d95e04fd1f
feat: 错误透传规则支持 skip_monitoring 跳过运维监控记录
...
在每条错误透传规则上新增 skip_monitoring 选项,开启后匹配该规则的错误
不会被记录到 ops_error_logs,减少监控噪音。默认关闭,不影响现有规则。
2026-02-10 11:42:39 +08:00
erio
fc4a1c5433
Merge branch 'release/custom-0.1.78'
...
# Conflicts:
# backend/cmd/server/VERSION
2026-02-10 11:41:29 +08:00
erio
6bdd580b3f
chore: bump version to 0.1.78.1
2026-02-10 11:40:36 +08:00
erio
9cf4882f4c
Merge tag 'v0.1.78' into develop
...
Resolve conflict in antigravity_gateway_service.go by keeping both
retry strategies:
- MODEL_CAPACITY_EXHAUSTED: handleModelCapacityExhaustedRetry (ours)
- Single-account 503 long delay: handleSingleAccountRetryInPlace (upstream)
Update tests to reflect that MODEL_CAPACITY_EXHAUSTED always goes
through capacity retry regardless of single-account mode.
2026-02-10 11:32:56 +08:00
erio
406dad998d
chore: bump version to 0.1.77.2
2026-02-10 10:59:34 +08:00
erio
8b0db22c18
Merge branch 'develop' into release/custom-0.1.77
2026-02-10 10:58:52 +08:00
shaw
5dd83d3cf2
fix: 移除特定system以适配新版cc客户端缓存失效的bug
v0.1.78
2026-02-10 10:28:34 +08:00
Wesley Liddick
14e1aac9b5
Merge pull request #533 from GuangYiDing/feat/antigravity-single-account-503-retry
...
feat: Antigravity 单账号分组 503 退避重试机制
2026-02-10 09:59:48 +08:00
yangjianbo
5d1c51a37f
fix(handler): 修复 gjson 迁移后的请求校验语义回退
...
- 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: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-10 09:13:20 +08:00
yangjianbo
58912d4ac5
perf(backend): 使用 gjson/sjson 优化热路径 JSON 处理
...
将 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: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-10 08:59:30 +08:00
erio
f06048eccf
fix: simplify MODEL_CAPACITY_EXHAUSTED to single retry for all cases
...
Both short (<20s) and long (>=20s/missing) retryDelay now retry once:
- Short: wait actual retryDelay, retry once
- Long/missing: wait 20s, retry once
- Still capacity exhausted: switch account
- Different error: let upper layer handle
2026-02-10 04:05:20 +08:00
erio
05f5a8b61d
fix: use switch statement for staticcheck QF1003 compliance
2026-02-10 03:59:39 +08:00
erio
662625a091
feat: optimize MODEL_CAPACITY_EXHAUSTED retry and remove extra failover retries
...
- MODEL_CAPACITY_EXHAUSTED now uses independent retry strategy:
- retryDelay < 20s: wait actual retryDelay then retry once
- retryDelay >= 20s or missing: retry up to 5 times at 20s intervals
- Still capacity exhausted after retries: switch account (failover)
- Different error during retry (e.g. 429): handle by actual error code
- No model rate limit set (capacity != rate limit)
- Remove Antigravity extra failover retries feature:
Same-account retry mechanism (cherry-picked) makes it redundant.
Removed: antigravityExtraRetries config, sleepFixedDelay, skip-non-antigravity logic.
2026-02-10 03:47:40 +08:00