@mixio-pro/kalaasetu-mcp 1.0.8 → 1.0.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mixio-pro/kalaasetu-mcp",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "A powerful Model Context Protocol server providing AI tools for content generation and analysis",
5
5
  "type": "module",
6
6
  "module": "src/index.ts",
@@ -10,6 +10,7 @@ import * as os from "os";
10
10
  import * as wav from "wav";
11
11
  import { PassThrough } from "stream";
12
12
  import { getStorage } from "../storage";
13
+ import { generateTimestampedFilename } from "../utils/filename";
13
14
 
14
15
  const ai = new GoogleGenAI({
15
16
  apiKey: process.env.GEMINI_API_KEY || "",
@@ -205,13 +206,16 @@ export const geminiTextToImage = {
205
206
  const imageData = part.inlineData.data;
206
207
  if (args.output_path) {
207
208
  const storage = getStorage();
209
+ const timestampedPath = generateTimestampedFilename(
210
+ args.output_path
211
+ );
208
212
  const url = await storage.writeFile(
209
- args.output_path,
213
+ timestampedPath,
210
214
  Buffer.from(imageData, "base64")
211
215
  );
212
216
  images.push({
213
217
  url,
214
- filename: args.output_path,
218
+ filename: timestampedPath,
215
219
  mimeType: "image/png",
216
220
  });
217
221
  }
@@ -283,13 +287,16 @@ export const geminiEditImage = {
283
287
  const imageData = part.inlineData.data;
284
288
  if (args.output_path) {
285
289
  const storage = getStorage();
290
+ const timestampedPath = generateTimestampedFilename(
291
+ args.output_path
292
+ );
286
293
  const url = await storage.writeFile(
287
- args.output_path,
294
+ timestampedPath,
288
295
  Buffer.from(imageData, "base64")
289
296
  );
290
297
  images.push({
291
298
  url,
292
- filename: args.output_path,
299
+ filename: timestampedPath,
293
300
  mimeType: "image/png",
294
301
  });
295
302
  }
@@ -425,10 +432,11 @@ export const geminiSingleSpeakerTts = {
425
432
  const audioBuffer = Buffer.from(data, "base64");
426
433
 
427
434
  // Generate output filename if not provided
428
- const outputPath = args.output_path || `voice_output_${Date.now()}.wav`;
435
+ const outputPath = args.output_path || "voice_output.wav";
436
+ const timestampedPath = generateTimestampedFilename(outputPath);
429
437
 
430
438
  const storage = getStorage();
431
- const url = await storage.writeFile(outputPath, audioBuffer);
439
+ const url = await storage.writeFile(timestampedPath, audioBuffer);
432
440
 
433
441
  return JSON.stringify({
434
442
  audio: {
@@ -4,6 +4,7 @@ import { exec } from "child_process";
4
4
  import * as path from "path";
5
5
  import { z } from "zod";
6
6
  import { getStorage } from "../storage";
7
+ import { generateTimestampedFilename } from "../utils/filename";
7
8
 
8
9
  async function wait(ms: number): Promise<void> {
9
10
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -287,11 +288,13 @@ export const imageToVideo = {
287
288
  [];
288
289
  const saveVideo = async (base64: string, index: number) => {
289
290
  if (!base64) return;
290
- const filePath = args.output_path
291
+ const baseFilename = args.output_path
291
292
  ? index === 0
292
293
  ? args.output_path
293
294
  : args.output_path.replace(/\.mp4$/i, `_${index}.mp4`)
294
- : `video_output_${Date.now()}${index === 0 ? "" : "_" + index}.mp4`;
295
+ : `video_output${index > 0 ? `_${index}` : ""}.mp4`;
296
+
297
+ const filePath = generateTimestampedFilename(baseFilename);
295
298
 
296
299
  const buf = Buffer.from(base64, "base64");
297
300
  const storage = getStorage();
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Generate a timestamped filename to avoid conflicts
3
+ * Format: YYYYMMDD_HHmmss_filename.ext
4
+ */
5
+ export function generateTimestampedFilename(basename: string): string {
6
+ const now = new Date();
7
+ const timestamp = now
8
+ .toISOString()
9
+ .replace(/[-:]/g, "")
10
+ .replace(/\.\d{3}Z$/, "")
11
+ .replace("T", "_");
12
+
13
+ // Extract extension if present
14
+ const lastDot = basename.lastIndexOf(".");
15
+ if (lastDot > 0) {
16
+ const name = basename.substring(0, lastDot);
17
+ const ext = basename.substring(lastDot);
18
+ return `${timestamp}_${name}${ext}`;
19
+ }
20
+
21
+ return `${timestamp}_${basename}`;
22
+ }