Commit Graph
13 Commits
Author SHA1 Message Date
yetone 71021b8f72 zcode 0.1.25: a key with no GLM Coding Plan says a ZCode gift plan (Start Plan, 1024 Dev Day) needs ZCode's sign-in
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.
2026-10-24 16:37:39 +08:00
yetone 57ec655a24 zcode 0.1.22: a Start Plan request goes with ZCode 3.16.3's headers alone, never the agent's, and without ?beta=true
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).
2026-10-24 00:44:28 +08:00
yetone 09f946b5e6 zcode 0.1.19: a GLM Coding Plan's own resets show on the card, each with its end, a team's say so, and a Start Plan refusal says what to do, as the built-in did
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.
2026-10-16 17:36:24 +08:00
如是 f06dacd1ec zcode 0.1.13: the claim line's name is a sentence magpie translates; its count and plan name are the display (#43)
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.
2026-10-08 11:52:36 +08:00
wizzy-yangandwizzy-yang c2b0462227 zcode 0.1.12: a counted window says its count as used or as left, as the share beside it is (#659) — the Coding Plan limits and the Start Plan / Trust Build buckets told only the vendor's own text, "28746939 / 100000000", so magpie's card froze that used-first count beside a "71.3% left" figure. Each counted window now carries the count as amount of limit, as WorkBuddy's credits do. usage.test.mjs: "a counted window carries what is used of the whole" fails on 0.1.11; bun test packages/zcode (73 pass) and bun scripts/check.mjs zcode pass. (#35)
Co-authored-by: wizzy-yang <wizzy-yang@users.noreply.github.com>
2026-10-07 18:46:04 +08:00
如是 bcec59ec31 zcode 0.1.11: a gift plan ZCode holds but hasn't granted is named on the card ("1 to claim · claim it in the ZCode app") (#30)
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.
2026-10-06 17:42:31 +08:00
erlinerd dbd14ccb98 zcode 0.1.9: the gift's models are trial entries the user picks, not an automatic gift-first route (#21)
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.
2026-10-05 14:24:17 +08:00
yetone ef81d34320 tests: a usage test's offline fetch is put back when its file is done, so the next file doesn't inherit it
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.
2026-10-02 23:13:06 +08:00
yetone 466d06ce55 zcode 0.1.5: the month's MCP tool calls are set aside as 'MCP · Month', as the built-in's quota did, not counted as a window — an older plan reports that uncapped month as 100% used, which read the account as out of quota and skipped it; a limit whose whole is 0 is set aside too. The new test in usage.test.mjs fails against 0.1.4. 2026-10-01 07:04:59 +08:00
yetone 01aee5da28 all: a usage read says what it means for the sign-in, and a renewal clears the mark whatever follows, as the built-ins did (要保证插件跟内置的所有逻辑都要一模一样) — auth.usage returns signIn on every path: expired where the built-in's quota read marked the account (Zed's /users/me 401, Factory's and MiMo's refused renewals, Qoder's refused job refresh), renewed after a renewal, which took the mark off, kept everywhere else, so magpie no longer guesses from the words 'sign in again' (Kiro's, Devin's and ZCode's usage errors marked accounts their built-ins never did) nor clears on a clean read. A request after a renewal says renewed on any status; one without says kept, as the built-ins cleared only on renewal. Kiro, Cursor, Devin, Command Code, WorkBuddy, Grok and ZCode, whose built-ins never marked an account, say kept on every answer. New tests fail against 85d7dd0's index.mjs. 2026-10-01 04:53:29 +08:00
yetone 85d7dd0d0a all: each plugin fails with its built-in's status and marks the sign-in as it did, through X-Magpie-Sign-In (要保证插件跟内置的所有逻辑都要一模一样) — Factory's and MiMo's refused renewals are the built-ins' 502 marked expired, not 401s; Qoder's vendor 403 is the built-in's 401 kept, its model list's failure a 400, its job refresh refused marked expired; Zed's retried 401 is a 401 kept, not a 403; Kiro's unreachable refresh a 401 kept; Cursor's expired trial a 401 kept; a vendor 401 WorkBuddy, Grok, Devin, Command Code and ZCode passed on no longer marks the account, as their built-ins never did, and Grok and MiMo no longer retry what their built-ins sent once. Messages take the built-ins' words. New tests fail against the previous index.mjs. 2026-10-01 04:47:03 +08:00
yetone b70f871d97 zcode 0.1.3: every card starts from the saved plan, as magpie's built-in's did — a reply with no level, a team detail that failed or an error no longer drops it; a model ZCode's config gives no context or output keeps 0, as the built-in, instead of a made-up 200K/131072 2026-10-01 02:56:05 +08:00
yetone 501bd238ed zcode 0.1.1: usage shows as magpie's built-in did — plan, period, windows and what they count, balance, team resets 2026-09-30 23:03:10 +08:00