@mixio-pro/kalaasetu-mcp 1.0.11 → 1.0.12
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 +1 -1
- package/src/tools/gemini.ts +7 -14
- package/src/tools/image-to-video.ts +12 -6
- package/src/utils/filename.ts +19 -3
package/package.json
CHANGED
package/src/tools/gemini.ts
CHANGED
|
@@ -245,16 +245,13 @@ export const geminiTextToImage = {
|
|
|
245
245
|
const imageData = part.inlineData.data;
|
|
246
246
|
if (args.output_path) {
|
|
247
247
|
const storage = getStorage();
|
|
248
|
-
const timestampedPath = generateTimestampedFilename(
|
|
249
|
-
args.output_path
|
|
250
|
-
);
|
|
251
248
|
const url = await storage.writeFile(
|
|
252
|
-
|
|
249
|
+
args.output_path,
|
|
253
250
|
Buffer.from(imageData, "base64")
|
|
254
251
|
);
|
|
255
252
|
images.push({
|
|
256
253
|
url,
|
|
257
|
-
filename:
|
|
254
|
+
filename: args.output_path,
|
|
258
255
|
mimeType: "image/png",
|
|
259
256
|
});
|
|
260
257
|
}
|
|
@@ -326,16 +323,13 @@ export const geminiEditImage = {
|
|
|
326
323
|
const imageData = part.inlineData.data;
|
|
327
324
|
if (args.output_path) {
|
|
328
325
|
const storage = getStorage();
|
|
329
|
-
const timestampedPath = generateTimestampedFilename(
|
|
330
|
-
args.output_path
|
|
331
|
-
);
|
|
332
326
|
const url = await storage.writeFile(
|
|
333
|
-
|
|
327
|
+
args.output_path,
|
|
334
328
|
Buffer.from(imageData, "base64")
|
|
335
329
|
);
|
|
336
330
|
images.push({
|
|
337
331
|
url,
|
|
338
|
-
filename:
|
|
332
|
+
filename: args.output_path,
|
|
339
333
|
mimeType: "image/png",
|
|
340
334
|
});
|
|
341
335
|
}
|
|
@@ -470,12 +464,11 @@ export const geminiSingleSpeakerTts = {
|
|
|
470
464
|
|
|
471
465
|
const audioBuffer = Buffer.from(data, "base64");
|
|
472
466
|
|
|
473
|
-
//
|
|
474
|
-
const outputPath = args.output_path || "voice_output.wav";
|
|
475
|
-
const timestampedPath = generateTimestampedFilename(outputPath);
|
|
467
|
+
// Use provided output path or generate default with timestamp
|
|
468
|
+
const outputPath = args.output_path || generateTimestampedFilename("voice_output.wav");
|
|
476
469
|
|
|
477
470
|
const storage = getStorage();
|
|
478
|
-
const url = await storage.writeFile(
|
|
471
|
+
const url = await storage.writeFile(outputPath, audioBuffer);
|
|
479
472
|
|
|
480
473
|
return JSON.stringify({
|
|
481
474
|
audio: {
|
|
@@ -302,13 +302,19 @@ export const imageToVideo = {
|
|
|
302
302
|
[];
|
|
303
303
|
const saveVideo = async (base64: string, index: number) => {
|
|
304
304
|
if (!base64) return;
|
|
305
|
-
|
|
306
|
-
|
|
305
|
+
|
|
306
|
+
// Use provided output path or generate default with timestamp
|
|
307
|
+
let filePath: string;
|
|
308
|
+
if (args.output_path) {
|
|
309
|
+
// User provided path - use as-is for first video, add index for subsequent
|
|
310
|
+
filePath = index === 0
|
|
307
311
|
? args.output_path
|
|
308
|
-
: args.output_path.replace(/\.mp4$/i, `_${index}.mp4`)
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
+
: args.output_path.replace(/\.mp4$/i, `_${index}.mp4`);
|
|
313
|
+
} else {
|
|
314
|
+
// No path provided - generate timestamped default
|
|
315
|
+
const defaultName = `video_output${index > 0 ? `_${index}` : ""}.mp4`;
|
|
316
|
+
filePath = generateTimestampedFilename(defaultName);
|
|
317
|
+
}
|
|
312
318
|
|
|
313
319
|
const buf = Buffer.from(base64, "base64");
|
|
314
320
|
const storage = getStorage();
|
package/src/utils/filename.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import * as path from "path";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Generate a timestamped filename to avoid conflicts
|
|
3
5
|
* Format: YYYYMMDD_HHmmss_filename.ext
|
|
6
|
+
* Preserves directory structure if present in the input path
|
|
4
7
|
*/
|
|
5
|
-
export function generateTimestampedFilename(
|
|
8
|
+
export function generateTimestampedFilename(filePath: string): string {
|
|
6
9
|
const now = new Date();
|
|
7
10
|
const timestamp = now
|
|
8
11
|
.toISOString()
|
|
@@ -10,13 +13,26 @@ export function generateTimestampedFilename(basename: string): string {
|
|
|
10
13
|
.replace(/\.\d{3}Z$/, "")
|
|
11
14
|
.replace("T", "_");
|
|
12
15
|
|
|
16
|
+
// Split into directory and filename
|
|
17
|
+
const dir = path.dirname(filePath);
|
|
18
|
+
const basename = path.basename(filePath);
|
|
19
|
+
|
|
13
20
|
// Extract extension if present
|
|
14
21
|
const lastDot = basename.lastIndexOf(".");
|
|
22
|
+
let timestampedFilename: string;
|
|
23
|
+
|
|
15
24
|
if (lastDot > 0) {
|
|
16
25
|
const name = basename.substring(0, lastDot);
|
|
17
26
|
const ext = basename.substring(lastDot);
|
|
18
|
-
|
|
27
|
+
timestampedFilename = `${timestamp}_${name}${ext}`;
|
|
28
|
+
} else {
|
|
29
|
+
timestampedFilename = `${timestamp}_${basename}`;
|
|
19
30
|
}
|
|
20
31
|
|
|
21
|
-
|
|
32
|
+
// Reconstruct the full path
|
|
33
|
+
if (dir === ".") {
|
|
34
|
+
return timestampedFilename;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return path.join(dir, timestampedFilename);
|
|
22
38
|
}
|