@fre4x/gemini 1.0.51 → 1.0.52

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.
Files changed (2) hide show
  1. package/dist/index.js +60 -31
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -67823,15 +67823,23 @@ Mock response \u2014 no API call made.`;
67823
67823
  responseText = response.text || "No analysis generated.";
67824
67824
  }
67825
67825
  if (output_dir) {
67826
- const fname = `analysis-${Date.now()}.txt`;
67827
- const fpath = path2.join(output_dir, fname);
67828
- await fs3.mkdir(output_dir, { recursive: true });
67829
- await fs3.writeFile(fpath, responseText);
67830
- return textResult(
67831
- `${responseText}
67826
+ try {
67827
+ const fname = `analysis-${Date.now()}.txt`;
67828
+ const fpath = path2.join(output_dir, fname);
67829
+ await fs3.mkdir(output_dir, { recursive: true });
67830
+ await fs3.writeFile(fpath, responseText);
67831
+ return textResult(
67832
+ `${responseText}
67832
67833
 
67833
67834
  \u2705 Analysis result saved to: ${fpath}`
67834
- );
67835
+ );
67836
+ } catch (error48) {
67837
+ return textResult(
67838
+ `${responseText}
67839
+
67840
+ \u26A0\uFE0F Failed to save analysis result: ${error48.message}`
67841
+ );
67842
+ }
67835
67843
  }
67836
67844
  return textResult(responseText);
67837
67845
  }
@@ -67918,14 +67926,21 @@ async function generateImage(rawArgs) {
67918
67926
  { type: "image", data: mockBase64, mimeType: "image/png" }
67919
67927
  ];
67920
67928
  if (output_dir) {
67921
- const fname = `image-${Date.now()}.png`;
67922
- const fpath = path2.join(output_dir, fname);
67923
- await fs3.mkdir(output_dir, { recursive: true });
67924
- await fs3.writeFile(fpath, Buffer.from(mockBase64, "base64"));
67925
- content2.push({
67926
- type: "text",
67927
- text: `[Mock] Saved to: ${fpath}`
67928
- });
67929
+ try {
67930
+ const fname = `image-${Date.now()}.png`;
67931
+ const fpath = path2.join(output_dir, fname);
67932
+ await fs3.mkdir(output_dir, { recursive: true });
67933
+ await fs3.writeFile(fpath, Buffer.from(mockBase64, "base64"));
67934
+ content2.push({
67935
+ type: "text",
67936
+ text: `[Mock] Saved to: ${fpath}`
67937
+ });
67938
+ } catch (error48) {
67939
+ content2.push({
67940
+ type: "text",
67941
+ text: `\u26A0\uFE0F [Mock] Failed to save image: ${error48.message}`
67942
+ });
67943
+ }
67929
67944
  }
67930
67945
  return { content: content2 };
67931
67946
  }
@@ -67956,24 +67971,31 @@ Check Imagen access at https://ai.google.dev/`
67956
67971
  };
67957
67972
  }
67958
67973
  const savedPaths = [];
67974
+ let saveErrorText = "";
67959
67975
  if (output_dir) {
67960
- await fs3.mkdir(output_dir, { recursive: true });
67961
- const paths = await Promise.all(
67962
- images.map(async (img, index) => {
67963
- const fname = `image-${Date.now()}-${index + 1}.png`;
67964
- const fpath = path2.join(output_dir, fname);
67965
- await fs3.writeFile(fpath, Buffer.from(img.data, "base64"));
67966
- return fpath;
67967
- })
67968
- );
67969
- savedPaths.push(...paths);
67976
+ try {
67977
+ await fs3.mkdir(output_dir, { recursive: true });
67978
+ const paths = await Promise.all(
67979
+ images.map(async (img, index) => {
67980
+ const fname = `image-${Date.now()}-${index + 1}.png`;
67981
+ const fpath = path2.join(output_dir, fname);
67982
+ await fs3.writeFile(fpath, Buffer.from(img.data, "base64"));
67983
+ return fpath;
67984
+ })
67985
+ );
67986
+ savedPaths.push(...paths);
67987
+ } catch (error48) {
67988
+ saveErrorText = `
67989
+
67990
+ \u26A0\uFE0F Failed to save images: ${error48.message}`;
67991
+ }
67970
67992
  }
67971
67993
  const content = [
67972
67994
  {
67973
67995
  type: "text",
67974
67996
  text: `\u2705 Image generated successfully (${images.length} image${images.length > 1 ? "s" : ""}, prompt: "${prompt}").${savedPaths.length > 0 ? `
67975
67997
  Saved to:
67976
- ${savedPaths.join("\n")}` : ""}`
67998
+ ${savedPaths.join("\n")}` : ""}${saveErrorText}`
67977
67999
  },
67978
68000
  ...images
67979
68001
  ];
@@ -68103,11 +68125,15 @@ ${JSON.stringify(op.response, null, 2)}`
68103
68125
  }
68104
68126
  });
68105
68127
  if (output_dir) {
68106
- const fname = `video-${Date.now()}-${index + 1}.mp4`;
68107
- const fpath = path2.join(output_dir, fname);
68108
- await fs3.mkdir(output_dir, { recursive: true });
68109
- await fs3.writeFile(fpath, buffer);
68110
- savedPaths.push(fpath);
68128
+ try {
68129
+ const fname = `video-${Date.now()}-${index + 1}.mp4`;
68130
+ const fpath = path2.join(output_dir, fname);
68131
+ await fs3.mkdir(output_dir, { recursive: true });
68132
+ await fs3.writeFile(fpath, buffer);
68133
+ savedPaths.push(fpath);
68134
+ } catch (error48) {
68135
+ console.error(`Failed to save video: ${error48.message}`);
68136
+ }
68111
68137
  }
68112
68138
  })
68113
68139
  );
@@ -68121,6 +68147,9 @@ ${videos.join("\n")}`
68121
68147
  lines.push(`
68122
68148
  Saved to:
68123
68149
  ${savedPaths.join("\n")}`);
68150
+ } else if (output_dir) {
68151
+ lines.push(`
68152
+ \u26A0\uFE0F Failed to save videos to disk.`);
68124
68153
  }
68125
68154
  return {
68126
68155
  content: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fre4x/gemini",
3
- "version": "1.0.51",
3
+ "version": "1.0.52",
4
4
  "description": "A Gemini MCP server providing multimodal analysis and image/video generation.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",