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,178 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.createMulmoScriptFromUrl = void 0;
40
+ require("dotenv/config");
41
+ const graphai_1 = require("graphai");
42
+ const openai_agent_1 = require("@graphai/openai_agent");
43
+ const vanilla = __importStar(require("@graphai/vanilla"));
44
+ const vanilla_node_agents_1 = require("@graphai/vanilla_node_agents");
45
+ const browserless_agent_1 = require("@graphai/browserless_agent");
46
+ const validate_mulmo_script_agent_1 = __importDefault(require("../agents/validate_mulmo_script_agent"));
47
+ const file_1 = require("../utils/file");
48
+ const schema_1 = require("../types/schema");
49
+ const graphData = {
50
+ version: 0.5,
51
+ // Execute sequentially because the free version of browserless API doesn't support concurrent execution.
52
+ concurrency: 1,
53
+ nodes: {
54
+ urls: {
55
+ value: [],
56
+ },
57
+ prompt: {
58
+ value: "",
59
+ },
60
+ outdir: {
61
+ value: "",
62
+ },
63
+ fileName: {
64
+ value: "",
65
+ },
66
+ // get the text content of the urls
67
+ fetchResults: {
68
+ agent: "mapAgent",
69
+ inputs: {
70
+ rows: ":urls",
71
+ },
72
+ params: {
73
+ compositeResult: true,
74
+ },
75
+ graph: {
76
+ nodes: {
77
+ fetcher: {
78
+ agent: "browserlessAgent",
79
+ inputs: {
80
+ url: ":row",
81
+ text_content: true,
82
+ },
83
+ },
84
+ copyAgent: {
85
+ agent: "copyAgent",
86
+ inputs: {
87
+ text: '{ url: "${:row}", text: "${:fetcher.text}" }',
88
+ },
89
+ params: {
90
+ namedKey: "text",
91
+ },
92
+ isResult: true,
93
+ },
94
+ },
95
+ },
96
+ },
97
+ // join the text content
98
+ sourceText: {
99
+ agent: "arrayJoinAgent",
100
+ inputs: {
101
+ array: ":fetchResults.copyAgent",
102
+ },
103
+ params: {
104
+ separator: ",",
105
+ },
106
+ },
107
+ // generate the mulmo script
108
+ mulmoScript: {
109
+ agent: "nestedAgent",
110
+ inputs: {
111
+ sourceText: ":sourceText",
112
+ prompt: ":prompt",
113
+ },
114
+ graph: {
115
+ loop: {
116
+ // If the script is not valid and the counter is less than 3, continue the loop
117
+ while: ":continue",
118
+ },
119
+ nodes: {
120
+ counter: {
121
+ value: 0,
122
+ update: ":counter.add(1)",
123
+ },
124
+ openAIAgent: {
125
+ agent: "openAIAgent",
126
+ inputs: {
127
+ model: "gpt-4o",
128
+ system: ":prompt",
129
+ prompt: "Please create a script using the information from the following URLs as reference: ${:sourceText.text}",
130
+ },
131
+ },
132
+ validateMulmoScriptAgent: {
133
+ agent: "validateMulmoScriptAgent",
134
+ inputs: {
135
+ text: ":openAIAgent.text.codeBlock()",
136
+ },
137
+ isResult: true,
138
+ },
139
+ continue: {
140
+ agent: ({ isValid, counter }) => {
141
+ return !isValid && counter < 3;
142
+ },
143
+ inputs: {
144
+ isValid: ":validateMulmoScriptAgent.isValid",
145
+ counter: ":counter",
146
+ },
147
+ },
148
+ },
149
+ },
150
+ },
151
+ writeJSON: {
152
+ if: ":mulmoScript.validateMulmoScriptAgent.isValid",
153
+ agent: "fileWriteAgent",
154
+ inputs: {
155
+ file: "${:outdir}/${:fileName}-${@now}.json",
156
+ text: ":mulmoScript.validateMulmoScriptAgent.data.toJSON()",
157
+ },
158
+ isResult: true,
159
+ },
160
+ },
161
+ };
162
+ const createMulmoScriptFromUrl = async ({ urls, templateName, outDirPath, filename }) => {
163
+ (0, file_1.mkdir)(outDirPath);
164
+ const parsedUrls = schema_1.urlsSchema.parse(urls);
165
+ const graph = new graphai_1.GraphAI(graphData, {
166
+ ...vanilla,
167
+ openAIAgent: openai_agent_1.openAIAgent,
168
+ browserlessAgent: browserless_agent_1.browserlessAgent,
169
+ validateMulmoScriptAgent: validate_mulmo_script_agent_1.default,
170
+ fileWriteAgent: vanilla_node_agents_1.fileWriteAgent,
171
+ });
172
+ graph.injectValue("urls", parsedUrls);
173
+ graph.injectValue("prompt", (0, file_1.readTemplatePrompt)(templateName));
174
+ graph.injectValue("outdir", outDirPath);
175
+ graph.injectValue("fileName", filename);
176
+ await graph.run();
177
+ };
178
+ exports.createMulmoScriptFromUrl = createMulmoScriptFromUrl;
@@ -0,0 +1 @@
1
+ export * from "./type";
@@ -0,0 +1,17 @@
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("./type"), exports);