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.
- package/README.md +108 -12
- package/assets/html/chart.html +47 -0
- package/assets/html/mermaid.html +63 -0
- package/assets/templates/business.json +60 -6
- package/assets/templates/children_book.json +1 -3
- package/assets/templates/coding.json +103 -0
- package/lib/actions/audio.d.ts +1 -1
- package/lib/actions/audio.js +52 -81
- package/lib/actions/images.d.ts +1 -1
- package/lib/actions/images.js +48 -80
- package/lib/actions/movie.d.ts +1 -1
- package/lib/actions/movie.js +76 -76
- package/lib/actions/translate.d.ts +1 -1
- package/lib/actions/translate.js +16 -52
- package/lib/agents/add_bgm_agent.d.ts +1 -1
- package/lib/agents/add_bgm_agent.js +10 -14
- package/lib/agents/combine_audio_files_agent.d.ts +1 -1
- package/lib/agents/combine_audio_files_agent.js +40 -30
- package/lib/agents/image_google_agent.d.ts +1 -1
- package/lib/agents/image_google_agent.js +8 -11
- package/lib/agents/image_openai_agent.js +7 -14
- package/lib/agents/index.d.ts +8 -8
- package/lib/agents/index.js +13 -30
- package/lib/agents/mulmo_prompts_agent.d.ts +1 -1
- package/lib/agents/mulmo_prompts_agent.js +7 -11
- package/lib/agents/prompts_data.js +1 -4
- package/lib/agents/tts_nijivoice_agent.d.ts +1 -1
- package/lib/agents/tts_nijivoice_agent.js +8 -12
- package/lib/agents/tts_openai_agent.js +9 -16
- package/lib/agents/validate_mulmo_script_agent.d.ts +1 -1
- package/lib/agents/validate_mulmo_script_agent.js +6 -10
- package/lib/cli/args.d.ts +2 -1
- package/lib/cli/args.js +16 -14
- package/lib/cli/cli.js +64 -49
- package/lib/cli/common.js +1 -5
- package/lib/cli/tool-args.d.ts +2 -1
- package/lib/cli/tool-args.js +19 -18
- package/lib/cli/tool-cli.js +32 -51
- package/lib/methods/index.d.ts +3 -3
- package/lib/methods/index.js +3 -19
- package/lib/methods/mulmo_script.d.ts +10 -5
- package/lib/methods/mulmo_script.js +17 -11
- package/lib/methods/mulmo_script_template.d.ts +1 -1
- package/lib/methods/mulmo_script_template.js +4 -10
- package/lib/methods/mulmo_studio_context.d.ts +1 -1
- package/lib/methods/mulmo_studio_context.js +3 -9
- package/lib/tools/create_mulmo_script_from_url.d.ts +3 -0
- package/lib/tools/create_mulmo_script_from_url.js +152 -0
- package/lib/tools/create_mulmo_script_interactively.d.ts +3 -0
- package/lib/tools/create_mulmo_script_interactively.js +217 -0
- package/lib/tools/dump_prompt.js +5 -8
- package/lib/tools/prompt.js +9 -11
- package/lib/tools/seed_from_url2.d.ts +3 -0
- package/lib/tools/seed_from_url2.js +154 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/types/index.js +1 -17
- package/lib/types/schema.d.ts +433 -71
- package/lib/types/schema.js +126 -111
- package/lib/types/type.d.ts +7 -3
- package/lib/types/type.js +1 -2
- package/lib/utils/const.d.ts +2 -1
- package/lib/utils/const.js +4 -6
- package/lib/utils/file.d.ts +19 -4
- package/lib/utils/file.js +78 -71
- package/lib/utils/filters.d.ts +1 -0
- package/lib/utils/filters.js +47 -26
- package/lib/utils/image_preprocess.d.ts +14 -0
- package/lib/utils/image_preprocess.js +52 -0
- package/lib/utils/inquirer.d.ts +2 -0
- package/lib/utils/inquirer.js +33 -0
- package/lib/utils/markdown.d.ts +3 -1
- package/lib/utils/markdown.js +17 -19
- package/lib/utils/plugins.d.ts +5 -0
- package/lib/utils/plugins.js +11 -0
- package/lib/utils/preprocess.d.ts +24 -7
- package/lib/utils/preprocess.js +8 -14
- package/lib/utils/string.js +4 -10
- package/lib/utils/text_hash.js +2 -39
- package/package.json +12 -6
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
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 =
|
|
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:
|
|
30
|
-
mock:
|
|
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
|
-
|
|
34
|
+
export default validateMulmoScriptAgentInfo;
|
package/lib/cli/args.d.ts
CHANGED
package/lib/cli/args.js
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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,
|
|
23
|
-
const baseDirPath =
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
|
|
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 (
|
|
35
|
-
|
|
33
|
+
const { mulmoFilePath, isHttpPath, fileOrUrl } = files;
|
|
34
|
+
if (args.v) {
|
|
35
|
+
GraphAILogger.info(files);
|
|
36
36
|
}
|
|
37
37
|
else {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
GraphAILogger.setLevelEnabled("error", false);
|
|
39
|
+
GraphAILogger.setLevelEnabled("log", false);
|
|
40
|
+
GraphAILogger.setLevelEnabled("warn", false);
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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 (!
|
|
52
|
-
|
|
64
|
+
if (!mulmoScript?.__test_invalid__) {
|
|
65
|
+
mulmoScriptSchema.parse(mulmoScript);
|
|
53
66
|
}
|
|
54
67
|
}
|
|
55
68
|
catch (error) {
|
|
56
|
-
|
|
57
|
-
|
|
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
|
|
79
|
+
await translate(context);
|
|
65
80
|
}
|
|
66
81
|
if (action === "audio") {
|
|
67
|
-
await
|
|
82
|
+
await audio(context, MulmoScriptMethods.getSpeechProvider(studio.script) === "nijivoice" ? 1 : 8);
|
|
68
83
|
}
|
|
69
84
|
if (action === "images") {
|
|
70
|
-
await
|
|
85
|
+
await images(context);
|
|
71
86
|
}
|
|
72
87
|
if (action === "movie") {
|
|
73
|
-
await
|
|
74
|
-
await
|
|
75
|
-
await
|
|
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
|
-
|
|
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;
|
package/lib/cli/tool-args.d.ts
CHANGED
package/lib/cli/tool-args.js
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
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("
|
|
38
|
-
alias: "
|
|
39
|
-
description: "
|
|
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();
|
package/lib/cli/tool-cli.js
CHANGED
|
@@ -1,78 +1,59 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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,
|
|
33
|
-
let { t: template } =
|
|
34
|
-
|
|
35
|
-
const
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
37
|
+
GraphAILogger.info("Selected template:", template);
|
|
55
38
|
}
|
|
56
39
|
}
|
|
57
40
|
if (action === "scripting") {
|
|
58
41
|
if (interactive) {
|
|
59
|
-
await (
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
57
|
+
GraphAILogger.info("An unexpected error occurred:", error);
|
|
77
58
|
process.exit(1);
|
|
78
59
|
});
|
package/lib/methods/index.d.ts
CHANGED
|
@@ -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";
|
package/lib/methods/index.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
|
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):
|
|
10
|
+
getCanvasSize(script: MulmoScript): MulmoCanvasDimension;
|
|
5
11
|
getAspectRatio(script: MulmoScript): string;
|
|
6
|
-
getSpeechProvider(script: MulmoScript):
|
|
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
|
-
|
|
15
|
+
getImageAgentInfo(script: MulmoScript): Text2ImageAgentInfo;
|
|
11
16
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
43
|
-
|
|
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,19 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 = (
|
|
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,12 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
|
4
|
+
return path.resolve(context.fileDirs.mulmoFileDirPath, relativePath);
|
|
11
5
|
},
|
|
12
6
|
};
|