@serii84/vertex-partner-provider 1.0.19 → 1.0.20

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 +12 -3
  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.19 - Fix response body consumption issue
3
+ * v1.0.20 - Normalize finish_reason to string (some models return object)
4
4
  */
5
5
 
6
6
  const { createOpenAICompatible } = require('@ai-sdk/openai-compatible');
@@ -25,14 +25,23 @@ function cleanResponse(parsed) {
25
25
  for (const choice of parsed.choices) {
26
26
  delete choice.matched_stop;
27
27
  delete choice.logprobs;
28
-
28
+
29
+ // Normalize finish_reason to a string (some models return an object)
30
+ if (choice.finish_reason && typeof choice.finish_reason === 'object') {
31
+ // Extract string value from object, common patterns: {type: "stop"}, {reason: "stop"}
32
+ choice.finish_reason = choice.finish_reason.type
33
+ || choice.finish_reason.reason
34
+ || choice.finish_reason.stop_reason
35
+ || 'stop';
36
+ }
37
+
29
38
  if (choice.delta) {
30
39
  if (!choice.delta.content && choice.delta.reasoning_content) {
31
40
  choice.delta.content = choice.delta.reasoning_content;
32
41
  }
33
42
  delete choice.delta.reasoning_content;
34
43
  }
35
-
44
+
36
45
  if (choice.message) {
37
46
  if (!choice.message.content && choice.message.reasoning_content) {
38
47
  choice.message.content = choice.message.reasoning_content;
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.20",
4
4
  "description": "Vertex AI partner models (GLM, Kimi, DeepSeek) for OpenCode",
5
5
  "main": "index.js",
6
6
  "scripts": {