ac4af582301a4e8a29245dbba767eba31334ddf9
15
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
276c806db2 |
plugins: a plugin's own requests are counted; a provider plugin's options get the editor (plugins#592)
zelong77 asked for two things once Devin 0.1.30's cache keep-alive
worked: its pings were invisible in magpie, and the interval and ping
count could only be edited in plugins.json. The owner decided pings are
shown as counted usage and the two numbers are edited in the GUI.
- host.js gives plugins input.magpie.usage(provider, call) and
input.magpie.account(provider). usage validates the call (kind
[a-z0-9_-]{1,40}, a model id, whole-number tokens from 0, status at
most 999, error clipped to 500) and sends an unasked "usage" event;
host.go hands it to plugin.OnUsage in the background.
- internal/usage/plugin_calls.go writes each one as a row of agent
magpie on the plugin's provider (provider.PluginID) and account
(provider.PluginAccountUser), with its kind. It is counted, priced
and in every total, not a probe. Kind cache_keepalive is in the
purpose catalog as "Cache keep-alive" (five languages), so the
request log names and filters it. The ping itself still goes straight
to Devin, never through the gateway, which would break the cache.
- /api/plugins reads every plugin's package options example, not only a
middleware's or request hook's, and the Installed row offers the same
Options JSON editor for a provider or agent plugin that suggests or
has options (not while it is off). Clear's confirm no longer calls
them a middleware's options.
- The Devin mover's min is 0.1.31, which reports each ping and gives
its two settings' defaults (285 s, 6) to the editor. npm has 0.1.31
(published 10:03Z); the plugins publish run is red only for
think-tags' known E404 (plugins#180).
- docs: provider-plugins.md (the API, the options editor),
gateway-sessions.md (the counted row beside probes).
Run at this tree (rebased on origin/main
|
||
|
|
3ee6c2d948 |
providers: a provider list looks at the stamps, plugin logins, client shapes and accounts once a request
/api/providers took ~25ms of CPU a call with the owner's real config (25 providers, plugins signed in), polled by every open window. Its profile had file system calls at about half, each repeated for every provider the list shows: - StampNow stat'ed providers.json, settings.json and the catalog for every provider (KeptListing); under a request's Hold it is looked at once. - plugin.ListedAt was asked for every plugin provider's Listed(); once a request (heldOf "plugin-listed"). - pluginLogins took logins.json's lock, a file opened across magpies, for every plugin even with nothing to change. It now settles the list as read first, and takes the lock and settles again from a fresh read only when something changes. - clientShape read and parsed client-shapes.json for every relay a list shows (TestsAs); parsed once until the file changes (filememo), a copy given out. - Logins(agent) took the same lock for every provider, twice with its account models; listed once an agent a request, a copy each, listed anew after a write (writePrivate's filememo.Forget). Run (on mote unless named): - go test ./internal/provider ./internal/gui -timeout 45m: provider ok (102s) with the new tests; gui red on TestMainWindowCorners (macOS 27, #3949) and on TestSettingsSaveKeepsWhatItDoesNotSend, red on main since |
||
|
|
88372a39d8 |
provider: listing accounts with nothing to change copies none of them
sideLogins and pluginLogins read the saved logins as a copy of the whole list each time, to change it if a sign-in was new. The Providers page and the panel list an agent's or a plugin's accounts a dozen times a poll, and almost always nothing changes: 61 MB of what twenty window polls allocated with real accounts. They now look at the logins as kept (sharedLogins, read only), and a list that has a change makes its own copy (readLogins) before it changes and writes it. TestAccountListsCopyNoLoginsUnchanged: twenty lists of a side sign-in and a plugin's accounts with nothing new copy the logins 0 times; a new plugin account is still written and listed. Run on mote (macOS 27): - gofmt, go vet ./internal/provider (darwin, windows, linux): ok - broken by hand (side_logins back on readLogins): red, "20 lists with nothing to change copied the accounts 40 times" - the new test alone, -count=3: ok - go test ./internal/provider ./internal/gateway: ok Not run: the whole suite; internal/provider and the gateway that reads its accounts are what this reaches. |
||
|
|
d95822eb35 |
provider: a keyless public plugin stays listed with subscription accounts off, and its name isn't blurred (lileo0668)
lileo0668 on Discord (#help): OpenCode Zen Free (plugin 0.1.18, the public credential) said 已登录 on the Plugins page, the Add sheet had one blurred row for it, a red line said "<name> 已登录,但 magpie 无法列出它", and Zen's free models were nowhere. Cause, reproduced on a sandbox magpie (HOME and XDG dirs under a scratch folder, :3561, `magpie web` on :3562) built from origin/main |
||
|
|
2921471de1 |
provider: Devin's mover min is 0.1.24 and its "cli" mark is the string OpenCode keeps
The Devin plugin 0.1.24 (plugins #396) stores the CLI sign-in's metadata.cli as "true", the string OpenCode 1 keeps, because OpenCode dropped a boolean there and with it the account. The mover now writes "true", and the back checks (Devin, Command Code) and pluginOwn accept both true and "true" through cliMarked, so accounts moved before keep working. Run at this head: - go test ./internal/provider -count=1 (skipping TestUnreadLoginsWriteErrorsKeepCredentials, #3632's crash): ok 101.9s - GOOS=linux and GOOS=windows go vet ./internal/provider: ok; gofmt -l clean - npm view @magpie-community/opencode-devin-auth version --prefer-online: 0.1.24 Broken by hand: the Devin back check put back to md["cli"] == true makes TestMoveDevin fail; restored. Not tried: a real Devin account move through OpenCode 1. |
||
|
|
344d11484e |
provider: Remove takes the account listed, by its slot, not a hidden one of the same name
dev (Discord) couldn't remove a ZCode account. The ZCode app's own
account had been removed in magpie (hidden), and a second one signed in
through magpie had the same name. Two things in the source caused it:
- editSideLogin matched the first saved entry by agent and name, hidden
ones included, so Forget took the hidden "zcode" slot. It signed out
the ZCode app's own account and left the listed zcode#l47q19 one.
- pluginLogins applied the own account's name (pluginOwnUser) after
pluginLabels had added the slot suffix to tell same-name accounts
apart, so both read "dev@z".
Now:
- pluginLabels applies the own names first and adds the suffix after,
so the listed names are unique ("dev@z (l47q19)").
- Forget, Switch and On/Off resolve the name against the accounts as
listed, then edit that saved entry by its slot (Home) or own-ness
(listedMatch/sameSaved). editSideLogin, which the other callers use
(chatgpt_api, copilot_lapsed, google, signin_revoked), prefers a shown
entry over a hidden one of the same name.
- A saved id doesn't help here: it is made from the name, so both
accounts had the same id (66dbee89c5d33fcd).
Existing data: an account whose name collided with another one is shown
with its slot suffix from the next read on. Nothing is rewritten.
Run:
- go test -tags nogui -timeout 45m ./... in a sandbox HOME: ok, every
package, at
|
||
|
|
c3b2e6109b |
provider: signing in to a plugin again takes the lapsed mark off when the providers' list is empty too (#2748)
clearPluginLapse cleared an account's "sign in again" mark only through
plugin.Cached(): it looked for the plugin's provider in the list and
cleared nothing when it wasn't there. The list is empty while
checkList reads another magpie's change to plugins.json again
(provCache = nil, before the providers file is written), so a sign-in
finished then left the account lapsed until a request or usage read
went through. TestPluginLoginTakesTheLapseOff (internal/cli) went red
that way on ubuntu CI twice (runs 39216129687 and 39234604936: "signed
in again, but still lapsed").
The mark now goes by the account's agent and key alone
(notePluginLapseOf), with the same sign-in count ordering as before;
only the stale usage reading still needs the provider, and is still
dropped when it is listed.
TestPluginSignInClearsLapseWithoutTheList saves two lapsed plugin
accounts with no plugin listed, signs one in again, and checks its mark
went and the other's stayed. On the old plugin_accounts.go it fails:
plugin_fetch_lapse_test.go:83: signed in again, but still lapsed:
"gone@fake's FakeCo sign-in has expired — sign in again"
and passes with the change.
Whether CI's two reds were this empty list and not another path is
inferred from the code, not captured; #2748 stays open until CI has
gone a while without it.
Run on origin/main
|
||
|
|
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. |
||
|
|
8c0ffcc640 |
provider: a plugin account signed in again is read afresh, not answered by the reading kept from the refused sign-in (TestPluginLoginTakesTheLapseOff red after its first run in a process)
clearPluginLapse took the lapsed mark off a plugin account signed in
again, but its usage reading from before stayed in loginUsageCache for a
minute. The next LoginUsage was answered from it: the old sign-in's
"expired" shown for the renewed account, and no plugin asked, so nothing
marked or cleared. TestPluginLoginTakesTheLapseOff hit it from its second
run in one process (-count=3: pass, fail, fail): the run before's last
reading, still under a minute old, answered the "gone" account's read
under the new HOME, and the vendor's refusal never marked it.
A sign-in now drops the account's kept reading (StaleAllowance), on both
paths that finish one (pluginDone and PluginSignedIn).
TestPluginLoginReadsUsageAfresh fails without the change at -count=1
("signed in again, but the usage is the old sign-in's: ... Error:the
FakeCo sign-in has expired"). With it, -run TestPluginLogin passes at
-count=5 and with -race -count=5; go test -tags nogui . ./internal/provider
./internal/plugin pass under a temp HOME with pinned caches; go vet and
GOOS=linux/windows go vet -tags nogui pass on the two packages.
|
||
|
|
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. |
||
|
|
47786c456e | plugins: a moved built-in's own account stays the agent's, and Qoder's first goes (插件版…保持一模一样) — the plugin's accounts were listed with no own one, so removing the agent CLI's own account (Devin, Grok, Command Code, Cursor, Kiro, ZCode, WorkBuddy) signed it out of the plugin and its name stayed as signed in at the move; it is now told by the mark each mover leaves on it, named as the CLI is signed in now, only hidden when removed (the CLI stays signed in) and shown again once the CLI or magpie signs in anew, as the built-in's was. Qoder's first account showed Remove and was refused; it now goes, the next put first, as the built-in let it. plugin.UseCached lets a test stand a plugin's provider up without Bun. TestMovedOwnAccount and TestMovedQoderFirstGoes fail without the change. | ||
|
|
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. | ||
|
|
ee5b1b7d44 | plugins: a plugin's account behaves as its built-in's (the user: 插件版的订阅 provider 和内置的…保持一模一样了吗) — a plugin's failed sign-in now says why ("the sign-in failed: the sign-in page expired") instead of a bare failure; a plugin account the provider refuses with 401 is marked lapsed, "<user>'s <provider> sign-in has expired — sign in again", beside the account and on its usage card as a built-in's is, and the mark goes when it answers again or is signed in anew; a Devin or Command Code account taken from the agent's CLI moves to the plugin marked as the CLI's and back as the agent's own, so the one it follows stays the one the CLI is signed in to. TestPluginProvider (lapsed), TestMoveSideState (cli) and TestPluginSignIn (reason) fail without the change. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... 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.
|
||
|
|
b63a0f1fd5 | plugins: a plugin's provider takes more than one account, as a built-in subscription does (the user: 插件当然要支持多账号了) — a plugin kept one sign-in per provider, and signing in again replaced it. Now each sign-in goes beside the others: plugin-auth.json keeps the first under the provider's id, as OpenCode does (so what is signed in already stays the first account), the rest under id#slot; logins.json lists them as it lists the built-ins' accounts, so the editor shows them all, one first, the others ticked on behind it or off, any made first, any removed (which signs it out). The host runs every request in its account's scope, so a plugin's getAuth, client.auth.set (a refreshed token), loader and provider.models see that account alone; a sign-in to an account already there (the same id, else the same secret) replaces that one's rather than listing it twice. The gateway spreads and fails over across the accounts on, as for the built-ins. Accounts with no id are told apart by the end of their key ("API key …abcd"), else by their slot. Also on the Devin page: the header shows the plugin's icon, and Cognition's opencode-devin is off the market (its gateway answers 404 model_not_found for models and chat). TestPluginAccounts (plugin: per-account requests and refreshes, dedupe, sign-out; provider: first, on/off, switch, forget, labels), TestPluginProvider (gateway: a 429 on the first account goes on the second) and plugin-signin.test.cjs (add a second account in the editor, make it first; fails without the change) are new. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass; plugin-signin, plugin-market, old-webkit, click-scroll pass. |