@sogni-ai/sogni-creative-agent-skill 3.33.1 → 3.35.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
@@ -95,9 +95,9 @@ import {
95
95
  import {
96
96
  HAPPYHORSE_REFERENCE_LIMITS,
97
97
  HappyHorseReferenceLimitError,
98
- SEEDANCE_REFERENCE_LIMITS,
99
98
  SeedanceReferenceLimitError,
100
99
  getHappyHorseReferenceLimits,
100
+ getSeedanceReferenceLimits,
101
101
  happyhorseTerminalGenerationFailurePayloadFromError,
102
102
  happyhorseTerminalPolicyPayloadFromError,
103
103
  seedanceTerminalGenerationFailurePayloadFromError,
@@ -1571,16 +1571,13 @@ const VIDEO_REF_PRERESIZE_MAX_ASPECT_DRIFT = 0.02;
1571
1571
  const MINIMAX_H3_MAX_VIDEO_PIXELS = 1_032_192;
1572
1572
 
1573
1573
  function isWanVideoModelId(modelId) {
1574
- return typeof modelId === 'string' && modelId.startsWith('wan_');
1574
+ return getSharedModelDefaults(modelId)?.family === 'wan22';
1575
1575
  }
1576
1576
 
1577
1577
  function isWanAnimateVideoModelId(modelId) {
1578
- return typeof modelId === 'string' && (
1579
- modelId.includes('_animate-move') ||
1580
- modelId.includes('_animate-replace') ||
1581
- modelId.includes('_animate_move') ||
1582
- modelId.includes('_animate_replace')
1583
- );
1578
+ if (!isWanVideoModelId(modelId)) return false;
1579
+ const workflow = inferVideoWorkflowFromModel(modelId);
1580
+ return workflow === 'animate-move' || workflow === 'animate-replace';
1584
1581
  }
1585
1582
 
1586
1583
  function isGptImage2ModelSelection(modelId) {
@@ -1588,6 +1585,67 @@ function isGptImage2ModelSelection(modelId) {
1588
1585
  return ['gpt-image-2', 'gptimage2', 'gpt-image', 'gpt_image_2'].includes(normalized);
1589
1586
  }
1590
1587
 
1588
+ const SEEDANCE_TASK_TYPES = new Set(['reference', 'edit', 'extend']);
1589
+ const QWEN_IMAGE_EDIT_2511_MODEL_IDS = new Set([
1590
+ 'qwen_image_edit_2511_fp8',
1591
+ 'qwen_image_edit_2511_fp8_lightning',
1592
+ ]);
1593
+ const LIGHTNING_IMAGE_MODEL_IDS = new Set([
1594
+ 'qwen_image_edit_2511_fp8_lightning',
1595
+ 'qwen_image_2512_fp8_lightning',
1596
+ ]);
1597
+
1598
+ function isQwenImageEdit2511ModelSelection(modelId) {
1599
+ return QWEN_IMAGE_EDIT_2511_MODEL_IDS.has(String(modelId || '').trim().toLowerCase());
1600
+ }
1601
+
1602
+ function isLightningImageModelSelection(modelId) {
1603
+ return LIGHTNING_IMAGE_MODEL_IDS.has(String(modelId || '').trim().toLowerCase());
1604
+ }
1605
+
1606
+ const SEEDANCE_25_MODEL_SELECTIONS = new Set([
1607
+ 'seedance-2-5',
1608
+ 'seedance2-5',
1609
+ 'seedance2-5-t2v',
1610
+ 'seedance2-5-ia2v',
1611
+ 'seedance2-5-v2v',
1612
+ ]);
1613
+
1614
+ const WAN3_MODEL_ID = 'wan3.0-video';
1615
+ const WAN3_MODEL_SELECTIONS = new Set([
1616
+ WAN3_MODEL_ID,
1617
+ 'wan3',
1618
+ 'wan3.0',
1619
+ 'wan3-video',
1620
+ 'wan-3',
1621
+ 'wan-3.0',
1622
+ ]);
1623
+ const WAN3_REFERENCE_LIMITS = Object.freeze({
1624
+ images: 10,
1625
+ videos: 5,
1626
+ audios: 5,
1627
+ files: 1,
1628
+ links: 1,
1629
+ });
1630
+ const WAN3_SUPPORTED_WORKFLOWS = new Set(['t2v', 'i2v', 'r2v', 'a2v', 'ia2v', 'v2v']);
1631
+ const WAN3_SUPPORTED_RESOLUTIONS = new Set([480, 720, 1080]);
1632
+ const WAN3_SUPPORTED_RATIOS = new Set(['adaptive', '16:9', '4:3', '1:1', '3:4', '9:16']);
1633
+ const WAN3_TASK_TYPES = new Set(['create', 'edit', 'extend']);
1634
+ const WAN3_MAX_SEED = 0x7fffffff;
1635
+
1636
+ function isWan3ModelSelectionLocal(modelId) {
1637
+ return WAN3_MODEL_SELECTIONS.has(String(modelId || '').trim().toLowerCase().replace(/_/g, '-'));
1638
+ }
1639
+
1640
+ function isWan3ModelLocal(modelId) {
1641
+ return String(modelId || '').trim().toLowerCase() === WAN3_MODEL_ID;
1642
+ }
1643
+
1644
+ function isSeedance25ModelSelectionLocal(modelId) {
1645
+ const normalized = String(modelId || '').trim().toLowerCase().replace(/_/g, '-');
1646
+ return SEEDANCE_25_MODEL_SELECTIONS.has(normalized);
1647
+ }
1648
+
1591
1649
  function normalizeMusicModelId(value) {
1592
1650
  const raw = String(value || '').trim();
1593
1651
  if (!raw) return null;
@@ -1607,7 +1665,10 @@ function normalizeMusicTimeSignature(value) {
1607
1665
  }
1608
1666
 
1609
1667
  function requiresSparkOnlyToken(modelId) {
1610
- return isGptImage2ModelSelection(modelId) || isSeedanceModel(modelId) || isHappyHorseModel(modelId);
1668
+ return isGptImage2ModelSelection(modelId)
1669
+ || isSeedanceModel(modelId)
1670
+ || isHappyHorseModel(modelId)
1671
+ || isWan3ModelSelectionLocal(modelId);
1611
1672
  }
1612
1673
 
1613
1674
  // Attach the user's explicit --billing-mode to a project config. Omitted by
@@ -1688,6 +1749,8 @@ function getMaxContextImages(modelId) {
1688
1749
 
1689
1750
  function videoDurationLimitsLikeWrapper(modelId) {
1690
1751
  if (isMiniMaxH3Model(modelId)) return { ...MINIMAX_H3_DURATION_LIMITS };
1752
+ if (isWan3ModelSelectionLocal(modelId)) return { min: 2, max: 30 };
1753
+ if (isSeedance25ModelSelectionLocal(modelId)) return { min: 4, max: 30 };
1691
1754
  if (isSeedanceModel(modelId)) return { min: 4, max: 15 };
1692
1755
  if (isHappyHorseModel(modelId)) return { min: 3, max: 15 };
1693
1756
  if (isLtxFamilyModel(modelId) || isWanAnimateVideoModelId(modelId)) return { min: 1, max: 20 };
@@ -1731,6 +1794,15 @@ function videoModelDimensionDefaultsLikeWrapper(modelId) {
1731
1794
  if (isHappyHorseModel(modelId) || isHappyHorseModelSelectionLocal(modelId)) {
1732
1795
  return { defaultWidth: 1920, defaultHeight: 1080, maxDimension: 1920, dimensionMultiple: 1 };
1733
1796
  }
1797
+ if (isWan3ModelSelectionLocal(modelId)) {
1798
+ return {
1799
+ defaultWidth: 1920,
1800
+ defaultHeight: 1080,
1801
+ minDimension: 480,
1802
+ maxDimension: 1920,
1803
+ dimensionMultiple: 1,
1804
+ };
1805
+ }
1734
1806
  return null;
1735
1807
  }
1736
1808
 
@@ -2111,8 +2183,14 @@ const DR34ML4Y_SUPPORTED_MODEL_IDS = new Set([
2111
2183
  LTX23_10EROS_MODEL_ID
2112
2184
  ]);
2113
2185
 
2114
- function resolveSkillVideoModelAlias(modelId, workflow = null, hasEndFrame = false) {
2186
+ function resolveSkillVideoModelAlias(
2187
+ modelId,
2188
+ workflow = null,
2189
+ hasStartFrame = false,
2190
+ hasEndFrame = false,
2191
+ ) {
2115
2192
  const normalized = String(modelId || '').trim().toLowerCase();
2193
+ if (isWan3ModelSelectionLocal(normalized)) return WAN3_MODEL_ID;
2116
2194
  if (normalized === 'ltx25' || normalized === 'ltx25-t2v') {
2117
2195
  const mode = ['i2v', 'a2v', 'ia2v', 'v2v'].includes(workflow) ? workflow : 't2v';
2118
2196
  return LTX25_DISTILLED_WORKFLOW_MODELS[mode];
@@ -2124,7 +2202,9 @@ function resolveSkillVideoModelAlias(modelId, workflow = null, hasEndFrame = fal
2124
2202
  if (normalized === 'minimax-h3' && workflow) {
2125
2203
  if (workflow === 'r2v') return MINIMAX_H3_R2V_MODEL_ID;
2126
2204
  if (workflow === 'i2v') {
2127
- return hasEndFrame ? 'minimax-h3-fl2va-fp8_flf2v' : 'minimax-h3-fl2va-fp8_i2v';
2205
+ return hasStartFrame && hasEndFrame
2206
+ ? 'minimax-h3-fl2va-fp8_flf2v'
2207
+ : 'minimax-h3-fl2va-fp8_i2v';
2128
2208
  }
2129
2209
  return 'minimax-h3-fl2va-fp8_t2v';
2130
2210
  }
@@ -2140,7 +2220,7 @@ function resolveSkillVideoModelAlias(modelId, workflow = null, hasEndFrame = fal
2140
2220
  return MINIMAX_H3_R2V_TURBO_MODEL_ID;
2141
2221
  }
2142
2222
  if (workflow === 'i2v') {
2143
- return hasEndFrame
2223
+ return hasStartFrame && hasEndFrame
2144
2224
  ? 'minimax-h3-fl2va-fp8_flf2v_turbo'
2145
2225
  : 'minimax-h3-fl2va-fp8_i2v_turbo';
2146
2226
  }
@@ -2263,19 +2343,19 @@ function parseOutpaintAspectRatio(value) {
2263
2343
  }
2264
2344
 
2265
2345
  function isLtxV2VModelId(modelId) {
2266
- return !!modelId && (modelId.includes('ltx23') || modelId.includes('ltx25')) && /_v2v(_|$)/.test(modelId);
2346
+ return isLtxFamilyModel(modelId) && inferVideoWorkflowFromModel(modelId) === 'v2v';
2267
2347
  }
2268
2348
 
2269
2349
  function isLtx23ModelId(modelId) {
2270
- return String(modelId || '').trim().toLowerCase().startsWith('ltx23-');
2350
+ return getSharedModelDefaults(modelId)?.family === 'ltx23';
2271
2351
  }
2272
2352
 
2273
2353
  function isLtx25ModelId(modelId) {
2274
- return String(modelId || '').trim().toLowerCase().startsWith('ltx25-');
2354
+ return getSharedModelDefaults(modelId)?.family === 'ltx25';
2275
2355
  }
2276
2356
 
2277
2357
  function isLtxFamilyModel(modelId) {
2278
- return isLtx2Model(modelId) || isLtx25ModelId(modelId);
2358
+ return isLtx2Model(modelId);
2279
2359
  }
2280
2360
 
2281
2361
  function ltx25WorkflowFromModelSelection(modelId) {
@@ -2482,6 +2562,13 @@ const options = {
2482
2562
  musicShift: null,
2483
2563
  video: false,
2484
2564
  videoWorkflow: null,
2565
+ seedanceTaskType: null,
2566
+ wan3TaskType: null,
2567
+ wan3Ratio: 'adaptive',
2568
+ wan3SmartDuration: false,
2569
+ wan3ReferenceFileUrl: null,
2570
+ wan3ReferenceLinkUrl: null,
2571
+ wan3Watermark: false,
2485
2572
  fps: 16,
2486
2573
  duration: 5,
2487
2574
  frames: null,
@@ -2661,6 +2748,13 @@ const cliSet = {
2661
2748
  musicShift: false,
2662
2749
  video: false,
2663
2750
  workflow: false,
2751
+ seedanceTaskType: false,
2752
+ wan3TaskType: false,
2753
+ wan3Ratio: false,
2754
+ wan3SmartDuration: false,
2755
+ wan3ReferenceFileUrl: false,
2756
+ wan3ReferenceLinkUrl: false,
2757
+ wan3Watermark: false,
2664
2758
  fps: false,
2665
2759
  duration: false,
2666
2760
  frames: false,
@@ -2944,6 +3038,41 @@ for (let i = 0; i < args.length; i++) {
2944
3038
  i++;
2945
3039
  options.videoWorkflow = raw;
2946
3040
  cliSet.workflow = true;
3041
+ } else if (arg === '--seedance-task-type') {
3042
+ const raw = requireFlagValue(args, i, arg);
3043
+ i++;
3044
+ options.seedanceTaskType = raw.trim().toLowerCase();
3045
+ cliSet.seedanceTaskType = true;
3046
+ } else if (arg === '--wan3-task-type') {
3047
+ const raw = requireFlagValue(args, i, arg);
3048
+ i++;
3049
+ options.wan3TaskType = raw.trim().toLowerCase();
3050
+ cliSet.wan3TaskType = true;
3051
+ } else if (arg === '--wan3-ratio' || arg === '--video-ratio') {
3052
+ const raw = requireFlagValue(args, i, arg);
3053
+ i++;
3054
+ options.wan3Ratio = raw.trim().toLowerCase();
3055
+ cliSet.wan3Ratio = true;
3056
+ } else if (arg === '--smart-duration') {
3057
+ options.wan3SmartDuration = true;
3058
+ cliSet.wan3SmartDuration = true;
3059
+ } else if (arg === '--no-smart-duration') {
3060
+ options.wan3SmartDuration = false;
3061
+ cliSet.wan3SmartDuration = true;
3062
+ } else if (arg === '--reference-file-url' || arg === '--ref-file-url') {
3063
+ options.wan3ReferenceFileUrl = requireFlagValue(args, i, arg).trim();
3064
+ i++;
3065
+ cliSet.wan3ReferenceFileUrl = true;
3066
+ } else if (arg === '--reference-link-url' || arg === '--ref-link-url') {
3067
+ options.wan3ReferenceLinkUrl = requireFlagValue(args, i, arg).trim();
3068
+ i++;
3069
+ cliSet.wan3ReferenceLinkUrl = true;
3070
+ } else if (arg === '--watermark') {
3071
+ options.wan3Watermark = true;
3072
+ cliSet.wan3Watermark = true;
3073
+ } else if (arg === '--no-watermark') {
3074
+ options.wan3Watermark = false;
3075
+ cliSet.wan3Watermark = true;
2947
3076
  } else if (arg === '--fps') {
2948
3077
  const raw = requireFlagValue(args, i, arg);
2949
3078
  i++;
@@ -3696,17 +3825,24 @@ Music Options:
3696
3825
  Video Options:
3697
3826
  --video, -v Generate video instead of image
3698
3827
  --workflow <type> Video workflow: t2v|i2v|r2v|s2v|ia2v|a2v|v2v|animate-move|animate-replace
3828
+ --seedance-task-type <type> Seedance 2.5 loose-reference operation: reference|edit|extend
3829
+ --wan3-task-type <type> Wan 3 operation: create|edit|extend (v2v defaults to edit)
3830
+ --wan3-ratio <ratio> Wan 3 ratio: adaptive|16:9|4:3|1:1|3:4|9:16
3831
+ --smart-duration, --no-smart-duration Let Wan 3 choose 2-30s, or use --duration
3832
+ --reference-file-url <url> Wan 3 public HTTPS document context (one, up to 100 MB; supported paged formats up to 50 pages)
3833
+ --reference-link-url <url> Wan 3 public HTTPS webpage context (one; mutually exclusive with file)
3834
+ --watermark, --no-watermark Toggle Wan 3's provider watermark (default: off)
3699
3835
  --fps <num> Frames per second (model default unless set)
3700
- --duration <sec> Duration in seconds (default: 5)
3836
+ --duration <sec> Duration in seconds (default: 5); Seedance 2.5 edit requires @Video1's source duration
3701
3837
  --frames <num> Override total frames (optional)
3702
- --target-resolution <px> Short-side target that preserves aspect ratio
3838
+ --target-resolution <px> Short-side target that preserves aspect ratio (Seedance 2.5: 480 or 720)
3703
3839
  --auto-resize-assets Auto-resize video reference assets (default)
3704
3840
  --no-auto-resize-assets Disable auto-resize for video assets
3705
3841
  --estimate-video-cost Estimate video cost and exit
3706
3842
  --ref <path|url> Reference image for video (start frame; Picture 1 on H3 r2v)
3707
3843
  --ref-end <path|url> End frame for interpolation/morphing; with --ref it
3708
3844
  defaults to the LTX-2.5 i2v first/last-frame workflow
3709
- (last frame on Seedance)
3845
+ (last frame on Seedance; L2VA endpoint on MiniMax H3 i2v)
3710
3846
  --ref-audio <path|url> Audio reference. Repeatable on Seedance and H3 r2v (up to 3 total);
3711
3847
  first entry is the primary, extras must be HTTPS URLs in CLI
3712
3848
  direct-gen for Seedance; H3 r2v uploads local/remote files.
@@ -3718,18 +3854,21 @@ Video Options:
3718
3854
  --ref-video <path|url> Video reference. Repeatable on Seedance and H3 r2v (up to 3 total);
3719
3855
  first entry is the primary, extras must be HTTPS URLs in CLI
3720
3856
  direct-gen for Seedance. On LTX/WAN: single primary for animate/v2v.
3721
- --generate-audio, --no-generate-audio Keep or strip MiniMax H3's generated audio track
3857
+ --generate-audio, --no-generate-audio Keep/strip H3 audio; enable/disable Wan 3 native audio
3722
3858
 
3723
3859
  Seedance Reference Modes (mutually exclusive on seedance2 / seedance2-mini / seedance2-fast / seedance2-5):
3724
3860
  - DEDICATED FRAME MODE: --ref (first frame) and/or --ref-end (last frame).
3725
- Best when you want canonical first/last frame anchoring; max 2 images.
3861
+ Best when you want canonical first/last frame anchoring; do not attach loose
3862
+ image, video, or audio references to the same request.
3726
3863
  - LOOSE REFERENCE MODE: -c/--context image refs plus optional --ref-audio /
3727
3864
  --ref-video extras. Anchor frame intent in the prompt with @Image1, @Image2,
3728
3865
  @Video1, @Audio1 etc. (e.g. "Use @Image1 as the opening shot reference").
3729
3866
  Up to 9 image / 3 video / 3 audio / 12 total references per video request
3730
3867
  on the 2.0 family; seedance2-5 raises the caps to 30 image / 10 video /
3731
- 10 audio / 30 total.
3732
- Combining --ref/--ref-end with -c/--context on Seedance is rejected client-side.
3868
+ 10 audio / 50 total.
3869
+ - Typed IA2V exception: with --workflow ia2v, --ref is a loose @Image
3870
+ reference beside --ref-audio, not a first_frame anchor. --ref-end is invalid.
3871
+ Combining native frame anchors with any loose reference is rejected client-side.
3733
3872
  All three modalities pull caps from the canonical
3734
3873
  @sogni-ai/sogni-protocol seedance-reference-limits catalog.
3735
3874
  --video-start <sec> Start offset into --ref-video for segmented V2V/animate
@@ -3787,7 +3926,7 @@ Hosted API Modes:
3787
3926
  --video-prompt <text> Motion prompt for the generated-keyframe durable workflow
3788
3927
  --negative-prompt <text> Negative prompt for generated workflow steps
3789
3928
  --generate-audio, --no-generate-audio Toggle audio generation for generated video steps
3790
- --expand-prompt, --no-expand-prompt Toggle prompt expansion for generated video steps
3929
+ --expand-prompt, --no-expand-prompt Toggle prompt expansion for Wan 3 direct video and generated video steps
3791
3930
  --watch-workflow Stream workflow events after starting
3792
3931
  --list-workflows List recent durable creative workflows
3793
3932
  --get-workflow <id> Fetch a workflow snapshot
@@ -3928,14 +4067,14 @@ image-only R2V need 32GB-class workers; video-conditioned R2V needs above 40GB.
3928
4067
  Prompts use MiniMax's exact ordered-field contracts and [Shot N] notation; see
3929
4068
  references/video-prompting.md "MiniMax H3 Prompting". No negative prompt field:
3930
4069
  state negatives in the structured prompt.):
3931
- minimax-h3 Text-to-video (also accepts minimax-h3-t2v); --ref/--ref-end pick i2v/flf2v
3932
- minimax-h3-i2v Image-to-video from a single first-frame image (--ref)
4070
+ minimax-h3 Text-to-video; --ref selects I2VA, --ref-end L2VA, and both FL2VA
4071
+ minimax-h3-i2v I2VA from --ref, or L2VA from a closing frame supplied as --ref-end
3933
4072
  minimax-h3-flf2v First-frame -> last-frame transition (--ref plus --ref-end)
3934
4073
  minimax-h3-r2v Multi-reference video: --ref/-c images, repeatable --ref-video/--ref-audio
3935
4074
  (9 images / 3 videos / 3 audios / 12 files total; requires an image or video)
3936
- minimax-h3-turbo 4-step Turbo; --ref/--ref-end select i2v/flf2v
4075
+ minimax-h3-turbo 4-step Turbo; --ref selects I2VA, --ref-end L2VA, and both FL2VA
3937
4076
  minimax-h3-t2v-turbo 4-step Turbo text-to-video
3938
- minimax-h3-i2v-turbo 4-step Turbo image-to-video (--ref)
4077
+ minimax-h3-i2v-turbo 4-step Turbo I2VA (--ref) or L2VA (--ref-end)
3939
4078
  minimax-h3-flf2v-turbo 4-step Turbo first-frame -> last-frame (--ref plus --ref-end)
3940
4079
  minimax-h3-r2v-turbo 4-step Ref2VA Turbo with loose image/video/audio references
3941
4080
  (upstream default: 960x544, Euler/simple)
@@ -4272,7 +4411,7 @@ if (options.multiAngle) {
4272
4411
  options.elevation = normalizeMultiAngleValue(options.elevation, MULTI_ANGLE_ELEVATION_ALIASES, elevationKeys, 'elevation');
4273
4412
  options.distance = normalizeMultiAngleValue(options.distance, MULTI_ANGLE_DISTANCE_ALIASES, distanceKeys, 'distance');
4274
4413
 
4275
- if (options.model && !options.model.includes('qwen_image_edit_2511')) {
4414
+ if (options.model && !isQwenImageEdit2511ModelSelection(options.model)) {
4276
4415
  fatalCliError('--multi-angle requires a Qwen Image Edit 2511 model.', {
4277
4416
  code: 'INVALID_ARGUMENT',
4278
4417
  details: { model: options.model }
@@ -4305,7 +4444,7 @@ if (options.multiAngle) {
4305
4444
  options.loraStrengths = [];
4306
4445
  }
4307
4446
  if (!cliSet.guidance && (options.guidance === null || options.guidance === undefined)) {
4308
- options.guidance = options.model.includes('lightning') ? 1.0 : 4.0;
4447
+ options.guidance = isLightningImageModelSelection(options.model) ? 1.0 : 4.0;
4309
4448
  }
4310
4449
  if (options.angleStrength === null || options.angleStrength === undefined) {
4311
4450
  options.angleStrength = 0.9;
@@ -4463,13 +4602,17 @@ if (options.video) {
4463
4602
  options.videoWorkflow = normalized;
4464
4603
  } else if (
4465
4604
  options.videoWorkflow === 'r2v'
4466
- && (isHappyHorseModelSelectionLocal(options.model) || isMiniMaxH3ModelSelectionLocal(options.model))
4605
+ && (
4606
+ isHappyHorseModelSelectionLocal(options.model)
4607
+ || isMiniMaxH3ModelSelectionLocal(options.model)
4608
+ || isWan3ModelSelectionLocal(options.model)
4609
+ )
4467
4610
  ) {
4468
- // HappyHorse and MiniMax H3 add reference-to-video (r2v) modes that the
4469
- // shared SkillVideoWorkflow enum does not carry yet.
4611
+ // These unified/reference models accept loose reference-to-video input
4612
+ // even when the pinned shared SkillVideoWorkflow enum predates r2v.
4470
4613
  options.videoWorkflow = 'r2v';
4471
4614
  } else {
4472
- fatalCliError(`Unknown workflow "${options.videoWorkflow}". Use t2v|i2v|s2v|ia2v|a2v|v2v|animate-move|animate-replace (r2v on HappyHorse or MiniMax H3).`, {
4615
+ fatalCliError(`Unknown workflow "${options.videoWorkflow}". Use t2v|i2v|s2v|ia2v|a2v|v2v|animate-move|animate-replace (r2v on HappyHorse, MiniMax H3, or Wan 3).`, {
4473
4616
  code: 'INVALID_ARGUMENT',
4474
4617
  details: { workflow: options.videoWorkflow }
4475
4618
  });
@@ -4490,15 +4633,42 @@ if (options.video) {
4490
4633
  if (!options.videoWorkflow && isSeedanceModelSelection(options.model)) {
4491
4634
  if (options.refVideo) {
4492
4635
  options.videoWorkflow = 'v2v';
4493
- } else if (options.refAudio && (options.refImage || options.refImageEnd)) {
4636
+ } else if (options.refAudio && options.refImage) {
4494
4637
  options.videoWorkflow = 'ia2v';
4495
4638
  } else {
4496
4639
  options.videoWorkflow = 't2v';
4497
4640
  }
4498
4641
  }
4499
4642
 
4500
- // MiniMax H3 has four concrete modes. The FL2VA checkpoint covers t2v, i2v,
4501
- // and first/last-frame (represented by the CLI's i2v workflow); Ref2VA is a
4643
+ // Wan 3 is one unified Alibaba model. The selected media shape chooses the
4644
+ // operation; unlike HappyHorse, no workflow suffix is appended to the model.
4645
+ // In audio/video workflows --ref is a loose reference image. In i2v it is a
4646
+ // dedicated first-frame anchor and may be paired with --ref-end.
4647
+ if (isWan3ModelSelectionLocal(options.model)) {
4648
+ if (!options.videoWorkflow) {
4649
+ const hasLooseImages = Array.isArray(options.contextImages) && options.contextImages.length > 0;
4650
+ const hasAudio = Boolean(options.refAudio || options.refAudios.length > 0);
4651
+ const hasVideo = Boolean(options.refVideo || options.refVideos.length > 0);
4652
+ if (hasVideo) {
4653
+ options.videoWorkflow = 'v2v';
4654
+ } else if (hasAudio && (options.refImage || hasLooseImages)) {
4655
+ options.videoWorkflow = 'ia2v';
4656
+ } else if (hasAudio) {
4657
+ options.videoWorkflow = 'a2v';
4658
+ } else if (hasLooseImages) {
4659
+ options.videoWorkflow = 'r2v';
4660
+ } else if (options.refImage || options.refImageEnd) {
4661
+ options.videoWorkflow = 'i2v';
4662
+ } else {
4663
+ options.videoWorkflow = 't2v';
4664
+ }
4665
+ }
4666
+ options.model = WAN3_MODEL_ID;
4667
+ }
4668
+
4669
+ // MiniMax H3 has four concrete worker selectors and five prompt shapes. The
4670
+ // FL2VA checkpoint covers t2v, first-frame i2v, last-frame-only l2v, and
4671
+ // first/last-frame (represented by the CLI's i2v workflow); Ref2VA is a
4502
4672
  // separate r2v checkpoint and is never inferred from loose references alone.
4503
4673
  // Selecting minimax-h3-r2v or explicitly passing --workflow r2v is required.
4504
4674
  if (isMiniMaxH3ModelSelectionLocal(options.model)) {
@@ -4518,6 +4688,7 @@ if (options.video) {
4518
4688
  options.model = resolveSkillVideoModelAlias(
4519
4689
  options.model,
4520
4690
  options.videoWorkflow,
4691
+ Boolean(options.refImage),
4521
4692
  Boolean(options.refImageEnd)
4522
4693
  );
4523
4694
  }
@@ -4562,7 +4733,12 @@ if (options.video) {
4562
4733
  }
4563
4734
  if (options.model) {
4564
4735
  options.model = resolveVideoModelAlias(
4565
- resolveSkillVideoModelAlias(options.model, options.videoWorkflow, Boolean(options.refImageEnd)),
4736
+ resolveSkillVideoModelAlias(
4737
+ options.model,
4738
+ options.videoWorkflow,
4739
+ Boolean(options.refImage),
4740
+ Boolean(options.refImageEnd),
4741
+ ),
4566
4742
  options.videoWorkflow
4567
4743
  );
4568
4744
  }
@@ -4884,7 +5060,16 @@ if (!loraCatalogUtilityAction && (options.loraCatalogModel || options.loraCatalo
4884
5060
  if (typeof options.prompt === 'string' && options.prompt.trim() === '') {
4885
5061
  options.prompt = '';
4886
5062
  }
4887
- if (!options.prompt && !options.upscaleImage && !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.verifyVideo && !options.concatVideos && !options.sourceReelDir && !options.remixAudio && !options.listMedia && !options.memoryAction && !options.personalityAction && !personaUtilityAction) {
5063
+ const wan3HasMediaInput = isWan3ModelLocal(options.model) && Boolean(
5064
+ options.refImage
5065
+ || options.refImageEnd
5066
+ || options.refAudio
5067
+ || options.refVideo
5068
+ || options.contextImages.length > 0
5069
+ || options.refAudios.length > 0
5070
+ || options.refVideos.length > 0
5071
+ );
5072
+ if (!options.prompt && !wan3HasMediaInput && !options.upscaleImage && !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.verifyVideo && !options.concatVideos && !options.sourceReelDir && !options.remixAudio && !options.listMedia && !options.memoryAction && !options.personalityAction && !personaUtilityAction) {
4888
5073
  fatalCliError('No prompt provided. Use --help for usage.', { code: 'INVALID_ARGUMENT' });
4889
5074
  }
4890
5075
 
@@ -4927,8 +5112,8 @@ if (!options.upscaleImage && (cliSet.upscaleScale || cliSet.upscaleTargetLongest
4927
5112
  });
4928
5113
  }
4929
5114
 
4930
- if (!options.video && !options.apiChat && !options.apiWorkflowAction && (options.refAudio || options.refVideo || options.refMask || options.referenceAudioIdentity || options.voicePersonaName || options.videoWorkflow || options.frames || options.targetResolution || options.audioStart !== null || options.audioDuration !== null || options.videoStart !== null || options.outpaintPosition || options.outpaintAspectRatio)) {
4931
- fatalCliError('Video-only options (--workflow/--frames/--target-resolution/--ref-audio/--ref-video/--mask/--outpaint-position/--reference-audio-identity/--voice-persona) require --video.', {
5115
+ if (!options.video && !options.apiChat && !options.apiWorkflowAction && (options.refAudio || options.refVideo || options.refMask || options.referenceAudioIdentity || options.voicePersonaName || options.videoWorkflow || options.seedanceTaskType || options.wan3TaskType || options.wan3SmartDuration || options.wan3ReferenceFileUrl || options.wan3ReferenceLinkUrl || options.wan3Watermark || cliSet.wan3Ratio || options.frames || options.targetResolution || options.audioStart !== null || options.audioDuration !== null || options.videoStart !== null || options.outpaintPosition || options.outpaintAspectRatio)) {
5116
+ fatalCliError('Video-only options (--workflow/--seedance-task-type/--wan3-task-type/--wan3-ratio/--smart-duration/--reference-file-url/--reference-link-url/--watermark/--frames/--target-resolution/--ref-audio/--ref-video/--mask/--outpaint-position/--reference-audio-identity/--voice-persona) require --video.', {
4932
5117
  code: 'INVALID_ARGUMENT'
4933
5118
  });
4934
5119
  }
@@ -4947,11 +5132,138 @@ if (options.photobooth) {
4947
5132
 
4948
5133
  if (options.video) {
4949
5134
  const isSeedanceVideo = isSeedanceModel(options.model);
5135
+ const isSeedance25Video = isSeedance25ModelSelectionLocal(options.model);
4950
5136
  const isHappyHorseVideo = isHappyHorseModel(options.model);
5137
+ const isWan3Video = isWan3ModelLocal(options.model);
4951
5138
  const isMiniMaxH3Video = isMiniMaxH3Model(options.model);
4952
5139
  const isMiniMaxH3R2v = isMiniMaxH3R2vModel(options.model);
4953
- if (isSeedanceVideo && !['t2v', 'ia2v', 'v2v'].includes(options.videoWorkflow)) {
4954
- fatalCliError('Seedance models support only t2v, ia2v, or v2v workflows.', {
5140
+ if (options.seedanceTaskType && !SEEDANCE_TASK_TYPES.has(options.seedanceTaskType)) {
5141
+ fatalCliError('--seedance-task-type must be one of: reference, edit, extend.', {
5142
+ code: 'INVALID_ARGUMENT',
5143
+ details: { seedanceTaskType: options.seedanceTaskType }
5144
+ });
5145
+ }
5146
+ if (options.seedanceTaskType && !isSeedance25Video) {
5147
+ fatalCliError('--seedance-task-type is supported only by Seedance 2.5.', {
5148
+ code: 'INVALID_ARGUMENT',
5149
+ details: { model: options.model, seedanceTaskType: options.seedanceTaskType }
5150
+ });
5151
+ }
5152
+ if (options.wan3TaskType && !WAN3_TASK_TYPES.has(options.wan3TaskType)) {
5153
+ fatalCliError('--wan3-task-type must be one of: create, edit, extend.', {
5154
+ code: 'INVALID_ARGUMENT',
5155
+ details: { wan3TaskType: options.wan3TaskType }
5156
+ });
5157
+ }
5158
+ if ((options.wan3TaskType || cliSet.wan3Ratio || options.wan3SmartDuration || options.wan3ReferenceFileUrl || options.wan3ReferenceLinkUrl || options.wan3Watermark) && !isWan3Video) {
5159
+ fatalCliError('Wan 3 controls are supported only by wan3 / wan3.0-video.', {
5160
+ code: 'INVALID_ARGUMENT',
5161
+ details: { model: options.model }
5162
+ });
5163
+ }
5164
+ if (isWan3Video && !WAN3_SUPPORTED_RATIOS.has(options.wan3Ratio)) {
5165
+ fatalCliError('--wan3-ratio must be one of: adaptive, 16:9, 4:3, 1:1, 3:4, 9:16.', {
5166
+ code: 'INVALID_ARGUMENT',
5167
+ details: { ratio: options.wan3Ratio }
5168
+ });
5169
+ }
5170
+ if (isWan3Video && options.wan3SmartDuration && (cliSet.duration || cliSet.frames)) {
5171
+ fatalCliError('--smart-duration cannot be combined with --duration or --frames.', {
5172
+ code: 'INVALID_ARGUMENT'
5173
+ });
5174
+ }
5175
+ if (isSeedance25Video && !options.seedanceTaskType) {
5176
+ if (options.videoWorkflow === 'v2v') {
5177
+ options.seedanceTaskType = 'edit';
5178
+ } else if (
5179
+ options.videoWorkflow === 'ia2v' ||
5180
+ options.contextImages.length > 0 ||
5181
+ options.refAudio ||
5182
+ options.refAudios.length > 0 ||
5183
+ options.refVideo ||
5184
+ options.refVideos.length > 0
5185
+ ) {
5186
+ options.seedanceTaskType = 'reference';
5187
+ }
5188
+ }
5189
+ const seedance25TypedIa2vImage =
5190
+ options.videoWorkflow === 'ia2v' && options.refImage && !options.refImageEnd;
5191
+ if (
5192
+ options.seedanceTaskType &&
5193
+ (options.refImageEnd || (options.refImage && !seedance25TypedIa2vImage))
5194
+ ) {
5195
+ fatalCliError(
5196
+ 'Seedance 2.5 reference/edit/extend uses loose media only. Use -c/--context for images; omit --ref/--ref-end frame anchors.',
5197
+ {
5198
+ code: 'INVALID_ARGUMENT',
5199
+ details: { seedanceTaskType: options.seedanceTaskType }
5200
+ }
5201
+ );
5202
+ }
5203
+ if (
5204
+ (options.seedanceTaskType === 'edit' || options.seedanceTaskType === 'extend') &&
5205
+ !options.refVideo && options.refVideos.length === 0
5206
+ ) {
5207
+ fatalCliError(`Seedance 2.5 ${options.seedanceTaskType} requires --ref-video.`, {
5208
+ code: 'INVALID_ARGUMENT',
5209
+ details: { seedanceTaskType: options.seedanceTaskType }
5210
+ });
5211
+ }
5212
+ if (
5213
+ options.seedanceTaskType === 'reference' &&
5214
+ options.contextImages.length === 0 &&
5215
+ !options.refAudio && options.refAudios.length === 0 &&
5216
+ !options.refVideo && options.refVideos.length === 0
5217
+ ) {
5218
+ fatalCliError(`Seedance 2.5 ${options.seedanceTaskType} requires at least one loose reference.`, {
5219
+ code: 'INVALID_ARGUMENT',
5220
+ details: { seedanceTaskType: options.seedanceTaskType }
5221
+ });
5222
+ }
5223
+ if (options.seedanceTaskType === 'edit' && !cliSet.duration) {
5224
+ fatalCliError(
5225
+ 'Seedance 2.5 edit requires --duration set to @Video1\'s source duration.',
5226
+ {
5227
+ code: 'INVALID_ARGUMENT',
5228
+ details: { seedanceTaskType: options.seedanceTaskType }
5229
+ }
5230
+ );
5231
+ }
5232
+ if (
5233
+ (options.seedanceTaskType === 'edit' || options.seedanceTaskType === 'extend') &&
5234
+ (cliSet.width || cliSet.height)
5235
+ ) {
5236
+ fatalCliError(
5237
+ `Seedance 2.5 ${options.seedanceTaskType} inherits @Video1's aspect ratio; use --target-resolution 480 or 720 instead of --width/--height.`,
5238
+ {
5239
+ code: 'INVALID_ARGUMENT',
5240
+ details: { seedanceTaskType: options.seedanceTaskType }
5241
+ }
5242
+ );
5243
+ }
5244
+ if (
5245
+ isSeedance25Video &&
5246
+ cliSet.targetResolution &&
5247
+ ![480, 720].includes(options.targetResolution)
5248
+ ) {
5249
+ fatalCliError('Seedance 2.5 --target-resolution must be 480 or 720.', {
5250
+ code: 'INVALID_ARGUMENT',
5251
+ details: { targetResolution: options.targetResolution }
5252
+ });
5253
+ }
5254
+ if (isWan3Video && cliSet.targetResolution && !WAN3_SUPPORTED_RESOLUTIONS.has(options.targetResolution)) {
5255
+ fatalCliError('Wan 3 --target-resolution must be 480, 720, or 1080.', {
5256
+ code: 'INVALID_ARGUMENT',
5257
+ details: { targetResolution: options.targetResolution }
5258
+ });
5259
+ }
5260
+ const seedanceWorkflows = isSeedance25Video
5261
+ ? ['t2v', 'ia2v', 'a2v', 'v2v']
5262
+ : ['t2v', 'ia2v', 'v2v'];
5263
+ if (isSeedanceVideo && !seedanceWorkflows.includes(options.videoWorkflow)) {
5264
+ fatalCliError(isSeedance25Video
5265
+ ? 'Seedance 2.5 supports only t2v, ia2v, a2v, or v2v workflows.'
5266
+ : 'Seedance 2.0 models support only t2v, ia2v, or v2v workflows.', {
4955
5267
  code: 'INVALID_ARGUMENT',
4956
5268
  details: { workflow: options.videoWorkflow, model: options.model }
4957
5269
  });
@@ -4962,6 +5274,12 @@ if (options.video) {
4962
5274
  details: { workflow: options.videoWorkflow, model: options.model }
4963
5275
  });
4964
5276
  }
5277
+ if (isWan3Video && !WAN3_SUPPORTED_WORKFLOWS.has(options.videoWorkflow)) {
5278
+ fatalCliError('Wan 3 supports t2v, i2v/flf, r2v, a2v, ia2v, and v2v workflows.', {
5279
+ code: 'INVALID_ARGUMENT',
5280
+ details: { workflow: options.videoWorkflow, model: options.model }
5281
+ });
5282
+ }
4965
5283
  if (isMiniMaxH3Video && !['t2v', 'i2v', 'r2v'].includes(options.videoWorkflow)) {
4966
5284
  fatalCliError('MiniMax H3 models support only t2v, i2v/flf2v, or r2v workflows.', {
4967
5285
  code: 'INVALID_ARGUMENT',
@@ -4974,6 +5292,12 @@ if (options.video) {
4974
5292
  details: { model: options.model, controlNetName: options.videoControlNetName }
4975
5293
  });
4976
5294
  }
5295
+ if (isWan3Video && (options.videoControlNetName || options.refMask || options.referenceAudioIdentity)) {
5296
+ fatalCliError('Wan 3 does not support ControlNet, masks, or LTX voice-identity references.', {
5297
+ code: 'INVALID_ARGUMENT',
5298
+ details: { model: options.model }
5299
+ });
5300
+ }
4977
5301
  if (isMiniMaxH3Video && (options.videoControlNetName || options.refMask || options.referenceAudioIdentity)) {
4978
5302
  fatalCliError('MiniMax H3 does not support ControlNet, masks, or LTX voice-identity references.', {
4979
5303
  code: 'INVALID_ARGUMENT',
@@ -4986,6 +5310,24 @@ if (options.video) {
4986
5310
  details: { model: options.model, steps: options.steps, guidance: options.guidance }
4987
5311
  });
4988
5312
  }
5313
+ if (isWan3Video && (cliSet.steps || cliSet.guidance)) {
5314
+ fatalCliError('Wan 3 uses vendor-managed sampling settings; omit --steps and --guidance.', {
5315
+ code: 'INVALID_ARGUMENT',
5316
+ details: { model: options.model, steps: options.steps, guidance: options.guidance }
5317
+ });
5318
+ }
5319
+ if (isWan3Video && typeof options.prompt === 'string' && options.prompt.length > 20000) {
5320
+ fatalCliError('Wan 3 prompts must be 20,000 characters or fewer.', {
5321
+ code: 'INVALID_ARGUMENT',
5322
+ details: { promptLength: options.prompt.length, maximum: 20000 }
5323
+ });
5324
+ }
5325
+ if (isWan3Video && cliSet.seed && (!Number.isInteger(options.seed) || options.seed < 0 || options.seed > WAN3_MAX_SEED)) {
5326
+ fatalCliError(`Wan 3 --seed must be an integer from 0 through ${WAN3_MAX_SEED}.`, {
5327
+ code: 'INVALID_ARGUMENT',
5328
+ details: { seed: options.seed }
5329
+ });
5330
+ }
4989
5331
  if (isHappyHorseVideo && options.apiGenerateAudio !== null) {
4990
5332
  fatalCliError('HappyHorse native audio is always on; omit --generate-audio/--no-generate-audio.', {
4991
5333
  code: 'INVALID_ARGUMENT',
@@ -4993,7 +5335,94 @@ if (options.video) {
4993
5335
  });
4994
5336
  }
4995
5337
 
4996
- if (options.videoWorkflow === 't2v') {
5338
+ if (isWan3Video) {
5339
+ options.wan3TaskType ??= options.videoWorkflow === 'v2v' ? 'edit' : 'create';
5340
+ const looseImages = (options.refImage && options.videoWorkflow !== 'i2v' ? 1 : 0)
5341
+ + options.contextImages.length;
5342
+ const looseVideos = (options.refVideo ? 1 : 0) + options.refVideos.length;
5343
+ const looseAudios = (options.refAudio ? 1 : 0) + options.refAudios.length;
5344
+ const looseTotal = looseImages + looseVideos + looseAudios;
5345
+ const hasFrameInputs = options.videoWorkflow === 'i2v' && Boolean(options.refImage || options.refImageEnd);
5346
+ const hasReferenceFile = Boolean(options.wan3ReferenceFileUrl);
5347
+ const hasReferenceLink = Boolean(options.wan3ReferenceLinkUrl);
5348
+
5349
+ if (hasReferenceFile && hasReferenceLink) {
5350
+ fatalCliError('Wan 3 accepts either --reference-file-url or --reference-link-url, not both.', {
5351
+ code: 'INVALID_ARGUMENT'
5352
+ });
5353
+ }
5354
+ if (
5355
+ (hasReferenceFile && !isHttpsUrl(options.wan3ReferenceFileUrl)) ||
5356
+ (hasReferenceLink && !isHttpsUrl(options.wan3ReferenceLinkUrl))
5357
+ ) {
5358
+ fatalCliError('Wan 3 document and webpage context must use public HTTPS URLs.', {
5359
+ code: 'INVALID_URL'
5360
+ });
5361
+ }
5362
+ if ((hasReferenceFile || hasReferenceLink) && hasFrameInputs) {
5363
+ fatalCliError('Wan 3 document/webpage context cannot be combined with first/last-frame anchors.', {
5364
+ code: 'INVALID_ARGUMENT'
5365
+ });
5366
+ }
5367
+ if ((options.wan3TaskType === 'edit' || options.wan3TaskType === 'extend') && looseVideos === 0) {
5368
+ fatalCliError(`Wan 3 ${options.wan3TaskType} requires --ref-video.`, {
5369
+ code: 'INVALID_ARGUMENT'
5370
+ });
5371
+ }
5372
+ if (options.wan3TaskType === 'extend' && options.wan3Ratio !== 'adaptive') {
5373
+ fatalCliError('Wan 3 extension requires --wan3-ratio adaptive.', {
5374
+ code: 'INVALID_ARGUMENT'
5375
+ });
5376
+ }
5377
+
5378
+ if (options.refImageEnd && !options.refImage) {
5379
+ fatalCliError('Wan 3 last-frame generation requires --ref as the first-frame image.', { code: 'INVALID_ARGUMENT' });
5380
+ }
5381
+ if (options.videoWorkflow === 't2v' && (hasFrameInputs || looseTotal > 0 || options.refImageEnd)) {
5382
+ fatalCliError('Wan 3 t2v does not accept reference media; choose i2v, r2v, a2v, ia2v, or v2v.', { code: 'INVALID_ARGUMENT' });
5383
+ }
5384
+ if (options.videoWorkflow === 'i2v') {
5385
+ if (!options.refImage) {
5386
+ fatalCliError('Wan 3 i2v requires --ref as its first-frame image.', { code: 'INVALID_ARGUMENT' });
5387
+ }
5388
+ if (options.contextImages.length > 0 || looseVideos > 0 || looseAudios > 0) {
5389
+ fatalCliError('Wan 3 first/last-frame anchors cannot be combined with loose image, video, or audio references.', { code: 'INVALID_ARGUMENT' });
5390
+ }
5391
+ }
5392
+ if (options.videoWorkflow === 'r2v') {
5393
+ if (options.refImageEnd) {
5394
+ fatalCliError('Wan 3 r2v uses loose references and does not accept --ref-end.', { code: 'INVALID_ARGUMENT' });
5395
+ }
5396
+ if (looseTotal === 0 && !hasReferenceFile && !hasReferenceLink) {
5397
+ fatalCliError('Wan 3 r2v requires image/video/audio media, a reference document, or a webpage.', { code: 'INVALID_ARGUMENT' });
5398
+ }
5399
+ }
5400
+ if (options.videoWorkflow === 'ia2v') {
5401
+ if (options.refImageEnd) {
5402
+ fatalCliError('Wan 3 ia2v maps --ref to a loose image and does not accept --ref-end.', { code: 'INVALID_ARGUMENT' });
5403
+ }
5404
+ if (looseAudios === 0 || looseImages + looseVideos === 0) {
5405
+ fatalCliError('Wan 3 ia2v requires audio plus at least one image or video reference.', { code: 'INVALID_ARGUMENT' });
5406
+ }
5407
+ }
5408
+ if (options.videoWorkflow === 'a2v') {
5409
+ if (looseAudios === 0) {
5410
+ fatalCliError('Wan 3 a2v requires --ref-audio.', { code: 'INVALID_ARGUMENT' });
5411
+ }
5412
+ if (looseImages > 0 || looseVideos > 0 || options.refImageEnd) {
5413
+ fatalCliError('Wan 3 a2v accepts audio references only; use ia2v or r2v for multimodal input.', { code: 'INVALID_ARGUMENT' });
5414
+ }
5415
+ }
5416
+ if (options.videoWorkflow === 'v2v') {
5417
+ if (looseVideos === 0) {
5418
+ fatalCliError('Wan 3 v2v requires --ref-video.', { code: 'INVALID_ARGUMENT' });
5419
+ }
5420
+ if (options.refImageEnd) {
5421
+ fatalCliError('Wan 3 v2v uses loose references and does not accept --ref-end.', { code: 'INVALID_ARGUMENT' });
5422
+ }
5423
+ }
5424
+ enforceWan3ReferenceCaps({ images: looseImages, videos: looseVideos, audios: looseAudios });
5425
+ } else if (options.videoWorkflow === 't2v') {
4997
5426
  if (!isSeedanceVideo && (
4998
5427
  options.refImage || options.refImageEnd || options.refAudio || options.refVideo
4999
5428
  || options.contextImages.length > 0 || options.refAudios.length > 0 || options.refVideos.length > 0
@@ -5020,11 +5449,11 @@ if (options.video) {
5020
5449
  fatalCliError('MiniMax H3 flf2v requires both --ref and --ref-end.', { code: 'INVALID_ARGUMENT' });
5021
5450
  }
5022
5451
  } else {
5023
- if (!options.refImage) {
5024
- fatalCliError('MiniMax H3 i2v requires --ref (a single first-frame image).', { code: 'INVALID_ARGUMENT' });
5452
+ if (!options.refImage && !options.refImageEnd) {
5453
+ fatalCliError('MiniMax H3 i2v requires exactly one endpoint: --ref for I2VA or --ref-end for L2VA.', { code: 'INVALID_ARGUMENT' });
5025
5454
  }
5026
- if (options.refImageEnd) {
5027
- fatalCliError('MiniMax H3 i2v accepts one first-frame image; use -m minimax-h3-flf2v for --ref plus --ref-end.', { code: 'INVALID_ARGUMENT' });
5455
+ if (options.refImage && options.refImageEnd) {
5456
+ fatalCliError('MiniMax H3 i2v accepts one endpoint; use -m minimax-h3-flf2v for --ref plus --ref-end.', { code: 'INVALID_ARGUMENT' });
5028
5457
  }
5029
5458
  }
5030
5459
  if (options.contextImages.length > 0 || options.refAudio || options.refVideo || options.refAudios.length > 0 || options.refVideos.length > 0) {
@@ -5069,9 +5498,12 @@ if (options.video) {
5069
5498
  }
5070
5499
  } else if (options.videoWorkflow === 'ia2v') {
5071
5500
  if (isSeedanceVideo) {
5072
- if (!options.refAudio || (!options.refImage && !options.refImageEnd && !options.refVideo)) {
5501
+ if (!options.refAudio || (!options.refImage && !options.refVideo)) {
5073
5502
  fatalCliError('Seedance ia2v requires --ref-audio plus --ref or --ref-video.', { code: 'INVALID_ARGUMENT' });
5074
5503
  }
5504
+ if (options.refImageEnd) {
5505
+ fatalCliError('Seedance ia2v treats --ref as a loose @Image reference and does not accept --ref-end. Use dedicated frame mode without audio for a native last-frame anchor.', { code: 'INVALID_ARGUMENT' });
5506
+ }
5075
5507
  } else if (!options.refImage || !options.refAudio) {
5076
5508
  fatalCliError('ia2v requires both --ref and --ref-audio.', { code: 'INVALID_ARGUMENT' });
5077
5509
  }
@@ -5120,35 +5552,46 @@ if (options.video) {
5120
5552
  if (options.videoStart !== null && !options.refVideo) {
5121
5553
  fatalCliError('--video-start requires --ref-video.', { code: 'INVALID_ARGUMENT' });
5122
5554
  }
5123
- if (isSeedanceVideo && options.refAudio && !options.refImage && !options.refImageEnd && !options.refVideo
5555
+ if (isSeedanceVideo && !isSeedance25Video && options.refAudio && !options.refImage && !options.refImageEnd && !options.refVideo
5124
5556
  && (!Array.isArray(options.contextImages) || options.contextImages.length === 0)) {
5125
- fatalCliError('Seedance audio references require --ref, --ref-video, or -c/--context image refs.', { code: 'INVALID_ARGUMENT' });
5557
+ fatalCliError('Seedance 2.0 audio references require --ref, --ref-video, or -c/--context image refs.', { code: 'INVALID_ARGUMENT' });
5126
5558
  }
5127
5559
 
5128
- // Seedance reference modes are mutually exclusive:
5129
- // - DEDICATED FRAME MODE: --ref (first frame) and/or --ref-end (last frame).
5130
- // Up to 2 images; the platform pins them as parameter-mode firstFrame/lastFrame.
5560
+ // Seedance provider roles form two mutually exclusive request shapes:
5561
+ // - DEDICATED FRAME MODE: --ref (first frame) and/or --ref-end (last frame)
5562
+ // outside the typed ia2v workflow. The platform pins them as
5563
+ // parameter-mode firstFrame/lastFrame.
5131
5564
  // - LOOSE REFERENCE MODE: -c/--context (repeatable image refs), --ref-audio extras,
5132
- // --ref-video extras. Up to 9 images / 3 videos / 3 audios / 12 total.
5565
+ // --ref-video extras. Seedance 2.0 permits 9 images / 3 videos / 3 audios /
5566
+ // 12 total; Seedance 2.5 permits 30 / 10 / 10 / 50 and audio-only input.
5133
5567
  // Anchor frame intent in the prompt with @Image1 / @Video1 / @Audio1 etc.
5134
- // Mixing dedicated frames with loose image refs is rejected at sogni-socket
5135
- // (jobsController.js) so we catch it client-side with a clearer message.
5136
- if (isSeedanceVideo
5137
- && (options.refImage || options.refImageEnd)
5138
- && Array.isArray(options.contextImages) && options.contextImages.length > 0) {
5568
+ // In typed ia2v, --ref is intentionally a loose reference_image beside the
5569
+ // audio, not a first_frame role. Every other frame-plus-loose combination is
5570
+ // rejected by sogni-socket, so catch it before uploading or charging.
5571
+ const seedanceFrameInputs = options.videoWorkflow === 'ia2v'
5572
+ ? [options.refImageEnd].filter(Boolean)
5573
+ : [options.refImage, options.refImageEnd].filter(Boolean);
5574
+ const seedanceLooseInputs = [
5575
+ ...(Array.isArray(options.contextImages) ? options.contextImages : []),
5576
+ options.refAudio,
5577
+ ...(Array.isArray(options.refAudios) ? options.refAudios : []),
5578
+ options.refVideo,
5579
+ ...(Array.isArray(options.refVideos) ? options.refVideos : []),
5580
+ ].filter(Boolean);
5581
+ if (isSeedanceVideo && seedanceFrameInputs.length > 0 && seedanceLooseInputs.length > 0) {
5139
5582
  fatalCliError(
5140
- 'Seedance reference modes are mutually exclusive: --ref/--ref-end (dedicated first/last frame) cannot be combined with -c/--context (loose image references). '
5141
- + 'Pick one: use --ref/--ref-end for first-class first-frame/last-frame anchoring (max 2 images), '
5142
- + 'or use -c/--context (plus optional @Image1/@Image2 prompt language) for up to 9 loose image references.',
5583
+ 'Seedance reference modes are mutually exclusive: native --ref/--ref-end frame anchors cannot be combined with loose image, video, or audio references. '
5584
+ + 'Pick one: use --ref/--ref-end alone for first-class frame anchoring, or use -c/--context with optional --ref-video/--ref-audio and @ImageN/@VideoN/@AudioN prompt language. '
5585
+ + 'For image-plus-audio generation, select --workflow ia2v; there --ref is mapped to a loose @Image reference instead of first_frame.',
5143
5586
  { code: 'INVALID_ARGUMENT', details: {
5144
- dedicatedFrames: [options.refImage, options.refImageEnd].filter(Boolean),
5145
- looseImageRefs: options.contextImages,
5587
+ dedicatedFrames: seedanceFrameInputs,
5588
+ looseReferences: seedanceLooseInputs,
5146
5589
  } },
5147
5590
  );
5148
5591
  }
5149
5592
  // Non-Seedance video models do not understand multi-ref audio/video extras —
5150
5593
  // they only support a single primary --ref-audio / --ref-video each.
5151
- if (!isSeedanceVideo && !isMiniMaxH3R2v) {
5594
+ if (!isSeedanceVideo && !isMiniMaxH3R2v && !isWan3Video) {
5152
5595
  if (Array.isArray(options.refAudios) && options.refAudios.length > 0) {
5153
5596
  fatalCliError('Multiple --ref-audio entries are supported only for Seedance loose references and MiniMax H3 r2v.', {
5154
5597
  code: 'INVALID_ARGUMENT',
@@ -5261,7 +5704,13 @@ if (options.video) {
5261
5704
 
5262
5705
  applyVideoPromptGuardrails();
5263
5706
 
5264
- if (options.video && (isSeedanceModel(options.model) || isHappyHorseModel(options.model)) && options.fps !== 24) {
5707
+ if (options.video && isWan3ModelLocal(options.model) && options.fps !== 30) {
5708
+ const originalFps = options.fps;
5709
+ options.fps = 30;
5710
+ if (!options.quiet) {
5711
+ console.error(`Adjusted Wan 3 fps from ${originalFps} to 30 (Wan 3 uses fixed 30fps video generation).`);
5712
+ }
5713
+ } else if (options.video && (isSeedanceModel(options.model) || isHappyHorseModel(options.model)) && options.fps !== 24) {
5265
5714
  const originalFps = options.fps;
5266
5715
  const vendorLabel = isHappyHorseModel(options.model) ? 'HappyHorse' : 'Seedance';
5267
5716
  options.fps = 24;
@@ -5270,10 +5719,19 @@ if (options.video && (isSeedanceModel(options.model) || isHappyHorseModel(option
5270
5719
  }
5271
5720
  }
5272
5721
 
5722
+ if (options.video && isWan3ModelLocal(options.model) && options.wan3SmartDuration) {
5723
+ // Reserve the maximum output for preflight pricing; transport sends
5724
+ // smartDuration instead of a fixed duration.
5725
+ options.duration = 30;
5726
+ }
5727
+
5273
5728
  if (options.video && !options.frames) {
5274
5729
  const durationLimits = videoDurationLimitsLikeWrapper(options.model);
5275
5730
  const requestedDuration = options.duration;
5276
- const clampedDuration = Math.max(durationLimits.min, Math.min(durationLimits.max, options.duration));
5731
+ let clampedDuration = Math.max(durationLimits.min, Math.min(durationLimits.max, options.duration));
5732
+ if (isWan3ModelLocal(options.model)) {
5733
+ clampedDuration = Math.round(clampedDuration);
5734
+ }
5277
5735
  if (clampedDuration !== options.duration) {
5278
5736
  // H3 reports its own adjustment below, after the frame grid decides the
5279
5737
  // duration actually delivered; announcing the clamp here would name a
@@ -5300,6 +5758,20 @@ if (options.video && !options.frames) {
5300
5758
  );
5301
5759
  }
5302
5760
  }
5761
+ } else if (options.video && isWan3ModelLocal(options.model)) {
5762
+ const maximumFrames = 901;
5763
+ if (
5764
+ !Number.isInteger(options.frames)
5765
+ || options.frames < 61
5766
+ || options.frames > maximumFrames
5767
+ || (options.frames - 1) % 30 !== 0
5768
+ ) {
5769
+ fatalCliError(`Wan 3 frames must be 61 + n×30 through ${maximumFrames} at fixed 30fps.`, {
5770
+ code: 'INVALID_ARGUMENT',
5771
+ details: { frames: options.frames, minimum: 61, maximum: maximumFrames, step: 30 }
5772
+ });
5773
+ }
5774
+ options.fps = 30;
5303
5775
  } else if (options.video && isMiniMaxH3Model(options.model)) {
5304
5776
  const { min: minFrames, max: maxFrames, step: frameStep, fps: h3Fps } = MINIMAX_H3_FRAME_GRID;
5305
5777
  if (options.frames < minFrames || options.frames > maxFrames || (options.frames - minFrames) % frameStep !== 0) {
@@ -5600,6 +6072,10 @@ if (commandUsesGenerationSeed && (options.seed === null || options.seed === unde
5600
6072
  : computePromptHashSeed(options);
5601
6073
  if (!options.quiet) console.error(`Using ${normalized} seed: ${options.seed}`);
5602
6074
  }
6075
+ if (commandUsesGenerationSeed && isWan3ModelLocal(options.model) && options.seed > WAN3_MAX_SEED) {
6076
+ options.seed %= WAN3_MAX_SEED + 1;
6077
+ if (!options.quiet) console.error(`Adjusted Wan 3 seed into its 0-${WAN3_MAX_SEED} range: ${options.seed}`);
6078
+ }
5603
6079
 
5604
6080
  // Load credentials
5605
6081
  // Parse a `KEY=value` credentials file robustly. Tolerates: a UTF-8 BOM, an
@@ -8628,6 +9104,46 @@ async function uploadSeedanceReferenceVideoUrl(pathOrUrl, apiKey, index = 0) {
8628
9104
  return uploaded.url;
8629
9105
  }
8630
9106
 
9107
+ async function uploadWan3ReferenceAudioUrl(pathOrUrl, apiKey, index, maxDurationSeconds) {
9108
+ const ref = { flag: '--ref-audio', value: pathOrUrl, kind: 'audio' };
9109
+ const buffer = await fetchMediaBuffer(pathOrUrl);
9110
+ const filename = mediaFilenameFromSource(pathOrUrl, 'wan3-reference-audio');
9111
+ const prepared = await trimSeedanceReferenceAudioToMp3({
9112
+ data: buffer,
9113
+ filename,
9114
+ start: index === 0 ? options.audioStart ?? 0 : 0,
9115
+ duration: maxDurationSeconds,
9116
+ });
9117
+ const data = Buffer.from(prepared.data);
9118
+ const uploaded = await uploadPreparedApiMediaReferenceV2(ref, index, apiKey, {
9119
+ buffer: data,
9120
+ filename: withMediaExtension(filename, 'mp3'),
9121
+ byteLength: data.length,
9122
+ mimeType: 'audio/mpeg',
9123
+ });
9124
+ return uploaded.url;
9125
+ }
9126
+
9127
+ async function uploadWan3ReferenceVideoUrl(pathOrUrl, apiKey, index, maxDurationSeconds) {
9128
+ const ref = { flag: '--ref-video', value: pathOrUrl, kind: 'video' };
9129
+ const buffer = await fetchMediaBuffer(pathOrUrl);
9130
+ const filename = mediaFilenameFromSource(pathOrUrl, 'wan3-reference-video.mp4');
9131
+ const prepared = await trimSeedanceV2VSourceVideo({
9132
+ data: buffer,
9133
+ filename,
9134
+ start: index === 0 ? options.videoStart ?? 0 : 0,
9135
+ duration: maxDurationSeconds,
9136
+ });
9137
+ const data = Buffer.from(prepared.data);
9138
+ const uploaded = await uploadPreparedApiMediaReferenceV2(ref, index, apiKey, {
9139
+ buffer: data,
9140
+ filename: withMediaExtension(filename, 'mp4'),
9141
+ byteLength: data.length,
9142
+ mimeType: 'video/mp4',
9143
+ });
9144
+ return uploaded.url;
9145
+ }
9146
+
8631
9147
  // Content types the Sogni media pipeline accepts for image references, mirroring
8632
9148
  // the `allowedContentTypes` the /v2/image/uploadUrl presigned-POST endpoint
8633
9149
  // returns. Kept as a constant so the skill validates exactly what the backend
@@ -8786,14 +9302,31 @@ function effectiveSeedanceReferenceCounts() {
8786
9302
  return { images, audios, videos };
8787
9303
  }
8788
9304
 
9305
+ function enforceWan3ReferenceCaps({ images, videos, audios }) {
9306
+ const checks = [
9307
+ ['images', images, WAN3_REFERENCE_LIMITS.images],
9308
+ ['videos', videos, WAN3_REFERENCE_LIMITS.videos],
9309
+ ['audios', audios, WAN3_REFERENCE_LIMITS.audios],
9310
+ ];
9311
+ for (const [kind, count, maximum] of checks) {
9312
+ if (count <= maximum) continue;
9313
+ const label = `reference ${kind}`;
9314
+ fatalCliError(`Wan 3 supports at most ${maximum} ${label} (got ${count}).`, {
9315
+ code: 'WAN3_REFERENCE_LIMIT_EXCEEDED',
9316
+ details: { kind, count, maximum, limits: WAN3_REFERENCE_LIMITS },
9317
+ });
9318
+ }
9319
+ }
9320
+
8789
9321
  // Wraps the shared validateSeedanceReferenceCounts() so a thrown
8790
9322
  // SeedanceReferenceLimitError is re-raised as a CLI fatal error with the same
8791
- // human message the hosted chat surfaces. Source of truth for the numeric caps
8792
- // (9 / 3 / 3 / 12) is @sogni-ai/sogni-protocol's seedance-reference-limits
8793
- // catalog, surfaced through @sogni-ai/sogni-intelligence-client/tools.
9323
+ // human message the hosted chat surfaces. Source of truth for the per-model
9324
+ // numeric caps (2.0: 9 / 3 / 3 / 12; 2.5: 30 / 10 / 10 / 50) is
9325
+ // @sogni-ai/sogni-protocol's seedance-reference-limits catalog, surfaced
9326
+ // through @sogni-ai/sogni-intelligence-client/tools.
8794
9327
  function enforceSeedanceReferenceCaps() {
8795
9328
  try {
8796
- validateSeedanceReferenceCounts(effectiveSeedanceReferenceCounts());
9329
+ validateSeedanceReferenceCounts(effectiveSeedanceReferenceCounts(), options.model);
8797
9330
  } catch (err) {
8798
9331
  if (err instanceof SeedanceReferenceLimitError) {
8799
9332
  fatalCliError(err.message, {
@@ -8802,7 +9335,7 @@ function enforceSeedanceReferenceCaps() {
8802
9335
  limitKind: err.limitKind,
8803
9336
  requestedCount: err.requestedCount,
8804
9337
  maxCount: err.maxCount,
8805
- limits: SEEDANCE_REFERENCE_LIMITS,
9338
+ limits: getSeedanceReferenceLimits(options.model),
8806
9339
  },
8807
9340
  });
8808
9341
  }
@@ -10048,8 +10581,8 @@ async function runMultiAngleFlow(client, log) {
10048
10581
  ? MULTI_ANGLE_AZIMUTHS.map((a) => a.key)
10049
10582
  : [options.azimuth];
10050
10583
  const modelDefaults = getModelDefaults(options.model, openclawConfig);
10051
- const steps = options.steps ?? modelDefaults?.steps ?? (options.model.includes('lightning') ? 4 : 20);
10052
- const guidance = options.guidance ?? modelDefaults?.guidance ?? (options.model.includes('lightning') ? 1.0 : 4.0);
10584
+ const steps = options.steps ?? modelDefaults?.steps ?? (isLightningImageModelSelection(options.model) ? 4 : 20);
10585
+ const guidance = options.guidance ?? modelDefaults?.guidance ?? (isLightningImageModelSelection(options.model) ? 1.0 : 4.0);
10053
10586
 
10054
10587
  let outputConfig = resolveMultiAngleOutputConfig(options.output, options.outputFormat);
10055
10588
  let tempOutputDir = null;
@@ -10394,6 +10927,7 @@ function miniMaxH3R2vReferenceImageCount() {
10394
10927
 
10395
10928
  function buildVideoEstimateParams({ tokenType, steps }) {
10396
10929
  const isSeedanceVideo = isSeedanceModel(options.model);
10930
+ const isWan3Video = isWan3ModelLocal(options.model);
10397
10931
  const referenceImageCount = miniMaxH3R2vReferenceImageCount();
10398
10932
  const params = {
10399
10933
  modelId: options.model,
@@ -10407,7 +10941,7 @@ function buildVideoEstimateParams({ tokenType, steps }) {
10407
10941
  ...(referenceImageCount !== undefined ? { referenceImageCount } : {})
10408
10942
  };
10409
10943
 
10410
- if (isSeedanceVideo && options.refVideo) {
10944
+ if ((isSeedanceVideo || isWan3Video) && options.refVideo) {
10411
10945
  params.hasVideoInput = true;
10412
10946
  if (isHttpsUrl(options.refVideo)) {
10413
10947
  params.referenceVideoUrls = [options.refVideo];
@@ -10473,7 +11007,10 @@ async function ensureSufficientVideoBalance(client, log) {
10473
11007
  const modelDefaults = getModelDefaults(options.model, openclawConfig);
10474
11008
  const steps = resolveVideoSteps(options.model, modelDefaults, options.steps);
10475
11009
  const isSeedanceVideo = isSeedanceModel(options.model);
10476
- if (!isSeedanceVideo && (!Number.isFinite(steps) || steps <= 0)) return;
11010
+ const isStepFreeVendorVideo = isSeedanceVideo
11011
+ || isHappyHorseModel(options.model)
11012
+ || isWan3ModelLocal(options.model);
11013
+ if (!isStepFreeVendorVideo && (!Number.isFinite(steps) || steps <= 0)) return;
10477
11014
 
10478
11015
  let estimate;
10479
11016
  try {
@@ -11195,7 +11732,10 @@ async function main() {
11195
11732
  const modelDefaults = getModelDefaults(options.model, openclawConfig);
11196
11733
  const steps = resolveVideoSteps(options.model, modelDefaults, options.steps);
11197
11734
  const isSeedanceVideo = isSeedanceModel(options.model);
11198
- if (!isSeedanceVideo && (!Number.isFinite(steps) || steps <= 0)) {
11735
+ const isStepFreeVendorVideo = isSeedanceVideo
11736
+ || isHappyHorseModel(options.model)
11737
+ || isWan3ModelLocal(options.model);
11738
+ if (!isStepFreeVendorVideo && (!Number.isFinite(steps) || steps <= 0)) {
11199
11739
  const err = new Error('--estimate-video-cost requires --steps (or modelDefaults for this model).');
11200
11740
  err.code = 'MISSING_STEPS';
11201
11741
  err.hint = 'Pass --steps explicitly (e.g. --steps 4 for lightx2v models).';
@@ -11327,11 +11867,12 @@ async function main() {
11327
11867
 
11328
11868
  const isSeedanceVideo = isSeedanceModel(options.model);
11329
11869
  const isHappyHorseVideo = isHappyHorseModel(options.model);
11870
+ const isWan3Video = isWan3ModelLocal(options.model);
11330
11871
  const isMiniMaxH3R2v = isMiniMaxH3R2vModel(options.model);
11331
11872
  // Vendor video models forward image references as HTTPS URL arrays (or
11332
11873
  // Sogni-hosted uploads) instead of inline buffers; HappyHorse takes
11333
11874
  // image-only references (i2v first_frame, r2v reference_image).
11334
- const isVendorReferenceVideo = isSeedanceVideo || isHappyHorseVideo;
11875
+ const isVendorReferenceVideo = isSeedanceVideo || isHappyHorseVideo || isWan3Video;
11335
11876
  if (isSeedanceVideo) {
11336
11877
  // Source of truth: @sogni-ai/sogni-protocol catalogs/seedance-reference-limits.json
11337
11878
  // surfaced through @sogni-ai/sogni-intelligence-client/tools.
@@ -11342,14 +11883,58 @@ async function main() {
11342
11883
  // HAPPYHORSE_REFERENCE_LIMITS (per-mode image-only caps).
11343
11884
  enforceHappyHorseReferenceCaps();
11344
11885
  }
11886
+ if (isWan3Video) {
11887
+ const looseImageCount = (options.refImage && options.videoWorkflow !== 'i2v' ? 1 : 0)
11888
+ + options.contextImages.length;
11889
+ enforceWan3ReferenceCaps({
11890
+ images: looseImageCount,
11891
+ videos: (options.refVideo ? 1 : 0) + options.refVideos.length,
11892
+ audios: (options.refAudio ? 1 : 0) + options.refAudios.length,
11893
+ });
11894
+ }
11345
11895
  if (isMiniMaxH3R2v) {
11346
11896
  enforceMiniMaxH3ReferenceCaps();
11347
11897
  }
11348
11898
  const seedanceReferenceImageUrls = [];
11349
11899
  const seedanceReferenceVideoUrls = [];
11350
11900
  const seedanceReferenceAudioUrls = [];
11351
- const useRefImageUrl = isVendorReferenceVideo && await appendSafeSeedanceReferenceUrl(seedanceReferenceImageUrls, options.refImage, 'Reference image');
11352
- const useRefImageEndUrl = isVendorReferenceVideo && await appendSafeSeedanceReferenceUrl(seedanceReferenceImageUrls, options.refImageEnd, 'End reference image');
11901
+ // Argument roles, never file location, determine provider semantics.
11902
+ // --ref/--ref-end are dedicated frame anchors even when they are HTTPS;
11903
+ // -c/--context is loose reference media. IA2V is the one typed exception:
11904
+ // its image travels beside audio as a loose @Image reference. HappyHorse
11905
+ // has no binary frame upload field and keeps URL forwarding.
11906
+ let useRefImageUrl = false;
11907
+ let useRefImageEndUrl = false;
11908
+ if (isHappyHorseVideo) {
11909
+ useRefImageUrl = await appendSafeSeedanceReferenceUrl(
11910
+ seedanceReferenceImageUrls,
11911
+ options.refImage,
11912
+ 'Reference image',
11913
+ );
11914
+ useRefImageEndUrl = await appendSafeSeedanceReferenceUrl(
11915
+ seedanceReferenceImageUrls,
11916
+ options.refImageEnd,
11917
+ 'End reference image',
11918
+ );
11919
+ } else if (
11920
+ (isSeedanceVideo && options.videoWorkflow === 'ia2v' && options.refImage)
11921
+ || (isWan3Video && options.videoWorkflow !== 'i2v' && options.refImage)
11922
+ ) {
11923
+ if (isHttpsUrl(options.refImage)) {
11924
+ useRefImageUrl = await appendSafeSeedanceReferenceUrl(
11925
+ seedanceReferenceImageUrls,
11926
+ options.refImage,
11927
+ 'Reference image',
11928
+ );
11929
+ } else {
11930
+ seedanceReferenceImageUrls.push(await uploadSeedanceReferenceImageUrl(
11931
+ options.refImage,
11932
+ creds.SOGNI_API_KEY,
11933
+ 0,
11934
+ ));
11935
+ useRefImageUrl = true;
11936
+ }
11937
+ }
11353
11938
  const refAudioFormatByPath = options.refAudio
11354
11939
  ? detectReferenceAudioFormat(
11355
11940
  new Uint8Array(),
@@ -11359,7 +11944,16 @@ async function main() {
11359
11944
  : 'unknown';
11360
11945
  let projectVideoStart = options.videoStart;
11361
11946
  let useRefAudioUrl = false;
11362
- if (isSeedanceVideo && options.refAudio) {
11947
+ if (isWan3Video && options.refAudio) {
11948
+ const audioCount = 1 + options.refAudios.length;
11949
+ seedanceReferenceAudioUrls.push(await uploadWan3ReferenceAudioUrl(
11950
+ options.refAudio,
11951
+ creds.SOGNI_API_KEY,
11952
+ 0,
11953
+ 15 / audioCount,
11954
+ ));
11955
+ useRefAudioUrl = true;
11956
+ } else if (isSeedanceVideo && options.refAudio) {
11363
11957
  const shouldUploadAudio =
11364
11958
  !isHttpsUrl(options.refAudio) ||
11365
11959
  refAudioFormatByPath !== 'mp3' ||
@@ -11378,7 +11972,21 @@ async function main() {
11378
11972
  }
11379
11973
  }
11380
11974
  let useRefVideoUrl = false;
11381
- if (isSeedanceVideo && options.refVideo) {
11975
+ if (isWan3Video && options.refVideo) {
11976
+ const videoCount = 1 + options.refVideos.length;
11977
+ const wan3OutputDuration = options.wan3SmartDuration
11978
+ ? 15
11979
+ : options.frames ? (options.frames - 1) / 30 : options.duration;
11980
+ const videoDurationBudget = Math.min(15, 30 - wan3OutputDuration) / videoCount;
11981
+ seedanceReferenceVideoUrls.push(await uploadWan3ReferenceVideoUrl(
11982
+ options.refVideo,
11983
+ creds.SOGNI_API_KEY,
11984
+ 0,
11985
+ videoDurationBudget,
11986
+ ));
11987
+ useRefVideoUrl = true;
11988
+ projectVideoStart = null;
11989
+ } else if (isSeedanceVideo && options.refVideo) {
11382
11990
  if (isHttpsUrl(options.refVideo) && options.videoStart === null) {
11383
11991
  useRefVideoUrl = await appendSafeSeedanceReferenceUrl(seedanceReferenceVideoUrls, options.refVideo, 'Reference video');
11384
11992
  } else {
@@ -11416,10 +12024,21 @@ async function main() {
11416
12024
  }
11417
12025
  }
11418
12026
  }
11419
- // Seedance-only loose extras: repeated --ref-audio / --ref-video entries
11420
- // past the first. HappyHorse takes no reference audio or video.
11421
- if (isSeedanceVideo) {
12027
+ // Loose extras: Seedance forwards compatible HTTPS assets; Wan 3 uploads
12028
+ // and bounds every asset so total vendor duration caps are respected.
12029
+ // HappyHorse takes no reference audio or video.
12030
+ if (isSeedanceVideo || isWan3Video) {
11422
12031
  for (const [extraAudioIndex, extraAudio] of options.refAudios.entries()) {
12032
+ if (isWan3Video) {
12033
+ const audioCount = (options.refAudio ? 1 : 0) + options.refAudios.length;
12034
+ seedanceReferenceAudioUrls.push(await uploadWan3ReferenceAudioUrl(
12035
+ extraAudio,
12036
+ creds.SOGNI_API_KEY,
12037
+ extraAudioIndex + (options.refAudio ? 1 : 0),
12038
+ 15 / audioCount,
12039
+ ));
12040
+ continue;
12041
+ }
11423
12042
  if (!isHttpsUrl(extraAudio)) {
11424
12043
  fatalCliError(
11425
12044
  `Additional --ref-audio "${extraAudio}" must be an HTTPS URL. ` +
@@ -11443,7 +12062,21 @@ async function main() {
11443
12062
  await appendSafeSeedanceReferenceUrl(seedanceReferenceAudioUrls, extraAudio, 'Seedance audio reference');
11444
12063
  }
11445
12064
  }
11446
- for (const extraVideo of options.refVideos) {
12065
+ for (const [extraVideoIndex, extraVideo] of options.refVideos.entries()) {
12066
+ if (isWan3Video) {
12067
+ const videoCount = (options.refVideo ? 1 : 0) + options.refVideos.length;
12068
+ const wan3OutputDuration = options.wan3SmartDuration
12069
+ ? 15
12070
+ : options.frames ? (options.frames - 1) / 30 : options.duration;
12071
+ const videoDurationBudget = Math.min(15, 30 - wan3OutputDuration) / videoCount;
12072
+ seedanceReferenceVideoUrls.push(await uploadWan3ReferenceVideoUrl(
12073
+ extraVideo,
12074
+ creds.SOGNI_API_KEY,
12075
+ extraVideoIndex + (options.refVideo ? 1 : 0),
12076
+ videoDurationBudget,
12077
+ ));
12078
+ continue;
12079
+ }
11447
12080
  if (!isHttpsUrl(extraVideo)) {
11448
12081
  fatalCliError(
11449
12082
  `Additional --ref-video "${extraVideo}" must be an HTTPS URL. ` +
@@ -11638,11 +12271,17 @@ async function main() {
11638
12271
 
11639
12272
  const steps = resolveVideoSteps(options.model, modelDefaults, options.steps);
11640
12273
  const guidance = options.guidance ?? modelDefaults?.guidance;
12274
+
12275
+ if (isWan3Video && options.wan3ReferenceFileUrl) {
12276
+ await assertSafeUrl(options.wan3ReferenceFileUrl, { allowedProtocols: ['https:'] });
12277
+ }
12278
+ if (isWan3Video && options.wan3ReferenceLinkUrl) {
12279
+ await assertSafeUrl(options.wan3ReferenceLinkUrl, { allowedProtocols: ['https:'] });
12280
+ }
11641
12281
 
11642
12282
  const projectConfig = {
11643
12283
  modelId: options.model,
11644
12284
  positivePrompt: options.prompt,
11645
- negativePrompt: '',
11646
12285
  stylePrompt: '',
11647
12286
  numberOfMedia: options.count,
11648
12287
  referenceImage: imageBuffer,
@@ -11653,6 +12292,22 @@ async function main() {
11653
12292
  waitForCompletion: false,
11654
12293
  disableNSFWFilter: options.noFilter === true
11655
12294
  };
12295
+ if (!isWan3Video && !isHappyHorseVideo && !isSeedanceVideo) {
12296
+ projectConfig.negativePrompt = '';
12297
+ }
12298
+ if (options.seedanceTaskType) {
12299
+ projectConfig.seedanceTaskType = options.seedanceTaskType;
12300
+ }
12301
+ if (isWan3Video) {
12302
+ projectConfig.ratio = options.wan3TaskType === 'extend' ? 'adaptive' : options.wan3Ratio;
12303
+ projectConfig.wan3TaskType = options.wan3TaskType;
12304
+ projectConfig.generateAudio = options.apiGenerateAudio ?? true;
12305
+ projectConfig.promptExtend = options.apiExpandPrompt ?? true;
12306
+ projectConfig.watermark = options.wan3Watermark;
12307
+ if (options.wan3SmartDuration) projectConfig.smartDuration = true;
12308
+ if (options.wan3ReferenceFileUrl) projectConfig.referenceFileUrl = options.wan3ReferenceFileUrl;
12309
+ if (options.wan3ReferenceLinkUrl) projectConfig.referenceLinkUrl = options.wan3ReferenceLinkUrl;
12310
+ }
11656
12311
 
11657
12312
  if (options.outputFormat) {
11658
12313
  projectConfig.outputFormat = options.outputFormat;
@@ -11668,7 +12323,7 @@ async function main() {
11668
12323
 
11669
12324
  if (options.frames) {
11670
12325
  projectConfig.frames = options.frames;
11671
- } else {
12326
+ } else if (!options.wan3SmartDuration) {
11672
12327
  projectConfig.duration = options.duration;
11673
12328
  }
11674
12329
 
@@ -11721,27 +12376,27 @@ async function main() {
11721
12376
  if (options.seed !== null && options.seed !== undefined) {
11722
12377
  projectConfig.seed = options.seed;
11723
12378
  }
11724
- if (options.apiGenerateAudio !== null && isMiniMaxH3Model(options.model)) {
12379
+ if (options.apiGenerateAudio !== null && (isMiniMaxH3Model(options.model) || isWan3Video)) {
11725
12380
  projectConfig.generateAudio = options.apiGenerateAudio;
11726
12381
  }
11727
- if (Number.isFinite(steps) && !isHappyHorseVideo && !isMiniMaxH3Model(options.model)) {
12382
+ if (Number.isFinite(steps) && !isHappyHorseVideo && !isMiniMaxH3Model(options.model) && !isWan3Video) {
11728
12383
  // HappyHorse routes through the vendor-job path and ignores `steps`,
11729
12384
  // mirroring Seedance (whose model defaults already omit them). H3 has
11730
12385
  // fixed sampling parameters and should receive no overrides.
11731
12386
  projectConfig.steps = steps;
11732
12387
  }
11733
- if (guidance !== null && guidance !== undefined && !isMiniMaxH3Model(options.model)) {
12388
+ if (guidance !== null && guidance !== undefined && !isMiniMaxH3Model(options.model) && !isWan3Video) {
11734
12389
  projectConfig.guidance = guidance;
11735
12390
  }
11736
12391
  if (cliSet.sampler && isMiniMaxH3TurboModel(options.model)) {
11737
12392
  projectConfig.sampler = options.sampler;
11738
- } else if (modelDefaults?.sampler && !isMiniMaxH3Model(options.model)) {
12393
+ } else if (modelDefaults?.sampler && !isMiniMaxH3Model(options.model) && !isWan3Video) {
11739
12394
  projectConfig.sampler = modelDefaults.sampler;
11740
12395
  }
11741
- if (modelDefaults?.scheduler && !isMiniMaxH3Model(options.model)) {
12396
+ if (modelDefaults?.scheduler && !isMiniMaxH3Model(options.model) && !isWan3Video) {
11742
12397
  projectConfig.scheduler = modelDefaults.scheduler;
11743
12398
  }
11744
- if (modelDefaults?.shift !== null && modelDefaults?.shift !== undefined && !isMiniMaxH3Model(options.model)) {
12399
+ if (modelDefaults?.shift !== null && modelDefaults?.shift !== undefined && !isMiniMaxH3Model(options.model) && !isWan3Video) {
11745
12400
  projectConfig.shift = modelDefaults.shift;
11746
12401
  }
11747
12402
  if (options.videoControlNetName && !isSeedanceModel(options.model)) {
@@ -11910,8 +12565,8 @@ async function main() {
11910
12565
  options.contextImages.map(img => fetchMediaBuffer(img))
11911
12566
  );
11912
12567
  const modelDefaults = getModelDefaults(options.model, openclawConfig);
11913
- const steps = options.steps ?? modelDefaults?.steps ?? (options.model.includes('lightning') ? 4 : 20);
11914
- const guidance = options.guidance ?? modelDefaults?.guidance ?? (options.model.includes('lightning') ? 3.5 : 7.5);
12568
+ const steps = options.steps ?? modelDefaults?.steps ?? (isLightningImageModelSelection(options.model) ? 4 : 20);
12569
+ const guidance = options.guidance ?? modelDefaults?.guidance ?? (isLightningImageModelSelection(options.model) ? 3.5 : 7.5);
11915
12570
  const gptImageQuality = isGptImage2ModelSelection(options.model)
11916
12571
  ? options.quality === 'pro'
11917
12572
  ? 'high'
@@ -12177,7 +12832,7 @@ async function main() {
12177
12832
  if (options.videoStart !== null) renderInfo.videoStart = options.videoStart;
12178
12833
  }
12179
12834
  if (options.refVideos.length > 0) renderInfo.refVideos = options.refVideos;
12180
- if (options.apiGenerateAudio !== null && isMiniMaxH3Model(options.model)) {
12835
+ if (options.apiGenerateAudio !== null && (isMiniMaxH3Model(options.model) || isWan3ModelLocal(options.model))) {
12181
12836
  renderInfo.generateAudio = options.apiGenerateAudio;
12182
12837
  }
12183
12838
  if (options.videoControlNetName && !isSeedanceModel(options.model)) {
@@ -12409,7 +13064,7 @@ async function main() {
12409
13064
  if (options.videoStart !== null) output.videoStart = options.videoStart;
12410
13065
  }
12411
13066
  if (options.refVideos.length > 0) output.refVideos = options.refVideos;
12412
- if (options.apiGenerateAudio !== null && isMiniMaxH3Model(options.model)) {
13067
+ if (options.apiGenerateAudio !== null && (isMiniMaxH3Model(options.model) || isWan3ModelLocal(options.model))) {
12413
13068
  output.generateAudio = options.apiGenerateAudio;
12414
13069
  }
12415
13070
  if (options.videoControlNetName && !isSeedanceModel(options.model)) {