@expiren/opencode-antigravity-auth 1.6.38 → 1.6.40

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
@@ -7556,6 +7556,10 @@ function ensureThinkingBeforeToolUseInMessages(messages, signatureSessionKey) {
7556
7556
  }) };
7557
7557
  });
7558
7558
  }
7559
+ var _lastCacheStats = null;
7560
+ function getLastCacheStats() {
7561
+ return _lastCacheStats;
7562
+ }
7559
7563
  function generateSyntheticProjectId() {
7560
7564
  const adjectives = ["useful", "bright", "swift", "calm", "bold"];
7561
7565
  const nouns = ["fuze", "wave", "spark", "flow", "core"];
@@ -8151,12 +8155,13 @@ async function transformAntigravityResponse(response, streaming, debugContext, r
8151
8155
  onInjectDebug: injectDebugThinking,
8152
8156
  onUsageMetadata: (usage) => {
8153
8157
  if (effectiveModel) {
8154
- logCacheStats(
8155
- effectiveModel,
8156
- usage.cachedContentTokenCount,
8157
- 0,
8158
- usage.promptTokenCount ?? usage.totalTokenCount
8159
- );
8158
+ const cacheRead = usage.cachedContentTokenCount;
8159
+ const totalInput = usage.promptTokenCount ?? usage.totalTokenCount;
8160
+ const hitRate = totalInput > 0 ? Math.round(cacheRead / totalInput * 100) : 0;
8161
+ const status = cacheRead > 0 ? "HIT" : "MISS";
8162
+ logCacheStats(effectiveModel, cacheRead, 0, totalInput);
8163
+ log6.debug(`[Cache] ${status} model=${effectiveModel} read=${cacheRead} total=${totalInput} hitRate=${hitRate}%`);
8164
+ _lastCacheStats = { model: effectiveModel, read: cacheRead, total: totalInput, hitRate };
8160
8165
  }
8161
8166
  },
8162
8167
  transformThinkingParts
@@ -8254,13 +8259,12 @@ ${debugText}` : "";
8254
8259
  const effectiveBody = patched ?? parsed ?? void 0;
8255
8260
  const usage = usageFromSse ?? (effectiveBody ? extractUsageMetadata(effectiveBody) : null);
8256
8261
  if (usage && effectiveModel) {
8257
- logCacheStats(
8258
- effectiveModel,
8259
- usage.cachedContentTokenCount ?? 0,
8260
- 0,
8261
- // API doesn't provide cache write tokens separately
8262
- usage.promptTokenCount ?? usage.totalTokenCount ?? 0
8263
- );
8262
+ const cacheRead = usage.cachedContentTokenCount ?? 0;
8263
+ const totalInput = usage.promptTokenCount ?? usage.totalTokenCount ?? 0;
8264
+ const hitRate = totalInput > 0 ? Math.round(cacheRead / totalInput * 100) : 0;
8265
+ const status = cacheRead > 0 ? "HIT" : "MISS";
8266
+ logCacheStats(effectiveModel, cacheRead, 0, totalInput);
8267
+ log6.debug(`[Cache] ${status} model=${effectiveModel} read=${cacheRead} total=${totalInput} hitRate=${hitRate}%`);
8264
8268
  }
8265
8269
  if (usage?.cachedContentTokenCount !== void 0) {
8266
8270
  headers.set("x-antigravity-cached-content-token-count", String(usage.cachedContentTokenCount));
@@ -12324,6 +12328,11 @@ var createAntigravityPlugin = (providerId) => async ({ client, directory }) => {
12324
12328
  debugLines.push(line);
12325
12329
  };
12326
12330
  pushDebug(`request=${urlString}`);
12331
+ const cachedStats = getLastCacheStats();
12332
+ if (cachedStats) {
12333
+ const label = cachedStats.hitRate > 0 ? "HIT" : "MISS";
12334
+ pushDebug(`[Cache] ${label} model=${cachedStats.model} read=${cachedStats.read} total=${cachedStats.total} hitRate=${cachedStats.hitRate}%`);
12335
+ }
12327
12336
  let lastFailure = null;
12328
12337
  let lastError = null;
12329
12338
  const abortSignal = init?.signal ?? void 0;