31 Commits
Author SHA1 Message Date
yetone 5f3202000c agy-cli 0.1.98: with Antigravity's app wired to magpie, the provider lists the Google account's models, not magpie's
@canlee886 on X: Antigravity was wired to magpie, and agy-cli as a
provider then listed magpie's own models (its routing groups, "GPT-6
Astra · routing group (Low…Max)"). That is a loop: magpie -> plugin ->
agy -> magpie.

Cause: magpie wires Antigravity's desktop app through the gateway block
in ~/.gemini/config/config.json, and agy 1.5.10 reads that same file. An
agy on ~/.gemini then lists and offers the gateway's models, whatever its
settings.json says. --settings '{"modelProvider":""}' doesn't help.
- The catalog's model probe ran `agy acp` with no --gemini-dir, so it was
  offered magpie's models, and the catalog keeps to what a session offers.
- `agy models` (the listing, the sign-in check, refusalNow) can't be
  given a --gemini-dir at all. It also answered from the gateway, and so
  took magpie's listing for a Google sign-in.
- Turns already ran on the bridge's own folder, and agy reads no app
  gateway there.

Fix:
- The probe runs on the folder a turn runs on (geminiDirArgs), so it is
  offered what a turn is served.
- With the app's gateway on (appGatewayOn: gateway.enabled true, or a
  file that isn't JSON), the listing and the sign-in check come from that
  session instead of `agy models`. refusalNow doesn't read the gateway's
  listing either.
- A gateway turned off, a missing file, an account home or no own
  folder: `agy models` is used as before.

Run:
- Real agy 1.5.10 in a sandbox HOME, with the real Google sign-in and
  the app's gateway pointing at a fake magpie on 127.0.0.1:
  - old index.mjs listed rg/gpt-6-astra and rg/gpt-6-luna, with three
    requests to the fake;
  - new listed claude-sonnet-4-6, claude-opus-4-6-thinking, gemini-3.8-
    flash and gpt-oss-120b, with no request to the fake.
  - A real turn went to Google, with 0 requests to the fake. Google
    answered 403: this test account is disabled for Antigravity.
- Four new tests in test/catalog.mjs. On the old index.mjs all 4 are red.
  With only the probe's --gemini-dir taken out by hand, the two listing
  tests are red ("magpie's own models were listed").
- On mote: bun scripts/check.mjs ok; agy-cli bun test 41 pass, 0 fail, in
  a temp HOME.

Not tried: an agy with no keyring (fileSignIn) or AGY_BRIDGE_GEMINI_DIR=
default. Its turns run on ~/.gemini and still follow the app's gateway;
filed separately.
2026-11-19 18:12:49 +08:00
yetone 62645eceb7 agy-cli 0.1.96: a resumed session runs in its own folder again, so agy's cache still hits
@chet030714 on X: Hermes through agy-cli started near 70% cache hits and
fell all day. agy's prompt cache follows the folder its process runs in.
Every agy the bridge started had a new mkdtemp folder, so a session
resumed after the 10-minute idle reclaim, an LRU eviction or a restart
replayed its whole history uncached, and the longer a conversation got,
the more each resume cost.

Measured with real agy 1.5.10 over ACP in a sandbox HOME (one session,
~24K tokens a turn): every turn in one process hit (cachedReadTokens
19,682 to 197,710). A resume in the same folder: 213,520 cached. In
another folder: 0 cached, 219,198 uncached. Only the process's folder
counts, not session/resume's cwd. The same folder after 13 minutes
idle, or removed and made again at the same path, still hits.

Now a parked session records its workspace, and a resume starts agy in
that folder (made again if it was removed), never in a spare's. Only a
magpie-agy-bridge-XXXXXX folder directly in the temp folder is taken
from the state file. A stopped agy leaves its folder when another
already runs there, and a resume waits for a removal in progress.

Run (at 63c2ff93 + this diff):
- mica, HOME=$(mktemp -d): packages/agy-cli `bun test`: 41 pass, 0 fail.
- The new test (usage-settlement.mjs, LRU resume runs in the session's
  folder) on the old index.mjs, by hand: fails.
- The real bridge, index.mjs loaded with real agy in a sandbox HOME, two
  turns with the process reclaimed between them (AGY_BRIDGE_IDLE_MS=5000):
  old code, resumed turn 0 of 32,127 cached; this change, 29,681 of
  32,018 cached.

Not tried: Windows and Linux with real agy. A resume from a park entry
written before this version still starts in a new folder, once.
2026-11-19 01:14:23 +08:00
yetone 34edf938da agy-cli: a 429 to the reworded prompt in the user turn is a rate limit, not a 400 (0.1.90)
HadStash on X (11-17, Google AI Ultra trial, agy-cli) got "agy bridge:
Antigravity answered 429 to this system prompt: RESOURCE_EXHAUSTED
(code 429)" as an Anthropic invalid_request_error, while the same account
works in the Antigravity client.

#formatAgentError called any bare 429 a prompt rejection when the RAW
client prompt has a line Antigravity turns away (turnsAway). Claude Code's
identity line is always there, so every 429 in a Claude Code session was
a 400 the client never retries and a gateway group doesn't treat as a
limit, even though what was sent was reworded (cloak.mjs) and sits in the
first user turn, the default since 11-15. Now that label is given only
when the instructions went in agy's session instructions
(AGY_BRIDGE_SYSTEM_APPEND=1), where the reworded prompt is still turned
away; in the user turn the 429 is a rate_limit_error (with the existing
"not a quota" note for the bare 429), so Claude Code retries it and a
group asks the next member. The turn still ends at agy's first 429
banner (Lmohn39), so nothing waits.

Real probes, account kumw95ya25, Code Assist direct (plug-raw), Claude
Code 2.1.326's captured prompt (SDK and CLI identity), 2 tries each:
- raw in system: refused 429 (gemini-3.8-flash)
- outgoing() in system: 429 2/2 on gemini-3.8-flash and claude-sonnet-4-6
- outgoing() in the user turn: 200 2/2 on both models
- user turn + Claude Code's 12 tools as function declarations: 200 2/2
Control prompt: 200 2/2.

Tests: repeat-batch's Lmohn39 test now runs the session-instructions
path (testkit's new `appendable`) for the 400 and the user-turn path
for the rate limit, Claude Code's identity line included; smoke's #980
case sets AGY_BRIDGE_SYSTEM_APPEND=1 and a new HadStash case checks the
user-turn 429. Broken by hand: against origin/main's index.mjs both are
red (repeat-batch 1 fail, smoke "BAD - HadStash ...").

Run on mote at this tree (HOME=$(mktemp -d)): bun scripts/check.mjs ok;
bun test 9040 pass, 1 fail: agy-cli test/usage.mjs "a hung sign-in with
an ended token is never restarted ..." at its 6s deadline, which is
#1191 (usage.mjs red on macOS under load, the failing tests change each
run; alone it went 5 of 41 red, other tests). Not this change: usage.mjs
doesn't reach #formatAgentError.

Not tried: the reporter's own account or agent (they don't say which;
the Anthropic-shaped error says a /v1/messages client). agy itself was
not run end to end: the Mac's agy account is disabled by Google, so the
probes went to Code Assist directly with agy-cli's cloak.mjs.
2026-11-17 23:38:34 +08:00
yetone 4b3af4a565 agy-cli 0.1.89: a session whose agy never loads the client's tools fails and says why (#1239)
pi declared read, bash, edit and write through the gateway on Windows and
the model saw only agy's own manage_task; `read` came back
`unknown tool: "read"`. agy reads a client's tools from the bridge's
ide-tools MCP server, which it starts by running `nc` from PATH. When
that never answers, #waitForToolList gave up after 5s without a word and
the turn ran with no client tool at all, for every client.

On Windows agy 1.5 runs only nc.exe, never the nc.cmd the bridge falls
back to. A failed nc.exe build was swallowed and cached for the whole
host process, so every session after it had no tools until magpie
restarted.

- A session that declares tools and whose agy hasn't listed them after
  AGY_BRIDGE_TOOL_LIST_WAIT_MS (now 20s) fails with 502
  tools_not_loaded, naming the cause: on Windows, the nc.exe build's own
  failure (not Bun, non-ASCII folder, bun build's exit code or "wrote no
  nc.exe" plus its last stderr lines); elsewhere, the `nc` MCP server
  that never answered. No session/prompt is sent.
- A live agy that never listed the tools a follow-up declares (started
  with none) is replaced (session_new reason tools_unlisted), not reused.
- On Windows a failed nc.exe build is tried again after 5 minutes,
  rather than never.

Tests: test/tools-listed.mjs (new, in agy-cli.test.mjs). The testkit's
fake agy can now not list tools (listTools), or not keep a watch
(watchTools), and records each listing.

Run at this tree:
- mica-run, HOME=$(mktemp -d): cd packages/agy-cli && bun test:
  41 pass 0 fail; bun scripts/check.mjs agy-cli: ok. (mote was at load
  130.) An earlier run of the same suite had test/usage.mjs red twice on
  its 3s usage-query deadline at mica load 23; it passed 41/41 twice
  alone. That is #1191.
- win-run on xiaomi-gpu (real Windows, Bun 1.4.2): tools-listed.mjs and
  windows-nc.mjs, 13 pass 0 fail. The first Windows run caught that the
  platform-neutral cases took the real win32 path; they now pin linux.

Broken by hand: tools-listed.mjs against the old index.mjs
(AGY_BRIDGE_TEST_INDEX = HEAD's copy): 3 of 5 red. The unlisted session
ran its turn (200, end_turn after 5s), the follow-up ran on the agy that
never listed Read, and the failed Windows build was never retried. The
two cases that should hold either way pass.

Earlier, on xiaomi-gpu: a real nc.exe built in ~335ms, and the shim
answered tools/list in 137ms first and ~28ms after.

Not tried: a real agy turn or a real Windows agy session. There is no
usable account: the Mac one is banned, and Windows agy answers
session/new with "Authentication required". So the reporter's exact
trigger (which nc.exe build failure, or none) isn't confirmed. The error
now names it on their machine.
2026-11-17 19:25:36 +08:00
yetone 75068043af agy-cli 0.1.82: each account lists the models agy offers it, not the last account's (#1229)
The cached `agy models` list and what agy acp offers a client were one
set of module globals. With several accounts on different plans, the
last session or probe of any account replaced them, so every account's
models() listed that account's models and the catalog flipped as
requests went by (#1229).

- The catalog, the offered set and the refresh/probe state are now kept
  per account home (currentHome(), "" for agy's own). magpie asks each
  account's models() in that account and serves the union, and already
  sends a model only to an account that lists it.
- A Proc remembers the account it was started for, and the offer probe
  remembers its account at the start, so what agy says later is noted
  for that account even outside its scope.
- models.json keeps agy's own account under the executable's path as
  before; another account's entry is "<path>#<home id>".
- provider.warming() waits on every account's listing and probe, and
  again for a probe a landing listing starts.
- A new account's static start no longer replaces the usage reader's
  rows from another account's real list; a changed agy still does.

Run (mote, HOME=$(mktemp -d)):
- bun test in packages/agy-cli: 37 pass, 0 fail (test/catalog.mjs 34
  of 34 under node --test too).
- bun scripts/check.mjs agy-cli: ok.

Broken by hand: origin/main's index.mjs with the new test: red
("#1229 每个账号列自己开放的型号,互不覆盖").

Not tried: two real agy accounts on different plans (none here); the
test fakes them with a per-HOME offered list.
2026-11-17 00:29:32 +08:00
yetone aafb20e6bf agy-cli 0.1.79: agy models runs with modelProvider cleared, so a gemini settings.json doesn't keep a stale list (#1218)
A turn runs agy acp on the bridge's folder and the Google sign-in, but the
listing, refusal and sign-in probes ran a bare `agy models`, which reads
the user's own settings.json. With "modelProvider": "gemini" there (an AI
Studio key), the listing failed without GEMINI_API_KEY in magpie's
environment and the old catalog stayed, or listed API-key mode's models.

- agy 1.5.9's global --settings takes a session-only settings.json object.
  The three `agy models` calls run as
  `agy --settings '{"modelProvider":""}' models` when agy's --help lists
  --settings (asked once per binary, cached by path, mtime and size like
  acpHelp); an agy that doesn't list it gets the bare command, as before.
  The reporter checked that this command goes back to the Google backend.
- testkit's fake answers `agy --help` and records each models spawn's
  args; its models behaviour sees them.

Run (mote, HOME=$(mktemp -d)):
- node --test on every node test file in packages/agy-cli/test: all pass
  (catalog 33, repeat-batch 54, usage 36, usage-settlement 40, ...).
- bun test packages/agy-cli: 37 pass, 0 fail (cp-hook and smoke are
  bun-only).
- bun scripts/check.mjs agy-cli: ok.

Broken by hand: origin/main's index.mjs with the new tests: the --settings
test fails (32 pass, 1 fail).

Not tried: a real agy with a gemini settings.json (the local agy account
answers 403); the flag's effect is the reporter's run. Not changed: with a
file sign-in, acp itself still reads the user's settings.json (no
--gemini-dir there).
2026-11-16 18:27:09 +08:00
yetone 3781c50f52 agy-cli 0.1.76: a URL or text document goes to agy as text, not a 400
daoche_wuzui on X (magpie 0.1.4264): URL context through agy-cli failed
with "a binary or URL document block in a user message (agy's ACP prompt
accepts text and images only) is not supported". The bridge turned away
every document that wasn't a text source.

agy 1.5.9's initialize says promptCapabilities {image, embeddedContext},
and its binary has only messages.EmbeddedResource.InlineText: an embedded
resource reaches the model as inline text, so a binary file can't be
carried. What can, now is (documents.mjs):

- a URL document (http/https): its URL, said to be unread, so the model
  fetches it with the client's tools instead of guessing;
- a base64 document of a text type (text/*, JSON, XML): its decoded text,
  when it is valid UTF-8;
- a PDF or other binary inside a tool_result (Claude Code's Read of a
  PDF): a note that it couldn't be attached and to extract its text with
  a tool, so the turn goes on instead of failing.

Still refused, with what to do: a PDF attached to the user message ("paste
the document's text, attach its pages as images, or let the agent read the
file with a tool"), a Files API file_id (send it inline), a non-http URL.
There is no PDF-to-text helper here or in magpie to extract it with.
Neither note names agy, the bridge or magpie.

Run at this tree (mica, HOME=$(mktemp -d)): packages/agy-cli bun test 37
pass 0 fail (new test/documents-unit.mjs, 15 checks); smoke ALL OK (381
checks); bun scripts/check.mjs agy-cli ok.
Broken by hand: smoke with 0.1.75's index.mjs: 3 FAILURES (the URL/text
document, the PDF 400's hint, the PDF in a tool_result).
Not tried: a real agy model. The owner's agy account answers "This
service has been disabled in this account for violation of Terms of
Service", so the fix was checked against the fake agy only. The
reporter's client isn't named in the tweet.
2026-11-16 15:04:02 +08:00
zhou.han 9e86a2c7b7 proc: a Linux zombie no longer holds a lock (#1198)
yetihan (#1198): a lock whose owner is a Linux zombie was held for
good. process.kill(pid, 0) succeeds on a zombie, so 15 packages' lock
and liveness checks counted an exited, unreaped owner as alive.

- scripts/proc.mjs: processStatus(pid) is dead on ESRCH, and on Linux
  also when /proc/<pid>/stat says Z or X; EPERM is "permission", any
  other error "unknown". processAlive / processExists keep each
  caller's old EPERM and unknown-error meaning.
- scripts/sync-proc.mjs copies it into each package (--check in the
  tests); every package's own check keeps its old semantics, now with
  zombies dead. agent-console's daemon bundle and window-warmup's dist
  are rebuilt.
- 15 packages bumped.

Review run at 28ef6622 (mote, HOME=$(mktemp -d)):
- node scripts/sync-proc.mjs --check: ok.
- bun test (whole repo): 8934 pass, 0 fail.
- bun scripts/check.mjs: every package ok.
- window-warmup's build reproduces its dist/plugin.js byte for byte.
  agent-console's bundle diff read line by line: the proc module plus
  esbuild's renumbered imports, nothing else (esbuild isn't installed
  on mote, so it wasn't rebuilt there).
- Real zombie on Linux (WSL, magpie-desktop): a bash child left
  unreaped by an exec'd sleep, /proc stat "Z": the old kill(0) check
  says alive, processStatus says dead; the running process says alive.

Not tried: each package's lock contention end to end.
2026-11-16 12:19:09 +08:00
yetone d7265c17e4 agy-cli 0.1.71: a new conversation takes a spare agy that is already started
A new conversation spawned `agy acp` and waited for initialize before
session/new. Now, after a conversation starts, the plugin warms one spare
agy for the same account, binary, folder, flags and environment: spawned and
initialised, with no session. The next new conversation for that key opens
its session on the spare and skips agy's start. Then another spare is warmed.

Only the process is warmed. On WSL with agy 1.5.9, measured through a
logging HTTPS proxy, spawn + initialize + 45s idle made no connection to
any host. session/new is where agy sends Code Assist calls (loadCodeAssist,
fetchAvailableModels, quota, user info, experiments), plus telemetry.
Closing an unused session writes its trajectory ACLs at Google. Sessions
also carry the conversation's own instructions. So sessions are never
opened ahead. agy reads its sign-in at session/new, so a spare picks up a
sign-in that changed after it started.

Spares are stopped when idle (IDLE_MS), first when the pool needs room,
never warmed when the pool has one slot left, at most 2 at a time, and
with the host (reapOnExit). agy also exits when its stdin closes.
AGY_BRIDGE_SPARE=0 turns them off.

TTFT of a second new conversation (test kit fake agy, initialize 1000ms,
session/new 3000ms): first 4026ms, second 3008ms; before, both ~4s. Real
agy start, measured on WSL: ~1s cold, ~0.25s warm. That is the saving. The
~3s session open (Google) and model latency remain.

Run (mote):
- test/spare.mjs on the old index.mjs (AGY_BRIDGE_TEST_INDEX): 6 of 7 red,
  only the AGY_BRIDGE_SPARE=0 case green. On the new index.mjs: 7 of 7
  green.
- `HOME=<sandbox> bun test packages/agy-cli/`: 36 pass, 0 fail.
- `bun scripts/check.mjs` ok.
The test kit defaults AGY_BRIDGE_SPARE=0 so suites that count spawns keep
their counts.

Not tried: a real signed-in account through the spare path, native
Windows agy, macOS agy.
2026-11-16 11:27:36 +08:00
yetone 175dfd2555 agy-cli 0.1.70: say when Google refuses the account (#3501) instead of a fallback list
Three X reports (16 Nov): "You do not have a valid license of this product
(#3501)", "models can't be fetched", and "magpie's agy proxy stopped
working". agy 1.5.9 gets Google's 403 #3501 on its eligibility check and
fails every command with it (agy models, agy -p). The plugin hid it:
models() fell back to the static catalog as if the account had those
models, usage said only "not eligible", and a request got 400 "model ... is
unavailable to this agy account" because the ACP session offers none.

Now:
- usage.mjs: agyRefusal() reads Google's refusal out of agy's output
  (#3501 first, else the eligibility line), never from agy's own log
  lines or a network failure; usage reports the #3501 text with what to
  do (update agy and sign in again, personal Gmail, unset AGY_ADC_AUTH,
  VPN/region).
- index.mjs: a failed `agy models` records the refusal per agy home;
  models() throws it (magpie shows it as the list error) instead of the
  static catalog, and recovers when agy lists again. A request whose
  session offers no model, or whose turn ends on the refusal, answers 403
  permission_error with the reason (stream and JSON), not 400. After a
  sign-in, magpie shows "agy signed in, but" and the refusal.
- README (zh, en): a Troubleshooting entry for #3501.

Run (mote, HOME=$(mktemp -d)):
- bun test ./packages/agy-cli: 35 pass, 0 fail (110s); bun scripts/check.mjs ok.
- test/usage.mjs with cp-hook preload 6 more times: 0 fail. One earlier
  run had "a direct read that fails leaves the region refusal standing"
  red with "agy usage could not start the CLI" at load ~28; the same red
  shows on the base tree (b35d4b35) in the same run, so it is not this
  change.
- Red on the old code (mica, base b35d4b35 with the new tests): catalog's
  two #3501 tests fail, usage.mjs fails to import agyRefusal.
- Real agy 1.5.9 on WSL (magpie-desktop) against a fake Code Assist that
  answers 403 #3501: before, models() gave the fallback list, chat gave 400
  "unavailable"; after, models() throws the #3501 reason, usage carries
  it, chat answers 403 permission_error with it.

Not tried: a real Google account that gets #3501; macOS and Windows with
real agy; a live ACP turn whose agent error carries #3501 (covered by the
fake agy in catalog.mjs only).
2026-11-16 10:57:34 +08:00
yetone 9907c187b2 agy-cli 0.1.68: bring in the retired Antigravity plugin's accounts
A user asked on X (@tongzhenbao) to move the accounts signed in on the
retired Antigravity plugin (provider "antigravity") into agy-cli in one
click. That plugin signed in with Antigravity's own Google OAuth client
(1071006060591-tmhssin2h21lcre235vtolojh4g403ep), and agy's own
`agy acp --login` link uses the same client id, so agy can take those
refresh tokens as its own: nothing is sent anywhere agy doesn't already
send its sign-in, and no other client is spoken for.

auth.import (magpie's "Import accounts from a file…") now takes:
- the old plugin's saved oauth entry, one, a list or plugin-auth.json's
  map of them (refresh "<token>|<project>", accountId = email);
- agy's own token file / keyring value (go-keyring-base64: prefix too).
A bare refresh token or another tool's export is refused, since it may be
another client's. Each account gets its own agy home with the token file
agy writes (0600), and is added only once `agy models` runs there; one agy
refuses leaves no home. An account already signed in (same email) gives
its existing key back.

Run:
- mote: packages/agy-cli `HOME=$(mktemp -d) bun test`: smoke, signin,
  cloak, install all pass; test/usage.mjs red (3 of 30, different each
  run) and red the same way on pristine origin/main e5cb9598 (8 and 9
  of 30, two runs on mote), green on ubuntu CI; filed separately.
- the new smoke checks are red on the old index.mjs ("plugin.auth.import
  is not a function").
- bun scripts/check.mjs: ok.
- real account, sandbox HOME: the owner's live old-plugin entry copied
  into a sandbox .gemini/antigravity-cli/antigravity-oauth-token;
  `SSH_CONNECTION=… agy models` listed the models and agy refreshed the
  file in the same shape (refresh token not rotated).

Not tried: the import through a running magpie with a real account
(magpie's Providers-page Move comes in a magpie release).
2026-11-16 01:29:08 +08:00
yetone e5cb9598c8 agy-cli 0.1.67: more than one Google account, each with its own usage
tongzhenbao on X wanted several accounts with their usage, as the old
built-in had. agy keeps one sign-in where it looks for it (the system
keyring's single "gemini"/"antigravity" entry), so the plugin was
single: true and its second sign-in way replaced the account.

Now the first account is agy's own, unchanged, and "Add another Google
account" signs another one in to an agy whose home is the account's
own (XDG_STATE_HOME/magpie-agy-bridge/accounts/<id>). Every agy run for
that account (sign-in, models, usage, requests) gets HOME (USERPROFILE
on Windows) there and SSH_CONNECTION set, which agy 1.5 reads as an SSH
session and so keeps the sign-in in .gemini/antigravity-cli/
antigravity-oauth-token under that home rather than the keyring. The
account's home is saved in its metadata (agyHome); the loader, usage and
models run its work in an AsyncLocalStorage scope that childEnv and the
stored sign-in read follow. Its conversations are keyed apart, and it
gets no --gemini-dir (its token is under its own .gemini). single: true
is gone, so each account has its own row and usage and rotates like
any other.

Checked by hand before writing it, with real agy and planted (expired)
tokens in sandbox homes: agy read the file token from the sandbox HOME
on macOS (mote) with SSH_CONNECTION set, on Windows (xiaomi-gpu) with
USERPROFILE set, and in WSL. The live keyring was never touched.

Run:
- packages/agy-cli `HOME=$(mktemp -d) bun test` on mote: 35 pass, 0 fail.
- bun scripts/check.mjs on mote: ok.
- test/smoke.mjs on Windows (win-run): ALL OK (369 checks).
- Broken by hand: the new smoke checks against the old index.mjs,
  signin.mjs and platform.mjs: 6 FAILURES (the method, single, the
  home, SSH_CONNECTION, the saved account, the failed home's cleanup).

Not tried: a real Google sign-in of a second account, so agy writing
the token file under SSH detection is known from file-mode users
(plugins#1165) rather than seen here. Signing an added account in
again makes a new home and leaves the old one (~800K). Every account
shares one model catalog.
2026-11-15 23:51:00 +08:00
Ruining YangandRuining Yang f4c2f2fb2b agy-cli 0.1.65: usage windows name the model ids they cover (#1180)
A usage window from `agy usage` now carries the model ids it covers, taken
from the catalog `agy models` listed: each display name in the group's
"Models within this group:" line (or the group's own name) maps to the
family id and every effort variant the catalog serves. With no catalog yet,
or a name the catalog doesn't have, a window has no ids. The windows stay
aside, so routing is unchanged; agy-cli 0.1.65.

Run at 8acf7ffb5 on macOS (mote), CI-style with a temp HOME:
bun test packages/agy-cli, 35 pass, 0 fail; bun scripts/check.mjs agy-cli
passes. Not tried: a real agy account (the local one answers 403).

Co-authored-by: Ruining Yang <ArmedHelicopter@users.noreply.github.com>
2026-11-15 20:31:27 +08:00
yetone b840915abc agy-cli 0.1.62: magpie's sign-in installs agy where there is none, and the plugin keeps that copy current (niuniu_8964 on X)
In magpie's Docker image there is no agy, so Sign in failed with "agy CLI
not found". The plugin now declares auth.cli (magpie 0.1.4246's hook,
engines.magpie raised to it): when agy isn't found, magpie's sign-in shows
"Installing Antigravity CLI…" and the plugin installs it the way Google's
install.sh does: the same manifest, the download checked against its
sha512, the antigravity binary taken out of the tarball, tried with
--version, then renamed into place. It goes into the data folder
($XDG_DATA_HOME/magpie-agy-cli/agy, ~/.local/share without it,
%LOCALAPPDATA% on Windows), which in the container is on /config, and is
searched last, so an agy the user installed wins. That copy is kept
current a minute after start and every 6 hours, only while it is the one
in use and not when AGY_CLI_DISABLE_AUTO_UPDATE is set.

Also: findAgy handed out a cached path to an agy removed since, so the
sign-in tried to spawn it (ENOENT) instead of installing it; and a write
loop left an error listener per wait (MaxListenersExceededWarning on the
260MB download).

Account code is unchanged.

Run, on mica: bun scripts/check.mjs ok; agy-cli bun test 34/34 under a
temp HOME (install.test.mjs: 10, against a local server). A6b red on the
old findAgy, green now.

Real use in magpie's Docker image (xiaomi-gpu, linux amd64), with magpie
0.1.4246's tree: `magpie plugin login agy-cli 1` and the browser UI's
POST /api/plugin-signin both installed agy 1.5.9 into
/config/data/magpie-agy-cli and went on to agy's Google link; it survived
a restart; agy.version set back to 1.5.0 was updated a minute after start.

Not tried: finishing the Google sign-in in the container, a real install
on macOS, Windows or musl.
2026-11-15 14:55:10 +08:00
yetone 57d1cc6a9f agy-cli: start agy without the machine's own skills when it can (#1166)
On Windows with agy 1.5.9, a session loaded 120 local skills from
~/.gemini/skills, ~/.gemini/config/skills and ~/.agents/skills although
the bridge agent says inheritCustomizations: false. Skills and the
client's MCP tools share agy's 20,000-token customization budget, so
agy dropped the six largest client tools (task, shell, …) and three
skills.

agy 1.5.9's acp takes --include-default-customizations (default true).
The bridge now passes --include-default-customizations=false when
`agy acp --help` lists the flag. An agy without it exits on an unknown
flag, so it is never passed blind. The answer is kept per binary (path,
mtime, size); a probe that errors or times out is asked again. The bare
`agy acp` model probe is unchanged. 0.1.52.

Run:
- bun test packages/agy-cli on mote (temp HOME): 21 pass, 0 fail;
  bun scripts/check.mjs agy-cli ok.
- the same on Windows (win-run, xiaomi-gpu): 21 pass, 0 fail.
- test/smoke.mjs alone with bun on mote: ALL OK (348 checks).
- real agy 1.5.9 on macOS: `agy acp --help` prints the flag on stderr
  (exit 0); a session started with the flag set to false runs.
Broken by hand: without the args.push in Proc.start, repeat-batch's
"#1166 … asked once" test and smoke's #1166 check go red.
Not tried: the reporter's Windows machine with its 120 skills. On this
Mac the default run sent no user skills to the model either, so it is
not shown here that the flag keeps them out; the reporter is asked to
confirm.
2026-11-15 06:43:07 +08:00
yetone 6646797e15 agy-cli 0.1.46: a catalog over agy's tool budget keeps every tool (#1140)
Since #989 every client tool is listed always-loaded, so all of them go
into agy's customization budget: 20,000 tokens counted as
ceil(UTF-8 bytes / 3). Past it, agy drops whole tools, the largest first,
and with tools: [] the model has no other way to reach them. tungloong's
131-tool catalog (~25,000 tokens) lost bash and 12 Paper tools.

Proc.listTools() now hands agy the catalog through fitTools
(tool-budget.mjs), aiming at 18,000 tokens to leave agy room for its name
prefix and serialization:
- within the budget, the catalog goes as it is (the same array);
- else $schema, title and examples come out where they are keywords (a
  property named "title" is the client's and stays);
- else every description is capped at the highest level L that fits,
  found by binary search: a property's at L bytes, a tool's own at 2.5L,
  a contract property's (an object with no properties, or tool-schema's
  Variants/Accepts anyOf text) at 11L. A cut drops a trailing Examples
  block first, ends on a sentence or a whole code point, and adds "…";
- at L = 0 the properties' descriptions go and the room left goes to the
  tools' own.
Names, property names, types, enum, const, required, items, anyOf and
bounds are never touched, and this.tools / toolsSignature stay as the
client sent them. The trimmed list is kept per catalog.

Run (WSL magpie-desktop, temp HOME; mote was at load 178 and mica's disk
is full): bun test 21 pass; node --test conversation-key, step-usage,
usage-settlement, repeat-batch, compat, tool-schema, catalog,
tool-budget, steer-in-session, windows-nc: 198 pass, 0 fail;
bun scripts/check.mjs agy-cli ok; npm pack --dry-run ships
tool-budget.mjs. With main's index.mjs the new bridge test fails (31,690
tokens reach agy). Not tried with a real agy: the budget and its
counting are the reporter's reading of agy 1.5.8, not checked here.
2026-11-14 18:34:29 +08:00
yetone b40a853c20 agy-cli 0.1.34: agy isn't run in the background without a sign-in, so it stops opening the browser (JZGiVvkSOA75376 on X)
On Windows 11, a signed-out agy opened Google's sign-in page 235 times
in one day. The usage refresh ran `agy` about every 3 minutes, and agy
opens the browser through ShellExecuteW, so the BROWSER=open.cmd guard
can't stop it.

New signin.mjs reads agy's stored sign-in without running agy. agy keeps
it through go-keyring, service "gemini" and user "antigravity":
- macOS: `security find-generic-password`;
- Windows: CredReadW from PowerShell, on the credential
  "gemini:antigravity".
It reads only whether a sign-in is stored, whether it has a refresh
token, and when the access token ends. The token itself never leaves
the function; a hash tells one sign-in from the next. Setting
GEMINI_API_KEY, GOOGLE_API_KEY, AGY_ADC_AUTH or GOOGLE_GENAI_USE_VERTEXAI
means agy signs in some other way, so nothing is concluded from the
keyring. AGY_BRIDGE_STORED_SIGNIN=skip turns the read off.

An access token that has ended is not "needs sign-in". The owner's
working agy has one that ended 11 hours ago and is renewed from its
refresh token. agy counts as unable to sign in when:
- no sign-in is stored;
- the access token has ended and there is no refresh token;
- or agy already failed on this stored sign-in: it said it needs a
  sign-in, or it hung with an ended token and printed nothing or
  sign-in talk, the way an agy waiting on its browser does. This holds
  until another sign-in is stored.

What changes:
- Usage: in those cases agy isn't run. The read says signIn "expired",
  and magpie shows the account's sign-in as expired. After the next good
  read it says "renewed", and magpie clears that.
- Other usage failures wait 10 minutes before the next run, doubling up
  to 6 hours. Before, they ran again on every refresh.
- The model listing (`agy models`) isn't run in the background in those
  cases either. The catalog it has stays.
- Signing in from magpie skips the `agy models` probe and goes straight
  to magpie's own sign-in link. A finished sign-in clears what was
  marked dead.
- A request answers 401 with X-Magpie-Sign-In: expired when no sign-in
  is stored. This uses the last read, so a request never waits for
  PowerShell.
- `agy --version` hanging is never read as a sign-in wait.

Run:
- mote, rebased on a02d5912: `bun scripts/check.mjs` ok and
  `bun test` in packages/agy-cli (20 pass, 0 fail).
- mote, root `HOME=<temp> bun test` at the pre-rebase head (e90d6f01
  base): 7588 pass, 427 fail, none in agy-cli. The reds named in the
  kept tail are OAuth callback-port and loopback page-service tests
  (mote at load ~35-40); main's own CI test job passes them, so this
  push's CI test job is the record for the whole suite.
- win-run on xiaomi-gpu: test/signin.mjs and test/usage.mjs (21 pass,
  3 skip on Windows), plus the PowerShell script for real. Over SSH,
  CredReadW answers 1312 (no logon session), which the script turns into
  "unknown". So the struct read was tried on a CREDENTIALW built in
  memory with a UTF-8 blob: the bytes round-trip and the sign-in parses.
Broken by hand:
- with the usage gate, the backoff hold and the dead mark removed, 5
  usage tests go red;
- with listAgyModels' gate and the request gate removed, the new catalog
  test goes red;
- with the request gate alone removed, it goes red too.
Not tried:
- a real signed-out agy, by the rule against running a real agy sign-in
  or a browser;
- CredReadW in an interactive Windows session (none was logged on);
- agy on Windows at all (xiaomi-gpu has no agy).
On Linux the keyring isn't read ("unknown"): agy runs as before, with
the backoff, and the xdg-open shim already stops the browser there.
2026-11-13 13:45:25 +08:00
yetone 0135b7b0ea agy-cli 0.1.32: the first model list after warming has agy's Claude and GPT models (#1064)
On a signed-in agy, `agy models` takes about 4.4s and `agy acp`'s
session/new about 3s. provider.models() needed three calls before
claude-opus-5-5, claude-sonnet-5-5 and gpt-oss-120b showed up, and
OpenCode 2.x calls it once.

What changed:
- packages/agy-cli/index.mjs:
  - The offered-model probe now starts in listAgyModels' .then, as soon as
    a non-empty list arrives and a caller asked for probeOffered. It no
    longer waits for the next models() call. A hung or failed `agy models`
    still never spawns the probe.
  - probeSignedIn reuses the `agy models` stdout it already has. The same
    parser (parseAgyModels, split out of listAgyModels) fills
    cachedModelCatalog, and the probe starts. Sign-in waits for the probe
    for at most 3s.
  - The offer (acpOfferedModels, acpOfferedKey, offeredProbeAt and any
    in-flight probe) is forgotten when agyPath changes and after a new
    sign-in finishes. A generation counter drops the answer of a probe
    that started before the reset.
  - provider.warming() returns a promise while a list or probe is still
    running, and null when nothing is.
- scripts/opencode2.mjs, copied byte for byte to every
  packages/*/opencode2.mjs: after the first background refresh, the
  adapter awaits hooks.provider.warming() once, for at most 60s, and then
  refreshes once more. It does not loop. Plugins without warming() behave
  as before.
- Not done: the issue's on-disk catalog cache (point 3), skipped as asked.

Known gap: agy-cli has no `config` hook, so under OpenCode 2.x the adapter
lists no provider for it. refresh() returns before it calls
provider.models(), so the follow-up refresh can't add agy's models on 2.x
until agy-cli gets a config hook.

Tests: test/testkit.mjs's fake agy takes a sessionNewDelayMs. The new
tests in test/catalog.mjs set 1.5s on both `agy models` and session/new
and wait for state through warming(), with no fixed sleeps:
- On a slow cold start, the first models() after warming lists Claude and
  GPT, from one probe spawn.
- authorize() on a signed-in agy fills the catalog, and the next models()
  runs no second `agy models`.
- The sign-in wait is bounded: with a 6s session/new, sign-in returns in
  about 4.5s.
- Changing agyPath probes again.
The hang test now awaits warming() before it counts acp spawns.
scripts/opencode2.test.mjs: the warming list is read a second time when
warming ends, and only once when nothing is warming.

Run on Linux (a separate test Mac was over its load limit):
- packages/agy-cli bun test: 17 pass, 0 fail.
- bun scripts/check.mjs agy-cli: ok.
- bun scripts/check.mjs (all packages): ok.
- Root bun test in a temp HOME: 8530 pass, 19 skip, 0 fail.

Broken by hand on Linux, each red, then restored green:
- No probe in the .then: the slow cold-start test.
- probeSignedIn drops the list: the authorize and bounded-wait tests.
- agyPath change keeps the old offer: the agyPath test.
- Unbounded sign-in wait: the bounded-wait test (7514ms).
- Probe also on a failed listing: the hang test.
- origin/main's index.mjs with the new tests: all four #1064 tests.
- Adapter reads the list once: the warming adapter test, and the
  copy-identity check.

Not tried: a real agy (no Google sign-in, no network). The reset after
login.finish has no unit test of its own.

Reported-by: hiee3
2026-11-13 10:59:13 +08:00
tungloongandtungloong 753a61f85c agy-cli 0.1.31: wait for MCP commit before cancelling steered tool turns (#1061)
When a client steers a live tool turn, agy-cli now waits for agy to commit the MCP responses (a tool_call_update, the next generation, or the prompt ending; AGY_BRIDGE_MCP_COMMIT_WAIT_MS, default 5s) before sending session/cancel. Before, the cancel could beat the response, and agy recorded "Tool execution was canceled". A clean steer keeps SQLite step usage trusted, and an unpolled LONGTOOL result stays in the steered prompt. A steer in progress is not evicted or reclaimed, and a second steer gets 503.

Reviewed at 01de2cc. Run on a separate test Mac (Bun 1.4.2, temp HOME): bun scripts/check.mjs agy-cli ok; bun test ./packages/agy-cli 17 pass. Broken by hand: with no commit wait, the smoke steer case, six steer-in-session groups and usage-settlement go red. Not tried by the reviewer: a real agy (the author's live run on agy 1.5.6 is in the PR).

Co-authored-by: tungloong <tungloong@users.noreply.github.com>
2026-11-13 08:21:35 +08:00
tungloongandtungloong a2e601dc21 agy-cli 0.1.28: tool schemas with $ref/allOf/oneOf reach the model with their fields (#1042)
Tool schemas that use $ref, allOf or oneOf now reach the model with all their fields (expandToolSchema).

Nullable unions are lowered to type:[X,"null"]. Inlining is capped by depth (counted only along $ref and allOf), by 8192 nodes and by 256 KiB. A tool with no schema gets a plain object. The ToolSearch fallback was dropped.

Run at 80d19737 merged with main 16e753e8: `bun test packages/agy-cli` 16 pass, check ok.

Broken by hand: lowering a nullable union to a single type makes 1 test fail, and removing the byte cap makes 1 test fail.

Not tried: a real agy turn with these schemas.

Co-authored-by: tungloong <tungloong@users.noreply.github.com>
2026-11-13 00:23:26 +08:00
yetone 80d3a00ee3 agy-cli 0.1.24: no console window or leftover conhost on Windows (#1047)
agy dials --ide-mcp-port by running `nc` from PATH, and on Windows the
bridge's nc was nc.cmd: cmd.exe running mcp-server.mjs, two console
programs. When agy starts a console program with a console of its own
(CREATE_NEW_CONSOLE, or CREATE_NO_WINDOW), each dial gets a window or a
conhost.exe. Each session also made its own bin dir, and a host that
exited left its parked agy's cmd/bun children and its workspace dirs
behind.

- Under Bun (magpie's runtime), nc is now a GUI-subsystem nc.exe that
  Bun builds from mcp-server.mjs on the user's own machine (`bun build
  --compile --windows-hide-console`, ~0.3s on the test box). A GUI exe
  gets no console under any creation flags, and it still talks over the
  stdio pipes agy hands it. Nothing prebuilt ships. It lives in
  %TEMP%\magpie-agy-bridge-nc-<hash of runtime, Bun version and server
  source>, so every session and every later host reuses one build. A dir
  no host has used for a week, or a half-done build dir older than an
  hour, is swept. If the build fails, or the runtime isn't Bun (e.g.
  opencode.exe), nc.cmd is used as before.
- At exit on Windows one `taskkill /T /F` ends every live agy with its
  tree (cmd, nc). The workspace rm retries while the just-killed
  processes let go of their cwd. Only a shim dir this host made is
  removed; the shared nc.exe dir stays.

Run on Windows 11 (build 26200, xiaomi-gpu), Bun 1.4.2. A fake agy (Go)
answers ACP and dials `nc 127.0.0.1 <port>` 3 times per session, with
CreationFlags none, CREATE_NO_WINDOW or CREATE_NEW_CONSOLE. 4 sessions
per run, all 12 dials answered in every run below. conhost counts are
those under the host after 4 sessions, while agy is parked:
  old, none:       5 conhost; agy 4, cmd 4, bun 4; 4 workspace dirs leaked
  old, nowindow:   9 conhost (+2 per session); same leak
  old, newconsole: 9 conhost (+2 per session); same leak
  new, none / nowindow / newconsole: 5 conhost (the parked agy's own);
    agy 4, nc.exe 4, no cmd, no bun; one magpie-agy-bridge-nc-<hash>
    dir, nothing else left in TEMP after exit
  new, idle eviction (3s): back to 1 conhost, no agy/nc left
  new, host hard-killed: no agy/nc left; the 4 workspace dirs stay (no
    code runs after a hard kill; the same on old, which also leaks its
    bin dir)
  old, DETACHED_PROCESS: the dial never answers (agy start times out),
    so that isn't what the reported agy does.
The system-wide conhost count was 1 before and after every run.

Tests: test/windows-nc.mjs (6 tests, on any OS through the kit's
platform, execPath and versions overrides): the build command, the
shared dir built once and reused by a later host, no nc.cmd, the
nc.cmd fallback, the one-run tree kill at exit and which dirs it
removes.
Run at this tree on mica (Bun 1.4.2, temp HOME): bun test
packages/agy-cli 15 pass 0 fail; bun scripts/check.mjs exit 0.
On the Windows box: 14 pass, 1 fail. The red is smoke.mjs's "no call to
the loaded tool reaches agy's validator in the old prompt". It fails the
same way at origin/main 8768126 on the same box, and is filed as #973.
Broken by hand, each red in windows-nc.mjs: never using nc.exe (2
red), a build without --windows-hide-console (2), a rebuild per host (1),
SIGKILL per child instead of the taskkill tree (1), removing the shared
dir at exit (1).
Not tried: a real agy on Windows (it isn't installed on the box, and was
not downloaded); whether a window is visible (ssh runs in session 0,
where none is, so conhosts were counted instead); the reporter's build
26300. A host killed hard can still leave an agy that ignores stdin EOF:
only a job object around the plugin host (magpie's
internal/plugin/host.go starts it with a plain cmd.Start) would end it.

Reported-by: Tericerice <Tericerice@users.noreply.github.com>
2026-11-12 17:39:45 +08:00
tungloongandtungloong 01eaa6dda4 agy-cli 0.1.20: each step's usage from agy's own store, and 1.5.1+ inputTokens read as uncached (#983)
agy 1.5.1+ reports ACP `inputTokens` as uncached prompt tokens only; `promptUsage()` tells the exclusive shape from the inclusive one by `totalTokens`, so cache reads are no longer clipped and the learned cache ratio no longer pins to 1.0. Each HTTP step of a multi-step tool loop is settled from agy's own per-call rows in `conversations/<id>.db` (`gen_metadata` on 1.5.1+, `steps` type 15 on 1.4.x-1.5.0) when they reconcile with ACP's total; same-generation tool continuations settle at 0, a cancelled or fallen-back turn stops trusting the store, and a clipped cold-start replay bounds its fallback estimate.

The reader (`step-usage.mjs`) never opens a store read-write. Under Bun it opens with `SQLITE_OPEN_READONLY | SQLITE_OPEN_URI` (Bun's SQLite on Linux and Windows parses `file:` URIs only with that flag), finalizes statements and waits on no busy timeout. A checkpointed WAL store with no `-wal`/`-shm` is read through `?immutable=1` and gains no side files; if `-wal` appears during that read it is read again live. Store paths are resolved to absolute first, and Windows `\\?\` and UNC paths get their own `file:` form. On an uncheckpointed store the only file a reader touches is SQLite's `-shm` WAL index.

Reviewed head 9054f47295d51d6f83f8585dd550312ebff8448a (base dba24067; merges cleanly onto main 7c44d027).

What ran at that head, Bun 1.4.2 everywhere, fresh temp HOME (and USERPROFILE on Windows):
- macOS (mote): `bun test packages/agy-cli` 14/14; step-usage 10/10, usage-settlement 33/33; `node --test test/step-usage.mjs` (Node 22.22) 10/10; `bun scripts/check.mjs` ok.
- Linux (WSL Ubuntu 24.04): `bun test packages/agy-cli` 14/14; step-usage 10/10, usage-settlement 33/33; Node 22.23 10/10; check.mjs ok.
- Windows 11: step-usage 10/10 (the loopback UNC share was reachable, so its branch ran), usage-settlement 33/33, Node 10/10, check.mjs ok. `bun test packages/agy-cli` 13/14: smoke's one red is "no call to the loaded tool reaches agy's validator in the old prompt", the known #973 (1 of 334 checks), not touched here.
- Root `bun test` on mica, merged onto origin/main 7c44d027, under suite.lock: 8407 pass, 20 skip, 0 fail across 593 files (fresh temp HOME).

Broken by hand (restored after each):
- Linux: SQLITE_OPEN_URI dropped -> step-usage 3 red, usage-settlement 2 red; `path.resolve` dropped -> the URI/relative-path test red (Bun and Node); the "no -wal after a failed immutable read returns null" guard dropped -> the mid-read test red (Bun and Node).
- macOS: the re-read after `-wal` appears removed, and the failed-immutable-read path returning null outright -> the mid-read test red under Bun and Node (at 262145f4; the code is unchanged since).
- Windows: the `\\` branch of `immutableUri` disabled -> the URI/UNC test red.

Not tried: a real agy session or account (fake agy and fixture stores only); Bun versions other than 1.4.2; a remote (non-loopback) UNC share.

Co-authored-by: tungloong <19512489+tungloong@users.noreply.github.com>
2026-11-12 04:30:07 +08:00
yetone 445f4143de Revert "agy-cli 0.1.19: tools with large schemas are shortened so agy keeps them in the model's function list (#989, klarkxy on X)"
This reverts commit 8e6c75b1e3.
2026-11-11 19:32:15 +08:00
yetone 8e6c75b1e3 agy-cli 0.1.19: tools with large schemas are shortened so agy keeps them in the model's function list (#989, klarkxy on X)
agy lazy-loads MCP tools (McpToolConfig.EnableLazyLoad and a call_mcp_tool
tool are in the 1.5.5 binary): a tool with a large declaration never reaches
the model's function list and nothing says so. The reporter saw tools of
about 691 tokens and up missing (bash, grep), 561 and below present. The
exact cut-off is not in the binary.

tool-budget.mjs fits each tool under 2000 characters (about 500 tokens; env
AGY_BRIDGE_TOOL_BUDGET, 0 = off). Order of loss: default/examples/title,
nested descriptions to 90 chars, the tool's description, nested descriptions,
and last the largest optional parameters (never required ones). Each changed
tool is logged on stderr as agy_bridge_tool_shrunk, with what was lost and
stillOver when it cannot fit.

Run (mica, HOME=$(mktemp -d)): bun test packages/agy-cli 14 pass, scripts/check.mjs ok.
Broken by hand: without the fitTools call in the request path the smoke
check goes red (5201 chars). Not tried: a real agy 1.5.x with Gemini 4
Carbon, so the 2000-character budget rests on the reporter's numbers.
2026-11-11 19:31:36 +08:00
yetone 9ec696258d agy-cli 0.1.18: turned-away system lines are broken up before agy sends them, and a 429 to one is not a quota (#980)
Antigravity answers 429 "Resource has been exhausted" to a few system
prompt lines whatever quota is left (Claude Code's billing line, the Claude
Agent SDK, Codex's and Hermes Agent's identities, oh-my-pi's RFC 2119
line). The antigravity provider breaks them up with zero-width spaces
(TURNED_AWAY / breakUp / cloak); agy-cli sent the client's system prompt
to agy as written, and called the 429 an exhausted quota
(rate_limit_error), so a client or routing group retried a prompt that
fails every time.

- cloak.mjs is a copy of antigravity's TURNED_AWAY, cloak and hint (the
  two-zero-width-space break-up of 11-11). Each package ships on its own,
  so cloak.test.mjs imports packages/antigravity's _internal and fails
  when the two give a different answer for any line or sample.
- Every route the system text reaches agy is cloaked: the session's
  systemPrompt.append (session/new and session/resume),
  <external_system_instructions> when agy can't append, a later system
  or developer message in the turn or the replayed history
  (renderTurnMessageParts), and a system/developer notice delivered
  beside a tool result (extractToolResults).
- What the bridge keys and hashes on is unchanged: proc.instructions,
  sameInstructions, instructionsIdentity, stripVolatileSystem and the
  session store keep the prompt as the client wrote it; cloak is applied
  only where the text is sent. User text is not touched.
- #formatAgentError: a "code 429 ... Resource has been exhausted" with a
  turned-away line in the session's instructions is an
  invalid_request_error, "Antigravity answered 429 to this system prompt:
  <detail> — <hint>", with the antigravity provider's hint. Any other 429
  stays rate_limit_error.
- READMEs (en, zh) say so under the minimal-agent section.

Run (wsl-run, magpie-desktop, HOME=$(mktemp -d), at f85f9ad0 + this change):
- bun test packages/agy-cli: 13 pass 0 fail (smoke ALL OK, 333 checks)
- bun scripts/check.mjs: exit 0
- root bun test: 8189 pass, 19 skip, 0 fail (580 files, 408s)
- rebased on 84ee9b88 (day-card, autoclaw, sap-aicore only): bun test packages/agy-cli
  13 pass 0 fail and bun scripts/check.mjs exit 0 again at this head

Broken by hand (each red, then restored):
- append: this.instructions uncloaked -> "#980 ... session instructions" BAD
- <external_system_instructions> uncloaked -> its #980 check BAD
- later system message uncloaked -> "#980 a later system message" BAD
- tool-result notice uncloaked -> "#980 ... system notice beside a tool
  result" BAD
- the turned-away branch of #formatAgentError off -> the 429 came back
  rate_limit_error, "#980 a 429 ... prompt rejection" BAD
- cloak.mjs back to one zero-width space after the first letter -> both
  cloak.test.mjs tests red

Not tried: against real Antigravity or a real agy (no vendor API was
reached; the fake agy in test/smoke.mjs stands in). Whether agy's own
request puts the appended instructions where Google matches them is
taken from the report and the antigravity provider, not measured here.
A turned-away line the user pastes into their own message is sent as
written, as the antigravity provider does.

Reported-by: shaohongwu
2026-11-11 17:54:13 +08:00
yetoneandklarkxy dbd082f6d1 agy-cli 0.1.15: an array tool schema whose items live only on a sibling gets an items schema Gemini accepts (klarkxy #963)
Gemini refuses an array schema with no `items`. array-items.mjs infers
the items from the schema around it, or adds a permissive items schema 8
levels deep, without narrowing what the client allowed; tuple `items`
lists are left as they are, with a hint. Closes #962.

Reviewed head c7d3e7b8 (on c27ba5f7), landed onto main 738fd501 with the
version moved to 0.1.15 and package.json `files` keeping both
re2-pattern.mjs (#946) and array-items.mjs.
Run at the reviewed head: WSL2 bun test packages/agy-cli 9 of 9,
check.mjs ok; Windows 8 pass, 1 fail, the same smoke red as main (#973).
Broken by hand: without the ensureGeminiArrayItems call in normalizeTools
smoke.mjs reports 2 failures; PERMISSIVE_ARRAY_DEPTH = 1 and removing
`if (openArray) return null` each turn a test red.
Run at this commit (WSL2 Ubuntu 24.04, Bun 1.4.2, temp HOME): bun test
packages/agy-cli 10 of 10 pass; bun scripts/check.mjs agy-cli ok;
npm pack --dry-run lists 14 files, both new modules among them.
Not tried: macOS (mote refused ssh), a real agy.

Closes #963

Co-authored-by: klarkxy <klarkxy@users.noreply.github.com>
2026-11-11 13:35:07 +08:00
yetoneandklarkxy 738fd501d7 agy-cli 0.1.14: tool schema patterns are turned into RE2 or dropped, so an ECMA-262 pattern no longer aborts the turn (klarkxy #946)
Tool input schemas' `pattern` and `patternProperties` keys are translated
to RE2 (re2-pattern.mjs) before they reach agy; a pattern RE2 can't hold
is dropped with a hint, and `additionalProperties: false` is lifted when
every patternProperties key was dropped. Closes #944.

Reviewed head 99093088 (on c27ba5f7), landed onto main a0b1e491 with the
version moved to 0.1.14.
Run at the reviewed head: WSL2 bun test packages/agy-cli 9 of 9,
check.mjs ok; Windows 8 pass, 1 fail, the same smoke red as main (#973).
A fuzz of 1,033 kept patterns compiled every one with Go's regexp
(go1.26.8), against 222 failures before the `[:` fix. Broken by hand:
the `[:` reject, the sanitizePatternFields call, the propertyNames /
contains / if / then / else / unevaluated* recursion and the
additionalProperties lift each turn re2-pattern-unit.mjs red.
Run at this commit (WSL2 Ubuntu 24.04, Bun 1.4.2, temp HOME): bun test
packages/agy-cli 9 of 9 pass; bun scripts/check.mjs agy-cli ok.
Not tried: macOS (mote refused ssh), a real agy.

Closes #946

Co-authored-by: klarkxy <klarkxy@users.noreply.github.com>
2026-11-11 13:34:04 +08:00
Klarkxy 73d2006444 agy-cli 0.1.11: sessions survive canonicalized tool input; a first prompt's tool steps count the settled prefix as cached (ChrisJ_AI on X, klarkxy #971)
Reported by ChrisJ_AI on X: Claude Code on an agy-cli model showed 268K-input turns
at 0% cache hit, turn after turn.

Two places dropped cache reuse; both are klarkxy's #971 (closes #970):
- a follow-up turn after the client filled defaults into historical
  tool_use.input (Edit's replace_all) failed matchesHistory / takeParked, so
  the live agy session was retired and the whole prefix replayed;
- tool steps of a fresh process's first prompt reported every token as a
  cache miss until the prompt ended (no ratio learned yet).

Run at reviewed head 27245320 (win-run, xiaomi-gpu): node --test
test/usage-settlement.mjs 26/26 pass; the same file against c27ba5f7's
index.mjs fails tests 20, 21 and 24 (red on old code). bun test
packages/agy-cli: 7 of 8 pass, smoke.mjs 1 failure of 321 checks, the same
count on c27ba5f7.
Not tried: a real agy (signed out on every machine here, mote refused SSH),
so the 0% was not reproduced against Google's cache; the in-turn figure is
an estimate, not ACP usage.
2026-11-11 13:20:37 +08:00
yetoneandyulong-ge 03ab6d66f4 agy-cli 0.1.2: list what agy acp offers before the first request (#854)
Until a request had opened an ACP session, agy-cli listed Gemini only
(offeredFilter), so a user who hadn't sent a Gemini request yet saw no
Opus (chriskan666 on Discord). provider.models() now asks agy's ACP
server itself, as yulong-ge's antigravity-official-acp (#854) does:
a short `agy acp` with the plugin's own clientInfo, initialize and
session/new (no prompt), reading the session's model option and
models.availableModels into the same offered set a request's session
fills. The session is closed when agy says it can be, and the process
and its temp folder are removed.

- Only provider.models() probes; a request opens its own session.
- It runs once `agy models` has answered (agy is signed in), at most
  once a minute while the offer is unknown, and not at all once known.
- models() waits for it as briefly as for the listing (500ms) and
  never longer; a failed or timed-out probe (30s) keeps Gemini only.
- An agy older than 1.4.12 gets no session.

#854's own code reads session/new's availableModels, not `agy models`
(its body says `agy models`); agy-cli already parsed `agy models`, so
nothing of that parser changed.

Run at origin/main ae518836 plus this diff (this commit's tree) on mote (macOS), HOME=$(mktemp -d), under suite.lock:

- `bun test packages/agy-cli`: 6 of 7 suites pass; test/usage.mjs was red
  once ("version/report hangs time out", 1239ms), a timing test this
  change doesn't touch: filed as #856. It then passed 5 of 5 alone.
  catalog 17 pass, smoke ALL OK (314 checks).
- `bun scripts/check.mjs agy-cli`: registry.json and agy-cli ok.
- repo-root `bun test`: 6878 pass, 0 fail (6898 tests, 500 files).

Broken by hand: models() with the probe off. catalog.mjs went 2 red
(the probe lists Opus with no request; a failed probe is tried again
after a minute) and smoke.mjs 1 BAD ("listing models learns what agy's
ACP server offers, before any request").

Not tried: a real signed-in agy. This Mac's agy 1.5.3 (CLI 1.4.12) is
signed out: `agy models` says "Please sign in to view available
models", and its `agy acp` answers initialize and refuses session/new
with -32000 "Authentication required" (the fake's sign-in error is that
reply). mote has no agy. That the ACP session offers Claude and GPT-OSS
to a non-editor client rests on #854's author's run (agy 1.5.3 acp,
13 models incl. Claude and GPT-OSS).

Co-authored-by: yulong-ge <41790869+yulong-ge@users.noreply.github.com>
2026-11-08 13:17:47 +08:00
yetone ecab839688 agy-cli 0.1.1: sign in to Google from magpie, through agy's own agy acp --login
treeman_26897 (Discord #feedback, 11-08): Sign in on agy-cli opened no
browser, and asked for a field to paste the callback into.

Cause: the plugin had no sign-in of its own. Its one method only checked
whether `agy models` worked, and if not it said to run `agy` in a
terminal. magpie still showed "Finish signing in ... in your browser",
but nothing ever opened a page.

Now the method is oauth:
- Already signed in to agy (`agy models` lists models): done at once. No
  page opens and no agy login starts.
- Otherwise the plugin starts `agy acp --login` (agy 1.5 and later). That
  prints Google's link and reads the code from stdin. magpie opens the
  link on the user's machine and shows its code field (method "code").
  - The field takes the code antigravity.google/oauth-callback shows, or
    that page's whole address.
  - No loopback is involved, so it works with Remote magpie and in Docker.
- agy trades the code and keeps the token in its keyring. The plugin never
  sees the token.
- The account is saved only once `agy models` lists models afterwards. A
  wrong, empty or expired code fails, and nothing is saved. Google's
  invalid_grant is worded as "turned the code away".
- The link waits 15 minutes, then agy is stopped. A new sign-in stops the
  previous agy.
- agy 1.4.x has no --login. It gets "update with `agy update`, or run
  `agy` in a terminal".
- The login runs with auto-update off, like the plugin's other agy
  processes.

Import from a file is not added. agy keeps its credentials in the system
keyring, not in a file under ~/.gemini/antigravity-cli.

The empty account the report also describes was not reproduced on
current magpie. A failed sign-in saved nothing, in the GUI and the CLI.
This version also needs models listed before it saves anything.

Run:
- On mote (macOS, Bun 1.4.2) at this tree, `bun test` in packages/agy-cli:
  7 pass / 0 fail.
- `bun scripts/check.mjs` and `bun scripts/check.mjs agy-cli`: exit 0.
- New smoke checks, with the old index.mjs put back: red, at "signed in
  to agy already, the sign-in saves agy" (the old method has no callback).
- Real agy 1.5.3 on mote, sandbox HOME, current magpie `web`, through
  Playwright:
  - Providers > agy-cli opened Google's sign-in page, and the code field
    showed.
  - A bogus code gave "Sign-in didn't finish: Google turned the code
    away...". /api/providers had no agy row.
- `magpie plugin login agy-cli`:
  - With a bogus code, the same error.
  - With real agy 1.4.12, the update message.
- Real agy 1.5.3 on Windows 11 (win-run) and on Linux (WSL2 Ubuntu 24.04,
  wsl-run): authorize gave Google's link in about 2s, and a bogus code
  failed with the invalid_grant wording. No agy was left running.

Not tried:
- A real Google sign-in through to models. Only bogus codes were used, and
  no real account was touched.
- magpie inside a Docker container.

Reported-by: treeman_26897
2026-11-08 11:48:40 +08:00
gitxmandgitxm 0f0c4ec68f agy-cli: Antigravity on the local agy CLI over ACP (#785)
New package `@magpie-community/opencode-agy-cli-auth` (provider `agy-cli`, `packages/agy-cli`). It serves Antigravity models through the user's installed `agy` CLI over ACP (`agy acp`) and uses agy's own Google sign-in. The plugin reads and writes no Google tokens.

The bridge is gitxm's. On top of it, after review:

- **ACP identity.** The client names itself (`opencode-agy-cli-auth` and its package version) instead of `zed`.
- **Catalog.**
  - Only what agy offers this client is listed: Gemini until a session says more, then the session's model option and `availableModels`.
  - Requests are still routed by everything `agy models` lists.
- **Prompt.** agy keeps its own system prompt by default. The minimal agent is opt-in with `AGY_BRIDGE_MINIMAL_AGENT=1`, and the README says what turning it on sends upstream.
- **Version check.** agy older than 1.4.12 is refused at the handshake. 1.4.12 is the oldest version the `nc` MCP bridge was checked on, and the README documents the bridge.
- **Auto-update.**
  - `AGY_CLI_DISABLE_AUTO_UPDATE` defaults to `true` only for the plugin's own agy processes.
  - A value the user set is passed on as written.
- **Docs.** The READMEs and the registry summary say how this differs from antigravity-acp (#87).
- **Tests.** The author's tests came over under `test/` with a fake agy (an ACP stdio server). Each suite runs in its own `bun test`, and a `mock.module` preload stands in for `node:child_process`.
- **Cleanup.** A duplicate, unreachable image branch in validateBody is gone.

Run at ae5eafb0 on mote (macOS) with HOME=$(mktemp -d):

- `bun test packages/agy-cli`: 7 pass. Per suite:
  - platform 14, compat 9, usage 20;
  - catalog 15, usage-settlement 18, repeat-batch 14;
  - smoke ALL OK (301 checks).
- `bun scripts/check.mjs`: all ok.
- Repo-wide `bun test`: 6792 pass, 0 fail (6812 tests, 492 files).

Broken by hand, and each went red:

- clientInfo set back to zed;
- the version check turned off;
- routing limited to the listed models;
- auto-update forced to true;
- the minimal agent on by default.

Not tried: a real agy, since mote has none, or a real Antigravity account.

Co-authored-by: gitxm <21175063+gitxm@users.noreply.github.com>
2026-11-07 20:14:45 +08:00