main
21
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
9204c079ae |
zcode 0.1.59: a reply the gift answered names the -Trial entry, so Usage, sessions and the request log show free quota was spent (WJaunita45604 on X)
Free first sent the plain model to the Start Plan under the plain name, and the gift answers under that name too, so magpie named the plan's model for both routes. trialNamed rewrites the model of a gift's whole reply or event stream to GLM-5.3-Flash-Trial; a failed reply, and a free-first replay on the coding plan, keep what came. Run: bun test dual.test.mjs on wsl (61 pass); the two new gift tests fail with the rename taken out. Not tried: a real Start Plan reply (no gift balance on this account at this hour). |
||
|
|
ea3573bfe9 |
zcode 0.1.58: an account served fewer than three is narrowed, not held; trial entries are free (#438)
takomitkm (plugins#438, 0.1.57, default settings) had the busy hold arm with one account, one agent and at most two in flight, at about five asks a minute, and arm again within a minute of its end. A coding plan model's weekly or monthly limit (1310) also rested the whole account, so its -Trial models got the cached 1310 without being asked. Busy hold. ZCode serves that account one Start Plan request at a time, so every second request was refused again at its 1s re-ask and counted toward the process-wide hold. A sustained cap with others of the same account in flight (the gate's lane busy >= 2) now narrows that account's gate to busy-1, at least one, for NARROW_FOR (5 minutes; startGate.now is its injectable clock) and counts toward no hold. A lone sustained cap still counts, so the hold stays process-wide and keeps the firewall protection: #801's caps came with up to ~10 in flight, which the gate never sends, and an account whose slots are taken elsewhere narrows 3 -> 2 -> 1 within a few caps and is then refused alone, which arms the hold as before. The queue answer says the account's current number. Rest. The models hook marks each -Trial entry free: true, so magpie's PaidBesideFree makes a coding plan model's quota refusal rest that model, not the account. Gift-only accounts' plain names stay unmarked. Side effects: the Free mark in pickers, free-preferring groups pick the trials first, and they price at 0, which they are. Run (mote, bun 1.4.2, HOME=$(mktemp -d)): packages/zcode bun test, 240 pass, 0 fail, 17 files, at this head rebased on 60acd62b; bun scripts/check.mjs exit 0. Broken by hand: - narrowing off (if (false && ...)): the three new inflight tests fail; the reporter's case shows the hold armed (until=1000000240000). - lone caps narrow too (busy < 1): seven hold tests fail (the saturated-elsewhere replay, refused-even-one-at-a-time, start.test's hold tests, dual's hold test). - free: true removed: the new gift test fails. Tests: inflight.test's reporter's case (fake caps at >= 2 in flight, injected clocks), the narrowing's expiry, and a lone refusal still arming the hold; gift.test's free trial entries. start.test's in-flight guard now uses twelve accounts of one request each, and dual.test's hold test a gate of one, so their caps stay lone ones. Not tried: a real ZCode account served one at a time; the core side (magpie's TestZCodeCodingPlanLimitLeavesTrials) is in magpie with the mover min. Reported-by: takomitkm |
||
|
|
93dacd738f |
zcode 0.1.57: the busy hold's answer arms no quota rest (#859)
A busy hold (0.1.54) armed while a Start Plan request was in flight
answers that request with the hold's own 429 from askBusy. It carries no
3008, so busy() does not claim it and spentUp counts it as a spent gift.
On a -Trial pick that rested the model in `blocked` for a minute, and
the next -Trial asks were answered locally "over its quota ... exhausted"
with quota left. Under free first it rested the model the same way
before the replay on the plan.
busyHeldAnswer now sets `x-magpie-busy-hold: 1`, and the -Trial and
free-first gift paths read it before spentUp: the hold's answer passes on
as the rate limit it is and arms no rest. Free first still replays a
held answer on the plan, through the plain >= 400 branch. The gate's
queue answer and the hold's early returns never reach those paths.
Run at the reviewed head e5858d7b merged with origin/main
|
||
|
|
a313a00306 |
zcode 0.1.56: the Start Plan goes three at a time and re-asks a cap twice, as ZCode's client does
Users of other agent apps on the ZCode plugin saw "rate limited 5 times in a minute" (star21321321124 on Discord). That is the plugin's own 3-minute busy hold (0.1.54, #801), which trips after ZCode refuses five requests in a minute as over its in-flight cap (429 3008/3009). The plugin drove those refusals itself: - It sent every request magpie passed it. magpie's lane is 3 per account, but nothing in the plugin held the Start Plan to that. - It re-asked a capped request up to six times over about 10s (BUSY_WAITS 250..4000, from #395). That kept slots taken and drew more caps. - It counted every capped request toward the hold, including ones the next re-ask got past. ZCode 3.17.2, read from its bundle: wqo = {3008, 3009, 3010} and kqo = [1e3, 2e3]. So a busy cap is re-asked at most twice, after 1s and 2s, Start Plan only. There is no hold, and one main turn runs per session. What changes: - BUSY_WAITS is [1000, 2000], with no jitter, and 3010 counts as busy. This applies to every plan, since the coding plan goes through the same askBusy. - startGate: on the Start Plan, an account has at most 3 requests in flight (#395 measured about 3: 3 of 12 and 4 of 12 served). The account is keyed by uid, then accountId, then key. Further requests wait in a FIFO queue in the plugin and are not sent. A slot is freed when the upstream body ends, the agent cancels, or its signal aborts (the body is pumped eagerly so an unread reply cannot hold a slot). After 2 minutes of waiting, the plugin answers 429 rate_limit_error with Retry-After 5: "ZCode's free Start Plan serves this account 3 requests at a time; this one waited 120s behind the others and was not sent. Run fewer agents or subagents on ZCode at once, or try again". The coding plan stays ungated. Its cap follows the tier (the #395 review), and magpie's lane covers it. - Free first skips the gift while its account's gate is full, so the plain model goes to the coding plan rather than queueing. - The hold counts a request only when ZCode refuses it again at the 1s re-ask. N=5, the 60s window and the 3-minute hold are unchanged, as is the rule that an in-flight or queued request stops once the hold is armed. Its message now says what happened and what to do: "ZCode turned away 5 requests in the last minute as too many requests at once, each again when asked a second later. So that ZCode's firewall does not block this network, magpie sends no free Start Plan requests for the next Ns. Wait, run fewer agents or subagents on ZCode at once, or use a GLM Coding Plan model". The words avoid "plan"+"limit" after "exceeded", which magpie's usedUpWords would read as spent. History checked: #395 (0.1.32) added the long waits and had an in-plugin gate removed in review, because it held Max coding-plan accounts to 3 and was keyed on the jwt. This gate is Start Plan only (one tier) and keyed per account. #801 (0.1.54) added the hold from the logs of 11-05 23:06 and 11-06 06:23: about 16 to 18 req/min, 7 to 10 in flight, and the first 405 after 205 to 517s. The hold still trips on sustained refusals: the replay below has the account saturated elsewhere, and the hold arms within the replayed minute with nothing sent after it. Run on mote, HOME=$(mktemp -d), at the rebased head, Bun 1.4.2: - bun test packages/zcode: 235 pass, 0 fail. - New inflight.test.mjs: 13 pass. It covers re-ask count and timing (3 asks, gaps of about 1s and 2s), 3010, at most 3 in flight of 12 sent at once, per-account slots, a slot held across re-asks, the queue wait running out (nothing sent, plain 429), abort while queued, a cancelled stream freeing its slot, the coding plan ungated, a cap the 1s re-ask got past not counting, and the hold message. It also replays #801's two days at 20x speed against a fake that refuses past 3 in flight: 0 refusals, peak 3, no hold, all served. A second replay with the account saturated elsewhere arms the hold within a minute. - bun scripts/check.mjs zcode: ok (registry.json, zcode). Repo bun test: 6780 pass, 0 fail, 20 skip, 491 files. Broken by hand: inflight.test.mjs against 0.1.55's index.mjs gives 11 of 13 red. 0.1.55 made 7 asks, had 12 in flight, drew 24 refusals in the replay, and armed the hold on caps a re-ask got past. Two pass on both, as expected: the coding plan stays ungated, and the saturated replay still holds. Not tried: real ZCode Start Plan accounts, live; the replay is synthetic from the #801 figures, as the raw logs are not in the repo. Not copied from ZCode's client: its "no re-ask on a session's first turn" rule, since the plugin cannot tell a first turn reliably. Reported-by: star21321321124 |
||
|
|
ea9904d54c |
zcode 0.1.55: no claim while ZCode asks its security check; the desktop's X-Title and a per-turn x-query-id
young02036 (Discord, 11-07): on an account with a GLM Coding Plan, the
GLM-5.3-Flash-Trial gift answers 405 code 3012 ("blocked due to unusual
activity") while the paid models work, and the plugin's daily check-in
gets a captcha every day while the app shows none.
Diffed against the official ZCode 3.17.2 (zip sha512 matched its
manifest; glm/zcode.cjs and app.asar's host and renderer code):
- The claim. The app's claimManualPlan posts the claim with
X-Aliyun-Captcha-Verify-Param/Region, and its renderer always runs the
traceless captcha first. client/configs says captcha.enabled true
(testdata/client-configs-1107.json, the real reply cut down). The plugin
can't make that proof, so each day's claim was one more refused claim.
Now claimDaily reads client/configs (cached ten minutes, a failed read
not kept) before posting: while captcha.enabled is not false nothing is
posted and each plan answers captcha, "claim it in the ZCode app"; a
config that doesn't read is failed, nothing posted. The captcha is not
got past.
- X-Title. The desktop's model requests say "Z Code@electron"
(sourceTitle from zcode-protocol-entrypoint); the plugin said
"Z Code@cli".
- x-query-id. ZCode sends one per user query (query_<uuid>, prefix
stripped). The Start Plan path now sends a UUID made from the session
and the count of user text messages: the same through a turn's tool
results, new with the next user message.
The 3012 itself: on the owner's account (no gift, so code 1005 "exceed
quota limit" means risk control let it through) every shape answered
200 code 1005: adaptive thinking with effort max and max_tokens 64000, a
1.6 MB body, max_tokens 200000, thinking enabled with budget 1024, and
X-Title electron. So the request's shape is not what trips 3012; the
reporter's account looks blocked by risk control as a whole, which only
ZCode support lifts. That the daily captcha-less claims fed it is a
guess.
Run (mote): HOME=$(mktemp -d) bun test in packages/zcode, 222 pass 0
fail; bun scripts/check.mjs zcode ok.
Broken by hand, each red, then restored (cmp ok): the claim gate removed
(2 fail), a config read failure taken as no captcha (1), x-query-id not
set (2), user turns counted wrong (1), the title back to cli (3).
Not tried: a real claim or a real 3012 account (the reporter's); the new
headers against an account that has a gift; Windows and Linux.
Reported-by: young02036
|
||
|
|
09a27bef01 |
zcode 0.1.54: a busy hold also stops requests already in flight (#801)
When five Start Plan requests in 60s get ZCode's 3008 "busy", magpie holds zcode.z.ai off, so that the counting firewall doesn't escalate to its 405 block. While the hold is on, a Start Plan request is answered locally with a 429 carrying Retry-After, and it is not counted. A request that was already retrying when the hold armed now stops too: askBusy checks the hold after counting a cap and again after each wait. The coding plan and free first's replay pass no onCap, so the hold never touches them. When the edge (405) hold and the busy hold are both on, the edge hold's answer wins. Run at the reviewed head 19f7e9019ca22a3bad97c974bdf796b88ec8e3e3 (Bun 1.4.2, HOME=$(mktemp -d)): - macOS (mote): bun test packages/zcode 217 pass 0 fail; bun scripts/check.mjs zcode ok; repo-root bun test 6580 pass, 20 skip, 0 fail (475 files). - Linux (WSL2 Ubuntu 24.04): bun test packages/zcode 217 pass 0 fail; check ok. Broken by hand (full zcode suite each): - post-sleep hold check removed: red, 16 asks instead of 12; - busyCap's in-hold return removed: red, hits 2 instead of 0. - The post-cap check removed, or onCap keying dropped: still green. These are latency and coding-plan scoping, left for a follow-up test. npm had 0.1.51 to 0.1.53 at review time, so 0.1.54 is free. Not tried: a real ZCode 3008 storm, the firewall's real 405, magpie's fallback on the hold's 429 in a real gateway run, Windows. |
||
|
|
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
|
||
|
|
36a017ac9e |
zcode 0.1.49: a free-first refusal no longer answers the -Trial entry a local "quota exhausted" 429; free first gets a switch in magpie's provider editor
Can4ry_ on X (11-04): testing GLM-5.3-Flash-Trial in magpie answered "429 · ZCode's limited quota for glm-5.3-flash is exhausted or temporarily unavailable" while ZCode's own app was served, glm-5.3-flash kept using the Coding Plan after the Start Plan opened at 23:00, and there was no freeFirst setting under the ZCode provider. Cause: free first's plain GLM-5.3-Flash request goes to the gift first. When zcode.z.ai turned it away with 405/3012 (risk control, or 0.1.46/0.1.47's 3.14.3 prompt texts), restModel rested glm-5.3-flash in `blocked`, the same map a -Trial entry's quota check reads. So for the next minute the Trial entry answered a local 429 that called the quota exhausted, without asking ZCode, and every plain request in that minute went to the plan. The suffix it added, "ZCode answered 429", was wrong too, and it pushed the spent words off the end of the message, so magpie's zcodeSpentWords didn't match and the gateway rested the whole account. Change: - A free-first refusal that is not a quota answer rests the model in a new `sidelined` map, read by free first only. A quota answer still rests it in `blocked`, which the -Trial entry obeys too. - The local 429 keeps "ZCode's limited quota for X is exhausted or temporarily unavailable" last; why it rests now goes in front. - auth.options declares a "Free quota first" switch (free_first, on by default, zh/zh-TW/ja/de words), read through input.magpie.options. Off keeps the plain models on the plan. A JSON freeFirst: false still turns it off; an absent key (an older magpie, OpenCode) leaves the JSON's word. - README says where the switch is and what a refusal rests now. Run: bun test packages/zcode on mote under a temp HOME, 197 pass, 0 fail. bun scripts/check.mjs on mote, exit 0. Broken by hand: the new dual tests against HEAD's index.mjs (the old code), 4 fail. "a free-first refusal leaves the -Trial entry asking ZCode" fails with 429 for 200, the reported case. The others are the spent words test (no match), the switch test, and the block-page test, whose second plain request went to the gift again. Not tried: a real account. The owner's account has no live Start Plan to be refused or spent. Not tried: magpie's editor showing the switch. That comes from host.js optionsOf and app.js pluginOptionsField, unchanged. |
||
|
|
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.
|
||
|
|
036fb6ed43 |
zcode 0.1.43: a block page holds zcode.z.ai off three minutes, for every account (#649, frank6com)
frank6com's 405 ("the provider's network firewall blocked requests from
this IP") is Aliyun's edge firewall in front of zcode.z.ai answering
POST /api/v1/zcode-plan/anthropic/v1/messages (the Start Plan) with its
405 HTML page. It is the address, not the method nor the account: ZCode's
own app got the same 405. Two Start Plan accounts and three sessions with
subagents (up to 6 requests at once from one IP), and every request after
the block went on knocking on the firewall, from both accounts, since the
gateway falls back but rests nothing for an edge block.
Now a block page sets a process-wide hold (edge.until, EDGE_HOLD three
minutes): while it lasts, a Start Plan request and a picked -Trial entry
are answered here with the same 405, permission_error and
provider.BlockedHint word for word, plus until when, so magpie's
EdgeBlocked and retryable still send the request to the group's next
provider. Free first leaves the gift and keeps a dual account on its
coding plan (api.z.ai, another host). A 3012 or a bare 405 is the
account's and holds nothing. The first request after the hold asks again.
Run, at this head, on mote:
- packages/zcode: bun test, 189 pass, 0 fail.
- bun scripts/check.mjs zcode: ok.
- Broken by hand: without the line that sets the hold, both new tests
are red (65 pass, 2 fail in start + dual); without !edgeHeld() in free
first, the dual test is red (66 pass, 1 fail).
Not tried: a real zcode.z.ai request. Reproducing needs the address
blocked, and asking until it is would block the owner's network. The page
the tests use is the one plugins#425 recorded.
|
||
|
|
b820704803 |
zcode 0.1.42: a plain GLM model spends a live ZCode gift first, by default (sgfvdsg86265 on X)
The request (X, 2117210897471169009): when the account has gift quota for a GLM model, which ZCode hands out every weekend, spend that first. freeFirst (#505) already does it, but only when it was turned on, so a gift lapsed unused behind an agent that asks for the plain model. It is now on unless the plugin's options or the provider's say `"freeFirst": false`, which are still honoured as they are. Every way the gift can fail (spent, a model it doesn't serve, no ZCode session, a refusal's minute of rest) still falls back to the coding plan, as before. A team seat's plain model spends the personal gift first too. The tests that are about the plan and the -Trial picks now build the plugin with freeFirst off, as they assumed it was. Run on mote: HOME=$(mktemp -d) bun test in packages/zcode, 187 pass; bun scripts/check.mjs zcode ok. Broken by hand: with the default back to off, "free first is on when nothing sets it" and "free first is on by default for a team seat" fail; the rest pass. Not tried: a real account with a claimed gift. The owner's account has only an unclaimed one, which wasn't claimed for this. |
||
|
|
5a9c776832 |
zcode 0.1.38: freeFirst, the plain model spends the account's gift first (#505)
freeFirst (a boolean plugin or provider option): a plain model request
spends the dual account's own live gift first, under the name the gift
lists, and falls back to the coding plan when the gift can't serve it.
Any gift failure (spent 1113/1005, block page, 4xx/5xx, its own
waited-out busy cap, a network throw) is replayed on the plan in the same
request with the plan's own busy patience; a caller's abort stays an
abort. -Trial entries keep their strict meaning. Off by default.
zcode 0.1.38.
Run at the reviewed head 7ae2ea15d (on main
|
||
|
|
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. |
||
|
|
3b3209e0dd |
zcode 0.1.34: a gift plan that starts later is named with its start, and gift buckets beside a Coding Plan carry their plan's name
windy (Discord): "添加zcode供应商的时候,好像无法区分Coding Plan 和Start Plan的额度?
例如今天23点要生效的Start Plan就没显示".
- A plan on /billing/balance whose starts_at is still to come serves
nothing yet: startPlan no longer routes to it (an "active" plan with a
future start would have been), and its buckets don't count. The card
names it in an aside line "ZCode gift plan not started yet", display
"<plan> · <start in local time>", soonest first.
- A coding account with a ZCode session reads the gift on every card
read, not only while a gift is live, so a coming plan shows beside the
Coding Plan. The route cache is read again when the coming plan starts.
- A gift-only account whose only plan starts later gets a card with that
line instead of "ended or never started".
- Beside a Coding Plan, every gift bucket is prefixed with its plan's
name ("Start Plan · GLM-5.1-Trial"), one plan or several.
Not known: which status ZCode gives a plan that hasn't started. The
fixtures use starts_at as the real balance/preview replies carry it
(Unix seconds) and try both "active" and an unknown status word; any
status but "expired" with a future starts_at is taken as coming. No
real account with a pending plan was read.
Run on mote: HOME=$(mktemp -d) bun test in packages/zcode, 142 pass
0 fail; pending.test.mjs under TZ=UTC, Pacific/Kiritimati and
America/Los_Angeles, 7 pass each; bun scripts/check.mjs, every package
ok. Broken by hand: with the old index.mjs, 6 of pending.test.mjs's 7
tests fail (the 7th, a plan whose start has come, passes on both).
|
||
|
|
2b56b3bc4f |
zcode: name the conversation in x-session-id as a bare UUID, so BigModel's prompt cache hits (#388)
ZCode's client names every request's conversation in x-session-id: a bare UUID, the same on each turn (3.14.3 xst/Tst). BigModel keeps a prompt's cache for the requests that name the same session. The plugin sent none, so a long conversation seldom hit the cache (#387). Every zcode request, on the Start Plan and on Coding Plan or team seats alike, now carries it: - the agent's session (chat.headers' sessionID, which magpie fills) goes as it is when it is a UUID, lower-cased; - any other id (magpie-<hex>, ses_..., sess_...) goes as a stable UUID made from its sha256; - with no session, a UUID made from the device. metadata.user_id's session_id is the same UUID, in dress() and marked(). Reviewed at 48013c0, which addresses all four points of the earlier review (UUID shape, session_id in user_id, rebase onto 0.1.30, no "Closes #387"): - TMPDIR=<scratch> HOME=$(mktemp -d) bun test in packages/zcode: 125 pass, 0 fail. bun scripts/check.mjs zcode passes. Merges cleanly onto main. - With main's index.mjs and the PR's tests: 17 fail (all 7 new session tests, plus the start, userid and dual assertions on the header). - Probe through the plugin's chat.headers and loader fetch, as magpie's host calls them (host.js passes sessionID and sets out.headers before the fetch): magpie-<hex> twice gives the same UUID in the header and in user_id.session_id, and ses_other gives a different UUID. None contains magpie, ses_ or sess_. Not tried: a real BigModel request (the author's hit-rate numbers are the evidence: 3/12 before, 24/24 after through magpie). |
||
|
|
57598ad410 |
zcode 0.1.30: a coding plan's requests name the device in metadata.user_id, as ZCode's do (#387)
wendyeq measured BigModel's GLM Coding Plan through magpie hitting the
prompt cache 1 time in 19 without metadata.user_id and 13 in 16 with it;
the official ZCode on the same account reads 95-98% of input from cache.
The plugin only put user_id on the Start Plan's dressed body; a coding
plan or team request went as the agent sent it, and Pi sends none.
ZCode 3.14.3 (glm/zcode.cjs) sets it on every Anthropic-format request,
not only the Start Plan's: Pst() returns MLs({deviceMid, sessionId}) for
any providerKind "anthropic", and vWr() puts it in
providerOptions.anthropic.metadata.userId for both generateText and
streamText. The value is {"device_id":<machine id>,"account_uuid":"",
"session_id":...}.
Now a coding plan or team request to .../v1/messages gets
metadata.user_id = {"device_id":<sign-in's saved device>,
"account_uuid":"","session_id":""}, the same value dress() puts on the
Start Plan's, when the agent sent no user_id of its own; other metadata
is kept and content-length dropped when the body changed. count_tokens
and non-Messages bodies go as they were. An account known only by a key
(a pasted API key, or a saved state with no device) gets a device id
hashed from the key, so it is the same on every start rather than
anyDevice, which was new per process.
Differences from ZCode, kept on purpose: ZCode overwrites any user_id
and fills session_id with its session (sess_ prefix stripped); this
keeps an agent's own user_id and sends session_id "" as dress() does,
one stable value per account.
Tests: userid.test.mjs (new, 6 tests; 5 red on origin/main's index.mjs,
the count_tokens one passes there as it should). start, toolsearch and
dual tests that pinned coding plan bodies byte for byte now expect the
agent's body plus the device's user_id.
Run at this tree: HOME=$(mktemp -d) bun test -> 2672 pass, 1 skip,
0 fail across 229 files; bun scripts/check.mjs ok.
Not tried: a real BigModel or Z.ai coding plan request, so the cache
hit rate after the change is the reporter's measurement, not mine.
|
||
|
|
b07478285c |
zcode 0.1.28: a key's route is read again with each card read, after a Start Plan refusal, and a minute after one list without its plan (#369, #379)
Also publishes #371 (a team seat lists the person's gift plans and their
-Trial models,
|
||
|
|
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. |
||
|
|
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
|
||
|
|
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. |
||
|
|
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. |