@terreno/ai 0.13.3 → 0.14.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.
@@ -39,8 +39,8 @@ const getModelId = (model: LanguageModel): string => {
39
39
  };
40
40
 
41
41
  export class AIService {
42
- private model: LanguageModel;
43
- private defaultTemperature: number;
42
+ readonly model: LanguageModel;
43
+ readonly defaultTemperature: number;
44
44
 
45
45
  constructor({model, defaultTemperature = TemperaturePresets.DEFAULT}: AIServiceOptions) {
46
46
  this.model = model;
@@ -216,13 +216,13 @@ export class AIService {
216
216
  parts.push({image: new URL(part.url), mediaType: part.mimeType, type: "image"});
217
217
  } else if (part.type === "file") {
218
218
  logger.debug("Building file message part", {
219
- filename: (part as any).filename,
219
+ filename: part.filename,
220
220
  mediaType: part.mimeType,
221
221
  urlPrefix: part.url?.substring(0, 50),
222
222
  });
223
223
  parts.push({
224
224
  data: new URL(part.url),
225
- filename: (part as any).filename,
225
+ filename: part.filename,
226
226
  mediaType: part.mimeType,
227
227
  type: "file",
228
228
  });
@@ -1,4 +1,5 @@
1
1
  import {Storage, type StorageOptions} from "@google-cloud/storage";
2
+ import {DateTime} from "luxon";
2
3
 
3
4
  import {FileAttachment} from "../models/fileAttachment";
4
5
 
@@ -31,7 +32,7 @@ export class FileStorageService {
31
32
  }
32
33
 
33
34
  async upload({buffer, filename, mimeType, userId}: UploadFileParams): Promise<UploadFileResult> {
34
- const timestamp = Date.now();
35
+ const timestamp = DateTime.now().toMillis();
35
36
  const sanitizedFilename = filename.replace(/[^a-zA-Z0-9._-]/g, "_");
36
37
  const gcsKey = `uploads/${userId.toString()}/${timestamp}-${sanitizedFilename}`;
37
38
 
@@ -59,7 +60,7 @@ export class FileStorageService {
59
60
  const file = this.bucket.file(gcsKey);
60
61
  const [url] = await file.getSignedUrl({
61
62
  action: "read",
62
- expires: Date.now() + 60 * 60 * 1000, // 1 hour
63
+ expires: DateTime.now().plus({hours: 1}).toMillis(),
63
64
  version: "v4",
64
65
  });
65
66
  return url;
@@ -1,3 +1,4 @@
1
+ // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
1
2
  import {afterAll, afterEach, beforeAll, beforeEach, mock} from "bun:test";
2
3
  import {Writable} from "node:stream";
3
4
  import {setupEnvironment, winstonLogger} from "@terreno/api";
@@ -161,6 +161,7 @@ export interface AIServiceOptions {
161
161
  export interface GenerateTextOptions {
162
162
  maxOutputTokens?: number;
163
163
  prompt: string;
164
+ // biome-ignore lint/suspicious/noExplicitAny: Vercel AI SDK's StopCondition is generic over the tool set; consumers may pass any tool shape.
164
165
  stopWhen?: import("ai").StopCondition<any>;
165
166
  systemPrompt?: string;
166
167
  temperature?: number;
@@ -179,6 +180,7 @@ export interface GenerateStreamOptions {
179
180
 
180
181
  export interface GenerateChatStreamOptions {
181
182
  messages: Array<{content: string; role: "user" | "assistant" | "system"}>;
183
+ // biome-ignore lint/suspicious/noExplicitAny: Vercel AI SDK's StopCondition is generic over the tool set; consumers may pass any tool shape.
182
184
  stopWhen?: import("ai").StopCondition<any>;
183
185
  systemPrompt?: string;
184
186
  toolChoice?: "auto" | "none" | "required";