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.
73 lines
2.8 KiB
Markdown
73 lines
2.8 KiB
Markdown
# ZCode limited-quota model entries
|
|
|
|
## Goal
|
|
|
|
Keep the plan's normal model list and existing request behavior. Append distinct
|
|
`<original-model>-Trial` entries from live ZCode balance data, including models
|
|
absent from the normal plan catalog, named in the catalog's spelling. A trial
|
|
entry spends the gift; a plain model always spends the coding plan — the choice
|
|
is the user's. Display names and IDs use English. All production changes remain
|
|
in the ZCode plugin.
|
|
|
|
## Verification layers
|
|
|
|
Use the plugin repository's existing Bun tests for model discovery, quota
|
|
metadata and HTTP routing. Check the emitted metadata against the current
|
|
Magpie plugin contract. No new UI page or test framework is introduced.
|
|
|
|
## Scenarios
|
|
|
|
### Add a real limited-quota model
|
|
|
|
- Given a coding-plan account has an active grant for a model absent from its plan catalog.
|
|
- When the plugin discovers its models.
|
|
- Then it includes that model as `<original-model>-Trial` alongside unchanged plan entries.
|
|
|
|
### Keep grant models discoverable while their quota is exhausted
|
|
|
|
- Given an active grant has an exhausted bucket.
|
|
- When the plugin discovers its models.
|
|
- Then its gift entry remains discoverable with the exhausted gift quota applied to that entry.
|
|
|
|
### Ignore ended grants and unrelated capabilities
|
|
|
|
- Given a balance includes expired grants or non-model capabilities.
|
|
- When the plugin discovers its models.
|
|
- Then neither creates gift model entries.
|
|
|
|
### Restore the upstream model name
|
|
|
|
- Given a request selects a discovered gift model.
|
|
- When the plugin sends the request to the grant endpoint.
|
|
- Then the request contains the original model name, without the Trial suffix.
|
|
|
|
### Keep a gift request within the gift pool
|
|
|
|
- Given the gift endpoint refuses a request and the coding plan still has credit.
|
|
- When the selected model is a gift entry.
|
|
- Then the plugin returns the refusal without sending a paid-plan request.
|
|
|
|
### Reject unavailable gift quota without spending paid credit
|
|
|
|
- Given the selected gift model is exhausted, unavailable, or temporarily blocked.
|
|
- When a request selects that gift entry.
|
|
- Then the plugin returns a clear error without sending a paid-plan request.
|
|
|
|
### Scope quota to the selected pool
|
|
|
|
- Given the coding-plan week is exhausted and a gift remains available.
|
|
- When Magpie evaluates the gift entry's quota metadata.
|
|
- Then only the corresponding gift allowance applies to that entry.
|
|
|
|
### Allow a live sibling bucket
|
|
|
|
- Given one gift bucket is exhausted and another live bucket serves the same model.
|
|
- When the plugin maps gift model quotas.
|
|
- Then the exhausted sibling does not make that gift entry appear exhausted.
|
|
|
|
### Keep plain models on the coding plan
|
|
|
|
- Given a caller uses an existing model ID without the Trial suffix.
|
|
- When the plugin routes the request.
|
|
- Then the request spends the coding plan, whatever the gift holds.
|