@expiren/opencode-antigravity-auth 1.6.37 → 1.6.39

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
@@ -8151,24 +8151,12 @@ async function transformAntigravityResponse(response, streaming, debugContext, r
8151
8151
  onInjectDebug: injectDebugThinking,
8152
8152
  onUsageMetadata: (usage) => {
8153
8153
  if (effectiveModel) {
8154
- logCacheStats(
8155
- effectiveModel,
8156
- usage.cachedContentTokenCount,
8157
- 0,
8158
- usage.promptTokenCount || usage.totalTokenCount
8159
- );
8160
- }
8161
- if (usage.cachedContentTokenCount !== void 0) {
8162
- headers.set("x-antigravity-cached-content-token-count", String(usage.cachedContentTokenCount));
8163
- }
8164
- if (usage.totalTokenCount !== void 0) {
8165
- headers.set("x-antigravity-total-token-count", String(usage.totalTokenCount));
8166
- }
8167
- if (usage.promptTokenCount !== void 0) {
8168
- headers.set("x-antigravity-prompt-token-count", String(usage.promptTokenCount));
8169
- }
8170
- if (usage.candidatesTokenCount !== void 0) {
8171
- headers.set("x-antigravity-candidates-token-count", String(usage.candidatesTokenCount));
8154
+ const cacheRead = usage.cachedContentTokenCount;
8155
+ const totalInput = usage.promptTokenCount ?? usage.totalTokenCount;
8156
+ const hitRate = totalInput > 0 ? Math.round(cacheRead / totalInput * 100) : 0;
8157
+ const status = cacheRead > 0 ? "HIT" : "MISS";
8158
+ logCacheStats(effectiveModel, cacheRead, 0, totalInput);
8159
+ log6.debug(`[Cache] ${status} model=${effectiveModel} read=${cacheRead} total=${totalInput} hitRate=${hitRate}%`);
8172
8160
  }
8173
8161
  },
8174
8162
  transformThinkingParts
@@ -8266,13 +8254,12 @@ ${debugText}` : "";
8266
8254
  const effectiveBody = patched ?? parsed ?? void 0;
8267
8255
  const usage = usageFromSse ?? (effectiveBody ? extractUsageMetadata(effectiveBody) : null);
8268
8256
  if (usage && effectiveModel) {
8269
- logCacheStats(
8270
- effectiveModel,
8271
- usage.cachedContentTokenCount ?? 0,
8272
- 0,
8273
- // API doesn't provide cache write tokens separately
8274
- usage.promptTokenCount ?? usage.totalTokenCount ?? 0
8275
- );
8257
+ const cacheRead = usage.cachedContentTokenCount ?? 0;
8258
+ const totalInput = usage.promptTokenCount ?? usage.totalTokenCount ?? 0;
8259
+ const hitRate = totalInput > 0 ? Math.round(cacheRead / totalInput * 100) : 0;
8260
+ const status = cacheRead > 0 ? "HIT" : "MISS";
8261
+ logCacheStats(effectiveModel, cacheRead, 0, totalInput);
8262
+ log6.debug(`[Cache] ${status} model=${effectiveModel} read=${cacheRead} total=${totalInput} hitRate=${hitRate}%`);
8276
8263
  }
8277
8264
  if (usage?.cachedContentTokenCount !== void 0) {
8278
8265
  headers.set("x-antigravity-cached-content-token-count", String(usage.cachedContentTokenCount));
@@ -12649,6 +12636,7 @@ var createAntigravityPlugin = (providerId) => async ({ client, directory }) => {
12649
12636
  );
12650
12637
  }
12651
12638
  };
12639
+ let apiRequestCount = 0;
12652
12640
  let shouldSwitchAccount = false;
12653
12641
  let headerStyle = preferredHeaderStyle;
12654
12642
  pushDebug(`headerStyle=${headerStyle} explicit=${explicitQuota}`);
@@ -12706,7 +12694,6 @@ var createAntigravityPlugin = (providerId) => async ({ client, directory }) => {
12706
12694
  let tokenConsumed = false;
12707
12695
  let capacityRetryCount = 0;
12708
12696
  let lastEndpointIndex = -1;
12709
- let apiRequestCount = 0;
12710
12697
  for (let i = 0; i < ANTIGRAVITY_ENDPOINT_FALLBACKS.length; i++) {
12711
12698
  if (i !== lastEndpointIndex) {
12712
12699
  capacityRetryCount = 0;