Skip to content

lane: the WorkBuddy lane speaks the CN publishment too, and checks in daily - #89

Closed
ghshhf wants to merge 1 commit into
LAGcomcom:masterfrom
ghshhf:pr-cn-realm-daily-checkin
Closed

ghshhf wants to merge 1 commit into
LAGcomcom:masterfrom
ghshhf:pr-cn-realm-daily-checkin

Conversation

@ghshhf

@ghshhf ghshhf commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

The WorkBuddy channel could only ever log into the international publishment. wbAccountFromToken refused any issuer that did not contain workbuddy.ai, so a codebuddy.cn account was rejected at the door with 令牌不属于国际版(workbuddy.ai),本渠道暂只支持国际版 — there was no way to add one.

This PR teaches the lane both publishments, and gives the CN one its real daily-earn endpoint.

The two publishments are not one host

That is the part worth knowing before reading the diff. CN splits across domains:

CN intl (current)
chat copilot.tencent.com + /v2/chat/completions www.workbuddy.ai + /v2/chat/completions
billing meter www.codebuddy.cn www.workbuddy.ai

Asking the meter on the chat host is why the CN credit read 404'd. The realm now carries the whole family — base, billing base, Origin, X-Domain, user-agent — through a table, so login, refresh, chat and the credit read each land on the right host.

The realm is the publishment the user picked when opening the login, unless the token's own issuer names one: a silent issuer must not silently downgrade a CN account to intl.

CN earns its daily through an endpoint, not a conversation

intl claims the daily with a one-token conversation (the shape fixed in #85). CN has a real one: POST /v2/billing/meter/daily-checkin.

It answers HTTP 400 with code: 10001 今天已签到 once the day is claimed. Judging by status alone would log a failure and retry hourly against a wall all day, so 10001 is treated as idempotent success and closes the local day. The hourly tick runs whichever daily the account's realm has.

What deliberately did not change

  • The free-model catalog is untouched. hy4-preview-f, hy3 and deepseek-v4.1-flash exist on both publishments; inventing CN-only model ids would have been guessing.
  • No multi-account. The account gained realm and lastCheckinDate, but it is still one account. A pool is a different change and a different risk profile.

On the endpoints

The domain split and the checkin path are taken from ardeyouxipianyi/workbuddy2api-hub (MIT), which already drives both publishments. They are consistent with the CN client's own traffic, but I could not verify them end to end: finishing a CN login needs a codebuddy.cn account to scan the QR, which I do not have. The chat path, the meter host and the checkin code handling are covered by tests against a local server; the live CN handshake is not. If a CN account is available, the 版本 picker on the card now offers 国内版 and the 签到 button exercises the whole path.

Tests

Five added, on internal/lane:

  • the checkin posts to the CN billing host, not the chat one
  • a 10001 answer closes the day instead of retrying
  • an intl account never fires a checkin
  • a CN token routes to copilot.tencent.com for chat
  • issuer evidence decides the realm when present

go vet ./... and go test ./... are green (17 packages).

… daily

The channel could only ever log into workbuddy.ai — wbAccountFromToken
refused any other issuer outright, so a codebuddy.cn account could not be
added at all. The two publishments now ride a realm table: chat on
copilot.tencent.com, the billing meter on www.codebuddy.cn (a different
host, which is why the meter 404'd when asked on the chat one), each with
its own Origin/X-Domain/UA family. The realm is the login the user opened,
unless the token's issuer names one — a silent issuer must not silently
downgrade a CN account to intl.

CN also earns its daily differently. intl claims it with a tiny
conversation; CN has a real endpoint for it, /v2/billing/meter/
daily-checkin, which answers HTTP 400 with code 10001 once the day is
claimed — so the day closes on that code too, instead of retrying hourly
against a wall. The hourly tick runs whichever daily the account's realm
has; the card grows a 版本 picker and a 签到 button for CN.

The static free-model catalog is untouched: hy4-preview-f, hy3 and
deepseek-v4.1-flash exist on both publishments.

go vet ./... and go test ./... are green.
@LAGcomcom

Copy link
Copy Markdown
Owner

@ghshhf CN realm 支持的设计读过了——多域名拆分(聊天 host 与 manager host 分离、realm 配置对象取代硬编码常量)是对的,CI 三平台也绿。但目前 mergeable=false:它落后 master 4 个提交,#90/#88/#86 刚改过 workbuddy_account.go(每日活跃信封修复)、main.go、admin.go、index.html,正好和你这边重叠。麻烦 rebase 到最新 master 解一下冲突(wbApplyModelQuirks 现在也被每日签到走了,你的 checkin 可以直接复用),推上来 CI 过了我就合。如果你这几天不方便,我这边 git 通道恢复后代rebase 也行。

@LAGcomcom

Copy link
Copy Markdown
Owner

已通过 rebase 版 #93 合并(原分支落后 master 4 个提交、与 #90/#88/#86 重叠所以 mergeable=false)。设计完全按你的来——两个 publishment 域名拆分(chat 走 copilot.tencent.com、meter 走 www.codebuddy.cn)、realm 配置对象取代硬编码、CN 走真实签到端点而非 intl 的活动对话,都很到位。我只做了 rebase + 冲突解决(client.go 插 wbLoginRealm 字段、workbuddy_test.go 两侧测试都保留)。作者署名保留在你名下。感谢这份贡献。

@LAGcomcom LAGcomcom closed this Oct 17, 2026
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