@expiren/opencode-antigravity-auth 1.6.25 → 1.6.27
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 +119 -32
- package/dist/index.js.map +3 -3
- package/dist/src/plugin/cli.d.ts +3 -2
- package/dist/src/plugin/cli.d.ts.map +1 -1
- package/dist/src/plugin/cli.js.map +1 -1
- package/dist/src/plugin/ui/auth-menu.d.ts +3 -8
- package/dist/src/plugin/ui/auth-menu.d.ts.map +1 -1
- package/dist/src/plugin/ui/auth-menu.js +133 -34
- package/dist/src/plugin/ui/auth-menu.js.map +1 -1
- package/dist/src/plugin.d.ts.map +1 -1
- package/dist/src/plugin.js +7 -0
- package/dist/src/plugin.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1683,11 +1683,11 @@ function classifyOverallQuotaHealth(cachedQuota) {
|
|
|
1683
1683
|
if (!cachedQuota) {
|
|
1684
1684
|
return { health: "unknown" };
|
|
1685
1685
|
}
|
|
1686
|
-
const
|
|
1686
|
+
const QUOTA_KEYS2 = ["claude", "gemini-pro", "gemini-flash"];
|
|
1687
1687
|
let groupsWithData = 0;
|
|
1688
1688
|
let exhaustedCount = 0;
|
|
1689
1689
|
let maxResetMs;
|
|
1690
|
-
for (const key of
|
|
1690
|
+
for (const key of QUOTA_KEYS2) {
|
|
1691
1691
|
const value = cachedQuota[key]?.remainingFraction;
|
|
1692
1692
|
if (typeof value !== "number" || !Number.isFinite(value)) continue;
|
|
1693
1693
|
groupsWithData++;
|
|
@@ -1779,6 +1779,114 @@ function getStatusBadge(status, account) {
|
|
|
1779
1779
|
return "";
|
|
1780
1780
|
}
|
|
1781
1781
|
}
|
|
1782
|
+
function getAccountTier(acc) {
|
|
1783
|
+
if (acc.isCurrentAccount) return 0;
|
|
1784
|
+
if (acc.enabled === false) return 6;
|
|
1785
|
+
if (acc.status === "active") {
|
|
1786
|
+
const overall = classifyOverallQuotaHealth(acc.cachedQuota);
|
|
1787
|
+
if (overall.health === "exhausted") return 3;
|
|
1788
|
+
if (overall.health === "partial") return 2;
|
|
1789
|
+
return 1;
|
|
1790
|
+
}
|
|
1791
|
+
if (acc.status === "rate-limited") return 4;
|
|
1792
|
+
return 5;
|
|
1793
|
+
}
|
|
1794
|
+
function getHealthLabel(acc) {
|
|
1795
|
+
if (acc.enabled === false) return "disabled";
|
|
1796
|
+
if (acc.status === "active") {
|
|
1797
|
+
const overall = classifyOverallQuotaHealth(acc.cachedQuota);
|
|
1798
|
+
if (overall.health === "exhausted") return "exhausted";
|
|
1799
|
+
if (overall.health === "partial") return "limited";
|
|
1800
|
+
return "active";
|
|
1801
|
+
}
|
|
1802
|
+
if (acc.status === "rate-limited") return "rate-limited";
|
|
1803
|
+
if (acc.status === "expired") return "expired";
|
|
1804
|
+
return "other";
|
|
1805
|
+
}
|
|
1806
|
+
var QUOTA_KEYS = [
|
|
1807
|
+
{ key: "claude", label: "Claude" },
|
|
1808
|
+
{ key: "gemini-pro", label: "Gemini Pro" },
|
|
1809
|
+
{ key: "gemini-flash", label: "Gemini Flash" }
|
|
1810
|
+
];
|
|
1811
|
+
function parseResetTimeToMs2(resetTime) {
|
|
1812
|
+
if (!resetTime) return null;
|
|
1813
|
+
const timestamp = Date.parse(resetTime);
|
|
1814
|
+
if (!Number.isFinite(timestamp)) return null;
|
|
1815
|
+
const ms = timestamp - Date.now();
|
|
1816
|
+
return ms > 0 ? ms : null;
|
|
1817
|
+
}
|
|
1818
|
+
function buildModelBreakdown(accounts) {
|
|
1819
|
+
const results = [];
|
|
1820
|
+
for (const { key, label } of QUOTA_KEYS) {
|
|
1821
|
+
let exhaustedCount = 0;
|
|
1822
|
+
let maxResetMs;
|
|
1823
|
+
for (const acc of accounts) {
|
|
1824
|
+
if (acc.enabled === false) continue;
|
|
1825
|
+
const group = acc.cachedQuota?.[key];
|
|
1826
|
+
if (!group || typeof group.remainingFraction !== "number") continue;
|
|
1827
|
+
if (group.remainingFraction <= 0) {
|
|
1828
|
+
exhaustedCount++;
|
|
1829
|
+
const resetMs = parseResetTimeToMs2(group.resetTime);
|
|
1830
|
+
if (resetMs !== null && (maxResetMs === void 0 || resetMs > maxResetMs)) {
|
|
1831
|
+
maxResetMs = resetMs;
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
if (exhaustedCount > 0) {
|
|
1836
|
+
const resetSuffix = maxResetMs !== void 0 ? ` ~${formatWaitDuration(maxResetMs)}` : "";
|
|
1837
|
+
results.push(`${label}: ${exhaustedCount} exhausted${resetSuffix}`);
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1840
|
+
return results;
|
|
1841
|
+
}
|
|
1842
|
+
function buildAccountSummary(accounts) {
|
|
1843
|
+
const counts = {};
|
|
1844
|
+
for (const acc of accounts) {
|
|
1845
|
+
const label = getHealthLabel(acc);
|
|
1846
|
+
counts[label] = (counts[label] ?? 0) + 1;
|
|
1847
|
+
}
|
|
1848
|
+
const order = ["active", "limited", "exhausted", "rate-limited", "expired", "disabled", "other"];
|
|
1849
|
+
const parts = order.filter((label) => (counts[label] ?? 0) > 0).map((label) => `${counts[label]} ${label}`);
|
|
1850
|
+
const modelBreakdown = buildModelBreakdown(accounts);
|
|
1851
|
+
const summary = parts.length > 0 ? parts.join(", ") : "";
|
|
1852
|
+
const modelPart = modelBreakdown.length > 0 ? ` | ${modelBreakdown.join(", ")}` : "";
|
|
1853
|
+
return summary ? `Accounts (${summary}${modelPart})` : "Accounts";
|
|
1854
|
+
}
|
|
1855
|
+
function buildAccountHint(account) {
|
|
1856
|
+
if (account.quotaSummary) {
|
|
1857
|
+
return account.quotaSummary;
|
|
1858
|
+
}
|
|
1859
|
+
if (account.lastUsed) {
|
|
1860
|
+
return `used ${formatRelativeTime(account.lastUsed)}`;
|
|
1861
|
+
}
|
|
1862
|
+
return "";
|
|
1863
|
+
}
|
|
1864
|
+
function buildAccountMenuItems(accounts) {
|
|
1865
|
+
const sorted = accounts.slice().sort((a, b) => getAccountTier(a) - getAccountTier(b));
|
|
1866
|
+
const items = [];
|
|
1867
|
+
let prevTier = -1;
|
|
1868
|
+
for (let i = 0; i < sorted.length; i++) {
|
|
1869
|
+
const account = sorted[i];
|
|
1870
|
+
const tier = getAccountTier(account);
|
|
1871
|
+
if (prevTier !== -1 && tier !== prevTier) {
|
|
1872
|
+
items.push({ label: "", value: { type: "cancel" }, separator: true });
|
|
1873
|
+
}
|
|
1874
|
+
prevTier = tier;
|
|
1875
|
+
const displayNum = i + 1;
|
|
1876
|
+
const statusBadge = getStatusBadge(account.status, account);
|
|
1877
|
+
const currentBadge = account.isCurrentAccount ? ` ${ANSI.cyan}[current]${ANSI.reset}` : "";
|
|
1878
|
+
const disabledBadge = account.enabled === false ? ` ${ANSI.red}[disabled]${ANSI.reset}` : "";
|
|
1879
|
+
const baseLabel = account.email || `Account ${displayNum}`;
|
|
1880
|
+
const numbered = `${displayNum}. ${baseLabel}`;
|
|
1881
|
+
const fullLabel = `${numbered}${currentBadge}${statusBadge}${disabledBadge}`;
|
|
1882
|
+
items.push({
|
|
1883
|
+
label: fullLabel,
|
|
1884
|
+
hint: buildAccountHint(account),
|
|
1885
|
+
value: { type: "select-account", account }
|
|
1886
|
+
});
|
|
1887
|
+
}
|
|
1888
|
+
return items;
|
|
1889
|
+
}
|
|
1782
1890
|
async function showAuthMenu(accounts) {
|
|
1783
1891
|
const items = [
|
|
1784
1892
|
{ label: "Actions", value: { type: "cancel" }, kind: "heading" },
|
|
@@ -1791,34 +1899,8 @@ async function showAuthMenu(accounts) {
|
|
|
1791
1899
|
{ label: "Verify all accounts", value: { type: "verify-all" }, color: "cyan" },
|
|
1792
1900
|
{ label: "Configure models in opencode.json", value: { type: "configure-models" }, color: "cyan" },
|
|
1793
1901
|
{ label: "", value: { type: "cancel" }, separator: true },
|
|
1794
|
-
{ label:
|
|
1795
|
-
...accounts
|
|
1796
|
-
const statusOrder = (acc) => {
|
|
1797
|
-
if (acc.isCurrentAccount) return 0;
|
|
1798
|
-
if (acc.status === "active") {
|
|
1799
|
-
const overall = classifyOverallQuotaHealth(acc.cachedQuota);
|
|
1800
|
-
if (overall.health === "exhausted") return 3;
|
|
1801
|
-
if (overall.health === "partial") return 2;
|
|
1802
|
-
return 1;
|
|
1803
|
-
}
|
|
1804
|
-
if (acc.status === "rate-limited") return 4;
|
|
1805
|
-
return 5;
|
|
1806
|
-
};
|
|
1807
|
-
return statusOrder(a) - statusOrder(b);
|
|
1808
|
-
}).map((account, displayIndex) => {
|
|
1809
|
-
const displayNum = displayIndex + 1;
|
|
1810
|
-
const statusBadge = getStatusBadge(account.status, account);
|
|
1811
|
-
const currentBadge = account.isCurrentAccount ? ` ${ANSI.cyan}[current]${ANSI.reset}` : "";
|
|
1812
|
-
const disabledBadge = account.enabled === false ? ` ${ANSI.red}[disabled]${ANSI.reset}` : "";
|
|
1813
|
-
const baseLabel = account.email || `Account ${displayNum}`;
|
|
1814
|
-
const numbered = `${displayNum}. ${baseLabel}`;
|
|
1815
|
-
const fullLabel = `${numbered}${currentBadge}${statusBadge}${disabledBadge}`;
|
|
1816
|
-
return {
|
|
1817
|
-
label: fullLabel,
|
|
1818
|
-
hint: account.quotaSummary ?? (account.lastUsed ? `used ${formatRelativeTime(account.lastUsed)}` : ""),
|
|
1819
|
-
value: { type: "select-account", account }
|
|
1820
|
-
};
|
|
1821
|
-
}),
|
|
1902
|
+
{ label: buildAccountSummary(accounts), value: { type: "cancel" }, kind: "heading" },
|
|
1903
|
+
...buildAccountMenuItems(accounts),
|
|
1822
1904
|
{ label: "", value: { type: "cancel" }, separator: true },
|
|
1823
1905
|
{ label: "Danger zone", value: { type: "cancel" }, kind: "heading" },
|
|
1824
1906
|
{ label: "Delete all accounts", value: { type: "delete-all" }, color: "red" }
|
|
@@ -1853,7 +1935,7 @@ async function showFingerprintHistory(history, accountLabel) {
|
|
|
1853
1935
|
{ label: "", value: null, separator: true },
|
|
1854
1936
|
{ label: "Fingerprint history", value: null, kind: "heading" },
|
|
1855
1937
|
...history.map((entry, index) => {
|
|
1856
|
-
const deviceShort = entry.deviceId.slice(0, 8);
|
|
1938
|
+
const deviceShort = entry.fingerprint.deviceId.slice(0, 8);
|
|
1857
1939
|
const reasonBadge = `${ANSI.dim}[${formatFingerprintReason(entry.reason)}]${ANSI.reset}`;
|
|
1858
1940
|
const label = `${index + 1}. ${deviceShort}... ${reasonBadge}`;
|
|
1859
1941
|
const hint = formatRelativeTime(entry.timestamp);
|
|
@@ -12847,6 +12929,7 @@ Alternatively, you can:
|
|
|
12847
12929
|
status = "rate-limited";
|
|
12848
12930
|
}
|
|
12849
12931
|
}
|
|
12932
|
+
const cooldownMs = acc.coolingDownUntil && acc.coolingDownUntil > now ? acc.coolingDownUntil - now : void 0;
|
|
12850
12933
|
return {
|
|
12851
12934
|
email: acc.email,
|
|
12852
12935
|
index: idx,
|
|
@@ -12855,7 +12938,11 @@ Alternatively, you can:
|
|
|
12855
12938
|
status,
|
|
12856
12939
|
isCurrentAccount: idx === (existingStorage2.activeIndex ?? 0),
|
|
12857
12940
|
enabled: acc.enabled !== false,
|
|
12858
|
-
quotaSummary: formatCachedQuotaSummary(acc)
|
|
12941
|
+
quotaSummary: formatCachedQuotaSummary(acc),
|
|
12942
|
+
cooldownMs,
|
|
12943
|
+
cooldownReason: cooldownMs ? acc.cooldownReason : void 0,
|
|
12944
|
+
cachedQuota: acc.cachedQuota,
|
|
12945
|
+
fingerprintHistory: acc.fingerprintHistory
|
|
12859
12946
|
};
|
|
12860
12947
|
});
|
|
12861
12948
|
menuResult = await promptLoginMode(existingAccounts);
|