@serii84/vertex-partner-provider 1.0.25 → 1.0.27

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 +13 -5
  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.25 - Skip all empty choices chunks (including usage-only)
3
+ * v1.0.27 - Ensure finish_reason is always a string
4
4
  */
5
5
 
6
6
  const fs = require('fs');
@@ -56,18 +56,22 @@ function cleanResponse(parsed) {
56
56
  || choice.finish_reason.stop_reason
57
57
  || 'stop';
58
58
  } else {
59
- cleanChoice.finish_reason = choice.finish_reason;
59
+ cleanChoice.finish_reason = String(choice.finish_reason);
60
60
  }
61
61
  }
62
62
 
63
63
  // Clean up delta - remove null values and non-standard fields
64
- if (choice.delta) {
64
+ // Only include delta if there's actual content (not on finish chunks)
65
+ if (choice.delta && !choice.finish_reason) {
65
66
  const cleanDelta = {};
66
67
  if (choice.delta.role) cleanDelta.role = choice.delta.role;
67
68
  if (choice.delta.content) cleanDelta.content = choice.delta.content;
68
69
  else if (choice.delta.reasoning_content) cleanDelta.content = choice.delta.reasoning_content;
69
70
  if (choice.delta.tool_calls) cleanDelta.tool_calls = choice.delta.tool_calls;
70
71
  cleanChoice.delta = cleanDelta;
72
+ } else if (choice.delta) {
73
+ // On finish chunks, include empty delta for compatibility
74
+ cleanChoice.delta = {};
71
75
  }
72
76
 
73
77
  if (choice.message) {
@@ -94,10 +98,13 @@ function cleanResponse(parsed) {
94
98
  }
95
99
 
96
100
  function transformStream(response) {
101
+ // Log response headers for debugging
102
+ debugLog('Response headers:', Object.fromEntries(response.headers.entries()));
103
+
97
104
  const reader = response.body.getReader();
98
105
  const decoder = new TextDecoder();
99
106
  const encoder = new TextEncoder();
100
-
107
+
101
108
  let buffer = '';
102
109
 
103
110
  const transformedStream = new ReadableStream({
@@ -123,7 +130,8 @@ function transformStream(response) {
123
130
  const data = message.slice(6);
124
131
 
125
132
  if (data === '[DONE]') {
126
- controller.enqueue(encoder.encode('data: [DONE]\n\n'));
133
+ debugLog('Received [DONE], not forwarding');
134
+ // Don't forward [DONE] - just let the stream end naturally
127
135
  continue;
128
136
  }
129
137
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serii84/vertex-partner-provider",
3
- "version": "1.0.25",
3
+ "version": "1.0.27",
4
4
  "description": "Vertex AI partner models (GLM, Kimi, DeepSeek) for OpenCode",
5
5
  "main": "index.js",
6
6
  "scripts": {