@terreno/ai 0.31.0 → 56.0.0-beta.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.
@@ -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 {};
@@ -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 factory = (_b = options.vertexFactory) !== null && _b !== void 0 ? _b : (_c = loadVertexModule()) === null || _c === void 0 ? void 0 : _c.createVertex;
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;
@@ -1,5 +1,5 @@
1
1
  import type { FindExactlyOnePlugin, FindOneOrNonePlugin } from "@terreno/api";
2
- import type { LanguageModel } from "ai";
2
+ import type { LanguageModel, StopCondition, ToolSet } from "ai";
3
3
  import type mongoose from "mongoose";
4
4
  export declare const DEFAULT_AI_REQUEST_TYPES: readonly ["general", "json_array", "json_object", "json_value", "remix", "summarization", "translation"];
5
5
  export type DefaultAIRequestType = (typeof DEFAULT_AI_REQUEST_TYPES)[number];
@@ -115,7 +115,7 @@ export interface AIServiceOptions {
115
115
  export interface GenerateTextOptions {
116
116
  maxOutputTokens?: number;
117
117
  prompt: string;
118
- stopWhen?: import("ai").StopCondition<any>;
118
+ stopWhen?: StopCondition<ToolSet>;
119
119
  systemPrompt?: string;
120
120
  temperature?: number;
121
121
  toolChoice?: "auto" | "none" | "required";
@@ -134,7 +134,7 @@ export interface GenerateChatStreamOptions {
134
134
  content: string;
135
135
  role: "user" | "assistant" | "system";
136
136
  }>;
137
- stopWhen?: import("ai").StopCondition<any>;
137
+ stopWhen?: StopCondition<ToolSet>;
138
138
  systemPrompt?: string;
139
139
  toolChoice?: "auto" | "none" | "required";
140
140
  tools?: Record<string, import("ai").Tool>;
package/package.json CHANGED
@@ -18,17 +18,17 @@
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/test": "0.31.0",
21
+ "@terreno/api": "56.0.0-beta.2",
22
+ "@terreno/test": "56.0.0-beta.2",
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/supertest": "^7.2.0",
27
- "@terreno/api": "0.31.0",
28
28
  "mongoose": "9.7.4",
29
29
  "passport-local-mongoose": "^9.0.1",
30
30
  "supertest": "^7.2.2",
31
- "typescript": "~5.9.2",
31
+ "typescript": "~6.0.3",
32
32
  "winston": "^3.18.3"
33
33
  },
34
34
  "exports": {
@@ -71,7 +71,7 @@
71
71
  "access": "public"
72
72
  },
73
73
  "peerDependencies": {
74
- "@terreno/api": "0.31.0",
74
+ "@terreno/api": "56.0.0-beta.2",
75
75
  "mongoose": "^8.0.0 || ^9.0.0"
76
76
  },
77
77
  "repository": {
@@ -90,5 +90,5 @@
90
90
  "test:coverage": "bun run ../scripts/check-coverage.ts"
91
91
  },
92
92
  "types": "dist/index.d.ts",
93
- "version": "0.31.0"
93
+ "version": "56.0.0-beta.2"
94
94
  }
@@ -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
- // When no vertexFactory is passed, loadVertexModule is called.
194
- // Since @ai-sdk/google-vertex is likely not installed in the test env, it returns undefined.
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
  });
@@ -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 factory = options.vertexFactory ?? loadVertexModule()?.createVertex;
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."
@@ -1,5 +1,5 @@
1
1
  import type {FindExactlyOnePlugin, FindOneOrNonePlugin} from "@terreno/api";
2
- import type {LanguageModel} from "ai";
2
+ import type {LanguageModel, StopCondition, ToolSet} from "ai";
3
3
  import type mongoose from "mongoose";
4
4
 
5
5
  // ============================================================
@@ -164,9 +164,7 @@ export interface AIServiceOptions {
164
164
  export interface GenerateTextOptions {
165
165
  maxOutputTokens?: number;
166
166
  prompt: string;
167
- // noExplicitAny: Vercel AI SDK's StopCondition is generic over the tool set; consumers may pass any tool shape.
168
- // biome-ignore lint/suspicious/noExplicitAny: Vercel AI SDK's StopCondition is generic over the tool set; consumers may pass any tool shape.
169
- stopWhen?: import("ai").StopCondition<any>;
167
+ stopWhen?: StopCondition<ToolSet>;
170
168
  systemPrompt?: string;
171
169
  temperature?: number;
172
170
  toolChoice?: "auto" | "none" | "required";
@@ -184,9 +182,7 @@ export interface GenerateStreamOptions {
184
182
 
185
183
  export interface GenerateChatStreamOptions {
186
184
  messages: Array<{content: string; role: "user" | "assistant" | "system"}>;
187
- // noExplicitAny: Vercel AI SDK's StopCondition is generic over the tool set; consumers may pass any tool shape.
188
- // biome-ignore lint/suspicious/noExplicitAny: Vercel AI SDK's StopCondition is generic over the tool set; consumers may pass any tool shape.
189
- stopWhen?: import("ai").StopCondition<any>;
185
+ stopWhen?: StopCondition<ToolSet>;
190
186
  systemPrompt?: string;
191
187
  toolChoice?: "auto" | "none" | "required";
192
188
  tools?: Record<string, import("ai").Tool>;
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": ["es2017", "dom", "es2017.object"],
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", "types.d.ts"]
39
+ "include": ["src/**/*.ts*", "src/*.ts", "src/**/*.d.ts"]
38
40
  }