@sogni-ai/sogni-creative-agent-skill 3.49.0 → 3.50.0

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.
package/sogni-agent.mjs CHANGED
@@ -29,7 +29,7 @@ import {
29
29
  } from './attribution.mjs';
30
30
  import { assertSafeUrl, fetchSafeUrl } from './ssrf-guard.mjs';
31
31
  import {
32
- MESH_FLAGS, SPEECH_VALUE_FLAGS, MUSIC3_MODEL_ID, MUSIC3_DEFAULTS, SPEECH_REFERENCE_SECONDS,
32
+ MESH_FLAGS, PIXAL3D_VIEW_FLAGS, SPEECH_VALUE_FLAGS, MUSIC3_MODEL_ID, MUSIC3_DEFAULTS, SPEECH_REFERENCE_SECONDS,
33
33
  prepareMediaUtilityOptions, imageUtilityConfig, speechConfig, utilityResultMetadata, validateGlb
34
34
  } from './media-utilities.mjs';
35
35
  import { SAM3_MODEL_ID, segmentPoint, segmentBox, validateSegmentationPrompts, segmentationConfig } from './sam-segmentation.mjs';
@@ -2378,11 +2378,45 @@ const MINIMAX_H3_MODEL_MODES = new Map([
2378
2378
  ['minimax-h3-fastvideo-int8_t2v_turbo_2stage', 't2v'],
2379
2379
  ['minimax-h3-fastvideo-int8_i2v_turbo_2stage', 'i2v'],
2380
2380
  ['minimax-h3-fastvideo-int8_flf2v_turbo_2stage', 'flf2v'],
2381
- ['minimax-h3-fastvideo-int8_t2v_turbo_2stage_720p', 't2v'],
2382
- ['minimax-h3-fastvideo-int8_i2v_turbo_2stage_720p', 'i2v'],
2383
- ['minimax-h3-fastvideo-int8_flf2v_turbo_2stage_720p', 'flf2v']
2381
+ ['minimax-h3-fastvideo-int8_ia2v_turbo', 'ia2v'],
2382
+ ['minimax-h3-fastvideo-int8_flfa2v_turbo', 'flfa2v'],
2383
+ ['minimax-h3-fastvideo-int8_a2v_turbo', 'a2v'],
2384
+ ['minimax-h3-fastvideo-int8_ia2v_turbo_2stage', 'ia2v'],
2385
+ ['minimax-h3-fastvideo-int8_flfa2v_turbo_2stage', 'flfa2v'],
2386
+ ['minimax-h3-fastvideo-int8_a2v_turbo_2stage', 'a2v']
2384
2387
  ]);
2385
2388
  const MINIMAX_H3_MODEL_IDS = new Set(MINIMAX_H3_MODEL_MODES.keys());
2389
+ // FastH3 audio guide: an uploaded audio file drives the
2390
+ // video from frame 0 and is kept in the output. ia2v takes a first frame plus
2391
+ // the audio, flfa2v a first and a last frame plus the audio, a2v the audio only.
2392
+ // Each has a two-stage id with the same request, delivered at twice the canvas.
2393
+ const MINIMAX_H3_AUDIO_GUIDE_MODEL_IDS = new Set([
2394
+ 'minimax-h3-fastvideo-int8_ia2v_turbo',
2395
+ 'minimax-h3-fastvideo-int8_flfa2v_turbo',
2396
+ 'minimax-h3-fastvideo-int8_a2v_turbo',
2397
+ 'minimax-h3-fastvideo-int8_ia2v_turbo_2stage',
2398
+ 'minimax-h3-fastvideo-int8_flfa2v_turbo_2stage',
2399
+ 'minimax-h3-fastvideo-int8_a2v_turbo_2stage'
2400
+ ]);
2401
+ // The two-stage audio ids and their selectors. The pinned Intelligence Client's
2402
+ // isMinimaxH3TwoStageModelId lists only the t2v/i2v/flf2v two-stage ids, so the
2403
+ // CLI adds these until the pin carries them.
2404
+ const MINIMAX_H3_AUDIO_GUIDE_TWO_STAGE_SELECTIONS = new Set([
2405
+ 'minimax-h3-fastvideo-int8_ia2v_turbo_2stage',
2406
+ 'minimax-h3-fastvideo-int8_flfa2v_turbo_2stage',
2407
+ 'minimax-h3-fastvideo-int8_a2v_turbo_2stage',
2408
+ 'minimax-h3-fasth3-ia2v-turbo-2stage',
2409
+ 'minimax-h3-fasth3-flfa2v-turbo-2stage',
2410
+ 'minimax-h3-fasth3-a2v-turbo-2stage'
2411
+ ]);
2412
+ const MINIMAX_H3_AUDIO_GUIDE_SELECTORS = new Map([
2413
+ ['minimax-h3-fasth3-ia2v-turbo', 'minimax-h3-fastvideo-int8_ia2v_turbo'],
2414
+ ['minimax-h3-fasth3-flfa2v-turbo', 'minimax-h3-fastvideo-int8_flfa2v_turbo'],
2415
+ ['minimax-h3-fasth3-a2v-turbo', 'minimax-h3-fastvideo-int8_a2v_turbo'],
2416
+ ['minimax-h3-fasth3-ia2v-turbo-2stage', 'minimax-h3-fastvideo-int8_ia2v_turbo_2stage'],
2417
+ ['minimax-h3-fasth3-flfa2v-turbo-2stage', 'minimax-h3-fastvideo-int8_flfa2v_turbo_2stage'],
2418
+ ['minimax-h3-fasth3-a2v-turbo-2stage', 'minimax-h3-fastvideo-int8_a2v_turbo_2stage']
2419
+ ]);
2386
2420
  const MINIMAX_H3_TURBO_MODEL_IDS = new Set([
2387
2421
  'minimax-h3-fl2va-fp8_t2v_turbo',
2388
2422
  'minimax-h3-fl2va-fp8_i2v_turbo',
@@ -2394,9 +2428,7 @@ const MINIMAX_H3_TURBO_MODEL_IDS = new Set([
2394
2428
  'minimax-h3-fastvideo-int8_t2v_turbo_2stage',
2395
2429
  'minimax-h3-fastvideo-int8_i2v_turbo_2stage',
2396
2430
  'minimax-h3-fastvideo-int8_flf2v_turbo_2stage',
2397
- 'minimax-h3-fastvideo-int8_t2v_turbo_2stage_720p',
2398
- 'minimax-h3-fastvideo-int8_i2v_turbo_2stage_720p',
2399
- 'minimax-h3-fastvideo-int8_flf2v_turbo_2stage_720p'
2431
+ ...MINIMAX_H3_AUDIO_GUIDE_MODEL_IDS
2400
2432
  ]);
2401
2433
  // FastH3 Two-Stage renders the FastH3 request on its own model ids and delivers
2402
2434
  // the clip at exactly twice the canvas, same frames and audio: 720p from 672x384,
@@ -2409,22 +2441,12 @@ const MINIMAX_H3_TWO_STAGE_MODEL_IDS = new Set([
2409
2441
  'minimax-h3-fastvideo-int8_i2v_turbo_2stage',
2410
2442
  'minimax-h3-fastvideo-int8_flf2v_turbo_2stage'
2411
2443
  ]);
2412
- // The Socket records 720p two-stage work (a 384 px canvas) under its own ids.
2413
- // Nothing here sends them: `--target-resolution 720` on a two-stage selector
2414
- // sends the `_2stage` id with the 384 px canvas. They are recognized as FastH3
2415
- // Turbo H3 ids; one named directly goes to the Socket unchanged, and the Socket
2416
- // requires its 384 px canvas.
2417
- const MINIMAX_H3_TWO_STAGE_720P_SOCKET_MODEL_IDS = new Set([
2418
- 'minimax-h3-fastvideo-int8_t2v_turbo_2stage_720p',
2419
- 'minimax-h3-fastvideo-int8_i2v_turbo_2stage_720p',
2420
- 'minimax-h3-fastvideo-int8_flf2v_turbo_2stage_720p'
2421
- ]);
2422
2444
  const MINIMAX_H3_FASTH3_TURBO_MODEL_IDS = new Set([
2423
2445
  'minimax-h3-fastvideo-int8_t2v_turbo',
2424
2446
  'minimax-h3-fastvideo-int8_i2v_turbo',
2425
2447
  'minimax-h3-fastvideo-int8_flf2v_turbo',
2426
2448
  ...MINIMAX_H3_TWO_STAGE_MODEL_IDS,
2427
- ...MINIMAX_H3_TWO_STAGE_720P_SOCKET_MODEL_IDS
2449
+ ...MINIMAX_H3_AUDIO_GUIDE_MODEL_IDS
2428
2450
  ]);
2429
2451
  const MINIMAX_H3_TURBO_SAMPLERS = Object.freeze(['euler', 'er_sde', 'sa_solver']);
2430
2452
  const MINIMAX_H3_TURBO_SAMPLER_SET = new Set(MINIMAX_H3_TURBO_SAMPLERS);
@@ -2544,8 +2566,17 @@ function resolveSkillVideoModelAlias(
2544
2566
  ? 'minimax-h3-fastvideo-int8_flf2v_turbo'
2545
2567
  : 'minimax-h3-fastvideo-int8_i2v_turbo';
2546
2568
  }
2569
+ if (workflow === 'ia2v') {
2570
+ return hasEndFrame
2571
+ ? 'minimax-h3-fastvideo-int8_flfa2v_turbo'
2572
+ : 'minimax-h3-fastvideo-int8_ia2v_turbo';
2573
+ }
2574
+ if (workflow === 'a2v') return 'minimax-h3-fastvideo-int8_a2v_turbo';
2547
2575
  return 'minimax-h3-fastvideo-int8_t2v_turbo';
2548
2576
  }
2577
+ if (MINIMAX_H3_AUDIO_GUIDE_SELECTORS.has(normalized)) {
2578
+ return MINIMAX_H3_AUDIO_GUIDE_SELECTORS.get(normalized);
2579
+ }
2549
2580
  if (normalized === 'minimax-h3-fasth3-t2v-turbo') {
2550
2581
  return 'minimax-h3-fastvideo-int8_t2v_turbo';
2551
2582
  }
@@ -2567,6 +2598,12 @@ function resolveSkillVideoModelAlias(
2567
2598
  ? 'minimax-h3-fastvideo-int8_flf2v_turbo_2stage'
2568
2599
  : 'minimax-h3-fastvideo-int8_i2v_turbo_2stage';
2569
2600
  }
2601
+ if (workflow === 'ia2v') {
2602
+ return hasEndFrame
2603
+ ? 'minimax-h3-fastvideo-int8_flfa2v_turbo_2stage'
2604
+ : 'minimax-h3-fastvideo-int8_ia2v_turbo_2stage';
2605
+ }
2606
+ if (workflow === 'a2v') return 'minimax-h3-fastvideo-int8_a2v_turbo_2stage';
2570
2607
  return 'minimax-h3-fastvideo-int8_t2v_turbo_2stage';
2571
2608
  }
2572
2609
  if (normalized === 'minimax-h3-fasth3-t2v-turbo-2stage') {
@@ -2615,16 +2652,27 @@ function isMiniMaxH3TurboModel(modelId) {
2615
2652
  }
2616
2653
 
2617
2654
  function isMiniMaxH3TwoStageModel(modelId) {
2618
- return isMinimaxH3TwoStageModelId(modelId);
2655
+ return isMinimaxH3TwoStageModelId(modelId)
2656
+ || MINIMAX_H3_AUDIO_GUIDE_TWO_STAGE_SELECTIONS.has(String(modelId || '').trim().toLowerCase());
2657
+ }
2658
+
2659
+ function isMiniMaxH3AudioGuideModel(modelId) {
2660
+ return MINIMAX_H3_AUDIO_GUIDE_MODEL_IDS.has(String(modelId || '').trim().toLowerCase());
2619
2661
  }
2620
2662
 
2663
+ // The two-stage canvas depends only on the delivered class and the source
2664
+ // aspect, never on the inputs, so each audio mode sizes like the frame mode
2665
+ // with the same images (the pinned Intelligence Client sizes only those).
2666
+ const MINIMAX_H3_TWO_STAGE_CANVAS_MODE = Object.freeze({ ia2v: 'i2v', flfa2v: 'flf2v', a2v: 't2v' });
2667
+
2621
2668
  /**
2622
2669
  * The FastH3 Two-Stage canvas for a source of this size: the Intelligence Client
2623
2670
  * turns the requested delivered class (720, 1080, or 1440/2K; undefined is 2K)
2624
2671
  * into a 384, 544 or 768 short edge in the source's aspect (or aspectRatio's).
2625
2672
  */
2626
2673
  function miniMaxH3TwoStageCanvas(modelId, deliveredClass, sourceWidth, sourceHeight, aspectRatio) {
2627
- const selector = `minimax-h3-fasth3-${miniMaxH3ModeFromModelId(modelId)}-turbo-2stage`;
2674
+ const mode = miniMaxH3ModeFromModelId(modelId);
2675
+ const selector = `minimax-h3-fasth3-${MINIMAX_H3_TWO_STAGE_CANVAS_MODE[mode] || mode}-turbo-2stage`;
2628
2676
  return calculateSharedVideoDimensions(sourceWidth, sourceHeight, deliveredClass, selector, aspectRatio || undefined);
2629
2677
  }
2630
2678
 
@@ -2664,9 +2712,22 @@ function isMiniMaxH3FastH3TurboSelectionLocal(modelId) {
2664
2712
  || normalized === 'minimax-h3-fasth3-t2v-turbo-2stage'
2665
2713
  || normalized === 'minimax-h3-fasth3-i2v-turbo-2stage'
2666
2714
  || normalized === 'minimax-h3-fasth3-flf2v-turbo-2stage'
2715
+ || MINIMAX_H3_AUDIO_GUIDE_SELECTORS.has(normalized)
2667
2716
  || MINIMAX_H3_FASTH3_TURBO_MODEL_IDS.has(normalized);
2668
2717
  }
2669
2718
 
2719
+ // An explicit FastH3 audio-guide selector or id, or a FastH3 family selector
2720
+ // that --ref-audio turns into one. Used before the workflow is resolved.
2721
+ function isMiniMaxH3AudioGuideSelectionLocal(modelId, hasReferenceAudio) {
2722
+ const normalized = String(modelId || '').trim().toLowerCase();
2723
+ return MINIMAX_H3_AUDIO_GUIDE_SELECTORS.has(normalized)
2724
+ || isMiniMaxH3AudioGuideModel(normalized)
2725
+ || (
2726
+ Boolean(hasReferenceAudio)
2727
+ && (normalized === 'minimax-h3-fasth3-turbo' || normalized === 'minimax-h3-fasth3-turbo-2stage')
2728
+ );
2729
+ }
2730
+
2670
2731
  function isMiniMaxH3ModelSelectionLocal(modelId) {
2671
2732
  const normalized = String(modelId || '').trim().toLowerCase();
2672
2733
  return normalized === 'minimax-h3'
@@ -2687,6 +2748,7 @@ function isMiniMaxH3ModelSelectionLocal(modelId) {
2687
2748
  || normalized === 'minimax-h3-fasth3-t2v-turbo-2stage'
2688
2749
  || normalized === 'minimax-h3-fasth3-i2v-turbo-2stage'
2689
2750
  || normalized === 'minimax-h3-fasth3-flf2v-turbo-2stage'
2751
+ || MINIMAX_H3_AUDIO_GUIDE_SELECTORS.has(normalized)
2690
2752
  || normalized === 'minimax-h3-balanced'
2691
2753
  || normalized === 'minimax-h3-t2v-balanced'
2692
2754
  || normalized === 'minimax-h3-i2v-balanced'
@@ -2710,6 +2772,7 @@ function isMiniMaxH3TurboModelSelectionLocal(modelId) {
2710
2772
  || normalized === 'minimax-h3-fasth3-t2v-turbo-2stage'
2711
2773
  || normalized === 'minimax-h3-fasth3-i2v-turbo-2stage'
2712
2774
  || normalized === 'minimax-h3-fasth3-flf2v-turbo-2stage'
2775
+ || MINIMAX_H3_AUDIO_GUIDE_SELECTORS.has(normalized)
2713
2776
  || isMiniMaxH3TurboModel(normalized);
2714
2777
  }
2715
2778
 
@@ -2733,9 +2796,20 @@ function miniMaxH3ModeFromModelId(modelId) {
2733
2796
  if (normalized === 'minimax-h3-i2v-balanced') return 'i2v';
2734
2797
  if (normalized === 'minimax-h3-flf2v-balanced') return 'flf2v';
2735
2798
  if (normalized === 'minimax-h3-r2v-balanced') return 'r2v';
2799
+ if (MINIMAX_H3_AUDIO_GUIDE_SELECTORS.has(normalized)) {
2800
+ return MINIMAX_H3_MODEL_MODES.get(MINIMAX_H3_AUDIO_GUIDE_SELECTORS.get(normalized));
2801
+ }
2736
2802
  return MINIMAX_H3_MODEL_MODES.get(normalized) || null;
2737
2803
  }
2738
2804
 
2805
+ // The FastH3 audio-guide selector that takes the audio the user supplied to an
2806
+ // H3 mode without an audio input, picked by the frame images supplied alongside
2807
+ // it (the Socket names the same substitute for such a request).
2808
+ function miniMaxH3AudioGuideSelectorFor(modelId, hasStartFrame, hasEndFrame) {
2809
+ const mode = hasEndFrame ? 'flfa2v' : hasStartFrame ? 'ia2v' : 'a2v';
2810
+ return `minimax-h3-fasth3-${mode}-turbo${isMiniMaxH3TwoStageModel(modelId) ? '-2stage' : ''}`;
2811
+ }
2812
+
2739
2813
  function normalizeMultiAngleValue(value, aliases, allowedKeys, label) {
2740
2814
  if (!value) return null;
2741
2815
  const normalized = value.toLowerCase().replace(/_/g, '-').replace(/\s+/g, ' ').trim();
@@ -3001,6 +3075,7 @@ const options = {
3001
3075
  voiceTranscript: null,
3002
3076
  speechCreativity: null,
3003
3077
  imageTo3d: null,
3078
+ pixal3dViews: {},
3004
3079
  removeBackground: null,
3005
3080
  matte: false,
3006
3081
  meshSettings: {},
@@ -3649,6 +3724,8 @@ for (let i = 0; i < args.length; i++) {
3649
3724
  cliSet.context = true;
3650
3725
  } else if (arg === '--image-to-3d' || arg === '--pixal3d') {
3651
3726
  options.imageTo3d = expandHomePath(requireFlagValue(args, i++, arg));
3727
+ } else if (arg === '--left-view' || arg === '--back-view' || arg === '--right-view') {
3728
+ options.pixal3dViews[PIXAL3D_VIEW_FLAGS[arg]] = expandHomePath(requireFlagValue(args, i++, arg));
3652
3729
  } else if (arg === '--remove-background') {
3653
3730
  options.removeBackground = expandHomePath(requireFlagValue(args, i++, arg));
3654
3731
  } else if (arg === '--matte') {
@@ -4359,7 +4436,14 @@ Photobooth (Face Transfer):
4359
4436
  --cn-guidance-end <n> ControlNet guidance end point (default: 0.3)
4360
4437
 
4361
4438
  3D and Background Removal:
4362
- --image-to-3d <image> Pixal3D: original image to binary GLB (alias --pixal3d)
4439
+ --image-to-3d <image> Pixal3D: original image to binary GLB (alias --pixal3d); with views, the FRONT view
4440
+ --left-view <image> Pixal3D multi-view: the subject turned so ITS OWN left side faces the camera
4441
+ (it faces screen-left)
4442
+ --back-view <image> Pixal3D multi-view: the subject seen from behind
4443
+ --right-view <image> Pixal3D multi-view: ITS OWN right side faces the camera (it faces screen-right).
4444
+ Any subset of views selects pixal3d_multiview_int8_i23d; views are named by the
4445
+ subject's sides, not the viewer's. Templates that label the subject's right side
4446
+ "left" build a model turned 180 degrees.
4363
4447
  --shape-resolution <n> 1024 (default) or 1536; optional --mesh-faces 5000–700000
4364
4448
  --texture-size <n> 1024–4096; --normal-map-size 512–2048; --ao-map-size 256–1024
4365
4449
  --remove-background <image> BiRefNet transparent PNG; --matte returns soft mask
@@ -4416,8 +4500,10 @@ Video Options:
4416
4500
  first entry is the primary, extras must be HTTPS URLs in CLI
4417
4501
  direct-gen for Seedance; H3 r2v uploads local/remote files.
4418
4502
  On LTX/WAN: single primary only (for ia2v/a2v/s2v lip-sync).
4419
- --audio-start <sec> Start offset into --ref-audio for audio-driven clips
4420
- --audio-duration <sec> Duration slice from --ref-audio
4503
+ MiniMax H3 FastH3 audio-to-video: one file that drives the clip and is its soundtrack.
4504
+ --audio-start <sec> Start offset into --ref-audio for audio-driven clips (FastH3 audio-to-video:
4505
+ where the audio window begins; the window is the video length)
4506
+ --audio-duration <sec> Duration slice from --ref-audio (not MiniMax H3 FastH3 audio-to-video)
4421
4507
  --reference-audio-identity <path> Voice identity clip for LTX native audio
4422
4508
  --voice-persona <name> Use saved persona voice clip as LTX voice identity
4423
4509
  --ref-video <path|url> Video reference. Repeatable on Seedance and H3 r2v (up to 3 total);
@@ -4671,6 +4757,15 @@ state negatives in the structured prompt.):
4671
4757
  FastH3 Two-Stage I2VA (--ref) or L2VA (--ref-end)
4672
4758
  minimax-h3-fasth3-flf2v-turbo-2stage
4673
4759
  FastH3 Two-Stage first-frame -> last-frame (--ref plus --ref-end)
4760
+ minimax-h3-fasth3-ia2v-turbo FastH3 audio-to-video: --ref first frame plus --ref-audio, which drives the
4761
+ motion from frame 0 and is the clip's soundtrack
4762
+ minimax-h3-fasth3-flfa2v-turbo FastH3 first + last frame plus audio (--ref, --ref-end, --ref-audio)
4763
+ minimax-h3-fasth3-a2v-turbo FastH3 audio only (--ref-audio). Audio modes: --audio-start picks the window,
4764
+ --duration/--frames set its length; no LoRAs, --audio-duration or
4765
+ --no-generate-audio. minimax-h3-fasth3-turbo with --ref-audio picks one of these.
4766
+ minimax-h3-fasth3-ia2v-turbo-2stage / -flfa2v-turbo-2stage / -a2v-turbo-2stage
4767
+ FastH3 Two-Stage audio-to-video; minimax-h3-fasth3-turbo-2stage with --ref-audio
4768
+ picks one of these
4674
4769
  H3 FL2VA Turbo sampler override --sampler euler|er_sde|sa_solver
4675
4770
  (Socket default: er_sde; CLI omits unless set)
4676
4771
  (scheduler remains fixed to simple)
@@ -5152,6 +5247,14 @@ if (options.music && options.loras.length > 0) {
5152
5247
  }
5153
5248
 
5154
5249
  if (options.video && options.loras.length > 0) {
5250
+ // No LoRA has been qualified on the FastH3 audio-guide graphs; Sogni refuses
5251
+ // them, so stop before reading the catalog or uploading anything.
5252
+ if (isMiniMaxH3AudioGuideSelectionLocal(options.model, options.refAudio)) {
5253
+ fatalCliError('MiniMax H3 FastH3 audio-to-video does not support LoRAs. Remove --lora/--loras.', {
5254
+ code: 'INVALID_ARGUMENT',
5255
+ details: { model: options.model, loras: options.loras }
5256
+ });
5257
+ }
5155
5258
  if (options.loras.length > 8) {
5156
5259
  fatalCliError('Video generation supports at most 8 LoRAs per render.', {
5157
5260
  code: 'INVALID_ARGUMENT',
@@ -5371,9 +5474,16 @@ if (options.video) {
5371
5474
  // is a separate r2v checkpoint and is never inferred from loose references.
5372
5475
  // Selecting the tier's minimax-h3-r2v* alias or explicitly passing
5373
5476
  // --workflow r2v with its bare tier selector is required.
5477
+ // FastH3 alone also has the audio guide: ia2v (first frame + audio, and with
5478
+ // --ref-end the flfa2v first/last frame + audio id, as i2v covers flf2v) and
5479
+ // a2v (audio only). Its family selectors pick them when --ref-audio is given.
5374
5480
  if (isMiniMaxH3ModelSelectionLocal(options.model)) {
5481
+ const selection = String(options.model).trim().toLowerCase();
5375
5482
  const pinnedMode = miniMaxH3ModeFromModelId(options.model);
5376
- const pinnedWorkflow = pinnedMode === 'flf2v' ? 'i2v' : pinnedMode;
5483
+ const pinnedWorkflow = pinnedMode === 'flf2v' ? 'i2v' : pinnedMode === 'flfa2v' ? 'ia2v' : pinnedMode;
5484
+ const hasReferenceAudio = Boolean(options.refAudio || options.refAudios.length > 0);
5485
+ const isFastH3FamilySelection = selection === 'minimax-h3-fasth3-turbo'
5486
+ || selection === 'minimax-h3-fasth3-turbo-2stage';
5377
5487
  if (pinnedWorkflow) {
5378
5488
  if (options.videoWorkflow && options.videoWorkflow !== pinnedWorkflow) {
5379
5489
  fatalCliError(`Workflow "${options.videoWorkflow}" does not match model "${options.model}".`, {
@@ -5383,7 +5493,40 @@ if (options.video) {
5383
5493
  }
5384
5494
  options.videoWorkflow = pinnedWorkflow;
5385
5495
  } else if (!options.videoWorkflow) {
5386
- options.videoWorkflow = (options.refImage || options.refImageEnd) ? 'i2v' : 't2v';
5496
+ const hasFrameImage = Boolean(options.refImage || options.refImageEnd);
5497
+ options.videoWorkflow = hasReferenceAudio && isFastH3FamilySelection
5498
+ ? (hasFrameImage ? 'ia2v' : 'a2v')
5499
+ : (hasFrameImage ? 'i2v' : 't2v');
5500
+ }
5501
+ const audioGuideSelector = miniMaxH3AudioGuideSelectorFor(
5502
+ options.model,
5503
+ Boolean(options.refImage),
5504
+ Boolean(options.refImageEnd)
5505
+ );
5506
+ const audioGuideHint = 'FastH3 audio-to-video: -m minimax-h3-fasth3-ia2v-turbo (--ref plus --ref-audio), '
5507
+ + '-m minimax-h3-fasth3-flfa2v-turbo (--ref, --ref-end and --ref-audio), or '
5508
+ + '-m minimax-h3-fasth3-a2v-turbo (--ref-audio only); add -2stage for Two-Stage. '
5509
+ + 'For audio as a loose reference rather than the soundtrack, use -m minimax-h3-r2v.';
5510
+ if (
5511
+ (options.videoWorkflow === 'ia2v' || options.videoWorkflow === 'a2v')
5512
+ && !isMiniMaxH3FastH3TurboSelectionLocal(options.model)
5513
+ ) {
5514
+ fatalCliError(`MiniMax H3 ${options.videoWorkflow} is the FastH3 audio guide; use -m ${audioGuideSelector}.`, {
5515
+ code: 'INVALID_ARGUMENT',
5516
+ details: { workflow: options.videoWorkflow, model: options.model, suggestedModel: audioGuideSelector },
5517
+ hint: audioGuideHint
5518
+ });
5519
+ }
5520
+ if (hasReferenceAudio && !['r2v', 'ia2v', 'a2v'].includes(options.videoWorkflow)) {
5521
+ fatalCliError(
5522
+ `${options.model} has no audio input, so --ref-audio would be ignored. `
5523
+ + `To drive the video with this audio, use -m ${audioGuideSelector}.`,
5524
+ {
5525
+ code: 'INVALID_ARGUMENT',
5526
+ details: { workflow: options.videoWorkflow, model: options.model, suggestedModel: audioGuideSelector },
5527
+ hint: audioGuideHint
5528
+ }
5529
+ );
5387
5530
  }
5388
5531
  options.model = resolveSkillVideoModelAlias(
5389
5532
  options.model,
@@ -5832,6 +5975,7 @@ if (typeof options.prompt === 'string' && options.prompt.trim() === '') {
5832
5975
  }
5833
5976
  const wan3ReferenceMediaCache = new Map();
5834
5977
  const wan3ReferencePreparationPlan = new Map();
5978
+ let wan3ReferenceVideoDurationSeconds = 0;
5835
5979
  const wan3HasMediaInput = isWan3ModelLocal(options.model) && Boolean(
5836
5980
  options.refImage
5837
5981
  || options.refImageEnd
@@ -6113,8 +6257,31 @@ if (options.video) {
6113
6257
  details: { workflow: options.videoWorkflow, model: options.model }
6114
6258
  });
6115
6259
  }
6116
- if (isMiniMaxH3Video && !['t2v', 'i2v', 'r2v'].includes(options.videoWorkflow)) {
6117
- fatalCliError('MiniMax H3 models support only t2v, i2v/flf2v, or r2v workflows.', {
6260
+ const isMiniMaxH3AudioGuideVideo = isMiniMaxH3AudioGuideModel(options.model);
6261
+ if (isMiniMaxH3AudioGuideVideo) {
6262
+ const audioGuideWorkflow = miniMaxH3ModeFromModelId(options.model) === 'a2v' ? 'a2v' : 'ia2v';
6263
+ if (options.videoWorkflow !== audioGuideWorkflow) {
6264
+ fatalCliError(`Workflow "${options.videoWorkflow}" does not match model "${options.model}".`, {
6265
+ code: 'INVALID_ARGUMENT',
6266
+ details: { workflow: options.videoWorkflow, model: options.model }
6267
+ });
6268
+ }
6269
+ // The graph always delivers the uploaded audio, trimmed to the video length.
6270
+ if (options.apiGenerateAudio === false) {
6271
+ fatalCliError('MiniMax H3 FastH3 audio-to-video always keeps the uploaded audio. Omit --no-generate-audio.', {
6272
+ code: 'INVALID_ARGUMENT',
6273
+ details: { model: options.model }
6274
+ });
6275
+ }
6276
+ if (options.audioDuration !== null) {
6277
+ fatalCliError(
6278
+ 'MiniMax H3 FastH3 audio-to-video has no --audio-duration: the uploaded audio is trimmed to the video length. '
6279
+ + 'Set --duration or --frames, and --audio-start to choose where the audio window begins.',
6280
+ { code: 'INVALID_ARGUMENT', details: { model: options.model, audioDuration: options.audioDuration } }
6281
+ );
6282
+ }
6283
+ } else if (isMiniMaxH3Video && !['t2v', 'i2v', 'r2v'].includes(options.videoWorkflow)) {
6284
+ fatalCliError('MiniMax H3 models support only t2v, i2v/flf2v, or r2v workflows; FastH3 also has ia2v/flfa2v/a2v audio-to-video.', {
6118
6285
  code: 'INVALID_ARGUMENT',
6119
6286
  details: { workflow: options.videoWorkflow, model: options.model }
6120
6287
  });
@@ -6335,6 +6502,36 @@ if (options.video) {
6335
6502
  if (options.refVideo) {
6336
6503
  fatalCliError('s2v does not accept reference video.', { code: 'INVALID_ARGUMENT' });
6337
6504
  }
6505
+ } else if (isMiniMaxH3AudioGuideVideo) {
6506
+ // Each FastH3 audio mode renders from exactly its own uploads.
6507
+ const h3AudioMode = miniMaxH3ModeFromModelId(options.model);
6508
+ const required = h3AudioMode === 'flfa2v'
6509
+ ? { flags: '--ref, --ref-end and --ref-audio', ok: options.refImage && options.refImageEnd && options.refAudio }
6510
+ : h3AudioMode === 'ia2v'
6511
+ ? { flags: '--ref and --ref-audio', ok: options.refImage && options.refAudio }
6512
+ : { flags: '--ref-audio', ok: options.refAudio };
6513
+ if (!required.ok) {
6514
+ fatalCliError(`MiniMax H3 FastH3 ${h3AudioMode} requires ${required.flags}.`, {
6515
+ code: 'INVALID_ARGUMENT',
6516
+ details: { model: options.model }
6517
+ });
6518
+ }
6519
+ const extras = [
6520
+ h3AudioMode === 'a2v' && options.refImage ? '--ref' : null,
6521
+ h3AudioMode !== 'flfa2v' && options.refImageEnd ? '--ref-end' : null,
6522
+ options.contextImages.length > 0 ? '-c/--context' : null,
6523
+ options.refVideo || options.refVideos.length > 0 ? '--ref-video' : null,
6524
+ options.refAudios.length > 0 ? 'a second --ref-audio' : null
6525
+ ].filter(Boolean);
6526
+ if (extras.length > 0) {
6527
+ const substitute = h3AudioMode !== 'flfa2v' && options.refImageEnd && options.refImage
6528
+ ? ` For a first and a last frame, use -m ${miniMaxH3AudioGuideSelectorFor(options.model, true, true)}.`
6529
+ : '';
6530
+ fatalCliError(
6531
+ `MiniMax H3 FastH3 ${h3AudioMode} takes only ${required.flags}; remove ${extras.join(', ')}.${substitute}`,
6532
+ { code: 'INVALID_ARGUMENT', details: { model: options.model, unsupported: extras } }
6533
+ );
6534
+ }
6338
6535
  } else if (options.videoWorkflow === 'ia2v') {
6339
6536
  if (isSeedanceVideo) {
6340
6537
  if (!options.refAudio || (!options.refImage && !options.refVideo)) {
@@ -6659,7 +6856,7 @@ if (options.video) {
6659
6856
  // FastH3 Two-Stage follows a local reference's aspect at the requested
6660
6857
  // delivered class, and caps the reference pre-resize to that canvas.
6661
6858
  let twoStageReferenceCanvas = null;
6662
- if (options._miniMaxH3TwoStageAutoCanvas && options.videoWorkflow === 'i2v' && hasVideoReference) {
6859
+ if (options._miniMaxH3TwoStageAutoCanvas && videoWorkflowHasFrameAnchors() && hasVideoReference) {
6663
6860
  const twoStageRefPath = options.refImage || options.refImageEnd;
6664
6861
  if (!isHttpUrl(twoStageRefPath) && existsSync(twoStageRefPath)) {
6665
6862
  const twoStageRefDims = getImageDimensionsFromBuffer(readFileSync(twoStageRefPath));
@@ -6741,7 +6938,7 @@ if (options.video) {
6741
6938
  );
6742
6939
  }
6743
6940
 
6744
- if (options.videoWorkflow === 'i2v' && (options.refImage || options.refImageEnd)) {
6941
+ if (videoWorkflowHasFrameAnchors() && (options.refImage || options.refImageEnd)) {
6745
6942
  const references = [
6746
6943
  {
6747
6944
  key: 'refImage',
@@ -9934,6 +10131,7 @@ async function prepareWan3ReferenceMediaPlan() {
9934
10131
  details: { referenceVideoDuration: totalVideoDuration, outputDuration: fixedOutputDuration }
9935
10132
  });
9936
10133
  }
10134
+ wan3ReferenceVideoDurationSeconds = totalVideoDuration;
9937
10135
  }
9938
10136
 
9939
10137
  async function transcodeSeedanceReferenceAudioToMp3(request) {
@@ -12038,15 +12236,25 @@ async function runMultiAngleFlow(client, log) {
12038
12236
  }
12039
12237
  }
12040
12238
 
12239
+ // The images of the MiniMax H3 FastH3 ia2v/flfa2v audio guide are first/last
12240
+ // frame anchors exactly like i2v's, so they follow i2v's canvas and
12241
+ // reference-resize rules. (Other ia2v models treat --ref as a loose reference.)
12242
+ function videoWorkflowHasFrameAnchors() {
12243
+ return options.videoWorkflow === 'i2v'
12244
+ || (options.videoWorkflow === 'ia2v' && isMiniMaxH3AudioGuideModel(options.model));
12245
+ }
12246
+
12041
12247
  function miniMaxH3R2vReferenceImageCount() {
12042
12248
  if (!isMiniMaxH3R2vModel(options.model)) return undefined;
12043
12249
  return (options.refImage ? 1 : 0)
12044
12250
  + (Array.isArray(options.contextImages) ? options.contextImages.length : 0);
12045
12251
  }
12046
12252
 
12047
- function buildVideoEstimateParams({ tokenType, steps }) {
12253
+ async function buildVideoEstimateParams({ tokenType, steps }) {
12048
12254
  const isSeedanceVideo = isSeedanceModel(options.model);
12049
12255
  const isWan3Video = isWan3ModelLocal(options.model);
12256
+ const isMiniMaxH3R2v = isMiniMaxH3R2vModel(options.model);
12257
+ const videoSources = [options.refVideo, ...options.refVideos].filter(Boolean);
12050
12258
  const referenceImageCount = miniMaxH3R2vReferenceImageCount();
12051
12259
  const params = {
12052
12260
  modelId: options.model,
@@ -12060,13 +12268,29 @@ function buildVideoEstimateParams({ tokenType, steps }) {
12060
12268
  ...(referenceImageCount !== undefined ? { referenceImageCount } : {})
12061
12269
  };
12062
12270
 
12063
- if ((isSeedanceVideo || isWan3Video) && options.refVideo) {
12271
+ if ((isSeedanceVideo || isWan3Video || isMiniMaxH3R2v) && videoSources.length > 0) {
12064
12272
  params.hasVideoInput = true;
12065
- if (isHttpsUrl(options.refVideo)) {
12066
- params.referenceVideoUrls = [options.refVideo];
12067
- } else {
12273
+ params.referenceVideoUrls = videoSources.filter(isHttpsUrl);
12274
+ if (videoSources.some(source => !isHttpsUrl(source))) {
12068
12275
  params.referenceVideo = true;
12069
12276
  }
12277
+ params.referenceVideoCount = videoSources.length;
12278
+ if (isWan3Video) {
12279
+ params.referenceVideoDurationSeconds = wan3ReferenceVideoDurationSeconds;
12280
+ } else if (isMiniMaxH3R2v) {
12281
+ const durations = await Promise.all(videoSources.map(async (source, index) => {
12282
+ const duration = await probeLocalMediaDurationSeconds(source)
12283
+ ?? await probeMediaBufferDurationSeconds(
12284
+ await fetchMediaBuffer(source),
12285
+ mediaFilenameFromSource(source, `h3-reference-video-${index + 1}.mp4`)
12286
+ );
12287
+ if (!Number.isFinite(duration) || duration < 2 || duration > 15) {
12288
+ throw new Error(`MiniMax H3 reference video ${index + 1} must be between 2 and 15 seconds.`);
12289
+ }
12290
+ return duration;
12291
+ }));
12292
+ params.referenceVideoDurationSeconds = durations.reduce((sum, duration) => sum + duration, 0);
12293
+ }
12070
12294
  }
12071
12295
 
12072
12296
  return params;
@@ -12137,7 +12361,7 @@ async function ensureSufficientVideoBalance(client, log) {
12137
12361
 
12138
12362
  let estimate;
12139
12363
  try {
12140
- estimate = await client.estimateVideoCost(buildVideoEstimateParams({ tokenType, steps }));
12364
+ estimate = await client.estimateVideoCost(await buildVideoEstimateParams({ tokenType, steps }));
12141
12365
  } catch (err) {
12142
12366
  if (!options.quiet) {
12143
12367
  if (isMiniMaxH3ExtendedDurationEstimateError(err)) {
@@ -12901,7 +13125,7 @@ async function main() {
12901
13125
  err.hint = 'Pass --steps explicitly (e.g. --steps 4 for lightx2v models).';
12902
13126
  throw err;
12903
13127
  }
12904
- const estimateParams = buildVideoEstimateParams({
13128
+ const estimateParams = await buildVideoEstimateParams({
12905
13129
  tokenType: options.tokenType || 'spark',
12906
13130
  steps
12907
13131
  });
@@ -13328,7 +13552,7 @@ async function main() {
13328
13552
  let videoDimensionRules = videoDimensionRulesFromDefaults(modelDefaults, options.model);
13329
13553
  // FastH3 Two-Stage: a downloaded (or local) reference sets the canvas aspect
13330
13554
  // at the requested delivered class, and the pre-resize stays on that canvas.
13331
- if (options._miniMaxH3TwoStageAutoCanvas && options.videoWorkflow === 'i2v' && (imageBuffer || endImageBuffer)) {
13555
+ if (options._miniMaxH3TwoStageAutoCanvas && videoWorkflowHasFrameAnchors() && (imageBuffer || endImageBuffer)) {
13332
13556
  const twoStageRefDims = await getVideoImageDimensionsFromBuffer(imageBuffer || endImageBuffer);
13333
13557
  if (twoStageRefDims?.width && twoStageRefDims?.height) {
13334
13558
  const twoStageCanvas = miniMaxH3TwoStageCanvas(
@@ -13402,7 +13626,7 @@ async function main() {
13402
13626
  // Pre-resize reference images to model-compatible dimensions if needed for i2v workflow.
13403
13627
  // The earlier preflight can inspect local files, but HTTPS references are downloaded only
13404
13628
  // here. Re-check the actual buffer so remote and local inputs follow the same grid rules.
13405
- if (options.videoWorkflow === 'i2v' && imageBuffer) {
13629
+ if (videoWorkflowHasFrameAnchors() && imageBuffer) {
13406
13630
  const dims = await getVideoImageDimensionsFromBuffer(imageBuffer);
13407
13631
  if (dims?.width && dims?.height) {
13408
13632
  const predicted = predictSharpInsideResizeDims(dims.width, dims.height, options.width, options.height);
@@ -13442,7 +13666,7 @@ async function main() {
13442
13666
  }
13443
13667
  }
13444
13668
  }
13445
- if (options.videoWorkflow === 'i2v' && endImageBuffer && options._needsRefEndResize) {
13669
+ if (videoWorkflowHasFrameAnchors() && endImageBuffer && options._needsRefEndResize) {
13446
13670
  const dims = getImageDimensionsFromBuffer(endImageBuffer);
13447
13671
  if (dims?.width && dims?.height) {
13448
13672
  const resizedBuffer = await resizeImageBufferForVideo(endImageBuffer, dims.width, dims.height, videoDimensionRules);
@@ -13771,12 +13995,22 @@ async function main() {
13771
13995
  const result = trackProjectResult(await client.createAudioProject(withBillingMode(speechConfig(options, referenceAudio))));
13772
13996
  if (result?.error || result?.message) throw buildProjectResultError(result);
13773
13997
  } else if (options.imageTo3d || options.removeBackground) {
13774
- log(options.imageTo3d ? 'Building a GLB with Pixal3D...' : 'Removing the background with BiRefNet...');
13998
+ const orbitViews = Object.entries(options.pixal3dViews);
13999
+ log(options.imageTo3d
14000
+ ? `Building a GLB with Pixal3D${orbitViews.length ? ` from ${orbitViews.length + 1} views` : ''}...`
14001
+ : 'Removing the background with BiRefNet...');
13775
14002
  const bytes = await fetchMediaBuffer(options.imageTo3d || options.removeBackground);
13776
14003
  const dimensions = getImageDimensionsFromBuffer(bytes);
13777
14004
  if (!dimensions?.width || !dimensions?.height) throw new Error('Supply an original PNG, JPEG, or WebP image.');
13778
14005
  options.width = dimensions.width; options.height = dimensions.height;
13779
- const result = trackProjectResult(await client.createImageProject(withBillingMode(imageUtilityConfig(options, bytes))));
14006
+ const viewBytes = {};
14007
+ for (const [view, source] of orbitViews) {
14008
+ viewBytes[view] = await fetchMediaBuffer(source);
14009
+ if (!getImageDimensionsFromBuffer(viewBytes[view])?.width) {
14010
+ throw new Error(`Supply an original PNG, JPEG, or WebP image for ${Object.keys(PIXAL3D_VIEW_FLAGS).find(flag => PIXAL3D_VIEW_FLAGS[flag] === view)}.`);
14011
+ }
14012
+ }
14013
+ const result = trackProjectResult(await client.createImageProject(withBillingMode(imageUtilityConfig(options, bytes, viewBytes))));
13780
14014
  if (result?.error || result?.message) throw buildProjectResultError(result);
13781
14015
  } else if (options.segmentImage) {
13782
14016
  log('Selecting the object with SAM 3...');
package/version.mjs CHANGED
@@ -1 +1 @@
1
- export const PACKAGE_VERSION = '3.49.0';
1
+ export const PACKAGE_VERSION = '3.50.0';