Skip to content

feat(providers): add experimental Huawei Cloud CodeArts (码道) adapter - #436

Merged
caigee-cmd merged 12 commits into
caigee-cmd:mainfrom
yoruuuchan:feat/codearts-provider
Oct 30, 2026
Merged

caigee-cmd merged 12 commits into
caigee-cmd:mainfrom
yoruuuchan:feat/codearts-provider

Conversation

@yoruuuchan

@yoruuuchan yoruuuchan commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add an experimental Huawei Cloud CodeArts Agent (码道) provider.

  • In-process OAuth PKCE adapter; short-lived STS credentials; direct OpenAI-compatible chat/SSE to snap-access.cn-north-4.myhuaweicloud.com.
  • No CodeArts IDE/CLI per request.
  • Catalog merges agent-center, builtin, and benefit sources; native model_id is kept separate from display model_name.
  • Vision models receive image content parts (supports_images from the builtin catalog); text-only models reject images with 400.
  • Reasoning levels come from /v1/model/thinking-variants; the selected max level is forwarded as reasoning_effort instead of being dropped to the upstream default.
  • Quota meters and daily/new-user credit check-in.
  • Registered as provider=codearts, region cn-north-4; console login and model settings updated.

Live acceptance

Single account:

  • OAuth login -> ready; 10 models called through Chat Completions.
  • Chat Completions, Anthropic Messages, and Responses: non-stream, stream, tools, reasoning, usage.
  • Image input verified on all three APIs with Qwen3-VL-235B; image tokens reflected in usage.
  • Reasoning options {high, max} exposed for GLM-5.2; console selection max persists as reasoning_effort=max and the chat request succeeds.
  • Quota read and check-in verified.

Two accounts:

  • Both ready; sticky session on account 1.
  • Disable account 1 -> same session fails over to account 2.
  • Re-enable account 1 -> session stays on account 2.
  • Disable account 2 -> session fails back to account 1.

Validation

  • go test ./... green on Linux (golang:1.25 container).
  • go vet, gofmt, git diff --check, changelog validation.
  • npm run lint and npm run sync with the locked frontend toolchain.
  • GitHub CI: go, windows-host, worker, frontend, container, secrets all pass.

Known limitations

  • Quota-exhaustion failover and normal load distribution were not live-tested.
  • Benefit-success path was not live-tested; both accounts are credit-only trials. Credit fallback is verified.
  • Image URLs/dimensions are subject to upstream behavior; data-URL images are verified.
  • Unusable-model learning is in-memory with a 30-minute TTL.

Experimental provider; not claiming full production acceptance.

@yoruuuchan

Copy link
Copy Markdown
Contributor Author

The previous head failed the frontend check because the embedded assets were generated locally with Vite 8.3.5 while \ rontend/package-lock.json\ pins 8.2.2. \�c97b3b\ regenerates \internal/webui/static\ with a clean Linux
pm ci\ (Vite 8.2.2). The new head currently has no workflow run on the fork branch; could a maintainer approve the workflow run? Thanks.

# Conflicts:
#	internal/webui/static/assets/AreaChart-OALiCBPp.js
#	internal/webui/static/assets/CartesianChart-VdPlNA-v.js
#	internal/webui/static/assets/CostChart-Pl_W6MDd.js
#	internal/webui/static/assets/LiveSparkline-DiMX1dL0.js
#	internal/webui/static/assets/TrafficChart-Dr6Iq6yR.js
#	internal/webui/static/assets/XAxis-CA8kJY2M.js
#	internal/webui/static/assets/index-BbhKWyTC.js
#	internal/webui/static/index.html
@yoruuuchan
yoruuuchan marked this pull request as ready for review October 30, 2026 01:54
@caigee-cmd

caigee-cmd commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

感谢提交码道适配器。进程内实现、凭据刷新,以及原生 model id 和展示名分开处理,这些都没问题,CI 也是绿的。现有账号不会受影响。

合并前有几处控制面的小缺口,都不影响其它供应商:

  1. codearts/ 模型前缀还没接到请求路由上。internal/executor/prepare.go 里的 providerPrefixes 仍停在 kimi/,所以 codearts/<model> 钉不住这个供应商。跨供应商池关闭时,这个 id 会落到 Qoder;池打开时,前缀会被忽略。README 和控制台提示已经写了这个前缀,请把它加进这张表。

  2. 调用方的 system prompt 默认仍会被丢掉。控制台给码道传的是 drop_system_prompt: false,但 accounts.DefaultDropSystemPrompt 只对 trae 和 kimi 返回 false。导入或通过 API 创建、又没带这个字段时,system prompt 会被剥掉。请把 codearts 加进这个 switch。

  3. 控制台里保存的 reasoning 档位刷新后不会回来。internal/console/models.go 的 modelSettingResponse 只给 trae、workbuddy、kimi 返回 reasoning_effort,码道会落到通用响应里,已保存的档位刷新后就没了。请按 kimi 的方式处理(只返回 reasoning,不带 max-mode)。

另外两处顺手即可:internal/app/architecture_test.go 的 isConcreteProvider 还没列入 codearts,分层检查覆盖不到新适配器;catalog.go 里 toModelInfo 的注释仍写着不声明图片,和现在的转发实现不一致。

额度耗尽切换还没实测,作为实验性供应商可以接受。上面三条补上之后就可以合。

@yoruuuchan

yoruuuchan commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor Author

已按 review 补齐,当前 head 9b4d43c:

  1. internal/executor/prepare.go 的 providerPrefixes 加入 codearts/,并补了 ProviderPrefix / ResolveProviderFilter 的测试;codearts/<model> 现在能正常钉住供应商。
  2. accounts.DefaultDropSystemPrompt 的 switch 加入 codearts,API/导入创建且未显式传字段时默认保留 caller system prompt;测试同步覆盖。
  3. console.modelSettingResponse 把 codearts 按 Kimi 处理,只返回 reasoning_effort,不返回 max_mode;补了 PATCH/GET 响应测试。

顺手项也处理了:

  • internal/app/architecture_test.go 的 isConcreteProvider 加入 codearts;
  • internal/providers/codearts/catalog.go 的 toModelInfo 注释改为图片/思考档位按目录声明转发。

CI 六项全绿(go / windows-host / worker / frontend / container / secrets)。额度耗尽切换仍如你所说,保持实验性未实测。可以继续看是否还有需要补的。

@caigee-cmd
caigee-cmd merged commit 9dd233a into caigee-cmd:main Oct 30, 2026
6 checks passed
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.

2 participants