@sogni-ai/sogni-creative-agent-skill 3.34.0 → 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
@@ -1611,6 +1611,36 @@ const SEEDANCE_25_MODEL_SELECTIONS = new Set([
1611
1611
  'seedance2-5-v2v',
1612
1612
  ]);
1613
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
+
1614
1644
  function isSeedance25ModelSelectionLocal(modelId) {
1615
1645
  const normalized = String(modelId || '').trim().toLowerCase().replace(/_/g, '-');
1616
1646
  return SEEDANCE_25_MODEL_SELECTIONS.has(normalized);
@@ -1635,7 +1665,10 @@ function normalizeMusicTimeSignature(value) {
1635
1665
  }
1636
1666
 
1637
1667
  function requiresSparkOnlyToken(modelId) {
1638
- return isGptImage2ModelSelection(modelId) || isSeedanceModel(modelId) || isHappyHorseModel(modelId);
1668
+ return isGptImage2ModelSelection(modelId)
1669
+ || isSeedanceModel(modelId)
1670
+ || isHappyHorseModel(modelId)
1671
+ || isWan3ModelSelectionLocal(modelId);
1639
1672
  }
1640
1673
 
1641
1674
  // Attach the user's explicit --billing-mode to a project config. Omitted by
@@ -1716,6 +1749,7 @@ function getMaxContextImages(modelId) {
1716
1749
 
1717
1750
  function videoDurationLimitsLikeWrapper(modelId) {
1718
1751
  if (isMiniMaxH3Model(modelId)) return { ...MINIMAX_H3_DURATION_LIMITS };
1752
+ if (isWan3ModelSelectionLocal(modelId)) return { min: 2, max: 30 };
1719
1753
  if (isSeedance25ModelSelectionLocal(modelId)) return { min: 4, max: 30 };
1720
1754
  if (isSeedanceModel(modelId)) return { min: 4, max: 15 };
1721
1755
  if (isHappyHorseModel(modelId)) return { min: 3, max: 15 };
@@ -1760,6 +1794,15 @@ function videoModelDimensionDefaultsLikeWrapper(modelId) {
1760
1794
  if (isHappyHorseModel(modelId) || isHappyHorseModelSelectionLocal(modelId)) {
1761
1795
  return { defaultWidth: 1920, defaultHeight: 1080, maxDimension: 1920, dimensionMultiple: 1 };
1762
1796
  }
1797
+ if (isWan3ModelSelectionLocal(modelId)) {
1798
+ return {
1799
+ defaultWidth: 1920,
1800
+ defaultHeight: 1080,
1801
+ minDimension: 480,
1802
+ maxDimension: 1920,
1803
+ dimensionMultiple: 1,
1804
+ };
1805
+ }
1763
1806
  return null;
1764
1807
  }
1765
1808
 
@@ -2147,6 +2190,7 @@ function resolveSkillVideoModelAlias(
2147
2190
  hasEndFrame = false,
2148
2191
  ) {
2149
2192
  const normalized = String(modelId || '').trim().toLowerCase();
2193
+ if (isWan3ModelSelectionLocal(normalized)) return WAN3_MODEL_ID;
2150
2194
  if (normalized === 'ltx25' || normalized === 'ltx25-t2v') {
2151
2195
  const mode = ['i2v', 'a2v', 'ia2v', 'v2v'].includes(workflow) ? workflow : 't2v';
2152
2196
  return LTX25_DISTILLED_WORKFLOW_MODELS[mode];
@@ -2519,6 +2563,12 @@ const options = {
2519
2563
  video: false,
2520
2564
  videoWorkflow: null,
2521
2565
  seedanceTaskType: null,
2566
+ wan3TaskType: null,
2567
+ wan3Ratio: 'adaptive',
2568
+ wan3SmartDuration: false,
2569
+ wan3ReferenceFileUrl: null,
2570
+ wan3ReferenceLinkUrl: null,
2571
+ wan3Watermark: false,
2522
2572
  fps: 16,
2523
2573
  duration: 5,
2524
2574
  frames: null,
@@ -2699,6 +2749,12 @@ const cliSet = {
2699
2749
  video: false,
2700
2750
  workflow: false,
2701
2751
  seedanceTaskType: false,
2752
+ wan3TaskType: false,
2753
+ wan3Ratio: false,
2754
+ wan3SmartDuration: false,
2755
+ wan3ReferenceFileUrl: false,
2756
+ wan3ReferenceLinkUrl: false,
2757
+ wan3Watermark: false,
2702
2758
  fps: false,
2703
2759
  duration: false,
2704
2760
  frames: false,
@@ -2987,6 +3043,36 @@ for (let i = 0; i < args.length; i++) {
2987
3043
  i++;
2988
3044
  options.seedanceTaskType = raw.trim().toLowerCase();
2989
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;
2990
3076
  } else if (arg === '--fps') {
2991
3077
  const raw = requireFlagValue(args, i, arg);
2992
3078
  i++;
@@ -3740,6 +3826,12 @@ Video Options:
3740
3826
  --video, -v Generate video instead of image
3741
3827
  --workflow <type> Video workflow: t2v|i2v|r2v|s2v|ia2v|a2v|v2v|animate-move|animate-replace
3742
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)
3743
3835
  --fps <num> Frames per second (model default unless set)
3744
3836
  --duration <sec> Duration in seconds (default: 5); Seedance 2.5 edit requires @Video1's source duration
3745
3837
  --frames <num> Override total frames (optional)
@@ -3762,7 +3854,7 @@ Video Options:
3762
3854
  --ref-video <path|url> Video reference. Repeatable on Seedance and H3 r2v (up to 3 total);
3763
3855
  first entry is the primary, extras must be HTTPS URLs in CLI
3764
3856
  direct-gen for Seedance. On LTX/WAN: single primary for animate/v2v.
3765
- --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
3766
3858
 
3767
3859
  Seedance Reference Modes (mutually exclusive on seedance2 / seedance2-mini / seedance2-fast / seedance2-5):
3768
3860
  - DEDICATED FRAME MODE: --ref (first frame) and/or --ref-end (last frame).
@@ -3834,7 +3926,7 @@ Hosted API Modes:
3834
3926
  --video-prompt <text> Motion prompt for the generated-keyframe durable workflow
3835
3927
  --negative-prompt <text> Negative prompt for generated workflow steps
3836
3928
  --generate-audio, --no-generate-audio Toggle audio generation for generated video steps
3837
- --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
3838
3930
  --watch-workflow Stream workflow events after starting
3839
3931
  --list-workflows List recent durable creative workflows
3840
3932
  --get-workflow <id> Fetch a workflow snapshot
@@ -4510,13 +4602,17 @@ if (options.video) {
4510
4602
  options.videoWorkflow = normalized;
4511
4603
  } else if (
4512
4604
  options.videoWorkflow === 'r2v'
4513
- && (isHappyHorseModelSelectionLocal(options.model) || isMiniMaxH3ModelSelectionLocal(options.model))
4605
+ && (
4606
+ isHappyHorseModelSelectionLocal(options.model)
4607
+ || isMiniMaxH3ModelSelectionLocal(options.model)
4608
+ || isWan3ModelSelectionLocal(options.model)
4609
+ )
4514
4610
  ) {
4515
- // HappyHorse and MiniMax H3 add reference-to-video (r2v) modes that the
4516
- // 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.
4517
4613
  options.videoWorkflow = 'r2v';
4518
4614
  } else {
4519
- 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).`, {
4520
4616
  code: 'INVALID_ARGUMENT',
4521
4617
  details: { workflow: options.videoWorkflow }
4522
4618
  });
@@ -4544,6 +4640,32 @@ if (options.video) {
4544
4640
  }
4545
4641
  }
4546
4642
 
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
+
4547
4669
  // MiniMax H3 has four concrete worker selectors and five prompt shapes. The
4548
4670
  // FL2VA checkpoint covers t2v, first-frame i2v, last-frame-only l2v, and
4549
4671
  // first/last-frame (represented by the CLI's i2v workflow); Ref2VA is a
@@ -4938,7 +5060,16 @@ if (!loraCatalogUtilityAction && (options.loraCatalogModel || options.loraCatalo
4938
5060
  if (typeof options.prompt === 'string' && options.prompt.trim() === '') {
4939
5061
  options.prompt = '';
4940
5062
  }
4941
- 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) {
4942
5073
  fatalCliError('No prompt provided. Use --help for usage.', { code: 'INVALID_ARGUMENT' });
4943
5074
  }
4944
5075
 
@@ -4981,8 +5112,8 @@ if (!options.upscaleImage && (cliSet.upscaleScale || cliSet.upscaleTargetLongest
4981
5112
  });
4982
5113
  }
4983
5114
 
4984
- if (!options.video && !options.apiChat && !options.apiWorkflowAction && (options.refAudio || options.refVideo || options.refMask || options.referenceAudioIdentity || options.voicePersonaName || options.videoWorkflow || options.seedanceTaskType || options.frames || options.targetResolution || options.audioStart !== null || options.audioDuration !== null || options.videoStart !== null || options.outpaintPosition || options.outpaintAspectRatio)) {
4985
- fatalCliError('Video-only options (--workflow/--seedance-task-type/--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.', {
4986
5117
  code: 'INVALID_ARGUMENT'
4987
5118
  });
4988
5119
  }
@@ -5003,6 +5134,7 @@ if (options.video) {
5003
5134
  const isSeedanceVideo = isSeedanceModel(options.model);
5004
5135
  const isSeedance25Video = isSeedance25ModelSelectionLocal(options.model);
5005
5136
  const isHappyHorseVideo = isHappyHorseModel(options.model);
5137
+ const isWan3Video = isWan3ModelLocal(options.model);
5006
5138
  const isMiniMaxH3Video = isMiniMaxH3Model(options.model);
5007
5139
  const isMiniMaxH3R2v = isMiniMaxH3R2vModel(options.model);
5008
5140
  if (options.seedanceTaskType && !SEEDANCE_TASK_TYPES.has(options.seedanceTaskType)) {
@@ -5017,6 +5149,29 @@ if (options.video) {
5017
5149
  details: { model: options.model, seedanceTaskType: options.seedanceTaskType }
5018
5150
  });
5019
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
+ }
5020
5175
  if (isSeedance25Video && !options.seedanceTaskType) {
5021
5176
  if (options.videoWorkflow === 'v2v') {
5022
5177
  options.seedanceTaskType = 'edit';
@@ -5096,6 +5251,12 @@ if (options.video) {
5096
5251
  details: { targetResolution: options.targetResolution }
5097
5252
  });
5098
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
+ }
5099
5260
  const seedanceWorkflows = isSeedance25Video
5100
5261
  ? ['t2v', 'ia2v', 'a2v', 'v2v']
5101
5262
  : ['t2v', 'ia2v', 'v2v'];
@@ -5113,6 +5274,12 @@ if (options.video) {
5113
5274
  details: { workflow: options.videoWorkflow, model: options.model }
5114
5275
  });
5115
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
+ }
5116
5283
  if (isMiniMaxH3Video && !['t2v', 'i2v', 'r2v'].includes(options.videoWorkflow)) {
5117
5284
  fatalCliError('MiniMax H3 models support only t2v, i2v/flf2v, or r2v workflows.', {
5118
5285
  code: 'INVALID_ARGUMENT',
@@ -5125,6 +5292,12 @@ if (options.video) {
5125
5292
  details: { model: options.model, controlNetName: options.videoControlNetName }
5126
5293
  });
5127
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
+ }
5128
5301
  if (isMiniMaxH3Video && (options.videoControlNetName || options.refMask || options.referenceAudioIdentity)) {
5129
5302
  fatalCliError('MiniMax H3 does not support ControlNet, masks, or LTX voice-identity references.', {
5130
5303
  code: 'INVALID_ARGUMENT',
@@ -5137,6 +5310,24 @@ if (options.video) {
5137
5310
  details: { model: options.model, steps: options.steps, guidance: options.guidance }
5138
5311
  });
5139
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
+ }
5140
5331
  if (isHappyHorseVideo && options.apiGenerateAudio !== null) {
5141
5332
  fatalCliError('HappyHorse native audio is always on; omit --generate-audio/--no-generate-audio.', {
5142
5333
  code: 'INVALID_ARGUMENT',
@@ -5144,7 +5335,94 @@ if (options.video) {
5144
5335
  });
5145
5336
  }
5146
5337
 
5147
- 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') {
5148
5426
  if (!isSeedanceVideo && (
5149
5427
  options.refImage || options.refImageEnd || options.refAudio || options.refVideo
5150
5428
  || options.contextImages.length > 0 || options.refAudios.length > 0 || options.refVideos.length > 0
@@ -5313,7 +5591,7 @@ if (options.video) {
5313
5591
  }
5314
5592
  // Non-Seedance video models do not understand multi-ref audio/video extras —
5315
5593
  // they only support a single primary --ref-audio / --ref-video each.
5316
- if (!isSeedanceVideo && !isMiniMaxH3R2v) {
5594
+ if (!isSeedanceVideo && !isMiniMaxH3R2v && !isWan3Video) {
5317
5595
  if (Array.isArray(options.refAudios) && options.refAudios.length > 0) {
5318
5596
  fatalCliError('Multiple --ref-audio entries are supported only for Seedance loose references and MiniMax H3 r2v.', {
5319
5597
  code: 'INVALID_ARGUMENT',
@@ -5426,7 +5704,13 @@ if (options.video) {
5426
5704
 
5427
5705
  applyVideoPromptGuardrails();
5428
5706
 
5429
- 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) {
5430
5714
  const originalFps = options.fps;
5431
5715
  const vendorLabel = isHappyHorseModel(options.model) ? 'HappyHorse' : 'Seedance';
5432
5716
  options.fps = 24;
@@ -5435,10 +5719,19 @@ if (options.video && (isSeedanceModel(options.model) || isHappyHorseModel(option
5435
5719
  }
5436
5720
  }
5437
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
+
5438
5728
  if (options.video && !options.frames) {
5439
5729
  const durationLimits = videoDurationLimitsLikeWrapper(options.model);
5440
5730
  const requestedDuration = options.duration;
5441
- 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
+ }
5442
5735
  if (clampedDuration !== options.duration) {
5443
5736
  // H3 reports its own adjustment below, after the frame grid decides the
5444
5737
  // duration actually delivered; announcing the clamp here would name a
@@ -5465,6 +5758,20 @@ if (options.video && !options.frames) {
5465
5758
  );
5466
5759
  }
5467
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;
5468
5775
  } else if (options.video && isMiniMaxH3Model(options.model)) {
5469
5776
  const { min: minFrames, max: maxFrames, step: frameStep, fps: h3Fps } = MINIMAX_H3_FRAME_GRID;
5470
5777
  if (options.frames < minFrames || options.frames > maxFrames || (options.frames - minFrames) % frameStep !== 0) {
@@ -5765,6 +6072,10 @@ if (commandUsesGenerationSeed && (options.seed === null || options.seed === unde
5765
6072
  : computePromptHashSeed(options);
5766
6073
  if (!options.quiet) console.error(`Using ${normalized} seed: ${options.seed}`);
5767
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
+ }
5768
6079
 
5769
6080
  // Load credentials
5770
6081
  // Parse a `KEY=value` credentials file robustly. Tolerates: a UTF-8 BOM, an
@@ -8793,6 +9104,46 @@ async function uploadSeedanceReferenceVideoUrl(pathOrUrl, apiKey, index = 0) {
8793
9104
  return uploaded.url;
8794
9105
  }
8795
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
+
8796
9147
  // Content types the Sogni media pipeline accepts for image references, mirroring
8797
9148
  // the `allowedContentTypes` the /v2/image/uploadUrl presigned-POST endpoint
8798
9149
  // returns. Kept as a constant so the skill validates exactly what the backend
@@ -8951,6 +9302,22 @@ function effectiveSeedanceReferenceCounts() {
8951
9302
  return { images, audios, videos };
8952
9303
  }
8953
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
+
8954
9321
  // Wraps the shared validateSeedanceReferenceCounts() so a thrown
8955
9322
  // SeedanceReferenceLimitError is re-raised as a CLI fatal error with the same
8956
9323
  // human message the hosted chat surfaces. Source of truth for the per-model
@@ -10560,6 +10927,7 @@ function miniMaxH3R2vReferenceImageCount() {
10560
10927
 
10561
10928
  function buildVideoEstimateParams({ tokenType, steps }) {
10562
10929
  const isSeedanceVideo = isSeedanceModel(options.model);
10930
+ const isWan3Video = isWan3ModelLocal(options.model);
10563
10931
  const referenceImageCount = miniMaxH3R2vReferenceImageCount();
10564
10932
  const params = {
10565
10933
  modelId: options.model,
@@ -10573,7 +10941,7 @@ function buildVideoEstimateParams({ tokenType, steps }) {
10573
10941
  ...(referenceImageCount !== undefined ? { referenceImageCount } : {})
10574
10942
  };
10575
10943
 
10576
- if (isSeedanceVideo && options.refVideo) {
10944
+ if ((isSeedanceVideo || isWan3Video) && options.refVideo) {
10577
10945
  params.hasVideoInput = true;
10578
10946
  if (isHttpsUrl(options.refVideo)) {
10579
10947
  params.referenceVideoUrls = [options.refVideo];
@@ -10639,7 +11007,10 @@ async function ensureSufficientVideoBalance(client, log) {
10639
11007
  const modelDefaults = getModelDefaults(options.model, openclawConfig);
10640
11008
  const steps = resolveVideoSteps(options.model, modelDefaults, options.steps);
10641
11009
  const isSeedanceVideo = isSeedanceModel(options.model);
10642
- 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;
10643
11014
 
10644
11015
  let estimate;
10645
11016
  try {
@@ -11361,7 +11732,10 @@ async function main() {
11361
11732
  const modelDefaults = getModelDefaults(options.model, openclawConfig);
11362
11733
  const steps = resolveVideoSteps(options.model, modelDefaults, options.steps);
11363
11734
  const isSeedanceVideo = isSeedanceModel(options.model);
11364
- 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)) {
11365
11739
  const err = new Error('--estimate-video-cost requires --steps (or modelDefaults for this model).');
11366
11740
  err.code = 'MISSING_STEPS';
11367
11741
  err.hint = 'Pass --steps explicitly (e.g. --steps 4 for lightx2v models).';
@@ -11493,11 +11867,12 @@ async function main() {
11493
11867
 
11494
11868
  const isSeedanceVideo = isSeedanceModel(options.model);
11495
11869
  const isHappyHorseVideo = isHappyHorseModel(options.model);
11870
+ const isWan3Video = isWan3ModelLocal(options.model);
11496
11871
  const isMiniMaxH3R2v = isMiniMaxH3R2vModel(options.model);
11497
11872
  // Vendor video models forward image references as HTTPS URL arrays (or
11498
11873
  // Sogni-hosted uploads) instead of inline buffers; HappyHorse takes
11499
11874
  // image-only references (i2v first_frame, r2v reference_image).
11500
- const isVendorReferenceVideo = isSeedanceVideo || isHappyHorseVideo;
11875
+ const isVendorReferenceVideo = isSeedanceVideo || isHappyHorseVideo || isWan3Video;
11501
11876
  if (isSeedanceVideo) {
11502
11877
  // Source of truth: @sogni-ai/sogni-protocol catalogs/seedance-reference-limits.json
11503
11878
  // surfaced through @sogni-ai/sogni-intelligence-client/tools.
@@ -11508,6 +11883,15 @@ async function main() {
11508
11883
  // HAPPYHORSE_REFERENCE_LIMITS (per-mode image-only caps).
11509
11884
  enforceHappyHorseReferenceCaps();
11510
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
+ }
11511
11895
  if (isMiniMaxH3R2v) {
11512
11896
  enforceMiniMaxH3ReferenceCaps();
11513
11897
  }
@@ -11532,7 +11916,10 @@ async function main() {
11532
11916
  options.refImageEnd,
11533
11917
  'End reference image',
11534
11918
  );
11535
- } else if (isSeedanceVideo && options.videoWorkflow === 'ia2v' && options.refImage) {
11919
+ } else if (
11920
+ (isSeedanceVideo && options.videoWorkflow === 'ia2v' && options.refImage)
11921
+ || (isWan3Video && options.videoWorkflow !== 'i2v' && options.refImage)
11922
+ ) {
11536
11923
  if (isHttpsUrl(options.refImage)) {
11537
11924
  useRefImageUrl = await appendSafeSeedanceReferenceUrl(
11538
11925
  seedanceReferenceImageUrls,
@@ -11557,7 +11944,16 @@ async function main() {
11557
11944
  : 'unknown';
11558
11945
  let projectVideoStart = options.videoStart;
11559
11946
  let useRefAudioUrl = false;
11560
- 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) {
11561
11957
  const shouldUploadAudio =
11562
11958
  !isHttpsUrl(options.refAudio) ||
11563
11959
  refAudioFormatByPath !== 'mp3' ||
@@ -11576,7 +11972,21 @@ async function main() {
11576
11972
  }
11577
11973
  }
11578
11974
  let useRefVideoUrl = false;
11579
- 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) {
11580
11990
  if (isHttpsUrl(options.refVideo) && options.videoStart === null) {
11581
11991
  useRefVideoUrl = await appendSafeSeedanceReferenceUrl(seedanceReferenceVideoUrls, options.refVideo, 'Reference video');
11582
11992
  } else {
@@ -11614,10 +12024,21 @@ async function main() {
11614
12024
  }
11615
12025
  }
11616
12026
  }
11617
- // Seedance-only loose extras: repeated --ref-audio / --ref-video entries
11618
- // past the first. HappyHorse takes no reference audio or video.
11619
- 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) {
11620
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
+ }
11621
12042
  if (!isHttpsUrl(extraAudio)) {
11622
12043
  fatalCliError(
11623
12044
  `Additional --ref-audio "${extraAudio}" must be an HTTPS URL. ` +
@@ -11641,7 +12062,21 @@ async function main() {
11641
12062
  await appendSafeSeedanceReferenceUrl(seedanceReferenceAudioUrls, extraAudio, 'Seedance audio reference');
11642
12063
  }
11643
12064
  }
11644
- 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
+ }
11645
12080
  if (!isHttpsUrl(extraVideo)) {
11646
12081
  fatalCliError(
11647
12082
  `Additional --ref-video "${extraVideo}" must be an HTTPS URL. ` +
@@ -11836,11 +12271,17 @@ async function main() {
11836
12271
 
11837
12272
  const steps = resolveVideoSteps(options.model, modelDefaults, options.steps);
11838
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
+ }
11839
12281
 
11840
12282
  const projectConfig = {
11841
12283
  modelId: options.model,
11842
12284
  positivePrompt: options.prompt,
11843
- negativePrompt: '',
11844
12285
  stylePrompt: '',
11845
12286
  numberOfMedia: options.count,
11846
12287
  referenceImage: imageBuffer,
@@ -11851,9 +12292,22 @@ async function main() {
11851
12292
  waitForCompletion: false,
11852
12293
  disableNSFWFilter: options.noFilter === true
11853
12294
  };
12295
+ if (!isWan3Video && !isHappyHorseVideo && !isSeedanceVideo) {
12296
+ projectConfig.negativePrompt = '';
12297
+ }
11854
12298
  if (options.seedanceTaskType) {
11855
12299
  projectConfig.seedanceTaskType = options.seedanceTaskType;
11856
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
+ }
11857
12311
 
11858
12312
  if (options.outputFormat) {
11859
12313
  projectConfig.outputFormat = options.outputFormat;
@@ -11869,7 +12323,7 @@ async function main() {
11869
12323
 
11870
12324
  if (options.frames) {
11871
12325
  projectConfig.frames = options.frames;
11872
- } else {
12326
+ } else if (!options.wan3SmartDuration) {
11873
12327
  projectConfig.duration = options.duration;
11874
12328
  }
11875
12329
 
@@ -11922,27 +12376,27 @@ async function main() {
11922
12376
  if (options.seed !== null && options.seed !== undefined) {
11923
12377
  projectConfig.seed = options.seed;
11924
12378
  }
11925
- if (options.apiGenerateAudio !== null && isMiniMaxH3Model(options.model)) {
12379
+ if (options.apiGenerateAudio !== null && (isMiniMaxH3Model(options.model) || isWan3Video)) {
11926
12380
  projectConfig.generateAudio = options.apiGenerateAudio;
11927
12381
  }
11928
- if (Number.isFinite(steps) && !isHappyHorseVideo && !isMiniMaxH3Model(options.model)) {
12382
+ if (Number.isFinite(steps) && !isHappyHorseVideo && !isMiniMaxH3Model(options.model) && !isWan3Video) {
11929
12383
  // HappyHorse routes through the vendor-job path and ignores `steps`,
11930
12384
  // mirroring Seedance (whose model defaults already omit them). H3 has
11931
12385
  // fixed sampling parameters and should receive no overrides.
11932
12386
  projectConfig.steps = steps;
11933
12387
  }
11934
- if (guidance !== null && guidance !== undefined && !isMiniMaxH3Model(options.model)) {
12388
+ if (guidance !== null && guidance !== undefined && !isMiniMaxH3Model(options.model) && !isWan3Video) {
11935
12389
  projectConfig.guidance = guidance;
11936
12390
  }
11937
12391
  if (cliSet.sampler && isMiniMaxH3TurboModel(options.model)) {
11938
12392
  projectConfig.sampler = options.sampler;
11939
- } else if (modelDefaults?.sampler && !isMiniMaxH3Model(options.model)) {
12393
+ } else if (modelDefaults?.sampler && !isMiniMaxH3Model(options.model) && !isWan3Video) {
11940
12394
  projectConfig.sampler = modelDefaults.sampler;
11941
12395
  }
11942
- if (modelDefaults?.scheduler && !isMiniMaxH3Model(options.model)) {
12396
+ if (modelDefaults?.scheduler && !isMiniMaxH3Model(options.model) && !isWan3Video) {
11943
12397
  projectConfig.scheduler = modelDefaults.scheduler;
11944
12398
  }
11945
- if (modelDefaults?.shift !== null && modelDefaults?.shift !== undefined && !isMiniMaxH3Model(options.model)) {
12399
+ if (modelDefaults?.shift !== null && modelDefaults?.shift !== undefined && !isMiniMaxH3Model(options.model) && !isWan3Video) {
11946
12400
  projectConfig.shift = modelDefaults.shift;
11947
12401
  }
11948
12402
  if (options.videoControlNetName && !isSeedanceModel(options.model)) {
@@ -12378,7 +12832,7 @@ async function main() {
12378
12832
  if (options.videoStart !== null) renderInfo.videoStart = options.videoStart;
12379
12833
  }
12380
12834
  if (options.refVideos.length > 0) renderInfo.refVideos = options.refVideos;
12381
- if (options.apiGenerateAudio !== null && isMiniMaxH3Model(options.model)) {
12835
+ if (options.apiGenerateAudio !== null && (isMiniMaxH3Model(options.model) || isWan3ModelLocal(options.model))) {
12382
12836
  renderInfo.generateAudio = options.apiGenerateAudio;
12383
12837
  }
12384
12838
  if (options.videoControlNetName && !isSeedanceModel(options.model)) {
@@ -12610,7 +13064,7 @@ async function main() {
12610
13064
  if (options.videoStart !== null) output.videoStart = options.videoStart;
12611
13065
  }
12612
13066
  if (options.refVideos.length > 0) output.refVideos = options.refVideos;
12613
- if (options.apiGenerateAudio !== null && isMiniMaxH3Model(options.model)) {
13067
+ if (options.apiGenerateAudio !== null && (isMiniMaxH3Model(options.model) || isWan3ModelLocal(options.model))) {
12614
13068
  output.generateAudio = options.apiGenerateAudio;
12615
13069
  }
12616
13070
  if (options.videoControlNetName && !isSeedanceModel(options.model)) {