agy-cli 0.1.97: usage finds an agy installed since at once, and a sign-in is named by its Google account
@tmr11235 on X (magpie v0.1.4520):
1. "The model test works, but the account says there is no CLI."
Usage held its "agy CLI not found" error for the backoff, which grows
from 10 minutes to 6 hours. A read made before agy was installed kept
saying "not found" for hours after a sign-in installed agy, while
chats and model tests already ran through it. Now:
- no agy found is never held;
- a held failure belongs to the agy path it was held for, so an agy
found since is read on the next refresh;
- the message says how magpie gets agy (sign in again), in noAgy's
words.
2. "After removing it and signing out, 登录 restored the account with no
sign-in, shown as API key." magpie's remove/sign-out deletes only
magpie's record. agy on the computer stays signed in, so 登录 adopts
that sign-in again with no browser (method 0's "auto"). That part is
by design. The "API key" label came from a sign-in saved without an
email: agy's keyring value names its account in id_token_email, and
when it doesn't (or the read fails), the saved record had no
metadata.email. pluginLabels then falls back to the record's type,
"API key". signedInAs now asks Google's userinfo with agy's own
access token when the stored value names no account, so the account
is listed under its email. An account saved before this keeps its
label until its next sign-in (登录 on it), which saves the email.
Their later quota "as of 2026/11/15, couldn't be read just now" is not
this: "not found" isn't a passing error, so magpie shows it rather than
an old reading. The read behind it fails with a timeout, 429 or network
error that magpie stood an old reading in for; magpie now says which
beside the date (magpie, readError).
Run (at origin/main bb849910 + this commit):
- mote, HOME=$(mktemp -d): packages/agy-cli `bun test`: 41 pass, 0 fail (3 files, 132s)
- test/usage.mjs alone: 46 pass, 0 fail. test/signin.mjs alone: 8 pass.
- The two new usage tests on the old usage.mjs (origin/main's), by hand:
both fail. signedInEmail's test fails there too (no such export).
- Real: agy 1.5.10's stored access token on this Mac, Google's userinfo
answers 200 with the account's email (masked in the log).
- Real Claude Code 2.1.327 through a sandbox magpie (agy-cli 0.1.96,
agy 1.5.10, gemini-3.8-flash, file sign-in in a sandbox HOME), for
the cache report from @niyezaimenglima: first run with a Read call
48,427 of 78,349 input cached; a --continue run 30,296 of 33,088
cached; one agy session for the conversation. Not reproduced, so no
change here for it.
Not tried: the reporter's own keyring value (whether it lacks
id_token_email, or an env sign-in was set); Windows and Linux; the
sign-in flow end to end in the GUI with the userinfo fallback.
This commit is contained in:
@@ -489,7 +489,7 @@ export async function fetchUsage(agy, {
|
||||
quota = readQuotaDirect,
|
||||
direct = false,
|
||||
} = {}) {
|
||||
if (!agy) throw new UsageError("agy CLI not found. Install it and run `agy` once to sign in.")
|
||||
if (!agy) throw new UsageError(NO_AGY)
|
||||
const deadline = Date.now() + timeout(timeoutMs)
|
||||
const directory = await fs.mkdtemp(path.join(tempRoot, "magpie-agy-usage-"))
|
||||
let pendingTreeKill = null
|
||||
@@ -600,6 +600,10 @@ function backoff(n) {
|
||||
return Math.min(BACKOFF_FIRST_MS * 2 ** Math.max(0, Math.min(n, 20) - 1), BACKOFF_MOST_MS)
|
||||
}
|
||||
|
||||
// what usage says while no agy is found: never held (createUsageReader),
|
||||
// and in noAgy's words, so it says how magpie gets one
|
||||
export const NO_AGY = "agy CLI not found. Sign in to this account again in magpie to have it installed, or install Antigravity CLI yourself."
|
||||
|
||||
const NEEDS_SIGN_IN = "Sign in again from this account's Sign in in magpie, or run `agy` in a terminal; magpie doesn't run agy for usage until then."
|
||||
|
||||
// No completed-result cache: sequential refreshes must see account/allowance changes.
|
||||
@@ -614,7 +618,10 @@ const NEEDS_SIGN_IN = "Sign in again from this account's Sign in in magpie, or r
|
||||
// - an explicit authentication rejection, or an ended token hanging silently
|
||||
// or with sign-in talk, blocks further background runs for that credential.
|
||||
// Diagnostic-only output isn't evidence of a browser sign-in.
|
||||
// - any other failure isn't run again for backoff(n).
|
||||
// - any other failure isn't run again for backoff(n). No agy found is not
|
||||
// held: finding it costs a few stat calls, and an agy installed since (a
|
||||
// sign-in installs it; tmr11235 on X saw it) is used on the next read,
|
||||
// not after hours of "not found" while its chats already run.
|
||||
export function createUsageReader(resolveAgy, options = {}) {
|
||||
const { signIn = () => storedSignIn(), now = () => Date.now(), ...fetchOptions } = options
|
||||
const pending = new Map()
|
||||
@@ -631,11 +638,14 @@ export function createUsageReader(resolveAgy, options = {}) {
|
||||
if (why) return expired(why)
|
||||
if (isDead(stored)) return expired("agy's sign-in no longer works")
|
||||
const key = stored?.state === "present" ? stored.fp : "unknown"
|
||||
if (held && held.key === key && now() < held.until) {
|
||||
const agy = resolveAgy()
|
||||
if (!agy) return { windows: [], error: NO_AGY, signIn: "kept" }
|
||||
// a failure held for another agy (gone, or another found since) isn't
|
||||
// this one's
|
||||
if (held && held.key === key && held.agy === agy && now() < held.until) {
|
||||
return { windows: [], error: held.error, signIn: held.auth ? "expired" : "kept" }
|
||||
}
|
||||
try {
|
||||
const agy = resolveAgy()
|
||||
// an access token that has ended or ends within two minutes, with a
|
||||
// refresh token: read without running agy (fetchUsage's direct)
|
||||
const direct = stored?.state === "present" && stored.canRenew && stored.expiresAt > 0 && stored.expiresAt - now() < 2 * 60 * 1000
|
||||
@@ -659,8 +669,8 @@ export function createUsageReader(resolveAgy, options = {}) {
|
||||
noteDead(stored)
|
||||
return expired("agy's sign-in no longer works")
|
||||
}
|
||||
const n = held?.key === key ? held.n + 1 : 1
|
||||
held = { key, n, until: now() + backoff(n), error: message, auth }
|
||||
const n = held?.key === key && held.agy === agy ? held.n + 1 : 1
|
||||
held = { key, agy, n, until: now() + backoff(n), error: message, auth }
|
||||
if (auth) saidExpired = true
|
||||
return { windows: [], error: message, signIn: auth ? "expired" : "kept" }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user