Skip to content

feat(vertex): 支持按渠道切换 v1beta1 端点(#171) - #180

Merged
woncc merged 2 commits into
mainfrom
cursor/upstream-issue-171-94b521664-20261105
Nov 5, 2026
Merged

woncc merged 2 commits into
mainfrom
cursor/upstream-issue-171-94b521664-20261105

Conversation

@woncc

@woncc woncc commented Nov 5, 2026 •

Copy link
Copy Markdown

🔗 关联任务 / Related Issue

Closes #171

上游:94b521664599d416fead8e57d8318717c0e29058(QuantumNous#8179)。仅向 fork main 提交。

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix)
  • ✨ 新功能 (New feature)
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

📝 变更描述 / Description

Vertex 渠道可切换 Gemini/Imagen 请求到 v1beta1;默认仍为 v1。后端限制版本值,前端支持保存、回读和七语言文案,并复用现有 FormField/Switch。Claude 与开源模型的端点、fork 的项目 ID/区域行为保持不变。

原始移植修改授权的 13 个文件,稳定 patch-id 与上游一致:69cf0d32dce40b6036971b8c306815b1cb9a8d56;以下独立审查返修另改 URL builder 与其既有测试文件,原 13 文件内容保持不变。本移植由 Codex AI 辅助完成,等待独立审查;未代替维护者作人工确认。

📸 运行证明 / Proof of Work

原始候选 ec97b85233a88c497f8a7d5cadf96e33d1d47143 的验证如下(本次返修未重跑前端/全量检查)。原始命令使用 GOMAXPROCS=2 RAYON_NUM_THREADS=2。工具根 T=/home/box/.parallel-project-orchestrator/programs/new-api-cherry-20261022/runtime/R0209W171/g4-R0209W171-94b521664-01/tools。

  • 根目录:GOWORK=off go test -p=2 -overlay=$T/go-overlay.json ./controller ./relay/channel/vertex -run 'TestR0209Vertex|TestGetRequestURLWithAPIKey|TestBuild.*URL' -count=1 -v 通过。覆盖版本校验、两种凭据模式、Gemini/Imagen、流式、默认版本,以及 Claude/开源模型保持原行为。
  • relaykit/:GOWORK=off go test -p=2 ./dto -count=1 -v 与 GOWORK=off go build -p=2 ./... 均通过。
  • web/:bun run test --config $T/vitest.config.ts --maxWorkers=1,6 个新用例通过;bun run test src/features/channels/lib/__tests__/vertex-channel.test.ts src/features/channels/components/__tests__/provider-selection.test.tsx --maxWorkers=1,39 个既有用例通过。
  • web/:bun run typecheck、bun run build 通过;./node_modules/.bin/oxlint --threads=2 -c .oxlintrc.json 检查改动的三个 TS/TSX 文件通过;./node_modules/.bin/oxfmt --threads=2 --check 检查上述文件及七个 locale 文件通过。
  • node $T/browser-check.mjs:真实 ChannelMutateDrawer 配合隔离 API fixture;中文开关回读为开启,点击后关闭,无浏览器异常。已检查 1280px 与 390px 截图,分别为证据目录的 vertex-beta-desktop.png、vertex-v1-mobile.png。

证据目录:/home/box/.parallel-project-orchestrator/programs/new-api-cherry-20261022/evidence/R0209W171/g4-R0209W171-94b521664-01(包含截图、原始日志、测试输入及 SHA-256 清单)。受源码所有权限制,新定向测试保存在独立工具/证据目录,通过 Go overlay 与外部 Vitest 配置执行,未新增仓库测试文件。

限制:全库 bun run format:check 报告 25 个未改动文件的既有格式问题,改动文件检查通过。未运行全量测试、真实供应商请求或生产部署;本次不改数据库、计费或鉴权逻辑,不涉及三数据库矩阵。

独立审查 R171-1 返修(1c582ca8edb0d9a9102ea686fc493bcfa4ac96bc):自定义 base 尾部 /v1 与 /v1beta1 随所选版本替换,避免双版本路径;保留自定义前缀、项目/区域/express 与 Claude/开源模型的固定版本路由。

  • 修改前:GOMAXPROCS=2 GOWORK=off go test -p=2 ./relay/channel/vertex/ -run 'TestGoogleModelURLVersionTransitions|TestNonGoogleModelURLsIgnoreGoogleAPIVersion' -count=1 -v 复现双版本路径失败。
  • 修改后:GOMAXPROCS=2 GOWORK=off go test -p=2 ./relay/channel/vertex/ -count=1 -v 通过;覆盖 API-key express/project、service-account 双向切换、默认/匹配版本与固定版本路由。gofmt、git diff --check 通过。证据:/home/box/.parallel-project-orchestrator/programs/new-api-cherry-20261022/evidence/R0209W171R1/g4-R0209W171R1-vertex-version-transition-01。未运行真实供应商、数据库矩阵或部署;待独立复审。

✅ 提交前检查项 / Checklist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[上游/现在能解] 94b521664 feat(vertex): add per-channel v1beta1 endpoint switch (#8179)

1 participant