@serii84/vertex-partner-provider 1.0.0 → 1.0.1
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.
- package/index.js +15 -16
- package/package.json +7 -10
package/index.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Vertex Partner Provider for OpenCode
|
|
3
|
-
*
|
|
4
|
-
* Uses custom fetch to inject Google Cloud auth since
|
|
5
|
-
* @ai-sdk/openai-compatible doesn't support async headers.
|
|
6
3
|
*/
|
|
7
4
|
|
|
8
5
|
const { createOpenAICompatible } = require('@ai-sdk/openai-compatible');
|
|
@@ -24,6 +21,9 @@ async function getAuthToken(googleAuthOptions) {
|
|
|
24
21
|
}
|
|
25
22
|
|
|
26
23
|
function createProvider(options = {}) {
|
|
24
|
+
// Debug: log what options we receive
|
|
25
|
+
console.error('[vertex-partner] Received options:', JSON.stringify(options, null, 2));
|
|
26
|
+
|
|
27
27
|
const {
|
|
28
28
|
project = process.env.GOOGLE_VERTEX_PROJECT,
|
|
29
29
|
location = process.env.GOOGLE_VERTEX_LOCATION || 'global',
|
|
@@ -32,8 +32,16 @@ function createProvider(options = {}) {
|
|
|
32
32
|
...rest
|
|
33
33
|
} = options;
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
console.error('[vertex-partner] Parsed:', { project, location, publisher });
|
|
36
|
+
|
|
37
|
+
if (!project) {
|
|
38
|
+
console.error('[vertex-partner] ERROR: project is required');
|
|
39
|
+
throw new Error('project is required. Set GOOGLE_VERTEX_PROJECT env var or pass project option.');
|
|
40
|
+
}
|
|
41
|
+
if (!publisher) {
|
|
42
|
+
console.error('[vertex-partner] ERROR: publisher is required');
|
|
43
|
+
throw new Error('publisher is required (e.g., "moonshotai", "zai-org", "deepseek-ai")');
|
|
44
|
+
}
|
|
37
45
|
|
|
38
46
|
const baseHost = location === 'global'
|
|
39
47
|
? 'aiplatform.googleapis.com'
|
|
@@ -43,30 +51,21 @@ function createProvider(options = {}) {
|
|
|
43
51
|
|
|
44
52
|
console.error(`[vertex-partner] baseURL: ${baseURL}`);
|
|
45
53
|
|
|
46
|
-
// Custom fetch that injects Google auth
|
|
47
54
|
const authFetch = async (url, init) => {
|
|
48
55
|
console.error(`[vertex-partner] Fetching: ${url}`);
|
|
49
|
-
|
|
50
56
|
const token = await getAuthToken(googleAuthOptions);
|
|
51
|
-
console.error(`[vertex-partner] Got token: ${token.substring(0, 20)}...`);
|
|
52
|
-
|
|
53
57
|
const headers = new Headers(init?.headers);
|
|
54
58
|
headers.set('Authorization', `Bearer ${token}`);
|
|
55
|
-
|
|
56
|
-
return fetch(url, {
|
|
57
|
-
...init,
|
|
58
|
-
headers,
|
|
59
|
-
});
|
|
59
|
+
return fetch(url, { ...init, headers });
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
const provider = createOpenAICompatible({
|
|
63
63
|
name: `vertex-${publisher}`,
|
|
64
64
|
baseURL,
|
|
65
|
-
fetch: authFetch,
|
|
65
|
+
fetch: authFetch,
|
|
66
66
|
...rest,
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
-
// Wrap to auto-prefix model IDs
|
|
70
69
|
const wrappedProvider = (modelId) => {
|
|
71
70
|
const fullModelId = modelId.includes('/') ? modelId : `${publisher}/${modelId}`;
|
|
72
71
|
console.error(`[vertex-partner] Using model: ${fullModelId}`);
|
package/package.json
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serii84/vertex-partner-provider",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Vertex AI partner models (GLM, Kimi, DeepSeek) for OpenCode",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "
|
|
7
|
+
"test": "node test.js"
|
|
8
8
|
},
|
|
9
|
-
"keywords": [],
|
|
9
|
+
"keywords": ["opencode", "vertex-ai", "ai-sdk", "glm", "kimi", "deepseek"],
|
|
10
10
|
"author": "",
|
|
11
|
-
"license": "
|
|
11
|
+
"license": "MIT",
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@ai-sdk/openai-compatible": "^2.0.4",
|
|
14
|
-
"
|
|
15
|
-
"ai": "^6.0.27",
|
|
16
|
-
"google-auth-library": "^10.5.0",
|
|
17
|
-
"zod": "^4.3.5"
|
|
14
|
+
"google-auth-library": "^10.5.0"
|
|
18
15
|
}
|
|
19
|
-
}
|
|
16
|
+
}
|