@sogni-ai/sogni-creative-agent-skill 3.46.0 → 3.49.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
@@ -28,6 +28,10 @@ import {
28
28
  semanticWorkloadAttribution,
29
29
  } from './attribution.mjs';
30
30
  import { assertSafeUrl, fetchSafeUrl } from './ssrf-guard.mjs';
31
+ import {
32
+ MESH_FLAGS, SPEECH_VALUE_FLAGS, MUSIC3_MODEL_ID, MUSIC3_DEFAULTS, SPEECH_REFERENCE_SECONDS,
33
+ prepareMediaUtilityOptions, imageUtilityConfig, speechConfig, utilityResultMetadata, validateGlb
34
+ } from './media-utilities.mjs';
31
35
  import { SAM3_MODEL_ID, segmentPoint, segmentBox, validateSegmentationPrompts, segmentationConfig } from './sam-segmentation.mjs';
32
36
  import {
33
37
  INTERNAL_FLAG as UPDATE_CHECK_INTERNAL_FLAG,
@@ -96,6 +100,10 @@ import {
96
100
  isGptImageModel,
97
101
  isKreaIdentityEditModel,
98
102
  SEEDANCE_R2V_REFERENCE_AUDIO_MAX_DURATION_SECONDS,
103
+ calculateVideoDimensions as calculateSharedVideoDimensions,
104
+ isMinimaxH3TwoStageModelId,
105
+ minimaxH3TwoStageCanvasShortEdge,
106
+ minimaxH3TwoStageDeliveredSize,
99
107
  prepareSeedanceV2VSourceVideo as prepareSharedSeedanceV2VSourceVideo
100
108
  } from '@sogni-ai/sogni-intelligence-client/media';
101
109
  import {
@@ -387,6 +395,7 @@ const SOCKET_EVENT_SUBSCRIPTIONS = Object.freeze({
387
395
  modelAvailability: false
388
396
  });
389
397
  const MUSIC_MODEL_IDS = {
398
+ music3: MUSIC3_MODEL_ID,
390
399
  turbo: 'ace_step_1.5_xl_turbo',
391
400
  speed: 'ace_step_1.5_xl_turbo',
392
401
  fast: 'ace_step_1.5_xl_turbo',
@@ -395,6 +404,7 @@ const MUSIC_MODEL_IDS = {
395
404
  lyric: 'ace_step_1.5_xl_sft'
396
405
  };
397
406
  const MUSIC_MODEL_DEFAULTS = {
407
+ [MUSIC3_MODEL_ID]: MUSIC3_DEFAULTS,
398
408
  'ace_step_1.5_xl_turbo': {
399
409
  steps: { min: 4, max: 16, default: 8 },
400
410
  shift: { min: 1, max: 6, default: 3 },
@@ -1186,7 +1196,12 @@ function computePromptHashSeed(opts) {
1186
1196
  const payload = {
1187
1197
  prompt: opts.prompt || '',
1188
1198
  model: opts.model || '',
1189
- workflow: opts.video ? opts.videoWorkflow : opts.music ? 'music' : 'image',
1199
+ workflow: opts.video ? opts.videoWorkflow : opts.speech ? 'speech' : opts.imageTo3d ? 'model' : opts.music ? 'music' : 'image',
1200
+ ...(opts.speech ? {
1201
+ speechMode: opts.speechMode || '', speechVoice: opts.speechVoice || '',
1202
+ voiceDescription: opts.voiceDescription || '', voiceReference: opts.voiceReference || '',
1203
+ voiceTranscript: opts.voiceTranscript || '', speechCreativity: opts.speechCreativity ?? null
1204
+ } : {}),
1190
1205
  width: opts.width,
1191
1206
  height: opts.height,
1192
1207
  azimuth: opts.azimuth || '',
@@ -1291,6 +1306,15 @@ function parseIntegerValue(raw, flagName) {
1291
1306
  return num;
1292
1307
  }
1293
1308
 
1309
+ // --target-resolution: a short side in pixels ("1080p" means 1080). "2K" names
1310
+ // the MiniMax H3 FastH3 Two-Stage 2K delivered class, 1440 in the Intelligence
1311
+ // Client's size table, and is refused for every other model once it resolves.
1312
+ function parseTargetResolutionValue(raw, flagName) {
1313
+ const normalized = String(raw ?? '').trim().toLowerCase();
1314
+ if (normalized === '2k') return { value: 1440, spelled2K: true };
1315
+ return { value: parsePositiveIntegerValue(normalized.replace(/p$/, ''), flagName), spelled2K: false };
1316
+ }
1317
+
1294
1318
  function parsePositiveIntegerValue(raw, flagName, min = 1, max = Infinity) {
1295
1319
  const num = parseIntegerValue(raw, flagName);
1296
1320
  if (num < min) {
@@ -2350,7 +2374,13 @@ const MINIMAX_H3_MODEL_MODES = new Map([
2350
2374
  ['minimax-h3-ref2va-fp8_r2v_balanced', 'r2v'],
2351
2375
  ['minimax-h3-fastvideo-int8_t2v_turbo', 't2v'],
2352
2376
  ['minimax-h3-fastvideo-int8_i2v_turbo', 'i2v'],
2353
- ['minimax-h3-fastvideo-int8_flf2v_turbo', 'flf2v']
2377
+ ['minimax-h3-fastvideo-int8_flf2v_turbo', 'flf2v'],
2378
+ ['minimax-h3-fastvideo-int8_t2v_turbo_2stage', 't2v'],
2379
+ ['minimax-h3-fastvideo-int8_i2v_turbo_2stage', 'i2v'],
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']
2354
2384
  ]);
2355
2385
  const MINIMAX_H3_MODEL_IDS = new Set(MINIMAX_H3_MODEL_MODES.keys());
2356
2386
  const MINIMAX_H3_TURBO_MODEL_IDS = new Set([
@@ -2360,12 +2390,41 @@ const MINIMAX_H3_TURBO_MODEL_IDS = new Set([
2360
2390
  'minimax-h3-ref2va-fp8_r2v_turbo',
2361
2391
  'minimax-h3-fastvideo-int8_t2v_turbo',
2362
2392
  'minimax-h3-fastvideo-int8_i2v_turbo',
2363
- 'minimax-h3-fastvideo-int8_flf2v_turbo'
2393
+ 'minimax-h3-fastvideo-int8_flf2v_turbo',
2394
+ 'minimax-h3-fastvideo-int8_t2v_turbo_2stage',
2395
+ 'minimax-h3-fastvideo-int8_i2v_turbo_2stage',
2396
+ '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'
2400
+ ]);
2401
+ // FastH3 Two-Stage renders the FastH3 request on its own model ids and delivers
2402
+ // the clip at exactly twice the canvas, same frames and audio: 720p from 672x384,
2403
+ // 1080p from 960x544, 2K from 1344x768. It is FastH3-class everywhere FastH3 is.
2404
+ // The size table, the id spellings and the delivered size come from the
2405
+ // Intelligence Client (isMinimaxH3TwoStageModelId, minimaxH3TwoStageCanvasShortEdge,
2406
+ // minimaxH3TwoStageDeliveredSize).
2407
+ const MINIMAX_H3_TWO_STAGE_MODEL_IDS = new Set([
2408
+ 'minimax-h3-fastvideo-int8_t2v_turbo_2stage',
2409
+ 'minimax-h3-fastvideo-int8_i2v_turbo_2stage',
2410
+ 'minimax-h3-fastvideo-int8_flf2v_turbo_2stage'
2411
+ ]);
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'
2364
2421
  ]);
2365
2422
  const MINIMAX_H3_FASTH3_TURBO_MODEL_IDS = new Set([
2366
2423
  'minimax-h3-fastvideo-int8_t2v_turbo',
2367
2424
  'minimax-h3-fastvideo-int8_i2v_turbo',
2368
- 'minimax-h3-fastvideo-int8_flf2v_turbo'
2425
+ 'minimax-h3-fastvideo-int8_flf2v_turbo',
2426
+ ...MINIMAX_H3_TWO_STAGE_MODEL_IDS,
2427
+ ...MINIMAX_H3_TWO_STAGE_720P_SOCKET_MODEL_IDS
2369
2428
  ]);
2370
2429
  const MINIMAX_H3_TURBO_SAMPLERS = Object.freeze(['euler', 'er_sde', 'sa_solver']);
2371
2430
  const MINIMAX_H3_TURBO_SAMPLER_SET = new Set(MINIMAX_H3_TURBO_SAMPLERS);
@@ -2496,6 +2555,29 @@ function resolveSkillVideoModelAlias(
2496
2555
  if (normalized === 'minimax-h3-fasth3-flf2v-turbo') {
2497
2556
  return 'minimax-h3-fastvideo-int8_flf2v_turbo';
2498
2557
  }
2558
+ if (normalized === 'minimax-h3-fasth3-turbo-2stage' && workflow) {
2559
+ if (workflow === 'r2v') {
2560
+ fatalCliError('MiniMax H3 FastH3 Two-Stage has no r2v workflow.', {
2561
+ code: 'INVALID_ARGUMENT',
2562
+ details: { model: modelId, workflow }
2563
+ });
2564
+ }
2565
+ if (workflow === 'i2v') {
2566
+ return hasStartFrame && hasEndFrame
2567
+ ? 'minimax-h3-fastvideo-int8_flf2v_turbo_2stage'
2568
+ : 'minimax-h3-fastvideo-int8_i2v_turbo_2stage';
2569
+ }
2570
+ return 'minimax-h3-fastvideo-int8_t2v_turbo_2stage';
2571
+ }
2572
+ if (normalized === 'minimax-h3-fasth3-t2v-turbo-2stage') {
2573
+ return 'minimax-h3-fastvideo-int8_t2v_turbo_2stage';
2574
+ }
2575
+ if (normalized === 'minimax-h3-fasth3-i2v-turbo-2stage') {
2576
+ return 'minimax-h3-fastvideo-int8_i2v_turbo_2stage';
2577
+ }
2578
+ if (normalized === 'minimax-h3-fasth3-flf2v-turbo-2stage') {
2579
+ return 'minimax-h3-fastvideo-int8_flf2v_turbo_2stage';
2580
+ }
2499
2581
  if (normalized === 'minimax-h3-balanced' && workflow) {
2500
2582
  if (workflow === 'r2v') {
2501
2583
  return MINIMAX_H3_R2V_BALANCED_MODEL_ID;
@@ -2532,6 +2614,32 @@ function isMiniMaxH3TurboModel(modelId) {
2532
2614
  return MINIMAX_H3_TURBO_MODEL_IDS.has(String(modelId || '').trim().toLowerCase());
2533
2615
  }
2534
2616
 
2617
+ function isMiniMaxH3TwoStageModel(modelId) {
2618
+ return isMinimaxH3TwoStageModelId(modelId);
2619
+ }
2620
+
2621
+ /**
2622
+ * The FastH3 Two-Stage canvas for a source of this size: the Intelligence Client
2623
+ * turns the requested delivered class (720, 1080, or 1440/2K; undefined is 2K)
2624
+ * into a 384, 544 or 768 short edge in the source's aspect (or aspectRatio's).
2625
+ */
2626
+ function miniMaxH3TwoStageCanvas(modelId, deliveredClass, sourceWidth, sourceHeight, aspectRatio) {
2627
+ const selector = `minimax-h3-fasth3-${miniMaxH3ModeFromModelId(modelId)}-turbo-2stage`;
2628
+ return calculateSharedVideoDimensions(sourceWidth, sourceHeight, deliveredClass, selector, aspectRatio || undefined);
2629
+ }
2630
+
2631
+ /**
2632
+ * Dimension rules that keep a pre-resized reference on the two-stage canvas, so
2633
+ * the resize cannot grow the clip into a larger, pricier delivered class.
2634
+ */
2635
+ function miniMaxH3TwoStageReferenceRules(rules, canvas) {
2636
+ return {
2637
+ ...rules,
2638
+ maxDimension: Math.min(rules.maxDimension, Math.max(canvas.width, canvas.height)),
2639
+ maxPixels: canvas.width * canvas.height
2640
+ };
2641
+ }
2642
+
2535
2643
  function isMiniMaxH3R2vModel(modelId) {
2536
2644
  const normalized = String(modelId || '').trim().toLowerCase();
2537
2645
  return normalized === MINIMAX_H3_R2V_MODEL_ID
@@ -2552,6 +2660,10 @@ function isMiniMaxH3FastH3TurboSelectionLocal(modelId) {
2552
2660
  || normalized === 'minimax-h3-fasth3-t2v-turbo'
2553
2661
  || normalized === 'minimax-h3-fasth3-i2v-turbo'
2554
2662
  || normalized === 'minimax-h3-fasth3-flf2v-turbo'
2663
+ || normalized === 'minimax-h3-fasth3-turbo-2stage'
2664
+ || normalized === 'minimax-h3-fasth3-t2v-turbo-2stage'
2665
+ || normalized === 'minimax-h3-fasth3-i2v-turbo-2stage'
2666
+ || normalized === 'minimax-h3-fasth3-flf2v-turbo-2stage'
2555
2667
  || MINIMAX_H3_FASTH3_TURBO_MODEL_IDS.has(normalized);
2556
2668
  }
2557
2669
 
@@ -2571,6 +2683,10 @@ function isMiniMaxH3ModelSelectionLocal(modelId) {
2571
2683
  || normalized === 'minimax-h3-fasth3-t2v-turbo'
2572
2684
  || normalized === 'minimax-h3-fasth3-i2v-turbo'
2573
2685
  || normalized === 'minimax-h3-fasth3-flf2v-turbo'
2686
+ || normalized === 'minimax-h3-fasth3-turbo-2stage'
2687
+ || normalized === 'minimax-h3-fasth3-t2v-turbo-2stage'
2688
+ || normalized === 'minimax-h3-fasth3-i2v-turbo-2stage'
2689
+ || normalized === 'minimax-h3-fasth3-flf2v-turbo-2stage'
2574
2690
  || normalized === 'minimax-h3-balanced'
2575
2691
  || normalized === 'minimax-h3-t2v-balanced'
2576
2692
  || normalized === 'minimax-h3-i2v-balanced'
@@ -2590,6 +2706,10 @@ function isMiniMaxH3TurboModelSelectionLocal(modelId) {
2590
2706
  || normalized === 'minimax-h3-fasth3-t2v-turbo'
2591
2707
  || normalized === 'minimax-h3-fasth3-i2v-turbo'
2592
2708
  || normalized === 'minimax-h3-fasth3-flf2v-turbo'
2709
+ || normalized === 'minimax-h3-fasth3-turbo-2stage'
2710
+ || normalized === 'minimax-h3-fasth3-t2v-turbo-2stage'
2711
+ || normalized === 'minimax-h3-fasth3-i2v-turbo-2stage'
2712
+ || normalized === 'minimax-h3-fasth3-flf2v-turbo-2stage'
2593
2713
  || isMiniMaxH3TurboModel(normalized);
2594
2714
  }
2595
2715
 
@@ -2606,6 +2726,9 @@ function miniMaxH3ModeFromModelId(modelId) {
2606
2726
  if (normalized === 'minimax-h3-fasth3-t2v-turbo') return 't2v';
2607
2727
  if (normalized === 'minimax-h3-fasth3-i2v-turbo') return 'i2v';
2608
2728
  if (normalized === 'minimax-h3-fasth3-flf2v-turbo') return 'flf2v';
2729
+ if (normalized === 'minimax-h3-fasth3-t2v-turbo-2stage') return 't2v';
2730
+ if (normalized === 'minimax-h3-fasth3-i2v-turbo-2stage') return 'i2v';
2731
+ if (normalized === 'minimax-h3-fasth3-flf2v-turbo-2stage') return 'flf2v';
2609
2732
  if (normalized === 'minimax-h3-t2v-balanced') return 't2v';
2610
2733
  if (normalized === 'minimax-h3-i2v-balanced') return 'i2v';
2611
2734
  if (normalized === 'minimax-h3-flf2v-balanced') return 'flf2v';
@@ -2851,6 +2974,7 @@ const options = {
2851
2974
  steps: null,
2852
2975
  guidance: null,
2853
2976
  outputFormat: null,
2977
+ returnLastFrame: false,
2854
2978
  imageQuality: null,
2855
2979
  imageBackground: null,
2856
2980
  imageOutputCompression: null,
@@ -2869,6 +2993,17 @@ const options = {
2869
2993
  seed: null,
2870
2994
  lastSeed: false,
2871
2995
  seedStrategy: null,
2996
+ speech: false,
2997
+ speechMode: null,
2998
+ speechVoice: null,
2999
+ voiceDescription: null,
3000
+ voiceReference: null,
3001
+ voiceTranscript: null,
3002
+ speechCreativity: null,
3003
+ imageTo3d: null,
3004
+ removeBackground: null,
3005
+ matte: false,
3006
+ meshSettings: {},
2872
3007
  music: false,
2873
3008
  musicLyrics: null,
2874
3009
  musicLanguage: null,
@@ -3002,7 +3137,7 @@ const options = {
3002
3137
  apiModelId: null,
3003
3138
  liveModelAction: null, // list|search
3004
3139
  liveModelQuery: null,
3005
- liveModelMedia: 'all', // image|video|audio|all
3140
+ liveModelMedia: 'all', // image|video|audio|model|all
3006
3141
  liveModelNetwork: null, // fast|relaxed; defaults to configured network
3007
3142
  liveModelTags: [], // repeatable --model-tag filters (AND semantics)
3008
3143
  loraCatalogAction: null, // list|search
@@ -3087,6 +3222,7 @@ const cliSet = {
3087
3222
  duration: false,
3088
3223
  frames: false,
3089
3224
  targetResolution: false,
3225
+ targetResolution2K: false,
3090
3226
  autoResizeVideoAssets: false,
3091
3227
  angles360Video: false,
3092
3228
  videoModel: false,
@@ -3206,6 +3342,8 @@ for (let i = 0; i < args.length; i++) {
3206
3342
  i++;
3207
3343
  options.guidance = parseNumberValue(raw, arg);
3208
3344
  cliSet.guidance = true;
3345
+ } else if (arg === '--return-last-frame') {
3346
+ options.returnLastFrame = true;
3209
3347
  } else if (arg === '--output-format' || arg === '--format') {
3210
3348
  const raw = requireFlagValue(args, i, arg);
3211
3349
  i++;
@@ -3428,8 +3566,18 @@ for (let i = 0; i < args.length; i++) {
3428
3566
  } else if (arg === '--target-resolution' || arg === '--short-side') {
3429
3567
  const raw = requireFlagValue(args, i, arg);
3430
3568
  i++;
3431
- options.targetResolution = parsePositiveIntegerValue(raw, arg);
3569
+ const parsed = parseTargetResolutionValue(raw, arg);
3570
+ options.targetResolution = parsed.value;
3432
3571
  cliSet.targetResolution = true;
3572
+ cliSet.targetResolution2K = parsed.spelled2K;
3573
+ } else if (arg === '--output-scale' || arg === '--2k') {
3574
+ // Retired: MiniMax H3 1080p/2K output is its own model id now, and Sogni
3575
+ // refuses any request carrying outputScale. Fail instead of guessing a model.
3576
+ fatalCliError(`${arg} is no longer supported. MiniMax H3 2K output is the FastH3 Two-Stage model: use -m minimax-h3-fasth3-turbo-2stage.`, {
3577
+ code: 'INVALID_ARGUMENT',
3578
+ details: { flag: arg },
3579
+ hint: 'Replace the flag with -m minimax-h3-fasth3-turbo-2stage (or minimax-h3-fasth3-t2v-turbo-2stage / -i2v- / -flf2v-), which delivers 2K by default (1344x768 -> 2688x1536); add --target-resolution 1080 or 720 for 1080p or 720p.'
3580
+ });
3433
3581
  } else if (arg === '--auto-resize-assets') {
3434
3582
  options.autoResizeVideoAssets = true;
3435
3583
  cliSet.autoResizeVideoAssets = true;
@@ -3499,6 +3647,23 @@ for (let i = 0; i < args.length; i++) {
3499
3647
  i++;
3500
3648
  options.contextImages.push(raw);
3501
3649
  cliSet.context = true;
3650
+ } else if (arg === '--image-to-3d' || arg === '--pixal3d') {
3651
+ options.imageTo3d = expandHomePath(requireFlagValue(args, i++, arg));
3652
+ } else if (arg === '--remove-background') {
3653
+ options.removeBackground = expandHomePath(requireFlagValue(args, i++, arg));
3654
+ } else if (arg === '--matte') {
3655
+ options.matte = true;
3656
+ } else if (Object.hasOwn(MESH_FLAGS, arg)) {
3657
+ const [key, min, max] = MESH_FLAGS[arg];
3658
+ options.meshSettings[key] = parsePositiveIntegerValue(requireFlagValue(args, i++, arg), arg, min, max);
3659
+ } else if (arg === '--speech') {
3660
+ options.speech = true;
3661
+ } else if (Object.hasOwn(SPEECH_VALUE_FLAGS, arg)) {
3662
+ const key = SPEECH_VALUE_FLAGS[arg];
3663
+ const value = requireFlagValue(args, i++, arg);
3664
+ options[key] = key === 'voiceReference' ? expandHomePath(value) : value;
3665
+ } else if (arg === '--speech-creativity') {
3666
+ options.speechCreativity = parseNumberValue(requireFlagValue(args, i++, arg), arg);
3502
3667
  } else if (arg === '--segment') {
3503
3668
  options.segmentImage = expandHomePath(requireFlagValue(args, i++, arg));
3504
3669
  } else if (arg === '--segment-point' || arg === '--segment-exclude') {
@@ -3788,8 +3953,8 @@ for (let i = 0; i < args.length; i++) {
3788
3953
  } else if (arg === '--model-media') {
3789
3954
  const raw = requireFlagValue(args, i, arg);
3790
3955
  i++;
3791
- if (!['image', 'video', 'audio', 'all'].includes(raw)) {
3792
- fatalCliError('--model-media must be one of image, video, audio, or all.', {
3956
+ if (!['image', 'video', 'audio', 'model', 'all'].includes(raw)) {
3957
+ fatalCliError('--model-media must be one of image, video, audio, model, or all.', {
3793
3958
  code: 'INVALID_ARGUMENT',
3794
3959
  details: { value: raw }
3795
3960
  });
@@ -4162,7 +4327,8 @@ Image Options:
4162
4327
  --distance <key> close-up|medium|wide
4163
4328
  --angle-strength <n> LoRA strength for multiple_angles (default: 0.9)
4164
4329
  --angle-description <text> Optional subject description
4165
- --output-format <f> Image output format: png|jpg (webp for GPT Image)
4330
+ --output-format <f> Images: png|jpg (webp for GPT Image); video: mp4|mov (MOV: Seedance 2.5)
4331
+ --return-last-frame Export the final video frame as an image (Seedance 2.5)
4166
4332
  --image-quality <q> GPT Image: low|medium|high; 2.5 also xhigh|max
4167
4333
  --image-background <b> auto|opaque; 2.5 also transparent (PNG/WebP)
4168
4334
  --image-output-compression <n> JPEG/WebP compression, integer 0–100
@@ -4192,12 +4358,27 @@ Photobooth (Face Transfer):
4192
4358
  --cn-strength <n> ControlNet strength (default: 0.8)
4193
4359
  --cn-guidance-end <n> ControlNet guidance end point (default: 0.3)
4194
4360
 
4361
+ 3D and Background Removal:
4362
+ --image-to-3d <image> Pixal3D: original image to binary GLB (alias --pixal3d)
4363
+ --shape-resolution <n> 1024 (default) or 1536; optional --mesh-faces 5000–700000
4364
+ --texture-size <n> 1024–4096; --normal-map-size 512–2048; --ao-map-size 256–1024
4365
+ --remove-background <image> BiRefNet transparent PNG; --matte returns soft mask
4366
+
4367
+ Speech Options:
4368
+ --speech Read the exact prompt as speech; output WAV by default
4369
+ --speech-mode <mode> voice (default), clone, or design
4370
+ --speech-voice <id> serena (default), vivian, uncle_fu, ryan, aiden, ono_anna, sohee, eric, dylan
4371
+ --voice-description <text> Optional delivery direction; required for design
4372
+ --voice-reference <audio> Required 3–30 second recording for clone (needs ffprobe)
4373
+ --voice-transcript <text> Optional transcript of clone reference
4374
+ --speech-creativity <n> Speech temperature 0.1–2; --language auto or language name
4375
+
4195
4376
  Music Options:
4196
4377
  --music Generate music/audio instead of image
4197
- --music-model <id> Music model: turbo|sft|ace_step_1.5_xl_turbo|ace_step_1.5_xl_sft
4198
- --lyrics <text> Optional song lyrics (omit for instrumental)
4378
+ --music-model <id> Music model: music3|turbo|sft (or full model ID)
4379
+ --lyrics <text> Song lyrics; Music 3 instrumentals benefit from section tags
4199
4380
  --language <code> Lyrics language code (default: en)
4200
- --duration <sec> Music duration in seconds (10-600, default: 30)
4381
+ --duration <sec> ACE: 10–600s, default 30; Music 3: 10–300s, default 60
4201
4382
  --length <sec> Alias for --duration
4202
4383
  --bpm <num> Beats per minute (30-300)
4203
4384
  --keyscale <text> Key/scale, e.g. "C major" or "A minor"
@@ -4221,7 +4402,9 @@ Video Options:
4221
4402
  --fps <num> Frames per second (model default unless set)
4222
4403
  --duration <sec> Duration in seconds (default: 5); Seedance 2.5 edit requires @Video1's source duration
4223
4404
  --frames <num> Override total frames (optional)
4224
- --target-resolution <px> Short-side target that preserves aspect ratio (Seedance 2.5: 480 or 720)
4405
+ --target-resolution <px> Short-side target that preserves aspect ratio (Seedance 2.5: 480, 720 or 1080).
4406
+ MiniMax H3 FastH3 Two-Stage: the delivered size, 720, 1080, or 2K (1440; default),
4407
+ rendered on a half-size canvas (672x384, 960x544, 1344x768)
4225
4408
  --auto-resize-assets Auto-resize video reference assets (default)
4226
4409
  --no-auto-resize-assets Disable auto-resize for video assets
4227
4410
  --estimate-video-cost Estimate video cost and exit
@@ -4332,7 +4515,7 @@ General:
4332
4515
  --balance, --balances Show account, plan, and SPARK/SOGNI balances and exit
4333
4516
  --list-models [query] List live Supernet media models; optionally filter by query
4334
4517
  --search-models <q> Search live models by ID or name (separator-insensitive)
4335
- --model-media <type> Filter model discovery: image|video|audio|all (default: all)
4518
+ --model-media <type> Filter model discovery: image|video|audio|model|all (default: all; model = 3D)
4336
4519
  --model-network <n> Model discovery network: fast|relaxed (default: configured network)
4337
4520
  --model-tag <tag> Filter by catalog tag, e.g. spicy or uncensored (repeatable, AND)
4338
4521
  --list-loras [query] List the live LoRA catalog with each LoRA's strength contract
@@ -4443,7 +4626,7 @@ Seedance Video Model Selectors:
4443
4626
  seedance2-ia2v Image+audio-to-video
4444
4627
  seedance2-v2v Video-to-video without ControlNet
4445
4628
  seedance2-5 Seedance 2.5 text-to-video (alias seedance2-5-t2v): 4-30s single clips,
4446
- 480p/720p only (no 1080p/4K), native audio, first/last frame via
4629
+ 480p/720p/1080p (no 4K), MP4/MOV and last-frame export, native audio, first/last frame via
4447
4630
  --ref/--ref-end, up to 30 image / 10 video / 10 audio refs (30 total)
4448
4631
  seedance2-5-ia2v Seedance 2.5 image+audio-to-video
4449
4632
  seedance2-5-v2v Seedance 2.5 video-to-video, editing, and extension, no ControlNet
@@ -4480,6 +4663,14 @@ state negatives in the structured prompt.):
4480
4663
  minimax-h3-fasth3-t2v-turbo FastH3 text-to-video (up to 6x faster than Standard)
4481
4664
  minimax-h3-fasth3-i2v-turbo FastH3 I2VA (--ref) or L2VA (--ref-end)
4482
4665
  minimax-h3-fasth3-flf2v-turbo FastH3 first-frame -> last-frame (--ref plus --ref-end)
4666
+ minimax-h3-fasth3-turbo-2stage FastH3 Two-Stage: delivered at twice the canvas, 2K by default (1344x768 -> 2688x1536);
4667
+ --target-resolution 1080 or 720 for 1080p or 720p; infers T2VA/I2VA/L2VA/FL2VA; no R2V
4668
+ minimax-h3-fasth3-t2v-turbo-2stage
4669
+ FastH3 Two-Stage text-to-video
4670
+ minimax-h3-fasth3-i2v-turbo-2stage
4671
+ FastH3 Two-Stage I2VA (--ref) or L2VA (--ref-end)
4672
+ minimax-h3-fasth3-flf2v-turbo-2stage
4673
+ FastH3 Two-Stage first-frame -> last-frame (--ref plus --ref-end)
4483
4674
  H3 FL2VA Turbo sampler override --sampler euler|er_sde|sa_solver
4484
4675
  (Socket default: er_sde; CLI omits unless set)
4485
4676
  (scheduler remains fixed to simple)
@@ -4558,6 +4749,9 @@ Examples:
4558
4749
  }
4559
4750
  }
4560
4751
 
4752
+ try { prepareMediaUtilityOptions(options, cliSet); }
4753
+ catch (error) { fatalCliError(error.message, { code: 'INVALID_ARGUMENT' }); }
4754
+
4561
4755
  let timeoutFromConfig = false;
4562
4756
  let widthFromConfig = false;
4563
4757
  let heightFromConfig = false;
@@ -4878,16 +5072,18 @@ if (!options.video && !options.music && options.model) {
4878
5072
  if (options.outputFormat) {
4879
5073
  const normalized = options.outputFormat.toLowerCase();
4880
5074
  options.outputFormat = normalized === 'jpeg' ? 'jpg' : normalized;
4881
- if (options.music) {
5075
+ if (options.imageTo3d) {
5076
+ // GLB is a model artifact, not an SDK image outputFormat.
5077
+ } else if (options.music || options.speech) {
4882
5078
  if (!MUSIC_OUTPUT_FORMATS.has(options.outputFormat)) {
4883
- fatalCliError('Music output format must be "mp3", "flac", or "wav".', {
5079
+ fatalCliError(`${options.speech ? 'Speech' : 'Music'} output format must be "mp3", "flac", or "wav".`, {
4884
5080
  code: 'INVALID_ARGUMENT',
4885
5081
  details: { outputFormat: options.outputFormat }
4886
5082
  });
4887
5083
  }
4888
5084
  } else if (options.video || options.upscaleVideo) {
4889
- if (options.outputFormat !== 'mp4') {
4890
- fatalCliError('Video output format must be "mp4".', {
5085
+ if (!['mp4', ...(options.video && isSeedance25ModelSelectionLocal(options.model) ? ['mov'] : [])].includes(options.outputFormat)) {
5086
+ fatalCliError('Video output format must be "mp4" (Seedance 2.5 also supports "mov").', {
4891
5087
  code: 'INVALID_ARGUMENT',
4892
5088
  details: { outputFormat: options.outputFormat }
4893
5089
  });
@@ -4900,6 +5096,10 @@ if (options.outputFormat) {
4900
5096
  }
4901
5097
  }
4902
5098
 
5099
+ if (options.returnLastFrame && (!options.video || !isSeedance25ModelSelectionLocal(options.model))) {
5100
+ fatalCliError('--return-last-frame requires Seedance 2.5 video.', { code: 'INVALID_ARGUMENT' });
5101
+ }
5102
+
4903
5103
  if (options.imageQuality !== null || options.imageBackground !== null || options.imageOutputCompression !== null || options.imageMask !== null) {
4904
5104
  try {
4905
5105
  if (options.video || options.music || !isGptImage2ModelSelection(options.model)) {
@@ -5012,7 +5212,7 @@ if (options.video && options.loras.length > 0) {
5012
5212
  const unknownVideoLoras = options.loras.filter(loraId => !videoLoraEntries.has(loraId));
5013
5213
  if (unknownVideoLoras.length > 0) {
5014
5214
  const availableIds = [...videoLoraEntries.keys()];
5015
- const isUnresolvedH3Alias = /^minimax-h3(?:-(?:fasth3-)?turbo)?$/.test(String(options.model || ''));
5215
+ const isUnresolvedH3Alias = /^minimax-h3(?:-turbo|-fasth3-turbo(?:-2stage)?)?$/.test(String(options.model || ''));
5016
5216
  fatalCliError(
5017
5217
  `Video LoRA "${unknownVideoLoras[0]}" is not published for model "${options.model}". ` +
5018
5218
  (availableIds.length > 0
@@ -5265,14 +5465,14 @@ if (options.music) {
5265
5465
  const configuredMusicModel = options.model || openclawConfig?.defaultMusicModel || 'turbo';
5266
5466
  options.model = normalizeMusicModelId(configuredMusicModel);
5267
5467
  if (!options.model) {
5268
- fatalCliError(`Unknown music model "${configuredMusicModel}". Use turbo, sft, ace_step_1.5_xl_turbo, or ace_step_1.5_xl_sft.`, {
5468
+ fatalCliError(`Unknown music model "${configuredMusicModel}". Use music3, turbo, sft, minimax_music3, ace_step_1.5_xl_turbo, or ace_step_1.5_xl_sft.`, {
5269
5469
  code: 'INVALID_ARGUMENT',
5270
5470
  details: { flag: cliSet.model ? '--model' : 'defaultMusicModel', value: configuredMusicModel }
5271
5471
  });
5272
5472
  }
5273
5473
  const musicDefaults = getMusicModelDefaults(options.model);
5274
5474
  if (!cliSet.duration || !Number.isFinite(options.duration)) {
5275
- options.duration = MUSIC_DURATION_LIMITS.default;
5475
+ options.duration = (musicDefaults.duration || MUSIC_DURATION_LIMITS).default;
5276
5476
  }
5277
5477
  if (!options.outputFormat) {
5278
5478
  options.outputFormat = 'mp3';
@@ -5290,11 +5490,13 @@ if (options.music) {
5290
5490
  options.scheduler = musicDefaults.scheduler.default;
5291
5491
  }
5292
5492
  if (!cliSet.musicShift) {
5293
- options.musicShift = musicDefaults.shift.default;
5493
+ options.musicShift = musicDefaults.shift?.default ?? null;
5294
5494
  }
5295
5495
  if (!cliSet.timeout && !timeoutFromConfig && options.timeout === 30000) {
5296
5496
  options.timeout = 600000;
5297
5497
  }
5498
+ } else if (options.speech || options.imageTo3d || options.removeBackground) {
5499
+ if (!cliSet.timeout && !timeoutFromConfig) options.timeout = 600000;
5298
5500
  } else if (options.video) {
5299
5501
  if (!options.model) {
5300
5502
  let defaultVideoModel = selectDefaultVideoModel(options.videoWorkflow, options, openclawConfig);
@@ -5392,15 +5594,50 @@ if (options.music) {
5392
5594
  options.steps = videoQuality.steps;
5393
5595
  }
5394
5596
  }
5395
- const videoShortSide = (cliSet.targetResolution || targetResolutionFromPrompt)
5396
- ? options.targetResolution
5397
- : (!isSeedanceVideo ? videoQuality?.shortSide : null);
5398
- if (videoShortSide && !cliSet.width && !cliSet.height && !widthFromConfig && !heightFromConfig && !widthFromPrompt && !heightFromPrompt) {
5597
+ // MiniMax H3 FastH3 Two-Stage: --target-resolution names the delivered class
5598
+ // (720, 1080, or 1440/2K; omitted is 2K) and the canvas is half of it, from the
5599
+ // Intelligence Client's size table. Anything else is refused, never guessed.
5600
+ const isTwoStageVideo = isMiniMaxH3TwoStageModel(options.model);
5601
+ if (cliSet.targetResolution2K && !isTwoStageVideo) {
5602
+ fatalCliError(`--target-resolution 2K is the MiniMax H3 FastH3 Two-Stage delivered size; ${options.model} takes a short side in pixels.`, {
5603
+ code: 'INVALID_ARGUMENT',
5604
+ details: { flag: '--target-resolution', value: '2K', model: options.model },
5605
+ hint: 'Use -m minimax-h3-fasth3-turbo-2stage for 2K MiniMax H3 video, or pass the short side in pixels.'
5606
+ });
5607
+ }
5608
+ const hasExplicitVideoCanvas = cliSet.width || cliSet.height || widthFromConfig || heightFromConfig || widthFromPrompt || heightFromPrompt;
5609
+ if (isTwoStageVideo) {
5610
+ const requestedClass = (cliSet.targetResolution || targetResolutionFromPrompt) ? options.targetResolution : undefined;
5611
+ try {
5612
+ minimaxH3TwoStageCanvasShortEdge(requestedClass);
5613
+ } catch (error) {
5614
+ fatalCliError(`${error.message}.`, {
5615
+ code: 'INVALID_ARGUMENT',
5616
+ details: { flag: '--target-resolution', value: requestedClass, model: options.model },
5617
+ hint: 'MiniMax H3 FastH3 Two-Stage --target-resolution is the delivered size: 720, 1080, or 2K (1440). Omit it for 2K.'
5618
+ });
5619
+ }
5620
+ options._miniMaxH3TwoStageClass = requestedClass;
5621
+ // An explicit -w/-h is the canvas as given; otherwise the class sets it, and
5622
+ // an i2v reference later re-derives it in the reference's aspect.
5623
+ options._miniMaxH3TwoStageAutoCanvas = !hasExplicitVideoCanvas;
5624
+ if (!hasExplicitVideoCanvas) {
5625
+ const canvas = miniMaxH3TwoStageCanvas(options.model, requestedClass, options.width, options.height, aspectRatioFromPrompt);
5626
+ options.width = canvas.width;
5627
+ options.height = canvas.height;
5628
+ }
5629
+ }
5630
+ const videoShortSide = isTwoStageVideo
5631
+ ? null
5632
+ : ((cliSet.targetResolution || targetResolutionFromPrompt)
5633
+ ? options.targetResolution
5634
+ : (!isSeedanceVideo ? videoQuality?.shortSide : null));
5635
+ if (videoShortSide && !hasExplicitVideoCanvas) {
5399
5636
  const dims = dimensionsWithShortSide(options.width, options.height, videoShortSide);
5400
5637
  options.width = dims.width;
5401
5638
  options.height = dims.height;
5402
5639
  }
5403
- if (aspectRatioFromPrompt && !cliSet.width && !cliSet.height) {
5640
+ if (aspectRatioFromPrompt && !cliSet.width && !cliSet.height && !isTwoStageVideo) {
5404
5641
  const dims = dimensionsForAspectRatio(options.width, options.height, aspectRatioFromPrompt);
5405
5642
  if (dims) {
5406
5643
  options.width = dims.width;
@@ -5469,8 +5706,12 @@ if (!options.video && !options.music && isGptImage2ModelSelection(options.model)
5469
5706
 
5470
5707
  if (options.music) {
5471
5708
  const musicDefaults = getMusicModelDefaults(options.model);
5472
- if (options.duration < MUSIC_DURATION_LIMITS.min || options.duration > MUSIC_DURATION_LIMITS.max) {
5473
- fatalCliError(`Music duration must be between ${MUSIC_DURATION_LIMITS.min} and ${MUSIC_DURATION_LIMITS.max} seconds.`, {
5709
+ const durationLimits = musicDefaults.duration || MUSIC_DURATION_LIMITS;
5710
+ if (options.model === MUSIC3_MODEL_ID && (cliSet.musicShift || cliSet.musicBpm || cliSet.musicKeyscale || cliSet.musicTimesig || cliSet.musicLanguage || cliSet.musicComposerMode)) {
5711
+ fatalCliError('Music 3 does not use shift, BPM, key, time signature, language, or composer controls. Describe musical direction in the prompt and lyrics.', { code: 'INVALID_ARGUMENT' });
5712
+ }
5713
+ if (options.duration < durationLimits.min || options.duration > durationLimits.max) {
5714
+ fatalCliError(`Music duration must be between ${durationLimits.min} and ${durationLimits.max} seconds.`, {
5474
5715
  code: 'INVALID_ARGUMENT',
5475
5716
  details: { duration: options.duration }
5476
5717
  });
@@ -5563,7 +5804,7 @@ const commandUsesGenerationSeed = !options.apiChat &&
5563
5804
  !options.remixAudio &&
5564
5805
  !options.upscaleImage &&
5565
5806
  !options.upscaleVideo &&
5566
- !options.segmentImage &&
5807
+ !options.segmentImage && !options.imageTo3d && !options.removeBackground &&
5567
5808
  !options.listMedia &&
5568
5809
  !options.memoryAction &&
5569
5810
  !options.personalityAction &&
@@ -5602,7 +5843,7 @@ const wan3HasMediaInput = isWan3ModelLocal(options.model) && Boolean(
5602
5843
  || options.wan3ReferenceFileUrl
5603
5844
  || options.wan3ReferenceLinkUrl
5604
5845
  );
5605
- if (!options.prompt && !wan3HasMediaInput && !options.segmentImage && !options.upscaleImage && !options.upscaleVideo && !options.apiChat && !apiWorkflowUtilityAction && !apiWorkflowStartAction && !apiModelUtilityAction && !liveModelUtilityAction && !loraCatalogUtilityAction && !apiReplayUtilityAction && !contractUtilityAction && !storyboardPlanUtilityAction && !options.estimateVideoCost && !options.multiAngle && !options.showBalance && !options.showVersion && !options.doctor && !options.extractLastFrame && !options.extractFirstFrame && !options.extractFrameAt && !options.trimVideo && !options.verifyVideo && !options.concatVideos && !options.sourceReelDir && !options.remixAudio && !options.listMedia && !options.memoryAction && !options.personalityAction && !personaUtilityAction) {
5846
+ if (!options.prompt && !wan3HasMediaInput && !options.segmentImage && !options.imageTo3d && !options.removeBackground && !options.upscaleImage && !options.upscaleVideo && !options.apiChat && !apiWorkflowUtilityAction && !apiWorkflowStartAction && !apiModelUtilityAction && !liveModelUtilityAction && !loraCatalogUtilityAction && !apiReplayUtilityAction && !contractUtilityAction && !storyboardPlanUtilityAction && !options.estimateVideoCost && !options.multiAngle && !options.showBalance && !options.showVersion && !options.doctor && !options.extractLastFrame && !options.extractFirstFrame && !options.extractFrameAt && !options.trimVideo && !options.verifyVideo && !options.concatVideos && !options.sourceReelDir && !options.remixAudio && !options.listMedia && !options.memoryAction && !options.personalityAction && !personaUtilityAction) {
5606
5847
  fatalCliError('No prompt provided. Use --help for usage.', { code: 'INVALID_ARGUMENT' });
5607
5848
  }
5608
5849
 
@@ -5826,7 +6067,7 @@ if (options.video) {
5826
6067
  (cliSet.width || cliSet.height)
5827
6068
  ) {
5828
6069
  fatalCliError(
5829
- `Seedance 2.5 ${options.seedanceTaskType} inherits @Video1's aspect ratio; use --target-resolution 480 or 720 instead of --width/--height.`,
6070
+ `Seedance 2.5 ${options.seedanceTaskType} inherits @Video1's aspect ratio; use --target-resolution 480, 720 or 1080 instead of --width/--height.`,
5830
6071
  {
5831
6072
  code: 'INVALID_ARGUMENT',
5832
6073
  details: { seedanceTaskType: options.seedanceTaskType }
@@ -5836,9 +6077,9 @@ if (options.video) {
5836
6077
  if (
5837
6078
  isSeedance25Video &&
5838
6079
  cliSet.targetResolution &&
5839
- ![480, 720].includes(options.targetResolution)
6080
+ ![480, 720, 1080].includes(options.targetResolution)
5840
6081
  ) {
5841
- fatalCliError('Seedance 2.5 --target-resolution must be 480 or 720.', {
6082
+ fatalCliError('Seedance 2.5 --target-resolution must be 480, 720 or 1080.', {
5842
6083
  code: 'INVALID_ARGUMENT',
5843
6084
  details: { targetResolution: options.targetResolution }
5844
6085
  });
@@ -6409,12 +6650,34 @@ if (options.video) {
6409
6650
  // clients that ceiling is model-aware — e.g. 3840 for LTX-2.x — on legacy clients it is a
6410
6651
  // blanket 1536).
6411
6652
  const hasVideoReference = Boolean(options.refImage || options.refImageEnd);
6412
- const videoDimensionRules = hasVideoReference
6653
+ const referenceVideoDimensionRules = hasVideoReference
6413
6654
  ? {
6414
6655
  ...baseVideoDimensionRules,
6415
6656
  maxDimension: Math.min(baseVideoDimensionRules.maxDimension, wrapperRefVideoDimensionCeiling(options.model))
6416
6657
  }
6417
6658
  : baseVideoDimensionRules;
6659
+ // FastH3 Two-Stage follows a local reference's aspect at the requested
6660
+ // delivered class, and caps the reference pre-resize to that canvas.
6661
+ let twoStageReferenceCanvas = null;
6662
+ if (options._miniMaxH3TwoStageAutoCanvas && options.videoWorkflow === 'i2v' && hasVideoReference) {
6663
+ const twoStageRefPath = options.refImage || options.refImageEnd;
6664
+ if (!isHttpUrl(twoStageRefPath) && existsSync(twoStageRefPath)) {
6665
+ const twoStageRefDims = getImageDimensionsFromBuffer(readFileSync(twoStageRefPath));
6666
+ if (twoStageRefDims?.width && twoStageRefDims?.height) {
6667
+ twoStageReferenceCanvas = miniMaxH3TwoStageCanvas(
6668
+ options.model,
6669
+ options._miniMaxH3TwoStageClass,
6670
+ twoStageRefDims.width,
6671
+ twoStageRefDims.height
6672
+ );
6673
+ options.width = twoStageReferenceCanvas.width;
6674
+ options.height = twoStageReferenceCanvas.height;
6675
+ }
6676
+ }
6677
+ }
6678
+ const videoDimensionRules = twoStageReferenceCanvas
6679
+ ? miniMaxH3TwoStageReferenceRules(referenceVideoDimensionRules, twoStageReferenceCanvas)
6680
+ : referenceVideoDimensionRules;
6418
6681
 
6419
6682
  // An implicit LTX i2v canvas follows an already-compatible local reference
6420
6683
  // directly. Resolve this before normalizing the model's landscape default so
@@ -8381,7 +8644,7 @@ async function runLiveModels() {
8381
8644
  ? [...new Set(model.tags.map(normalizeLiveModelTag).filter(Boolean))].sort()
8382
8645
  : []
8383
8646
  })).filter(model =>
8384
- ['image', 'video', 'audio'].includes(model.media) &&
8647
+ ['image', 'video', 'audio', 'model'].includes(model.media) &&
8385
8648
  model.networks.includes(network) &&
8386
8649
  (media === 'all' || model.media === media)
8387
8650
  );
@@ -12653,6 +12916,9 @@ async function main() {
12653
12916
  }
12654
12917
  if (options.json) {
12655
12918
  const duration = options.frames ? Math.max(1, Math.round((options.frames - 1) / options.fps)) : options.duration;
12919
+ const delivered = isMiniMaxH3TwoStageModel(options.model)
12920
+ ? minimaxH3TwoStageDeliveredSize(options.width, options.height)
12921
+ : null;
12656
12922
  console.log(JSON.stringify({
12657
12923
  success: true,
12658
12924
  type: 'video-cost',
@@ -12665,6 +12931,7 @@ async function main() {
12665
12931
  steps,
12666
12932
  tokenType: options.tokenType || 'spark',
12667
12933
  count: options.count,
12934
+ ...(delivered ? { deliveredWidth: delivered.width, deliveredHeight: delivered.height } : {}),
12668
12935
  estimate
12669
12936
  }));
12670
12937
  } else {
@@ -12699,13 +12966,14 @@ async function main() {
12699
12966
  client.on(ClientEvent.JOB_COMPLETED, (data) => {
12700
12967
  const jobData = data.job?.data || {};
12701
12968
  results.push({
12702
- resultUrl: data.resultUrl || (options.music ? data.audioUrl : (options.video || options.upscaleVideo) ? data.videoUrl : data.imageUrl),
12969
+ resultUrl: data.resultUrl || ((options.music || options.speech) ? data.audioUrl : (options.video || options.upscaleVideo) ? data.videoUrl : data.imageUrl),
12970
+ lastFrameUrl: data.lastFrameUrl || data.job?.lastFrameUrl || jobData.lastFrameUrl,
12703
12971
  seed: jobData.seed,
12704
12972
  jobIndex: data.jobIndex,
12705
12973
  projectId: data.projectId
12706
12974
  });
12707
12975
  completedJobs++;
12708
- log(`${options.music ? 'Music' : (options.video || options.upscaleVideo) ? 'Video' : 'Image'} ${completedJobs}/${options.count} completed`);
12976
+ log(`${options.speech ? 'Speech' : options.imageTo3d ? '3D model' : options.music ? 'Music' : (options.video || options.upscaleVideo) ? 'Video' : 'Image'} ${completedJobs}/${options.count} completed`);
12709
12977
 
12710
12978
  if (completedJobs >= options.count) {
12711
12979
  clearTimeout(timeout);
@@ -12736,7 +13004,7 @@ async function main() {
12736
13004
  });
12737
13005
 
12738
13006
  // Progress for longer-running media jobs.
12739
- if (options.video || options.music || options.upscaleVideo) {
13007
+ if (options.video || options.music || options.speech || options.imageTo3d || options.removeBackground || options.upscaleVideo) {
12740
13008
  client.on(ClientEvent.PROJECT_PROGRESS, (data) => {
12741
13009
  if (data.percentage && data.percentage > 0) {
12742
13010
  log(`Progress: ${Math.round(data.percentage)}%`);
@@ -13057,7 +13325,23 @@ async function main() {
13057
13325
  ? await prepareReferenceAudioIdentityMedia(options.referenceAudioIdentity)
13058
13326
  : undefined;
13059
13327
  const modelDefaults = getModelDefaults(options.model, openclawConfig);
13060
- const videoDimensionRules = videoDimensionRulesFromDefaults(modelDefaults, options.model);
13328
+ let videoDimensionRules = videoDimensionRulesFromDefaults(modelDefaults, options.model);
13329
+ // FastH3 Two-Stage: a downloaded (or local) reference sets the canvas aspect
13330
+ // at the requested delivered class, and the pre-resize stays on that canvas.
13331
+ if (options._miniMaxH3TwoStageAutoCanvas && options.videoWorkflow === 'i2v' && (imageBuffer || endImageBuffer)) {
13332
+ const twoStageRefDims = await getVideoImageDimensionsFromBuffer(imageBuffer || endImageBuffer);
13333
+ if (twoStageRefDims?.width && twoStageRefDims?.height) {
13334
+ const twoStageCanvas = miniMaxH3TwoStageCanvas(
13335
+ options.model,
13336
+ options._miniMaxH3TwoStageClass,
13337
+ twoStageRefDims.width,
13338
+ twoStageRefDims.height
13339
+ );
13340
+ options.width = twoStageCanvas.width;
13341
+ options.height = twoStageCanvas.height;
13342
+ videoDimensionRules = miniMaxH3TwoStageReferenceRules(videoDimensionRules, twoStageCanvas);
13343
+ }
13344
+ }
13061
13345
 
13062
13346
  if (
13063
13347
  options.videoWorkflow === 'v2v' &&
@@ -13204,6 +13488,7 @@ async function main() {
13204
13488
  if (options.seedanceTaskType) {
13205
13489
  projectConfig.seedanceTaskType = options.seedanceTaskType;
13206
13490
  }
13491
+ if (options.returnLastFrame) projectConfig.returnLastFrame = true;
13207
13492
  if (isWan3Video) {
13208
13493
  projectConfig.ratio = options.wan3Ratio;
13209
13494
  projectConfig.generateAudio = options.apiGenerateAudio ?? true;
@@ -13295,6 +13580,14 @@ async function main() {
13295
13580
  if (options.apiGenerateAudio !== null && (isMiniMaxH3Model(options.model) || isWan3Video)) {
13296
13581
  projectConfig.generateAudio = options.apiGenerateAudio;
13297
13582
  }
13583
+ if (isMiniMaxH3TwoStageModel(options.model) && !options.quiet) {
13584
+ // Two-stage renders this canvas and delivers twice it: same frames and audio.
13585
+ const delivered = minimaxH3TwoStageDeliveredSize(projectConfig.width, projectConfig.height);
13586
+ console.error(
13587
+ `MiniMax H3 FastH3 Two-Stage: delivered at ${delivered.width}x${delivered.height} ` +
13588
+ `(twice the ${projectConfig.width}x${projectConfig.height} canvas), same length and audio.`
13589
+ );
13590
+ }
13298
13591
  if (Number.isFinite(steps) && !isHappyHorseVideo && !isMiniMaxH3Model(options.model) && !isWan3Video) {
13299
13592
  // HappyHorse routes through the vendor-job path and ignores `steps`,
13300
13593
  // mirroring Seedance (whose model defaults already omit them). H3 has
@@ -13464,6 +13757,27 @@ async function main() {
13464
13757
  if (upscaleVideoResult?.error || upscaleVideoResult?.message) {
13465
13758
  throw annotateVideoUpscaleError(buildProjectResultError(upscaleVideoResult));
13466
13759
  }
13760
+ } else if (options.speech) {
13761
+ log(`Generating speech (${options.speechMode}) with ${options.model}...`);
13762
+ let referenceAudio;
13763
+ if (options.voiceReference) {
13764
+ referenceAudio = await fetchMediaBuffer(options.voiceReference);
13765
+ const seconds = await probeMediaBufferDurationSeconds(referenceAudio, options.voiceReference);
13766
+ if (!Number.isFinite(seconds)) throw new Error('Cannot read voice reference duration. Install ffprobe and supply a valid audio recording.');
13767
+ if (seconds < SPEECH_REFERENCE_SECONDS.min || seconds > SPEECH_REFERENCE_SECONDS.max) {
13768
+ throw new Error('Voice cloning requires a 3–30 second reference recording.');
13769
+ }
13770
+ }
13771
+ const result = trackProjectResult(await client.createAudioProject(withBillingMode(speechConfig(options, referenceAudio))));
13772
+ if (result?.error || result?.message) throw buildProjectResultError(result);
13773
+ } else if (options.imageTo3d || options.removeBackground) {
13774
+ log(options.imageTo3d ? 'Building a GLB with Pixal3D...' : 'Removing the background with BiRefNet...');
13775
+ const bytes = await fetchMediaBuffer(options.imageTo3d || options.removeBackground);
13776
+ const dimensions = getImageDimensionsFromBuffer(bytes);
13777
+ if (!dimensions?.width || !dimensions?.height) throw new Error('Supply an original PNG, JPEG, or WebP image.');
13778
+ options.width = dimensions.width; options.height = dimensions.height;
13779
+ const result = trackProjectResult(await client.createImageProject(withBillingMode(imageUtilityConfig(options, bytes))));
13780
+ if (result?.error || result?.message) throw buildProjectResultError(result);
13467
13781
  } else if (options.segmentImage) {
13468
13782
  log('Selecting the object with SAM 3...');
13469
13783
  const bytes = await fetchMediaBuffer(options.segmentImage);
@@ -13728,11 +14042,11 @@ async function main() {
13728
14042
  const seeds = results.map(r => r.seed ?? options.seed);
13729
14043
  const renderInfo = {
13730
14044
  timestamp: new Date().toISOString(),
13731
- type: options.music ? 'music' : (options.video || options.upscaleVideo) ? 'video' : 'image',
14045
+ type: options.speech ? 'speech' : options.imageTo3d ? 'model' : options.music ? 'music' : (options.video || options.upscaleVideo) ? 'video' : 'image',
13732
14046
  prompt: options.prompt,
13733
14047
  model: options.model,
13734
- width: options.music ? null : options.width,
13735
- height: options.music ? null : options.height,
14048
+ width: (options.music || options.speech || options.imageTo3d) ? null : options.width,
14049
+ height: (options.music || options.speech || options.imageTo3d) ? null : options.height,
13736
14050
  seed: firstResult.seed ?? options.seed,
13737
14051
  seedStrategy: options.seedStrategy || null,
13738
14052
  seeds,
@@ -13745,6 +14059,10 @@ async function main() {
13745
14059
  if (options.outputFormat) {
13746
14060
  renderInfo.outputFormat = options.outputFormat;
13747
14061
  }
14062
+ if (options.returnLastFrame) {
14063
+ renderInfo.returnLastFrame = true;
14064
+ renderInfo.lastFrameUrls = results.map(result => result.lastFrameUrl).filter(Boolean);
14065
+ }
13748
14066
  if (options.sampler) {
13749
14067
  renderInfo.sampler = options.sampler;
13750
14068
  }
@@ -13831,12 +14149,15 @@ async function main() {
13831
14149
  renderInfo.photobooth = true;
13832
14150
  renderInfo.refImage = options.refImage;
13833
14151
  }
13834
- saveLastRender(renderInfo);
13835
-
14152
+ Object.assign(renderInfo, utilityResultMetadata(options));
14153
+ const localPaths = [];
14154
+
13836
14155
  // Save to file if requested
13837
14156
  if (options.output && urls[0]) {
13838
14157
  const response = await fetchWithTimeout(urls[0]);
14158
+ if (!response.ok) throw new Error(`Result download failed: HTTP ${response.status}`);
13839
14159
  const buffer = Buffer.from(await response.arrayBuffer());
14160
+ if (options.imageTo3d) validateGlb(buffer);
13840
14161
 
13841
14162
  const dir = dirname(options.output);
13842
14163
  if (dir && dir !== '.' && !existsSync(dir)) mkdirSync(dir, { recursive: true });
@@ -13960,20 +14281,43 @@ async function main() {
13960
14281
  await buildConcatVideoFromClips(options.output, [clip1Path, clip2Path]);
13961
14282
  log(`Saved looping video to ${options.output}`);
13962
14283
  } else {
13963
- writeOutputFileSafe(options.output, buffer, (options.video || options.upscaleVideo) ? 'video' : options.music ? 'audio' : 'image');
14284
+ writeOutputFileSafe(options.output, buffer, (options.video || options.upscaleVideo) ? 'video' : (options.music || options.speech) ? 'audio' : options.imageTo3d ? 'model' : 'image');
13964
14285
  log(`Saved to ${options.output}`);
13965
14286
  }
13966
14287
  }
13967
14288
 
14289
+ if (options.output && urls[0]) localPaths.push(options.output);
14290
+ if (options.output && (options.speech || options.music)) {
14291
+ for (let index = 1; index < urls.length; index++) {
14292
+ const extension = extname(options.output);
14293
+ const path = options.output.slice(0, options.output.length - extension.length) + `-${index + 1}` + extension;
14294
+ await downloadUrlToFile(urls[index], path);
14295
+ localPaths.push(path);
14296
+ }
14297
+ }
14298
+ if (localPaths.length) renderInfo.localPaths = localPaths;
14299
+ saveLastRender(renderInfo);
14300
+ const lastFramePaths = [];
14301
+ if (options.returnLastFrame && options.output) {
14302
+ for (const [index, result] of results.entries()) {
14303
+ if (!result.lastFrameUrl) continue;
14304
+ const extension = new URL(result.lastFrameUrl).pathname.match(/\.(png|jpe?g|webp)$/i)?.[1] || 'jpg';
14305
+ const framePath = options.output.replace(/\.[^/.]+$/, '') + `-last-frame${results.length > 1 ? `-${index + 1}` : ''}.${extension}`;
14306
+ await downloadUrlToFile(result.lastFrameUrl, framePath);
14307
+ lastFramePaths.push(framePath);
14308
+ log(`Saved last frame to ${framePath}`);
14309
+ }
14310
+ }
14311
+
13968
14312
  // Output result
13969
14313
  if (options.json) {
13970
14314
  const output = {
13971
14315
  success: true,
13972
- type: options.music ? 'music' : (options.video || options.upscaleVideo) ? 'video' : 'image',
14316
+ type: options.speech ? 'speech' : options.imageTo3d ? 'model' : options.music ? 'music' : (options.video || options.upscaleVideo) ? 'video' : 'image',
13973
14317
  prompt: options.prompt,
13974
14318
  model: options.model,
13975
- width: options.music ? null : options.width,
13976
- height: options.music ? null : options.height,
14319
+ width: (options.music || options.speech || options.imageTo3d) ? null : options.width,
14320
+ height: (options.music || options.speech || options.imageTo3d) ? null : options.height,
13977
14321
  seed: firstResult.seed ?? options.seed,
13978
14322
  seedStrategy: options.seedStrategy || null,
13979
14323
  seeds,
@@ -13981,9 +14325,15 @@ async function main() {
13981
14325
  localPath: options.output || null,
13982
14326
  tokenType: options.tokenType || 'spark'
13983
14327
  };
14328
+ Object.assign(output, utilityResultMetadata(options));
14329
+ if (localPaths.length) output.localPaths = localPaths;
13984
14330
  if (options.outputFormat) {
13985
14331
  output.outputFormat = options.outputFormat;
13986
14332
  }
14333
+ if (options.returnLastFrame) {
14334
+ output.lastFrameUrls = results.map(result => result.lastFrameUrl).filter(Boolean);
14335
+ if (lastFramePaths.length) output.lastFramePaths = lastFramePaths;
14336
+ }
13987
14337
  if (options.sampler) {
13988
14338
  output.sampler = options.sampler;
13989
14339
  }
@@ -14026,6 +14376,11 @@ async function main() {
14026
14376
  output.duration = options.frames ? options.frames / options.fps : options.duration;
14027
14377
  if (options.frames) output.frames = options.frames;
14028
14378
  if (options.targetResolution) output.targetResolution = options.targetResolution;
14379
+ if (isMiniMaxH3TwoStageModel(options.model)) {
14380
+ const delivered = minimaxH3TwoStageDeliveredSize(options.width, options.height);
14381
+ output.deliveredWidth = delivered.width;
14382
+ output.deliveredHeight = delivered.height;
14383
+ }
14029
14384
  output.strictSize = options.strictSize || false;
14030
14385
  if (options.autoResizeVideoAssets !== null) {
14031
14386
  output.autoResizeVideoAssets = options.autoResizeVideoAssets;
@@ -14089,6 +14444,9 @@ async function main() {
14089
14444
  console.log(JSON.stringify(output));
14090
14445
  } else {
14091
14446
  urls.forEach(url => console.log(url));
14447
+ if (options.returnLastFrame) {
14448
+ results.forEach(result => { if (result.lastFrameUrl) console.log(`Last frame: ${result.lastFrameUrl}`); });
14449
+ }
14092
14450
  }
14093
14451
  } else {
14094
14452
  throw new Error('No output generated - may have been filtered');