@serii84/vertex-partner-provider 1.0.13 → 1.0.15

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 +3 -96
  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.13 - Proper SSE format
3
+ * v1.0.15 - No transform, pass through raw (debug)
4
4
  */
5
5
 
6
6
  const { createOpenAICompatible } = require('@ai-sdk/openai-compatible');
@@ -20,86 +20,6 @@ async function getAuthToken(googleAuthOptions) {
20
20
  return token.token;
21
21
  }
22
22
 
23
- function transformStream(response) {
24
- const reader = response.body.getReader();
25
- const decoder = new TextDecoder();
26
- const encoder = new TextEncoder();
27
-
28
- let buffer = '';
29
-
30
- const transformedStream = new ReadableStream({
31
- async pull(controller) {
32
- try {
33
- const { done, value } = await reader.read();
34
-
35
- if (done) {
36
- controller.close();
37
- return;
38
- }
39
-
40
- buffer += decoder.decode(value, { stream: true });
41
-
42
- // Process complete SSE messages (separated by double newline)
43
- let boundary;
44
- while ((boundary = buffer.indexOf('\n\n')) !== -1) {
45
- const message = buffer.slice(0, boundary);
46
- buffer = buffer.slice(boundary + 2);
47
-
48
- if (!message.trim()) continue;
49
-
50
- // Handle data lines
51
- if (message.startsWith('data: ')) {
52
- const data = message.slice(6);
53
-
54
- if (data === '[DONE]') {
55
- controller.enqueue(encoder.encode('data: [DONE]\n\n'));
56
- continue;
57
- }
58
-
59
- try {
60
- const parsed = JSON.parse(data);
61
-
62
- // Skip chunks with empty choices
63
- if (parsed.choices && parsed.choices.length === 0) {
64
- continue;
65
- }
66
-
67
- // Transform choices
68
- if (parsed.choices) {
69
- for (const choice of parsed.choices) {
70
- if (choice.delta) {
71
- // Convert reasoning_content to content
72
- if (!choice.delta.content && choice.delta.reasoning_content) {
73
- choice.delta.content = choice.delta.reasoning_content;
74
- }
75
- delete choice.delta.reasoning_content;
76
- }
77
- }
78
- }
79
-
80
- controller.enqueue(encoder.encode('data: ' + JSON.stringify(parsed) + '\n\n'));
81
- } catch (e) {
82
- // Skip invalid JSON
83
- }
84
- }
85
- }
86
- } catch (err) {
87
- controller.error(err);
88
- }
89
- },
90
-
91
- cancel() {
92
- reader.cancel();
93
- }
94
- });
95
-
96
- return new Response(transformedStream, {
97
- headers: response.headers,
98
- status: response.status,
99
- statusText: response.statusText,
100
- });
101
- }
102
-
103
23
  function createVertexPartner(options = {}) {
104
24
  const {
105
25
  project = process.env.GOOGLE_VERTEX_PROJECT,
@@ -122,21 +42,8 @@ function createVertexPartner(options = {}) {
122
42
  const headers = new Headers(init?.headers);
123
43
  headers.set('Authorization', `Bearer ${token}`);
124
44
 
125
- let isStreaming = false;
126
- if (init?.body) {
127
- try {
128
- const body = JSON.parse(init.body);
129
- isStreaming = body.stream === true;
130
- } catch (e) {}
131
- }
132
-
133
- const response = await fetch(url, { ...init, headers });
134
-
135
- if (isStreaming && response.ok) {
136
- return transformStream(response);
137
- }
138
-
139
- return response;
45
+ // Just pass through - no transform
46
+ return fetch(url, { ...init, headers });
140
47
  };
141
48
 
142
49
  const provider = createOpenAICompatible({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serii84/vertex-partner-provider",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "Vertex AI partner models (GLM, Kimi, DeepSeek) for OpenCode",
5
5
  "main": "index.js",
6
6
  "scripts": {