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.
40 lines
1.6 KiB
Go
40 lines
1.6 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.
|
|
|
|
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)
|
|
}
|