Skip to content

lane: CodeArts 渠道改为原生移植,拆掉 v1.7.17 的内嵌服务 - #90

Merged
LAGcomcom merged 2 commits into
masterfrom
port/codearts-native
Oct 17, 2026
Merged

LAGcomcom merged 2 commits into
masterfrom
port/codearts-native

Conversation

@LAGcomcom

Copy link
Copy Markdown
Owner

按反馈重做 #82:不是把 codearts2api 整个嵌进来跑一个 HTTP 服务,而是只把它的协议移植进 zen-gate 自己的渠道体系——和 WorkBuddy / Kilo 同一种原生渠道。

拆掉的(v1.7.17 / #82 的内嵌方案)

internal/codeartshub/ 整棵树删除:HTTP server、账号池、独立调度器、panel.html、:8096 上的第二套 OAuth 登录。

保留并移植的(协议层)

  • internal/codearts/upstream + auth(它自带的测试套件一并保留、照常跑):华为云 SDK-HMAC-SHA256 签名、DPoP(ES256,refresh 与密钥绑定的根源)、OAuth PKCE + ticket 轮询双通道、/api/v2/chat/completions SSE、三路模型发现(agent-center / builtin / 限时福利)与 maas_type 路由、每日签到积分领取。
  • lane 层 CAAccount:一个落盘账号(STS 三元组 + refresh 绑定),WorkBuddy 同款契约——临近过期先续、401 刷新重试一次、caMu 单飞(DPoP 绑定的轮换不允许并发 refresh,否则锁死账号)。
  • ChannelCodeArts 进目录机制:账号门控的在线发现(福利套餐是轮换的,做不了静态表)、无指纹的 chat post 带会话稳定的 Chat-Id、独立探测、福利模型自动带 maas_type: benefit。
  • 仪表盘卡片与 WorkBuddy 完全同构:授权登录按钮(服务端默认浏览器打开华为门户,回调/轮询都在 lane 内完成)、退出登录、启用开关走自己的 dirty-key 分支(gateway: the WorkBuddy switch must reach the config it publishes #69 的教训)、Masked() 掩掉全部 5 个机密字段 + DPoP 密钥、每日签到挂在 main 的小时循环上。

测试

lane 8 例(httptest 全链路:ticket 登录、近过期先续、401 刷新重试 + Chat-Id/Session-Id 亲和、福利头、过期解析、错误分类)+ gateway 开关持久化 + store 掩码/深拷贝。go vet + go test ./... 全绿。

注意:本 PR 取代 v1.7.17(那个 release 的渠道实际没法登录——hub 启动时从磁盘读账号文件,卡片按钮只是链到它自己的 panel)。合并后我会发 v1.7.18 并在公告里说明升级路径。

Huawei Cloud CodeArts Agent's free tier arrives as a fourth lane channel, built on
a port of codearts2api's protocol (MIT) rather than its process. The v1.7.17 hub
kept the whole upstream binary in-repo (HTTP server, account pool, its own
scheduler, a second OAuth panel on :8096); what zen-gate needs is only the wire
language — the login round-trip, the account lifecycle and the model catalog all
belong to the lane, the same way the WorkBuddy and Kilo sources work.

- internal/codearts/upstream + auth: the signer (SDK-HMAC-SHA256 over all
  headers), DPoP (ES256), OAuth PKCE + ticket-poll fallback, the chat stream,
  model/benefit discovery and the credit check-in. Its own test suite ships and
  runs with it. The server/pool/scheduler/panel are gone; internal/codeartshub
  is deleted.
- lane CAAccount is one persisted account (STS triple + the refresh binding),
  the WorkBuddy contract: refresh before expiry, one 401 refresh-and-retry per
  turn, single-flight under caMu — a double refresh on the DPoP-bound rotation
  locks the account out, so every exchange holds the lock.
- ChannelCodeArts joins the catalog machinery: account-gated live discovery (a
  rotating benefit roster cannot be a static table), a fingerprint-free chat
  post keyed by a stable per-conversation Chat-Id, its own probe, and benefit
  models ride the maas_type header discovery proved they need.
- The dashboard card mirrors WorkBuddy's: 授权登录 opens the Huawei portal in
  the DEFAULT browser — the loopback callback races the ticket poll inside the
  lane — with model badges, and the enable switch persists through its own
  dirty-key branch. Masked() hides all five secret fields plus the DPoP key.
- The daily credit check-in rides main's loop like WorkBuddy's activity claim.

Tests: 8 lane cases (ticket login, both refresh paths with the chat-affinity
headers, the benefit header, expiry round-trip, error shapes), settings
persistence, and store masking/clone. go vet + go test ./... green.
The v1.7.17 provider-tracking probe tested symbols the native port
removes; its settings half is replaced by codearts_settings_test.go
and its account-state half by the lane CAAccount tests.
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.

1 participant