mulmocast 0.0.1 → 0.0.2

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 (79) hide show
  1. package/README.md +108 -12
  2. package/assets/html/chart.html +47 -0
  3. package/assets/html/mermaid.html +63 -0
  4. package/assets/templates/business.json +60 -6
  5. package/assets/templates/children_book.json +1 -3
  6. package/assets/templates/coding.json +103 -0
  7. package/lib/actions/audio.d.ts +1 -1
  8. package/lib/actions/audio.js +52 -81
  9. package/lib/actions/images.d.ts +1 -1
  10. package/lib/actions/images.js +48 -80
  11. package/lib/actions/movie.d.ts +1 -1
  12. package/lib/actions/movie.js +76 -76
  13. package/lib/actions/translate.d.ts +1 -1
  14. package/lib/actions/translate.js +16 -52
  15. package/lib/agents/add_bgm_agent.d.ts +1 -1
  16. package/lib/agents/add_bgm_agent.js +10 -14
  17. package/lib/agents/combine_audio_files_agent.d.ts +1 -1
  18. package/lib/agents/combine_audio_files_agent.js +40 -30
  19. package/lib/agents/image_google_agent.d.ts +1 -1
  20. package/lib/agents/image_google_agent.js +8 -11
  21. package/lib/agents/image_openai_agent.js +7 -14
  22. package/lib/agents/index.d.ts +8 -8
  23. package/lib/agents/index.js +13 -30
  24. package/lib/agents/mulmo_prompts_agent.d.ts +1 -1
  25. package/lib/agents/mulmo_prompts_agent.js +7 -11
  26. package/lib/agents/prompts_data.js +1 -4
  27. package/lib/agents/tts_nijivoice_agent.d.ts +1 -1
  28. package/lib/agents/tts_nijivoice_agent.js +8 -12
  29. package/lib/agents/tts_openai_agent.js +9 -16
  30. package/lib/agents/validate_mulmo_script_agent.d.ts +1 -1
  31. package/lib/agents/validate_mulmo_script_agent.js +6 -10
  32. package/lib/cli/args.d.ts +2 -1
  33. package/lib/cli/args.js +16 -14
  34. package/lib/cli/cli.js +64 -49
  35. package/lib/cli/common.js +1 -5
  36. package/lib/cli/tool-args.d.ts +2 -1
  37. package/lib/cli/tool-args.js +19 -18
  38. package/lib/cli/tool-cli.js +32 -51
  39. package/lib/methods/index.d.ts +3 -3
  40. package/lib/methods/index.js +3 -19
  41. package/lib/methods/mulmo_script.d.ts +10 -5
  42. package/lib/methods/mulmo_script.js +17 -11
  43. package/lib/methods/mulmo_script_template.d.ts +1 -1
  44. package/lib/methods/mulmo_script_template.js +4 -10
  45. package/lib/methods/mulmo_studio_context.d.ts +1 -1
  46. package/lib/methods/mulmo_studio_context.js +3 -9
  47. package/lib/tools/create_mulmo_script_from_url.d.ts +3 -0
  48. package/lib/tools/create_mulmo_script_from_url.js +152 -0
  49. package/lib/tools/create_mulmo_script_interactively.d.ts +3 -0
  50. package/lib/tools/create_mulmo_script_interactively.js +217 -0
  51. package/lib/tools/dump_prompt.js +5 -8
  52. package/lib/tools/prompt.js +9 -11
  53. package/lib/tools/seed_from_url2.d.ts +3 -0
  54. package/lib/tools/seed_from_url2.js +154 -0
  55. package/lib/types/index.d.ts +1 -1
  56. package/lib/types/index.js +1 -17
  57. package/lib/types/schema.d.ts +433 -71
  58. package/lib/types/schema.js +126 -111
  59. package/lib/types/type.d.ts +7 -3
  60. package/lib/types/type.js +1 -2
  61. package/lib/utils/const.d.ts +2 -1
  62. package/lib/utils/const.js +4 -6
  63. package/lib/utils/file.d.ts +19 -4
  64. package/lib/utils/file.js +78 -71
  65. package/lib/utils/filters.d.ts +1 -0
  66. package/lib/utils/filters.js +47 -26
  67. package/lib/utils/image_preprocess.d.ts +14 -0
  68. package/lib/utils/image_preprocess.js +52 -0
  69. package/lib/utils/inquirer.d.ts +2 -0
  70. package/lib/utils/inquirer.js +33 -0
  71. package/lib/utils/markdown.d.ts +3 -1
  72. package/lib/utils/markdown.js +17 -19
  73. package/lib/utils/plugins.d.ts +5 -0
  74. package/lib/utils/plugins.js +11 -0
  75. package/lib/utils/preprocess.d.ts +24 -7
  76. package/lib/utils/preprocess.js +8 -14
  77. package/lib/utils/string.js +4 -10
  78. package/lib/utils/text_hash.js +2 -39
  79. package/package.json +12 -6
@@ -1,16 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateMulmoScriptAgent = void 0;
4
- const schema_1 = require("../types/schema");
1
+ import { mulmoScriptSchema } from "../types/schema.js";
5
2
  /**
6
3
  * MulmoScript JSON validation agent
7
4
  * Validates if a JSON string conforms to the MulmoScript schema
8
5
  */
9
- const validateMulmoScriptAgent = async ({ namedInputs, }) => {
6
+ export const validateMulmoScriptAgent = async ({ namedInputs, }) => {
10
7
  const { text } = namedInputs;
11
8
  try {
12
9
  const jsonData = JSON.parse(text);
13
- const parsed = schema_1.mulmoScriptSchema.parse(jsonData);
10
+ const parsed = mulmoScriptSchema.parse(jsonData);
14
11
  return {
15
12
  isValid: true,
16
13
  data: parsed,
@@ -23,11 +20,10 @@ const validateMulmoScriptAgent = async ({ namedInputs, }) => {
23
20
  };
24
21
  }
25
22
  };
26
- exports.validateMulmoScriptAgent = validateMulmoScriptAgent;
27
23
  const validateMulmoScriptAgentInfo = {
28
24
  name: "validateMulmoScriptAgent",
29
- agent: exports.validateMulmoScriptAgent,
30
- mock: exports.validateMulmoScriptAgent,
25
+ agent: validateMulmoScriptAgent,
26
+ mock: validateMulmoScriptAgent,
31
27
  samples: [],
32
28
  description: "Validates if a JSON string conforms to the MulmoScript schema",
33
29
  category: ["validation"],
@@ -35,4 +31,4 @@ const validateMulmoScriptAgentInfo = {
35
31
  repository: "https://github.com/receptron/mulmocast-cli/tree/main/src/agents/validate_script_agent.ts",
36
32
  license: "MIT",
37
33
  };
38
- exports.default = validateMulmoScriptAgentInfo;
34
+ export default validateMulmoScriptAgentInfo;
package/lib/cli/args.d.ts CHANGED
@@ -3,8 +3,9 @@ export declare const args: {
3
3
  v: boolean;
4
4
  o: string | undefined;
5
5
  b: string | undefined;
6
- s: string | undefined;
6
+ a: string | undefined;
7
7
  i: string | undefined;
8
+ f: boolean;
8
9
  _: (string | number)[];
9
10
  $0: string;
10
11
  };
package/lib/cli/args.js CHANGED
@@ -1,17 +1,11 @@
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.args = void 0;
7
- const yargs_1 = __importDefault(require("yargs"));
8
- const helpers_1 = require("yargs/helpers");
9
- const common_1 = require("./common");
10
- exports.args = (0, common_1.commonOptions)((0, yargs_1.default)((0, helpers_1.hideBin)(process.argv)))
11
- .scriptName("mulmocast")
12
- .option("s", {
13
- alias: "scratchpaddir",
14
- description: "scratchpad dir",
1
+ import yargs from "yargs";
2
+ import { hideBin } from "yargs/helpers";
3
+ import { commonOptions } from "./common.js";
4
+ export const args = commonOptions(yargs(hideBin(process.argv)))
5
+ .scriptName("mulmo")
6
+ .option("a", {
7
+ alias: "audiodir",
8
+ description: "audio dir",
15
9
  demandOption: false,
16
10
  type: "string",
17
11
  })
@@ -20,6 +14,13 @@ exports.args = (0, common_1.commonOptions)((0, yargs_1.default)((0, helpers_1.hi
20
14
  description: "image dir",
21
15
  demandOption: false,
22
16
  type: "string",
17
+ })
18
+ .option("f", {
19
+ alias: "force",
20
+ description: "force generate",
21
+ demandOption: false,
22
+ default: false,
23
+ type: "boolean",
23
24
  })
24
25
  .command("$0 <action> <file>", "Run mulmocast", (yargs) => {
25
26
  return yargs
@@ -35,4 +36,5 @@ exports.args = (0, common_1.commonOptions)((0, yargs_1.default)((0, helpers_1.hi
35
36
  })
36
37
  .strict()
37
38
  .help()
39
+ .alias("help", "h")
38
40
  .parseSync();
package/lib/cli/cli.js CHANGED
@@ -1,78 +1,93 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ import "dotenv/config";
3
+ import fs from "fs";
4
+ import path from "path";
5
+ import { GraphAILogger } from "graphai";
6
+ import { args } from "./args.js";
7
+ import { createOrUpdateStudioData } from "../utils/preprocess.js";
8
+ import { outDirName, imageDirName, audioDirName } from "../utils/const.js";
9
+ import { MulmoScriptMethods } from "../methods/index.js";
10
+ import { translate } from "../actions/translate.js";
11
+ import { images } from "../actions/images.js";
12
+ import { audio } from "../actions/audio.js";
13
+ import { movie } from "../actions/movie.js";
14
+ import { getBaseDirPath, getFullPath, readMulmoScriptFile, fetchMulmoScriptFile } from "../utils/file.js";
15
+ import { mulmoScriptSchema } from "../types/schema.js";
16
+ const isHttp = (fileOrUrl) => {
17
+ return /^https?:\/\//.test(fileOrUrl);
5
18
  };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- require("dotenv/config");
8
- const fs_1 = __importDefault(require("fs"));
9
- const path_1 = __importDefault(require("path"));
10
- const graphai_1 = require("graphai");
11
- const args_1 = require("./args");
12
- const preprocess_1 = require("../utils/preprocess");
13
- const const_1 = require("../utils/const");
14
- const methods_1 = require("../methods");
15
- const translate_1 = require("../actions/translate");
16
- const images_1 = require("../actions/images");
17
- const audio_1 = require("../actions/audio");
18
- const movie_1 = require("../actions/movie");
19
- const file_1 = require("../utils/file");
20
- const schema_1 = require("../types/schema");
21
19
  const getFileObject = () => {
22
- const { basedir, file, outdir, imagedir, scratchpaddir } = args_1.args;
23
- const baseDirPath = (0, file_1.getBaseDirPath)(basedir);
24
- const mulmoFilePath = (0, file_1.getFullPath)(baseDirPath, file ?? "");
25
- const mulmoFileDirPath = path_1.default.dirname(mulmoFilePath);
26
- const outDirPath = (0, file_1.getFullPath)(baseDirPath, outdir ?? const_1.outDirName);
27
- const imageDirPath = (0, file_1.getFullPath)(baseDirPath, imagedir ?? const_1.imageDirName);
28
- const scratchpadDirPath = (0, file_1.getFullPath)(baseDirPath, scratchpaddir ?? const_1.scratchpadDirName);
29
- return { baseDirPath, mulmoFilePath, mulmoFileDirPath, outDirPath, imageDirPath, scratchpadDirPath };
20
+ const { basedir, file, outdir, imagedir, audiodir } = args;
21
+ const baseDirPath = getBaseDirPath(basedir);
22
+ const fileOrUrl = file ?? "";
23
+ const isHttpPath = isHttp(fileOrUrl);
24
+ const mulmoFilePath = isHttpPath ? "" : getFullPath(baseDirPath, fileOrUrl);
25
+ const mulmoFileDirPath = path.dirname(isHttpPath ? baseDirPath : mulmoFilePath);
26
+ const outDirPath = getFullPath(baseDirPath, outdir ?? outDirName);
27
+ const imageDirPath = getFullPath(outDirPath, imagedir ?? imageDirName);
28
+ const audioDirPath = getFullPath(outDirPath, audiodir ?? audioDirName);
29
+ return { baseDirPath, mulmoFilePath, mulmoFileDirPath, outDirPath, imageDirPath, audioDirPath, isHttpPath, fileOrUrl };
30
30
  };
31
31
  const main = async () => {
32
32
  const files = getFileObject();
33
- const { mulmoFilePath } = files;
34
- if (args_1.args.v) {
35
- console.log(files);
33
+ const { mulmoFilePath, isHttpPath, fileOrUrl } = files;
34
+ if (args.v) {
35
+ GraphAILogger.info(files);
36
36
  }
37
37
  else {
38
- graphai_1.GraphAILogger.setLevelEnabled("error", false);
39
- graphai_1.GraphAILogger.setLevelEnabled("log", false);
40
- graphai_1.GraphAILogger.setLevelEnabled("warn", false);
38
+ GraphAILogger.setLevelEnabled("error", false);
39
+ GraphAILogger.setLevelEnabled("log", false);
40
+ GraphAILogger.setLevelEnabled("warn", false);
41
41
  }
42
- if (!fs_1.default.existsSync(mulmoFilePath)) {
43
- console.error("File not exists");
44
- return -1;
45
- }
46
- // TODO some option process
47
- const { action } = args_1.args;
48
- const studio = (0, preprocess_1.createOrUpdateStudioData)(mulmoFilePath, files);
42
+ const { action, force } = args;
43
+ const readData = await (async () => {
44
+ if (isHttpPath) {
45
+ const res = await fetchMulmoScriptFile(fileOrUrl);
46
+ if (!res.result || !res.script) {
47
+ GraphAILogger.info(`ERROR: HTTP error! ${res.status} ${fileOrUrl}`);
48
+ process.exit(1);
49
+ }
50
+ return {
51
+ mulmoData: res.script,
52
+ fileName: path.parse(fileOrUrl).name,
53
+ };
54
+ }
55
+ if (!fs.existsSync(mulmoFilePath)) {
56
+ GraphAILogger.info("ERROR: File not exists " + mulmoFilePath);
57
+ process.exit(1);
58
+ }
59
+ return readMulmoScriptFile(mulmoFilePath, "ERROR: File does not exist " + mulmoFilePath);
60
+ })();
61
+ const { mulmoData: mulmoScript, fileName } = readData;
49
62
  // validate mulmoStudioSchema. skip if __test_invalid__ is true
50
63
  try {
51
- if (!studio.script?.__test_invalid__) {
52
- schema_1.mulmoStudioSchema.parse(studio);
64
+ if (!mulmoScript?.__test_invalid__) {
65
+ mulmoScriptSchema.parse(mulmoScript);
53
66
  }
54
67
  }
55
68
  catch (error) {
56
- console.error(`Error: invalid MulmoScript Schema: ${mulmoFilePath} \n ${error}`);
57
- return -1;
69
+ GraphAILogger.info(`Error: invalid MulmoScript Schema: ${isHttpPath ? fileOrUrl : mulmoFilePath} \n ${error}`);
70
+ process.exit(1);
58
71
  }
72
+ const studio = createOrUpdateStudioData(mulmoScript, fileName, files);
59
73
  const context = {
60
74
  studio,
61
75
  fileDirs: files,
76
+ force: Boolean(force),
62
77
  };
63
78
  if (action === "translate") {
64
- await (0, translate_1.translate)(context);
79
+ await translate(context);
65
80
  }
66
81
  if (action === "audio") {
67
- await (0, audio_1.audio)(context, methods_1.MulmoScriptMethods.getSpeechProvider(studio.script) === "nijivoice" ? 1 : 8);
82
+ await audio(context, MulmoScriptMethods.getSpeechProvider(studio.script) === "nijivoice" ? 1 : 8);
68
83
  }
69
84
  if (action === "images") {
70
- await (0, images_1.images)(context);
85
+ await images(context);
71
86
  }
72
87
  if (action === "movie") {
73
- await (0, audio_1.audio)(context, methods_1.MulmoScriptMethods.getSpeechProvider(studio.script) === "nijivoice" ? 1 : 8);
74
- await (0, images_1.images)(context);
75
- await (0, movie_1.movie)(context);
88
+ await audio(context, MulmoScriptMethods.getSpeechProvider(studio.script) === "nijivoice" ? 1 : 8);
89
+ await images(context);
90
+ await movie(context);
76
91
  }
77
92
  };
78
93
  main();
package/lib/cli/common.js CHANGED
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.commonOptions = void 0;
4
- const commonOptions = (yargs) => {
1
+ export const commonOptions = (yargs) => {
5
2
  return yargs
6
3
  .option("v", {
7
4
  alias: "verbose",
@@ -23,4 +20,3 @@ const commonOptions = (yargs) => {
23
20
  type: "string",
24
21
  });
25
22
  };
26
- exports.commonOptions = commonOptions;
@@ -6,7 +6,8 @@ export declare const args: {
6
6
  u: string[] | never[];
7
7
  i: boolean | undefined;
8
8
  t: string | undefined;
9
- f: string;
9
+ c: string | undefined;
10
+ s: string;
10
11
  _: (string | number)[];
11
12
  $0: string;
12
13
  };
@@ -1,18 +1,12 @@
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.args = void 0;
7
- const yargs_1 = __importDefault(require("yargs"));
8
- const helpers_1 = require("yargs/helpers");
9
- const common_1 = require("./common");
10
- const graphai_1 = require("graphai");
11
- const file_1 = require("../utils/file");
12
- graphai_1.GraphAILogger.setLevelEnabled("error", false);
13
- const availableTemplateNames = (0, file_1.getAvailableTemplates)().map((template) => template.filename);
14
- exports.args = (0, common_1.commonOptions)((0, yargs_1.default)((0, helpers_1.hideBin)(process.argv)))
15
- .scriptName("mulmocast-tool")
1
+ import yargs from "yargs";
2
+ import { hideBin } from "yargs/helpers";
3
+ import { commonOptions } from "./common.js";
4
+ import { GraphAILogger } from "graphai";
5
+ import { getAvailableTemplates } from "../utils/file.js";
6
+ GraphAILogger.setLevelEnabled("error", false);
7
+ const availableTemplateNames = getAvailableTemplates().map((template) => template.filename);
8
+ export const args = commonOptions(yargs(hideBin(process.argv)))
9
+ .scriptName("mulmo-tool")
16
10
  .option("u", {
17
11
  alias: "url",
18
12
  description: "URLs to reference (required when not in interactive mode)",
@@ -34,9 +28,15 @@ exports.args = (0, common_1.commonOptions)((0, yargs_1.default)((0, helpers_1.hi
34
28
  choices: availableTemplateNames,
35
29
  type: "string",
36
30
  })
37
- .option("f", {
38
- alias: "filename",
39
- description: "output filename",
31
+ .option("c", {
32
+ alias: "cache",
33
+ description: "cache dir",
34
+ demandOption: false,
35
+ type: "string",
36
+ })
37
+ .option("s", {
38
+ alias: "script",
39
+ description: "script filename",
40
40
  demandOption: false,
41
41
  default: "script",
42
42
  type: "string",
@@ -50,4 +50,5 @@ exports.args = (0, common_1.commonOptions)((0, yargs_1.default)((0, helpers_1.hi
50
50
  })
51
51
  .strict()
52
52
  .help()
53
+ .alias("help", "h")
53
54
  .parseSync();
@@ -1,78 +1,59 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- require("dotenv/config");
8
- const graphai_1 = require("graphai");
9
- const inquirer_1 = __importDefault(require("inquirer"));
10
- const tool_args_1 = require("./tool-args");
11
- const const_1 = require("../utils/const");
12
- const seed_from_url_1 = require("../tools/seed_from_url");
13
- const file_1 = require("../utils/file");
14
- const seed_1 = require("../tools/seed");
15
- const dump_prompt_1 = require("../tools/dump_prompt");
16
- const selectTemplate = async () => {
17
- const availableTemplates = (0, file_1.getAvailableTemplates)();
18
- const answers = await inquirer_1.default.prompt([
19
- {
20
- type: "list",
21
- name: "templateName",
22
- message: "Select a template to use",
23
- choices: availableTemplates.map((t) => ({
24
- name: `${t.filename} - ${t.description}`,
25
- value: t.filename,
26
- })),
27
- },
28
- ]);
29
- return answers.templateName;
30
- };
2
+ import "dotenv/config";
3
+ import { GraphAILogger } from "graphai";
4
+ import { args } from "./tool-args.js";
5
+ import { outDirName, cacheDirName } from "../utils/const.js";
6
+ import { createMulmoScriptFromUrl } from "../tools/create_mulmo_script_from_url.js";
7
+ import { getBaseDirPath, getFullPath } from "../utils/file.js";
8
+ import { createMulmoScriptInteractively } from "../tools/create_mulmo_script_interactively.js";
9
+ import { dumpPromptFromTemplate } from "../tools/dump_prompt.js";
10
+ import { getUrlsIfNeeded, selectTemplate } from "../utils/inquirer.js";
31
11
  const main = async () => {
32
- const { o: outdir, u: urls, b: basedir, action, v: verbose, i: interactive, f: filename } = tool_args_1.args;
33
- let { t: template } = tool_args_1.args;
34
- const baseDirPath = (0, file_1.getBaseDirPath)(basedir);
35
- const outDirPath = (0, file_1.getFullPath)(baseDirPath, outdir ?? const_1.outDirName);
12
+ const { o: outdir, b: basedir, action, v: verbose, i: interactive, s: filename, cache } = args;
13
+ let { t: template } = args;
14
+ let { u: urls } = args;
15
+ const baseDirPath = getBaseDirPath(basedir);
16
+ const outDirPath = getFullPath(baseDirPath, outdir ?? outDirName);
17
+ const cacheDirPath = getFullPath(outDirPath, cache ?? cacheDirName);
36
18
  if (verbose) {
37
- console.log("baseDirPath:", baseDirPath);
38
- console.log("outDirPath:", outDirPath);
39
- console.log("template:", template);
40
- console.log("urls:", urls);
41
- console.log("action:", action);
42
- console.log("interactive:", interactive);
43
- console.log("filename:", filename);
19
+ GraphAILogger.info("baseDirPath:", baseDirPath);
20
+ GraphAILogger.info("outDirPath:", outDirPath);
21
+ GraphAILogger.info("cacheDirPath:", cacheDirPath);
22
+ GraphAILogger.info("template:", template);
23
+ GraphAILogger.info("urls:", urls);
24
+ GraphAILogger.info("action:", action);
25
+ GraphAILogger.info("interactive:", interactive);
26
+ GraphAILogger.info("filename:", filename);
44
27
  }
45
28
  else {
46
- graphai_1.GraphAILogger.setLevelEnabled("error", false);
47
- graphai_1.GraphAILogger.setLevelEnabled("log", false);
48
- graphai_1.GraphAILogger.setLevelEnabled("warn", false);
29
+ GraphAILogger.setLevelEnabled("error", false);
30
+ GraphAILogger.setLevelEnabled("log", false);
31
+ GraphAILogger.setLevelEnabled("warn", false);
49
32
  }
50
33
  // If template is not specified, show the selection prompt
51
34
  if (!template) {
52
35
  template = await selectTemplate();
53
36
  if (verbose) {
54
- console.log("Selected template:", template);
37
+ GraphAILogger.info("Selected template:", template);
55
38
  }
56
39
  }
57
40
  if (action === "scripting") {
58
41
  if (interactive) {
59
- await (0, seed_1.createMulmoScriptWithInteractive)({ outDirPath, templateName: template, urls: urls, filename });
60
- }
61
- else if (urls.length > 0) {
62
- await (0, seed_from_url_1.createMulmoScriptFromUrl)({ urls, templateName: template, outDirPath, filename });
42
+ await createMulmoScriptInteractively({ outDirPath, templateName: template, urls, filename, cacheDirPath });
63
43
  }
64
44
  else {
65
- throw new Error("urls is required when not in interactive mode");
45
+ urls = await getUrlsIfNeeded(urls);
46
+ await createMulmoScriptFromUrl({ urls, templateName: template, outDirPath, filename, cacheDirPath });
66
47
  }
67
48
  }
68
49
  else if (action === "prompt") {
69
- await (0, dump_prompt_1.dumpPromptFromTemplate)({ templateName: template });
50
+ await dumpPromptFromTemplate({ templateName: template });
70
51
  }
71
52
  else {
72
53
  throw new Error(`Unknown or unsupported action: ${action}`);
73
54
  }
74
55
  };
75
56
  main().catch((error) => {
76
- console.error("An unexpected error occurred:", error);
57
+ GraphAILogger.info("An unexpected error occurred:", error);
77
58
  process.exit(1);
78
59
  });
@@ -1,3 +1,3 @@
1
- export * from "./mulmo_script";
2
- export * from "./mulmo_script_template";
3
- export * from "./mulmo_studio_context";
1
+ export * from "./mulmo_script.js";
2
+ export * from "./mulmo_script_template.js";
3
+ export * from "./mulmo_studio_context.js";
@@ -1,19 +1,3 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./mulmo_script"), exports);
18
- __exportStar(require("./mulmo_script_template"), exports);
19
- __exportStar(require("./mulmo_studio_context"), exports);
1
+ export * from "./mulmo_script.js";
2
+ export * from "./mulmo_script_template.js";
3
+ export * from "./mulmo_studio_context.js";
@@ -1,11 +1,16 @@
1
- import { MulmoDimension, MulmoScript, MulmoBeat, SpeechOptions } from "../types";
1
+ import "dotenv/config";
2
+ import { MulmoCanvasDimension, MulmoScript, MulmoBeat, SpeechOptions, Text2ImageProvider, MulmoImageParams, Text2SpeechProvider } from "../types/index.js";
3
+ export type Text2ImageAgentInfo = {
4
+ provider: Text2ImageProvider;
5
+ agent: string;
6
+ imageParams: MulmoImageParams;
7
+ };
2
8
  export declare const MulmoScriptMethods: {
3
9
  getPadding(script: MulmoScript): number;
4
- getCanvasSize(script: MulmoScript): MulmoDimension;
10
+ getCanvasSize(script: MulmoScript): MulmoCanvasDimension;
5
11
  getAspectRatio(script: MulmoScript): string;
6
- getSpeechProvider(script: MulmoScript): string;
7
- getImageProvider(script: MulmoScript): string;
12
+ getSpeechProvider(script: MulmoScript): Text2SpeechProvider;
8
13
  getTextSlideStyle(script: MulmoScript, beat: MulmoBeat): string;
9
14
  getSpeechOptions(script: MulmoScript, beat: MulmoBeat): SpeechOptions | undefined;
10
- getText2imageAgent(script: MulmoScript): string;
15
+ getImageAgentInfo(script: MulmoScript): Text2ImageAgentInfo;
11
16
  };
@@ -1,6 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MulmoScriptMethods = void 0;
1
+ import "dotenv/config";
2
+ import { text2ImageProviderSchema, text2SpeechProviderSchema, mulmoCanvasDimensionSchema } from "../types/schema.js";
4
3
  const defaultTextSlideStyles = [
5
4
  "body { margin: 40px; margin-top: 60px; color:#333; font-size: 48px }",
6
5
  "h1 { font-size: 60px; text-align: center }",
@@ -12,12 +11,12 @@ const defaultTextSlideStyles = [
12
11
  "td, th { padding: 8px }",
13
12
  "tr:nth-child(even) { background-color: #eee }",
14
13
  ];
15
- exports.MulmoScriptMethods = {
14
+ export const MulmoScriptMethods = {
16
15
  getPadding(script) {
17
16
  return script.videoParams?.padding ?? 1000; // msec
18
17
  },
19
18
  getCanvasSize(script) {
20
- return script.canvasSize ?? { width: 1280, height: 720 };
19
+ return mulmoCanvasDimensionSchema.parse(script.canvasSize);
21
20
  },
22
21
  getAspectRatio(script) {
23
22
  // Google's text2image specific parameter
@@ -25,10 +24,7 @@ exports.MulmoScriptMethods = {
25
24
  return size.width > size.height ? "16:9" : "9:16";
26
25
  },
27
26
  getSpeechProvider(script) {
28
- return script.speechParams?.provider ?? "openai";
29
- },
30
- getImageProvider(script) {
31
- return script.imageParams?.provider ?? "openai";
27
+ return text2SpeechProviderSchema.parse(script.speechParams?.provider);
32
28
  },
33
29
  getTextSlideStyle(script, beat) {
34
30
  const styles = script.textSlideParams?.cssStyles ?? defaultTextSlideStyles;
@@ -39,7 +35,17 @@ exports.MulmoScriptMethods = {
39
35
  getSpeechOptions(script, beat) {
40
36
  return { ...script.speechParams.speakers[beat.speaker].speechOptions, ...beat.speechOptions };
41
37
  },
42
- getText2imageAgent(script) {
43
- return this.getImageProvider(script) === "google" ? "imageGoogleAgent" : "imageOpenaiAgent";
38
+ getImageAgentInfo(script) {
39
+ // Notice that we copy imageParams from script and update
40
+ // provider and model appropriately.
41
+ const provider = text2ImageProviderSchema.parse(script.imageParams?.provider);
42
+ const defaultImageParams = {
43
+ model: provider === "openai" ? process.env.DEFAULT_OPENAI_IMAGE_MODEL : undefined,
44
+ };
45
+ return {
46
+ provider,
47
+ agent: provider === "google" ? "imageGoogleAgent" : "imageOpenaiAgent",
48
+ imageParams: { ...defaultImageParams, ...script.imageParams },
49
+ };
44
50
  },
45
51
  };
@@ -1,4 +1,4 @@
1
- import { MulmoScriptTemplate } from "../types";
1
+ import { MulmoScriptTemplate } from "../types/index.js";
2
2
  export declare const MulmoScriptTemplateMethods: {
3
3
  getSystemPrompt(template: MulmoScriptTemplate): string;
4
4
  };
@@ -1,19 +1,13 @@
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.MulmoScriptTemplateMethods = void 0;
7
- const zod_to_json_schema_1 = __importDefault(require("zod-to-json-schema"));
8
- const schema_1 = require("../types/schema");
9
- exports.MulmoScriptTemplateMethods = {
1
+ import { zodToJsonSchema } from "zod-to-json-schema";
2
+ import { mulmoScriptSchema } from "../types/schema.js";
3
+ export const MulmoScriptTemplateMethods = {
10
4
  getSystemPrompt(template) {
11
5
  // script is provided, use it as a script template
12
6
  if (template.script) {
13
7
  return `${template.systemPrompt}\n\`\`\`JSON\n${JSON.stringify(template.script)}\n\`\`\``;
14
8
  }
15
9
  // script is not provided, use the default schema
16
- const defaultSchema = (0, zod_to_json_schema_1.default)(schema_1.mulmoScriptSchema, {
10
+ const defaultSchema = zodToJsonSchema(mulmoScriptSchema, {
17
11
  strictUnions: true,
18
12
  });
19
13
  const specificOutputPrompt = `The output should follow the JSON schema specified below. Please provide your response as valid JSON within \`\`\`json code blocks for clarity.`;
@@ -1,4 +1,4 @@
1
- import { MulmoStudioContext } from "../types";
1
+ import { MulmoStudioContext } from "../types/index.js";
2
2
  export declare const MulmoStudioContextMethods: {
3
3
  resolveAssetPath(context: MulmoStudioContext, relativePath: string): string;
4
4
  };
@@ -1,12 +1,6 @@
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.MulmoStudioContextMethods = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- exports.MulmoStudioContextMethods = {
1
+ import path from "path";
2
+ export const MulmoStudioContextMethods = {
9
3
  resolveAssetPath(context, relativePath) {
10
- return path_1.default.resolve(context.fileDirs.mulmoFileDirPath, relativePath);
4
+ return path.resolve(context.fileDirs.mulmoFileDirPath, relativePath);
11
5
  },
12
6
  };
@@ -0,0 +1,3 @@
1
+ import "dotenv/config";
2
+ import { ScriptingParams } from "../types/index.js";
3
+ export declare const createMulmoScriptFromUrl: ({ urls, templateName, outDirPath, filename, cacheDirPath }: ScriptingParams) => Promise<void>;