@zhexin/pi-agy 0.2.0 → 0.2.1

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/images.ts +11 -11
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zhexin/pi-agy",
3
3
  "description": "Antigravity OAuth provider for the Pi agent.",
4
- "version": "0.2.0",
4
+ "version": "0.2.1",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "keywords": [
package/src/images.ts CHANGED
@@ -20,13 +20,13 @@ type GeminiResponse = {
20
20
  finishReason: string;
21
21
  finishMessage: string;
22
22
  }[];
23
- promptFeedback: { blockReason: string; blockReasonMessage: string };
23
+ promptFeedback?: { blockReason?: string; blockReasonMessage?: string };
24
24
  usageMetadata: {
25
- promptTokenCount: number;
26
- candidatesTokenCount: number;
27
- cachedContentTokenCount: number;
28
- thoughtsTokenCount: number;
29
- totalTokenCount: number;
25
+ promptTokenCount?: number;
26
+ candidatesTokenCount?: number;
27
+ cachedContentTokenCount?: number;
28
+ thoughtsTokenCount?: number;
29
+ totalTokenCount?: number;
30
30
  };
31
31
  };
32
32
 
@@ -105,12 +105,12 @@ export const imagesApi: ProviderImages = {
105
105
  if (response.usageMetadata) {
106
106
  const raw = response.usageMetadata;
107
107
  const usage: Usage = {
108
- input: raw.promptTokenCount - raw.cachedContentTokenCount,
109
- output: raw.candidatesTokenCount + raw.thoughtsTokenCount,
110
- cacheRead: raw.cachedContentTokenCount,
108
+ input: raw.promptTokenCount ?? 0,
109
+ output: raw.candidatesTokenCount ?? 0,
110
+ cacheRead: raw.cachedContentTokenCount ?? 0,
111
111
  cacheWrite: 0,
112
- reasoning: raw.thoughtsTokenCount,
113
- totalTokens: raw.totalTokenCount,
112
+ reasoning: raw.thoughtsTokenCount ?? 0,
113
+ totalTokens: raw.totalTokenCount ?? 0,
114
114
  cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
115
115
  };
116
116
  calculateCost(model, usage);