@sogni-ai/sogni-creative-agent-skill 3.53.0 → 3.54.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 +5 -2
- package/.agents/skills/sogni-creative-agent-skill/references/hosted-api.md +53 -2
- package/.agents/skills/sogni-creative-agent-skill/references/models.md +50 -2
- package/.agents/skills/sogni-creative-agent-skill/references/video-prompting.md +79 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/CHANGELOG.md +14 -0
- package/README.md +9 -2
- package/SKILL.md +10 -10
- package/desktop-extension/manifest.json +1 -1
- package/desktop-extension/server/tools.mjs +28 -0
- package/generated/creative-agent-runtime.mjs +9 -6
- package/llm.txt +4 -2
- package/openclaw.plugin.json +1 -1
- package/package.json +3 -3
- package/plugin-skills/sogni-creative-agent/SKILL.md +3 -0
- package/references/hosted-api.md +53 -2
- package/references/models.md +50 -2
- package/references/video-prompting.md +79 -1
- package/skill-package.json +2 -2
- package/skills/video_editing.md +1 -0
- package/skills/video_generation.md +1 -0
- package/sogni-agent.mjs +337 -9
- package/version.mjs +1 -1
package/sogni-agent.mjs
CHANGED
|
@@ -104,7 +104,15 @@ import {
|
|
|
104
104
|
isMinimaxH3TwoStageModelId,
|
|
105
105
|
minimaxH3TwoStageCanvasShortEdge,
|
|
106
106
|
minimaxH3TwoStageDeliveredSize,
|
|
107
|
-
prepareSeedanceV2VSourceVideo as prepareSharedSeedanceV2VSourceVideo
|
|
107
|
+
prepareSeedanceV2VSourceVideo as prepareSharedSeedanceV2VSourceVideo,
|
|
108
|
+
getWan22VideoSizeRefusal,
|
|
109
|
+
WAN22_MAX_VIDEO_PIXELS,
|
|
110
|
+
// MiniMax H3 intermediate keyframes: the frame math and checks every
|
|
111
|
+
// surface shares (Intelligence Client with SDK 5.58.0 keyframes support).
|
|
112
|
+
checkMinimaxH3Keyframes,
|
|
113
|
+
isMinimaxH3KeyframeModelId,
|
|
114
|
+
minimaxH3KeyframeFrameIndex,
|
|
115
|
+
MINIMAX_H3_MAX_KEYFRAMES
|
|
108
116
|
} from '@sogni-ai/sogni-intelligence-client/media';
|
|
109
117
|
import {
|
|
110
118
|
HAPPYHORSE_REFERENCE_LIMITS,
|
|
@@ -821,9 +829,32 @@ function classifyCliError(error, context = {}) {
|
|
|
821
829
|
if (happyhorseClassified) return happyhorseClassified;
|
|
822
830
|
}
|
|
823
831
|
|
|
832
|
+
// Socket 4100: no online worker serving this model can pin MiniMax H3
|
|
833
|
+
// keyframes yet. That is capacity, not a defect in the request: retryable.
|
|
834
|
+
if (isMiniMaxH3KeyframesUnavailableError(error)) {
|
|
835
|
+
const socketMessage = /keyframe/i.test(rawMessage) ? rawMessage : null;
|
|
836
|
+
return {
|
|
837
|
+
error_type: 'MODEL_UNAVAILABLE',
|
|
838
|
+
category: 'model_unavailable',
|
|
839
|
+
message: socketMessage || MINIMAX_H3_KEYFRAMES_UNAVAILABLE_MESSAGE,
|
|
840
|
+
retryable: true,
|
|
841
|
+
...(!socketMessage && rawMessage ? { technicalError: rawMessage } : {})
|
|
842
|
+
};
|
|
843
|
+
}
|
|
844
|
+
|
|
824
845
|
return classifySkillError(error);
|
|
825
846
|
}
|
|
826
847
|
|
|
848
|
+
const MINIMAX_H3_KEYFRAMES_UNAVAILABLE_CODE = '4100';
|
|
849
|
+
const MINIMAX_H3_KEYFRAMES_UNAVAILABLE_MESSAGE = 'No worker that can pin MiniMax H3 keyframes is online for this model right now. '
|
|
850
|
+
+ 'Try again shortly, or render without --keyframe.';
|
|
851
|
+
|
|
852
|
+
function isMiniMaxH3KeyframesUnavailableError(error) {
|
|
853
|
+
if (!error || typeof error !== 'object') return false;
|
|
854
|
+
return [error.code, error.errorCode, error.error_code, error.originalCode, error.payload?.errorCode, error.payload?.error_code]
|
|
855
|
+
.some((code) => code !== undefined && code !== null && String(code) === MINIMAX_H3_KEYFRAMES_UNAVAILABLE_CODE);
|
|
856
|
+
}
|
|
857
|
+
|
|
827
858
|
function addCanonicalErrorFields(payload, error, context = {}) {
|
|
828
859
|
const classified = classifyCliError(error, context);
|
|
829
860
|
payload.error = classified.message;
|
|
@@ -1049,6 +1080,7 @@ function applyCreativeBrainPreflight() {
|
|
|
1049
1080
|
options.height = plan.height;
|
|
1050
1081
|
widthFromPrompt = true;
|
|
1051
1082
|
heightFromPrompt = true;
|
|
1083
|
+
exactPixelsFromPrompt = true;
|
|
1052
1084
|
}
|
|
1053
1085
|
// The planner reports a stated aspect even when --target-resolution keeps it
|
|
1054
1086
|
// from sizing the canvas itself (dimensionSource stays unset then). The aspect
|
|
@@ -1228,6 +1260,8 @@ function computePromptHashSeed(opts) {
|
|
|
1228
1260
|
loraStrengths: opts.loraStrengths || [],
|
|
1229
1261
|
refImage: opts.refImage || '',
|
|
1230
1262
|
refImageEnd: opts.refImageEnd || '',
|
|
1263
|
+
// Only when present, so seeds of requests without keyframes never change.
|
|
1264
|
+
...(opts.keyframes?.length ? { keyframes: opts.keyframes.map(({ image, seconds }) => [image, seconds]) } : {}),
|
|
1231
1265
|
refAudio: opts.refAudio || '',
|
|
1232
1266
|
audioStart: opts.audioStart ?? null,
|
|
1233
1267
|
audioDuration: opts.audioDuration ?? null,
|
|
@@ -2501,6 +2535,46 @@ function miniMaxH3FramesForDuration(durationSeconds) {
|
|
|
2501
2535
|
return Math.max(min, Math.min(max, min + Math.round((desiredFrames - min) / step) * step));
|
|
2502
2536
|
}
|
|
2503
2537
|
|
|
2538
|
+
// MiniMax H3 intermediate keyframes: still images the worker pins at chosen
|
|
2539
|
+
// frames strictly between the first and the last frame (repeatable
|
|
2540
|
+
// --keyframe <image>@<seconds>). They are in addition to --ref/--ref-end, never
|
|
2541
|
+
// a replacement. The image-to-video, first/last-frame, Sound to Video (FastH3
|
|
2542
|
+
// audio guide) and Reference to Video ids take them (isMinimaxH3KeyframeModelId);
|
|
2543
|
+
// text-to-video never does.
|
|
2544
|
+
const MINIMAX_H3_KEYFRAME_MODELS_HINT = 'Keyframes work on the MiniMax H3 image-to-video and first/last-frame models '
|
|
2545
|
+
+ '(minimax-h3-i2v, minimax-h3-flf2v and their -balanced, -turbo, -fasth3 and two-stage forms), '
|
|
2546
|
+
+ 'the FastH3 Sound to Video models (minimax-h3-fasth3-ia2v-turbo, -flfa2v-turbo, -a2v-turbo and their -2stage forms) '
|
|
2547
|
+
+ 'and Reference to Video (minimax-h3-r2v and its -balanced, -turbo and two-stage forms).';
|
|
2548
|
+
|
|
2549
|
+
// A pinned frame's time as an H3 cut-marker clock (MM:SS.mmm), rounded down to
|
|
2550
|
+
// the millisecond so a cut written at it never lands after the keyframe.
|
|
2551
|
+
function formatMiniMaxH3KeyframeClock(frameIndex) {
|
|
2552
|
+
const millis = Math.floor((frameIndex * 1000) / MINIMAX_H3_FRAME_GRID.fps);
|
|
2553
|
+
const minutes = String(Math.floor(millis / 60000)).padStart(2, '0');
|
|
2554
|
+
const seconds = String(Math.floor((millis % 60000) / 1000)).padStart(2, '0');
|
|
2555
|
+
return `${minutes}:${seconds}.${String(millis % 1000).padStart(3, '0')}`;
|
|
2556
|
+
}
|
|
2557
|
+
|
|
2558
|
+
// `--keyframe <image>@<seconds>`: the last "@" separates the time, so a path or
|
|
2559
|
+
// URL that itself contains "@" still parses. A trailing "s" is accepted.
|
|
2560
|
+
function parseKeyframeFlagValue(raw, flag = '--keyframe') {
|
|
2561
|
+
const text = String(raw ?? '').trim();
|
|
2562
|
+
const at = text.lastIndexOf('@');
|
|
2563
|
+
const imagePart = at > 0 ? text.slice(0, at).trim() : '';
|
|
2564
|
+
const timeMatch = at > 0 ? /^(\d+(?:\.\d+)?|\.\d+)s?$/i.exec(text.slice(at + 1).trim()) : null;
|
|
2565
|
+
if (!imagePart || !timeMatch) {
|
|
2566
|
+
fatalCliError(
|
|
2567
|
+
`${flag} takes <image>@<seconds>: the image, then when the video lands on it (got "${text}").`,
|
|
2568
|
+
{
|
|
2569
|
+
code: 'INVALID_ARGUMENT',
|
|
2570
|
+
details: { flag, value: text },
|
|
2571
|
+
hint: `Example: ${flag} ./turn.png@3.5 pins turn.png 3.5 seconds into the clip. Repeat ${flag} for up to ${MINIMAX_H3_MAX_KEYFRAMES} keyframes.`
|
|
2572
|
+
}
|
|
2573
|
+
);
|
|
2574
|
+
}
|
|
2575
|
+
return { image: expandHomePath(imagePart), seconds: Number(timeMatch[1]) };
|
|
2576
|
+
}
|
|
2577
|
+
|
|
2504
2578
|
const LTX23_10EROS_FIXED_SETTINGS = Object.freeze({
|
|
2505
2579
|
steps: 9,
|
|
2506
2580
|
guidance: 1,
|
|
@@ -3152,6 +3226,7 @@ const options = {
|
|
|
3152
3226
|
angles360Video: null,
|
|
3153
3227
|
refImage: null, // Reference image for video (start frame)
|
|
3154
3228
|
refImageEnd: null, // End frame for video interpolation
|
|
3229
|
+
keyframes: [], // MiniMax H3 intermediate keyframes from repeatable --keyframe <image>@<seconds>: [{ image, seconds, frameIndex }]
|
|
3155
3230
|
refAudio: null, // Uploaded/generated audio for ia2v/a2v, or s2v lip-sync (primary)
|
|
3156
3231
|
refAudios: [], // Additional Seedance loose audio refs; first --ref-audio fills refAudio, subsequent calls append here
|
|
3157
3232
|
audioStart: null, // Optional start offset into reference audio
|
|
@@ -3351,6 +3426,7 @@ const cliSet = {
|
|
|
3351
3426
|
videoModel: false,
|
|
3352
3427
|
refImage: false,
|
|
3353
3428
|
refImageEnd: false,
|
|
3429
|
+
keyframes: false,
|
|
3354
3430
|
refAudio: false,
|
|
3355
3431
|
refAudios: false,
|
|
3356
3432
|
audioStart: false,
|
|
@@ -3719,6 +3795,11 @@ for (let i = 0; i < args.length; i++) {
|
|
|
3719
3795
|
i++;
|
|
3720
3796
|
options.refImageEnd = raw;
|
|
3721
3797
|
cliSet.refImageEnd = true;
|
|
3798
|
+
} else if (arg === '--keyframe') {
|
|
3799
|
+
const raw = requireFlagValue(args, i, arg);
|
|
3800
|
+
i++;
|
|
3801
|
+
options.keyframes.push(parseKeyframeFlagValue(raw, arg));
|
|
3802
|
+
cliSet.keyframes = true;
|
|
3722
3803
|
} else if (arg === '--ref-audio' || arg === '--audio') {
|
|
3723
3804
|
const raw = expandHomePath(requireFlagValue(args, i, arg));
|
|
3724
3805
|
i++;
|
|
@@ -4585,6 +4666,11 @@ Video Options:
|
|
|
4585
4666
|
--ref-end <path|url> End frame for interpolation/morphing; with --ref it
|
|
4586
4667
|
defaults to the LTX-2.5 i2v first/last-frame workflow
|
|
4587
4668
|
(last frame on Seedance; L2VA endpoint on MiniMax H3 i2v)
|
|
4669
|
+
--keyframe <image>@<sec> MiniMax H3 only: pin an image (path or URL) at that time inside the clip,
|
|
4670
|
+
in addition to --ref/--ref-end. Repeatable, up to 8, strictly between the
|
|
4671
|
+
first and last frame. H3 i2v/flf2v, FastH3 Sound to Video and Ref2VA models.
|
|
4672
|
+
Describe what each keyframe shows in the prompt at its time. Two keyframes
|
|
4673
|
+
are included in the price; each extra one adds a little.
|
|
4588
4674
|
--ref-audio <path|url> Audio reference. Repeatable on Seedance and H3 r2v (up to 3 total);
|
|
4589
4675
|
first entry is the primary, extras must be HTTPS URLs in CLI
|
|
4590
4676
|
direct-gen for Seedance; H3 r2v uploads local/remote files.
|
|
@@ -4966,6 +5052,7 @@ let fpsFromConfig = false;
|
|
|
4966
5052
|
let widthFromPrompt = false;
|
|
4967
5053
|
let heightFromPrompt = false;
|
|
4968
5054
|
let targetResolutionFromPrompt = false;
|
|
5055
|
+
let exactPixelsFromPrompt = false;
|
|
4969
5056
|
let durationFromPrompt = false;
|
|
4970
5057
|
let aspectRatioFromPrompt = null;
|
|
4971
5058
|
let configuredDefaultVideoWorkflow = null;
|
|
@@ -6378,6 +6465,24 @@ if (options.video) {
|
|
|
6378
6465
|
details: { targetResolution: options.targetResolution }
|
|
6379
6466
|
});
|
|
6380
6467
|
}
|
|
6468
|
+
// Wan 2.2 renders at most 1,048,576 pixels per frame (1024x1024), so its
|
|
6469
|
+
// short side can never exceed 1024: 1080p, 1440p and 4K cannot fit. Refuse the
|
|
6470
|
+
// named resolution instead of rendering it smaller without saying so.
|
|
6471
|
+
if (
|
|
6472
|
+
isWanVideoModelId(options.model) &&
|
|
6473
|
+
(cliSet.targetResolution || targetResolutionFromPrompt) &&
|
|
6474
|
+
Number(options.targetResolution) > 1024
|
|
6475
|
+
) {
|
|
6476
|
+
fatalCliError(
|
|
6477
|
+
`Wan 2.2 cannot render ${options.targetResolution}p. It renders at most 1,048,576 pixels per frame (1024×1024), ` +
|
|
6478
|
+
'so its short side is at most 1024 pixels.',
|
|
6479
|
+
{
|
|
6480
|
+
code: 'INVALID_ARGUMENT',
|
|
6481
|
+
details: { model: options.model, targetResolution: options.targetResolution, maxPixels: WAN22_MAX_VIDEO_PIXELS },
|
|
6482
|
+
hint: `Use --target-resolution 720 (or 768), -w 1024 -h 1024, or -m ltx25 for ${options.targetResolution}p.`
|
|
6483
|
+
}
|
|
6484
|
+
);
|
|
6485
|
+
}
|
|
6381
6486
|
if (isWan3Video && cliSet.targetResolution && !WAN3_SUPPORTED_RESOLUTIONS.has(options.targetResolution)) {
|
|
6382
6487
|
fatalCliError('Wan 3 --target-resolution must be 480, 720, or 1080.', {
|
|
6383
6488
|
code: 'INVALID_ARGUMENT',
|
|
@@ -6984,6 +7089,112 @@ if (options.video && !options.frames) {
|
|
|
6984
7089
|
options.fps = h3Fps;
|
|
6985
7090
|
}
|
|
6986
7091
|
|
|
7092
|
+
// MiniMax H3 intermediate keyframes (--keyframe <image>@<seconds>), checked once
|
|
7093
|
+
// the model and the frame count are final so every error names the clip it was
|
|
7094
|
+
// checked against. Direct renders pin each time to a frame of the job's 24fps
|
|
7095
|
+
// grid; hosted chat uploads the images for the agent to pin, and the hosted
|
|
7096
|
+
// tool checks the times against the length it picks. Nothing is clamped or dropped.
|
|
7097
|
+
function validateMiniMaxH3KeyframeOptions() {
|
|
7098
|
+
const keyframes = options.keyframes;
|
|
7099
|
+
if (keyframes.length === 0) return;
|
|
7100
|
+
const fail = (message, details = {}, hint = undefined) => fatalCliError(message, {
|
|
7101
|
+
code: 'INVALID_ARGUMENT',
|
|
7102
|
+
details: { flag: '--keyframe', ...details },
|
|
7103
|
+
...(hint ? { hint } : {})
|
|
7104
|
+
});
|
|
7105
|
+
if (options.apiWorkflowAction) {
|
|
7106
|
+
fail(
|
|
7107
|
+
'--keyframe does not apply to --api-workflow. Put keyframes: [{ "imageIndex": -1, "atSeconds": 3.5 }] in the '
|
|
7108
|
+
+ 'animate_photo, sound_to_video or generate_video step arguments of --workflow-input, and attach the images with -c/--context.',
|
|
7109
|
+
{ apiWorkflow: true }
|
|
7110
|
+
);
|
|
7111
|
+
}
|
|
7112
|
+
if (!options.apiChat && !options.video) {
|
|
7113
|
+
fail('--keyframe requires --video with a MiniMax H3 model (or --api-chat / --durable-chat).');
|
|
7114
|
+
}
|
|
7115
|
+
const conflict = [
|
|
7116
|
+
['--looping', options.looping],
|
|
7117
|
+
['--angles-360-video', options.angles360Video],
|
|
7118
|
+
['--source-reel', options.sourceReelDir],
|
|
7119
|
+
['--multi-angle', options.multiAngle]
|
|
7120
|
+
].find(([, enabled]) => enabled);
|
|
7121
|
+
if (conflict) {
|
|
7122
|
+
fail(`--keyframe cannot be combined with ${conflict[0]}, which renders more than one clip.`, { conflictsWith: conflict[0] });
|
|
7123
|
+
}
|
|
7124
|
+
if (keyframes.length > MINIMAX_H3_MAX_KEYFRAMES) {
|
|
7125
|
+
fail(
|
|
7126
|
+
`MiniMax H3 pins at most ${MINIMAX_H3_MAX_KEYFRAMES} keyframes (got ${keyframes.length}).`,
|
|
7127
|
+
{ count: keyframes.length, maximum: MINIMAX_H3_MAX_KEYFRAMES }
|
|
7128
|
+
);
|
|
7129
|
+
}
|
|
7130
|
+
for (const keyframe of keyframes) {
|
|
7131
|
+
if (!isHttpUrl(keyframe.image) && !existsSync(keyframe.image)) {
|
|
7132
|
+
fatalCliError(`Keyframe image not found: ${keyframe.image}`, {
|
|
7133
|
+
code: 'MISSING_FILE',
|
|
7134
|
+
details: { flag: '--keyframe', path: keyframe.image, seconds: keyframe.seconds },
|
|
7135
|
+
hint: 'Check the path, or pass an http(s) URL.'
|
|
7136
|
+
});
|
|
7137
|
+
}
|
|
7138
|
+
}
|
|
7139
|
+
|
|
7140
|
+
// Direct renders know the model and the frame count the job renders (a Sound
|
|
7141
|
+
// to Video window is always the clip length). Hosted chat does not: the agent
|
|
7142
|
+
// picks both, so only what holds for every H3 clip is checked here.
|
|
7143
|
+
let frames;
|
|
7144
|
+
let edgeHint;
|
|
7145
|
+
if (!options.apiChat) {
|
|
7146
|
+
if (!isMinimaxH3KeyframeModelId(options.model)) {
|
|
7147
|
+
const textToVideo = isMiniMaxH3Model(options.model);
|
|
7148
|
+
fail(
|
|
7149
|
+
textToVideo
|
|
7150
|
+
? `${options.model} is MiniMax H3 text-to-video, which cannot pin keyframes. Add --ref (or --ref-end) for image-to-video, or pick a Sound to Video or Reference to Video model.`
|
|
7151
|
+
: `--keyframe is MiniMax H3 only; ${options.model} does not take keyframes.`,
|
|
7152
|
+
{ model: options.model },
|
|
7153
|
+
MINIMAX_H3_KEYFRAME_MODELS_HINT
|
|
7154
|
+
);
|
|
7155
|
+
}
|
|
7156
|
+
frames = options.frames;
|
|
7157
|
+
edgeHint = {
|
|
7158
|
+
i2v: 'the first and last frames come from --ref and --ref-end',
|
|
7159
|
+
flf2v: 'the first and last frames come from --ref and --ref-end',
|
|
7160
|
+
flfa2v: 'the first and last frames come from --ref and --ref-end',
|
|
7161
|
+
ia2v: 'the first frame comes from --ref, and the last frame cannot be pinned',
|
|
7162
|
+
a2v: 'audio-only clips cannot pin their first or last frame',
|
|
7163
|
+
r2v: 'reference-to-video cannot pin its first or last frame'
|
|
7164
|
+
}[miniMaxH3ModeFromModelId(options.model)];
|
|
7165
|
+
}
|
|
7166
|
+
|
|
7167
|
+
// The shared check names entries by position; the CLI names them by the
|
|
7168
|
+
// order the --keyframe flags were given.
|
|
7169
|
+
const check = checkMinimaxH3Keyframes(
|
|
7170
|
+
keyframes.map(({ seconds }, index) => ({ imageIndex: index, atSeconds: seconds })),
|
|
7171
|
+
{
|
|
7172
|
+
...(frames ? {
|
|
7173
|
+
frames,
|
|
7174
|
+
framesSource: cliSet.frames ? `--frames ${frames}` : `--duration ${options.duration} renders ${frames} frames`,
|
|
7175
|
+
suggestDuration: true
|
|
7176
|
+
} : {}),
|
|
7177
|
+
...(edgeHint ? { edgeHint } : {})
|
|
7178
|
+
}
|
|
7179
|
+
);
|
|
7180
|
+
if (!check.ok) {
|
|
7181
|
+
const message = check.errors
|
|
7182
|
+
.map((error) => error
|
|
7183
|
+
.replace(/keyframes\[(\d+)\]/g, (_match, index) => `keyframe ${Number(index) + 1} (${keyframes[Number(index)].image})`)
|
|
7184
|
+
.replace('or set duration to', 'or set --duration to'))
|
|
7185
|
+
.map((error) => `${error.charAt(0).toUpperCase()}${error.slice(1)}`)
|
|
7186
|
+
.join(' ');
|
|
7187
|
+
fail(message, {
|
|
7188
|
+
keyframes: keyframes.map(({ image, seconds }) => ({ image, seconds })),
|
|
7189
|
+
...(frames ? { frames } : {})
|
|
7190
|
+
});
|
|
7191
|
+
}
|
|
7192
|
+
// Time order is the order the keyframes are uploaded, pinned and described in.
|
|
7193
|
+
options.keyframes = check.keyframes.map(({ imageIndex, frameIndex }) => ({ ...keyframes[imageIndex], frameIndex }));
|
|
7194
|
+
}
|
|
7195
|
+
|
|
7196
|
+
validateMiniMaxH3KeyframeOptions();
|
|
7197
|
+
|
|
6987
7198
|
// Video dimensions:
|
|
6988
7199
|
// - Sogni video pipelines have model-specific min/max dimensions and divisors.
|
|
6989
7200
|
// - When using i2v (or any ref-based workflow), the Sogni client wrapper will *resize the reference image*
|
|
@@ -7073,6 +7284,26 @@ if (options.video) {
|
|
|
7073
7284
|
const originalVideoWidth = options.width;
|
|
7074
7285
|
const originalVideoHeight = options.height;
|
|
7075
7286
|
const normalizedVideoDims = normalizeVideoDimensionsLikeWrapper(options.width, options.height, videoDimensionRules);
|
|
7287
|
+
// Wan 2.2 renders at most 1,048,576 pixels per frame, with each side between
|
|
7288
|
+
// 480 and 1536. Since 2026-09-26 the network scales a larger request down to
|
|
7289
|
+
// about 1 MP (a side below 480 is still refused, error 4101). A size the user
|
|
7290
|
+
// asked for (-w/-h or exact pixels in the prompt) is refused here instead of
|
|
7291
|
+
// being shrunk without asking; sizes the CLI chooses itself are fitted by the
|
|
7292
|
+
// rules above.
|
|
7293
|
+
if (isWanVideoModelId(options.model) && (cliSet.width || cliSet.height || exactPixelsFromPrompt)) {
|
|
7294
|
+
const refusal = getWan22VideoSizeRefusal(originalVideoWidth, originalVideoHeight);
|
|
7295
|
+
if (refusal) {
|
|
7296
|
+
fatalCliError(refusal, {
|
|
7297
|
+
code: 'INVALID_VIDEO_SIZE',
|
|
7298
|
+
details: {
|
|
7299
|
+
model: options.model,
|
|
7300
|
+
requested: { width: originalVideoWidth, height: originalVideoHeight },
|
|
7301
|
+
maxPixels: WAN22_MAX_VIDEO_PIXELS
|
|
7302
|
+
},
|
|
7303
|
+
hint: `Try: --width ${normalizedVideoDims.width} --height ${normalizedVideoDims.height}, or -m ltx25 for a larger size.`
|
|
7304
|
+
});
|
|
7305
|
+
}
|
|
7306
|
+
}
|
|
7076
7307
|
options.width = normalizedVideoDims.width;
|
|
7077
7308
|
options.height = normalizedVideoDims.height;
|
|
7078
7309
|
if (isMiniMaxH3Model(options.model) && options.width * options.height > 1344 * 768) {
|
|
@@ -7692,6 +7923,16 @@ function getApiModeMediaReferences() {
|
|
|
7692
7923
|
}
|
|
7693
7924
|
if (options.refImage) refs.push({ flag: '--ref', value: options.refImage, kind: 'image' });
|
|
7694
7925
|
if (options.refImageEnd) refs.push({ flag: '--ref-end', value: options.refImageEnd, kind: 'image' });
|
|
7926
|
+
// MiniMax H3 keyframes follow the frame images, in time order, so the hosted
|
|
7927
|
+
// agent can pin each one by its upload index (-1 is the first image upload).
|
|
7928
|
+
for (const [index, keyframe] of options.keyframes.entries()) {
|
|
7929
|
+
refs.push({
|
|
7930
|
+
flag: '--keyframe',
|
|
7931
|
+
value: keyframe.image,
|
|
7932
|
+
kind: 'image',
|
|
7933
|
+
keyframe: { slot: index + 1, seconds: keyframe.seconds, frameIndex: keyframe.frameIndex }
|
|
7934
|
+
});
|
|
7935
|
+
}
|
|
7695
7936
|
if (options.refAudio) refs.push({ flag: '--ref-audio', value: options.refAudio, kind: 'audio' });
|
|
7696
7937
|
for (const value of options.refAudios || []) {
|
|
7697
7938
|
if (value) refs.push({ flag: '--ref-audio', value, kind: 'audio' });
|
|
@@ -7769,6 +8010,7 @@ function apiMediaReferenceUploadType(ref, index) {
|
|
|
7769
8010
|
if (ref.kind === 'audio') return 'referenceAudio';
|
|
7770
8011
|
if (ref.kind === 'video') return 'referenceVideo';
|
|
7771
8012
|
if (ref.flag === '--ref-end') return 'referenceImageEnd';
|
|
8013
|
+
if (ref.flag === '--keyframe') return `keyframeImage${ref.keyframe.slot}`;
|
|
7772
8014
|
if (ref.flag === '--mask') return `contextImage${Math.min(index + 1, 16)}`;
|
|
7773
8015
|
if (ref.flag === '-c/--context') return `contextImage${Math.min(index + 1, 16)}`;
|
|
7774
8016
|
return 'referenceImage';
|
|
@@ -8039,6 +8281,29 @@ function formatApiMediaReferencesForPrompt(mediaReferences) {
|
|
|
8039
8281
|
return `API media references:\n${lines.join('\n')}`;
|
|
8040
8282
|
}
|
|
8041
8283
|
|
|
8284
|
+
// The --keyframe request in the hosted tools' own terms. Negative imageIndex
|
|
8285
|
+
// counts image uploads only, in media_references order (-1 is the first), so
|
|
8286
|
+
// each keyframe is named by its position among the image references.
|
|
8287
|
+
function formatApiKeyframePlanForPrompt(imageRefs) {
|
|
8288
|
+
const keyframes = imageRefs
|
|
8289
|
+
.map((ref, position) => (ref.keyframe ? { ref, imageIndex: -(position + 1) } : null))
|
|
8290
|
+
.filter(Boolean);
|
|
8291
|
+
if (keyframes.length === 0) return '';
|
|
8292
|
+
const argument = JSON.stringify(keyframes.map(({ ref, imageIndex }) => ({
|
|
8293
|
+
imageIndex,
|
|
8294
|
+
atSeconds: ref.keyframe.seconds
|
|
8295
|
+
})));
|
|
8296
|
+
const clocks = keyframes
|
|
8297
|
+
.map(({ ref }) => formatMiniMaxH3KeyframeClock(ref.keyframe.frameIndex ?? minimaxH3KeyframeFrameIndex(ref.keyframe.seconds)))
|
|
8298
|
+
.join(', ');
|
|
8299
|
+
return [
|
|
8300
|
+
'MiniMax H3 keyframes: pin these uploaded images inside the video, in addition to any first or last frame, '
|
|
8301
|
+
+ `with the keyframes argument ${argument}.`,
|
|
8302
|
+
'Use a MiniMax H3 image-to-video, first/last-frame, Sound to Video or Reference to Video model, keep the clip '
|
|
8303
|
+
+ `longer than the last keyframe, and describe in the video prompt what each keyframe shows at its time (${clocks}).`
|
|
8304
|
+
].join('\n');
|
|
8305
|
+
}
|
|
8306
|
+
|
|
8042
8307
|
function extractApiEnvelopeData(payload) {
|
|
8043
8308
|
return payload?.data && typeof payload.data === 'object' ? payload.data : payload;
|
|
8044
8309
|
}
|
|
@@ -8189,7 +8454,8 @@ async function buildApiChatMessages(apiMediaRefs, apiMediaReferences) {
|
|
|
8189
8454
|
const nonImageRefs = apiMediaReferences.filter(ref => ref.kind !== 'image');
|
|
8190
8455
|
const promptText = [
|
|
8191
8456
|
options.prompt || 'Describe the attached media.',
|
|
8192
|
-
formatApiMediaReferencesForPrompt(nonImageRefs)
|
|
8457
|
+
formatApiMediaReferencesForPrompt(nonImageRefs),
|
|
8458
|
+
formatApiKeyframePlanForPrompt(imageRefs)
|
|
8193
8459
|
].filter(Boolean).join('\n\n');
|
|
8194
8460
|
|
|
8195
8461
|
const messages = [{ role: 'system', content: system }];
|
|
@@ -11506,7 +11772,7 @@ function roundToMultiple(value, multiple) {
|
|
|
11506
11772
|
return Math.max(multiple, Math.round(value / multiple) * multiple);
|
|
11507
11773
|
}
|
|
11508
11774
|
|
|
11509
|
-
function inferSourceReelDimensions(metadata, targetShortSide) {
|
|
11775
|
+
function inferSourceReelDimensions(metadata, targetShortSide, model = SOURCE_REEL_DEFAULT_MODEL) {
|
|
11510
11776
|
const rawWidth = Number(metadata?.width) || targetShortSide;
|
|
11511
11777
|
const rawHeight = Number(metadata?.height) || targetShortSide;
|
|
11512
11778
|
const aspect = rawWidth > 0 && rawHeight > 0 ? rawWidth / rawHeight : 1;
|
|
@@ -11533,10 +11799,16 @@ function inferSourceReelDimensions(metadata, targetShortSide) {
|
|
|
11533
11799
|
height *= scale;
|
|
11534
11800
|
}
|
|
11535
11801
|
|
|
11536
|
-
|
|
11537
|
-
|
|
11538
|
-
|
|
11539
|
-
|
|
11802
|
+
let roundedWidth = roundToMultiple(width, 16);
|
|
11803
|
+
let roundedHeight = roundToMultiple(height, 16);
|
|
11804
|
+
// Wan 2.2 (the default reel model) renders at most 1,048,576 pixels per
|
|
11805
|
+
// frame, so a size chosen for it is fitted inside that budget.
|
|
11806
|
+
if (isWanVideoModelId(model) && roundedWidth * roundedHeight > WAN22_MAX_VIDEO_PIXELS) {
|
|
11807
|
+
const scale = Math.sqrt(WAN22_MAX_VIDEO_PIXELS / (roundedWidth * roundedHeight));
|
|
11808
|
+
roundedWidth = Math.max(480, Math.floor((roundedWidth * scale) / 16) * 16);
|
|
11809
|
+
roundedHeight = Math.max(480, Math.floor((roundedHeight * scale) / 16) * 16);
|
|
11810
|
+
}
|
|
11811
|
+
return { width: roundedWidth, height: roundedHeight };
|
|
11540
11812
|
}
|
|
11541
11813
|
|
|
11542
11814
|
function uniqueSourceReelWorkdir(sourceDir) {
|
|
@@ -11647,6 +11919,18 @@ function buildSourceReelPlan() {
|
|
|
11647
11919
|
const transitionBasePrompt = options.sourceReelTransitionPrompt || SOURCE_REEL_DEFAULT_TRANSITION_PROMPT;
|
|
11648
11920
|
const promptOverrides = loadSourceReelTransitionPromptOverrides(options.sourceReelTransitionPrompts);
|
|
11649
11921
|
const model = options.sourceReelModel || (cliSet.model ? options.model : null) || SOURCE_REEL_DEFAULT_MODEL;
|
|
11922
|
+
// Wan 2.2's short side can never exceed 1024 inside its 1,048,576-pixel budget.
|
|
11923
|
+
if (isWanVideoModelId(model) && Number(options.sourceReelTargetResolution) > 1024) {
|
|
11924
|
+
fatalCliError(
|
|
11925
|
+
`Wan 2.2 cannot render ${options.sourceReelTargetResolution}p. It renders at most 1,048,576 pixels per frame ` +
|
|
11926
|
+
'(1024×1024), so its short side is at most 1024 pixels.',
|
|
11927
|
+
{
|
|
11928
|
+
code: 'INVALID_ARGUMENT',
|
|
11929
|
+
details: { model, sourceReelTargetResolution: options.sourceReelTargetResolution, maxPixels: WAN22_MAX_VIDEO_PIXELS },
|
|
11930
|
+
hint: 'Use --reel-target-resolution 768 (the default) or pick another --reel-model.'
|
|
11931
|
+
}
|
|
11932
|
+
);
|
|
11933
|
+
}
|
|
11650
11934
|
const fps = cliSet.fps ? options.fps : 32;
|
|
11651
11935
|
const concurrency = options.sourceReelConcurrency || 2;
|
|
11652
11936
|
|
|
@@ -11748,7 +12032,7 @@ async function prepareSourceReelReferenceImages(plan, log) {
|
|
|
11748
12032
|
let dimensions = plan.dimensions;
|
|
11749
12033
|
if (!dimensions) {
|
|
11750
12034
|
const metadata = await sharp(plan.clips[0].path).rotate().metadata();
|
|
11751
|
-
dimensions = inferSourceReelDimensions(metadata, plan.targetResolution);
|
|
12035
|
+
dimensions = inferSourceReelDimensions(metadata, plan.targetResolution, plan.model);
|
|
11752
12036
|
plan.dimensions = dimensions;
|
|
11753
12037
|
}
|
|
11754
12038
|
|
|
@@ -12824,6 +13108,35 @@ function videoWorkflowHasFrameAnchors() {
|
|
|
12824
13108
|
|| (options.videoWorkflow === 'ia2v' && isMiniMaxH3AudioGuideModel(options.model));
|
|
12825
13109
|
}
|
|
12826
13110
|
|
|
13111
|
+
// The keyframes a render pinned, for --json output and render info.
|
|
13112
|
+
function describeKeyframesForOutput() {
|
|
13113
|
+
return options.keyframes.map(({ image, seconds, frameIndex }) => ({
|
|
13114
|
+
image,
|
|
13115
|
+
seconds,
|
|
13116
|
+
frameIndex,
|
|
13117
|
+
clock: formatMiniMaxH3KeyframeClock(frameIndex)
|
|
13118
|
+
}));
|
|
13119
|
+
}
|
|
13120
|
+
|
|
13121
|
+
// Load each --keyframe image as SDK keyframes, in time order. The Intelligence
|
|
13122
|
+
// Client wrapper cover-crops each one onto the canvas the job renders exactly
|
|
13123
|
+
// like the last frame (twice the canvas on two-stage models); with asset
|
|
13124
|
+
// auto-resize off, the worker makes the same centred crop.
|
|
13125
|
+
async function prepareMiniMaxH3Keyframes() {
|
|
13126
|
+
return Promise.all(options.keyframes.map(async (keyframe) => {
|
|
13127
|
+
const image = await fetchMediaBuffer(keyframe.image);
|
|
13128
|
+
const dims = await getVideoImageDimensionsFromBuffer(image);
|
|
13129
|
+
if (!dims?.width || !dims?.height) {
|
|
13130
|
+
const err = new Error(`Keyframe image ${keyframe.image} is not a readable image.`);
|
|
13131
|
+
err.code = 'INVALID_ARGUMENT';
|
|
13132
|
+
err.hint = 'Pass a PNG, JPEG or WebP still for each --keyframe.';
|
|
13133
|
+
err.details = { flag: '--keyframe', image: keyframe.image, seconds: keyframe.seconds };
|
|
13134
|
+
throw err;
|
|
13135
|
+
}
|
|
13136
|
+
return { image, frameIndex: keyframe.frameIndex };
|
|
13137
|
+
}));
|
|
13138
|
+
}
|
|
13139
|
+
|
|
12827
13140
|
function miniMaxH3R2vReferenceImageCount() {
|
|
12828
13141
|
if (!isMiniMaxH3R2vModel(options.model)) return undefined;
|
|
12829
13142
|
return (options.refImage ? 1 : 0)
|
|
@@ -12845,7 +13158,9 @@ async function buildVideoEstimateParams({ tokenType, steps }) {
|
|
|
12845
13158
|
tokenType,
|
|
12846
13159
|
...(Number.isFinite(steps) && steps > 0 ? { steps } : {}),
|
|
12847
13160
|
...(options.frames ? { frames: options.frames } : { duration: options.duration }),
|
|
12848
|
-
...(referenceImageCount !== undefined ? { referenceImageCount } : {})
|
|
13161
|
+
...(referenceImageCount !== undefined ? { referenceImageCount } : {}),
|
|
13162
|
+
// MiniMax H3 keyframes: two are included, each extra one adds output time.
|
|
13163
|
+
...(options.keyframes.length > 0 ? { keyframeCount: options.keyframes.length } : {})
|
|
12849
13164
|
};
|
|
12850
13165
|
|
|
12851
13166
|
if ((isSeedanceVideo || isWan3Video || isMiniMaxH3R2v) && videoSources.length > 0) {
|
|
@@ -13746,6 +14061,7 @@ async function main() {
|
|
|
13746
14061
|
tokenType: options.tokenType || 'spark',
|
|
13747
14062
|
count: options.count,
|
|
13748
14063
|
...(delivered ? { deliveredWidth: delivered.width, deliveredHeight: delivered.height } : {}),
|
|
14064
|
+
...(options.keyframes.length > 0 ? { keyframeCount: options.keyframes.length } : {}),
|
|
13749
14065
|
estimate
|
|
13750
14066
|
}));
|
|
13751
14067
|
} else {
|
|
@@ -13838,6 +14154,9 @@ async function main() {
|
|
|
13838
14154
|
log(`Generating video (${options.videoWorkflow}) with ${options.model}...`);
|
|
13839
14155
|
if (options.refImage) log(`Reference image: ${options.refImage}`);
|
|
13840
14156
|
if (options.refImageEnd) log(`End frame: ${options.refImageEnd}`);
|
|
14157
|
+
for (const keyframe of options.keyframes) {
|
|
14158
|
+
log(`Keyframe at ${formatMiniMaxH3KeyframeClock(keyframe.frameIndex)} (frame ${keyframe.frameIndex}): ${keyframe.image}`);
|
|
14159
|
+
}
|
|
13841
14160
|
if (options.refAudio) log(`Reference audio: ${options.refAudio}`);
|
|
13842
14161
|
for (const referenceAudio of options.refAudios) log(`Additional reference audio: ${referenceAudio}`);
|
|
13843
14162
|
if (options.referenceAudioIdentity) log(`Voice identity: ${options._voicePersonaResolvedName || options.referenceAudioIdentity}`);
|
|
@@ -14352,6 +14671,10 @@ async function main() {
|
|
|
14352
14671
|
if (contextImageBuffers.length > 0) {
|
|
14353
14672
|
projectConfig.contextImages = contextImageBuffers;
|
|
14354
14673
|
}
|
|
14674
|
+
// MiniMax H3 intermediate keyframes, in time order.
|
|
14675
|
+
if (options.keyframes.length > 0) {
|
|
14676
|
+
projectConfig.keyframes = await prepareMiniMaxH3Keyframes();
|
|
14677
|
+
}
|
|
14355
14678
|
applyLtxTransitionLora(
|
|
14356
14679
|
projectConfig,
|
|
14357
14680
|
options.model,
|
|
@@ -14952,6 +15275,7 @@ async function main() {
|
|
|
14952
15275
|
}
|
|
14953
15276
|
renderInfo.refImage = options.refImage;
|
|
14954
15277
|
renderInfo.refImageEnd = options.refImageEnd;
|
|
15278
|
+
if (options.keyframes.length > 0) renderInfo.keyframes = describeKeyframesForOutput();
|
|
14955
15279
|
if (options.refAudio) {
|
|
14956
15280
|
renderInfo.refAudio = options.refAudio;
|
|
14957
15281
|
if (options.audioStart !== null) renderInfo.audioStart = options.audioStart;
|
|
@@ -15229,6 +15553,7 @@ async function main() {
|
|
|
15229
15553
|
}
|
|
15230
15554
|
if (options.refImage) output.refImage = options.refImage;
|
|
15231
15555
|
if (options.refImageEnd) output.refImageEnd = options.refImageEnd;
|
|
15556
|
+
if (options.keyframes.length > 0) output.keyframes = describeKeyframesForOutput();
|
|
15232
15557
|
if (options.refAudio) {
|
|
15233
15558
|
output.refAudio = options.refAudio;
|
|
15234
15559
|
if (options.audioStart !== null) output.audioStart = options.audioStart;
|
|
@@ -15348,6 +15673,9 @@ async function main() {
|
|
|
15348
15673
|
autoResizeVideoAssets: options.video ? (options.autoResizeVideoAssets ?? null) : null,
|
|
15349
15674
|
refImage: options.video ? (options.refImage ?? null) : null,
|
|
15350
15675
|
refImageEnd: options.video ? (options.refImageEnd ?? null) : null,
|
|
15676
|
+
...(options.video && options.keyframes.length > 0
|
|
15677
|
+
? { keyframes: options.keyframes.map(({ image, seconds, frameIndex }) => ({ image, seconds, frameIndex: frameIndex ?? null })) }
|
|
15678
|
+
: {}),
|
|
15351
15679
|
refAudio: options.video ? (options.refAudio ?? null) : null,
|
|
15352
15680
|
referenceAudioIdentity: options.video ? (options.referenceAudioIdentity ?? null) : null,
|
|
15353
15681
|
refVideo: options.video ? (options.refVideo ?? null) : null,
|
package/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const PACKAGE_VERSION = '3.
|
|
1
|
+
export const PACKAGE_VERSION = '3.54.0';
|