@serii84/vertex-partner-provider 1.0.0 → 1.0.2

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 +10 -24
  2. package/package.json +6 -9
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');
@@ -23,7 +20,9 @@ async function getAuthToken(googleAuthOptions) {
23
20
  return token.token;
24
21
  }
25
22
 
26
- function createProvider(options = {}) {
23
+ function createVertexPartner(options = {}) {
24
+ console.error('[vertex-partner] Received options:', JSON.stringify(options, null, 2));
25
+
27
26
  const {
28
27
  project = process.env.GOOGLE_VERTEX_PROJECT,
29
28
  location = process.env.GOOGLE_VERTEX_LOCATION || 'global',
@@ -32,6 +31,8 @@ function createProvider(options = {}) {
32
31
  ...rest
33
32
  } = options;
34
33
 
34
+ console.error('[vertex-partner] Parsed:', { project, location, publisher });
35
+
35
36
  if (!project) throw new Error('project is required');
36
37
  if (!publisher) throw new Error('publisher is required');
37
38
 
@@ -40,33 +41,23 @@ function createProvider(options = {}) {
40
41
  : `${location}-aiplatform.googleapis.com`;
41
42
 
42
43
  const baseURL = `https://${baseHost}/v1/projects/${project}/locations/${location}/endpoints/openapi`;
43
-
44
44
  console.error(`[vertex-partner] baseURL: ${baseURL}`);
45
45
 
46
- // Custom fetch that injects Google auth
47
46
  const authFetch = async (url, init) => {
48
47
  console.error(`[vertex-partner] Fetching: ${url}`);
49
-
50
48
  const token = await getAuthToken(googleAuthOptions);
51
- console.error(`[vertex-partner] Got token: ${token.substring(0, 20)}...`);
52
-
53
49
  const headers = new Headers(init?.headers);
54
50
  headers.set('Authorization', `Bearer ${token}`);
55
-
56
- return fetch(url, {
57
- ...init,
58
- headers,
59
- });
51
+ return fetch(url, { ...init, headers });
60
52
  };
61
53
 
62
54
  const provider = createOpenAICompatible({
63
55
  name: `vertex-${publisher}`,
64
56
  baseURL,
65
- fetch: authFetch, // Use custom fetch for auth
57
+ fetch: authFetch,
66
58
  ...rest,
67
59
  });
68
60
 
69
- // Wrap to auto-prefix model IDs
70
61
  const wrappedProvider = (modelId) => {
71
62
  const fullModelId = modelId.includes('/') ? modelId : `${publisher}/${modelId}`;
72
63
  console.error(`[vertex-partner] Using model: ${fullModelId}`);
@@ -84,11 +75,6 @@ function createProvider(options = {}) {
84
75
  return wrappedProvider;
85
76
  }
86
77
 
87
- module.exports = createProvider;
88
- module.exports.createProvider = createProvider;
89
- module.exports.createVertexPartner = createProvider;
90
- module.exports.createGLM = (opts) => createProvider({ ...opts, publisher: 'zai-org' });
91
- module.exports.createKimi = (opts) => createProvider({ ...opts, publisher: 'moonshotai' });
92
- module.exports.createDeepSeek = (opts) => createProvider({ ...opts, publisher: 'deepseek-ai' });
93
- module.exports.createMiniMax = (opts) => createProvider({ ...opts, publisher: 'minimaxai' });
94
- module.exports.createQwen = (opts) => createProvider({ ...opts, publisher: 'qwen' });
78
+ // ONLY export the main function - no convenience exports!
79
+ // OpenCode picks the first "create*" alphabetically
80
+ module.exports = { createVertexPartner };
package/package.json CHANGED
@@ -1,19 +1,16 @@
1
1
  {
2
2
  "name": "@serii84/vertex-partner-provider",
3
- "version": "1.0.0",
4
- "description": "",
3
+ "version": "1.0.2",
4
+ "description": "Vertex AI partner models (GLM, Kimi, DeepSeek) for OpenCode",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
7
+ "test": "node test.js"
8
8
  },
9
- "keywords": [],
9
+ "keywords": ["opencode", "vertex-ai", "ai-sdk", "glm", "kimi", "deepseek"],
10
10
  "author": "",
11
- "license": "ISC",
11
+ "license": "MIT",
12
12
  "dependencies": {
13
13
  "@ai-sdk/openai-compatible": "^2.0.4",
14
- "@ai-sdk/provider-utils": "^4.0.4",
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
  }