@sogni-ai/sogni-creative-agent-skill 3.61.0 → 3.62.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 (31) hide show
  1. package/.agents/skills/sogni-creative-agent-skill/SKILL.md +21 -3
  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 +3 -2
  4. package/.agents/skills/sogni-creative-agent-skill/references/interactive-worlds.md +8 -0
  5. package/.agents/skills/sogni-creative-agent-skill/references/models.md +150 -19
  6. package/.agents/skills/sogni-creative-agent-skill/references/personas-memory.md +1 -1
  7. package/.agents/skills/sogni-creative-agent-skill/references/video-editing.md +74 -2
  8. package/.agents/skills/sogni-creative-agent-skill/references/video-prompting.md +9 -0
  9. package/.claude-plugin/plugin.json +1 -1
  10. package/.codex-plugin/plugin.json +1 -1
  11. package/CHANGELOG.md +26 -0
  12. package/README.md +9 -8
  13. package/SKILL.md +15 -17
  14. package/desktop-extension/manifest.json +2 -2
  15. package/llm.txt +7 -2
  16. package/openclaw.plugin.json +2 -3
  17. package/package.json +3 -3
  18. package/plugin-skills/sogni-creative-agent/SKILL.md +3 -1
  19. package/references/hosted-api.md +9 -3
  20. package/references/image-prompting.md +3 -2
  21. package/references/interactive-worlds.md +8 -0
  22. package/references/models.md +150 -19
  23. package/references/openclaw-config.md +4 -1
  24. package/references/personas-memory.md +1 -1
  25. package/references/video-editing.md +74 -2
  26. package/references/video-prompting.md +9 -0
  27. package/skill-package.json +2 -2
  28. package/skills/image_editing.md +2 -1
  29. package/skills/image_generation.md +1 -1
  30. package/sogni-agent.mjs +98 -21
  31. package/version.mjs +1 -1
@@ -1,8 +1,8 @@
1
1
  # Video Editing & Stitching (local FFmpeg-wrapper workflows)
2
2
 
3
3
  Read this when the user asks to animate between images, continue a video,
4
- bridge two videos, build a 360 turntable video, stitch clips, or remix/layer
5
- audio over a finished video.
4
+ bridge two videos, build a 360 turntable video, stitch clips (above all clips
5
+ from different models), or remix/layer audio over a finished video.
6
6
 
7
7
  **Never run raw `ffmpeg`, `ls`, or `cp` shell commands for any of this.**
8
8
  Always use the built-in safe wrappers: `--extract-first-frame`,
@@ -10,6 +10,52 @@ Always use the built-in safe wrappers: `--extract-first-frame`,
10
10
  `--video-start`, `--audio-start`, `--audio-duration`. They produce safer, more
11
11
  reproducible results and are the only sanctioned file operations.
12
12
 
13
+ ## Before you show a stitched video: check every join
14
+
15
+ Judge video from many frames, never a handful (Mark, 2026-11-02: judging from "a
16
+ handful of frames" is "a major major major detriment to quality"). Look at
17
+ two dozen or more frames across every clip. After every `--concat-videos`,
18
+ check each join: pull the last frame of each clip and the first frame of the
19
+ next (`--extract-last-frame` / `--extract-first-frame`) and compare them at full
20
+ size. Check:
21
+
22
+ - the same people on the same sides, with the same props and wardrobe;
23
+ - a vehicle that keeps its model, lights, mirrors, plate and passengers;
24
+ - eyelines that point at whoever is being spoken to, and motion that keeps its
25
+ screen direction;
26
+ - the same light and time of day.
27
+
28
+ Two clips in the same framing but a different place or time read as a jump:
29
+ put a clip between them. A join that breaks continuity is a defect even when
30
+ each clip is good on its own. The Sogni Worlds Kit's `node world joins <video>`
31
+ lays out every cut of a finished film, frame by frame on both sides, in one step.
32
+
33
+ ## Check that the world stays physical, and split the checking up
34
+
35
+ A video model draws whatever the prompt names, even when the first frame lacks it:
36
+ "the cars pile into a pillar" over a still with no pillar grows one down out of the
37
+ sky. On every clip, check that:
38
+
39
+ - nothing appears, vanishes or grows;
40
+ - people sit the right way in vehicles (the driver faces the wheel);
41
+ - people are in scale with doors, windows and wheels;
42
+ - props stay on the same side in every angle;
43
+ - the skyline, bridges and direction of travel agree across clips, and pursuers stay
44
+ behind;
45
+ - a shot that should move moves;
46
+ - every sign and plate reads correctly.
47
+
48
+ Name only what the first frame shows, or put the object in the still first. Before
49
+ the user sees a stitched video, have a fresh agent with no stake in the clips run the
50
+ same list over it.
51
+
52
+ Work in parallel wherever it costs no quality: build every contact sheet in one
53
+ ffmpeg pass, then give each reviewer a few clips with their ready sheets (one reviewer
54
+ working through a whole film clip by clip took 32 minutes; split up, it takes a few).
55
+ Re-check only what changed since the last review, and submit independent renders
56
+ together, judging each as it lands. One agent keeps the edit and the final call:
57
+ helpers report what they find and never change the cut.
58
+
13
59
  ## Animate Between Two Images (First-Frame / Last-Frame)
14
60
 
15
61
  When a user asks to **animate between two images**, use `--ref` (first frame) and `--ref-end` (last frame):
@@ -157,10 +203,36 @@ sogni-agent --remix-audio ./merged.mp4 ./final.mp4 \
157
203
  - `--mix-audio` overlays one extra track (mixed with a peak limiter so it never clips); position it with `--mix-at` and adjust level with `--mix-gain` (dB).
158
204
  - To mix more than two layers, chain `--remix-audio` passes (each only re-encodes audio).
159
205
 
206
+ ## Cutting takes from different models together
207
+
208
+ Learned on Sogni's own productions (2026-10):
209
+
210
+ - **Set the frame rate yourself.** `--concat-videos` uses the highest clip fps
211
+ by default. One Wan 3 shot (30 fps) among Seedance or MiniMax H3 shots (24
212
+ fps) turns the whole sequence into 30 fps with repeated frames. Pass
213
+ `--concat-fps 24`.
214
+ - **Watch the joined sequence at full size.** A shot from another model often
215
+ has a different contrast and colour from the shots around it. Point it out to
216
+ the person: matching the grade needs a colour tool outside this CLI.
217
+ - **Listen to the last second of each clip.** Generated clips often end on a
218
+ whoosh or swish that nothing on screen makes, and it sounds bad on a cut.
219
+ If a clip ends on one, end the shot before it. Between scenes, a plain cut
220
+ beats a whoosh, a synthetic whip blur or a crossfade.
221
+ - **To change what a screen or a sign shows across a moving shot,** edit the
222
+ clip with Seedance 2.5 (`--seedance-task-type edit`), rather than tracking a
223
+ mask and compositing. See models.md › Seedance 2.5 takes in practice.
224
+
160
225
  ## Multiple Angles (Turnaround) and 360 Video
161
226
 
162
227
  Generate specific camera angles from a single reference image using the Multiple Angles LoRA:
163
228
 
229
+ These flags run Qwen Image Edit 2511, the only model with the Multiple Angles
230
+ LoRA. It is an older model that is never a default or a recommendation: use
231
+ `--multi-angle` / `--angles-360` only when the user asks for them (or the
232
+ Multiple Angles LoRA) by name. For an ordinary change of camera angle, edit
233
+ with `-c` on the model SKILL.md's edit-model routing picks (Krea 2 Identity
234
+ Edit for a person, FLUX 3 Image Klein for type or design).
235
+
164
236
  ```bash
165
237
  # Single angle
166
238
  sogni-agent --multi-angle -c subject.jpg \
@@ -345,6 +345,15 @@ Tested on a branching horror route the same day, on top of the rules above:
345
345
  plain American accent with a light, mid-pitched voice at a quick, breathless
346
346
  pace, says: <d>[English] …</d>`. "A bright, breathless voice" alone drifted
347
347
  to a British accent between takes.
348
+ - **A recurring character keeps one voice, word for word.** Write each speaking
349
+ character's voice once (their reference clip if they have one, plus one fixed
350
+ wording) and paste it verbatim into every clip they speak in. With a Seedance
351
+ voice reference, say "Jean's voice is exactly @Audio1." once and "Jean, in his
352
+ own voice exactly @Audio1," before each of his lines, and add no accent or
353
+ language words: a fresh description ("plain American English") pulls the take
354
+ off the reference, and the character sounds like a different person from clip
355
+ to clip. Delivery (quiet, gritted) goes after the tag. Judge by ear, played
356
+ right after an approved line.
348
357
  - **Dialogue after the action that motivates it.** She says "That's my dad"
349
358
  after she has picked the photograph up, in the shot where she holds it.
350
359
  - **Whose hands.** In first-person coverage say whose hands are in frame
@@ -3,12 +3,12 @@
3
3
  "private": true,
4
4
  "type": "module",
5
5
  "dependencies": {
6
- "@sogni-ai/sogni-intelligence-client": "4.22.4",
6
+ "@sogni-ai/sogni-intelligence-client": "4.22.9",
7
7
  "execa": "^10.0.1",
8
8
  "json5": "^2.2.3",
9
9
  "sharp": "0.35.5"
10
10
  },
11
11
  "overrides": {
12
- "@sogni-ai/sogni-client": "5.71.0"
12
+ "@sogni-ai/sogni-client": "5.73.0"
13
13
  }
14
14
  }
@@ -28,7 +28,8 @@ Edit, restore, restyle, refine, upscale, or change the camera angle of an existi
28
28
 
29
29
  - Persona images must always be produced with `edit_image` and a reference photo — never invoke `generate_image` for persona output.
30
30
  - Use `-m krea2_identity_edit_v1_2` for identity-preserving Krea 2 edits with 1-2 context images; use `-m dark_beast_krea2_identity_edit_v1_2` for the Dark Beast Krea 2 identity edit LoRA. Both support 512-2048 px output, 8-12 steps, guidance 1, and default to 10 steps.
31
- - Qwen Image Edit supports up to 3 context images, GPT Image 2 supports up to 16, FLUX 3 Image Klein (`flux3_image_klein_sd_int8_convrot`, hosted `flux-3-klein`) supports up to 10, Seedream 5.0 Pro Uncensored (`seedream-5-0-pro-uncensored`, only when the user asks for it; it shares the Seedance 2.5 Uncensored likeness agreement) supports up to 10, and Krea identity edit models support up to 2.
31
+ - Choose the edit model from what the request means, never from keywords; an explicitly requested model always wins. A person or character whose likeness must hold: `krea2_identity_edit_v1_2` (hosted `krea-identity-edit`). Type, logos, posters and other graphic design: `flux3_image_klein_sd_int8_convrot` (hosted `flux-3-klein`). NSFW: `dark_beast_krea2_identity_edit_v1_2` (hosted `dark-beast-krea2-identity-edit`). The best result when the user has Premium Spark or asks for top quality: `gpt-image-2.5-sunburst`. Never choose Qwen Image Edit, an older model, unless the user names it.
32
+ - GPT Image 2 and 2.5 support up to 16 context images, FLUX 3 Image Klein (`flux3_image_klein_sd_int8_convrot`, hosted `flux-3-klein`) supports up to 10, Seedream 5.0 Pro Uncensored (`seedream-5-0-pro-uncensored`, only when the user asks for it; it shares the Seedance 2.5 Uncensored likeness agreement) supports up to 10, Krea identity edit models support up to 2, and the older Qwen Image Edit up to 3.
32
33
  - `refine_result` acts on a prior generation in the session; do not call it before any image has been produced or uploaded.
33
34
  - Use `upscale_image` when the user only wants a larger, higher-resolution copy. It takes one source image plus an optional 2x/3x/4x scale or target longest edge. Both 8px-aligned output edges must remain within 512-15360px; use 7680 for 8K or 15360 for 16K. Targets above 7680px return JPG. If a scale leaves the short edge below 512px, retry with the minimum target longest edge reported by the tool. Never stretch the image, invent a prompt, or substitute `restore_photo`, `refine_result`, or `edit_image` for a pure upscale.
34
35
  - For source-preserving style edits such as "anime version of this image", "keep everything the same", or requests that preserve pose, clothing, background, framing, or composition, use image editing with the provided image as context. Do not switch to photobooth/face-transfer just because the user asks to preserve the face.
@@ -18,7 +18,7 @@ Text-to-image synthesis with the current Sogni image stack (Z-Image, Krea 2, Dar
18
18
 
19
19
  - Use natural-language descriptions (subject, setting, composition, lighting, style) for Krea 2, Z-Image, FLUX.1 Schnell, Chroma, and Qwen rather than keyword lists.
20
20
  - Krea 2 favors long, detailed prompts but also handles short ones; to render text in the image, wrap the exact words in quotes (e.g. a sign reading "OPEN").
21
- - Use `-m dark_beast_krea2_fp8` when the user explicitly requests Dark Beast Krea 2 or the uncensored community Krea 2 fine-tune.
21
+ - Use `-m dark_beast_krea2_fp8` when the user explicitly requests Dark Beast Krea 2 or the uncensored community Krea 2 fine-tune, or asks for a horror or sexy still: GPT Image's OpenAI safety system refuses gore on a real person's likeness and sexualized content.
22
22
  - FLUX 3 Image Klein (`-m flux3_image_klein_sd_int8_convrot`; hosted selector `flux-3-klein`) works best with a full scene caption. Its guidance is fixed at 1, so a negative prompt has no effect.
23
23
  - Seedream 5.0 Pro Uncensored (`-m seedream-5-0-pro-uncensored`, the same hosted selector) is used only when the user asks for it or for uncensored Seedream output. It renders 921,600-4,194,304 pixels up to 16:1 (default 1536x1536) and takes no seed, steps, guidance, LoRAs, or negative prompt. It shares the Seedance 2.5 Uncensored likeness agreement: on error 4103, tell the user to accept it in the Sogni app and do not retry.
24
24
  - The app applies model-specific prompt-enhancement automatically — pass the user's intent faithfully and avoid empty quality-booster spam.
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,
@@ -107,6 +106,8 @@ import {
107
106
  SEEDREAM_DEFAULT_HEIGHT,
108
107
  SEEDREAM_DEFAULT_WIDTH,
109
108
  SEEDANCE_R2V_REFERENCE_AUDIO_MAX_DURATION_SECONDS,
109
+ getSeedanceReferenceAudioMaxDurationSeconds,
110
+ getSeedanceV2VReferenceMaxDurationSeconds,
110
111
  calculateVideoDimensions as calculateSharedVideoDimensions,
111
112
  isMinimaxH3TwoStageModelId,
112
113
  minimaxH3TwoStageCanvasShortEdge,
@@ -814,6 +815,11 @@ function classifyCliError(error, context = {}) {
814
815
  };
815
816
  }
816
817
 
818
+ // The same class as the timeout this replaces on a long chat call: another try can work.
819
+ if (error?.code === 'NETWORK_CONNECTION_LOST') {
820
+ return { error_type: 'PROVIDER_TIMEOUT', category: 'timeout', message: rawMessage, retryable: true };
821
+ }
822
+
817
823
  // Socket 4103: Seedance 2.5 Uncensored, Seedance 2.0 Mini Uncensored and
818
824
  // Seedream 5.0 Pro Uncensored refuse every job until the account accepts their
819
825
  // shared one-time likeness and consent agreement in the Sogni app. The message
@@ -1023,8 +1029,8 @@ function fatalCliError(message, opts = {}) {
1023
1029
 
1024
1030
  // Friendly guidance shown when the Sogni API key is missing or rejected.
1025
1031
  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. ' +
1032
+ 'Your Sogni API key was rejected. Verify it — or generate a new one — at ' +
1033
+ 'https://dashboard.sogni.ai/api-key. ' +
1028
1034
  "If you don't have a Sogni account yet, create one there first, then add its API key.";
1029
1035
 
1030
1036
  // Detect an invalid/rejected API key across the several shapes the SDK can
@@ -1895,6 +1901,25 @@ function getJpegDimensions(buffer) {
1895
1901
  }
1896
1902
 
1897
1903
  const FLUX3_IMAGE_KLEIN_MODEL_ID = 'flux3_image_klein_sd_int8_convrot';
1904
+ const KREA2_IDENTITY_EDIT_MODEL_ID = 'krea2_identity_edit_v1_2';
1905
+ const KREA2_IDENTITY_EDIT_MAX_CONTEXT_IMAGES = 2;
1906
+
1907
+ /**
1908
+ * The model a context edit (-c) uses when neither -m nor the OpenClaw
1909
+ * defaultEditModel names one. Mark's routing (2026-11-01): Krea 2 Identity Edit
1910
+ * for edits of people, FLUX 3 Image Klein for type and graphic design, Dark
1911
+ * Beast Krea 2 Identity Edit for NSFW, GPT Image 2.5 Sunburst as the Premium
1912
+ * Spark best option, and never Qwen Image Edit. Agents choose among them with
1913
+ * -m from what the request means (SKILL.md). Without -m the CLI cannot know what
1914
+ * the request means, so it edits with Krea 2 Identity Edit, which takes one or
1915
+ * two references, and with FLUX 3 Image Klein (up to ten) when more are given.
1916
+ */
1917
+ function defaultEditModelFor(contextImageCount) {
1918
+ return contextImageCount > KREA2_IDENTITY_EDIT_MAX_CONTEXT_IMAGES
1919
+ ? FLUX3_IMAGE_KLEIN_MODEL_ID
1920
+ : KREA2_IDENTITY_EDIT_MODEL_ID;
1921
+ }
1922
+
1898
1923
  const FLUX3_IMAGE_KLEIN_SINGLE_REFERENCE_MAX_PIXELS = 4 * 1024 * 1024;
1899
1924
  // About 2 megapixels: Black Forest Labs says Klein does best at 2K, and 2K is
1900
1925
  // 2 MP (Mark, 2026-10-17). The size of a text-to-image with no size given, and
@@ -4993,7 +5018,8 @@ Image Options:
4993
5018
  --loras <ids> Comma-separated LoRA ids
4994
5019
  --lora-strength <n> LoRA strength (repeatable)
4995
5020
  --lora-strengths <n> Comma-separated LoRA strengths
4996
- -c, --context <path> Context image for editing (can use multiple)
5021
+ -c, --context <path> Context image for editing (can use multiple); without -m edits with
5022
+ krea2_identity_edit_v1_2, or flux3_image_klein_sd_int8_convrot for 3-10 images
4997
5023
  --last-image Use last generated image as context
4998
5024
  --segment <path|url> SAM 3 object selection; returns one original-size PNG mask
4999
5025
  --segment-point <x,y> Include point, normalized 0–1; repeat to refine
@@ -5292,8 +5318,8 @@ Image Models:
5292
5318
  dark_beast_krea2_identity_edit_v1_2 Dark Beast Krea 2 Identity Edit (up to 2 context images)
5293
5319
  flux1-schnell-fp8 Very fast
5294
5320
  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
5321
+ qwen_image_edit_2511_fp8 Older edit model (up to 3 images): only when named with -m
5322
+ qwen_image_edit_2511_fp8_lightning Older fast edit model: only when named with -m
5297
5323
  rtx_vsr_pro Promptless deterministic RTX VSR upscale (--upscale)
5298
5324
 
5299
5325
  Recommended LTX 2.5 Video Models:
@@ -5456,8 +5482,9 @@ Examples:
5456
5482
  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
5483
  sogni-agent --video --ref subject.jpg --ref-video motion.mp4 --workflow animate-move "transfer motion"
5458
5484
  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
5485
+ sogni-agent -c photo.jpg "make the background a beach"
5460
5486
  sogni-agent -c person.jpg -m krea2_identity_edit_v1_2 "editorial portrait, same identity, new wardrobe"
5487
+ sogni-agent -c poster.png -m flux3_image_klein_sd_int8_convrot "the headline now reads GRAND OPENING in the same lettering"
5461
5488
  sogni-agent -c subject.jpg -c style.jpg "apply the style to the subject"
5462
5489
  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
5490
  sogni-agent --photobooth --ref face.jpg "80s fashion portrait"
@@ -6510,7 +6537,7 @@ if (options.music) {
6510
6537
  }
6511
6538
  } else if (options.contextImages.length > 0) {
6512
6539
  // 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';
6540
+ options.model = options.model || openclawConfig?.defaultEditModel || defaultEditModelFor(options.contextImages.length);
6514
6541
  if (!cliSet.timeout && !timeoutFromConfig && options.timeout === 30000) {
6515
6542
  options.timeout = 60000; // 1 min for editing
6516
6543
  }
@@ -7983,7 +8010,7 @@ if (options.contextImages.length > 0 && !options.video) {
7983
8010
  fatalCliError(`Model ${options.model} does not support context images.`, {
7984
8011
  code: 'INVALID_ARGUMENT',
7985
8012
  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'
8013
+ 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
8014
  });
7988
8015
  }
7989
8016
  if (options.contextImages.length > maxImages) {
@@ -8099,8 +8126,8 @@ function loadCredentials() {
8099
8126
  const err = new Error('No Sogni API key found.');
8100
8127
  err.code = 'MISSING_CREDENTIALS';
8101
8128
  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.';
8129
+ ? `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.`
8130
+ : '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
8131
  err.details = {
8105
8132
  triedEnv: ['SOGNI_API_KEY'],
8106
8133
  triedFile: CREDENTIALS_PATH,
@@ -8392,7 +8419,18 @@ async function fetchApiJson(path, {
8392
8419
  };
8393
8420
 
8394
8421
  const response = await fetchWithTimeout(url, init, timeoutMs);
8395
- const text = await response.text();
8422
+ let text;
8423
+ try {
8424
+ text = await response.text();
8425
+ } catch (cause) {
8426
+ // A kept-alive chat call answers 200 long before its reply, so the connection can
8427
+ // still drop here, and fetch reports that only as "terminated".
8428
+ const err = new Error('The connection to Sogni was lost before the reply finished.');
8429
+ err.code = 'NETWORK_CONNECTION_LOST';
8430
+ err.hint = 'Check your internet connection or proxy, then run the request again. Part of the work may already have run.';
8431
+ err.cause = cause;
8432
+ throw err;
8433
+ }
8396
8434
  let payload = {};
8397
8435
  if (text) {
8398
8436
  try {
@@ -8782,6 +8820,21 @@ function extractChatMessage(payload) {
8782
8820
  return data?.choices?.[0]?.message || data?.choices?.[0]?.delta || payload?.choices?.[0]?.message || {};
8783
8821
  }
8784
8822
 
8823
+ // With this header, a chat call still working after 90 seconds answers 200 and sends
8824
+ // spaces until it finishes, so it outlasts this CLI's timeout and Cloudflare's. A failure
8825
+ // after that can only arrive in the body, so every such call must check it below. The
8826
+ // body also has no Content-Length, so a hop that ends it early looks like a clean end.
8827
+ const CHAT_KEEPALIVE_HEADERS = { 'X-Sogni-Nonstream-Keepalive': 'true' };
8828
+
8829
+ function throwIfChatBodyHasError(payload) {
8830
+ const data = extractApiEnvelopeData(payload);
8831
+ if (!payload?.error && data?.choices) return;
8832
+ const err = new Error(payload?.error?.message || 'Sogni ended this chat call without a complete reply.');
8833
+ err.code = 'API_REQUEST_FAILED';
8834
+ err.details = { payload };
8835
+ throw err;
8836
+ }
8837
+
8785
8838
  function extractChatWorkflows(payload) {
8786
8839
  const data = extractApiEnvelopeData(payload);
8787
8840
  return data?.creative_workflows || payload?.creative_workflows || [];
@@ -9026,9 +9079,11 @@ async function runApiChat(log) {
9026
9079
  apiKey,
9027
9080
  method: 'POST',
9028
9081
  body,
9082
+ headers: CHAT_KEEPALIVE_HEADERS,
9029
9083
  timeoutMs: CHAT_HTTP_TIMEOUT_MS,
9030
9084
  workloadAttribution,
9031
9085
  }));
9086
+ throwIfChatBodyHasError(payload);
9032
9087
  const message = extractChatMessage(payload);
9033
9088
  const workflows = extractChatWorkflows(payload);
9034
9089
  const toolCalls = message.tool_calls || message.toolCalls || [];
@@ -9536,9 +9591,11 @@ async function generateStoryboardWorkflowStoryline(apiKey) {
9536
9591
  apiKey,
9537
9592
  method: 'POST',
9538
9593
  body,
9594
+ headers: CHAT_KEEPALIVE_HEADERS,
9539
9595
  timeoutMs: CHAT_HTTP_TIMEOUT_MS,
9540
9596
  workloadAttribution,
9541
9597
  }));
9598
+ throwIfChatBodyHasError(payload);
9542
9599
  const message = extractChatMessage(payload);
9543
9600
  const storyline = typeof message.content === 'string' ? message.content.trim() : '';
9544
9601
  if (!storyline) {
@@ -11131,7 +11188,7 @@ async function trimSeedanceReferenceAudioToMp3(request) {
11131
11188
  const start = Math.max(0, Number(request.start) || 0);
11132
11189
  const duration = Math.max(
11133
11190
  0.1,
11134
- Math.min(15, Number(request.duration) || 15),
11191
+ Math.min(seedanceReferenceAudioMaxSeconds(), Number(request.duration) || seedanceReferenceAudioMaxSeconds()),
11135
11192
  );
11136
11193
  try {
11137
11194
  writeFileSync(inputPath, Buffer.from(request.data));
@@ -11178,13 +11235,22 @@ async function trimSeedanceV2VSourceVideo(request) {
11178
11235
  };
11179
11236
  }
11180
11237
 
11238
+ // Seedance 2.5 and 2.5 Uncensored accept 30 s of reference video and audio; the 2.0 family accepts 15 s.
11239
+ function seedanceReferenceVideoMaxSeconds() {
11240
+ return getSeedanceV2VReferenceMaxDurationSeconds(options.model);
11241
+ }
11242
+
11243
+ function seedanceReferenceAudioMaxSeconds() {
11244
+ return Math.floor(getSeedanceReferenceAudioMaxDurationSeconds(options.model));
11245
+ }
11246
+
11181
11247
  function seedanceReferenceAudioWindow() {
11182
11248
  const requestedDuration = options.audioDuration ?? options.duration;
11183
11249
  const maxDurationSeconds = Math.min(
11184
11250
  Number.isFinite(Number(requestedDuration)) && Number(requestedDuration) > 0
11185
11251
  ? Number(requestedDuration)
11186
- : SEEDANCE_R2V_REFERENCE_AUDIO_MAX_DURATION_SECONDS,
11187
- 15,
11252
+ : getSeedanceReferenceAudioMaxDurationSeconds(options.model),
11253
+ seedanceReferenceAudioMaxSeconds(),
11188
11254
  );
11189
11255
  return {
11190
11256
  maxDurationSeconds,
@@ -11241,7 +11307,7 @@ async function prepareSeedanceReferenceVideoUploadFile(pathOrUrl, buffer) {
11241
11307
  const sourceDurationSeconds = await probeLocalMediaDurationSeconds(pathOrUrl);
11242
11308
  const requestedDuration = Number.isFinite(Number(options.duration))
11243
11309
  ? Number(options.duration)
11244
- : SEEDANCE_V2V_REFERENCE_MAX_DURATION_SECONDS;
11310
+ : seedanceReferenceVideoMaxSeconds();
11245
11311
  const prepared = await prepareSharedSeedanceV2VSourceVideo(
11246
11312
  buffer,
11247
11313
  rawMimeType,
@@ -11249,7 +11315,7 @@ async function prepareSeedanceReferenceVideoUploadFile(pathOrUrl, buffer) {
11249
11315
  sourceDurationSeconds,
11250
11316
  requestedDuration,
11251
11317
  options.videoStart ?? 0,
11252
- { trimVideo: trimSeedanceV2VSourceVideo },
11318
+ { trimVideo: trimSeedanceV2VSourceVideo, modelId: options.model },
11253
11319
  );
11254
11320
  if (!options.quiet && prepared.trimmed) {
11255
11321
  console.error('Prepared Seedance V2V reference video clip before upload.');
@@ -11425,7 +11491,7 @@ async function trimSeedanceV2VSourceVideoBuffer(buffer, sourceLabel, startOffset
11425
11491
  const start = Math.max(0, Number(startOffset) || 0);
11426
11492
  const duration = Math.max(
11427
11493
  0.1,
11428
- Math.min(SEEDANCE_V2V_REFERENCE_MAX_DURATION_SECONDS, Number(requestedDuration) || SEEDANCE_V2V_REFERENCE_MAX_DURATION_SECONDS),
11494
+ Math.min(seedanceReferenceVideoMaxSeconds(), Number(requestedDuration) || seedanceReferenceVideoMaxSeconds()),
11429
11495
  );
11430
11496
  try {
11431
11497
  writeFileSync(inputPath, buffer);
@@ -14102,7 +14168,7 @@ async function runDoctor() {
14102
14168
  }
14103
14169
  } catch (err) {
14104
14170
  if (isInvalidApiKeyError(err)) {
14105
- add('auth', 'fail', 'API key rejected — get a fresh key at https://dashboard.sogni.ai (account menu)');
14171
+ add('auth', 'fail', 'API key rejected — get a fresh key at https://dashboard.sogni.ai/api-key');
14106
14172
  } else {
14107
14173
  add('auth', 'warn', `could not verify the key (network?): ${err?.message || err}`);
14108
14174
  }
@@ -15141,7 +15207,8 @@ async function main() {
15141
15207
  && shouldTrimSeedanceV2VSourceVideo({
15142
15208
  sourceDurationSeconds: null,
15143
15209
  requestedDurationSeconds: options.duration,
15144
- startOffsetSeconds: options.videoStart ?? 0
15210
+ startOffsetSeconds: options.videoStart ?? 0,
15211
+ maxDurationSeconds: seedanceReferenceVideoMaxSeconds()
15145
15212
  })
15146
15213
  ) {
15147
15214
  videoBuffer = await trimSeedanceV2VSourceVideoBuffer(
@@ -16464,10 +16531,20 @@ async function main() {
16464
16531
  }
16465
16532
  } catch (e) {}
16466
16533
  }
16534
+ await flushStdout();
16467
16535
  process.exit(exitCode);
16468
16536
  }
16469
16537
 
16538
+ // process.exit drops whatever a pipe hasn't taken yet. On macOS that is everything past
16539
+ // its first 64 KB, so a long --json reply reached an agent cut short, with exit code 0.
16540
+ function flushStdout() {
16541
+ return new Promise((resolve) => process.stdout.write('', resolve));
16542
+ }
16543
+
16470
16544
  main().then(
16471
- () => process.exit(0),
16545
+ async () => {
16546
+ await flushStdout();
16547
+ process.exit(0);
16548
+ },
16472
16549
  (error) => reportFatalError(error)
16473
16550
  );
package/version.mjs CHANGED
@@ -1 +1 @@
1
- export const PACKAGE_VERSION = '3.61.0';
1
+ export const PACKAGE_VERSION = '3.62.0';