Files
magpie/internal/provider/zed.go
T
yetone 21252f6a2c provider: Zed's built-in is retired; its plugin serves it
The first built-in taken out (the owner, 10-16: 陆续把内置Provider下线掉,
一定要下线完毕). @magpie-community/opencode-zed-auth serves Zed for
everyone now; built-in accounts not moved yet are moved by the hourly
loop, or from the Providers list's line (the commit before).

Removed: the built-in's sign-in (zed_signin.go and its loopback paste
branch), usage (zed_usage.go), its login list, switch, forget and
account cases, its own-backend case in asksOwnBackend, the gateway's
serveZed and zed.go, internal/zed, and the tests of only those.

Kept, because the mover and the plugin path use them: zed.go's
credential and login readers (migrate_zed.go's move), zed_body.go
(plugins.go), and Zed in accountIDs, side_logins, cards_kept,
plugin_usage's movedCards, the gateway's estimatedMoved and the CLI's
account names, which name the plugin's accounts too. Zed the editor as
an agent (internal/agent, the library's MCP target) is untouched.

Tests changed: TestMovedBuiltinQuiet is TestRetiredBuiltinQuiet (no Zed
card, its sign-in refused, the move still offered with the account);
TestZedMoveCarriesItsModels compares the models without internal/zed;
TestLoopbackSignInsTakePastedAddress and asksOwnBackend's set lose Zed.
AGENTS.md and gateway-routing.md no longer name Zed's built-in client.

Run on this tree over af08ecb27's parent tree:
- go test -tags nogui ./... -count=1 -timeout 90m: 64 packages ok,
  internal/gui red only in TestCoreScriptBudget (the Move line; the
  budget is raised in af08ecb27). Rebased onto it:
  go test -tags nogui ./internal/gui -count=1: ok.
- Earlier on wt6 before the three fixes: provider red in
  TestAsksOwnBackendAgreesWithTheGatewayDispatch and
  TestLoopbackSignInsTakePastedAddress (Zed still named), fixed here.
- gofmt -l internal: nothing; GOOS=linux and GOOS=windows
  go vet -tags nogui ./...: clean.
- GUI: retired-move, plugin-move, deprecation-notice and
  deprecated-subscriptions, both engines, en and zh: 20 pass.
2026-10-17 23:10:59 +08:00

56 lines
1.8 KiB
Go

package provider
// PLUGIN-SERVED (see AGENTS.md): Zed ("zed") is a retired built-in
// subscription, served by its plugin alone,
// @magpie-community/opencode-zed-auth (provider.BuiltinRetired). Its sign-in,
// models, requests and usage are the plugin's; all that is left here is
// reading the accounts signed in to the built-in, for the move onto the
// plugin (migrate_zed.go). A fix belongs in the plugin
// (github.com/magpie-community/plugins, packages/zed), with the mover's min
// raised in internal/provider/migrate_zed.go.
import "encoding/json"
// zedCreds is what a Zed sign-in left: the account's id and access token
// (which last until Zed refuses them), the machine id they were issued with,
// the organization its models are asked under, and the model list last read.
type zedCreds struct {
UserID string `json:"userId"`
Access string `json:"accessToken"`
SystemID string `json:"systemId"`
Org string `json:"organizationId,omitempty"`
Login string `json:"login,omitempty"`
Name string `json:"name,omitempty"`
Plan string `json:"plan,omitempty"` // plan_v3, e.g. zed_pro
Models json.RawMessage `json:"models,omitempty"`
}
func zedSaved(l savedLogin) (zedCreds, bool) {
var c zedCreds
if json.Unmarshal(l.Auth, &c) != nil || c.UserID == "" || c.Access == "" {
return zedCreds{}, false
}
return c, true
}
type zedLogin struct {
Login
creds zedCreds
}
// zedLogins is every Zed account signed in to the built-in, the one in use
// first.
func zedLogins() []zedLogin {
var out []zedLogin
for _, l := range sideLogins("zed", "", func(l savedLogin) bool {
_, ok := zedSaved(l)
return ok
}) {
c, _ := zedSaved(l.saved)
a := zedLogin{Login: l.Login, creds: c}
a.Lapsed = l.saved.Lapsed
out = append(out, a)
}
return out
}