@sogni-ai/sogni-creative-agent-skill 3.43.0 → 3.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/sogni-agent.mjs CHANGED
@@ -28,6 +28,7 @@ import {
28
28
  semanticWorkloadAttribution,
29
29
  } from './attribution.mjs';
30
30
  import { assertSafeUrl, fetchSafeUrl } from './ssrf-guard.mjs';
31
+ import { SAM3_MODEL_ID, segmentPoint, segmentBox, validateSegmentationPrompts, segmentationConfig } from './sam-segmentation.mjs';
31
32
  import {
32
33
  INTERNAL_FLAG as UPDATE_CHECK_INTERNAL_FLAG,
33
34
  runForegroundCheck as runUpdateCheckForeground,
@@ -89,6 +90,10 @@ import {
89
90
  } from '@sogni-ai/sogni-intelligence-client/chatRun';
90
91
  import {
91
92
  buildImageEditExecutionControls,
93
+ normalizeGptImageModelAlias,
94
+ normalizeGptImageQuality,
95
+ getGptImageRequestOptions,
96
+ isGptImageModel,
92
97
  isKreaIdentityEditModel,
93
98
  SEEDANCE_R2V_REFERENCE_AUDIO_MAX_DURATION_SECONDS,
94
99
  prepareSeedanceV2VSourceVideo as prepareSharedSeedanceV2VSourceVideo
@@ -1201,6 +1206,7 @@ function computePromptHashSeed(opts) {
1201
1206
  musicCreativity: opts.musicCreativity ?? null,
1202
1207
  musicShift: opts.musicShift ?? null,
1203
1208
  targetResolution: opts.targetResolution ?? null,
1209
+ ...(opts.outputScale === 2 ? { outputScale: 2 } : {}),
1204
1210
  loras: opts.loras || [],
1205
1211
  loraStrengths: opts.loraStrengths || [],
1206
1212
  refImage: opts.refImage || '',
@@ -1286,6 +1292,17 @@ function parseIntegerValue(raw, flagName) {
1286
1292
  return num;
1287
1293
  }
1288
1294
 
1295
+ // MiniMax H3 2K delivery (--output-scale 2 / --2k): the clip renders on the
1296
+ // requested canvas and is delivered at twice its width and height.
1297
+ function parseOutputScaleValue(raw, flagName) {
1298
+ const normalized = String(raw ?? '').trim().toLowerCase();
1299
+ if (normalized === '1' || normalized === '2') return Number(normalized);
1300
+ fatalCliError(`${flagName} must be 1 or 2 (2 delivers MiniMax H3 2K output).`, {
1301
+ code: 'INVALID_ARGUMENT',
1302
+ details: { flag: flagName, value: raw }
1303
+ });
1304
+ }
1305
+
1289
1306
  function parsePositiveIntegerValue(raw, flagName, min = 1, max = Infinity) {
1290
1307
  const num = parseIntegerValue(raw, flagName);
1291
1308
  if (num < min) {
@@ -1525,6 +1542,19 @@ async function probeVideoUpscaleSource(buffer, sourceLabel) {
1525
1542
  // restating a limit.
1526
1543
  const VIDEO_UPSCALE_TOO_LONG_PATTERN = /This video is too long to upscale\b.*$/s;
1527
1544
 
1545
+ const MINIMAX_H3_OUTPUT_SCALE_UNAVAILABLE_MESSAGE = 'MiniMax H3 2K output is not available right now';
1546
+
1547
+ // Only Comfy workers 1.0.212+ render 2K; the socket refuses before reserving
1548
+ // funds when none is connected, so say so and point at the standard size.
1549
+ function annotateMiniMaxH3OutputScaleError(error) {
1550
+ const message = String(error?.message || error?.originalError?.message || '');
1551
+ if (error && typeof error === 'object' && message.includes(MINIMAX_H3_OUTPUT_SCALE_UNAVAILABLE_MESSAGE)) {
1552
+ if (!error.code || error.code === 'PROJECT_ERROR') error.code = 'MODEL_UNAVAILABLE';
1553
+ error.hint = 'Workers that render MiniMax H3 2K are not online right now, so nothing was charged. Retry without --2k for the standard size, or try again later.';
1554
+ }
1555
+ return error;
1556
+ }
1557
+
1528
1558
  function annotateVideoUpscaleError(error) {
1529
1559
  const message = String(error?.message || error?.originalError?.message || '');
1530
1560
  if (error && typeof error === 'object' && message.includes(FLASHVSR_UNAVAILABLE_MESSAGE)) {
@@ -1766,8 +1796,20 @@ function isWanAnimateVideoModelId(modelId) {
1766
1796
  }
1767
1797
 
1768
1798
  function isGptImage2ModelSelection(modelId) {
1769
- const normalized = String(modelId || '').trim().toLowerCase();
1770
- return ['gpt-image-2', 'gptimage2', 'gpt-image', 'gpt_image_2'].includes(normalized);
1799
+ return isGptImageModel(normalizeGptImageModelAlias(modelId));
1800
+ }
1801
+
1802
+ function imageOptionsFromCli() {
1803
+ if (!isGptImage2ModelSelection(options.model)) return {};
1804
+ return {
1805
+ ...getGptImageRequestOptions({
1806
+ gptImageBackground: options.imageBackground ?? undefined,
1807
+ gptImageOutputCompression: options.imageOutputCompression ?? undefined,
1808
+ outputFormat: options.outputFormat ?? 'png'
1809
+ }, options.model),
1810
+ gptImageQuality: normalizeGptImageQuality(options.imageQuality ??
1811
+ (options.quality === 'pro' ? 'high' : options.quality === 'fast' ? 'low' : 'medium'), options.model)
1812
+ };
1771
1813
  }
1772
1814
 
1773
1815
  const SEEDANCE_TASK_TYPES = new Set(['reference', 'edit', 'extend']);
@@ -2834,6 +2876,10 @@ const options = {
2834
2876
  steps: null,
2835
2877
  guidance: null,
2836
2878
  outputFormat: null,
2879
+ imageQuality: null,
2880
+ imageBackground: null,
2881
+ imageOutputCompression: null,
2882
+ imageMask: null,
2837
2883
  sampler: null,
2838
2884
  scheduler: null,
2839
2885
  loras: [],
@@ -2871,6 +2917,7 @@ const options = {
2871
2917
  duration: 5,
2872
2918
  frames: null,
2873
2919
  targetResolution: null, // Short-side target for video, preserving aspect ratio
2920
+ outputScale: 1, // MiniMax H3 delivery scale: 2 = 2K, twice the requested canvas
2874
2921
  autoResizeVideoAssets: null,
2875
2922
  estimateVideoCost: false,
2876
2923
  showBalance: false,
@@ -2893,6 +2940,10 @@ const options = {
2893
2940
  outpaintAspectRatio: null, // Optional target aspect ratio for outpaint canvas growth
2894
2941
  contextImages: [], // Context images for image editing
2895
2942
  upscaleImage: null, // Source image for promptless RTX VSR upscaling
2943
+ segmentImage: null,
2944
+ segmentPoints: [],
2945
+ segmentBoxes: [],
2946
+ segmentText: null,
2896
2947
  upscaleScale: 2,
2897
2948
  upscaleTargetLongestEdge: null,
2898
2949
  upscaleVideo: null, // Source video for promptless FlashVSR upscaling
@@ -3062,6 +3113,7 @@ const cliSet = {
3062
3113
  duration: false,
3063
3114
  frames: false,
3064
3115
  targetResolution: false,
3116
+ outputScale: false,
3065
3117
  autoResizeVideoAssets: false,
3066
3118
  angles360Video: false,
3067
3119
  videoModel: false,
@@ -3186,6 +3238,14 @@ for (let i = 0; i < args.length; i++) {
3186
3238
  i++;
3187
3239
  options.outputFormat = raw;
3188
3240
  cliSet.outputFormat = true;
3241
+ } else if (arg === '--image-quality') {
3242
+ options.imageQuality = requireFlagValue(args, i++, arg);
3243
+ } else if (arg === '--image-background') {
3244
+ options.imageBackground = requireFlagValue(args, i++, arg);
3245
+ } else if (arg === '--image-output-compression') {
3246
+ options.imageOutputCompression = parseNumberValue(requireFlagValue(args, i++, arg), arg);
3247
+ } else if (arg === '--image-mask') {
3248
+ options.imageMask = requireFlagValue(args, i++, arg);
3189
3249
  } else if (arg === '--sampler') {
3190
3250
  const raw = requireFlagValue(args, i, arg);
3191
3251
  i++;
@@ -3397,6 +3457,14 @@ for (let i = 0; i < args.length; i++) {
3397
3457
  i++;
3398
3458
  options.targetResolution = parsePositiveIntegerValue(raw, arg);
3399
3459
  cliSet.targetResolution = true;
3460
+ } else if (arg === '--output-scale') {
3461
+ const raw = requireFlagValue(args, i, arg);
3462
+ i++;
3463
+ options.outputScale = parseOutputScaleValue(raw, arg);
3464
+ cliSet.outputScale = true;
3465
+ } else if (arg === '--2k') {
3466
+ options.outputScale = 2;
3467
+ cliSet.outputScale = true;
3400
3468
  } else if (arg === '--auto-resize-assets') {
3401
3469
  options.autoResizeVideoAssets = true;
3402
3470
  cliSet.autoResizeVideoAssets = true;
@@ -3466,6 +3534,16 @@ for (let i = 0; i < args.length; i++) {
3466
3534
  i++;
3467
3535
  options.contextImages.push(raw);
3468
3536
  cliSet.context = true;
3537
+ } else if (arg === '--segment') {
3538
+ options.segmentImage = expandHomePath(requireFlagValue(args, i++, arg));
3539
+ } else if (arg === '--segment-point' || arg === '--segment-exclude') {
3540
+ try { options.segmentPoints.push(segmentPoint(requireFlagValue(args, i++, arg), arg === '--segment-point' ? 'positive' : 'negative')); }
3541
+ catch (error) { fatalCliError(error.message, { code: 'INVALID_ARGUMENT' }); }
3542
+ } else if (arg === '--segment-box') {
3543
+ try { options.segmentBoxes.push(segmentBox(requireFlagValue(args, i++, arg))); }
3544
+ catch (error) { fatalCliError(error.message, { code: 'INVALID_ARGUMENT' }); }
3545
+ } else if (arg === '--segment-text') {
3546
+ options.segmentText = requireFlagValue(args, i++, arg);
3469
3547
  } else if (arg === '--upscale') {
3470
3548
  const raw = expandHomePath(requireFlagValue(args, i, arg));
3471
3549
  i++;
@@ -4119,7 +4197,11 @@ Image Options:
4119
4197
  --distance <key> close-up|medium|wide
4120
4198
  --angle-strength <n> LoRA strength for multiple_angles (default: 0.9)
4121
4199
  --angle-description <text> Optional subject description
4122
- --output-format <f> Image output format: png|jpg (webp for gpt-image-2)
4200
+ --output-format <f> Image output format: png|jpg (webp for GPT Image)
4201
+ --image-quality <q> GPT Image: low|medium|high; 2.5 also xhigh|max
4202
+ --image-background <b> auto|opaque; 2.5 also transparent (PNG/WebP)
4203
+ --image-output-compression <n> JPEG/WebP compression, integer 0–100
4204
+ --image-mask <path|url> PNG alpha mask of first --context image, same size
4123
4205
  --sampler <name> Sampler (images/music; H3 LightX2V Turbo: euler|er_sde|sa_solver; FastH3: euler)
4124
4206
  --scheduler <name> Scheduler (model-dependent)
4125
4207
  --lora <id> Image LoRA id (repeatable; order is significant)
@@ -4128,6 +4210,11 @@ Image Options:
4128
4210
  --lora-strengths <n> Comma-separated LoRA strengths
4129
4211
  -c, --context <path> Context image for editing (can use multiple)
4130
4212
  --last-image Use last generated image as context
4213
+ --segment <path|url> SAM 3 object selection; returns one original-size PNG mask
4214
+ --segment-point <x,y> Include point, normalized 0–1; repeat to refine
4215
+ --segment-exclude <x,y> Exclude point, normalized 0–1; repeat to refine
4216
+ --segment-box <x0,y0,x1,y1> Object bounds, normalized 0–1
4217
+ --segment-text <text> Object description; combine with boxes, never points
4131
4218
  --upscale <path|url> Promptless NVIDIA RTX VSR upscale, up to 16K (one source image)
4132
4219
  --upscale-scale <n> Enlarge longest edge by 2, 3, or 4 (default: 2)
4133
4220
  --target-longest-edge <px> Explicit output longest edge, up to 15360 (overrides scale)
@@ -4170,6 +4257,9 @@ Video Options:
4170
4257
  --duration <sec> Duration in seconds (default: 5); Seedance 2.5 edit requires @Video1's source duration
4171
4258
  --frames <num> Override total frames (optional)
4172
4259
  --target-resolution <px> Short-side target that preserves aspect ratio (Seedance 2.5: 480 or 720)
4260
+ --output-scale <1|2> MiniMax H3 only: 2 delivers 2K, twice the requested canvas (1344x768 -> 2688x1536),
4261
+ same length and audio; +10 Spark/s at 544/768p class, +6 at 480p (workers 1.0.212+)
4262
+ --2k Shorthand for --output-scale 2
4173
4263
  --auto-resize-assets Auto-resize video reference assets (default)
4174
4264
  --no-auto-resize-assets Disable auto-resize for video assets
4175
4265
  --estimate-video-cost Estimate video cost and exit
@@ -4346,6 +4436,8 @@ Personas (named people with reference photos):
4346
4436
  Image Models:
4347
4437
  z_image_turbo_bf16 Fast, general purpose (default)
4348
4438
  gpt-image-2 OpenAI GPT Image 2 text-to-image and edit (up to 16 context images)
4439
+ gpt-image-2.5-sunburst GPT Image 2.5 Sunburst: edits, masks, 16 references, transparency
4440
+ gpt-image-2.5-flare GPT Image 2.5 Flare: edits, masks, 16 references, transparency
4349
4441
  krea2_turbo_fp8_scaled Krea 2 Turbo text-to-image
4350
4442
  dark_beast_krea2_fp8 Dark Beast Krea 2 text-to-image
4351
4443
  krea2_identity_edit_v1_2 Krea 2 Identity Edit LoRA (up to 2 context images)
@@ -4818,6 +4910,9 @@ if (options.multiAngle) {
4818
4910
  }
4819
4911
  }
4820
4912
 
4913
+ if (!options.video && !options.music && options.model) {
4914
+ options.model = normalizeGptImageModelAlias(options.model);
4915
+ }
4821
4916
  if (options.outputFormat) {
4822
4917
  const normalized = options.outputFormat.toLowerCase();
4823
4918
  options.outputFormat = normalized === 'jpeg' ? 'jpg' : normalized;
@@ -4843,6 +4938,24 @@ if (options.outputFormat) {
4843
4938
  }
4844
4939
  }
4845
4940
 
4941
+ if (options.imageQuality !== null || options.imageBackground !== null || options.imageOutputCompression !== null || options.imageMask !== null) {
4942
+ try {
4943
+ if (options.video || options.music || !isGptImage2ModelSelection(options.model)) {
4944
+ throw new Error('Image quality, background, compression and mask options require a GPT Image model.');
4945
+ }
4946
+ // Provider-chosen (auto) quality is never used.
4947
+ if (options.imageQuality !== null && !['low', 'medium', 'high', 'xhigh', 'max'].includes(options.imageQuality)) {
4948
+ throw new Error('--image-quality must be low, medium, high, xhigh, or max.');
4949
+ }
4950
+ imageOptionsFromCli();
4951
+ if (options.imageMask && options.contextImages.length === 0) {
4952
+ throw new Error('--image-mask requires a first --context source image.');
4953
+ }
4954
+ } catch (error) {
4955
+ fatalCliError(error.message, { code: 'INVALID_ARGUMENT' });
4956
+ }
4957
+ }
4958
+
4846
4959
  if (options.video) {
4847
4960
  options.model = resolveSkillVideoModelAlias(options.model);
4848
4961
  if (options.model === LTX23_10EROS_MODEL_ID && !options.noFilter) {
@@ -5348,6 +5461,10 @@ if (options.music) {
5348
5461
  if (!cliSet.timeout && !timeoutFromConfig && options.timeout === 30000) {
5349
5462
  options.timeout = 1800000; // 30 min for queued video work
5350
5463
  }
5464
+ } else if (options.segmentImage) {
5465
+ if (options.model && options.model !== SAM3_MODEL_ID) fatalCliError(`--segment requires model ${SAM3_MODEL_ID}.`, { code: 'INVALID_ARGUMENT' });
5466
+ options.model = SAM3_MODEL_ID;
5467
+ if (!cliSet.timeout && !timeoutFromConfig) options.timeout = 180000;
5351
5468
  } else if (options.upscaleImage) {
5352
5469
  if (options.model && options.model !== RTX_VSR_MODEL_ID) {
5353
5470
  fatalCliError(`--upscale requires model ${RTX_VSR_MODEL_ID}.`, {
@@ -5377,6 +5494,17 @@ if (options.music) {
5377
5494
  options.model = options.model || openclawConfig?.defaultImageModel || 'z_image_turbo_bf16';
5378
5495
  }
5379
5496
 
5497
+ if (!options.video && !options.music && isGptImage2ModelSelection(options.model)) {
5498
+ options.model = normalizeGptImageModelAlias(options.model);
5499
+ if (!cliSet.width && !widthFromConfig && !widthFromPrompt) options.width = 1024;
5500
+ if (!cliSet.height && !heightFromConfig && !heightFromPrompt) options.height = 1024;
5501
+ const { width, height } = options;
5502
+ if (width % 16 || height % 16 || Math.max(width, height) > 3840 || Math.max(width, height) / Math.min(width, height) > 3 || width * height < 655360 || width * height > 8294400) {
5503
+ fatalCliError('GPT Image dimensions must be multiples of 16, at most 3840 per edge, within 3:1 and 655360–8294400 pixels.', { code: 'INVALID_ARGUMENT' });
5504
+ }
5505
+ if (!cliSet.timeout && !timeoutFromConfig) options.timeout = 600000;
5506
+ }
5507
+
5380
5508
  if (options.music) {
5381
5509
  const musicDefaults = getMusicModelDefaults(options.model);
5382
5510
  if (options.duration < MUSIC_DURATION_LIMITS.min || options.duration > MUSIC_DURATION_LIMITS.max) {
@@ -5473,6 +5601,7 @@ const commandUsesGenerationSeed = !options.apiChat &&
5473
5601
  !options.remixAudio &&
5474
5602
  !options.upscaleImage &&
5475
5603
  !options.upscaleVideo &&
5604
+ !options.segmentImage &&
5476
5605
  !options.listMedia &&
5477
5606
  !options.memoryAction &&
5478
5607
  !options.personalityAction &&
@@ -5511,7 +5640,7 @@ const wan3HasMediaInput = isWan3ModelLocal(options.model) && Boolean(
5511
5640
  || options.wan3ReferenceFileUrl
5512
5641
  || options.wan3ReferenceLinkUrl
5513
5642
  );
5514
- if (!options.prompt && !wan3HasMediaInput && !options.upscaleImage && !options.upscaleVideo && !options.apiChat && !apiWorkflowUtilityAction && !apiWorkflowStartAction && !apiModelUtilityAction && !liveModelUtilityAction && !loraCatalogUtilityAction && !apiReplayUtilityAction && !contractUtilityAction && !storyboardPlanUtilityAction && !options.estimateVideoCost && !options.multiAngle && !options.showBalance && !options.showVersion && !options.doctor && !options.extractLastFrame && !options.extractFirstFrame && !options.extractFrameAt && !options.trimVideo && !options.verifyVideo && !options.concatVideos && !options.sourceReelDir && !options.remixAudio && !options.listMedia && !options.memoryAction && !options.personalityAction && !personaUtilityAction) {
5643
+ if (!options.prompt && !wan3HasMediaInput && !options.segmentImage && !options.upscaleImage && !options.upscaleVideo && !options.apiChat && !apiWorkflowUtilityAction && !apiWorkflowStartAction && !apiModelUtilityAction && !liveModelUtilityAction && !loraCatalogUtilityAction && !apiReplayUtilityAction && !contractUtilityAction && !storyboardPlanUtilityAction && !options.estimateVideoCost && !options.multiAngle && !options.showBalance && !options.showVersion && !options.doctor && !options.extractLastFrame && !options.extractFirstFrame && !options.extractFrameAt && !options.trimVideo && !options.verifyVideo && !options.concatVideos && !options.sourceReelDir && !options.remixAudio && !options.listMedia && !options.memoryAction && !options.personalityAction && !personaUtilityAction) {
5515
5644
  fatalCliError('No prompt provided. Use --help for usage.', { code: 'INVALID_ARGUMENT' });
5516
5645
  }
5517
5646
 
@@ -5526,6 +5655,17 @@ if (options.apiChat && !options.prompt && getApiModeMediaReferences().length ===
5526
5655
  fatalCliError('--api-chat requires a prompt or media reference for planning.', { code: 'INVALID_ARGUMENT' });
5527
5656
  }
5528
5657
 
5658
+ if (options.segmentImage) {
5659
+ if (options.prompt || options.video || options.music || options.upscaleImage || options.upscaleVideo || options.photobooth || options.contextImages.length || options.refImage || options.refImageEnd
5660
+ || options.apiChat || options.apiWorkflowAction || options.multiAngle || options.noFilter || options.count !== 1 || cliSet.width || cliSet.height) {
5661
+ fatalCliError('--segment requires one original image with selection points or --segment-text; omit generation prompts, resize, other generation modes and --no-filter.', { code: 'INVALID_ARGUMENT' });
5662
+ }
5663
+ try { validateSegmentationPrompts(options.segmentPoints, options.segmentText, options.segmentBoxes); }
5664
+ catch (error) { fatalCliError(error.message, { code: 'INVALID_ARGUMENT' }); }
5665
+ } else if (options.segmentPoints.length || options.segmentBoxes.length || options.segmentText !== null) {
5666
+ fatalCliError('Selection prompts require --segment <path|url>.', { code: 'INVALID_ARGUMENT' });
5667
+ }
5668
+
5529
5669
  if (options.upscaleImage) {
5530
5670
  if (options.prompt) {
5531
5671
  fatalCliError('--upscale is promptless and does not accept a prompt.', { code: 'INVALID_ARGUMENT' });
@@ -5596,8 +5736,8 @@ if (options.legacyWan3TaskType !== null) {
5596
5736
  );
5597
5737
  }
5598
5738
 
5599
- if (!options.video && !options.apiChat && !options.apiWorkflowAction && (options.refAudio || options.refVideo || options.refMask || options.referenceAudioIdentity || options.voicePersonaName || options.videoWorkflow || options.seedanceTaskType || 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)) {
5600
- fatalCliError('Video-only options (--workflow/--seedance-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.', {
5739
+ if (!options.video && !options.apiChat && !options.apiWorkflowAction && (options.refAudio || options.refVideo || options.refMask || options.referenceAudioIdentity || options.voicePersonaName || options.videoWorkflow || options.seedanceTaskType || options.wan3SmartDuration || options.wan3ReferenceFileUrl || options.wan3ReferenceLinkUrl || options.wan3Watermark || cliSet.wan3Ratio || options.frames || options.targetResolution || cliSet.outputScale || options.audioStart !== null || options.audioDuration !== null || options.videoStart !== null || options.outpaintPosition || options.outpaintAspectRatio)) {
5740
+ fatalCliError('Video-only options (--workflow/--seedance-task-type/--wan3-ratio/--smart-duration/--reference-file-url/--reference-link-url/--watermark/--frames/--target-resolution/--output-scale/--2k/--ref-audio/--ref-video/--mask/--outpaint-position/--reference-audio-identity/--voice-persona) require --video.', {
5601
5741
  code: 'INVALID_ARGUMENT'
5602
5742
  });
5603
5743
  }
@@ -5747,6 +5887,15 @@ if (options.video) {
5747
5887
  details: { targetResolution: options.targetResolution }
5748
5888
  });
5749
5889
  }
5890
+ // 2K delivery exists only on MiniMax H3 (Comfy worker 1.0.212+); the SDK
5891
+ // rejects it elsewhere, so refuse here with the model named instead.
5892
+ if (cliSet.outputScale && options.outputScale === 2 && !isMiniMaxH3Model(options.model)) {
5893
+ fatalCliError(`--output-scale 2 (--2k) is a MiniMax H3 option; ${options.model} is delivered at its requested size.`, {
5894
+ code: 'INVALID_ARGUMENT',
5895
+ details: { flag: '--output-scale', model: options.model },
5896
+ hint: 'Use a MiniMax H3 model (for example -m minimax-h3-fasth3-turbo --2k), or drop --2k.'
5897
+ });
5898
+ }
5750
5899
  const seedanceWorkflows = isSeedance25Video
5751
5900
  ? ['t2v', 'ia2v', 'a2v', 'v2v']
5752
5901
  : ['t2v', 'ia2v', 'v2v'];
@@ -7935,6 +8084,7 @@ function buildGeneratedKeyframeVideoWorkflowInput() {
7935
8084
  }
7936
8085
 
7937
8086
  function storyboardWorkflowImageQualityFromCli() {
8087
+ if (options.imageQuality) return options.imageQuality;
7938
8088
  if (!cliSet.quality || !options.quality) return undefined;
7939
8089
  if (options.quality === 'pro') return 'high';
7940
8090
  if (options.quality === 'fast') return 'low';
@@ -11691,7 +11841,8 @@ function buildVideoEstimateParams({ tokenType, steps }) {
11691
11841
  tokenType,
11692
11842
  ...(Number.isFinite(steps) && steps > 0 ? { steps } : {}),
11693
11843
  ...(options.frames ? { frames: options.frames } : { duration: options.duration }),
11694
- ...(referenceImageCount !== undefined ? { referenceImageCount } : {})
11844
+ ...(referenceImageCount !== undefined ? { referenceImageCount } : {}),
11845
+ ...(options.outputScale === 2 && isMiniMaxH3Model(options.model) ? { outputScale: 2 } : {})
11695
11846
  };
11696
11847
 
11697
11848
  if ((isSeedanceVideo || isWan3Video) && options.refVideo) {
@@ -12562,6 +12713,7 @@ async function main() {
12562
12713
  steps,
12563
12714
  tokenType: options.tokenType || 'spark',
12564
12715
  count: options.count,
12716
+ ...(options.outputScale === 2 ? { outputScale: 2 } : {}),
12565
12717
  estimate
12566
12718
  }));
12567
12719
  } else {
@@ -13192,6 +13344,18 @@ async function main() {
13192
13344
  if (options.apiGenerateAudio !== null && (isMiniMaxH3Model(options.model) || isWan3Video)) {
13193
13345
  projectConfig.generateAudio = options.apiGenerateAudio;
13194
13346
  }
13347
+ if (options.outputScale === 2 && isMiniMaxH3Model(options.model)) {
13348
+ // 2K delivery: same canvas, frames and audio; the worker enlarges the
13349
+ // finished render 2x. Sent only when asked, so plain requests are unchanged.
13350
+ projectConfig.outputScale = 2;
13351
+ if (!options.quiet) {
13352
+ console.error(
13353
+ `MiniMax H3 2K output: delivered at ${projectConfig.width * 2}x${projectConfig.height * 2} ` +
13354
+ `(twice the requested ${projectConfig.width}x${projectConfig.height} canvas), same length and audio; ` +
13355
+ 'adds 10 Spark per second at 544/768p-class sizes (6 at 480p).'
13356
+ );
13357
+ }
13358
+ }
13195
13359
  if (Number.isFinite(steps) && !isHappyHorseVideo && !isMiniMaxH3Model(options.model) && !isWan3Video) {
13196
13360
  // HappyHorse routes through the vendor-job path and ignores `steps`,
13197
13361
  // mirroring Seedance (whose model defaults already omit them). H3 has
@@ -13361,6 +13525,14 @@ async function main() {
13361
13525
  if (upscaleVideoResult?.error || upscaleVideoResult?.message) {
13362
13526
  throw annotateVideoUpscaleError(buildProjectResultError(upscaleVideoResult));
13363
13527
  }
13528
+ } else if (options.segmentImage) {
13529
+ log('Selecting the object with SAM 3...');
13530
+ const bytes = await fetchMediaBuffer(options.segmentImage);
13531
+ const dimensions = getImageDimensionsFromBuffer(bytes);
13532
+ const config = segmentationConfig(bytes, dimensions, options.segmentPoints, options.segmentText, options.tokenType || 'spark', options.segmentBoxes);
13533
+ options.width = config.width; options.height = config.height; options.outputFormat = 'png';
13534
+ const result = trackProjectResult(await client.createImageProject(withBillingMode(config)));
13535
+ if (result?.error || result?.message) throw buildProjectResultError(result);
13364
13536
  } else if (options.upscaleImage) {
13365
13537
  log(`Upscaling with ${RTX_VSR_MODEL_ID}...`);
13366
13538
  const sourceBuffer = await fetchMediaBuffer(options.upscaleImage);
@@ -13459,6 +13631,8 @@ async function main() {
13459
13631
  if (gptImageQuality) {
13460
13632
  editConfig.gptImageQuality = gptImageQuality;
13461
13633
  }
13634
+ Object.assign(editConfig, imageOptionsFromCli());
13635
+ if (options.imageMask) editConfig.gptImageMask = await fetchMediaBuffer(options.imageMask);
13462
13636
  if (options.loras.length > 0) {
13463
13637
  editConfig.loras = options.loras;
13464
13638
  }
@@ -13574,6 +13748,7 @@ async function main() {
13574
13748
  if (gptImageQuality) {
13575
13749
  projectConfig.gptImageQuality = gptImageQuality;
13576
13750
  }
13751
+ Object.assign(projectConfig, imageOptionsFromCli());
13577
13752
  if (options.sampler) {
13578
13753
  projectConfig.sampler = options.sampler;
13579
13754
  }
@@ -13674,6 +13849,7 @@ async function main() {
13674
13849
  renderInfo.duration = options.frames ? options.frames / options.fps : options.duration;
13675
13850
  if (options.frames) renderInfo.frames = options.frames;
13676
13851
  if (options.targetResolution) renderInfo.targetResolution = options.targetResolution;
13852
+ if (options.outputScale === 2) renderInfo.outputScale = 2;
13677
13853
  if (options.autoResizeVideoAssets !== null) {
13678
13854
  renderInfo.autoResizeVideoAssets = options.autoResizeVideoAssets;
13679
13855
  }
@@ -13769,6 +13945,7 @@ async function main() {
13769
13945
  else if (options.duration) projectConfig2.duration = options.duration;
13770
13946
  if (Number.isFinite(steps2)) projectConfig2.steps = steps2;
13771
13947
  if (guidance2 !== null && guidance2 !== undefined) projectConfig2.guidance = guidance2;
13948
+ if (options.outputScale === 2 && isMiniMaxH3Model(options.model)) projectConfig2.outputScale = 2;
13772
13949
 
13773
13950
  // Create a new client for second clip to avoid event conflicts
13774
13951
  const creds = loadCredentials();
@@ -13912,6 +14089,7 @@ async function main() {
13912
14089
  output.duration = options.frames ? options.frames / options.fps : options.duration;
13913
14090
  if (options.frames) output.frames = options.frames;
13914
14091
  if (options.targetResolution) output.targetResolution = options.targetResolution;
14092
+ if (options.outputScale === 2) output.outputScale = 2;
13915
14093
  output.strictSize = options.strictSize || false;
13916
14094
  if (options.autoResizeVideoAssets !== null) {
13917
14095
  output.autoResizeVideoAssets = options.autoResizeVideoAssets;
@@ -13983,6 +14161,7 @@ async function main() {
13983
14161
  } catch (error) {
13984
14162
  // A FlashVSR refusal can also arrive as a project event after submission.
13985
14163
  if (options.upscaleVideo) annotateVideoUpscaleError(error);
14164
+ if (options.video && options.outputScale === 2) annotateMiniMaxH3OutputScaleError(error);
13986
14165
  // Token auto-fallback: if using auto mode and got insufficient balance, retry with the other token
13987
14166
  const isBalanceError = isStructuredInsufficientBalanceError(error);
13988
14167
  if (_allowAutoTokenFallback && isBalanceError && options.tokenType === 'spark') {
package/version.mjs CHANGED
@@ -1 +1 @@
1
- export const PACKAGE_VERSION = '3.43.0';
1
+ export const PACKAGE_VERSION = '3.47.0';