mulmocast 0.0.1

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 (83) hide show
  1. package/README.md +74 -0
  2. package/assets/audio/silent300.mp3 +0 -0
  3. package/assets/audio/silent800.mp3 +0 -0
  4. package/assets/music/StarsBeyondEx.mp3 +0 -0
  5. package/assets/templates/business.json +89 -0
  6. package/assets/templates/children_book.json +135 -0
  7. package/assets/templates/podcast_standard.json +5 -0
  8. package/assets/templates/sensei_and_taro.json +123 -0
  9. package/lib/actions/audio.d.ts +3 -0
  10. package/lib/actions/audio.js +186 -0
  11. package/lib/actions/images.d.ts +2 -0
  12. package/lib/actions/images.js +211 -0
  13. package/lib/actions/movie.d.ts +2 -0
  14. package/lib/actions/movie.js +81 -0
  15. package/lib/actions/translate.d.ts +3 -0
  16. package/lib/actions/translate.js +236 -0
  17. package/lib/agents/add_bgm_agent.d.ts +3 -0
  18. package/lib/agents/add_bgm_agent.js +61 -0
  19. package/lib/agents/combine_audio_files_agent.d.ts +3 -0
  20. package/lib/agents/combine_audio_files_agent.js +57 -0
  21. package/lib/agents/image_google_agent.d.ts +15 -0
  22. package/lib/agents/image_google_agent.js +88 -0
  23. package/lib/agents/image_openai_agent.d.ts +15 -0
  24. package/lib/agents/image_openai_agent.js +59 -0
  25. package/lib/agents/index.d.ts +13 -0
  26. package/lib/agents/index.js +31 -0
  27. package/lib/agents/mulmo_prompts_agent.d.ts +7 -0
  28. package/lib/agents/mulmo_prompts_agent.js +41 -0
  29. package/lib/agents/prompts_data.d.ts +15 -0
  30. package/lib/agents/prompts_data.js +19 -0
  31. package/lib/agents/tts_nijivoice_agent.d.ts +4 -0
  32. package/lib/agents/tts_nijivoice_agent.js +68 -0
  33. package/lib/agents/tts_openai_agent.d.ts +4 -0
  34. package/lib/agents/tts_openai_agent.js +50 -0
  35. package/lib/agents/validate_mulmo_script_agent.d.ts +17 -0
  36. package/lib/agents/validate_mulmo_script_agent.js +38 -0
  37. package/lib/cli/args.d.ts +10 -0
  38. package/lib/cli/args.js +38 -0
  39. package/lib/cli/cli.d.ts +2 -0
  40. package/lib/cli/cli.js +78 -0
  41. package/lib/cli/common.d.ts +8 -0
  42. package/lib/cli/common.js +26 -0
  43. package/lib/cli/tool-args.d.ts +12 -0
  44. package/lib/cli/tool-args.js +53 -0
  45. package/lib/cli/tool-cli.d.ts +2 -0
  46. package/lib/cli/tool-cli.js +78 -0
  47. package/lib/methods/index.d.ts +3 -0
  48. package/lib/methods/index.js +19 -0
  49. package/lib/methods/mulmo_script.d.ts +11 -0
  50. package/lib/methods/mulmo_script.js +45 -0
  51. package/lib/methods/mulmo_script_template.d.ts +4 -0
  52. package/lib/methods/mulmo_script_template.js +22 -0
  53. package/lib/methods/mulmo_studio_context.d.ts +4 -0
  54. package/lib/methods/mulmo_studio_context.js +12 -0
  55. package/lib/tools/dump_prompt.d.ts +3 -0
  56. package/lib/tools/dump_prompt.js +9 -0
  57. package/lib/tools/prompt.d.ts +1 -0
  58. package/lib/tools/prompt.js +20 -0
  59. package/lib/tools/seed.d.ts +3 -0
  60. package/lib/tools/seed.js +201 -0
  61. package/lib/tools/seed_from_url.d.ts +3 -0
  62. package/lib/tools/seed_from_url.js +178 -0
  63. package/lib/types/index.d.ts +1 -0
  64. package/lib/types/index.js +17 -0
  65. package/lib/types/schema.d.ts +5817 -0
  66. package/lib/types/schema.js +207 -0
  67. package/lib/types/type.d.ts +33 -0
  68. package/lib/types/type.js +2 -0
  69. package/lib/utils/const.d.ts +3 -0
  70. package/lib/utils/const.js +6 -0
  71. package/lib/utils/file.d.ts +28 -0
  72. package/lib/utils/file.js +112 -0
  73. package/lib/utils/filters.d.ts +3 -0
  74. package/lib/utils/filters.js +32 -0
  75. package/lib/utils/markdown.d.ts +1 -0
  76. package/lib/utils/markdown.js +27 -0
  77. package/lib/utils/preprocess.d.ts +247 -0
  78. package/lib/utils/preprocess.js +53 -0
  79. package/lib/utils/string.d.ts +9 -0
  80. package/lib/utils/string.js +60 -0
  81. package/lib/utils/text_hash.d.ts +1 -0
  82. package/lib/utils/text_hash.js +41 -0
  83. package/package.json +77 -0
@@ -0,0 +1,207 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.urlsSchema = exports.mulmoScriptTemplateSchema = exports.mulmoStudioSchema = exports.mulmoStudioBeatSchema = exports.mulmoScriptSchema = exports.mulmoSpeechParamsSchema = exports.mulmoCastCreditSchema = exports.mulmoDimensionSchema = exports.mulmoBeatSchema = exports.videoParamsSchema = exports.textSlideParamsSchema = exports.mulmoImageParamsSchema = exports.mulmoAudioAssetSchema = exports.mulmoMediaSchema = exports.speakerDictionarySchema = exports.speechOptionsSchema = exports.multiLingualTextsSchema = exports.localizedTextSchema = exports.langSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.langSchema = zod_1.z.string();
6
+ const URLStringSchema = zod_1.z.string().url();
7
+ exports.localizedTextSchema = zod_1.z
8
+ .object({
9
+ text: zod_1.z.string(),
10
+ lang: zod_1.z.string(),
11
+ // caption: z.string(),
12
+ texts: zod_1.z.array(zod_1.z.string()).optional(),
13
+ ttsTexts: zod_1.z.array(zod_1.z.string()).optional(),
14
+ duration: zod_1.z.number().optional(), // generated // video duration time(ms)
15
+ // filename: z.string().optional(), // generated //
16
+ })
17
+ .strict();
18
+ exports.multiLingualTextsSchema = zod_1.z.record(exports.langSchema, exports.localizedTextSchema);
19
+ exports.speechOptionsSchema = zod_1.z
20
+ .object({
21
+ speed: zod_1.z.number().optional(), // default: 1.0
22
+ instruction: zod_1.z.string().optional(),
23
+ })
24
+ .strict();
25
+ const speakerIdSchema = zod_1.z.string();
26
+ const speakerDataSchema = zod_1.z
27
+ .object({
28
+ displayName: zod_1.z.record(exports.langSchema, zod_1.z.string()),
29
+ voiceId: zod_1.z.string(),
30
+ speechOptions: exports.speechOptionsSchema.optional(),
31
+ })
32
+ .strict();
33
+ exports.speakerDictionarySchema = zod_1.z.record(speakerIdSchema, speakerDataSchema);
34
+ const mediaSourceSchema = zod_1.z.discriminatedUnion("kind", [
35
+ zod_1.z.object({ kind: zod_1.z.literal("url"), url: URLStringSchema }).strict(), // https://example.com/foo.pdf
36
+ zod_1.z.object({ kind: zod_1.z.literal("data"), data: zod_1.z.string() }).strict(), // base64
37
+ zod_1.z.object({ kind: zod_1.z.literal("path"), path: zod_1.z.string() }).strict(), // foo.pdf
38
+ ]);
39
+ // String is easier for AI, string array is easier for human
40
+ const stringOrStringArray = zod_1.z.union([zod_1.z.string(), zod_1.z.array(zod_1.z.string())]);
41
+ const MulmoMarkdownMediaSchema = zod_1.z
42
+ .object({
43
+ type: zod_1.z.literal("markdown"),
44
+ markdown: stringOrStringArray,
45
+ })
46
+ .strict();
47
+ const MulmoWebMediaSchema = zod_1.z
48
+ .object({
49
+ type: zod_1.z.literal("web"),
50
+ url: URLStringSchema,
51
+ })
52
+ .strict();
53
+ const MulmoPdfMediaSchema = zod_1.z
54
+ .object({
55
+ type: zod_1.z.literal("pdf"),
56
+ source: mediaSourceSchema,
57
+ })
58
+ .strict();
59
+ const MulmoImageMediaSchema = zod_1.z
60
+ .object({
61
+ type: zod_1.z.literal("image"),
62
+ source: mediaSourceSchema,
63
+ })
64
+ .strict();
65
+ const MulmoSvgMediaSchema = zod_1.z
66
+ .object({
67
+ type: zod_1.z.literal("svg"),
68
+ source: mediaSourceSchema,
69
+ })
70
+ .strict();
71
+ const MulmoMovieMediaSchema = zod_1.z
72
+ .object({
73
+ type: zod_1.z.literal("movie"),
74
+ source: mediaSourceSchema,
75
+ })
76
+ .strict();
77
+ const MulmoTextSlideMediaSchema = zod_1.z
78
+ .object({
79
+ type: zod_1.z.literal("textSlide"),
80
+ slide: zod_1.z.object({
81
+ title: zod_1.z.string(),
82
+ bullets: zod_1.z.array(zod_1.z.string()),
83
+ }),
84
+ })
85
+ .strict();
86
+ exports.mulmoMediaSchema = zod_1.z.union([
87
+ MulmoMarkdownMediaSchema,
88
+ MulmoWebMediaSchema,
89
+ MulmoPdfMediaSchema,
90
+ MulmoImageMediaSchema,
91
+ MulmoSvgMediaSchema,
92
+ MulmoMovieMediaSchema,
93
+ MulmoTextSlideMediaSchema,
94
+ ]);
95
+ const MulmoAudioMediaSchema = zod_1.z
96
+ .object({
97
+ type: zod_1.z.literal("audio"),
98
+ source: mediaSourceSchema,
99
+ })
100
+ .strict();
101
+ const MulmoMidiMediaSchema = zod_1.z
102
+ .object({
103
+ type: zod_1.z.literal("midi"),
104
+ source: zod_1.z.string(), // TODO: define it later
105
+ })
106
+ .strict();
107
+ exports.mulmoAudioAssetSchema = zod_1.z.union([MulmoAudioMediaSchema, MulmoMidiMediaSchema]);
108
+ exports.mulmoImageParamsSchema = zod_1.z
109
+ .object({
110
+ model: zod_1.z.string().optional(), // default: provider specific
111
+ size: zod_1.z.string().optional(), // default: provider specific
112
+ style: zod_1.z.string().optional(), // optional image style
113
+ moderation: zod_1.z.string().optional(), // optional image style
114
+ })
115
+ .strict();
116
+ exports.textSlideParamsSchema = zod_1.z
117
+ .object({
118
+ cssStyles: zod_1.z.array(zod_1.z.string()),
119
+ })
120
+ .strict();
121
+ exports.videoParamsSchema = zod_1.z
122
+ .object({
123
+ padding: zod_1.z.number().optional(), // msec
124
+ })
125
+ .strict();
126
+ exports.mulmoBeatSchema = zod_1.z
127
+ .object({
128
+ speaker: speakerIdSchema,
129
+ text: zod_1.z.string(),
130
+ image: exports.mulmoMediaSchema.optional(),
131
+ audio: exports.mulmoAudioAssetSchema.optional(),
132
+ imageParams: exports.mulmoImageParamsSchema.optional(), // beat specific parameters
133
+ speechOptions: exports.speechOptionsSchema.optional(),
134
+ textSlideParams: exports.textSlideParamsSchema.optional(),
135
+ imagePrompt: zod_1.z.string().optional(), // specified or inserted by preprocessor
136
+ })
137
+ .strict();
138
+ exports.mulmoDimensionSchema = zod_1.z
139
+ .object({
140
+ width: zod_1.z.number(),
141
+ height: zod_1.z.number(),
142
+ })
143
+ .strict();
144
+ // export const voiceMapSchema = z.record(speakerIdSchema, z.string())
145
+ exports.mulmoCastCreditSchema = zod_1.z
146
+ .object({
147
+ version: zod_1.z.literal("1.0"),
148
+ credit: zod_1.z.literal("closing").optional(),
149
+ })
150
+ .strict();
151
+ exports.mulmoSpeechParamsSchema = zod_1.z
152
+ .object({
153
+ provider: zod_1.z.string().optional(),
154
+ speakers: exports.speakerDictionarySchema,
155
+ })
156
+ .strict();
157
+ exports.mulmoScriptSchema = zod_1.z
158
+ .object({
159
+ // global settings
160
+ $mulmocast: exports.mulmoCastCreditSchema,
161
+ title: zod_1.z.string(),
162
+ description: zod_1.z.string().optional(),
163
+ reference: zod_1.z.string().optional(),
164
+ lang: exports.langSchema.optional(), // default "en"
165
+ canvasSize: exports.mulmoDimensionSchema.optional(),
166
+ beats: zod_1.z.array(exports.mulmoBeatSchema),
167
+ speechParams: exports.mulmoSpeechParamsSchema,
168
+ imageParams: exports.mulmoImageParamsSchema
169
+ .extend({
170
+ provider: zod_1.z.string().optional(),
171
+ })
172
+ .optional(),
173
+ // for textSlides
174
+ textSlideParams: exports.textSlideParamsSchema.optional(),
175
+ videoParams: exports.videoParamsSchema.optional(),
176
+ // images: ImageInfo[] // generated
177
+ imagePath: zod_1.z.string().optional(), // for keynote images movie ??
178
+ omitCaptions: zod_1.z.boolean().optional(), // default is false
179
+ // for debugging
180
+ __test_invalid__: zod_1.z.boolean().optional(),
181
+ })
182
+ .strict();
183
+ exports.mulmoStudioBeatSchema = exports.mulmoBeatSchema
184
+ .extend({
185
+ multiLingualTexts: exports.multiLingualTextsSchema.optional(),
186
+ hash: zod_1.z.string().optional(),
187
+ duration: zod_1.z.number().optional(),
188
+ audioFile: zod_1.z.string().optional(),
189
+ imageFile: zod_1.z.string().optional(), // path to the image
190
+ })
191
+ .strict();
192
+ exports.mulmoStudioSchema = zod_1.z
193
+ .object({
194
+ script: exports.mulmoScriptSchema,
195
+ filename: zod_1.z.string(),
196
+ beats: zod_1.z.array(exports.mulmoStudioBeatSchema),
197
+ })
198
+ .strict();
199
+ exports.mulmoScriptTemplateSchema = zod_1.z
200
+ .object({
201
+ title: zod_1.z.string(),
202
+ description: zod_1.z.string(),
203
+ systemPrompt: zod_1.z.string(),
204
+ script: exports.mulmoScriptSchema.optional(),
205
+ })
206
+ .strict();
207
+ exports.urlsSchema = zod_1.z.array(zod_1.z.string().url({ message: "Invalid URL format" }));
@@ -0,0 +1,33 @@
1
+ import { langSchema, localizedTextSchema, mulmoBeatSchema, mulmoScriptSchema, mulmoStudioSchema, mulmoStudioBeatSchema, speakerDictionarySchema, mulmoImageParamsSchema, mulmoSpeechParamsSchema, textSlideParamsSchema, speechOptionsSchema, mulmoDimensionSchema, mulmoScriptTemplateSchema } from "./schema";
2
+ import { z } from "zod";
3
+ export type LANG = z.infer<typeof langSchema>;
4
+ export type MulmoBeat = z.infer<typeof mulmoBeatSchema>;
5
+ export type SpeakerDictonary = z.infer<typeof speakerDictionarySchema>;
6
+ export type MulmoSpeechParams = z.infer<typeof mulmoSpeechParamsSchema>;
7
+ export type SpeechOptions = z.infer<typeof speechOptionsSchema>;
8
+ export type MulmoImageParams = z.infer<typeof mulmoImageParamsSchema>;
9
+ export type TextSlideParams = z.infer<typeof textSlideParamsSchema>;
10
+ export type LocalizedText = z.infer<typeof localizedTextSchema>;
11
+ export type MulmoScript = z.infer<typeof mulmoScriptSchema>;
12
+ export type MulmoDimension = z.infer<typeof mulmoDimensionSchema>;
13
+ export type MulmoStudioBeat = z.infer<typeof mulmoStudioBeatSchema>;
14
+ export type MulmoStudio = z.infer<typeof mulmoStudioSchema>;
15
+ export type MulmoScriptTemplate = z.infer<typeof mulmoScriptTemplateSchema>;
16
+ export type FileDirs = {
17
+ mulmoFilePath: string;
18
+ mulmoFileDirPath: string;
19
+ baseDirPath: string;
20
+ outDirPath: string;
21
+ imageDirPath: string;
22
+ scratchpadDirPath: string;
23
+ };
24
+ export type MulmoStudioContext = {
25
+ fileDirs: FileDirs;
26
+ studio: MulmoStudio;
27
+ };
28
+ export type ScriptingParams = {
29
+ urls: string[];
30
+ outDirPath: string;
31
+ templateName: string;
32
+ filename: string;
33
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ export declare const outDirName = "output";
2
+ export declare const scratchpadDirName = "scratchpad";
3
+ export declare const imageDirName = "images";
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.imageDirName = exports.scratchpadDirName = exports.outDirName = void 0;
4
+ exports.outDirName = "output";
5
+ exports.scratchpadDirName = "scratchpad";
6
+ exports.imageDirName = "images";
@@ -0,0 +1,28 @@
1
+ import { MulmoScript, MulmoScriptTemplate } from "../types";
2
+ export declare function readMulmoScriptFile<T = MulmoScript>(path: string, errorMessage: string): {
3
+ mulmoData: T;
4
+ mulmoDataPath: string;
5
+ fileName: string;
6
+ };
7
+ export declare function readMulmoScriptFile<T = MulmoScript>(path: string): {
8
+ mulmoData: T;
9
+ mulmoDataPath: string;
10
+ fileName: string;
11
+ } | null;
12
+ export declare const getOutputStudioFilePath: (outDirPath: string, fileName: string) => string;
13
+ export declare const getOutputBGMFilePath: (outDirPath: string, fileName: string) => string;
14
+ export declare const getOutputVideoFilePath: (outDirPath: string, fileName: string) => string;
15
+ export declare const getOutputAudioFilePath: (outDirPath: string, fileName: string) => string;
16
+ export declare const getScratchpadFilePath: (scratchpadDirName: string, fileName: string) => string;
17
+ export declare const getTemplateFilePath: (templateName: string) => string;
18
+ export declare const mkdir: (dirPath: string) => void;
19
+ export declare const silentPath: string;
20
+ export declare const silentLastPath: string;
21
+ export declare const defaultBGMPath: string;
22
+ export declare const getBaseDirPath: (basedir?: string) => string;
23
+ export declare const getFullPath: (baseDirPath: string | undefined, file: string) => string;
24
+ export declare const readTemplatePrompt: (templateName: string) => string;
25
+ export declare const getAvailableTemplates: () => (MulmoScriptTemplate & {
26
+ filename: string;
27
+ })[];
28
+ export declare const writingMessage: (filePath: string) => void;
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.writingMessage = exports.getAvailableTemplates = exports.readTemplatePrompt = exports.getFullPath = exports.getBaseDirPath = exports.defaultBGMPath = exports.silentLastPath = exports.silentPath = exports.mkdir = exports.getTemplateFilePath = exports.getScratchpadFilePath = exports.getOutputAudioFilePath = exports.getOutputVideoFilePath = exports.getOutputBGMFilePath = exports.getOutputStudioFilePath = void 0;
7
+ exports.readMulmoScriptFile = readMulmoScriptFile;
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const graphai_1 = require("graphai");
11
+ const mulmo_script_template_1 = require("../methods/mulmo_script_template");
12
+ const schema_1 = require("../types/schema");
13
+ function readMulmoScriptFile(arg2, errorMessage) {
14
+ const scriptPath = path_1.default.resolve(arg2);
15
+ if (!fs_1.default.existsSync(scriptPath)) {
16
+ if (errorMessage) {
17
+ console.error(errorMessage);
18
+ process.exit(1);
19
+ }
20
+ return null;
21
+ }
22
+ const scriptData = fs_1.default.readFileSync(scriptPath, "utf-8");
23
+ const script = JSON.parse(scriptData);
24
+ const parsedPath = path_1.default.parse(scriptPath);
25
+ return {
26
+ mulmoData: script,
27
+ mulmoDataPath: scriptPath,
28
+ fileName: parsedPath.name,
29
+ };
30
+ }
31
+ const getOutputStudioFilePath = (outDirPath, fileName) => {
32
+ return path_1.default.resolve(outDirPath, fileName + "_studio.json");
33
+ };
34
+ exports.getOutputStudioFilePath = getOutputStudioFilePath;
35
+ const getOutputBGMFilePath = (outDirPath, fileName) => {
36
+ return path_1.default.resolve(outDirPath, fileName + "_bgm.mp3");
37
+ };
38
+ exports.getOutputBGMFilePath = getOutputBGMFilePath;
39
+ const getOutputVideoFilePath = (outDirPath, fileName) => {
40
+ return path_1.default.resolve(outDirPath, fileName + ".mp4");
41
+ };
42
+ exports.getOutputVideoFilePath = getOutputVideoFilePath;
43
+ const getOutputAudioFilePath = (outDirPath, fileName) => {
44
+ return path_1.default.resolve(outDirPath, fileName + ".mp3");
45
+ };
46
+ exports.getOutputAudioFilePath = getOutputAudioFilePath;
47
+ const getScratchpadFilePath = (scratchpadDirName, fileName) => {
48
+ return path_1.default.resolve(scratchpadDirName, fileName + ".mp3");
49
+ };
50
+ exports.getScratchpadFilePath = getScratchpadFilePath;
51
+ const getTemplateFilePath = (templateName) => {
52
+ return path_1.default.resolve(__dirname, "../../assets/templates/" + templateName + ".json");
53
+ };
54
+ exports.getTemplateFilePath = getTemplateFilePath;
55
+ const mkdir = (dirPath) => {
56
+ if (!fs_1.default.existsSync(dirPath)) {
57
+ console.info("mkdir: " + dirPath);
58
+ fs_1.default.mkdirSync(dirPath, { recursive: true });
59
+ }
60
+ };
61
+ exports.mkdir = mkdir;
62
+ exports.silentPath = path_1.default.resolve(__dirname, "../../assets/audio/silent300.mp3");
63
+ exports.silentLastPath = path_1.default.resolve(__dirname, "../../assets/audio/silent800.mp3");
64
+ exports.defaultBGMPath = path_1.default.resolve(__dirname, "../../assets/music/StarsBeyondEx.mp3");
65
+ // for cli
66
+ const getBaseDirPath = (basedir) => {
67
+ if (!basedir) {
68
+ return process.cwd();
69
+ }
70
+ if (path_1.default.isAbsolute(basedir)) {
71
+ return path_1.default.normalize(basedir);
72
+ }
73
+ return path_1.default.resolve(process.cwd(), basedir);
74
+ };
75
+ exports.getBaseDirPath = getBaseDirPath;
76
+ const getFullPath = (baseDirPath, file) => {
77
+ if (path_1.default.isAbsolute(file)) {
78
+ return path_1.default.normalize(file);
79
+ }
80
+ if (baseDirPath) {
81
+ return path_1.default.resolve(baseDirPath, file);
82
+ }
83
+ return path_1.default.resolve(file);
84
+ };
85
+ exports.getFullPath = getFullPath;
86
+ const readTemplatePrompt = (templateName) => {
87
+ const templatePath = (0, exports.getTemplateFilePath)(templateName);
88
+ const scriptData = fs_1.default.readFileSync(templatePath, "utf-8");
89
+ const template = schema_1.mulmoScriptTemplateSchema.parse(JSON.parse(scriptData));
90
+ const prompt = mulmo_script_template_1.MulmoScriptTemplateMethods.getSystemPrompt(template);
91
+ return prompt;
92
+ };
93
+ exports.readTemplatePrompt = readTemplatePrompt;
94
+ const getAvailableTemplates = () => {
95
+ const templatesDir = path_1.default.resolve(__dirname, "../../assets/templates");
96
+ if (!fs_1.default.existsSync(templatesDir)) {
97
+ return [];
98
+ }
99
+ const files = fs_1.default.readdirSync(templatesDir);
100
+ return files.map((file) => {
101
+ const template = JSON.parse(fs_1.default.readFileSync(path_1.default.resolve(templatesDir, file), "utf-8"));
102
+ return {
103
+ ...schema_1.mulmoScriptTemplateSchema.parse(template),
104
+ filename: file.replace(/\.json$/, ""),
105
+ };
106
+ });
107
+ };
108
+ exports.getAvailableTemplates = getAvailableTemplates;
109
+ const writingMessage = (filePath) => {
110
+ graphai_1.GraphAILogger.info(`writing: ${filePath}`);
111
+ };
112
+ exports.writingMessage = writingMessage;
@@ -0,0 +1,3 @@
1
+ import "dotenv/config";
2
+ import type { AgentFilterFunction } from "graphai";
3
+ export declare const fileCacheAgentFilter: AgentFilterFunction;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.fileCacheAgentFilter = void 0;
7
+ require("dotenv/config");
8
+ const promises_1 = __importDefault(require("fs/promises"));
9
+ const graphai_1 = require("graphai");
10
+ const file_1 = require("./file");
11
+ const fileCacheAgentFilter = async (context, next) => {
12
+ const { namedInputs } = context;
13
+ const { file, text } = namedInputs;
14
+ try {
15
+ await promises_1.default.access(file);
16
+ const elements = file.split("/");
17
+ graphai_1.GraphAILogger.info("cache hit: " + elements[elements.length - 1], text.slice(0, 10));
18
+ return true;
19
+ }
20
+ catch (__e) {
21
+ const output = (await next(context));
22
+ const buffer = output ? output["buffer"] : undefined;
23
+ if (buffer) {
24
+ (0, file_1.writingMessage)(file);
25
+ await promises_1.default.writeFile(file, buffer);
26
+ return true;
27
+ }
28
+ graphai_1.GraphAILogger.log("no cache, no buffer: " + file);
29
+ return false;
30
+ }
31
+ };
32
+ exports.fileCacheAgentFilter = fileCacheAgentFilter;
@@ -0,0 +1 @@
1
+ export declare const convertMarkdownToImage: (markdown: string, style: string, outputPath: string) => Promise<void>;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.convertMarkdownToImage = void 0;
7
+ const marked_1 = require("marked");
8
+ const puppeteer_1 = __importDefault(require("puppeteer"));
9
+ const convertMarkdownToImage = async (markdown, style, outputPath) => {
10
+ // Step 0: Prepare the header
11
+ const header = `<head><style>${style}</style></head>`;
12
+ // Step 1: Convert Markdown to HTML
13
+ const body = await (0, marked_1.marked)(markdown);
14
+ const html = `<htlm>${header}<body>${body}</body></html>`;
15
+ // Step 2: Use Puppeteer to render HTML to an image
16
+ const browser = await puppeteer_1.default.launch();
17
+ const page = await browser.newPage();
18
+ // Set the page content to the HTML generated from the Markdown
19
+ await page.setContent(html);
20
+ // Adjust page settings if needed (like width, height, etc.)
21
+ await page.setViewport({ width: 1200, height: 800 });
22
+ // Step 3: Capture screenshot of the page (which contains the Markdown-rendered HTML)
23
+ await page.screenshot({ path: outputPath });
24
+ await browser.close();
25
+ console.log(`Image saved to ${outputPath}`);
26
+ };
27
+ exports.convertMarkdownToImage = convertMarkdownToImage;