@sogni-ai/sogni-creative-agent-skill 3.47.0 → 3.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/sogni-creative-agent-skill/SKILL.md +27 -2
- package/.agents/skills/sogni-creative-agent-skill/references/interactive-worlds.md +81 -3
- package/.agents/skills/sogni-creative-agent-skill/references/models.md +175 -51
- package/.agents/skills/sogni-creative-agent-skill/references/video-prompting.md +22 -12
- package/.claude-plugin/plugin.json +2 -2
- package/.codex-plugin/plugin.json +3 -3
- package/CHANGELOG.md +28 -0
- package/README.md +35 -14
- package/SKILL.md +14 -14
- package/desktop-extension/README.md +1 -1
- package/desktop-extension/manifest.json +1 -1
- package/generated/creative-agent-runtime.mjs +6 -8
- package/llm.txt +16 -4
- package/media-utilities.mjs +131 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +6 -5
- package/plugin-skills/sogni-creative-agent/SKILL.md +19 -1
- package/references/interactive-worlds.md +9 -3
- package/references/models.md +175 -51
- package/references/video-prompting.md +22 -12
- package/scripts/sync-hermes-skill.mjs +1 -0
- package/skill-package.json +1 -1
- package/skills/sogni-creative-agent/SKILL.md +1 -1
- package/sogni-agent.mjs +407 -114
- package/version.mjs +1 -1
package/sogni-agent.mjs
CHANGED
|
@@ -28,6 +28,10 @@ import {
|
|
|
28
28
|
semanticWorkloadAttribution,
|
|
29
29
|
} from './attribution.mjs';
|
|
30
30
|
import { assertSafeUrl, fetchSafeUrl } from './ssrf-guard.mjs';
|
|
31
|
+
import {
|
|
32
|
+
MESH_FLAGS, SPEECH_VALUE_FLAGS, MUSIC3_MODEL_ID, MUSIC3_DEFAULTS, SPEECH_REFERENCE_SECONDS,
|
|
33
|
+
prepareMediaUtilityOptions, imageUtilityConfig, speechConfig, utilityResultMetadata, validateGlb
|
|
34
|
+
} from './media-utilities.mjs';
|
|
31
35
|
import { SAM3_MODEL_ID, segmentPoint, segmentBox, validateSegmentationPrompts, segmentationConfig } from './sam-segmentation.mjs';
|
|
32
36
|
import {
|
|
33
37
|
INTERNAL_FLAG as UPDATE_CHECK_INTERNAL_FLAG,
|
|
@@ -96,6 +100,10 @@ import {
|
|
|
96
100
|
isGptImageModel,
|
|
97
101
|
isKreaIdentityEditModel,
|
|
98
102
|
SEEDANCE_R2V_REFERENCE_AUDIO_MAX_DURATION_SECONDS,
|
|
103
|
+
calculateVideoDimensions as calculateSharedVideoDimensions,
|
|
104
|
+
isMinimaxH3TwoStageModelId,
|
|
105
|
+
minimaxH3TwoStageCanvasShortEdge,
|
|
106
|
+
minimaxH3TwoStageDeliveredSize,
|
|
99
107
|
prepareSeedanceV2VSourceVideo as prepareSharedSeedanceV2VSourceVideo
|
|
100
108
|
} from '@sogni-ai/sogni-intelligence-client/media';
|
|
101
109
|
import {
|
|
@@ -387,6 +395,7 @@ const SOCKET_EVENT_SUBSCRIPTIONS = Object.freeze({
|
|
|
387
395
|
modelAvailability: false
|
|
388
396
|
});
|
|
389
397
|
const MUSIC_MODEL_IDS = {
|
|
398
|
+
music3: MUSIC3_MODEL_ID,
|
|
390
399
|
turbo: 'ace_step_1.5_xl_turbo',
|
|
391
400
|
speed: 'ace_step_1.5_xl_turbo',
|
|
392
401
|
fast: 'ace_step_1.5_xl_turbo',
|
|
@@ -395,6 +404,7 @@ const MUSIC_MODEL_IDS = {
|
|
|
395
404
|
lyric: 'ace_step_1.5_xl_sft'
|
|
396
405
|
};
|
|
397
406
|
const MUSIC_MODEL_DEFAULTS = {
|
|
407
|
+
[MUSIC3_MODEL_ID]: MUSIC3_DEFAULTS,
|
|
398
408
|
'ace_step_1.5_xl_turbo': {
|
|
399
409
|
steps: { min: 4, max: 16, default: 8 },
|
|
400
410
|
shift: { min: 1, max: 6, default: 3 },
|
|
@@ -1186,7 +1196,12 @@ function computePromptHashSeed(opts) {
|
|
|
1186
1196
|
const payload = {
|
|
1187
1197
|
prompt: opts.prompt || '',
|
|
1188
1198
|
model: opts.model || '',
|
|
1189
|
-
workflow: opts.video ? opts.videoWorkflow : opts.music ? 'music' : 'image',
|
|
1199
|
+
workflow: opts.video ? opts.videoWorkflow : opts.speech ? 'speech' : opts.imageTo3d ? 'model' : opts.music ? 'music' : 'image',
|
|
1200
|
+
...(opts.speech ? {
|
|
1201
|
+
speechMode: opts.speechMode || '', speechVoice: opts.speechVoice || '',
|
|
1202
|
+
voiceDescription: opts.voiceDescription || '', voiceReference: opts.voiceReference || '',
|
|
1203
|
+
voiceTranscript: opts.voiceTranscript || '', speechCreativity: opts.speechCreativity ?? null
|
|
1204
|
+
} : {}),
|
|
1190
1205
|
width: opts.width,
|
|
1191
1206
|
height: opts.height,
|
|
1192
1207
|
azimuth: opts.azimuth || '',
|
|
@@ -1206,7 +1221,6 @@ function computePromptHashSeed(opts) {
|
|
|
1206
1221
|
musicCreativity: opts.musicCreativity ?? null,
|
|
1207
1222
|
musicShift: opts.musicShift ?? null,
|
|
1208
1223
|
targetResolution: opts.targetResolution ?? null,
|
|
1209
|
-
...(opts.outputScale === 2 ? { outputScale: 2 } : {}),
|
|
1210
1224
|
loras: opts.loras || [],
|
|
1211
1225
|
loraStrengths: opts.loraStrengths || [],
|
|
1212
1226
|
refImage: opts.refImage || '',
|
|
@@ -1292,15 +1306,13 @@ function parseIntegerValue(raw, flagName) {
|
|
|
1292
1306
|
return num;
|
|
1293
1307
|
}
|
|
1294
1308
|
|
|
1295
|
-
//
|
|
1296
|
-
//
|
|
1297
|
-
|
|
1309
|
+
// --target-resolution: a short side in pixels ("1080p" means 1080). "2K" names
|
|
1310
|
+
// the MiniMax H3 FastH3 Two-Stage 2K delivered class, 1440 in the Intelligence
|
|
1311
|
+
// Client's size table, and is refused for every other model once it resolves.
|
|
1312
|
+
function parseTargetResolutionValue(raw, flagName) {
|
|
1298
1313
|
const normalized = String(raw ?? '').trim().toLowerCase();
|
|
1299
|
-
if (normalized === '
|
|
1300
|
-
|
|
1301
|
-
code: 'INVALID_ARGUMENT',
|
|
1302
|
-
details: { flag: flagName, value: raw }
|
|
1303
|
-
});
|
|
1314
|
+
if (normalized === '2k') return { value: 1440, spelled2K: true };
|
|
1315
|
+
return { value: parsePositiveIntegerValue(normalized.replace(/p$/, ''), flagName), spelled2K: false };
|
|
1304
1316
|
}
|
|
1305
1317
|
|
|
1306
1318
|
function parsePositiveIntegerValue(raw, flagName, min = 1, max = Infinity) {
|
|
@@ -1542,19 +1554,6 @@ async function probeVideoUpscaleSource(buffer, sourceLabel) {
|
|
|
1542
1554
|
// restating a limit.
|
|
1543
1555
|
const VIDEO_UPSCALE_TOO_LONG_PATTERN = /This video is too long to upscale\b.*$/s;
|
|
1544
1556
|
|
|
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
|
-
|
|
1558
1557
|
function annotateVideoUpscaleError(error) {
|
|
1559
1558
|
const message = String(error?.message || error?.originalError?.message || '');
|
|
1560
1559
|
if (error && typeof error === 'object' && message.includes(FLASHVSR_UNAVAILABLE_MESSAGE)) {
|
|
@@ -2375,7 +2374,13 @@ const MINIMAX_H3_MODEL_MODES = new Map([
|
|
|
2375
2374
|
['minimax-h3-ref2va-fp8_r2v_balanced', 'r2v'],
|
|
2376
2375
|
['minimax-h3-fastvideo-int8_t2v_turbo', 't2v'],
|
|
2377
2376
|
['minimax-h3-fastvideo-int8_i2v_turbo', 'i2v'],
|
|
2378
|
-
['minimax-h3-fastvideo-int8_flf2v_turbo', 'flf2v']
|
|
2377
|
+
['minimax-h3-fastvideo-int8_flf2v_turbo', 'flf2v'],
|
|
2378
|
+
['minimax-h3-fastvideo-int8_t2v_turbo_2stage', 't2v'],
|
|
2379
|
+
['minimax-h3-fastvideo-int8_i2v_turbo_2stage', 'i2v'],
|
|
2380
|
+
['minimax-h3-fastvideo-int8_flf2v_turbo_2stage', 'flf2v'],
|
|
2381
|
+
['minimax-h3-fastvideo-int8_t2v_turbo_2stage_720p', 't2v'],
|
|
2382
|
+
['minimax-h3-fastvideo-int8_i2v_turbo_2stage_720p', 'i2v'],
|
|
2383
|
+
['minimax-h3-fastvideo-int8_flf2v_turbo_2stage_720p', 'flf2v']
|
|
2379
2384
|
]);
|
|
2380
2385
|
const MINIMAX_H3_MODEL_IDS = new Set(MINIMAX_H3_MODEL_MODES.keys());
|
|
2381
2386
|
const MINIMAX_H3_TURBO_MODEL_IDS = new Set([
|
|
@@ -2385,12 +2390,41 @@ const MINIMAX_H3_TURBO_MODEL_IDS = new Set([
|
|
|
2385
2390
|
'minimax-h3-ref2va-fp8_r2v_turbo',
|
|
2386
2391
|
'minimax-h3-fastvideo-int8_t2v_turbo',
|
|
2387
2392
|
'minimax-h3-fastvideo-int8_i2v_turbo',
|
|
2388
|
-
'minimax-h3-fastvideo-int8_flf2v_turbo'
|
|
2393
|
+
'minimax-h3-fastvideo-int8_flf2v_turbo',
|
|
2394
|
+
'minimax-h3-fastvideo-int8_t2v_turbo_2stage',
|
|
2395
|
+
'minimax-h3-fastvideo-int8_i2v_turbo_2stage',
|
|
2396
|
+
'minimax-h3-fastvideo-int8_flf2v_turbo_2stage',
|
|
2397
|
+
'minimax-h3-fastvideo-int8_t2v_turbo_2stage_720p',
|
|
2398
|
+
'minimax-h3-fastvideo-int8_i2v_turbo_2stage_720p',
|
|
2399
|
+
'minimax-h3-fastvideo-int8_flf2v_turbo_2stage_720p'
|
|
2400
|
+
]);
|
|
2401
|
+
// FastH3 Two-Stage renders the FastH3 request on its own model ids and delivers
|
|
2402
|
+
// the clip at exactly twice the canvas, same frames and audio: 720p from 672x384,
|
|
2403
|
+
// 1080p from 960x544, 2K from 1344x768. It is FastH3-class everywhere FastH3 is.
|
|
2404
|
+
// The size table, the id spellings and the delivered size come from the
|
|
2405
|
+
// Intelligence Client (isMinimaxH3TwoStageModelId, minimaxH3TwoStageCanvasShortEdge,
|
|
2406
|
+
// minimaxH3TwoStageDeliveredSize).
|
|
2407
|
+
const MINIMAX_H3_TWO_STAGE_MODEL_IDS = new Set([
|
|
2408
|
+
'minimax-h3-fastvideo-int8_t2v_turbo_2stage',
|
|
2409
|
+
'minimax-h3-fastvideo-int8_i2v_turbo_2stage',
|
|
2410
|
+
'minimax-h3-fastvideo-int8_flf2v_turbo_2stage'
|
|
2411
|
+
]);
|
|
2412
|
+
// The Socket records 720p two-stage work (a 384 px canvas) under its own ids.
|
|
2413
|
+
// Nothing here sends them: `--target-resolution 720` on a two-stage selector
|
|
2414
|
+
// sends the `_2stage` id with the 384 px canvas. They are recognized as FastH3
|
|
2415
|
+
// Turbo H3 ids; one named directly goes to the Socket unchanged, and the Socket
|
|
2416
|
+
// requires its 384 px canvas.
|
|
2417
|
+
const MINIMAX_H3_TWO_STAGE_720P_SOCKET_MODEL_IDS = new Set([
|
|
2418
|
+
'minimax-h3-fastvideo-int8_t2v_turbo_2stage_720p',
|
|
2419
|
+
'minimax-h3-fastvideo-int8_i2v_turbo_2stage_720p',
|
|
2420
|
+
'minimax-h3-fastvideo-int8_flf2v_turbo_2stage_720p'
|
|
2389
2421
|
]);
|
|
2390
2422
|
const MINIMAX_H3_FASTH3_TURBO_MODEL_IDS = new Set([
|
|
2391
2423
|
'minimax-h3-fastvideo-int8_t2v_turbo',
|
|
2392
2424
|
'minimax-h3-fastvideo-int8_i2v_turbo',
|
|
2393
|
-
'minimax-h3-fastvideo-int8_flf2v_turbo'
|
|
2425
|
+
'minimax-h3-fastvideo-int8_flf2v_turbo',
|
|
2426
|
+
...MINIMAX_H3_TWO_STAGE_MODEL_IDS,
|
|
2427
|
+
...MINIMAX_H3_TWO_STAGE_720P_SOCKET_MODEL_IDS
|
|
2394
2428
|
]);
|
|
2395
2429
|
const MINIMAX_H3_TURBO_SAMPLERS = Object.freeze(['euler', 'er_sde', 'sa_solver']);
|
|
2396
2430
|
const MINIMAX_H3_TURBO_SAMPLER_SET = new Set(MINIMAX_H3_TURBO_SAMPLERS);
|
|
@@ -2521,6 +2555,29 @@ function resolveSkillVideoModelAlias(
|
|
|
2521
2555
|
if (normalized === 'minimax-h3-fasth3-flf2v-turbo') {
|
|
2522
2556
|
return 'minimax-h3-fastvideo-int8_flf2v_turbo';
|
|
2523
2557
|
}
|
|
2558
|
+
if (normalized === 'minimax-h3-fasth3-turbo-2stage' && workflow) {
|
|
2559
|
+
if (workflow === 'r2v') {
|
|
2560
|
+
fatalCliError('MiniMax H3 FastH3 Two-Stage has no r2v workflow.', {
|
|
2561
|
+
code: 'INVALID_ARGUMENT',
|
|
2562
|
+
details: { model: modelId, workflow }
|
|
2563
|
+
});
|
|
2564
|
+
}
|
|
2565
|
+
if (workflow === 'i2v') {
|
|
2566
|
+
return hasStartFrame && hasEndFrame
|
|
2567
|
+
? 'minimax-h3-fastvideo-int8_flf2v_turbo_2stage'
|
|
2568
|
+
: 'minimax-h3-fastvideo-int8_i2v_turbo_2stage';
|
|
2569
|
+
}
|
|
2570
|
+
return 'minimax-h3-fastvideo-int8_t2v_turbo_2stage';
|
|
2571
|
+
}
|
|
2572
|
+
if (normalized === 'minimax-h3-fasth3-t2v-turbo-2stage') {
|
|
2573
|
+
return 'minimax-h3-fastvideo-int8_t2v_turbo_2stage';
|
|
2574
|
+
}
|
|
2575
|
+
if (normalized === 'minimax-h3-fasth3-i2v-turbo-2stage') {
|
|
2576
|
+
return 'minimax-h3-fastvideo-int8_i2v_turbo_2stage';
|
|
2577
|
+
}
|
|
2578
|
+
if (normalized === 'minimax-h3-fasth3-flf2v-turbo-2stage') {
|
|
2579
|
+
return 'minimax-h3-fastvideo-int8_flf2v_turbo_2stage';
|
|
2580
|
+
}
|
|
2524
2581
|
if (normalized === 'minimax-h3-balanced' && workflow) {
|
|
2525
2582
|
if (workflow === 'r2v') {
|
|
2526
2583
|
return MINIMAX_H3_R2V_BALANCED_MODEL_ID;
|
|
@@ -2557,6 +2614,32 @@ function isMiniMaxH3TurboModel(modelId) {
|
|
|
2557
2614
|
return MINIMAX_H3_TURBO_MODEL_IDS.has(String(modelId || '').trim().toLowerCase());
|
|
2558
2615
|
}
|
|
2559
2616
|
|
|
2617
|
+
function isMiniMaxH3TwoStageModel(modelId) {
|
|
2618
|
+
return isMinimaxH3TwoStageModelId(modelId);
|
|
2619
|
+
}
|
|
2620
|
+
|
|
2621
|
+
/**
|
|
2622
|
+
* The FastH3 Two-Stage canvas for a source of this size: the Intelligence Client
|
|
2623
|
+
* turns the requested delivered class (720, 1080, or 1440/2K; undefined is 2K)
|
|
2624
|
+
* into a 384, 544 or 768 short edge in the source's aspect (or aspectRatio's).
|
|
2625
|
+
*/
|
|
2626
|
+
function miniMaxH3TwoStageCanvas(modelId, deliveredClass, sourceWidth, sourceHeight, aspectRatio) {
|
|
2627
|
+
const selector = `minimax-h3-fasth3-${miniMaxH3ModeFromModelId(modelId)}-turbo-2stage`;
|
|
2628
|
+
return calculateSharedVideoDimensions(sourceWidth, sourceHeight, deliveredClass, selector, aspectRatio || undefined);
|
|
2629
|
+
}
|
|
2630
|
+
|
|
2631
|
+
/**
|
|
2632
|
+
* Dimension rules that keep a pre-resized reference on the two-stage canvas, so
|
|
2633
|
+
* the resize cannot grow the clip into a larger, pricier delivered class.
|
|
2634
|
+
*/
|
|
2635
|
+
function miniMaxH3TwoStageReferenceRules(rules, canvas) {
|
|
2636
|
+
return {
|
|
2637
|
+
...rules,
|
|
2638
|
+
maxDimension: Math.min(rules.maxDimension, Math.max(canvas.width, canvas.height)),
|
|
2639
|
+
maxPixels: canvas.width * canvas.height
|
|
2640
|
+
};
|
|
2641
|
+
}
|
|
2642
|
+
|
|
2560
2643
|
function isMiniMaxH3R2vModel(modelId) {
|
|
2561
2644
|
const normalized = String(modelId || '').trim().toLowerCase();
|
|
2562
2645
|
return normalized === MINIMAX_H3_R2V_MODEL_ID
|
|
@@ -2577,6 +2660,10 @@ function isMiniMaxH3FastH3TurboSelectionLocal(modelId) {
|
|
|
2577
2660
|
|| normalized === 'minimax-h3-fasth3-t2v-turbo'
|
|
2578
2661
|
|| normalized === 'minimax-h3-fasth3-i2v-turbo'
|
|
2579
2662
|
|| normalized === 'minimax-h3-fasth3-flf2v-turbo'
|
|
2663
|
+
|| normalized === 'minimax-h3-fasth3-turbo-2stage'
|
|
2664
|
+
|| normalized === 'minimax-h3-fasth3-t2v-turbo-2stage'
|
|
2665
|
+
|| normalized === 'minimax-h3-fasth3-i2v-turbo-2stage'
|
|
2666
|
+
|| normalized === 'minimax-h3-fasth3-flf2v-turbo-2stage'
|
|
2580
2667
|
|| MINIMAX_H3_FASTH3_TURBO_MODEL_IDS.has(normalized);
|
|
2581
2668
|
}
|
|
2582
2669
|
|
|
@@ -2596,6 +2683,10 @@ function isMiniMaxH3ModelSelectionLocal(modelId) {
|
|
|
2596
2683
|
|| normalized === 'minimax-h3-fasth3-t2v-turbo'
|
|
2597
2684
|
|| normalized === 'minimax-h3-fasth3-i2v-turbo'
|
|
2598
2685
|
|| normalized === 'minimax-h3-fasth3-flf2v-turbo'
|
|
2686
|
+
|| normalized === 'minimax-h3-fasth3-turbo-2stage'
|
|
2687
|
+
|| normalized === 'minimax-h3-fasth3-t2v-turbo-2stage'
|
|
2688
|
+
|| normalized === 'minimax-h3-fasth3-i2v-turbo-2stage'
|
|
2689
|
+
|| normalized === 'minimax-h3-fasth3-flf2v-turbo-2stage'
|
|
2599
2690
|
|| normalized === 'minimax-h3-balanced'
|
|
2600
2691
|
|| normalized === 'minimax-h3-t2v-balanced'
|
|
2601
2692
|
|| normalized === 'minimax-h3-i2v-balanced'
|
|
@@ -2615,6 +2706,10 @@ function isMiniMaxH3TurboModelSelectionLocal(modelId) {
|
|
|
2615
2706
|
|| normalized === 'minimax-h3-fasth3-t2v-turbo'
|
|
2616
2707
|
|| normalized === 'minimax-h3-fasth3-i2v-turbo'
|
|
2617
2708
|
|| normalized === 'minimax-h3-fasth3-flf2v-turbo'
|
|
2709
|
+
|| normalized === 'minimax-h3-fasth3-turbo-2stage'
|
|
2710
|
+
|| normalized === 'minimax-h3-fasth3-t2v-turbo-2stage'
|
|
2711
|
+
|| normalized === 'minimax-h3-fasth3-i2v-turbo-2stage'
|
|
2712
|
+
|| normalized === 'minimax-h3-fasth3-flf2v-turbo-2stage'
|
|
2618
2713
|
|| isMiniMaxH3TurboModel(normalized);
|
|
2619
2714
|
}
|
|
2620
2715
|
|
|
@@ -2631,6 +2726,9 @@ function miniMaxH3ModeFromModelId(modelId) {
|
|
|
2631
2726
|
if (normalized === 'minimax-h3-fasth3-t2v-turbo') return 't2v';
|
|
2632
2727
|
if (normalized === 'minimax-h3-fasth3-i2v-turbo') return 'i2v';
|
|
2633
2728
|
if (normalized === 'minimax-h3-fasth3-flf2v-turbo') return 'flf2v';
|
|
2729
|
+
if (normalized === 'minimax-h3-fasth3-t2v-turbo-2stage') return 't2v';
|
|
2730
|
+
if (normalized === 'minimax-h3-fasth3-i2v-turbo-2stage') return 'i2v';
|
|
2731
|
+
if (normalized === 'minimax-h3-fasth3-flf2v-turbo-2stage') return 'flf2v';
|
|
2634
2732
|
if (normalized === 'minimax-h3-t2v-balanced') return 't2v';
|
|
2635
2733
|
if (normalized === 'minimax-h3-i2v-balanced') return 'i2v';
|
|
2636
2734
|
if (normalized === 'minimax-h3-flf2v-balanced') return 'flf2v';
|
|
@@ -2876,6 +2974,7 @@ const options = {
|
|
|
2876
2974
|
steps: null,
|
|
2877
2975
|
guidance: null,
|
|
2878
2976
|
outputFormat: null,
|
|
2977
|
+
returnLastFrame: false,
|
|
2879
2978
|
imageQuality: null,
|
|
2880
2979
|
imageBackground: null,
|
|
2881
2980
|
imageOutputCompression: null,
|
|
@@ -2894,6 +2993,17 @@ const options = {
|
|
|
2894
2993
|
seed: null,
|
|
2895
2994
|
lastSeed: false,
|
|
2896
2995
|
seedStrategy: null,
|
|
2996
|
+
speech: false,
|
|
2997
|
+
speechMode: null,
|
|
2998
|
+
speechVoice: null,
|
|
2999
|
+
voiceDescription: null,
|
|
3000
|
+
voiceReference: null,
|
|
3001
|
+
voiceTranscript: null,
|
|
3002
|
+
speechCreativity: null,
|
|
3003
|
+
imageTo3d: null,
|
|
3004
|
+
removeBackground: null,
|
|
3005
|
+
matte: false,
|
|
3006
|
+
meshSettings: {},
|
|
2897
3007
|
music: false,
|
|
2898
3008
|
musicLyrics: null,
|
|
2899
3009
|
musicLanguage: null,
|
|
@@ -2917,7 +3027,6 @@ const options = {
|
|
|
2917
3027
|
duration: 5,
|
|
2918
3028
|
frames: null,
|
|
2919
3029
|
targetResolution: null, // Short-side target for video, preserving aspect ratio
|
|
2920
|
-
outputScale: 1, // MiniMax H3 delivery scale: 2 = 2K, twice the requested canvas
|
|
2921
3030
|
autoResizeVideoAssets: null,
|
|
2922
3031
|
estimateVideoCost: false,
|
|
2923
3032
|
showBalance: false,
|
|
@@ -3028,7 +3137,7 @@ const options = {
|
|
|
3028
3137
|
apiModelId: null,
|
|
3029
3138
|
liveModelAction: null, // list|search
|
|
3030
3139
|
liveModelQuery: null,
|
|
3031
|
-
liveModelMedia: 'all', // image|video|audio|all
|
|
3140
|
+
liveModelMedia: 'all', // image|video|audio|model|all
|
|
3032
3141
|
liveModelNetwork: null, // fast|relaxed; defaults to configured network
|
|
3033
3142
|
liveModelTags: [], // repeatable --model-tag filters (AND semantics)
|
|
3034
3143
|
loraCatalogAction: null, // list|search
|
|
@@ -3113,7 +3222,7 @@ const cliSet = {
|
|
|
3113
3222
|
duration: false,
|
|
3114
3223
|
frames: false,
|
|
3115
3224
|
targetResolution: false,
|
|
3116
|
-
|
|
3225
|
+
targetResolution2K: false,
|
|
3117
3226
|
autoResizeVideoAssets: false,
|
|
3118
3227
|
angles360Video: false,
|
|
3119
3228
|
videoModel: false,
|
|
@@ -3233,6 +3342,8 @@ for (let i = 0; i < args.length; i++) {
|
|
|
3233
3342
|
i++;
|
|
3234
3343
|
options.guidance = parseNumberValue(raw, arg);
|
|
3235
3344
|
cliSet.guidance = true;
|
|
3345
|
+
} else if (arg === '--return-last-frame') {
|
|
3346
|
+
options.returnLastFrame = true;
|
|
3236
3347
|
} else if (arg === '--output-format' || arg === '--format') {
|
|
3237
3348
|
const raw = requireFlagValue(args, i, arg);
|
|
3238
3349
|
i++;
|
|
@@ -3455,16 +3566,18 @@ for (let i = 0; i < args.length; i++) {
|
|
|
3455
3566
|
} else if (arg === '--target-resolution' || arg === '--short-side') {
|
|
3456
3567
|
const raw = requireFlagValue(args, i, arg);
|
|
3457
3568
|
i++;
|
|
3458
|
-
|
|
3569
|
+
const parsed = parseTargetResolutionValue(raw, arg);
|
|
3570
|
+
options.targetResolution = parsed.value;
|
|
3459
3571
|
cliSet.targetResolution = true;
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3572
|
+
cliSet.targetResolution2K = parsed.spelled2K;
|
|
3573
|
+
} else if (arg === '--output-scale' || arg === '--2k') {
|
|
3574
|
+
// Retired: MiniMax H3 1080p/2K output is its own model id now, and Sogni
|
|
3575
|
+
// refuses any request carrying outputScale. Fail instead of guessing a model.
|
|
3576
|
+
fatalCliError(`${arg} is no longer supported. MiniMax H3 2K output is the FastH3 Two-Stage model: use -m minimax-h3-fasth3-turbo-2stage.`, {
|
|
3577
|
+
code: 'INVALID_ARGUMENT',
|
|
3578
|
+
details: { flag: arg },
|
|
3579
|
+
hint: 'Replace the flag with -m minimax-h3-fasth3-turbo-2stage (or minimax-h3-fasth3-t2v-turbo-2stage / -i2v- / -flf2v-), which delivers 2K by default (1344x768 -> 2688x1536); add --target-resolution 1080 or 720 for 1080p or 720p.'
|
|
3580
|
+
});
|
|
3468
3581
|
} else if (arg === '--auto-resize-assets') {
|
|
3469
3582
|
options.autoResizeVideoAssets = true;
|
|
3470
3583
|
cliSet.autoResizeVideoAssets = true;
|
|
@@ -3534,6 +3647,23 @@ for (let i = 0; i < args.length; i++) {
|
|
|
3534
3647
|
i++;
|
|
3535
3648
|
options.contextImages.push(raw);
|
|
3536
3649
|
cliSet.context = true;
|
|
3650
|
+
} else if (arg === '--image-to-3d' || arg === '--pixal3d') {
|
|
3651
|
+
options.imageTo3d = expandHomePath(requireFlagValue(args, i++, arg));
|
|
3652
|
+
} else if (arg === '--remove-background') {
|
|
3653
|
+
options.removeBackground = expandHomePath(requireFlagValue(args, i++, arg));
|
|
3654
|
+
} else if (arg === '--matte') {
|
|
3655
|
+
options.matte = true;
|
|
3656
|
+
} else if (Object.hasOwn(MESH_FLAGS, arg)) {
|
|
3657
|
+
const [key, min, max] = MESH_FLAGS[arg];
|
|
3658
|
+
options.meshSettings[key] = parsePositiveIntegerValue(requireFlagValue(args, i++, arg), arg, min, max);
|
|
3659
|
+
} else if (arg === '--speech') {
|
|
3660
|
+
options.speech = true;
|
|
3661
|
+
} else if (Object.hasOwn(SPEECH_VALUE_FLAGS, arg)) {
|
|
3662
|
+
const key = SPEECH_VALUE_FLAGS[arg];
|
|
3663
|
+
const value = requireFlagValue(args, i++, arg);
|
|
3664
|
+
options[key] = key === 'voiceReference' ? expandHomePath(value) : value;
|
|
3665
|
+
} else if (arg === '--speech-creativity') {
|
|
3666
|
+
options.speechCreativity = parseNumberValue(requireFlagValue(args, i++, arg), arg);
|
|
3537
3667
|
} else if (arg === '--segment') {
|
|
3538
3668
|
options.segmentImage = expandHomePath(requireFlagValue(args, i++, arg));
|
|
3539
3669
|
} else if (arg === '--segment-point' || arg === '--segment-exclude') {
|
|
@@ -3823,8 +3953,8 @@ for (let i = 0; i < args.length; i++) {
|
|
|
3823
3953
|
} else if (arg === '--model-media') {
|
|
3824
3954
|
const raw = requireFlagValue(args, i, arg);
|
|
3825
3955
|
i++;
|
|
3826
|
-
if (!['image', 'video', 'audio', 'all'].includes(raw)) {
|
|
3827
|
-
fatalCliError('--model-media must be one of image, video, audio, or all.', {
|
|
3956
|
+
if (!['image', 'video', 'audio', 'model', 'all'].includes(raw)) {
|
|
3957
|
+
fatalCliError('--model-media must be one of image, video, audio, model, or all.', {
|
|
3828
3958
|
code: 'INVALID_ARGUMENT',
|
|
3829
3959
|
details: { value: raw }
|
|
3830
3960
|
});
|
|
@@ -4197,7 +4327,8 @@ Image Options:
|
|
|
4197
4327
|
--distance <key> close-up|medium|wide
|
|
4198
4328
|
--angle-strength <n> LoRA strength for multiple_angles (default: 0.9)
|
|
4199
4329
|
--angle-description <text> Optional subject description
|
|
4200
|
-
--output-format <f>
|
|
4330
|
+
--output-format <f> Images: png|jpg (webp for GPT Image); video: mp4|mov (MOV: Seedance 2.5)
|
|
4331
|
+
--return-last-frame Export the final video frame as an image (Seedance 2.5)
|
|
4201
4332
|
--image-quality <q> GPT Image: low|medium|high; 2.5 also xhigh|max
|
|
4202
4333
|
--image-background <b> auto|opaque; 2.5 also transparent (PNG/WebP)
|
|
4203
4334
|
--image-output-compression <n> JPEG/WebP compression, integer 0–100
|
|
@@ -4227,12 +4358,27 @@ Photobooth (Face Transfer):
|
|
|
4227
4358
|
--cn-strength <n> ControlNet strength (default: 0.8)
|
|
4228
4359
|
--cn-guidance-end <n> ControlNet guidance end point (default: 0.3)
|
|
4229
4360
|
|
|
4361
|
+
3D and Background Removal:
|
|
4362
|
+
--image-to-3d <image> Pixal3D: original image to binary GLB (alias --pixal3d)
|
|
4363
|
+
--shape-resolution <n> 1024 (default) or 1536; optional --mesh-faces 5000–700000
|
|
4364
|
+
--texture-size <n> 1024–4096; --normal-map-size 512–2048; --ao-map-size 256–1024
|
|
4365
|
+
--remove-background <image> BiRefNet transparent PNG; --matte returns soft mask
|
|
4366
|
+
|
|
4367
|
+
Speech Options:
|
|
4368
|
+
--speech Read the exact prompt as speech; output WAV by default
|
|
4369
|
+
--speech-mode <mode> voice (default), clone, or design
|
|
4370
|
+
--speech-voice <id> serena (default), vivian, uncle_fu, ryan, aiden, ono_anna, sohee, eric, dylan
|
|
4371
|
+
--voice-description <text> Optional delivery direction; required for design
|
|
4372
|
+
--voice-reference <audio> Required 3–30 second recording for clone (needs ffprobe)
|
|
4373
|
+
--voice-transcript <text> Optional transcript of clone reference
|
|
4374
|
+
--speech-creativity <n> Speech temperature 0.1–2; --language auto or language name
|
|
4375
|
+
|
|
4230
4376
|
Music Options:
|
|
4231
4377
|
--music Generate music/audio instead of image
|
|
4232
|
-
--music-model <id> Music model: turbo|sft
|
|
4233
|
-
--lyrics <text>
|
|
4378
|
+
--music-model <id> Music model: music3|turbo|sft (or full model ID)
|
|
4379
|
+
--lyrics <text> Song lyrics; Music 3 instrumentals benefit from section tags
|
|
4234
4380
|
--language <code> Lyrics language code (default: en)
|
|
4235
|
-
--duration <sec>
|
|
4381
|
+
--duration <sec> ACE: 10–600s, default 30; Music 3: 10–300s, default 60
|
|
4236
4382
|
--length <sec> Alias for --duration
|
|
4237
4383
|
--bpm <num> Beats per minute (30-300)
|
|
4238
4384
|
--keyscale <text> Key/scale, e.g. "C major" or "A minor"
|
|
@@ -4256,10 +4402,9 @@ Video Options:
|
|
|
4256
4402
|
--fps <num> Frames per second (model default unless set)
|
|
4257
4403
|
--duration <sec> Duration in seconds (default: 5); Seedance 2.5 edit requires @Video1's source duration
|
|
4258
4404
|
--frames <num> Override total frames (optional)
|
|
4259
|
-
--target-resolution <px> Short-side target that preserves aspect ratio (Seedance 2.5: 480 or
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
--2k Shorthand for --output-scale 2
|
|
4405
|
+
--target-resolution <px> Short-side target that preserves aspect ratio (Seedance 2.5: 480, 720 or 1080).
|
|
4406
|
+
MiniMax H3 FastH3 Two-Stage: the delivered size, 720, 1080, or 2K (1440; default),
|
|
4407
|
+
rendered on a half-size canvas (672x384, 960x544, 1344x768)
|
|
4263
4408
|
--auto-resize-assets Auto-resize video reference assets (default)
|
|
4264
4409
|
--no-auto-resize-assets Disable auto-resize for video assets
|
|
4265
4410
|
--estimate-video-cost Estimate video cost and exit
|
|
@@ -4370,7 +4515,7 @@ General:
|
|
|
4370
4515
|
--balance, --balances Show account, plan, and SPARK/SOGNI balances and exit
|
|
4371
4516
|
--list-models [query] List live Supernet media models; optionally filter by query
|
|
4372
4517
|
--search-models <q> Search live models by ID or name (separator-insensitive)
|
|
4373
|
-
--model-media <type> Filter model discovery: image|video|audio|all (default: all)
|
|
4518
|
+
--model-media <type> Filter model discovery: image|video|audio|model|all (default: all; model = 3D)
|
|
4374
4519
|
--model-network <n> Model discovery network: fast|relaxed (default: configured network)
|
|
4375
4520
|
--model-tag <tag> Filter by catalog tag, e.g. spicy or uncensored (repeatable, AND)
|
|
4376
4521
|
--list-loras [query] List the live LoRA catalog with each LoRA's strength contract
|
|
@@ -4481,7 +4626,7 @@ Seedance Video Model Selectors:
|
|
|
4481
4626
|
seedance2-ia2v Image+audio-to-video
|
|
4482
4627
|
seedance2-v2v Video-to-video without ControlNet
|
|
4483
4628
|
seedance2-5 Seedance 2.5 text-to-video (alias seedance2-5-t2v): 4-30s single clips,
|
|
4484
|
-
480p/720p
|
|
4629
|
+
480p/720p/1080p (no 4K), MP4/MOV and last-frame export, native audio, first/last frame via
|
|
4485
4630
|
--ref/--ref-end, up to 30 image / 10 video / 10 audio refs (30 total)
|
|
4486
4631
|
seedance2-5-ia2v Seedance 2.5 image+audio-to-video
|
|
4487
4632
|
seedance2-5-v2v Seedance 2.5 video-to-video, editing, and extension, no ControlNet
|
|
@@ -4518,6 +4663,14 @@ state negatives in the structured prompt.):
|
|
|
4518
4663
|
minimax-h3-fasth3-t2v-turbo FastH3 text-to-video (up to 6x faster than Standard)
|
|
4519
4664
|
minimax-h3-fasth3-i2v-turbo FastH3 I2VA (--ref) or L2VA (--ref-end)
|
|
4520
4665
|
minimax-h3-fasth3-flf2v-turbo FastH3 first-frame -> last-frame (--ref plus --ref-end)
|
|
4666
|
+
minimax-h3-fasth3-turbo-2stage FastH3 Two-Stage: delivered at twice the canvas, 2K by default (1344x768 -> 2688x1536);
|
|
4667
|
+
--target-resolution 1080 or 720 for 1080p or 720p; infers T2VA/I2VA/L2VA/FL2VA; no R2V
|
|
4668
|
+
minimax-h3-fasth3-t2v-turbo-2stage
|
|
4669
|
+
FastH3 Two-Stage text-to-video
|
|
4670
|
+
minimax-h3-fasth3-i2v-turbo-2stage
|
|
4671
|
+
FastH3 Two-Stage I2VA (--ref) or L2VA (--ref-end)
|
|
4672
|
+
minimax-h3-fasth3-flf2v-turbo-2stage
|
|
4673
|
+
FastH3 Two-Stage first-frame -> last-frame (--ref plus --ref-end)
|
|
4521
4674
|
H3 FL2VA Turbo sampler override --sampler euler|er_sde|sa_solver
|
|
4522
4675
|
(Socket default: er_sde; CLI omits unless set)
|
|
4523
4676
|
(scheduler remains fixed to simple)
|
|
@@ -4596,6 +4749,9 @@ Examples:
|
|
|
4596
4749
|
}
|
|
4597
4750
|
}
|
|
4598
4751
|
|
|
4752
|
+
try { prepareMediaUtilityOptions(options, cliSet); }
|
|
4753
|
+
catch (error) { fatalCliError(error.message, { code: 'INVALID_ARGUMENT' }); }
|
|
4754
|
+
|
|
4599
4755
|
let timeoutFromConfig = false;
|
|
4600
4756
|
let widthFromConfig = false;
|
|
4601
4757
|
let heightFromConfig = false;
|
|
@@ -4916,16 +5072,18 @@ if (!options.video && !options.music && options.model) {
|
|
|
4916
5072
|
if (options.outputFormat) {
|
|
4917
5073
|
const normalized = options.outputFormat.toLowerCase();
|
|
4918
5074
|
options.outputFormat = normalized === 'jpeg' ? 'jpg' : normalized;
|
|
4919
|
-
if (options.
|
|
5075
|
+
if (options.imageTo3d) {
|
|
5076
|
+
// GLB is a model artifact, not an SDK image outputFormat.
|
|
5077
|
+
} else if (options.music || options.speech) {
|
|
4920
5078
|
if (!MUSIC_OUTPUT_FORMATS.has(options.outputFormat)) {
|
|
4921
|
-
fatalCliError('Music output format must be "mp3", "flac", or "wav"
|
|
5079
|
+
fatalCliError(`${options.speech ? 'Speech' : 'Music'} output format must be "mp3", "flac", or "wav".`, {
|
|
4922
5080
|
code: 'INVALID_ARGUMENT',
|
|
4923
5081
|
details: { outputFormat: options.outputFormat }
|
|
4924
5082
|
});
|
|
4925
5083
|
}
|
|
4926
5084
|
} else if (options.video || options.upscaleVideo) {
|
|
4927
|
-
if (options.
|
|
4928
|
-
fatalCliError('Video output format must be "mp4".', {
|
|
5085
|
+
if (!['mp4', ...(options.video && isSeedance25ModelSelectionLocal(options.model) ? ['mov'] : [])].includes(options.outputFormat)) {
|
|
5086
|
+
fatalCliError('Video output format must be "mp4" (Seedance 2.5 also supports "mov").', {
|
|
4929
5087
|
code: 'INVALID_ARGUMENT',
|
|
4930
5088
|
details: { outputFormat: options.outputFormat }
|
|
4931
5089
|
});
|
|
@@ -4938,6 +5096,10 @@ if (options.outputFormat) {
|
|
|
4938
5096
|
}
|
|
4939
5097
|
}
|
|
4940
5098
|
|
|
5099
|
+
if (options.returnLastFrame && (!options.video || !isSeedance25ModelSelectionLocal(options.model))) {
|
|
5100
|
+
fatalCliError('--return-last-frame requires Seedance 2.5 video.', { code: 'INVALID_ARGUMENT' });
|
|
5101
|
+
}
|
|
5102
|
+
|
|
4941
5103
|
if (options.imageQuality !== null || options.imageBackground !== null || options.imageOutputCompression !== null || options.imageMask !== null) {
|
|
4942
5104
|
try {
|
|
4943
5105
|
if (options.video || options.music || !isGptImage2ModelSelection(options.model)) {
|
|
@@ -5050,7 +5212,7 @@ if (options.video && options.loras.length > 0) {
|
|
|
5050
5212
|
const unknownVideoLoras = options.loras.filter(loraId => !videoLoraEntries.has(loraId));
|
|
5051
5213
|
if (unknownVideoLoras.length > 0) {
|
|
5052
5214
|
const availableIds = [...videoLoraEntries.keys()];
|
|
5053
|
-
const isUnresolvedH3Alias = /^minimax-h3(?:-
|
|
5215
|
+
const isUnresolvedH3Alias = /^minimax-h3(?:-turbo|-fasth3-turbo(?:-2stage)?)?$/.test(String(options.model || ''));
|
|
5054
5216
|
fatalCliError(
|
|
5055
5217
|
`Video LoRA "${unknownVideoLoras[0]}" is not published for model "${options.model}". ` +
|
|
5056
5218
|
(availableIds.length > 0
|
|
@@ -5303,14 +5465,14 @@ if (options.music) {
|
|
|
5303
5465
|
const configuredMusicModel = options.model || openclawConfig?.defaultMusicModel || 'turbo';
|
|
5304
5466
|
options.model = normalizeMusicModelId(configuredMusicModel);
|
|
5305
5467
|
if (!options.model) {
|
|
5306
|
-
fatalCliError(`Unknown music model "${configuredMusicModel}". Use turbo, sft, ace_step_1.5_xl_turbo, or ace_step_1.5_xl_sft.`, {
|
|
5468
|
+
fatalCliError(`Unknown music model "${configuredMusicModel}". Use music3, turbo, sft, minimax_music3, ace_step_1.5_xl_turbo, or ace_step_1.5_xl_sft.`, {
|
|
5307
5469
|
code: 'INVALID_ARGUMENT',
|
|
5308
5470
|
details: { flag: cliSet.model ? '--model' : 'defaultMusicModel', value: configuredMusicModel }
|
|
5309
5471
|
});
|
|
5310
5472
|
}
|
|
5311
5473
|
const musicDefaults = getMusicModelDefaults(options.model);
|
|
5312
5474
|
if (!cliSet.duration || !Number.isFinite(options.duration)) {
|
|
5313
|
-
options.duration = MUSIC_DURATION_LIMITS.default;
|
|
5475
|
+
options.duration = (musicDefaults.duration || MUSIC_DURATION_LIMITS).default;
|
|
5314
5476
|
}
|
|
5315
5477
|
if (!options.outputFormat) {
|
|
5316
5478
|
options.outputFormat = 'mp3';
|
|
@@ -5328,11 +5490,13 @@ if (options.music) {
|
|
|
5328
5490
|
options.scheduler = musicDefaults.scheduler.default;
|
|
5329
5491
|
}
|
|
5330
5492
|
if (!cliSet.musicShift) {
|
|
5331
|
-
options.musicShift = musicDefaults.shift
|
|
5493
|
+
options.musicShift = musicDefaults.shift?.default ?? null;
|
|
5332
5494
|
}
|
|
5333
5495
|
if (!cliSet.timeout && !timeoutFromConfig && options.timeout === 30000) {
|
|
5334
5496
|
options.timeout = 600000;
|
|
5335
5497
|
}
|
|
5498
|
+
} else if (options.speech || options.imageTo3d || options.removeBackground) {
|
|
5499
|
+
if (!cliSet.timeout && !timeoutFromConfig) options.timeout = 600000;
|
|
5336
5500
|
} else if (options.video) {
|
|
5337
5501
|
if (!options.model) {
|
|
5338
5502
|
let defaultVideoModel = selectDefaultVideoModel(options.videoWorkflow, options, openclawConfig);
|
|
@@ -5430,15 +5594,50 @@ if (options.music) {
|
|
|
5430
5594
|
options.steps = videoQuality.steps;
|
|
5431
5595
|
}
|
|
5432
5596
|
}
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
|
|
5436
|
-
|
|
5597
|
+
// MiniMax H3 FastH3 Two-Stage: --target-resolution names the delivered class
|
|
5598
|
+
// (720, 1080, or 1440/2K; omitted is 2K) and the canvas is half of it, from the
|
|
5599
|
+
// Intelligence Client's size table. Anything else is refused, never guessed.
|
|
5600
|
+
const isTwoStageVideo = isMiniMaxH3TwoStageModel(options.model);
|
|
5601
|
+
if (cliSet.targetResolution2K && !isTwoStageVideo) {
|
|
5602
|
+
fatalCliError(`--target-resolution 2K is the MiniMax H3 FastH3 Two-Stage delivered size; ${options.model} takes a short side in pixels.`, {
|
|
5603
|
+
code: 'INVALID_ARGUMENT',
|
|
5604
|
+
details: { flag: '--target-resolution', value: '2K', model: options.model },
|
|
5605
|
+
hint: 'Use -m minimax-h3-fasth3-turbo-2stage for 2K MiniMax H3 video, or pass the short side in pixels.'
|
|
5606
|
+
});
|
|
5607
|
+
}
|
|
5608
|
+
const hasExplicitVideoCanvas = cliSet.width || cliSet.height || widthFromConfig || heightFromConfig || widthFromPrompt || heightFromPrompt;
|
|
5609
|
+
if (isTwoStageVideo) {
|
|
5610
|
+
const requestedClass = (cliSet.targetResolution || targetResolutionFromPrompt) ? options.targetResolution : undefined;
|
|
5611
|
+
try {
|
|
5612
|
+
minimaxH3TwoStageCanvasShortEdge(requestedClass);
|
|
5613
|
+
} catch (error) {
|
|
5614
|
+
fatalCliError(`${error.message}.`, {
|
|
5615
|
+
code: 'INVALID_ARGUMENT',
|
|
5616
|
+
details: { flag: '--target-resolution', value: requestedClass, model: options.model },
|
|
5617
|
+
hint: 'MiniMax H3 FastH3 Two-Stage --target-resolution is the delivered size: 720, 1080, or 2K (1440). Omit it for 2K.'
|
|
5618
|
+
});
|
|
5619
|
+
}
|
|
5620
|
+
options._miniMaxH3TwoStageClass = requestedClass;
|
|
5621
|
+
// An explicit -w/-h is the canvas as given; otherwise the class sets it, and
|
|
5622
|
+
// an i2v reference later re-derives it in the reference's aspect.
|
|
5623
|
+
options._miniMaxH3TwoStageAutoCanvas = !hasExplicitVideoCanvas;
|
|
5624
|
+
if (!hasExplicitVideoCanvas) {
|
|
5625
|
+
const canvas = miniMaxH3TwoStageCanvas(options.model, requestedClass, options.width, options.height, aspectRatioFromPrompt);
|
|
5626
|
+
options.width = canvas.width;
|
|
5627
|
+
options.height = canvas.height;
|
|
5628
|
+
}
|
|
5629
|
+
}
|
|
5630
|
+
const videoShortSide = isTwoStageVideo
|
|
5631
|
+
? null
|
|
5632
|
+
: ((cliSet.targetResolution || targetResolutionFromPrompt)
|
|
5633
|
+
? options.targetResolution
|
|
5634
|
+
: (!isSeedanceVideo ? videoQuality?.shortSide : null));
|
|
5635
|
+
if (videoShortSide && !hasExplicitVideoCanvas) {
|
|
5437
5636
|
const dims = dimensionsWithShortSide(options.width, options.height, videoShortSide);
|
|
5438
5637
|
options.width = dims.width;
|
|
5439
5638
|
options.height = dims.height;
|
|
5440
5639
|
}
|
|
5441
|
-
if (aspectRatioFromPrompt && !cliSet.width && !cliSet.height) {
|
|
5640
|
+
if (aspectRatioFromPrompt && !cliSet.width && !cliSet.height && !isTwoStageVideo) {
|
|
5442
5641
|
const dims = dimensionsForAspectRatio(options.width, options.height, aspectRatioFromPrompt);
|
|
5443
5642
|
if (dims) {
|
|
5444
5643
|
options.width = dims.width;
|
|
@@ -5507,8 +5706,12 @@ if (!options.video && !options.music && isGptImage2ModelSelection(options.model)
|
|
|
5507
5706
|
|
|
5508
5707
|
if (options.music) {
|
|
5509
5708
|
const musicDefaults = getMusicModelDefaults(options.model);
|
|
5510
|
-
|
|
5511
|
-
|
|
5709
|
+
const durationLimits = musicDefaults.duration || MUSIC_DURATION_LIMITS;
|
|
5710
|
+
if (options.model === MUSIC3_MODEL_ID && (cliSet.musicShift || cliSet.musicBpm || cliSet.musicKeyscale || cliSet.musicTimesig || cliSet.musicLanguage || cliSet.musicComposerMode)) {
|
|
5711
|
+
fatalCliError('Music 3 does not use shift, BPM, key, time signature, language, or composer controls. Describe musical direction in the prompt and lyrics.', { code: 'INVALID_ARGUMENT' });
|
|
5712
|
+
}
|
|
5713
|
+
if (options.duration < durationLimits.min || options.duration > durationLimits.max) {
|
|
5714
|
+
fatalCliError(`Music duration must be between ${durationLimits.min} and ${durationLimits.max} seconds.`, {
|
|
5512
5715
|
code: 'INVALID_ARGUMENT',
|
|
5513
5716
|
details: { duration: options.duration }
|
|
5514
5717
|
});
|
|
@@ -5601,7 +5804,7 @@ const commandUsesGenerationSeed = !options.apiChat &&
|
|
|
5601
5804
|
!options.remixAudio &&
|
|
5602
5805
|
!options.upscaleImage &&
|
|
5603
5806
|
!options.upscaleVideo &&
|
|
5604
|
-
!options.segmentImage &&
|
|
5807
|
+
!options.segmentImage && !options.imageTo3d && !options.removeBackground &&
|
|
5605
5808
|
!options.listMedia &&
|
|
5606
5809
|
!options.memoryAction &&
|
|
5607
5810
|
!options.personalityAction &&
|
|
@@ -5640,7 +5843,7 @@ const wan3HasMediaInput = isWan3ModelLocal(options.model) && Boolean(
|
|
|
5640
5843
|
|| options.wan3ReferenceFileUrl
|
|
5641
5844
|
|| options.wan3ReferenceLinkUrl
|
|
5642
5845
|
);
|
|
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) {
|
|
5846
|
+
if (!options.prompt && !wan3HasMediaInput && !options.segmentImage && !options.imageTo3d && !options.removeBackground && !options.upscaleImage && !options.upscaleVideo && !options.apiChat && !apiWorkflowUtilityAction && !apiWorkflowStartAction && !apiModelUtilityAction && !liveModelUtilityAction && !loraCatalogUtilityAction && !apiReplayUtilityAction && !contractUtilityAction && !storyboardPlanUtilityAction && !options.estimateVideoCost && !options.multiAngle && !options.showBalance && !options.showVersion && !options.doctor && !options.extractLastFrame && !options.extractFirstFrame && !options.extractFrameAt && !options.trimVideo && !options.verifyVideo && !options.concatVideos && !options.sourceReelDir && !options.remixAudio && !options.listMedia && !options.memoryAction && !options.personalityAction && !personaUtilityAction) {
|
|
5644
5847
|
fatalCliError('No prompt provided. Use --help for usage.', { code: 'INVALID_ARGUMENT' });
|
|
5645
5848
|
}
|
|
5646
5849
|
|
|
@@ -5736,8 +5939,8 @@ if (options.legacyWan3TaskType !== null) {
|
|
|
5736
5939
|
);
|
|
5737
5940
|
}
|
|
5738
5941
|
|
|
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 ||
|
|
5740
|
-
fatalCliError('Video-only options (--workflow/--seedance-task-type/--wan3-ratio/--smart-duration/--reference-file-url/--reference-link-url/--watermark/--frames/--target-resolution/--
|
|
5942
|
+
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)) {
|
|
5943
|
+
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.', {
|
|
5741
5944
|
code: 'INVALID_ARGUMENT'
|
|
5742
5945
|
});
|
|
5743
5946
|
}
|
|
@@ -5864,7 +6067,7 @@ if (options.video) {
|
|
|
5864
6067
|
(cliSet.width || cliSet.height)
|
|
5865
6068
|
) {
|
|
5866
6069
|
fatalCliError(
|
|
5867
|
-
`Seedance 2.5 ${options.seedanceTaskType} inherits @Video1's aspect ratio; use --target-resolution 480 or
|
|
6070
|
+
`Seedance 2.5 ${options.seedanceTaskType} inherits @Video1's aspect ratio; use --target-resolution 480, 720 or 1080 instead of --width/--height.`,
|
|
5868
6071
|
{
|
|
5869
6072
|
code: 'INVALID_ARGUMENT',
|
|
5870
6073
|
details: { seedanceTaskType: options.seedanceTaskType }
|
|
@@ -5874,9 +6077,9 @@ if (options.video) {
|
|
|
5874
6077
|
if (
|
|
5875
6078
|
isSeedance25Video &&
|
|
5876
6079
|
cliSet.targetResolution &&
|
|
5877
|
-
![480, 720].includes(options.targetResolution)
|
|
6080
|
+
![480, 720, 1080].includes(options.targetResolution)
|
|
5878
6081
|
) {
|
|
5879
|
-
fatalCliError('Seedance 2.5 --target-resolution must be 480 or
|
|
6082
|
+
fatalCliError('Seedance 2.5 --target-resolution must be 480, 720 or 1080.', {
|
|
5880
6083
|
code: 'INVALID_ARGUMENT',
|
|
5881
6084
|
details: { targetResolution: options.targetResolution }
|
|
5882
6085
|
});
|
|
@@ -5887,15 +6090,6 @@ if (options.video) {
|
|
|
5887
6090
|
details: { targetResolution: options.targetResolution }
|
|
5888
6091
|
});
|
|
5889
6092
|
}
|
|
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
|
-
}
|
|
5899
6093
|
const seedanceWorkflows = isSeedance25Video
|
|
5900
6094
|
? ['t2v', 'ia2v', 'a2v', 'v2v']
|
|
5901
6095
|
: ['t2v', 'ia2v', 'v2v'];
|
|
@@ -6456,12 +6650,34 @@ if (options.video) {
|
|
|
6456
6650
|
// clients that ceiling is model-aware — e.g. 3840 for LTX-2.x — on legacy clients it is a
|
|
6457
6651
|
// blanket 1536).
|
|
6458
6652
|
const hasVideoReference = Boolean(options.refImage || options.refImageEnd);
|
|
6459
|
-
const
|
|
6653
|
+
const referenceVideoDimensionRules = hasVideoReference
|
|
6460
6654
|
? {
|
|
6461
6655
|
...baseVideoDimensionRules,
|
|
6462
6656
|
maxDimension: Math.min(baseVideoDimensionRules.maxDimension, wrapperRefVideoDimensionCeiling(options.model))
|
|
6463
6657
|
}
|
|
6464
6658
|
: baseVideoDimensionRules;
|
|
6659
|
+
// FastH3 Two-Stage follows a local reference's aspect at the requested
|
|
6660
|
+
// delivered class, and caps the reference pre-resize to that canvas.
|
|
6661
|
+
let twoStageReferenceCanvas = null;
|
|
6662
|
+
if (options._miniMaxH3TwoStageAutoCanvas && options.videoWorkflow === 'i2v' && hasVideoReference) {
|
|
6663
|
+
const twoStageRefPath = options.refImage || options.refImageEnd;
|
|
6664
|
+
if (!isHttpUrl(twoStageRefPath) && existsSync(twoStageRefPath)) {
|
|
6665
|
+
const twoStageRefDims = getImageDimensionsFromBuffer(readFileSync(twoStageRefPath));
|
|
6666
|
+
if (twoStageRefDims?.width && twoStageRefDims?.height) {
|
|
6667
|
+
twoStageReferenceCanvas = miniMaxH3TwoStageCanvas(
|
|
6668
|
+
options.model,
|
|
6669
|
+
options._miniMaxH3TwoStageClass,
|
|
6670
|
+
twoStageRefDims.width,
|
|
6671
|
+
twoStageRefDims.height
|
|
6672
|
+
);
|
|
6673
|
+
options.width = twoStageReferenceCanvas.width;
|
|
6674
|
+
options.height = twoStageReferenceCanvas.height;
|
|
6675
|
+
}
|
|
6676
|
+
}
|
|
6677
|
+
}
|
|
6678
|
+
const videoDimensionRules = twoStageReferenceCanvas
|
|
6679
|
+
? miniMaxH3TwoStageReferenceRules(referenceVideoDimensionRules, twoStageReferenceCanvas)
|
|
6680
|
+
: referenceVideoDimensionRules;
|
|
6465
6681
|
|
|
6466
6682
|
// An implicit LTX i2v canvas follows an already-compatible local reference
|
|
6467
6683
|
// directly. Resolve this before normalizing the model's landscape default so
|
|
@@ -8428,7 +8644,7 @@ async function runLiveModels() {
|
|
|
8428
8644
|
? [...new Set(model.tags.map(normalizeLiveModelTag).filter(Boolean))].sort()
|
|
8429
8645
|
: []
|
|
8430
8646
|
})).filter(model =>
|
|
8431
|
-
['image', 'video', 'audio'].includes(model.media) &&
|
|
8647
|
+
['image', 'video', 'audio', 'model'].includes(model.media) &&
|
|
8432
8648
|
model.networks.includes(network) &&
|
|
8433
8649
|
(media === 'all' || model.media === media)
|
|
8434
8650
|
);
|
|
@@ -11841,8 +12057,7 @@ function buildVideoEstimateParams({ tokenType, steps }) {
|
|
|
11841
12057
|
tokenType,
|
|
11842
12058
|
...(Number.isFinite(steps) && steps > 0 ? { steps } : {}),
|
|
11843
12059
|
...(options.frames ? { frames: options.frames } : { duration: options.duration }),
|
|
11844
|
-
...(referenceImageCount !== undefined ? { referenceImageCount } : {})
|
|
11845
|
-
...(options.outputScale === 2 && isMiniMaxH3Model(options.model) ? { outputScale: 2 } : {})
|
|
12060
|
+
...(referenceImageCount !== undefined ? { referenceImageCount } : {})
|
|
11846
12061
|
};
|
|
11847
12062
|
|
|
11848
12063
|
if ((isSeedanceVideo || isWan3Video) && options.refVideo) {
|
|
@@ -12701,6 +12916,9 @@ async function main() {
|
|
|
12701
12916
|
}
|
|
12702
12917
|
if (options.json) {
|
|
12703
12918
|
const duration = options.frames ? Math.max(1, Math.round((options.frames - 1) / options.fps)) : options.duration;
|
|
12919
|
+
const delivered = isMiniMaxH3TwoStageModel(options.model)
|
|
12920
|
+
? minimaxH3TwoStageDeliveredSize(options.width, options.height)
|
|
12921
|
+
: null;
|
|
12704
12922
|
console.log(JSON.stringify({
|
|
12705
12923
|
success: true,
|
|
12706
12924
|
type: 'video-cost',
|
|
@@ -12713,7 +12931,7 @@ async function main() {
|
|
|
12713
12931
|
steps,
|
|
12714
12932
|
tokenType: options.tokenType || 'spark',
|
|
12715
12933
|
count: options.count,
|
|
12716
|
-
...(
|
|
12934
|
+
...(delivered ? { deliveredWidth: delivered.width, deliveredHeight: delivered.height } : {}),
|
|
12717
12935
|
estimate
|
|
12718
12936
|
}));
|
|
12719
12937
|
} else {
|
|
@@ -12748,13 +12966,14 @@ async function main() {
|
|
|
12748
12966
|
client.on(ClientEvent.JOB_COMPLETED, (data) => {
|
|
12749
12967
|
const jobData = data.job?.data || {};
|
|
12750
12968
|
results.push({
|
|
12751
|
-
resultUrl: data.resultUrl || (options.music ? data.audioUrl : (options.video || options.upscaleVideo) ? data.videoUrl : data.imageUrl),
|
|
12969
|
+
resultUrl: data.resultUrl || ((options.music || options.speech) ? data.audioUrl : (options.video || options.upscaleVideo) ? data.videoUrl : data.imageUrl),
|
|
12970
|
+
lastFrameUrl: data.lastFrameUrl || data.job?.lastFrameUrl || jobData.lastFrameUrl,
|
|
12752
12971
|
seed: jobData.seed,
|
|
12753
12972
|
jobIndex: data.jobIndex,
|
|
12754
12973
|
projectId: data.projectId
|
|
12755
12974
|
});
|
|
12756
12975
|
completedJobs++;
|
|
12757
|
-
log(`${options.music ? 'Music' : (options.video || options.upscaleVideo) ? 'Video' : 'Image'} ${completedJobs}/${options.count} completed`);
|
|
12976
|
+
log(`${options.speech ? 'Speech' : options.imageTo3d ? '3D model' : options.music ? 'Music' : (options.video || options.upscaleVideo) ? 'Video' : 'Image'} ${completedJobs}/${options.count} completed`);
|
|
12758
12977
|
|
|
12759
12978
|
if (completedJobs >= options.count) {
|
|
12760
12979
|
clearTimeout(timeout);
|
|
@@ -12785,7 +13004,7 @@ async function main() {
|
|
|
12785
13004
|
});
|
|
12786
13005
|
|
|
12787
13006
|
// Progress for longer-running media jobs.
|
|
12788
|
-
if (options.video || options.music || options.upscaleVideo) {
|
|
13007
|
+
if (options.video || options.music || options.speech || options.imageTo3d || options.removeBackground || options.upscaleVideo) {
|
|
12789
13008
|
client.on(ClientEvent.PROJECT_PROGRESS, (data) => {
|
|
12790
13009
|
if (data.percentage && data.percentage > 0) {
|
|
12791
13010
|
log(`Progress: ${Math.round(data.percentage)}%`);
|
|
@@ -13106,7 +13325,23 @@ async function main() {
|
|
|
13106
13325
|
? await prepareReferenceAudioIdentityMedia(options.referenceAudioIdentity)
|
|
13107
13326
|
: undefined;
|
|
13108
13327
|
const modelDefaults = getModelDefaults(options.model, openclawConfig);
|
|
13109
|
-
|
|
13328
|
+
let videoDimensionRules = videoDimensionRulesFromDefaults(modelDefaults, options.model);
|
|
13329
|
+
// FastH3 Two-Stage: a downloaded (or local) reference sets the canvas aspect
|
|
13330
|
+
// at the requested delivered class, and the pre-resize stays on that canvas.
|
|
13331
|
+
if (options._miniMaxH3TwoStageAutoCanvas && options.videoWorkflow === 'i2v' && (imageBuffer || endImageBuffer)) {
|
|
13332
|
+
const twoStageRefDims = await getVideoImageDimensionsFromBuffer(imageBuffer || endImageBuffer);
|
|
13333
|
+
if (twoStageRefDims?.width && twoStageRefDims?.height) {
|
|
13334
|
+
const twoStageCanvas = miniMaxH3TwoStageCanvas(
|
|
13335
|
+
options.model,
|
|
13336
|
+
options._miniMaxH3TwoStageClass,
|
|
13337
|
+
twoStageRefDims.width,
|
|
13338
|
+
twoStageRefDims.height
|
|
13339
|
+
);
|
|
13340
|
+
options.width = twoStageCanvas.width;
|
|
13341
|
+
options.height = twoStageCanvas.height;
|
|
13342
|
+
videoDimensionRules = miniMaxH3TwoStageReferenceRules(videoDimensionRules, twoStageCanvas);
|
|
13343
|
+
}
|
|
13344
|
+
}
|
|
13110
13345
|
|
|
13111
13346
|
if (
|
|
13112
13347
|
options.videoWorkflow === 'v2v' &&
|
|
@@ -13253,6 +13488,7 @@ async function main() {
|
|
|
13253
13488
|
if (options.seedanceTaskType) {
|
|
13254
13489
|
projectConfig.seedanceTaskType = options.seedanceTaskType;
|
|
13255
13490
|
}
|
|
13491
|
+
if (options.returnLastFrame) projectConfig.returnLastFrame = true;
|
|
13256
13492
|
if (isWan3Video) {
|
|
13257
13493
|
projectConfig.ratio = options.wan3Ratio;
|
|
13258
13494
|
projectConfig.generateAudio = options.apiGenerateAudio ?? true;
|
|
@@ -13344,17 +13580,13 @@ async function main() {
|
|
|
13344
13580
|
if (options.apiGenerateAudio !== null && (isMiniMaxH3Model(options.model) || isWan3Video)) {
|
|
13345
13581
|
projectConfig.generateAudio = options.apiGenerateAudio;
|
|
13346
13582
|
}
|
|
13347
|
-
if (options.
|
|
13348
|
-
//
|
|
13349
|
-
|
|
13350
|
-
|
|
13351
|
-
|
|
13352
|
-
|
|
13353
|
-
|
|
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
|
-
}
|
|
13583
|
+
if (isMiniMaxH3TwoStageModel(options.model) && !options.quiet) {
|
|
13584
|
+
// Two-stage renders this canvas and delivers twice it: same frames and audio.
|
|
13585
|
+
const delivered = minimaxH3TwoStageDeliveredSize(projectConfig.width, projectConfig.height);
|
|
13586
|
+
console.error(
|
|
13587
|
+
`MiniMax H3 FastH3 Two-Stage: delivered at ${delivered.width}x${delivered.height} ` +
|
|
13588
|
+
`(twice the ${projectConfig.width}x${projectConfig.height} canvas), same length and audio.`
|
|
13589
|
+
);
|
|
13358
13590
|
}
|
|
13359
13591
|
if (Number.isFinite(steps) && !isHappyHorseVideo && !isMiniMaxH3Model(options.model) && !isWan3Video) {
|
|
13360
13592
|
// HappyHorse routes through the vendor-job path and ignores `steps`,
|
|
@@ -13525,6 +13757,27 @@ async function main() {
|
|
|
13525
13757
|
if (upscaleVideoResult?.error || upscaleVideoResult?.message) {
|
|
13526
13758
|
throw annotateVideoUpscaleError(buildProjectResultError(upscaleVideoResult));
|
|
13527
13759
|
}
|
|
13760
|
+
} else if (options.speech) {
|
|
13761
|
+
log(`Generating speech (${options.speechMode}) with ${options.model}...`);
|
|
13762
|
+
let referenceAudio;
|
|
13763
|
+
if (options.voiceReference) {
|
|
13764
|
+
referenceAudio = await fetchMediaBuffer(options.voiceReference);
|
|
13765
|
+
const seconds = await probeMediaBufferDurationSeconds(referenceAudio, options.voiceReference);
|
|
13766
|
+
if (!Number.isFinite(seconds)) throw new Error('Cannot read voice reference duration. Install ffprobe and supply a valid audio recording.');
|
|
13767
|
+
if (seconds < SPEECH_REFERENCE_SECONDS.min || seconds > SPEECH_REFERENCE_SECONDS.max) {
|
|
13768
|
+
throw new Error('Voice cloning requires a 3–30 second reference recording.');
|
|
13769
|
+
}
|
|
13770
|
+
}
|
|
13771
|
+
const result = trackProjectResult(await client.createAudioProject(withBillingMode(speechConfig(options, referenceAudio))));
|
|
13772
|
+
if (result?.error || result?.message) throw buildProjectResultError(result);
|
|
13773
|
+
} else if (options.imageTo3d || options.removeBackground) {
|
|
13774
|
+
log(options.imageTo3d ? 'Building a GLB with Pixal3D...' : 'Removing the background with BiRefNet...');
|
|
13775
|
+
const bytes = await fetchMediaBuffer(options.imageTo3d || options.removeBackground);
|
|
13776
|
+
const dimensions = getImageDimensionsFromBuffer(bytes);
|
|
13777
|
+
if (!dimensions?.width || !dimensions?.height) throw new Error('Supply an original PNG, JPEG, or WebP image.');
|
|
13778
|
+
options.width = dimensions.width; options.height = dimensions.height;
|
|
13779
|
+
const result = trackProjectResult(await client.createImageProject(withBillingMode(imageUtilityConfig(options, bytes))));
|
|
13780
|
+
if (result?.error || result?.message) throw buildProjectResultError(result);
|
|
13528
13781
|
} else if (options.segmentImage) {
|
|
13529
13782
|
log('Selecting the object with SAM 3...');
|
|
13530
13783
|
const bytes = await fetchMediaBuffer(options.segmentImage);
|
|
@@ -13789,11 +14042,11 @@ async function main() {
|
|
|
13789
14042
|
const seeds = results.map(r => r.seed ?? options.seed);
|
|
13790
14043
|
const renderInfo = {
|
|
13791
14044
|
timestamp: new Date().toISOString(),
|
|
13792
|
-
type: options.music ? 'music' : (options.video || options.upscaleVideo) ? 'video' : 'image',
|
|
14045
|
+
type: options.speech ? 'speech' : options.imageTo3d ? 'model' : options.music ? 'music' : (options.video || options.upscaleVideo) ? 'video' : 'image',
|
|
13793
14046
|
prompt: options.prompt,
|
|
13794
14047
|
model: options.model,
|
|
13795
|
-
width: options.music ? null : options.width,
|
|
13796
|
-
height: options.music ? null : options.height,
|
|
14048
|
+
width: (options.music || options.speech || options.imageTo3d) ? null : options.width,
|
|
14049
|
+
height: (options.music || options.speech || options.imageTo3d) ? null : options.height,
|
|
13797
14050
|
seed: firstResult.seed ?? options.seed,
|
|
13798
14051
|
seedStrategy: options.seedStrategy || null,
|
|
13799
14052
|
seeds,
|
|
@@ -13806,6 +14059,10 @@ async function main() {
|
|
|
13806
14059
|
if (options.outputFormat) {
|
|
13807
14060
|
renderInfo.outputFormat = options.outputFormat;
|
|
13808
14061
|
}
|
|
14062
|
+
if (options.returnLastFrame) {
|
|
14063
|
+
renderInfo.returnLastFrame = true;
|
|
14064
|
+
renderInfo.lastFrameUrls = results.map(result => result.lastFrameUrl).filter(Boolean);
|
|
14065
|
+
}
|
|
13809
14066
|
if (options.sampler) {
|
|
13810
14067
|
renderInfo.sampler = options.sampler;
|
|
13811
14068
|
}
|
|
@@ -13849,7 +14106,6 @@ async function main() {
|
|
|
13849
14106
|
renderInfo.duration = options.frames ? options.frames / options.fps : options.duration;
|
|
13850
14107
|
if (options.frames) renderInfo.frames = options.frames;
|
|
13851
14108
|
if (options.targetResolution) renderInfo.targetResolution = options.targetResolution;
|
|
13852
|
-
if (options.outputScale === 2) renderInfo.outputScale = 2;
|
|
13853
14109
|
if (options.autoResizeVideoAssets !== null) {
|
|
13854
14110
|
renderInfo.autoResizeVideoAssets = options.autoResizeVideoAssets;
|
|
13855
14111
|
}
|
|
@@ -13893,12 +14149,15 @@ async function main() {
|
|
|
13893
14149
|
renderInfo.photobooth = true;
|
|
13894
14150
|
renderInfo.refImage = options.refImage;
|
|
13895
14151
|
}
|
|
13896
|
-
|
|
13897
|
-
|
|
14152
|
+
Object.assign(renderInfo, utilityResultMetadata(options));
|
|
14153
|
+
const localPaths = [];
|
|
14154
|
+
|
|
13898
14155
|
// Save to file if requested
|
|
13899
14156
|
if (options.output && urls[0]) {
|
|
13900
14157
|
const response = await fetchWithTimeout(urls[0]);
|
|
14158
|
+
if (!response.ok) throw new Error(`Result download failed: HTTP ${response.status}`);
|
|
13901
14159
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
14160
|
+
if (options.imageTo3d) validateGlb(buffer);
|
|
13902
14161
|
|
|
13903
14162
|
const dir = dirname(options.output);
|
|
13904
14163
|
if (dir && dir !== '.' && !existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
@@ -13945,7 +14204,6 @@ async function main() {
|
|
|
13945
14204
|
else if (options.duration) projectConfig2.duration = options.duration;
|
|
13946
14205
|
if (Number.isFinite(steps2)) projectConfig2.steps = steps2;
|
|
13947
14206
|
if (guidance2 !== null && guidance2 !== undefined) projectConfig2.guidance = guidance2;
|
|
13948
|
-
if (options.outputScale === 2 && isMiniMaxH3Model(options.model)) projectConfig2.outputScale = 2;
|
|
13949
14207
|
|
|
13950
14208
|
// Create a new client for second clip to avoid event conflicts
|
|
13951
14209
|
const creds = loadCredentials();
|
|
@@ -14023,20 +14281,43 @@ async function main() {
|
|
|
14023
14281
|
await buildConcatVideoFromClips(options.output, [clip1Path, clip2Path]);
|
|
14024
14282
|
log(`Saved looping video to ${options.output}`);
|
|
14025
14283
|
} else {
|
|
14026
|
-
writeOutputFileSafe(options.output, buffer, (options.video || options.upscaleVideo) ? 'video' : options.music ? 'audio' : 'image');
|
|
14284
|
+
writeOutputFileSafe(options.output, buffer, (options.video || options.upscaleVideo) ? 'video' : (options.music || options.speech) ? 'audio' : options.imageTo3d ? 'model' : 'image');
|
|
14027
14285
|
log(`Saved to ${options.output}`);
|
|
14028
14286
|
}
|
|
14029
14287
|
}
|
|
14030
14288
|
|
|
14289
|
+
if (options.output && urls[0]) localPaths.push(options.output);
|
|
14290
|
+
if (options.output && (options.speech || options.music)) {
|
|
14291
|
+
for (let index = 1; index < urls.length; index++) {
|
|
14292
|
+
const extension = extname(options.output);
|
|
14293
|
+
const path = options.output.slice(0, options.output.length - extension.length) + `-${index + 1}` + extension;
|
|
14294
|
+
await downloadUrlToFile(urls[index], path);
|
|
14295
|
+
localPaths.push(path);
|
|
14296
|
+
}
|
|
14297
|
+
}
|
|
14298
|
+
if (localPaths.length) renderInfo.localPaths = localPaths;
|
|
14299
|
+
saveLastRender(renderInfo);
|
|
14300
|
+
const lastFramePaths = [];
|
|
14301
|
+
if (options.returnLastFrame && options.output) {
|
|
14302
|
+
for (const [index, result] of results.entries()) {
|
|
14303
|
+
if (!result.lastFrameUrl) continue;
|
|
14304
|
+
const extension = new URL(result.lastFrameUrl).pathname.match(/\.(png|jpe?g|webp)$/i)?.[1] || 'jpg';
|
|
14305
|
+
const framePath = options.output.replace(/\.[^/.]+$/, '') + `-last-frame${results.length > 1 ? `-${index + 1}` : ''}.${extension}`;
|
|
14306
|
+
await downloadUrlToFile(result.lastFrameUrl, framePath);
|
|
14307
|
+
lastFramePaths.push(framePath);
|
|
14308
|
+
log(`Saved last frame to ${framePath}`);
|
|
14309
|
+
}
|
|
14310
|
+
}
|
|
14311
|
+
|
|
14031
14312
|
// Output result
|
|
14032
14313
|
if (options.json) {
|
|
14033
14314
|
const output = {
|
|
14034
14315
|
success: true,
|
|
14035
|
-
type: options.music ? 'music' : (options.video || options.upscaleVideo) ? 'video' : 'image',
|
|
14316
|
+
type: options.speech ? 'speech' : options.imageTo3d ? 'model' : options.music ? 'music' : (options.video || options.upscaleVideo) ? 'video' : 'image',
|
|
14036
14317
|
prompt: options.prompt,
|
|
14037
14318
|
model: options.model,
|
|
14038
|
-
width: options.music ? null : options.width,
|
|
14039
|
-
height: options.music ? null : options.height,
|
|
14319
|
+
width: (options.music || options.speech || options.imageTo3d) ? null : options.width,
|
|
14320
|
+
height: (options.music || options.speech || options.imageTo3d) ? null : options.height,
|
|
14040
14321
|
seed: firstResult.seed ?? options.seed,
|
|
14041
14322
|
seedStrategy: options.seedStrategy || null,
|
|
14042
14323
|
seeds,
|
|
@@ -14044,9 +14325,15 @@ async function main() {
|
|
|
14044
14325
|
localPath: options.output || null,
|
|
14045
14326
|
tokenType: options.tokenType || 'spark'
|
|
14046
14327
|
};
|
|
14328
|
+
Object.assign(output, utilityResultMetadata(options));
|
|
14329
|
+
if (localPaths.length) output.localPaths = localPaths;
|
|
14047
14330
|
if (options.outputFormat) {
|
|
14048
14331
|
output.outputFormat = options.outputFormat;
|
|
14049
14332
|
}
|
|
14333
|
+
if (options.returnLastFrame) {
|
|
14334
|
+
output.lastFrameUrls = results.map(result => result.lastFrameUrl).filter(Boolean);
|
|
14335
|
+
if (lastFramePaths.length) output.lastFramePaths = lastFramePaths;
|
|
14336
|
+
}
|
|
14050
14337
|
if (options.sampler) {
|
|
14051
14338
|
output.sampler = options.sampler;
|
|
14052
14339
|
}
|
|
@@ -14089,7 +14376,11 @@ async function main() {
|
|
|
14089
14376
|
output.duration = options.frames ? options.frames / options.fps : options.duration;
|
|
14090
14377
|
if (options.frames) output.frames = options.frames;
|
|
14091
14378
|
if (options.targetResolution) output.targetResolution = options.targetResolution;
|
|
14092
|
-
if (options.
|
|
14379
|
+
if (isMiniMaxH3TwoStageModel(options.model)) {
|
|
14380
|
+
const delivered = minimaxH3TwoStageDeliveredSize(options.width, options.height);
|
|
14381
|
+
output.deliveredWidth = delivered.width;
|
|
14382
|
+
output.deliveredHeight = delivered.height;
|
|
14383
|
+
}
|
|
14093
14384
|
output.strictSize = options.strictSize || false;
|
|
14094
14385
|
if (options.autoResizeVideoAssets !== null) {
|
|
14095
14386
|
output.autoResizeVideoAssets = options.autoResizeVideoAssets;
|
|
@@ -14153,6 +14444,9 @@ async function main() {
|
|
|
14153
14444
|
console.log(JSON.stringify(output));
|
|
14154
14445
|
} else {
|
|
14155
14446
|
urls.forEach(url => console.log(url));
|
|
14447
|
+
if (options.returnLastFrame) {
|
|
14448
|
+
results.forEach(result => { if (result.lastFrameUrl) console.log(`Last frame: ${result.lastFrameUrl}`); });
|
|
14449
|
+
}
|
|
14156
14450
|
}
|
|
14157
14451
|
} else {
|
|
14158
14452
|
throw new Error('No output generated - may have been filtered');
|
|
@@ -14161,7 +14455,6 @@ async function main() {
|
|
|
14161
14455
|
} catch (error) {
|
|
14162
14456
|
// A FlashVSR refusal can also arrive as a project event after submission.
|
|
14163
14457
|
if (options.upscaleVideo) annotateVideoUpscaleError(error);
|
|
14164
|
-
if (options.video && options.outputScale === 2) annotateMiniMaxH3OutputScaleError(error);
|
|
14165
14458
|
// Token auto-fallback: if using auto mode and got insufficient balance, retry with the other token
|
|
14166
14459
|
const isBalanceError = isStructuredInsufficientBalanceError(error);
|
|
14167
14460
|
if (_allowAutoTokenFallback && isBalanceError && options.tokenType === 'spark') {
|