@sogni-ai/sogni-creative-agent-skill 3.61.1 → 3.63.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.
Files changed (38) hide show
  1. package/.agents/skills/sogni-creative-agent-skill/SKILL.md +24 -13
  2. package/.agents/skills/sogni-creative-agent-skill/references/hosted-api.md +9 -3
  3. package/.agents/skills/sogni-creative-agent-skill/references/image-prompting.md +47 -7
  4. package/.agents/skills/sogni-creative-agent-skill/references/interactive-worlds.md +8 -0
  5. package/.agents/skills/sogni-creative-agent-skill/references/loop-maker.md +2 -2
  6. package/.agents/skills/sogni-creative-agent-skill/references/models.md +132 -41
  7. package/.agents/skills/sogni-creative-agent-skill/references/personas-memory.md +1 -1
  8. package/.agents/skills/sogni-creative-agent-skill/references/private-mature-video.md +21 -16
  9. package/.agents/skills/sogni-creative-agent-skill/references/video-editing.md +52 -0
  10. package/.agents/skills/sogni-creative-agent-skill/references/video-prompting.md +813 -64
  11. package/.claude-plugin/plugin.json +1 -1
  12. package/.codex-plugin/plugin.json +1 -1
  13. package/CHANGELOG.md +33 -0
  14. package/README.md +36 -24
  15. package/SKILL.md +31 -27
  16. package/desktop-extension/manifest.json +2 -2
  17. package/desktop-extension/server/index.mjs +2 -1
  18. package/desktop-extension/server/tools.mjs +49 -5
  19. package/generated/creative-agent-runtime.mjs +9 -9
  20. package/llm.txt +14 -2
  21. package/openclaw.plugin.json +2 -3
  22. package/package.json +7 -5
  23. package/plugin-skills/sogni-creative-agent/SKILL.md +17 -11
  24. package/references/hosted-api.md +9 -3
  25. package/references/image-prompting.md +47 -7
  26. package/references/interactive-worlds.md +8 -0
  27. package/references/loop-maker.md +2 -2
  28. package/references/models.md +132 -41
  29. package/references/openclaw-config.md +4 -1
  30. package/references/personas-memory.md +1 -1
  31. package/references/private-mature-video.md +21 -16
  32. package/references/video-editing.md +52 -0
  33. package/references/video-prompting.md +813 -64
  34. package/skill-package.json +2 -2
  35. package/skills/image_editing.md +2 -1
  36. package/skills/image_generation.md +2 -2
  37. package/sogni-agent.mjs +428 -30
  38. package/version.mjs +1 -1
package/sogni-agent.mjs CHANGED
@@ -50,7 +50,6 @@ import {
50
50
  PUBLIC_SKILL_DEFAULT_TOOL_DEFINITIONS,
51
51
  PUBLIC_SKILL_DEFAULT_TOOL_NAMES,
52
52
  QUALITY_TIERS,
53
- SEEDANCE_V2V_REFERENCE_MAX_DURATION_SECONDS,
54
53
  VIDEO_WORKFLOW_DEFAULT_MODELS,
55
54
  buildStoryboardProject,
56
55
  buildStoryboardVideoHostedToolSequenceInput,
@@ -92,6 +91,11 @@ import {
92
91
  import {
93
92
  extractToolCallProgressUpdate
94
93
  } from '@sogni-ai/sogni-intelligence-client/chatRun';
94
+ import {
95
+ MODEL_PROMPT_GUIDES,
96
+ getModelPromptGuide,
97
+ renderModelPromptGuide
98
+ } from '@sogni-ai/sogni-intelligence-client/prompt-guides';
95
99
  import {
96
100
  buildImageEditExecutionControls,
97
101
  normalizeGptImageModelAlias,
@@ -107,6 +111,8 @@ import {
107
111
  SEEDREAM_DEFAULT_HEIGHT,
108
112
  SEEDREAM_DEFAULT_WIDTH,
109
113
  SEEDANCE_R2V_REFERENCE_AUDIO_MAX_DURATION_SECONDS,
114
+ getSeedanceReferenceAudioMaxDurationSeconds,
115
+ getSeedanceV2VReferenceMaxDurationSeconds,
110
116
  calculateVideoDimensions as calculateSharedVideoDimensions,
111
117
  isMinimaxH3TwoStageModelId,
112
118
  minimaxH3TwoStageCanvasShortEdge,
@@ -814,6 +820,11 @@ function classifyCliError(error, context = {}) {
814
820
  };
815
821
  }
816
822
 
823
+ // The same class as the timeout this replaces on a long chat call: another try can work.
824
+ if (error?.code === 'NETWORK_CONNECTION_LOST') {
825
+ return { error_type: 'PROVIDER_TIMEOUT', category: 'timeout', message: rawMessage, retryable: true };
826
+ }
827
+
817
828
  // Socket 4103: Seedance 2.5 Uncensored, Seedance 2.0 Mini Uncensored and
818
829
  // Seedream 5.0 Pro Uncensored refuse every job until the account accepts their
819
830
  // shared one-time likeness and consent agreement in the Sogni app. The message
@@ -1023,8 +1034,8 @@ function fatalCliError(message, opts = {}) {
1023
1034
 
1024
1035
  // Friendly guidance shown when the Sogni API key is missing or rejected.
1025
1036
  const INVALID_API_KEY_HINT =
1026
- 'Your Sogni API key was rejected. Verify it — or generate a new one — by ' +
1027
- 'logging into https://dashboard.sogni.ai and opening the account menu. ' +
1037
+ 'Your Sogni API key was rejected. Verify it — or generate a new one — at ' +
1038
+ 'https://dashboard.sogni.ai/api-key. ' +
1028
1039
  "If you don't have a Sogni account yet, create one there first, then add its API key.";
1029
1040
 
1030
1041
  // Detect an invalid/rejected API key across the several shapes the SDK can
@@ -1895,6 +1906,25 @@ function getJpegDimensions(buffer) {
1895
1906
  }
1896
1907
 
1897
1908
  const FLUX3_IMAGE_KLEIN_MODEL_ID = 'flux3_image_klein_sd_int8_convrot';
1909
+ const KREA2_IDENTITY_EDIT_MODEL_ID = 'krea2_identity_edit_v1_2';
1910
+ const KREA2_IDENTITY_EDIT_MAX_CONTEXT_IMAGES = 2;
1911
+
1912
+ /**
1913
+ * The model a context edit (-c) uses when neither -m nor the OpenClaw
1914
+ * defaultEditModel names one. Mark's routing (2026-11-01): Krea 2 Identity Edit
1915
+ * for edits of people, FLUX 3 Image Klein for type and graphic design, Dark
1916
+ * Beast Krea 2 Identity Edit for NSFW, GPT Image 2.5 Sunburst as the Premium
1917
+ * Spark best option, and never Qwen Image Edit. Agents choose among them with
1918
+ * -m from what the request means (SKILL.md). Without -m the CLI cannot know what
1919
+ * the request means, so it edits with Krea 2 Identity Edit, which takes one or
1920
+ * two references, and with FLUX 3 Image Klein (up to ten) when more are given.
1921
+ */
1922
+ function defaultEditModelFor(contextImageCount) {
1923
+ return contextImageCount > KREA2_IDENTITY_EDIT_MAX_CONTEXT_IMAGES
1924
+ ? FLUX3_IMAGE_KLEIN_MODEL_ID
1925
+ : KREA2_IDENTITY_EDIT_MODEL_ID;
1926
+ }
1927
+
1898
1928
  const FLUX3_IMAGE_KLEIN_SINGLE_REFERENCE_MAX_PIXELS = 4 * 1024 * 1024;
1899
1929
  // About 2 megapixels: Black Forest Labs says Klein does best at 2K, and 2K is
1900
1930
  // 2 MP (Mark, 2026-10-17). The size of a text-to-image with no size given, and
@@ -2017,6 +2047,19 @@ function imageOptionsFromCli() {
2017
2047
  }
2018
2048
 
2019
2049
  const SEEDANCE_TASK_TYPES = new Set(['reference', 'edit', 'extend']);
2050
+
2051
+ // Seedance 2.5 draft mode: a draft's job id is what --seedance-finalize takes,
2052
+ // and its expiry is the last moment it can be rendered at 1080p. Reported only
2053
+ // for draft-mode requests, from the completed SDK job.
2054
+ function seedanceDraftResultFields(job) {
2055
+ if (!options.seedanceDraft && options.seedanceFinalize === null) return {};
2056
+ return {
2057
+ jobId: job?.id ?? null,
2058
+ ...(options.seedanceDraft
2059
+ ? { seedanceDraft: job?.seedanceDraft === true, seedanceDraftExpiresAt: job?.seedanceDraftExpiresAt ?? null }
2060
+ : { seedanceDraftJobId: job?.seedanceDraftJobId ?? options.seedanceFinalize })
2061
+ };
2062
+ }
2020
2063
  const QWEN_IMAGE_EDIT_2511_MODEL_IDS = new Set([
2021
2064
  'qwen_image_edit_2511_fp8',
2022
2065
  'qwen_image_edit_2511_fp8_lightning',
@@ -3514,6 +3557,181 @@ function loadOpenClawPluginConfig() {
3514
3557
  }
3515
3558
  }
3516
3559
 
3560
+ // ---------------------------------------------------------------------------
3561
+ // Prompt guides: `sogni-agent prompt-guide [model] [--mode <mode>] [--json]`
3562
+ // prints the prompt rules Sogni's own writers use for a model and mode
3563
+ // (@sogni-ai/sogni-intelligence-client/prompt-guides), so an agent can read
3564
+ // them before writing the prompt itself. The model is resolved the way -m is,
3565
+ // by model id only; nothing here reads prompt text. No API call, no credentials.
3566
+ // ---------------------------------------------------------------------------
3567
+ const PROMPT_GUIDE_USAGE = 'sogni-agent prompt-guide <model> [--mode <mode>] [--json]';
3568
+
3569
+ function promptGuideCatalog() {
3570
+ return Object.entries(MODEL_PROMPT_GUIDES).map(([family, modes]) => ({
3571
+ family,
3572
+ modes: Object.keys(modes),
3573
+ models: [...new Set(Object.values(modes).flatMap((guide) => guide.models))],
3574
+ }));
3575
+ }
3576
+
3577
+ function formatPromptGuideCatalog() {
3578
+ const lines = [
3579
+ `Usage: ${PROMPT_GUIDE_USAGE}`,
3580
+ "Prints the prompt rules Sogni's own writers use for a model, to read before you write its prompt. Free and offline.",
3581
+ '',
3582
+ ];
3583
+ for (const { family, modes, models } of promptGuideCatalog()) {
3584
+ lines.push(family, ` modes: ${modes.join(', ')}`, ` models: ${models.join(', ')}`);
3585
+ }
3586
+ return lines.join('\n');
3587
+ }
3588
+
3589
+ // The CLI resolves -m against the run's workflow and frames: with a workflow,
3590
+ // `wan22` t2v/i2v renders on LTX 2.5, and bare tier selectors such as
3591
+ // `minimax-h3-balanced` resolve only with one. A guide mode names both. With no
3592
+ // mode, a run with no media attached is t2v.
3593
+ const PROMPT_GUIDE_MODE_WORKFLOWS = Object.freeze({
3594
+ t2v: ['t2v', false, false],
3595
+ extend: ['t2v', false, false],
3596
+ i2v: ['i2v', true, false],
3597
+ 'i2v-keyframes': ['i2v', true, false],
3598
+ l2v: ['i2v', false, true],
3599
+ flf: ['i2v', true, true],
3600
+ flf2v: ['i2v', true, true],
3601
+ r2v: ['r2v', false, false],
3602
+ v2v: ['v2v', false, false],
3603
+ a2v: ['a2v', false, false],
3604
+ 'a2v-keyframes': ['a2v', false, false],
3605
+ ia2v: ['ia2v', true, false],
3606
+ flfa2v: ['ia2v', true, true],
3607
+ s2v: ['s2v', true, false],
3608
+ 'animate-move': ['animate-move', true, false],
3609
+ 'animate-replace': ['animate-replace', true, false],
3610
+ });
3611
+
3612
+ // Every guide mode, in registry order, for listing what one -m value supports.
3613
+ const PROMPT_GUIDE_MODES = [...new Set(Object.values(MODEL_PROMPT_GUIDES).flatMap((modes) => Object.keys(modes)))];
3614
+
3615
+ // The guide for a -m value and mode, resolved in the CLI's own order: its video
3616
+ // selectors for that workflow, then its image selector normalization. The model
3617
+ // id decides; nothing reads prompt text.
3618
+ function resolvePromptGuide(model, mode) {
3619
+ const [workflow, hasStartFrame, hasEndFrame] = mode
3620
+ ? (PROMPT_GUIDE_MODE_WORKFLOWS[mode] || [])
3621
+ : PROMPT_GUIDE_MODE_WORKFLOWS.t2v;
3622
+ const video = resolveVideoModelAlias(
3623
+ resolveHappyHorseModelId(
3624
+ resolveSkillVideoModelAlias(model, workflow ?? null, Boolean(hasStartFrame), Boolean(hasEndFrame)),
3625
+ workflow ?? null
3626
+ ),
3627
+ workflow
3628
+ );
3629
+ const image = normalizeSeedreamModelAlias(normalizeGptImageModelAlias(model));
3630
+ for (const resolvedModel of new Set([video, image])) {
3631
+ const guide = getModelPromptGuide(resolvedModel, mode || undefined);
3632
+ if (guide) return { guide, resolvedModel };
3633
+ }
3634
+ return null;
3635
+ }
3636
+
3637
+ function runPromptGuideAction(argv) {
3638
+ let model = null;
3639
+ let mode = null;
3640
+ let showCatalog = false;
3641
+ for (let i = 0; i < argv.length; i++) {
3642
+ const arg = argv[i];
3643
+ if (arg === '--mode') {
3644
+ mode = requireFlagValue(argv, i, arg).trim().toLowerCase();
3645
+ i++;
3646
+ } else if (arg === '-m' || arg === '--model') {
3647
+ model = requireFlagValue(argv, i, arg).trim();
3648
+ i++;
3649
+ } else if (arg === '--json' || arg === '--no-update-check') {
3650
+ // --json is read from the raw argv (JSON_ERROR_MODE); the update check reads its own flag.
3651
+ } else if (arg === '--help') {
3652
+ showCatalog = true;
3653
+ } else if (arg.startsWith('-')) {
3654
+ fatalCliError(`Unknown prompt-guide option: ${arg}`, {
3655
+ code: 'INVALID_ARGUMENT',
3656
+ hint: `Usage: ${PROMPT_GUIDE_USAGE}`
3657
+ });
3658
+ } else if (model === null) {
3659
+ model = arg.trim();
3660
+ } else {
3661
+ fatalCliError(`prompt-guide takes one model; got "${model}" and "${arg}".`, {
3662
+ code: 'INVALID_ARGUMENT',
3663
+ hint: `Usage: ${PROMPT_GUIDE_USAGE}`
3664
+ });
3665
+ }
3666
+ }
3667
+
3668
+ const failWithCatalog = (message, details) => {
3669
+ if (!JSON_ERROR_MODE) console.error(formatPromptGuideCatalog());
3670
+ fatalCliError(message, {
3671
+ code: 'INVALID_ARGUMENT',
3672
+ details: { ...details, families: promptGuideCatalog() },
3673
+ hint: `Usage: ${PROMPT_GUIDE_USAGE}. Run sogni-agent prompt-guide with no model to list every guide.`
3674
+ });
3675
+ };
3676
+
3677
+ if (showCatalog || !model) {
3678
+ if (mode && !showCatalog) {
3679
+ failWithCatalog('prompt-guide --mode needs a model.', { mode });
3680
+ }
3681
+ if (JSON_ERROR_MODE) {
3682
+ console.log(JSON.stringify({ success: true, type: 'prompt-guide-list', usage: PROMPT_GUIDE_USAGE, families: promptGuideCatalog() }));
3683
+ } else {
3684
+ console.log(formatPromptGuideCatalog());
3685
+ }
3686
+ return;
3687
+ }
3688
+
3689
+ // Modes differ per selector (krea2-identity-edit only edits; wan22 s2v stays
3690
+ // on WAN 2.2 while its t2v renders on LTX 2.5), so list this -m value's own.
3691
+ const modes = PROMPT_GUIDE_MODES.filter((entry) => resolvePromptGuide(model, entry));
3692
+ const resolved = resolvePromptGuide(model, mode);
3693
+ if (!resolved) {
3694
+ if (mode && modes.length > 0) {
3695
+ fatalCliError(`No "${mode}" prompt guide for ${model}. Its modes: ${modes.join(', ')}.`, {
3696
+ code: 'INVALID_ARGUMENT',
3697
+ details: { model, mode, modes },
3698
+ hint: `Run sogni-agent prompt-guide ${model} --mode <${modes.join('|')}>.`
3699
+ });
3700
+ }
3701
+ failWithCatalog(`No prompt guide for model "${model}".`, { model, mode });
3702
+ }
3703
+
3704
+ const { guide, resolvedModel } = resolved;
3705
+ if (JSON_ERROR_MODE) {
3706
+ console.log(JSON.stringify({
3707
+ success: true,
3708
+ type: 'prompt-guide',
3709
+ model,
3710
+ resolvedModel,
3711
+ family: guide.family,
3712
+ mode: guide.mode,
3713
+ modes,
3714
+ guide,
3715
+ }));
3716
+ return;
3717
+ }
3718
+ const otherModes = modes.filter((entry) => entry !== guide.mode);
3719
+ const footer = [
3720
+ `-m ${model} resolves to ${resolvedModel} in this mode.`,
3721
+ ...(otherModes.length > 0
3722
+ ? [`Other modes: ${otherModes.join(', ')}. Print one with: sogni-agent prompt-guide ${model} --mode <mode>`]
3723
+ : []),
3724
+ ];
3725
+ console.log(`${renderModelPromptGuide(guide, { audience: 'agent' })}\n\n${footer.join('\n')}`);
3726
+ }
3727
+
3728
+ // prompt-guide runs here: after the model alias tables it resolves with, and
3729
+ // before any config, credential or network work.
3730
+ if (RAW_ARGS[0] === 'prompt-guide') {
3731
+ runPromptGuideAction(RAW_ARGS.slice(1));
3732
+ process.exit(0);
3733
+ }
3734
+
3517
3735
  const openclawConfig = loadOpenClawPluginConfig();
3518
3736
  const CREDENTIALS_PATH = resolveConfiguredPath(
3519
3737
  getEnv('SOGNI_CREDENTIALS_PATH') || openclawConfig?.credentialsPath,
@@ -3609,6 +3827,8 @@ const options = {
3609
3827
  video: false,
3610
3828
  videoWorkflow: null,
3611
3829
  seedanceTaskType: null,
3830
+ seedanceDraft: false,
3831
+ seedanceFinalize: null,
3612
3832
  legacyWan3TaskType: null,
3613
3833
  wan3Ratio: 'adaptive',
3614
3834
  wan3SmartDuration: false,
@@ -3812,6 +4032,8 @@ const cliSet = {
3812
4032
  video: false,
3813
4033
  workflow: false,
3814
4034
  seedanceTaskType: false,
4035
+ seedanceDraft: false,
4036
+ seedanceFinalize: false,
3815
4037
  wan3Ratio: false,
3816
4038
  wan3SmartDuration: false,
3817
4039
  wan3ReferenceFileUrl: false,
@@ -4125,6 +4347,14 @@ for (let i = 0; i < args.length; i++) {
4125
4347
  i++;
4126
4348
  options.seedanceTaskType = raw.trim().toLowerCase();
4127
4349
  cliSet.seedanceTaskType = true;
4350
+ } else if (arg === '--seedance-draft') {
4351
+ options.seedanceDraft = true;
4352
+ cliSet.seedanceDraft = true;
4353
+ } else if (arg === '--seedance-finalize') {
4354
+ const raw = requireFlagValue(args, i, arg);
4355
+ i++;
4356
+ options.seedanceFinalize = raw.trim();
4357
+ cliSet.seedanceFinalize = true;
4128
4358
  } else if (arg === '--wan3-task-type') {
4129
4359
  const raw = requireFlagValue(args, i, arg);
4130
4360
  i++;
@@ -4993,7 +5223,8 @@ Image Options:
4993
5223
  --loras <ids> Comma-separated LoRA ids
4994
5224
  --lora-strength <n> LoRA strength (repeatable)
4995
5225
  --lora-strengths <n> Comma-separated LoRA strengths
4996
- -c, --context <path> Context image for editing (can use multiple)
5226
+ -c, --context <path> Context image for editing (can use multiple); without -m edits with
5227
+ krea2_identity_edit_v1_2, or flux3_image_klein_sd_int8_convrot for 3-10 images
4997
5228
  --last-image Use last generated image as context
4998
5229
  --segment <path|url> SAM 3 object selection; returns one original-size PNG mask
4999
5230
  --segment-point <x,y> Include point, normalized 0–1; repeat to refine
@@ -5058,6 +5289,9 @@ Video Options:
5058
5289
  --video, -v Generate video instead of image
5059
5290
  --workflow <type> Video workflow: t2v|i2v|r2v|s2v|ia2v|a2v|v2v|animate-move|animate-replace
5060
5291
  --seedance-task-type <type> Seedance 2.5 loose-reference operation: reference|edit|extend
5292
+ --seedance-draft Seedance 2.5: render a 480p draft that --seedance-finalize can render at 1080p
5293
+ --seedance-finalize <draft-job-id> Seedance 2.5: render that draft at 1080p with its own prompt, media,
5294
+ length, ratio, seed and audio (send none of them; the final is billed at 1080p)
5061
5295
  --wan3-ratio <ratio> Wan 3 ratio: adaptive|16:9|4:3|1:1|3:4|9:16
5062
5296
  --smart-duration, --no-smart-duration Let Wan 3 choose 2-30s, or use --duration
5063
5297
  --reference-file-url <url> Wan 3 public HTTPS document context (one, up to 100 MB; supported paged formats up to 50 pages)
@@ -5224,6 +5458,11 @@ General:
5224
5458
  --version, -V Show sogni-agent version and exit
5225
5459
  --no-update-check Skip the once-daily npm update check for this run
5226
5460
  self-update Upgrade sogni-agent in place (npm/pnpm/yarn/bun auto-detected)
5461
+ prompt-guide <model> [--mode <mode>] [--json]
5462
+ Print the prompt rules Sogni's own writers use for a model and mode
5463
+ (t2v|i2v|l2v|flf|r2v|v2v|a2v|ia2v|extend|generate|edit|...); read them
5464
+ before writing that model's prompt. Free and offline. With no model it
5465
+ lists every guide
5227
5466
  --extract-last-frame <video> <image> Extract last frame from a video (safe ffmpeg wrapper)
5228
5467
  --extract-first-frame <video> <image> Extract first frame from a video (safe ffmpeg wrapper)
5229
5468
  --extract-frame-at <video> <sec> <image> Extract a timestamped frame (safe ffmpeg wrapper)
@@ -5292,8 +5531,8 @@ Image Models:
5292
5531
  dark_beast_krea2_identity_edit_v1_2 Dark Beast Krea 2 Identity Edit (up to 2 context images)
5293
5532
  flux1-schnell-fp8 Very fast
5294
5533
  qwen_image_2512_fp8 High quality
5295
- qwen_image_edit_2511_fp8 Image editing with context (up to 3 images)
5296
- qwen_image_edit_2511_fp8_lightning Fast image editing
5534
+ qwen_image_edit_2511_fp8 Older edit model (up to 3 images): only when named with -m
5535
+ qwen_image_edit_2511_fp8_lightning Older fast edit model: only when named with -m
5297
5536
  rtx_vsr_pro Promptless deterministic RTX VSR upscale (--upscale)
5298
5537
 
5299
5538
  Recommended LTX 2.5 Video Models:
@@ -5435,7 +5674,8 @@ LTX-2 / LTX-2.3 rollback models:
5435
5674
 
5436
5675
  Examples:
5437
5676
  sogni-agent "a cat wearing a hat"
5438
- sogni-agent -o cat.jpg "a cat"
5677
+ sogni-agent prompt-guide seedance2-5 --mode i2v
5678
+ sogni-agent -o cat.jpg "a cat"
5439
5679
  sogni-agent --multi-angle -c subject.jpg --azimuth front-right --elevation eye-level --distance medium "studio portrait"
5440
5680
  sogni-agent --angles-360 -c subject.jpg "studio portrait"
5441
5681
  sogni-agent --video --ref cat.jpg -o cat.mp4 "cat walks around"
@@ -5456,8 +5696,9 @@ Examples:
5456
5696
  sogni-agent --video -m ltx25 --duration 20 "A wide cinematic aerial shot opens over steep tropical cliffs at golden hour, warm sunlight grazing the rock faces while sea mist drifts above the water below. Palm trees bend gently along the ridge as waves roll against the shoreline, leaving bright bands of foam across the dark stone. The camera glides forward in one continuous pass, revealing more of the coastline as sunlight flickers across wet surfaces and distant birds wheel through the haze. The scene holds a calm, upscale travel-film mood with smooth stabilized motion and crisp environmental detail."
5457
5697
  sogni-agent --video --ref subject.jpg --ref-video motion.mp4 --workflow animate-move "transfer motion"
5458
5698
  sogni-agent --video --last-image "gentle camera pan"
5459
- sogni-agent -c photo.jpg "make the background a beach" -m qwen_image_edit_2511_fp8
5699
+ sogni-agent -c photo.jpg "make the background a beach"
5460
5700
  sogni-agent -c person.jpg -m krea2_identity_edit_v1_2 "editorial portrait, same identity, new wardrobe"
5701
+ sogni-agent -c poster.png -m flux3_image_klein_sd_int8_convrot "the headline now reads GRAND OPENING in the same lettering"
5461
5702
  sogni-agent -c subject.jpg -c style.jpg "apply the style to the subject"
5462
5703
  sogni-agent -m flux3_image_klein_sd_int8_convrot -c mug.png -c kitchen.jpg "the mug from the first image on the oak counter from the second image, morning window light"
5463
5704
  sogni-agent --photobooth --ref face.jpg "80s fashion portrait"
@@ -6424,6 +6665,13 @@ if (options.music) {
6424
6665
  : 'Use -m minimax-h3-fasth3-turbo-2stage for 2K MiniMax H3 video, or pass the short side in pixels.'
6425
6666
  });
6426
6667
  }
6668
+ // Seedance 2.5 drafts render at 480p only, so a draft with no size asked for
6669
+ // gets the 480p canvas. A finalize sends no size: its final is the 1080p size
6670
+ // for the draft's ratio.
6671
+ if (options.seedanceDraft && !cliSet.targetResolution && !targetResolutionFromPrompt && !cliSet.width && !cliSet.height) {
6672
+ options.targetResolution = 480;
6673
+ cliSet.targetResolution = true;
6674
+ }
6427
6675
  const hasExplicitVideoCanvas = cliSet.width || cliSet.height || widthFromConfig || heightFromConfig || widthFromPrompt || heightFromPrompt;
6428
6676
  if (isTwoStageVideo) {
6429
6677
  const requestedClass = (cliSet.targetResolution || targetResolutionFromPrompt) ? options.targetResolution : undefined;
@@ -6510,7 +6758,7 @@ if (options.music) {
6510
6758
  }
6511
6759
  } else if (options.contextImages.length > 0) {
6512
6760
  // Use the default edit model when context images are provided unless -m overrides it.
6513
- options.model = options.model || openclawConfig?.defaultEditModel || 'qwen_image_edit_2511_fp8_lightning';
6761
+ options.model = options.model || openclawConfig?.defaultEditModel || defaultEditModelFor(options.contextImages.length);
6514
6762
  if (!cliSet.timeout && !timeoutFromConfig && options.timeout === 30000) {
6515
6763
  options.timeout = 60000; // 1 min for editing
6516
6764
  }
@@ -6622,6 +6870,8 @@ const personaUtilityAction = Boolean(options.personaAction && options.personaAct
6622
6870
  const contractUtilityAction = Boolean(options.contractAction);
6623
6871
  const storyboardPlanUtilityAction = Boolean(options.storyboardPlanAction);
6624
6872
  const commandUsesGenerationSeed = !options.apiChat &&
6873
+ // A Seedance 2.5 finalize renders its draft with the draft's own seed.
6874
+ !options.seedanceFinalize &&
6625
6875
  !apiWorkflowUtilityAction &&
6626
6876
  !apiModelUtilityAction &&
6627
6877
  !liveModelUtilityAction &&
@@ -6692,7 +6942,7 @@ const wan3HasMediaInput = isWan3ModelLocal(options.model) && Boolean(
6692
6942
  || options.wan3ReferenceFileUrl
6693
6943
  || options.wan3ReferenceLinkUrl
6694
6944
  );
6695
- if (!options.prompt && !options.projectLookup && !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) {
6945
+ if (!options.prompt && !options.projectLookup && !options.seedanceFinalize && !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) {
6696
6946
  fatalCliError('No prompt provided. Use --help for usage.', { code: 'INVALID_ARGUMENT' });
6697
6947
  }
6698
6948
 
@@ -6814,8 +7064,8 @@ if (options.legacyWan3TaskType !== null) {
6814
7064
  );
6815
7065
  }
6816
7066
 
6817
- 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)) {
6818
- 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.', {
7067
+ if (!options.video && !options.apiChat && !options.apiWorkflowAction && (options.refAudio || options.refVideo || options.refMask || options.referenceAudioIdentity || options.voicePersonaName || options.videoWorkflow || options.seedanceTaskType || options.seedanceDraft || options.seedanceFinalize || 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)) {
7068
+ fatalCliError('Video-only options (--workflow/--seedance-task-type/--seedance-draft/--seedance-finalize/--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.', {
6819
7069
  code: 'INVALID_ARGUMENT'
6820
7070
  });
6821
7071
  }
@@ -6852,6 +7102,61 @@ if (options.video) {
6852
7102
  details: { model: options.model, seedanceTaskType: options.seedanceTaskType }
6853
7103
  });
6854
7104
  }
7105
+ // Seedance 2.5 draft mode: --seedance-draft renders a 480p draft, and
7106
+ // --seedance-finalize renders that draft at 1080p. The final reuses every
7107
+ // generation-defining input of its draft, and Sogni refuses any of them sent
7108
+ // again, so they are refused here in the CLI's own flag names.
7109
+ if ((options.seedanceDraft || options.seedanceFinalize !== null) && !isSeedance25Video) {
7110
+ fatalCliError('Seedance draft mode (--seedance-draft, --seedance-finalize) is supported only by Seedance 2.5.', {
7111
+ code: 'INVALID_ARGUMENT',
7112
+ details: { model: options.model },
7113
+ hint: 'Pass -m with the Seedance 2.5 model that made (or will make) the draft, such as -m seedance2-5.'
7114
+ });
7115
+ }
7116
+ if (options.seedanceDraft && options.seedanceFinalize !== null) {
7117
+ fatalCliError('--seedance-draft and --seedance-finalize cannot be combined: render a draft, or finalize one.', {
7118
+ code: 'INVALID_ARGUMENT'
7119
+ });
7120
+ }
7121
+ if (options.seedanceDraft && (cliSet.targetResolution || targetResolutionFromPrompt) && Number(options.targetResolution) !== 480) {
7122
+ fatalCliError(`Seedance 2.5 drafts render at 480p only, not ${options.targetResolution}p. Use --target-resolution 480 or leave it out.`, {
7123
+ code: 'INVALID_ARGUMENT',
7124
+ details: { targetResolution: options.targetResolution }
7125
+ });
7126
+ }
7127
+ if (options.seedanceFinalize !== null) {
7128
+ if (!options.seedanceFinalize) {
7129
+ fatalCliError('--seedance-finalize needs the job id of a Seedance 2.5 draft.', { code: 'INVALID_ARGUMENT' });
7130
+ }
7131
+ const inherited = [
7132
+ [options.prompt, 'a prompt'],
7133
+ [options.refImage, '--ref'],
7134
+ [options.refImageEnd, '--ref-end'],
7135
+ [options.contextImages.length > 0, '-c/--context'],
7136
+ [options.refAudio || options.refAudios.length > 0, '--ref-audio'],
7137
+ [options.refVideo || options.refVideos.length > 0, '--ref-video'],
7138
+ [options.referenceAudioIdentity || options.voicePersonaName, '--reference-audio-identity/--voice-persona'],
7139
+ [options.keyframes.length > 0, '--keyframe'],
7140
+ [cliSet.duration, '--duration'],
7141
+ [cliSet.frames, '--frames'],
7142
+ [cliSet.seed || options.lastSeed, '--seed/--last-seed'],
7143
+ [options.apiGenerateAudio !== null, '--generate-audio/--no-generate-audio'],
7144
+ [cliSet.seedanceTaskType || cliSet.workflow, '--seedance-task-type/--workflow'],
7145
+ [cliSet.width || cliSet.height || cliSet.targetResolution, '-w/-h/--target-resolution'],
7146
+ [cliSet.count && options.count !== 1, '-n']
7147
+ ].filter(([present]) => present).map(([, flag]) => flag);
7148
+ if (inherited.length > 0) {
7149
+ fatalCliError(
7150
+ `A Seedance 2.5 finalize renders its draft at 1080p with the draft's own prompt, media, length, ratio, seed and audio; remove ${inherited.join(', ')}.`,
7151
+ {
7152
+ code: 'INVALID_ARGUMENT',
7153
+ details: { seedanceFinalize: options.seedanceFinalize, inherited },
7154
+ hint: `sogni-agent --video -m ${options.model} --seedance-finalize ${options.seedanceFinalize} -o final.mp4`
7155
+ }
7156
+ );
7157
+ }
7158
+ options.count = 1;
7159
+ }
6855
7160
  if ((cliSet.wan3Ratio || options.wan3SmartDuration || options.wan3ReferenceFileUrl || options.wan3ReferenceLinkUrl || options.wan3Watermark) && !isWan3Video) {
6856
7161
  fatalCliError('Wan 3 controls are supported only by Wan 3 or Wan 3.0 Enhanced.', {
6857
7162
  code: 'INVALID_ARGUMENT',
@@ -7367,7 +7672,8 @@ if (options.video) {
7367
7672
  fatalCliError(
7368
7673
  'Seedance reference modes are mutually exclusive: native --ref/--ref-end frame anchors cannot be combined with loose image, video, or audio references. '
7369
7674
  + 'Pick one: use --ref/--ref-end alone for first-class frame anchoring, or use -c/--context with optional --ref-video/--ref-audio and @ImageN/@VideoN/@AudioN prompt language. '
7370
- + 'For image-plus-audio generation, select --workflow ia2v; there --ref is mapped to a loose @Image reference instead of first_frame.',
7675
+ + 'For image-plus-audio generation, select --workflow ia2v; there --ref is mapped to a loose @Image reference instead of first_frame. '
7676
+ + 'To open on a picture while using references, pass it with -c and state it in the prompt as the first frame ("@ImageN is the first frame of this video").',
7371
7677
  { code: 'INVALID_ARGUMENT', details: {
7372
7678
  dedicatedFrames: seedanceFrameInputs,
7373
7679
  looseReferences: seedanceLooseInputs,
@@ -7983,7 +8289,7 @@ if (options.contextImages.length > 0 && !options.video) {
7983
8289
  fatalCliError(`Model ${options.model} does not support context images.`, {
7984
8290
  code: 'INVALID_ARGUMENT',
7985
8291
  details: { model: options.model },
7986
- hint: 'Try: qwen_image_edit_2511_fp8, qwen_image_edit_2511_fp8_lightning, flux3_image_klein_sd_int8_convrot (up to 10), krea2_identity_edit_v1_2, or dark_beast_krea2_identity_edit_v1_2'
8292
+ hint: 'Try: krea2_identity_edit_v1_2 (people, up to 2), flux3_image_klein_sd_int8_convrot (type and design, up to 10), dark_beast_krea2_identity_edit_v1_2 (NSFW, up to 2), or gpt-image-2.5-sunburst (Premium Spark, up to 16)'
7987
8293
  });
7988
8294
  }
7989
8295
  if (options.contextImages.length > maxImages) {
@@ -8099,8 +8405,8 @@ function loadCredentials() {
8099
8405
  const err = new Error('No Sogni API key found.');
8100
8406
  err.code = 'MISSING_CREDENTIALS';
8101
8407
  err.hint = credentialsFileExisted
8102
- ? `Found ${CREDENTIALS_PATH} but it has no usable "SOGNI_API_KEY=..." line. Check for typos/extra quotes, or set SOGNI_API_KEY in the environment. Get your key at https://dashboard.sogni.ai (account menu).`
8103
- : 'Set SOGNI_API_KEY, or configure SOGNI_CREDENTIALS_PATH with SOGNI_API_KEY. You can find your API key by logging into https://dashboard.sogni.ai and opening the account menu.';
8408
+ ? `Found ${CREDENTIALS_PATH} but it has no usable "SOGNI_API_KEY=..." line. Check for typos/extra quotes, or set SOGNI_API_KEY in the environment. Get your key at https://dashboard.sogni.ai/api-key.`
8409
+ : 'Set SOGNI_API_KEY, or configure SOGNI_CREDENTIALS_PATH with SOGNI_API_KEY. You can get an API key at https://dashboard.sogni.ai/api-key.';
8104
8410
  err.details = {
8105
8411
  triedEnv: ['SOGNI_API_KEY'],
8106
8412
  triedFile: CREDENTIALS_PATH,
@@ -8392,7 +8698,18 @@ async function fetchApiJson(path, {
8392
8698
  };
8393
8699
 
8394
8700
  const response = await fetchWithTimeout(url, init, timeoutMs);
8395
- const text = await response.text();
8701
+ let text;
8702
+ try {
8703
+ text = await response.text();
8704
+ } catch (cause) {
8705
+ // A kept-alive chat call answers 200 long before its reply, so the connection can
8706
+ // still drop here, and fetch reports that only as "terminated".
8707
+ const err = new Error('The connection to Sogni was lost before the reply finished.');
8708
+ err.code = 'NETWORK_CONNECTION_LOST';
8709
+ err.hint = 'Check your internet connection or proxy, then run the request again. Part of the work may already have run.';
8710
+ err.cause = cause;
8711
+ throw err;
8712
+ }
8396
8713
  let payload = {};
8397
8714
  if (text) {
8398
8715
  try {
@@ -8782,6 +9099,21 @@ function extractChatMessage(payload) {
8782
9099
  return data?.choices?.[0]?.message || data?.choices?.[0]?.delta || payload?.choices?.[0]?.message || {};
8783
9100
  }
8784
9101
 
9102
+ // With this header, a chat call still working after 90 seconds answers 200 and sends
9103
+ // spaces until it finishes, so it outlasts this CLI's timeout and Cloudflare's. A failure
9104
+ // after that can only arrive in the body, so every such call must check it below. The
9105
+ // body also has no Content-Length, so a hop that ends it early looks like a clean end.
9106
+ const CHAT_KEEPALIVE_HEADERS = { 'X-Sogni-Nonstream-Keepalive': 'true' };
9107
+
9108
+ function throwIfChatBodyHasError(payload) {
9109
+ const data = extractApiEnvelopeData(payload);
9110
+ if (!payload?.error && data?.choices) return;
9111
+ const err = new Error(payload?.error?.message || 'Sogni ended this chat call without a complete reply.');
9112
+ err.code = 'API_REQUEST_FAILED';
9113
+ err.details = { payload };
9114
+ throw err;
9115
+ }
9116
+
8785
9117
  function extractChatWorkflows(payload) {
8786
9118
  const data = extractApiEnvelopeData(payload);
8787
9119
  return data?.creative_workflows || payload?.creative_workflows || [];
@@ -9026,9 +9358,11 @@ async function runApiChat(log) {
9026
9358
  apiKey,
9027
9359
  method: 'POST',
9028
9360
  body,
9361
+ headers: CHAT_KEEPALIVE_HEADERS,
9029
9362
  timeoutMs: CHAT_HTTP_TIMEOUT_MS,
9030
9363
  workloadAttribution,
9031
9364
  }));
9365
+ throwIfChatBodyHasError(payload);
9032
9366
  const message = extractChatMessage(payload);
9033
9367
  const workflows = extractChatWorkflows(payload);
9034
9368
  const toolCalls = message.tool_calls || message.toolCalls || [];
@@ -9536,9 +9870,11 @@ async function generateStoryboardWorkflowStoryline(apiKey) {
9536
9870
  apiKey,
9537
9871
  method: 'POST',
9538
9872
  body,
9873
+ headers: CHAT_KEEPALIVE_HEADERS,
9539
9874
  timeoutMs: CHAT_HTTP_TIMEOUT_MS,
9540
9875
  workloadAttribution,
9541
9876
  }));
9877
+ throwIfChatBodyHasError(payload);
9542
9878
  const message = extractChatMessage(payload);
9543
9879
  const storyline = typeof message.content === 'string' ? message.content.trim() : '';
9544
9880
  if (!storyline) {
@@ -11131,7 +11467,7 @@ async function trimSeedanceReferenceAudioToMp3(request) {
11131
11467
  const start = Math.max(0, Number(request.start) || 0);
11132
11468
  const duration = Math.max(
11133
11469
  0.1,
11134
- Math.min(15, Number(request.duration) || 15),
11470
+ Math.min(seedanceReferenceAudioMaxSeconds(), Number(request.duration) || seedanceReferenceAudioMaxSeconds()),
11135
11471
  );
11136
11472
  try {
11137
11473
  writeFileSync(inputPath, Buffer.from(request.data));
@@ -11178,13 +11514,22 @@ async function trimSeedanceV2VSourceVideo(request) {
11178
11514
  };
11179
11515
  }
11180
11516
 
11517
+ // Seedance 2.5 and 2.5 Uncensored accept 30 s of reference video and audio; the 2.0 family accepts 15 s.
11518
+ function seedanceReferenceVideoMaxSeconds() {
11519
+ return getSeedanceV2VReferenceMaxDurationSeconds(options.model);
11520
+ }
11521
+
11522
+ function seedanceReferenceAudioMaxSeconds() {
11523
+ return Math.floor(getSeedanceReferenceAudioMaxDurationSeconds(options.model));
11524
+ }
11525
+
11181
11526
  function seedanceReferenceAudioWindow() {
11182
11527
  const requestedDuration = options.audioDuration ?? options.duration;
11183
11528
  const maxDurationSeconds = Math.min(
11184
11529
  Number.isFinite(Number(requestedDuration)) && Number(requestedDuration) > 0
11185
11530
  ? Number(requestedDuration)
11186
- : SEEDANCE_R2V_REFERENCE_AUDIO_MAX_DURATION_SECONDS,
11187
- 15,
11531
+ : getSeedanceReferenceAudioMaxDurationSeconds(options.model),
11532
+ seedanceReferenceAudioMaxSeconds(),
11188
11533
  );
11189
11534
  return {
11190
11535
  maxDurationSeconds,
@@ -11241,7 +11586,7 @@ async function prepareSeedanceReferenceVideoUploadFile(pathOrUrl, buffer) {
11241
11586
  const sourceDurationSeconds = await probeLocalMediaDurationSeconds(pathOrUrl);
11242
11587
  const requestedDuration = Number.isFinite(Number(options.duration))
11243
11588
  ? Number(options.duration)
11244
- : SEEDANCE_V2V_REFERENCE_MAX_DURATION_SECONDS;
11589
+ : seedanceReferenceVideoMaxSeconds();
11245
11590
  const prepared = await prepareSharedSeedanceV2VSourceVideo(
11246
11591
  buffer,
11247
11592
  rawMimeType,
@@ -11249,7 +11594,7 @@ async function prepareSeedanceReferenceVideoUploadFile(pathOrUrl, buffer) {
11249
11594
  sourceDurationSeconds,
11250
11595
  requestedDuration,
11251
11596
  options.videoStart ?? 0,
11252
- { trimVideo: trimSeedanceV2VSourceVideo },
11597
+ { trimVideo: trimSeedanceV2VSourceVideo, modelId: options.model },
11253
11598
  );
11254
11599
  if (!options.quiet && prepared.trimmed) {
11255
11600
  console.error('Prepared Seedance V2V reference video clip before upload.');
@@ -11425,7 +11770,7 @@ async function trimSeedanceV2VSourceVideoBuffer(buffer, sourceLabel, startOffset
11425
11770
  const start = Math.max(0, Number(startOffset) || 0);
11426
11771
  const duration = Math.max(
11427
11772
  0.1,
11428
- Math.min(SEEDANCE_V2V_REFERENCE_MAX_DURATION_SECONDS, Number(requestedDuration) || SEEDANCE_V2V_REFERENCE_MAX_DURATION_SECONDS),
11773
+ Math.min(seedanceReferenceVideoMaxSeconds(), Number(requestedDuration) || seedanceReferenceVideoMaxSeconds()),
11429
11774
  );
11430
11775
  try {
11431
11776
  writeFileSync(inputPath, buffer);
@@ -12998,7 +13343,10 @@ function projectLookupSummary(result) {
12998
13343
  ...(job.reason ? { reason: job.reason } : {}),
12999
13344
  ...(job.kind ? { kind: job.kind } : {}),
13000
13345
  ...(job.url ? { url: job.url } : {}),
13001
- ...(job.urlUnavailable ? { urlUnavailable: job.urlUnavailable } : {})
13346
+ ...(job.urlUnavailable ? { urlUnavailable: job.urlUnavailable } : {}),
13347
+ // Seedance 2.5 draft mode: render a draft at 1080p with --seedance-finalize <id> before it expires.
13348
+ ...(job.seedanceDraft === true ? { seedanceDraft: true, seedanceDraftExpiresAt: job.seedanceDraftExpiresAt ?? null } : {}),
13349
+ ...(job.seedanceDraftJobId ? { seedanceDraftJobId: job.seedanceDraftJobId } : {})
13002
13350
  }))
13003
13351
  };
13004
13352
  }
@@ -13858,7 +14206,11 @@ async function buildVideoEstimateParams({ tokenType, steps }) {
13858
14206
  ...(options.frames ? { frames: options.frames } : { duration: options.duration }),
13859
14207
  ...(referenceImageCount !== undefined ? { referenceImageCount } : {}),
13860
14208
  // MiniMax H3 keyframes: two are included, each extra one adds output time.
13861
- ...(options.keyframes.length > 0 ? { keyframeCount: options.keyframes.length } : {})
14209
+ ...(options.keyframes.length > 0 ? { keyframeCount: options.keyframes.length } : {}),
14210
+ // Seedance 2.5 draft mode: a draft is quoted as its 480p job, a finalize
14211
+ // from its draft (the server ignores this request's size and length).
14212
+ ...(options.seedanceDraft ? { seedanceDraft: true } : {}),
14213
+ ...(options.seedanceFinalize !== null ? { seedanceDraftJobId: options.seedanceFinalize } : {})
13862
14214
  };
13863
14215
 
13864
14216
  if ((isSeedanceVideo || isWan3Video || isMiniMaxH3R2v) && videoSources.length > 0) {
@@ -14102,7 +14454,7 @@ async function runDoctor() {
14102
14454
  }
14103
14455
  } catch (err) {
14104
14456
  if (isInvalidApiKeyError(err)) {
14105
- add('auth', 'fail', 'API key rejected — get a fresh key at https://dashboard.sogni.ai (account menu)');
14457
+ add('auth', 'fail', 'API key rejected — get a fresh key at https://dashboard.sogni.ai/api-key');
14106
14458
  } else {
14107
14459
  add('auth', 'warn', `could not verify the key (network?): ${err?.message || err}`);
14108
14460
  }
@@ -14755,6 +15107,12 @@ async function main() {
14755
15107
  count: options.count,
14756
15108
  ...(delivered ? { deliveredWidth: delivered.width, deliveredHeight: delivered.height } : {}),
14757
15109
  ...(options.keyframes.length > 0 ? { keyframeCount: options.keyframes.length } : {}),
15110
+ // A finalize is quoted from its draft: 1080p in the draft's ratio, for
15111
+ // the draft's length, not this request's defaults.
15112
+ ...(options.seedanceFinalize !== null
15113
+ ? { width: null, height: null, frames: null, duration: null, seedanceDraftJobId: options.seedanceFinalize }
15114
+ : {}),
15115
+ ...(options.seedanceDraft ? { seedanceDraft: true } : {}),
14758
15116
  estimate
14759
15117
  }));
14760
15118
  } else {
@@ -14799,6 +15157,7 @@ async function main() {
14799
15157
  seed: jobData.seed,
14800
15158
  jobIndex: data.jobIndex,
14801
15159
  projectId: data.projectId,
15160
+ ...seedanceDraftResultFields(data.job),
14802
15161
  nsfwDetected: data.job?.nsfwDetected ?? jobData.nsfwDetected ?? false,
14803
15162
  nsfwSources: data.job?.nsfwSources ?? jobData.nsfwSources ?? [],
14804
15163
  ...(withheld ? { urlUnavailable: 'sensitiveContent' } : {})
@@ -15141,7 +15500,8 @@ async function main() {
15141
15500
  && shouldTrimSeedanceV2VSourceVideo({
15142
15501
  sourceDurationSeconds: null,
15143
15502
  requestedDurationSeconds: options.duration,
15144
- startOffsetSeconds: options.videoStart ?? 0
15503
+ startOffsetSeconds: options.videoStart ?? 0,
15504
+ maxDurationSeconds: seedanceReferenceVideoMaxSeconds()
15145
15505
  })
15146
15506
  ) {
15147
15507
  videoBuffer = await trimSeedanceV2VSourceVideoBuffer(
@@ -15331,6 +15691,7 @@ async function main() {
15331
15691
  if (options.seedanceTaskType) {
15332
15692
  projectConfig.seedanceTaskType = options.seedanceTaskType;
15333
15693
  }
15694
+ if (options.seedanceDraft) projectConfig.seedanceDraft = true;
15334
15695
  if (options.returnLastFrame) projectConfig.returnLastFrame = true;
15335
15696
  if (isWan3Video) {
15336
15697
  projectConfig.ratio = options.wan3Ratio;
@@ -15493,6 +15854,16 @@ async function main() {
15493
15854
  projectConfig.loraStrengths = options.loraStrengths;
15494
15855
  }
15495
15856
 
15857
+ if (options.seedanceFinalize !== null) {
15858
+ // The final is its draft at 1080p: Sogni takes the prompt, media, length,
15859
+ // ratio, seed and audio from the draft and refuses them sent again. The
15860
+ // flags that set them are refused up front; the default length is not.
15861
+ delete projectConfig.duration;
15862
+ projectConfig.positivePrompt = '';
15863
+ projectConfig.seedanceDraftJobId = options.seedanceFinalize;
15864
+ log(`Rendering Seedance draft ${options.seedanceFinalize} at 1080p...`);
15865
+ }
15866
+
15496
15867
  await warnAboutInFlightProjects(client, log);
15497
15868
  const videoResult = trackProjectResult(
15498
15869
  await client.createVideoProject(withBillingMode(projectConfig))
@@ -15964,8 +16335,11 @@ async function main() {
15964
16335
  seeds,
15965
16336
  projectId: firstResult.projectId,
15966
16337
  urls: urls,
15967
- results: results.map(({ resultUrl, seed, jobIndex, nsfwDetected, nsfwSources, urlUnavailable }) => ({
15968
- url: resultUrl, seed, jobIndex, nsfwDetected, nsfwSources, ...(urlUnavailable ? { urlUnavailable } : {})
16338
+ results: results.map(({ resultUrl, seed, jobIndex, nsfwDetected, nsfwSources, urlUnavailable, jobId, seedanceDraft, seedanceDraftExpiresAt, seedanceDraftJobId }) => ({
16339
+ url: resultUrl, seed, jobIndex, nsfwDetected, nsfwSources, ...(urlUnavailable ? { urlUnavailable } : {}),
16340
+ ...(jobId ? { jobId } : {}),
16341
+ ...(seedanceDraft !== undefined ? { seedanceDraft, seedanceDraftExpiresAt } : {}),
16342
+ ...(seedanceDraftJobId ? { seedanceDraftJobId } : {})
15969
16343
  })),
15970
16344
  localPath: options.output || null,
15971
16345
  tokenType: options.tokenType || 'spark',
@@ -16364,6 +16738,13 @@ async function main() {
16364
16738
  guidanceEnd: options.cnGuidanceEnd ?? 0.6,
16365
16739
  };
16366
16740
  }
16741
+ if (options.seedanceFinalize !== null) {
16742
+ // The final's size and length are its draft's, at 1080p, not this
16743
+ // request's defaults.
16744
+ output.width = null;
16745
+ output.height = null;
16746
+ output.duration = null;
16747
+ }
16367
16748
  console.log(JSON.stringify(output));
16368
16749
  } else {
16369
16750
  urls.forEach(url => console.log(url));
@@ -16371,6 +16752,13 @@ async function main() {
16371
16752
  if (options.returnLastFrame) {
16372
16753
  results.forEach(result => { if (result.lastFrameUrl) console.log(`Last frame: ${result.lastFrameUrl}`); });
16373
16754
  }
16755
+ if (options.seedanceDraft) {
16756
+ results.forEach(result => {
16757
+ if (!result.jobId) return;
16758
+ const until = result.seedanceDraftExpiresAt ? ` until ${result.seedanceDraftExpiresAt}` : '';
16759
+ console.log(`Seedance draft ${result.jobId}. Render it at 1080p${until} with: sogni-agent --video -m ${options.model} --seedance-finalize ${result.jobId} -o final.mp4`);
16760
+ });
16761
+ }
16374
16762
  }
16375
16763
  } else {
16376
16764
  throw new Error('No output generated - may have been filtered');
@@ -16464,10 +16852,20 @@ async function main() {
16464
16852
  }
16465
16853
  } catch (e) {}
16466
16854
  }
16855
+ await flushStdout();
16467
16856
  process.exit(exitCode);
16468
16857
  }
16469
16858
 
16859
+ // process.exit drops whatever a pipe hasn't taken yet. On macOS that is everything past
16860
+ // its first 64 KB, so a long --json reply reached an agent cut short, with exit code 0.
16861
+ function flushStdout() {
16862
+ return new Promise((resolve) => process.stdout.write('', resolve));
16863
+ }
16864
+
16470
16865
  main().then(
16471
- () => process.exit(0),
16866
+ async () => {
16867
+ await flushStdout();
16868
+ process.exit(0);
16869
+ },
16472
16870
  (error) => reportFatalError(error)
16473
16871
  );