@expiren/opencode-antigravity-auth 1.6.22 → 1.6.23

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/dist/index.js CHANGED
@@ -1638,7 +1638,7 @@ function formatQuotaStatusBadge(status) {
1638
1638
  return `${ANSI.yellow}[WAIT${suffix}]${ANSI.reset}`;
1639
1639
  }
1640
1640
  case "EXHAUSTED": {
1641
- const suffix = status.waitMs ? ` resets in ${formatWaitDuration(status.waitMs)}` : " resets in ?h";
1641
+ const suffix = status.waitMs ? ` resets in ${formatWaitDuration(status.waitMs)}` : "";
1642
1642
  return `${ANSI.red}[EXHAUSTED${suffix}]${ANSI.reset}`;
1643
1643
  }
1644
1644
  case "COOLDOWN": {
@@ -1664,7 +1664,7 @@ function formatQuotaStatusPlain(status) {
1664
1664
  return `WAIT${suffix}`;
1665
1665
  }
1666
1666
  case "EXHAUSTED": {
1667
- const suffix = status.waitMs ? ` resets in ${formatWaitDuration(status.waitMs)}` : " resets in ?h";
1667
+ const suffix = status.waitMs ? ` resets in ${formatWaitDuration(status.waitMs)}` : "";
1668
1668
  return `EXHAUSTED${suffix}`;
1669
1669
  }
1670
1670
  case "COOLDOWN": {
@@ -1679,10 +1679,39 @@ function formatQuotaStatusPlain(status) {
1679
1679
  }
1680
1680
  }
1681
1681
  }
1682
+ function classifyOverallQuotaHealth(cachedQuota) {
1683
+ if (!cachedQuota) {
1684
+ return { health: "unknown" };
1685
+ }
1686
+ const QUOTA_KEYS = ["claude", "gemini-pro", "gemini-flash"];
1687
+ let groupsWithData = 0;
1688
+ let exhaustedCount = 0;
1689
+ let maxResetMs;
1690
+ for (const key of QUOTA_KEYS) {
1691
+ const value = cachedQuota[key]?.remainingFraction;
1692
+ if (typeof value !== "number" || !Number.isFinite(value)) continue;
1693
+ groupsWithData++;
1694
+ if (value <= 0) {
1695
+ exhaustedCount++;
1696
+ const resetMs = parseResetTimeToMs(cachedQuota[key]?.resetTime);
1697
+ if (resetMs !== null && (maxResetMs === void 0 || resetMs > maxResetMs)) {
1698
+ maxResetMs = resetMs;
1699
+ }
1700
+ }
1701
+ }
1702
+ if (groupsWithData === 0) return { health: "unknown" };
1703
+ if (exhaustedCount === groupsWithData) return { health: "exhausted", maxResetMs };
1704
+ if (exhaustedCount > 0) return { health: "partial", maxResetMs };
1705
+ return { health: "available" };
1706
+ }
1682
1707
  function formatCachedQuotaWithStatus(cachedQuota) {
1683
1708
  if (!cachedQuota) {
1684
1709
  return void 0;
1685
1710
  }
1711
+ const overall = classifyOverallQuotaHealth(cachedQuota);
1712
+ if (overall.health === "exhausted") {
1713
+ return overall.maxResetMs ? `resets in ${formatWaitDuration(overall.maxResetMs)}` : void 0;
1714
+ }
1686
1715
  const entries = [
1687
1716
  { key: "claude", label: "Claude" },
1688
1717
  { key: "gemini-pro", label: "Gemini Pro" },
@@ -1727,6 +1756,13 @@ function getStatusBadge(status, account) {
1727
1756
  const cooldownStatus = buildCooldownStatus(account.cooldownMs, account.cooldownReason);
1728
1757
  return ` ${formatQuotaStatusBadge(cooldownStatus)}`;
1729
1758
  }
1759
+ if (status === "active" && account?.cachedQuota) {
1760
+ const overall = classifyOverallQuotaHealth(account.cachedQuota);
1761
+ if (overall.health === "exhausted") {
1762
+ const suffix = overall.maxResetMs ? ` resets in ${formatWaitDuration(overall.maxResetMs)}` : "";
1763
+ return ` ${ANSI.red}[exhausted${suffix}]${ANSI.reset}`;
1764
+ }
1765
+ }
1730
1766
  switch (status) {
1731
1767
  case "active":
1732
1768
  return ` ${ANSI.green}[active]${ANSI.reset}`;
@@ -1756,9 +1792,13 @@ async function showAuthMenu(accounts) {
1756
1792
  ...accounts.slice().sort((a, b) => {
1757
1793
  const statusOrder = (acc) => {
1758
1794
  if (acc.isCurrentAccount) return 0;
1759
- if (acc.status === "active") return 1;
1760
- if (acc.status === "rate-limited") return 2;
1761
- return 3;
1795
+ if (acc.status === "active") {
1796
+ const overall = classifyOverallQuotaHealth(acc.cachedQuota);
1797
+ if (overall.health === "exhausted") return 2;
1798
+ return 1;
1799
+ }
1800
+ if (acc.status === "rate-limited") return 3;
1801
+ return 4;
1762
1802
  };
1763
1803
  return statusOrder(a) - statusOrder(b);
1764
1804
  }).map((account) => {