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).
71 lines
2.2 KiB
Go
71 lines
2.2 KiB
Go
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
|
|
},
|
|
}
|
|
}
|