@serii84/vertex-partner-provider 1.0.23 → 1.0.24

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 +16 -10
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,9 +1,20 @@
1
1
  /**
2
2
  * Vertex Partner Provider for OpenCode
3
- * v1.0.23 - Fix: whitelist-based cleaning, pass through usage chunks
3
+ * v1.0.24 - Debug: write to file instead of console
4
4
  */
5
5
 
6
+ const fs = require('fs');
7
+ const path = require('path');
8
+
6
9
  const DEBUG = process.env.VERTEX_DEBUG === 'true';
10
+ const DEBUG_FILE = process.env.VERTEX_DEBUG_FILE || '/tmp/vertex-debug.log';
11
+
12
+ function debugLog(...args) {
13
+ if (!DEBUG) return;
14
+ const timestamp = new Date().toISOString();
15
+ const message = args.map(a => typeof a === 'string' ? a : JSON.stringify(a, null, 2)).join(' ');
16
+ fs.appendFileSync(DEBUG_FILE, `[${timestamp}] ${message}\n`);
17
+ }
7
18
 
8
19
  const { createOpenAICompatible } = require('@ai-sdk/openai-compatible');
9
20
  const { GoogleAuth } = require('google-auth-library');
@@ -119,26 +130,21 @@ function transformStream(response) {
119
130
  try {
120
131
  const parsed = JSON.parse(data);
121
132
 
122
- if (DEBUG) {
123
- console.log('[VERTEX DEBUG] Raw chunk:', JSON.stringify(parsed, null, 2));
124
- }
133
+ debugLog('Raw chunk:', parsed);
125
134
 
126
135
  const cleaned = cleanResponse(parsed);
127
136
 
128
137
  // Skip chunks that have no useful data after cleaning
129
138
  if ((!cleaned.choices || cleaned.choices.length === 0) && !cleaned.usage) {
139
+ debugLog('Skipping empty chunk');
130
140
  continue;
131
141
  }
132
142
 
133
- if (DEBUG) {
134
- console.log('[VERTEX DEBUG] Cleaned chunk:', JSON.stringify(cleaned, null, 2));
135
- }
143
+ debugLog('Cleaned chunk:', cleaned);
136
144
 
137
145
  controller.enqueue(encoder.encode('data: ' + JSON.stringify(cleaned) + '\n\n'));
138
146
  } catch (e) {
139
- if (DEBUG) {
140
- console.log('[VERTEX DEBUG] JSON parse error:', e.message, 'Data:', data);
141
- }
147
+ debugLog('JSON parse error:', e.message, 'Data:', data);
142
148
  // Skip invalid JSON
143
149
  }
144
150
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serii84/vertex-partner-provider",
3
- "version": "1.0.23",
3
+ "version": "1.0.24",
4
4
  "description": "Vertex AI partner models (GLM, Kimi, DeepSeek) for OpenCode",
5
5
  "main": "index.js",
6
6
  "scripts": {