ac4af582301a4e8a29245dbba767eba31334ddf9
13
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
6fc532198f |
provider: a CLI's sign-in is asked again only when its files change (#3185)
magpie asked each agent CLI who is signed in once a minute, for as long
as it ran. cursor-agent is a Node program that asks Cursor's servers:
~0.5s of CPU and ~200 MB each time. devin auth status took ~1.9s wall.
On a laptop that is a process spawned every minute, all day.
cliIdentity now takes a mark: a cheap fingerprint of where the CLI keeps
its sign-in (Cursor: authInfo in ~/.cursor/cli-config.json; Devin: a hash
of its credentials file). While the mark reads as it did when the answer
was asked, nobody can have signed in or out, and the CLI is asked again
only after 30 minutes. A changed mark, or one that can't be read, is
asked at once as before. The mark is a file read, never the keychain, so
nothing that can block runs under the identity's lock.
Run:
- TestCLIIdentityAskedOnASignInChange: red with unchanged() forced false
("sign-in unchanged, a minute on: asked 2 times"), green with the fix.
- go test ./internal/provider -run 'CLIIdentity|Cursor|Devin': ok.
- Real use: magpie serve in a sandbox HOME holding copies of the owner's
Devin and Cursor CLI installs and sign-ins, Providers open in WebKit,
every child of serve logged every 0.3s for 5 minutes, caches warm:
origin/main
|
||
|
|
0718beb437 |
provider: FetchNew waits on no CLI for who is signed in; none feeds a list it fetches
cliIdentities() still held cursorStatus after Cursor's built-in was retired. Nothing FetchNew fetches waits on `cursor-agent about` any more: the Cursor plugin lists its own accounts (Listed), and cursorIdentity only names its carried-over account. But a page's FetchNewBehind still found the never-asked CLI unsettled and ran behind the page, so FetchingNew stayed up on a poll with nothing due, the same loop Devin's entry caused (TestFetchingNewOnceStarted and TestFetchingNewForgottenWhileListed red from the Cursor commit on). Removed: cliIdentities, awaitIdentities, asking, identitiesUnsettled and identitiesAnswered, and their branches in fetchNewGo and fetchNewHeld, which now list the accounts once. TestFetchingNewForgottenWhileListed (#2390) and the CLI half of TestFetchingNewOnceStarted (#1147, #1789) tested only that wait, and go with it. cursorStatus and devinStatus stay as cliIdentity, asked by the plugin's own-account name and the movers; left_alone_test names them itself. Run in magpie-wt-int (this commit on the retire stack): go test -tags nogui -count=1 -run 'FetchingNew|FetchNew|LeftAlone|Identit|Mover' ./internal/provider: ok go vet -tags nogui ./internal/provider; staticcheck -checks U1000 ./internal/provider: only sameAccount, unused on origin/main too The full suite at the stack's final head is recorded in the last commit's body. |
||
|
|
07a445f42b |
provider: Devin's built-in is retired; its plugin serves it
"devin" joins retiredBuiltins, as Zed (c0605abc2) and Grok (60ecd598c)
did. @magpie-community/opencode-devin-auth serves it, moved or not.
Removed:
- Sign-in: the PKCE localhost listen and callback branch in signin.go,
devinExchange/devinExchangeURL. The exchange is Codex's alone again.
- Accounts: devinAccount and devinProvider in the account list, and the
Logins, switch, on and forget cases (devinSide, devinLoginList,
switchDevinLogin, setDevinLoginOn, forgetDevinLogin, removeDevinHome,
addDevinLogin, devinAlsoOn). "devin" keeps its place in Logins("") with
a nil list.
- Usage: devin_usage.go whole (perLogin fetch, usageLogins, loginQuota).
devinUsageVersion moved to devin_images.go, which still uses it.
- asksOwnBackend's "devin".
- Gateway: attempt()'s serveDevin dispatch and the Devin translator
(serveDevin, askDevin, buildDevin, decodeDevin, the Gemini schema and
tool-description rewriting, the call-id helpers). gateway/devin.go is
now connect_pb.go and keeps only the protobuf and Connect framing that
cursor.go uses.
- Tests of the built-in alone: gateway devin_test, devin_gemini_schema,
devin_sampling and devin_tool_ids; provider devin_usage_test,
devin_cli_signed_out_test, TestDevinSignIn, TestDevinSeveralAccounts,
TestSignInInstallsMissingCLI, TestDevinSignInUnseen, the Devin case of
the required-tools test, and TestDevinSplitParallelCallsKeepTheirResults.
Kept, because the plugin, the devin agent or the move uses them:
- The mover, devinLogins, devinIdentity/devinStatus, DevinAuthAt,
devinCredentialsAt, newDevinHome, devinCommand/devinProxy.
- DevinFamilies, DevinVariant and models.go's p.ID == "devin" shaping
(the plugin's provider id is "devin" too). internal/agent/devin.go
reads the families.
- The installer's "devin" case: the plugin's sign-in installs the CLI.
- The PLUGIN-SERVED notices in devin.go, devin_accounts.go and
devin_images.go, reworded as retired.
Also fixed:
- cliIdentities no longer lists devinStatus. No look at the accounts
asks it now, so it stayed unsettled, and FetchNewBehind told every page
that lists were on their way (TestFetchingNewOnceStarted went red).
- 60ecd598c (Grok) left TestFetchingNewForgottenWhileListed red: its
hook was GrokExecutable in the account listing. It and
TestFetchNewListsAgainForAnAnswerWhileListing now hook kiroCLIDB,
which is read after Cursor's account. Retiring Kiro will need another
hook.
Tests whose meaning changed:
- TestSignInInstallFails and TestSignInCanceledWhileInstalling go
through StartPluginSignIn("devin"), the plugin's install of the CLI.
- TestDevinCLIGoesThroughItsProxy seeds both accounts in logins.json
instead of signing one in. The sign-in's proxy is covered by
TestPluginSignInGoesThroughItsProxy.
- TestLeftAloneRunsNoCLI no longer expects `devin auth status` when the
subscription is switched on.
- TestFetchingNewOnceStarted's unanswered CLI is Cursor's.
- devinRawID moved to anthropic_call_ids_test.go. A Devin call id is
checked as safeCallID("dv_", ...).
Run:
- gofmt -l internal: clean.
- go vet -tags nogui ./... on darwin, GOOS=linux and GOOS=windows: clean.
- staticcheck U1000 on provider and gateway: no Devin leftovers.
- go test -tags nogui -count=1 -run '^(every test in provider, cli and
gateway that names Devin|TestFetchNew.*|TestFetchingNew.*|
TestLeftAlone.*|.*Identit.*)$' ./internal/provider ./internal/cli
./internal/gateway: ok.
- -run 'Migrat|Move|Moved|Retir|SignIn|AsksOwnBackend|SideLogin|Logins|
Unmoved|Install|Proxy|Account' ./internal/provider: ok.
- -run 'Devin|Required|Split|CallID|Cursor|Connect|Parity|ToolImage|
Format|BillingLine' ./internal/gateway: ok.
- -run 'Devin|Plugin|Retired|Moved' ./internal/gui ./internal/agent: ok.
- Not run: the whole packages, the full suite, the GUI node suite (the
machine is loaded).
|
||
|
|
75cbc7e1e5 |
provider: a subscription switched off or removed makes no background requests, no claude auth status every minute (Riko on Discord)
Riko switched Claude off in Providers, and magpie still ran `claude auth status --json` about every minute. Off only kept the gateway from routing to it. Every page and request lists accounts, which re-asked the CLI, and the background loops went on reading allowances, renewing, switching, warming, checking in and fetching lists. The same held for each sibling with a CLI or account check: Cursor (`cursor-agent about`), Devin (`devin auth status`) and the rest. What changed: - left_alone.go: leftAlone(id), true for a provider that is Off or Hidden (account removed). - account.go claudeIdentity and cli_identity.go get (Cursor, Devin): the CLI isn't asked; what it said last (memory or cli-identity.json) is served, so the account stays listed to switch on again. - subscription_usage.go: claude, cursor and grok are checked as hidden before their account is looked up (the look-up ran the CLI). - login_usage.go loginUsageAt, keepalive.go RenewLogins, codex_switch.go NextLogin, codex_warmup.go keepWarm: leftAlone where only accountRemoved (or nothing) was checked. - models.go newDue: a provider that is off has no list fetched. - checkin.go: each check-in account knows its card's provider; the loop skips one that is left alone, a press still checks it in (minimax, trae, qoder, workbuddy, plugin check-ins set it). - docs/subsystems/providers-accounts.md says so. Not covered: KeepPluginsListed lists every plugin at once in the host. A Cursor switched off that was never asked who is signed in isn't listed until switched on. What was run: - TestLeftAloneRunsNoCLI: fake claude, cursor-agent and devin on PATH log each run; with claude and cursor off and devin removed, All, Hidden, fetchSubscriptionUsage, LoginUsage, RenewLogins, SwitchWhenSpent and FetchNew run three times over stale caches and no CLI is run; switched back on, all three are asked again. - Break check: with the source changes reverted it fails with "switched off or removed, the CLIs were run: [claude_auth_status_--json cursor-agent_about_--format_json devin_auth_status ...]"; with only the claude gate removed only claude is logged, with only cliIdentity's only cursor and devin. - go test -tags nogui -timeout 45m ./internal/provider ./internal/gateway: ok (399s, 1271s). - gofmt -l: clean. go vet (darwin), GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...: clean, under set -o pipefail. |
||
|
|
dbcf791e4e |
providers: the Providers page keeps asking while an account's list is on its way, as a fetch started behind it is counted before it returns (#1147)
* providers: the Providers page keeps asking while an account's list is on its way, as a fetch started behind it is counted before it returns FetchNewBehind and FetchNewSoon started FetchNew in a goroutine, and newRunning, which FetchingNew reads, was counted only once it ran: providersState read FetchingNew straight after, was told no fetch was on its way, and the page stopped asking with the list still to come. fetchNewGo counts a fetch before it returns, but only one with work: a poll with nothing due starts and counts nothing, or each poll found the last one's no-op still under way and the page asked for ever (#1092 at GOMAXPROCS=1). Which accounts are due is known at once unless a CLI is left to ask who is signed in (never answered, being asked or about to be asked by the next look): then the fetch is counted and lists, waits on the CLI (#1789) and fetches behind the page, which doesn't wait on a CLI (#541). FetchNewSoon lists nothing before it returns, so /api/state?last=1 still answers at once (#1519). FetchingNew also says true while fetchingNew is set, for a page whose FetchNewBehind found another still picking the accounts due (tsuixl). FetchNew keeps main's missing: an account that failed, one waiting out newFetchRetry unless another's fetch listed it meanwhile, or a CLI that didn't answer in time. The accounts are listed again when a CLI answered while they were listed. * providers: a CLI that answers while the accounts are listed has its account's list fetched in that pass, and one forgotten then sends the fetch behind the page fetchNewHeld counts the CLIs answered before it lists the accounts and lists them again if one answered by the time awaitIdentities returns, in place of listForNew; TestFetchNewListsAgainForAnAnswerWhileListing fails without it (and on main). fetchNewGo, which lists only with no CLI left to ask, sends the fetch behind the page when one was forgotten meanwhile (a sign-in finishing); TestFetchingNewForgottenWhileListed fails without it. FetchNewSoon no longer counts itself before FetchNew does: fetchingNew covers that. The CLI cases of TestFetchingNewOnceStarted wait on a 5s look and allow 1s (yetone). |
||
|
|
94aa153973 |
tui, provider, serve: a signed-in account's models are fetched at start, so Routing offers Cursor's whole list without m (#1789, reyoung)
The terminal and `magpie serve` never called provider.FetchNew, which the window calls at start: a signed-in Cursor account's list exists only at Cursor, so the TUI's Routing pickers (and a headless gateway's /v1/models) offered the fallback cursor/auto alone until the list was fetched by hand with m on the Providers page. - tui: Init fetches the new lists (fetchModelsCmd, alongside the catalog sync). A model picker open when they arrive (Routing members, the classifier, a provider's models, an agent's model field) is filled in place through its relist, keeping its filter and the model under the cursor. A list left missing (no network) is asked for again a minute later (modelsRetry). Built on reyoung's branch and test. - serve: FetchNew at start, again each minute while a list is missing. - provider: FetchNew reports whether a list is missing, and waits for a CLI asked who is signed in for the first time (awaitIdentities), then lists the accounts again. With the real Cursor account in a fresh sandbox, `cursor-agent about` answered after a look's 3s firstAsk, so FetchNew saw no Cursor account and `magpie serve` still listed 1 model with the TUI fix alone. The window's startBackend gets the same wait. - docs: providers-accounts.md says who fetches the lists and when. Run: - internal/tui TestTUIFetchesSubscriptionModels (6 views) and TestTUIAsksAgainForAMissingList, -race x3; red with the Init fetch, the relist, the cursor restore or the retry tick each removed by hand. A first `about` slowed to 12s injected: passes (the test re-asks). - internal/provider TestFetchNewWaitsForASlowSignIn: red without awaitIdentities (no provider "cursor"); TestFetchNewAccount covers the missing result. - Real Cursor account, sandbox HOME with a keychain holding only Cursor's two items: TUI on main showed cursor/auto only in Routing; the fix shows the full list and "24 models" on Providers. `magpie serve`: main 1 Cursor model at /v1/models, the fix 24 within 5s. - gofmt -l, go vet (darwin, GOOS=linux, GOOS=windows), go test ./... in a sandbox HOME. Not tried: Linux and Windows real Cursor CLIs (the fake CLI tests skip on Windows); Devin's CLI identity goes through the same wait but wasn't tried with a real account. |
||
|
|
8c5b9f928d |
provider, agent, gui: subscription accounts can be turned off, and then no agent's sign-in is read (#1535, MaxHaiCom)
What changed: Settings → Privacy → Subscription accounts (On/Off), `magpie accounts discovery [on|off]` and MAGPIE_NO_ACCOUNTS=1 turn off account discovery. It stays on by default. While it is off, magpie reads none of the agents' sign-ins: ~/.claude/.credentials.json, .claude.json's account, ~/.codex/auth.json, Copilot's, Cursor's, Devin's, Kiro's, Gemini's, ZCode's, Command Code's and OpenCode's files. It runs no `security` / `secret-tool` for the Keychain or Secret Service, and asks no agent CLI who is signed in. It serves no subscription. API-key providers, middleware plugins and Pi extensions work as before. Why: the reporter runs magpie on machines where reading other tools' credentials isn't wanted. The owner delegated the call. How: settings.NoAccountDiscovery (kept per computer by KeepOwn) and settings.AccountDiscoveryOff(). The variable only ever turns discovery off. The gates sit at every reader (readAccountFile, discoveryOff) and at every route that reads or writes a sign-in, so a route that skips Accounts still reads nothing: - Accounts, All, Logins, usage, renewal, warm-up, session identities, check-ins; - switching, forgetting, SetLoginOn, StartSignIn, the imports; - moves onto plugins. The ones that write refuse with an error that names how to turn it back on. On the agent side, Agent.Source and OpenCode's auth.json are gated, and Codex wiring goes by magpie's stash instead of auth.json, so a toggle never rewires Codex. logins.json and plugin-auth.json are left untouched and serve again when discovery is turned back on. A change applies at once (ForgetAccounts). Docs: providers-accounts.md, README (en, zh-CN), and the site's CLI table (en, zh, ja). Run: - TestAccountDiscoveryOffReadsNoSignIn (provider) and TestAccountDiscoveryOffAgentsReadNoSignIn (agent). Every credential path is a FIFO that records each open, and security, secret-tool, claude, codex, cursor-agent, devin, kiro-cli, copilot and grok are fakes on PATH. Both fail with the gate removed: they show the opens and `security find-generic-password -s Claude Code-credentials`, among others. Both pass with the gate in place. - TestAccountDiscoverySetting and TestAccountsDiscoveryCmd. - account-discovery.test.cjs: chromium and webkit, 900 and 360 wide, en/zh/zh-TW/ja/de, 32/32. The neighbouring privacy, redact, settings-sections and i18n-keys GUI tests: 49/49. - The full `go test -tags nogui ./...`, gofmt -l, and go vet for darwin, linux and windows on the touched packages. Not tried: a real machine under fs_usage, and Linux and Windows at runtime. The FIFO tests are !windows. |
||
|
|
9c37723110 |
provider: a test binary keeps no CLI identity on disk, so a late ask can't write into the next test's folder (#1538, sibling of #1524)
TestDshHomePickSurvivesSyncAndEffort failed under full-suite load and
passed alone. The cause is cliIdentity: a look starts an ask of the CLI
(a failing testenv stand-in) and, once the answer is a minute old, a
refresh in a goroutine. keep() writes cli-identity.json under the
XDG_CONFIG_HOME current when it finishes, so an ask slow under load,
still going when its test ended, wrote into the config folder of the
test running then while t.TempDir's cleanup was removing it:
"TempDir RemoveAll cleanup: ... directory not empty".
|
||
|
|
4ee3a76b7f |
gateway: a test's config folder isn't written into by a CLI identity asked behind its request (#1524)
TestEncodedBodyInflatedPastLimit failed under load at its TempDir cleanup
("unlinkat .../001/magpie: directory not empty"). The server wasn't the
writer: New() starts no goroutine, and httptest's Close waits for the
handlers. The writer is provider's cliIdentity. Reading the accounts
reads Cursor's and Devin's identity. In the gateway's tests, testenv's
stand-in cursor-agent and devin are on PATH, so their CLIs count as
installed. After the first answer, a look older than a minute asks the
CLI again in a goroutine and doesn't wait for it. When the stand-in
answers signed out, keep() writes cli-identity.json (MkdirAll, then a
temp file renamed in) under the XDG_CONFIG_HOME of whatever test is
running then. Under load the stand-in takes seconds, so the write lands
as that test's TempDir is removed.
Found by injecting a delay, not by rerunning. With get() refreshing at
every look and a 15ms sleep after the ask, a -count=3 run of
TestEncodedBodyInflatedPastLimit failed 3 subtests with the exact error
from the issue (/v1/responses/zstd, /v1/chat/completions/zstd,
/v1/videos/gzip). With this change and the same injection,
-count=5 of TestEncodedBody*, TestUnknownBodyEncodingRefused and
TestKeyLimitReservesDecodedBody passed.
provider.KeepCLIIdentities (default true) now decides whether the
answers are kept on disk. The gateway's TestMain turns it off, as it
already turns off keepRoutes for the same reason. Production doesn't
change. TestNoCLIIdentityKeptInTests goes red if TestMain leaves it on.
TestCLIIdentityNotKeptWhenOff checks that an answer is still served and
nothing is written.
The same pattern: every gateway test that calls New() and never stops it
was a suspect. Server has no Stop and New() starts nothing, so the pattern
itself is harmless; the background write was the cause wherever a
request looks at the accounts. provider's own tests still keep
identities on, since several of them test the file; they haven't failed
this way.
Run: go test -tags nogui -count=1 -timeout 40m ./internal/gateway
./internal/provider (ok); gofmt -l; GOOS=linux and GOOS=windows go vet
-tags nogui ./internal/gateway ./internal/provider.
|
||
|
|
1f14004676 |
provider: a CLI that fails to say who is signed in, or takes 5s or more, is asked again after 1, 2, 4… minutes up to 30, not every minute: a cursor-agent that calls itself no longer runs for 10s every minute (#1278, JJ-Lin)
Cursor's and Devin's sign-in is read from their CLIs (cliIdentity), asked again behind what is served once the last answer is a minute old. A cursor-agent that calls itself (an old ~/.local/bin wrapper running `cursor agent`) never answers: each ask ran its 10s timeout and started hundreds of processes, every minute magpie's pages or gateway read the accounts. With no Cursor token kept, it still counted as an answer (nobody signed in), so a "failed asks back off" rule alone would not have reached JJ-Lin's case: an ask that takes slowAsk (5s) or longer backs off too. A quick answer, or a sign-in or out (forget), has the CLI asked every minute again. What is served is unchanged: a failed ask keeps it, a slow answer is taken as before. Verified: - red without the change: TestCLIIdentityFailingAskedLessOften/fails and /slow both fail with "asked again a minute after the second"; pass with it (-race -count=3 with the other TestCLIIdentity tests). - go test -tags nogui ./internal/provider/ in a sandbox HOME; go vet -tags nogui of provider for darwin, linux and windows. |
||
|
|
2de043dabf |
provider: Cursor stays listed when cursor-agent can't say who is signed in (cataglyphis: 供应商选型中间歇无法显示 cursor,导致路由里不能正常路由到 cursor 的模型) — who Cursor's account is comes from cursor-agent about --format json, asked again behind the served answer every minute, and any about that failed, ran past its 10s (it asks Cursor's servers), or printed something besides its JSON was taken for nobody signed in: Cursor dropped out of the Providers page and of routing (All() lists the accounts for both), and that was kept on disk, until an ask a minute or more on came back. Now an ask that couldn't tell leaves what was served, on disk too, and is asked again in a minute (cliIdentity's ask returns an error for that); Cursor is taken as signed out only when about says so in its JSON or cursor-agent keeps no token. About's JSON after a line of its own (an update notice) is read too. Devin's ask is as before. Tested with fake cursor-agent scripts in a temp HOME (signed in, update notice, says nobody, fails, no JSON, fails with the token gone) and the cache through a failed ask and a sure sign-out; not tested against a real cursor-agent, and what made reporter's about fail isn't known
|
||
|
|
8ad73e8bfc | accounts: a slow or hanging agent CLI no longer holds the providers page (#123) — its timeout now ends the call (a CLI that is a script running node left node holding the output, and the call waited for it however long, the 10s timeouts notwithstanding: a CLI's pipes are closed 2s after); a CLI never answered before is waited for 3s, once, then served as nobody signed in until its answer comes behind; and a CLI saying nobody is signed in is kept like any answer, where before it wasn't and every start waited for it again. Tried with cursor-agent and devin hanging 20s and the network black-holed: the first providers call went from 40.6s to 6s on a first start, and to 13ms on the next | ||
|
|
0686bdffa7 | accounts: a magpie just started no longer holds every page and request for cursor-agent and devin — who their CLIs say is signed in is kept on disk (cli-identity.json), served at once on the next start and asked again behind it; only a first look ever, or one after a sign-in or out, waits for the CLI. The window's first read went from ~4s to ~0.15s here with both signed in, and the gateway page shows its skeleton, not blank cards, while the state loads (#123) |