@serii84/vertex-partner-provider 1.0.6 → 1.0.7

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 (3) hide show
  1. package/index.js +15 -2
  2. package/package.json +1 -1
  3. package/test.js +0 -78
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Vertex Partner Provider for OpenCode
3
- * No logging - clean output
3
+ * Forces non-streaming to avoid parsing issues
4
4
  */
5
5
 
6
6
  const { createOpenAICompatible } = require('@ai-sdk/openai-compatible');
@@ -41,7 +41,20 @@ function createVertexPartner(options = {}) {
41
41
  const token = await getAuthToken(googleAuthOptions);
42
42
  const headers = new Headers(init?.headers);
43
43
  headers.set('Authorization', `Bearer ${token}`);
44
- return fetch(url, { ...init, headers });
44
+
45
+ // Force non-streaming by modifying the request body
46
+ let modifiedInit = { ...init, headers };
47
+ if (init?.body) {
48
+ try {
49
+ const body = JSON.parse(init.body);
50
+ body.stream = false; // Force non-streaming
51
+ modifiedInit.body = JSON.stringify(body);
52
+ } catch (e) {
53
+ // If body isn't JSON, leave it as is
54
+ }
55
+ }
56
+
57
+ return fetch(url, modifiedInit);
45
58
  };
46
59
 
47
60
  const provider = createOpenAICompatible({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serii84/vertex-partner-provider",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Vertex AI partner models (GLM, Kimi, DeepSeek) for OpenCode",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/test.js DELETED
@@ -1,78 +0,0 @@
1
- /**
2
- * Test script for Vertex Partner Provider
3
- *
4
- * Run with: node test.js
5
- *
6
- * Requires: gcloud auth application-default login
7
- */
8
-
9
- const { createGLM, createDeepSeek, createKimi } = require('./index.js');
10
- const { generateText, tool } = require('ai');
11
- const { z } = require('zod');
12
-
13
- const PROJECT = process.env.GOOGLE_VERTEX_PROJECT || 'noter-1c2a1';
14
-
15
- async function testBasicChat() {
16
- console.log('\nšŸ“ Test 1: Basic Chat');
17
- console.log('-'.repeat(40));
18
-
19
- const glm = createGLM({ project: PROJECT, location: 'global' });
20
- const model = glm('glm-4.7-maas');
21
-
22
- console.log('Model ID:', model.modelId);
23
-
24
- const result = await generateText({
25
- model,
26
- prompt: 'Say "Hello from GLM!" and nothing else.',
27
- });
28
-
29
- console.log('āœ… Response:', result.text);
30
- return true;
31
- }
32
-
33
- async function testToolCalling() {
34
- console.log('\nšŸ”§ Test 2: Tool Calling');
35
- console.log('-'.repeat(40));
36
-
37
- const glm = createGLM({ project: PROJECT, location: 'global' });
38
-
39
- const result = await generateText({
40
- model: glm('glm-4.7-maas'),
41
- prompt: 'What is the weather in San Francisco? Use the weather tool.',
42
- tools: {
43
- weather: tool({
44
- description: 'Get the weather for a location',
45
- parameters: z.object({
46
- location: z.string().describe('The city name'),
47
- }),
48
- execute: async ({ location }) => {
49
- return { location, temperature: 72, condition: 'sunny' };
50
- },
51
- }),
52
- },
53
- maxSteps: 3,
54
- });
55
-
56
- console.log('āœ… Response:', result.text);
57
- console.log('Tool calls:', result.toolCalls?.length || 0);
58
- return true;
59
- }
60
-
61
- async function main() {
62
- console.log('='.repeat(50));
63
- console.log('Vertex Partner Provider Test Suite');
64
- console.log('='.repeat(50));
65
- console.log(`Project: ${PROJECT}`);
66
-
67
- try {
68
- await testBasicChat();
69
- await testToolCalling();
70
- console.log('\nāœ… All tests passed!');
71
- } catch (error) {
72
- console.error('\nāŒ Test failed:', error.message);
73
- if (error.cause) console.error('Cause:', JSON.stringify(error.cause, null, 2));
74
- process.exit(1);
75
- }
76
- }
77
-
78
- main();