d3fc6f2bfada18e6ae7887b79ed1e4c650ca37e1
1882
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
d3fc6f2bfa |
provider: FileError and groupsKeeping read providers.json's kept parse
Each Providers page asked FileError whether providers.json reads, and
groupsKeeping whether any group unlists models; outside a held request
both parsed the whole file again (6.7MB growslice of 112MB per 40
/api/providers asks on the real-account copy). Both now use the parse
filememo keeps until the file changes (storedFile); FileError falls
back to read() only when that parse fails, so a broken file still says
so with read's own error. Both are read-only uses.
Run: TestFileErrorReadsParsedFileOnce red with the memo path taken out
("parsed the file 3 more times"), green with it; TestFileError* and
the unlist tests on mote.
|
||
|
|
0ec28be0d4 |
provider: a look at the accounts for sign-in alerts is held, built once
signInStates ran twice every two minutes all day: once for the app's notification (WatchSignIns) and once for the gateway's hooks (tellHooksOfSignIns). Outside a request nothing is held, so each account's PluginOf built the plugins' list again (plugin.Cached reads plugins.json and the plugins' auth) and Logins read every login again. The look now holds the catalog (provider.Hold), as a request does, so each is built once a look. |
||
|
|
b3791e8a6a |
providers: the page's model, provider, preset and group-member lists are made at their size
/api/providers grew five lists by append, each of large elements: a group's members (Member, 1408 bytes) in membersFound, the picks a vendor list lacks (catalog.Model) in providerInfoWith, and the Providers and Presets lists of providersState. Each is now made once at its count. membersFound also clones a member's path and builds its key only after the checks that pass it over, and a group with no member found still gives nil. |
||
|
|
c02a491e87 |
provider: a Codex auth.json is parsed once for its bytes, not on every look
codexWho (email and workspace) and codexLoginIn's user and plan are read
from an auth.json's bytes alone, yet were a JSON parse and a JWT decode on
every call: codexName runs sameLogin over every saved account against each
other, and liveLogin("codex") is asked from four loops at rest
(loginsNow, rememberLogins, heldByCodex, renewLogins). Both now go
through authMemo, a map keyed by the bytes (a hit makes no string and
allocates nothing), emptied at 64 entries so tokens renewed every hour
don't pile up.
Measured on mote with a copy of the real accounts (acidle.sh, alloc
between 60s and 180s at rest):
- t17 (
|
||
|
|
8016b9fcad |
providers: the page counts the catalog instead of copying it
providersState read provider.Catalog() only for its length and its routing groups, and Catalog copies every listed model's Entry (1.6 KB each): catalogKeeping was 11.5MB of 128.5MB allocated over 40 asks of /api/providers on the real account. provider.CatalogGroups gives the groups (the caller's own copy) and the count Catalog would have, by the same Unlisted and group-unlisting rules, with no model copied. Measured on mote with the real account copy (aalloc.sh, 40 asks, alloc_space delta): 128.5MB (v0.1.3452) -> 115.4MB, -10%; 213.4MB before v0.1.3446. Run: go vet ./internal/provider ./internal/gui; go test -count=1 -timeout 45m ./internal/provider ./internal/gui (ok, ok) on mote. New TestCatalogGroupsIsCatalogs compares it with Catalog with no groups, a group listing alone beside an unlisted provider, and that group off; counting the unlisted models too, by hand, makes it fail in all three. Not tried: Windows and Linux (no OS-specific code). |
||
|
|
8295db7d10 |
providers: hostOf shares hostnameOf's parsed URLs
|
||
|
|
a09e967f53 |
providers: with no account removed, Hidden makes no account
Hidden read every sign-in (Accounts: Codex, plugins, Claude...) and then kept those the user removed. The Providers page asks it twice a poll (directly and through Excluded), and most users removed none; the real account has none, so ~0.6 MB a poll was made for an empty answer. It now looks at the saved file first and returns nil when nothing in it is hidden. Measured on mote with the real account copy, 40 asks of /api/providers (aalloc.sh, alloc_space delta): 169.8MB (v0.1.3447) -> 146.6MB, -14%. CPU for 30 asks (aeach.sh): 0.65s -> 0.56s. Run: go vet ./internal/provider; go test -count=1 -timeout 45m ./internal/provider ./internal/gui (ok, ok) on mote. New TestHiddenNoneMakesNoAccount fails with the check taken out by hand (254 allocations, its accounts 249) and checks a removed account is still listed. Not tried: Windows and Linux (no OS-specific code). |
||
|
|
1eebd1ff3c |
providers: a known maker price is answered without garbage too
|
||
|
|
b53f4e7c49 |
providers: a known price and a known hostname are answered without garbage
The Providers list asks the price memo for every model of every provider on each poll, and the hit built its key as a new string each time. The key is now built in a stack buffer and looked up through string(k), which Go doesn't allocate for a map index; it is copied out only when the price is new. hostnameOf parsed every provider's base URL with url.Parse on every poll; the hostname is now kept per URL (reset at 512). Measured on mote with the real account copy (aalloc.sh, 40 asks of /api/providers, alloc_space delta): 213.4MB at origin/main (t12), 186.9MB with this change (t13), -12%. CPU for 30 asks 0.64s -> 0.62s. Run: go vet ./internal/catalog ./internal/provider; go test -count=1 -timeout 45m ./internal/catalog ./internal/provider (ok, ok) on mote. New TestPricedOnceHitAllocatesNothing and TestHostnameOfKept fail on the old code (1 allocation each, broken by hand) and pass with it. Not tried: Windows and Linux (no OS-specific code). |
||
|
|
ab3710de3a |
hooks: onSignIn tells a request hook of an account to sign in again
shannnnnks on X: with several Codex accounts behind the gateway, one is
now and then signed out, and they want the notify plugin to push it.
The magpie that serves the gateway now looks every 2 minutes (first
after 1) at the same sign-in states the desktop alert reads
(provider.WatchSignIns' checkSignIns, so every provider: Claude, Copilot
and plugin accounts that lapsed, and built-ins whose mark says the
sign-in expired or must be done again, Codex's revoked and refused
refreshes among them; accounts in use only). Each account to sign in
again, and each Claude sign-in ending within days, goes to every hooks
file that exports onSignIn, once until the account works again, kept in
signin-hooks.json beside the desktop alert's own file. The event is
{provider, providerName, account, state: "signed-out"|"ending", endsAt?}:
the account is its display label; no token and no vendor reason text.
It is fire-and-forget in the Bun host (gatewayRequest operation
"signIn"), each hook under its own timeout, one that throws doesn't stop
the next. With no hooks file nothing is looked at or marked. A hooks
file may now export onSignIn alone, without onRequest.
Docs: gateway-request-hooks.md (Sign-in notification),
providers-accounts.md, site plugins.html en/zh/ja.
Run on mote at d939dd699 (on origin/main 835439ebf; then rebased on
|
||
|
|
00af08e7b8 |
routing: a renamed group still answers to its old id until a new group takes it
xinvxueyuan on Discord asked that renaming a routing group keep the old group/<id> working (agents and scripts still name it), and that the old id stop working only when a new group takes that id. A Group now keeps Former, the ids it had before RenameGroup, newest last. FindGroup, FindGroupAlso and Resolve (the gateway's known-model check) fall back to the group whose Former has the id (routedGroupOf). A group saved or renamed onto an id drops it from every other group's Former (dropFormer). A save that doesn't send Former keeps the old list. Run (mote): go test ./internal/provider -run 'Rename|Group' ok; go test ./internal/gateway -run TestRoutingGroups ok, with a new check: rename mine->ours, POST group/mine answers 200 through ours. Broken by hand: routedGroupOf without the Former loop turns TestRenamedGroupKeepsItsOldID red; Resolve without the fallback turns TestRoutingGroups red with 404 "knows no model group/mine". Full provider/gateway/gui/agent run and Linux/Windows vet started on mote after push; reds will be filed. Not tried: the GUI showing the old id anywhere (it doesn't list it). Reported-by: xinvxueyuan (Discord) |
||
|
|
c6331b427c |
routing: a group bound to gateway keys is theirs alone (Xerxes754)
Xerxes754 on X asked to bind a routing group to one or two gateway
keys, so other keys neither see nor use it. Before this a key could only
be held to models from its own side (naming group/<id> in its Models);
a key with no limits reached every group, and nothing on a group could
keep it from one.
A group now has Keys (key ids). Set, only those keys, and keys issued
under one of them, may use it:
- groupBarred/groupGiven in key_models.go answer it for every route that
reaches a group: chat, responses, messages, count_tokens, embeddings,
images, video, the decider and the subagent and image MCP paths. Any
other key gets 403 "bound to other gateway keys", naming the group and
the Routing page, and nothing goes upstream.
- /v1/models and /v1/models/{id} leave it out for any other key, a key
held to models that names it included. provider.GroupsBound keeps an
unbound magpie's list as before.
- A keyless request from this computer uses it, as key limits never
hold one; callerGuard now names a loopback request's key when it
sends one, so a key used locally is held too.
- SaveGroup keeps the stored keys when a save doesn't name them (the
CLI, the TUI, the card toggles); an empty list clears them. Ids are
trimmed, deduped and capped. Sharing a group leaves its keys out;
importing over one keeps them.
- GUI: Routing, a group's Edit, row "Gateway keys" (网关密钥) with a
button "Any gateway key" (任意网关密钥) that opens the app menu of the
user's keys (multi-pick); a bound key since deleted shows "key
deleted" (密钥已删除). The row shows once there is a key to bind.
/api/groups lists gatewayKeys (no browser, read-only or issued keys).
zh, zh-TW, ja, de strings.
- Not covered: a bound group nested in another group is reached through
the outer one (documented in gateway-routing.md).
Run (mote unless said), at this head rebased on
|
||
|
|
f37de8cc4e |
provider: the saved Claude accounts' files are listed once per request
claudeCodePrice and claudeModelsOf listed claude-accounts/*/.claude.json with filepath.Glob on every call, and each Claude model's price asks. Building an agent's model list (the window's drift poll rebuilds it each minute, buildClaudeVia and Pi's list) read the folder once per model. The listing is now held while a request holds the catalog (heldOf, 1 s), so a build lists it once; outside a hold it is listed afresh, as before. Measured on mote, real-account copy, GUI page open in Playwright Chromium, network blocked, 115 s CPU profile (acgui.sh), v0.1.3425-era build vs this change: - filepath.Glob: 50 ms -> gone; agent.buildModels 90 ms -> 50 ms - total samples 320 ms -> 290 ms; footprint 197 MB -> 172 MB (one run each) Test: TestClaudeCodeFilesListedOncePerHold saves a folder during a hold and checks the hold's second listing is the first one (same array), and that after the hold the new folder is seen. Broken by hand (the old claudeCodeFiles): red, "listed again within one hold". Run (mote): go test ./internal/provider ./internal/agent ok; go vet native (provider, agent), GOOS=linux and GOOS=windows (provider) ok; gofmt clean. |
||
|
|
8f72f95304 |
provider: a group's lookup copies the group found, not every group
FindGroup, FindGroupAlso and GroupFinder built every routing group with groupsIn, which copies each group and its rules, to return one. The window's 15-second /api/drift poll asks GroupFinder for each Pi model on a group (piModelJSON), and the gateway asks once per request on a group. They now read the groups held (sharedGroupsIn, heldFrom while Hold is active) and copy only the group found and each group a member comes through (cloneGroup), so what a caller gets is still its own to change. Measured on mote with the real-account copy, GUI page open in Playwright Chromium, network blocked, 2 minutes (acgui.sh): - piModelJSON allocations: 10.6 MB -> 1.5 MB (v0.1.3420 vs this change) - process CPU 0.39 s vs 0.43 s, footprint 187 vs 197 MB: within the run noise of the once-a-minute catalog rebuilds; the drop is in the profile. Test: TestGroupFoundCopiesItselfAlone changes a found group, its member's Via and EffortMap, and checks FindGroup, GroupFinder and Groups still see the saved ones; then 50 looks must allocate less than 50 copies of every group (100 groups with rules). Broken by hand, each red: - A: sharedGroupsIn -> groupsIn: looks 5384832 B >= copies 4796000 B - B: no cloneGroup of the found group: index out of range (shared slice) - C: no clone of a member's sub-group: "a change to a found group reached the next look" Run (mote): go test ./internal/provider ./internal/agent ok; go test ./internal/gateway -timeout 45m ok; go vet native, GOOS=linux, GOOS=windows ok; gofmt -l clean. Not tried: a gateway request through a group with a real account (the path is the same FindGroup the test covers). |
||
|
|
88b541a25c |
images: every pointer names Settings › Models › Images, where the page is
The image models moved under Settings › Models, but the Library's Magpie
Image sheet, the MCP server's instructions to agents, the gateway's
"no image model" errors, the video tool's text and the docs still sent
users to "Settings › Images", a tab that no longer exists (the scattered
settings audit after netube99 on X). Every user-facing string now names
Settings › Models › Images in en, zh, zh-TW, ja and de, as do the site's
Qwen docs (en, zh, ja), llms-full.txt, the subsystem pages and comments.
Run in the tree with this change and the rest of the audit's fixes
(mote, base
|
||
|
|
cdd99c5578 |
routing: a re: pattern with a lookahead saves and matches as its preview showed
maer8824 on Discord wrote "re:(?!.*flash).*glm.*" (glm but not flash) in
a routing group. The GUI's preview, which reads patterns with JS's
RegExp, matched the right models, but saving failed: Go's regexp has no
lookaround ("invalid or unsupported Perl syntax: (?!").
compilePattern now reads with Go's regexp first, as before, and only a
pattern Go can't read goes to regexp2 (already in go.sum; now required
directly), with a 100ms bound on one match. A pattern Go reads keeps
exactly the matches it had; one neither reads is still refused with
Go's error. Groups' patterns and providers' auto-include rules both
compile here, so both take it.
Run on mote at this head: go mod verify ok; go vet ./... ok;
GOOS=linux and GOOS=windows go vet ./internal/provider/ ok;
go test -count=1 ./internal/provider/ ok (133s).
Broken by hand: with groupmatch.go/autolist.go/go.mod reverted,
TestRegexpPatternLookahead fails 5 ways (the reporter's error among them).
Not tried: a real group saved in the GUI; the full suite follows the push.
Reported-by: maer8824 (Discord)
|
||
|
|
1f1d210156 |
quotas: a wallet's counted spend goes out on /v1/magpie/quotas too (#5770)
|
||
|
|
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 |
||
|
|
fc8e98ba47 |
edit: Codex's thousands of [projects] tables are left out of the reads that don't want them (#2278)
Codex writes a [projects."…"] table for every project it is trusted in;
the owner's config.toml has 10,933 of them in 1.5 MB. go-toml's decoder
checks each table against its siblings one at a time, so every decode
of the file cost ~0.3s of CPU, and six readers decoded it again each
time Codex wrote it, plus a whole-file check before each write magpie
made to it.
- edit.TOMLWithout drops [projects…] tables in a single unstable.Parser
pass. The agent's codexTopOf, sessions' readCodexConfig, provider's
readCodexStoreSetting, library's rtk sandbox, hooks rekey and MCP
entries read through it. None of them reads projects. A file that
doesn't parse is passed through unchanged, so it still fails.
- validateTOML checks definitions with the rest of the file and the
projects decoded apart, 128 projects to a decode. A bare [projects]
table, a dotted projects.… key outside the tables, or any error
decodes the whole file, so the error is the one it gives.
Run on mote (M5 Pro):
- BenchmarkCodexConfigDecode (10,933 projects): 283ms -> 7.6ms a decode.
- BenchmarkValidateCodexConfig: 52ms (the whole decode was 283ms).
- Startup CPU profile, first 70s, the real-account copy (the real
1,524,099-byte config.toml): 2.76s -> 2.26s of samples; go-toml
0.32s -> none sampled.
- go test ./internal/edit ./internal/sessions ./internal/provider
./internal/library ./internal/agent: all ok.
- go vet of the same five on darwin, GOOS=linux and GOOS=windows; gofmt -l clean.
Broken by hand:
- Decoding the batches into struct{} instead of a map:
TestValidateTOMLDefinitionsInGroups went red ("a key twice", "a
subtable then its key"), so the check keeps maps.
Not tried:
- the whole suite. Only the five packages that read the file were run.
- Now that projects is left out, a project table defined twice no longer
fails these readers' decode. Codex itself refuses such a file.
|
||
|
|
c056b7c8c3 |
provider: a Responses provider's turns may go over the Responses WebSocket (#5781)
A provider the user added with an http(s) Responses address can now send its Responses turns over the Responses WebSocket that magpie already speaks to chatgpt.com (codexSocket), with `socket=auto|on|off`: - off, or absent: today's behaviour exactly. Provider.Via hides any socket value an outer context carried, so such a provider never dials. - auto: tries the socket, falls back to HTTP when the handshake is refused or the socket ends before the reply, and speaks HTTP to a host for 10 minutes once it refused the handshake (codexShun). - on: the same fallback, but never shuns; the socket is tried each turn. Provider.Via puts the provider's Responses host and path in the request's context (withSocket); codexSocket's gate is provider.SocketTurn, which takes a ChatGPT turn as before, or a POST to that host at <Responses>/responses. The rest is the ChatGPT leg's: the kept socket and its delta (codexKeepKey now also hashes the scheme, X-Api-Key and Api-Key), the error frames, 1009 handling. A provider's reply with no Content-Type is marked text/event-stream, since it is read as one. Routing, keys, limits, usage and masking are unchanged: only the transport under the request differs. Set with `magpie provider set <id> socket=auto|on|off` (refused on a provider with an account, no http(s) Responses address, or Vertex, TakesSocket), saved in providers.json as "socket", shown by `provider show`, and in the editor's Advanced as a WebSocket tick beside HTTP version (ticked saves auto, keeps a CLI's on, unticked saves off; shown only while the Responses address is http(s) and there is no account). docs/subsystems/providers-accounts.md describes it. app.js pays for its rows by three long comments cut to one line (renderMove, the vendors' status pages, header rows): the core's scripts are 478 bytes smaller than on |
||
|
|
4da0aa0272 |
provider: Kiro's mover min is 0.1.35, its sign-in words in magpie's languages
Kiro plugin 0.1.35 (plugins 588b3611) gives each sign-in way, its first question, the question's choices and their hints in zh, zh-TW, ja and de, which magpie shows since the commit before last, and the API key field a ksk_… placeholder (mahiro233 on Discord). keepMovedCurrent brings every moved Kiro user to it. npm view @magpie-community/opencode-kiro-auth version --prefer-online --registry https://registry.npmjs.org: 0.1.35 (shasum 98618eda), at landing. The publish run 42600418987 is red for the known middleware-system-prompt and middleware-think-tags trust errors only; kiro itself published. A one-line min change; the Go checks of the two commits before ran at that tree on mote (internal/provider ok). |
||
|
|
40cbdaa7e8 |
provider: an account's window can be capped at a fixed amount of its unit
A window magpie reads with a total and a unit (a day's 1000 credits, a
plan's requests) can now be capped at an amount of that unit, not only
a share: 9won_25273 asked to stop an account at 300 of its day's credits.
- AccountWindowAmounts keeps it per account and window (capId). An
amount and a window's own share replace each other.
- WindowCaps.limitShare turns it into a share of the total for the mark
and NearCap. CapHeld and capReached hold the account once the window's
count reaches the amount (past), and rest it as the percentage cap
does: the next account takes the request. cappedError and the trace
say "has used 300 credits ... past its cap of 300".
- A reading with no total ignores the amount; the account's share
applies.
- GUI: the window meter's menu has one more item, Amount..., typed in
place (provider/windowcap with amount). It shows only on a window
with a unit and total. Strings in zh, zh-TW, ja, de.
- CLI: magpie provider account-cap <id> <account> --window <name>
--amount <n|off>.
Usage outside magpie counts: every cap reads the vendor's own count, so
what the account spent in the vendor's app or on another machine counts
from the next reading on. magpie can only hold back its own requests.
Run, at this head on Linux (wsl-run, magpie-desktop):
- gofmt -l: clean; go vet ./... for linux (-tags nogui) and windows: ok (darwin
vet needs cgo, so it runs with the full suite on mote afterwards)
- go test -run 'Lang|ToolLoop|LoopGuard|Cap|Amount' ./internal/gateway
./internal/provider ./internal/cli: ok (TestWindowAmountCapHeld,
TestSetWindowAmount, TestWindowAmountHoldsTheAccount, the CLI cases)
- GUI window-cap, window-cap-pool, account-cap in chromium and webkit,
420 and 1100 wide, en zh zh-TW ja de: 78 of 78 in each engine. An
earlier webkit run lost the amount test's page once ("Target page,
context or browser has been closed"); it passed in 2 more full-file
runs and 60 of 60 alone
- i18n-keys: only "a plugin's words are its own" red, words that aren't
this change's (#5332, #5426, #5482)
Broken by hand: limitShare ignoring amounts (of < 0): TestWindowAmountCapHeld
and TestWindowAmountHoldsTheAccount go red.
Not tried: the full go test ./... at this head (queued on mote, runs
after); a real account at an amount cap.
iFlytek: 9won's 讯飞 overshoot isn't covered. Loomy's daily window sends
used as a count and amount as what is left (plugins#889); AStudio's
wallets tell a balance only, which no cap can hold (#5770).
Reported-by: 9won_25273 (Discord)
|
||
|
|
2b8ff0fbeb |
routing: an account's model list older than the model is unknown, not a plan without it
wudao_85256 on Discord: two ChatGPT Plus accounts on the Codex subscription, each serving gpt-6.1-sol alone. With both on, Routing said of the second "its plan doesn't list gpt-6.1-sol", and once the first ran out of its allowance nothing failed over: an unlisted account is asked only after a listing one refuses the model as unserved, never after a 429. Re-adding the account and refreshing changed nothing. Cause: the second account's own list (models/codex@<user>.json) was the evidence, and it was stale. The ChatGPT backend lists gpt-6.1-sol only to Codex 0.161.0 and later ( |
||
|
|
40cfae5d3b |
provider: Kiro's mover needs opencode-kiro-auth 0.1.34, which gives each model Kiro's credit multiplier as its rate
01huadalang on Discord asked for Kiro's credit multiplier. 0.1.34 (plugins 1aab125b) reads each model's rateMultiplier (rateUnit "Credit") from ListAvailableModels and carries it as the model's rate, which magpie's plugin host reads as Model.Rate. Usage is not multiplied again: a meteringEvent's credits already include the rate. Raising min makes keepMovedCurrent update every moved user's plugin. Run: npm view --prefer-online --registry https://registry.npmjs.org @magpie-community/opencode-kiro-auth version = 0.1.34, checked again at landing. At base |
||
|
|
2d1b7c1b6c |
codex: a workspace sharing Codex's sign-in reads and sends as its own workspace
JdAZzzzzz (X) has a personal Pro and a Team seat of one ChatGPT login in
magpie, and switches workspace in the Codex app. Both cards read the
same plan ("Prolite"), week, reset time, pace and two reset cards; only
the token counts (local sessions) differed.
Cause: one ChatGPT sign-in reaches every workspace of its login with
one refresh token. Codex's workspace routing (codex-rs
login/src/auth/manager/workspace_routing.rs, /wham/accounts/check)
changes which one auth.json names in tokens.account_id. rememberLogins
saved each workspace as an account (codexWho goes by account_id), both
with that refresh token. renewSaved found the account not in use "held
by Codex" (heldByCodex: same refresh token), renewed through Codex's
store as it should, and returned that store's account id too: the
workspace Codex is on. So the other account's usage, plan, resets and
the gateway's requests for it named the workspace in use, and spent it.
- renewSaved returns the saved account's own workspace for a token read
where Codex holds the sign-in, in ~/.codex and in another Codex folder
(codexOwnWorkspace).
- A sign-in sync put Codex's auth.json on every record sharing its
refresh token, so the other workspace's record was carried as the one
in use. liveCodex and applyLogins no longer match by refresh token
when the workspaces are known apart (codexWorkspacesApart).
TestCodexAppWorkspaceSwitchReadsEachWorkspace: one sign-in (same
refresh token, the real token's claim layout), the app's switch with
only account_id rewritten or with the tokens naming the new workspace,
Codex left on either one. On the old code all 4 cases are red with the
report's picture ("jd@example.com · ws-team (ws-team) reads plan
"prolite" ... 2 resets; its workspace has "team" ... 0 resets"), the
account's requests signed for the other workspace, and CollectSignIns
carrying each record as the other workspace. Green with the change.
Run at
|
||
|
|
608c1543e8 |
gateway: a bare model name goes to the asking agent's own subscription first
freefcw on X: Codex, started by Mirasim, asked for gpt-6-astra by its bare
name. Its own ChatGPT subscription serves it, but magpie sent it to Devin
through the group it found (auto-gpt-6-astra, soonest renewal first).
With found groups off it still went to another vendor: Resolve takes the
first provider in the Providers order, AutoStandIn and agent.Reseat did
the same.
Now:
- A bare model id the asking agent's own subscription in magpie serves (a
provider whose Account.Agent is the agent: Codex's ChatGPT accounts,
Claude's for Claude Code, Copilot's) goes there, found groups on or off
(gateway ownFirst, provider.OwnRoute). count_tokens counts it there too.
- Kept as they were: a group the user made or changed by that name; a found
group magpie set one of the agent's fields to (agent.SetToGroup over the
applied record, #750's bare spelling included, wired as
gateway.SetToGroup); a gateway key held to some models; ids with a
provider in them and group refs; clients magpie doesn't know as an agent.
- Found groups off: a bare id several providers serve, none of them the
agent's own, is refused for an agent that has a subscription of its own
in magpie, with a 400 naming the provider/model ids and
"magpie group auto on" (provider.OffSpread). Off, magpie picks no vendor.
- AutoStandInFor and Reseat's sameModel prefer the agent's own
subscription for a found group that is gone.
Docs: gateway-routing.md's Model resolution row and the bare-ids section.
Run (mote, at this tree on
|
||
|
|
c81065ca72 |
providers: System One for a custom provider and Ark's pay as you go
A user on Discord (#feedback) found no System One endpoint under a custom provider's More endpoints (OpenAI Responses), no System One choice in its Model settings, and on the Volcengine Ark page neither an endpoint nor any model a routing group could ask as its classifier. System One is asked at POST …/systemone under a provider's Decide base; a model is offered as a group's classifier only when its provider has one. Two causes: - A custom provider kept a Decide URL only when its API was "System One base URL". With a Responses or chat URL there was no field for it, and Save sent "" for one the provider didn't have yet. More endpoints now has "System One URL" for any API, saved as typed. - Ark's pay as you go answers System One on the same key at ark.<region>.volces.com/api/v1, but a provider asked at …/api/v3 (the preset's or a custom one, chat completions or Responses) had no Decide unless the user knew to type it. normalize now sets it (arkSystemOne); a URL the user gave is kept. The Coding and Agent Plans answer System One 404, so they get none, and decideKeys leaves out a key whose plan has none (a Coding Plan key beside a pay-as-you-go one). Ark's one decision model is offered whatever chat models are picked, as Bailian's is (OfferedDeciders). Run on mote at this head's tree (65aacb8f8, on |
||
|
|
77076eef47 |
agent: an npm update on Windows lets go of magpie's own claude and codex first
CLJY (Discord) had %APPDATA%\npm with only the 308-byte sh shim of claude: no claude.cmd, no claude.ps1 and no codex at all, and `npm i -g @anthropic-ai/claude-code` ended in "npm warn cleanup ... EPERM ... unlink ...\.claude-code-<rand>\...\claude-code-win32-x64\claude.exe". On Windows a running program's file can't be removed. npm moves the old package aside, takes the old shims away, and stops partway when a claude.exe of that package is still running; the sh shim is what is left. magpie keeps such processes running itself: - the Claude subscription bridge keeps up to 6 Claude Code runs waiting for their conversations' next turns, for up to an hour; - Codex's app-server daemon has no idle exit, and magpie restarts it. Its Update button ran npm with both still up. - agent.UpdateCLI, on Windows through npm, bun or pnpm, first lets go of them: gateway.LetGoIdleClaudeCode ends every waiting run (its session shelved for the next turn, as a run let go past idleMost is) and returns once each has exited; provider.StopIdleCodexDaemon stops the daemon when no codex session is on it. Runs in a turn and sessions are left. - An update on Windows that leaves the CLI's file gone fails, saying to quit it and reinstall, instead of "updated". - proc's toolIn (FindTool) and codexExecutable no longer take the bare extensionless file on Windows, which CreateProcess can't run. Beside name.exe and name.cmd, the sh shim alone stands for the .exe it runs (Claude Code's bin\claude.exe), read from cmd-shim's exec line and kept inside its folder; a node shim (codex) or any other script is skipped. The testdata shims are cmd-shim 7's bytes, made with cmd-shim@7 on the Windows box. Run at this head (rebased on origin/main; after the rebase, vet on all three systems and the changed tests again: ok on Windows and macOS): - gofmt -l internal/: clean. go vet of proc, agent, provider and gateway on macOS (mote), Windows (win-run) and Linux (wsl-run): ok. - Windows (win-run): internal/proc ok; TestToolInNPMShShimAlone, TestLetGoIdleClaudeCodeFreesTheExe and the TestClaudeIdle* tests pass. internal/agent, internal/provider and internal/gateway (-run "Claude|LetGo|Codex") have Windows reds, and the same run at origin/main |
||
|
|
08a42c40ff |
provider: a Remote magpie's cards are passed on down a chain of magpies
yuyong_id (Discord) chains three magpies through Remote: magpie1 has a Codex subscription, magpie2 uses magpie1, magpie3 uses magpie2. magpie2 showed magpie1's Codex card; magpie3 showed none. Cause: since |
||
|
|
e0f6eda641 |
gateway: a probe's reply that thinks its 16 tokens and ends unsaid is answered (plugins#827)
Through a Remote magpie, the plain model test of Open Design's
glm-5.3-flash was red. The model always thinks. It spent the test's 16
tokens on that and ended after content_block_stop, with no message_delta
or message_stop. So:
- translate made it a 502 "ended before it was complete";
- the 502 is busy, so the remote retried it and waited out its 60s
patience;
- the asking magpie had given the remote only 20s (testWait), and said
no answer came.
Each step is now fixed for the class, not for this model:
- A reply whose request was capped at a short probe's worth
(cutVoidTokens, 1024) and that spent some of it, then ended cleanly
with nothing saying it ended, ended at its length (endsAtProbeCap).
- This holds in translate, in streamTranslated and in gathered (a
Responses plugin's stream asked whole becomes response.incomplete at
max_output_tokens).
- It covers Anthropic and Responses upstreams only. Gemini always
ends with a finishReason, so a Gemini stream without one stays a cut
(TestGeminiUpstreamEndedShort, asked for 256, caught a wider first
draft).
- A reply asked for more than 1024, or one that spent nothing, is
still the 502.
- A client may say how long it waits (provider.WaitHeader,
X-Magpie-Wait, in seconds). The gateway then takes no same-one retry
pause and no patience round that would end within clientRoom (10s) of
that wait (keptAlive.outlives), so the client gets the error while it
still waits. Like every X-Magpie- header, it is not sent upstream.
- A model test through a remote magpie waits pluginTestWait (60s), as a
plugin's test does here, and sends that wait as X-Magpie-Wait.
Not changed: a stream relayed as it came (passthrough to an agent of the
same protocol) still gets no end added. That is filed as #5736 and named
in gateway-routing.md.
Run, through mote-run:
- At the pushed tree, rebased on origin/main
|
||
|
|
44d6dd75d1 |
gateway: a subscription's capped or spent turn goes on to the user's group with it in
adorable_piglet on Discord (v0.1.3354): a Codex subscription with a usage
cap set in magpie, first in a routing group with two APIs after it. Past
the cap the Codex app's turns were answered 429 "usage cap reached" and
never reached the APIs; only switching the subscription off in Providers
moved them.
Cause: the Codex app signed in to ChatGPT asks Codex's own model
("gpt-5.5"), never "group/<id>". With a cap on the account,
codexAccounts routes the turn as codex/gpt-5.5, and serve plans the
codex provider and its own Fallback list only. A group that merely has
codex/gpt-5.5 in it was never planned, so with every account held the
answer was cappedError's 429. A request for the group itself was already
routed on past the cap (TestCappedSubscriptionGivesWayInGroup, green on
the old code too). The same gap was on Codex's own sign-in out of its
allowance at OpenAI: codexFallsBack counted the subscription's Fallback
only, so the backend's usage_limit_reached reached Codex.
Fix:
- provider.GroupsAfter(id): the routing groups the user built that have
the model in them and another member to go on to, in the user's order;
auto groups, hidden or switched-off ones are none.
- serve: when every account is held at its cap (pl.capped, no candidate
left, CapStop off), or for a turn codexFallBack handed on, the provider
is planned again with those groups after its own fallbacks
(groupsAfter), each group routed as a request to it is. One place, so
it holds on every protocol (chat, responses, messages, Codex's backend
path), streaming or not, and for plugin-served subscriptions.
- codexFallsBack counts those groups as fallbacks too.
- Stop at the caps (CapStop) still answers 429 (planPaused returns
before any fallback, the groups included).
Tests:
- TestCappedCodexOwnModelGoesToItsGroup: backend path with "gpt-5.5" and
/v1/responses with "codex/gpt-5.5", stream and not; red on origin/main
|
||
|
|
8a7f77cb71 |
provider, plugin: a sign-in whose refresh token rotates is never carried (#5583)
With Sign-ins ticked in Sync, a MiniMax Code sign-in went to both of the
reporter's computers. MiniMax spends a refresh token once: each computer
renewed it as it came due, the loser got invalid_grant 400 and was
signed out for good, with no newer generation anywhere in the sync path
to come back from. Qoder spends its refresh tokens once too.
The safest rule is that such a credential has one owner: it is never
carried. The auth hook declares `rotating` beside keepAlive and
refreshLead; the host passes it in the providers' row (Provider.Rotating),
and the carry path honours it: CollectSignIns leaves such sign-ins out of
what a backup or sync carries, and records() leaves out one an older file
carried, so MergeSignIns neither takes one in nor sends one up, and
RestoreSignIns writes none. Since the plugins don't declare it yet, and
the plugin host's list may not be read when a sync runs at start, magpie
also knows MiniMax Code (minimax-code, minimax-code-global) and Qoder
(qoder, qoder-cn) as rotating (rotatesKnown, read from their sources).
Nothing is deleted: local sign-ins stay, and a copy already on the server
falls out of the carried set by the usual removal.
The tradeoff, on purpose: each computer signs in to these itself. The
reporter's "relay" (carry one generation chain, re-read the store before
declaring a sign-in dead) would keep cross-computer sync for them; it is
a design of its own, not this fix, and stays open on the issue.
Ported from ggbdpq's patch on the issue, with rotatesKnown added so the
rule holds now and before the host lists its providers.
Run:
- TestCollectSignInsLeavesARotatingSignInOut,
TestMergeSignInsDoesNotTakeARotatingSignInIn,
TestRestoreSignInsLeavesARotatingSignInOut and
TestKnownRotatingSignInsStayWithNoPluginListed (new): all four red on
the old signins_carry.go ("a rotating sign-in is carried", "put in
here", Added:1, "minimax-code's rotating sign-in is carried"), green
after.
- go test -tags nogui ./internal/provider/ -run 'SignIns|Rotating' on mote.
- gofmt -l on the changed files: nothing.
Not tried: the two-computer race with real MiniMax Code or Qoder accounts.
Reported-by: skalitz-wolf (yetone/magpie#5583)
Reported-by: gua2100 (Discord)
Co-authored-by: ggbdpq <ggbdpq@gmail.com>
|
||
|
|
64ecd0f693 |
provider: Qoder's mover min is 0.2.64 (plugins#880, #879)
qoder 0.2.64 answers a model the account's listing has off, while its usage says no credits are left, with 429 "usage limit reached: the account's credits are used up (800 / 800 credits), …" instead of the 400 "unknown or disabled model" that a routing group on /v1/chat/completions neither failed over on nor rested the account for (yetone/magpie#5726). An id Qoder never served keeps the 400. Its Windows check-in also finds the runtime qodercli 1.21.2 caches as one file, runtime-info-win32-<arch>-<hash>.exe. Raising the min lets keepMovedCurrent update every moved Qoder and Qoder CN user. npm checked first: `npm view --prefer-online --registry https://registry.npmjs.org @magpie-community/opencode-qoder-auth version` gives 0.2.64. Plugins commit e2d15ba6. Run on mote: `go test -count=1 -timeout 45m ./internal/provider` ok (262s). `gofmt -l internal/provider` is clean. Not tried: a real out-of-credit Qoder account; Windows itself. Reported-by: zane668 (#880) Reported-by: ArmedHelicopter (#879) |
||
|
|
6b0b7a96e9 |
claude: a Max 20x account reads Claude Ultra, apart from Max 5x
Anthropic renamed Max 20x to Claude Ultra, but Claude Code still says subscriptionType "max" for both Max plans; only rateLimitTier (default_claude_max_20x / _5x) tells them apart. Every account chip read "Claude Max", so a 20x account looked like a 5x one (owner's report). claudePlan names "max" with a max_20x tier "ultra". Every place a Claude plan is written uses it (sign-in, Claude Code's own login, a saved directory taken back, the live account, `claude auth status`), and parseLogins reads an account saved as "max" before by its tier, so no one signs in again. claudeRenewedHeld compared the raw "max" with the held account's plan; it now compares the same name, or a renewed Ultra account would no longer find the held one. Run: TestClaudeMax20xIsUltra on mote at |
||
|
|
aa3d11d5b7 |
kimi: a key's booster wallet is read, and a key spending it isn't rested to the month (#5721)
apple_test_src on X (#5721): a Kimi Code key at 98.85% of its month was rested until the month renews, while Kimi still served it from its booster wallet. magpie never read the wallet. readKimiCode now reads booster_wallet (or boosterWallet). A BOOSTER wallet with an amount over 0 adds an "Extra usage" row: amountLeft, in cents x 1e6, in the currency of monthlyChargeLimit, else monthlyUsed, else USD. When something is left, the plan windows are marked Credits. The gateway's full() then doesn't count a key on its booster as full at the month's 98%. A 429 quota refusal rests it as any refusal does, not until the month renews. A wallet that is empty, of another type or missing changes nothing. Tests: TestReadKimiCodeBooster runs on the reporter's literal body (testdata/kimi-booster-5721.json, where 0 is left: no Credits) and on the same body with amountLeft injected (snake and camel case). A GIFT wallet and amount 0 add nothing. TestKimiKeyOnItsBoosterIsNotRestedToTheMonth: a key with booster left isn't full and its 429 rests it under 24h; a spent key is still rested by its window. Run on mote: gofmt -l clean; GOOS=linux and GOOS=windows go vet of internal/provider and internal/gateway; go test ./internal/provider ./internal/gateway -count=1 -timeout 45m: both ok (154.9s, 951.7s). Broken by hand: routing.go reverted turns the gateway test red ("a key on its booster counts as full at the month's 98%"); dropping the Credits marking turns the provider test red. Not tried: a real Kimi key with booster balance left (the reporter's body has 0 left). |
||
|
|
ed0ab567cb |
usage: a key's balance card carries its curve again
nf1qaz2w on Discord: Usage -> Overview showed the subscriptions' curves and no "Balance over time" for any API key. |
||
|
|
b684308c61 |
provider: an allowance or usage read a test leaves running ends with it (#3174)
TestClaudeAccountServesModelsListedSinceItsFetch went red in full internal/provider runs under load (macOS CI at |
||
|
|
c6bdc172a0 |
netguard: a fake-IP resolver's own AAAA beside its fake A is left out, not refused
jiezhengj (Discord, 11-08): under Clash Verge Rev's TUN (mihomo
1.19.33, enhanced-mode fake-ip, fake-ip-range 198.18.0.1/16) every
web_fetch of `magpie mcp search` answered "it is at a private address".
#2593 already lets a name whose every answer is in 198.18.0.0/15 through,
so that wasn't it. Clash Verge Rev writes dns.ipv6: true and
fake-ip-range6: fdfe:dcba:9876::1/64 into its default config (and fills
in 2001:2::/64 when IPv6 is on without one), and mihomo then answers
AAAA from that pool too (dns/middleware.go withFakeIP, read at
v1.19.33). The resolver's answer was 198.18.x.y beside fdfe:dcba:9876::z,
the ULA is private, a fake answer beside a private one is refused, so
every name failed.
netguard.FakePaired names that AAAA: an IPv6 address in fc00::/7 or
2001:2::/48 while the same answer holds an IPv4 one in 198.18.0.0/15.
It is dropped where Loon's paired AAAA is dropped (dropLoon in the
gateway's publicTransport, iconIPs for a provider's icon, the two
places that share netguard), and the fake A is judged and pinned in its
place. 2001:2::/48 (RFC 5180 benchmarking) joins Public's special ranges;
it wasn't covered by 2001::/32 and passed as public.
Why this opens nothing new: the AAAA is never dialled. What is dialled
is the fake A, exactly as when the resolver answered the A alone, which
#2593 already allows: an address in 198.18.0.0/15, which no host on a
normal network uses, so without a TUN it goes to the default route and
reaches the internet or nothing. A hostile DNS that pairs 198.18.0.9
with fd00::<a LAN host> gets the 198.18 address dialled, never the LAN
one. Through a proxy on this computer the proxy gets the name, as for a
pure fake answer; a hostile resolver could already give a proxy another
answer for that name than it gave magpie, so the pairing adds no route.
What stays refused (tests below): a ULA or 2001:2:: alone or beside a
real A, a fake pair beside 10.0.0.1 or ::1, a fake A beside a public
address, and ULA / 2001:2:: / 198.18 address literals.
Ran (on mote; whole packages at base
|
||
|
|
2c31815c59 |
provider: Kiro's mover needs opencode-kiro-auth 0.1.33, which asks an account in the IDE's CreateResponse experiment at /v1/responses
ThirdTimes (plugins#842, plugins#848): on one Builder ID account the
plugin's generateAssistantResponse got 429 USER_REQUEST_RATE_EXCEEDED,
and Kiro IDE 1.4.121 was answered 11s later on CreateResponse ("api=
CreateResponse armSource=experiment"). 0.1.33 (plugins 9b41df15) reads
Kiro's feature configuration as the IDE does. An account in the
create_response_api arm is asked at /v1/responses with the IDE's body and
headers, and any other account is unchanged. Raising min makes
keepMovedCurrent update every moved user's plugin.
Run: npm view --prefer-online --registry https://registry.npmjs.org
@magpie-community/opencode-kiro-auth version = 0.1.33 at landing.
mote-run go test -run 'Kiro|Mover|Moved' ./internal/provider/ ok. gofmt -l
clean. The plugin's own record is in its commit (package 168 pass, plugins
root 6892 pass 0 fail). Not tried: a real Kiro account in the arm.
|
||
|
|
0f04dca6e3 |
provider: WorkBuddy's plugin is at least 0.2.26, where deepseek-v4.1-flash replies 128000
sayagoodbyeplz on Discord: WorkBuddy's deepseek-v4.1-flash was told to agents as replying 384000 tokens (models.dev's), but WorkBuddy serves 128000. Plugin 0.2.26 (magpie-community/plugins 7e01fa81) gives each model it declares before the account's list is read its reply limit, with the China build's deepseek-v4.1-flash at 128000. keepMovedCurrent now brings every moved user's plugin up to it. npm view --prefer-online --registry https://registry.npmjs.org @magpie-community/opencode-workbuddy-auth version: 0.2.26, at landing. Run (WSL magpie-desktop, Go 1.26.8, at this tree, since mote is down): go test -tags nogui -run 'Mover|Moved|Migrat|ModelOutput|Output' ./internal/provider/: ok Not tried: a real moved WorkBuddy account updating to 0.2.26. Full suite not run at push. Reported-by: sayagoodbyeplz (Discord) |
||
|
|
b0926e81a2 |
import: a link can say where its key's balance is read (balance=, balance_path=, balance_method=)
A relay's "Add to magpie" link can now name the URL that tells a key its balance, where the amount sits in the reply, and GET or POST. magpie takes it only on the host of one of the link's own base URLs, over https, with no userinfo or fragment, so a link can't send the key anywhere its requests don't already go; anything else refuses the whole link. balance_path or balance_method without balance is an error. No header or token is taken from a link: an account-wide token is worth more than a key, and a URL stays in browser history. - provider.ParseImport: linkBalance checks and sets BalanceURL, BalancePath and BalanceMethod. - CLI: the import preview shows the balance URL and doesn't ask it before yes (showProviderAsking). - GUI: the import dialog shows method, URL and field (.imp-bal). - Docs: docs/import in en, zh and ja (table rows, a note on headers, the builder's three fields with the same host check, a security bullet); docs/reference.md's parameter table. Run on mote at this tree (rebased on |
||
|
|
1aabc66fd1 |
gateway: /v1/models answers its ETag, and 304 to a client that has the list already
clyzhicore (Discord) runs a server magpie as the gateway and a local magpie that takes its /v1/models and writes the models into dsh. They asked for an ETag or a list you can wait on, so the local side knows a change at once and a dead connection costs little. The wait is there since |
||
|
|
15918265e3 |
zcode mover: min 0.1.57, the busy hold's answer arms no quota rest
plugins#859 (zxy20250120) merged as 93dacd738: an in-flight Start Plan request answered by the busy hold's own 429 was counted as a spent gift, so a -Trial model (or free first) rested in `blocked` for a minute with quota left. 0.1.57 marks that answer and both gift paths skip it. npm view --prefer-online --registry https://registry.npmjs.org @magpie-community/opencode-zcode-auth version: 0.1.57 at landing. Run on mote: go test -run 'Mover|Moved|Migrat|ZCode|Zcode' ./internal/provider ok; gofmt -l clean. Full suite: not run at push. The plugin change itself was run in the PR review (bun test packages/zcode 236/0, red on main's index.mjs). |
||
|
|
37df73b1bb |
balance: a key holds several credits that expire, each added and removed on its own
tenacious_eagle_96548 (Discord, 11-08) has two promotional credits on one
key, one ending tomorrow and one the day after. v0.1.3305 kept one grant
per key, and its form showed the date only after Enter or a blur, with no
button to confirm.
- OwnBalance.Expiring is now a list (`expirings`, up to 20). Spending
goes to the grant that ends soonest first (ties by when it was typed),
and each grant drops out at its day. A write prunes ended grants.
- The pill and the menu say "Expires in N days" per grant, amber from 7
days. The menu has a Remove item per grant, "Add credit that
expires…" and "No credit that expires" to clear them all.
- The form shows the amount and the last day together, the day filled in
30 days ahead, with an Add button; Enter adds, Escape cancels, a bad
amount or a past day is refused in place. The app's own menu, no
native select, no stripes. A pill with two or more grants wraps at a
grant on a narrow row (a class, not :has(), for Safari before 15.4).
- CLI: `--expiring amount@day` can be given several times, `--expiring
off` clears all, `--expiring-remove [amount@]day` removes one. --help
prints usage; a day that isn't a date, or is past, is refused.
- /api/provider/keyexpiring adds `{expiring:{amount,until}}`, removes
`{expiring:{at,until},remove:true}`, clears `{expiring:null}`.
Old data: a v0.1.3305 single `expiring` grant is read as the first grant
and saved as `expirings` on the next write, for every user. An older
magpie reading the new file sees no grants (the balance itself stays).
Run on mote at
|
||
|
|
8f6298fb5e |
providers: a notification when an account in use has to be signed in again, and before a Claude sign-in ends
steven_4422 asked on Discord whether magpie warns when a Claude Code login is close to expiring or has expired. It didn't, outside the app: a sign-in that Anthropic, OpenAI, GitHub or a plugin's vendor refused showed only on the account's row (Sign-in required, Sign in again) and on the provider row's Signed out pill, and nothing warned before a Claude sign-in ended. The system notifications covered only usage, balance, reset, masking and task-done alerts. What Claude's tokens carry (read from Claude Code 2.1.316): the access token refreshes itself, but claudeAiOauth.refreshTokenExpiresAt ends the sign-in. Claude Code sets it from refresh_token_expires_in, or to 30 days from the sign-in, keeps it over a refresh that sends none, says "Your login expires in N days · run /login to renew" from 3 days before, and treats a sign-in past it as none. It skips the warning when the access token outlasts that end by more than the 3 days. - provider.WatchSignIns looks a minute after start and then every two minutes. It reads only magpie's own files and asks no vendor. It covers every account in use of every subscription that is on. - An account is told of when its row says Sign in again, by the Providers page's own test (needsSignIn mirrors renderAccounts): any mark on a Claude, Copilot or plugin account, and on another built-in (Codex revoked, a refresh that failed, ChatGPT API) a mark that signInGone matches. - A Claude account is also told of 3 days before refreshTokenExpiresAt, by Claude Code's rule (claudeSignInEnds). - Each alert goes out once: a lapse until the account is usable again, an end until it moves. The marks are kept in signin-alerts.json, so a restart doesn't repeat them, and an unreadable file tells nothing. - The GUI sends the alert as "<Name> · <user>" with "Signed out — click to sign in again" or "Sign-in ends in N days — click to sign in again", in en, zh, zh-TW, ja and de. A click opens that provider's editor (?view=providers&edit=<id>), where the account's Sign in again is. A Linux dismissal still opens nothing (#2513). Run on mote in a sandbox HOME, on this change over |
||
|
|
04ed05733e |
codex: a refresh of Codex's sign-in never writes its account back over a switch
darwish4021 on Discord (macOS, Codex app, 11-08): after
|
||
|
|
c736906b17 |
providers: part of a key's typed balance may expire on a day
tenacious_eagle_96548 (Discord, #general): some vendors split a balance
into money that stays and credit good until a date. A key's balance typed
by hand can now carry that part (`expiring`: {amount, until, at}, in the
balance's currency, until = the last day it counts).
- Spending order: the expiring part is spent first, as DeepSeek spends
its granted balance before money topped up. It takes the spend from its
`at` up to its end (midnight after `until`, local time) or now; only
what it took after `From` comes off the rest, so a refill or typing the
balance again doesn't count it twice.
- Left is the whole balance. From its end the remainder counts no more,
and unspent credit is gone.
- Typing the balance again keeps the part in the same currency and drops
it in the other, where its amount would mean another sum.
- A balance saved before has no part and reads exactly as it did
(TestTypedBalanceSavedBeforeExpiring).
- Set from the pill's menu: "Credit that expires…" asks the amount, then
the last day (a day gone by, or the other currency's sign, refused);
"No credit that expires" takes it off. GUI route provider/keyexpiring;
CLI `magpie provider key-balance <id> <key> --expiring amount@yyyy-mm-dd|off`.
- Shown: the pill "≈$100.00 left · $30.00 expires in 30 days", the Usage
page and panel line "Expires in 30 days ≈$30.00", amber from 7 days;
TUI and `magpie quota` "($30.00 until Dec 7)". New strings in zh,
zh-TW, ja and de.
Run (mote):
- go test of internal/provider, internal/gui, internal/cli (with
TestCoreScriptBudget: the days' lines in app.js are paid for by five
balance comments cut there, no raise; core 1,533,559 of 1,533,802); the new tests
again with TZ=UTC and TZ=Pacific/Kiritimati (every clock held);
gofmt -l clean; GOOS=linux and GOOS=windows go vet of those packages.
- GUI: key-balance-expiring.test.cjs 20/20 (chromium and webkit, 400px,
en/zh/zh-TW/ja/de), with every balance-*, key-*, i18n-* file: 768
pass, 6 red, each red the same alone on origin/main
|
||
|
|
5849b47ca0 |
provider: Grok's mover min is 0.2.6 (plugins#852)
opencode-grok-auth 0.2.6 (plugins ae5188363, lxyer) asks Grok again when a Responses stream is cut before its first byte. It tries up to three times, before the answer is returned, so a 429 or 401 on a retry comes back as itself. Once a byte has arrived, the stream goes on as it comes, reasoning included. A later cut just ends the stream, and magpie closes it as a whole response.failed ( |
||
|
|
7880a00ac6 |
models: a model of a key's provider can be asked on System One
axelburks on Discord: a relay serves its decision model under a name of its own (an Ark endpoint id). A key's provider with a System One URL beside a conversation URL can set a model's API to decide (System One in Model settings' API row, its chip's right-click, or `magpie model api <pid/model> decide`). The model is then a decision model there: asked on System One by its own name, offered to routing groups, kept out of the conversation models, and a turn for it is refused with 400 before the vendor is asked. Auto gives it back. A provider with no System One URL, with that URL alone, an account, a remote magpie and Vertex refuse it, saying why. Chat routing (apisAmong) ignores decide. Broken by hand: removing the decideSet check in DecidesModel turns TestModelSetToSystemOneIsADecisionModel and TestModelSetToSystemOneAskedThere red. Run, on this stack over origin/main |
||
|
|
7a6211d047 |
providers: a model's own headers, in Model settings
axelburks on Discord: a vendor routes one model by a header of its own. A key's provider (built-in or custom) can give each model headers (settings.ModelHeaders["pid/model"]). They go on that provider's requests for that model alone, after the provider's headers and after auth: a name both have is sent once, as the model's, so a user's value is never overridden by the provider's or magpie's key header. The gateway names the model (provider.WithModel) on every route that asks one: chat on each API, translated and streamed, count_tokens, System One's decision, embeddings, images, videos and the model test. A fallback provider serving the same model id gets its own headers only. Accounts and plugins carry their sign-in's headers and take none. The editor's "Name, price and reasoning level" panel is now "Model settings" (every language), with + Add header per model, staged and made with the Save; Restore default takes them away. The rows being typed are kept out of the draft's compare, so an untouched editor still closes without asking. Broken by hand: dropping WithModel from gateway.go turns TestModelHeadersReachTheirModelOnEveryRoute red; dropping the provider id check in modelOf turns TestModelHeadersStayWithTheirProvider red. Run, on this stack over origin/main |