@serii84/vertex-partner-provider 1.0.2 → 1.0.6
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 +1 -12
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Vertex Partner Provider for OpenCode
|
|
3
|
+
* No logging - clean output
|
|
3
4
|
*/
|
|
4
5
|
|
|
5
6
|
const { createOpenAICompatible } = require('@ai-sdk/openai-compatible');
|
|
@@ -14,25 +15,19 @@ async function getAuthToken(googleAuthOptions) {
|
|
|
14
15
|
...googleAuthOptions,
|
|
15
16
|
});
|
|
16
17
|
}
|
|
17
|
-
|
|
18
18
|
const client = await authClient.getClient();
|
|
19
19
|
const token = await client.getAccessToken();
|
|
20
20
|
return token.token;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
function createVertexPartner(options = {}) {
|
|
24
|
-
console.error('[vertex-partner] Received options:', JSON.stringify(options, null, 2));
|
|
25
|
-
|
|
26
24
|
const {
|
|
27
25
|
project = process.env.GOOGLE_VERTEX_PROJECT,
|
|
28
26
|
location = process.env.GOOGLE_VERTEX_LOCATION || 'global',
|
|
29
27
|
publisher,
|
|
30
28
|
googleAuthOptions,
|
|
31
|
-
...rest
|
|
32
29
|
} = options;
|
|
33
30
|
|
|
34
|
-
console.error('[vertex-partner] Parsed:', { project, location, publisher });
|
|
35
|
-
|
|
36
31
|
if (!project) throw new Error('project is required');
|
|
37
32
|
if (!publisher) throw new Error('publisher is required');
|
|
38
33
|
|
|
@@ -41,10 +36,8 @@ function createVertexPartner(options = {}) {
|
|
|
41
36
|
: `${location}-aiplatform.googleapis.com`;
|
|
42
37
|
|
|
43
38
|
const baseURL = `https://${baseHost}/v1/projects/${project}/locations/${location}/endpoints/openapi`;
|
|
44
|
-
console.error(`[vertex-partner] baseURL: ${baseURL}`);
|
|
45
39
|
|
|
46
40
|
const authFetch = async (url, init) => {
|
|
47
|
-
console.error(`[vertex-partner] Fetching: ${url}`);
|
|
48
41
|
const token = await getAuthToken(googleAuthOptions);
|
|
49
42
|
const headers = new Headers(init?.headers);
|
|
50
43
|
headers.set('Authorization', `Bearer ${token}`);
|
|
@@ -55,12 +48,10 @@ function createVertexPartner(options = {}) {
|
|
|
55
48
|
name: `vertex-${publisher}`,
|
|
56
49
|
baseURL,
|
|
57
50
|
fetch: authFetch,
|
|
58
|
-
...rest,
|
|
59
51
|
});
|
|
60
52
|
|
|
61
53
|
const wrappedProvider = (modelId) => {
|
|
62
54
|
const fullModelId = modelId.includes('/') ? modelId : `${publisher}/${modelId}`;
|
|
63
|
-
console.error(`[vertex-partner] Using model: ${fullModelId}`);
|
|
64
55
|
return provider(fullModelId);
|
|
65
56
|
};
|
|
66
57
|
|
|
@@ -75,6 +66,4 @@ function createVertexPartner(options = {}) {
|
|
|
75
66
|
return wrappedProvider;
|
|
76
67
|
}
|
|
77
68
|
|
|
78
|
-
// ONLY export the main function - no convenience exports!
|
|
79
|
-
// OpenCode picks the first "create*" alphabetically
|
|
80
69
|
module.exports = { createVertexPartner };
|