@expiren/opencode-antigravity-auth 1.6.36 → 1.6.37
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 +43 -4
- package/dist/index.js.map +2 -2
- package/dist/src/plugin/core/streaming/transformer.d.ts +3 -1
- package/dist/src/plugin/core/streaming/transformer.d.ts.map +1 -1
- package/dist/src/plugin/core/streaming/transformer.js +20 -4
- package/dist/src/plugin/core/streaming/transformer.js.map +1 -1
- package/dist/src/plugin/core/streaming/types.d.ts +7 -0
- package/dist/src/plugin/core/streaming/types.d.ts.map +1 -1
- package/dist/src/plugin/request.d.ts.map +1 -1
- package/dist/src/plugin/request.js +17 -1
- package/dist/src/plugin/request.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3810,7 +3810,7 @@ function deduplicateThinkingText(response, sentBuffer, displayedThinkingHashes)
|
|
|
3810
3810
|
}
|
|
3811
3811
|
return response;
|
|
3812
3812
|
}
|
|
3813
|
-
function transformSseLine(line, signatureStore, thoughtBuffer, sentThinkingBuffer, callbacks, options, debugState2) {
|
|
3813
|
+
function transformSseLine(line, signatureStore, thoughtBuffer, sentThinkingBuffer, callbacks, options, debugState2, usageState) {
|
|
3814
3814
|
if (!line.startsWith("data:")) {
|
|
3815
3815
|
return line;
|
|
3816
3816
|
}
|
|
@@ -3830,6 +3830,18 @@ function transformSseLine(line, signatureStore, thoughtBuffer, sentThinkingBuffe
|
|
|
3830
3830
|
callbacks.onCacheSignature
|
|
3831
3831
|
);
|
|
3832
3832
|
}
|
|
3833
|
+
if (usageState) {
|
|
3834
|
+
const resp = parsed.response;
|
|
3835
|
+
const meta = resp.usageMetadata;
|
|
3836
|
+
if (meta && typeof meta === "object") {
|
|
3837
|
+
usageState.lastUsage = {
|
|
3838
|
+
cachedContentTokenCount: typeof meta.cachedContentTokenCount === "number" ? meta.cachedContentTokenCount : 0,
|
|
3839
|
+
promptTokenCount: typeof meta.promptTokenCount === "number" ? meta.promptTokenCount : 0,
|
|
3840
|
+
candidatesTokenCount: typeof meta.candidatesTokenCount === "number" ? meta.candidatesTokenCount : 0,
|
|
3841
|
+
totalTokenCount: typeof meta.totalTokenCount === "number" ? meta.totalTokenCount : 0
|
|
3842
|
+
};
|
|
3843
|
+
}
|
|
3844
|
+
}
|
|
3833
3845
|
let response = deduplicateThinkingText(
|
|
3834
3846
|
parsed.response,
|
|
3835
3847
|
sentThinkingBuffer,
|
|
@@ -3906,6 +3918,7 @@ function createStreamingTransformer(signatureStore, callbacks, options = {}) {
|
|
|
3906
3918
|
const sentThinkingBuffer = createThoughtBuffer();
|
|
3907
3919
|
const debugState2 = { injected: false };
|
|
3908
3920
|
let hasSeenUsageMetadata = false;
|
|
3921
|
+
const usageState = { lastUsage: null };
|
|
3909
3922
|
return new TransformStream({
|
|
3910
3923
|
transform(chunk, controller) {
|
|
3911
3924
|
buffer += decoder.decode(chunk, { stream: true });
|
|
@@ -3922,7 +3935,8 @@ function createStreamingTransformer(signatureStore, callbacks, options = {}) {
|
|
|
3922
3935
|
sentThinkingBuffer,
|
|
3923
3936
|
callbacks,
|
|
3924
3937
|
options,
|
|
3925
|
-
debugState2
|
|
3938
|
+
debugState2,
|
|
3939
|
+
usageState
|
|
3926
3940
|
);
|
|
3927
3941
|
controller.enqueue(encoder.encode(transformedLine + "\n"));
|
|
3928
3942
|
}
|
|
@@ -3940,7 +3954,8 @@ function createStreamingTransformer(signatureStore, callbacks, options = {}) {
|
|
|
3940
3954
|
sentThinkingBuffer,
|
|
3941
3955
|
callbacks,
|
|
3942
3956
|
options,
|
|
3943
|
-
debugState2
|
|
3957
|
+
debugState2,
|
|
3958
|
+
usageState
|
|
3944
3959
|
);
|
|
3945
3960
|
controller.enqueue(encoder.encode(transformedLine));
|
|
3946
3961
|
}
|
|
@@ -3959,6 +3974,9 @@ data: ${JSON.stringify(syntheticUsage)}
|
|
|
3959
3974
|
|
|
3960
3975
|
`));
|
|
3961
3976
|
}
|
|
3977
|
+
if (usageState.lastUsage && callbacks.onUsageMetadata) {
|
|
3978
|
+
callbacks.onUsageMetadata(usageState.lastUsage);
|
|
3979
|
+
}
|
|
3962
3980
|
}
|
|
3963
3981
|
});
|
|
3964
3982
|
}
|
|
@@ -8131,7 +8149,28 @@ async function transformAntigravityResponse(response, streaming, debugContext, r
|
|
|
8131
8149
|
{
|
|
8132
8150
|
onCacheSignature: cacheSignature,
|
|
8133
8151
|
onInjectDebug: injectDebugThinking,
|
|
8134
|
-
|
|
8152
|
+
onUsageMetadata: (usage) => {
|
|
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));
|
|
8172
|
+
}
|
|
8173
|
+
},
|
|
8135
8174
|
transformThinkingParts
|
|
8136
8175
|
},
|
|
8137
8176
|
{
|