@serii84/vertex-partner-provider 1.0.21 → 1.0.22

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/index.js +18 -6
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Vertex Partner Provider for OpenCode
3
- * v1.0.21 - Debug: log raw responses to find issue
3
+ * v1.0.22 - Fix: remove null values from delta, remove empty usage
4
4
  */
5
5
 
6
6
  const DEBUG = process.env.VERTEX_DEBUG === 'true';
@@ -30,18 +30,25 @@ function cleanResponse(parsed) {
30
30
 
31
31
  // Normalize finish_reason to a string (some models return an object)
32
32
  if (choice.finish_reason && typeof choice.finish_reason === 'object') {
33
- // Extract string value from object, common patterns: {type: "stop"}, {reason: "stop"}
34
33
  choice.finish_reason = choice.finish_reason.type
35
34
  || choice.finish_reason.reason
36
35
  || choice.finish_reason.stop_reason
37
36
  || 'stop';
38
37
  }
39
38
 
39
+ // Clean up delta - remove null values and non-standard fields
40
40
  if (choice.delta) {
41
41
  if (!choice.delta.content && choice.delta.reasoning_content) {
42
42
  choice.delta.content = choice.delta.reasoning_content;
43
43
  }
44
44
  delete choice.delta.reasoning_content;
45
+
46
+ // Remove null values from delta - OpenAI format uses empty object, not nulls
47
+ for (const key of Object.keys(choice.delta)) {
48
+ if (choice.delta[key] === null) {
49
+ delete choice.delta[key];
50
+ }
51
+ }
45
52
  }
46
53
 
47
54
  if (choice.message) {
@@ -52,14 +59,19 @@ function cleanResponse(parsed) {
52
59
  }
53
60
  }
54
61
  }
55
-
62
+
63
+ // Clean usage - only keep standard fields, remove if empty/invalid
56
64
  if (parsed.usage) {
57
65
  const { prompt_tokens, completion_tokens, total_tokens } = parsed.usage;
58
- parsed.usage = { prompt_tokens, completion_tokens, total_tokens };
66
+ if (prompt_tokens != null || completion_tokens != null || total_tokens != null) {
67
+ parsed.usage = { prompt_tokens, completion_tokens, total_tokens };
68
+ } else {
69
+ delete parsed.usage;
70
+ }
59
71
  }
60
-
72
+
61
73
  delete parsed.metadata;
62
-
74
+
63
75
  return parsed;
64
76
  }
65
77
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serii84/vertex-partner-provider",
3
- "version": "1.0.21",
3
+ "version": "1.0.22",
4
4
  "description": "Vertex AI partner models (GLM, Kimi, DeepSeek) for OpenCode",
5
5
  "main": "index.js",
6
6
  "scripts": {