mulmocast 1.2.43 → 1.2.45
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/lib/actions/audio.d.ts +1 -0
- package/lib/actions/audio.js +16 -11
- package/lib/actions/image_references.js +3 -22
- package/lib/actions/images.js +3 -7
- package/lib/actions/movie.js +3 -2
- package/lib/actions/translate.js +2 -2
- package/lib/agents/add_bgm_agent.js +3 -3
- package/lib/agents/combine_audio_files_agent.js +2 -1
- package/lib/index.common.d.ts +1 -0
- package/lib/index.common.js +1 -0
- package/lib/methods/mulmo_beat.js +1 -1
- package/lib/methods/mulmo_media_source.d.ts +6 -2
- package/lib/methods/mulmo_media_source.js +81 -6
- package/lib/types/schema.d.ts +29 -823
- package/lib/types/schema.js +6 -1
- package/lib/types/type.d.ts +3 -1
- package/lib/utils/context.d.ts +0 -48
- package/lib/utils/context.js +4 -5
- package/lib/utils/error_cause.d.ts +84 -0
- package/lib/utils/error_cause.js +107 -0
- package/lib/utils/ffmpeg_utils.js +2 -1
- package/lib/utils/file.js +1 -1
- package/lib/utils/filters.js +2 -2
- package/lib/utils/image_plugins/source.d.ts +2 -4
- package/lib/utils/image_plugins/source.js +5 -34
- package/lib/utils/utils.d.ts +0 -1
- package/lib/utils/utils.js +0 -14
- package/package.json +9 -9
package/lib/types/schema.js
CHANGED
|
@@ -38,6 +38,11 @@ export const speakerDictionarySchema = z.record(speakerIdSchema, speakerDataSche
|
|
|
38
38
|
lang: z.record(langSchema, speakerDataSchema).optional(),
|
|
39
39
|
}));
|
|
40
40
|
export const mediaSourceSchema = z.discriminatedUnion("kind", [
|
|
41
|
+
z.object({ kind: z.literal("url"), url: URLStringSchema }).strict(), // https://example.com/foo.pdf
|
|
42
|
+
z.object({ kind: z.literal("base64"), data: z.string().min(1) }).strict(), // base64
|
|
43
|
+
z.object({ kind: z.literal("path"), path: z.string().min(1) }).strict(), // foo.pdf
|
|
44
|
+
]);
|
|
45
|
+
export const mediaSourceMermaidSchema = z.discriminatedUnion("kind", [
|
|
41
46
|
z.object({ kind: z.literal("url"), url: URLStringSchema }).strict(), // https://example.com/foo.pdf
|
|
42
47
|
z.object({ kind: z.literal("base64"), data: z.string().min(1) }).strict(), // base64
|
|
43
48
|
z.object({ kind: z.literal("text"), text: z.string().min(1) }).strict(), // plain text
|
|
@@ -108,7 +113,7 @@ export const mulmoMermaidMediaSchema = z
|
|
|
108
113
|
.object({
|
|
109
114
|
type: z.literal("mermaid"),
|
|
110
115
|
title: z.string().describe("The title of the diagram"),
|
|
111
|
-
code:
|
|
116
|
+
code: mediaSourceMermaidSchema.describe("The code of the mermaid diagram"),
|
|
112
117
|
appendix: z.array(z.string()).optional().describe("The appendix of the mermaid diagram; typically, style information."),
|
|
113
118
|
})
|
|
114
119
|
.strict();
|
package/lib/types/type.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CallbackFunction } from "graphai";
|
|
2
|
-
import { langSchema, localizedTextSchema, mulmoBeatSchema, mulmoScriptSchema, mulmoStudioSchema, mulmoStudioBeatSchema, mulmoStoryboardSchema, mulmoStoryboardSceneSchema, mulmoStudioMultiLingualSchema, mulmoStudioMultiLingualArraySchema, mulmoStudioMultiLingualDataSchema, mulmoStudioMultiLingualFileSchema, speakerDictionarySchema, mulmoImageParamsSchema, mulmoImageParamsImagesSchema, mulmoFillOptionSchema, mulmoMovieParamsSchema, textSlideParamsSchema, speechOptionsSchema, speakerDataSchema, mulmoCanvasDimensionSchema, mulmoPromptTemplateSchema, mulmoPromptTemplateFileSchema, text2ImageProviderSchema, text2HtmlImageProviderSchema, text2MovieProviderSchema, text2SpeechProviderSchema, mulmoPresentationStyleSchema, multiLingualTextsSchema, mulmoImageAssetSchema, mulmoMermaidMediaSchema, mulmoTextSlideMediaSchema, mulmoMarkdownMediaSchema, mulmoImageMediaSchema, mulmoChartMediaSchema, mediaSourceSchema, mulmoSessionStateSchema, mulmoOpenAIImageModelSchema, mulmoGoogleImageModelSchema, mulmoGoogleMovieModelSchema, mulmoReplicateMovieModelSchema, mulmoImagePromptMediaSchema } from "./schema.js";
|
|
2
|
+
import { langSchema, localizedTextSchema, mulmoBeatSchema, mulmoScriptSchema, mulmoStudioSchema, mulmoStudioBeatSchema, mulmoStoryboardSchema, mulmoStoryboardSceneSchema, mulmoStudioMultiLingualSchema, mulmoStudioMultiLingualArraySchema, mulmoStudioMultiLingualDataSchema, mulmoStudioMultiLingualFileSchema, speakerDictionarySchema, mulmoImageParamsSchema, mulmoImageParamsImagesSchema, mulmoFillOptionSchema, mulmoMovieParamsSchema, textSlideParamsSchema, speechOptionsSchema, speakerDataSchema, mulmoCanvasDimensionSchema, mulmoPromptTemplateSchema, mulmoPromptTemplateFileSchema, text2ImageProviderSchema, text2HtmlImageProviderSchema, text2MovieProviderSchema, text2SpeechProviderSchema, mulmoPresentationStyleSchema, multiLingualTextsSchema, mulmoImageAssetSchema, mulmoMermaidMediaSchema, mulmoTextSlideMediaSchema, mulmoMarkdownMediaSchema, mulmoImageMediaSchema, mulmoChartMediaSchema, mediaSourceSchema, mediaSourceMermaidSchema, mulmoSessionStateSchema, mulmoOpenAIImageModelSchema, mulmoGoogleImageModelSchema, mulmoGoogleMovieModelSchema, mulmoReplicateMovieModelSchema, mulmoImagePromptMediaSchema } from "./schema.js";
|
|
3
3
|
import { pdf_modes, pdf_sizes, storyToScriptGenerateMode } from "../utils/const.js";
|
|
4
4
|
import type { LLM } from "../utils/provider2agent.js";
|
|
5
5
|
import { z } from "zod";
|
|
@@ -24,6 +24,7 @@ export type MulmoStoryboardScene = z.infer<typeof mulmoStoryboardSceneSchema>;
|
|
|
24
24
|
export type MulmoStoryboard = z.infer<typeof mulmoStoryboardSchema>;
|
|
25
25
|
export type MulmoStudioBeat = z.infer<typeof mulmoStudioBeatSchema>;
|
|
26
26
|
export type MulmoMediaSource = z.infer<typeof mediaSourceSchema>;
|
|
27
|
+
export type MulmoMediaMermaidSource = z.infer<typeof mediaSourceMermaidSchema>;
|
|
27
28
|
export type MulmoStudio = z.infer<typeof mulmoStudioSchema>;
|
|
28
29
|
export type MulmoPromptTemplate = z.infer<typeof mulmoPromptTemplateSchema>;
|
|
29
30
|
export type MulmoPromptTemplateFile = z.infer<typeof mulmoPromptTemplateFileSchema>;
|
|
@@ -129,3 +130,4 @@ export type PublicAPIArgs = {
|
|
|
129
130
|
settings?: Record<string, string>;
|
|
130
131
|
callbacks?: CallbackFunction[];
|
|
131
132
|
};
|
|
133
|
+
export type ImageType = "image" | "movie";
|
package/lib/utils/context.d.ts
CHANGED
|
@@ -30,9 +30,6 @@ export declare const createStudioData: (_mulmoScript: MulmoScript, fileName: str
|
|
|
30
30
|
} | {
|
|
31
31
|
kind: "base64";
|
|
32
32
|
data: string;
|
|
33
|
-
} | {
|
|
34
|
-
text: string;
|
|
35
|
-
kind: "text";
|
|
36
33
|
} | {
|
|
37
34
|
path: string;
|
|
38
35
|
kind: "path";
|
|
@@ -61,9 +58,6 @@ export declare const createStudioData: (_mulmoScript: MulmoScript, fileName: str
|
|
|
61
58
|
} | {
|
|
62
59
|
kind: "base64";
|
|
63
60
|
data: string;
|
|
64
|
-
} | {
|
|
65
|
-
text: string;
|
|
66
|
-
kind: "text";
|
|
67
61
|
} | {
|
|
68
62
|
path: string;
|
|
69
63
|
kind: "path";
|
|
@@ -121,9 +115,6 @@ export declare const createStudioData: (_mulmoScript: MulmoScript, fileName: str
|
|
|
121
115
|
} | {
|
|
122
116
|
kind: "base64";
|
|
123
117
|
data: string;
|
|
124
|
-
} | {
|
|
125
|
-
text: string;
|
|
126
|
-
kind: "text";
|
|
127
118
|
} | {
|
|
128
119
|
path: string;
|
|
129
120
|
kind: "path";
|
|
@@ -136,9 +127,6 @@ export declare const createStudioData: (_mulmoScript: MulmoScript, fileName: str
|
|
|
136
127
|
} | {
|
|
137
128
|
kind: "base64";
|
|
138
129
|
data: string;
|
|
139
|
-
} | {
|
|
140
|
-
text: string;
|
|
141
|
-
kind: "text";
|
|
142
130
|
} | {
|
|
143
131
|
path: string;
|
|
144
132
|
kind: "path";
|
|
@@ -151,9 +139,6 @@ export declare const createStudioData: (_mulmoScript: MulmoScript, fileName: str
|
|
|
151
139
|
} | {
|
|
152
140
|
kind: "base64";
|
|
153
141
|
data: string;
|
|
154
|
-
} | {
|
|
155
|
-
text: string;
|
|
156
|
-
kind: "text";
|
|
157
142
|
} | {
|
|
158
143
|
path: string;
|
|
159
144
|
kind: "path";
|
|
@@ -166,9 +151,6 @@ export declare const createStudioData: (_mulmoScript: MulmoScript, fileName: str
|
|
|
166
151
|
} | {
|
|
167
152
|
kind: "base64";
|
|
168
153
|
data: string;
|
|
169
|
-
} | {
|
|
170
|
-
text: string;
|
|
171
|
-
kind: "text";
|
|
172
154
|
} | {
|
|
173
155
|
path: string;
|
|
174
156
|
kind: "path";
|
|
@@ -223,9 +205,6 @@ export declare const createStudioData: (_mulmoScript: MulmoScript, fileName: str
|
|
|
223
205
|
} | {
|
|
224
206
|
kind: "base64";
|
|
225
207
|
data: string;
|
|
226
|
-
} | {
|
|
227
|
-
text: string;
|
|
228
|
-
kind: "text";
|
|
229
208
|
} | {
|
|
230
209
|
path: string;
|
|
231
210
|
kind: "path";
|
|
@@ -366,9 +345,6 @@ export declare const initializeContextFromFiles: (files: FileObject, raiseError:
|
|
|
366
345
|
} | {
|
|
367
346
|
kind: "base64";
|
|
368
347
|
data: string;
|
|
369
|
-
} | {
|
|
370
|
-
text: string;
|
|
371
|
-
kind: "text";
|
|
372
348
|
} | {
|
|
373
349
|
path: string;
|
|
374
350
|
kind: "path";
|
|
@@ -397,9 +373,6 @@ export declare const initializeContextFromFiles: (files: FileObject, raiseError:
|
|
|
397
373
|
} | {
|
|
398
374
|
kind: "base64";
|
|
399
375
|
data: string;
|
|
400
|
-
} | {
|
|
401
|
-
text: string;
|
|
402
|
-
kind: "text";
|
|
403
376
|
} | {
|
|
404
377
|
path: string;
|
|
405
378
|
kind: "path";
|
|
@@ -457,9 +430,6 @@ export declare const initializeContextFromFiles: (files: FileObject, raiseError:
|
|
|
457
430
|
} | {
|
|
458
431
|
kind: "base64";
|
|
459
432
|
data: string;
|
|
460
|
-
} | {
|
|
461
|
-
text: string;
|
|
462
|
-
kind: "text";
|
|
463
433
|
} | {
|
|
464
434
|
path: string;
|
|
465
435
|
kind: "path";
|
|
@@ -472,9 +442,6 @@ export declare const initializeContextFromFiles: (files: FileObject, raiseError:
|
|
|
472
442
|
} | {
|
|
473
443
|
kind: "base64";
|
|
474
444
|
data: string;
|
|
475
|
-
} | {
|
|
476
|
-
text: string;
|
|
477
|
-
kind: "text";
|
|
478
445
|
} | {
|
|
479
446
|
path: string;
|
|
480
447
|
kind: "path";
|
|
@@ -487,9 +454,6 @@ export declare const initializeContextFromFiles: (files: FileObject, raiseError:
|
|
|
487
454
|
} | {
|
|
488
455
|
kind: "base64";
|
|
489
456
|
data: string;
|
|
490
|
-
} | {
|
|
491
|
-
text: string;
|
|
492
|
-
kind: "text";
|
|
493
457
|
} | {
|
|
494
458
|
path: string;
|
|
495
459
|
kind: "path";
|
|
@@ -502,9 +466,6 @@ export declare const initializeContextFromFiles: (files: FileObject, raiseError:
|
|
|
502
466
|
} | {
|
|
503
467
|
kind: "base64";
|
|
504
468
|
data: string;
|
|
505
|
-
} | {
|
|
506
|
-
text: string;
|
|
507
|
-
kind: "text";
|
|
508
469
|
} | {
|
|
509
470
|
path: string;
|
|
510
471
|
kind: "path";
|
|
@@ -559,9 +520,6 @@ export declare const initializeContextFromFiles: (files: FileObject, raiseError:
|
|
|
559
520
|
} | {
|
|
560
521
|
kind: "base64";
|
|
561
522
|
data: string;
|
|
562
|
-
} | {
|
|
563
|
-
text: string;
|
|
564
|
-
kind: "text";
|
|
565
523
|
} | {
|
|
566
524
|
path: string;
|
|
567
525
|
kind: "path";
|
|
@@ -689,9 +647,6 @@ export declare const initializeContextFromFiles: (files: FileObject, raiseError:
|
|
|
689
647
|
} | {
|
|
690
648
|
kind: "base64";
|
|
691
649
|
data: string;
|
|
692
|
-
} | {
|
|
693
|
-
text: string;
|
|
694
|
-
kind: "text";
|
|
695
650
|
} | {
|
|
696
651
|
path: string;
|
|
697
652
|
kind: "path";
|
|
@@ -720,9 +675,6 @@ export declare const initializeContextFromFiles: (files: FileObject, raiseError:
|
|
|
720
675
|
} | {
|
|
721
676
|
kind: "base64";
|
|
722
677
|
data: string;
|
|
723
|
-
} | {
|
|
724
|
-
text: string;
|
|
725
|
-
kind: "text";
|
|
726
678
|
} | {
|
|
727
679
|
path: string;
|
|
728
680
|
kind: "path";
|
package/lib/utils/context.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GraphAILogger } from "graphai";
|
|
2
|
-
import
|
|
3
|
-
import { readMulmoScriptFile, fetchMulmoScriptFile } from "./file.js";
|
|
2
|
+
import { readMulmoScriptFile, fetchMulmoScriptFile, isFile } from "./file.js";
|
|
4
3
|
import { beatId, multiLingualObjectToArray } from "./utils.js";
|
|
5
4
|
import { mulmoStudioSchema, mulmoCaptionParamsSchema, mulmoPresentationStyleSchema } from "../types/schema.js";
|
|
6
5
|
import { MulmoPresentationStyleMethods, MulmoScriptMethods, MulmoStudioMultiLingualMethod } from "../methods/index.js";
|
|
@@ -86,14 +85,14 @@ export const fetchScript = async (isHttpPath, mulmoFilePath, fileOrUrl) => {
|
|
|
86
85
|
}
|
|
87
86
|
return res.script;
|
|
88
87
|
}
|
|
89
|
-
if (!
|
|
88
|
+
if (!isFile(mulmoFilePath)) {
|
|
90
89
|
GraphAILogger.info(`ERROR: File not exists ${mulmoFilePath}`);
|
|
91
90
|
return null;
|
|
92
91
|
}
|
|
93
92
|
return readMulmoScriptFile(mulmoFilePath, "ERROR: File does not exist " + mulmoFilePath)?.mulmoData ?? null;
|
|
94
93
|
};
|
|
95
94
|
export const getMultiLingual = (multilingualFilePath, beats) => {
|
|
96
|
-
if (!
|
|
95
|
+
if (!isFile(multilingualFilePath)) {
|
|
97
96
|
return beats.reduce((tmp, beat, index) => {
|
|
98
97
|
const key = beatId(beat?.id, index);
|
|
99
98
|
tmp[key] = { multiLingualTexts: {} };
|
|
@@ -107,7 +106,7 @@ export const getPresentationStyle = (presentationStylePath) => {
|
|
|
107
106
|
if (!presentationStylePath) {
|
|
108
107
|
return null;
|
|
109
108
|
}
|
|
110
|
-
if (!
|
|
109
|
+
if (!isFile(presentationStylePath)) {
|
|
111
110
|
throw new Error(`ERROR: File not exists ${presentationStylePath}`);
|
|
112
111
|
}
|
|
113
112
|
const jsonData = readMulmoScriptFile(presentationStylePath, "ERROR: File does not exist " + presentationStylePath)?.mulmoData ?? null;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export declare const urlFileNotFoundType = "urlFileNotFound";
|
|
2
|
+
export declare const fileNotExistType = "fileNotExist";
|
|
3
|
+
export declare const unknownMediaType = "unknownMedia";
|
|
4
|
+
export declare const sourceUndefinedType = "undefinedSourceType";
|
|
5
|
+
export declare const movieAction = "movie";
|
|
6
|
+
export declare const imageAction = "images";
|
|
7
|
+
export declare const audioAction = "audio";
|
|
8
|
+
export declare const imageReferenceAction = "imageReference";
|
|
9
|
+
export declare const audioFileTarget = "audioFile";
|
|
10
|
+
export declare const imageFileTarget = "imageFile";
|
|
11
|
+
export declare const movieFileTarget = "movieFile";
|
|
12
|
+
export declare const videoSourceTarget = "videoSource";
|
|
13
|
+
export declare const audioSourceTarget = "audioSource";
|
|
14
|
+
export declare const codeTextTarget = "codeText";
|
|
15
|
+
export declare const getAudioInputIdsError: (index: number, fileName: string) => {
|
|
16
|
+
type: string;
|
|
17
|
+
action: string;
|
|
18
|
+
target: string;
|
|
19
|
+
agentName: string;
|
|
20
|
+
beatIndex: number;
|
|
21
|
+
fileName: string;
|
|
22
|
+
};
|
|
23
|
+
export declare const audioCheckerError: (index: number, fileName: string) => {
|
|
24
|
+
type: string;
|
|
25
|
+
action: string;
|
|
26
|
+
target: string;
|
|
27
|
+
agentName: string;
|
|
28
|
+
beatIndex: number;
|
|
29
|
+
fileName: string;
|
|
30
|
+
};
|
|
31
|
+
export declare const createVideoFileError: (index: number, fileName: string) => {
|
|
32
|
+
type: string;
|
|
33
|
+
action: string;
|
|
34
|
+
target: string;
|
|
35
|
+
agentName: string;
|
|
36
|
+
beatIndex: number;
|
|
37
|
+
fileName: string;
|
|
38
|
+
};
|
|
39
|
+
export declare const createVideoSourceError: (index: number) => {
|
|
40
|
+
type: string;
|
|
41
|
+
action: string;
|
|
42
|
+
target: string;
|
|
43
|
+
agentName: string;
|
|
44
|
+
beatIndex: number;
|
|
45
|
+
};
|
|
46
|
+
export declare const invalidAudioSourceError: (beatIndex: number) => {
|
|
47
|
+
type: string;
|
|
48
|
+
action: string;
|
|
49
|
+
target: string;
|
|
50
|
+
agentName: string;
|
|
51
|
+
beatIndex: number;
|
|
52
|
+
};
|
|
53
|
+
export declare const downLoadReferenceImageError: (key: string, url: string) => {
|
|
54
|
+
type: string;
|
|
55
|
+
action: string;
|
|
56
|
+
target: string;
|
|
57
|
+
agentName: string;
|
|
58
|
+
key: string;
|
|
59
|
+
url: string;
|
|
60
|
+
};
|
|
61
|
+
export declare const downloadImagePluginError: (url: string, imageType: string) => {
|
|
62
|
+
type: string;
|
|
63
|
+
action: string;
|
|
64
|
+
target: string;
|
|
65
|
+
agentName: string;
|
|
66
|
+
url: string;
|
|
67
|
+
};
|
|
68
|
+
export declare const getTextError: (url: string) => {
|
|
69
|
+
type: string;
|
|
70
|
+
action: string;
|
|
71
|
+
target: string;
|
|
72
|
+
agentName: string;
|
|
73
|
+
url: string;
|
|
74
|
+
};
|
|
75
|
+
export declare const imageReferenceUnknownMediaError: (key: string) => {
|
|
76
|
+
type: string;
|
|
77
|
+
action: string;
|
|
78
|
+
key: string;
|
|
79
|
+
};
|
|
80
|
+
export declare const imagePluginUnknownMediaError: (imageType: string) => {
|
|
81
|
+
type: string;
|
|
82
|
+
action: string;
|
|
83
|
+
target: string;
|
|
84
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
export const urlFileNotFoundType = "urlFileNotFound";
|
|
2
|
+
export const fileNotExistType = "fileNotExist";
|
|
3
|
+
export const unknownMediaType = "unknownMedia";
|
|
4
|
+
export const sourceUndefinedType = "undefinedSourceType";
|
|
5
|
+
export const movieAction = "movie";
|
|
6
|
+
export const imageAction = "images";
|
|
7
|
+
export const audioAction = "audio";
|
|
8
|
+
export const imageReferenceAction = "imageReference";
|
|
9
|
+
export const audioFileTarget = "audioFile";
|
|
10
|
+
export const imageFileTarget = "imageFile";
|
|
11
|
+
export const movieFileTarget = "movieFile";
|
|
12
|
+
export const videoSourceTarget = "videoSource";
|
|
13
|
+
export const audioSourceTarget = "audioSource";
|
|
14
|
+
export const codeTextTarget = "codeText";
|
|
15
|
+
export const getAudioInputIdsError = (index, fileName) => {
|
|
16
|
+
return {
|
|
17
|
+
type: fileNotExistType,
|
|
18
|
+
action: movieAction,
|
|
19
|
+
target: audioFileTarget,
|
|
20
|
+
agentName: "combineAudioFiles",
|
|
21
|
+
beatIndex: index,
|
|
22
|
+
fileName,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export const audioCheckerError = (index, fileName) => {
|
|
26
|
+
return {
|
|
27
|
+
type: fileNotExistType,
|
|
28
|
+
action: imageAction,
|
|
29
|
+
target: imageFileTarget,
|
|
30
|
+
agentName: "audioChecker",
|
|
31
|
+
beatIndex: index,
|
|
32
|
+
fileName,
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export const createVideoFileError = (index, fileName) => {
|
|
36
|
+
return {
|
|
37
|
+
type: fileNotExistType,
|
|
38
|
+
action: movieAction,
|
|
39
|
+
target: imageFileTarget,
|
|
40
|
+
agentName: "createVideo",
|
|
41
|
+
beatIndex: index,
|
|
42
|
+
fileName,
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
// undefinedSource
|
|
46
|
+
export const createVideoSourceError = (index) => {
|
|
47
|
+
return {
|
|
48
|
+
type: sourceUndefinedType,
|
|
49
|
+
action: movieAction,
|
|
50
|
+
target: videoSourceTarget,
|
|
51
|
+
agentName: "createVideo",
|
|
52
|
+
beatIndex: index,
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
export const invalidAudioSourceError = (beatIndex) => {
|
|
56
|
+
return {
|
|
57
|
+
type: sourceUndefinedType,
|
|
58
|
+
action: audioAction,
|
|
59
|
+
target: audioSourceTarget,
|
|
60
|
+
agentName: "getAudioPathOrUrl",
|
|
61
|
+
beatIndex,
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
// 404
|
|
65
|
+
export const downLoadReferenceImageError = (key, url) => {
|
|
66
|
+
return {
|
|
67
|
+
type: urlFileNotFoundType,
|
|
68
|
+
action: imageReferenceAction,
|
|
69
|
+
target: imageFileTarget,
|
|
70
|
+
agentName: "downloadUrl",
|
|
71
|
+
key,
|
|
72
|
+
url,
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
export const downloadImagePluginError = (url, imageType) => {
|
|
76
|
+
return {
|
|
77
|
+
type: urlFileNotFoundType,
|
|
78
|
+
action: imageAction,
|
|
79
|
+
target: imageType === "image" ? imageFileTarget : movieFileTarget,
|
|
80
|
+
agentName: "imagePlugin",
|
|
81
|
+
url,
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
export const getTextError = (url) => {
|
|
85
|
+
return {
|
|
86
|
+
type: urlFileNotFoundType,
|
|
87
|
+
action: imageAction,
|
|
88
|
+
target: codeTextTarget,
|
|
89
|
+
agentName: "mermaid",
|
|
90
|
+
url,
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
//
|
|
94
|
+
export const imageReferenceUnknownMediaError = (key) => {
|
|
95
|
+
return {
|
|
96
|
+
type: unknownMediaType,
|
|
97
|
+
action: imageReferenceAction,
|
|
98
|
+
key,
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
export const imagePluginUnknownMediaError = (imageType) => {
|
|
102
|
+
return {
|
|
103
|
+
type: unknownMediaType,
|
|
104
|
+
action: imageAction,
|
|
105
|
+
target: imageType,
|
|
106
|
+
};
|
|
107
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import ffmpeg from "fluent-ffmpeg";
|
|
2
2
|
import { GraphAILogger } from "graphai";
|
|
3
|
+
import { isFile } from "./file.js";
|
|
3
4
|
import fs from "fs";
|
|
4
5
|
export const setFfmpegPath = (ffmpegPath) => {
|
|
5
6
|
ffmpeg.setFfmpegPath(ffmpegPath);
|
|
@@ -100,7 +101,7 @@ export const extractImageFromMovie = (movieFile, imagePath) => {
|
|
|
100
101
|
};
|
|
101
102
|
export const trimMusic = (inputFile, startTime, duration) => {
|
|
102
103
|
return new Promise((resolve, reject) => {
|
|
103
|
-
if (!inputFile.startsWith("http://") && !inputFile.startsWith("https://") && !
|
|
104
|
+
if (!inputFile.startsWith("http://") && !inputFile.startsWith("https://") && !isFile(inputFile)) {
|
|
104
105
|
reject(new Error(`File not found: ${inputFile}`));
|
|
105
106
|
return;
|
|
106
107
|
}
|
package/lib/utils/file.js
CHANGED
|
@@ -17,7 +17,7 @@ export const updateNpmRoot = (_npmRoot) => {
|
|
|
17
17
|
};
|
|
18
18
|
export function readMulmoScriptFile(arg2, errorMessage) {
|
|
19
19
|
const scriptPath = path.resolve(arg2);
|
|
20
|
-
if (!
|
|
20
|
+
if (!isFile(scriptPath)) {
|
|
21
21
|
if (errorMessage) {
|
|
22
22
|
GraphAILogger.info(errorMessage);
|
|
23
23
|
}
|
package/lib/utils/filters.js
CHANGED
|
@@ -3,7 +3,7 @@ import fs from "fs";
|
|
|
3
3
|
import path from "path";
|
|
4
4
|
import fsPromise from "fs/promises";
|
|
5
5
|
import { GraphAILogger } from "graphai";
|
|
6
|
-
import { writingMessage } from "./file.js";
|
|
6
|
+
import { writingMessage, isFile } from "./file.js";
|
|
7
7
|
import { text2hash } from "./utils_node.js";
|
|
8
8
|
import { MulmoStudioContextMethods } from "../methods/mulmo_studio_context.js";
|
|
9
9
|
import { replacementsJa, replacePairsJa } from "../utils/string.js";
|
|
@@ -64,7 +64,7 @@ export const browserlessCacheGenerator = (cacheDir) => {
|
|
|
64
64
|
const browserlessCache = async (context, next) => {
|
|
65
65
|
const cacheKey = text2hash(context?.namedInputs?.url);
|
|
66
66
|
const cachePath = path.resolve(cacheDir, cacheKey + ".txt");
|
|
67
|
-
if (
|
|
67
|
+
if (isFile(cachePath)) {
|
|
68
68
|
// console.log("cache hit!!");
|
|
69
69
|
const text = fs.readFileSync(cachePath, "utf-8");
|
|
70
70
|
return { text };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { ImageProcessorParams } from "../../types/index.js";
|
|
2
|
-
type ImageType = "image" | "movie";
|
|
1
|
+
import { type ImageProcessorParams, type ImageType } from "../../types/index.js";
|
|
3
2
|
export declare const processSource: (imageType: ImageType) => (params: ImageProcessorParams) => Promise<string | undefined>;
|
|
4
|
-
export declare const pathSource: (
|
|
5
|
-
export {};
|
|
3
|
+
export declare const pathSource: (imageType: ImageType) => (params: ImageProcessorParams) => string | undefined;
|
|
@@ -1,48 +1,19 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import { GraphAILogger } from "graphai";
|
|
3
1
|
import { MulmoMediaSourceMethods } from "../../methods/mulmo_media_source.js";
|
|
4
|
-
function fixExtention(path, imageType) {
|
|
5
|
-
if (imageType === "movie") {
|
|
6
|
-
return path.replace(/\.png$/, ".mov");
|
|
7
|
-
}
|
|
8
|
-
return path;
|
|
9
|
-
}
|
|
10
2
|
export const processSource = (imageType) => {
|
|
11
3
|
return async (params) => {
|
|
12
4
|
const { beat, context } = params;
|
|
13
5
|
if (!beat?.image || beat.image.type !== imageType)
|
|
14
6
|
return;
|
|
15
|
-
|
|
16
|
-
const response = await fetch(beat.image.source.url);
|
|
17
|
-
if (!response.ok) {
|
|
18
|
-
throw new Error(`Failed to download image: ${beat.image.source.url}`);
|
|
19
|
-
}
|
|
20
|
-
const buffer = Buffer.from(await response.arrayBuffer());
|
|
21
|
-
// Detect file extension from Content-Type header or URL
|
|
22
|
-
const imagePath = fixExtention(params.imagePath, beat.image.type);
|
|
23
|
-
await fs.promises.writeFile(imagePath, buffer);
|
|
24
|
-
return imagePath;
|
|
25
|
-
}
|
|
26
|
-
const path = MulmoMediaSourceMethods.resolve(beat.image.source, context);
|
|
27
|
-
if (path) {
|
|
28
|
-
return path;
|
|
29
|
-
}
|
|
30
|
-
GraphAILogger.error(`Image Plugin unknown ${imageType} source type:`, beat.image);
|
|
31
|
-
throw new Error(`ERROR: unknown ${imageType} source type`);
|
|
7
|
+
return MulmoMediaSourceMethods.imagePluginSource(beat.image.source, context, params.imagePath, imageType);
|
|
32
8
|
};
|
|
33
9
|
};
|
|
34
|
-
export const pathSource = (
|
|
10
|
+
export const pathSource = (imageType) => {
|
|
35
11
|
return (params) => {
|
|
36
12
|
const { beat, context } = params;
|
|
13
|
+
if (!beat?.image || beat.image.type !== imageType)
|
|
14
|
+
return;
|
|
37
15
|
if (beat.image?.type == "image" || beat.image?.type == "movie") {
|
|
38
|
-
|
|
39
|
-
return fixExtention(params.imagePath, beat.image.type);
|
|
40
|
-
}
|
|
41
|
-
const path = MulmoMediaSourceMethods.resolve(beat.image.source, context);
|
|
42
|
-
if (path) {
|
|
43
|
-
return path;
|
|
44
|
-
}
|
|
45
|
-
return undefined;
|
|
16
|
+
return MulmoMediaSourceMethods.imagePluginSourcePath(beat.image.source, context, params.imagePath, imageType);
|
|
46
17
|
}
|
|
47
18
|
};
|
|
48
19
|
};
|
package/lib/utils/utils.d.ts
CHANGED
|
@@ -17,7 +17,6 @@ export declare const localizedText: (beat: MulmoBeat, multiLingualData?: MulmoSt
|
|
|
17
17
|
export declare function processLineBreaks(text: string): string;
|
|
18
18
|
export declare function userAssert(condition: boolean, message: string): asserts condition;
|
|
19
19
|
export declare const settings2GraphAIConfig: (settings?: Record<string, string>, env?: Record<string, string | undefined>) => ConfigDataDictionary<DefaultConfigData>;
|
|
20
|
-
export declare const getExtention: (contentType: string | null, url: string) => string;
|
|
21
20
|
type Primitive = string | number | boolean | symbol | bigint;
|
|
22
21
|
type CleanableValue = Primitive | null | undefined | CleanableObject | CleanableValue[];
|
|
23
22
|
type CleanableObject = {
|
package/lib/utils/utils.js
CHANGED
|
@@ -90,20 +90,6 @@ export const settings2GraphAIConfig = (settings, env) => {
|
|
|
90
90
|
};
|
|
91
91
|
return deepClean(config) ?? {};
|
|
92
92
|
};
|
|
93
|
-
export const getExtention = (contentType, url) => {
|
|
94
|
-
if (contentType?.includes("jpeg") || contentType?.includes("jpg")) {
|
|
95
|
-
return "jpg";
|
|
96
|
-
}
|
|
97
|
-
else if (contentType?.includes("png")) {
|
|
98
|
-
return "png";
|
|
99
|
-
}
|
|
100
|
-
// Fall back to URL extension
|
|
101
|
-
const urlExtension = url.split(".").pop()?.toLowerCase();
|
|
102
|
-
if (urlExtension && ["jpg", "jpeg", "png"].includes(urlExtension)) {
|
|
103
|
-
return urlExtension === "jpeg" ? "jpg" : urlExtension;
|
|
104
|
-
}
|
|
105
|
-
return "png"; // default
|
|
106
|
-
};
|
|
107
93
|
export const deepClean = (input) => {
|
|
108
94
|
if (input === null || input === undefined || input === "") {
|
|
109
95
|
return undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mulmocast",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.45",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.node.js",
|
|
@@ -82,18 +82,18 @@
|
|
|
82
82
|
"@graphai/vanilla_node_agents": "^2.0.4",
|
|
83
83
|
"@inquirer/input": "^4.2.4",
|
|
84
84
|
"@inquirer/select": "^4.3.4",
|
|
85
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
85
|
+
"@modelcontextprotocol/sdk": "^1.19.1",
|
|
86
86
|
"@mozilla/readability": "^0.6.0",
|
|
87
87
|
"@tavily/core": "^0.5.11",
|
|
88
88
|
"clipboardy": "^4.0.0",
|
|
89
|
-
"dotenv": "^17.2.
|
|
89
|
+
"dotenv": "^17.2.3",
|
|
90
90
|
"fluent-ffmpeg": "^2.1.3",
|
|
91
|
-
"graphai": "^2.0.
|
|
91
|
+
"graphai": "^2.0.16",
|
|
92
92
|
"jsdom": "^27.0.0",
|
|
93
93
|
"marked": "^16.3.0",
|
|
94
94
|
"mulmocast-vision": "^1.0.4",
|
|
95
95
|
"ora": "^8.2.0",
|
|
96
|
-
"puppeteer": "^24.
|
|
96
|
+
"puppeteer": "^24.23.0",
|
|
97
97
|
"replicate": "^1.1.0",
|
|
98
98
|
"yaml": "^2.8.1",
|
|
99
99
|
"yargs": "^18.0.0",
|
|
@@ -103,16 +103,16 @@
|
|
|
103
103
|
"devDependencies": {
|
|
104
104
|
"@receptron/test_utils": "^2.0.3",
|
|
105
105
|
"@types/fluent-ffmpeg": "^2.1.26",
|
|
106
|
-
"@types/jsdom": "^
|
|
106
|
+
"@types/jsdom": "^27.0.0",
|
|
107
107
|
"@types/yargs": "^17.0.33",
|
|
108
|
-
"eslint": "^9.
|
|
108
|
+
"eslint": "^9.37.0",
|
|
109
109
|
"eslint-config-prettier": "^10.1.8",
|
|
110
110
|
"eslint-plugin-prettier": "^5.5.4",
|
|
111
111
|
"eslint-plugin-sonarjs": "^3.0.5",
|
|
112
112
|
"prettier": "^3.6.2",
|
|
113
113
|
"tsx": "^4.20.6",
|
|
114
|
-
"typescript": "^5.9.
|
|
115
|
-
"typescript-eslint": "^8.
|
|
114
|
+
"typescript": "^5.9.3",
|
|
115
|
+
"typescript-eslint": "^8.45.0"
|
|
116
116
|
},
|
|
117
117
|
"engines": {
|
|
118
118
|
"node": ">=20.0.0"
|