mulmocast 0.0.18 → 0.0.20
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 +44 -36
- package/assets/templates/ghibli_image_only.json +28 -0
- package/lib/actions/audio.js +13 -11
- package/lib/actions/captions.js +2 -3
- package/lib/actions/images.d.ts +5 -0
- package/lib/actions/images.js +41 -17
- package/lib/actions/movie.js +17 -3
- package/lib/actions/translate.js +3 -3
- package/lib/agents/add_bgm_agent.js +2 -2
- package/lib/agents/combine_audio_files_agent.js +96 -53
- package/lib/agents/image_openai_agent.js +2 -1
- package/lib/agents/validate_schema_agent.d.ts +1 -1
- package/lib/agents/validate_schema_agent.js +3 -3
- package/lib/cli/helpers.js +6 -1
- package/lib/index.browser.d.ts +2 -0
- package/lib/index.browser.js +3 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/methods/mulmo_presentation_style.js +2 -1
- package/lib/types/schema.d.ts +197 -129
- package/lib/types/schema.js +9 -5
- package/lib/utils/const.d.ts +1 -0
- package/lib/utils/const.js +1 -0
- package/lib/utils/file.d.ts +1 -0
- package/lib/utils/file.js +4 -0
- package/lib/utils/image_plugins/beat.d.ts +1 -0
- package/lib/utils/image_plugins/beat.js +3 -0
- package/lib/utils/image_plugins/chart.d.ts +1 -0
- package/lib/utils/image_plugins/chart.js +2 -0
- package/lib/utils/image_plugins/html_tailwind.d.ts +1 -0
- package/lib/utils/image_plugins/html_tailwind.js +2 -0
- package/lib/utils/image_plugins/image.d.ts +1 -0
- package/lib/utils/image_plugins/image.js +1 -0
- package/lib/utils/image_plugins/index.d.ts +3 -3
- package/lib/utils/image_plugins/index.js +6 -3
- package/lib/utils/image_plugins/markdown.d.ts +1 -0
- package/lib/utils/image_plugins/markdown.js +2 -0
- package/lib/utils/image_plugins/mermaid.d.ts +1 -0
- package/lib/utils/image_plugins/mermaid.js +3 -1
- package/lib/utils/image_plugins/movie.d.ts +1 -0
- package/lib/utils/image_plugins/movie.js +1 -0
- package/lib/utils/image_plugins/source.js +1 -1
- package/lib/utils/image_plugins/text_slide.d.ts +1 -0
- package/lib/utils/image_plugins/text_slide.js +2 -0
- package/lib/utils/image_plugins/utils.d.ts +2 -0
- package/lib/utils/image_plugins/utils.js +3 -0
- package/lib/utils/preprocess.d.ts +3 -1
- package/package.json +13 -3
- package/scripts/templates/image_prompt_only_template.json +27 -0
- package/lib/agents/image_mock_agent.d.ts +0 -4
- package/lib/agents/image_mock_agent.js +0 -18
- package/lib/agents/mulmo_prompts_agent.d.ts +0 -7
- package/lib/agents/mulmo_prompts_agent.js +0 -37
- package/lib/agents/prompts_data.d.ts +0 -15
- package/lib/agents/prompts_data.js +0 -16
- package/lib/agents/validate_mulmo_script_agent.d.ts +0 -17
- package/lib/agents/validate_mulmo_script_agent.js +0 -34
- package/lib/cli/args.d.ts +0 -15
- package/lib/cli/args.js +0 -62
- package/lib/cli/cli.d.ts +0 -17
- package/lib/cli/cli.js +0 -117
- package/lib/cli/run.d.ts +0 -2
- package/lib/cli/run.js +0 -3
- package/lib/cli/tool-args.d.ts +0 -16
- package/lib/cli/tool-args.js +0 -64
- package/lib/cli/tool-cli.d.ts +0 -2
- package/lib/cli/tool-cli.js +0 -69
- package/lib/methods/mulmo_script.d.ts +0 -11
- package/lib/methods/mulmo_script.js +0 -59
- package/lib/methods/mulmo_studio.d.ts +0 -8
- package/lib/methods/mulmo_studio.js +0 -24
- package/lib/tools/prompt.d.ts +0 -1
- package/lib/tools/prompt.js +0 -18
- package/lib/utils/image_plugins/tailwind.d.ts +0 -3
- package/lib/utils/image_plugins/tailwind.js +0 -18
- package/lib/utils/pdf.d.ts +0 -9
- package/lib/utils/pdf.js +0 -77
package/lib/cli/args.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import yargs from "yargs";
|
|
2
|
-
import { hideBin } from "yargs/helpers";
|
|
3
|
-
import { commonOptions } from "./common.js";
|
|
4
|
-
import { pdf_modes, pdf_sizes, languages } from "../utils/const.js";
|
|
5
|
-
export const getArgs = () => {
|
|
6
|
-
return commonOptions(yargs(hideBin(process.argv)))
|
|
7
|
-
.scriptName("mulmo")
|
|
8
|
-
.option("a", {
|
|
9
|
-
alias: "audiodir",
|
|
10
|
-
description: "audio dir",
|
|
11
|
-
demandOption: false,
|
|
12
|
-
type: "string",
|
|
13
|
-
})
|
|
14
|
-
.option("i", {
|
|
15
|
-
alias: "imagedir",
|
|
16
|
-
description: "image dir",
|
|
17
|
-
demandOption: false,
|
|
18
|
-
type: "string",
|
|
19
|
-
})
|
|
20
|
-
.option("f", {
|
|
21
|
-
alias: "force",
|
|
22
|
-
description: "force generate",
|
|
23
|
-
demandOption: false,
|
|
24
|
-
default: false,
|
|
25
|
-
type: "boolean",
|
|
26
|
-
})
|
|
27
|
-
.option("c", {
|
|
28
|
-
alias: "caption",
|
|
29
|
-
description: "Video captions",
|
|
30
|
-
choices: languages,
|
|
31
|
-
demandOption: false,
|
|
32
|
-
type: "string",
|
|
33
|
-
})
|
|
34
|
-
.option("pdf_mode", {
|
|
35
|
-
description: "pdf mode",
|
|
36
|
-
demandOption: false,
|
|
37
|
-
choices: pdf_modes,
|
|
38
|
-
type: "string",
|
|
39
|
-
default: "slide",
|
|
40
|
-
})
|
|
41
|
-
.option("pdf_size", {
|
|
42
|
-
choices: pdf_sizes,
|
|
43
|
-
default: "letter",
|
|
44
|
-
describe: "PDF paper size (default: letter for US standard)",
|
|
45
|
-
})
|
|
46
|
-
.command("$0 <action> <file>", "Run mulmocast", (yargs) => {
|
|
47
|
-
return yargs
|
|
48
|
-
.positional("action", {
|
|
49
|
-
describe: "action to perform",
|
|
50
|
-
choices: ["translate", "audio", "images", "movie", "pdf"],
|
|
51
|
-
type: "string",
|
|
52
|
-
})
|
|
53
|
-
.positional("file", {
|
|
54
|
-
describe: "Mulmo Script File",
|
|
55
|
-
type: "string",
|
|
56
|
-
});
|
|
57
|
-
})
|
|
58
|
-
.strict()
|
|
59
|
-
.help()
|
|
60
|
-
.alias("help", "h")
|
|
61
|
-
.parseSync();
|
|
62
|
-
};
|
package/lib/cli/cli.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import "dotenv/config";
|
|
3
|
-
export declare const getFileObject: (_args: {
|
|
4
|
-
[x: string]: unknown;
|
|
5
|
-
}) => {
|
|
6
|
-
baseDirPath: string;
|
|
7
|
-
mulmoFilePath: string;
|
|
8
|
-
mulmoFileDirPath: string;
|
|
9
|
-
outDirPath: string;
|
|
10
|
-
imageDirPath: string;
|
|
11
|
-
audioDirPath: string;
|
|
12
|
-
isHttpPath: boolean;
|
|
13
|
-
fileOrUrl: string;
|
|
14
|
-
outputStudioFilePath: string;
|
|
15
|
-
fileName: string;
|
|
16
|
-
};
|
|
17
|
-
export declare const main: () => Promise<void>;
|
package/lib/cli/cli.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import "dotenv/config";
|
|
3
|
-
import fs from "fs";
|
|
4
|
-
import path from "path";
|
|
5
|
-
import { GraphAILogger } from "graphai";
|
|
6
|
-
import { getArgs } from "./args.js";
|
|
7
|
-
import { createOrUpdateStudioData } from "../utils/preprocess.js";
|
|
8
|
-
import { outDirName, imageDirName, audioDirName } from "../utils/const.js";
|
|
9
|
-
import { translate, audio, images, movie, pdf, captions } from "../actions/index.js";
|
|
10
|
-
import { getBaseDirPath, getFullPath, readMulmoScriptFile, fetchMulmoScriptFile, getOutputStudioFilePath, resolveDirPath } from "../utils/file.js";
|
|
11
|
-
import { isHttp } from "../utils/utils.js";
|
|
12
|
-
import clipboardy from "clipboardy";
|
|
13
|
-
export const getFileObject = (_args) => {
|
|
14
|
-
const { basedir, file, outdir, imagedir, audiodir } = _args;
|
|
15
|
-
const baseDirPath = getBaseDirPath(basedir);
|
|
16
|
-
const outDirPath = getFullPath(baseDirPath, outdir ?? outDirName);
|
|
17
|
-
const { fileOrUrl, fileName } = (() => {
|
|
18
|
-
if (file === "__clipboard") {
|
|
19
|
-
// We generate a new unique script file from clipboard text in the output directory
|
|
20
|
-
const now = new Date();
|
|
21
|
-
const pad = (n) => n.toString().padStart(2, "0");
|
|
22
|
-
const fileName = `script_${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}_${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
|
|
23
|
-
const clipboardText = clipboardy.readSync();
|
|
24
|
-
const fileOrUrl = resolveDirPath(outDirPath, `${fileName}.json`);
|
|
25
|
-
fs.writeFileSync(fileOrUrl, clipboardText, "utf8");
|
|
26
|
-
return { fileOrUrl, fileName };
|
|
27
|
-
}
|
|
28
|
-
const fileOrUrl = file ?? "";
|
|
29
|
-
const fileName = path.parse(fileOrUrl).name;
|
|
30
|
-
return { fileOrUrl, fileName };
|
|
31
|
-
})();
|
|
32
|
-
const isHttpPath = isHttp(fileOrUrl);
|
|
33
|
-
const mulmoFilePath = isHttpPath ? "" : getFullPath(baseDirPath, fileOrUrl);
|
|
34
|
-
const mulmoFileDirPath = path.dirname(isHttpPath ? baseDirPath : mulmoFilePath);
|
|
35
|
-
const imageDirPath = getFullPath(outDirPath, imagedir ?? imageDirName);
|
|
36
|
-
const audioDirPath = getFullPath(outDirPath, audiodir ?? audioDirName);
|
|
37
|
-
const outputStudioFilePath = getOutputStudioFilePath(outDirPath, fileName);
|
|
38
|
-
return { baseDirPath, mulmoFilePath, mulmoFileDirPath, outDirPath, imageDirPath, audioDirPath, isHttpPath, fileOrUrl, outputStudioFilePath, fileName };
|
|
39
|
-
};
|
|
40
|
-
const fetchScript = async (isHttpPath, mulmoFilePath, fileOrUrl) => {
|
|
41
|
-
if (isHttpPath) {
|
|
42
|
-
const res = await fetchMulmoScriptFile(fileOrUrl);
|
|
43
|
-
if (!res.result || !res.script) {
|
|
44
|
-
GraphAILogger.info(`ERROR: HTTP error! ${res.status} ${fileOrUrl}`);
|
|
45
|
-
process.exit(1);
|
|
46
|
-
}
|
|
47
|
-
return res.script;
|
|
48
|
-
}
|
|
49
|
-
if (!fs.existsSync(mulmoFilePath)) {
|
|
50
|
-
GraphAILogger.info(`ERROR: File not exists ${mulmoFilePath}`);
|
|
51
|
-
process.exit(1);
|
|
52
|
-
}
|
|
53
|
-
return readMulmoScriptFile(mulmoFilePath, "ERROR: File does not exist " + mulmoFilePath).mulmoData;
|
|
54
|
-
};
|
|
55
|
-
export const main = async () => {
|
|
56
|
-
const args = getArgs();
|
|
57
|
-
const files = getFileObject(args);
|
|
58
|
-
const { mulmoFilePath, isHttpPath, fileOrUrl, fileName, outputStudioFilePath } = files;
|
|
59
|
-
if (args.v) {
|
|
60
|
-
GraphAILogger.info(files);
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
GraphAILogger.setLevelEnabled("error", false);
|
|
64
|
-
GraphAILogger.setLevelEnabled("log", false);
|
|
65
|
-
GraphAILogger.setLevelEnabled("warn", false);
|
|
66
|
-
}
|
|
67
|
-
const { action, f: force, pdf_mode, pdf_size, l: lang, c: caption } = args;
|
|
68
|
-
const mulmoScript = await fetchScript(isHttpPath, mulmoFilePath, fileOrUrl);
|
|
69
|
-
// Create or update MulmoStudio file with MulmoScript
|
|
70
|
-
const currentStudio = readMulmoScriptFile(outputStudioFilePath);
|
|
71
|
-
const studio = (() => {
|
|
72
|
-
try {
|
|
73
|
-
// validate mulmoStudioSchema. skip if __test_invalid__ is true
|
|
74
|
-
return createOrUpdateStudioData(mulmoScript, currentStudio?.mulmoData, fileName);
|
|
75
|
-
}
|
|
76
|
-
catch (error) {
|
|
77
|
-
GraphAILogger.info(`Error: invalid MulmoScript Schema: ${isHttpPath ? fileOrUrl : mulmoFilePath} \n ${error}`);
|
|
78
|
-
process.exit(1);
|
|
79
|
-
}
|
|
80
|
-
})();
|
|
81
|
-
const context = {
|
|
82
|
-
studio,
|
|
83
|
-
fileDirs: files,
|
|
84
|
-
force: Boolean(force),
|
|
85
|
-
lang: lang,
|
|
86
|
-
caption: caption,
|
|
87
|
-
};
|
|
88
|
-
if (action === "translate" || lang || caption) {
|
|
89
|
-
GraphAILogger.log("run translate");
|
|
90
|
-
await translate(context);
|
|
91
|
-
}
|
|
92
|
-
if (action === "audio") {
|
|
93
|
-
await audio(context);
|
|
94
|
-
}
|
|
95
|
-
if (action === "images") {
|
|
96
|
-
await images(context);
|
|
97
|
-
}
|
|
98
|
-
if (action === "movie") {
|
|
99
|
-
if (caption) {
|
|
100
|
-
await captions(context);
|
|
101
|
-
}
|
|
102
|
-
await audio(context);
|
|
103
|
-
await images(context);
|
|
104
|
-
await movie(context);
|
|
105
|
-
}
|
|
106
|
-
if (action === "pdf") {
|
|
107
|
-
await images(context);
|
|
108
|
-
await pdf(context, pdf_mode, pdf_size);
|
|
109
|
-
}
|
|
110
|
-
if (context.studio.script.title) {
|
|
111
|
-
GraphAILogger.info(context.studio.script.title);
|
|
112
|
-
}
|
|
113
|
-
if (context.studio.script.references) {
|
|
114
|
-
const textOutput = context.studio.script.references.map((reference) => `${reference.title}\n${reference.url}`).join("\n");
|
|
115
|
-
GraphAILogger.info(textOutput);
|
|
116
|
-
}
|
|
117
|
-
};
|
package/lib/cli/run.d.ts
DELETED
package/lib/cli/run.js
DELETED
package/lib/cli/tool-args.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export declare const args: {
|
|
2
|
-
[x: string]: unknown;
|
|
3
|
-
v: boolean;
|
|
4
|
-
o: string | undefined;
|
|
5
|
-
b: string | undefined;
|
|
6
|
-
l: string | undefined;
|
|
7
|
-
u: string[] | never[];
|
|
8
|
-
i: boolean | undefined;
|
|
9
|
-
t: string | undefined;
|
|
10
|
-
c: string | undefined;
|
|
11
|
-
s: string;
|
|
12
|
-
llm_agent: string | undefined;
|
|
13
|
-
llm_model: string | undefined;
|
|
14
|
-
_: (string | number)[];
|
|
15
|
-
$0: string;
|
|
16
|
-
};
|
package/lib/cli/tool-args.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import yargs from "yargs";
|
|
2
|
-
import { hideBin } from "yargs/helpers";
|
|
3
|
-
import { commonOptions } from "./common.js";
|
|
4
|
-
import { getAvailableTemplates } from "../utils/file.js";
|
|
5
|
-
import { llmAgents } from "../utils/utils.js";
|
|
6
|
-
const availableTemplateNames = getAvailableTemplates().map((template) => template.filename);
|
|
7
|
-
export const args = commonOptions(yargs(hideBin(process.argv)))
|
|
8
|
-
.scriptName("mulmo-tool")
|
|
9
|
-
.option("u", {
|
|
10
|
-
alias: "url",
|
|
11
|
-
description: "URLs to reference (required when not in interactive mode)",
|
|
12
|
-
demandOption: false,
|
|
13
|
-
default: [],
|
|
14
|
-
type: "array",
|
|
15
|
-
string: true,
|
|
16
|
-
})
|
|
17
|
-
.option("i", {
|
|
18
|
-
alias: "interactive",
|
|
19
|
-
description: "Generate script in interactive mode with user prompts",
|
|
20
|
-
demandOption: false,
|
|
21
|
-
type: "boolean",
|
|
22
|
-
})
|
|
23
|
-
.option("t", {
|
|
24
|
-
alias: "template",
|
|
25
|
-
description: "Template name to use",
|
|
26
|
-
demandOption: false,
|
|
27
|
-
choices: availableTemplateNames,
|
|
28
|
-
type: "string",
|
|
29
|
-
})
|
|
30
|
-
.option("c", {
|
|
31
|
-
alias: "cache",
|
|
32
|
-
description: "cache dir",
|
|
33
|
-
demandOption: false,
|
|
34
|
-
type: "string",
|
|
35
|
-
})
|
|
36
|
-
.option("s", {
|
|
37
|
-
alias: "script",
|
|
38
|
-
description: "script filename",
|
|
39
|
-
demandOption: false,
|
|
40
|
-
default: "script",
|
|
41
|
-
type: "string",
|
|
42
|
-
})
|
|
43
|
-
.option("llm_agent", {
|
|
44
|
-
description: "llm agent",
|
|
45
|
-
demandOption: false,
|
|
46
|
-
choices: llmAgents,
|
|
47
|
-
type: "string",
|
|
48
|
-
})
|
|
49
|
-
.option("llm_model", {
|
|
50
|
-
description: "llm model",
|
|
51
|
-
demandOption: false,
|
|
52
|
-
type: "string",
|
|
53
|
-
})
|
|
54
|
-
.command("$0 <action>", "Run mulmocast tool", (yargs) => {
|
|
55
|
-
return yargs.positional("action", {
|
|
56
|
-
describe: "action to perform",
|
|
57
|
-
choices: ["scripting", "prompt", "schema"],
|
|
58
|
-
type: "string",
|
|
59
|
-
});
|
|
60
|
-
})
|
|
61
|
-
.strict()
|
|
62
|
-
.help()
|
|
63
|
-
.alias("help", "h")
|
|
64
|
-
.parseSync();
|
package/lib/cli/tool-cli.d.ts
DELETED
package/lib/cli/tool-cli.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
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";
|
|
11
|
-
import { mulmoScriptSchema } from "../types/schema.js";
|
|
12
|
-
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
13
|
-
const main = async () => {
|
|
14
|
-
const { o: outdir, b: basedir, action, v: verbose, i: interactive, s: filename, cache } = args;
|
|
15
|
-
let { t: template } = args;
|
|
16
|
-
const { u: urls } = args;
|
|
17
|
-
const { llm_model, llm_agent } = args;
|
|
18
|
-
const baseDirPath = getBaseDirPath(basedir);
|
|
19
|
-
const outDirPath = getFullPath(baseDirPath, outdir ?? outDirName);
|
|
20
|
-
const cacheDirPath = getFullPath(outDirPath, cache ?? cacheDirName);
|
|
21
|
-
if (verbose) {
|
|
22
|
-
GraphAILogger.info("baseDirPath:", baseDirPath);
|
|
23
|
-
GraphAILogger.info("outDirPath:", outDirPath);
|
|
24
|
-
GraphAILogger.info("cacheDirPath:", cacheDirPath);
|
|
25
|
-
GraphAILogger.info("template:", template);
|
|
26
|
-
GraphAILogger.info("urls:", urls);
|
|
27
|
-
GraphAILogger.info("action:", action);
|
|
28
|
-
GraphAILogger.info("interactive:", interactive);
|
|
29
|
-
GraphAILogger.info("filename:", filename);
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
GraphAILogger.setLevelEnabled("error", false);
|
|
33
|
-
GraphAILogger.setLevelEnabled("log", false);
|
|
34
|
-
GraphAILogger.setLevelEnabled("warn", false);
|
|
35
|
-
}
|
|
36
|
-
// If template is not specified, show the selection prompt
|
|
37
|
-
if (!template) {
|
|
38
|
-
template = await selectTemplate();
|
|
39
|
-
if (verbose) {
|
|
40
|
-
GraphAILogger.info("Selected template:", template);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
if (action === "scripting") {
|
|
44
|
-
const context = { outDirPath, templateName: template, urls, filename, cacheDirPath, llm_model, llm_agent };
|
|
45
|
-
if (interactive) {
|
|
46
|
-
await createMulmoScriptInteractively(context);
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
context.urls = await getUrlsIfNeeded(urls);
|
|
50
|
-
await createMulmoScriptFromUrl(context);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
else if (action === "prompt") {
|
|
54
|
-
await dumpPromptFromTemplate({ templateName: template });
|
|
55
|
-
}
|
|
56
|
-
else if (action === "schema") {
|
|
57
|
-
const defaultSchema = zodToJsonSchema(mulmoScriptSchema, {
|
|
58
|
-
strictUnions: true,
|
|
59
|
-
});
|
|
60
|
-
GraphAILogger.info(JSON.stringify(defaultSchema, null, 2));
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
throw new Error(`Unknown or unsupported action: ${action}`);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
main().catch((error) => {
|
|
67
|
-
GraphAILogger.info("An unexpected error occurred:", error);
|
|
68
|
-
process.exit(1);
|
|
69
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import "dotenv/config";
|
|
2
|
-
import { MulmoCanvasDimension, MulmoScript, MulmoBeat, SpeechOptions, Text2SpeechProvider, Text2ImageAgentInfo, BeatMediaType } from "../types/index.js";
|
|
3
|
-
export declare const MulmoScriptMethods: {
|
|
4
|
-
getCanvasSize(script: MulmoScript): MulmoCanvasDimension;
|
|
5
|
-
getSpeechProvider(script: MulmoScript): Text2SpeechProvider;
|
|
6
|
-
getAllSpeechProviders(script: MulmoScript): Set<Text2SpeechProvider>;
|
|
7
|
-
getTextSlideStyle(script: MulmoScript, beat: MulmoBeat): string;
|
|
8
|
-
getSpeechOptions(script: MulmoScript, beat: MulmoBeat): SpeechOptions | undefined;
|
|
9
|
-
getImageAgentInfo(script: MulmoScript, dryRun?: boolean): Text2ImageAgentInfo;
|
|
10
|
-
getImageType(_: MulmoScript, beat: MulmoBeat): BeatMediaType;
|
|
11
|
-
};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import "dotenv/config";
|
|
2
|
-
import { text2ImageProviderSchema, text2SpeechProviderSchema, mulmoCanvasDimensionSchema } from "../types/schema.js";
|
|
3
|
-
const defaultTextSlideStyles = [
|
|
4
|
-
'*,*::before,*::after{box-sizing:border-box}body,h1,h2,h3,h4,p,figure,blockquote,dl,dd{margin:0}ul[role="list"],ol[role="list"]{list-style:none}html:focus-within{scroll-behavior:smooth}body{min-height:100vh;text-rendering:optimizeSpeed;line-height:1.5}a:not([class]){text-decoration-skip-ink:auto}img,picture{max-width:100%;display:block}input,button,textarea,select{font:inherit}@media(prefers-reduced-motion:reduce){html:focus-within{scroll-behavior:auto}*,*::before,*::after{animation-duration:.01ms !important;animation-iteration-count:1 !important;transition-duration:.01ms !important;scroll-behavior:auto !important}}',
|
|
5
|
-
"body { margin: 60px; margin-top: 40px; color:#333; font-size: 30px; font-family: Arial, sans-serif; box-sizing: border-box; height: 100vh }",
|
|
6
|
-
"h1 { font-size: 56px; margin-bottom: 20px; text-align: center }",
|
|
7
|
-
"h2 { font-size: 48px; text-align: center }",
|
|
8
|
-
"h3 { font-size: 36px }",
|
|
9
|
-
"ul { margin-left: 40px } ",
|
|
10
|
-
"pre { background: #eeeecc; font-size: 16px; padding:4px }",
|
|
11
|
-
"p { margin-left: 40px }",
|
|
12
|
-
"table { font-size: 36px; margin: auto; border: 1px solid gray; border-collapse: collapse }",
|
|
13
|
-
"th { border-bottom: 1px solid gray }",
|
|
14
|
-
"td, th { padding: 8px }",
|
|
15
|
-
"tr:nth-child(even) { background-color: #eee }",
|
|
16
|
-
];
|
|
17
|
-
export const MulmoScriptMethods = {
|
|
18
|
-
getCanvasSize(script) {
|
|
19
|
-
return mulmoCanvasDimensionSchema.parse(script.canvasSize);
|
|
20
|
-
},
|
|
21
|
-
getSpeechProvider(script) {
|
|
22
|
-
return text2SpeechProviderSchema.parse(script.speechParams?.provider);
|
|
23
|
-
},
|
|
24
|
-
getAllSpeechProviders(script) {
|
|
25
|
-
const providers = new Set();
|
|
26
|
-
const defaultProvider = this.getSpeechProvider(script);
|
|
27
|
-
Object.values(script.speechParams.speakers).forEach((speaker) => {
|
|
28
|
-
const provider = speaker.provider ?? defaultProvider;
|
|
29
|
-
providers.add(provider);
|
|
30
|
-
});
|
|
31
|
-
return providers;
|
|
32
|
-
},
|
|
33
|
-
getTextSlideStyle(script, beat) {
|
|
34
|
-
const styles = script.textSlideParams?.cssStyles ?? [];
|
|
35
|
-
// NOTES: Taking advantage of CSS override rule (you can redefine it to override)
|
|
36
|
-
const extraStyles = beat.textSlideParams?.cssStyles ?? [];
|
|
37
|
-
// This code allows us to support both string and array of strings for cssStyles
|
|
38
|
-
return [...defaultTextSlideStyles, ...[styles], ...[extraStyles]].flat().join("\n");
|
|
39
|
-
},
|
|
40
|
-
getSpeechOptions(script, beat) {
|
|
41
|
-
return { ...script.speechParams.speakers[beat.speaker].speechOptions, ...beat.speechOptions };
|
|
42
|
-
},
|
|
43
|
-
getImageAgentInfo(script, dryRun = false) {
|
|
44
|
-
// Notice that we copy imageParams from script and update
|
|
45
|
-
// provider and model appropriately.
|
|
46
|
-
const provider = text2ImageProviderSchema.parse(script.imageParams?.provider);
|
|
47
|
-
const defaultImageParams = {
|
|
48
|
-
model: provider === "openai" ? process.env.DEFAULT_OPENAI_IMAGE_MODEL : undefined,
|
|
49
|
-
};
|
|
50
|
-
return {
|
|
51
|
-
provider,
|
|
52
|
-
agent: dryRun ? "mediaMockAgent" : provider === "google" ? "imageGoogleAgent" : "imageOpenaiAgent",
|
|
53
|
-
imageParams: { ...defaultImageParams, ...script.imageParams },
|
|
54
|
-
};
|
|
55
|
-
},
|
|
56
|
-
getImageType(_, beat) {
|
|
57
|
-
return beat.image?.type == "movie" ? "movie" : "image";
|
|
58
|
-
},
|
|
59
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { MulmoStudio } from "../types/index.js";
|
|
2
|
-
type SessionType = "audio" | "image" | "video" | "multiLingual" | "caption" | "pdf";
|
|
3
|
-
type BeatSessionType = "audio" | "image" | "multiLingual" | "caption" | "movie";
|
|
4
|
-
export declare const MulmoStudioMethods: {
|
|
5
|
-
setSessionState(studio: MulmoStudio, sessionType: SessionType, value: boolean): void;
|
|
6
|
-
setBeatSessionState(studio: MulmoStudio, sessionType: BeatSessionType, index: number, value: boolean): void;
|
|
7
|
-
};
|
|
8
|
-
export {};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { GraphAILogger } from "graphai";
|
|
2
|
-
const notifyStateChange = (studio, sessionType) => {
|
|
3
|
-
const prefix = studio.state.inSession[sessionType] ? "<" : " >";
|
|
4
|
-
GraphAILogger.info(`${prefix} ${sessionType}`);
|
|
5
|
-
};
|
|
6
|
-
const notifyBeatStateChange = (studio, sessionType, index) => {
|
|
7
|
-
const prefix = studio.state.inBeatSession[sessionType].has(index) ? "{" : " }";
|
|
8
|
-
GraphAILogger.info(`${prefix} ${sessionType} ${index}`);
|
|
9
|
-
};
|
|
10
|
-
export const MulmoStudioMethods = {
|
|
11
|
-
setSessionState(studio, sessionType, value) {
|
|
12
|
-
studio.state.inSession[sessionType] = value;
|
|
13
|
-
notifyStateChange(studio, sessionType);
|
|
14
|
-
},
|
|
15
|
-
setBeatSessionState(studio, sessionType, index, value) {
|
|
16
|
-
if (value) {
|
|
17
|
-
studio.state.inBeatSession[sessionType].add(index);
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
studio.state.inBeatSession[sessionType].delete(index);
|
|
21
|
-
}
|
|
22
|
-
notifyBeatStateChange(studio, sessionType, index);
|
|
23
|
-
},
|
|
24
|
-
};
|
package/lib/tools/prompt.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/tools/prompt.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { fileURLToPath } from "url";
|
|
4
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
5
|
-
const __dirname = path.dirname(__filename);
|
|
6
|
-
const main = async () => {
|
|
7
|
-
const basePath = path.resolve(__dirname, "../../prompts/");
|
|
8
|
-
const ret = {};
|
|
9
|
-
fs.readdirSync(basePath).map((file) => {
|
|
10
|
-
const key = file.split(".")[0];
|
|
11
|
-
const content = fs.readFileSync(path.resolve(basePath, file), "utf-8");
|
|
12
|
-
ret[key] = content;
|
|
13
|
-
});
|
|
14
|
-
const code = ["// This file is auto-generated by src/tools/prompt.ts and Do not be edited manually.", `export const prompts = ${JSON.stringify(ret)};`].join("\n");
|
|
15
|
-
fs.writeFileSync(path.resolve(__dirname, "../../src/agents/prompts_data.ts"), code, "utf8");
|
|
16
|
-
// console.log(hoge);
|
|
17
|
-
};
|
|
18
|
-
main();
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { getHTMLFile } from "../file.js";
|
|
2
|
-
import { renderHTMLToImage, interpolate } from "../markdown.js";
|
|
3
|
-
export const imageType = "tailwind";
|
|
4
|
-
const processTailwind = async (params) => {
|
|
5
|
-
const { beat, imagePath, canvasSize } = params;
|
|
6
|
-
if (!beat.image || beat.image.type !== imageType)
|
|
7
|
-
return;
|
|
8
|
-
const html = Array.isArray(beat.image.html) ? beat.image.html.join("\n") : beat.image.html;
|
|
9
|
-
const template = getHTMLFile("tailwind");
|
|
10
|
-
const htmlData = interpolate(template, {
|
|
11
|
-
// style: textSlideStyle,
|
|
12
|
-
// width: Math.round(canvasSize.width * 0.625).toString(),
|
|
13
|
-
html_body: html,
|
|
14
|
-
});
|
|
15
|
-
await renderHTMLToImage(htmlData, imagePath, canvasSize.width, canvasSize.height);
|
|
16
|
-
return imagePath;
|
|
17
|
-
};
|
|
18
|
-
export const process = processTailwind;
|
package/lib/utils/pdf.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { PDFFont } from "pdf-lib";
|
|
2
|
-
export declare const fontSize = 12;
|
|
3
|
-
export declare const textMargin = 6;
|
|
4
|
-
export declare const drawSize: (fitWidth: boolean, expectWidth: number, expectHeight: number, origWidth: number, origHeight: number) => {
|
|
5
|
-
containerWidth: number;
|
|
6
|
-
drawWidth: number;
|
|
7
|
-
drawHeight: number;
|
|
8
|
-
};
|
|
9
|
-
export declare const wrapText: (text: string, font: PDFFont, fontSize: number, maxWidth: number) => string[];
|
package/lib/utils/pdf.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
export const fontSize = 12;
|
|
2
|
-
export const textMargin = 6;
|
|
3
|
-
export const drawSize = (fitWidth, expectWidth, expectHeight, origWidth, origHeight) => {
|
|
4
|
-
if (fitWidth) {
|
|
5
|
-
const drawWidth = expectWidth;
|
|
6
|
-
const scale = drawWidth / origWidth;
|
|
7
|
-
const drawHeight = origHeight * scale;
|
|
8
|
-
return {
|
|
9
|
-
containerWidth: expectWidth,
|
|
10
|
-
drawWidth,
|
|
11
|
-
drawHeight,
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
const drawHeight = expectHeight;
|
|
15
|
-
const scale = drawHeight / origHeight;
|
|
16
|
-
const drawWidth = origWidth * scale;
|
|
17
|
-
return {
|
|
18
|
-
containerWidth: expectWidth,
|
|
19
|
-
drawWidth,
|
|
20
|
-
drawHeight,
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
const isFullwidth = (char) => {
|
|
24
|
-
const code = char.charCodeAt(0);
|
|
25
|
-
return ((code >= 0x3000 && code <= 0x9fff) || // CJK, punctuation, kana
|
|
26
|
-
(code >= 0xff00 && code <= 0xffef) // Fullwidth ASCII
|
|
27
|
-
);
|
|
28
|
-
};
|
|
29
|
-
export const wrapText = (text, font, fontSize, maxWidth) => {
|
|
30
|
-
const lines = [];
|
|
31
|
-
for (const rawLine of text.split("\n")) {
|
|
32
|
-
let line = "";
|
|
33
|
-
let buffer = "";
|
|
34
|
-
for (let i = 0; i < rawLine.length; i++) {
|
|
35
|
-
const char = rawLine[i];
|
|
36
|
-
buffer += char;
|
|
37
|
-
const width = font.widthOfTextAtSize(line + buffer, fontSize);
|
|
38
|
-
const nextChar = rawLine[i + 1];
|
|
39
|
-
const currentIsFull = isFullwidth(char);
|
|
40
|
-
const nextIsFull = nextChar && isFullwidth(nextChar);
|
|
41
|
-
const isBreakable = currentIsFull || (!currentIsFull && (char === " " || nextChar === " " || nextIsFull));
|
|
42
|
-
if (width > maxWidth && line) {
|
|
43
|
-
lines.push(line);
|
|
44
|
-
line = buffer;
|
|
45
|
-
buffer = "";
|
|
46
|
-
}
|
|
47
|
-
if (isBreakable || i === rawLine.length - 1) {
|
|
48
|
-
line += buffer;
|
|
49
|
-
buffer = "";
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (line)
|
|
53
|
-
lines.push(line);
|
|
54
|
-
}
|
|
55
|
-
return lines;
|
|
56
|
-
};
|
|
57
|
-
/*
|
|
58
|
-
export const wrapText = (text: string, font: PDFFont, fontSize: number, maxWidth: number) => {
|
|
59
|
-
const words = text.split(" ");
|
|
60
|
-
const lines = [];
|
|
61
|
-
let currentLine = "";
|
|
62
|
-
|
|
63
|
-
for (const word of words) {
|
|
64
|
-
const nextLine = currentLine ? `${currentLine} ${word}` : word;
|
|
65
|
-
// console.log(nextLine);
|
|
66
|
-
const width = font.widthOfTextAtSize(nextLine ?? "", fontSize);
|
|
67
|
-
if (width <= maxWidth) {
|
|
68
|
-
currentLine = nextLine;
|
|
69
|
-
} else {
|
|
70
|
-
lines.push(currentLine);
|
|
71
|
-
currentLine = word;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
if (currentLine) lines.push(currentLine);
|
|
75
|
-
return lines;
|
|
76
|
-
};
|
|
77
|
-
*/
|