@sogni-ai/sogni-creative-agent-skill 3.40.0 → 3.41.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 +14 -2
- package/.agents/skills/sogni-creative-agent-skill/references/hosted-api.md +72 -1
- package/.agents/skills/sogni-creative-agent-skill/references/models.md +19 -0
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/CHANGELOG.md +29 -0
- package/README.md +3 -2
- package/SKILL.md +24 -3
- package/desktop-extension/manifest.json +1 -1
- package/generated/creative-agent-runtime.mjs +132 -3
- package/openclaw.plugin.json +1 -1
- package/package.json +3 -3
- package/plugin-skills/sogni-creative-agent/SKILL.md +8 -0
- package/references/hosted-api.md +72 -1
- package/references/interactive-worlds.md +72 -0
- package/references/models.md +19 -0
- package/skill-package.json +1 -1
- package/skills/README.md +1 -1
- package/skills/video_editing.md +4 -1
- package/sogni-agent.mjs +366 -36
- package/version.mjs +1 -1
package/sogni-agent.mjs
CHANGED
|
@@ -1368,6 +1368,171 @@ function resolveRtxVsrDimensions(sourceWidth, sourceHeight, { scale = 2, targetL
|
|
|
1368
1368
|
};
|
|
1369
1369
|
}
|
|
1370
1370
|
|
|
1371
|
+
// Promptless FlashVSR video upscaling (--upscale-video). The server probes the
|
|
1372
|
+
// uploaded source and stays authoritative; these public limits let the CLI
|
|
1373
|
+
// explain an unsupported clip before any upload.
|
|
1374
|
+
const FLASHVSR_MODEL_ID = 'flashvsr_v1.1_tiny_long_bf16';
|
|
1375
|
+
const VIDEO_UPSCALE_RESOLUTIONS = [1080, 1440];
|
|
1376
|
+
const VIDEO_UPSCALE_DEFAULT_RESOLUTION = 1440;
|
|
1377
|
+
const VIDEO_UPSCALE_MAX_SOURCE_SHORT_EDGE = 768;
|
|
1378
|
+
// Source area counted in 64-pixel blocks: about 1344x768, or 768x1344 in portrait.
|
|
1379
|
+
const VIDEO_UPSCALE_MAX_SOURCE_BLOCK_PIXELS = 1344 * 768;
|
|
1380
|
+
const VIDEO_UPSCALE_MAX_FRAMES = 362;
|
|
1381
|
+
const VIDEO_UPSCALE_MAX_DURATION_SECONDS = 362 / 24;
|
|
1382
|
+
const VIDEO_UPSCALE_MIN_FPS = 1;
|
|
1383
|
+
const VIDEO_UPSCALE_MAX_FPS = 60;
|
|
1384
|
+
const VIDEO_UPSCALE_MAX_BYTES = 100 * 1024 * 1024;
|
|
1385
|
+
const VIDEO_UPSCALE_MAX_OUTPUT_LONG_EDGE = 2560;
|
|
1386
|
+
const VIDEO_UPSCALE_MAX_OUTPUT_PIXELS = 2560 * 1440;
|
|
1387
|
+
const FLASHVSR_UNAVAILABLE_MESSAGE = 'FlashVSR video upscaling is not available yet. Please try again later.';
|
|
1388
|
+
|
|
1389
|
+
function parseVideoUpscaleResolutionValue(raw, flag) {
|
|
1390
|
+
const value = Number(String(raw ?? '').trim().toLowerCase().replace(/p$/, ''));
|
|
1391
|
+
if (!VIDEO_UPSCALE_RESOLUTIONS.includes(value)) {
|
|
1392
|
+
fatalCliError(`${flag} must be 1080 or 1440.`, {
|
|
1393
|
+
code: 'INVALID_ARGUMENT',
|
|
1394
|
+
details: { flag, value: raw, allowed: VIDEO_UPSCALE_RESOLUTIONS }
|
|
1395
|
+
});
|
|
1396
|
+
}
|
|
1397
|
+
return value;
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
function videoUpscaleOutputFor(sourceWidth, sourceHeight, resolution) {
|
|
1401
|
+
const ratio = resolution / Math.min(sourceWidth, sourceHeight);
|
|
1402
|
+
if (ratio > 2) {
|
|
1403
|
+
return {
|
|
1404
|
+
problem: `${resolution}p needs a source at least ${resolution / 2}px on its short edge; this video is ${sourceWidth}×${sourceHeight}.`
|
|
1405
|
+
};
|
|
1406
|
+
}
|
|
1407
|
+
if (ratio <= 1) {
|
|
1408
|
+
return { problem: `This ${sourceWidth}×${sourceHeight} video is already ${resolution}p or larger.` };
|
|
1409
|
+
}
|
|
1410
|
+
const width = Math.round((sourceWidth * ratio) / 2) * 2;
|
|
1411
|
+
const height = Math.round((sourceHeight * ratio) / 2) * 2;
|
|
1412
|
+
if (Math.max(width, height) > VIDEO_UPSCALE_MAX_OUTPUT_LONG_EDGE || width * height > VIDEO_UPSCALE_MAX_OUTPUT_PIXELS) {
|
|
1413
|
+
return {
|
|
1414
|
+
problem: `At ${resolution}p this ${sourceWidth}×${sourceHeight} video would be ${width}×${height}, larger than the 2560×1440 upscale output limit.`
|
|
1415
|
+
};
|
|
1416
|
+
}
|
|
1417
|
+
return { resolution, width, height };
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
// Output geometry matches the server's derivation: the short edge becomes the
|
|
1421
|
+
// target and both edges round to even pixels. Without an explicit resolution,
|
|
1422
|
+
// 1440p is used when the source allows it and 1080p otherwise.
|
|
1423
|
+
function resolveVideoUpscaleOutput(sourceWidth, sourceHeight, requestedResolution = null) {
|
|
1424
|
+
if (Math.min(sourceWidth, sourceHeight) > VIDEO_UPSCALE_MAX_SOURCE_SHORT_EDGE) {
|
|
1425
|
+
fatalCliError(
|
|
1426
|
+
`This video is ${sourceWidth}×${sourceHeight}; video upscaling accepts sources up to ${VIDEO_UPSCALE_MAX_SOURCE_SHORT_EDGE}px on the short edge.`,
|
|
1427
|
+
{ code: 'INVALID_UPSCALE_SOURCE', details: { sourceWidth, sourceHeight } }
|
|
1428
|
+
);
|
|
1429
|
+
}
|
|
1430
|
+
if (Math.ceil(sourceWidth / 64) * 64 * Math.ceil(sourceHeight / 64) * 64 > VIDEO_UPSCALE_MAX_SOURCE_BLOCK_PIXELS) {
|
|
1431
|
+
fatalCliError(
|
|
1432
|
+
`This video is ${sourceWidth}×${sourceHeight}; video upscaling accepts sources up to about 1344×768 pixels, or 768×1344 in portrait.`,
|
|
1433
|
+
{ code: 'INVALID_UPSCALE_SOURCE', details: { sourceWidth, sourceHeight } }
|
|
1434
|
+
);
|
|
1435
|
+
}
|
|
1436
|
+
const candidates = requestedResolution ? [requestedResolution] : [VIDEO_UPSCALE_DEFAULT_RESOLUTION, 1080];
|
|
1437
|
+
let lastProblem = '';
|
|
1438
|
+
for (const resolution of candidates) {
|
|
1439
|
+
const output = videoUpscaleOutputFor(sourceWidth, sourceHeight, resolution);
|
|
1440
|
+
if (!output.problem) return output;
|
|
1441
|
+
lastProblem = output.problem;
|
|
1442
|
+
}
|
|
1443
|
+
fatalCliError(lastProblem, {
|
|
1444
|
+
code: 'INVALID_UPSCALE_SIZE',
|
|
1445
|
+
details: { sourceWidth, sourceHeight, requestedResolution },
|
|
1446
|
+
...(requestedResolution === 1440 ? { hint: 'Use --upscale-resolution 1080 for this source.' } : {})
|
|
1447
|
+
});
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
// Read the exact source geometry, frame count, and frame rate with ffprobe so
|
|
1451
|
+
// the request matches what the server verifies after upload.
|
|
1452
|
+
async function probeVideoUpscaleSource(buffer, sourceLabel) {
|
|
1453
|
+
if (buffer.length > VIDEO_UPSCALE_MAX_BYTES) {
|
|
1454
|
+
fatalCliError('Video upscaling accepts source files up to 100 MB.', {
|
|
1455
|
+
code: 'INVALID_UPSCALE_SOURCE',
|
|
1456
|
+
details: { sizeBytes: buffer.length, maxBytes: VIDEO_UPSCALE_MAX_BYTES }
|
|
1457
|
+
});
|
|
1458
|
+
}
|
|
1459
|
+
const ffprobePath = getEnv('FFPROBE_PATH') || 'ffprobe';
|
|
1460
|
+
sanitizePath(ffprobePath, 'FFPROBE_PATH');
|
|
1461
|
+
const tempDir = createTrackedTempDir('sogni-video-upscale-probe-');
|
|
1462
|
+
const inputPath = mediaTempInputPath(tempDir, sourceLabel, '.mp4');
|
|
1463
|
+
let result;
|
|
1464
|
+
try {
|
|
1465
|
+
writeFileSync(inputPath, buffer);
|
|
1466
|
+
result = await runCommand(ffprobePath, [
|
|
1467
|
+
'-v', 'error',
|
|
1468
|
+
'-select_streams', 'v:0',
|
|
1469
|
+
'-count_frames',
|
|
1470
|
+
'-show_entries',
|
|
1471
|
+
'stream=width,height,nb_read_frames,avg_frame_rate,r_frame_rate,sample_aspect_ratio,color_transfer:stream_side_data=rotation',
|
|
1472
|
+
'-of', 'json',
|
|
1473
|
+
inputPath,
|
|
1474
|
+
], { captureOutput: true });
|
|
1475
|
+
} finally {
|
|
1476
|
+
try { if (existsSync(inputPath)) unlinkSync(inputPath); } catch {}
|
|
1477
|
+
try { rmdirSync(tempDir); } catch {}
|
|
1478
|
+
}
|
|
1479
|
+
if (result?.error && result.status === null) {
|
|
1480
|
+
const err = new Error('ffprobe is required for --upscale-video.');
|
|
1481
|
+
err.code = 'MISSING_FFPROBE';
|
|
1482
|
+
err.hint = 'Install ffmpeg/ffprobe (e.g. `brew install ffmpeg` / `apt install ffmpeg`) or set FFPROBE_PATH to a working ffprobe binary.';
|
|
1483
|
+
err.details = { ffprobePath };
|
|
1484
|
+
throw err;
|
|
1485
|
+
}
|
|
1486
|
+
let stream = null;
|
|
1487
|
+
try {
|
|
1488
|
+
stream = JSON.parse(result?.stdout || '{}')?.streams?.[0] ?? null;
|
|
1489
|
+
} catch {
|
|
1490
|
+
stream = null;
|
|
1491
|
+
}
|
|
1492
|
+
const width = Number(stream?.width);
|
|
1493
|
+
const height = Number(stream?.height);
|
|
1494
|
+
const frames = Number(stream?.nb_read_frames);
|
|
1495
|
+
const fps = parseFrameRate(stream?.avg_frame_rate);
|
|
1496
|
+
if (result?.status !== 0 || ![width, height, frames].every((value) => Number.isSafeInteger(value) && value > 0) || !fps) {
|
|
1497
|
+
fatalCliError('The source video dimensions, frame count, or frame rate could not be read. Use an MP4 or MOV file of 100 MB or less.', {
|
|
1498
|
+
code: 'INVALID_UPSCALE_SOURCE',
|
|
1499
|
+
details: { source: sourceLabel }
|
|
1500
|
+
});
|
|
1501
|
+
}
|
|
1502
|
+
if (fps < VIDEO_UPSCALE_MIN_FPS || fps > VIDEO_UPSCALE_MAX_FPS) {
|
|
1503
|
+
fatalCliError(`This video runs at ${Number(fps.toFixed(3))} fps; video upscaling accepts ${VIDEO_UPSCALE_MIN_FPS}-${VIDEO_UPSCALE_MAX_FPS} fps.`, {
|
|
1504
|
+
code: 'INVALID_UPSCALE_SOURCE',
|
|
1505
|
+
details: { fps }
|
|
1506
|
+
});
|
|
1507
|
+
}
|
|
1508
|
+
if (frames > VIDEO_UPSCALE_MAX_FRAMES || frames / fps > VIDEO_UPSCALE_MAX_DURATION_SECONDS + 0.001) {
|
|
1509
|
+
fatalCliError(
|
|
1510
|
+
`This video is ${frames} frames (${(frames / fps).toFixed(2)} s); video upscaling accepts up to ${VIDEO_UPSCALE_MAX_FRAMES} frames and about 15 seconds.`,
|
|
1511
|
+
{ code: 'INVALID_UPSCALE_SOURCE', details: { frames, fps } }
|
|
1512
|
+
);
|
|
1513
|
+
}
|
|
1514
|
+
const rotated = Array.isArray(stream?.side_data_list)
|
|
1515
|
+
&& stream.side_data_list.some((item) => Number(item?.rotation || 0) % 360 !== 0);
|
|
1516
|
+
if (!['1:1', 'N/A', undefined].includes(stream?.sample_aspect_ratio) || rotated) {
|
|
1517
|
+
fatalCliError('Export the video with square pixels and its rotation applied before upscaling.', {
|
|
1518
|
+
code: 'INVALID_UPSCALE_SOURCE'
|
|
1519
|
+
});
|
|
1520
|
+
}
|
|
1521
|
+
if (['smpte2084', 'arib-std-b67'].includes(stream?.color_transfer ?? '')) {
|
|
1522
|
+
fatalCliError('Convert HDR video to SDR before upscaling.', { code: 'INVALID_UPSCALE_SOURCE' });
|
|
1523
|
+
}
|
|
1524
|
+
return { width, height, frames, fps, sizeBytes: buffer.length };
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
function annotateVideoUpscaleError(error) {
|
|
1528
|
+
const message = String(error?.message || error?.originalError?.message || '');
|
|
1529
|
+
if (error && typeof error === 'object' && message.includes(FLASHVSR_UNAVAILABLE_MESSAGE)) {
|
|
1530
|
+
if (!error.code || error.code === 'PROJECT_ERROR') error.code = 'MODEL_UNAVAILABLE';
|
|
1531
|
+
error.hint = 'FlashVSR upscaling workers are not online yet, so nothing was charged. Try again later.';
|
|
1532
|
+
}
|
|
1533
|
+
return error;
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1371
1536
|
// Safety cap for -n/--count: every output is a paid generation, so a typo like
|
|
1372
1537
|
// `-n 1000` (meant `-n 10`) must not launch a thousand-render batch. Raise
|
|
1373
1538
|
// deliberately with SOGNI_MAX_COUNT when a bigger batch is really wanted.
|
|
@@ -1423,12 +1588,18 @@ function isStructuredInsufficientBalanceError(error) {
|
|
|
1423
1588
|
* / `addCanonicalErrorFields`) cannot tell that the failure is e.g.
|
|
1424
1589
|
* `INSUFFICIENT_BALANCE`, so the "Buy Spark Packs" CTA silently no-ops.
|
|
1425
1590
|
*/
|
|
1426
|
-
function buildProjectResultError(projectResult) {
|
|
1427
|
-
const
|
|
1591
|
+
function buildProjectResultError(projectResult, fallback = 'Project failed') {
|
|
1592
|
+
const nested = projectResult?.error;
|
|
1593
|
+
const failure = nested && typeof nested === 'object' ? nested : projectResult;
|
|
1594
|
+
const message = [typeof nested === 'object' ? nested?.message : nested, failure?.error, failure?.message, projectResult?.message, projectResult]
|
|
1595
|
+
.find((value) => typeof value === 'string' && value.trim()) || fallback;
|
|
1428
1596
|
const err = new Error(message);
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1597
|
+
// SDK create responses and error events must keep the same typed failure.
|
|
1598
|
+
// In particular, an object-valued error must never become "[object Object]".
|
|
1599
|
+
for (const key of ['code', 'originalCode', 'errorCode', 'error_code', 'details', 'hint', 'originalError', 'isNSFW']) {
|
|
1600
|
+
const value = failure?.[key] ?? projectResult?.[key];
|
|
1601
|
+
if (value !== undefined) err[key] = value;
|
|
1602
|
+
}
|
|
1432
1603
|
if (classifyCliError(err).category === 'insufficient_credits' && !err.hint) {
|
|
1433
1604
|
err.hint = SPARK_PACKS_PURCHASE_HINT;
|
|
1434
1605
|
}
|
|
@@ -2715,6 +2886,8 @@ const options = {
|
|
|
2715
2886
|
upscaleImage: null, // Source image for promptless RTX VSR upscaling
|
|
2716
2887
|
upscaleScale: 2,
|
|
2717
2888
|
upscaleTargetLongestEdge: null,
|
|
2889
|
+
upscaleVideo: null, // Source video for promptless FlashVSR upscaling
|
|
2890
|
+
upscaleResolution: null, // FlashVSR output short edge (1080 | 1440)
|
|
2718
2891
|
looping: false, // Create looping video (i2v only): generate A→B then B→A and concatenate
|
|
2719
2892
|
photobooth: false, // Photobooth mode (InstantID face transfer)
|
|
2720
2893
|
cnStrength: null, // ControlNet strength override
|
|
@@ -2901,6 +3074,8 @@ const cliSet = {
|
|
|
2901
3074
|
upscaleImage: false,
|
|
2902
3075
|
upscaleScale: false,
|
|
2903
3076
|
upscaleTargetLongestEdge: false,
|
|
3077
|
+
upscaleVideo: false,
|
|
3078
|
+
upscaleResolution: false,
|
|
2904
3079
|
looping: false,
|
|
2905
3080
|
photobooth: false,
|
|
2906
3081
|
cnStrength: false,
|
|
@@ -3302,6 +3477,16 @@ for (let i = 0; i < args.length; i++) {
|
|
|
3302
3477
|
RTX_VSR_MAX_DIMENSION
|
|
3303
3478
|
);
|
|
3304
3479
|
cliSet.upscaleTargetLongestEdge = true;
|
|
3480
|
+
} else if (arg === '--upscale-video') {
|
|
3481
|
+
const raw = expandHomePath(requireFlagValue(args, i, arg));
|
|
3482
|
+
i++;
|
|
3483
|
+
options.upscaleVideo = raw;
|
|
3484
|
+
cliSet.upscaleVideo = true;
|
|
3485
|
+
} else if (arg === '--upscale-resolution') {
|
|
3486
|
+
const raw = requireFlagValue(args, i, arg);
|
|
3487
|
+
i++;
|
|
3488
|
+
options.upscaleResolution = parseVideoUpscaleResolutionValue(raw, arg);
|
|
3489
|
+
cliSet.upscaleResolution = true;
|
|
3305
3490
|
} else if (arg === '--photobooth') {
|
|
3306
3491
|
options.photobooth = true;
|
|
3307
3492
|
cliSet.photobooth = true;
|
|
@@ -3937,6 +4122,8 @@ Image Options:
|
|
|
3937
4122
|
--upscale <path|url> Promptless NVIDIA RTX VSR upscale, up to 16K (one source image)
|
|
3938
4123
|
--upscale-scale <n> Enlarge longest edge by 2, 3, or 4 (default: 2)
|
|
3939
4124
|
--target-longest-edge <px> Explicit output longest edge, up to 15360 (overrides scale)
|
|
4125
|
+
--upscale-video <path|url> Promptless FlashVSR upscale of one video to 1080p/1440p (keeps frames, fps, audio)
|
|
4126
|
+
--upscale-resolution <p> Output short edge for --upscale-video: 1080 or 1440 (default: 1440; 1080 below 720p)
|
|
3940
4127
|
|
|
3941
4128
|
Photobooth (Face Transfer):
|
|
3942
4129
|
--photobooth Face transfer mode (InstantID + SDXL Turbo)
|
|
@@ -4045,7 +4232,7 @@ Hosted API Modes:
|
|
|
4045
4232
|
--no-api-tool-execution Ask for tool calls/plans but do not execute Sogni tools
|
|
4046
4233
|
--llm-model <id> LLM model for --api-chat (default: ${DEFAULT_LLM_MODEL})
|
|
4047
4234
|
--task-profile <p> LLM task profile for --api-chat: general|coding|reasoning
|
|
4048
|
-
--max-tokens <num> Max chat completion tokens for --api-chat and storyboard planning
|
|
4235
|
+
--max-tokens <num> Max chat completion tokens for --api-chat and storyboard planning (default: 4096)
|
|
4049
4236
|
--thinking, --no-thinking Toggle chat_template_kwargs.enable_thinking
|
|
4050
4237
|
--system <text> System prompt for --api-chat
|
|
4051
4238
|
--list-api-models List Sogni Intelligence LLM models from /v1/models
|
|
@@ -4177,6 +4364,9 @@ LTX 2.3 rollback-only capabilities:
|
|
|
4177
4364
|
ltx23-22b-fp8_v2v_distilled Video-to-video rollback
|
|
4178
4365
|
ltx23-22b-10eros-v1.4-fp8mixed_i2v Private mature-theme I2V; first and/or last frame; requires --no-filter
|
|
4179
4366
|
|
|
4367
|
+
Video Upscale Model:
|
|
4368
|
+
flashvsr_v1.1_tiny_long_bf16 Promptless FlashVSR upscale to 1080p/1440p (--upscale-video)
|
|
4369
|
+
|
|
4180
4370
|
Music Models:
|
|
4181
4371
|
ace_step_1.5_xl_turbo Default direct music generation
|
|
4182
4372
|
ace_step_1.5_xl_sft Quality variant with stronger lyric handling
|
|
@@ -4629,7 +4819,7 @@ if (options.outputFormat) {
|
|
|
4629
4819
|
details: { outputFormat: options.outputFormat }
|
|
4630
4820
|
});
|
|
4631
4821
|
}
|
|
4632
|
-
} else if (options.video) {
|
|
4822
|
+
} else if (options.video || options.upscaleVideo) {
|
|
4633
4823
|
if (options.outputFormat !== 'mp4') {
|
|
4634
4824
|
fatalCliError('Video output format must be "mp4".', {
|
|
4635
4825
|
code: 'INVALID_ARGUMENT',
|
|
@@ -5138,6 +5328,17 @@ if (options.music) {
|
|
|
5138
5328
|
if (!cliSet.timeout && !timeoutFromConfig && options.timeout === 30000) {
|
|
5139
5329
|
options.timeout = 1800000; // 30 min for queued and long-running video jobs
|
|
5140
5330
|
}
|
|
5331
|
+
} else if (options.upscaleVideo) {
|
|
5332
|
+
if (options.model && options.model !== FLASHVSR_MODEL_ID) {
|
|
5333
|
+
fatalCliError(`--upscale-video requires model ${FLASHVSR_MODEL_ID}.`, {
|
|
5334
|
+
code: 'INVALID_ARGUMENT',
|
|
5335
|
+
details: { model: options.model, requiredModel: FLASHVSR_MODEL_ID }
|
|
5336
|
+
});
|
|
5337
|
+
}
|
|
5338
|
+
options.model = FLASHVSR_MODEL_ID;
|
|
5339
|
+
if (!cliSet.timeout && !timeoutFromConfig && options.timeout === 30000) {
|
|
5340
|
+
options.timeout = 1800000; // 30 min for queued video work
|
|
5341
|
+
}
|
|
5141
5342
|
} else if (options.upscaleImage) {
|
|
5142
5343
|
if (options.model && options.model !== RTX_VSR_MODEL_ID) {
|
|
5143
5344
|
fatalCliError(`--upscale requires model ${RTX_VSR_MODEL_ID}.`, {
|
|
@@ -5262,6 +5463,7 @@ const commandUsesGenerationSeed = !options.apiChat &&
|
|
|
5262
5463
|
!options.sourceReelDir &&
|
|
5263
5464
|
!options.remixAudio &&
|
|
5264
5465
|
!options.upscaleImage &&
|
|
5466
|
+
!options.upscaleVideo &&
|
|
5265
5467
|
!options.listMedia &&
|
|
5266
5468
|
!options.memoryAction &&
|
|
5267
5469
|
!options.personalityAction &&
|
|
@@ -5300,7 +5502,7 @@ const wan3HasMediaInput = isWan3ModelLocal(options.model) && Boolean(
|
|
|
5300
5502
|
|| options.wan3ReferenceFileUrl
|
|
5301
5503
|
|| options.wan3ReferenceLinkUrl
|
|
5302
5504
|
);
|
|
5303
|
-
if (!options.prompt && !wan3HasMediaInput && !options.upscaleImage && !options.apiChat && !apiWorkflowUtilityAction && !apiWorkflowStartAction && !apiModelUtilityAction && !liveModelUtilityAction && !loraCatalogUtilityAction && !apiReplayUtilityAction && !contractUtilityAction && !storyboardPlanUtilityAction && !options.estimateVideoCost && !options.multiAngle && !options.showBalance && !options.showVersion && !options.doctor && !options.extractLastFrame && !options.extractFirstFrame && !options.extractFrameAt && !options.trimVideo && !options.verifyVideo && !options.concatVideos && !options.sourceReelDir && !options.remixAudio && !options.listMedia && !options.memoryAction && !options.personalityAction && !personaUtilityAction) {
|
|
5505
|
+
if (!options.prompt && !wan3HasMediaInput && !options.upscaleImage && !options.upscaleVideo && !options.apiChat && !apiWorkflowUtilityAction && !apiWorkflowStartAction && !apiModelUtilityAction && !liveModelUtilityAction && !loraCatalogUtilityAction && !apiReplayUtilityAction && !contractUtilityAction && !storyboardPlanUtilityAction && !options.estimateVideoCost && !options.multiAngle && !options.showBalance && !options.showVersion && !options.doctor && !options.extractLastFrame && !options.extractFirstFrame && !options.extractFrameAt && !options.trimVideo && !options.verifyVideo && !options.concatVideos && !options.sourceReelDir && !options.remixAudio && !options.listMedia && !options.memoryAction && !options.personalityAction && !personaUtilityAction) {
|
|
5304
5506
|
fatalCliError('No prompt provided. Use --help for usage.', { code: 'INVALID_ARGUMENT' });
|
|
5305
5507
|
}
|
|
5306
5508
|
|
|
@@ -5343,6 +5545,38 @@ if (!options.upscaleImage && (cliSet.upscaleScale || cliSet.upscaleTargetLongest
|
|
|
5343
5545
|
});
|
|
5344
5546
|
}
|
|
5345
5547
|
|
|
5548
|
+
if (options.upscaleVideo) {
|
|
5549
|
+
if (options.prompt) {
|
|
5550
|
+
fatalCliError('--upscale-video is promptless and does not accept a prompt.', { code: 'INVALID_ARGUMENT' });
|
|
5551
|
+
}
|
|
5552
|
+
if (
|
|
5553
|
+
options.upscaleImage || options.video || options.music || options.photobooth || options.multiAngle
|
|
5554
|
+
|| options.contextImages.length > 0 || options.refImage || options.refImageEnd || options.refAudio
|
|
5555
|
+
|| options.refAudios.length > 0 || options.refVideo || options.refVideos.length > 0 || options.refMask
|
|
5556
|
+
) {
|
|
5557
|
+
fatalCliError('--upscale-video cannot be combined with --upscale, --video, --music, photobooth, --multi-angle, --ref, --ref-end, --ref-audio, --ref-video, --mask, or -c/--context.', {
|
|
5558
|
+
code: 'INVALID_ARGUMENT'
|
|
5559
|
+
});
|
|
5560
|
+
}
|
|
5561
|
+
if (options.count !== 1) {
|
|
5562
|
+
fatalCliError('--upscale-video produces exactly one output; omit -n/--count or set it to 1.', {
|
|
5563
|
+
code: 'INVALID_ARGUMENT',
|
|
5564
|
+
details: { count: options.count }
|
|
5565
|
+
});
|
|
5566
|
+
}
|
|
5567
|
+
if (cliSet.width || cliSet.height || cliSet.fps || cliSet.duration || cliSet.frames) {
|
|
5568
|
+
fatalCliError('--upscale-video keeps the source frames, frame rate, and aspect ratio; choose the output with --upscale-resolution 1080 or 1440.', {
|
|
5569
|
+
code: 'INVALID_ARGUMENT'
|
|
5570
|
+
});
|
|
5571
|
+
}
|
|
5572
|
+
}
|
|
5573
|
+
|
|
5574
|
+
if (!options.upscaleVideo && cliSet.upscaleResolution) {
|
|
5575
|
+
fatalCliError('--upscale-resolution requires --upscale-video <path|url>.', {
|
|
5576
|
+
code: 'INVALID_ARGUMENT'
|
|
5577
|
+
});
|
|
5578
|
+
}
|
|
5579
|
+
|
|
5346
5580
|
if (options.legacyWan3TaskType !== null) {
|
|
5347
5581
|
fatalCliError(
|
|
5348
5582
|
'--wan3-task-type has been removed because Wan 3 has no provider edit/extend task mode. Use --workflow r2v with --ref-video for loose conditioning, or select a video-to-video model for editing.',
|
|
@@ -6528,6 +6762,7 @@ async function dispatchWorkflowActionViaSdk(action, apiKey, params) {
|
|
|
6528
6762
|
? { maxEstimatedCapacityUnits: params.maxEstimatedCapacityUnits }
|
|
6529
6763
|
: {}),
|
|
6530
6764
|
...(params.confirmCost != null ? { confirmCost: params.confirmCost } : {}),
|
|
6765
|
+
...(typeof params.safeContentFilter === 'boolean' ? { safeContentFilter: params.safeContentFilter } : {}),
|
|
6531
6766
|
...(params.idempotencyKey ? { idempotencyKey: params.idempotencyKey } : {}),
|
|
6532
6767
|
...(params.attribution ? { attribution: params.attribution } : {}),
|
|
6533
6768
|
},
|
|
@@ -6663,6 +6898,13 @@ const DEFAULT_HTTP_TIMEOUT_MS = (() => {
|
|
|
6663
6898
|
return Number.isFinite(raw) && raw > 0 ? raw : 30000;
|
|
6664
6899
|
})();
|
|
6665
6900
|
|
|
6901
|
+
// Chat waits for a complete model response, including multi-scene tool JSON.
|
|
6902
|
+
// Keep catalog/download timeouts short while allowing hosted planning to finish.
|
|
6903
|
+
const CHAT_HTTP_TIMEOUT_MS = (() => {
|
|
6904
|
+
const raw = Number.parseInt(getEnv('SOGNI_HTTP_TIMEOUT_MS') || '', 10);
|
|
6905
|
+
return Number.isFinite(raw) && raw > 0 ? raw : 120000;
|
|
6906
|
+
})();
|
|
6907
|
+
|
|
6666
6908
|
// Uploads keep the timer running for the whole request-body send (the fetch
|
|
6667
6909
|
// promise only resolves once the server responds), so they get a longer budget
|
|
6668
6910
|
// than the connect-phase default that suffices for GET/download/stream calls.
|
|
@@ -6694,6 +6936,7 @@ async function fetchApiJson(path, {
|
|
|
6694
6936
|
body = undefined,
|
|
6695
6937
|
headers = {},
|
|
6696
6938
|
workloadAttribution = undefined,
|
|
6939
|
+
timeoutMs = DEFAULT_HTTP_TIMEOUT_MS,
|
|
6697
6940
|
} = {}) {
|
|
6698
6941
|
const url = await buildSafeApiUrl(path);
|
|
6699
6942
|
const init = {
|
|
@@ -6702,7 +6945,7 @@ async function fetchApiJson(path, {
|
|
|
6702
6945
|
...(body === undefined ? {} : { body: JSON.stringify(body) })
|
|
6703
6946
|
};
|
|
6704
6947
|
|
|
6705
|
-
const response = await fetchWithTimeout(url, init);
|
|
6948
|
+
const response = await fetchWithTimeout(url, init, timeoutMs);
|
|
6706
6949
|
const text = await response.text();
|
|
6707
6950
|
let payload = {};
|
|
6708
6951
|
if (text) {
|
|
@@ -7125,12 +7368,20 @@ V2 TURN ARCHITECTURE:
|
|
|
7125
7368
|
- Do not narrate hidden planning, tool selection, JSON, function names, or internal architecture to the user.
|
|
7126
7369
|
|
|
7127
7370
|
SOGNI PRODUCT KNOWLEDGE:
|
|
7128
|
-
- Sogni can create and edit images, generate and transform videos, compose music/lyrics, restore photos, apply styles, analyze media, and use uploaded or generated assets as references.
|
|
7371
|
+
- Sogni can create and edit images, generate and transform videos, compose music/lyrics, generate speech, restore photos, apply styles, analyze media, and use uploaded or generated assets as references. Use the exposed tools and their current model contracts for exact capabilities.
|
|
7129
7372
|
- GPT Image 2 in Sogni creates images from text prompts, edits/restyles uploaded or generated references, builds storyboard/keyframe sheets, character/reference boards, ad/product composites, and layout/text-heavy stills.
|
|
7130
7373
|
- For action requests, use image generation for text-to-image and image editing when references guide identity, likeness, composition, style, objects, logos, or products. Paid renders show a preflight estimate before spending.
|
|
7131
|
-
-
|
|
7374
|
+
- A storyboard/keyframe sheet can guide a finished video when the user requests that stage. Honor an explicit model choice; select a supported workflow, duration, and reference mode from the exposed model contract.
|
|
7132
7375
|
- For Sogni, model, GPT Image, Seedance, or creative capability questions, describe the media tools Sogni can use instead of falling back to generic text-only limitations.
|
|
7133
|
-
- For unknown product facts, state uncertainty and point to docs.sogni.ai or Discord
|
|
7376
|
+
- For unknown product facts, state uncertainty and point to docs.sogni.ai or Discord.
|
|
7377
|
+
|
|
7378
|
+
MEDIA EXECUTION:
|
|
7379
|
+
- Preserve the requested stage: writing or reviewing a storyboard stops at text; a storyboard image stops at the still. An explicit create-images, animate, and stitch request authorizes those stages in order unless the user asks for a review pause.
|
|
7380
|
+
- Preserve exact image prompts, visible lettering, model choices, source selection, dimensions, and the latest requested duration. A new task does not inherit unrelated earlier render settings. Text-only creation has no source image; pure enlargement of a source uses the promptless upscale tool.
|
|
7381
|
+
- For separate image variations, use the requested count and one complete Dynamic Prompt branch per output. Repeat shared visible text, visual elements, dialogue, and loop motion in every affected branch. For one storyboard sheet, fully write every requested scene, preserving scene titles, panel count, and layout; aspect-ratio numbers are not panel counts.
|
|
7382
|
+
- Use actual uploaded/generated asset indices and preserve reference order. Bind explicit first and last frames, including a return to the original still for a loop. Distinguish audio used as a loose reference from audio driving synchronized performance.
|
|
7383
|
+
- Treat returned media and completed stages as authoritative. Continue only unfinished requested stages; do not render a successful stage again because a summary lacks a tool call. Stop when a tool asks to wait for the user or reports that all outputs failed.
|
|
7384
|
+
- When a tool offers an optional content-filter change, wait for the user's choice and a successful setting change before retrying. If confirmation is declined or unavailable, stop. Do not automatically change settings after a failure, attribute an unknown rejection to a provider, or offer the setting as a remedy for a mandatory model policy.`;
|
|
7134
7385
|
|
|
7135
7386
|
/**
|
|
7136
7387
|
* Build the persona/memory/personality dynamic-system-prompt suffix the
|
|
@@ -7279,6 +7530,11 @@ function chatRunWaitingStatus(type) {
|
|
|
7279
7530
|
}
|
|
7280
7531
|
|
|
7281
7532
|
async function runApiChat(log) {
|
|
7533
|
+
if (options.durableChat && (options.apiTools !== 'creative-agent' || options.apiToolExecution === false)) {
|
|
7534
|
+
const error = new Error('--durable-chat does not support --api-tools overrides or --no-api-tool-execution. Use --api-chat for restricted tools or planning without tool execution.');
|
|
7535
|
+
error.code = 'DURABLE_CHAT_UNSUPPORTED_TOOL_OPTIONS';
|
|
7536
|
+
throw error;
|
|
7537
|
+
}
|
|
7282
7538
|
const creds = loadCredentials();
|
|
7283
7539
|
const apiKey = requireApiKeyCredentials(creds, '--api-chat');
|
|
7284
7540
|
const apiMediaRefs = getApiModeMediaReferences();
|
|
@@ -7289,7 +7545,7 @@ async function runApiChat(log) {
|
|
|
7289
7545
|
model: options.llmModel || DEFAULT_LLM_MODEL,
|
|
7290
7546
|
messages,
|
|
7291
7547
|
temperature: 0.4,
|
|
7292
|
-
max_tokens: options.apiMaxTokens ||
|
|
7548
|
+
max_tokens: options.apiMaxTokens || 4096,
|
|
7293
7549
|
token_type: options.tokenType || 'spark',
|
|
7294
7550
|
app_source: SOGNI_APP_SOURCE,
|
|
7295
7551
|
sogni_tools: options.apiTools,
|
|
@@ -7314,6 +7570,7 @@ async function runApiChat(log) {
|
|
|
7314
7570
|
apiKey,
|
|
7315
7571
|
method: 'POST',
|
|
7316
7572
|
body,
|
|
7573
|
+
timeoutMs: CHAT_HTTP_TIMEOUT_MS,
|
|
7317
7574
|
workloadAttribution,
|
|
7318
7575
|
}));
|
|
7319
7576
|
const message = extractChatMessage(payload);
|
|
@@ -7408,6 +7665,7 @@ async function runApiChatDurable(log, { apiKey, body, workloadAttribution }) {
|
|
|
7408
7665
|
const restBase = new URL(restEndpoint).origin;
|
|
7409
7666
|
|
|
7410
7667
|
const assistantParts = [];
|
|
7668
|
+
let currentAssistantText = '';
|
|
7411
7669
|
const toolCalls = [];
|
|
7412
7670
|
const workflows = [];
|
|
7413
7671
|
let runId = null;
|
|
@@ -7447,12 +7705,23 @@ async function runApiChatDurable(log, { apiKey, body, workloadAttribution }) {
|
|
|
7447
7705
|
for await (const event of helpers.sdkChatRunsStreamEvents(client, runId, {})) {
|
|
7448
7706
|
const type = event?.type || event?.event || '';
|
|
7449
7707
|
const payload = chatRunEventPayload(event);
|
|
7450
|
-
//
|
|
7451
|
-
|
|
7452
|
-
if (
|
|
7453
|
-
|
|
7708
|
+
// Completion events contain a full message snapshot, not another
|
|
7709
|
+
// delta. Reconcile the current message before starting the next round.
|
|
7710
|
+
if (type === 'assistant_message_completed') {
|
|
7711
|
+
const completedText = typeof payload?.content === 'string' ? payload.content : currentAssistantText;
|
|
7454
7712
|
if (!options.json) {
|
|
7455
|
-
|
|
7713
|
+
const remainder = completedText.startsWith(currentAssistantText)
|
|
7714
|
+
? completedText.slice(currentAssistantText.length)
|
|
7715
|
+
: `\n${completedText}`;
|
|
7716
|
+
if (remainder) process.stdout.write(remainder);
|
|
7717
|
+
}
|
|
7718
|
+
assistantParts.push(completedText);
|
|
7719
|
+
currentAssistantText = '';
|
|
7720
|
+
} else {
|
|
7721
|
+
const delta = chatRunAssistantDelta(type, payload);
|
|
7722
|
+
if (typeof delta === 'string' && delta) {
|
|
7723
|
+
currentAssistantText += delta;
|
|
7724
|
+
if (!options.json) process.stdout.write(delta);
|
|
7456
7725
|
}
|
|
7457
7726
|
}
|
|
7458
7727
|
// Per-job progress / ETA / completion / error log lines for
|
|
@@ -7537,6 +7806,7 @@ async function runApiChatDurable(log, { apiKey, body, workloadAttribution }) {
|
|
|
7537
7806
|
},
|
|
7538
7807
|
);
|
|
7539
7808
|
|
|
7809
|
+
if (currentAssistantText) assistantParts.push(currentAssistantText);
|
|
7540
7810
|
const content = assistantParts.join('');
|
|
7541
7811
|
if (options.json) {
|
|
7542
7812
|
console.log(JSON.stringify({
|
|
@@ -7759,7 +8029,7 @@ async function generateStoryboardWorkflowStoryline(apiKey) {
|
|
|
7759
8029
|
model: options.llmModel || DEFAULT_LLM_MODEL,
|
|
7760
8030
|
messages,
|
|
7761
8031
|
temperature: 0.45,
|
|
7762
|
-
max_tokens: options.apiMaxTokens ||
|
|
8032
|
+
max_tokens: options.apiMaxTokens || 4096,
|
|
7763
8033
|
token_type: options.tokenType || 'spark',
|
|
7764
8034
|
app_source: SOGNI_APP_SOURCE,
|
|
7765
8035
|
...(options.apiTaskProfile ? { task_profile: options.apiTaskProfile } : {}),
|
|
@@ -7779,6 +8049,7 @@ async function generateStoryboardWorkflowStoryline(apiKey) {
|
|
|
7779
8049
|
apiKey,
|
|
7780
8050
|
method: 'POST',
|
|
7781
8051
|
body,
|
|
8052
|
+
timeoutMs: CHAT_HTTP_TIMEOUT_MS,
|
|
7782
8053
|
workloadAttribution,
|
|
7783
8054
|
}));
|
|
7784
8055
|
const message = extractChatMessage(payload);
|
|
@@ -8683,6 +8954,7 @@ async function runApiWorkflow() {
|
|
|
8683
8954
|
mediaReferences: apiMediaReferences.length > 0 ? apiMediaReferences : undefined,
|
|
8684
8955
|
maxEstimatedCapacityUnits: options.apiWorkflowMaxCost ?? undefined,
|
|
8685
8956
|
confirmCost: options.apiWorkflowConfirmCost ?? undefined,
|
|
8957
|
+
safeContentFilter: options.noFilter === true ? false : undefined,
|
|
8686
8958
|
idempotencyKey: options.apiWorkflowIdempotencyKey ?? undefined,
|
|
8687
8959
|
attribution: workloadAttribution,
|
|
8688
8960
|
}))
|
|
@@ -8699,6 +8971,7 @@ async function runApiWorkflow() {
|
|
|
8699
8971
|
max_estimated_capacity_units: options.apiWorkflowMaxCost,
|
|
8700
8972
|
} : {}),
|
|
8701
8973
|
...(options.apiWorkflowConfirmCost !== null ? { confirm_cost: options.apiWorkflowConfirmCost } : {}),
|
|
8974
|
+
...(options.noFilter === true ? { safe_content_filter: false } : {}),
|
|
8702
8975
|
token_type: tokenType,
|
|
8703
8976
|
app_source: SOGNI_APP_SOURCE
|
|
8704
8977
|
},
|
|
@@ -11006,7 +11279,7 @@ async function runImageEditProjectWithEvents(client, editConfig, expectedCount,
|
|
|
11006
11279
|
if (projectId && data.projectId !== projectId) return;
|
|
11007
11280
|
if (!projectId) projectId = data.projectId;
|
|
11008
11281
|
cleanup();
|
|
11009
|
-
rejectPromise(
|
|
11282
|
+
rejectPromise(buildProjectResultError(data, 'Job failed'));
|
|
11010
11283
|
};
|
|
11011
11284
|
|
|
11012
11285
|
const cleanup = () => {
|
|
@@ -12235,7 +12508,7 @@ async function main() {
|
|
|
12235
12508
|
|
|
12236
12509
|
// Video catalog data is loaded before model-aware dimension planning.
|
|
12237
12510
|
// Other media types retain the connected-stage lookup used previously.
|
|
12238
|
-
if (!options.video) {
|
|
12511
|
+
if (!options.video && !options.upscaleVideo) {
|
|
12239
12512
|
await loadLiveModelDefaults(options.model);
|
|
12240
12513
|
}
|
|
12241
12514
|
await ensureSufficientVideoBalance(client, log);
|
|
@@ -12314,13 +12587,13 @@ async function main() {
|
|
|
12314
12587
|
client.on(ClientEvent.JOB_COMPLETED, (data) => {
|
|
12315
12588
|
const jobData = data.job?.data || {};
|
|
12316
12589
|
results.push({
|
|
12317
|
-
resultUrl: data.resultUrl || (options.music ? data.audioUrl : options.video ? data.videoUrl : data.imageUrl),
|
|
12590
|
+
resultUrl: data.resultUrl || (options.music ? data.audioUrl : (options.video || options.upscaleVideo) ? data.videoUrl : data.imageUrl),
|
|
12318
12591
|
seed: jobData.seed,
|
|
12319
12592
|
jobIndex: data.jobIndex,
|
|
12320
12593
|
projectId: data.projectId
|
|
12321
12594
|
});
|
|
12322
12595
|
completedJobs++;
|
|
12323
|
-
log(`${options.music ? 'Music' : options.video ? 'Video' : 'Image'} ${completedJobs}/${options.count} completed`);
|
|
12596
|
+
log(`${options.music ? 'Music' : (options.video || options.upscaleVideo) ? 'Video' : 'Image'} ${completedJobs}/${options.count} completed`);
|
|
12324
12597
|
|
|
12325
12598
|
if (completedJobs >= options.count) {
|
|
12326
12599
|
clearTimeout(timeout);
|
|
@@ -12330,31 +12603,28 @@ async function main() {
|
|
|
12330
12603
|
|
|
12331
12604
|
client.on(ClientEvent.JOB_FAILED, (data) => {
|
|
12332
12605
|
clearTimeout(timeout);
|
|
12333
|
-
reject(
|
|
12606
|
+
reject(buildProjectResultError(data, 'Job failed'));
|
|
12334
12607
|
});
|
|
12335
12608
|
|
|
12336
12609
|
client.on(ClientEvent.PROJECT_FAILED, (data) => {
|
|
12337
12610
|
clearTimeout(timeout);
|
|
12338
|
-
|
|
12339
|
-
reject(new Error(message));
|
|
12611
|
+
reject(buildProjectResultError(data));
|
|
12340
12612
|
});
|
|
12341
12613
|
|
|
12342
12614
|
client.on(ClientEvent.PROJECT_EVENT, (event) => {
|
|
12343
12615
|
if (event?.type !== 'error') return;
|
|
12344
12616
|
clearTimeout(timeout);
|
|
12345
|
-
|
|
12346
|
-
reject(new Error(message));
|
|
12617
|
+
reject(buildProjectResultError(event));
|
|
12347
12618
|
});
|
|
12348
12619
|
|
|
12349
12620
|
client.on(ClientEvent.JOB_EVENT, (event) => {
|
|
12350
12621
|
if (event?.type !== 'error') return;
|
|
12351
12622
|
clearTimeout(timeout);
|
|
12352
|
-
|
|
12353
|
-
reject(new Error(message));
|
|
12623
|
+
reject(buildProjectResultError(event, 'Job failed'));
|
|
12354
12624
|
});
|
|
12355
12625
|
|
|
12356
12626
|
// Progress for longer-running media jobs.
|
|
12357
|
-
if (options.video || options.music) {
|
|
12627
|
+
if (options.video || options.music || options.upscaleVideo) {
|
|
12358
12628
|
client.on(ClientEvent.PROJECT_PROGRESS, (data) => {
|
|
12359
12629
|
if (data.percentage && data.percentage > 0) {
|
|
12360
12630
|
log(`Progress: ${Math.round(data.percentage)}%`);
|
|
@@ -13039,6 +13309,49 @@ async function main() {
|
|
|
13039
13309
|
if (audioResult?.error || audioResult?.message) {
|
|
13040
13310
|
throw buildProjectResultError(audioResult);
|
|
13041
13311
|
}
|
|
13312
|
+
} else if (options.upscaleVideo) {
|
|
13313
|
+
log(`Upscaling video with ${FLASHVSR_MODEL_ID}...`);
|
|
13314
|
+
const sourceBuffer = await fetchMediaBuffer(options.upscaleVideo);
|
|
13315
|
+
const source = await probeVideoUpscaleSource(sourceBuffer, options.upscaleVideo);
|
|
13316
|
+
const target = resolveVideoUpscaleOutput(source.width, source.height, options.upscaleResolution);
|
|
13317
|
+
options.width = target.width;
|
|
13318
|
+
options.height = target.height;
|
|
13319
|
+
options.frames = source.frames;
|
|
13320
|
+
options.fps = source.fps;
|
|
13321
|
+
options.outputFormat = 'mp4';
|
|
13322
|
+
options._videoUpscale = { source, resolution: target.resolution };
|
|
13323
|
+
log(
|
|
13324
|
+
`Source ${source.width}x${source.height}, ${source.frames} frames at ${Number(source.fps.toFixed(3))} fps; ` +
|
|
13325
|
+
`output ${target.width}x${target.height} (${target.resolution}p), every frame and the audio kept.`
|
|
13326
|
+
);
|
|
13327
|
+
|
|
13328
|
+
// The exact frame count and rate satisfy the SDK's FlashVSR validation;
|
|
13329
|
+
// the server re-probes the upload and adopts its verified size, so the
|
|
13330
|
+
// output width/height are not sent.
|
|
13331
|
+
const upscaleVideoConfig = {
|
|
13332
|
+
modelId: FLASHVSR_MODEL_ID,
|
|
13333
|
+
positivePrompt: '',
|
|
13334
|
+
numberOfMedia: 1,
|
|
13335
|
+
referenceVideo: sourceBuffer,
|
|
13336
|
+
upscaleResolution: target.resolution,
|
|
13337
|
+
frames: source.frames,
|
|
13338
|
+
fps: source.fps,
|
|
13339
|
+
tokenType: options.tokenType || 'spark',
|
|
13340
|
+
waitForCompletion: false,
|
|
13341
|
+
autoResizeVideoAssets: false
|
|
13342
|
+
};
|
|
13343
|
+
|
|
13344
|
+
let upscaleVideoResult;
|
|
13345
|
+
try {
|
|
13346
|
+
upscaleVideoResult = trackProjectResult(
|
|
13347
|
+
await client.createVideoProject(withBillingMode(upscaleVideoConfig))
|
|
13348
|
+
);
|
|
13349
|
+
} catch (error) {
|
|
13350
|
+
throw annotateVideoUpscaleError(error);
|
|
13351
|
+
}
|
|
13352
|
+
if (upscaleVideoResult?.error || upscaleVideoResult?.message) {
|
|
13353
|
+
throw annotateVideoUpscaleError(buildProjectResultError(upscaleVideoResult));
|
|
13354
|
+
}
|
|
13042
13355
|
} else if (options.upscaleImage) {
|
|
13043
13356
|
log(`Upscaling with ${RTX_VSR_MODEL_ID}...`);
|
|
13044
13357
|
const sourceBuffer = await fetchMediaBuffer(options.upscaleImage);
|
|
@@ -13292,7 +13605,7 @@ async function main() {
|
|
|
13292
13605
|
const seeds = results.map(r => r.seed ?? options.seed);
|
|
13293
13606
|
const renderInfo = {
|
|
13294
13607
|
timestamp: new Date().toISOString(),
|
|
13295
|
-
type: options.music ? 'music' : options.video ? 'video' : 'image',
|
|
13608
|
+
type: options.music ? 'music' : (options.video || options.upscaleVideo) ? 'video' : 'image',
|
|
13296
13609
|
prompt: options.prompt,
|
|
13297
13610
|
model: options.model,
|
|
13298
13611
|
width: options.music ? null : options.width,
|
|
@@ -13338,6 +13651,14 @@ async function main() {
|
|
|
13338
13651
|
renderInfo.shift = options.musicShift;
|
|
13339
13652
|
}
|
|
13340
13653
|
}
|
|
13654
|
+
if (options.upscaleVideo && options._videoUpscale) {
|
|
13655
|
+
renderInfo.upscaleResolution = options._videoUpscale.resolution;
|
|
13656
|
+
renderInfo.fps = options.fps;
|
|
13657
|
+
renderInfo.frames = options.frames;
|
|
13658
|
+
renderInfo.sourceVideo = options.upscaleVideo;
|
|
13659
|
+
renderInfo.sourceWidth = options._videoUpscale.source.width;
|
|
13660
|
+
renderInfo.sourceHeight = options._videoUpscale.source.height;
|
|
13661
|
+
}
|
|
13341
13662
|
if (options.video) {
|
|
13342
13663
|
renderInfo.workflow = options.videoWorkflow;
|
|
13343
13664
|
renderInfo.fps = options.fps;
|
|
@@ -13486,12 +13807,12 @@ async function main() {
|
|
|
13486
13807
|
|
|
13487
13808
|
client2.on(ClientEvent.JOB_FAILED, (data) => {
|
|
13488
13809
|
clearTimeout(timeout);
|
|
13489
|
-
reject(
|
|
13810
|
+
reject(buildProjectResultError(data, 'Second clip generation failed'));
|
|
13490
13811
|
});
|
|
13491
13812
|
|
|
13492
13813
|
client2.on(ClientEvent.PROJECT_FAILED, (data) => {
|
|
13493
13814
|
clearTimeout(timeout);
|
|
13494
|
-
reject(
|
|
13815
|
+
reject(buildProjectResultError(data, 'Second clip project failed'));
|
|
13495
13816
|
});
|
|
13496
13817
|
|
|
13497
13818
|
// Show progress for second clip
|
|
@@ -13516,7 +13837,7 @@ async function main() {
|
|
|
13516
13837
|
await buildConcatVideoFromClips(options.output, [clip1Path, clip2Path]);
|
|
13517
13838
|
log(`Saved looping video to ${options.output}`);
|
|
13518
13839
|
} else {
|
|
13519
|
-
writeOutputFileSafe(options.output, buffer, options.video ? 'video' : options.music ? 'audio' : 'image');
|
|
13840
|
+
writeOutputFileSafe(options.output, buffer, (options.video || options.upscaleVideo) ? 'video' : options.music ? 'audio' : 'image');
|
|
13520
13841
|
log(`Saved to ${options.output}`);
|
|
13521
13842
|
}
|
|
13522
13843
|
}
|
|
@@ -13525,7 +13846,7 @@ async function main() {
|
|
|
13525
13846
|
if (options.json) {
|
|
13526
13847
|
const output = {
|
|
13527
13848
|
success: true,
|
|
13528
|
-
type: options.music ? 'music' : options.video ? 'video' : 'image',
|
|
13849
|
+
type: options.music ? 'music' : (options.video || options.upscaleVideo) ? 'video' : 'image',
|
|
13529
13850
|
prompt: options.prompt,
|
|
13530
13851
|
model: options.model,
|
|
13531
13852
|
width: options.music ? null : options.width,
|
|
@@ -13569,6 +13890,13 @@ async function main() {
|
|
|
13569
13890
|
output.shift = options.musicShift;
|
|
13570
13891
|
}
|
|
13571
13892
|
}
|
|
13893
|
+
if (options.upscaleVideo && options._videoUpscale) {
|
|
13894
|
+
output.upscaleResolution = options._videoUpscale.resolution;
|
|
13895
|
+
output.fps = options.fps;
|
|
13896
|
+
output.frames = options.frames;
|
|
13897
|
+
output.sourceWidth = options._videoUpscale.source.width;
|
|
13898
|
+
output.sourceHeight = options._videoUpscale.source.height;
|
|
13899
|
+
}
|
|
13572
13900
|
if (options.video) {
|
|
13573
13901
|
output.workflow = options.videoWorkflow;
|
|
13574
13902
|
output.fps = options.fps;
|
|
@@ -13644,6 +13972,8 @@ async function main() {
|
|
|
13644
13972
|
}
|
|
13645
13973
|
|
|
13646
13974
|
} catch (error) {
|
|
13975
|
+
// A FlashVSR refusal can also arrive as a project event after submission.
|
|
13976
|
+
if (options.upscaleVideo) annotateVideoUpscaleError(error);
|
|
13647
13977
|
// Token auto-fallback: if using auto mode and got insufficient balance, retry with the other token
|
|
13648
13978
|
const isBalanceError = isStructuredInsufficientBalanceError(error);
|
|
13649
13979
|
if (_allowAutoTokenFallback && isBalanceError && options.tokenType === 'spark') {
|