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.
This commit is contained in:
yetone
2026-10-16 17:36:24 +08:00
parent 4a35799021
commit 09f946b5e6
5 changed files with 184 additions and 9 deletions
+15 -1
View File
@@ -24,7 +24,12 @@ over Anthropic's Messages API. Provider id: `zcode`.
ZCode's does: ZCode's headers, ZCode's system prompt ahead of the
agent's, the day in a `<system-reminder>` turn before the agent's
turns, and the sign-in's device id in `metadata.user_id`. GLM Coding
Plan and team requests go as the agent sent them.
Plan and team requests go as the agent sent them. One it still turns
away (a 405, the block page or code 3012) comes back with what to do
about it, as magpie's built-in said: "ZCode's Start Plan still turned
this request away, though magpie sends it as the ZCode app does; …
Use an account with a GLM Coding Plan, or add another provider to this
group".
- The Start Plan's token can't be refreshed. When it runs out, sign in
again.
- **ZCode app's sign-in**
@@ -96,6 +101,15 @@ behind an error, so a gift hiccup must not black out a working Coding
Plan. A gift that goes out of date while requests use it simply stops
showing.
**Resets.** A GLM Coding Plan of the account's own, and a team seat,
show the resets the vendor's usage page lists
(`/api/biz/customer-package-reset/list`, `targetType=PERSONAL` with the
plan's key, `TEAM` with the team's sign-in): how many of the five hours
and of the week are still available, and when each runs out, soonest
first. A team's are marked a team's. They are only read; a reset is
spent on the vendor's own page. A list that can't be read, or has none
left, shows no count.
**Gift plans ZCode holds but has not granted.** ZCode hands out one-off
trust-build / gift plans (a day's ZCode Trust Build, say) that are not
on the account until the ZCode app claims them. The plugin reads the