mulmocast 2.6.9 → 2.6.10

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.
@@ -60,14 +60,16 @@ export const imageGenAIAgent = async ({ namedInputs, params, config, }) => {
60
60
  const model = params.model ?? provider2ImageAgent["google"].defaultModel;
61
61
  const apiKey = config?.apiKey;
62
62
  const ai = params.vertexai_project
63
- ? new GoogleGenAI({
64
- vertexai: true,
65
- project: params.vertexai_project,
66
- location: params.vertexai_location ?? "us-central1",
67
- })
63
+ ? (() => {
64
+ const location = params.vertexai_location ?? "us-central1";
65
+ if (model === "gemini-3-pro-image-preview" && location !== "global") {
66
+ GraphAILogger.warn(`imageGenAIAgent: model "${model}" on Vertex AI is only available in location "global", but got "${location}". Set imageParams.vertexai_location to "global".`);
67
+ }
68
+ return new GoogleGenAI({ vertexai: true, project: params.vertexai_project, location });
69
+ })()
68
70
  : (() => {
69
71
  if (!apiKey) {
70
- throw new Error("Google GenAI API key is required (GEMINI_API_KEY)", {
72
+ throw new Error("Google GenAI authentication is required. Either set GEMINI_API_KEY (Gemini API) or specify imageParams.vertexai_project (Vertex AI). See docs/vertexai_en.md or docs/vertexai_ja.md.", {
71
73
  cause: apiKeyMissingError("imageGenAIAgent", imageAction, "GEMINI_API_KEY"),
72
74
  });
73
75
  }
@@ -4,6 +4,22 @@ import Replicate from "replicate";
4
4
  import { getAspectRatio } from "./movie_replicate_agent.js";
5
5
  import { apiKeyMissingError, agentIncorrectAPIKeyError, agentGenerationError, agentInvalidResponseError, imageAction, imageFileTarget, hasCause, } from "../utils/error_cause.js";
6
6
  import { provider2ImageAgent } from "../types/provider2agent.js";
7
+ // Replicate image models return one of: FileOutput (object with url() method),
8
+ // Array<FileOutput>, string URL, or { url: string }. Normalize to URL string/URL.
9
+ const extractImageUrl = (output) => {
10
+ if (typeof output === "string")
11
+ return output;
12
+ if (Array.isArray(output))
13
+ return output.length > 0 ? extractImageUrl(output[0]) : undefined;
14
+ if (output && typeof output === "object" && "url" in output) {
15
+ const url = output.url;
16
+ if (typeof url === "function")
17
+ return url();
18
+ if (typeof url === "string")
19
+ return url;
20
+ }
21
+ return undefined;
22
+ };
7
23
  export const imageReplicateAgent = async ({ namedInputs, params, config, }) => {
8
24
  const { prompt, referenceImages } = namedInputs;
9
25
  const { canvasSize } = params;
@@ -29,22 +45,21 @@ export const imageReplicateAgent = async ({ namedInputs, params, config, }) => {
29
45
  }
30
46
  try {
31
47
  const output = await replicate.run(model, { input });
32
- // Download the generated video
33
- if (output && Array.isArray(output) && output.length > 0 && typeof output[0] === "object" && "url" in output[0]) {
34
- const imageUrl = output[0].url();
35
- const imageResponse = await fetch(imageUrl);
36
- if (!imageResponse.ok) {
37
- throw new Error(`Error downloading image: ${imageResponse.status} - ${imageResponse.statusText}`, {
38
- cause: agentGenerationError("imageReplicateAgent", imageAction, imageFileTarget),
39
- });
40
- }
41
- const arrayBuffer = await imageResponse.arrayBuffer();
42
- const buffer = Buffer.from(arrayBuffer);
43
- return { buffer };
48
+ const imageUrl = extractImageUrl(output);
49
+ if (!imageUrl) {
50
+ throw new Error("ERROR: generateImage returned undefined", {
51
+ cause: agentInvalidResponseError("imageReplicateAgent", imageAction, imageFileTarget),
52
+ });
44
53
  }
45
- throw new Error("ERROR: generateImage returned undefined", {
46
- cause: agentInvalidResponseError("imageReplicateAgent", imageAction, imageFileTarget),
47
- });
54
+ const imageResponse = await fetch(imageUrl);
55
+ if (!imageResponse.ok) {
56
+ throw new Error(`Error downloading image: ${imageResponse.status} - ${imageResponse.statusText}`, {
57
+ cause: agentGenerationError("imageReplicateAgent", imageAction, imageFileTarget),
58
+ });
59
+ }
60
+ const arrayBuffer = await imageResponse.arrayBuffer();
61
+ const buffer = Buffer.from(arrayBuffer);
62
+ return { buffer };
48
63
  }
49
64
  catch (error) {
50
65
  GraphAILogger.info("Replicate generation error:", error);
@@ -175,7 +175,7 @@ export const movieGenAIAgent = async ({ namedInputs, params, config, }) => {
175
175
  })
176
176
  : (() => {
177
177
  if (!apiKey) {
178
- throw new Error("Google GenAI API key is required (GEMINI_API_KEY)", {
178
+ throw new Error("Google GenAI authentication is required. Either set GEMINI_API_KEY (Gemini API) or specify movieParams.vertexai_project (Vertex AI). See docs/vertexai_en.md or docs/vertexai_ja.md.", {
179
179
  cause: apiKeyMissingError("movieGenAIAgent", imageAction, "GEMINI_API_KEY"),
180
180
  });
181
181
  }
@@ -136,6 +136,11 @@ export const movieReplicateAgent = async ({ namedInputs, params, config, }) => {
136
136
  cause: agentGenerationError("movieReplicateAgent", imageAction, unsupportedModelTarget),
137
137
  });
138
138
  }
139
+ if (provider2MovieAgent.replicate.modelParams[model].start_image_required && !imagePath) {
140
+ throw new Error(`Model ${model} requires a start image (image-to-video only)`, {
141
+ cause: agentGenerationError("movieReplicateAgent", imageAction, unsupportedModelTarget),
142
+ });
143
+ }
139
144
  const duration = getModelDuration("replicate", model, params.duration);
140
145
  if (duration === undefined || !provider2MovieAgent.replicate.modelParams[model].durations.includes(duration)) {
141
146
  throw new Error(`Duration ${duration} is not supported for model ${model}. Supported durations: ${provider2MovieAgent.replicate.modelParams[model].durations.join(", ")}`, {
@@ -84,6 +84,7 @@ type MovieAudioSpec = {
84
84
  type ReplicateMovieModelParams = {
85
85
  durations: number[];
86
86
  start_image: string | undefined;
87
+ start_image_required?: boolean;
87
88
  last_image?: string;
88
89
  reference_images_param?: string;
89
90
  audio: MovieAudioSpec;
@@ -69,7 +69,23 @@ export const provider2ImageAgent = {
69
69
  replicate: {
70
70
  agentName: "imageReplicateAgent",
71
71
  defaultModel: "bytedance/seedream-4",
72
- models: ["bytedance/seedream-4", "qwen/qwen-image"],
72
+ models: [
73
+ "bytedance/seedream-4",
74
+ "qwen/qwen-image",
75
+ "black-forest-labs/flux-2-pro",
76
+ "black-forest-labs/flux-2-dev",
77
+ "black-forest-labs/flux-1.1-pro",
78
+ "black-forest-labs/flux-1.1-pro-ultra",
79
+ "black-forest-labs/flux-pro",
80
+ "black-forest-labs/flux-dev",
81
+ "black-forest-labs/flux-schnell",
82
+ "ideogram-ai/ideogram-v3-turbo",
83
+ "ideogram-ai/ideogram-v3-balanced",
84
+ "ideogram-ai/ideogram-v3-quality",
85
+ "recraft-ai/recraft-v3",
86
+ "stability-ai/stable-diffusion-3.5-large",
87
+ "luma/photon",
88
+ ],
73
89
  keyName: "REPLICATE_API_TOKEN",
74
90
  },
75
91
  mock: {
@@ -112,6 +128,10 @@ export const provider2MovieAgent = {
112
128
  "runwayml/gen-4.5",
113
129
  "kwaivgi/kling-v3-omni-video",
114
130
  "kwaivgi/kling-v3-video",
131
+ "alibaba/happyhorse-1.0",
132
+ "minimax/hailuo-2.3",
133
+ "minimax/hailuo-2.3-fast",
134
+ "pixverse/pixverse-v5",
115
135
  ],
116
136
  modelParams: {
117
137
  "bytedance/seedance-1-lite": {
@@ -273,6 +293,36 @@ export const provider2MovieAgent = {
273
293
  audio: { mode: AUDIO_MODE_OPTIONAL, param: "generate_audio" },
274
294
  price_per_sec: 0.3,
275
295
  },
296
+ // TODO: price_per_sec for the models below is a coarse approximation.
297
+ // Actual Replicate pricing varies by resolution / duration / quality and
298
+ // cannot be expressed as a single per-second number. Verify each model at
299
+ // https://replicate.com/<owner>/<model> when this field starts being consumed.
300
+ "alibaba/happyhorse-1.0": {
301
+ durations: [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
302
+ start_image: "image",
303
+ audio: { mode: AUDIO_MODE_NEVER },
304
+ price_per_sec: 0.05,
305
+ },
306
+ "minimax/hailuo-2.3": {
307
+ durations: [6, 10],
308
+ start_image: "first_frame_image",
309
+ audio: { mode: AUDIO_MODE_NEVER },
310
+ price_per_sec: 0.1,
311
+ },
312
+ "minimax/hailuo-2.3-fast": {
313
+ durations: [6, 10],
314
+ start_image: "first_frame_image",
315
+ start_image_required: true,
316
+ audio: { mode: AUDIO_MODE_NEVER },
317
+ price_per_sec: 0.06,
318
+ },
319
+ "pixverse/pixverse-v5": {
320
+ durations: [5, 8],
321
+ start_image: "image",
322
+ last_image: "last_frame_image",
323
+ audio: { mode: AUDIO_MODE_NEVER },
324
+ price_per_sec: 0.12,
325
+ },
276
326
  },
277
327
  },
278
328
  google: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mulmocast",
3
- "version": "2.6.9",
3
+ "version": "2.6.10",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "lib/index.node.js",
@@ -0,0 +1,29 @@
1
+ {
2
+ "$mulmocast": {
3
+ "version": "1.1"
4
+ },
5
+ "canvasSize": {
6
+ "width": 1024,
7
+ "height": 1024
8
+ },
9
+ "imageParams": {
10
+ "provider": "replicate",
11
+ "model": "black-forest-labs/flux-2-pro"
12
+ },
13
+ "speechParams": {
14
+ "speakers": {
15
+ "Presenter": {
16
+ "voiceId": "shimmer",
17
+ "provider": "openai"
18
+ }
19
+ }
20
+ },
21
+ "lang": "en",
22
+ "beats": [
23
+ {
24
+ "speaker": "Presenter",
25
+ "text": "Testing flux-2-pro on Replicate.",
26
+ "imagePrompt": "A cinematic photo of a red panda holding a tiny espresso cup, soft window light, shallow depth of field"
27
+ }
28
+ ]
29
+ }
@@ -0,0 +1,79 @@
1
+ {
2
+ "$mulmocast": { "version": "1.1" },
3
+ "canvasSize": { "width": 1024, "height": 1024 },
4
+ "imageParams": {
5
+ "provider": "replicate"
6
+ },
7
+ "speechParams": {
8
+ "speakers": {
9
+ "Presenter": {
10
+ "voiceId": "shimmer",
11
+ "provider": "openai"
12
+ }
13
+ }
14
+ },
15
+ "audioParams": { "bgmVolume": 0 },
16
+ "lang": "en",
17
+ "title": "Replicate Image Models Showcase",
18
+ "beats": [
19
+ {
20
+ "speaker": "Presenter",
21
+ "text": "PROMPT: A red panda holding a tiny espresso cup, soft window light, cinematic.",
22
+ "image": {
23
+ "type": "textSlide",
24
+ "slide": {
25
+ "title": "PROMPT: A red panda holding a tiny espresso cup, soft window light, cinematic."
26
+ }
27
+ }
28
+ },
29
+ {
30
+ "id": "flux-2-pro",
31
+ "speaker": "Presenter",
32
+ "text": "Flux 2 Pro from Black Forest Labs — high quality text-to-image.",
33
+ "imagePrompt": "A red panda holding a tiny espresso cup, soft window light, cinematic",
34
+ "imageParams": { "model": "black-forest-labs/flux-2-pro" }
35
+ },
36
+ {
37
+ "id": "flux-1.1-pro-ultra",
38
+ "speaker": "Presenter",
39
+ "text": "Flux 1.1 Pro Ultra — ultra-high resolution variant.",
40
+ "imagePrompt": "A red panda holding a tiny espresso cup, soft window light, cinematic",
41
+ "imageParams": { "model": "black-forest-labs/flux-1.1-pro-ultra" }
42
+ },
43
+ {
44
+ "id": "flux-schnell",
45
+ "speaker": "Presenter",
46
+ "text": "Flux Schnell — fastest open Flux model.",
47
+ "imagePrompt": "A red panda holding a tiny espresso cup, soft window light, cinematic",
48
+ "imageParams": { "model": "black-forest-labs/flux-schnell" }
49
+ },
50
+ {
51
+ "id": "ideogram-v3-turbo",
52
+ "speaker": "Presenter",
53
+ "text": "Ideogram v3 Turbo — strong at typography and posters.",
54
+ "imagePrompt": "A red panda holding a tiny espresso cup, soft window light, cinematic",
55
+ "imageParams": { "model": "ideogram-ai/ideogram-v3-turbo" }
56
+ },
57
+ {
58
+ "id": "recraft-v3",
59
+ "speaker": "Presenter",
60
+ "text": "Recraft v3 — strong at clean illustration and text in images.",
61
+ "imagePrompt": "A red panda holding a tiny espresso cup, soft window light, cinematic",
62
+ "imageParams": { "model": "recraft-ai/recraft-v3" }
63
+ },
64
+ {
65
+ "id": "sd-3.5-large",
66
+ "speaker": "Presenter",
67
+ "text": "Stable Diffusion 3.5 Large — open weights baseline.",
68
+ "imagePrompt": "A red panda holding a tiny espresso cup, soft window light, cinematic",
69
+ "imageParams": { "model": "stability-ai/stable-diffusion-3.5-large" }
70
+ },
71
+ {
72
+ "id": "luma-photon",
73
+ "speaker": "Presenter",
74
+ "text": "Luma Photon — strong photorealism and style transfer.",
75
+ "imagePrompt": "A red panda holding a tiny espresso cup, soft window light, cinematic",
76
+ "imageParams": { "model": "luma/photon" }
77
+ }
78
+ ]
79
+ }
@@ -0,0 +1,50 @@
1
+ {
2
+ "$mulmocast": { "version": "1.1" },
3
+ "movieParams": {
4
+ "provider": "replicate"
5
+ },
6
+ "audioParams": { "bgmVolume": 0 },
7
+ "captionParams": { "lang": "en" },
8
+ "lang": "en",
9
+ "title": "Replicate New Movie Models Showcase",
10
+ "beats": [
11
+ {
12
+ "text": "PROMPT: a woman is walking through a busy Tokyo street at night, she is wearing dark sunglasses",
13
+ "image": {
14
+ "type": "textSlide",
15
+ "slide": {
16
+ "title": "PROMPT: a woman is walking through a busy Tokyo street at night, she is wearing dark sunglasses"
17
+ }
18
+ }
19
+ },
20
+ {
21
+ "id": "alibaba-happyhorse",
22
+ "text": "alibaba/happyhorse-1.0",
23
+ "duration": 5,
24
+ "moviePrompt": "a woman is walking through a busy Tokyo street at night, she is wearing dark sunglasses",
25
+ "movieParams": { "model": "alibaba/happyhorse-1.0" }
26
+ },
27
+ {
28
+ "id": "hailuo-23",
29
+ "text": "minimax/hailuo-2.3",
30
+ "duration": 6,
31
+ "moviePrompt": "a woman is walking through a busy Tokyo street at night, she is wearing dark sunglasses",
32
+ "movieParams": { "model": "minimax/hailuo-2.3" }
33
+ },
34
+ {
35
+ "id": "pixverse-v5",
36
+ "text": "pixverse/pixverse-v5",
37
+ "duration": 5,
38
+ "moviePrompt": "a woman is walking through a busy Tokyo street at night, she is wearing dark sunglasses",
39
+ "movieParams": { "model": "pixverse/pixverse-v5" }
40
+ },
41
+ {
42
+ "id": "hailuo-23-fast",
43
+ "text": "minimax/hailuo-2.3-fast (i2v: starts from a generated still image)",
44
+ "duration": 6,
45
+ "imagePrompt": "a woman wearing dark sunglasses standing on a busy Tokyo street at night, neon reflections, cinematic still",
46
+ "moviePrompt": "the woman starts walking forward, neon reflections shimmer on the wet pavement",
47
+ "movieParams": { "model": "minimax/hailuo-2.3-fast" }
48
+ }
49
+ ]
50
+ }