mulmocast 0.1.7 → 1.1.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 (75) hide show
  1. package/assets/templates/akira_comic.json +1 -1
  2. package/assets/templates/ani.json +3 -3
  3. package/assets/templates/ani_ja.json +4 -5
  4. package/assets/templates/characters.json +1 -1
  5. package/assets/templates/children_book.json +1 -1
  6. package/assets/templates/comic_strips.json +1 -1
  7. package/assets/templates/drslump_comic.json +1 -1
  8. package/assets/templates/ghibli_comic.json +1 -1
  9. package/assets/templates/ghibli_image_only.json +1 -1
  10. package/assets/templates/ghibli_shorts.json +2 -3
  11. package/assets/templates/ghost_comic.json +1 -1
  12. package/assets/templates/onepiece_comic.json +1 -1
  13. package/assets/templates/portrait_movie.json +1 -1
  14. package/assets/templates/realistic_movie.json +1 -1
  15. package/assets/templates/sensei_and_taro.json +4 -5
  16. package/assets/templates/shorts.json +1 -1
  17. package/assets/templates/trailer.json +1 -1
  18. package/lib/actions/audio.js +6 -7
  19. package/lib/actions/image_agents.d.ts +46 -76
  20. package/lib/actions/image_agents.js +18 -3
  21. package/lib/actions/images.js +65 -4
  22. package/lib/actions/movie.js +3 -2
  23. package/lib/agents/index.d.ts +3 -1
  24. package/lib/agents/index.js +3 -1
  25. package/lib/agents/lipsync_replicate_agent.d.ts +5 -0
  26. package/lib/agents/lipsync_replicate_agent.js +57 -0
  27. package/lib/agents/movie_replicate_agent.js +17 -5
  28. package/lib/agents/sound_effect_replicate_agent.d.ts +5 -0
  29. package/lib/agents/sound_effect_replicate_agent.js +59 -0
  30. package/lib/data/index.d.ts +2 -0
  31. package/lib/data/index.js +2 -0
  32. package/lib/data/promptTemplates.d.ts +695 -0
  33. package/lib/data/promptTemplates.js +957 -0
  34. package/lib/data/scriptTemplates.d.ts +233 -0
  35. package/lib/data/scriptTemplates.js +580 -0
  36. package/lib/index.browser.d.ts +2 -1
  37. package/lib/index.browser.js +2 -1
  38. package/lib/mcp/server.js +2 -2
  39. package/lib/methods/index.d.ts +1 -0
  40. package/lib/methods/index.js +1 -0
  41. package/lib/methods/mulmo_presentation_style.d.ts +18 -5
  42. package/lib/methods/mulmo_presentation_style.js +31 -20
  43. package/lib/methods/mulmo_script.d.ts +4 -0
  44. package/lib/methods/mulmo_script.js +31 -0
  45. package/lib/tools/story_to_script.js +2 -2
  46. package/lib/types/agent.d.ts +19 -0
  47. package/lib/types/schema.d.ts +628 -246
  48. package/lib/types/schema.js +31 -12
  49. package/lib/types/type.d.ts +2 -3
  50. package/lib/utils/assets.d.ts +18 -0
  51. package/lib/utils/assets.js +101 -0
  52. package/lib/utils/context.d.ts +40 -12
  53. package/lib/utils/context.js +3 -1
  54. package/lib/utils/file.d.ts +12 -4
  55. package/lib/utils/file.js +48 -24
  56. package/lib/utils/preprocess.d.ts +30 -11
  57. package/lib/utils/preprocess.js +7 -5
  58. package/lib/utils/provider2agent.d.ts +30 -1
  59. package/lib/utils/provider2agent.js +86 -0
  60. package/lib/utils/utils.js +6 -0
  61. package/package.json +8 -4
  62. package/scripts/templates/business.json +1 -1
  63. package/scripts/templates/children_book.json +1 -1
  64. package/scripts/templates/coding.json +1 -1
  65. package/scripts/templates/html.json +1 -1
  66. package/scripts/templates/image_prompt_only_template.json +1 -1
  67. package/scripts/templates/image_prompts_template.json +1 -1
  68. package/scripts/templates/image_refs.json +1 -1
  69. package/scripts/templates/movie_prompts_no_text_template.json +1 -1
  70. package/scripts/templates/movie_prompts_template.json +1 -1
  71. package/scripts/templates/presentation.json +1 -1
  72. package/scripts/templates/sensei_and_taro.json +1 -1
  73. package/scripts/templates/shorts_template.json +1 -1
  74. package/scripts/templates/text_only_template.json +1 -1
  75. package/scripts/templates/voice_over.json +1 -1
@@ -0,0 +1,57 @@
1
+ import { readFileSync } from "fs";
2
+ import { GraphAILogger } from "graphai";
3
+ import Replicate from "replicate";
4
+ import { provider2LipSyncAgent } from "../utils/provider2agent.js";
5
+ export const lipSyncReplicateAgent = async ({ namedInputs, params, config, }) => {
6
+ const { movieFile, audioFile } = namedInputs;
7
+ const apiKey = config?.apiKey;
8
+ const model = params.model ?? provider2LipSyncAgent.replicate.defaultModel;
9
+ if (!apiKey) {
10
+ throw new Error("REPLICATE_API_TOKEN environment variable is required");
11
+ }
12
+ const replicate = new Replicate({
13
+ auth: apiKey,
14
+ });
15
+ const videoBuffer = readFileSync(movieFile);
16
+ const audioBuffer = readFileSync(audioFile);
17
+ const videoUri = `data:video/quicktime;base64,${videoBuffer.toString("base64")}`;
18
+ const audioUri = `data:audio/wav;base64,${audioBuffer.toString("base64")}`;
19
+ const input = {
20
+ video: videoUri,
21
+ audio: audioUri,
22
+ duration: params.duration,
23
+ };
24
+ try {
25
+ const model_identifier = provider2LipSyncAgent.replicate.modelParams[model]?.identifier ?? model;
26
+ const output = await replicate.run(model_identifier, {
27
+ input,
28
+ });
29
+ if (output && typeof output === "object" && "url" in output) {
30
+ const videoUrl = output.url();
31
+ const videoResponse = await fetch(videoUrl);
32
+ if (!videoResponse.ok) {
33
+ throw new Error(`Error downloading video: ${videoResponse.status} - ${videoResponse.statusText}`);
34
+ }
35
+ const arrayBuffer = await videoResponse.arrayBuffer();
36
+ return { buffer: Buffer.from(arrayBuffer) };
37
+ }
38
+ return undefined;
39
+ }
40
+ catch (error) {
41
+ GraphAILogger.info("Failed to generate lip sync:", error.message);
42
+ throw error;
43
+ }
44
+ };
45
+ const lipSyncReplicateAgentInfo = {
46
+ name: "lipSyncReplicateAgent",
47
+ agent: lipSyncReplicateAgent,
48
+ mock: lipSyncReplicateAgent,
49
+ samples: [],
50
+ description: "Replicate Lip Sync agent (video + audio to video)",
51
+ category: ["movie"],
52
+ author: "Receptron Team",
53
+ repository: "https://github.com/receptron/mulmocast-cli/",
54
+ license: "MIT",
55
+ environmentVariables: ["REPLICATE_API_TOKEN"],
56
+ };
57
+ export default lipSyncReplicateAgentInfo;
@@ -11,6 +11,7 @@ async function generateMovie(model, apiKey, prompt, imagePath, aspectRatio, dura
11
11
  duration,
12
12
  image: undefined,
13
13
  start_image: undefined,
14
+ first_frame_image: undefined,
14
15
  aspect_ratio: aspectRatio, // only for bytedance/seedance-1-lite
15
16
  // resolution: "720p", // only for bytedance/seedance-1-lite
16
17
  // fps: 24, // only for bytedance/seedance-1-lite
@@ -22,15 +23,19 @@ async function generateMovie(model, apiKey, prompt, imagePath, aspectRatio, dura
22
23
  if (imagePath) {
23
24
  const buffer = readFileSync(imagePath);
24
25
  const base64Image = `data:image/png;base64,${buffer.toString("base64")}`;
25
- if (model === "kwaivgi/kling-v2.1" || model === "kwaivgi/kling-v1.6-pro" || model === "minimax/hailuo-02") {
26
- input.start_image = base64Image;
26
+ const start_image = provider2MovieAgent.replicate.modelParams[model]?.start_image;
27
+ if (start_image === "first_frame_image" || start_image === "image" || start_image === "start_image") {
28
+ input[start_image] = base64Image;
29
+ }
30
+ else if (start_image === undefined) {
31
+ throw new Error(`Model ${model} does not support image-to-video generation`);
27
32
  }
28
33
  else {
29
34
  input.image = base64Image;
30
35
  }
31
36
  }
32
37
  try {
33
- const output = await replicate.run(model ?? provider2MovieAgent.replicate.defaultModel, { input });
38
+ const output = await replicate.run(model, { input });
34
39
  // Download the generated video
35
40
  if (output && typeof output === "object" && "url" in output) {
36
41
  const videoUrl = output.url();
@@ -62,13 +67,20 @@ export const getAspectRatio = (canvasSize) => {
62
67
  export const movieReplicateAgent = async ({ namedInputs, params, config, }) => {
63
68
  const { prompt, imagePath } = namedInputs;
64
69
  const aspectRatio = getAspectRatio(params.canvasSize);
65
- const duration = params.duration ?? 5;
70
+ const model = params.model ?? provider2MovieAgent.replicate.defaultModel;
71
+ if (!provider2MovieAgent.replicate.modelParams[model]) {
72
+ throw new Error(`Model ${model} is not supported`);
73
+ }
74
+ const duration = params.duration ?? provider2MovieAgent.replicate.modelParams[model].durations[0] ?? 5;
75
+ if (!provider2MovieAgent.replicate.modelParams[model].durations.includes(duration)) {
76
+ throw new Error(`Duration ${duration} is not supported for model ${model}. Supported durations: ${provider2MovieAgent.replicate.modelParams[model].durations.join(", ")}`);
77
+ }
66
78
  const apiKey = config?.apiKey;
67
79
  if (!apiKey) {
68
80
  throw new Error("REPLICATE_API_TOKEN environment variable is required");
69
81
  }
70
82
  try {
71
- const buffer = await generateMovie(params.model, apiKey, prompt, imagePath, aspectRatio, duration);
83
+ const buffer = await generateMovie(model, apiKey, prompt, imagePath, aspectRatio, duration);
72
84
  if (buffer) {
73
85
  return { buffer };
74
86
  }
@@ -0,0 +1,5 @@
1
+ import type { AgentFunction, AgentFunctionInfo } from "graphai";
2
+ import type { AgentBufferResult, SoundEffectAgentInputs, ReplicateSoundEffectAgentParams, ReplicateSoundEffectAgentConfig } from "../types/agent.js";
3
+ export declare const soundEffectReplicateAgent: AgentFunction<ReplicateSoundEffectAgentParams, AgentBufferResult, SoundEffectAgentInputs, ReplicateSoundEffectAgentConfig>;
4
+ declare const soundEffectReplicateAgentInfo: AgentFunctionInfo;
5
+ export default soundEffectReplicateAgentInfo;
@@ -0,0 +1,59 @@
1
+ import { readFileSync } from "fs";
2
+ import { GraphAILogger } from "graphai";
3
+ import Replicate from "replicate";
4
+ import { provider2SoundEffectAgent } from "../utils/provider2agent.js";
5
+ export const soundEffectReplicateAgent = async ({ namedInputs, params, config }) => {
6
+ const { prompt, movieFile } = namedInputs;
7
+ const apiKey = config?.apiKey;
8
+ const model = params.model ?? provider2SoundEffectAgent.replicate.defaultModel;
9
+ if (!apiKey) {
10
+ throw new Error("REPLICATE_API_TOKEN environment variable is required");
11
+ }
12
+ const replicate = new Replicate({
13
+ auth: apiKey,
14
+ });
15
+ const buffer = readFileSync(movieFile);
16
+ const uri = `data:video/quicktime;base64,${buffer.toString("base64")}`;
17
+ const input = {
18
+ video: uri,
19
+ prompt,
20
+ duration: params.duration,
21
+ // seed: -1,
22
+ // num_steps: 25,
23
+ // cfg_strength: 4.5,
24
+ // negative_prompt: "music"
25
+ };
26
+ try {
27
+ const model_identifier = provider2SoundEffectAgent.replicate.modelParams[model]?.identifier ?? model;
28
+ const output = await replicate.run(model_identifier, {
29
+ input,
30
+ });
31
+ if (output && typeof output === "object" && "url" in output) {
32
+ const videoUrl = output.url();
33
+ const videoResponse = await fetch(videoUrl);
34
+ if (!videoResponse.ok) {
35
+ throw new Error(`Error downloading video: ${videoResponse.status} - ${videoResponse.statusText}`);
36
+ }
37
+ const arrayBuffer = await videoResponse.arrayBuffer();
38
+ return { buffer: Buffer.from(arrayBuffer) };
39
+ }
40
+ return undefined;
41
+ }
42
+ catch (error) {
43
+ GraphAILogger.info("Failed to generate sound effect:", error.message);
44
+ throw error;
45
+ }
46
+ };
47
+ const soundEffectReplicateAgentInfo = {
48
+ name: "soundEffectReplicateAgent",
49
+ agent: soundEffectReplicateAgent,
50
+ mock: soundEffectReplicateAgent,
51
+ samples: [],
52
+ description: "Replicate Sound Effect agent (movie to movie)",
53
+ category: ["movie"],
54
+ author: "Receptron Team",
55
+ repository: "https://github.com/receptron/mulmocast-cli/",
56
+ license: "MIT",
57
+ environmentVariables: ["REPLICATE_API_TOKEN"],
58
+ };
59
+ export default soundEffectReplicateAgentInfo;
@@ -0,0 +1,2 @@
1
+ export * from "./promptTemplates.js";
2
+ export * from "./scriptTemplates.js";
@@ -0,0 +1,2 @@
1
+ export * from "./promptTemplates.js";
2
+ export * from "./scriptTemplates.js";