5 Commits
Author SHA1 Message Date
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
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 768eafd6dc agy-cli 0.1.25: nc.exe is built under magpie's renamed Bun too (tearicerice on X)
windowsNcBuild() accepted only a runtime named bun / bun.exe. magpie's plugin
host runs the Bun it downloads as magpie-bun(.exe) (internal/plugin
bunupdate.go magpieBun), so on Windows 0.1.24 always returned null and fell
back to nc.cmd: the console window and conhost per `agy acp` MCP call stayed
(#1047). The name now matches (magpie-)?bun(.exe). An opencode build, which
reports a bun version but has no `build` command, and Node still get null.

Run: node --test packages/agy-cli/test/windows-nc.mjs on mica, 6 of 6 pass.
Broke by hand: the old regex puts the new magpie-bun.exe assertion red (1 of
6 fails). win-run on xiaomi-gpu: a copy of Bun renamed magpie-bun.exe,
platform.mjs picked it, `build --compile --windows-hide-console` exited 0,
nc.exe PE subsystem = 2 (GUI).
Siblings: no other package checks a Bun basename (grep).
Not tried: a real `agy acp` session on Windows.
2026-11-12 20:32:36 +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
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