daoche_wuzui on X asked how magpie serves Antigravity and whether a
request goes out under a suffixed model: nothing showed the id actually
sent. Antigravity's plugin turns gemini-3.7-flash at high effort into
gemini-3.7-flash-high, and a relay's upstream name (ModelWires) renames
a model too; the ledger and Routing showed only the routed model.
- A plugin's reply may carry X-Magpie-Sent-Model
(provider.SentModelHeader). forward() reads it from plugin providers
only (a non-plugin's header is ignored) and deletes it, so it never
reaches the agent. Without it, provider.SentNameOnIn (the upstream
name, or Antigravity's variant) is used.
- wireName keeps the id only when it differs from the model. It goes in
usage.Record.Wire (`wire`, omitempty), the trace's Try.Wire, the
ledger cache and a last CSV column, sent_model (docs/reference.md).
- Usage › Requests: the Sent cell and the detail show the sent id when
there is one, with "model → sent id" on hover. Routing: a try sent
under another id gets one aside line, "Sent to the vendor as {model}"
(zh, zh-TW, ja, de).
- Antigravity's mover min is 0.2.4: plugins 67fb1258 sets the header on
every reply (stream, whole and errors); its tgz is on the plugins
repo's dist branch.
Run at this head (ef997d186 + this), on mote:
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./...: ok.
- go test -tags nogui -count=1 -timeout 45m ./...: every package ok but
internal/gateway, red only in TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes,
red 5 of 5 alone at origin/main ef997d186 too (#7117, taken).
- GUI: the 46 files that reach the Usage ledger, Routing's tries and
i18n (i18n-*, ledger-*, usage-ledger-*, routing-try-fixed, sent-model
and the files that read the Sent cell or an aside): 230 ok; red only
aside-native (#6212) and usage-ledger-chart's remembered metric
(#6790), both red the same way at origin/main ef997d186. The whole
GUI suite (1609 files) was still running at push; its reds so far are
in account-arrange and the Codex lone-capped-account files.
- sent-model.test.cjs: 10/10, Chromium and WebKit, en zh zh-TW ja de.
- Plugin: bun test packages/antigravity 136 pass, check.mjs ok.
Rebased onto 593ea437d (three gateway/routing commits) before the push,
then again: gofmt; vet of gateway, usage and provider for darwin, linux
and windows; the new tests with the gateway's Wire, Ultrafast and Prefix
tests; sent-model and i18n-keys (14 pass): ok.
Broken by hand, each red:
- no noteWireModel call: TestPluginSentModelIsKept;
- the IsPlugin check removed: the spoofed-header case;
- no SentNameOnIn fallback: TestUpstreamNameSentIsKept;
- an id equal to the model kept: both tests;
- the old GUI assets: every sent-model case; the old usage page.js
alone: the Sent cell assertion;
- the plugin's old index.mjs: its new test (31 pass, 1 fail).
Not tried: a real Antigravity account (the plugin's header was tested
with its fake vendor only).
71 lines
2.8 KiB
Go
71 lines
2.8 KiB
Go
package provider
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
// Antigravity's accounts on @magpie-community/opencode-antigravity-auth:
|
|
// the plugin keeps a Google sign-in as an oauth entry whose refresh is
|
|
// "<refresh token>|<project>", with the access token and its expiry beside
|
|
// it and the email as its accountId. An account the built-in had no
|
|
// project for yet goes with none, and the plugin asks Code Assist for it
|
|
// (loadCodeAssist, onboardUser) as the built-in did.
|
|
func init() {
|
|
movers["antigravity"] = &mover{
|
|
pkg: "@magpie-community/opencode-antigravity-auth",
|
|
min: "0.2.4", // 0.2.4 says the id a request went out under (x-magpie-sent-model), the variant the effort picked, for the ledger and Routing; 0.2.3 Claude Code's identity line goes as "You're …" (#1151); 0.2.1 serves again as 0.1.18 did, for the users who have it, and is withdrawn for anyone new (plugin.WithdrawnOf; owner, 11-15: 正在使用的继续正常,加个提示,新用户不让下载); 0.2.0 retired it, sending nothing; 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 googleSavedLogins("antigravity") {
|
|
a := l.acct.auth
|
|
if a.RefreshToken == "" {
|
|
continue
|
|
}
|
|
out = append(out, Moving{User: l.User, First: l.Active, On: l.On, Lapsed: l.Lapsed != "", Plan: l.Plan, Auth: map[string]any{
|
|
"type": "oauth",
|
|
"refresh": a.RefreshToken + "|" + a.Project,
|
|
"access": a.AccessToken,
|
|
"expires": a.Expiry,
|
|
"accountId": l.User,
|
|
}})
|
|
}
|
|
return out, nil
|
|
},
|
|
back: func(ls []savedLogin, user string, auth map[string]any) ([]savedLogin, string, error) {
|
|
rt, project, _ := strings.Cut(str(auth["refresh"]), "|")
|
|
if rt == "" {
|
|
return ls, "", errors.New("Antigravity: an unreadable plugin sign-in")
|
|
}
|
|
if user == "" {
|
|
user = str(auth["accountId"])
|
|
}
|
|
if user == "" {
|
|
return ls, "", errors.New("Antigravity: a plugin sign-in with no account")
|
|
}
|
|
i := backInto(&ls, "antigravity", user)
|
|
var a googleAuth
|
|
_ = json.Unmarshal(ls[i].Auth, &a)
|
|
a.RefreshToken, a.AccessToken = rt, str(auth["access"])
|
|
if e, ok := auth["expires"].(float64); ok {
|
|
a.Expiry = int64(e)
|
|
}
|
|
if project != "" {
|
|
a.Project = project
|
|
}
|
|
b, err := json.Marshal(a)
|
|
if err != nil {
|
|
return ls, "", err
|
|
}
|
|
ls[i].Auth, ls[i].Lapsed, ls[i].Refused, ls[i].Seen = b, "", "", time.Now().UTC().Truncate(time.Second)
|
|
if project != "" {
|
|
ls[i].Project = project
|
|
}
|
|
return ls, ls[i].User, nil
|
|
},
|
|
}
|
|
}
|