mulmocast 1.1.5 → 1.1.7

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 (77) hide show
  1. package/lib/actions/audio.js +10 -1
  2. package/lib/actions/image_agents.d.ts +3 -12
  3. package/lib/actions/image_agents.js +12 -8
  4. package/lib/actions/images.js +2 -1
  5. package/lib/actions/translate.d.ts +51 -2
  6. package/lib/actions/translate.js +193 -148
  7. package/lib/agents/combine_audio_files_agent.js +1 -1
  8. package/lib/agents/lipsync_replicate_agent.js +10 -3
  9. package/lib/agents/tts_nijivoice_agent.js +1 -1
  10. package/lib/cli/commands/audio/handler.js +1 -1
  11. package/lib/cli/commands/image/handler.js +1 -1
  12. package/lib/cli/commands/movie/handler.js +1 -1
  13. package/lib/cli/commands/pdf/handler.js +1 -1
  14. package/lib/cli/helpers.d.ts +1 -4
  15. package/lib/cli/helpers.js +3 -2
  16. package/lib/index.common.d.ts +1 -0
  17. package/lib/index.common.js +1 -0
  18. package/lib/mcp/server.js +1 -1
  19. package/lib/methods/mulmo_presentation_style.d.ts +3 -2
  20. package/lib/methods/mulmo_script.d.ts +4 -1
  21. package/lib/methods/mulmo_script.js +18 -2
  22. package/lib/methods/mulmo_studio_context.d.ts +1 -0
  23. package/lib/methods/mulmo_studio_context.js +8 -0
  24. package/lib/types/agent.d.ts +1 -0
  25. package/lib/types/schema.d.ts +326 -230
  26. package/lib/types/schema.js +10 -3
  27. package/lib/types/type.d.ts +3 -2
  28. package/lib/utils/const.d.ts +1 -0
  29. package/lib/utils/const.js +2 -1
  30. package/lib/utils/context.d.ts +393 -50
  31. package/lib/utils/context.js +90 -57
  32. package/lib/utils/filters.d.ts +1 -0
  33. package/lib/utils/filters.js +8 -0
  34. package/lib/utils/image_plugins/mermaid.js +1 -1
  35. package/lib/utils/image_plugins/source.js +1 -1
  36. package/lib/utils/preprocess.d.ts +2 -2
  37. package/lib/utils/preprocess.js +3 -3
  38. package/lib/utils/provider2agent.d.ts +3 -2
  39. package/lib/utils/provider2agent.js +20 -2
  40. package/lib/utils/string.d.ts +1 -1
  41. package/lib/utils/string.js +12 -8
  42. package/lib/utils/utils.js +2 -6
  43. package/package.json +2 -2
  44. package/scripts/templates/image_refs.json +1 -0
  45. package/scripts/templates/voice_over.json +1 -0
  46. package/scripts/test/gpt.json +1 -0
  47. package/scripts/test/test1.json +1 -0
  48. package/scripts/test/test_audio.json +1 -0
  49. package/scripts/test/test_audio_instructions.json +1 -0
  50. package/scripts/test/test_beats.json +1 -0
  51. package/scripts/test/test_captions.json +1 -0
  52. package/scripts/test/test_elevenlabs_models.json +1 -0
  53. package/scripts/test/test_hello.json +1 -0
  54. package/scripts/test/test_hello_google.json +1 -0
  55. package/scripts/test/test_html.json +1 -0
  56. package/scripts/test/test_image_refs.json +1 -0
  57. package/scripts/test/test_images.json +1 -0
  58. package/scripts/test/test_lang.json +58 -2
  59. package/scripts/test/test_layout.json +1 -0
  60. package/scripts/test/test_lipsync.json +9 -0
  61. package/scripts/test/test_loop.json +1 -0
  62. package/scripts/test/test_media.json +1 -0
  63. package/scripts/test/test_mixed_providers.json +1 -0
  64. package/scripts/test/test_movie.json +1 -0
  65. package/scripts/test/test_no_audio.json +1 -0
  66. package/scripts/test/test_no_audio_with_credit.json +1 -0
  67. package/scripts/test/test_order.json +1 -0
  68. package/scripts/test/test_order_portrait.json +1 -0
  69. package/scripts/test/test_replicate.json +19 -0
  70. package/scripts/test/test_slideout_left_no_audio.json +1 -0
  71. package/scripts/test/test_spillover.json +1 -0
  72. package/scripts/test/test_transition.json +1 -0
  73. package/scripts/test/test_transition_no_audio.json +1 -0
  74. package/scripts/test/test_video_speed.json +1 -0
  75. package/scripts/test/test_voice_over.json +1 -0
  76. package/scripts/test/test_voices.json +1 -0
  77. package/scripts/templates/image_prompt_only_template.ts +0 -95
@@ -5,6 +5,6 @@ export const handler = async (argv) => {
5
5
  if (!context) {
6
6
  process.exit(1);
7
7
  }
8
- await runTranslateIfNeeded(context, argv);
8
+ await runTranslateIfNeeded(context);
9
9
  await images(context);
10
10
  };
@@ -5,6 +5,6 @@ export const handler = async (argv) => {
5
5
  if (!context) {
6
6
  process.exit(1);
7
7
  }
8
- await runTranslateIfNeeded(context, argv);
8
+ await runTranslateIfNeeded(context, true);
9
9
  await audio(context).then(images).then(captions).then(movie);
10
10
  };
@@ -5,7 +5,7 @@ export const handler = async (argv) => {
5
5
  if (!context) {
6
6
  process.exit(1);
7
7
  }
8
- await runTranslateIfNeeded(context, argv);
8
+ await runTranslateIfNeeded(context);
9
9
  await images(context);
10
10
  await pdf(context, argv.pdf_mode, argv.pdf_size);
11
11
  };
@@ -1,9 +1,6 @@
1
1
  import type { CliArgs } from "../types/cli_types.js";
2
2
  import { FileObject, InitOptions, MulmoStudioContext } from "../types/index.js";
3
- export declare const runTranslateIfNeeded: (context: MulmoStudioContext, argv: {
4
- l?: string;
5
- c?: string;
6
- }) => Promise<void>;
3
+ export declare const runTranslateIfNeeded: (context: MulmoStudioContext, includeCaption?: boolean) => Promise<void>;
7
4
  export declare const setGraphAILogger: (verbose: boolean | undefined, logValues?: Record<string, unknown>) => void;
8
5
  export declare const getFileObject: (args: {
9
6
  basedir?: string;
@@ -5,10 +5,11 @@ import clipboardy from "clipboardy";
5
5
  import { getBaseDirPath, getFullPath, getOutputStudioFilePath, resolveDirPath, mkdir, getOutputMultilingualFilePath, generateTimestampedFileName, } from "../utils/file.js";
6
6
  import { isHttp } from "../utils/utils.js";
7
7
  import { outDirName, imageDirName, audioDirName } from "../utils/const.js";
8
+ import { MulmoStudioContextMethods } from "../methods/mulmo_studio_context.js";
8
9
  import { translate } from "../actions/translate.js";
9
10
  import { initializeContextFromFiles } from "../utils/context.js";
10
- export const runTranslateIfNeeded = async (context, argv) => {
11
- if (argv.l || context.studio.script.captionParams?.lang) {
11
+ export const runTranslateIfNeeded = async (context, includeCaption = false) => {
12
+ if (MulmoStudioContextMethods.needTranslate(context, includeCaption)) {
12
13
  GraphAILogger.log("run translate");
13
14
  await translate(context);
14
15
  }
@@ -1,2 +1,3 @@
1
1
  export * from "./types/index.js";
2
2
  export * from "./utils/provider2agent.js";
3
+ export * from "./utils/const.js";
@@ -1,3 +1,4 @@
1
1
  // Entry point for universal code
2
2
  export * from "./types/index.js";
3
3
  export * from "./utils/provider2agent.js";
4
+ export * from "./utils/const.js";
package/lib/mcp/server.js CHANGED
@@ -104,7 +104,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
104
104
  throw new Error("Failed to initialize context from MulmoScript");
105
105
  }
106
106
  // Run translation if needed
107
- await runTranslateIfNeeded(context, argv);
107
+ await runTranslateIfNeeded(context);
108
108
  // Execute the requested command
109
109
  switch (cmd) {
110
110
  case "movie":
@@ -36,9 +36,10 @@ export declare const MulmoPresentationStyleMethods: {
36
36
  defaultModel: import("../utils/provider2agent.js").ReplicateModel;
37
37
  models: import("../utils/provider2agent.js").ReplicateModel[];
38
38
  modelParams: Record<import("../utils/provider2agent.js").ReplicateModel, {
39
- identifier?: `${string}/${string}:${string}`;
40
- video: string;
39
+ identifier?: `${string}/${string}:${string}` | `${string}/${string}`;
40
+ video?: string;
41
41
  audio: string;
42
+ image?: string;
42
43
  }>;
43
44
  };
44
45
  getConcurrency(presentationStyle: MulmoPresentationStyle): 4 | 16;
@@ -1,4 +1,7 @@
1
- import { MulmoScript } from "../types/index.js";
1
+ import { type MulmoScript, type MulmoStudioMultiLingual } from "../types/index.js";
2
2
  export declare const MulmoScriptMethods: {
3
3
  validate(script: any): MulmoScript;
4
4
  };
5
+ export declare const MulmoStudioMultiLingualMethod: {
6
+ validate(jsonData: any, studioBeatsLength: number): MulmoStudioMultiLingual;
7
+ };
@@ -1,4 +1,4 @@
1
- import { mulmoScriptSchema } from "../types/index.js";
1
+ import { mulmoScriptSchema, mulmoStudioMultiLingualFileSchema } from "../types/index.js";
2
2
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3
3
  const validate_1_0 = (script) => {
4
4
  if (script.speechParams?.provider) {
@@ -18,6 +18,9 @@ const validators = [{ from: "1.0", to: "1.1", validator: validate_1_0 }];
18
18
  export const MulmoScriptMethods = {
19
19
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
20
  validate(script) {
21
+ const version = script.$mulmocast.version;
22
+ // lang was optional in 1.0 and 1.1
23
+ const defaultLang = version === "1.0" || version === "1.1" ? { lang: "en" } : {};
21
24
  const validatedScript = validators.reduce((acc, validator) => {
22
25
  if (acc.$mulmocast.version === validator.from) {
23
26
  const validated = validator.validator(acc);
@@ -25,7 +28,20 @@ export const MulmoScriptMethods = {
25
28
  return validated;
26
29
  }
27
30
  return acc;
28
- }, script);
31
+ }, { ...defaultLang, ...script });
29
32
  return mulmoScriptSchema.parse(validatedScript);
30
33
  },
31
34
  };
35
+ export const MulmoStudioMultiLingualMethod = {
36
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
37
+ validate(jsonData, studioBeatsLength) {
38
+ // TODO version check
39
+ const result = mulmoStudioMultiLingualFileSchema.safeParse(jsonData);
40
+ const dataSet = result.success ? result.data.multiLingual : [];
41
+ while (dataSet.length < studioBeatsLength) {
42
+ dataSet.push({ multiLingualTexts: {} });
43
+ }
44
+ dataSet.length = studioBeatsLength;
45
+ return dataSet;
46
+ },
47
+ };
@@ -11,4 +11,5 @@ export declare const MulmoStudioContextMethods: {
11
11
  getCaption(context: MulmoStudioContext): string | undefined;
12
12
  setSessionState(context: MulmoStudioContext, sessionType: SessionType, value: boolean): void;
13
13
  setBeatSessionState(context: MulmoStudioContext, sessionType: BeatSessionType, index: number, value: boolean): void;
14
+ needTranslate(context: MulmoStudioContext, includeCaption?: boolean): boolean | "" | undefined;
14
15
  };
@@ -63,4 +63,12 @@ export const MulmoStudioContextMethods = {
63
63
  }
64
64
  notifyBeatStateChange(context, sessionType, index);
65
65
  },
66
+ needTranslate(context, includeCaption = false) {
67
+ // context.studio.script.lang = defaultLang, context.lang = targetLanguage.
68
+ if (includeCaption) {
69
+ return (context.studio.script.lang !== context.lang ||
70
+ (context.studio.script.captionParams?.lang && context.studio.script.lang !== context.studio.script.captionParams?.lang));
71
+ }
72
+ return context.studio.script.lang !== context.lang;
73
+ },
66
74
  };
@@ -77,6 +77,7 @@ export type LipSyncAgentInputs = {
77
77
  lipSyncFile: string;
78
78
  movieFile: string;
79
79
  audioFile: string;
80
+ imageFile: string;
80
81
  };
81
82
  export type GoogleMovieAgentConfig = GoogleImageAgentConfig;
82
83
  export type ReplicateMovieAgentConfig = AgentConfig;