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.
This commit is contained in:
@@ -144,7 +144,7 @@ test("ZCode's Start Plan: its buckets, each for its models", async () => {
|
||||
signIn: "kept",
|
||||
plan: "Start Plan", until: new Date((now + 7 * 86400) * 1000).toISOString(), renew: "off",
|
||||
windows: [{ name: "GLM-5.1", used: 25, display: "250000 / 1000000", resetsAt: new Date((now + 3600) * 1000).toISOString(), span: 86400,
|
||||
models: ["GLM-5.1"] }],
|
||||
models: ["GLM-5.1", "GLM-5.1-Trial"] }],
|
||||
})
|
||||
expect(calls[0].url.origin).toBe("https://zcode.z.ai")
|
||||
expect(calls[0].headers["X-Device-Mid"]).toBe("11111111-2222-4333-8444-555555555555")
|
||||
@@ -159,7 +159,7 @@ test("ZCode's Start Plan: its buckets, each for its models", async () => {
|
||||
balance = startBalance(now, "active")
|
||||
balance.balances = [{ plan_id: "zai-start-plan", capabilities: [" model: GLM-5-Turbo ", "model:"], total_units: 200, remaining_units: "150",
|
||||
period_start: now, period_end: now + 7 * 86400 }]
|
||||
expect((await usage(auth)).windows).toEqual([{ name: "GLM-5-Turbo", used: 25, display: "50 / 200", span: 7 * 86400, models: ["GLM-5-Turbo"] }])
|
||||
expect((await usage(auth)).windows).toEqual([{ name: "GLM-5-Turbo", used: 25, display: "50 / 200", span: 7 * 86400, models: ["GLM-5-Turbo", "GLM-5-Turbo-Trial"] }])
|
||||
|
||||
// its token run out
|
||||
expect(await usage(oauth({ site: "zai", jwt: jwt(now - 60) }))).toEqual({ signIn: "kept", error: "ZCode's sign-in has expired; sign in to ZCode again (or add the account again in magpie)" })
|
||||
|
||||
Reference in New Issue
Block a user