@expiren/opencode-antigravity-auth 1.6.33 → 1.6.34

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
@@ -9049,6 +9049,8 @@ var AccountManager = class _AccountManager {
9049
9049
  savePending = false;
9050
9050
  saveTimeout = null;
9051
9051
  savePromiseResolvers = [];
9052
+ sessionStartTime = Date.now();
9053
+ sessionRequestCounts = /* @__PURE__ */ new Map();
9052
9054
  static async loadFromDisk(authFallback) {
9053
9055
  const stored = await loadAccounts();
9054
9056
  return new _AccountManager(authFallback, stored);
@@ -9716,6 +9718,7 @@ var AccountManager = class _AccountManager {
9716
9718
  }
9717
9719
  account.dailyRequestCounts[family]++;
9718
9720
  account.lastUsed = nowMs();
9721
+ this.recordSessionRequest(accountIndex, family);
9719
9722
  }
9720
9723
  /**
9721
9724
  * Get request counts for an account for today.
@@ -9755,6 +9758,45 @@ var AccountManager = class _AccountManager {
9755
9758
  }
9756
9759
  return result.sort((a, b) => b.count - a.count);
9757
9760
  }
9761
+ /**
9762
+ * Record a request for the current session (in-memory only).
9763
+ */
9764
+ recordSessionRequest(accountIndex, family) {
9765
+ const key = String(accountIndex);
9766
+ const current = this.sessionRequestCounts.get(key) ?? { claude: 0, gemini: 0 };
9767
+ current[family]++;
9768
+ this.sessionRequestCounts.set(key, current);
9769
+ }
9770
+ /**
9771
+ * Get a summary of the current session's request usage.
9772
+ */
9773
+ getSessionSummary() {
9774
+ const durationMs = Date.now() - this.sessionStartTime;
9775
+ const durationMinutes = Math.round(durationMs / 6e4);
9776
+ const durationHours = durationMs / 36e5;
9777
+ let totalClaude = 0;
9778
+ let totalGemini = 0;
9779
+ const perAccount = [];
9780
+ for (const [key, counts] of this.sessionRequestCounts) {
9781
+ const idx = Number(key);
9782
+ const account = this.accounts[idx];
9783
+ totalClaude += counts.claude;
9784
+ totalGemini += counts.gemini;
9785
+ if (counts.claude > 0 || counts.gemini > 0) {
9786
+ perAccount.push({ index: idx, email: account?.email, claude: counts.claude, gemini: counts.gemini });
9787
+ }
9788
+ }
9789
+ const totalRequests = totalClaude + totalGemini;
9790
+ const requestsPerHour = durationHours > 0 ? Math.round(totalRequests / durationHours) : 0;
9791
+ return {
9792
+ durationMinutes,
9793
+ totalClaude,
9794
+ totalGemini,
9795
+ requestsPerHour,
9796
+ accountsUsed: perAccount.length,
9797
+ perAccount: perAccount.sort((a, b) => b.claude + b.gemini - (a.claude + a.gemini))
9798
+ };
9799
+ }
9758
9800
  isAccountOverSoftQuota(account, family, thresholdPercent, cacheTtlMs, model) {
9759
9801
  return isOverSoftQuotaThreshold(account, family, thresholdPercent, cacheTtlMs, model);
9760
9802
  }
@@ -12026,6 +12068,16 @@ var createAntigravityPlugin = (providerId) => async ({ client, directory }) => {
12026
12068
  const eventHandler = async (input2) => {
12027
12069
  await updateChecker.event(input2);
12028
12070
  if (input2.event.type === "session.created") {
12071
+ const prevSummary = activeAccountManager?.getSessionSummary();
12072
+ if (prevSummary && (prevSummary.totalClaude > 0 || prevSummary.totalGemini > 0)) {
12073
+ log10.debug("prev-session-quota-summary", {
12074
+ durationMinutes: prevSummary.durationMinutes,
12075
+ totalClaude: prevSummary.totalClaude,
12076
+ totalGemini: prevSummary.totalGemini,
12077
+ requestsPerHour: prevSummary.requestsPerHour,
12078
+ accountsUsed: prevSummary.accountsUsed
12079
+ });
12080
+ }
12029
12081
  const props = input2.event.properties;
12030
12082
  if (props?.info?.parentID) {
12031
12083
  isChildSession = true;
@@ -12942,6 +12994,23 @@ Alternatively, you can:
12942
12994
  }
12943
12995
  const totalToday = accountManager.getTotalDailyRequests(family);
12944
12996
  pushDebug(`[Quota] Total ${family} requests today (all accounts): ${totalToday}`);
12997
+ const cachedQuota = account.cachedQuota;
12998
+ if (cachedQuota) {
12999
+ const quotaFamily = family === "claude" ? "claude" : "gemini-flash";
13000
+ const groupQuota = cachedQuota[quotaFamily];
13001
+ if (groupQuota?.remainingFraction != null) {
13002
+ const pct = Math.round(groupQuota.remainingFraction * 100);
13003
+ pushDebug(`[Quota] Account ${account.index} cached ${quotaFamily} remaining: ${pct}%${groupQuota.resetTime ? ` (resets ${groupQuota.resetTime})` : ""}`);
13004
+ }
13005
+ }
13006
+ const sessionSummary = accountManager.getSessionSummary();
13007
+ if (sessionSummary.durationMinutes >= 1) {
13008
+ const familyTotal = family === "claude" ? sessionSummary.totalClaude : sessionSummary.totalGemini;
13009
+ if (familyTotal > 0) {
13010
+ const ratePerHour = sessionSummary.requestsPerHour;
13011
+ pushDebug(`[Quota] Session: ${sessionSummary.durationMinutes}min, ${familyTotal} ${family} reqs, ~${ratePerHour} reqs/hr, ${sessionSummary.accountsUsed} accounts used`);
13012
+ }
13013
+ }
12945
13014
  return transformedResponse;
12946
13015
  } catch (error) {
12947
13016
  if (tokenConsumed) {