ac4af582301a4e8a29245dbba767eba31334ddf9
22
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
a06872dec8 |
caps: a wallet window's spend is counted, so a cap holds it (#5770)
A window that tells only what is left (QuotaWindow.Balance: AStudio 0.2.0's 通用积分 and 星火积分, SuperMagic's points) read 0% used until it was empty, so an account cap never tripped on it. 9won capped an AStudio account at 4 and it spent over 1,000 credits past it. magpie now counts what such a wallet spends (wallet_spend.go). Each plugin reading's balance is set against the one before: a fall is spent, a rise (top-up, daily grant) is not. The count runs over the window's own period when it tells a reset, else the local day: a wallet never renews, and a cap reached for good would switch the account off with no time it comes back; the ask was "N a day". Spend before a period's first reading, or across a gap between periods, is unknown and not counted; spentSince says when counting began. The counts are kept in wallet-spend.json beside providers.json, so a restart doesn't lose them. Every wallet window carries spent and spentSince. On an account with a usage cap (WindowCaps.Holds) it also reads as amount spent of limit (spent plus what is left), and used that share. A cap by share then holds it in routing (allowanceOf takes the fields as they are) and on the GUI row (capHeldOf reads used). So does 40cbdaa7e's amount cap, which skipped a window with no total: 9won's "at most 300 a day" on a wallet now holds (magpie provider account-cap ... --window 通用积分 --amount 300). An uncapped wallet is unchanged: balance alone, routed by Allowance.Left. A cap just set is judged from the next reading. holdsBounds leaves wallets out: there is no whole to reckon "holds" from. Tests, each red on the old code (broken by hand where they compile): - TestPluginWalletCapHolds: real plugin host, fake plugin, wallet 10,000 -> 9,500 on an account capped at 4. Used 5, CapHeld set, the uncapped account untouched. Red with the plugin_usage.go hook removed (Used 0, Spent nil). - TestWalletSpendCounted: falls counted, top-ups not, a restart reads the count back, the next local day and a told reset start over (UTC+8 fixed zone), failed and share readings left alone. - TestWalletCapHolds: account cap 4, the window's own cap 4, and an amount cap of 700 (not held at 650 spent, held at 750). - TestWindowHoldsLeavesAWalletOut: red without the holdsBounds change (a wallet reckoned a 500-token whole). Run on mote at this tree on |
||
|
|
fa6725ee7f |
grok: an account with no plan says Grok, and the provider is Grok, not "Grok (SuperGrok)" (#3668, zane668, skygunner)
zane668's two Grok accounts both showed "SuperGrok", one of them on a plan that isn't. Two places named a tier no one had told magpie: - the account chip's Grok branch (accountPlan in app.js) fell back to the literal "SuperGrok" when the plugin reported no plan, and the Grok plugin reports none, so every account said it; - the retired built-in's provider name (movedCards in plugin_usage.go) and the Add sheet's Grok tile were "Grok (SuperGrok)". A known plan is still shown as told; with none, the chip says the provider's own name, Grok. The provider row and the Add tile say Grok; the tile's plans line still lists "SuperGrok · X Premium+" as the plans it takes. skygunner's patch (their branch fix/r25-grok-plan-absent-label, commit 7ca156c68, on #3668) is the app.js fallback and grok-plan.test.cjs, with plugin-plan.test.cjs updated; applied as written. The provider name and the Add tile are added here. Not changed: the plugin's own name "Grok (SuperGrok)" in magpie-community/plugins (packages/grok), which magpie's moved-card name overrides, and the plugin still returns no plan, so the real tier needs Grok's API for it, which isn't known yet. Run at the pushed head, on mote: - GUI (chromium + webkit, narrow widths, every language): grok-plan (new), plugin-plan, i18n-keys, add-sheet, deprecated-subscriptions, plugin-market, provider-listed-as, plugin-movable-review, plugin-signed-out-account: 65 pass, 0 fail. - go test -tags nogui ./internal/provider/ ./internal/gui/: ok (TestMovedProviderName now expects "Grok"). - GOOS=linux and GOOS=windows go vet -tags nogui ./internal/provider/: ok; gofmt -l clean. - Broken by hand: the "SuperGrok" fallback put back, grok-plan is red. Not tried: the real Grok plugin signed in with a real account. Co-authored-by: skygunner <84759+skygunner@users.noreply.github.com> Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com> |
||
|
|
ca1fc43fc9 |
provider: quota history draws no line for a plugin's aside window that says no share (#4825)
ggbdpq's patch (gua2100 on Discord), reviewed and landed with an
end-to-end test and a doc line.
What changed
- quotaOfPlugin marks an aside window that leaves `used` out, with no
count to reckon one from, as noShare. pointOf refuses such a window,
so the history no longer draws a flat 100%-left line for it. The card
still shows the row as before.
- noShare is unexported and so lost on JSON. Cards restored from the
cache have AsOf set, and noteQuotaHistory skips them, so this never
matters.
- Review changes: TestAsideWindowWithoutUsedDrawsNoLine now also runs
the windows through noteQuotaHistory and QuotaHistories in a sandbox
HOME, and wants lines [Bonus Weekly] only.
docs/subsystems/providers-accounts.md says such a window isn't kept.
Run at the pushed head (on mote, base
|
||
|
|
1390aa458f |
provider: a usage window's count is its share when used is left out (plugins#468)
A plugin window that sent amount and limit but no used was text alone (Text, Aside), and an account whose windows all did so was unknown to routing, weighed behind accounts it should beat. quotaOfPlugin now fills Used from amount/limit when both are above 0 and used is absent: 370 of 1000 is 37. An amount of 0 is what a left-out amount reads as, so a limit alone still says nothing (#3650 unchanged). aside still keeps a window out of routing whatever its count. amount is the amount used: the guide ("amount of limit used") and host.js's usageOf say so, and every community plugin that sends it (magpie-community/plugins 95fa761) sends the used count, never what is left: codearts (limit - remain), joycode (item.used), kiro, minimax (total - left), raccoon (granted - avail), cloudflare-workers-ai, cline (used, or total - remaining), zcode (used, total - remaining, or currentValue), gcp-ai (credits.used), copilot (limit - remaining), trae, workbuddy. None reaches the new path: each of these windows sends a finite used beside amount/limit. The one that can leave used out, cloudflare-workers-ai with no Analytics reading, sends amount null, which reads as 0, so its window stays text as before. The path is for plugins outside the community repo (GitHub-tagged or local) that send a count and no share. Run (mote, at this tree): gofmt -l clean; vet on three OSes; go test -tags nogui -timeout 45m ./... (go test -tags nogui -timeout 45m ./... at base |
||
|
|
8bade6c5e2 |
provider: a plugin's usage window can be a prepaid wallet's balance (#3950)
SuperMagic's accounts (mycf_711's magicrew plugin) are prepaid wallets of
points with no total. A plugin can now send a usage window as
{name, balance: 6291, unit: "积分"} with no used or limit.
- host.js passes a finite balance on (at least 0), anything else as null.
plugin.UsageWindow.Balance and provider.QuotaWindow.Balance are *float64.
- quotaOfPlugin keeps the figure and does not make the window Text or
Aside, so routing knows the account with no Used invented. allowanceOf
copies it into Limit.Balance; an empty wallet counts as used up.
Allowance.Left(model) is the least balance of the windows that count
the model.
- weighRouted fills routes.Seat.Left and Seat.LeftIn (the account's
provider and unit). Smart, pace and usage (least used) put the seat
with more left first where they would otherwise tie (byLeft), only
when every seat with a balance shares one LeftIn: balances in two
units or two providers are never compared. Tiers still come first.
- The Usage card, the Routing page (Weighed.Balance: the small row's
text, no bar, a why sentence, the account list), magpie accounts and
the status line show the figure, "6,291 积分 left", never a share.
- Docs: provider-plugins (new section), gateway-routing,
providers-accounts, plugin-runtime, host.js typings and the site's
plugins page (en, zh, ja).
Run, at base
|
||
|
|
9733ed1b4a |
usage: a plugin window that doesn't say used is no reading (#3650)
A plugin usage window that leaves out `used` was read as 0 in host.js
usageOf. The card then showed "100% left" (or NaN% once the GUI saw a
missing value), and allowanceOf ranked the account as the one with all
of its allowance left, so smart routing put spent accounts first.
Now a left-out used is null from the host, plugin.UsageWindow.Used is a
*float64, and quotaOfPlugin makes such a window Text and Aside: the card
shows its display (else "No allowance reported"), with no percentage and
no meter, and routing leaves it out. An account whose windows all tell no
share has no allowance and is not known to routing (routedAllowance), as
one never read: not preferred and not rested. A window that says used:0
is a reading at 0, as before.
Ported from skygunner's fix/usage-absent-used (6791aa99). Changed from
the branch:
- lastAllowances (the reading kept on disk) built an empty allowance for
such an account, which routing read as known with all of it left. Both
it and Allowances now go through routedAllowance.
- quotaText shows "No allowance reported" for a no-share window with no
display, rather than a blank.
- A host-level test (the bun host with the fake plugin) and the GUI test
widened to both engines, every language, 900 and 390px, used and left.
- The branch's check-in wording change is its own commit.
Note: an account whose windows are all aside or text was known with 0%
used before; it is now not known, so loginRoom won't pick it as the
next account with room.
Run at this tree (base
|
||
|
|
1dfa284840 |
usage: a plugin's row of text alone shows its text, not "· 100% left"
AutoClaw's 积分余额, Cline's balance, Cursor's Auto + Composer note and
the other plugin rows that are only words come to magpie as a window set
aside with a display and nothing counted (used 0, no amount, no limit).
Every surface read that used 0 as a share: the usage card said
"1,234 积分 · 100% left" (or "· 0% used") beside an empty meter, the
panel drew an empty ring, the TUI an empty bar, `magpie accounts` and
`magpie quota` "积分余额 0% (1,234 积分)", and the status line
"积分余额 0%".
provider: QuotaWindow.Text (json "text") marks such a row in
quotaOfPlugin: aside, a display, used/amount/limit all 0. Aside is
required: Cursor's On-demand "$0 / $20" isn't set aside and is a real
0%. QuotaSpan carries it to /api/quotas.
GUI (app.js): quotaText gives the display alone; the account row's
meter, the Usage page's track and the panel's rings leave the row out;
a panel card with only such rows shows their text on its line, as an
Unlimited card does. The tray's menu-bar text already skips aside rows.
TUI quotaCell, the CLI's quotaCell (accounts, quota) and statuslineCard
write the name and the text.
app.js stays under its budget (1,322,289, not raised; now 1,322,275):
to make room, the 8 copies of Math.max(0, Math.min(100, x)) are one
to100(x), and 8 one-line [..].filter(Boolean).join("\n") tooltips are
tipLines(..). Same results; the GUI files below cover those callers.
Readings cached before this release have no text flag and show as
before until the account is read again (a minute's cache, or Refresh).
Run, at this commit's tree (rebased on origin/main
|
||
|
|
0f1666b387 |
provider: a built-in can be retired, its plugin serving it moved or not, and its unmoved accounts get a Move line
The owner (10-16) wants every deprecated built-in taken out of magpie,
one at a time. This is the ground for that; it retires nothing yet.
- retiredBuiltins / BuiltinRetired(id) in migrate.go name a built-in
whose code is gone. Only an id with a mover can be retired.
- PluginServes(id) is Moved(id) or retired. Every gate that asked
Moved(id) asks it now: sign-in, Factory keys, usage, logins, cards,
forget, accounts, check-ins, plugin sign-in, the CLI's accounts and
providers, the GUI's account label.
- A retired row's move.state is plugin, and its id is in onPlugins
once the plugin is installed.
- /api/providers lists a retired subscription's built-in accounts that
haven't moved in `unmoved` (MoveCandidate, now with the failed move's
error and why). The GUI shows a quiet line over the Providers list
for each, with Move / Try again (unmovedLine), in en, zh, zh-TW, ja
and de.
- AGENTS.md and docs/subsystems/provider-plugins.md say what a retired
built-in is.
Run at 270aa1c9c with this change:
- go test -tags nogui ./... -count=1 -timeout 90m: 66 packages ok.
- gofmt -l internal: nothing. GOOS=linux and GOOS=windows
go vet -tags nogui ./...: clean.
- GUI, both engines, en and zh: retired-move (new, 4/4), plugin-move,
deprecation-notice, deprecated-subscriptions, plugin-move-unserved,
plugin-movable-review, i18n-keys: 39 pass.
- TestRetiredBuiltinIsThePlugins -count=20 (it picks a mover at random).
The Move line is the Providers list's own, not a page that could be a
plugin. It took the core's scripts to 1,427,218 bytes, which the budget
main raised in
|
||
|
|
7ba1b49846 |
plugin: a plugin's usage resets carry the team's and each window's
ZCode's built-in showed the personal plan's and the team's resets with each
reset's end; a plugin's usage could carry only one. host.js now passes a
plugin's resets.team and resets.each through, and movedCards shows them as
the built-in did. zcode 0.1.19 sends them.
TestPluginUsage's team and each check (plugin_usage_test.go) goes red without it.
Run at
|
||
|
|
2944e7e0b5 |
usage: a plugin's failed allowance read says the plugin's reason on the card, not only in its tooltip (太陽と向日葵 on Discord, aqiu817/magpie-sensenova#1)
SenseNova (日日新) has no built-in in magpie: the reporter's balance comes
from the community plugin github:aqiu817/magpie-sensenova, whose usage hook
signs in to platform.sensenova.cn with the console account typed at
sign-in and reads /lite/console/v1/tokenplan/pool-usage; the API key can't
read it. When that sign-in fails the plugin returns its reason in
usage.error, the host passes it on intact (usageOf keeps balance, windows
and error), and magpie showed only "暂时无法获取额度" with the reason in a
hover title, which a Docker web GUI user never sees.
Now a SubscriptionQuota whose Error is the plugin's own usage.error carries
pluginError, and quotaError(err, q) says "Allowance unavailable: {why}"
with the reason's first line (cut at 160 characters) on the provider
editor's account row, the Usage page's card and the tray's card. magpie's
own errors (not signed in, no such plugin, a host or transport failure)
and every error quotaError already words keep their wording. New string
in en, zh, zh-TW, ja and de.
The likely cause on the plugin's side, read from SenseNova's console JS
and not tried with an account: its password login takes the 用户名 (6–24
letters or digits); a phone number signs in by SMS code only, and the
plugin's prompt asks for "手机号 / 邮箱". That fix belongs in the plugin's
repo; nothing was posted there.
Run (sandbox HOME under the scratchpad, GOCACHE/GOMODCACHE pinned):
- go test -run TestPluginUsage$ ./internal/provider: ok. With
q.PluginError's assignment commented out it fails:
"plugin_usage_test.go:89: fakeco: plugin error = false, a@fake's = false".
- internal/gui/tests/plugin-quota-error.test.cjs (new), chromium and
webkit x en, zh, zh-TW, ja, de: 10/10. With origin/main's app.js it
fails in every language: "row: Allowance unavailable", "row: 暂时无法获取额度", ...
- GUI, both engines: plugin-quota-error, glm-quota-error, balance-fix,
copilot-signed-out-account, opencode-go-quota-error,
quota-balance-error, quota-curve, plugin-signed-out-account,
revoked-signin-account, usage-remote-cards, usage-access-key-card,
usage-card-refresh, usage-remote-key-limits, gui-de, gui-ja,
gui-zh-tw, i18n-keys: 223/223 each; after the move onto
|
||
|
|
af39ee4b5f |
gateway: a 402 for a usage limit rests the model out of quota, until the window renews (#1979)
Factory answers a Standard pool used up with 402 "You've reached your weekly standard usage limit (resets in 0h 19min). Switch to Droid Core ...". failure() read every 402 as out of credit, so the whole account rested a fixed 30 minutes: its Droid Core models (GLM-5.3, the reporter's fallback) were skipped with it, the "resets in" was ignored, and renewed() never lifted the rest when the window came back, since it lifts only failQuota or By=="window" rests (Ziqi-Cui, 09:16Z). - failure(): a 402 that matches usedUpWords and says nothing of money (creditWords, insufficient_quota) is failQuota. A payment 402, an empty one, Kiro's monthly count, Command Code's credits stay credit. - With failQuota the pooled check applies: Factory's Standard windows are scoped away from Core (built-in factoryQuota matches; the plugin's notModels/models through quotaOfPlugin), so only the model rests, and only until its window's end. - resetsAt also reads "resets in Xd Yh Zmin" (resetsAfter) when no windows are known, capped at longestWritten. - FactoryAllowanceForTest / PluginAllowanceForTest let the gateway test build both paths' allowances from their real payloads. Run: TestFactoryStandardOutLeavesCore (built-in and plugin:factory), TestPaymentRequiredReadByItsWords, TestResetsInWords; full internal/gateway (327s) and internal/provider ok; gofmt -l; go vet darwin, windows, linux -tags nogui. Broken by hand: the new failure() case removed -> both subtests red (account rested for credit, GLM resting); resetsAfter returning 0 -> TestResetsInWords red; quotaOfPlugin's notModels ignored -> plugin subtest red. Not tried: a live Factory account; Factory's Droid Core used-up wording is assumed to read like Standard's. |
||
|
|
6f1b432759 |
provider, gui: smart routing spends WorkBuddy credits that expire soonest first (cdredfox on X)
WorkBuddy's Credits window had no reset, so in a Smart group every WorkBuddy account ranked alike. workbuddy plugin 0.1.14 (plugins f0274d6) reads WorkBuddy's own package lists (billing/meter/get-user-resource-paid- packages and -free-packages, the calls WorkBuddy's client makes) and reports on the Credits window when the soonest-ending package that still has credits ends (runsOutAt) and how many credits it holds (runsOut). The daily Free Plan slice (CapacityType 4) and code 001 aren't counted: they renew daily. magpie carries runsOutAt from the plugin's usage window into QuotaWindow and the routing Limit. Allowance.Renewal, which only Smart ranks on, treats it as the window's reset when it is sooner than the real one. Pace, the tiers, For, Full and resting are unchanged. The mover's min is raised to 0.1.14 so moved users get the plugin. The usage card and account meter say "232.4 expire in 5h" in every language. Run: - plugin: bun test, 63 pass; 2 of the 3 new tests fail on 0.1.13's index.mjs. Verified live on a workbuddy-ai account in a sandbox HOME: Bonus Pack 232.4 left ending 10-12T16:39Z ranked before Pro (10-28). - TestWorkBuddyCreditsRunOutForRouting and TestSmartSpendsWorkBuddyCreditsRunningOutFirst: both fail with the Renewal change removed by hand. - GUI: credits-run-out.test.cjs in webkit and chromium, 5 languages, at 360/440/1000px, red on the old app.js; with i18n-keys, quota-*, panel-usage, reset-each-title, usage-fold: 117 pass. - go test ./... green (agent and gateway rerun with -timeout 30m after the default 10m ran out under load from other sessions; 378s and 492s). - gofmt -l clean; GOOS=linux and windows go vet of provider, plugin, gateway clean. Not tried: the CN workbuddy site (its token was stale, 401), so the CN package list is assumed to have the same shape. The built-in WorkBuddy (not moved users) doesn't get this. The account-line tooltip has no GUI test of its own. |
||
|
|
99009b9333 |
provider: a plugin's model pool counts a bare id with its @sizes, so a routing group's cursor/grok-4.7 is weighed on Cursor Models, not a used-up Other Models (Will on Discord)
Will's routing group keeps cursor/grok-4.7. Cursor's plugin (0.2.2/0.2.3) lists Grok 4.7 only at its context sizes, grok-4.7@256k and grok-4.7@500k, and its usage() builds the Cursor Models window's models and Other Models' notModels from those ids. quotaOfPlugin matched a model against those lists by the whole string, so bare grok-4.7 (which the plugin still runs, at its default size) fell into Other Models: used up, so the Routing page showed it 0% left and weighRouted ranked it last, while composer-2.5 showed ~84%. The window's lists are now an idSet: a bare id is in it when one of its id@size is, and an id@size when its bare id is. Only the trailing @size is taken off, so distinct models stay apart: another @size of a model, another family member (grok-4), and other suffixes (ZCode's -Trial) still match by the whole id. Every route that asks a plugin window whether it counts a model goes through w.matches -> Limit.applies (routing's For, Pace, Count, Renewal, fallback's Pooled, CapHeld, QuotaWindow.Counts for the usage page's holds), so the one change reaches them all. host.js's contract comment says so for plugin authors. The plugin's own lists are also fixed in magpie-community/plugins (cursor 0.2.4 adds each listed id's bare name to its pool), for magpie versions before this one. Verified: - TestPluginPoolCountsBareIDOfSizes (the reporter's literal ids) fails on the old code: "grok-4.7: used 100, want 16", "the usage page's holds count grok-4.7 in Other Models", "grok-4.8@1m: used 100, want 16"; passes with the change. - gofmt -l clean; go vet, GOOS=linux and GOOS=windows go vet -tags nogui on internal/provider and internal/plugin; go build for darwin, linux, windows. - go test -tags nogui ./... green but TestNoCommandBypassesProc, red on main since |
||
|
|
137ebee82f |
provider: a remote magpie's cards carry what was read behind the requests — the account switching's, the Codex warm-up's and routing's readings of each account (LoginUsage), routing's of each key (KeyAllowance) — and after a restart the readings kept in quotas.json, not only what the Usage page last read (#1313, jorben)
A magpie serving only other magpies (`magpie serve` in a container) has nobody on its Usage page, so GET /v1/magpie/quotas/cards, answered by CachedCards from the page's caches (subscriptionUsageCache, planQuotaCache, keyBalanceCache), said "nothing read on that magpie yet" while its Codex account's usage was read every few minutes behind the requests: those readings land in loginUsageCache (and a key's in keyAllowances), which CachedCards never looked at; after a restart even a page-read card was gone until the page was opened, though quotas.json held it.
CachedCards still asks nobody. It now lays each account's latest LoginUsage reading over its card when it is newer by readSeq (perLogin's cards are that same reading, so the page's own later read stands), adds a card for an account read that way and never on the page, named and drawn as the page names it (accountCard: perLogin now takes that face), and falls back to the reading kept on disk, dated (AsOf). Keys the same way: routing's KeyAllowance reading now keeps what was read with the windows (plan, balance, parts, readSeq) and is laid over the key's plan or balance card, or makes one; with no card read since start, the plan and balance cards kept in quotas.json are told. Cursor (known by asking its CLI), Grok (read by home) and a Kiro key keep the page's cards only. The local Usage page is unchanged.
Not fixed here: the quota history (/v1/magpie/quotas/history) is still written only by the page's reads.
Red before: with CachedCards as on origin/main and everything else in place, TestRemoteMagpieShowsBackgroundReadings (gateway, through lanGuard(New().Handler()) and a remote-magpie provider: CodexUsedUp, then RemoteCards) fails with the reporter's card ("nothing read on that magpie yet; refresh to have it read"), and TestCachedCardsTellBackgroundReadings, TestCachedCardsKeepALaterPageRead and TestCachedCardsTellKeyReadings fail; all pass with it. ForgetKeptCardsForTest is called from the gateway's fresh() so TestRemoteMagpieQuotas's "nothing read" holds under -count.
Run (Docker golang:1.26.8, the Mac's syspolicyd pegged): go test -tags nogui ./internal/... (internal/agent as uid 1000), go test -race ./internal/provider ./internal/gateway, go test -count=2 -run TestRemoteMagpie ./internal/gateway; go vet -tags nogui for darwin, linux and windows on internal/provider and internal/gateway; gofmt -l. No app.js change.
|
||
|
|
470d1e71a5 |
provider: a plugin account's usage reading begun before a request was answered no longer overrules the answer, so a 401's lapse mark isn't taken off by a clean reading already out (TestPluginFailover, about 1 run in 90) (waitingsnow) (#1176)
TestPluginFailover failed about 1 run in 90 at "a refused isn't marked". With notePluginLapse logged, a failing run read: a background reading of a's allowance (loginReading, after the "stream" round's StaleAllowance) began at 31.985; the upstream answered a's request 401 at 32.001 and notePluginSaid marked a lapsed at 32.003; the reading ended clean at 32.011 and notePluginLapse(200) took the mark off; the test read the logins at 32.042. Users meet the same: a reading of the Usage page or of routing's allowances that is out when a request is refused clears the mark the refusal left, and routing goes on trying the refused account; one that ends refused marks an account a request has just gone through on. What plugin accounts' sign-ins are told of is now counted under loginsMu (pluginSignInTold, pluginSignInSaid). A request's answer, a sign-in and the plugin's own signIn events are told now and apply as before. pluginLoginQuota takes the count before plugin.AccountUsage, and what its reading found applies only when nothing was told of that account since (notePluginLapseSince), as Allowances leaves out an account renewed while it read. A count rather than a time: Windows' clock moves in ticks of up to 15.6ms, and a reading begun just after an answer would read as begun with it. TestPluginUsageReadOlderThanAnswer holds the fake plugin's usage on an httptest server ($FAKE_USAGE, whose 401 the fake now reads as an expired sign-in) while a request's answer is noted, both ways, and checks that readings begun afterwards still mark and clear. Each direction fails without the fix. TestPluginFailover now reads the allowances the "stream" round left stale before the "gone" round: the fake's usage doesn't ask the upstream that refuses, so a reading that asks after the 401 finds the sign-in good and rightly takes the mark off. A review reproduced that with a delay injected before the count is taken. Left as it is: a reading whose own renewal of the token tells "renewed" before it asks skips the "expired" it then finds; the next 401 marks the account. Not tried with a real plugin account. Under a temp HOME with Go's caches pinned and bun 1.4.2: gofmt, go vet -tags nogui ./..., builds for darwin, GOOS=linux -tags nogui and GOOS=windows (and windows vet of provider and gateway) pass; go test -tags nogui ./... passes; the changed provider tests and TestPluginSaysSignIn/TestPluginFailover pass with -race -count=20; the report's `go test -tags nogui -race -cpu 1,2,4 -count=30 -run '^TestPluginFailover$' ./internal/gateway/` passed 3 rounds (270 runs), where it failed 3 of about 54 runs before the fix on the same loaded machine. |
||
|
|
37809ac722 |
usage: WorkBuddy's credits are said beside their share — on the Routing page, the Usage page and the menu bar, used or left as the share is (#659)
Moody-Sin: the Routing page showed a WorkBuddy account as "已用 71%" only, which for a plan counted in credits says little. A quota window now carries its own count when the vendor counts in amounts — amount of limit, in unit (QuotaWindow, QuotaSpan for quota --json and /v1/magpie/quotas, and the routing trace's Weighed, from the window its share is of: Allowance.Count). WorkBuddy's built-in fills it from the resource summary, and @magpie-community/opencode-workbuddy-auth 0.1.8 tells it from auth.usage (amount / limit / unit, passed through host.js); the workbuddy mover's min is 0.1.8. The Routing page's stage and its list of what each account did, the Usage page's meter, the menu bar's tooltip and the TUI say "3,550 / 5,000 credits · 71% used", or "1,450 / 5,000 credits · 29% left" with Left on (积分 in Chinese); a window counted in shares alone reads as before. quota-credits.test.cjs (WebKit, en/zh, used/left, Routing and Usage pages) fails on the old assets and passes; TestQuotaWindowCount, TestAllowanceCount, TestTraceTellsTheCount, TestPluginUsage (the count through the host) and TestWorkBuddyAccounts cover the Go side. Tried with the real WorkBuddy and WorkBuddy AI accounts in a sandbox magpie: moved onto the local plugin, /api/usage/quotas gives 33.29 / 3900 and 13.47 / 2250 credits and the Usage page reads "33.29 / 3,900 积分 · 已用 0.9%", "3,866.71 / 3,900 积分 · 剩余 99.1%" after a click on the count; not moved, the built-in gives the same for WorkBuddy. The Routing page with two real accounts of one provider wasn't tried (one account each). go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass. |
||
|
|
4ba51bb627 | plugin: a plugin names its own icon and the key field's title and hint (Lemon on Discord) — a plugin's provider took only the market's icon, and an api method's key field always read "<name> API key" with no hint. auth.icon (or package.json "magpie": {"icon"}) as an https URL, fetched once through the public-only icon path, or a data:image URI now comes before the market icon; an api method's label titles the key field as in OpenCode, and a new placeholder hints it, in the window and in magpie plugin login. README has a For plugin authors section. TestPluginOwnIcon, TestPluginOwnIconAndKeyHint and plugin-key-hint.test.cjs (Chromium, WebKit, en/zh) fail without the change. | ||
|
|
a28509e268 | providers: a built-in moved before its host was kept shows the vendor's host, not the plugin's id (要保证插件订阅 provider 跟内置的订阅 provider所有逻辑都要一模一样) — magpie providers and the Providers list showed "commandcode-plan", "zcode", "grok" for moves made before the move kept the built-in's host; those now show the built-in's own (api.commandcode.ai, api.z.ai, cli-chat-proxy.grok.com…), and one whose built-in showed none shows none. TestMovedShowsBuiltinHost fails without the change. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass. | ||
|
|
1fa21850a3 | plugins: a plugin can say its sign-in renewed, and what a usage read means for it (要保证插件跟内置的所有逻辑都要一模一样) — a built-in whose sign-in renewed took the lapse mark off whatever the request then met, and a plugin could only clear it with a success: X-Magpie-Sign-In: renewed now clears it on any status. A usage read marked a plugin account whenever its error said to sign in again and cleared it on any clean read, where Qoder's, Kiro's and others' built-ins marked none from usage: auth.usage may now say signIn: expired, kept or renewed, taken as the header is; one that doesn't say keeps the old reading. TestPluginSaysSignIn and TestPluginUsageLapse fail without the change. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./internal/gateway ./internal/provider ./internal/plugin pass. | ||
|
|
566ae09db1 | plugins: a moved provider's accounts keep what the built-in's had (你确保插件版的订阅 provider 和内置的一模一样了吗) — each account of a plugin provider has its own plan's models, not the first account's; a move carries each account's plan and a lapsed mark; a usage read that finds the sign-in gone marks the account and a clean one clears it, a network failure shows the last reading; a plugin that fails to load keeps its providers rather than taking them away; Kiro's API key is named and an OAuth account beside it stays off as in the built-in; Command Code Plan keeps its name. TestUnloadedPluginKeepsProviders, TestPluginUsageLapse, TestPluginAccountModels, TestMovedProviderName, TestKiroMover and the move test fail without the change. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./internal/provider ./internal/plugin ./internal/gateway pass. | ||
|
|
4a0fbc332c |
plugins: a built-in moved onto its plugin looks and works as it did (你确保插件版的订阅 provider 和其对应的内置的…都保持一模一样了吗?) — moved onto its plugin, a built-in lost pieces: its tile's name, icon, plans and risk note went to the plugin's own, "Add account" still opened the built-in's sign-in (in the app, on the server and in magpie accounts add), an agent's own sign-in the built-in still found showed a second usage card of the same account, the account's plan badge went, WorkBuddy's daily check-in stopped, the provider's icon and site were the plugin's, WorkBuddy AI's card was named WorkBuddy, and Devin, which had no card of its own, lost the plugin's. Now a moved built-in keeps its tile and risk sheet and signs in through its plugin; its cards take the built-in's place and name, and it has none of its own; the plan the plugin tells stays with the account; WorkBuddy checks in through the plugin, which signs the call; a card is left out only where its built-in's slot showed it. TestMovedBuiltinQuiet, TestWorkBuddyCheckinThroughPlugin, TestMoveToPlugin (Devin-like card) and TestPluginUsage (plan kept) fail without the change. Command Code and Devin moved and back in a sandbox HOME: one card each, plan, name. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass; plugin-move, plugin-signin, commandcode-risk, old-webkit pass; click-scroll's WebKit fails the same on origin/main under this load.
|
||
|
|
f5f10bda4d | plugins: a plugin's accounts show their allowance as the built-ins' do (the user: 所有插件要完整支持显示额度!跟内置一模一样!) — a plugin's auth.usage now tells plan, user, until, renew, balance, resets (count, until, by window, five hours, weekly) and windows (used past 100 when overspent, resets at/in, display, span, the models a window counts or leaves out, aside), and magpie shows them on the usage page, in the menu bar, beside each account and to the gateway, which passes over an account used up for the model asked; a built-in moved onto its plugin keeps its card's name and icon. Also: Command Code's subscription endpoint answering 200 {"success":false} was read as "No plan" by the built-in (and the plugin), it is now unread; a moved Devin was listed twice, the built-in still finding the Devin CLI's own sign-in; and moving back left the plugin's rows in logins.json, listed as empty accounts. Checked in a sandbox HOME with real Command Code and Devin accounts moved onto the community plugins (0.1.1): GOAT, its period, 5 hours / Weekly / Credits for Command Code, Teams, balance and Daily/Weekly for Devin, the same on the built-in after moving back, no plugin rows left. TestPluginUsage, TestCommandCodeSubscriptionUnread and TestMove (the plugin's rows after moving back) fail without the change. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass (TestClaudeSignedOut and TestUserPath timed out once at load 22, pass alone). |