diff --git a/packages/agy-cli/index.mjs b/packages/agy-cli/index.mjs index da783c8..c83f7cb 100644 --- a/packages/agy-cli/index.mjs +++ b/packages/agy-cli/index.mjs @@ -610,7 +610,29 @@ function modelFamilyId(model) { return model.id.slice(0, -(model.effort.length + 1)) } +// Orchestrator pairs a planner (Carbon or Argon) with Gemini 4 Hydrogen, +// which applies edits and runs builds with agy's own tools. The bridge's agent +// has only the client's tools (tools: [] in agentDefinition), so the handoff +// can't happen here and an Orchestrator turn is its planner alone, at a fixed +// thinking level. It isn't listed, and a request naming it is told which +// model it would really get. +function isOrchestrator(model) { + const id = typeof model === "string" ? model : model?.id ?? "" + const name = typeof model === "string" ? "" : model?.name ?? "" + return /^gemini-[a-z0-9.]*-?orchestrator/i.test(id) || /^Orchestrator\b/i.test(name) +} + +function orchestratorPlanner(id) { + return /argon|g1-pro/i.test(id) ? "gemini-4-argon" : "gemini-4-carbon" +} + +function orchestratorRefusal(id) { + const planner = orchestratorPlanner(id) + return `agy bridge: ${id} (Orchestrator) is not served: its Gemini 4 Hydrogen handoff needs agy's own tools, which the bridge leaves to your client, so it would run as ${planner} alone. Choose ${planner}, or gemini-4-hydrogen, with the effort you want.` +} + function buildModelCatalog(list) { + list = list.filter(model => !isOrchestrator(model)) const rawIds = new Set(list.map(model => model.id)) const families = new Map() for (const model of list) { @@ -840,6 +862,13 @@ function modelLimits(id) { // Gemini 4 Carbon (Ultra plans): the numbers Antigravity's own model list gives it if (/^gemini-4-carbon$/i.test(family)) return { context: 1048576, output: 262144 } if (/^claude-(?:opus|sonnet)-5-5$/i.test(family)) return { context: 1000000, output: 64000 } + // Antigravity's own model list (internal/provider/testdata/antigravity-models-2026-10-20.json + // in magpie): maxTokens/maxOutputTokens + if (/^claude-(?:sonnet-4-6|opus-4-6)(?:-thinking)?$/i.test(family)) return { context: 250000, output: 64000 } + if (/^gemini-3\.5-flash$/i.test(family)) return { context: 1048576, output: 65536 } + if (/^gemini-3\.1-flash-lite$/i.test(family)) return { context: 1048576, output: 65535 } + // Gemini 4 Hydrogen: Google's own API listing (models.dev's google provider) + if (/^gemini-4-hydrogen$/i.test(family)) return { context: 1048576, output: 65536 } if (/^gpt-oss-120b$/i.test(family)) return { context: 131072, output: 32768 } return undefined } @@ -6333,6 +6362,7 @@ export const AntigravityBridgePlugin = async () => { // derives a key, instructions or history from the body. const layout = requestLayout(body) body = { ...canonicalBody(body), model: requestedModel } + if (isOrchestrator(requestedModel)) return jsonError(400, orchestratorRefusal(requestedModel), undefined, { noRetry: true }) const model = resolveAgyModel(await loadModelCatalog(agy), requestedModel, body) const selection = { model: requestedModel, effort: requestedEffort(body) } // an account's conversations are its own: its agy has them diff --git a/packages/agy-cli/package.json b/packages/agy-cli/package.json index 63221f8..b3a761b 100644 --- a/packages/agy-cli/package.json +++ b/packages/agy-cli/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-agy-cli-auth", - "version": "0.1.71", + "version": "0.1.72", "description": "Magpie/OpenCode model provider that connects your local agy CLI through the Agent Client Protocol (agy acp), so Antigravity subscription models run through the real CLI", "type": "module", "main": "./opencode.mjs", diff --git a/packages/agy-cli/test/catalog.mjs b/packages/agy-cli/test/catalog.mjs index c961439..45b042e 100644 --- a/packages/agy-cli/test/catalog.mjs +++ b/packages/agy-cli/test/catalog.mjs @@ -450,6 +450,41 @@ test("Gemini 4 Carbon(Ultra):会话开放就列出,limit 是 Antigravity }) }) +// @jiangnan_ (X, agy 1.5.9): Orchestrator through the bridge is its planner +// alone, since the Hydrogen handoff needs agy's own tools (tools: []). +const ORCH_ROWS = [ + ["gemini-4-carbon-high", "Gemini 4 Carbon (High)"], ["gemini-4-carbon-medium", "Gemini 4 Carbon (Medium)"], ["gemini-4-carbon-low", "Gemini 4 Carbon (Low)"], + ["gemini-4-argon-high", "Gemini 4 Argon (High)"], ["gemini-4-argon-low", "Gemini 4 Argon (Low)"], + ["gemini-4-hydrogen-high", "Gemini 4 Hydrogen (High)"], ["gemini-4-hydrogen-xhigh", "Gemini 4 Hydrogen (XHigh)"], + ["gemini-4-hydrogen-medium", "Gemini 4 Hydrogen (Medium)"], ["gemini-4-hydrogen-low", "Gemini 4 Hydrogen (Low)"], + ["gemini-pro-orchestrator", "Orchestrator (Carbon)"], ["gemini-pro-orchestrator-g1-pro", "Orchestrator (Argon)"], + ["claude-sonnet-4-6", "Claude Sonnet 4.6 (Thinking)"], ["claude-opus-4-6-thinking", "Claude Opus 4.6 (Thinking)"], +] + +test("Orchestrator 不列出,点名它的请求得 400 并指向它实际会跑的型号;Hydrogen 等有 limit", async () => { + await withKit({ modelsBehavior: { stdout: modelsOutput(ORCH_ROWS) }, offeredModels: ORCH_ROWS }, async (kit) => { + await kit.models() + await settle(kit) + const models = await kit.models() + for (const id of ["gemini-pro-orchestrator", "gemini-pro-orchestrator-g1-pro"]) assert.equal(models[id], undefined, `列出了 ${id}`) + for (const model of Object.values(models)) assert.doesNotMatch(String(model.name), /Orchestrator/i) + const plain = (value) => JSON.parse(JSON.stringify(value)) + assert.deepEqual(plain(models["gemini-4-hydrogen"].limit), { context: 1048576, output: 65536 }) + assert.deepEqual(Object.keys(models["gemini-4-hydrogen"].variants ?? {}).sort(), ["high", "low", "medium", "xhigh"]) + assert.deepEqual(plain(models["gemini-4-carbon"].limit), { context: 1048576, output: 262144 }) + assert.deepEqual(plain(models["claude-sonnet-4-6"].limit), { context: 250000, output: 64000 }) + assert.deepEqual(plain(models["claude-opus-4-6-thinking"].limit), { context: 250000, output: 64000 }) + const spawned = kit.children.size + for (const [requested, planner] of [["agy-cli/gemini-pro-orchestrator", "gemini-4-carbon"], ["gemini-pro-orchestrator-g1-pro", "gemini-4-argon"]]) { + const response = await kit.request(baseBody({ model: requested, tools: [], messages: [{ role: "user", content: "hi" }] })) + assert.equal(response.status, 400) + const body = await response.json() + assert.match(body.error.message, new RegExp(`Choose ${planner}`)) + } + assert.equal(kit.children.size, spawned, "被拒的 Orchestrator 请求起了 agy") + }) +}) + test("各家族 limit 正确,未知动态型号不猜成 1M", async () => { const expected = { "gemini-4-argon": { context: 1048576, output: 65536 },