@serii84/vertex-partner-provider 1.0.20 → 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.
- package/index.js +17 -3
- 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.
|
|
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
|
|
|
@@ -97,15 +99,27 @@ function transformStream(response) {
|
|
|
97
99
|
|
|
98
100
|
try {
|
|
99
101
|
const parsed = JSON.parse(data);
|
|
100
|
-
|
|
102
|
+
|
|
103
|
+
if (DEBUG) {
|
|
104
|
+
console.log('[VERTEX DEBUG] Raw chunk:', JSON.stringify(parsed, null, 2));
|
|
105
|
+
}
|
|
106
|
+
|
|
101
107
|
// Skip empty choices (usage-only chunk)
|
|
102
108
|
if (parsed.choices && parsed.choices.length === 0) {
|
|
103
109
|
continue;
|
|
104
110
|
}
|
|
105
|
-
|
|
111
|
+
|
|
106
112
|
const cleaned = cleanResponse(parsed);
|
|
113
|
+
|
|
114
|
+
if (DEBUG) {
|
|
115
|
+
console.log('[VERTEX DEBUG] Cleaned chunk:', JSON.stringify(cleaned, null, 2));
|
|
116
|
+
}
|
|
117
|
+
|
|
107
118
|
controller.enqueue(encoder.encode('data: ' + JSON.stringify(cleaned) + '\n\n'));
|
|
108
119
|
} catch (e) {
|
|
120
|
+
if (DEBUG) {
|
|
121
|
+
console.log('[VERTEX DEBUG] JSON parse error:', e.message, 'Data:', data);
|
|
122
|
+
}
|
|
109
123
|
// Skip invalid JSON
|
|
110
124
|
}
|
|
111
125
|
}
|