@serii84/vertex-partner-provider 1.0.19 → 1.0.21

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 +28 -5
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  /**
2
2
  * Vertex Partner Provider for OpenCode
3
- * v1.0.19 - Fix response body consumption issue
3
+ * v1.0.21 - Debug: log raw responses to find issue
4
4
  */
5
5
 
6
+ const DEBUG = process.env.VERTEX_DEBUG === 'true';
7
+
6
8
  const { createOpenAICompatible } = require('@ai-sdk/openai-compatible');
7
9
  const { GoogleAuth } = require('google-auth-library');
8
10
 
@@ -25,14 +27,23 @@ function cleanResponse(parsed) {
25
27
  for (const choice of parsed.choices) {
26
28
  delete choice.matched_stop;
27
29
  delete choice.logprobs;
28
-
30
+
31
+ // Normalize finish_reason to a string (some models return an object)
32
+ if (choice.finish_reason && typeof choice.finish_reason === 'object') {
33
+ // Extract string value from object, common patterns: {type: "stop"}, {reason: "stop"}
34
+ choice.finish_reason = choice.finish_reason.type
35
+ || choice.finish_reason.reason
36
+ || choice.finish_reason.stop_reason
37
+ || 'stop';
38
+ }
39
+
29
40
  if (choice.delta) {
30
41
  if (!choice.delta.content && choice.delta.reasoning_content) {
31
42
  choice.delta.content = choice.delta.reasoning_content;
32
43
  }
33
44
  delete choice.delta.reasoning_content;
34
45
  }
35
-
46
+
36
47
  if (choice.message) {
37
48
  if (!choice.message.content && choice.message.reasoning_content) {
38
49
  choice.message.content = choice.message.reasoning_content;
@@ -88,15 +99,27 @@ function transformStream(response) {
88
99
 
89
100
  try {
90
101
  const parsed = JSON.parse(data);
91
-
102
+
103
+ if (DEBUG) {
104
+ console.log('[VERTEX DEBUG] Raw chunk:', JSON.stringify(parsed, null, 2));
105
+ }
106
+
92
107
  // Skip empty choices (usage-only chunk)
93
108
  if (parsed.choices && parsed.choices.length === 0) {
94
109
  continue;
95
110
  }
96
-
111
+
97
112
  const cleaned = cleanResponse(parsed);
113
+
114
+ if (DEBUG) {
115
+ console.log('[VERTEX DEBUG] Cleaned chunk:', JSON.stringify(cleaned, null, 2));
116
+ }
117
+
98
118
  controller.enqueue(encoder.encode('data: ' + JSON.stringify(cleaned) + '\n\n'));
99
119
  } catch (e) {
120
+ if (DEBUG) {
121
+ console.log('[VERTEX DEBUG] JSON parse error:', e.message, 'Data:', data);
122
+ }
100
123
  // Skip invalid JSON
101
124
  }
102
125
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serii84/vertex-partner-provider",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "description": "Vertex AI partner models (GLM, Kimi, DeepSeek) for OpenCode",
5
5
  "main": "index.js",
6
6
  "scripts": {