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/main8701eb35ewith the real plugin from npm: with Settings -> Privacy -> Subscription accounts off (#1535, or MAGPIE_NO_ACCOUNTS), pluginLogins and All() drop every plugin provider, but PluginAPIKey, the keyless/key route, was not gated. The sign-in went through, plugin-auth.json held it, the Plugins page said signed in, and /api/providers listed nothing, so the GUI showed "signed in, but magpie can't list it". With accounts on it signs in and lists fine. v0.1.1847 (the reporter's) has the same code. The blur: /api/plugin-signin answered user = the plugin's name, Hide accounts takes every answer's user for an account, and spares only listed providers' names, so "OpenCode Zen Free" was blurred on the card, the sheet row and the red line. Fix: - publicPlugin: a plugin whose every way in is keyless holds no account of the user's. With accounts off it is still listed (pluginLogins, All, Accounts), served (Sign) and signed in (PluginAPIKey). - Any other plugin's key is refused with errAccountDiscoveryOff before anything is saved, as its browser sign-in already was. - /api/plugin-signin's key answer no longer names the plugin as a user; the GUI names it from subOf. Hide accounts spares every plugin's id and name from providers.plugins. - providers-accounts.md and discovery.go say so. Run at the rebased head (792f0f286, thenfd80ed99c): - internal/provider TestPublicPluginListedWithAccountsOff, TestAccountDiscoveryOffReadsNoSignIn, TestAccountDiscoverySetting, TestPluginKeylessSingleIdentity, TestPluginEmptyKeyOnlyKeyless: ok. - wsl-run go test -tags nogui ./... -timeout 45m: every package ok but internal/agent: TestGrokInstalled (#3548) and TestOmpDetectedWithPiDir (#4033), the Linux box's known reds; internal/agent isn't touched here. - go vet nogui ./internal/provider ./internal/gui for linux and windows, darwin for provider; gofmt clean. - GUI (wsl-run, chromium + webkit, en zh zh-TW ja de, 900 and 360 wide): plugin-name-unmasked (new), plugin-keyless-signin, account-eye-provider, account-eye, account-mask, privacy-hides-accounts, plugin-moved-signin, plugin-other-ways, plugin-signin-no-url, plugin-key-hint, i18n*: 106 of 106 (on792f0f286); plugin-name-unmasked and plugin-keyless-signin 20 of 20 there too. - Rebased again ontofd80ed99c(mover mins, Picked only, Kimi, usage): the provider tests above ok there. - A first GUI batch on mote timed out on browser launch at load ~90 from other sessions' runners; not a code red, rerun on WSL. Broken by hand: - the four provider files back to origin/main: the new test fails "Zen Free not listed with accounts off: map[]". - Sign's exemption alone: "Zen Free not served with accounts off". - All's exemption alone: "not listed ... map[]". - PluginAPIKey's gate off: Acme's key is not refused (it goes on to the plugin host). - app.js's plugin-name exemption off: plugin-name-unmasked red 5 of 5 (chromium). Not tried: the reporter's own computer; that their Subscription accounts switch is off is inferred, the one route that reproduces it. A real request through the gateway with the fixed build and accounts off wasn't sent; the provider test signs Zen's request. The plugin itself is unchanged (0.1.18 on npm).
42 lines
1.8 KiB
Go
42 lines
1.8 KiB
Go
// Account discovery off (#1535, MaxHaiCom): with Settings → Privacy's
|
|
// "Subscription accounts" off, `magpie accounts discovery off`, or
|
|
// MAGPIE_NO_ACCOUNTS=1, magpie reads no agent's sign-in — no
|
|
// ~/.claude/.credentials.json, ~/.codex/auth.json, Copilot, Cursor, Kiro,
|
|
// Devin or other credential file, no Keychain or Secret Service item, and
|
|
// no agent CLI asked who is signed in — and serves no subscription. API-key
|
|
// providers work as before.
|
|
//
|
|
// The gates sit at every source (the readers below Accounts, Logins,
|
|
// usage, renewal, warm-up, session identities) and every sink that would
|
|
// write a sign-in (switching, forgetting, sign-in, imports, moves onto
|
|
// plugins), so a route that skips Accounts still reads nothing. What magpie
|
|
// kept of its own (logins.json, plugin-auth.json) is left as it is, unread
|
|
// and unwritten, and comes back when discovery is turned on again.
|
|
// Middleware plugins and Pi extensions in the plugin host are not
|
|
// subscriptions and run as before, and neither is a public plugin, one
|
|
// whose every way in is keyless (publicPlugin): it holds no account of
|
|
// the user's, so it is listed, signed in and served (lileo0668).
|
|
|
|
package provider
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
|
|
"github.com/yetone/magpie/internal/settings"
|
|
)
|
|
|
|
var errAccountDiscoveryOff = errors.New("subscription accounts are off in magpie (Settings → Privacy, or `magpie accounts discovery on`)")
|
|
|
|
// discoveryOff is whether agents' sign-ins are left unread; see above.
|
|
func discoveryOff() bool { return settings.AccountDiscoveryOff() }
|
|
|
|
// readAccountFile is os.ReadFile for an agent's credential file, refused
|
|
// while discovery is off.
|
|
func readAccountFile(path string) ([]byte, error) {
|
|
if discoveryOff() {
|
|
return nil, errAccountDiscoveryOff
|
|
}
|
|
return os.ReadFile(path)
|
|
}
|