Files
plugins/packages/agent-agy/agy.agent.js
T
yetone 450279c4e0 agent-agy 0.1.0: Antigravity CLI (agy) as an agent plugin
The agent plugin magpie's built-in agy moves onto. It names agy's
settings.json, where magpie's models go beside the user's own
(merge: customModelsConfig.customModels), and how agy is started:
GEMINI_API_KEY and GOOGLE_GEMINI_BASE_URL from magpie's gateway and
--model, given by the agy function magpie puts in the user's shells.
own() lists the user's own custom models by their provider.

Run: bun test in packages/agent-agy (3 pass) and bun scripts/check.mjs
(ok) on mote. magpie's TestAgyPlugin, TestAgyHandedToPlugin and
TestAgyHandedOverUnwire load this file and pass against the magpie
change that reads launch, merge, effort, wsl and aliases. A magpie
without that change keeps agy its built-in's, so this package does
nothing there.
2026-11-11 03:46:52 +08:00

52 lines
2.0 KiB
JavaScript

// Antigravity CLI (agy) keeps its model in
// ~/.gemini/antigravity-cli/settings.json, and the models it can pick in
// customModelsConfig.customModels, each {apiProvider, modelName}. It takes
// 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
// `magpie agy run`, which gives agy GEMINI_API_KEY, GOOGLE_GEMINI_BASE_URL
// and --model while its model is one of magpie's.
export const agent = {
id: "agy",
name: "Antigravity CLI",
icon: "antigravity-color",
aliases: ["antigravity-cli"],
bin: "agy",
dir: "~/.gemini/antigravity-cli",
config: "~/.gemini/antigravity-cli/settings.json",
format: "json",
model: "model",
prefix: "magpie/",
launch: {
env: { GEMINI_API_KEY: "{key}", GOOGLE_GEMINI_BASE_URL: "{url}" },
model: "--model",
},
// magpie's models go in beside the user's own
merge: ["customModelsConfig.customModels"],
effort: true,
wsl: true,
}
const GEMINI = "API_PROVIDER_GOOGLE_GEMINI"
export function connect({ models }) {
const custom = {}
for (const m of models) custom[`magpie/${m.id}`] = { apiProvider: GEMINI, modelName: m.id }
return { modelProvider: "gemini", "customModelsConfig.customModels": custom }
}
// 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
export function own({ config, model }) {
const custom = config?.customModelsConfig?.customModels ?? {}
const out = []
for (const [k, v] of Object.entries(custom)) {
if (k.startsWith("magpie/")) continue
const p = String(v?.apiProvider ?? "")
const direct = p.includes("ANTHROPIC") ? "Anthropic" : p.includes("OPENAI") ? "OpenAI" : "Google"
out.push({ value: k, model: String(v?.modelName ?? k), direct })
}
out.sort((a, b) => (a.value < b.value ? -1 : a.value > b.value ? 1 : 0))
if (model && !(model in custom)) out.unshift({ value: model, model, direct: "Google" })
return out
}