agy-cli 0.1.55: with agy's sign-in in a file (no keyring, Docker), agy stays on its own folder (#1165)

0.1.54 (#1166) started agy acp with --gemini-dir pointing at a folder of
the bridge's own, which keeps the machine's skills out. That assumed agy's
Google sign-in lives in the system keyring. Where there is none (a Docker
container, Linux with no D-Bus session), agy keeps it in
~/.gemini/antigravity-cli/antigravity-oauth-token instead. The bridge's
folder had no sign-in, and every request failed "session/new failed:
Authentication required". shawn8888 reported it on #1165 from
ghcr.io/yetone/magpie with agy 1.5.9.

Now, when that file exists and AGY_BRIDGE_GEMINI_DIR names no folder, no
--gemini-dir is passed, and agy uses its own folder and sign-in.
--include-default-customizations=false is still passed. A folder the user
names is still used.

Run (mica, node --test test/repeat-batch.mjs test/usage-settlement.mjs,
temp HOME): 83 pass, 0 fail. bun scripts/check.mjs agy-cli: ok.
Broken by hand: without the file check, the new "#1165 … stays on that
folder" test fails (1 pass, 1 fail).

Not tried: a real Docker container with agy. The token file's path is
the one the reporter saw.
This commit is contained in:
yetone
2026-11-15 09:46:03 +08:00
parent 3238ab8518
commit f7fc6641c5
3 changed files with 44 additions and 3 deletions
+16 -2
View File
@@ -208,7 +208,8 @@ function findAgy() {
// but on Windows it still loaded all 120 of a user's skills; --gemini-dir
// pointed at a folder of the bridge's own leaves them all out (the reporter
// ran it: no skills, every client tool listed). agy's Google sign-in is in
// the system keyring, not in that folder (signin.mjs), so it still applies.
// the system keyring, not in that folder (signin.mjs), so it still applies;
// with no keyring it is a file in the folder, and see fileSignIn.
// An agy without these flags refuses to start on them, so each is passed
// only when `agy acp --help` lists it. The answer is kept per binary (path,
// mtime, size), so an agy update asks again; a probe that failed is asked
@@ -248,9 +249,22 @@ export function bridgeGeminiDir(env = process.env) {
// geminiDirArgs gives agy the bridge's own folder when its acp lists
// --gemini-dir and the folder can be made, else nothing (agy's ~/.gemini).
// Where no keyring is (a Docker container, a Linux with no D-Bus session),
// agy keeps its Google sign-in in a file under its folder instead, and a
// folder of the bridge's own would have no sign-in (plugins#1165): then agy
// stays on its own, unless AGY_BRIDGE_GEMINI_DIR names one.
export function fileSignIn(home = os.homedir()) {
try {
return fs.statSync(path.join(home, ".gemini", "antigravity-cli", "antigravity-oauth-token")).isFile()
} catch {
return false
}
}
export async function geminiDirArgs(agyPath, env = process.env) {
const dir = bridgeGeminiDir(env)
if (!dir || !/--gemini[-_]dir\b/.test(await acpHelp(agyPath))) return { args: [], dir: null }
if (!dir || (!env.AGY_BRIDGE_GEMINI_DIR && fileSignIn())) return { args: [], dir: null }
if (!/--gemini[-_]dir\b/.test(await acpHelp(agyPath))) return { args: [], dir: null }
try {
await fs.promises.mkdir(dir, { recursive: true, mode: 0o700 })
} catch {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@magpie-community/opencode-agy-cli-auth",
"version": "0.1.54",
"version": "0.1.55",
"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",
+27
View File
@@ -1066,6 +1066,33 @@ test("#1166: an agy whose acp --help lists --gemini-dir runs in the bridge's own
})
})
test("#1165: with agy's sign-in in a file under ~/.gemini (no keyring, Docker), agy stays on that folder", async () => {
await withKit({ acpHelp: GEMINI_DIR_HELP }, async (kit) => {
const token = path.join(kit.env.HOME, ".gemini", "antigravity-cli", "antigravity-oauth-token")
fs.mkdirSync(path.dirname(token), { recursive: true })
fs.writeFileSync(token, "{}", { mode: 0o600 })
scriptedAgent(kit)
const reply = await readSse(await kit.request(baseBody({ metadata: { user_id: "file-token" }, messages: [{ role: "user", content: "hello" }] })))
assert.equal(reply.stopReason, "end_turn")
assert.ok(!kit.acpSpawns[0].args.includes("--gemini-dir"), kit.acpSpawns[0].args.join(" "))
assert.ok(kit.acpSpawns[0].args.includes("--include-default-customizations=false"))
})
})
test("#1165: a folder AGY_BRIDGE_GEMINI_DIR names is used even with a file sign-in", async () => {
await withKit({ acpHelp: GEMINI_DIR_HELP }, async (kit) => {
const named = path.join(kit.env.HOME, "named-agy")
kit.env.AGY_BRIDGE_GEMINI_DIR = named
const token = path.join(kit.env.HOME, ".gemini", "antigravity-cli", "antigravity-oauth-token")
fs.mkdirSync(path.dirname(token), { recursive: true })
fs.writeFileSync(token, "{}")
scriptedAgent(kit)
await readSse(await kit.request(baseBody({ metadata: { user_id: "file-token-named" }, messages: [{ role: "user", content: "hello" }] })))
const args = kit.acpSpawns[0].args
assert.equal(args[args.indexOf("--gemini-dir") + 1], named, args.join(" "))
})
})
test("#1166: AGY_BRIDGE_GEMINI_DIR=default leaves agy on the machine's own folder", async () => {
await withKit({ acpHelp: GEMINI_DIR_HELP, env: { AGY_BRIDGE_GEMINI_DIR: "default" } }, async (kit) => {
scriptedAgent(kit)