mulmocast 0.0.1 → 0.0.3

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 (115) hide show
  1. package/README.md +129 -15
  2. package/assets/font/NotoSansJP-Regular.ttf +0 -0
  3. package/assets/html/chart.html +38 -0
  4. package/assets/html/mermaid.html +51 -0
  5. package/assets/templates/business.json +57 -14
  6. package/assets/templates/children_book.json +1 -3
  7. package/assets/templates/coding.json +140 -0
  8. package/lib/actions/audio.d.ts +2 -2
  9. package/lib/actions/audio.js +88 -101
  10. package/lib/actions/images.d.ts +1 -1
  11. package/lib/actions/images.js +50 -88
  12. package/lib/actions/index.d.ts +5 -0
  13. package/lib/actions/index.js +5 -0
  14. package/lib/actions/movie.d.ts +9 -1
  15. package/lib/actions/movie.js +124 -65
  16. package/lib/actions/pdf.d.ts +2 -0
  17. package/lib/actions/pdf.js +211 -0
  18. package/lib/actions/pdf2.d.ts +2 -0
  19. package/lib/actions/pdf2.js +203 -0
  20. package/lib/actions/translate.d.ts +1 -1
  21. package/lib/actions/translate.js +38 -61
  22. package/lib/agents/add_bgm_agent.d.ts +1 -1
  23. package/lib/agents/add_bgm_agent.js +10 -14
  24. package/lib/agents/anthropic_agent.d.ts +23 -0
  25. package/lib/agents/anthropic_agent.js +162 -0
  26. package/lib/agents/combine_audio_files_agent.d.ts +1 -1
  27. package/lib/agents/combine_audio_files_agent.js +33 -32
  28. package/lib/agents/image_google_agent.d.ts +1 -1
  29. package/lib/agents/image_google_agent.js +8 -11
  30. package/lib/agents/image_openai_agent.js +7 -14
  31. package/lib/agents/index.d.ts +8 -8
  32. package/lib/agents/index.js +13 -30
  33. package/lib/agents/mulmo_prompts_agent.d.ts +1 -1
  34. package/lib/agents/mulmo_prompts_agent.js +7 -11
  35. package/lib/agents/nested_agent.d.ts +9 -0
  36. package/lib/agents/nested_agent.js +138 -0
  37. package/lib/agents/prompts_data.js +1 -4
  38. package/lib/agents/tts_nijivoice_agent.d.ts +1 -1
  39. package/lib/agents/tts_nijivoice_agent.js +8 -12
  40. package/lib/agents/tts_openai_agent.js +9 -16
  41. package/lib/agents/validate_mulmo_script_agent.d.ts +1 -1
  42. package/lib/agents/validate_mulmo_script_agent.js +6 -10
  43. package/lib/cli/args.d.ts +5 -2
  44. package/lib/cli/args.js +52 -35
  45. package/lib/cli/cli.d.ts +14 -0
  46. package/lib/cli/cli.js +74 -57
  47. package/lib/cli/common.js +1 -5
  48. package/lib/cli/tool-args.d.ts +4 -1
  49. package/lib/cli/tool-args.js +29 -18
  50. package/lib/cli/tool-cli.js +34 -51
  51. package/lib/methods/index.d.ts +4 -3
  52. package/lib/methods/index.js +4 -19
  53. package/lib/methods/mulmo_media_source.d.ts +4 -0
  54. package/lib/methods/mulmo_media_source.js +21 -0
  55. package/lib/methods/mulmo_script.d.ts +6 -5
  56. package/lib/methods/mulmo_script.js +29 -16
  57. package/lib/methods/mulmo_script_template.d.ts +1 -1
  58. package/lib/methods/mulmo_script_template.js +4 -10
  59. package/lib/methods/mulmo_studio_context.d.ts +1 -1
  60. package/lib/methods/mulmo_studio_context.js +3 -9
  61. package/lib/tools/create_mulmo_script_from_url.d.ts +3 -0
  62. package/lib/tools/create_mulmo_script_from_url.js +152 -0
  63. package/lib/tools/create_mulmo_script_interactively.d.ts +3 -0
  64. package/lib/tools/create_mulmo_script_interactively.js +258 -0
  65. package/lib/tools/dump_prompt.js +5 -8
  66. package/lib/tools/prompt.js +9 -11
  67. package/lib/tools/seed_from_url2.d.ts +3 -0
  68. package/lib/tools/seed_from_url2.js +154 -0
  69. package/lib/types/index.d.ts +2 -1
  70. package/lib/types/index.js +2 -17
  71. package/lib/types/schema.d.ts +3624 -2798
  72. package/lib/types/schema.js +172 -123
  73. package/lib/types/type.d.ts +34 -3
  74. package/lib/types/type.js +1 -2
  75. package/lib/utils/const.d.ts +4 -1
  76. package/lib/utils/const.js +6 -6
  77. package/lib/utils/file.d.ts +22 -4
  78. package/lib/utils/file.js +100 -79
  79. package/lib/utils/filters.d.ts +1 -0
  80. package/lib/utils/filters.js +47 -26
  81. package/lib/utils/image_plugins/chart.d.ts +3 -0
  82. package/lib/utils/image_plugins/chart.js +18 -0
  83. package/lib/utils/image_plugins/image.d.ts +2 -0
  84. package/lib/utils/image_plugins/image.js +3 -0
  85. package/lib/utils/image_plugins/index.d.ts +7 -0
  86. package/lib/utils/image_plugins/index.js +7 -0
  87. package/lib/utils/image_plugins/markdown.d.ts +3 -0
  88. package/lib/utils/image_plugins/markdown.js +11 -0
  89. package/lib/utils/image_plugins/mermaid.d.ts +3 -0
  90. package/lib/utils/image_plugins/mermaid.js +21 -0
  91. package/lib/utils/image_plugins/movie.d.ts +2 -0
  92. package/lib/utils/image_plugins/movie.js +3 -0
  93. package/lib/utils/image_plugins/source.d.ts +4 -0
  94. package/lib/utils/image_plugins/source.js +15 -0
  95. package/lib/utils/image_plugins/text_slide.d.ts +3 -0
  96. package/lib/utils/image_plugins/text_slide.js +12 -0
  97. package/lib/utils/image_plugins/type_guards.d.ts +6 -0
  98. package/lib/utils/image_plugins/type_guards.js +21 -0
  99. package/lib/utils/image_preprocess.d.ts +14 -0
  100. package/lib/utils/image_preprocess.js +52 -0
  101. package/lib/utils/inquirer.d.ts +2 -0
  102. package/lib/utils/inquirer.js +33 -0
  103. package/lib/utils/markdown.d.ts +3 -1
  104. package/lib/utils/markdown.js +20 -19
  105. package/lib/utils/pdf.d.ts +8 -0
  106. package/lib/utils/pdf.js +75 -0
  107. package/lib/utils/plugins.d.ts +5 -0
  108. package/lib/utils/plugins.js +11 -0
  109. package/lib/utils/preprocess.d.ts +70 -123
  110. package/lib/utils/preprocess.js +37 -43
  111. package/lib/utils/string.js +4 -10
  112. package/lib/utils/text_hash.js +2 -39
  113. package/lib/utils/utils.d.ts +12 -0
  114. package/lib/utils/utils.js +34 -0
  115. package/package.json +23 -8
@@ -1,31 +1,14 @@
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.validateMulmoScriptAgent = exports.ttsOpenaiAgent = exports.ttsNijivoiceAgent = exports.mulmoPromptsAgent = exports.imageOpenaiAgent = exports.imageGoogleAgent = exports.combineAudioFilesAgent = exports.addBGMAgent = exports.textInputAgent = exports.browserlessAgent = exports.fileWriteAgent = exports.openAIAgent = void 0;
7
- const add_bgm_agent_1 = __importDefault(require("./add_bgm_agent"));
8
- exports.addBGMAgent = add_bgm_agent_1.default;
9
- const combine_audio_files_agent_1 = __importDefault(require("./combine_audio_files_agent"));
10
- exports.combineAudioFilesAgent = combine_audio_files_agent_1.default;
11
- const image_google_agent_1 = __importDefault(require("./image_google_agent"));
12
- exports.imageGoogleAgent = image_google_agent_1.default;
13
- const image_openai_agent_1 = __importDefault(require("./image_openai_agent"));
14
- exports.imageOpenaiAgent = image_openai_agent_1.default;
15
- const mulmo_prompts_agent_1 = __importDefault(require("./mulmo_prompts_agent"));
16
- exports.mulmoPromptsAgent = mulmo_prompts_agent_1.default;
17
- const tts_nijivoice_agent_1 = __importDefault(require("./tts_nijivoice_agent"));
18
- exports.ttsNijivoiceAgent = tts_nijivoice_agent_1.default;
19
- const tts_openai_agent_1 = __importDefault(require("./tts_openai_agent"));
20
- exports.ttsOpenaiAgent = tts_openai_agent_1.default;
21
- const validate_mulmo_script_agent_1 = __importDefault(require("./validate_mulmo_script_agent"));
22
- exports.validateMulmoScriptAgent = validate_mulmo_script_agent_1.default;
23
- const browserless_agent_1 = require("@graphai/browserless_agent");
24
- Object.defineProperty(exports, "browserlessAgent", { enumerable: true, get: function () { return browserless_agent_1.browserlessAgent; } });
25
- const input_agents_1 = require("@graphai/input_agents");
26
- Object.defineProperty(exports, "textInputAgent", { enumerable: true, get: function () { return input_agents_1.textInputAgent; } });
27
- const openai_agent_1 = require("@graphai/openai_agent");
28
- Object.defineProperty(exports, "openAIAgent", { enumerable: true, get: function () { return openai_agent_1.openAIAgent; } });
1
+ import addBGMAgent from "./add_bgm_agent.js";
2
+ import combineAudioFilesAgent from "./combine_audio_files_agent.js";
3
+ import imageGoogleAgent from "./image_google_agent.js";
4
+ import imageOpenaiAgent from "./image_openai_agent.js";
5
+ import mulmoPromptsAgent from "./mulmo_prompts_agent.js";
6
+ import ttsNijivoiceAgent from "./tts_nijivoice_agent.js";
7
+ import ttsOpenaiAgent from "./tts_openai_agent.js";
8
+ import validateMulmoScriptAgent from "./validate_mulmo_script_agent.js";
9
+ import { browserlessAgent } from "@graphai/browserless_agent";
10
+ import { textInputAgent } from "@graphai/input_agents";
11
+ import { openAIAgent } from "@graphai/openai_agent";
29
12
  // import * as vanilla from "@graphai/vanilla";
30
- const vanilla_node_agents_1 = require("@graphai/vanilla_node_agents");
31
- Object.defineProperty(exports, "fileWriteAgent", { enumerable: true, get: function () { return vanilla_node_agents_1.fileWriteAgent; } });
13
+ import { fileWriteAgent } from "@graphai/vanilla_node_agents";
14
+ export { openAIAgent, fileWriteAgent, browserlessAgent, textInputAgent, addBGMAgent, combineAudioFilesAgent, imageGoogleAgent, imageOpenaiAgent, mulmoPromptsAgent, ttsNijivoiceAgent, ttsOpenaiAgent, validateMulmoScriptAgent, };
@@ -1,5 +1,5 @@
1
1
  import { AgentFunction, AgentFunctionInfo } from "graphai";
2
- import { prompts } from "./prompts_data";
2
+ import { prompts } from "./prompts_data.js";
3
3
  export declare const mulmoPromptsAgent: AgentFunction<{
4
4
  promptKey: keyof typeof prompts;
5
5
  }>;
@@ -1,24 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mulmoPromptsAgent = void 0;
4
- const prompts_data_1 = require("./prompts_data");
5
- const mulmoPromptsAgent = async ({ params }) => {
1
+ import { prompts } from "./prompts_data.js";
2
+ export const mulmoPromptsAgent = async ({ params }) => {
6
3
  const { promptKey } = params;
7
4
  if (promptKey) {
8
- const prompt = prompts_data_1.prompts[promptKey];
5
+ const prompt = prompts[promptKey];
9
6
  if (prompt) {
10
7
  return {
11
8
  text: prompt,
12
9
  };
13
10
  }
14
11
  }
15
- return prompts_data_1.prompts;
12
+ return prompts;
16
13
  };
17
- exports.mulmoPromptsAgent = mulmoPromptsAgent;
18
14
  const mulmoPromptsAgentInfo = {
19
15
  name: "mulmoPromptsAgent",
20
- agent: exports.mulmoPromptsAgent,
21
- mock: exports.mulmoPromptsAgent,
16
+ agent: mulmoPromptsAgent,
17
+ mock: mulmoPromptsAgent,
22
18
  samples: [
23
19
  {
24
20
  inputs: {},
@@ -38,4 +34,4 @@ const mulmoPromptsAgentInfo = {
38
34
  // package: "@graphai/prompts",
39
35
  license: "MIT",
40
36
  };
41
- exports.default = mulmoPromptsAgentInfo;
37
+ export default mulmoPromptsAgentInfo;
@@ -0,0 +1,9 @@
1
+ import type { AgentFunction, AgentFunctionInfo, AgentFunctionContext, GraphData, ResultData, DefaultResultData } from "graphai";
2
+ import type { GraphAISupressError, GraphAIOnError } from "@graphai/agent_utils";
3
+ type NestedAgentGeneratorOption = {
4
+ resultNodeId: string;
5
+ };
6
+ export declare const nestedAgentGenerator: (graphData: GraphData, options?: NestedAgentGeneratorOption) => (context: AgentFunctionContext) => Promise<ResultData<DefaultResultData> | GraphAIOnError>;
7
+ export declare const nestedAgent: AgentFunction<Partial<GraphAISupressError> & NestedAgentGeneratorOption>;
8
+ declare const nestedAgentInfo: AgentFunctionInfo;
9
+ export default nestedAgentInfo;
@@ -0,0 +1,138 @@
1
+ import { GraphAI, assert, graphDataLatestVersion } from "graphai";
2
+ export const nestedAgentGenerator = (graphData, options) => {
3
+ return async (context) => {
4
+ const { namedInputs, log, debugInfo, params, forNestedGraph } = context;
5
+ assert(!!forNestedGraph, "Please update graphai to 0.5.19 or higher");
6
+ const { agents, graphOptions, onLogCallback, callbacks } = forNestedGraph;
7
+ const { taskManager } = graphOptions;
8
+ const supressError = params.supressError ?? false;
9
+ if (taskManager) {
10
+ const status = taskManager.getStatus(false);
11
+ assert(status.concurrency > status.running, `nestedAgent: Concurrency is too low: ${status.concurrency}`);
12
+ }
13
+ assert(!!graphData, "nestedAgent: graph is required");
14
+ const { nodes } = graphData;
15
+ const newNodes = Object.keys(nodes).reduce((tmp, key) => {
16
+ const node = nodes[key];
17
+ if ("agent" in node) {
18
+ tmp[key] = node;
19
+ }
20
+ else {
21
+ const { value, update, isResult, console } = node;
22
+ tmp[key] = { value, update, isResult, console };
23
+ }
24
+ return tmp;
25
+ }, {});
26
+ const nestedGraphData = { ...graphData, nodes: newNodes, version: graphDataLatestVersion }; // deep enough copy
27
+ const nodeIds = Object.keys(namedInputs);
28
+ if (nodeIds.length > 0) {
29
+ nodeIds.forEach((nodeId) => {
30
+ if (nestedGraphData.nodes[nodeId] === undefined) {
31
+ // If the input node does not exist, automatically create a static node
32
+ nestedGraphData.nodes[nodeId] = { value: namedInputs[nodeId] };
33
+ }
34
+ else {
35
+ // Otherwise, inject the proper data here (instead of calling injectTo method later)
36
+ if (namedInputs[nodeId] !== undefined) {
37
+ nestedGraphData.nodes[nodeId]["value"] = namedInputs[nodeId];
38
+ }
39
+ }
40
+ });
41
+ }
42
+ try {
43
+ if (nestedGraphData.version === undefined && debugInfo.version) {
44
+ nestedGraphData.version = debugInfo.version;
45
+ }
46
+ const graphAI = new GraphAI(nestedGraphData, agents || {}, graphOptions);
47
+ // for backward compatibility. Remove 'if' later
48
+ if (onLogCallback) {
49
+ graphAI.onLogCallback = onLogCallback;
50
+ }
51
+ if (callbacks) {
52
+ graphAI.callbacks = callbacks;
53
+ }
54
+ debugInfo.subGraphs.set(graphAI.graphId, graphAI);
55
+ const results = await graphAI.run(false);
56
+ debugInfo.subGraphs.delete(graphAI.graphId);
57
+ log?.push(...graphAI.transactionLogs());
58
+ console.log("FFF");
59
+ if (options && options.resultNodeId) {
60
+ return results[options.resultNodeId];
61
+ }
62
+ return results;
63
+ }
64
+ catch (error) {
65
+ console.log("FFF2");
66
+ if (error instanceof Error && supressError) {
67
+ console.log("FFF3");
68
+ return {
69
+ onError: {
70
+ message: error.message,
71
+ error,
72
+ },
73
+ };
74
+ }
75
+ console.log("FFF4", error);
76
+ throw error;
77
+ }
78
+ };
79
+ };
80
+ export const nestedAgent = async (context) => {
81
+ const { forNestedGraph, params } = context;
82
+ const { graphData } = forNestedGraph ?? { graphData: { nodes: {} } };
83
+ assert(!!graphData, "No GraphData");
84
+ return await nestedAgentGenerator(graphData, params)(context);
85
+ };
86
+ const nestedAgentInfo = {
87
+ name: "nestedAgent",
88
+ agent: nestedAgent,
89
+ mock: nestedAgent,
90
+ samples: [
91
+ {
92
+ inputs: {
93
+ message: "hello",
94
+ },
95
+ params: {},
96
+ result: {
97
+ test: ["hello"],
98
+ },
99
+ graph: {
100
+ nodes: {
101
+ test: {
102
+ agent: "copyAgent",
103
+ params: { namedKey: "messages" },
104
+ inputs: { messages: [":message"] },
105
+ isResult: true,
106
+ },
107
+ },
108
+ },
109
+ },
110
+ {
111
+ inputs: {
112
+ message: "hello",
113
+ },
114
+ params: {
115
+ resultNodeId: "test",
116
+ },
117
+ result: ["hello"],
118
+ graph: {
119
+ nodes: {
120
+ test: {
121
+ agent: "copyAgent",
122
+ params: { namedKey: "messages" },
123
+ inputs: { messages: [":message"] },
124
+ isResult: true,
125
+ },
126
+ },
127
+ },
128
+ },
129
+ ],
130
+ description: "nested Agent",
131
+ category: ["graph"],
132
+ author: "Receptron team",
133
+ repository: "https://github.com/receptron/graphai",
134
+ source: "https://github.com/receptron/graphai/blob/main/agents/vanilla_agents/src/graph_agents/nested_agent.ts",
135
+ package: "@graphai/vanilla",
136
+ license: "MIT",
137
+ };
138
+ export default nestedAgentInfo;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.prompts = void 0;
4
1
  // This file is auto-generated by src/tools/prompt.ts and Do not be edited manually.
5
- exports.prompts = {
2
+ export const prompts = {
6
3
  abstract: "We need to add a summary at the beginning of script, which summarizes this episode, which is very engaging. Please come up with a few sentences for the announcer to read, enter them into this script, and present it as an artifact.",
7
4
  image_prompt: 'We need to generate a series of images for this podcast. For each line of given json, generate an appropriate text prompt for text-2-image AI, considering the flow of whole discussion and add it as "imagePrompt" property to the script. We don\'t want to show student, teacher or classroom in the image. Do not eliminate any lines.\n\n[Examples]\nA modern tech conference stage with a speaker discussing AI advancements, futuristic lighting and a large digital screen displaying AI-related graphics.\nA close-up of an AI executive speaking at a press conference, with a backdrop displaying AI chip designs and a world map.\nA futuristic AI research lab with glowing blue data streams and a large AI model being visualized on a digital display.\nA high-tech meeting room with analysts discussing global AI trends, holographic charts displaying AI development.\nA balanced scale with AI progress on one side and economic factors on the other, symbolizing analysis and perspective.\nA newspaper headline about a breakthrough in AI technology, with digital code overlaying the article.\nA timeline showing the gradual evolution of AI models, with key milestones highlighted.\n',
8
5
  prompt: 'generate a podcast script based on this topic in the JSON format using the opening statement below. Monologue by the Host. Complete story.\nClearly mention the news source.\nNews source:\nArticle url: ...\n\n```json\n{\n "title": "(title of this episode)",\n "description": "(short description of this episode)",\n "reference": "(url to the article)",\n "tts": "openAI", // or "nijivoice", default is "openAI"\n "speakers": {\n "Host": {\n "voiceId": "shimmer",\n "displayName": {\n "en": "Host"\n }\n },\n },\n "beats": [\n {\n "speaker": "Host",\n "text": "Hello and welcome to another episode of \'life is artificial\', where we explore the cutting edge of technology, innovation, and what the future could look like.",\n },\n {\n "speaker": "Host",\n "text": "Today, ...",\n },\n ...\n ]\n}\n```\n\n',
@@ -1,4 +1,4 @@
1
- import { AgentFunction, AgentFunctionInfo } from "graphai";
1
+ import type { AgentFunction, AgentFunctionInfo } from "graphai";
2
2
  export declare const ttsNijivoiceAgent: AgentFunction;
3
3
  declare const ttsNijivoiceAgentInfo: AgentFunctionInfo;
4
4
  export default ttsNijivoiceAgentInfo;
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ttsNijivoiceAgent = void 0;
4
- const graphai_1 = require("graphai");
1
+ import { GraphAILogger, assert } from "graphai";
5
2
  const nijovoiceApiKey = process.env.NIJIVOICE_API_KEY ?? "";
6
3
  const errorMessage = [
7
4
  "TTS NijiVoice: No API key. ",
@@ -9,10 +6,10 @@ const errorMessage = [
9
6
  "1. Obtain an API key from Niji Voice (https://platform.nijivoice.com/) and set it as the NIJIVOICE_API_KEY environment variable.",
10
7
  '2. Use OpenAI\'s TTS instead of Niji Voice by changing speechParams.provider from "nijivoice" to "openai".',
11
8
  ].join("\n");
12
- const ttsNijivoiceAgent = async ({ params, namedInputs }) => {
9
+ export const ttsNijivoiceAgent = async ({ params, namedInputs }) => {
13
10
  const { apiKey, suppressError, voice, speed, speed_global } = params;
14
11
  const { text } = namedInputs;
15
- (0, graphai_1.assert)(apiKey ?? nijovoiceApiKey, errorMessage);
12
+ assert(apiKey ?? nijovoiceApiKey, errorMessage);
16
13
  const url = `https://api.nijivoice.com/api/platform/v1/voice-actors/${voice}/generate-voice`;
17
14
  const options = {
18
15
  method: "POST",
@@ -40,7 +37,7 @@ const ttsNijivoiceAgent = async ({ params, namedInputs }) => {
40
37
  error: voiceJson,
41
38
  };
42
39
  }
43
- console.error(voiceJson);
40
+ GraphAILogger.info(voiceJson);
44
41
  throw new Error("TTS Nijivoice Error");
45
42
  }
46
43
  catch (e) {
@@ -49,15 +46,14 @@ const ttsNijivoiceAgent = async ({ params, namedInputs }) => {
49
46
  error: e,
50
47
  };
51
48
  }
52
- console.error(e);
49
+ GraphAILogger.info(e);
53
50
  throw new Error("TTS Nijivoice Error");
54
51
  }
55
52
  };
56
- exports.ttsNijivoiceAgent = ttsNijivoiceAgent;
57
53
  const ttsNijivoiceAgentInfo = {
58
54
  name: "ttsNijivoiceAgent",
59
- agent: exports.ttsNijivoiceAgent,
60
- mock: exports.ttsNijivoiceAgent,
55
+ agent: ttsNijivoiceAgent,
56
+ mock: ttsNijivoiceAgent,
61
57
  samples: [],
62
58
  description: "TTS nijivoice agent",
63
59
  category: ["tts"],
@@ -65,4 +61,4 @@ const ttsNijivoiceAgentInfo = {
65
61
  repository: "https://github.com/receptron/graphai/",
66
62
  license: "MIT",
67
63
  };
68
- exports.default = ttsNijivoiceAgentInfo;
64
+ export default ttsNijivoiceAgentInfo;
@@ -1,15 +1,9 @@
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.ttsOpenaiAgent = void 0;
7
- const graphai_1 = require("graphai");
8
- const openai_1 = __importDefault(require("openai"));
9
- const ttsOpenaiAgent = async ({ namedInputs, params }) => {
1
+ import { GraphAILogger } from "graphai";
2
+ import OpenAI from "openai";
3
+ export const ttsOpenaiAgent = async ({ namedInputs, params }) => {
10
4
  const { text } = namedInputs;
11
5
  const { apiKey, model, voice, suppressError, instructions } = params;
12
- const openai = new openai_1.default({ apiKey });
6
+ const openai = new OpenAI({ apiKey });
13
7
  try {
14
8
  const tts_options = {
15
9
  model: model ?? "gpt-4o-mini-tts", // "tts-1",
@@ -19,7 +13,7 @@ const ttsOpenaiAgent = async ({ namedInputs, params }) => {
19
13
  if (instructions) {
20
14
  tts_options["instructions"] = instructions;
21
15
  }
22
- graphai_1.GraphAILogger.log("ttsOptions", tts_options);
16
+ GraphAILogger.log("ttsOptions", tts_options);
23
17
  const response = await openai.audio.speech.create(tts_options);
24
18
  const buffer = Buffer.from(await response.arrayBuffer());
25
19
  return { buffer };
@@ -30,15 +24,14 @@ const ttsOpenaiAgent = async ({ namedInputs, params }) => {
30
24
  error: e,
31
25
  };
32
26
  }
33
- console.error(e);
27
+ GraphAILogger.info(e);
34
28
  throw new Error("TTS OpenAI Error");
35
29
  }
36
30
  };
37
- exports.ttsOpenaiAgent = ttsOpenaiAgent;
38
31
  const ttsOpenaiAgentInfo = {
39
32
  name: "ttsOpenaiAgent",
40
- agent: exports.ttsOpenaiAgent,
41
- mock: exports.ttsOpenaiAgent,
33
+ agent: ttsOpenaiAgent,
34
+ mock: ttsOpenaiAgent,
42
35
  samples: [],
43
36
  description: "OpenAI TTS agent",
44
37
  category: ["tts"],
@@ -47,4 +40,4 @@ const ttsOpenaiAgentInfo = {
47
40
  license: "MIT",
48
41
  environmentVariables: ["OPENAI_API_KEY"],
49
42
  };
50
- exports.default = ttsOpenaiAgentInfo;
43
+ export default ttsOpenaiAgentInfo;
@@ -1,5 +1,5 @@
1
1
  import type { AgentFunction, AgentFunctionInfo, DefaultConfigData } from "graphai";
2
- import { MulmoScript } from "../types";
2
+ import { MulmoScript } from "../types/index.js";
3
3
  interface ValidateMulmoScriptInputs {
4
4
  text: string;
5
5
  }
@@ -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
@@ -1,10 +1,13 @@
1
- export declare const args: {
1
+ export declare const getArgs: () => {
2
2
  [x: string]: unknown;
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;
9
+ pdf_mode: string;
10
+ pdf_size: string;
8
11
  _: (string | number)[];
9
12
  $0: string;
10
13
  };
package/lib/cli/args.js CHANGED
@@ -1,38 +1,55 @@
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",
15
- demandOption: false,
16
- type: "string",
17
- })
18
- .option("i", {
19
- alias: "imagedir",
20
- description: "image dir",
21
- demandOption: false,
22
- type: "string",
23
- })
24
- .command("$0 <action> <file>", "Run mulmocast", (yargs) => {
25
- return yargs
26
- .positional("action", {
27
- describe: "action to perform",
28
- choices: ["translate", "audio", "images", "movie", "preprocess"],
1
+ import yargs from "yargs";
2
+ import { hideBin } from "yargs/helpers";
3
+ import { commonOptions } from "./common.js";
4
+ import { pdf_modes, pdf_sizes } 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,
29
18
  type: "string",
30
19
  })
31
- .positional("file", {
32
- describe: "Mulmo Script File",
20
+ .option("f", {
21
+ alias: "force",
22
+ description: "force generate",
23
+ demandOption: false,
24
+ default: false,
25
+ type: "boolean",
26
+ })
27
+ .option("pdf_mode", {
28
+ description: "pdf mode",
29
+ demandOption: false,
30
+ choices: pdf_modes,
33
31
  type: "string",
34
- });
35
- })
36
- .strict()
37
- .help()
38
- .parseSync();
32
+ default: "slide",
33
+ })
34
+ .option("pdf_size", {
35
+ choices: pdf_sizes,
36
+ default: "letter",
37
+ describe: "PDF paper size (default: letter for US standard)",
38
+ })
39
+ .command("$0 <action> <file>", "Run mulmocast", (yargs) => {
40
+ return yargs
41
+ .positional("action", {
42
+ describe: "action to perform",
43
+ choices: ["translate", "audio", "images", "movie", "pdf", "preprocess"],
44
+ type: "string",
45
+ })
46
+ .positional("file", {
47
+ describe: "Mulmo Script File",
48
+ type: "string",
49
+ });
50
+ })
51
+ .strict()
52
+ .help()
53
+ .alias("help", "h")
54
+ .parseSync();
55
+ };
package/lib/cli/cli.d.ts CHANGED
@@ -1,2 +1,16 @@
1
1
  #!/usr/bin/env node
2
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
+ };