@timmyjl12/pi-agy-bridge 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/package.json +1 -1
- package/src/account-manager.ts +3 -1
- package/src/accounts.ts +49 -4
- package/src/ui/menu.ts +46 -8
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Use Google Antigravity models (Gemini, Claude, GPT-OSS) in [pi](https://github.c
|
|
|
4
4
|
|
|
5
5
|
It follows the design of `pi-claude-code`: **pi keeps the conversation, the approvals and the tool execution; agy is only the model.** Every pi request becomes one ACP prompt turn. When the model wants a pi tool it writes a small tool-call block, pi runs the tool, and the next request carries the result. Nothing is parked between requests, so a slow tool (a long `pytest` run, a user dialog) can take as long as it needs and there is no turn time limit.
|
|
6
6
|
|
|
7
|
-
> Status: 0.2.0. Multiple Antigravity accounts: each extra account runs as its own provider `agy-<alias or id>` with its own login, managed from `/agy-bridge menu` or the `/agy-bridge` account commands; verified live on agy 1.5.14 with two Google accounts answering side by side. agy 1.5.14 is now tested: it refuses pi's appended system prompt silently (no notice for ~2 min), which uto now detects with a 30 s refusal probe and answers inline (see [Multiple Antigravity accounts](#multiple-antigravity-accounts)). 0.1.5: the default bridge home now honors Pi's configured agent directory (`PI_CODING_AGENT_DIR`). Every Pi session shutdown now recycles the outgoing runtime instead of permanently latching it shut, so a late pi-advisor retry can start a fresh ACP process; explicit terminal disposal remains terminal. The compatibility probe passed on `agy 1.5.8`, `1.5.9` and `1.5.12`; the drift from 1.5.9 to 1.5.12 is additive only (the `gemini-4-neon` family, `gemini-pro-orchestrator-neon`, and `xhigh` as a `thought_level`). The `google-antigravity` SDK is current at `0.1.23` on both PyPI and the SDK repository, and its fingerprint still matches the recorded baseline. On 2026-11-14 (agy 1.5.9) the Antigravity backend began refusing pi's default system prompt sent through the append hook with `RESOURCE_EXHAUSTED`; live `gemini-4-hydrogen` turns and pi-subagents runs succeed through the `auto` inline fallback (see `PI_AGY_SYSTEM_PROMPT`). Earlier live bridge checks passed on `agy 1.5.8`. Live turns succeeded on `gemini-3.8-flash`, `gemini-4-hydrogen` (including `xhigh`), and `gemini-pro-orchestrator-g1-pro`. A real pi surface check with the configured extensions also passed. Claude, GPT-OSS and the `gemini-4-neon` family have not been exercised in a live model turn.
|
|
7
|
+
> Status: 0.2.1. Extra-account sign-in works on agy 1.5.14: agy now prints a link and waits for the authorization code, so the bridge opens the link and asks for the code in a dialog. 0.2.0: Multiple Antigravity accounts: each extra account runs as its own provider `agy-<alias or id>` with its own login, managed from `/agy-bridge menu` or the `/agy-bridge` account commands; verified live on agy 1.5.14 with two Google accounts answering side by side. agy 1.5.14 is now tested: it refuses pi's appended system prompt silently (no notice for ~2 min), which uto now detects with a 30 s refusal probe and answers inline (see [Multiple Antigravity accounts](#multiple-antigravity-accounts)). 0.1.5: the default bridge home now honors Pi's configured agent directory (`PI_CODING_AGENT_DIR`). Every Pi session shutdown now recycles the outgoing runtime instead of permanently latching it shut, so a late pi-advisor retry can start a fresh ACP process; explicit terminal disposal remains terminal. The compatibility probe passed on `agy 1.5.8`, `1.5.9` and `1.5.12`; the drift from 1.5.9 to 1.5.12 is additive only (the `gemini-4-neon` family, `gemini-pro-orchestrator-neon`, and `xhigh` as a `thought_level`). The `google-antigravity` SDK is current at `0.1.23` on both PyPI and the SDK repository, and its fingerprint still matches the recorded baseline. On 2026-11-14 (agy 1.5.9) the Antigravity backend began refusing pi's default system prompt sent through the append hook with `RESOURCE_EXHAUSTED`; live `gemini-4-hydrogen` turns and pi-subagents runs succeed through the `auto` inline fallback (see `PI_AGY_SYSTEM_PROMPT`). Earlier live bridge checks passed on `agy 1.5.8`. Live turns succeeded on `gemini-3.8-flash`, `gemini-4-hydrogen` (including `xhigh`), and `gemini-pro-orchestrator-g1-pro`. A real pi surface check with the configured extensions also passed. Claude, GPT-OSS and the `gemini-4-neon` family have not been exercised in a live model turn.
|
|
8
8
|
|
|
9
9
|
## Requirements
|
|
10
10
|
|
|
@@ -59,12 +59,14 @@ agy keeps one login per OS user (on Windows the Credential Manager entry `gemini
|
|
|
59
59
|
|
|
60
60
|
```
|
|
61
61
|
/agy-bridge add acct2 # or: /agy-bridge menu → Add account
|
|
62
|
-
# your browser opens: sign in with the second Google account
|
|
62
|
+
# your browser opens: sign in with the second Google account, then paste the
|
|
63
|
+
# authorization code (or the full URL of the page you land on) into pi's prompt
|
|
63
64
|
/agy-bridge accounts
|
|
64
65
|
agy default agy's own login enabled
|
|
65
66
|
agy-acct2 acct2 timm…2385@gmail.com enabled
|
|
66
67
|
```
|
|
67
68
|
|
|
69
|
+
- **Sign-in on agy 1.5.14+.** With a per-account token file agy no longer catches the browser redirect; it prints a link and waits for the code. The bridge opens that link (set `PI_AGY_NO_BROWSER=1` to only show it), asks for the code in a dialog and passes it to agy. An empty answer cancels.
|
|
68
70
|
- **Your default account is unchanged.** `agy/<model>` keeps using agy's normal login; without extra accounts this package behaves exactly as before.
|
|
69
71
|
- **Use them in fallback chains.** A quota error on one account parks only that `provider/model` (pi-fallback-chains' per-model quota rule), so a chain can continue on the next account:
|
|
70
72
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@timmyjl12/pi-agy-bridge",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "pi provider for Google Antigravity (agy) models over the official ACP server, modelled on pi-claude-code: pi keeps the loop, history and tool execution",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/src/account-manager.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
type LoginHandle,
|
|
23
23
|
type LoginProgress,
|
|
24
24
|
type LoginResult,
|
|
25
|
+
type RequestLoginCode,
|
|
25
26
|
} from "./accounts.ts";
|
|
26
27
|
import { describeError } from "./errors.ts";
|
|
27
28
|
import { describeModels } from "./model-catalog.ts";
|
|
@@ -303,7 +304,7 @@ export class AccountManager {
|
|
|
303
304
|
|
|
304
305
|
/** Sign an extra account in through `agy acp --login` (browser). On success the email is recorded as the
|
|
305
306
|
* account's expected identity and its provider is refreshed. */
|
|
306
|
-
async login(id: string, onProgress?: (progress: LoginProgress) => void): Promise<LoginResult> {
|
|
307
|
+
async login(id: string, onProgress?: (progress: LoginProgress) => void, requestCode?: RequestLoginCode): Promise<LoginResult> {
|
|
307
308
|
await this.load();
|
|
308
309
|
if (id === DEFAULT_ACCOUNT) {
|
|
309
310
|
return { ok: false, message: "the default account uses agy's own login: run `agy` in a terminal and sign in there" };
|
|
@@ -319,6 +320,7 @@ export class AccountManager {
|
|
|
319
320
|
id,
|
|
320
321
|
env: this.#options.runtime?.pool?.env ?? process.env,
|
|
321
322
|
onProgress,
|
|
323
|
+
...(requestCode ? { requestCode } : {}),
|
|
322
324
|
...(this.#options.loginPrefixArgs ? { prefixArgs: this.#options.loginPrefixArgs } : {}),
|
|
323
325
|
});
|
|
324
326
|
this.#logins.set(id, handle);
|
package/src/accounts.ts
CHANGED
|
@@ -259,6 +259,13 @@ export interface LoginProgress {
|
|
|
259
259
|
line?: string;
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
+
/** agy >= 1.5.14 with file token storage does not catch the OAuth redirect itself: it prints the sign-in link and
|
|
263
|
+
* waits on stdin for the authorization code (or the full URL of the page the browser lands on). */
|
|
264
|
+
const CODE_PROMPT = /paste the authorization code/i;
|
|
265
|
+
|
|
266
|
+
/** Asked once agy waits for the authorization code. Resolve with the code / landing URL, or undefined to cancel. */
|
|
267
|
+
export type RequestLoginCode = (url: string | undefined, signal: AbortSignal) => Promise<string | undefined>;
|
|
268
|
+
|
|
262
269
|
export interface LoginResult {
|
|
263
270
|
ok: boolean;
|
|
264
271
|
email?: string;
|
|
@@ -279,6 +286,8 @@ export function startLogin(options: {
|
|
|
279
286
|
env?: NodeJS.ProcessEnv;
|
|
280
287
|
timeoutMs?: number;
|
|
281
288
|
onProgress?: (progress: LoginProgress) => void;
|
|
289
|
+
/** Supplies the authorization code when agy asks for it. Without it agy's stdin is closed (sign-in fails). */
|
|
290
|
+
requestCode?: RequestLoginCode;
|
|
282
291
|
/** Test seam: arguments placed before agy's own (e.g. a fake script run by node). */
|
|
283
292
|
prefixArgs?: readonly string[];
|
|
284
293
|
}): LoginHandle {
|
|
@@ -293,16 +302,48 @@ export function startLogin(options: {
|
|
|
293
302
|
child = spawn(options.command, args, {
|
|
294
303
|
cwd: paths.root,
|
|
295
304
|
env: { ...(options.env ?? process.env), ...FILE_STORAGE_ENV },
|
|
296
|
-
stdio: ["
|
|
305
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
297
306
|
windowsHide: true,
|
|
298
307
|
});
|
|
308
|
+
const stdin = child.stdin;
|
|
309
|
+
stdin?.on("error", () => undefined); // agy may exit before the code is written (EPIPE)
|
|
310
|
+
if (!options.requestCode) stdin?.end();
|
|
311
|
+
const asking = new AbortController();
|
|
312
|
+
let loginUrl: string | undefined;
|
|
313
|
+
let prompted = false;
|
|
314
|
+
let transcript = "";
|
|
315
|
+
const askForCode = async (): Promise<void> => {
|
|
316
|
+
if (!options.requestCode || !stdin) return;
|
|
317
|
+
let code: string | undefined;
|
|
318
|
+
try {
|
|
319
|
+
code = await options.requestCode(loginUrl, asking.signal);
|
|
320
|
+
} catch {
|
|
321
|
+
code = undefined;
|
|
322
|
+
}
|
|
323
|
+
if (asking.signal.aborted) return;
|
|
324
|
+
const value = code?.trim();
|
|
325
|
+
if (!value) {
|
|
326
|
+
cancelled = true;
|
|
327
|
+
child?.kill();
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
stdin.end(`${value}\n`);
|
|
331
|
+
};
|
|
299
332
|
const onText = (chunk: Buffer | string): void => {
|
|
300
|
-
|
|
301
|
-
|
|
333
|
+
const text = String(chunk).replace(/\x1b\[[0-9;]*m/g, "");
|
|
334
|
+
for (const line of text.split(/\r?\n/)) {
|
|
335
|
+
const clean = line.trim();
|
|
302
336
|
if (!clean) continue;
|
|
303
337
|
const url = /https:\/\/\S+/.exec(clean)?.[0];
|
|
338
|
+
if (url && !loginUrl) loginUrl = url;
|
|
304
339
|
options.onProgress?.(url ? { url, line: clean } : { line: clean });
|
|
305
340
|
}
|
|
341
|
+
// The prompt has no trailing newline and may arrive split across chunks.
|
|
342
|
+
transcript = (transcript + text).slice(-4096);
|
|
343
|
+
if (!prompted && CODE_PROMPT.test(transcript)) {
|
|
344
|
+
prompted = true;
|
|
345
|
+
void askForCode();
|
|
346
|
+
}
|
|
306
347
|
};
|
|
307
348
|
child.stdout?.on("data", onText);
|
|
308
349
|
child.stderr?.on("data", onText);
|
|
@@ -326,6 +367,7 @@ export function startLogin(options: {
|
|
|
326
367
|
resolve({ code });
|
|
327
368
|
});
|
|
328
369
|
});
|
|
370
|
+
asking.abort(); // dismiss a still-open code dialog when agy has already exited
|
|
329
371
|
const identity = await readIdentity(paths.loginLog);
|
|
330
372
|
if (cancelled) return { ok: false, message: "sign-in cancelled" };
|
|
331
373
|
if (exit.error) return { ok: false, message: `could not start agy: ${exit.error.message}` };
|
|
@@ -336,7 +378,10 @@ export function startLogin(options: {
|
|
|
336
378
|
if (!identity.fileStorage) {
|
|
337
379
|
return { ok: false, message: "agy did not switch to per-account token storage; the account was not isolated (see UPGRADING.md)" };
|
|
338
380
|
}
|
|
339
|
-
if (!identity.email)
|
|
381
|
+
if (!identity.email) {
|
|
382
|
+
const reason = /(?:Error|couldn't log in):?\s*(.+)$/im.exec(transcript)?.[1]?.trim();
|
|
383
|
+
return { ok: false, message: `sign-in did not complete (agy exit code ${exit.code ?? "?"}${reason ? `: ${reason}` : ""})` };
|
|
384
|
+
}
|
|
340
385
|
return { ok: true, email: identity.email, message: `signed in as ${maskEmail(identity.email)}` };
|
|
341
386
|
})();
|
|
342
387
|
return {
|
package/src/ui/menu.ts
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
// Every action here calls the same AccountManager / runtime function as its `/agy-bridge` subcommand, so the menu and
|
|
4
4
|
// the commands can never drift. In a non-TUI host (RPC, print) the same actions run through ui.select/input/confirm.
|
|
5
5
|
|
|
6
|
+
import { spawn } from "node:child_process";
|
|
6
7
|
import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
7
|
-
import { DEFAULT_ACCOUNT, labelFor, maskEmail, validateAccountName } from "../accounts.ts";
|
|
8
|
+
import { DEFAULT_ACCOUNT, labelFor, maskEmail, validateAccountName, type RequestLoginCode } from "../accounts.ts";
|
|
8
9
|
import type { AccountManager, AccountView } from "../account-manager.ts";
|
|
9
10
|
import { buildDoctor, buildStatus } from "../doctor.ts";
|
|
10
11
|
import { CONFIG_ENV_NAMES } from "../config.ts";
|
|
@@ -182,15 +183,52 @@ export function accountActionsView(view: AccountView, loginRunning: boolean): Pa
|
|
|
182
183
|
|
|
183
184
|
// ---- actions (shared with commands) ------------------------------------------------------------------------------
|
|
184
185
|
|
|
186
|
+
/** Open a URL in the system browser. agy with per-account token storage only prints its sign-in link, so the bridge
|
|
187
|
+
* opens it. Disabled by PI_AGY_NO_BROWSER=1. Failures are ignored: the link is also shown as a notification. */
|
|
188
|
+
export function openInBrowser(url: string, env: NodeJS.ProcessEnv = process.env): boolean {
|
|
189
|
+
// Only Google's own sign-in page: the URL comes from a child process's output.
|
|
190
|
+
if (env.PI_AGY_NO_BROWSER === "1" || !url.startsWith("https://accounts.google.com/")) return false;
|
|
191
|
+
const [command, args] =
|
|
192
|
+
process.platform === "win32"
|
|
193
|
+
? ["rundll32", ["url.dll,FileProtocolHandler", url]] // no cmd.exe: '&' in the URL needs no quoting
|
|
194
|
+
: process.platform === "darwin"
|
|
195
|
+
? ["open", [url]]
|
|
196
|
+
: ["xdg-open", [url]];
|
|
197
|
+
try {
|
|
198
|
+
const child = spawn(command, args, { detached: true, stdio: "ignore", windowsHide: true });
|
|
199
|
+
child.on("error", () => undefined);
|
|
200
|
+
child.unref();
|
|
201
|
+
return true;
|
|
202
|
+
} catch {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** Ask for the authorization code agy waits for. The URL is also sent as a notification so it can be copied. */
|
|
208
|
+
export function codeRequester(ctx: Ctx, id: string): RequestLoginCode | undefined {
|
|
209
|
+
if (!ctx.hasUI) return undefined;
|
|
210
|
+
return (_url, signal) =>
|
|
211
|
+
ctx.ui.input(
|
|
212
|
+
`Sign-in for "${id}": after approving in the browser, paste the code (or the full URL of the page you land on); empty = cancel`,
|
|
213
|
+
"authorization code or https://antigravity.google/oauth-callback?...",
|
|
214
|
+
{ signal },
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
185
218
|
export async function runLogin(manager: AccountManager, id: string, ctx: Ctx, notify: Notify): Promise<boolean> {
|
|
186
|
-
notify(`pi-agy-bridge: signing in account "${id}" —
|
|
219
|
+
notify(`pi-agy-bridge: signing in account "${id}" — open the link below, approve, then paste the code it shows (up to 5 min)…`, "info");
|
|
187
220
|
let urlShown = false;
|
|
188
|
-
const result = await manager.login(
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
221
|
+
const result = await manager.login(
|
|
222
|
+
id,
|
|
223
|
+
(progress) => {
|
|
224
|
+
if (progress.url && !urlShown) {
|
|
225
|
+
urlShown = true;
|
|
226
|
+
const opened = openInBrowser(progress.url);
|
|
227
|
+
notify(`pi-agy-bridge: ${opened ? "opened the sign-in page; if no browser appeared, visit" : "sign-in link"}: ${progress.url}`, "info");
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
codeRequester(ctx, id),
|
|
231
|
+
);
|
|
194
232
|
notify(`pi-agy-bridge: ${id}: ${result.message}`, result.ok ? "info" : "error");
|
|
195
233
|
if (result.ok) {
|
|
196
234
|
const check = await manager.check(id);
|