provider: Antigravity moves onto @magpie-community/opencode-antigravity-auth
The plugin (plugins e35aa928, 0.1.0 on the dist branch) ports the
built-in's sign-in, project set-up, models and levels, request shaping,
errors and usage pools. This adds its mover, so the hourly MoveRetiring
moves every Antigravity account onto it, with no way back:
- out: each saved antigravity login becomes an oauth sign-in, refresh
"<refresh token>|<project>", access, expires and the email.
- back: splits the refresh again and writes token, expiry and project
into the built-in login, clearing Lapsed and Refused.
- antigravity_pool.go says PLUGIN-SERVED. The built-in code stays until
every account has gone over; Gemini CLI and the agy agent stay built in.
- AGENTS.md lists Antigravity in the moved table.
Run:
- Real move (WSL magpie-desktop, sandbox HOME holding only a copy of the
owner's live Antigravity login, nogui build of this tree):
`magpie plugins move antigravity` installed the plugin, wrote state
"plugin" with the backup; `serve` on 127.0.0.1:3476 listed 11
antigravity models; gemini-3-flash and claude-sonnet-4-6 answered
"pong" through the plugin; /v1/magpie/quotas read the plan
("Antigravity Starter Quota") and each model's window plus both 7-day
pools. The copied login was deleted after.
- TestAntigravityMover (out and back, lapsed and own accounts),
TestMovedBuiltinsSayTheirPlugin: pass on WSL. The test's b-account
check was red until back cleared Refused.
- go vet -tags nogui ./... and GOOS=windows go vet ./... clean;
go test -tags nogui -timeout 45m ./... on WSL (no gtk4 there) at this
head: 92 packages ok, provider/plugin/gateway's own tests included.
Three reds, none on a path this touches:
- internal/agent TestGrokInstalled: WSL binfmt interop, red alone at
0f94acc99 too (#3548).
- internal/cli timed out in TestGroupMembersFast's PATH lookup (an
os.Stat stuck ~44m, #5234, commented); passes alone here and on main.
- internal/gateway TestUnroutedSlowBodyNotCutOff 504 "held 0s" under
the full run; passes alone here (-count=3) and on main (#5953).
- After rebasing onto 4d95d81ea, at this head: vet (linux nogui and
windows) clean, internal/provider and internal/plugin ok whole,
internal/gateway -run 'TestPlugin|TestUnrouted' ok.
- TestPluginToldTheEffort red with host.js's MAGPIE_ONLY entry removed
by hand (the vendor saw X-Magpie-Effort), green restored.
Not tried: the plugin's browser sign-in end to end (import and the moved
account were); a Mac or Windows run (mote unreachable). The min is 0.1.0
from the dist branch: npm has no version yet, its first publish needs
the owner (no NPM_TOKEN in the plugins repo).
This commit is contained in:
@@ -31,6 +31,7 @@ the same job:
|
||||
|
||||
| Subscription | id | Plugin (npm) | Mover |
|
||||
| --- | --- | --- | --- |
|
||||
| Antigravity | `antigravity` | `@magpie-community/opencode-antigravity-auth` | `internal/provider/migrate_antigravity.go` |
|
||||
| Command Code | `commandcode-plan` | `@magpie-community/opencode-commandcode-auth` | `internal/provider/migrate_side.go` |
|
||||
| Cursor | `cursor` | `@magpie-community/opencode-cursor-auth` | `internal/provider/migrate_side.go` |
|
||||
| Devin | `devin` | `@magpie-community/opencode-devin-auth` | `internal/provider/migrate_side.go` |
|
||||
@@ -76,8 +77,11 @@ Two cases decide it:
|
||||
nothing; a line over the Providers list says so, with why and a Move
|
||||
(`providers.unmoved`, `unmovedLine` in app.js). With no row of its own,
|
||||
the Add sheet leaves it to the Plugins page (`unusedSub`). Every
|
||||
subscription in the table above is retired (10-17); gates ask
|
||||
`provider.PluginServes(id)` (moved or retired).
|
||||
subscription in the table above is retired (10-17) except Antigravity,
|
||||
which is moved but whose built-in code is still there until every
|
||||
account has gone over (11-10); gates ask `provider.PluginServes(id)`
|
||||
(moved or retired). Gemini CLI (`gemini`) and the agy agent stay built
|
||||
in.
|
||||
|
||||
The plugin does everything: sign-in, refresh, models, requests, usage and
|
||||
errors. It runs in the plugin host (`internal/plugin`). The built-ins'
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
package provider
|
||||
|
||||
// PLUGIN-SERVED (see AGENTS.md): Antigravity ("antigravity") is a
|
||||
// deprecated built-in subscription served by its plugin,
|
||||
// @magpie-community/opencode-antigravity-auth, once moved onto it
|
||||
// (provider.Moved). A moved one's sign-ins, models, requests and usage are
|
||||
// all the plugin's, never this code's (only the move, in migrate*.go, still
|
||||
// reads its accounts). A fix here alone doesn't reach those users; fix the
|
||||
// plugin (github.com/magpie-community/plugins, packages/antigravity) and
|
||||
// raise the mover's min in internal/provider/migrate_antigravity.go.
|
||||
// Gemini CLI ("gemini") and the agy agent stay built in.
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Antigravity's accounts on @magpie-community/opencode-antigravity-auth:
|
||||
// the plugin keeps a Google sign-in as an oauth entry whose refresh is
|
||||
// "<refresh token>|<project>", with the access token and its expiry beside
|
||||
// it and the email as its accountId. An account the built-in had no
|
||||
// project for yet goes with none, and the plugin asks Code Assist for it
|
||||
// (loadCodeAssist, onboardUser) as the built-in did.
|
||||
func init() {
|
||||
movers["antigravity"] = &mover{
|
||||
pkg: "@magpie-community/opencode-antigravity-auth",
|
||||
min: "0.1.0", // the built-in's sign-in, project, models, request shaping, errors and usage pools, ported
|
||||
agents: []string{"antigravity"},
|
||||
out: func() ([]Moving, error) {
|
||||
var out []Moving
|
||||
for _, l := range googleLogins("antigravity") {
|
||||
a := l.acct.auth
|
||||
if a.RefreshToken == "" {
|
||||
continue
|
||||
}
|
||||
out = append(out, Moving{User: l.User, First: l.Active, On: l.On, Lapsed: l.Lapsed != "", Plan: l.Plan, Auth: map[string]any{
|
||||
"type": "oauth",
|
||||
"refresh": a.RefreshToken + "|" + a.Project,
|
||||
"access": a.AccessToken,
|
||||
"expires": a.Expiry,
|
||||
"accountId": l.User,
|
||||
}})
|
||||
}
|
||||
return out, nil
|
||||
},
|
||||
back: func(ls []savedLogin, user string, auth map[string]any) ([]savedLogin, string, error) {
|
||||
rt, project, _ := strings.Cut(str(auth["refresh"]), "|")
|
||||
if rt == "" {
|
||||
return ls, "", errors.New("Antigravity: an unreadable plugin sign-in")
|
||||
}
|
||||
if user == "" {
|
||||
user = str(auth["accountId"])
|
||||
}
|
||||
if user == "" {
|
||||
return ls, "", errors.New("Antigravity: a plugin sign-in with no account")
|
||||
}
|
||||
i := backInto(&ls, "antigravity", user)
|
||||
var a googleAuth
|
||||
_ = json.Unmarshal(ls[i].Auth, &a)
|
||||
a.RefreshToken, a.AccessToken = rt, str(auth["access"])
|
||||
if e, ok := auth["expires"].(float64); ok {
|
||||
a.Expiry = int64(e)
|
||||
}
|
||||
if project != "" {
|
||||
a.Project = project
|
||||
}
|
||||
b, err := json.Marshal(a)
|
||||
if err != nil {
|
||||
return ls, "", err
|
||||
}
|
||||
ls[i].Auth, ls[i].Lapsed, ls[i].Refused, ls[i].Seen = b, "", "", time.Now().UTC().Truncate(time.Second)
|
||||
if project != "" {
|
||||
ls[i].Project = project
|
||||
}
|
||||
return ls, ls[i].User, nil
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Antigravity's accounts go to its plugin as "<refresh token>|<project>"
|
||||
// with the access token, its expiry and the email; one with no project yet
|
||||
// goes with none for the plugin to ask Code Assist. Back, a renewed sign-in
|
||||
// is written into the account it came from, its project kept when the
|
||||
// plugin's has none, and one signed in since is added.
|
||||
func TestAntigravityMover(t *testing.T) {
|
||||
claudeHome(t)
|
||||
auth := func(a googleAuth) json.RawMessage {
|
||||
b, _ := json.Marshal(a)
|
||||
return b
|
||||
}
|
||||
saveLogins(t,
|
||||
savedLogin{Agent: "antigravity", User: "a@x.com", Auth: auth(googleAuth{RefreshToken: "ra", AccessToken: "aa", Expiry: 1900000000000, Project: "proj-a"}), On: true, First: true, Plan: "Google AI Pro"},
|
||||
savedLogin{Agent: "antigravity", User: "b@x.com", Auth: auth(googleAuth{RefreshToken: "rb"}), Lapsed: "refused", Refused: revokedPrefix + "rb"},
|
||||
// Gemini CLI's accounts are no Antigravity's
|
||||
savedLogin{Agent: "gemini", User: "g@x.com", Auth: auth(googleAuth{RefreshToken: "rg"}), On: true})
|
||||
ForgetAccounts()
|
||||
|
||||
ms := movingOf(t, "antigravity")
|
||||
if len(ms) != 2 {
|
||||
t.Fatalf("moving %+v", ms)
|
||||
}
|
||||
a := ms["a@x.com"]
|
||||
if !a.First || !a.On || a.Lapsed || a.Plan != "Google AI Pro" || a.Auth["type"] != "oauth" || a.Auth["refresh"] != "ra|proj-a" ||
|
||||
a.Auth["access"] != "aa" || a.Auth["expires"] != int64(1900000000000) || a.Auth["accountId"] != "a@x.com" {
|
||||
t.Fatalf("a: %+v", a)
|
||||
}
|
||||
if b := ms["b@x.com"]; b.First || !b.Lapsed || b.Auth["refresh"] != "rb|" || b.Auth["accountId"] != "b@x.com" {
|
||||
t.Fatalf("b: %+v", b)
|
||||
}
|
||||
|
||||
// a renewed, with the project the plugin found for it
|
||||
ls, user, err := movers["antigravity"].back(readLogins(), "a@x.com", map[string]any{"type": "oauth", "refresh": "ra2|proj-a2", "access": "aa2", "expires": float64(1950000000000), "accountId": "a@x.com"})
|
||||
if err != nil || user != "a@x.com" {
|
||||
t.Fatalf("back a: %q %v", user, err)
|
||||
}
|
||||
var got googleAuth
|
||||
l := loginOf(t, ls, "antigravity", "a@x.com")
|
||||
if json.Unmarshal(l.Auth, &got) != nil || got.RefreshToken != "ra2" || got.AccessToken != "aa2" || got.Expiry != 1950000000000 || got.Project != "proj-a2" || l.Project != "proj-a2" || l.Plan != "Google AI Pro" {
|
||||
t.Fatalf("a back: %+v %s", l, l.Auth)
|
||||
}
|
||||
// b back with no project: the one it had stays, and it is lapsed no more
|
||||
ls, _, err = movers["antigravity"].back(ls, "b@x.com", map[string]any{"type": "oauth", "refresh": "rb2|", "access": "ab2", "accountId": "b@x.com"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if l := loginOf(t, ls, "antigravity", "b@x.com"); l.Lapsed != "" || l.Refused != "" || func() error { got = googleAuth{}; return json.Unmarshal(l.Auth, &got) }() != nil || got.RefreshToken != "rb2" || got.Project != "" {
|
||||
t.Fatalf("b back: %+v %s", l, l.Auth)
|
||||
}
|
||||
// one signed in through the plugin since, named by its accountId
|
||||
n := len(ls)
|
||||
ls, user, err = movers["antigravity"].back(ls, "", map[string]any{"type": "oauth", "refresh": "rc|proj-c", "access": "ac", "accountId": "c@x.com"})
|
||||
if err != nil || user != "c@x.com" || len(ls) != n+1 {
|
||||
t.Fatalf("back c: %q %v %d", user, err, len(ls))
|
||||
}
|
||||
if l := loginOf(t, ls, "antigravity", "c@x.com"); l.Project != "proj-c" {
|
||||
t.Fatalf("c back: %+v", l)
|
||||
}
|
||||
for _, bad := range []map[string]any{{"type": "oauth", "refresh": "|p", "accountId": "d@x.com"}, {"type": "oauth", "refresh": "rd"}} {
|
||||
if _, _, err := movers["antigravity"].back(ls, "", bad); err == nil {
|
||||
t.Fatalf("back took %v", bad)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user