agent-agy 0.2.0: magpie's own settings file, passed with --settings
As magpie's built-in agy does since 0cc91af3d: the plugin's config is ~/.gemini/antigravity-cli/magpie-settings.json, handed to agy with --settings, and agy's own settings.json is only read (base) for the user's own model and custom models. remote-control runs plain, as agy is. Needs magpie with agentplug's base, launch.args and launch.plain. Run: bun test packages/agent-agy (4 pass, on mote), and magpie's internal/agent TestAgyPlugin against this file.
This commit is contained in:
@@ -6,8 +6,9 @@
|
|||||||
magpie plugin add @magpie-community/agent-agy
|
magpie plugin add @magpie-community/agent-agy
|
||||||
```
|
```
|
||||||
|
|
||||||
Pick one of magpie's models in the Antigravity CLI row. magpie writes into
|
Pick one of magpie's models in the Antigravity CLI row. magpie writes a file
|
||||||
`~/.gemini/antigravity-cli/settings.json`:
|
of its own, `~/.gemini/antigravity-cli/magpie-settings.json`, and leaves
|
||||||
|
your `settings.json` alone:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
@@ -21,16 +22,18 @@ Pick one of magpie's models in the Antigravity CLI row. magpie writes into
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Your own custom models stay beside magpie's. agy takes the address and key
|
Your own custom models from `settings.json` are carried in beside magpie's.
|
||||||
of a Gemini endpoint only from how it is started, so magpie adds a function
|
agy takes the address and key of a Gemini endpoint only from how it is
|
||||||
`agy` to your shells' profiles: it runs `magpie agy run`, which starts the
|
started, so magpie adds a function `agy` to your shells' profiles: it runs
|
||||||
agy on your PATH with `GEMINI_API_KEY`, `GOOGLE_GEMINI_BASE_URL` and
|
`magpie agy run`, which starts the agy on your PATH with `GEMINI_API_KEY`,
|
||||||
`--model` while its model is one of magpie's, and as it is otherwise.
|
`GOOGLE_GEMINI_BASE_URL`, `--settings magpie-settings.json` and `--model`
|
||||||
|
while its model is one of magpie's, and as it is otherwise.
|
||||||
|
`agy remote-control` always runs as it is, on your Google sign-in.
|
||||||
`magpie agy env` prints what it starts agy with.
|
`magpie agy env` prints what it starts agy with.
|
||||||
|
|
||||||
Picking agy's own model again, or switching it off, puts every key back as
|
Picking agy's own model again, or switching it off, takes
|
||||||
it was and takes the function out. agy in a WSL distro is set up the same
|
`magpie-settings.json` and the function away. agy in a WSL distro is set up
|
||||||
way, from Windows.
|
the same way, from Windows.
|
||||||
|
|
||||||
This plugin takes the place of the Antigravity CLI magpie shipped with: what
|
This plugin takes the place of the Antigravity CLI magpie shipped with: what
|
||||||
that one set up is handed over as it is.
|
that one set up is handed over as it is.
|
||||||
|
|||||||
@@ -1,10 +1,19 @@
|
|||||||
// Antigravity CLI (agy) keeps its model in
|
// Antigravity CLI (agy) keeps its settings in
|
||||||
// ~/.gemini/antigravity-cli/settings.json, and the models it can pick in
|
// ~/.gemini/antigravity-cli/settings.json, and the models it can pick in
|
||||||
// customModelsConfig.customModels, each {apiProvider, modelName}. It takes
|
// customModelsConfig.customModels, each {apiProvider, modelName}. It takes
|
||||||
// the address and key of a Gemini endpoint only from how it is started,
|
// the address and key of a Gemini endpoint only from how it is started,
|
||||||
// so magpie starts it: the function agy magpie puts in your shells runs
|
// so magpie starts it: the function agy magpie puts in your shells runs
|
||||||
// `magpie agy run`, which gives agy GEMINI_API_KEY, GOOGLE_GEMINI_BASE_URL
|
// `magpie agy run`, which gives agy GEMINI_API_KEY, GOOGLE_GEMINI_BASE_URL,
|
||||||
// and --model while its model is one of magpie's.
|
// --settings magpie-settings.json and --model while its model is one of
|
||||||
|
// magpie's.
|
||||||
|
//
|
||||||
|
// magpie writes only magpie-settings.json, a file of its own beside
|
||||||
|
// settings.json, which agy reads for the one session started with
|
||||||
|
// --settings: "modelProvider": "gemini" in settings.json would make every
|
||||||
|
// agy an API-key session, with no Google account and so no remote
|
||||||
|
// control. agy takes customModels whole from that file, so the user's own
|
||||||
|
// custom models are carried into it beside magpie's. remote-control runs
|
||||||
|
// as agy is, on the user's sign-in.
|
||||||
export const agent = {
|
export const agent = {
|
||||||
id: "agy",
|
id: "agy",
|
||||||
name: "Antigravity CLI",
|
name: "Antigravity CLI",
|
||||||
@@ -12,32 +21,42 @@ export const agent = {
|
|||||||
aliases: ["antigravity-cli"],
|
aliases: ["antigravity-cli"],
|
||||||
bin: "agy",
|
bin: "agy",
|
||||||
dir: "~/.gemini/antigravity-cli",
|
dir: "~/.gemini/antigravity-cli",
|
||||||
config: "~/.gemini/antigravity-cli/settings.json",
|
config: "~/.gemini/antigravity-cli/magpie-settings.json",
|
||||||
|
base: "~/.gemini/antigravity-cli/settings.json",
|
||||||
format: "json",
|
format: "json",
|
||||||
model: "model",
|
model: "model",
|
||||||
prefix: "magpie/",
|
prefix: "magpie/",
|
||||||
launch: {
|
launch: {
|
||||||
env: { GEMINI_API_KEY: "{key}", GOOGLE_GEMINI_BASE_URL: "{url}" },
|
env: { GEMINI_API_KEY: "{key}", GOOGLE_GEMINI_BASE_URL: "{url}" },
|
||||||
model: "--model",
|
model: "--model",
|
||||||
|
args: { "--settings": "{config}" },
|
||||||
|
plain: ["remote-control", "--remote-control", "-remote-control"],
|
||||||
},
|
},
|
||||||
// magpie's models go in beside the user's own
|
|
||||||
merge: ["customModelsConfig.customModels"],
|
|
||||||
effort: true,
|
effort: true,
|
||||||
wsl: true,
|
wsl: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
const GEMINI = "API_PROVIDER_GOOGLE_GEMINI"
|
const GEMINI = "API_PROVIDER_GOOGLE_GEMINI"
|
||||||
|
|
||||||
export function connect({ models }) {
|
// the user's own custom models, from settings.json
|
||||||
const custom = {}
|
const ownModels = (base) => {
|
||||||
|
const out = {}
|
||||||
|
for (const [k, v] of Object.entries(base?.customModelsConfig?.customModels ?? {})) {
|
||||||
|
if (!k.startsWith("magpie/")) out[k] = v
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
export function connect({ models, base }) {
|
||||||
|
const custom = ownModels(base)
|
||||||
for (const m of models) custom[`magpie/${m.id}`] = { apiProvider: GEMINI, modelName: m.id }
|
for (const m of models) custom[`magpie/${m.id}`] = { apiProvider: GEMINI, modelName: m.id }
|
||||||
return { modelProvider: "gemini", "customModelsConfig.customModels": custom }
|
return { modelProvider: "gemini", "customModelsConfig.customModels": custom }
|
||||||
}
|
}
|
||||||
|
|
||||||
// the user's own models, which go to their provider rather than through
|
// the user's own models, which go to their provider rather than through
|
||||||
// magpie, and the one agy is on when it isn't listed
|
// magpie, and the one agy is on when it isn't listed
|
||||||
export function own({ config, model }) {
|
export function own({ base, model }) {
|
||||||
const custom = config?.customModelsConfig?.customModels ?? {}
|
const custom = base?.customModelsConfig?.customModels ?? {}
|
||||||
const out = []
|
const out = []
|
||||||
for (const [k, v] of Object.entries(custom)) {
|
for (const [k, v] of Object.entries(custom)) {
|
||||||
if (k.startsWith("magpie/")) continue
|
if (k.startsWith("magpie/")) continue
|
||||||
|
|||||||
@@ -4,13 +4,35 @@ import { agent, connect, own } from "./agy.agent.js"
|
|||||||
test("says where agy keeps its model, and how it is started", () => {
|
test("says where agy keeps its model, and how it is started", () => {
|
||||||
expect(agent).toMatchObject({
|
expect(agent).toMatchObject({
|
||||||
id: "agy",
|
id: "agy",
|
||||||
config: "~/.gemini/antigravity-cli/settings.json",
|
config: "~/.gemini/antigravity-cli/magpie-settings.json",
|
||||||
|
base: "~/.gemini/antigravity-cli/settings.json",
|
||||||
format: "json",
|
format: "json",
|
||||||
model: "model",
|
model: "model",
|
||||||
prefix: "magpie/",
|
prefix: "magpie/",
|
||||||
bin: "agy",
|
bin: "agy",
|
||||||
launch: { env: { GEMINI_API_KEY: "{key}", GOOGLE_GEMINI_BASE_URL: "{url}" }, model: "--model" },
|
launch: {
|
||||||
merge: ["customModelsConfig.customModels"],
|
env: { GEMINI_API_KEY: "{key}", GOOGLE_GEMINI_BASE_URL: "{url}" },
|
||||||
|
model: "--model",
|
||||||
|
args: { "--settings": "{config}" },
|
||||||
|
plain: ["remote-control", "--remote-control", "-remote-control"],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
expect(agent.merge).toBeUndefined()
|
||||||
|
})
|
||||||
|
|
||||||
|
test("carries the user's own custom models from settings.json beside magpie's", () => {
|
||||||
|
const base = {
|
||||||
|
customModelsConfig: {
|
||||||
|
customModels: {
|
||||||
|
"my-claude": { apiProvider: "API_PROVIDER_ANTHROPIC", modelName: "claude-sonnet-4-5" },
|
||||||
|
"magpie/old": { apiProvider: "API_PROVIDER_GOOGLE_GEMINI", modelName: "old" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
const out = connect({ model: { id: "deepseek/pro" }, models: [{ id: "deepseek/pro" }], base })
|
||||||
|
expect(out["customModelsConfig.customModels"]).toEqual({
|
||||||
|
"my-claude": { apiProvider: "API_PROVIDER_ANTHROPIC", modelName: "claude-sonnet-4-5" },
|
||||||
|
"magpie/deepseek/pro": { apiProvider: "API_PROVIDER_GOOGLE_GEMINI", modelName: "deepseek/pro" },
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -30,7 +52,7 @@ test("lists magpie's models as agy's Gemini models", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test("the user's own models go to their own provider", () => {
|
test("the user's own models go to their own provider", () => {
|
||||||
const config = {
|
const base = {
|
||||||
customModelsConfig: {
|
customModelsConfig: {
|
||||||
customModels: {
|
customModels: {
|
||||||
"magpie/deepseek/pro": { apiProvider: "API_PROVIDER_GOOGLE_GEMINI", modelName: "deepseek/pro" },
|
"magpie/deepseek/pro": { apiProvider: "API_PROVIDER_GOOGLE_GEMINI", modelName: "deepseek/pro" },
|
||||||
@@ -39,11 +61,11 @@ test("the user's own models go to their own provider", () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
expect(own({ config, model: "gemini-3-pro" })).toEqual([
|
expect(own({ base, model: "gemini-3-pro" })).toEqual([
|
||||||
{ value: "gemini-3-pro", model: "gemini-3-pro", direct: "Google" },
|
{ value: "gemini-3-pro", model: "gemini-3-pro", direct: "Google" },
|
||||||
{ value: "my-claude", model: "claude-sonnet-4-5", direct: "Anthropic" },
|
{ value: "my-claude", model: "claude-sonnet-4-5", direct: "Anthropic" },
|
||||||
{ value: "my-gpt", model: "gpt-5", direct: "OpenAI" },
|
{ value: "my-gpt", model: "gpt-5", direct: "OpenAI" },
|
||||||
])
|
])
|
||||||
expect(own({ config, model: "my-gpt" }).map((o) => o.value)).toEqual(["my-claude", "my-gpt"])
|
expect(own({ base, model: "my-gpt" }).map((o) => o.value)).toEqual(["my-claude", "my-gpt"])
|
||||||
expect(own({ config: {}, model: "" })).toEqual([])
|
expect(own({ base: {}, model: "" })).toEqual([])
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@magpie-community/agent-agy",
|
"name": "@magpie-community/agent-agy",
|
||||||
"version": "0.1.0",
|
"version": "0.2.0",
|
||||||
"description": "Antigravity CLI (agy) as a magpie agent: pick one of magpie's models for it on the Agents page, and agy starts on magpie's gateway",
|
"description": "Antigravity CLI (agy) as a magpie agent: pick one of magpie's models for it on the Agents page, and agy starts on magpie's gateway",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"files": ["agy.agent.js", "README.md"],
|
"files": ["agy.agent.js", "README.md"],
|
||||||
|
|||||||
Reference in New Issue
Block a user