diff --git a/AGENTS.md b/AGENTS.md index 6cd92ce63..0de862c25 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -77,11 +77,21 @@ 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) 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. + subscription in the table above is retired (10-17; Antigravity 11-15); + gates ask `provider.PluginServes(id)` (moved or retired). Gemini CLI + (`gemini`) and the agy agent stay built in. +- **Antigravity is off entirely** (the owner, 11-15): Google bans + accounts it sees on Code Assist through Antigravity's own client, the + built-in's way and the plugin's alike. The built-in's code is still in + the tree, but `googleLogins` lists nothing once the plugin serves it, so + it asks Google for nothing; the mover reads `googleSavedLogins`. The + plugin's 0.2.0 (the mover's min) sends nothing either: every request + gets a 410 "retired" naming Antigravity (local agy CLI), + `@magpie-community/opencode-agy-cli-auth`, which runs the user's own + agy over ACP, and it left the registry. Don't bring either route back. + The route's tests serve it again through + `provider.AntigravityBuiltinForTest()` until its code is taken out + (#6723). The plugin does everything: sign-in, refresh, models, requests, usage and errors. It runs in the plugin host (`internal/plugin`). The built-ins' diff --git a/README.md b/README.md index f8a9ca3f1..5175b32ff 100644 --- a/README.md +++ b/README.md @@ -168,7 +168,7 @@ An agent you're signed in to is a subscription with models behind it, so magpie - **Claude**: drives the real local `claude` binary and bridges your agent's tools over MCP - **Codex / ChatGPT**: your ChatGPT plan's models, in every other agent -- **GitHub Copilot**, **Gemini (Code Assist)**, **Antigravity**, **Grok (SuperGrok)** and more +- **GitHub Copilot**, **Gemini (Code Assist)**, **Antigravity** (through your own agy CLI), **Grok (SuperGrok)** and more - **Any OpenCode auth plugin or pi package** from npm **Daily warm-up** starts each Claude and ChatGPT account's 5-hour window at the times you choose, or the moment the last one resets. @@ -213,7 +213,6 @@ A conversation **stays with the account that answered it** while the vendor's pr ```sh magpie plugin add opencode-gemini-auth # an OpenCode plugin from npm -magpie plugin add pi-antigravity # a pi package, the same way magpie plugin login google-plugin # its own sign-in flow, in magpie ``` diff --git a/README.zh-CN.md b/README.zh-CN.md index c41a7ad4a..a305b587e 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -168,7 +168,7 @@ Agent 会把读到的东西放进提示词:一个 `.env`、一份配置、一 - **Claude**:驱动本机真正的 `claude` 程序,通过 MCP 桥接你的 Agent 的工具 - **Codex / ChatGPT**:你的 ChatGPT 订阅里的模型,给所有其他 Agent 用 -- **GitHub Copilot**、**Gemini(Code Assist)**、**Antigravity**、**Grok(SuperGrok)** 等等 +- **GitHub Copilot**、**Gemini(Code Assist)**、**Antigravity**(经你自己的 agy CLI)、**Grok(SuperGrok)** 等等 - **任何 OpenCode 登录插件或 pi 包**,直接从 npm 安装 **每日预热**会在你选定的时间,或者上一个窗口刚重置时,启动每个 Claude 和 ChatGPT 账号的 5 小时窗口。 @@ -213,7 +213,6 @@ Agent 会把读到的东西放进提示词:一个 `.env`、一份配置、一 ```sh magpie plugin add opencode-gemini-auth # npm 上的 OpenCode 插件 -magpie plugin add pi-antigravity # pi 包,同样的方式 magpie plugin login google-plugin # 在 magpie 里走它自己的登录流程 ``` diff --git a/docs/subsystems/provider-plugins.md b/docs/subsystems/provider-plugins.md index fa440a46a..6ffdff398 100644 --- a/docs/subsystems/provider-plugins.md +++ b/docs/subsystems/provider-plugins.md @@ -19,7 +19,7 @@ The `movers` map assembled in `internal/provider/migrate*.go` is the authoritati `provider.Moved(id)` identifies a subscription whose migration state in `migrations.json` is `plugin`. In `/api/providers`, its row exposes `move.state == "plugin"`; the GUI also receives its id in `onPlugins`. -A retired built-in (`retiredBuiltins` in [`migrate.go`](../../internal/provider/migrate.go), `provider.BuiltinRetired(id)`) has no built-in code left: the plugin serves it whether or not a move has run, and its row's `move.state` is `plugin`. Gates that once asked `Moved(id)` ask `provider.PluginServes(id)`, which is moved or retired. Built-in accounts of a retired subscription that haven't moved yet are served by nothing; `/api/providers` lists them in `unmoved` (each a `MoveCandidate`, with the failed move's `error` and `why`), and the GUI shows a line over the Providers list with a Move button (`unmovedLine` in `app.js`). Built-ins are retired one at a time, each in the commit that removes its code. +A retired built-in (`retiredBuiltins` in [`migrate.go`](../../internal/provider/migrate.go), `provider.BuiltinRetired(id)`) has no built-in code left: the plugin serves it whether or not a move has run, and its row's `move.state` is `plugin`. Gates that once asked `Moved(id)` ask `provider.PluginServes(id)`, which is moved or retired. Built-in accounts of a retired subscription that haven't moved yet are served by nothing; `/api/providers` lists them in `unmoved` (each a `MoveCandidate`, with the failed move's `error` and `why`), and the GUI shows a line over the Providers list with a Move button (`unmovedLine` in `app.js`). Built-ins are retired one at a time, each in the commit that removes its code. Antigravity is the exception (11-15): retired before its code is removed, it is kept from Google by `googleLogins`, which lists no account of a subscription its plugin serves (the mover reads `googleSavedLogins`), and its plugin's 0.2.0 answers every request with a 410 that points to Antigravity (local agy CLI). | Operation | Built-in owns the subscription | Plugin owns the subscription | | --- | --- | --- | diff --git a/internal/agent/antigravity_test.go b/internal/agent/antigravity_test.go index 35d98744c..3e9f83429 100644 --- a/internal/agent/antigravity_test.go +++ b/internal/agent/antigravity_test.go @@ -60,6 +60,7 @@ func antigravityFile(t *testing.T, path string) map[string]json.RawMessage { // model list come back when it is turned off, and what else the file holds // is never touched. func TestAntigravityGateway(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route home := antigravityHome(t) path := filepath.Join(home, ".antigravity", "settings.json") if !slices.ContainsFunc(All(), func(x *Agent) bool { return x.ID == "antigravity" && x.Name == "Antigravity" }) { diff --git a/internal/agent/openmausbot_test.go b/internal/agent/openmausbot_test.go index fe3eff589..0ae33456d 100644 --- a/internal/agent/openmausbot_test.go +++ b/internal/agent/openmausbot_test.go @@ -436,6 +436,7 @@ func ombSaves(t *testing.T, path string, engine json.RawMessage) { // picked; no catalog change follows, so before KeepOpenMausBotListed // nothing wrote magpie's list again. func TestOpenMausBotListWrittenAgain(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route home := syncHome(t) stashHome(t) ombRelay(t) diff --git a/internal/gateway/agy_accounts_test.go b/internal/gateway/agy_accounts_test.go index f89bb74e5..7b59bb5c6 100644 --- a/internal/gateway/agy_accounts_test.go +++ b/internal/gateway/agy_accounts_test.go @@ -1,6 +1,7 @@ package gateway import ( + "github.com/yetone/magpie/internal/provider" "io" "net/http" "net/http/httptest" @@ -26,6 +27,7 @@ func agyCLITurn(t *testing.T, s *Server, model string) (int, string) { // quota is spent is passed over for the next, and the turn after asks the // one with quota first, while agy itself stays on one model. func TestAgyUsesEveryAntigravityAccount(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route var asked []string s, _ := antigravityGroupFor(t, []string{"u1@example.com", "u2@example.com"}, "m", func(w http.ResponseWriter, r *http.Request) { who := strings.TrimPrefix(r.Header.Get("Authorization"), "Bearer ") diff --git a/internal/gateway/antigravity_agent_effort_test.go b/internal/gateway/antigravity_agent_effort_test.go index 2330d34c0..d55b3eed6 100644 --- a/internal/gateway/antigravity_agent_effort_test.go +++ b/internal/gateway/antigravity_agent_effort_test.go @@ -22,6 +22,7 @@ import ( // as the variant at that level, told that level; with none picked they go // as before, and another agent's requests never take its pick. func TestAntigravityAgentEffort(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route fresh(t) logins := []map[string]any{{ "agent": "antigravity", "user": "a@example.com", "on": true, diff --git a/internal/gateway/antigravity_array_items_test.go b/internal/gateway/antigravity_array_items_test.go index b37dacf16..cfaf2b565 100644 --- a/internal/gateway/antigravity_array_items_test.go +++ b/internal/gateway/antigravity_array_items_test.go @@ -24,6 +24,7 @@ const arrayItems400 = `{"error":{"code":400,"message":"* GenerateContentRequest. // takes (the reporter's table: {} and {"type":"string"} both answer 200); // before, it went as it came and Google turned the whole turn away. func TestAntigravityArrayGetsItems(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route r, err := parseAnthropic([]byte(arrayItemsAsk)) if err != nil { t.Fatal(err) @@ -48,6 +49,7 @@ func TestAntigravityArrayGetsItems(t *testing.T) { // properties, items, an anyOf/oneOf member, an allOf, a $ref to $defs, a // type list with null; one that has items keeps its own. func TestPlainSchemaArraysAllHaveItems(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route in := `{"type":"object","$defs":{"Tags":{"type":"array","description":"tags"}}, "properties":{ "grid":{"type":"array","items":{"type":"array"}}, @@ -90,6 +92,7 @@ func TestPlainSchemaArraysAllHaveItems(t *testing.T) { // that refused doesn't rest. Before, the route ended on the 400 (the // reporter's tries held the one attempt). func TestGroupFailsOverGoogleSchema400(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route fresh(t) a := &scripted{replies: []reply{{400, "", arrayItems400}}} b := &scripted{replies: []reply{{200, "", chatOK}}} diff --git a/internal/gateway/antigravity_cloak_test.go b/internal/gateway/antigravity_cloak_test.go index 8013e0e94..4e3b2d839 100644 --- a/internal/gateway/antigravity_cloak_test.go +++ b/internal/gateway/antigravity_cloak_test.go @@ -126,6 +126,7 @@ func unsaid(got string) string { // SDK's line reworded, and the copy magpie sent until 11-14, which Google // turned away 5 of 5 that day, goes the same way. func TestAntigravityCloakClaudeCode2316(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route want := "You are a Claude agent, built on the Claude Agent SDK by Anthropic.\n" for _, entry := range []string{"sdk-cli", "claude-desktop"} { system := "x-anthropic-billing-header: cc_version=2.1.316.2e4; cc_entrypoint=" + entry + ";\nYou are a Claude agent, built on Anthropic's Claude Agent SDK.\n" @@ -147,6 +148,7 @@ func TestAntigravityCloakClaudeCode2316(t *testing.T) { } func TestAntigravityCloakRewordsEveryLineItTurnsAway(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route for _, system := range []string{ "You are a Claude agent, built on Anthropic's Claude Agent SDK.", codexGPT5System, @@ -208,6 +210,7 @@ func TestAntigravityCloakRewordsEveryLineItTurnsAway(t *testing.T) { } func TestAntigravityHermesHint(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route if antigravityHint(hermesOldSystem) != antigravityHermesHint { t.Error("Hermes' old persona isn't told its own hint") } @@ -287,6 +290,7 @@ func codexAGPost(s *Server, body string) (int, string) { // user can turn on, they are refused as before, told why at a status the // agent doesn't retry. func TestAntigravityAnswersHermesAndCodexByDefault(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route var sent string s, _ := antigravityGroupFor(t, []string{"u@example.com"}, "gemini-3-flash", fakeGoogle(&sent)) @@ -336,6 +340,7 @@ func TestAntigravityAnswersHermesAndCodexByDefault(t *testing.T) { // CLI's own sign-in, on the same Code Assist envelope, and every other // provider are sent the prompt as the agent wrote it. func TestOnlyAntigravityIsSentThePromptReworded(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route r := &Request{System: hermesOldSystem + "\n" + codexGPT5System, Messages: []Message{{Role: "user", Parts: []Part{{Kind: Text, Text: "hi"}}}}} gemini := provider.Provider{ID: "gemini-cli", Account: &provider.Account{Agent: "gemini"}} if b := string(codeAssistBody(gemini, r, "gemini-3-flash", nil)); !strings.Contains(b, "You are Hermes Agent, an intelligent") || strings.Contains(b, ``) || strings.Contains(b, zeroWidth) { @@ -367,6 +372,7 @@ func TestOnlyAntigravityIsSentThePromptReworded(t *testing.T) { // DeepSeek Harness's paragraph on @ paths goes to an Antigravity account // reworded, and to every other provider as written (plugins#1028). func TestAntigravityDSHAtPathsGoReworded(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route dsh := agReworded[0][0] r := &Request{System: "You are DeepSeek Harness.\n\n" + dsh + "\n\nBe brief.", Messages: []Message{{Role: "user", Parts: []Part{{Kind: Text, Text: "hi"}}}}} ag := provider.Provider{ID: "antigravity", Account: &provider.Account{Agent: "antigravity"}} @@ -409,6 +415,7 @@ const ompLine = "RFC 2119 keywords: MUST, REQUIRED, SHOULD, RECOMMENDED, MAY, OP // (eric_li8983 on X, 11-14): broken up by zero-width spaces it was // turned away on a real account, worded so 0 in 10. func TestAntigravityCloakOmpLine(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route got := antigravityCloak(ompSystem) if want := strings.Replace(ompSystem, "keywords", "key words", 1); got != want { t.Fatalf("went as %q, want %q", got, want) @@ -426,6 +433,7 @@ func TestAntigravityCloakOmpLine(t *testing.T) { // account on 11-14, and each goes reworded. A copy that only matched as // written went out whole and was turned away. func TestAntigravityCloakLineWrappedOrWidened(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route copies := []string{ strings.Replace(ompLine, "REQUIRED, ", "REQUIRED,\n", 1), strings.Replace(ompLine, "REQUIRED, ", "REQUIRED,\r\n", 1), @@ -479,6 +487,7 @@ func TestAntigravityCloakLineWrappedOrWidened(t *testing.T) { // 429 (3 of 3 on a real account). The model's own turns, the caller's // request and every other account keep it as written. func TestAntigravityCloaksTheLineInAUsersTurn(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route said := "You were told: " + codexGPT5System // the lines Google let through in a user's turn go as written there others := "x-anthropic-billing-header: cc_version=2.1.316.2e4;\nYou are a Claude agent, built on Anthropic's Claude Agent SDK.\n" + hermesOldSystem + "\nRFC 2119 keywords: MUST, REQUIRED, SHOULD, RECOMMENDED, MAY, OPTIONAL." diff --git a/internal/gateway/antigravity_codex_test.go b/internal/gateway/antigravity_codex_test.go index f7a8d47b2..f1b84dd77 100644 --- a/internal/gateway/antigravity_codex_test.go +++ b/internal/gateway/antigravity_codex_test.go @@ -2,6 +2,7 @@ package gateway import ( "fmt" + "github.com/yetone/magpie/internal/provider" "io" "net/http" "net/http/httptest" @@ -19,6 +20,7 @@ const codexGPT5System = "You are Codex, an agent based on GPT-5. You and the use // with the same 429 it gives Claude Code's prompt, in any case; the lines // it answers were each tried on a real Antigravity account (10-27). func TestAntigravityTurnsAwayCodexsGPT5Prompt(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route for _, system := range []string{ codexGPT5System, "You are Codex, a coding agent based on GPT-5. You and the user share the same workspace.", @@ -79,6 +81,7 @@ func codexAGTurn(switched, search bool) string { // Codex is told why at a status it doesn't retry, Antigravity is asked // once, and the account doesn't rest. func TestAntigravityTurnsCodexsGPT5ThreadAwayOnce(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route for _, c := range []struct{ switched, search bool }{{false, false}, {true, false}, {false, true}, {true, true}} { switched, search := c.switched, c.search t.Run(fmt.Sprintf("switched=%v,search=%v", switched, search), func(t *testing.T) { @@ -125,6 +128,7 @@ func TestAntigravityTurnsCodexsGPT5ThreadAwayOnce(t *testing.T) { // In a group, the next Codex turn carrying that prompt skips Antigravity // as Claude Code's does, and the skip says Codex's hint. func TestAntigravityForeseesCodexsGPT5Prompt(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route asked := 0 s, _ := antigravityTurnedAwayGroup(t, []string{"u@example.com"}, func(w http.ResponseWriter, r *http.Request) { asked++ @@ -145,6 +149,7 @@ func TestAntigravityForeseesCodexsGPT5Prompt(t *testing.T) { } func TestAntigravityCodexHintIsTheRoutingPages(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route b, err := os.ReadFile(filepath.Join("..", "gui", "assets", "plugins", "routing", "client.js")) if err != nil { t.Fatal(err) diff --git a/internal/gateway/antigravity_display_items_test.go b/internal/gateway/antigravity_display_items_test.go index cc85c0c32..7cbe78674 100644 --- a/internal/gateway/antigravity_display_items_test.go +++ b/internal/gateway/antigravity_display_items_test.go @@ -1,6 +1,7 @@ package gateway import ( + "github.com/yetone/magpie/internal/provider" "testing" "github.com/tidwall/gjson" @@ -25,6 +26,7 @@ const displayItemsAsk = `{"model":"group/gemini-3-8-flash","max_tokens":32,"mess // that has properties an object, whatever its enum or const says: typed // from its values, the node went on with items on a string. func TestGeminiToolTypesItemsBeforeEnum(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route out := geminiToolTypes([]byte(displayItemsAsk)) props := gjson.GetBytes(out, "tools.0.input_schema.properties") if got := props.Get("display.type").String(); got != "array" { @@ -45,6 +47,7 @@ func TestGeminiToolTypesItemsBeforeEnum(t *testing.T) { // sent it, as this version's local magpie passes it on, and as a magpie // from before passed it on (display typed "string"). func TestAntigravityItemsOnlyOnArrays(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route older := `{"model":"group/gemini-3-8-flash","max_tokens":32,"messages":[{"role":"user","content":"hi"}], "tools":[{"name":"show","description":"show rows","input_schema":{"type":"object","properties":{ "display":{"type":"string","description":"columns to display","items":{"type":"string"},"enum":["name","size","date"]}, diff --git a/internal/gateway/antigravity_draw_test.go b/internal/gateway/antigravity_draw_test.go index c13f17f3d..39a84d4ac 100644 --- a/internal/gateway/antigravity_draw_test.go +++ b/internal/gateway/antigravity_draw_test.go @@ -1,6 +1,7 @@ package gateway import ( + "github.com/yetone/magpie/internal/provider" "io" "net/http" "net/http/httptest" @@ -47,6 +48,7 @@ func drawOn(t *testing.T, s *Server) (int, string) { // spent account while the next had its quota (01huadalang on Discord: // several accounts, one's image quota spent, no move to the next). func TestAntigravityDrawingOutOfQuotaInsideTheReplyGoesOn(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route s, asked := antigravityDrawers(t, func(w http.ResponseWriter) { w.Header().Set("Content-Type", "text/event-stream") io.WriteString(w, sse("data: "+antigravityQuota)) @@ -62,6 +64,7 @@ func TestAntigravityDrawingOutOfQuotaInsideTheReplyGoesOn(t *testing.T) { // Any other error said inside the reply is no account's quota, and the // drawing still ends there: the next account isn't asked, nothing rests. func TestAntigravityDrawingOtherErrorInsideTheReplyStays(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route s, asked := antigravityDrawers(t, func(w http.ResponseWriter) { w.Header().Set("Content-Type", "text/event-stream") io.WriteString(w, sse(`data: {"error":{"code":500,"message":"Internal error encountered.","status":"INTERNAL"}}`)) @@ -82,6 +85,7 @@ func TestAntigravityDrawingOtherErrorInsideTheReplyStays(t *testing.T) { // drawing asks the account that still has its quota first, where before // every drawing asked the spent one again, and its text models stay in. func TestAntigravityDrawingQuotaRestsTheImageModel(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route for _, tc := range []struct { name string spent func(w http.ResponseWriter) diff --git a/internal/gateway/antigravity_empty_bound_test.go b/internal/gateway/antigravity_empty_bound_test.go index 546fdfc0b..df7bf422e 100644 --- a/internal/gateway/antigravity_empty_bound_test.go +++ b/internal/gateway/antigravity_empty_bound_test.go @@ -1,6 +1,7 @@ package gateway import ( + "github.com/yetone/magpie/internal/provider" "io" "net/http" "net/http/httptest" @@ -16,6 +17,7 @@ import ( // conversation (vhjjkkhg on X: 8 to 9 tries, 10+ minutes, from Alma on // Responses). No account rests for it. func TestEmptyReplyOnTwoAccountsEndsTheRequest(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route users := []string{"u1@example.com", "u2@example.com", "u3@example.com", "u4@example.com", "u5@example.com"} for _, path := range []string{"/v1/responses", "/v1/chat/completions"} { t.Run(path, func(t *testing.T) { diff --git a/internal/gateway/antigravity_enum_blank_test.go b/internal/gateway/antigravity_enum_blank_test.go index 8326a7593..b26002d32 100644 --- a/internal/gateway/antigravity_enum_blank_test.go +++ b/internal/gateway/antigravity_enum_blank_test.go @@ -2,6 +2,7 @@ package gateway import ( "encoding/json" + "github.com/yetone/magpie/internal/provider" "strings" "testing" ) @@ -12,6 +13,7 @@ import ( // An enum of blanks alone, and a blank const, go without their enum; a // number in an enum still drops it whole. func TestPlainSchemaDropsBlankEnumValues(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route in := `{"type":"object","properties":{"StatusMessage":{"type":"object","properties":{"operationStatus":{"allOf":[{"enum":["processing","warning","error",""],"type":"string","x-enum-varnames":["EndpointOperationStatusProcessing","EndpointOperationStatusWarning","EndpointOperationStatusError","EndpointOperationStatusDone"]}],"description":"'', 'error', 'processing'","example":"error"}}},` + `"blank":{"type":"string","enum":[""," "]},"c":{"type":"string","const":""},"n":{"enum":["a",1,""]}}}` var got struct { diff --git a/internal/gateway/antigravity_models_test.go b/internal/gateway/antigravity_models_test.go index 61d394302..7c1dcf65a 100644 --- a/internal/gateway/antigravity_models_test.go +++ b/internal/gateway/antigravity_models_test.go @@ -17,6 +17,7 @@ import ( // /v1/models?format=antigravity, is {"list": [...]} in the app's own // fields, the models the key may use, each with its window and name. func TestAntigravityCatalog(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route setup(t, provider.Anthropic, &fake{}) if err := provider.Save(provider.Provider{ID: "ds", Name: "DS", Key: "k", Chat: "http://127.0.0.1:1/v1", Models: []string{"big", "plain"}}); err != nil { t.Fatal(err) @@ -104,6 +105,7 @@ func TestAntigravityCatalog(t *testing.T) { // level it has no word for is left out, and a model with one level left // is listed once, as a menu of one is no choice (YujunT46308 on X). func TestAntigravityLevels(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route for _, c := range []struct { in, want []string }{ @@ -123,6 +125,7 @@ func TestAntigravityLevels(t *testing.T) { // level asked, fitted to the model's, else at medium, as the app's own // picker starts one, else its weakest; a model with no levels as it is. func TestAntigravityModelStartsOnALevel(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route setup(t, provider.Anthropic, &fake{}) if err := provider.Save(provider.Provider{ID: "ds", Name: "DS", Key: "k", Chat: "http://127.0.0.1:1/v1", Models: []string{"three", "two", "plain"}}); err != nil { t.Fatal(err) diff --git a/internal/gateway/antigravity_pool_test.go b/internal/gateway/antigravity_pool_test.go index 606c37b9a..cfb4cabde 100644 --- a/internal/gateway/antigravity_pool_test.go +++ b/internal/gateway/antigravity_pool_test.go @@ -18,6 +18,7 @@ import ( // Discovery and routing agree when a new model is available only to a // secondary account, including the family id clients actually request. func TestAntigravityPoolRoutesDiscoveredModels(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route fresh(t) var logins []map[string]any for _, user := range []string{"old", "new"} { diff --git a/internal/gateway/antigravity_rest_test.go b/internal/gateway/antigravity_rest_test.go index 8e665d61d..99e20304f 100644 --- a/internal/gateway/antigravity_rest_test.go +++ b/internal/gateway/antigravity_rest_test.go @@ -131,6 +131,7 @@ func turnOn(t *testing.T, s *Server, body string) (int, string) { // an hour for a request it refused, its usage isn't asked again, and the // next turn asks it first again — as the refusal it is, not a spent quota. func TestAntigravityTurnedAwayRestsNobody(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route s, askedUsage := antigravityTurnedAwayGroup(t, []string{"u@example.com"}, func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusTooManyRequests) io.WriteString(w, turnedAway) @@ -170,6 +171,7 @@ func TestAntigravityTurnedAwayRestsNobody(t *testing.T) { // as before), and once the last refusal is old, it is asked again, so a // block Google lifts is noticed. func TestAntigravityTurnedAwayIsForeseen(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route asked := 0 s, askedUsage := antigravityTurnedAwayGroup(t, []string{"u@example.com"}, func(w http.ResponseWriter, r *http.Request) { asked++ @@ -225,6 +227,7 @@ func TestAntigravityTurnedAwayIsForeseen(t *testing.T) { // A 429 that really is the plan used up — no such system prompt asking — // still rests the account, as it did (#147, #530). func TestAntigravityQuotaStillRests(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route s, askedUsage := antigravityTurnedAwayGroup(t, []string{"u@example.com"}, func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusTooManyRequests) io.WriteString(w, turnedAway) @@ -252,6 +255,7 @@ func TestAntigravityQuotaStillRests(t *testing.T) { // no excuse for an account that really is broken, overloaded or denied: it // rests as it would on any other request (the maintenance review of #873). func TestAntigravityTurnedAwayIsOnlyTheRefusal(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route for _, tc := range []struct { name string status int @@ -286,6 +290,7 @@ func TestAntigravityTurnedAwayIsOnlyTheRefusal(t *testing.T) { // ledger keeps it: a Claude Code turn's 429 is as visible as any other // failed call (the maintenance review of #873). func TestAntigravityTurnedAwayStillLandsInTheLedger(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route s, _ := antigravityTurnedAwayGroup(t, []string{"u@example.com"}, func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusTooManyRequests) io.WriteString(w, turnedAway) @@ -310,6 +315,7 @@ func TestAntigravityTurnedAwayStillLandsInTheLedger(t *testing.T) { // a round-trip apiece before the group reaches the member that answers // (the maintenance review of #873). func TestAntigravityTurnedAwayLeavesItsMatesForLast(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route s, _ := antigravityTurnedAwayGroup(t, []string{"u@example.com", "v@example.com"}, func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusTooManyRequests) io.WriteString(w, turnedAway) @@ -336,6 +342,7 @@ func TestAntigravityTurnedAwayLeavesItsMatesForLast(t *testing.T) { // It leaves the account alone as the 429 does, and an error event of any // other kind still rests it. func TestAntigravityTurnedAwaySaidInsideTheReply(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route for _, tc := range []struct { name string body string @@ -398,6 +405,7 @@ func directTurn(system string, stream bool) string { // page tells it as the agent's prompt turned away, not a quota used up; the // account doesn't rest and isn't asked again. func TestAntigravityTurnedAwayLastIsNoQuota(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route for _, stream := range []bool{false, true} { t.Run(fmt.Sprintf("stream=%v", stream), func(t *testing.T) { asked := 0 @@ -441,6 +449,7 @@ func TestAntigravityTurnedAwayLastIsNoQuota(t *testing.T) { // event), with nobody left: told the same, at a status not retried, and not // asked again as a failure that may pass. func TestAntigravityTurnedAwayInsideTheReplyLast(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route asked := 0 s, _ := antigravityTurnedAwayGroup(t, []string{"u@example.com"}, func(w http.ResponseWriter, r *http.Request) { asked++ @@ -463,6 +472,7 @@ func TestAntigravityTurnedAwayInsideTheReplyLast(t *testing.T) { // is told what Antigravity turned away and why, at a status it doesn't // retry — not the other's quota, which waiting wouldn't fix either. func TestAntigravityTurnedAwayThenAQuota(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route s, _ := antigravityTurnedAwayGroup(t, []string{"u@example.com"}, func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusTooManyRequests) io.WriteString(w, turnedAway) @@ -491,6 +501,7 @@ func TestAntigravityTurnedAwayThenAQuota(t *testing.T) { // nobody left the agent gets the 429 (Rest-of-#666 review: refusal, account // or model, told apart by what was said, not by the system prompt alone). func TestAntigravityQuotaOnAClaudeCodeTurnStaysQuota(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route t.Run("in a group", func(t *testing.T) { s, askedUsage := antigravityTurnedAwayGroup(t, []string{"u@example.com"}, func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusTooManyRequests) @@ -528,6 +539,7 @@ func TestAntigravityQuotaOnAClaudeCodeTurnStaysQuota(t *testing.T) { // The Routing page says the note apart from Antigravity's words, in its own // language, only when it knows the very words the gateway adds. func TestAntigravityTurnedAwayHintIsTheRoutingPages(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route b, err := os.ReadFile(filepath.Join("..", "gui", "assets", "plugins", "routing", "client.js")) if err != nil { t.Fatal(err) @@ -544,6 +556,7 @@ func TestAntigravityTurnedAwayHintIsTheRoutingPages(t *testing.T) { // while the next ticked one had all its quota left (Dani Ariyanto on // Discord, 10-24: OpenCode on Gemini 3.8 Flash, seven accounts). func TestAntigravityQuotaRestsUntilItsReset(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route var asked []string s, _ := antigravityGroupFor(t, []string{"u1@example.com", "u2@example.com"}, "gemini-3.8-flash", func(w http.ResponseWriter, r *http.Request) { who := strings.TrimPrefix(r.Header.Get("Authorization"), "Bearer ") diff --git a/internal/gateway/antigravity_root_union_test.go b/internal/gateway/antigravity_root_union_test.go index 0b0b9a829..c635b59b9 100644 --- a/internal/gateway/antigravity_root_union_test.go +++ b/internal/gateway/antigravity_root_union_test.go @@ -2,6 +2,7 @@ package gateway import ( "encoding/json" + "github.com/yetone/magpie/internal/provider" "reflect" "testing" @@ -18,6 +19,7 @@ const rgSchema = `{"type":"object","properties":{"pattern":{"type":"string"},"cu // {"type":"string"} and Claude there answered 400 "tools.4.custom. // input_schema.type: Input should be 'object'". func TestAntigravityRootOneOfKeepsObject(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route got := plainSchema(json.RawMessage(rgSchema)) var parameters map[string]any if err := json.Unmarshal(got, ¶meters); err != nil { @@ -32,6 +34,7 @@ func TestAntigravityRootOneOfKeepsObject(t *testing.T) { // The same tool through the route the reporter took: an OpenAI Chat // declaration, parseChat, then the Antigravity body. func TestAntigravityChatToolRootOneOfKeepsObject(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route r, err := parseChat([]byte(`{"model":"m","messages":[{"role":"user","content":"hi"}],"tools":[{"type":"function","function":{"name":"rg","description":"search","parameters":` + rgSchema + `}}]}`)) if err != nil { t.Fatal(err) @@ -53,6 +56,7 @@ func TestAntigravityChatToolRootOneOfKeepsObject(t *testing.T) { // member does; a null branch makes it nullable. A union with nothing of // its own beside it is still read as its first branch that isn't null. func TestPlainSchemaUnionKeepsOwnShape(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route for _, c := range []struct{ name, in, want string }{ {"root oneOf", rgSchema, `{"type":"object","properties":{"pattern":{"type":"string"},"cursor":{"type":"string"}}}`}, @@ -98,6 +102,7 @@ func TestPlainSchemaUnionKeepsOwnShape(t *testing.T) { // the upstreams that refuse a root union), keeps the same tool an object // with both its fields: its constraint-only branches are passed over. func TestObjectSchemaRootOneOfKeepsObject(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route ps := gjson.ParseBytes(objectSchema(json.RawMessage(rgSchema))) if ps.Get("type").String() != "object" || !ps.Get("properties.pattern").Exists() || !ps.Get("properties.cursor").Exists() || ps.Get("oneOf").Exists() || ps.Get("required").Exists() { t.Fatalf("got %s", ps.Raw) diff --git a/internal/gateway/antigravity_suspended_test.go b/internal/gateway/antigravity_suspended_test.go index 6f6da3567..ff428c879 100644 --- a/internal/gateway/antigravity_suspended_test.go +++ b/internal/gateway/antigravity_suspended_test.go @@ -26,6 +26,7 @@ const antigravitySuspended = `{"error":{"code":403,"message":"This service has b // unknown failure that doubled to ten and had it asked, and refused, every // ten minutes for good. func TestAntigravitySuspendedRestsAsRestricted(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route var asked []string s, askedUsage := antigravityGroupFor(t, []string{"u1@example.com", "u2@example.com"}, "gemini-3.8-flash", func(w http.ResponseWriter, r *http.Request) { who := strings.TrimPrefix(r.Header.Get("Authorization"), "Bearer ") @@ -75,6 +76,7 @@ func TestAntigravitySuspendedRestsAsRestricted(t *testing.T) { // Google's own words; lifted on the Routing page (an appeal went through), // it is asked again. func TestAntigravitySuspendedAloneRests(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route n, back := 0, false s, _ := antigravityGroupFor(t, []string{"u1@example.com"}, "gemini-3.8-flash", func(w http.ResponseWriter, r *http.Request) { n++ @@ -111,6 +113,7 @@ func TestAntigravitySuspendedAloneRests(t *testing.T) { // a Google plugin's: another 403 from Antigravity, and the same words from a // key's relay or another plugin, fail as before. func TestAntigravitySuspendedIsGooglesAlone(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route ag := candidate{p: provider.Provider{ID: "antigravity", Account: &provider.Account{Agent: "antigravity", User: "u"}}} gem := candidate{p: provider.Provider{ID: "gemini", Account: &provider.Account{Agent: "gemini", User: "u"}}} key := candidate{p: provider.Provider{ID: "relay", Key: "k"}} diff --git a/internal/gateway/antigravity_unlisted_test.go b/internal/gateway/antigravity_unlisted_test.go index df8602304..bf47d2c2c 100644 --- a/internal/gateway/antigravity_unlisted_test.go +++ b/internal/gateway/antigravity_unlisted_test.go @@ -111,6 +111,7 @@ const codeAssistNotFound = `{"error":{"code":404,"message":"Requested entity was // Gemini 4 on one Antigravity account of several). The Routing page has // it asked, not "unlisted, skipped", and the first rests for that model. func TestUnlistedAccountAskedAfterModelRefused(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route s, turn, asked := unlistedArgon(t, map[string]string{ "a@example.com": `{"models":{"gemini-3.8-flash":{},"gemini-4-argon":{"displayName":"Gemini 4 Argon"}}}`, "b@example.com": `{"models":{"gemini-3.8-flash":{}}}`, @@ -142,6 +143,7 @@ func TestUnlistedAccountAskedAfterModelRefused(t *testing.T) { // bodies) leaves the accounts whose list lacks it alone, as before: they // would only refuse it too. func TestUnlistedAccountNotAskedForOtherRefusals(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route for _, c := range []struct { name, body string code int @@ -168,6 +170,7 @@ func TestUnlistedAccountNotAskedForOtherRefusals(t *testing.T) { // A gateway key held to some accounts (#905) isn't given an unlisted // account it may not use: the refusal reaches its agent, as before. func TestUnlistedAccountHeldFromKey(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route _, turn, asked := unlistedArgon(t, map[string]string{ "a@example.com": `{"models":{"gemini-3.8-flash":{},"gemini-4-argon":{"displayName":"Gemini 4 Argon"}}}`, "b@example.com": `{"models":{"gemini-3.8-flash":{}}}`, @@ -187,6 +190,7 @@ func TestUnlistedAccountHeldFromKey(t *testing.T) { // The unlisted account is asked before the provider's Fallback: it is the // same model on the same subscription, which the fallback is not. func TestUnlistedAccountBeforeFallback(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route _, turn, asked := unlistedArgon(t, map[string]string{ "a@example.com": `{"models":{"gemini-3.8-flash":{},"gemini-4-argon":{"displayName":"Gemini 4 Argon"}}}`, "b@example.com": `{"models":{"gemini-3.8-flash":{}}}`, diff --git a/internal/gateway/codeassist_missing_test.go b/internal/gateway/codeassist_missing_test.go index b470b8231..1dd2c2860 100644 --- a/internal/gateway/codeassist_missing_test.go +++ b/internal/gateway/codeassist_missing_test.go @@ -14,6 +14,7 @@ import ( // only it rests on that account; the account itself doesn't, and its // other models are asked as before. func TestCodeAssistMissingModelRestsTheModel(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route const notFound = `{"error":{"code":404,"message":"Requested entity was not found.","status":"NOT_FOUND"}}` s, _ := antigravityGroupFor(t, []string{"u@example.com"}, "argon", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") diff --git a/internal/gateway/gemini_empty_reply_test.go b/internal/gateway/gemini_empty_reply_test.go index 024bf1c18..7ebe0036c 100644 --- a/internal/gateway/gemini_empty_reply_test.go +++ b/internal/gateway/gemini_empty_reply_test.go @@ -142,6 +142,7 @@ func TestLateRestsEmptyReply(t *testing.T) { // the accounts must not be put into rest backoff, and the routing group must // fall over to another member to answer (#1221). func TestGeminiEmptyReplyGroupFailover(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route for _, stream := range []bool{true, false} { t.Run(map[bool]string{true: "stream", false: "nostream"}[stream], func(t *testing.T) { s, _ := antigravityGroupFor(t, []string{"u1@example.com", "u2@example.com"}, "gemini-3.8-flash", func(w http.ResponseWriter, r *http.Request) { diff --git a/internal/gateway/gemini_image_config_test.go b/internal/gateway/gemini_image_config_test.go index 6ae57519d..e5e3de2db 100644 --- a/internal/gateway/gemini_image_config_test.go +++ b/internal/gateway/gemini_image_config_test.go @@ -163,6 +163,7 @@ func TestGeminiImageConfigReachesTheGeminiAPI(t *testing.T) { // envelope: Antigravity is asked as a Gemini API is, its request a Gemini // request. func TestGeminiImageConfigReachesCodeAssist(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) diff --git a/internal/gateway/gemini_image_size_test.go b/internal/gateway/gemini_image_size_test.go index 87e46370c..139cc311b 100644 --- a/internal/gateway/gemini_image_size_test.go +++ b/internal/gateway/gemini_image_size_test.go @@ -82,6 +82,7 @@ func TestImagesAPISizeReachesTheGeminiAPI(t *testing.T) { // (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) diff --git a/internal/gateway/region_fresh_test.go b/internal/gateway/region_fresh_test.go index 50b2d6037..df83a7531 100644 --- a/internal/gateway/region_fresh_test.go +++ b/internal/gateway/region_fresh_test.go @@ -5,6 +5,7 @@ import ( "crypto/tls" "crypto/x509" "fmt" + "github.com/yetone/magpie/internal/provider" "io" "net" "net/http" @@ -170,6 +171,7 @@ func antigravityOnEdge(t *testing.T, users []string, v *edgeVendor) *Server { // 400, while a new connection was answered. The next account now goes out // on a new connection and answers, and the account refused rests not. func TestAntigravityRegionRefusalAsksTheNextOnANewConnection(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route v := newEdgeVendor(t, true, googleRegion400) s := antigravityOnEdge(t, []string{"u1@example.com", "u2@example.com"}, v) code, out := turnOn(t, s, directTurn("You are a helpful assistant.", false)) @@ -200,6 +202,7 @@ func TestAntigravityRegionRefusalAsksTheNextOnANewConnection(t *testing.T) { // #5182: the only account, refused for where the request came from, is // asked again a moment later, on a new connection, and answers. func TestAntigravityRegionRefusalAsksTheLastAgain(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route pause := retryPause retryPause = time.Millisecond t.Cleanup(func() { retryPause = pause }) @@ -222,6 +225,7 @@ func TestAntigravityRegionRefusalAsksTheLastAgain(t *testing.T) { // (restAfter), and counts no failure: the account is asked first again. // A 500 on the same account still rests it as before. func TestRegionRefusalRestsNoAccount(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route for _, body := range []string{googleRegion400, antigravityRegion400} { s, askedUsage := antigravityTurnedAwayGroup(t, []string{"u1@example.com", "u2@example.com"}, func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") @@ -272,6 +276,7 @@ func TestRegionRefusalRestsNoAccount(t *testing.T) { // nobody rests, and the agent is told Google's regional restriction on // the model, at the 400 it doesn't retry. func TestRegionRefusalOfTheModelEndsAfterOneMoreAsk(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route pause := retryPause retryPause = time.Millisecond t.Cleanup(func() { retryPause = pause }) diff --git a/internal/gateway/restricted_held_test.go b/internal/gateway/restricted_held_test.go index c10b8f71f..fac42d182 100644 --- a/internal/gateway/restricted_held_test.go +++ b/internal/gateway/restricted_held_test.go @@ -26,6 +26,7 @@ func agyTurn(s *Server) (int, string) { // suspended Antigravity accounts, 23 and 22 tries, none answered). Lifted // on the Routing page, the account is asked again. func TestSuspendedAccountsNotAskedWhileTheyRest(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route var asked []string s, _ := antigravityGroupFor(t, []string{"u1@example.com", "u2@example.com"}, "gemini-3.8-flash", func(w http.ResponseWriter, r *http.Request) { asked = append(asked, strings.TrimPrefix(r.Header.Get("Authorization"), "Bearer ")) @@ -86,6 +87,7 @@ func TestRestrictedLoneAccountNotAskedWhileItRests(t *testing.T) { // A refusal of the request's content is not the account's: it rests // nobody, and the next request asks the same account again. func TestContentRefusalStillAsksTheAccount(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route n := 0 s, _ := antigravityGroupFor(t, []string{"u1@example.com"}, "gemini-3.8-flash", func(w http.ResponseWriter, r *http.Request) { n++ @@ -108,6 +110,7 @@ func TestContentRefusalStillAsksTheAccount(t *testing.T) { // the account's rest isn't taken anew by each such turn: it ends when it // would, rather than never while the conversation goes on. func TestSuspendedStrictConversationKeepsItsRest(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route var asked []string suspended := false s, _ := antigravityGroupFor(t, []string{"u1@example.com", "u2@example.com"}, "gemini-3.8-flash", func(w http.ResponseWriter, r *http.Request) { diff --git a/internal/gateway/sse_bare_test.go b/internal/gateway/sse_bare_test.go index e951863fd..3a6b0e6bd 100644 --- a/internal/gateway/sse_bare_test.go +++ b/internal/gateway/sse_bare_test.go @@ -117,6 +117,7 @@ func TestBareErrorsHoldsNothingElse(t *testing.T) { // that "ended before it was complete". It is the request's fault: the // account doesn't rest, and the route books the 400. func TestAntigravityBareErrorIsTheVendors(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route for name, reply := range agBareEnds { for _, stream := range []bool{true, false} { t.Run(fmt.Sprintf("%s/stream=%v", name, stream), func(t *testing.T) { diff --git a/internal/gateway/translated_probe_test.go b/internal/gateway/translated_probe_test.go index cd0a2f51d..37101892a 100644 --- a/internal/gateway/translated_probe_test.go +++ b/internal/gateway/translated_probe_test.go @@ -21,6 +21,7 @@ import ( // "hi" built by the translator in the account's envelope, and says what // the vendor answered — a word, or its refusal. func TestAntigravityModelTest(t *testing.T) { + t.Cleanup(provider.AntigravityBuiltinForTest()) // the retired built-in route fresh(t) dir := filepath.Dir(provider.Path()) if err := os.MkdirAll(dir, 0o700); err != nil { diff --git a/internal/provider/account_order_test.go b/internal/provider/account_order_test.go index c4217f59e..37cd0c882 100644 --- a/internal/provider/account_order_test.go +++ b/internal/provider/account_order_test.go @@ -86,6 +86,7 @@ func loginRoutingUsers(p *Provider) []string { } func TestAccountOrderSideLoginsAllRoutingModes(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route googleSandbox(t, &fakeGoogle{}) users := []string{"a@example.test", "b@example.test", "c@example.test", "off@example.test"} for _, user := range users { diff --git a/internal/provider/antigravity_models_test.go b/internal/provider/antigravity_models_test.go index bf70cee08..821a635ba 100644 --- a/internal/provider/antigravity_models_test.go +++ b/internal/provider/antigravity_models_test.go @@ -31,6 +31,7 @@ var antigravityListed = []catalog.Model{ // those levels; a model with one id, or only a name like another's, // stays as Antigravity lists it. func TestCollapseAntigravityModels(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route var got []string for _, m := range collapseAntigravityModels(antigravityListed) { got = append(got, m.ID+"|"+m.Name+"|"+strings.Join(m.Efforts, ",")) @@ -92,6 +93,7 @@ func TestCollapseAntigravityModels(t *testing.T) { // ids: each is the model magpie offers for it now, once, where it was; // the rest stay. func TestAntigravityLegacyPicks(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route home := t.TempDir() t.Setenv("HOME", home) t.Setenv("USERPROFILE", home) @@ -134,6 +136,7 @@ func TestAntigravityLegacyPicks(t *testing.T) { // id its model's with "(Tiered)" (EZN7L2C3, #955: agy's list showed // magpie/antigravity/gemini-3.6-flash-tiered), any other its id. func TestAntigravityUnnamedModels(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route raw := []catalog.Model{ {ID: "gemini-3.6-flash-high", Name: "Gemini 3.6 Flash (High)"}, {ID: "gemini-3.6-flash-low", Name: "Gemini 3.6 Flash (Low)"}, diff --git a/internal/provider/antigravity_pool_test.go b/internal/provider/antigravity_pool_test.go index 32e6b5e73..97befd22c 100644 --- a/internal/provider/antigravity_pool_test.go +++ b/internal/provider/antigravity_pool_test.go @@ -12,6 +12,7 @@ import ( // A rollout can give the first account 4.6 and another enabled account // 5.5. Refresh must discover both, and routing must know who lists each. func TestAntigravityModelsAcrossAccounts(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route replies := map[string]string{ "project-old": `{"models":{"gemini-3.8-flash":{},"claude-opus-4-6-thinking":{"displayName":"Claude Opus 4.6 (Thinking)"},"gpt-oss-120b-medium":{}}, "agentModelSorts":[{"groups":[{"modelIds":["gemini-3.8-flash","claude-opus-4-6-thinking","gpt-oss-120b-medium"]}]}]}`, @@ -120,6 +121,7 @@ func TestAntigravityModelsAcrossAccounts(t *testing.T) { // The merge keeps each account's own order: a model only a later account // has goes right after the model before it in that account's list. func TestMergeAntigravityOrder(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route ids := func(ss ...string) []catalog.Model { var out []catalog.Model for _, s := range ss { diff --git a/internal/provider/antigravity_quota_list_test.go b/internal/provider/antigravity_quota_list_test.go index 334789dd5..53cd6560d 100644 --- a/internal/provider/antigravity_quota_list_test.go +++ b/internal/provider/antigravity_quota_list_test.go @@ -17,6 +17,7 @@ import ( // account made preferred is needed for the picker, routing or its bar. // An account switched off changes nothing. func TestAntigravityQuotaReadingListsNewModels(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route replies := map[string]string{ "project-a": `{"models":{"gemini-3.8-flash":{"quotaInfo":{"remainingFraction":1}},"gemini-4-argon-disabled":{"displayName":"Gemini 4 Argon","disabled":true}}}`, "project-b": `{"models":{"gemini-3.8-flash":{"quotaInfo":{"remainingFraction":1}}}}`, diff --git a/internal/provider/antigravity_quota_routing_test.go b/internal/provider/antigravity_quota_routing_test.go index b592f9231..932e22fe3 100644 --- a/internal/provider/antigravity_quota_routing_test.go +++ b/internal/provider/antigravity_quota_routing_test.go @@ -8,6 +8,7 @@ import ( // Routing sees the same model family the picker offers, including when // quota is read before the live model catalog has been saved. func TestAntigravityQuotaRoutesBaseModel(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route f := &fakeGoogle{ load: `{"cloudaicompanionProject":"test-project"}`, models: `{"models":{ diff --git a/internal/provider/antigravity_retired_test.go b/internal/provider/antigravity_retired_test.go new file mode 100644 index 000000000..493388cce --- /dev/null +++ b/internal/provider/antigravity_retired_test.go @@ -0,0 +1,57 @@ +package provider + +import ( + "context" + "testing" + "time" +) + +// Antigravity's built-in is retired (11-15): Google bans accounts it sees +// on Code Assist through Antigravity's client. A saved account is still +// read by its mover, but nothing lists, reads usage for or asks Google +// with it, while Gemini CLI's accounts, on the same code, are untouched. +func TestRetiredAntigravityAsksGoogleNothing(t *testing.T) { + f := &fakeGoogle{quota: `{"buckets":[]}`, models: `{"models":{}}`} + googleSandbox(t, f) + exp := time.Now().Add(time.Hour).UnixMilli() + if err := addGoogleLogin("antigravity", "ag@example.com", "", googleAuth{AccessToken: "at-ag", RefreshToken: "rt-ag", Project: "proj-ag", Expiry: exp}); err != nil { + t.Fatal(err) + } + ForgetAccounts() + + if !PluginServes("antigravity") { + t.Fatal("antigravity's built-in is not retired") + } + if ls := googleLogins("antigravity"); len(ls) != 0 { + t.Fatalf("googleLogins(antigravity) = %d accounts, want none: the built-in serves nothing", len(ls)) + } + if _, ok := googleAccountOf("antigravity"); ok { + t.Fatal("googleAccountOf(antigravity) gave an account") + } + if ls := googleSavedLogins("antigravity"); len(ls) != 1 || ls[0].User != "ag@example.com" { + t.Fatalf("googleSavedLogins(antigravity) = %+v, want the saved account for its mover", ls) + } + if ms := movingOf(t, "antigravity"); len(ms) != 1 { + t.Fatalf("the mover carries %d accounts, want 1: %+v", len(ms), ms) + } + for _, q := range fetchSubscriptionUsage(context.Background()) { + if q.Provider == "antigravity" { + t.Fatalf("usage has an Antigravity card: %+v", q) + } + } + f.mu.Lock() + asked := len(f.heads) + f.mu.Unlock() + if asked != 0 { + t.Fatalf("Google was asked %d times with only an Antigravity account saved", asked) + } + + // Gemini CLI's accounts, on the same code, are served as before + if err := addGoogleLogin("gemini", "g@example.com", "", googleAuth{AccessToken: "at-g", RefreshToken: "rt-g", Project: "proj-g", Expiry: exp}); err != nil { + t.Fatal(err) + } + ForgetAccounts() + if ls := googleLogins("gemini"); len(ls) != 1 { + t.Fatalf("googleLogins(gemini) = %d accounts, want 1", len(ls)) + } +} diff --git a/internal/provider/antigravity_tier_test.go b/internal/provider/antigravity_tier_test.go index ecbb22d78..621ec458a 100644 --- a/internal/provider/antigravity_tier_test.go +++ b/internal/provider/antigravity_tier_test.go @@ -81,6 +81,7 @@ func antigravityModelIDs(t *testing.T, agent string) []string { // in entitlement.userTier, as Antigravity's language server does, and the // log says what Google answered and what magpie left out. func TestAntigravityProAccountNamesItsTier(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route f := &fakeGoogle{load: proLoad, modelsFor: tierModels("g1-pro-tier")} googleSandbox(t, f) buf := captureLog(t) @@ -109,6 +110,7 @@ func TestAntigravityProAccountNamesItsTier(t *testing.T) { // A tier Google won't take from the account is left out: the next is // tried, then none, and the refusal is logged. func TestAntigravityTierRefusedFallsBack(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route f := &fakeGoogle{load: proLoad, modelsFor: tierModels("standard-tier")} googleSandbox(t, f) buf := captureLog(t) @@ -143,6 +145,7 @@ func TestAntigravityTierRefusedFallsBack(t *testing.T) { // before; one whose project was kept with its sign-in still has its tiers // asked for, so a Pro account imported with its project names its plan. func TestAntigravityTierFreeAndKeptProject(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route f := &fakeGoogle{ load: `{"currentTier":{"id":"free-tier","name":"Antigravity"},"paidTier":{"id":"free-tier","name":"Antigravity Starter Quota"},"cloudaicompanionProject":"aicode-consumers"}`, modelsFor: tierModels("g1-pro-tier"), @@ -176,6 +179,7 @@ func TestAntigravityTierFreeAndKeptProject(t *testing.T) { // left out of the list for every client; the models beside it, and their // ids, are as Google sent them. func TestAntigravityDisabledModelLeftOut(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route f := &fakeGoogle{load: `{"currentTier":{"id":"free-tier","name":"Antigravity"},"cloudaicompanionProject":"aicode-consumers"}`, models: `{"models":{ "gemini-3.8-flash-high":{"displayName":"Gemini 3.8 Flash (High)","maxTokens":1048576,"quotaInfo":{"remainingFraction":1}}, "gemini-4-argon-disabled":{"displayName":"Gemini 4 Argon","maxTokens":1048576,"disabled":true,"quotaInfo":{"remainingFraction":1}}, @@ -203,6 +207,7 @@ func TestAntigravityDisabledModelLeftOut(t *testing.T) { // sub2api, Antigravity-Manager), and lists what that gives. Should that // fail too, the log says so and the account keeps the list it had. func TestAntigravityProInvalidTierAsksWithoutOne(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route const load = `{"currentTier":{"id":"free-tier","name":"Antigravity"}, "paidTier":{"id":"g1-pro-tier","name":"Google AI Pro"}, "cloudaicompanionProject":"aicode-consumers"}` @@ -275,6 +280,7 @@ func TestAntigravityProInvalidTierAsksWithoutOne(t *testing.T) { // a step no row is written for, it isn't named again for tierRefusedFor, // and a list that fails without one is still written down. func TestAntigravityRefusedTierAskedOnceAndNoRow(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route const load = `{"currentTier":{"id":"free-tier","name":"Antigravity"}, "paidTier":{"id":"g1-pro-tier","name":"Google AI Pro"}, "cloudaicompanionProject":"aicode-consumers"}` @@ -363,6 +369,7 @@ func TestAntigravityRefusedTierAskedOnceAndNoRow(t *testing.T) { // A tier refused for a reason other than a 400 (Google down) is named // again on the next list. func TestAntigravityTierNotRestedForOtherFailures(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route f := &fakeGoogle{load: proLoad, modelsFor: func(body map[string]any) (int, string) { if body["entitlement"] != nil { return 503, `{"error":{"code":503,"message":"The service is currently unavailable.","status":"UNAVAILABLE"}}` @@ -391,6 +398,7 @@ func TestAntigravityTierNotRestedForOtherFailures(t *testing.T) { // Now they are asked again once an hour old, as Gemini CLI's experiments // are, and a list names the tier the account has now. func TestAntigravityTierAskedAgainAfterUpgrade(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route const free = `{"currentTier":{"id":"free-tier","name":"Antigravity"},"cloudaicompanionProject":"aicode-consumers"}` const ultra = `{"currentTier":{"id":"standard-tier","name":"Antigravity","usesGcpTos":true}, "paidTier":{"id":"g1-ultra-tier","name":"Google AI Ultra"},"cloudaicompanionProject":"aicode-consumers"}` diff --git a/internal/provider/cpa_efforts_test.go b/internal/provider/cpa_efforts_test.go index ba2f51b5a..cc512995c 100644 --- a/internal/provider/cpa_efforts_test.go +++ b/internal/provider/cpa_efforts_test.go @@ -24,6 +24,7 @@ import ( // every list Codex and the ChatGPT app are handed; one whose base magpie // doesn't know still takes none, and a vendor's own word stays its own. func TestCPAVariantModelsBorrowLevels(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route home := t.TempDir() t.Setenv("HOME", home) t.Setenv("USERPROFILE", home) diff --git a/internal/provider/effort_price_test.go b/internal/provider/effort_price_test.go index 3dae11082..41548f791 100644 --- a/internal/provider/effort_price_test.go +++ b/internal/provider/effort_price_test.go @@ -16,6 +16,7 @@ import ( // part of a model's own name (-max, mistral-medium) is not taken for an // effort of another model. func TestEffortIDPricedAsItsModel(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route home := t.TempDir() t.Setenv("HOME", home) t.Setenv("USERPROFILE", home) diff --git a/internal/provider/exposed_ids_test.go b/internal/provider/exposed_ids_test.go index 8974d3420..764d8d3f0 100644 --- a/internal/provider/exposed_ids_test.go +++ b/internal/provider/exposed_ids_test.go @@ -6,6 +6,7 @@ import "testing" // providers only: every other provider's, each account's and plugin's, // was built on each usage read for nothing. func TestExposedIDsBuildsOnlyTheProvidersAsked(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route isolate(t) for _, p := range []Provider{ {ID: "asked", Name: "Asked", Key: "k", Chat: "http://127.0.0.1:1/v1", Models: []string{"gemini-a"}}, @@ -28,6 +29,7 @@ func TestExposedIDsBuildsOnlyTheProvidersAsked(t *testing.T) { // providers whose quotas are narrowed are built once while nothing changes, so the catalog they // load can be let go, and again after a change, which reaches the answer. func TestKeptExposedIDsBuiltOncePerChange(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route isolate(t) keptExposed.Lock() keptExposed.ids = nil diff --git a/internal/provider/find_elsewhere_test.go b/internal/provider/find_elsewhere_test.go index f6784a2ae..541610a29 100644 --- a/internal/provider/find_elsewhere_test.go +++ b/internal/provider/find_elsewhere_test.go @@ -12,6 +12,7 @@ import ( // Discord: `magpie provider refresh antigravity` found no Antigravity, which // the window showed signed in); without the variable it says nothing more. func TestFindSaysFilesAreElsewhere(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route h := t.TempDir() t.Setenv("HOME", h) t.Setenv("USERPROFILE", h) diff --git a/internal/provider/first_off_test.go b/internal/provider/first_off_test.go index d888c6865..87880be5b 100644 --- a/internal/provider/first_off_test.go +++ b/internal/provider/first_off_test.go @@ -12,6 +12,7 @@ import ( // ticked off it hands first to the next ticked account; with no other // ticked, it stays, as one account is always used. func TestFirstTickedOffHandsFirstOn(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route claudeHome(t) auth := func(r string) json.RawMessage { b, _ := json.Marshal(googleAuth{RefreshToken: r}) diff --git a/internal/provider/forget_last_login_test.go b/internal/provider/forget_last_login_test.go index d7de3089c..4da02e7e4 100644 --- a/internal/provider/forget_last_login_test.go +++ b/internal/provider/forget_last_login_test.go @@ -11,6 +11,7 @@ import ( // other account to put first. The only one goes; with another there, the // first still waits for it to be put first. func TestForgetOnlyFirstLogin(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route claudeHome(t) auth := func(r string) json.RawMessage { b, _ := json.Marshal(googleAuth{RefreshToken: r}) diff --git a/internal/provider/google.go b/internal/provider/google.go index b3bf5befb..5b8638729 100644 --- a/internal/provider/google.go +++ b/internal/provider/google.go @@ -227,8 +227,19 @@ type googleLogin struct { acct googleAccount } -// googleLogins lists an app's accounts, the first in use first. +// googleLogins lists an app's accounts the built-in serves, the first in +// use first: none for one its plugin serves (Antigravity, retired), so +// nothing here asks Google for its models, usage or requests. func googleLogins(agent string) []googleLogin { + if PluginServes(agent) { + return nil + } + return googleSavedLogins(agent) +} + +// googleSavedLogins lists an app's saved accounts, the first in use first, +// served or not: its mover reads them to carry them over. +func googleSavedLogins(agent string) []googleLogin { own, hasOwn := googleAccount{}, false if agent == "gemini" { own, hasOwn = geminiOwnLogin() diff --git a/internal/provider/google_import_test.go b/internal/provider/google_import_test.go index 45f447d74..84d63de49 100644 --- a/internal/provider/google_import_test.go +++ b/internal/provider/google_import_test.go @@ -14,6 +14,7 @@ import ( ) func TestParseGoogleImportFormats(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route cases := []struct { name, data string want []googleImport // n and err not compared unless set @@ -118,6 +119,7 @@ func (f *fakeGoogleImport) ServeHTTP(w http.ResponseWriter, r *http.Request) { } func TestImportGoogleAccounts(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route googleSandbox(t, &fakeGoogle{}) f := &fakeGoogleImport{users: map[string]string{"1//a": "a@x.com", "1//b": "b@x.com", "1//c": "c@x.com", "1//n": "nouser"}} srv := httptest.NewServer(f) diff --git a/internal/provider/google_test.go b/internal/provider/google_test.go index 6980d483c..bdba66828 100644 --- a/internal/provider/google_test.go +++ b/internal/provider/google_test.go @@ -161,6 +161,7 @@ func TestGeminiOwnLoginRefreshesInMemory(t *testing.T) { // minted for another client (Antigravity's) can't be refreshed as Gemini // CLI's and isn't listed; one without an ID token is taken as Gemini CLI's. func TestGeminiOwnLoginOnlyGeminiCLIsClient(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route idToken := func(claims map[string]any) string { b, _ := json.Marshal(claims) return "e30." + base64.RawURLEncoding.EncodeToString(b) + ".sig" @@ -268,6 +269,7 @@ func TestSetGoogleProject(t *testing.T) { // roll it out to the account, previews where its quota has one — and each // goes to Code Assist by the id the CLI sends. func TestGeminiModelsAsTheCLIOffersThem(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route ids := func(ms []catalog.Model) string { var s []string for _, m := range ms { @@ -355,6 +357,7 @@ func TestGeminiModelsAsTheCLIOffersThem(t *testing.T) { // Antigravity's account is onboarded on the daily endpoint, asking until // it is done, and its requests carry what Antigravity sends. func TestAntigravityProjectAndEnvelope(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route f := &fakeGoogle{ load: `{"allowedTiers":[{"id":"free-tier","name":"Antigravity","isDefault":true}]}`, onboard: `{"done":true,"response":{"cloudaicompanionProject":"ag-proj"}}`, @@ -409,6 +412,7 @@ func TestAntigravityProjectAndEnvelope(t *testing.T) { // read as bloat), so the GUI can show one figure a family; the windows // themselves, and the model each counts for routing, stay as they were. func TestAntigravityQuotaFamilies(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route f := &fakeGoogle{ load: `{"allowedTiers":[{"id":"free-tier","name":"Antigravity","isDefault":true}]}`, onboard: `{"done":true,"response":{"cloudaicompanionProject":"ag-proj"}}`, @@ -462,6 +466,7 @@ func TestAntigravityQuotaFamilies(t *testing.T) { // after the models', each model naming its group, and a page of text shows // the groups' windows in place of the models'. func TestAntigravityQuotaPools(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route f := &fakeGoogle{ load: `{"allowedTiers":[{"id":"free-tier","name":"Antigravity","isDefault":true}]}`, onboard: `{"done":true,"response":{"cloudaicompanionProject":"ag-proj"}}`, @@ -608,6 +613,7 @@ func TestPooledWindowsPartialAggregateKeepsModelFallback(t *testing.T) { // model it adds isn't given those of a model of that name elsewhere // (Anthropic's 1M for Claude), nor said to see when it doesn't. func TestAntigravityModelsAsItListsThem(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route f := &fakeGoogle{ load: `{"allowedTiers":[{"id":"free-tier","name":"Antigravity","isDefault":true}]}`, onboard: `{"done":true,"response":{"cloudaicompanionProject":"ag-proj"}}`, @@ -661,6 +667,7 @@ func TestAntigravityModelsAsItListsThem(t *testing.T) { // list and in Usage's windows, so no two read the same; a level tagged // with its own family keeps the name it was given. func TestAntigravityRetiredModelNamedForItself(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route f := &fakeGoogle{ load: `{"allowedTiers":[{"id":"free-tier","name":"Antigravity","isDefault":true}]}`, onboard: `{"done":true,"response":{"cloudaicompanionProject":"ag-proj"}}`, @@ -747,6 +754,7 @@ func TestAntigravityRetiredModelNamedForItself(t *testing.T) { // name does; no two models read the same, and the names Antigravity gives // the rest stay. func TestAntigravityRetiredModelNamedWithoutTag(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route raw, err := os.ReadFile("testdata/antigravity-models-2026-10-20.json") if err != nil { t.Fatal(err) @@ -831,6 +839,7 @@ func TestAntigravityRetiredModelNamedWithoutTag(t *testing.T) { // models, whichever Google lists first and whether or not it has 5 hours // (01huadalang on Discord: a Gemini 4 bar of 7 days, and Claude's gone). func TestAntigravityQuotaModelGroup(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route argon := func(five bool) string { b := `{"bucketId":"gemini-argon-wtu-weekly","window":"weekly","remainingFraction":0.53,"resetTime":"2099-01-07T00:00:00Z","displayName":"Gemini 4 Argon Weekly Limit"}` if five { @@ -903,6 +912,7 @@ func TestAntigravityQuotaModelGroup(t *testing.T) { // names it; one read alike folds, as before; with the group in the // summary, the group's (TestAntigravityQuotaModelGroup). func TestAntigravityQuotaModelApartFromGroup(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route at := func(d time.Duration) string { return time.Now().Add(d).UTC().Format(time.RFC3339) } five, week := at(3*time.Hour), at(6*24*time.Hour) gemini := `{"displayName":"Gemini Models","description":"Models within this group: Gemini Flash, Gemini Pro","buckets":[ @@ -987,6 +997,7 @@ func TestAntigravityQuotaModelApartFromGroup(t *testing.T) { // "Gemini … 7d" rings at 1% beside Gemini's own. A model read as any of // its group's windows draws on the group. func TestAntigravityQuotaModelsReadAsGroupWeek(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route at := func(d time.Duration) string { return time.Now().Add(d).UTC().Format(time.RFC3339) } five, week := at(5*time.Hour), at(5*24*time.Hour) gemini := `{"displayName":"Gemini Models","description":"Models within this group: Gemini Flash, Gemini Pro","buckets":[ diff --git a/internal/provider/localid_test.go b/internal/provider/localid_test.go index d16be1725..6e42dd2d8 100644 --- a/internal/provider/localid_test.go +++ b/internal/provider/localid_test.go @@ -266,6 +266,7 @@ func TestModelIDServingAndPrice(t *testing.T) { // the account's own say of it is: the account's picks kept from before, // and the variant an Antigravity family goes out as at an effort. func TestModelIDAtAnAccount(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route prefsHome(t) if err := os.MkdirAll(filepath.Dir(catalog.LivePath("antigravity")), 0o755); err != nil { t.Fatal(err) diff --git a/internal/provider/logins_unread_test.go b/internal/provider/logins_unread_test.go index fda9b6a99..700581cac 100644 --- a/internal/provider/logins_unread_test.go +++ b/internal/provider/logins_unread_test.go @@ -82,6 +82,7 @@ func TestUnreadLoginsWriteErrorsKeepCredentials(t *testing.T) { // Valid JSON can still be unreadable as saved accounts. On a cold start, // adding an account must keep those original credentials in a backup. func TestUnreadLoginsFieldTypesKeptBeforeWrite(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route for _, tc := range []struct { name string text string @@ -130,6 +131,7 @@ func TestUnreadLoginsFieldTypesKeptBeforeWrite(t *testing.T) { } func TestReadableLoginsNotKeptAside(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route googleSandbox(t, &fakeGoogle{}) for _, u := range []string{"a@x.com", "b@x.com"} { if err := addGoogleLogin("antigravity", u, "", googleAuth{RefreshToken: "1//" + u, Project: "p"}); err != nil { @@ -152,6 +154,7 @@ func TestReadableLoginsNotKeptAside(t *testing.T) { // else) was read as no accounts, and the next account added wrote the // file anew with that one alone: every saved sign-in gone. func TestUnreadLoginsNotWrittenOver(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route googleSandbox(t, &fakeGoogle{}) for _, u := range []string{"a@x.com", "b@x.com"} { if err := addGoogleLogin("antigravity", u, "", googleAuth{RefreshToken: "1//" + u, Project: "p"}); err != nil { diff --git a/internal/provider/logins_windows_test.go b/internal/provider/logins_windows_test.go index d1ffac211..be178ecc2 100644 --- a/internal/provider/logins_windows_test.go +++ b/internal/provider/logins_windows_test.go @@ -17,6 +17,7 @@ import ( // that followed left every account out (Packing1 on Discord, Windows 11: // 「整行都没了,供应商里面antigravity直接消失了」 after an update). func TestLoginsKeptWhileAnotherMagpieWrites(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route googleSandbox(t, &fakeGoogle{}) if err := addGoogleLogin("antigravity", "a@x.com", "", googleAuth{RefreshToken: "1//a", Project: "pa"}); err != nil { t.Fatal(err) diff --git a/internal/provider/migrate.go b/internal/provider/migrate.go index 9aa8e1e3e..559b21551 100644 --- a/internal/provider/migrate.go +++ b/internal/provider/migrate.go @@ -40,6 +40,7 @@ import ( "strconv" "strings" "sync" + "sync/atomic" "time" "github.com/yetone/magpie/internal/filememo" @@ -292,7 +293,26 @@ func Movable(id string) bool { return movers[id] != nil } // is listed by MoveCandidates with why, until it moves. The built-ins are // retired one by one, each with its code (the owner, 10-16: 陆续把内置 // Provider下线掉), so this is the set retired so far. -func BuiltinRetired(id string) bool { return Movable(id) && retiredBuiltins[id] } +func BuiltinRetired(id string) bool { + if id == "antigravity" && antigravityBuiltinForTest.Load() > 0 { + return false + } + return Movable(id) && retiredBuiltins[id] +} + +// antigravityBuiltinForTest counts the tests that serve the built-in +// Antigravity again (AntigravityBuiltinForTest). +var antigravityBuiltinForTest atomic.Int32 + +// AntigravityBuiltinForTest serves the built-in Antigravity again until the +// returned func runs. Its route has served nothing since it was retired on +// 11-15, and its code is still shared with Gemini CLI's: the tests of that +// route use this until the code is taken out (#6723). +func AntigravityBuiltinForTest() func() { + antigravityBuiltinForTest.Add(1) + var once sync.Once + return func() { once.Do(func() { antigravityBuiltinForTest.Add(-1) }) } +} // retiredBuiltins are the built-in subscriptions whose code is gone. var retiredBuiltins = map[string]bool{ @@ -309,6 +329,10 @@ var retiredBuiltins = map[string]bool{ "grok": true, "devin": true, CommandCodePlanID: true, + // Google bans accounts it sees on Code Assist through Antigravity's + // own client (the owner, 11-15): the plugin's 0.2.0 sends nothing and + // points to Antigravity (local agy CLI), which drives the user's agy + "antigravity": true, } // PluginServes is whether the built-in id's subscription is its plugin's to diff --git a/internal/provider/migrate_antigravity.go b/internal/provider/migrate_antigravity.go index a23bf3cf1..6f6e4edb9 100644 --- a/internal/provider/migrate_antigravity.go +++ b/internal/provider/migrate_antigravity.go @@ -16,11 +16,11 @@ import ( func init() { movers["antigravity"] = &mover{ pkg: "@magpie-community/opencode-antigravity-auth", - min: "0.1.18", // a variant at xhigh (Gemini 4 Hydrogen) is asked at xhigh (plugins#1169); 0.1.14: Gemini 4's late INVALID_ARGUMENT, a bare line in the stream, is asked again and says it isn't a region block (0.1.13 Codex's GPT-5 line reworded in a user's turn, 0.1.12 rewords instead of zero-width, 0.1.11 omp's "key words", 0.1.0 ported the built-in) + min: "0.2.0", // retired: sends nothing, points to Antigravity (local agy CLI) (owner, 11-15); 0.1.18 a variant at xhigh (Gemini 4 Hydrogen) is asked at xhigh (plugins#1169); 0.1.14: Gemini 4's late INVALID_ARGUMENT, a bare line in the stream, is asked again and says it isn't a region block (0.1.13 Codex's GPT-5 line reworded in a user's turn, 0.1.12 rewords instead of zero-width, 0.1.11 omp's "key words", 0.1.0 ported the built-in) agents: []string{"antigravity"}, out: func() ([]Moving, error) { var out []Moving - for _, l := range googleLogins("antigravity") { + for _, l := range googleSavedLogins("antigravity") { a := l.acct.auth if a.RefreshToken == "" { continue diff --git a/internal/provider/model_names_test.go b/internal/provider/model_names_test.go index 100678953..7a883547f 100644 --- a/internal/provider/model_names_test.go +++ b/internal/provider/model_names_test.go @@ -142,6 +142,7 @@ func TestPickedNamesAvoidCollisions(t *testing.T) { // Picking a subset must not refill names Available deliberately left as ids. // Unlisted picks still reserve all listed names and ids, even if not picked. func TestPickedNamesKeepListed(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route home := t.TempDir() t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config")) t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache")) diff --git a/internal/provider/modelprefs_test.go b/internal/provider/modelprefs_test.go index 29825f539..adef2f0cc 100644 --- a/internal/provider/modelprefs_test.go +++ b/internal/provider/modelprefs_test.go @@ -741,6 +741,7 @@ func TestUpstreamNameAsGivesAModelTheNameItWasGiven(t *testing.T) { // really went out — read against the family, every level of it reads as // another model answering. func TestSentNameInAsksForTheVariantTheEffortPicks(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route prefsHome(t) // Antigravity's ids of one model at three levels, as its fetch left them if err := os.MkdirAll(filepath.Dir(catalog.LivePath("antigravity")), 0o755); err != nil { @@ -785,6 +786,7 @@ func TestSentNameInAsksForTheVariantTheEffortPicks(t *testing.T) { // built by (codeAssistID) and the rule a ledger reads a record back against // are one rule, and these are the two ends of it. func TestSentNameInAsksAVariantIdForWhatTheEffortPicks(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route prefsHome(t) // one model at three levels, and one at two, so a family's default is // the top of it in one case and not the other @@ -841,6 +843,7 @@ func TestSentNameInAsksAVariantIdForWhatTheEffortPicks(t *testing.T) { // magpie knows, which is what the gateway's own dispatch (codeAssistID) reads // the same way. func TestSentNameIsJudgedByTheAccountAndNotByTheProviderId(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route prefsHome(t) if err := os.MkdirAll(filepath.Dir(catalog.LivePath("antigravity")), 0o755); err != nil { t.Fatal(err) diff --git a/internal/provider/plugin_usage_pool_test.go b/internal/provider/plugin_usage_pool_test.go index 77f29e314..aa7595e31 100644 --- a/internal/provider/plugin_usage_pool_test.go +++ b/internal/provider/plugin_usage_pool_test.go @@ -13,6 +13,7 @@ import ( // of text names them with their pool in place of the models' own, as the // built-in's quota did. func TestPluginWindowsKeepPoolAndFamily(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route week := float64(7 * 24 * 3600) q := quotaOfPlugin(SubscriptionQuota{Provider: "antigravity", User: "a@gmail.com"}, plugin.Usage{Windows: []plugin.UsageWindow{ {Name: "Gemini 3.8 Flash", Model: "gemini-3.8-flash", Family: "gemini", Pool: "Gemini", Used: fptr(20), Span: week}, diff --git a/internal/provider/quota_alert_test.go b/internal/provider/quota_alert_test.go index 94d375301..0d61d1a29 100644 --- a/internal/provider/quota_alert_test.go +++ b/internal/provider/quota_alert_test.go @@ -152,6 +152,7 @@ func TestCheckAlertsKeepsMarks(t *testing.T) { // window is what should be told of, once per pool and named with it — not // once for every model drawing on it, and not the 5-hour asides. func TestDueAlertsPoolWindows(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route now := time.Date(2026, 10, 1, 9, 0, 0, 0, time.UTC) reset := now.Add(48 * time.Hour) five, week := 5*time.Hour, 7*24*time.Hour @@ -203,6 +204,7 @@ func TestDueAlertsPoolWindows(t *testing.T) { // does, so its renewal is reminded of too. The pools' 5-hour asides say // nothing, as any 5-hour window does (#720: too often to be news). func TestDueRemindersPoolWeekly(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route now := time.Date(2026, 10, 1, 9, 0, 0, 0, time.UTC) soon := now.Add(20 * time.Hour) five, week := 5*time.Hour, 7*24*time.Hour diff --git a/internal/provider/quota_history_test.go b/internal/provider/quota_history_test.go index 339103237..a75ba5d28 100644 --- a/internal/provider/quota_history_test.go +++ b/internal/provider/quota_history_test.go @@ -211,6 +211,7 @@ func TestMergeQuotaHistory(t *testing.T) { // the models' windows still aren't. Another measured window set aside for // routing keeps its own line too (chowyuan1314, #4612). func TestQuotaHistoryKeepsAntigravityPools(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route testenv.SetHome(t, t.TempDir()) t.Setenv("XDG_CONFIG_HOME", t.TempDir()) t0 := time.Date(2026, 10, 27, 8, 0, 0, 0, time.UTC) diff --git a/internal/provider/quota_last_user_test.go b/internal/provider/quota_last_user_test.go index 53d32efbc..a1643b3d7 100644 --- a/internal/provider/quota_last_user_test.go +++ b/internal/provider/quota_last_user_test.go @@ -11,6 +11,7 @@ import ( // came back with the kept windows and no User, and 768 of 1,440 // Antigravity accounts each drew a card of its own on the Usage page). func TestAccountReadingNamed(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route t.Setenv("XDG_CONFIG_HOME", t.TempDir()) restart := func() { lastQuotas.Lock() diff --git a/internal/provider/quotas_dedupe_test.go b/internal/provider/quotas_dedupe_test.go index 65692fbf7..ed9fa80fa 100644 --- a/internal/provider/quotas_dedupe_test.go +++ b/internal/provider/quotas_dedupe_test.go @@ -108,6 +108,7 @@ func TestPlanLeftOutOfACopy(t *testing.T) { // place of the models' drawing on it (the shapes TestAntigravityQuotaPools // records): one span per pool window, the pool in its name. func TestQuotaReportPoolsAntigravity(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route now := time.Date(2026, 10, 1, 9, 0, 0, 0, time.UTC) reset := now.Add(48 * time.Hour) five, week := 5*time.Hour, 7*24*time.Hour diff --git a/internal/provider/signin_paste_test.go b/internal/provider/signin_paste_test.go index 407b69430..e40153c99 100644 --- a/internal/provider/signin_paste_test.go +++ b/internal/provider/signin_paste_test.go @@ -177,6 +177,7 @@ func TestPastedAddressAndCallbackFinishOnce(t *testing.T) { // bar doesn't offer it. Claude's is Claude Code's own (signin_claude_test.go); // Command Code's, whose key is posted, is its plugin's (TestLoopbackPorts). func TestLoopbackSignInsTakePastedAddress(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route claudeHome(t) fakeCodexTokens(t, nil) for _, agent := range []string{"codex", "gemini", "antigravity"} { diff --git a/internal/provider/signin_pasted_test.go b/internal/provider/signin_pasted_test.go index e9fdad284..99309ba52 100644 --- a/internal/provider/signin_pasted_test.go +++ b/internal/provider/signin_pasted_test.go @@ -81,6 +81,7 @@ func TestImportBoxFinishesAPastedClaudeCode(t *testing.T) { // What isn't a sign-in's end is left to import, and an address among // refresh tokens is never sent to the vendor as one. func TestImportTellsAddressesFromAccounts(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route for _, s := range []string{ `{"tokens":{"refresh_token":"rt_x"}}`, "rt_abc123", diff --git a/internal/provider/zeroed_1505_test.go b/internal/provider/zeroed_1505_test.go index c9af4450c..e3eb0ca5b 100644 --- a/internal/provider/zeroed_1505_test.go +++ b/internal/provider/zeroed_1505_test.go @@ -17,6 +17,7 @@ import ( // no accounts. Its last good generation, kept beside it, is read instead, // and the user told. func TestZeroedLoginsReadFromBackup(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route googleSandbox(t, &fakeGoogle{}) lastgood.Reset() t.Cleanup(lastgood.Reset) @@ -71,6 +72,7 @@ func TestZeroedLoginsReadFromBackup(t *testing.T) { // With no backup, a zeroed logins.json is copied aside before an account // added writes over it. func TestZeroedLoginsWithoutBackupKeptAside(t *testing.T) { + t.Cleanup(AntigravityBuiltinForTest()) // the retired built-in route googleSandbox(t, &fakeGoogle{}) lastgood.Reset() t.Cleanup(lastgood.Reset) diff --git a/site/public/docs/ja/subscriptions.html b/site/public/docs/ja/subscriptions.html index 8ace896d1..455582a1b 100644 --- a/site/public/docs/ja/subscriptions.html +++ b/site/public/docs/ja/subscriptions.html @@ -4,7 +4,7 @@