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.
小八 (Discord #general, 10-24): Claude Code through magpie on ZCode
(glm-5.3, glm-5.3-flash) gave subagents only the deferred MCP tools;
Bash, Read and Write were missing. Another upstream worked.
Cause, measured against api.z.ai with a real GLM Coding Plan account:
when a request's tools include one named exactly "ToolSearch", z.ai
shows the model none of the other tools except those a tool_reference
loaded. Claude Code 2.1.310's subagent request (captured from the real
binary in a sandbox HOME) has Agent, Bash, Edit, Read, Skill,
ToolSearch, DeferredToolPlaceholder (defer_loading) and Write. Input
tokens for that request: 2886 with ToolSearch, 2439 with no tools at
all, 5995 without ToolSearch. ToolSearch plus Bash also counts 2886.
Renaming the tool (tool_search, ToolSearchTool, SearchTools, ...) gives
6346, every tool counted. The anthropic-beta header changes nothing
(with or without advanced-tool-use: 2886), and neither does
defer_loading. So 0.1.22's dropped beta on the Start Plan is not the
cause; the coding plan path, which keeps the agent's headers, fails
the same way. ZCode 3.14.3's own client sends no ToolSearch tool and
no defer_loading (glm/zcode.cjs).
Now every path (GLM Coding Plan, team, Start Plan and gift) sends
Claude Code's ToolSearch as ToolSearchTool, in the tools and in the
assistant turns that called it. Tools go without defer_loading, as
ZCode's do; Claude Code sends a deferred tool's schema only after a
search loaded it. DeferredToolPlaceholder is left out. The tool_reference
results stay. The model's calls to ToolSearchTool come back to Claude
Code as ToolSearch, in a stream's content_block_start or a whole
message's content. A request without ToolSearch, or one that already
has a tool named ToolSearchTool, goes as before.
Run:
- toolsearch.test.mjs: 4 of 5 fail on 0.1.23's index.mjs (the
passthrough test passes on both). bun test packages/zcode under a
scratch HOME: 97 pass. bun scripts/check.mjs zcode: ok.
- Real, through the plugin's fetch to api.z.ai (GLM Coding Plan),
real Claude Code 2.1.310 in a sandbox HOME with a stdio MCP server:
on 0.1.23, "spawn a subagent to run ls -a with Bash" ended with the
model saying it had no Agent tool. On this change the subagent ran
Bash and returned the listing. A deferred MCP tool loaded through
ToolSearch (now sent as ToolSearchTool) and was then called.
Not tried: the Start Plan against z.ai. The account's Start Plan
quota is spent (1005 exceed quota limit), so that path has only the
fake-server test. BigModel (open.bigmodel.cn) was not tried either.
01huadalang (Discord #feedback, 10-24): an account with the 1024 plan and
the new-user plan showed GLM-5.3 at 0 once the new-user plan's GLM-5.3 was
used up, and never showed the 1024 plan's GLM-5.3.
Cause: the plugin already kept every live plan's buckets (giftOf) and
counted a model on the live one (bestBuckets), setting the spent one aside.
But every window was named by its bucket's show_name alone, so both read
"GLM-5.3", and the windows went out in the balance's order: the new-user
plan's spent GLM-5.3 and its Flash first, the 1024 plan's after. magpie's
account row shows a card's first two windows and puts the rest in its
tooltip, so the row showed the spent GLM-5.3 at 0 and the 1024 plan's
allowance was out of sight, and where both showed they couldn't be told
apart.
Fix (startUsage and dualUsage alike): when the gift's buckets come from
more than one plan, each window is named "<plan> · <bucket>" ("ZCode 1024
Dev Day · GLM-5.3"); one plan's buckets keep their own names, as before.
The windows a request spends go before those set aside, each group in the
balance's order. A used-up plan still shows, at 100% used, set aside.
The 1024 plan's plan_id, name, show_names, capabilities and grant_units in
the new fixture are real bytes: the owner's account read
/billing/preview (read-only GET, credentials read in memory, nothing
written) and is offered "ZCode 1024 Dev Day" (zcode-v3-start-plan-1024,
GLM-5.3-Flash 300M, GLM-5.3 200M). That account has no active plan, so
its /billing/balance is empty; the balance rows are written in the shape
the existing fixtures use, and the new-user plan's name is the Start
Plan's from ganlerk's balance. The reporter's real balance wasn't seen.
Run at this head (parent efa41e3, origin/main fetched just before):
- packages/zcode: HOME=$(mktemp -d) bun test (Bun) 92 pass, 0 fail. The
tests import bun:test, so they don't run under Node; under Node 24 the
plugin loaded (node --check) and a scratch script ran auth.usage over the
reporter's two-plan shape, gift-only and with a coding plan, and gave
the labelled, ordered windows.
- Whole repo, as CI runs it: HOME=$(mktemp -d) bun test 2375 pass,
0 fail; bun scripts/check.mjs all pass.
- Broke it by hand: index.mjs at efa41e3 turns the two new gift tests and
ganlerk's test red (3 fail); keeping the labels but dropping the
ordering turns both new tests red.
Changed expectations: ganlerk's test and dual.test's "every live plan"
test have two plans, so their windows now carry the plan's name.
Not tried: no account with two active gift plans was available, so no
real card with both was seen in magpie. Not changed: in dualUsage a
spent bucket set aside keeps its plain model names (startUsage drops
them); aside windows don't count, so left as it was.
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).
fordlyn's report: on a Start Plan account zcode.z.ai now answers every
request whose system has more than three blocks with 405
{"code":3012,"msg":"request has been blocked due to unusual activity."}.
dress() put ZCode's three cached blocks first and then the agent's own
system texts as blocks 4, 5, ..., so every agent (all of them send a
system prompt) was turned away; only a system-less request passed.
What ZCode does, read from ZCode.app 3.14.3's glm/zcode.cjs
(ContextBuilder.assembleSystemMessages): it sends at most three system
messages, the cli_prefix section, the stable sections, and every dynamic
system section joined with "\n\n" into a third block that starts with
"\n\n". A section added to the builder (addSection) is dynamic by
default, so ZCode's own extra system text lands in the third block.
dress() now does the same: the agent's non-blank text blocks are joined
with "\n\n" after afterEnvironment in the third block, which keeps its
cache mark. The first two blocks stay byte for byte ZCode's, as the
issue's bisect requires. GLM Coding Plan and team requests are not
dressed and are unchanged.
Run: TMPDIR=<scratch> HOME=<scratch>/home bun test (2341 pass, 0 fail);
bun scripts/check.mjs (all ok). The new #343 test in start.test.mjs and
four updated layout tests are red on the old index.mjs (5 of 12 fail).
Not tried against the real API: no Start Plan account at hand. The
reporter's own harness got 200 for this shape (system "x", system plus
tools, 32 KB system, multi-turn).
An account with a GLM Coding Plan of its own and a seat on a team's plan
could only reach its own plan: signedIn took the own plan whenever there
was one and looked for a team seat only when there wasn't. ZCode itself
defaults the same way but lets the user switch its plan picker to the
team's plan (a "team-coding-plan" selection with the team's organization
and project, read from ZCode.app's bundle).
New sign-in method "ZCode: a team's GLM Coding Plan" (asks Z.ai or
BigModel, as the key method does) signs in through the same ZCode flow
and takes the team seat alone: the team project's zcode-team-api-key, as
the existing team-only route already does. It is saved under
"<email> (team)" so magpie's host keeps it as a second account instead of
replacing the own-plan account of the same email. With no seat it fails
with the reason and never falls back to the own plan. Existing sign-ins
are unchanged.
Run: TMPDIR=<scratch> HOME=<scratch>/h1 bun test (2016 pass, 0 fail);
bun scripts/check.mjs (all ok). team.test.mjs goes red (2 of 4) with the
onTeam argument dropped from the callback. Not tried against a real
account with both plans (none at hand).
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.
What changed: ZCode 3.15 keeps no coding plan key in credentials.json any
more. The key it uses is in config.json, at provider["builtin:bigmodel-
coding-plan" / "builtin:zai-coding-plan"].options.apiKey; ZCode 3.15.3's
host reads that value as it is. ownSignIn found no key, so a signed-in
GLM Coding Plan account fell to the Start Plan and read as having no plan.
ownSignIn now falls back to config.json (configKey) when credentials.json
has no key: Z.ai's first, then BigModel. It also takes the provider ids
3.15 normalizes to (account:*-individual-coding-plan) and a value written
encrypted. A value that isn't a key, such as "{env:...}", is skipped. A key
in credentials.json and a team switch still come first. This matches
magpie's built-in (magpie 1d8e83a79, zcodeOwn/zcodeConfigKey).
What was run:
- The new own.test.mjs case uses the reporter's layout (BigModel sign-in,
no key in credentials.json, key in config.json). It fails without the
fallback ("j1" in place of "bm.secret").
- Every packages/zcode test file passes under a scratch HOME/TMPDIR:
dual 25, gift 20, models 1, moved 1, own 6, signin 3, start 10, usage 15.
- bun scripts/check.mjs passes.
Not tried: a real ZCode 3.15 account.
What changed: ZCode 3.14 has a 数据存储路径 (data storage path) setting.
Changing it copies ~/.zcode/v2 to <folder>/.zcode/v2 (all but setting.json,
copyDataDirectory's filter) and from the next start ZCode reads
credentials.json and runtime/provider from there. The choice stays in the
home folder's .zcode/v2/setting.json as dataBaseDir
(readBootstrapDataBaseDirFromDisk), and setting.json itself is always read
from the home folder (getSettingsFile: ZCODE_DESKTOP_HOME_DIR, HOME,
USERPROFILE). The plugin read credentials.json and runtime/provider from
~/.zcode/v2 only, so for such a user "ZCode app's sign-in" read the stale
copy left at home (or nothing). It now reads dataBaseDir as magpie's built-in
does (magpie 41972b25f, internal/appdir ZCodeDataIn: trimmed, ignored when
empty, not a string or not absolute) for credentials.json and the
zcode-builtin.json walk, and keeps reading setting.json (the team plan)
from the home folder. The credential key's seed is unchanged: ZCode builds
it from os.homedir(), not the data folder.
Read from ZCode 3.14.3's app.asar (a copy): out/main/index.js (bootstrap),
out/main/chunk-*.js and out/host/chunk-*.js (getDataBaseDir,
getAppConfigDir, copyDataDirectory, getCredentialsFile, the settings file
under the home folder, defaultCredentialSecret).
What was run:
- moved.test.mjs (new): with dataBaseDir set, ownSignIn takes the moved
folder's key and session over the stale home copy, and a team plan named
in the home setting.json; "", blank, relative, number and null keep the
home folder. With zcodeDir put back on homedir() it fails (old key read).
- HOME=$(mktemp -d) bun test at the repo root: 1185 pass, 0 fail.
- bun scripts/check.mjs zcode.
- Not run: a real ZCode with a moved folder, Windows.
The app's sign-in stores the account ZCode is signed in to, and stateOf
read ~/.zcode/v2 again for every request. After ZCode switched to account
B and the app's sign-in was added again, both entries read B's
credentials: A's sent B's requests and its usage card showed B.
stateOf now follows ZCode's own credentials only when ZCode's user is the
entry's accountId. Otherwise (ZCode signed out, or on another account) it
uses the snapshot saved at sign-in, which holds the coding plan key, the
Start Plan JWT, the team project and the device. A snapshot whose JWT has
run out says EXPIRED (sign in again), as a lapsed sign-in already did,
instead of borrowing B's session.
own.test.mjs: two app sign-ins (A, then B) with ZCode on B; A's request
carries A's key and no request (messages, plan, usage) carries B's key or
JWT; and A with only an expired JWT says sign in again without sending
B's. Both fail on 0.1.15 (A sent idB.secretB; the expired case was served
with B's JWT). The first test now keeps the account's user_info as ZCode
signs in again. HOME=$(mktemp -d) bun test packages/zcode: 79 pass.
bun scripts/check.mjs zcode passes.
The plugin runs in magpie's plugin host, so process.cwd() is magpie's own
folder (C:\Users\<user>\.config\magpie on Windows). The Start Plan's
"# Environment" section said it as "Primary working directory", with a
constant "Is a git repository: no" and magpie's shell, and the model went
looking in magpie's folder.
Now the folder and the git state are the agent's, as magpie tells the
plugin's fetch in x-magpie-work-dir (percent-encoded) and
x-magpie-work-git (yes/no) (yetone/magpie, provider.WorkDirHeader). Each
line is left out when magpie doesn't tell it (an older magpie, an agent
that names no folder, a folder not on this computer). The Shell line is
gone: the agent's shell isn't known here. Platform and OS Version stay;
they are this computer's, as the X-Os-* headers already say. The headers
are taken off before anything is sent, on the coding plan too.
Run: bun test in packages/zcode (77 pass), bun scripts/check.mjs zcode.
With the old index.mjs the new tests fail (6 fail). One real request
through the plugin with the owner's z.ai account (coding plan; its Start
Plan balance is empty, so the dressed Start Plan path was not tried
against the real service): 200.
sun1090's account has no GLM Coding Plan, only ZCode's Start Plan, whose
buckets serve GLM-5.3 (3,000,000) and GLM-5.3-Flash (5,000,000). magpie's
usage card counted GLM-5.3, but the model list had GLM-5.3-Flash, GLM-5.2
and GLM-5-Turbo (the Start Plan's providerId in ZCode's provider config,
revisions 23 and 30, which leaves GLM-5.3 out) plus GLM-5.3-Trial and
GLM-5.3-Flash-Trial, so GLM-5.3 itself was missing.
ZCode 3.14.3 (host/index.js, resolveZaiStartPlanBalanceModelIds and the
start-plan overlay's builtinModelIds) lists a Start Plan account's models
as the balance's bucket capabilities, by their own names. A gift-only
account's requests all go to zcode.z.ai's Start Plan anyway, so the plugin
now also lists each gift model under its own name for such an account.
The -Trial entries stay, so a model a user already picked keeps working;
a coding plan account's gift is still reached only through its -Trial
entries. A gift model's context, output and efforts now also come from
the coding plan's config and the fallback table, so GLM-5.3(-Trial) on
a Start Plan account gets low/high/max rather than no efforts.
gift.test.mjs: "a gift-only account lists its gift's models by their own
names" fails on 0.1.13 (GLM-5.3 undefined); it also checks every model the
card counts is listed and that GLM-5.3 goes to zcode.z.ai. "a coding plan
account's gift stays on its trial entries alone" guards the dual route.
HOME=$(mktemp -d) bun test packages/zcode (75 pass) and
bun scripts/check.mjs zcode pass. Not tried with a real Start Plan
account.
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.
Why: a GLM Coding Plan account can also hold gift plans from ZCode
activities (a "Trust Build" grant, say). They lapse on a fixed date, and
every request went to the coding plan, so their allowance went unspent.
What: plansOf now reads the gift's balance (per the ZCode session, kept
10 minutes) and takes the union of the models every live bucket of every
active gift plan still serves (not expired, remaining_units > 0). A
request for a model the gift serves goes to the Start Plan first, dressed
as ZCode's own client; when the gift can't serve it — any answer 400 or
over, or its quota error inside an HTTP 200 (code 1113/1005) — the
request is replayed once to the coding plan as the agent sent it. Only a
quota answer keeps that model off the gift for a minute; a 405 refusal is
asked again next request. The usage card shows the coding plan's windows
and the gift's buckets together, each bucket prefixed with its plan's
name; a gift read that fails leaves just the coding card. A pure gift
account (no coding plan) behaves as before.
Tests: dual.test.mjs, 14 tests — routing, replay, the 60s quota block,
the 200-with-quota-error case, stream passthrough, an expired ZCode
session, the cache TTLs, a multi-plan union and a gift-only account;
HOME=$(mktemp -d) bun test (37 pass) 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.
ARNO on Discord: the plugin's Start Plan requests were answered 405 / 3012
"blocked due to unusual activity" while his own plugin (Freeflow, provider
zcode-start) worked from the same machine. zcode.z.ai serves the plan only
to what looks like ZCode's own request: a Start Plan request now carries
ZCode's headers and its body is dressed as ZCode's (three cached system
blocks, the environment section, the date reminder as the first turn, one
cache mark on the last block, metadata.user_id naming the sign-in's
device). The prompt texts are magpie's (901fd87e), each matching ARNO's
plugin's hash. Coding Plan and team requests are unchanged. The Start Plan
is advertised again.
- workbuddy: 'Illegal API invocation from an unapproved channel' ends in the hint magpie's built-in added (provider.WBRefusedHint), where magpie's routing page finds it; models with credits x0.00 carry free: true
- zcode: a new sign-in, "ZCode app's sign-in", reads ~/.zcode/v2 (credentials decrypted as ZCode keeps them, setting.json's team plan) for every request, as magpie's built-in did; magpie moves ZCode's own account marked source: zcode
- every {type:"failed"} carries an error reason magpie shows
- commandcode/devin: accounts taken from the CLI are marked metadata.cli and re-read its credentials on each request, usage and models
- factory: a refused refresh answers 401 authentication_error (Anthropic shape on /llm/a/, OpenAI's elsewhere) instead of throwing; the whoami back-off is per account; 403 hints name the account to sign in again
- versions: factory/devin/commandcode/cursor/kiro/mimo/zed/zcode 0.1.2, workbuddy 0.1.3