@serii84/vertex-partner-provider 1.0.27 → 1.0.29

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 +25 -7
  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.27 - Ensure finish_reason is always a string
3
+ * v1.0.29 - Remove delta from finish chunks entirely
4
4
  */
5
5
 
6
6
  const fs = require('fs');
@@ -61,7 +61,7 @@ function cleanResponse(parsed) {
61
61
  }
62
62
 
63
63
  // Clean up delta - remove null values and non-standard fields
64
- // Only include delta if there's actual content (not on finish chunks)
64
+ // Don't include delta on finish chunks at all
65
65
  if (choice.delta && !choice.finish_reason) {
66
66
  const cleanDelta = {};
67
67
  if (choice.delta.role) cleanDelta.role = choice.delta.role;
@@ -69,10 +69,8 @@ function cleanResponse(parsed) {
69
69
  else if (choice.delta.reasoning_content) cleanDelta.content = choice.delta.reasoning_content;
70
70
  if (choice.delta.tool_calls) cleanDelta.tool_calls = choice.delta.tool_calls;
71
71
  cleanChoice.delta = cleanDelta;
72
- } else if (choice.delta) {
73
- // On finish chunks, include empty delta for compatibility
74
- cleanChoice.delta = {};
75
72
  }
73
+ // Note: intentionally NOT including delta on finish chunks
76
74
 
77
75
  if (choice.message) {
78
76
  const cleanMessage = { role: choice.message.role };
@@ -113,6 +111,26 @@ function transformStream(response) {
113
111
  const { done, value } = await reader.read();
114
112
 
115
113
  if (done) {
114
+ // Process any remaining data in buffer
115
+ if (buffer.trim()) {
116
+ debugLog('Processing remaining buffer:', buffer);
117
+ if (buffer.startsWith('data: ')) {
118
+ const data = buffer.slice(6).trim();
119
+ if (data === '[DONE]') {
120
+ controller.enqueue(encoder.encode('data: [DONE]\n\n'));
121
+ } else if (data) {
122
+ try {
123
+ const parsed = JSON.parse(data);
124
+ const cleaned = cleanResponse(parsed);
125
+ if (cleaned.choices && cleaned.choices.length > 0) {
126
+ controller.enqueue(encoder.encode('data: ' + JSON.stringify(cleaned) + '\n\n'));
127
+ }
128
+ } catch (e) {
129
+ debugLog('Final buffer parse error:', e.message);
130
+ }
131
+ }
132
+ }
133
+ }
116
134
  controller.close();
117
135
  return;
118
136
  }
@@ -130,8 +148,8 @@ function transformStream(response) {
130
148
  const data = message.slice(6);
131
149
 
132
150
  if (data === '[DONE]') {
133
- debugLog('Received [DONE], not forwarding');
134
- // Don't forward [DONE] - just let the stream end naturally
151
+ debugLog('Forwarding [DONE]');
152
+ controller.enqueue(encoder.encode('data: [DONE]\n\n'));
135
153
  continue;
136
154
  }
137
155
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serii84/vertex-partner-provider",
3
- "version": "1.0.27",
3
+ "version": "1.0.29",
4
4
  "description": "Vertex AI partner models (GLM, Kimi, DeepSeek) for OpenCode",
5
5
  "main": "index.js",
6
6
  "scripts": {