switchroom 0.14.0 → 0.14.2

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.
@@ -13356,6 +13356,7 @@ class AuthBroker {
13356
13356
  fetcher;
13357
13357
  providers;
13358
13358
  quota = {};
13359
+ lastQuotaCache = {};
13359
13360
  shaIndex = {};
13360
13361
  thresholdViolations = {};
13361
13362
  lastWrittenExpiresAt = new Map;
@@ -13768,13 +13769,15 @@ class AuthBroker {
13768
13769
  const meta = readAccountMeta(label, this.home);
13769
13770
  const q = this.quota[label];
13770
13771
  const exhausted = q !== undefined && q.exhausted_until > this.now();
13772
+ const lq = this.lastQuotaCache[label];
13771
13773
  return {
13772
13774
  label,
13773
13775
  expiresAt: creds?.claudeAiOauth?.expiresAt,
13774
13776
  exhausted,
13775
13777
  exhausted_until: q?.exhausted_until,
13776
13778
  threshold_violations: this.thresholdViolations[label] ?? 0,
13777
- last_refreshed_at: meta?.lastRefreshedAt
13779
+ last_refreshed_at: meta?.lastRefreshedAt,
13780
+ last_quota: lq ?? null
13778
13781
  };
13779
13782
  });
13780
13783
  const agents = Object.entries(this.config.agents ?? {}).map(([name, agent]) => {
@@ -13831,6 +13834,18 @@ class AuthBroker {
13831
13834
  ok: result.ok,
13832
13835
  error: result.ok ? undefined : result.reason
13833
13836
  });
13837
+ if (result.ok) {
13838
+ this.lastQuotaCache[label] = {
13839
+ fiveHourUtilizationPct: result.data.fiveHourUtilizationPct,
13840
+ sevenDayUtilizationPct: result.data.sevenDayUtilizationPct,
13841
+ fiveHourResetAt: result.data.fiveHourResetAt?.toISOString() ?? null,
13842
+ sevenDayResetAt: result.data.sevenDayResetAt?.toISOString() ?? null,
13843
+ representativeClaim: result.data.representativeClaim,
13844
+ overageStatus: result.data.overageStatus,
13845
+ overageDisabledReason: result.data.overageDisabledReason,
13846
+ capturedAt: this.now()
13847
+ };
13848
+ }
13834
13849
  return { label, result };
13835
13850
  }));
13836
13851
  socket.write(encodeSuccess(id, { results }));