Danbuth's GLM Coding Max account had claimed ZCode's Start Plan (plan_id
zcode-v3-start-plan-1029, named "ZCODE GLOBAL BUILD") and found no Start
Plan on magpie's card. The plugin did read it: usage asks
/billing/balance beside /quota/limit and adds every live gift plan's
buckets after the Coding windows, whatever the plan type, every plan
and not only the first. The bucket was the panel's third ring, named
"ZCODE GLOBAL BUILD · GLM-5.3-Trial", which magpie's ring and account row
cut to "ZCODE GLOBAL BUI…": neither the model nor the plan's kind.
ZCode 3.16.3's own popover (host getStartPlanSnapshot, renderer
"Today's balance") lists these buckets by show_name, apart from the
Coding Plan's windows. So a gift bucket's name now starts with that
(the picker's -Trial id when it counts a model) and the plan follows:
"GLM-5.3-Trial · ZCODE GLOBAL BUILD". A gift-only account with several
plans names them the same way round.
Run (on mote, HOME=$(mktemp -d)): `bun test packages/zcode`, 151 pass 0
fail; `bun scripts/check.mjs`, every package ok, exit 0. The new test
uses a real /quota/limit reply (owner's account, read in a sandbox HOME
copy with GETs only) and the real ZCODE GLOBAL BUILD plan row from #503,
times moved to now. Broken by hand (old label order): the new test and
five others red; put back, green.
Not tried: a real balance of the ZCODE GLOBAL BUILD plan (the owner's
account has none), so its buckets take the shape of ganlerk's Start Plan
balance. Not changed: magpie's tray panel shows at most three rings and
the account row two windows, so beside a Coding Plan's 5h and weekly
only the first gift bucket is on the panel; the rest are in the tooltip
and on the Usage page.
ZCode hands out gift/resource plans that sit on an account until claimed,
and an account used only through magpie let them lapse. The plugin now has
auth.checkin, so magpie's daily check-in (`magpie accounts checkin`, and
Settings -> Daily check-in, where ZCode is off until the user turns it on)
claims them, the shape the MiniMax, Qoder and Loomy plugins use.
claimDaily reads GET /api/v1/zcode-plan/billing/preview (the list the card
already read) and POSTs {"plan_id"} to /billing/claim for each plan it
lists, with the account's ZCode jwt, X-Device-Mid, X-ZCode-App-Version and
X-Platform, as kongbai01203 captured them. The claim is judged by the body's
code: 0 claimed, 1003 "target already exists" (HTTP 200) done, 3007 or a
captcha message "captcha" (claim it in the ZCode app), anything else, an
HTTP error without a code or a body that isn't JSON failed. A failed read is
never taken as claimed, and no answer carries signIn, so a failed claim
leaves the account as it was. Nothing listed is inactive; a key-only
account is ineligible; an expired ZCode session is failed with no request.
A plan claimed now drops the account's cached route, so the next request
uses it. One failed among several makes the whole answer failed (with the
claimed ones named), so magpie asks again later and the claimed ones then
answer 1003.
Run (on mote, HOME=$(mktemp -d)): `bun test` in packages/zcode, 150 pass;
the whole repo's `bun test`, 3698 pass 0 fail of 3706 across 297 files;
`bun scripts/check.mjs zcode` ok. checkin.test.mjs covers preview empty,
one plan claimed with code 0 (request body and headers checked), 1003,
3007, seven unreadable claim answers, five unreadable previews, one
claimed + one failed then asked again, and key/expired accounts asking
nothing. Broken by hand: 1003 -> claimed and an unreadable reply ->
claimed turned three of these tests red; put back, green.
Not tried: a real claim that answers code 0. No account has a plan to
claim right now (every preview answers plans: []), so the code 0 body is
a fixture carrying only its code, and nothing else of it is read. On
10-06 a claim without the ZCode app's Aliyun captcha was answered 400
code 3007 (#30); if ZCode still asks that for a fresh plan, the check-in
says "captcha" and the plan is claimed in the app, as before. The real
1003 reply is in the tests as captured.
windy (Discord): "添加zcode供应商的时候,好像无法区分Coding Plan 和Start Plan的额度?
例如今天23点要生效的Start Plan就没显示".
- A plan on /billing/balance whose starts_at is still to come serves
nothing yet: startPlan no longer routes to it (an "active" plan with a
future start would have been), and its buckets don't count. The card
names it in an aside line "ZCode gift plan not started yet", display
"<plan> · <start in local time>", soonest first.
- A coding account with a ZCode session reads the gift on every card
read, not only while a gift is live, so a coming plan shows beside the
Coding Plan. The route cache is read again when the coming plan starts.
- A gift-only account whose only plan starts later gets a card with that
line instead of "ended or never started".
- Beside a Coding Plan, every gift bucket is prefixed with its plan's
name ("Start Plan · GLM-5.1-Trial"), one plan or several.
Not known: which status ZCode gives a plan that hasn't started. The
fixtures use starts_at as the real balance/preview replies carry it
(Unix seconds) and try both "active" and an unknown status word; any
status but "expired" with a future starts_at is taken as coming. No
real account with a pending plan was read.
Run on mote: HOME=$(mktemp -d) bun test in packages/zcode, 142 pass
0 fail; pending.test.mjs under TZ=UTC, Pacific/Kiritimati and
America/Los_Angeles, 7 pass each; bun scripts/check.mjs, every package
ok. Broken by hand: with the old index.mjs, 6 of pending.test.mjs's 7
tests fail (the 7th, a plan whose start has come, passes on both).
A team seat's ZCode session also reads the person's own gift plans (#359): plansOf no longer returns {start:false, gift:null} for every team seat. A team seat stays on its team plan (its personal plan list is not read), its <model>-Trial entries are listed, its card shows the gift buckets beside the team's windows, and a team seat with no or an expired ZCode session gets the "ZCode gift plans (-Trial models) need ZCode's sign-in" line. Plain models spend the team key; -Trial models go to zcode.z.ai with the ZCode session and no team key or organization header.
Reviewed at 4778e0d (on main ba9801c, merges clean). Run in a worktree, Bun 1.4.2, sandbox HOME and TMPDIR: `bun test packages/zcode` 107 pass, 0 fail. With main's index.mjs put back, 6 fail (the 4 new team-gift tests and the two changed team-seat tests), so the tests guard the change. `bun scripts/check.mjs zcode` ok. Loaded through magpie's plugin host (magpie origin/main 4dfd88206, scripts/try.sh in a sandbox HOME): zcode listed with 4 models.
Not tried: a real team-seat account here; the author reports a BigModel team seat listing the trials and a Flash Trial request answering 200. The version bump (0.1.28) follows in its own commit.
bigsteven (Discord #feedback, 10-24): GLM Coding Plan spent, requests
go to it, and the model list has no GLM-5.3-Trial. Which sign-in the
account has is still asked; three ways the plugin drops a signed-in
account's -Trial entries, or drops them unsaid, are fixed here:
- ZCode's provider config out of reach (cdn-zcode.z.ai, 8s): the list
falls back to the table and is marked magpie.fellBack, and magpie
then keeps the list it was told last (internal/plugin/providers.go),
from before the gift. The -Trial entries just read from the balance
went with it. A list that carries trial entries is no longer marked.
- A gift balance read that failed was cached as "no gift" for ten
minutes beside a good plan list, so one hiccup hid the -Trial
entries and the gift's card section for ten minutes. It is now
unknown and asked again in a minute (an expired session is known,
and kept for ten).
- A key, or a sign-in whose ZCode session has expired (that token
can't be renewed, and with a key beside it the account is never
marked), reads no gift, so it lists no -Trial models, and the card
said nothing. Its card now sets aside a line "ZCode gift plans
(-Trial models) need ZCode's sign-in", with why in the display (an
API key / no ZCode session / sign-in expired).
Run: HOME=<scratch> bun test packages/zcode: 102 pass (3 new tests);
bun scripts/check.mjs zcode ok.
Broken by hand: each of the three fixes reverted alone turns its
tests red (fellBack 1, retry 2, card line 1), restored after.
Changed on purpose: dual.test's "a gift read that fails at once still
trusts the plan list for ten minutes" now says a minute; usage.test's
key and key-only oauth cards carry the new line.
Not tried: a real account (no ZCode sign-in with a gift in this
session), nor a real CDN failure; the config fallback was forced in the
test through _internal.config(null). The new line's name is not yet in
magpie's i18n. A team-seat sign-in (an account with no plan of its own)
still lists no -Trial entries; not changed here.
rtbeilin (X, 10-24) has ZCode 1024 Dev Day and no GLM Coding Plan.
"ZCode app's sign-in" works in magpie; the browser sign-in and the API
key don't.
The key: ZCode's gift plans are served by zcode.z.ai to ZCode's session
token (zcodejwttoken, the poll's `token`). A key carries none, so a key
reaches api.z.ai's / open.bigmodel.cn's coding plan alone, and a
gift-only account has nothing there. The card was empty, no error
(usage.test's own "API key, BigModel's" case: an empty list and no
limits gave {windows: []}), and each request got Z.ai's 1113 "no
resource package" with nothing saying why. Now:
- codingUsage: a subscription list read as having no VALID plan, with no
level, no counted window and no saved plan, is the card's error
NO_PLAN_KEY, which names the gift plans and says to add the account
with "ZCode app's sign-in" or a ZCode browser sign-in. A list that
can't be read keeps the card as it was.
- the fetch: a coding-plan refusal >= 400 to a sign-in with no ZCode
session, whose code is 1113 (error.code, error.type or the envelope's
code), keeps its status and Z.ai's words and adds NO_PLAN_KEY. The
body is read only after the request failed. A sign-in with a session
and any other code go as they came.
README says it under the key method.
The browser sign-in: no cause found. 3.16.3's bundle (the current
stable, downloaded from zcode.z.ai's release manifest) starts, polls
and reads the flow as the plugin does: same init body, the same
redirect / redirect_uri override, the same ready fields, Z.ai's token
exchanged at /api/auth/z/login. yg6888's screenshot in the same thread
shows two Dev Day accounts working in magpie. Not changed here.
Run:
- bun test packages/zcode, scratch HOME: 99 pass. The two new tests
(usage "a key with no GLM Coding Plan...", signin "a key's 1113...")
fail on 0.1.24's index.mjs. bun scripts/check.mjs zcode: ok.
- Real: the owner's real Z.ai key through the new usage hook: card
"GLM Coding Lite", 5 hours + Weekly, no error. A bogus key: card
"Authentication Failed", a request 401 {"error":{"message":
"Authentication Failed","type":"1000"}} unchanged.
Not tried: a real key with no plan (none at hand), so the 1113 body is
magpie's zhipu_coding_test fixture, not a captured one. BigModel's real
answer neither. The browser sign-in with a Dev Day account.
01huadalang (Discord) gets 405 / "ZCode's Start Plan still turned this
request away" again on 0.1.21. #343's check was a curl request to magpie,
which carries no agent headers.
What reached zcode.z.ai: startHeaders set ZCode's headers on top of the
ones it was given and removed only x-api-key, authorization and
X-Device-Mid. A plugin provider has no account of its own in magpie's
gateway, so a request from Claude Code goes to the plugin with
Claude Code's own headers (anthropic-beta claude-code-20250219,...,
x-app: cli, x-stainless-*, anthropic-dangerous-direct-browser-access,
x-claude-code-session-id) and ?beta=true on the URL (gateway.go
claudeCodeHeader, #179). All of that went on to the Start Plan. The
retired built-in deleted anthropic-beta, and its accounts never got the
Claude Code pass-through. ZCode sends none of these on the Start Plan:
its only beta, advanced-tool-use, is for coding plans.
Now startHeaders builds a new header set: the body's content-type and
ZCode's headers, as ZCode.app 3.16.3 (the current stable, 10-23) sends
them in glm/zcode.cjs:
- buildZCodeSourceHeadersFromContext: X-Os-Version is os.release()
alone (it was "darwin 25.2.0 arm64"), and X-Client-Timezone is
"unknown" when there is none.
- createModelRequestAttributionHeaders: the new x-zcode-query-source:
main_turn.
- APP_VERSION goes to 3.16.3 (User-Agent, X-ZCode-App-Version and the
app_version query).
The Start Plan URL loses its query. Prompt texts, the Start Plan
provider entry and ai-sdk/anthropic 3.0.81 are the same in 3.14.3 and
3.16.3 (checked against both bundles). The GLM Coding Plan and team
paths are unchanged, and a new test holds that they keep the agent's
query and headers.
Not established: which header (if any) zcode.z.ai keys on. No Start
Plan account was used. A network block of the user's IP is still
possible, and the error still says so.
Run: bun test in packages/zcode under a temp HOME, 90 pass. The two
start.test.mjs header tests fail on 0.1.21's index.mjs (Claude Code's
x-app/x-stainless-*/anthropic-beta and the query reach the fake).
What changed, for parity with magpie's built-in ZCode before it retires:
- Personal resets. The built-in's zcodeQuota read
/api/biz/customer-package-reset/list?targetType=PERSONAL with the plan's
key (zhipuPersonalResets, yetone/magpie#1191) and showed the count, by
window, and each reset's end. The plugin read only the team's list.
codingUsage now reads the personal list alongside the subscription list,
so a Coding Plan card (and a dual gift + Coding Plan card, built on it)
carries resets: {count, byWindow, fiveHour, weekly, until, each}.
- Team resets now carry team: true and each, as zhipuTeamResets set Team.
Both lists are read by one resetsOf: only available ones count, each
{until?, window} sorted soonest first with an endless one last
(sortResetCards), nothing on a failed read or none left.
- Start Plan refusal. A Start Plan answer that is a 405, the block page
("request has been blocked" / errors.aliyun.com) or code 3012 / "unusual
activity" now comes back, same status, as {type:"error", error:{message:
"<vendor's words, or the status for a block page> — <hint>"}}, the hint
word for word magpie's provider.ZCodeStartBlockedHint, as the built-in's
zcodeStartExplain / Provider.Explain put it. The block page's own words
are left out, so magpie's APIError no longer reads it as a network
firewall's (BlockedHint). Coding Plan and team answers are untouched.
- README: the resets and the Start Plan's hint.
What was run:
- usage.test.mjs: a new test with #1191's literal reset list (the
built-in's zhipuResetList) fails on 0.1.18 (no resets); the team test,
now expecting team and each, fails on 0.1.18 too.
- start.test.mjs: the new refusal test fails with the startBlocked line
disabled by hand (block page passed through), passes with it.
- Every packages/zcode test file under a scratch HOME: dual 25, gift 20,
models 1, moved 1, own 6, signin 3, start 11, usage 16 (83 pass).
- bun scripts/check.mjs zcode passes.
Not tried: a real account's reset list or a real Start Plan refusal.
`team` and `each` reach magpie's card from its next release; older magpie
ignores them.
The claim line was a window named after the plan and displaying
"1 to claim · claim it in the ZCode app". magpie shows a window's
display as it came — quotaCount (internal/gui/assets/app.js) returns
w.display when the window has no limit — and translates only the name
(t(w.name), on the card, the tips and the chart), so the line stayed
English on a Chinese interface (yetone/magpie#1001). The plugin cannot
know the interface's language (host.js and provider.Provider hand it no
locale) and magpie's translation is keyed by the string, so the
sentence has to be the name.
The window is now named "Gift plans to claim in the ZCode app" and its
display is "1 · ZCode Trust Build": the count and the plan's own name,
which are data and stay as they came, and one name for any number, so
no plural forms are needed. aside, the placement after every real
window, and the failure handling (nothing to claim, a failed preview or
an error card add no line) are unchanged. magpie adds the zh/ja/de
entries for that name alongside this.
usage.test.mjs: the fixtures carry the new name and display, and the
names list of "a coding account's line goes after its coding and gift
windows". Four of them fail on 0.1.12; bun test packages/zcode (73
pass) and bun scripts/check.mjs zcode pass.
ZCode hands out one-off trust-build / gift plans that are not on the
account until the ZCode app claims them; the plugin only ever consumed
gifts already granted, so an account signed in through magpie alone sat
on the entitlement and it lapsed unclaimed (yetone/magpie#1001). The
claim itself cannot be made here: POST /billing/claim is answered 400
code 3007 "captcha verify failed" without the Aliyun captcha
attestation, and the SDK that makes it (AliyunCaptcha.js) throws unless
window and document exist, so only the app's renderer can claim one.
The author asked for the read-only half instead: ask the app's own list
(GET /api/v1/zcode-plan/billing/preview, the call the app's settings
dialog makes) while the usage card is read, and name what it lists.
The line is a window set aside, so the card shows it and routing, usage
caps and the menu bar pass it over (allowanceOf skips Aside windows;
sameAccount skips them too, so a GLM key's plan still matches the
account by its real windows). It goes last, after the coding plan's and
the gift's own buckets. A preview that fails or lists nothing adds no
line at all, a card that is an error keeps its error and asks nothing,
and an expired sign-in is no request either: the read never changes a
card or a route.
Both fixtures are real responses: an account's preview while the day's
ZCode Trust Build was unclaimed, and one after it had claimed it
(plans: []). usage.test.mjs is new (6 cases; all 72 of the package pass,
bun scripts/check.mjs zcode passes). The preview's shape is also
verified against a real account: the request goes out on the JWT with
the device id, app_version and platform the app sends.
Why: 0.1.8 sent every request for a gift-served model to the gift first, so a user who meant to spend the coding plan had no say, and the card hid the gift's models behind notModels. The gift is an allowance outside the plan; spending it should be a choice.
What: every model a live gift bucket serves is listed again as <model>-Trial, in the catalog's spelling (GLM-5.3-Flash-Trial), and a request for that entry goes to the gift dressed as ZCode's own; a plain model always spends the coding plan. A trial entry whose bucket is spent or blocked answers 429 without touching the coding plan, as do the gift's quota errors (1113, 1005 inside a 200); any other gift answer goes on as it came. The usage card names the gift window by its trial model, drops the plan prefix, and puts MCP - Month last.
Tests: dual.test.mjs rewritten for the new routing (a plain model to the coding plan whatever the gift holds, a trial entry to the gift), usage.test.mjs and gift.test.mjs follow the naming; bun test (65 pass in the package, 516 in the repo) and bun scripts/check.mjs zcode pass.
bun test runs every file in one process, and three usage tests left
globalThis.fetch on a fake of theirs: zcode's (offline, set in a
beforeEach, never restored), kiro's and workbuddy's (offline, set at
import, never restored). A file run after them got that fake:
- minimax's tests (27/27 alone) failed 19 after zcode's usage test: the
plugin's requests to the local fake MiniMax went to zcode's offline and
threw "no network in tests".
- qoder's cn.test.mjs takes globalThis.fetch as the real one when it loads;
after kiro's or workbuddy's usage test that was offline, so every request
meant for its Bun.serve stand-in threw. The CN sign-in, which polls on
through errors, timed out at 10 s and kept polling, and the job-token test
timed out too, so a full bun test never finished.
Each of the three now keeps the fetch it found and puts it back in
afterAll. Test-only; no package version changes. HOME=$(mktemp -d) bun
test: 341 pass, 0 fail across 42 files (8.5 s); bun scripts/check.mjs
passes.