@terreno/ai 0.30.0 → 56.0.0-beta.0
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/dist/service/vertex.d.ts +12 -0
- package/dist/service/vertex.js +3 -2
- package/package.json +5 -5
- package/src/service/vertex.test.ts +3 -3
- package/src/service/vertex.ts +7 -1
- package/tsconfig.json +4 -2
package/dist/service/vertex.d.ts
CHANGED
|
@@ -19,6 +19,12 @@ export interface VertexLanguageModelProvider {
|
|
|
19
19
|
(modelId: string): LanguageModel;
|
|
20
20
|
image: (modelId: string) => ImageModel;
|
|
21
21
|
}
|
|
22
|
+
interface VertexModule {
|
|
23
|
+
createVertex: (opts: {
|
|
24
|
+
location: string;
|
|
25
|
+
project: string;
|
|
26
|
+
}) => VertexLanguageModelProvider;
|
|
27
|
+
}
|
|
22
28
|
export interface CreateVertexProviderOptions {
|
|
23
29
|
/**
|
|
24
30
|
* Optional allow-list of model ids consumers may use. When omitted or empty (the default), ALL
|
|
@@ -29,6 +35,11 @@ export interface CreateVertexProviderOptions {
|
|
|
29
35
|
location?: string;
|
|
30
36
|
/** GCP project id. Falls back to the GOOGLE_VERTEX_PROJECT env var. */
|
|
31
37
|
project?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Injectable loader for the `@ai-sdk/google-vertex` module, primarily for testing the
|
|
40
|
+
* "module not installed" fallback deterministically. Defaults to a `require`-based loader.
|
|
41
|
+
*/
|
|
42
|
+
loadModule?: () => VertexModule | undefined;
|
|
32
43
|
/**
|
|
33
44
|
* Injectable factory for the `@ai-sdk/google-vertex` provider, primarily for testing. When
|
|
34
45
|
* omitted, the provider is loaded dynamically from `@ai-sdk/google-vertex`.
|
|
@@ -113,3 +124,4 @@ export declare const verifyVertexModelsEnabled: (options: VerifyVertexModelsOpti
|
|
|
113
124
|
* do not throw so local development and offline environments keep working.
|
|
114
125
|
*/
|
|
115
126
|
export declare const assertVertexModelsEnabled: (options: VerifyVertexModelsOptions) => Promise<VertexModelAvailability>;
|
|
127
|
+
export {};
|
package/dist/service/vertex.js
CHANGED
|
@@ -168,7 +168,7 @@ var aiPlatformHost = function (location) {
|
|
|
168
168
|
* installed, so callers can fall back to another provider or demo mode.
|
|
169
169
|
*/
|
|
170
170
|
var createVertexProvider = function (options) {
|
|
171
|
-
var _a, _b, _c;
|
|
171
|
+
var _a, _b, _c, _d;
|
|
172
172
|
if (options === void 0) { options = {}; }
|
|
173
173
|
var project = (_a = options.project) !== null && _a !== void 0 ? _a : process.env.GOOGLE_VERTEX_PROJECT;
|
|
174
174
|
if (!project) {
|
|
@@ -176,7 +176,8 @@ var createVertexProvider = function (options) {
|
|
|
176
176
|
}
|
|
177
177
|
var location = resolveLocation(options.location);
|
|
178
178
|
var allowedModels = options.allowedModels && options.allowedModels.length > 0 ? options.allowedModels : undefined;
|
|
179
|
-
var
|
|
179
|
+
var loadModule = (_b = options.loadModule) !== null && _b !== void 0 ? _b : loadVertexModule;
|
|
180
|
+
var factory = (_c = options.vertexFactory) !== null && _c !== void 0 ? _c : (_d = loadModule()) === null || _d === void 0 ? void 0 : _d.createVertex;
|
|
180
181
|
if (!factory) {
|
|
181
182
|
api_1.logger.warn("Vertex AI (Gemini Enterprise Agent Platform) provider requested but @ai-sdk/google-vertex is not installed.");
|
|
182
183
|
return undefined;
|
package/package.json
CHANGED
|
@@ -18,18 +18,18 @@
|
|
|
18
18
|
"description": "AI service layer for Terreno apps - GPT chat, request logging, and admin tools.",
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@biomejs/biome": "^2.3.6",
|
|
21
|
-
"@terreno/
|
|
21
|
+
"@terreno/api": "56.0.0-beta.0",
|
|
22
|
+
"@terreno/test": "56.0.0-beta.0",
|
|
22
23
|
"@types/bun": "^1.3.8",
|
|
23
24
|
"@types/express": "^5.0.6",
|
|
24
25
|
"@types/luxon": "^3.7.1",
|
|
25
26
|
"@types/multer": "^1.4.12",
|
|
26
27
|
"@types/passport-local-mongoose": "^6.1.5",
|
|
27
28
|
"@types/supertest": "^7.2.0",
|
|
28
|
-
"@terreno/api": "0.30.0",
|
|
29
29
|
"mongoose": "8.23.0",
|
|
30
30
|
"passport-local-mongoose": "^9.0.1",
|
|
31
31
|
"supertest": "^7.2.2",
|
|
32
|
-
"typescript": "~
|
|
32
|
+
"typescript": "~6.0.3",
|
|
33
33
|
"winston": "^3.18.3"
|
|
34
34
|
},
|
|
35
35
|
"exports": {
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"access": "public"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
|
-
"@terreno/api": "0.
|
|
75
|
+
"@terreno/api": "56.0.0-beta.0",
|
|
76
76
|
"mongoose": "^8.0.0"
|
|
77
77
|
},
|
|
78
78
|
"repository": {
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"test:coverage": "bun run ../scripts/check-coverage.ts"
|
|
92
92
|
},
|
|
93
93
|
"types": "dist/index.d.ts",
|
|
94
|
-
"version": "0.
|
|
94
|
+
"version": "56.0.0-beta.0"
|
|
95
95
|
}
|
|
@@ -190,9 +190,9 @@ describe("vertex helpers", () => {
|
|
|
190
190
|
|
|
191
191
|
describe("createVertexProvider without vertexFactory", () => {
|
|
192
192
|
it("returns undefined when @ai-sdk/google-vertex is not installed (no factory)", () => {
|
|
193
|
-
//
|
|
194
|
-
//
|
|
195
|
-
const provider = createVertexProvider({project: "demo-project"});
|
|
193
|
+
// Inject a loader that simulates the module being unavailable so the fallback is
|
|
194
|
+
// deterministic even when @ai-sdk/google-vertex is hoisted into the monorepo.
|
|
195
|
+
const provider = createVertexProvider({loadModule: () => undefined, project: "demo-project"});
|
|
196
196
|
expect(provider).toBeUndefined();
|
|
197
197
|
});
|
|
198
198
|
});
|
package/src/service/vertex.ts
CHANGED
|
@@ -42,6 +42,11 @@ export interface CreateVertexProviderOptions {
|
|
|
42
42
|
location?: string;
|
|
43
43
|
/** GCP project id. Falls back to the GOOGLE_VERTEX_PROJECT env var. */
|
|
44
44
|
project?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Injectable loader for the `@ai-sdk/google-vertex` module, primarily for testing the
|
|
47
|
+
* "module not installed" fallback deterministically. Defaults to a `require`-based loader.
|
|
48
|
+
*/
|
|
49
|
+
loadModule?: () => VertexModule | undefined;
|
|
45
50
|
/**
|
|
46
51
|
* Injectable factory for the `@ai-sdk/google-vertex` provider, primarily for testing. When
|
|
47
52
|
* omitted, the provider is loaded dynamically from `@ai-sdk/google-vertex`.
|
|
@@ -170,7 +175,8 @@ export const createVertexProvider = (
|
|
|
170
175
|
const allowedModels =
|
|
171
176
|
options.allowedModels && options.allowedModels.length > 0 ? options.allowedModels : undefined;
|
|
172
177
|
|
|
173
|
-
const
|
|
178
|
+
const loadModule = options.loadModule ?? loadVertexModule;
|
|
179
|
+
const factory = options.vertexFactory ?? loadModule()?.createVertex;
|
|
174
180
|
if (!factory) {
|
|
175
181
|
logger.warn(
|
|
176
182
|
"Vertex AI (Gemini Enterprise Agent Platform) provider requested but @ai-sdk/google-vertex is not installed."
|
package/tsconfig.json
CHANGED
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
"downlevelIteration": true,
|
|
8
8
|
"esModuleInterop": true,
|
|
9
9
|
"forceConsistentCasingInFileNames": true,
|
|
10
|
+
"ignoreDeprecations": "6.0",
|
|
10
11
|
"jsx": "react",
|
|
11
|
-
"lib": ["
|
|
12
|
+
"lib": ["es2022", "dom"],
|
|
12
13
|
"module": "commonjs",
|
|
13
14
|
"moduleResolution": "node",
|
|
14
15
|
"noEmit": false,
|
|
@@ -18,6 +19,7 @@
|
|
|
18
19
|
"noUnusedLocals": false,
|
|
19
20
|
"noUnusedParameters": false,
|
|
20
21
|
"outDir": "./dist",
|
|
22
|
+
"rootDir": "./src",
|
|
21
23
|
"preserveConstEnums": true,
|
|
22
24
|
"removeComments": false,
|
|
23
25
|
"skipLibCheck": true,
|
|
@@ -34,5 +36,5 @@
|
|
|
34
36
|
"src/**/*.isolated.tsx",
|
|
35
37
|
"src/tests"
|
|
36
38
|
],
|
|
37
|
-
"include": ["src/**/*.ts*", "src/*.ts", "
|
|
39
|
+
"include": ["src/**/*.ts*", "src/*.ts", "src/**/*.d.ts"]
|
|
38
40
|
}
|