@fre4x/gemini 1.0.24 → 1.0.26
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/index.js +84 -31
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -55372,8 +55372,8 @@ var GENERATE_TEXT_TOOL = {
|
|
|
55372
55372
|
prompt: { type: "string", description: "The text prompt to generate content from" },
|
|
55373
55373
|
model: {
|
|
55374
55374
|
type: "string",
|
|
55375
|
-
description: "Gemini model
|
|
55376
|
-
default: "gemini-2.
|
|
55375
|
+
description: "Gemini model \u2014 omit to use the default (gemini-2.5-flash, current stable). Use list_models to see options.",
|
|
55376
|
+
default: "gemini-2.5-flash"
|
|
55377
55377
|
}
|
|
55378
55378
|
},
|
|
55379
55379
|
required: ["prompt"]
|
|
@@ -55393,8 +55393,8 @@ var ANALYZE_MEDIA_TOOL = {
|
|
|
55393
55393
|
},
|
|
55394
55394
|
model: {
|
|
55395
55395
|
type: "string",
|
|
55396
|
-
description: "Gemini model
|
|
55397
|
-
default: "gemini-2.
|
|
55396
|
+
description: "Gemini model \u2014 omit to use the default (gemini-2.5-flash, current stable)",
|
|
55397
|
+
default: "gemini-2.5-flash"
|
|
55398
55398
|
}
|
|
55399
55399
|
},
|
|
55400
55400
|
required: ["prompt", "media_url"]
|
|
@@ -55417,7 +55417,7 @@ var LIST_MODELS_TOOL = {
|
|
|
55417
55417
|
};
|
|
55418
55418
|
var GENERATE_IMAGE_TOOL = {
|
|
55419
55419
|
name: "generate_image",
|
|
55420
|
-
description: "Generate an image using Imagen and
|
|
55420
|
+
description: "Generate an image using Imagen, return as base64 and optionally save to disk",
|
|
55421
55421
|
inputSchema: {
|
|
55422
55422
|
type: "object",
|
|
55423
55423
|
properties: {
|
|
@@ -55431,6 +55431,10 @@ var GENERATE_IMAGE_TOOL = {
|
|
|
55431
55431
|
type: "string",
|
|
55432
55432
|
description: "Imagen model (default: imagen-3.0-generate-002)",
|
|
55433
55433
|
default: "imagen-3.0-generate-002"
|
|
55434
|
+
},
|
|
55435
|
+
output_dir: {
|
|
55436
|
+
type: "string",
|
|
55437
|
+
description: "Directory to save image file (e.g. /tmp or ./output). Omit to skip saving."
|
|
55434
55438
|
}
|
|
55435
55439
|
},
|
|
55436
55440
|
required: ["prompt"]
|
|
@@ -55454,13 +55458,17 @@ var GENERATE_VIDEO_TOOL = {
|
|
|
55454
55458
|
};
|
|
55455
55459
|
var GET_VIDEO_STATUS_TOOL = {
|
|
55456
55460
|
name: "get_video_status",
|
|
55457
|
-
description: "Poll
|
|
55461
|
+
description: "Poll status of async video generation. Returns done=true and video URLs when complete. Optionally downloads and saves to disk.",
|
|
55458
55462
|
inputSchema: {
|
|
55459
55463
|
type: "object",
|
|
55460
55464
|
properties: {
|
|
55461
55465
|
operation_name: {
|
|
55462
55466
|
type: "string",
|
|
55463
55467
|
description: "Operation name returned by generate_video"
|
|
55468
|
+
},
|
|
55469
|
+
output_dir: {
|
|
55470
|
+
type: "string",
|
|
55471
|
+
description: "Directory to save video file when done (e.g. /tmp or ./output). Omit to skip saving."
|
|
55464
55472
|
}
|
|
55465
55473
|
},
|
|
55466
55474
|
required: ["operation_name"]
|
|
@@ -55484,7 +55492,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
55484
55492
|
const { name, arguments: args } = request.params;
|
|
55485
55493
|
try {
|
|
55486
55494
|
if (name === "generate_text") {
|
|
55487
|
-
const { prompt, model = "gemini-2.
|
|
55495
|
+
const { prompt, model = "gemini-2.5-flash" } = z2.object({ prompt: z2.string(), model: z2.string().optional() }).parse(args);
|
|
55488
55496
|
if (IS_MOCK) {
|
|
55489
55497
|
return { content: [{ type: "text", text: `[Mock] Generated text for: "${prompt}" (model: ${model})
|
|
55490
55498
|
|
|
@@ -55494,7 +55502,7 @@ Mock response \u2014 no API call made.` }] };
|
|
|
55494
55502
|
return { content: [{ type: "text", text: response.text || "No response generated." }] };
|
|
55495
55503
|
}
|
|
55496
55504
|
if (name === "analyze_media") {
|
|
55497
|
-
const { prompt, media_url, mime_type: providedMimeType, model = "gemini-2.
|
|
55505
|
+
const { prompt, media_url, mime_type: providedMimeType, model = "gemini-2.5-flash" } = z2.object({
|
|
55498
55506
|
prompt: z2.string(),
|
|
55499
55507
|
media_url: z2.string(),
|
|
55500
55508
|
mime_type: z2.string().optional(),
|
|
@@ -55534,11 +55542,10 @@ Mock response \u2014 no API call made.` }] };
|
|
|
55534
55542
|
content: [{ type: "text", text: [
|
|
55535
55543
|
"## Available Gemini Models\n",
|
|
55536
55544
|
"### \u{1F4DD} Text Generation",
|
|
55537
|
-
"- gemini-2.5-
|
|
55538
|
-
"- gemini-2.
|
|
55539
|
-
"- gemini-2.
|
|
55540
|
-
"
|
|
55541
|
-
"- gemini-1.5-flash (stable, fast)",
|
|
55545
|
+
"- gemini-2.5-flash \u2B50 (stable GA, recommended default)",
|
|
55546
|
+
"- gemini-2.5-pro (most capable)",
|
|
55547
|
+
"- gemini-2.5-flash-lite (lightweight, preview)",
|
|
55548
|
+
"\u26A0\uFE0F gemini-1.5-* and gemini-2.0-* are deprecated (sunset Sep 2025 / Jun 2026)",
|
|
55542
55549
|
"\n### \u{1F5BC}\uFE0F Image Generation (use with generate_image)",
|
|
55543
55550
|
"- imagen-3.0-generate-002",
|
|
55544
55551
|
"\n### \u{1F3AC} Video Generation (use with generate_video + get_video_status)",
|
|
@@ -55576,15 +55583,25 @@ Mock response \u2014 no API call made.` }] };
|
|
|
55576
55583
|
return { content: [{ type: "text", text: lines.join("\n").trim() || "No models found." }] };
|
|
55577
55584
|
}
|
|
55578
55585
|
if (name === "generate_image") {
|
|
55579
|
-
const { prompt, aspect_ratio = "1:1", model = "imagen-3.0-generate-002" } = z2.object({
|
|
55586
|
+
const { prompt, aspect_ratio = "1:1", model = "imagen-3.0-generate-002", output_dir } = z2.object({
|
|
55580
55587
|
prompt: z2.string(),
|
|
55581
55588
|
aspect_ratio: z2.string().optional(),
|
|
55582
|
-
model: z2.string().optional()
|
|
55589
|
+
model: z2.string().optional(),
|
|
55590
|
+
output_dir: z2.string().optional()
|
|
55583
55591
|
}).parse(args);
|
|
55584
55592
|
if (IS_MOCK) {
|
|
55585
|
-
|
|
55586
|
-
|
|
55587
|
-
|
|
55593
|
+
const mockBase64 = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==";
|
|
55594
|
+
const content2 = [
|
|
55595
|
+
{ type: "image", data: mockBase64, mimeType: "image/png" }
|
|
55596
|
+
];
|
|
55597
|
+
if (output_dir) {
|
|
55598
|
+
const fname = `image-${Date.now()}.png`;
|
|
55599
|
+
const fpath = `${output_dir.replace(/\/$/, "")}/${fname}`;
|
|
55600
|
+
await fs.mkdir(output_dir, { recursive: true });
|
|
55601
|
+
await fs.writeFile(fpath, Buffer.from(mockBase64, "base64"));
|
|
55602
|
+
content2.push({ type: "text", text: `[Mock] Saved to: ${fpath}` });
|
|
55603
|
+
}
|
|
55604
|
+
return { content: content2 };
|
|
55588
55605
|
}
|
|
55589
55606
|
const response = await ai.models.generateImages({
|
|
55590
55607
|
model,
|
|
@@ -55607,7 +55624,22 @@ Check Imagen access at https://ai.google.dev/` }],
|
|
|
55607
55624
|
isError: true
|
|
55608
55625
|
};
|
|
55609
55626
|
}
|
|
55610
|
-
|
|
55627
|
+
const savedPaths = [];
|
|
55628
|
+
if (output_dir) {
|
|
55629
|
+
await fs.mkdir(output_dir, { recursive: true });
|
|
55630
|
+
for (const img of images) {
|
|
55631
|
+
const fname = `image-${Date.now()}-${savedPaths.length + 1}.png`;
|
|
55632
|
+
const fpath = `${output_dir.replace(/\/$/, "")}/${fname}`;
|
|
55633
|
+
await fs.writeFile(fpath, Buffer.from(img.data, "base64"));
|
|
55634
|
+
savedPaths.push(fpath);
|
|
55635
|
+
}
|
|
55636
|
+
}
|
|
55637
|
+
const content = [...images];
|
|
55638
|
+
if (savedPaths.length > 0) {
|
|
55639
|
+
content.push({ type: "text", text: `Saved to:
|
|
55640
|
+
${savedPaths.join("\n")}` });
|
|
55641
|
+
}
|
|
55642
|
+
return { content };
|
|
55611
55643
|
}
|
|
55612
55644
|
if (name === "generate_video") {
|
|
55613
55645
|
const { prompt, model = "veo-2.0-generate-001" } = z2.object({ prompt: z2.string(), model: z2.string().optional() }).parse(args);
|
|
@@ -55631,11 +55663,17 @@ Poll every ~30 seconds until done=true.` }]
|
|
|
55631
55663
|
};
|
|
55632
55664
|
}
|
|
55633
55665
|
if (name === "get_video_status") {
|
|
55634
|
-
const { operation_name } = z2.object({ operation_name: z2.string() }).parse(args);
|
|
55666
|
+
const { operation_name, output_dir } = z2.object({ operation_name: z2.string(), output_dir: z2.string().optional() }).parse(args);
|
|
55635
55667
|
if (IS_MOCK) {
|
|
55636
|
-
|
|
55637
|
-
|
|
55638
|
-
|
|
55668
|
+
const lines2 = [`[Mock] Operation: ${operation_name}`, "done: true", "Video URL: https://example.com/mock-video.mp4"];
|
|
55669
|
+
if (output_dir) {
|
|
55670
|
+
const fname = `video-${Date.now()}.mp4`;
|
|
55671
|
+
const fpath = `${output_dir.replace(/\/$/, "")}/${fname}`;
|
|
55672
|
+
await fs.mkdir(output_dir, { recursive: true });
|
|
55673
|
+
await fs.writeFile(fpath, "[mock video data]");
|
|
55674
|
+
lines2.push(`Saved to: ${fpath}`);
|
|
55675
|
+
}
|
|
55676
|
+
return { content: [{ type: "text", text: lines2.join("\n") }] };
|
|
55639
55677
|
}
|
|
55640
55678
|
const resp = await fetch(
|
|
55641
55679
|
`https://generativelanguage.googleapis.com/v1beta/${operation_name}?key=${API_KEY}`
|
|
@@ -55652,16 +55690,31 @@ Video URL: https://example.com/mock-video.mp4` }] };
|
|
|
55652
55690
|
};
|
|
55653
55691
|
}
|
|
55654
55692
|
const videos = (op.response?.generatedVideos ?? []).map((v) => v.video?.uri ?? "").filter(Boolean);
|
|
55655
|
-
|
|
55656
|
-
content: [{
|
|
55657
|
-
|
|
55658
|
-
|
|
55693
|
+
if (videos.length === 0) {
|
|
55694
|
+
return { content: [{ type: "text", text: `Complete but no video URLs found:
|
|
55695
|
+
${JSON.stringify(op.response, null, 2)}` }] };
|
|
55696
|
+
}
|
|
55697
|
+
const savedPaths = [];
|
|
55698
|
+
if (output_dir) {
|
|
55699
|
+
await fs.mkdir(output_dir, { recursive: true });
|
|
55700
|
+
for (const url2 of videos) {
|
|
55701
|
+
const fname = `video-${Date.now()}-${savedPaths.length + 1}.mp4`;
|
|
55702
|
+
const fpath = `${output_dir.replace(/\/$/, "")}/${fname}`;
|
|
55703
|
+
const videoResp = await fetch(url2);
|
|
55704
|
+
if (!videoResp.ok) throw new Error(`Failed to download video: ${videoResp.status}`);
|
|
55705
|
+
const buf = await videoResp.arrayBuffer();
|
|
55706
|
+
await fs.writeFile(fpath, Buffer.from(buf));
|
|
55707
|
+
savedPaths.push(fpath);
|
|
55708
|
+
}
|
|
55709
|
+
}
|
|
55710
|
+
const lines = [`Video generation complete!
|
|
55659
55711
|
|
|
55660
55712
|
Download URLs:
|
|
55661
|
-
${videos.join("\n")}`
|
|
55662
|
-
|
|
55663
|
-
|
|
55664
|
-
|
|
55713
|
+
${videos.join("\n")}`];
|
|
55714
|
+
if (savedPaths.length > 0) lines.push(`
|
|
55715
|
+
Saved to:
|
|
55716
|
+
${savedPaths.join("\n")}`);
|
|
55717
|
+
return { content: [{ type: "text", text: lines.join("") }] };
|
|
55665
55718
|
}
|
|
55666
55719
|
throw new Error(`Tool not found: ${name}`);
|
|
55667
55720
|
} catch (error48) {
|