antigravity: 2.30 reads its gateway from ~/.gemini/config/config.json; magpie writes both (YujunT46308 on X)
Antigravity 2.30.0 moved the Enterprise Gateway settings from ~/.antigravity/settings.json to ~/.gemini/config/config.json (same gateway/models schema, beside the app's userSettings and plugins). Each version reads only its own file and an update copies nothing across, so a wiring made for 2.29 left 2.30 off magpie, on every OS (the report was Windows). The AGY_LLM_GATEWAY_* variables and admin paths are unchanged. magpie now writes the same gateway block, listSource and defaultModelId into both files, each with its own stash, and puts each back on disconnect (config.json keeps userSettings/plugins; a config.json that isn't there is not created on disconnect). Sync carries a wiring made by an older magpie into config.json at the next start, at the level the wired file starts on. Check judges each file. Run: - Windows (xiaomi-gpu, real 2.30.0 per-user install, sandbox USERPROFILE/APPDATA): language_server.exe headless as the hub. With only settings.json wired (what magpie wrote before) it lists no models and never resolves a gateway catalog: the report reproduced. With this magpie.exe (serve, provider add, `antigravity magpie/up/g3`): config.json gets the block beside userSettings, the LS logs "Resolving models from Tier 2 (Remote catalog listSource: http://127.0.0.1:3640/v1/models" and GetAvailableModels returns up/g3. `antigravity default` gives config.json back as it was and settings.json as {}. - macOS (mote, real 2.30.0 language server headless): origin/main's magpie wires, then this tree's `magpie serve` syncs config.json, 2.30 resolves Tier 2 from it; off restores both files. - win-run go test -run ^TestAntigravity ./internal/agent: ok. - mote: go test ./internal/agent; -run Antigravity ./internal/gateway ./internal/gui; gofmt -l; go vet ./internal/agent; GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet ./...: all ok. Broken by hand: config.json left out of antigravityFiles -> TestAntigravityConfigJSON and TestAntigravitySyncWiresConfigJSON red; Sync not connecting an unwired file -> TestAntigravitySyncWiresConfigJSON red. Not tried: a chat turn from the real 2.30 GUI app (only its language server, headless); Linux's 2.30 build (same language server code path, same home-relative file); whether the agy CLI reads config.json (it has its own ~/.gemini/antigravity-cli/settings.json row, untouched).
This commit is contained in:
@@ -96,7 +96,7 @@ something else shows up as drift.
|
||||
- Kiro Crew (AWS's persistent agent: KiroCrew.app, the `kirocrew` CLI, its Gateway on :5476) has no model setting of its own: it runs every session on a harness over ACP, chosen by `agent.acp_backend` in `$KIROCREW_HOME/config.json` (default `~/.kiro/crew`; `""` is kiro-cli), and dispatched members by `agent.member_acp_backend` (`kirocrew` in [`kirocrew.go`](../../internal/agent/kirocrew.go); github.com/kirodotdev/KiroCrew v0.9.0, `src/kiro_crew/` `config/paths.py`, `config/loader.py`, `config/sections.py`, `agent_sdk/backends.py`). Connecting it sets both to an agent already connected to magpie (Codex, Claude Code, OpenCode, Pi or Goose; Pi can't take dispatch, so only the first key for it), preferring the one whose ACP adapter is installed (codex-acp, claude-agent-acp, pi-acp; looked for, never installed, and named in the notice when missing). When `agent.acp_backend` already names one of those five and that agent is installed but not connected, connecting Kiro Crew connects that agent too, in the same action, and runs Crew on it (wuping9525 on Windows: Crew on Claude Code, Claude Code not connected); the stash's `kirocrew.joined` records it, and Kiro Crew's Disconnect disconnects it again, unless the user disconnected it themselves since (`kiroCrewUserLeft` in `Agent.Disconnect`), and a disconnect the user had made before stays theirs. Otherwise, with none connected it refuses and says which to connect. On Windows the app is found by `~\.kirocrew-app\.venv\Scripts\kirocrew.exe` and an adapter also by npm's `.cmd`/`.exe` shim names. `config.local.json` is merged over `config.json` and wins, so a harness set there is the user's: magpie neither writes nor reads past it, and the row says so. The previous values are stashed and put back on Disconnect, only while each key still holds what magpie wrote; a file magpie made is removed when it is left empty. The row reads as connected only while the harness it names is still wired to magpie. Open sessions keep their harness; new ones take it.
|
||||
- OpenPencil (ZSeven-W/openpencil, the `openpencil-desktop` app) keeps the builtin agents its chat runs on in `settings.json` in Rust's `dirs::config_dir()` joined with `openpencil`: `~/Library/Application Support/openpencil` on a Mac, `$XDG_CONFIG_HOME` or `~/.config` on Linux, `%APPDATA%` on Windows (`openPencil` in [`openpencil.go`](../../internal/agent/openpencil.go); its `settings_io.rs` and `settings_payload.rs`). magpie adds one entry to `builtin_agents`, `id: magpie`, `kind: openai-compat` at the gateway's `/v1` with a key naming OpenPencil (its User-Agent isn't known), `preset: custom`, the picked models as OpenPencil writes a list: the first as `model`, `models` only for two or more, at most 64 (v0.8.4 reads `model` alone). The user's other entries and settings stay, and so do the `display_name` and `enabled` they give magpie's entry; a sync with nothing to change doesn't write. OpenPencil needs `"version": 1` (a file without it is set aside as corrupt and saving stops), so magpie writes it in a file it makes and leaves a file with any other version, or none, alone. Disconnect takes the entry out, and the file when only the version and an empty list are left. OpenPencil reads the file once at start and writes it back whole when it quits, so a change is refused while `openpencil-desktop` runs (Windows can't be asked, so the notice says to quit it first). The model is picked in OpenPencil's chat, so the field is whether magpie is in its picker (`ListsModels`). Detected by its settings folder, `~/.openpencil` (its CLI's), `OpenPencil.app` (`com.zseven-w.openpencil`), or `%ProgramFiles%\OpenPencil`. open-pencil/open-pencil, the other app of the name, keeps its providers in its webview's localStorage, so it is not a row: it reaches magpie through Pi or an ACP agent magpie wires.
|
||||
- OpenBot (nightly-labs/openbot, openbot.run; jiezhengj on Discord) keeps the OpenAI-compatible endpoints its model picker lists in `openbot-custom-providers-v1.json` in Electron's userData folder, app data joined with `OpenBot`: `~/Library/Application Support/OpenBot` on a Mac, `%APPDATA%\OpenBot` on Windows, `$XDG_CONFIG_HOME/OpenBot` or `~/.config/OpenBot` on Linux (`openBot` in [`openbot.go`](../../internal/agent/openbot.go); its `custom-provider-store.ts` and `opencode-config.ts`, v0.58.0). magpie adds one entry to `providers`, `id: magpie` at the gateway's `/v1` with `secret: null`: an entry's key and headers are one safeStorage ciphertext (the Keychain, DPAPI) that magpie doesn't open, so OpenBot hands the entry to OpenCode keyless, the gateway takes it as a request from this computer, and it counts as OpenCode's. OpenBot's list decoders fail closed (one entry or model it wouldn't take empties the list), so the models are the picked ones whose `magpie/<id>` OpenBot accepts (ASCII letters, digits and `._:/[],=-`, at most 160), at most 64, with a context window only inside 1,024 to 100,000,000. The user's other entries stay, and so do the `name`, `harness` and `secret` they give magpie's entry; a sync with nothing to change doesn't write. A file whose `version` isn't the number 1, or whose `providers` isn't a list, is one OpenBot itself refuses, so magpie leaves it alone. Disconnect takes the entry out, and the file when only the version and an empty list are left. OpenBot reads the file once at start and writes it whole only when an endpoint is saved, edited or removed there, so the notice (while it runs) says to restart it before doing that. The model is picked in OpenBot's picker (`ListsModels`). Detected by its userData folder, `OpenBot.app` (`app.openbot.desktop`), or `OpenBot.exe` under `%LOCALAPPDATA%\Programs` or `%ProgramFiles%`. Its MCP servers live in its SQLite database, which magpie doesn't write: magpie's `/mcp/magpie/…` servers are added there by hand as HTTP servers.
|
||||
- Antigravity, Google's desktop app (not Antigravity IDE, `com.google.antigravity-ide`), takes a gateway from `~/.antigravity/settings.json` from 2.15 on: Google's Antigravity Enterprise Gateway (docs.cloud.google.com/gemini/enterprise/docs/ai-developer-tools/connect-enterprise-gateway; `antigravity` in [`antigravity.go`](../../internal/agent/antigravity.go), ryougi_hachi on X). magpie writes `gateway` as `{enabled: true, url: <gateway>, apiKey: <key naming Antigravity>, wireProtocol: openai}` and the model it starts on as `models.defaultModelId`, and takes out `models.list`, which would narrow the picker to the user's own. It also points `models.listSource`, the app's remote model catalog, at `<gateway>/v1/models?format=antigravity` (`gateway.antigravityModels`): `{"list": [{modelId, displayName, maxTokens, maxOutputTokens, supportsImages, supportsThinking}]}`, the models the key may use. The backend (2.29.0) resolves models from `models.list`, then `listSource` (fetched with the gateway key), then `<url>/v1/models`, then its built-in catalog. From `/v1/models` it reads the id alone, and a model its catalog doesn't know gets its family's defaults, a 200K window whatever the model's, so every magpie model had 200K (YujunT46308 on X); `context_window`, `context_length` and `max_input_tokens` there are not read. A bare array or `{"list": …}` is read; `{"models": …}` is not. A field magpie doesn't know is left out and the app's default stands. The picker shows `displayName`, so the names follow magpie's (`ListsModels`, not `NoNames`). The app's picker (its `main.js`, 2.29.0) offers effort only by grouping entries named `<name> (Low)`, `(Medium)`, `(High)`, `(XHigh)` or `(Max)` (its regex also takes `(Low thinking)`) under one row with an effort menu, two levels or more, starting on medium when a group has it, else the lowest; a model listed once had no effort control at all (YujunT46308 on X). So a model with two or more of those levels is listed once a level, `<id>:<level>` named `<name> (<Level>)` (`antigravityLevels`), and the request goes out under the chosen entry's id, whose `:level` suffix the gateway sends upstream ahead of the row's pick; the app's own `reasoning_effort` (`low` whatever was chosen, in a 2.29.0 run) loses to it. `models.defaultModelId` names one of those entries, since an id the catalog doesn't list starts the app on its first model: `gateway.AntigravityModel` adds the row's effort, fitted, else medium, else the lowest. The row's effort sets that start level (and is what a model with fewer than two levels is asked for); `Sync` moves a file written before onto a level, keeping a level already there. The model field shows the id without the level.`Sync` adds `listSource` to a file wired before, at the gateway's current address, stashing one of the user's. On the openai protocol the backend streams `<url>/v1/chat/completions` with the key as a bearer token and a User-Agent of `antigravity/hub/<version>`. The user's gateway, default model, list and `listSource` are stashed and put back on disconnect, or when a model of their own is picked; `caCertPath` and the rest of the file are never touched, and a `Sync` keeps what the user added to magpie's block (`customHeaders`). On a gateway the app uses no Google sign-in, and its backend asks Google for nothing (no `cloud_code_endpoint` or `api_server_url` call in a headless run): Google's docs say a gateway and a Google Account can't be used at once. What Google's servers turn on for a signed-in account, its experiments and the commands behind them (`/boost`, `/teamwork`, `/plugin`, `/generative_ui`, YujunT46308), is off while it is on magpie. No key in the file keeps both (`proxy` only routes the app's own HTTP), so the notice shown on connecting names what is lost and that turning it off gives it back. An organisation's `admin_settings.json` and the `AGY_LLM_GATEWAY_*` variables win over the file, so `Check` says when either sets a gateway. agy reads the same file below its own settings: an agy connected on its own row keeps its route, one that isn't follows the app's gateway, as the notice says. `~/.antigravity` is Antigravity IDE's and agy's too, so the app is found by its bundle at 2.15 or later (`desktopApps`) or `~/.gemini/antigravity/agyhub_summaries_proto.pb`, which only its backend writes. The app reads the file at start, so the notice asks for a restart. The Antigravity accounts magpie signs in (provider `antigravity`) are a separate thing: those send magpie's requests to Google.
|
||||
- Antigravity, Google's desktop app (not Antigravity IDE, `com.google.antigravity-ide`), takes a gateway from `~/.antigravity/settings.json` from 2.15 on, and from `~/.gemini/config/config.json` (beside its `userSettings` and `plugins`) from 2.30 on, which reads only that file (YujunT46308 on X). magpie writes the same block into both, and a wiring made before 2.30 is carried into the new file at magpie's next start: Google's Antigravity Enterprise Gateway (docs.cloud.google.com/gemini/enterprise/docs/ai-developer-tools/connect-enterprise-gateway; `antigravity` in [`antigravity.go`](../../internal/agent/antigravity.go), ryougi_hachi on X). magpie writes `gateway` as `{enabled: true, url: <gateway>, apiKey: <key naming Antigravity>, wireProtocol: openai}` and the model it starts on as `models.defaultModelId`, and takes out `models.list`, which would narrow the picker to the user's own. It also points `models.listSource`, the app's remote model catalog, at `<gateway>/v1/models?format=antigravity` (`gateway.antigravityModels`): `{"list": [{modelId, displayName, maxTokens, maxOutputTokens, supportsImages, supportsThinking}]}`, the models the key may use. The backend (2.29.0) resolves models from `models.list`, then `listSource` (fetched with the gateway key), then `<url>/v1/models`, then its built-in catalog. From `/v1/models` it reads the id alone, and a model its catalog doesn't know gets its family's defaults, a 200K window whatever the model's, so every magpie model had 200K (YujunT46308 on X); `context_window`, `context_length` and `max_input_tokens` there are not read. A bare array or `{"list": …}` is read; `{"models": …}` is not. A field magpie doesn't know is left out and the app's default stands. The picker shows `displayName`, so the names follow magpie's (`ListsModels`, not `NoNames`). The app's picker (its `main.js`, 2.29.0) offers effort only by grouping entries named `<name> (Low)`, `(Medium)`, `(High)`, `(XHigh)` or `(Max)` (its regex also takes `(Low thinking)`) under one row with an effort menu, two levels or more, starting on medium when a group has it, else the lowest; a model listed once had no effort control at all (YujunT46308 on X). So a model with two or more of those levels is listed once a level, `<id>:<level>` named `<name> (<Level>)` (`antigravityLevels`), and the request goes out under the chosen entry's id, whose `:level` suffix the gateway sends upstream ahead of the row's pick; the app's own `reasoning_effort` (`low` whatever was chosen, in a 2.29.0 run) loses to it. `models.defaultModelId` names one of those entries, since an id the catalog doesn't list starts the app on its first model: `gateway.AntigravityModel` adds the row's effort, fitted, else medium, else the lowest. The row's effort sets that start level (and is what a model with fewer than two levels is asked for); `Sync` moves a file written before onto a level, keeping a level already there. The model field shows the id without the level.`Sync` adds `listSource` to a file wired before, at the gateway's current address, stashing one of the user's. On the openai protocol the backend streams `<url>/v1/chat/completions` with the key as a bearer token and a User-Agent of `antigravity/hub/<version>`. The user's gateway, default model, list and `listSource` are stashed and put back on disconnect, or when a model of their own is picked; `caCertPath` and the rest of the file are never touched, and a `Sync` keeps what the user added to magpie's block (`customHeaders`). On a gateway the app uses no Google sign-in, and its backend asks Google for nothing (no `cloud_code_endpoint` or `api_server_url` call in a headless run): Google's docs say a gateway and a Google Account can't be used at once. What Google's servers turn on for a signed-in account, its experiments and the commands behind them (`/boost`, `/teamwork`, `/plugin`, `/generative_ui`, YujunT46308), is off while it is on magpie. No key in the file keeps both (`proxy` only routes the app's own HTTP), so the notice shown on connecting names what is lost and that turning it off gives it back. An organisation's `admin_settings.json` and the `AGY_LLM_GATEWAY_*` variables win over the file, so `Check` says when either sets a gateway. agy reads the same file below its own settings: an agy connected on its own row keeps its route, one that isn't follows the app's gateway, as the notice says. `~/.antigravity` is Antigravity IDE's and agy's too, so the app is found by its bundle at 2.15 or later (`desktopApps`) or `~/.gemini/antigravity/agyhub_summaries_proto.pb`, which only its backend writes. The app reads the file at start, so the notice asks for a restart. The Antigravity accounts magpie signs in (provider `antigravity`) are a separate thing: those send magpie's requests to Google.
|
||||
- NewMax (newmax.cc, an Electron app on the Claude Agent SDK) keeps its settings as JSON in the row `app` of the `settings` table of `newmax.db`, a SQLite database in WAL mode in `$NEWMAX_USER_DATA_DIR`, else `~/.newmax` on every system (`newMax` in [`newmax.go`](../../internal/agent/newmax.go); its main bundle's `configureAppDataPaths`, `loadPersistedAppSettings` and the renderer's `mergeProviders`, v1.1.22). magpie adds one entry to `providers` in the shape NewMax's own import writes, `id: magpie-gateway` (its own preset is `magpie`, its import's ids hold `%3A`), `apiFormat: anthropic` at the gateway's root (NewMax appends `/v1/messages`) with `ANTHROPIC_AUTH_TOKEN` and a key naming NewMax, at most 20 models (`MAX_MODELS`) as `models` and `enabledModels` with their context windows, and its id at the end of `providerOrder`. The row is edited in place in one immediate transaction, so every other byte stays; the user's `name` and `enabled` for magpie's entry and the fields NewMax adds to it stay through a sync, and a sync with nothing to change doesn't write. A row that isn't a JSON object, or whose `providers` or `providerOrder` isn't a list, is left alone. With no row (NewMax at its defaults), magpie writes one with its entry alone, as NewMax lays its defaults and presets under the row; with no database yet, it asks to open NewMax once. Disconnect takes the entry and the id out, sets a pick of it back to `default`, and takes the row out when only what magpie made is left. NewMax holds its settings in memory and writes the whole row back whenever one changes, so a change is refused while `NewMax` (`newmax` on Linux) runs (Windows can't be asked, so the notice says to quit it first). The model is picked in NewMax's model picker, so the field is whether magpie is in it (`ListsModels`). Detected by its data folder or `NewMax.app` (`cc.newmax.desktop`).
|
||||
- LiveAgent (Stack-Cairn/LiveAgent v2, a Tauri app) runs its models through K-brain, a Go backend it starts with its data folder, which keeps every provider in `config.json` there: `$LIVEAGENT_HOME`, else `$K_BRAIN_HOME`, else the folder `~/.liveagent/data-dir.json` points to (`{"path": …}`, set when the user moves LiveAgent's data), else `~/.liveagent` on every system (`liveAgent` in [`liveagent.go`](../../internal/agent/liveagent.go); LiveAgent's `data_home.rs` and `kbrain_backend.rs`, K-brain v0.107.12's `internal/config`). The file is JSONC in Pi's provider shape, decoded with unknown fields refused, so magpie writes only K-brain's fields. K-brain asks all of a provider's models on its one API, so magpie writes up to three providers and puts each model on the one of the API it is served on natively (`catalog.Model.APIs`, as dsh's routes): `providers.magpie-responses` for Responses and `providers.magpie` for every other OpenAI-side model (Chat Completions), each `type: codex` with `api` and `requestFormat` as LiveAgent's own settings write an OpenAI-compatible provider, `baseUrl` the gateway's `/v1` (K-brain appends only `/chat/completions` or `/responses`); `providers.magpie-anthropic` for Messages, `type: claude_code` and `api: anthropic-messages`, `baseUrl` the gateway's root (K-brain appends `/v1` and posts to `/messages` with `X-Api-Key`). LiveAgent's settings lock an Anthropic provider's API and let the user switch an OpenAI one between Chat Completions and Responses; a sync keeps the format they picked (Discord, xiaoxiaofei). A provider left with no model is taken out. Each has a key naming LiveAgent, `activeModels: null` (every model on), magpie's order as `modelOrder`, and `models` sorted by id as K-brain writes them, with each one's display name, context window, output limit and `input: [text, image]` when it takes images. Comments and every other key stay. Through a sync the user's name for each entry, the models they turned off (`activeModels`), their order and the fields K-brain adds (its `metadata`) stay; a model that moves to another of magpie's providers (a `config.json` from before, with every model on one Anthropic `magpie`) brings its name and off with it, and a pick of it follows; a model new to magpie's list is on and goes last, and a sync with nothing to change doesn't write. A model of magpie's the user deleted in LiveAgent, or a whole provider of magpie's, stays out until they put it back or magpie is turned off and on for LiveAgent (zero2sin on Discord: every sync, so every restart, wrote magpie's twenty or thirty models back): magpie keeps, per `config.json`, which of its models and providers LiveAgent has had (`liveAgentKept`, in the stash). One magpie added while LiveAgent ran is pending under the processes then (`liveAgentPIDs`), since LiveAgent's next save drops a model it never read: missing under those processes, or after they quit, it is written again; once other processes run it counts as had. On Windows, which can't be asked what runs, each counts as had at once. A default (or compact) model still K-brain's own, `model1` of its endpoint-less `demo` provider, becomes magpie's first; one the user picked stays. A file K-brain wouldn't read as providers (not an object, `providers` not an object, a top-level `models`, one provider written bare) is left alone. Disconnect takes magpie's entries out and a pick of them back to K-brain's default; a file left with no provider gets K-brain's `demo` back, since K-brain takes one with none as written over and restores `config.json.bak`, which can still hold magpie's; a file with nothing but what magpie made goes. LiveAgent's backend makes the file as `{}` when there is none (so a disconnect that takes the file away is undone the next start, harmlessly), reads it when it starts and writes it whole whenever a setting changes, so a change is refused while `liveagent` or `k-brain` runs (Windows can't be asked, so the notice says to quit it first). A model id another provider of the user's lists too has its metadata shared by K-brain, so a sync may write that model's limits back each time. The model is picked in LiveAgent's model picker, so the field is whether magpie is in it (`ListsModels`). Detected by its data folder, `LiveAgent.app` (`com.xiaofei.liveagent`) or its Windows install. Its logo is the app's own 64px icon (`src-tauri/icons/64x64.png`, MIT) in an SVG.
|
||||
- DevEco Code (Huawei's OpenCode fork, #1885) is wired as OpenCode is (`deveco` in [`agents.go`](../../internal/agent/agents.go)): magpie's provider goes into the first of `deveco.jsonc`, `deveco.json` and `config.json` in `~/.config/deveco` (the one DevEco merges last, so the one that wins), or in `$DEVECO_CONFIG_DIR` when that is absolute, read after them. 0.2.3 sends `deveco/0.2.3 ai-sdk/…` to a provider of its config, but much of the OpenCode code it keeps still sends OpenCode's own User-Agent (`opencode/<version>`), so its provider's key is `magpie-deveco` (`openCodeKeyAt`), not the plain `magpie` OpenCode and MiMo Code send, and Check asks for that key. Its npm package has no Linux binary, so no install command is offered there (`cliSpec.only`).
|
||||
|
||||
+245
-108
@@ -1,8 +1,9 @@
|
||||
package agent
|
||||
|
||||
// Antigravity, Google's desktop app (2.15 and later), sends its requests to
|
||||
// a gateway of the user's instead of Google when ~/.antigravity/settings.json
|
||||
// turns one on: Google's Antigravity Enterprise Gateway, documented at
|
||||
// a gateway of the user's instead of Google when its settings file turns one
|
||||
// on (~/.antigravity/settings.json up to 2.29, ~/.gemini/config/config.json
|
||||
// from 2.30; antigravityFiles): Google's Antigravity Enterprise Gateway, documented at
|
||||
// docs.cloud.google.com/gemini/enterprise/docs/ai-developer-tools/connect-enterprise-gateway
|
||||
// (ryougi_hachi on X):
|
||||
//
|
||||
@@ -82,58 +83,207 @@ func antigravityAdmin() string {
|
||||
// antigravityAdminPath is antigravityAdmin, swapped by a test.
|
||||
var antigravityAdminPath = antigravityAdmin
|
||||
|
||||
func antigravity(home string) *Agent {
|
||||
dir := filepath.Join(home, ".antigravity")
|
||||
path := filepath.Join(dir, "settings.json")
|
||||
model := jsonGet(path, antigravityModel)
|
||||
stashGateway, stashModel, stashList := "antigravity:"+path+":gateway", "antigravity:"+path+":defaultModelId", "antigravity:"+path+":list"
|
||||
stashSource := "antigravity:" + path + ":listSource"
|
||||
// wired: the file's gateway is on and carries a key magpie gave it
|
||||
wired := func() bool {
|
||||
on, _ := edit.GetJSON(path, "gateway.enabled")
|
||||
key, _ := edit.GetJSON(path, "gateway.apiKey")
|
||||
return on == "true" && gatewayKey(key)
|
||||
// antigravityFiles are the files Antigravity's app takes its gateway from,
|
||||
// newest first: ~/.gemini/config/config.json from 2.30 on, where the app
|
||||
// also keeps its userSettings and plugins, and ~/.antigravity/settings.json
|
||||
// up to 2.29. Each version reads its own alone (2.30.0 and 2.29.0's
|
||||
// language servers, headless: a gateway in the other file goes unread and
|
||||
// the app asks for a Google sign-in), and an update moves nothing across,
|
||||
// so a file magpie wired for 2.29 left 2.30 off magpie (YujunT46308 on
|
||||
// X, Windows). magpie writes the same block into both.
|
||||
func antigravityFiles(home string) []string {
|
||||
return []string{
|
||||
filepath.Join(home, ".gemini", "config", "config.json"),
|
||||
filepath.Join(home, ".antigravity", "settings.json"),
|
||||
}
|
||||
gatewayBlock := func() map[string]any {
|
||||
return map[string]any{"enabled": true, "url": gateway.URL(), "apiKey": agentKey("antigravity"), "wireProtocol": "openai"}
|
||||
}
|
||||
|
||||
// agyFile is the wiring of one of antigravityFiles.
|
||||
type agyFile struct {
|
||||
path string
|
||||
stashGateway, stashModel, stashList, stashSrc string
|
||||
}
|
||||
|
||||
func newAgyFile(path string) agyFile {
|
||||
k := "antigravity:" + path + ":"
|
||||
return agyFile{path: path, stashGateway: k + "gateway", stashModel: k + "defaultModelId", stashList: k + "list", stashSrc: k + "listSource"}
|
||||
}
|
||||
|
||||
func (f agyFile) model() string { return jsonGet(f.path, antigravityModel)() }
|
||||
|
||||
// wired: the file's gateway is on and carries a key magpie gave it
|
||||
func (f agyFile) wired() bool {
|
||||
on, _ := edit.GetJSON(f.path, "gateway.enabled")
|
||||
key, _ := edit.GetJSON(f.path, "gateway.apiKey")
|
||||
return on == "true" && gatewayKey(key)
|
||||
}
|
||||
|
||||
func antigravityGateway() map[string]any {
|
||||
return map[string]any{"enabled": true, "url": gateway.URL(), "apiKey": agentKey("antigravity"), "wireProtocol": "openai"}
|
||||
}
|
||||
|
||||
// keepSource stashes a catalog of the user's that a file wired before
|
||||
// magpie wrote one holds, to come back with their gateway
|
||||
func (f agyFile) keepSource() {
|
||||
v, _ := edit.GetJSON(f.path, antigravitySource)
|
||||
if v != "" && !strings.Contains(v, "format="+gateway.AntigravityFormat) && unstashPeek(f.stashSrc) == "" {
|
||||
raw, _ := edit.GetJSONRaw(f.path, antigravitySource)
|
||||
stash(map[string]string{f.stashSrc: raw})
|
||||
}
|
||||
// keepSource stashes a catalog of the user's that a file wired before
|
||||
// magpie wrote one holds, to come back with their gateway
|
||||
keepSource := func() {
|
||||
v, _ := edit.GetJSON(path, antigravitySource)
|
||||
if v != "" && !strings.Contains(v, "format="+gateway.AntigravityFormat) && unstashPeek(stashSource) == "" {
|
||||
raw, _ := edit.GetJSONRaw(path, antigravitySource)
|
||||
stash(map[string]string{stashSource: raw})
|
||||
}
|
||||
}
|
||||
// startOn writes the model the app starts on, cur, at the level its
|
||||
// picker offers for want (the effort picked, "" for the row's), when
|
||||
// it is magpie's and the file is on magpie
|
||||
startOn := func(cur, want string) error {
|
||||
if cur == "" || !wired() {
|
||||
return nil
|
||||
}
|
||||
base, at := antigravityBase(cur), ""
|
||||
if want == "" {
|
||||
want = provider.AgentEffort("antigravity")
|
||||
if _, at = provider.MemberEffort(cur); at != "" {
|
||||
want = at // the level it starts on stays, if offered
|
||||
}
|
||||
}
|
||||
if !isMagpie(base) {
|
||||
return nil
|
||||
}
|
||||
if to := gateway.AntigravityModel(base, want); to != cur {
|
||||
return edit.SetJSON(path, edit.KV{Path: antigravityModel, Value: to})
|
||||
}
|
||||
}
|
||||
|
||||
// startOn writes the model the app starts on, cur, at the level its
|
||||
// picker offers for want (the effort picked, "" for the row's), when it
|
||||
// is magpie's and the file is on magpie
|
||||
func (f agyFile) startOn(cur, want string) error {
|
||||
if cur == "" || !f.wired() {
|
||||
return nil
|
||||
}
|
||||
// putRaw writes back what was stashed as it was, or takes key out
|
||||
putRaw := func(key, raw string) error {
|
||||
if raw == "" {
|
||||
return edit.DelJSON(path, key)
|
||||
base, at := antigravityBase(cur), ""
|
||||
if want == "" {
|
||||
want = provider.AgentEffort("antigravity")
|
||||
if _, at = provider.MemberEffort(cur); at != "" {
|
||||
want = at // the level it starts on stays, if offered
|
||||
}
|
||||
return edit.SetJSON(path, edit.KV{Path: key, Value: json.RawMessage(raw)})
|
||||
}
|
||||
if !isMagpie(base) {
|
||||
return nil
|
||||
}
|
||||
if to := gateway.AntigravityModel(base, want); to != cur {
|
||||
return edit.SetJSON(f.path, edit.KV{Path: antigravityModel, Value: to})
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// putRaw writes back what was stashed as it was, or takes key out
|
||||
func (f agyFile) putRaw(key, raw string) error {
|
||||
if raw == "" {
|
||||
return edit.DelJSON(f.path, key)
|
||||
}
|
||||
return edit.SetJSON(f.path, edit.KV{Path: key, Value: json.RawMessage(raw)})
|
||||
}
|
||||
|
||||
// connect puts the file on magpie's gateway, starting on ref (one of
|
||||
// magpie's models, "" to leave the model as it is), the user's gateway,
|
||||
// model, list and catalog stashed the first time
|
||||
func (f agyFile) connect(ref string) error {
|
||||
on := f.wired()
|
||||
if !on {
|
||||
g, _ := edit.GetJSONRaw(f.path, "gateway")
|
||||
m, _ := edit.GetJSONRaw(f.path, antigravityModel)
|
||||
l, _ := edit.GetJSONRaw(f.path, antigravityList)
|
||||
c, _ := edit.GetJSONRaw(f.path, antigravitySource)
|
||||
stash(map[string]string{f.stashGateway: g, f.stashModel: m, f.stashList: l, f.stashSrc: c})
|
||||
}
|
||||
// a list of the user's would hide magpie's models from the picker,
|
||||
// and it is read ahead of the catalog that gives each its window; it
|
||||
// is stashed with their gateway
|
||||
if err := edit.DelJSON(f.path, antigravityList); err != nil {
|
||||
return err
|
||||
}
|
||||
// set again on magpie, what the user added to its block stays
|
||||
block := any(antigravityGateway())
|
||||
if on {
|
||||
f.keepSource()
|
||||
block = theirsKept(f.path, "gateway", func() any { return antigravityGateway() })()
|
||||
}
|
||||
kv := []edit.KV{{Path: "gateway", Value: block}, {Path: antigravitySource, Value: antigravityCatalog()}}
|
||||
if ref != "" {
|
||||
kv = append(kv, edit.KV{Path: antigravityModel, Value: gateway.AntigravityModel(ref, provider.AgentEffort("antigravity"))})
|
||||
} else if !on {
|
||||
// a model of the user's own isn't one of the gateway's
|
||||
if err := edit.DelJSON(f.path, antigravityModel); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return edit.SetJSON(f.path, kv...)
|
||||
}
|
||||
|
||||
// leave takes the file off magpie onto v, a model of the user's own, or
|
||||
// what they had (""); a file not there is made for v only when always
|
||||
func (f agyFile) leave(v string, always bool) error {
|
||||
if f.wired() {
|
||||
// back to what the user had
|
||||
if err := f.putRaw("gateway", unstash(f.stashGateway)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := f.putRaw(antigravityList, unstash(f.stashList)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := f.putRaw(antigravitySource, unstash(f.stashSrc)); err != nil {
|
||||
return err
|
||||
}
|
||||
if v == "" {
|
||||
if err := f.putRaw(antigravityModel, unstash(f.stashModel)); err != nil {
|
||||
return err
|
||||
}
|
||||
return antigravityTidy(f.path)
|
||||
}
|
||||
forget(f.stashModel)
|
||||
} else if !always && !isFile(f.path) {
|
||||
// nothing of the user's to change, and no file to make for it
|
||||
return nil
|
||||
}
|
||||
if v == "" {
|
||||
if err := edit.DelJSON(f.path, antigravityModel); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if err := edit.SetJSON(f.path, edit.KV{Path: antigravityModel, Value: v}); err != nil {
|
||||
return err
|
||||
}
|
||||
return antigravityTidy(f.path)
|
||||
}
|
||||
|
||||
// sync brings a wired file's gateway and catalog to the gateway's current
|
||||
// address, and the model it starts on to a level the catalog lists
|
||||
func (f agyFile) sync() error {
|
||||
if err := syncJSON(f.path, "gateway", theirsKept(f.path, "gateway", func() any { return antigravityGateway() })); err != nil {
|
||||
return err
|
||||
}
|
||||
// the catalog at the gateway's address, and on a file wired before
|
||||
// magpie wrote one, so its windows reach it too
|
||||
if v, _ := edit.GetJSON(f.path, antigravitySource); v != antigravityCatalog() {
|
||||
f.keepSource()
|
||||
if err := edit.SetJSON(f.path, edit.KV{Path: antigravitySource, Value: antigravityCatalog()}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// the model it starts on as its catalog lists it now: a model with
|
||||
// levels is listed once a level, and an id the catalog doesn't list
|
||||
// starts the app on its first model instead
|
||||
return f.startOn(f.model(), "")
|
||||
}
|
||||
|
||||
func antigravity(home string) *Agent {
|
||||
paths := antigravityFiles(home)
|
||||
files := make([]agyFile, len(paths))
|
||||
for i, p := range paths {
|
||||
files[i] = newAgyFile(p)
|
||||
}
|
||||
legacy := files[len(files)-1]
|
||||
dir, path := filepath.Dir(legacy.path), legacy.path
|
||||
// on is the first file on magpie, the one the model is read from
|
||||
on := func() (agyFile, bool) {
|
||||
for _, f := range files {
|
||||
if f.wired() {
|
||||
return f, true
|
||||
}
|
||||
}
|
||||
return agyFile{}, false
|
||||
}
|
||||
wired := func() bool { _, ok := on(); return ok }
|
||||
// model is the model the app starts on: the wired file's, else the
|
||||
// first one's that names one
|
||||
model := func() string {
|
||||
if f, ok := on(); ok {
|
||||
return f.model()
|
||||
}
|
||||
for _, f := range files {
|
||||
if v := f.model(); v != "" {
|
||||
return v
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
return &Agent{
|
||||
ID: "antigravity", Name: "Antigravity", Icon: "antigravity-color", Aliases: []string{"antigravity-app", "agy-app"},
|
||||
@@ -159,24 +309,38 @@ func antigravity(home string) *Agent {
|
||||
return ""
|
||||
},
|
||||
Sync: func() error {
|
||||
if !wired() {
|
||||
w, ok := on()
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
if err := syncJSON(path, "gateway", theirsKept(path, "gateway", func() any { return gatewayBlock() })); err != nil {
|
||||
return err
|
||||
}
|
||||
// the catalog at the gateway's address, and on a file wired
|
||||
// before magpie wrote one, so its windows reach it too
|
||||
if v, _ := edit.GetJSON(path, antigravitySource); v != antigravityCatalog() {
|
||||
keepSource()
|
||||
if err := edit.SetJSON(path, edit.KV{Path: antigravitySource, Value: antigravityCatalog()}); err != nil {
|
||||
cur := w.model()
|
||||
for _, f := range files {
|
||||
if f.wired() {
|
||||
if err := f.sync(); err != nil {
|
||||
return err
|
||||
}
|
||||
continue
|
||||
}
|
||||
// a file wired by a magpie before it knew this one, or
|
||||
// for the app's other version: the same block in it, at
|
||||
// the level the wired file starts on
|
||||
ref := ""
|
||||
if b := antigravityBase(cur); isMagpie(b) {
|
||||
ref = b
|
||||
}
|
||||
if err := f.connect(ref); err != nil {
|
||||
return err
|
||||
}
|
||||
if ref != "" {
|
||||
if err := edit.SetJSON(f.path, edit.KV{Path: antigravityModel, Value: cur}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := f.startOn(f.model(), ""); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// the model it starts on as its catalog lists it now: a model
|
||||
// with levels is listed once a level, and an id the catalog
|
||||
// doesn't list starts the app on its first model instead
|
||||
return startOn(model(), "")
|
||||
return nil
|
||||
},
|
||||
Check: func() string {
|
||||
if !wired() {
|
||||
@@ -190,8 +354,13 @@ func antigravity(home string) *Agent {
|
||||
if u := os.Getenv("AGY_LLM_GATEWAY_URL"); u != "" && u != gateway.URL() {
|
||||
return noticeAntigravityEnv.say("url", u)
|
||||
}
|
||||
return wiringOff("Antigravity", path, func(k string) (string, bool) { return edit.GetJSON(path, "gateway."+k) },
|
||||
"url", gateway.URL(), "apiKey", agentKey("antigravity"))
|
||||
for _, f := range files {
|
||||
if s := wiringOff("Antigravity", f.path, func(k string) (string, bool) { return edit.GetJSON(f.path, "gateway."+k) },
|
||||
"url", gateway.URL(), "apiKey", agentKey("antigravity")); s != "" {
|
||||
return s
|
||||
}
|
||||
}
|
||||
return ""
|
||||
},
|
||||
Fields: []Field{{
|
||||
Key: "model", Label: "model",
|
||||
@@ -203,57 +372,20 @@ func antigravity(home string) *Agent {
|
||||
return model()
|
||||
},
|
||||
Set: func(v string) error {
|
||||
on := wired()
|
||||
if ref, ok := strings.CutPrefix(v, magpieID+"/"); ok && isMagpie(ref) {
|
||||
if !on {
|
||||
g, _ := edit.GetJSONRaw(path, "gateway")
|
||||
m, _ := edit.GetJSONRaw(path, antigravityModel)
|
||||
l, _ := edit.GetJSONRaw(path, antigravityList)
|
||||
c, _ := edit.GetJSONRaw(path, antigravitySource)
|
||||
stash(map[string]string{stashGateway: g, stashModel: m, stashList: l, stashSource: c})
|
||||
}
|
||||
// a list of the user's would hide magpie's models from
|
||||
// the picker, and it is read ahead of the catalog that
|
||||
// gives each its window; it is stashed with their gateway
|
||||
if err := edit.DelJSON(path, antigravityList); err != nil {
|
||||
return err
|
||||
}
|
||||
// set again on magpie, what the user added to its block stays
|
||||
block := any(gatewayBlock())
|
||||
if on {
|
||||
keepSource()
|
||||
block = theirsKept(path, "gateway", func() any { return gatewayBlock() })()
|
||||
}
|
||||
return edit.SetJSON(path, edit.KV{Path: "gateway", Value: block}, edit.KV{Path: antigravityModel, Value: gateway.AntigravityModel(ref, provider.AgentEffort("antigravity"))},
|
||||
edit.KV{Path: antigravitySource, Value: antigravityCatalog()})
|
||||
}
|
||||
if on {
|
||||
// back to what the user had
|
||||
if err := putRaw("gateway", unstash(stashGateway)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := putRaw(antigravityList, unstash(stashList)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := putRaw(antigravitySource, unstash(stashSource)); err != nil {
|
||||
return err
|
||||
}
|
||||
if v == "" {
|
||||
if err := putRaw(antigravityModel, unstash(stashModel)); err != nil {
|
||||
for _, f := range files {
|
||||
if err := f.connect(ref); err != nil {
|
||||
return err
|
||||
}
|
||||
return antigravityTidy(path)
|
||||
}
|
||||
forget(stashModel)
|
||||
return nil
|
||||
}
|
||||
if v == "" {
|
||||
if err := edit.DelJSON(path, antigravityModel); err != nil {
|
||||
for _, f := range files {
|
||||
if err := f.leave(v, f.path == legacy.path); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if err := edit.SetJSON(path, edit.KV{Path: antigravityModel, Value: v}); err != nil {
|
||||
return err
|
||||
}
|
||||
return antigravityTidy(path)
|
||||
return nil
|
||||
},
|
||||
Options: func(cur map[string]string) []Option {
|
||||
// the user's own model is Google's, on their sign-in, or their
|
||||
@@ -278,7 +410,12 @@ func antigravity(home string) *Agent {
|
||||
if err := provider.SetAgentEffort("antigravity", v); err != nil {
|
||||
return err
|
||||
}
|
||||
return startOn(model(), v)
|
||||
for _, f := range files {
|
||||
if err := f.startOn(f.model(), v); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
},
|
||||
Options: func(map[string]string) []Option {
|
||||
if !wired() {
|
||||
|
||||
@@ -442,3 +442,105 @@ func TestAntigravitySyncAddsCatalog(t *testing.T) {
|
||||
t.Errorf("the user's catalog lost: %s", readFile(path))
|
||||
}
|
||||
}
|
||||
|
||||
// antigravityConfig is ~/.gemini/config/config.json as Antigravity 2.30
|
||||
// writes it, with what the app keeps there besides a gateway.
|
||||
const antigravityConfig = `{
|
||||
"userSettings": {"remoteControlHostname": "mote-local-zero-void"},
|
||||
"plugins": {"github": {"enabled": true}}
|
||||
}
|
||||
`
|
||||
|
||||
// Antigravity 2.30 takes its gateway from ~/.gemini/config/config.json and
|
||||
// no longer reads ~/.antigravity/settings.json, which 2.29 alone reads
|
||||
// (YujunT46308 on X: on Windows 2.30.0 the app was off magpie). magpie
|
||||
// writes the same block into both, and turning it off leaves each as it
|
||||
// was.
|
||||
func TestAntigravityConfigJSON(t *testing.T) {
|
||||
home := antigravityHome(t)
|
||||
cfg := filepath.Join(home, ".gemini", "config", "config.json")
|
||||
legacy := filepath.Join(home, ".antigravity", "settings.json")
|
||||
os.MkdirAll(filepath.Dir(cfg), 0o755)
|
||||
os.WriteFile(cfg, []byte(antigravityConfig), 0o600)
|
||||
a := antigravity(home)
|
||||
f := a.Field("model")
|
||||
if err := f.Set("magpie/anth/claude-sonnet-5"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
want := map[string]any{"enabled": true, "url": gateway.URL(), "apiKey": agentKey("antigravity"), "wireProtocol": "openai"}
|
||||
models := map[string]any{"defaultModelId": "anth/claude-sonnet-5", "listSource": gateway.URL() + "/v1/models?format=antigravity"}
|
||||
for _, p := range []string{cfg, legacy} {
|
||||
file := antigravityFile(t, p)
|
||||
if !sameJSON(string(file["gateway"]), want) {
|
||||
t.Errorf("%s gateway: %s", p, file["gateway"])
|
||||
}
|
||||
if !sameJSON(string(file["models"]), models) {
|
||||
t.Errorf("%s models: %s", p, file["models"])
|
||||
}
|
||||
}
|
||||
file := antigravityFile(t, cfg)
|
||||
if !sameJSON(string(file["userSettings"]), map[string]any{"remoteControlHostname": "mote-local-zero-void"}) || file["plugins"] == nil {
|
||||
t.Errorf("what the app keeps in config.json changed:\n%s", readFile(cfg))
|
||||
}
|
||||
if c := a.Check(); c != "" {
|
||||
t.Errorf("check: %q", c)
|
||||
}
|
||||
if got := f.Get(); got != "magpie/anth/claude-sonnet-5" {
|
||||
t.Errorf("get: %q", got)
|
||||
}
|
||||
if err := f.Set(""); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !sameJSON(readFile(cfg), json.RawMessage(antigravityConfig)) {
|
||||
t.Errorf("config.json not as it was:\n%s", readFile(cfg))
|
||||
}
|
||||
if !sameJSON(readFile(legacy), map[string]any{}) {
|
||||
t.Errorf("settings.json left behind:\n%s", readFile(legacy))
|
||||
}
|
||||
}
|
||||
|
||||
// A settings.json a magpie before 2.30's file wired, beside the
|
||||
// config.json 2.30 wrote, gets the same block into config.json on the
|
||||
// next sync, at the level it starts on; turning it off then gives both
|
||||
// back.
|
||||
func TestAntigravitySyncWiresConfigJSON(t *testing.T) {
|
||||
home := antigravityHome(t)
|
||||
cfg := filepath.Join(home, ".gemini", "config", "config.json")
|
||||
legacy := filepath.Join(home, ".antigravity", "settings.json")
|
||||
old := `{"caCertPath":"/etc/ssl/certs/x.pem","gateway":{"enabled":true,"url":"` + gateway.URL() + `","apiKey":"` + agentKey("antigravity") + `","wireProtocol":"openai"},` +
|
||||
`"models":{"defaultModelId":"anth/claude-sonnet-5","listSource":"` + gateway.URL() + `/v1/models?format=antigravity"}}`
|
||||
os.MkdirAll(filepath.Dir(legacy), 0o755)
|
||||
os.WriteFile(legacy, []byte(old), 0o600)
|
||||
os.MkdirAll(filepath.Dir(cfg), 0o755)
|
||||
os.WriteFile(cfg, []byte(antigravityConfig), 0o600)
|
||||
a := antigravity(home)
|
||||
if err := a.Sync(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
file := antigravityFile(t, cfg)
|
||||
want := map[string]any{"enabled": true, "url": gateway.URL(), "apiKey": agentKey("antigravity"), "wireProtocol": "openai"}
|
||||
if !sameJSON(string(file["gateway"]), want) {
|
||||
t.Fatalf("config.json's gateway after sync: %s", readFile(cfg))
|
||||
}
|
||||
var m map[string]any
|
||||
json.Unmarshal(file["models"], &m)
|
||||
if m["defaultModelId"] != jsonGet(legacy, antigravityModel)() || m["listSource"] != antigravityCatalog() {
|
||||
t.Errorf("config.json's models: %s, settings.json's: %s", file["models"], antigravityFile(t, legacy)["models"])
|
||||
}
|
||||
before := readFile(cfg)
|
||||
if err := a.Sync(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if readFile(cfg) != before {
|
||||
t.Errorf("a second sync rewrote config.json:\n%s", readFile(cfg))
|
||||
}
|
||||
if err := a.Field("model").Set(""); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !sameJSON(readFile(cfg), json.RawMessage(antigravityConfig)) {
|
||||
t.Errorf("config.json not as it was:\n%s", readFile(cfg))
|
||||
}
|
||||
if !sameJSON(readFile(legacy), map[string]any{"caCertPath": "/etc/ssl/certs/x.pem"}) {
|
||||
t.Errorf("settings.json:\n%s", readFile(legacy))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user