Google bans accounts it sees on Code Assist through Antigravity's own
client. magpie offered that route twice, the built-in and
@magpie-community/opencode-antigravity-auth, and anyone who picked
Antigravity in magpie took it by default (the owner, 11-15: 全部下线,改推
agy-cli).
- retiredBuiltins has antigravity. googleLogins lists no account of a
subscription its plugin serves, so no list, usage read, quota read or
request goes to Google with a built-in Antigravity account (the usage
loop in subscription_usage.go had no gate of its own). The mover reads
googleSavedLogins, so saved accounts still move.
- The mover's min is 0.2.0 (on the plugins dist index, b8bf5a57): that
version sends nothing, answers every request 410 ModelDeprecated
("model has been retired", which modelRetired reads, so a group asks its
next member) naming Antigravity (local agy CLI) and
`magpie plugin add @magpie-community/opencode-agy-cli-auth`, and turns
sign-in away. It left the plugins registry (003a38ff).
- Gemini CLI's route, on the same code, is unchanged.
- The built-in's code stays for now (shared with Gemini CLI); taking it
out is #6723. Its 123 tests serve it again for their run through
provider.AntigravityBuiltinForTest(), a counter BuiltinRetired reads.
- README (en, zh) and site docs subscriptions (en, zh, ja) point to
Antigravity through the user's own agy CLI. AGENTS.md and
provider-plugins.md say why and that neither route comes back.
What users lose: Antigravity with Google accounts signed in to magpie, and
rotating several of them. agy-cli serves the one account the user's agy is
signed in to, and needs agy installed.
Tests: TestRetiredAntigravityAsksGoogleNothing saves an Antigravity
account and checks googleLogins/googleAccountOf give nothing, the mover
still carries it, usage has no Antigravity card and the fake Google was
asked nothing, and Gemini's account still lists. Broken by hand (the
PluginServes gate removed from googleLogins): red,
"googleLogins(antigravity) = 1 accounts".
Run (mote/mica, at this change on origin/main 5bd41301b): gofmt -l clean;
go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
./... and go build ./... ok; go test ./internal/gateway/ (1245s),
./internal/agent/ (419s), ./internal/provider/ (253s) ok on mica;
after rebasing on origin/main f362d3b9a: go test ./internal/provider/
(160s) and ./internal/plugin/ (184s) ok on mica.
Earlier at this change minus the test opt-ins: sessions, usage, library,
gui ok (mica). internal/cli's TestEveryRouteHasACommandOrIsNamed is red at
5bd41301b itself (/api/warm-all, #6724), not from this change.
Not run: the full ./... suite (mote and mica each had another session's
full or GUI suite); the GUI suite (no app.js change); a real move of a
built-in Antigravity account onto 0.2.0.
Plugins side: magpie-community/plugins 003a38ff (antigravity 0.2.0) and
f9155256 (agy-cli 0.1.56, comments only).
109 lines
5.2 KiB
Go
109 lines
5.2 KiB
Go
package gateway
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"net/http"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/tidwall/gjson"
|
|
"github.com/yetone/magpie/internal/provider"
|
|
)
|
|
|
|
// geminiDrawn is a Gemini API's answer with one image drawn.
|
|
const geminiDrawn = `{"candidates":[{"content":{"role":"model","parts":[{"inlineData":{"mimeType":"image/png","data":"aGVsbG8="}}]},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":10,"candidatesTokenCount":3}}`
|
|
|
|
// A size an images API client asks for reaches a Gemini image model on
|
|
// Google's own API as an imageSize beside the aspect ratio (#3936): a size
|
|
// asked as pixels only became a ratio, so the model drew at its default 1K
|
|
// and no size above 1K could be asked. A size the 1K default covers is the
|
|
// aspect ratio alone, as before, and a ratio asked as one is no size.
|
|
func TestImagesAPISizeReachesTheGeminiAPI(t *testing.T) {
|
|
fresh(t)
|
|
var body []byte
|
|
if err := provider.Save(provider.Provider{ID: "gg", Name: "Google", Chat: "https://generativelanguage.googleapis.com/v1beta/openai", Key: "key", Models: []string{"gemini-3-pro-image-preview", "gemini-2.5-flash-image"}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
s := New()
|
|
s.client = &http.Client{Transport: countTransport(func(r *http.Request) (*http.Response, error) {
|
|
b, err := io.ReadAll(r.Body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if !strings.HasSuffix(r.URL.Path, ":generateContent") {
|
|
return nil, fmt.Errorf("unexpected request to %s", r.URL)
|
|
}
|
|
body = b
|
|
return &http.Response{StatusCode: http.StatusOK, Header: http.Header{"Content-Type": {"application/json"}}, Body: io.NopCloser(strings.NewReader(geminiDrawn))}, nil
|
|
})}
|
|
code, a, raw := postImages(t, s, "/v1/images/generations", "application/json", `{"model":"gg/gemini-3-pro-image-preview","prompt":"a magpie","size":"4096x4096"}`)
|
|
if code != 200 || len(a.Data) != 1 {
|
|
t.Fatalf("%d %s", code, raw)
|
|
}
|
|
if sent := gjson.GetBytes(body, "generationConfig.imageConfig").Raw; !sameConfig(sent, `{"aspectRatio":"1:1","imageSize":"4K"}`) {
|
|
t.Fatalf("size 4096x4096: imageConfig was %s: %s", sent, body)
|
|
}
|
|
code, _, raw = postImages(t, s, "/v1/images/generations", "application/json", `{"model":"gg/gemini-3-pro-image-preview","prompt":"a magpie","size":"1536x1024"}`)
|
|
if code != 200 {
|
|
t.Fatalf("%d %s", code, raw)
|
|
}
|
|
if sent := gjson.GetBytes(body, "generationConfig.imageConfig").Raw; !sameConfig(sent, `{"aspectRatio":"3:2","imageSize":"2K"}`) {
|
|
t.Fatalf("size 1536x1024: imageConfig was %s: %s", sent, body)
|
|
}
|
|
// a size the model's 1K default draws at is the ratio alone, as before
|
|
code, _, raw = postImages(t, s, "/v1/images/generations", "application/json", `{"model":"gg/gemini-3-pro-image-preview","prompt":"a magpie","size":"1024x1024"}`)
|
|
if code != 200 {
|
|
t.Fatalf("%d %s", code, raw)
|
|
}
|
|
if sent := gjson.GetBytes(body, "generationConfig.imageConfig").Raw; !sameConfig(sent, `{"aspectRatio":"1:1"}`) {
|
|
t.Fatalf("size 1024x1024: imageConfig was %s: %s", sent, body)
|
|
}
|
|
// a Gemini 2.x image model draws at 1K only: the ratio alone, as before
|
|
code, _, raw = postImages(t, s, "/v1/images/generations", "application/json", `{"model":"gg/gemini-2.5-flash-image","prompt":"a magpie","size":"4096x4096"}`)
|
|
if code != 200 {
|
|
t.Fatalf("%d %s", code, raw)
|
|
}
|
|
if sent := gjson.GetBytes(body, "generationConfig.imageConfig").Raw; !sameConfig(sent, `{"aspectRatio":"1:1"}`) {
|
|
t.Fatalf("gemini-2.5-flash-image 4096x4096: imageConfig was %s: %s", sent, body)
|
|
}
|
|
// a ratio asked as one is no size
|
|
code, _, raw = postImages(t, s, "/v1/images/generations", "application/json", `{"model":"gg/gemini-3-pro-image-preview","prompt":"a magpie","size":"16:9"}`)
|
|
if code != 200 {
|
|
t.Fatalf("%d %s", code, raw)
|
|
}
|
|
if sent := gjson.GetBytes(body, "generationConfig.imageConfig").Raw; !sameConfig(sent, `{"aspectRatio":"16:9"}`) {
|
|
t.Fatalf("size 16:9: imageConfig was %s: %s", sent, body)
|
|
}
|
|
}
|
|
|
|
// The same reaches a Google sign-in's image model (#3936): the images API's
|
|
// size becomes the imageConfig a Gemini client's own arrives in
|
|
// (TestGeminiImageConfigReachesCodeAssist), inside Code Assist's envelope
|
|
// too. None asked, none sent, as before.
|
|
func TestImagesAPISizeReachesCodeAssist(t *testing.T) {
|
|
t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route
|
|
rec := &asksKept{}
|
|
s, _ := antigravityGroupFor(t, []string{"u@example.com"}, agDrawer, func(w http.ResponseWriter, r *http.Request) {
|
|
rec.keep(r)
|
|
w.Header().Set("Content-Type", "text/event-stream")
|
|
io.WriteString(w, sse(drawnPNG))
|
|
})
|
|
code, a, raw := postImages(t, s, "/v1/images/generations", "application/json", `{"model":"antigravity/`+agDrawer+`","prompt":"a cat","size":"4096x4096"}`)
|
|
if code != 200 || len(a.Data) != 1 {
|
|
t.Fatalf("%d %s", code, raw)
|
|
}
|
|
got, _ := rec.last()
|
|
if sent := gjson.GetBytes(got.body, "request.generationConfig.imageConfig").Raw; !sameConfig(sent, `{"aspectRatio":"1:1","imageSize":"4K"}`) {
|
|
t.Fatalf("size 4096x4096: imageConfig was %s: %s", sent, got.body)
|
|
}
|
|
code, _, raw = postImages(t, s, "/v1/images/generations", "application/json", `{"model":"antigravity/`+agDrawer+`","prompt":"a cat"}`)
|
|
if code != 200 {
|
|
t.Fatalf("%d %s", code, raw)
|
|
}
|
|
got, _ = rec.last()
|
|
if sent := gjson.GetBytes(got.body, "request.generationConfig.imageConfig").Raw; sent != "" {
|
|
t.Fatalf("no size asked: imageConfig was %s", sent)
|
|
}
|
|
}
|