@aigne/gemini 1.74.0-beta.3 → 1.74.0-beta.5

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.
@@ -1,5 +1,5 @@
1
- import { ImageModel, imageModelInputSchema } from "@aigne/core";
2
- import { checkArguments, flat, isNonNullable, pick } from "@aigne/core/utils/type-utils";
1
+ import { ImageModel, imageModelInputSchema } from "@aigne/model-base";
2
+ import { checkArguments, flat, isNonNullable, pick } from "@aigne/model-base/utils/type-utils";
3
3
  import { GoogleGenAI, Modality } from "@google/genai";
4
4
  import { z } from "zod";
5
5
 
@@ -1 +1 @@
1
- {"version":3,"file":"gemini-image-model.mjs","names":[],"sources":["../src/gemini-image-model.ts"],"sourcesContent":["import {\n type AgentInvokeOptions,\n type FileUnionContent,\n ImageModel,\n type ImageModelInput,\n type ImageModelOptions,\n type ImageModelOutput,\n imageModelInputSchema,\n} from \"@aigne/core\";\nimport { checkArguments, flat, isNonNullable, pick } from \"@aigne/core/utils/type-utils\";\nimport {\n type GenerateContentConfig,\n type GenerateImagesConfig,\n GoogleGenAI,\n Modality,\n type PartUnion,\n} from \"@google/genai\";\nimport { z } from \"zod\";\n\nconst DEFAULT_MODEL = \"imagen-4.0-generate-001\";\n\nexport interface GeminiImageModelInput\n extends ImageModelInput,\n GenerateImagesConfig,\n GenerateContentConfig {}\nexport interface GeminiImageModelOutput extends ImageModelOutput {}\n\nexport interface GeminiImageModelOptions\n extends ImageModelOptions<GeminiImageModelInput, GeminiImageModelOutput> {\n apiKey?: string;\n baseURL?: string;\n model?: string;\n modelOptions?: Omit<Partial<GeminiImageModelInput>, \"model\">;\n clientOptions?: Record<string, any>;\n}\n\nconst geminiImageModelInputSchema = imageModelInputSchema.extend({});\n\nconst geminiImageModelOptionsSchema = z.object({\n apiKey: z.string().optional(),\n baseURL: z.string().optional(),\n model: z.string().optional(),\n modelOptions: z.object({}).optional(),\n clientOptions: z.object({}).optional(),\n});\n\nexport class GeminiImageModel extends ImageModel<GeminiImageModelInput, GeminiImageModelOutput> {\n constructor(public override options?: GeminiImageModelOptions) {\n super({\n ...options,\n inputSchema: geminiImageModelInputSchema,\n description: options?.description ?? \"Draw or edit image by Gemini image models\",\n });\n if (options) checkArguments(this.name, geminiImageModelOptionsSchema, options);\n }\n\n protected _client?: GoogleGenAI;\n\n protected apiKeyEnvName = \"GEMINI_API_KEY\";\n\n get client() {\n if (this._client) return this._client;\n\n const { apiKey } = this.credential;\n\n if (!apiKey)\n throw new Error(\n `${this.name} requires an API key. Please provide it via \\`options.apiKey\\`, or set the \\`${this.apiKeyEnvName}\\` environment variable`,\n );\n\n this._client ??= new GoogleGenAI({ apiKey });\n\n return this._client;\n }\n\n override get credential() {\n return {\n url: this.options?.baseURL || process.env.GEMINI_BASE_URL,\n apiKey: this.options?.apiKey || process.env[this.apiKeyEnvName],\n model: this.options?.model || DEFAULT_MODEL,\n };\n }\n\n get modelOptions() {\n return this.options?.modelOptions;\n }\n\n /**\n * Process the input and generate a response\n * @param input The input to process\n * @returns The generated response\n */\n override async process(\n input: GeminiImageModelInput,\n _options: AgentInvokeOptions,\n ): Promise<ImageModelOutput> {\n const model = input.modelOptions?.model || this.credential.model;\n const responseFormat = input.responseFormat || \"base64\";\n if (responseFormat === \"url\") {\n throw new Error(\"Gemini image models currently only support base64 format\");\n }\n\n if (model.includes(\"imagen\")) {\n return this.generateImageByImagenModel(input);\n }\n\n return this.generateImageByGeminiModel(input);\n }\n\n private async generateImageByImagenModel(\n input: GeminiImageModelInput,\n ): Promise<ImageModelOutput> {\n const model = input.modelOptions?.model || this.credential.model;\n\n const mergedInput = { ...this.modelOptions, ...input.modelOptions, ...input };\n\n const inputKeys = [\n \"seed\",\n \"safetyFilterLevel\",\n \"personGeneration\",\n \"outputMimeType\",\n \"outputGcsUri\",\n \"outputCompressionQuality\",\n \"negativePrompt\",\n \"language\",\n \"includeSafetyAttributes\",\n \"includeRaiReason\",\n \"imageSize\",\n \"guidanceScale\",\n \"aspectRatio\",\n \"addWatermark\",\n ];\n\n const response = await this.client.models.generateImages({\n model,\n prompt: mergedInput.prompt,\n config: { numberOfImages: mergedInput.n || 1, ...pick(mergedInput, inputKeys) },\n });\n\n return {\n images:\n response.generatedImages\n ?.map<FileUnionContent | undefined>(({ image }) =>\n image?.imageBytes\n ? { type: \"file\", data: image.imageBytes, mimeType: image.mimeType }\n : undefined,\n )\n .filter(isNonNullable) || [],\n usage: {\n inputTokens: 0,\n outputTokens: 0,\n },\n model,\n };\n }\n\n private async generateImageByGeminiModel(\n input: GeminiImageModelInput,\n ): Promise<ImageModelOutput> {\n const model = input.modelOptions?.model || this.credential.model;\n\n const mergedInput = { ...this.modelOptions, ...input.modelOptions, ...input };\n\n const inputKeys = [\n \"abortSignal\",\n \"audioTimestamp\",\n \"automaticFunctionCalling\",\n \"cachedContent\",\n \"frequencyPenalty\",\n \"httpOptions\",\n \"labels\",\n \"logprobs\",\n \"maxOutputTokens\",\n \"mediaResolution\",\n \"modelSelectionConfig\",\n \"presencePenalty\",\n \"responseJsonSchema\",\n \"responseLogprobs\",\n \"responseMimeType\",\n \"responseSchema\",\n \"routingConfig\",\n \"safetySettings\",\n \"seed\",\n \"speechConfig\",\n \"stopSequences\",\n \"systemInstruction\",\n \"temperature\",\n \"thinkingConfig\",\n \"toolConfig\",\n \"tools\",\n \"topK\",\n \"topP\",\n \"imageConfig\",\n ];\n\n const images = await Promise.all(\n flat(input.image).map<Promise<PartUnion>>(async (image) => {\n const { data, mimeType } = await this.transformFileType(\"file\", image);\n return { inlineData: { data, mimeType } };\n }),\n );\n\n const response = await this.client.models.generateContent({\n model,\n contents: [{ text: input.prompt }, ...images],\n config: {\n responseModalities: [Modality.TEXT, Modality.IMAGE],\n candidateCount: input.n || 1,\n ...pick(mergedInput, inputKeys),\n },\n });\n\n const allImages = (response.candidates ?? [])\n .flatMap((candidate) => candidate.content?.parts ?? [])\n .map<FileUnionContent | null>((part) =>\n part.inlineData?.data\n ? {\n type: \"file\",\n data: part.inlineData.data,\n filename: part.inlineData.displayName,\n mimeType: part.inlineData.mimeType,\n }\n : null,\n )\n .filter(isNonNullable);\n\n return {\n images: allImages,\n usage: {\n inputTokens: response.usageMetadata?.promptTokenCount || 0,\n outputTokens: response.usageMetadata?.candidatesTokenCount || 0,\n },\n model,\n };\n }\n}\n"],"mappings":";;;;;;AAmBA,MAAM,gBAAgB;AAiBtB,MAAM,8BAA8B,sBAAsB,OAAO,EAAE,CAAC;AAEpE,MAAM,gCAAgC,EAAE,OAAO;CAC7C,QAAQ,EAAE,QAAQ,CAAC,UAAU;CAC7B,SAAS,EAAE,QAAQ,CAAC,UAAU;CAC9B,OAAO,EAAE,QAAQ,CAAC,UAAU;CAC5B,cAAc,EAAE,OAAO,EAAE,CAAC,CAAC,UAAU;CACrC,eAAe,EAAE,OAAO,EAAE,CAAC,CAAC,UAAU;CACvC,CAAC;AAEF,IAAa,mBAAb,cAAsC,WAA0D;CAC9F,YAAY,AAAgB,SAAmC;AAC7D,QAAM;GACJ,GAAG;GACH,aAAa;GACb,aAAa,SAAS,eAAe;GACtC,CAAC;EALwB;AAM1B,MAAI,QAAS,gBAAe,KAAK,MAAM,+BAA+B,QAAQ;;CAGhF,AAAU;CAEV,AAAU,gBAAgB;CAE1B,IAAI,SAAS;AACX,MAAI,KAAK,QAAS,QAAO,KAAK;EAE9B,MAAM,EAAE,WAAW,KAAK;AAExB,MAAI,CAAC,OACH,OAAM,IAAI,MACR,GAAG,KAAK,KAAK,+EAA+E,KAAK,cAAc,yBAChH;AAEH,OAAK,YAAY,IAAI,YAAY,EAAE,QAAQ,CAAC;AAE5C,SAAO,KAAK;;CAGd,IAAa,aAAa;AACxB,SAAO;GACL,KAAK,KAAK,SAAS,WAAW,QAAQ,IAAI;GAC1C,QAAQ,KAAK,SAAS,UAAU,QAAQ,IAAI,KAAK;GACjD,OAAO,KAAK,SAAS,SAAS;GAC/B;;CAGH,IAAI,eAAe;AACjB,SAAO,KAAK,SAAS;;;;;;;CAQ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EAAE,MAAM,aAAa,MAAM,KAAK,kBAAkB,QAAQ,MAAM;AACtE,UAAO,EAAE,YAAY;IAAE;IAAM;IAAU,EAAE;IACzC,CACH;EAED,MAAM,WAAW,MAAM,KAAK,OAAO,OAAO,gBAAgB;GACxD;GACA,UAAU,CAAC,EAAE,MAAM,MAAM,QAAQ,EAAE,GAAG,OAAO;GAC7C,QAAQ;IACN,oBAAoB,CAAC,SAAS,MAAM,SAAS,MAAM;IACnD,gBAAgB,MAAM,KAAK;IAC3B,GAAG,KAAK,aAAa,UAAU;IAChC;GACF,CAAC;AAgBF,SAAO;GACL,SAfiB,SAAS,cAAc,EAAE,EACzC,SAAS,cAAc,UAAU,SAAS,SAAS,EAAE,CAAC,CACtD,KAA8B,SAC7B,KAAK,YAAY,OACb;IACE,MAAM;IACN,MAAM,KAAK,WAAW;IACtB,UAAU,KAAK,WAAW;IAC1B,UAAU,KAAK,WAAW;IAC3B,GACD,KACL,CACA,OAAO,cAAc;GAItB,OAAO;IACL,aAAa,SAAS,eAAe,oBAAoB;IACzD,cAAc,SAAS,eAAe,wBAAwB;IAC/D;GACD;GACD"}
1
+ {"version":3,"file":"gemini-image-model.mjs","names":[],"sources":["../src/gemini-image-model.ts"],"sourcesContent":["import {\n type FileUnionContent,\n ImageModel,\n type ImageModelInput,\n type ImageModelOptions,\n type ImageModelOutput,\n imageModelInputSchema,\n type ModelInvokeOptions,\n} from \"@aigne/model-base\";\nimport { checkArguments, flat, isNonNullable, pick } from \"@aigne/model-base/utils/type-utils\";\nimport {\n type GenerateContentConfig,\n type GenerateImagesConfig,\n GoogleGenAI,\n Modality,\n type PartUnion,\n} from \"@google/genai\";\nimport { z } from \"zod\";\n\nconst DEFAULT_MODEL = \"imagen-4.0-generate-001\";\n\nexport interface GeminiImageModelInput\n extends ImageModelInput,\n GenerateImagesConfig,\n GenerateContentConfig {}\nexport interface GeminiImageModelOutput extends ImageModelOutput {}\n\nexport interface GeminiImageModelOptions\n extends ImageModelOptions<GeminiImageModelInput, GeminiImageModelOutput> {\n apiKey?: string;\n baseURL?: string;\n model?: string;\n modelOptions?: Omit<Partial<GeminiImageModelInput>, \"model\">;\n clientOptions?: Record<string, any>;\n}\n\nconst geminiImageModelInputSchema = imageModelInputSchema.extend({});\n\nconst geminiImageModelOptionsSchema = z.object({\n apiKey: z.string().optional(),\n baseURL: z.string().optional(),\n model: z.string().optional(),\n modelOptions: z.object({}).optional(),\n clientOptions: z.object({}).optional(),\n});\n\nexport class GeminiImageModel extends ImageModel<GeminiImageModelInput, GeminiImageModelOutput> {\n constructor(public override options?: GeminiImageModelOptions) {\n super({\n ...options,\n inputSchema: geminiImageModelInputSchema,\n description: options?.description ?? \"Draw or edit image by Gemini image models\",\n });\n if (options) checkArguments(this.name, geminiImageModelOptionsSchema, options);\n }\n\n protected _client?: GoogleGenAI;\n\n protected apiKeyEnvName = \"GEMINI_API_KEY\";\n\n get client() {\n if (this._client) return this._client;\n\n const { apiKey } = this.credential;\n\n if (!apiKey)\n throw new Error(\n `${this.name} requires an API key. Please provide it via \\`options.apiKey\\`, or set the \\`${this.apiKeyEnvName}\\` environment variable`,\n );\n\n this._client ??= new GoogleGenAI({ apiKey });\n\n return this._client;\n }\n\n override get credential() {\n return {\n url: this.options?.baseURL || process.env.GEMINI_BASE_URL,\n apiKey: this.options?.apiKey || process.env[this.apiKeyEnvName],\n model: this.options?.model || DEFAULT_MODEL,\n };\n }\n\n get modelOptions() {\n return this.options?.modelOptions;\n }\n\n /**\n * Process the input and generate a response\n * @param input The input to process\n * @returns The generated response\n */\n override async process(\n input: GeminiImageModelInput,\n _options: ModelInvokeOptions,\n ): Promise<ImageModelOutput> {\n const model = input.modelOptions?.model || this.credential.model;\n const responseFormat = input.responseFormat || \"base64\";\n if (responseFormat === \"url\") {\n throw new Error(\"Gemini image models currently only support base64 format\");\n }\n\n if (model.includes(\"imagen\")) {\n return this.generateImageByImagenModel(input);\n }\n\n return this.generateImageByGeminiModel(input);\n }\n\n private async generateImageByImagenModel(\n input: GeminiImageModelInput,\n ): Promise<ImageModelOutput> {\n const model = input.modelOptions?.model || this.credential.model;\n\n const mergedInput = { ...this.modelOptions, ...input.modelOptions, ...input };\n\n const inputKeys = [\n \"seed\",\n \"safetyFilterLevel\",\n \"personGeneration\",\n \"outputMimeType\",\n \"outputGcsUri\",\n \"outputCompressionQuality\",\n \"negativePrompt\",\n \"language\",\n \"includeSafetyAttributes\",\n \"includeRaiReason\",\n \"imageSize\",\n \"guidanceScale\",\n \"aspectRatio\",\n \"addWatermark\",\n ];\n\n const response = await this.client.models.generateImages({\n model,\n prompt: mergedInput.prompt,\n config: { numberOfImages: mergedInput.n || 1, ...pick(mergedInput, inputKeys) },\n });\n\n return {\n images:\n response.generatedImages\n ?.map<FileUnionContent | undefined>(({ image }) =>\n image?.imageBytes\n ? { type: \"file\", data: image.imageBytes, mimeType: image.mimeType }\n : undefined,\n )\n .filter(isNonNullable) || [],\n usage: {\n inputTokens: 0,\n outputTokens: 0,\n },\n model,\n };\n }\n\n private async generateImageByGeminiModel(\n input: GeminiImageModelInput,\n ): Promise<ImageModelOutput> {\n const model = input.modelOptions?.model || this.credential.model;\n\n const mergedInput = { ...this.modelOptions, ...input.modelOptions, ...input };\n\n const inputKeys = [\n \"abortSignal\",\n \"audioTimestamp\",\n \"automaticFunctionCalling\",\n \"cachedContent\",\n \"frequencyPenalty\",\n \"httpOptions\",\n \"labels\",\n \"logprobs\",\n \"maxOutputTokens\",\n \"mediaResolution\",\n \"modelSelectionConfig\",\n \"presencePenalty\",\n \"responseJsonSchema\",\n \"responseLogprobs\",\n \"responseMimeType\",\n \"responseSchema\",\n \"routingConfig\",\n \"safetySettings\",\n \"seed\",\n \"speechConfig\",\n \"stopSequences\",\n \"systemInstruction\",\n \"temperature\",\n \"thinkingConfig\",\n \"toolConfig\",\n \"tools\",\n \"topK\",\n \"topP\",\n \"imageConfig\",\n ];\n\n const images = await Promise.all(\n flat(input.image).map<Promise<PartUnion>>(async (image) => {\n const { data, mimeType } = await this.transformFileType(\"file\", image);\n return { inlineData: { data, mimeType } };\n }),\n );\n\n const response = await this.client.models.generateContent({\n model,\n contents: [{ text: input.prompt }, ...images],\n config: {\n responseModalities: [Modality.TEXT, Modality.IMAGE],\n candidateCount: input.n || 1,\n ...pick(mergedInput, inputKeys),\n },\n });\n\n const allImages = (response.candidates ?? [])\n .flatMap((candidate) => candidate.content?.parts ?? [])\n .map<FileUnionContent | null>((part) =>\n part.inlineData?.data\n ? {\n type: \"file\",\n data: part.inlineData.data,\n filename: part.inlineData.displayName,\n mimeType: part.inlineData.mimeType,\n }\n : null,\n )\n .filter(isNonNullable);\n\n return {\n images: allImages,\n usage: {\n inputTokens: response.usageMetadata?.promptTokenCount || 0,\n outputTokens: response.usageMetadata?.candidatesTokenCount || 0,\n },\n model,\n };\n }\n}\n"],"mappings":";;;;;;AAmBA,MAAM,gBAAgB;AAiBtB,MAAM,8BAA8B,sBAAsB,OAAO,EAAE,CAAC;AAEpE,MAAM,gCAAgC,EAAE,OAAO;CAC7C,QAAQ,EAAE,QAAQ,CAAC,UAAU;CAC7B,SAAS,EAAE,QAAQ,CAAC,UAAU;CAC9B,OAAO,EAAE,QAAQ,CAAC,UAAU;CAC5B,cAAc,EAAE,OAAO,EAAE,CAAC,CAAC,UAAU;CACrC,eAAe,EAAE,OAAO,EAAE,CAAC,CAAC,UAAU;CACvC,CAAC;AAEF,IAAa,mBAAb,cAAsC,WAA0D;CAC9F,YAAY,AAAgB,SAAmC;AAC7D,QAAM;GACJ,GAAG;GACH,aAAa;GACb,aAAa,SAAS,eAAe;GACtC,CAAC;EALwB;AAM1B,MAAI,QAAS,gBAAe,KAAK,MAAM,+BAA+B,QAAQ;;CAGhF,AAAU;CAEV,AAAU,gBAAgB;CAE1B,IAAI,SAAS;AACX,MAAI,KAAK,QAAS,QAAO,KAAK;EAE9B,MAAM,EAAE,WAAW,KAAK;AAExB,MAAI,CAAC,OACH,OAAM,IAAI,MACR,GAAG,KAAK,KAAK,+EAA+E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GAAG,KAAK;GAAc,GAAG,MAAM;GAAc,GAAG;GAAO;EAE7E,MAAM,YAAY;GAChB;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD;EAED,MAAM,SAAS,MAAM,QAAQ,IAC3B,KAAK,MAAM,MAAM,CAAC,IAAwB,OAAO,UAAU;GACzD,MAAM,EAAE,MAAM,aAAa,MAAM,KAAK,kBAAkB,QAAQ,MAAM;AACtE,UAAO,EAAE,YAAY;IAAE;IAAM;IAAU,EAAE;IACzC,CACH;EAED,MAAM,WAAW,MAAM,KAAK,OAAO,OAAO,gBAAgB;GACxD;GACA,UAAU,CAAC,EAAE,MAAM,MAAM,QAAQ,EAAE,GAAG,OAAO;GAC7C,QAAQ;IACN,oBAAoB,CAAC,SAAS,MAAM,SAAS,MAAM;IACnD,gBAAgB,MAAM,KAAK;IAC3B,GAAG,KAAK,aAAa,UAAU;IAChC;GACF,CAAC;AAgBF,SAAO;GACL,SAfiB,SAAS,cAAc,EAAE,EACzC,SAAS,cAAc,UAAU,SAAS,SAAS,EAAE,CAAC,CACtD,KAA8B,SAC7B,KAAK,YAAY,OACb;IACE,MAAM;IACN,MAAM,KAAK,WAAW;IACtB,UAAU,KAAK,WAAW;IAC1B,UAAU,KAAK,WAAW;IAC3B,GACD,KACL,CACA,OAAO,cAAc;GAItB,OAAO;IACL,aAAa,SAAS,eAAe,oBAAoB;IACzD,cAAc,SAAS,eAAe,wBAAwB;IAC/D;GACD;GACD"}
@@ -1,15 +1,15 @@
1
1
  const require_utils = require('./utils.cjs');
2
- let _aigne_core = require("@aigne/core");
3
- let _aigne_core_utils_logger = require("@aigne/core/utils/logger");
4
- let _aigne_core_utils_type_utils = require("@aigne/core/utils/type-utils");
5
- let _aigne_utils_nodejs = require("@aigne/utils/nodejs");
2
+ let _aigne_model_base = require("@aigne/model-base");
3
+ let _aigne_model_base_utils_logger = require("@aigne/model-base/utils/logger");
4
+ let _aigne_model_base_utils_nodejs = require("@aigne/model-base/utils/nodejs");
5
+ let _aigne_model_base_utils_type_utils = require("@aigne/model-base/utils/type-utils");
6
6
  let _google_genai = require("@google/genai");
7
7
  let zod = require("zod");
8
8
 
9
9
  //#region src/gemini-video-model.ts
10
10
  const DEFAULT_MODEL = "veo-3.1-generate-preview";
11
11
  const DEFAULT_SECONDS = 8;
12
- const geminiVideoModelInputSchema = _aigne_core.videoModelInputSchema.extend({
12
+ const geminiVideoModelInputSchema = _aigne_model_base.videoModelInputSchema.extend({
13
13
  negativePrompt: zod.z.string().optional(),
14
14
  aspectRatio: zod.z.enum(["16:9", "9:16"]).optional(),
15
15
  size: zod.z.enum(["720p", "1080p"]).optional(),
@@ -19,8 +19,8 @@ const geminiVideoModelInputSchema = _aigne_core.videoModelInputSchema.extend({
19
19
  "8"
20
20
  ]).optional(),
21
21
  personGeneration: zod.z.string().optional(),
22
- lastFrame: _aigne_core.fileUnionContentSchema.optional(),
23
- referenceImages: _aigne_core.fileUnionContentSchema.array().optional()
22
+ lastFrame: _aigne_model_base.fileUnionContentSchema.optional(),
23
+ referenceImages: _aigne_model_base.fileUnionContentSchema.array().optional()
24
24
  });
25
25
  const geminiVideoModelOptionsSchema = zod.z.object({
26
26
  apiKey: zod.z.string().optional(),
@@ -30,7 +30,7 @@ const geminiVideoModelOptionsSchema = zod.z.object({
30
30
  clientOptions: zod.z.object({}).optional(),
31
31
  pollingInterval: zod.z.number().optional()
32
32
  });
33
- var GeminiVideoModel = class extends _aigne_core.VideoModel {
33
+ var GeminiVideoModel = class extends _aigne_model_base.VideoModel {
34
34
  constructor(options) {
35
35
  super({
36
36
  ...options,
@@ -38,7 +38,7 @@ var GeminiVideoModel = class extends _aigne_core.VideoModel {
38
38
  inputSchema: geminiVideoModelInputSchema
39
39
  });
40
40
  this.options = options;
41
- if (options) (0, _aigne_core_utils_type_utils.checkArguments)(this.name, geminiVideoModelOptionsSchema, options);
41
+ if (options) (0, _aigne_model_base_utils_type_utils.checkArguments)(this.name, geminiVideoModelOptionsSchema, options);
42
42
  }
43
43
  /**
44
44
  * @hidden
@@ -65,17 +65,17 @@ var GeminiVideoModel = class extends _aigne_core.VideoModel {
65
65
  return this.options?.modelOptions;
66
66
  }
67
67
  async downloadToFile(dir, videoId, videoFile) {
68
- _aigne_core_utils_logger.logger.debug("Downloading video content...");
69
- const localPath = _aigne_utils_nodejs.nodejs.path.join(dir, `${videoId}.mp4`);
68
+ _aigne_model_base_utils_logger.logger.debug("Downloading video content...");
69
+ const localPath = _aigne_model_base_utils_nodejs.nodejs.path.join(dir, `${videoId}.mp4`);
70
70
  await this.client.files.download({
71
71
  file: videoFile,
72
72
  downloadPath: localPath
73
73
  });
74
- _aigne_core_utils_logger.logger.debug(`Generated video saved to ${localPath}`);
74
+ _aigne_model_base_utils_logger.logger.debug(`Generated video saved to ${localPath}`);
75
75
  await require_utils.waitFileSizeStable(localPath);
76
- return (await _aigne_utils_nodejs.nodejs.fs.readFile(localPath)).toString("base64");
76
+ return (await _aigne_model_base_utils_nodejs.nodejs.fs.readFile(localPath)).toString("base64");
77
77
  }
78
- async process(input, options) {
78
+ async process(input, _options) {
79
79
  const model = input.model ?? input.modelOptions?.model ?? this.credential.model;
80
80
  const mergedInput = {
81
81
  ...this.modelOptions,
@@ -114,18 +114,18 @@ var GeminiVideoModel = class extends _aigne_core.VideoModel {
114
114
  };
115
115
  });
116
116
  let operation = await this.client.models.generateVideos(params);
117
- _aigne_core_utils_logger.logger.debug("Video generation started...");
117
+ _aigne_model_base_utils_logger.logger.debug("Video generation started...");
118
118
  const pollingInterval = this.options?.pollingInterval ?? 1e4;
119
119
  while (!operation.done) {
120
- _aigne_core_utils_logger.logger.debug("Waiting for video generation to complete...");
120
+ _aigne_model_base_utils_logger.logger.debug("Waiting for video generation to complete...");
121
121
  await new Promise((resolve) => setTimeout(resolve, pollingInterval));
122
122
  operation = await this.client.operations.getVideosOperation({ operation });
123
123
  }
124
124
  if (!operation.response?.generatedVideos?.[0]?.video) throw new Error("Video generation failed: No video generated");
125
125
  const videoFile = operation.response.generatedVideos[0].video;
126
126
  if (!videoFile) throw new Error("Video generation failed: No video file returned");
127
- const dir = _aigne_utils_nodejs.nodejs.path.join(_aigne_utils_nodejs.nodejs.os.tmpdir(), options?.context?.id || "");
128
- await _aigne_utils_nodejs.nodejs.fs.mkdir(dir, { recursive: true });
127
+ const dir = _aigne_model_base_utils_nodejs.nodejs.path.join(_aigne_model_base_utils_nodejs.nodejs.os.tmpdir(), `gemini-video-${Date.now()}`);
128
+ await _aigne_model_base_utils_nodejs.nodejs.fs.mkdir(dir, { recursive: true });
129
129
  const videoId = Date.now().toString();
130
130
  return {
131
131
  videos: [{
@@ -1,4 +1,4 @@
1
- import { AgentInvokeOptions, FileUnionContent, VideoModel, VideoModelInput, VideoModelOptions, VideoModelOutput } from "@aigne/core";
1
+ import { FileUnionContent, ModelInvokeOptions, VideoModel, VideoModelInput, VideoModelOptions, VideoModelOutput } from "@aigne/model-base";
2
2
  import { GoogleGenAI } from "@google/genai";
3
3
 
4
4
  //#region src/gemini-video-model.d.ts
@@ -7,47 +7,47 @@ import { GoogleGenAI } from "@google/genai";
7
7
  */
8
8
  interface GeminiVideoModelInput extends VideoModelInput {
9
9
  /**
10
- * Text describing content that should not appear in the video
11
- */
10
+ * Text describing content that should not appear in the video
11
+ */
12
12
  negativePrompt?: string;
13
13
  /**
14
- * Aspect ratio of the video
15
- *
16
- * Veo 3.1: "16:9" (default, 720p and 1080p), "9:16" (720p and 1080p)
17
- * Veo 3: "16:9" (default, 720p and 1080p), "9:16" (720p and 1080p)
18
- */
14
+ * Aspect ratio of the video
15
+ *
16
+ * Veo 3.1: "16:9" (default, 720p and 1080p), "9:16" (720p and 1080p)
17
+ * Veo 3: "16:9" (default, 720p and 1080p), "9:16" (720p and 1080p)
18
+ */
19
19
  aspectRatio?: "16:9" | "9:16";
20
20
  /**
21
- * Resolution of the video
22
- *
23
- * Veo 3.1: "720p" (default), "1080p" (only supports 8 seconds duration)
24
- * Veo 3: "720p" (default), "1080p" (16:9 only)
25
- */
21
+ * Resolution of the video
22
+ *
23
+ * Veo 3.1: "720p" (default), "1080p" (only supports 8 seconds duration)
24
+ * Veo 3: "720p" (default), "1080p" (16:9 only)
25
+ */
26
26
  size?: "720p" | "1080p";
27
27
  /**
28
- * Duration of the generated video in seconds
29
- *
30
- * Veo 3.1: "4", "6", "8"
31
- * Veo 3: "4", "6", "8"
32
- */
28
+ * Duration of the generated video in seconds
29
+ *
30
+ * Veo 3.1: "4", "6", "8"
31
+ * Veo 3: "4", "6", "8"
32
+ */
33
33
  seconds?: "4" | "6" | "8";
34
34
  /**
35
- * Control person generation
36
- *
37
- * For text-to-video and image-to-video:
38
- * - Veo 3.1: "allow_all" for image-to-video, frame interpolation and reference images; only "allow_adult" for text-to-video
39
- * - Veo 3: "allow_all" for image-to-video; only "allow_adult" for text-to-video
40
- * - Veo 2: "allow_all", "allow_adult", "dont_allow"
41
- */
35
+ * Control person generation
36
+ *
37
+ * For text-to-video and image-to-video:
38
+ * - Veo 3.1: "allow_all" for image-to-video, frame interpolation and reference images; only "allow_adult" for text-to-video
39
+ * - Veo 3: "allow_all" for image-to-video; only "allow_adult" for text-to-video
40
+ * - Veo 2: "allow_all", "allow_adult", "dont_allow"
41
+ */
42
42
  personGeneration?: string;
43
43
  /**
44
- * Last frame for video generation (frame interpolation)
45
- */
44
+ * Last frame for video generation (frame interpolation)
45
+ */
46
46
  lastFrame?: FileUnionContent;
47
47
  /**
48
- * Reference images for video generation
49
- * Only supported in Veo 3.1 models
50
- */
48
+ * Reference images for video generation
49
+ * Only supported in Veo 3.1 models
50
+ */
51
51
  referenceImages?: FileUnionContent[];
52
52
  }
53
53
  /**
@@ -59,44 +59,44 @@ interface GeminiVideoModelOutput extends VideoModelOutput {}
59
59
  */
60
60
  interface GeminiVideoModelOptions extends VideoModelOptions<GeminiVideoModelInput, GeminiVideoModelOutput> {
61
61
  /**
62
- * API key for Gemini API
63
- *
64
- * If not provided, will look for GEMINI_API_KEY in environment variables
65
- */
62
+ * API key for Gemini API
63
+ *
64
+ * If not provided, will look for GEMINI_API_KEY in environment variables
65
+ */
66
66
  apiKey?: string;
67
67
  /**
68
- * Base URL for Gemini API
69
- *
70
- * Useful for proxies or alternate endpoints
71
- */
68
+ * Base URL for Gemini API
69
+ *
70
+ * Useful for proxies or alternate endpoints
71
+ */
72
72
  baseURL?: string;
73
73
  /**
74
- * Gemini model to use
75
- *
76
- * Defaults to 'veo-3.1-generate-preview'
77
- */
74
+ * Gemini model to use
75
+ *
76
+ * Defaults to 'veo-3.1-generate-preview'
77
+ */
78
78
  model?: string;
79
79
  /**
80
- * Additional model options to control behavior
81
- */
80
+ * Additional model options to control behavior
81
+ */
82
82
  modelOptions?: Omit<Partial<GeminiVideoModelInput>, "model">;
83
83
  /**
84
- * Client options for Gemini API
85
- */
84
+ * Client options for Gemini API
85
+ */
86
86
  clientOptions?: Record<string, any>;
87
87
  /**
88
- * Polling interval in milliseconds for checking video generation status
89
- *
90
- * Defaults to 10000ms (10 seconds)
91
- */
88
+ * Polling interval in milliseconds for checking video generation status
89
+ *
90
+ * Defaults to 10000ms (10 seconds)
91
+ */
92
92
  pollingInterval?: number;
93
93
  }
94
94
  declare class GeminiVideoModel extends VideoModel<GeminiVideoModelInput, GeminiVideoModelOutput> {
95
95
  options?: GeminiVideoModelOptions | undefined;
96
96
  constructor(options?: GeminiVideoModelOptions | undefined);
97
97
  /**
98
- * @hidden
99
- */
98
+ * @hidden
99
+ */
100
100
  protected _client?: GoogleGenAI;
101
101
  protected apiKeyEnvName: string;
102
102
  get client(): GoogleGenAI;
@@ -110,7 +110,7 @@ declare class GeminiVideoModel extends VideoModel<GeminiVideoModelInput, GeminiV
110
110
  uri?: string;
111
111
  videoBytes?: any;
112
112
  }): Promise<string>;
113
- process(input: GeminiVideoModelInput, options: AgentInvokeOptions): Promise<GeminiVideoModelOutput>;
113
+ process(input: GeminiVideoModelInput, _options: ModelInvokeOptions): Promise<GeminiVideoModelOutput>;
114
114
  }
115
115
  //#endregion
116
116
  export { GeminiVideoModel, GeminiVideoModelInput, GeminiVideoModelOptions, GeminiVideoModelOutput };
@@ -1 +1 @@
1
- {"version":3,"file":"gemini-video-model.d.cts","names":[],"sources":["../src/gemini-video-model.ts"],"mappings":";;;;;AAqBA;;UAAiB,qBAAA,SAA8B,eAAA;EAAA;;AAuD/C;EAvD+C,cAAA;EAAA;;AAuD/C;AAKA;;;EA5D+C,WAAA;EAAA;;AAuD/C;AAKA;;;EA5D+C,IAAA;EAAA;;AAuD/C;AAKA;;;EA5D+C,OAAA;EAAA;;AAuD/C;AAKA;;;;;EA5D+C,gBAAA;EAAA;;AAuD/C;EAvD+C,SAAA,GA2CjC,gBAAA;EAAA;;;;EAAA,eAAA,GAMM,gBAAA;AAAA;AAAA;;;AAAA,UAMH,sBAAA,SAA+B,gBAAA;AAAA;AAKhD;;AALgD,UAK/B,uBAAA,SACP,iBAAA,CAAkB,qBAAA,EAAuB,sBAAA;EAAA;;;;;EAAA,MAAA;EAAA;;;;;EAAA,OAAA;EAAA;;;;;EAAA,KAAA;EAAA;;;EAAA,YAAA,GAyBlC,IAAA,CAAK,OAAA,CAAQ,qBAAA;EAAA;;;EAAA,aAAA,GAKZ,MAAA;EAAA;;;AA6BlB;;EA7BkB,eAAA;AAAA;AAAA,cA6BL,gBAAA,SAAyB,UAAA,CAAW,qBAAA,EAAuB,sBAAA;EAAA,OAAA,GAChC,uBAAA;EAAA,YAAA,OAAA,GAAA,uBAAA;EAAA;;;EAAA,UAAA,OAAA,GAalB,WAAA;EAAA,UAAA,aAAA;EAAA,IAAA,OAAA,GAIV,WAAA;EAAA,IAAA,WAAA;IAAA,GAAA;IAAA,MAAA;IAAA,KAAA;EAAA;EAAA,IAAA,aAAA,GAmBM,IAAA,CAAA,OAAA,CAAA,qBAAA;EAAA,eAAA,GAAA,UAAA,OAAA,UAA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AAA,GACT,OAAA,CAAQ,sBAAA;AAAA"}
@@ -1,4 +1,4 @@
1
- import { AgentInvokeOptions, FileUnionContent, VideoModel, VideoModelInput, VideoModelOptions, VideoModelOutput } from "@aigne/core";
1
+ import { FileUnionContent, ModelInvokeOptions, VideoModel, VideoModelInput, VideoModelOptions, VideoModelOutput } from "@aigne/model-base";
2
2
  import { GoogleGenAI } from "@google/genai";
3
3
 
4
4
  //#region src/gemini-video-model.d.ts
@@ -7,47 +7,47 @@ import { GoogleGenAI } from "@google/genai";
7
7
  */
8
8
  interface GeminiVideoModelInput extends VideoModelInput {
9
9
  /**
10
- * Text describing content that should not appear in the video
11
- */
10
+ * Text describing content that should not appear in the video
11
+ */
12
12
  negativePrompt?: string;
13
13
  /**
14
- * Aspect ratio of the video
15
- *
16
- * Veo 3.1: "16:9" (default, 720p and 1080p), "9:16" (720p and 1080p)
17
- * Veo 3: "16:9" (default, 720p and 1080p), "9:16" (720p and 1080p)
18
- */
14
+ * Aspect ratio of the video
15
+ *
16
+ * Veo 3.1: "16:9" (default, 720p and 1080p), "9:16" (720p and 1080p)
17
+ * Veo 3: "16:9" (default, 720p and 1080p), "9:16" (720p and 1080p)
18
+ */
19
19
  aspectRatio?: "16:9" | "9:16";
20
20
  /**
21
- * Resolution of the video
22
- *
23
- * Veo 3.1: "720p" (default), "1080p" (only supports 8 seconds duration)
24
- * Veo 3: "720p" (default), "1080p" (16:9 only)
25
- */
21
+ * Resolution of the video
22
+ *
23
+ * Veo 3.1: "720p" (default), "1080p" (only supports 8 seconds duration)
24
+ * Veo 3: "720p" (default), "1080p" (16:9 only)
25
+ */
26
26
  size?: "720p" | "1080p";
27
27
  /**
28
- * Duration of the generated video in seconds
29
- *
30
- * Veo 3.1: "4", "6", "8"
31
- * Veo 3: "4", "6", "8"
32
- */
28
+ * Duration of the generated video in seconds
29
+ *
30
+ * Veo 3.1: "4", "6", "8"
31
+ * Veo 3: "4", "6", "8"
32
+ */
33
33
  seconds?: "4" | "6" | "8";
34
34
  /**
35
- * Control person generation
36
- *
37
- * For text-to-video and image-to-video:
38
- * - Veo 3.1: "allow_all" for image-to-video, frame interpolation and reference images; only "allow_adult" for text-to-video
39
- * - Veo 3: "allow_all" for image-to-video; only "allow_adult" for text-to-video
40
- * - Veo 2: "allow_all", "allow_adult", "dont_allow"
41
- */
35
+ * Control person generation
36
+ *
37
+ * For text-to-video and image-to-video:
38
+ * - Veo 3.1: "allow_all" for image-to-video, frame interpolation and reference images; only "allow_adult" for text-to-video
39
+ * - Veo 3: "allow_all" for image-to-video; only "allow_adult" for text-to-video
40
+ * - Veo 2: "allow_all", "allow_adult", "dont_allow"
41
+ */
42
42
  personGeneration?: string;
43
43
  /**
44
- * Last frame for video generation (frame interpolation)
45
- */
44
+ * Last frame for video generation (frame interpolation)
45
+ */
46
46
  lastFrame?: FileUnionContent;
47
47
  /**
48
- * Reference images for video generation
49
- * Only supported in Veo 3.1 models
50
- */
48
+ * Reference images for video generation
49
+ * Only supported in Veo 3.1 models
50
+ */
51
51
  referenceImages?: FileUnionContent[];
52
52
  }
53
53
  /**
@@ -59,44 +59,44 @@ interface GeminiVideoModelOutput extends VideoModelOutput {}
59
59
  */
60
60
  interface GeminiVideoModelOptions extends VideoModelOptions<GeminiVideoModelInput, GeminiVideoModelOutput> {
61
61
  /**
62
- * API key for Gemini API
63
- *
64
- * If not provided, will look for GEMINI_API_KEY in environment variables
65
- */
62
+ * API key for Gemini API
63
+ *
64
+ * If not provided, will look for GEMINI_API_KEY in environment variables
65
+ */
66
66
  apiKey?: string;
67
67
  /**
68
- * Base URL for Gemini API
69
- *
70
- * Useful for proxies or alternate endpoints
71
- */
68
+ * Base URL for Gemini API
69
+ *
70
+ * Useful for proxies or alternate endpoints
71
+ */
72
72
  baseURL?: string;
73
73
  /**
74
- * Gemini model to use
75
- *
76
- * Defaults to 'veo-3.1-generate-preview'
77
- */
74
+ * Gemini model to use
75
+ *
76
+ * Defaults to 'veo-3.1-generate-preview'
77
+ */
78
78
  model?: string;
79
79
  /**
80
- * Additional model options to control behavior
81
- */
80
+ * Additional model options to control behavior
81
+ */
82
82
  modelOptions?: Omit<Partial<GeminiVideoModelInput>, "model">;
83
83
  /**
84
- * Client options for Gemini API
85
- */
84
+ * Client options for Gemini API
85
+ */
86
86
  clientOptions?: Record<string, any>;
87
87
  /**
88
- * Polling interval in milliseconds for checking video generation status
89
- *
90
- * Defaults to 10000ms (10 seconds)
91
- */
88
+ * Polling interval in milliseconds for checking video generation status
89
+ *
90
+ * Defaults to 10000ms (10 seconds)
91
+ */
92
92
  pollingInterval?: number;
93
93
  }
94
94
  declare class GeminiVideoModel extends VideoModel<GeminiVideoModelInput, GeminiVideoModelOutput> {
95
95
  options?: GeminiVideoModelOptions | undefined;
96
96
  constructor(options?: GeminiVideoModelOptions | undefined);
97
97
  /**
98
- * @hidden
99
- */
98
+ * @hidden
99
+ */
100
100
  protected _client?: GoogleGenAI;
101
101
  protected apiKeyEnvName: string;
102
102
  get client(): GoogleGenAI;
@@ -110,7 +110,7 @@ declare class GeminiVideoModel extends VideoModel<GeminiVideoModelInput, GeminiV
110
110
  uri?: string;
111
111
  videoBytes?: any;
112
112
  }): Promise<string>;
113
- process(input: GeminiVideoModelInput, options: AgentInvokeOptions): Promise<GeminiVideoModelOutput>;
113
+ process(input: GeminiVideoModelInput, _options: ModelInvokeOptions): Promise<GeminiVideoModelOutput>;
114
114
  }
115
115
  //#endregion
116
116
  export { GeminiVideoModel, GeminiVideoModelInput, GeminiVideoModelOptions, GeminiVideoModelOutput };
@@ -1 +1 @@
1
- {"version":3,"file":"gemini-video-model.d.mts","names":[],"sources":["../src/gemini-video-model.ts"],"mappings":";;;;;AAqBA;;UAAiB,qBAAA,SAA8B,eAAA;EAAA;;AAuD/C;EAvD+C,cAAA;EAAA;;AAuD/C;AAKA;;;EA5D+C,WAAA;EAAA;;AAuD/C;AAKA;;;EA5D+C,IAAA;EAAA;;AAuD/C;AAKA;;;EA5D+C,OAAA;EAAA;;AAuD/C;A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AzBA,eAAA,GAAkB,gBAAA;AAAA;;;;UAMH,sBAAA,SAA+B,gBAAA;AAiEhD;;;AAAA,UA5DiB,uBAAA,SACP,iBAAA,CAAkB,qBAAA,EAAuB,sBAAA;EA2DqB;;;;;EArDtE,MAAA;EA0FgB;;;;;EAnFhB,OAAA;EA0GG;;;;;EAnGH,KAAA;EAuCsE;;;EAlCtE,YAAA,GAAe,IAAA,CAAK,OAAA,CAAQ,qBAAA;EAmCU;;;EA9BtC,aAAA,GAAgB,MAAA;EA6CN;;;;;EAtCV,eAAA;AAAA;AAAA,cAsBW,gBAAA,SAAyB,UAAA,CAAW,qBAAA,EAAuB,sBAAA;EAC1C,OAAA,GAAU,uBAAA;cAAV,OAAA,GAAU,uBAAA;EAoCtB;;;EAAA,UAvBN,OAAA,GAAU,WAAA;EAAA,UAEV,aAAA;EAAA,IAEN,MAAA,CAAA,GAAM,WAAA;EAAA,IAWG,UAAA,CAAA;;;;;MAQT,YAAA,CAAA,GAAY,IAAA,CAAA,OAAA,CAAA,qBAAA;EAIV,cAAA,CACJ,GAAA,UACA,OAAA,UACA,SAAA;IAAa,GAAA;IAAc,UAAA;EAAA,IAC1B,OAAA;EAYY,OAAA,CACb,KAAA,EAAO,qBAAA,EACP,QAAA,EAAU,kBAAA,GACT,OAAA,CAAQ,sBAAA;AAAA"}
@@ -1,8 +1,8 @@
1
1
  import { waitFileSizeStable } from "./utils.mjs";
2
- import { VideoModel, fileUnionContentSchema, videoModelInputSchema } from "@aigne/core";
3
- import { logger } from "@aigne/core/utils/logger";
4
- import { checkArguments } from "@aigne/core/utils/type-utils";
5
- import { nodejs } from "@aigne/utils/nodejs";
2
+ import { VideoModel, fileUnionContentSchema, videoModelInputSchema } from "@aigne/model-base";
3
+ import { logger } from "@aigne/model-base/utils/logger";
4
+ import { nodejs } from "@aigne/model-base/utils/nodejs";
5
+ import { checkArguments } from "@aigne/model-base/utils/type-utils";
6
6
  import { GoogleGenAI } from "@google/genai";
7
7
  import { z } from "zod";
8
8
 
@@ -75,7 +75,7 @@ var GeminiVideoModel = class extends VideoModel {
75
75
  await waitFileSizeStable(localPath);
76
76
  return (await nodejs.fs.readFile(localPath)).toString("base64");
77
77
  }
78
- async process(input, options) {
78
+ async process(input, _options) {
79
79
  const model = input.model ?? input.modelOptions?.model ?? this.credential.model;
80
80
  const mergedInput = {
81
81
  ...this.modelOptions,
@@ -124,7 +124,7 @@ var GeminiVideoModel = class extends VideoModel {
124
124
  if (!operation.response?.generatedVideos?.[0]?.video) throw new Error("Video generation failed: No video generated");
125
125
  const videoFile = operation.response.generatedVideos[0].video;
126
126
  if (!videoFile) throw new Error("Video generation failed: No video file returned");
127
- const dir = nodejs.path.join(nodejs.os.tmpdir(), options?.context?.id || "");
127
+ const dir = nodejs.path.join(nodejs.os.tmpdir(), `gemini-video-${Date.now()}`);
128
128
  await nodejs.fs.mkdir(dir, { recursive: true });
129
129
  const videoId = Date.now().toString();
130
130
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"gemini-video-model.mjs","names":[],"sources":["../src/gemini-video-model.ts"],"sourcesContent":["import type {\n AgentInvokeOptions,\n FileUnionContent,\n VideoModelInput,\n VideoModelOptions,\n VideoModelOutput,\n} from \"@aigne/core\";\nimport { fileUnionContentSchema, VideoModel, videoModelInputSchema } from \"@aigne/core\";\nimport { logger } from \"@aigne/core/utils/logger\";\nimport { checkArguments } from \"@aigne/core/utils/type-utils\";\nimport { nodejs } from \"@aigne/utils/nodejs\";\nimport { type GenerateVideosParameters, GoogleGenAI } from \"@google/genai\";\nimport { type ZodType, z } from \"zod\";\nimport { waitFileSizeStable } from \"./utils.js\";\n\nconst DEFAULT_MODEL = \"veo-3.1-generate-preview\";\nconst DEFAULT_SECONDS = 8;\n\n/**\n * Input options for Gemini Video Model\n */\nexport interface GeminiVideoModelInput extends VideoModelInput {\n /**\n * Text describing content that should not appear in the video\n */\n negativePrompt?: string;\n\n /**\n * Aspect ratio of the video\n *\n * Veo 3.1: \"16:9\" (default, 720p and 1080p), \"9:16\" (720p and 1080p)\n * Veo 3: \"16:9\" (default, 720p and 1080p), \"9:16\" (720p and 1080p)\n */\n aspectRatio?: \"16:9\" | \"9:16\";\n\n /**\n * Resolution of the video\n *\n * Veo 3.1: \"720p\" (default), \"1080p\" (only supports 8 seconds duration)\n * Veo 3: \"720p\" (default), \"1080p\" (16:9 only)\n */\n size?: \"720p\" | \"1080p\";\n\n /**\n * Duration of the generated video in seconds\n *\n * Veo 3.1: \"4\", \"6\", \"8\"\n * Veo 3: \"4\", \"6\", \"8\"\n */\n seconds?: \"4\" | \"6\" | \"8\";\n\n /**\n * Control person generation\n *\n * For text-to-video and image-to-video:\n * - Veo 3.1: \"allow_all\" for image-to-video, frame interpolation and reference images; only \"allow_adult\" for text-to-video\n * - Veo 3: \"allow_all\" for image-to-video; only \"allow_adult\" for text-to-video\n * - Veo 2: \"allow_all\", \"allow_adult\", \"dont_allow\"\n */\n personGeneration?: string;\n\n /**\n * Last frame for video generation (frame interpolation)\n */\n lastFrame?: FileUnionContent;\n\n /**\n * Reference images for video generation\n * Only supported in Veo 3.1 models\n */\n referenceImages?: FileUnionContent[];\n}\n\n/**\n * Output from Gemini Video Model\n */\nexport interface GeminiVideoModelOutput extends VideoModelOutput {}\n\n/**\n * Configuration options for Gemini Video Model\n */\nexport interface GeminiVideoModelOptions\n extends VideoModelOptions<GeminiVideoModelInput, GeminiVideoModelOutput> {\n /**\n * API key for Gemini API\n *\n * If not provided, will look for GEMINI_API_KEY in environment variables\n */\n apiKey?: string;\n\n /**\n * Base URL for Gemini API\n *\n * Useful for proxies or alternate endpoints\n */\n baseURL?: string;\n\n /**\n * Gemini model to use\n *\n * Defaults to 'veo-3.1-generate-preview'\n */\n model?: string;\n\n /**\n * Additional model options to control behavior\n */\n modelOptions?: Omit<Partial<GeminiVideoModelInput>, \"model\">;\n\n /**\n * Client options for Gemini API\n */\n clientOptions?: Record<string, any>;\n\n /**\n * Polling interval in milliseconds for checking video generation status\n *\n * Defaults to 10000ms (10 seconds)\n */\n pollingInterval?: number;\n}\n\nconst geminiVideoModelInputSchema: ZodType<GeminiVideoModelInput> = videoModelInputSchema.extend({\n negativePrompt: z.string().optional(),\n aspectRatio: z.enum([\"16:9\", \"9:16\"]).optional(),\n size: z.enum([\"720p\", \"1080p\"]).optional(),\n seconds: z.enum([\"4\", \"6\", \"8\"]).optional(),\n personGeneration: z.string().optional(),\n lastFrame: fileUnionContentSchema.optional(),\n referenceImages: fileUnionContentSchema.array().optional(),\n});\n\nconst geminiVideoModelOptionsSchema = z.object({\n apiKey: z.string().optional(),\n baseURL: z.string().optional(),\n model: z.string().optional(),\n modelOptions: z.object({}).optional(),\n clientOptions: z.object({}).optional(),\n pollingInterval: z.number().optional(),\n});\n\nexport class GeminiVideoModel extends VideoModel<GeminiVideoModelInput, GeminiVideoModelOutput> {\n constructor(public override options?: GeminiVideoModelOptions) {\n super({\n ...options,\n description: options?.description ?? \"Generate videos using Google Gemini Veo models\",\n inputSchema: geminiVideoModelInputSchema,\n });\n\n if (options) checkArguments(this.name, geminiVideoModelOptionsSchema, options);\n }\n\n /**\n * @hidden\n */\n protected _client?: GoogleGenAI;\n\n protected apiKeyEnvName = \"GEMINI_API_KEY\";\n\n get client() {\n const { apiKey } = this.credential;\n if (!apiKey)\n throw new Error(\n `${this.name} requires an API key. Please provide it via \\`options.apiKey\\`, or set the \\`${this.apiKeyEnvName}\\` environment variable`,\n );\n\n this._client ??= new GoogleGenAI({ apiKey, ...this.options?.clientOptions });\n return this._client;\n }\n\n override get credential() {\n return {\n url: this.options?.baseURL || process.env.GEMINI_BASE_URL,\n apiKey: this.options?.apiKey || process.env[this.apiKeyEnvName],\n model: this.options?.model || DEFAULT_MODEL,\n };\n }\n\n get modelOptions() {\n return this.options?.modelOptions;\n }\n\n async downloadToFile(\n dir: string,\n videoId: string,\n videoFile: { uri?: string; videoBytes?: any },\n ): Promise<string> {\n logger.debug(\"Downloading video content...\");\n const localPath = nodejs.path.join(dir, `${videoId}.mp4`);\n await this.client.files.download({ file: videoFile, downloadPath: localPath });\n logger.debug(`Generated video saved to ${localPath}`);\n\n await waitFileSizeStable(localPath);\n\n const buffer = await nodejs.fs.readFile(localPath);\n return buffer.toString(\"base64\");\n }\n\n override async process(\n input: GeminiVideoModelInput,\n options: AgentInvokeOptions,\n ): Promise<GeminiVideoModelOutput> {\n const model = input.model ?? input.modelOptions?.model ?? this.credential.model;\n const mergedInput = { ...this.modelOptions, ...input };\n\n if (mergedInput.referenceImages && !model.includes(\"veo-3.1\")) {\n throw new Error(\"referenceImages is only supported in Veo 3.1 models\");\n }\n\n const config: GenerateVideosParameters[\"config\"] = {};\n if (mergedInput.negativePrompt) config.negativePrompt = mergedInput.negativePrompt;\n if (mergedInput.aspectRatio) config.aspectRatio = mergedInput.aspectRatio;\n if (mergedInput.size) config.resolution = mergedInput.size;\n if (mergedInput.seconds) config.durationSeconds = parseInt(mergedInput.seconds, 10);\n if (mergedInput.personGeneration) config.personGeneration = mergedInput.personGeneration;\n if (mergedInput.lastFrame) {\n config.lastFrame = await this.transformFileType(\"file\", mergedInput.lastFrame).then(\n (file) => {\n return {\n imageBytes: file.data,\n mimeType: file.mimeType,\n };\n },\n );\n }\n\n if (mergedInput.referenceImages) {\n config.referenceImages = await Promise.all(\n mergedInput.referenceImages.map(async (image) => {\n return await this.transformFileType(\"file\", image).then((file) => {\n return {\n image: {\n imageBytes: file.data,\n mimeType: file.mimeType,\n },\n };\n });\n }),\n );\n }\n\n const params: GenerateVideosParameters = {\n model,\n prompt: mergedInput.prompt,\n config,\n };\n\n if (mergedInput.image) {\n params.image = await this.transformFileType(\"file\", mergedInput.image).then((file) => {\n return {\n imageBytes: file.data,\n mimeType: file.mimeType,\n };\n });\n }\n\n // Start video generation\n let operation = await this.client.models.generateVideos(params);\n logger.debug(\"Video generation started...\");\n\n // Poll operation status until complete\n const pollingInterval = this.options?.pollingInterval ?? 10000;\n while (!operation.done) {\n logger.debug(\"Waiting for video generation to complete...\");\n await new Promise((resolve) => setTimeout(resolve, pollingInterval));\n operation = await this.client.operations.getVideosOperation({ operation });\n }\n\n if (!operation.response?.generatedVideos?.[0]?.video) {\n throw new Error(\"Video generation failed: No video generated\");\n }\n\n // Download the generated video\n const generatedVideo = operation.response.generatedVideos[0];\n const videoFile = generatedVideo.video;\n\n if (!videoFile) {\n throw new Error(\"Video generation failed: No video file returned\");\n }\n\n // Save to temporary directory\n const dir = nodejs.path.join(nodejs.os.tmpdir(), options?.context?.id || \"\");\n await nodejs.fs.mkdir(dir, { recursive: true });\n\n const videoId = Date.now().toString();\n\n return {\n videos: [\n {\n type: \"file\",\n data: await this.downloadToFile(dir, videoId, videoFile),\n mimeType: \"video/mp4\",\n filename: `${videoId}.mp4`,\n },\n ],\n usage: {\n inputTokens: 0,\n outputTokens: 0,\n },\n model,\n seconds: mergedInput.seconds ? parseInt(mergedInput.seconds, 10) : DEFAULT_SECONDS,\n };\n }\n}\n"],"mappings":";;;;;;;;;AAeA,MAAM,gBAAgB;AACtB,MAAM,kBAAkB;AA0GxB,MAAM,8BAA8D,sBAAsB,OAAO;CAC/F,gBAAgB,EAAE,QAAQ,CAAC,UAAU;CACrC,aAAa,EAAE,KAAK,CAAC,QAAQ,OAAO,CAAC,CAAC,UAAU;CAChD,MAAM,EAAE,KAAK,CAAC,QAAQ,QAAQ,CAAC,CAAC,UAAU;CAC1C,SAAS,EAAE,KAAK;EAAC;EAAK;EAAK;EAAI,CAAC,CAAC,UAAU;CAC3C,kBAAkB,EAAE,QAAQ,CAAC,UAAU;CACvC,WAAW,uBAAuB,UAAU;CAC5C,iBAAiB,uBAAuB,OAAO,CAAC,UAAU;CAC3D,CAAC;AAEF,MAAM,gCAAgC,EAAE,OAAO;CAC7C,QAAQ,EAAE,QAAQ,CAAC,UAAU;CAC7B,SAAS,EAAE,QAAQ,CAAC,UAAU;CAC9B,OAAO,EAAE,QAAQ,CAAC,UAAU;CAC5B,cAAc,EAAE,OAAO,EAAE,CAAC,CAAC,UAAU;CACrC,eAA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AC;;AAG5E,MAAI,CAAC,UAAU,UAAU,kBAAkB,IAAI,MAC7C,OAAM,IAAI,MAAM,8CAA8C;EAKhE,MAAM,YADiB,UAAU,SAAS,gBAAgB,GACzB;AAEjC,MAAI,CAAC,UACH,OAAM,IAAI,MAAM,kDAAkD;EAIpE,MAAM,MAAM,OAAO,KAAK,KAAK,OAAO,GAAG,QAAQ,EAAE,SAAS,SAAS,MAAM,GAAG;AAC5E,QAAM,OAAO,GAAG,MAAM,KAAK,EAAE,WAAW,MAAM,CAAC;EAE/C,MAAM,UAAU,KAAK,KAAK,CAAC,UAAU;AAErC,SAAO;GACL,QAAQ,CACN;IACE,MAAM;IACN,MAAM,MAAM,KAAK,eAAe,KAAK,SAAS,UAAU;IACxD,UAAU;IACV,UAAU,GAAG,QAAQ;IACtB,CACF;GACD,OAAO;IACL,aAAa;IACb,cAAc;IACf;GACD;GACA,SAAS,YAAY,UAAU,SAAS,YAAY,SAAS,GAAG,GAAG;GACpE"}
1
+ {"version":3,"file":"gemini-video-model.mjs","names":[],"sources":["../src/gemini-video-model.ts"],"sourcesContent":["import type {\n FileUnionContent,\n ModelInvokeOptions,\n VideoModelInput,\n VideoModelOptions,\n VideoModelOutput,\n} from \"@aigne/model-base\";\nimport { fileUnionContentSchema, VideoModel, videoModelInputSchema } from \"@aigne/model-base\";\nimport { logger } from \"@aigne/model-base/utils/logger\";\nimport { nodejs } from \"@aigne/model-base/utils/nodejs\";\nimport { checkArguments } from \"@aigne/model-base/utils/type-utils\";\nimport { type GenerateVideosParameters, GoogleGenAI } from \"@google/genai\";\nimport { type ZodType, z } from \"zod\";\nimport { waitFileSizeStable } from \"./utils.js\";\n\nconst DEFAULT_MODEL = \"veo-3.1-generate-preview\";\nconst DEFAULT_SECONDS = 8;\n\n/**\n * Input options for Gemini Video Model\n */\nexport interface GeminiVideoModelInput extends VideoModelInput {\n /**\n * Text describing content that should not appear in the video\n */\n negativePrompt?: string;\n\n /**\n * Aspect ratio of the video\n *\n * Veo 3.1: \"16:9\" (default, 720p and 1080p), \"9:16\" (720p and 1080p)\n * Veo 3: \"16:9\" (default, 720p and 1080p), \"9:16\" (720p and 1080p)\n */\n aspectRatio?: \"16:9\" | \"9:16\";\n\n /**\n * Resolution of the video\n *\n * Veo 3.1: \"720p\" (default), \"1080p\" (only supports 8 seconds duration)\n * Veo 3: \"720p\" (default), \"1080p\" (16:9 only)\n */\n size?: \"720p\" | \"1080p\";\n\n /**\n * Duration of the generated video in seconds\n *\n * Veo 3.1: \"4\", \"6\", \"8\"\n * Veo 3: \"4\", \"6\", \"8\"\n */\n seconds?: \"4\" | \"6\" | \"8\";\n\n /**\n * Control person generation\n *\n * For text-to-video and image-to-video:\n * - Veo 3.1: \"allow_all\" for image-to-video, frame interpolation and reference images; only \"allow_adult\" for text-to-video\n * - Veo 3: \"allow_all\" for image-to-video; only \"allow_adult\" for text-to-video\n * - Veo 2: \"allow_all\", \"allow_adult\", \"dont_allow\"\n */\n personGeneration?: string;\n\n /**\n * Last frame for video generation (frame interpolation)\n */\n lastFrame?: FileUnionContent;\n\n /**\n * Reference images for video generation\n * Only supported in Veo 3.1 models\n */\n referenceImages?: FileUnionContent[];\n}\n\n/**\n * Output from Gemini Video Model\n */\nexport interface GeminiVideoModelOutput extends VideoModelOutput {}\n\n/**\n * Configuration options for Gemini Video Model\n */\nexport interface GeminiVideoModelOptions\n extends VideoModelOptions<GeminiVideoModelInput, GeminiVideoModelOutput> {\n /**\n * API key for Gemini API\n *\n * If not provided, will look for GEMINI_API_KEY in environment variables\n */\n apiKey?: string;\n\n /**\n * Base URL for Gemini API\n *\n * Useful for proxies or alternate endpoints\n */\n baseURL?: string;\n\n /**\n * Gemini model to use\n *\n * Defaults to 'veo-3.1-generate-preview'\n */\n model?: string;\n\n /**\n * Additional model options to control behavior\n */\n modelOptions?: Omit<Partial<GeminiVideoModelInput>, \"model\">;\n\n /**\n * Client options for Gemini API\n */\n clientOptions?: Record<string, any>;\n\n /**\n * Polling interval in milliseconds for checking video generation status\n *\n * Defaults to 10000ms (10 seconds)\n */\n pollingInterval?: number;\n}\n\nconst geminiVideoModelInputSchema: ZodType<GeminiVideoModelInput> = videoModelInputSchema.extend({\n negativePrompt: z.string().optional(),\n aspectRatio: z.enum([\"16:9\", \"9:16\"]).optional(),\n size: z.enum([\"720p\", \"1080p\"]).optional(),\n seconds: z.enum([\"4\", \"6\", \"8\"]).optional(),\n personGeneration: z.string().optional(),\n lastFrame: fileUnionContentSchema.optional(),\n referenceImages: fileUnionContentSchema.array().optional(),\n});\n\nconst geminiVideoModelOptionsSchema = z.object({\n apiKey: z.string().optional(),\n baseURL: z.string().optional(),\n model: z.string().optional(),\n modelOptions: z.object({}).optional(),\n clientOptions: z.object({}).optional(),\n pollingInterval: z.number().optional(),\n});\n\nexport class GeminiVideoModel extends VideoModel<GeminiVideoModelInput, GeminiVideoModelOutput> {\n constructor(public override options?: GeminiVideoModelOptions) {\n super({\n ...options,\n description: options?.description ?? \"Generate videos using Google Gemini Veo models\",\n inputSchema: geminiVideoModelInputSchema,\n });\n\n if (options) checkArguments(this.name, geminiVideoModelOptionsSchema, options);\n }\n\n /**\n * @hidden\n */\n protected _client?: GoogleGenAI;\n\n protected apiKeyEnvName = \"GEMINI_API_KEY\";\n\n get client() {\n const { apiKey } = this.credential;\n if (!apiKey)\n throw new Error(\n `${this.name} requires an API key. Please provide it via \\`options.apiKey\\`, or set the \\`${this.apiKeyEnvName}\\` environment variable`,\n );\n\n this._client ??= new GoogleGenAI({ apiKey, ...this.options?.clientOptions });\n return this._client;\n }\n\n override get credential() {\n return {\n url: this.options?.baseURL || process.env.GEMINI_BASE_URL,\n apiKey: this.options?.apiKey || process.env[this.apiKeyEnvName],\n model: this.options?.model || DEFAULT_MODEL,\n };\n }\n\n get modelOptions() {\n return this.options?.modelOptions;\n }\n\n async downloadToFile(\n dir: string,\n videoId: string,\n videoFile: { uri?: string; videoBytes?: any },\n ): Promise<string> {\n logger.debug(\"Downloading video content...\");\n const localPath = nodejs.path.join(dir, `${videoId}.mp4`);\n await this.client.files.download({ file: videoFile, downloadPath: localPath });\n logger.debug(`Generated video saved to ${localPath}`);\n\n await waitFileSizeStable(localPath);\n\n const buffer = await nodejs.fs.readFile(localPath);\n return buffer.toString(\"base64\");\n }\n\n override async process(\n input: GeminiVideoModelInput,\n _options: ModelInvokeOptions,\n ): Promise<GeminiVideoModelOutput> {\n const model = input.model ?? input.modelOptions?.model ?? this.credential.model;\n const mergedInput = { ...this.modelOptions, ...input };\n\n if (mergedInput.referenceImages && !model.includes(\"veo-3.1\")) {\n throw new Error(\"referenceImages is only supported in Veo 3.1 models\");\n }\n\n const config: GenerateVideosParameters[\"config\"] = {};\n if (mergedInput.negativePrompt) config.negativePrompt = mergedInput.negativePrompt;\n if (mergedInput.aspectRatio) config.aspectRatio = mergedInput.aspectRatio;\n if (mergedInput.size) config.resolution = mergedInput.size;\n if (mergedInput.seconds) config.durationSeconds = parseInt(mergedInput.seconds, 10);\n if (mergedInput.personGeneration) config.personGeneration = mergedInput.personGeneration;\n if (mergedInput.lastFrame) {\n config.lastFrame = await this.transformFileType(\"file\", mergedInput.lastFrame).then(\n (file) => {\n return {\n imageBytes: file.data,\n mimeType: file.mimeType,\n };\n },\n );\n }\n\n if (mergedInput.referenceImages) {\n config.referenceImages = await Promise.all(\n mergedInput.referenceImages.map(async (image) => {\n return await this.transformFileType(\"file\", image).then((file) => {\n return {\n image: {\n imageBytes: file.data,\n mimeType: file.mimeType,\n },\n };\n });\n }),\n );\n }\n\n const params: GenerateVideosParameters = {\n model,\n prompt: mergedInput.prompt,\n config,\n };\n\n if (mergedInput.image) {\n params.image = await this.transformFileType(\"file\", mergedInput.image).then((file) => {\n return {\n imageBytes: file.data,\n mimeType: file.mimeType,\n };\n });\n }\n\n // Start video generation\n let operation = await this.client.models.generateVideos(params);\n logger.debug(\"Video generation started...\");\n\n // Poll operation status until complete\n const pollingInterval = this.options?.pollingInterval ?? 10000;\n while (!operation.done) {\n logger.debug(\"Waiting for video generation to complete...\");\n await new Promise((resolve) => setTimeout(resolve, pollingInterval));\n operation = await this.client.operations.getVideosOperation({ operation });\n }\n\n if (!operation.response?.generatedVideos?.[0]?.video) {\n throw new Error(\"Video generation failed: No video generated\");\n }\n\n // Download the generated video\n const generatedVideo = operation.response.generatedVideos[0];\n const videoFile = generatedVideo.video;\n\n if (!videoFile) {\n throw new Error(\"Video generation failed: No video file returned\");\n }\n\n // Save to temporary directory\n const dir = nodejs.path.join(nodejs.os.tmpdir(), `gemini-video-${Date.now()}`);\n await nodejs.fs.mkdir(dir, { recursive: true });\n\n const videoId = Date.now().toString();\n\n return {\n videos: [\n {\n type: \"file\",\n data: await this.downloadToFile(dir, videoId, videoFile),\n mimeType: \"video/mp4\",\n filename: `${videoId}.mp4`,\n },\n ],\n usage: {\n inputTokens: 0,\n outputTokens: 0,\n },\n model,\n seconds: mergedInput.seconds ? parseInt(mergedInput.seconds, 10) : DEFAULT_SECONDS,\n };\n }\n}\n"],"mappings":";;;;;;;;;AAeA,MAAM,gBAAgB;AACtB,MAAM,kBAAkB;AA0GxB,MAAM,8BAA8D,sBAAsB,OAAO;CAC/F,gBAAgB,EAAE,QAAQ,CAAC,UAAU;CACrC,aAAa,EAAE,KAAK,CAAC,QAAQ,OAAO,CAAC,CAAC,UAAU;CAChD,MAAM,EAAE,KAAK,CAAC,QAAQ,QAAQ,CAAC,CAAC,UAAU;CAC1C,SAAS,EAAE,KAAK;EAAC;EAAK;EAAK;EAAI,CAAC,CAAC,UAAU;CAC3C,kBAAkB,EAAE,QAAQ,CAAC,UAAU;CACvC,WAAW,uBAAuB,UAAU;CAC5C,iBAAiB,uBAAuB,OAAO,CAAC,UAAU;CAC3D,CAAC;AAEF,MAAM,gCAAgC,EAAE,OAAO;CAC7C,QAAQ,EAAE,QAAQ,CAAC,UAAU;CAC7B,SAAS,EAAE,QAAQ,CAAC,UAAU;CAC9B,OAAO,EAAE,QAAQ,CAAC,UAAU;CAC5B,cAAc,EAAE,OAAO,EAAE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WAAW,mBAAmB,EAAE,WAAW,CAAC;;AAG5E,MAAI,CAAC,UAAU,UAAU,kBAAkB,IAAI,MAC7C,OAAM,IAAI,MAAM,8CAA8C;EAKhE,MAAM,YADiB,UAAU,SAAS,gBAAgB,GACzB;AAEjC,MAAI,CAAC,UACH,OAAM,IAAI,MAAM,kDAAkD;EAIpE,MAAM,MAAM,OAAO,KAAK,KAAK,OAAO,GAAG,QAAQ,EAAE,gBAAgB,KAAK,KAAK,GAAG;AAC9E,QAAM,OAAO,GAAG,MAAM,KAAK,EAAE,WAAW,MAAM,CAAC;EAE/C,MAAM,UAAU,KAAK,KAAK,CAAC,UAAU;AAErC,SAAO;GACL,QAAQ,CACN;IACE,MAAM;IACN,MAAM,MAAM,KAAK,eAAe,KAAK,SAAS,UAAU;IACxD,UAAU;IACV,UAAU,GAAG,QAAQ;IACtB,CACF;GACD,OAAO;IACL,aAAa;IACb,cAAc;IACf;GACD;GACA,SAAS,YAAY,UAAU,SAAS,YAAY,SAAS,GAAG,GAAG;GACpE"}
package/dist/utils.cjs CHANGED
@@ -1,4 +1,4 @@
1
- let _aigne_utils_nodejs = require("@aigne/utils/nodejs");
1
+ let _aigne_model_base_utils_nodejs = require("@aigne/model-base/utils/nodejs");
2
2
 
3
3
  //#region src/utils.ts
4
4
  /**
@@ -21,7 +21,7 @@ async function waitFileSizeStable(filePath, options) {
21
21
  while (stableCount < requiredStableCount) {
22
22
  if (Date.now() - startTime > timeout) throw new Error(`Timeout waiting for file to stabilize: ${filePath}`);
23
23
  await new Promise((resolve) => setTimeout(resolve, checkInterval));
24
- const currentSize = (await _aigne_utils_nodejs.nodejs.fs.stat(filePath)).size;
24
+ const currentSize = (await _aigne_model_base_utils_nodejs.nodejs.fs.stat(filePath)).size;
25
25
  if (currentSize === previousSize && currentSize > 0) stableCount++;
26
26
  else {
27
27
  stableCount = 0;
package/dist/utils.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { nodejs } from "@aigne/utils/nodejs";
1
+ import { nodejs } from "@aigne/model-base/utils/nodejs";
2
2
 
3
3
  //#region src/utils.ts
4
4
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"utils.mjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import { nodejs } from \"@aigne/utils/nodejs\";\n\n/**\n * Wait for file size to stabilize, ensuring the file download is complete.\n *\n * @param filePath - The path to the file to check\n * @param options - Configuration options\n * @param options.checkInterval - Check interval in milliseconds (default: 500ms)\n * @param options.stableCount - Number of consecutive checks with same size to consider stable (default: 3)\n * @param options.timeout - Timeout in milliseconds (default: 60000ms)\n * @throws Error when timeout is reached\n */\nexport async function waitFileSizeStable(\n filePath: string,\n options?: {\n checkInterval?: number;\n stableCount?: number;\n timeout?: number;\n },\n): Promise<void> {\n const checkInterval = options?.checkInterval ?? 500;\n const requiredStableCount = options?.stableCount ?? 3;\n const timeout = options?.timeout ?? 60000;\n\n const startTime = Date.now();\n let previousSize = 0;\n let stableCount = 0;\n\n while (stableCount < requiredStableCount) {\n if (Date.now() - startTime > timeout) {\n throw new Error(`Timeout waiting for file to stabilize: ${filePath}`);\n }\n\n await new Promise((resolve) => setTimeout(resolve, checkInterval));\n\n const stats = await nodejs.fs.stat(filePath);\n const currentSize = stats.size;\n\n if (currentSize === previousSize && currentSize > 0) {\n stableCount++;\n } else {\n stableCount = 0;\n previousSize = currentSize;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,eAAsB,mBACpB,UACA,SAKe;CACf,MAAM,gBAAgB,SAAS,iBAAiB;CAChD,MAAM,sBAAsB,SAAS,eAAe;CACpD,MAAM,UAAU,SAAS,WAAW;CAEpC,MAAM,YAAY,KAAK,KAAK;CAC5B,IAAI,eAAe;CACnB,IAAI,cAAc;AAElB,QAAO,cAAc,qBAAqB;AACxC,MAAI,KAAK,KAAK,GAAG,YAAY,QAC3B,OAAM,IAAI,MAAM,0CAA0C,WAAW;AAGvE,QAAM,IAAI,SAAS,YAAY,WAAW,SAAS,cAAc,CAAC;EAGlE,MAAM,eADQ,MAAM,OAAO,GAAG,KAAK,SAAS,EAClB;AAE1B,MAAI,gBAAgB,gBAAgB,cAAc,EAChD;OACK;AACL,iBAAc;AACd,kBAAe"}
1
+ {"version":3,"file":"utils.mjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import { nodejs } from \"@aigne/model-base/utils/nodejs\";\n\n/**\n * Wait for file size to stabilize, ensuring the file download is complete.\n *\n * @param filePath - The path to the file to check\n * @param options - Configuration options\n * @param options.checkInterval - Check interval in milliseconds (default: 500ms)\n * @param options.stableCount - Number of consecutive checks with same size to consider stable (default: 3)\n * @param options.timeout - Timeout in milliseconds (default: 60000ms)\n * @throws Error when timeout is reached\n */\nexport async function waitFileSizeStable(\n filePath: string,\n options?: {\n checkInterval?: number;\n stableCount?: number;\n timeout?: number;\n },\n): Promise<void> {\n const checkInterval = options?.checkInterval ?? 500;\n const requiredStableCount = options?.stableCount ?? 3;\n const timeout = options?.timeout ?? 60000;\n\n const startTime = Date.now();\n let previousSize = 0;\n let stableCount = 0;\n\n while (stableCount < requiredStableCount) {\n if (Date.now() - startTime > timeout) {\n throw new Error(`Timeout waiting for file to stabilize: ${filePath}`);\n }\n\n await new Promise((resolve) => setTimeout(resolve, checkInterval));\n\n const stats = await nodejs.fs.stat(filePath);\n const currentSize = stats.size;\n\n if (currentSize === previousSize && currentSize > 0) {\n stableCount++;\n } else {\n stableCount = 0;\n previousSize = currentSize;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,eAAsB,mBACpB,UACA,SAKe;CACf,MAAM,gBAAgB,SAAS,iBAAiB;CAChD,MAAM,sBAAsB,SAAS,eAAe;CACpD,MAAM,UAAU,SAAS,WAAW;CAEpC,MAAM,YAAY,KAAK,KAAK;CAC5B,IAAI,eAAe;CACnB,IAAI,cAAc;AAElB,QAAO,cAAc,qBAAqB;AACxC,MAAI,KAAK,KAAK,GAAG,YAAY,QAC3B,OAAM,IAAI,MAAM,0CAA0C,WAAW;AAGvE,QAAM,IAAI,SAAS,YAAY,WAAW,SAAS,cAAc,CAAC;EAGlE,MAAM,eADQ,MAAM,OAAO,GAAG,KAAK,SAAS,EAClB;AAE1B,MAAI,gBAAgB,gBAAgB,cAAc,EAChD;OACK;AACL,iBAAc;AACd,kBAAe"}