Commit Graph
9 Commits
Author SHA1 Message Date
yetone 367edb503c zcode 0.1.53: a spent bucket's 200 says 429 on the plain path too (#817)
A ZCode answer that carries a spent code (1005 "exceed quota limit",
1113) inside an HTTP 200 now reaches magpie as a 429 on every path. Before,
only a -Trial entry (forcedGift) and free first's gift did this. On a
gift-only Start Plan account, a request for the plain model (GLM-5.3) went
through `return done(kept(res))` as a 200. magpie took it for a reply that
did not stream (502), failOther, and its window branch rested the whole
account until the bucket reset. GLM-5.3-Flash, which has its own bucket,
went unused for ~22h. As a 429 it is failQuota, and magpie rests the model
whose window is full.

spentSaid reads only a non-stream JSON answer under 400. Any other answer,
a stream included, goes on as it came. A reply whose text happens to say
1005 stays a 200. The same applies to the plan answer free first replays
on (replayOnPlan, three places), and to the coding plan's own 200 with
1113.

Run at 081c67ac on mote, HOME a temp folder: bun test packages/zcode
212 pass, 0 fail; the whole repo bun test 6558 pass, 20 skip, 0 fail;
scripts/check.mjs exit 0. Broken by hand, each red: the plain path back
to done(kept(res)) (gift.test's two new tests, 200 for 429); the
replays without spentSaid (dual.test's new free-first test).

Not tried: a live spent bucket. The 200 body is the reporter's words, and
dual.test's fixture already had it.

Reported-by: zane668
2026-11-07 09:11:36 +08:00
yetone c96d04bb6b zcode 0.1.51: a gift-only account lists only the models its balance names (young02036)
young02036 on Discord: two ZCode accounts in magpie, one with no GLM
Coding Plan whose Start Plan holds glm-5.3-flash, one subscribed whose
gift shows as GLM-5.3-Flash-Trial. Picking per account the models each
can use worked; left to the plugin's lists, requests failed while the
ZCode app on the same accounts worked.

A gift-only account listed every model the Start Plan's provider config
names (GLM-5.3-Flash, GLM-5.2, GLM-5-Turbo), whatever its balance held,
so magpie's routing took it to serve models it has no bucket for. ZCode
3.17.2 offers such an account the balance's models alone
(resolveStartPlanBalanceAvailability / resolveZaiStartPlanBalanceModelIds).
The models hook now keeps, for a gift-only account, the config models
its balance names (plus the gift names the config lacks and the -Trial
entries, as before). A balance naming no model, or one that can't be
read, leaves the config's list as it was. Coding plan accounts are
unchanged.

Run (mote, bun 1.4.2, isolated HOME): bun test packages/zcode, 200 pass;
bun scripts/check.mjs zcode ok. The new gift.test.mjs case was red on the
old code (GLM-5-Turbo and GLM-5.2 listed) and green after.
Not tried: a real ZCode account (none available); whether the reported
3012 came from such a request is not proven.
2026-11-05 11:30:10 +08:00
yetone 6a75bbd43c zcode 0.1.47: a gift model goes out under ZCode's registry spelling, and a rested model says why
A -Trial request took the model name from the bucket's capabilities,
lowercased ("glm-5.3-flash"), and sent that. ZCode 3.17.2 sends its registry
id ("GLM-5.3-Flash"): normalizeOfficialGlmModelId's spelling, which its own
docs say is not rewritten on requests. The plugin now sends the registry
spelling for the models ZCode knows (wireModel), for trial entries and the
free-first plain model alike; unknown names go as the bucket wrote them.

A 429 from the gift also rests that model for a minute, and the local
refusal in that minute read the same as a spent bucket. It now says ZCode
answered 429 to the last request and the model is not asked again for a
minute.

Not changed: X-Device-Mid. 3.17.2's docs say it goes on config GETs, not on
the model transport, and start.test.mjs holds that.

Run at this head: bun test packages/zcode on mote, 193 pass. Undoing
wireModel turns 7 tests red. Not tried: a real account (none here); the
cause of the reports (429 and 405 on glm-5.3-flash-trial, 11-03) is not
proven, the model spelling is the one request difference found in the
3.17.2 source.
2026-11-04 00:35:49 +08:00
yetone 63748b9d67 zcode 0.1.36: a gift bucket beside a Coding Plan is named by its model first (#504)
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.
2026-10-30 10:31:28 +08:00
yetone cc0bd902b3 zcode 0.1.26: a gift's -Trial models are listed when ZCode's config is out of reach, a failed gift read is asked again in a minute, and a card with no ZCode session says the gift needs one
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.
2026-10-24 17:04:32 +08:00
yetone 1f8d38b8cd zcode 0.1.23: with two gift plans each bucket is named by its plan, and the live ones come first
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.
2026-10-24 05:04:58 +08:00
yetone aca7c59261 zcode 0.1.14: a gift-only account lists its gift's models by their own names, as ZCode does (yetone/magpie#1261)
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.
2026-10-08 16:12:53 +08:00
yetone 6b13dc05e4 zcode 0.1.10: a gift-only account's spent bucket doesn't hold up a model another of its plans still has (ganlerk on Discord) — an account with both ZCode Trust Build (GLM-5.3-Flash 14.5% used) and the Start Plan (GLM-5.3-Flash all used) showed the Start Plan's spent bucket as counting GLM-5.3-Flash, so magpie read the model, and the account, as 100% used and sent Flash requests elsewhere. The server picks the bucket (ZCode sends no plan with a request), so a gift-only account's usage now counts each model on its live bucket, the least used, and sets spent siblings aside, as an account with a coding plan already did. bun scripts/check.mjs zcode and the zcode tests pass; the new gift test fails on 0.1.9. 2026-10-05 19:50:37 +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