Commit Graph
2 Commits
Author SHA1 Message Date
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
erlinerd d22ac2039a zcode 0.1.8: spend an account's gift plans before its GLM Coding Plan, and show both on the usage card (#19)
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.
2026-10-04 20:04:08 +08:00