@sogni-ai/sogni-creative-agent-skill 3.11.1 → 3.13.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/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [3.13.0](https://github.com/Sogni-AI/sogni-creative-agent-skill/compare/v3.12.0...v3.13.0) (2026-07-05)
2
+
3
+
4
+ ### Features
5
+
6
+ * **cli:** port SourceReel folder-to-video reels from recovered branch ([0e61830](https://github.com/Sogni-AI/sogni-creative-agent-skill/commit/0e6183090a0e1af698bce5de112246bcd44d5eac))
7
+
8
+ # [3.12.0](https://github.com/Sogni-AI/sogni-creative-agent-skill/compare/v3.11.1...v3.12.0) (2026-07-05)
9
+
10
+
11
+ ### Features
12
+
13
+ * **unlimited:** surface plan entitlement and billing mode across the CLI ([373490f](https://github.com/Sogni-AI/sogni-creative-agent-skill/commit/373490fc30da1edea84d7928691ab419b44f5bcf))
14
+
1
15
  ## [3.11.1](https://github.com/Sogni-AI/sogni-creative-agent-skill/compare/v3.11.0...v3.11.1) (2026-07-05)
2
16
 
3
17
 
package/README.md CHANGED
@@ -51,6 +51,8 @@ With this skill, an agent can:
51
51
  - [Manual install from source](#manual-install-from-source)
52
52
  - [Verify your install](#verify-your-install)
53
53
  - [Upgrading safely from inside an agent](#upgrading-safely-from-inside-an-agent)
54
+ - [Claude Desktop](#claude-desktop)
55
+ - [Also works in OpenAI Codex](#also-works-in-openai-codex)
54
56
  - [Setup (Sogni API key)](#setup-sogni-api-key)
55
57
  - [Usage](#usage)
56
58
  - [CLI Reference](#cli-reference)
@@ -283,6 +285,24 @@ Don't use both — you'd get duplicate Sogni tools. The extension wraps the same
283
285
 
284
286
  Video/audio editing features need ffmpeg on your machine; the `npx` installer offers to install it for you.
285
287
 
288
+ ### Also works in OpenAI Codex
289
+
290
+ The same local MCP server runs in OpenAI Codex — the Codex CLI and IDE extension read MCP servers from `~/.codex/config.toml`. With the CLI installed globally (`npm i -g @sogni-ai/sogni-creative-agent-skill`), register it and start a new Codex session:
291
+
292
+ ```bash
293
+ codex mcp add sogni-creative-agent -- node "$(npm root -g)/@sogni-ai/sogni-creative-agent-skill/desktop-extension/server/index.mjs"
294
+ ```
295
+
296
+ Or write the `~/.codex/config.toml` entry yourself (use the absolute path from `npm root -g`):
297
+
298
+ ```toml
299
+ [mcp_servers.sogni-creative-agent]
300
+ command = "node"
301
+ args = ["/opt/homebrew/lib/node_modules/@sogni-ai/sogni-creative-agent-skill/desktop-extension/server/index.mjs"]
302
+ ```
303
+
304
+ Codex also runs the Skill natively (see [OpenAI Codex CLI](#openai-codex-cli)) — pick one integration per machine; running both gives Codex duplicate Sogni tools. The server finds your globally installed `sogni-agent`, ffmpeg, and saved credentials on its own, so no `env` block is needed.
305
+
286
306
  ---
287
307
 
288
308
  ## Setup (Sogni API key)
@@ -564,7 +584,7 @@ Uses SDXL Turbo (`coreml-sogniXLturbo_alpha1_ad`) at 1024×1024 by default. The
564
584
 
565
585
  Multi-angle mode (`--multi-angle` / `--angles-360`) auto-builds the `<sks>` prompt and applies the `multiple_angles` LoRA. `--angles-360-video` generates i2v clips between consecutive angles (including last → first) and concatenates them with `ffmpeg` into a seamless loop.
566
586
 
567
- `--balance` / `--balances` does not require a prompt and prints current `SPARK` and `SOGNI` balances before exiting.
587
+ `--balance` / `--balances` does not require a prompt and prints the account username, subscription plan (`Plan: Sogni Unlimited (active)` / `Plan: none`), and current `SPARK` and `SOGNI` balances before exiting. In `--json` mode the payload carries `username` and `subscription` fields (`null` when unavailable). `--doctor` likewise reports the authenticated user and an explicit `plan` check, so a wrong-account API key or a missing subscription is visible at a glance.
568
588
 
569
589
  ---
570
590
 
@@ -704,7 +724,9 @@ App Store and Google Play prices may differ from web pricing due to platform fee
704
724
  - **Not covered (Premium Spark only):** external-vendor models — **GPT Image 2** (`gpt-image-2`), **Seedance 2.0 / Seedance 2.0 Mini / Seedance 2.0 Fast** (`seedance-2-0`, `seedance-2-0-mini`, `seedance-2-0-fast`), and **HappyHorse 1.1** (`happyhorse-1.1-t2v`, `happyhorse-1.1-i2v`, `happyhorse-1.1-r2v`). These always require Premium Spark eligibility even with an active subscription; they never bill to the subscription and never fall back to SOGNI.
705
725
  - **Token choice stays yours:** selecting SOGNI (`--token-type sogni`) opts a job out of subscription coverage and spends SOGNI instead. Coverage applies when the active token is Spark.
706
726
 
707
- The CLI never sends `billingMode`/coverage hints itself; the server decides coverage from the account's verified entitlement and the resolved model. A subscription claim is never honored without a server-verified entitlement.
727
+ By default the CLI sends no `billingMode`/coverage hint; the server decides coverage from the account's verified entitlement and the resolved model, and a subscription claim is never honored without a server-verified entitlement. `--billing-mode` makes the choice explicit when you need it: `subscription` requires Unlimited coverage (the job fails instead of spending tokens), `tokens` opts out of coverage and bills Spark/SOGNI, and `auto` states the default server behavior explicitly.
728
+
729
+ With an active subscription, the CLI also skips its client-side "insufficient SPARK" pre-flight for covered video renders — a low token balance no longer blocks jobs the plan pays for. Vendor models and `--billing-mode tokens` keep the pre-flight, and the server remains authoritative either way.
708
730
 
709
731
  ### Free-trial usage limits
710
732
 
package/SKILL.md CHANGED
@@ -2,7 +2,7 @@
2
2
  name: sogni-creative-agent-skill
3
3
  description: "Sogni Creative Agent Skill: agent skill and CLI for image, video, and music generation using Sogni AI's decentralized GPU network. Supports personas (named people with saved reference photos and voice clips), persistent memories, custom personality, style transfer, angle synthesis, Seedance/HappyHorse/LTX/WAN video, music/lyrics, hosted chat, durable workflows, replay records, and multi-step creative workflows. Ask the agent to \"draw\", \"generate\", \"create an image\", \"make a video/animate\", \"make music\", \"apply a style\", or \"generate me as a superhero\"."
4
4
  metadata:
5
- version: "3.11.0"
5
+ version: "3.12.0"
6
6
  homepage: https://sogni.ai
7
7
  openclaw:
8
8
  emoji: "🎨"
@@ -191,6 +191,7 @@ sogni-agent doctor --json
191
191
  | `--photobooth` | Face transfer mode (with `--ref`) | - |
192
192
  | `--persona <name>` | Use a saved persona (photo + voice auto-attach) | - |
193
193
  | `--token-type spark\|sogni\|auto` | `auto` retries native models with SOGNI when SPARK is low | spark |
194
+ | `--billing-mode auto\|subscription\|tokens` | `subscription` requires Sogni Unlimited coverage; `tokens` opts out of it | server decides |
194
195
  | `--last`, `--last-image` | Inspect last render / reuse it as context or ref | - |
195
196
  | `--json` | Machine-parseable stdout (progress goes to stderr) | false |
196
197
  | `-q, --quiet` | Suppress progress output | false |
@@ -221,7 +222,7 @@ For "4k" / "uhd" requests where the user accepts the Premium Spark vendor path o
221
222
 
222
223
  ### Video editing, stitching, 360 turnarounds
223
224
 
224
- Trigger patterns — "animate/morph image A to image B" (`--ref A --ref-end B`; on LTX-2.3 i2v this is a single render — the transition/morph LoRA auto-applies, no bridge clip), "continue this video" (extract last frame → i2v → concat), "transition between two videos" (bridge clip between two *finished videos*), "360 video" (`--angles-360 --angles-360-video`), "add/replace the soundtrack" (`--concat-audio` / `--remix-audio`). **Read [`references/video-editing.md`](./references/video-editing.md) for the step-by-step recipes.**
225
+ Trigger patterns — "animate/morph image A to image B" (`--ref A --ref-end B`; on LTX-2.3 i2v this is a single render — the transition/morph LoRA auto-applies, no bridge clip), "continue this video" (extract last frame → i2v → concat), "transition between two videos" (bridge clip between two *finished videos*), "make a reel/slideshow from these images" or "animate this folder of images" (`--source-reel <dir>`; plan first with the free `--reel-plan-only`; options: `--reel-image-seconds`, `--reel-transition-seconds`, `--reel-loop`/`--no-reel-loop`, `--reel-image-prompt`, `--reel-transition-prompt`), "360 video" (`--angles-360 --angles-360-video`), "add/replace the soundtrack" (`--concat-audio` / `--remix-audio`). **Read [`references/video-editing.md`](./references/video-editing.md) for the step-by-step recipes.**
225
226
 
226
227
  **Security: never run raw shell commands (`ffmpeg`, `ls`, `cp`, etc.) for file operations or video/audio manipulation.** Always use the CLI's built-in safe wrappers: `--extract-first-frame`, `--extract-last-frame`, `--concat-videos`, `--remix-audio`, `--list-media`, `--video-start`, `--audio-start`, `--audio-duration`, `--looping`.
227
228
 
@@ -296,7 +297,7 @@ Failure (single JSON object on stdout, exit code 1; progress/warnings on stderr)
296
297
  }
297
298
  ```
298
299
 
299
- `--json --balance` → `{ "success": true, "type": "balance", "spark": 12.34, "sogni": 0.56 }`. `--last --json` wraps the last render record in a `{ "success": true, ... }` envelope and exits 1 with `errorCode: "NO_LAST_RENDER"` when nothing has been rendered. In `--json` mode stdout always carries exactly one JSON object — SSE workflow frames and progress lines go to stderr.
300
+ `--json --balance` → `{ "success": true, "type": "balance", "spark": 12.34, "sogni": 0.56, "username": "name", "subscription": { "active": true, "status": "active", "tier": "unlimited" } }` (`username`/`subscription` are `null` when unavailable; an active subscription means eligible renders are covered by Sogni Unlimited even when `spark` is low). `--last --json` wraps the last render record in a `{ "success": true, ... }` envelope and exits 1 with `errorCode: "NO_LAST_RENDER"` when nothing has been rendered. In `--json` mode stdout always carries exactly one JSON object — SSE workflow frames and progress lines go to stderr.
300
301
 
301
302
  ## Cost
302
303
 
@@ -31,6 +31,9 @@ The text block always keeps the full-resolution URL / saved path. Set
31
31
  pointing at this server inside the global npm package (preferred).
32
32
  2. The packed `.mcpb` is the manual drag-and-drop alternative
33
33
  (Claude Desktop → Settings → Extensions).
34
+ 3. OpenAI Codex uses the same server:
35
+ `codex mcp add sogni-creative-agent -- node <abs path to server/index.mjs>`
36
+ (the Codex CLI and IDE extension read `~/.codex/config.toml`).
34
37
 
35
38
  The server needs the CLI installed globally (`npm i -g @sogni-ai/sogni-creative-agent-skill`);
36
39
  when missing, every tool returns a hint to run `npx setup-sogni-agent-skill`.
@@ -2,7 +2,7 @@
2
2
  "manifest_version": "0.3",
3
3
  "name": "sogni-creative-agent",
4
4
  "display_name": "Sogni Creative Agent",
5
- "version": "3.11.0",
5
+ "version": "3.12.0",
6
6
  "description": "Generate images, video, and music on Sogni AI's decentralized GPU network — with personas, memories, and safe video editing tools.",
7
7
  "author": { "name": "Sogni AI", "url": "https://sogni.ai" },
8
8
  "homepage": "https://sogni.ai",
@@ -2,7 +2,7 @@
2
2
  "id": "sogni-creative-agent-skill",
3
3
  "name": "Sogni Creative Agent Skill — Image, Video & Music Generation",
4
4
  "description": "Agent skill and CLI for Sogni AI image, video, and music generation.",
5
- "version": "3.11.0",
5
+ "version": "3.12.0",
6
6
  "skills": [
7
7
  "."
8
8
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sogni-ai/sogni-creative-agent-skill",
3
- "version": "3.11.1",
3
+ "version": "3.13.0",
4
4
  "description": "Sogni Creative Agent Skill: agent skill and CLI for Sogni AI image, video, and music generation.",
5
5
  "type": "module",
6
6
  "main": "sogni-agent.mjs",
@@ -76,7 +76,7 @@
76
76
  "sogni-agent.mjs"
77
77
  ],
78
78
  "dependencies": {
79
- "@sogni-ai/sogni-intelligence-client": "3.5.1",
79
+ "@sogni-ai/sogni-intelligence-client": "3.7.0",
80
80
  "execa": "^9.6.1",
81
81
  "json5": "^2.2.3",
82
82
  "sharp": "^0.34.5"
@@ -83,6 +83,29 @@ To **create a transition between two existing videos** (A → B), bridge them wi
83
83
 
84
84
  > **i2v clips are silent and use the model's own frame rate** (often not 24). `--concat-videos` normalizes fps/size and fills silent audio automatically, so mismatched clips stitch correctly — but passing `--fps` to the transition generation keeps things clean from the start. Use `--concat-fps <n>` to force a specific output frame rate.
85
85
 
86
+ ## SourceReel: Folder of Images → Loopable Video
87
+
88
+ Turn a folder of images into one stitched video: each image becomes an animated
89
+ clip, consecutive images are bridged by generated transition clips, and the
90
+ whole set is concatenated into a single mp4 (a single image renders one clip with
91
+ no transitions). **Always plan first — `--reel-plan-only` prints the planned
92
+ clips/transitions for free without rendering.** The render populates a working
93
+ folder (`<source>/sogni-source-reel-*`, or `--reel-workdir <dir>`) that keeps
94
+ every intermediate ref, clip, and transition so reruns can reuse them; the final
95
+ stitch **requires ffmpeg**. Looping is on by default (a last→first transition
96
+ closes the loop) — pass `--no-reel-loop` for a one-way reel.
97
+
98
+ ```bash
99
+ # 1. Plan the reel for free (no rendering)
100
+ sogni-agent --source-reel ./images --reel-plan-only
101
+
102
+ # 2. Render clips + transitions and stitch (loop on by default)
103
+ sogni-agent --source-reel ./images \
104
+ --reel-image-seconds 3 --reel-transition-seconds 3 \
105
+ --reel-image-prompt "friendly camera-ready motion" \
106
+ --reel-output ./reel.mp4
107
+ ```
108
+
86
109
  ## Segment a Longer Reference Video
87
110
 
88
111
  For local stitched workflows that only need part of a source video:
@@ -3,7 +3,7 @@
3
3
  "private": true,
4
4
  "type": "module",
5
5
  "dependencies": {
6
- "@sogni-ai/sogni-intelligence-client": "3.5.1",
6
+ "@sogni-ai/sogni-intelligence-client": "3.7.0",
7
7
  "execa": "^9.6.1",
8
8
  "json5": "^2.2.3",
9
9
  "sharp": "^0.34.5"
package/sogni-agent.mjs CHANGED
@@ -1271,6 +1271,41 @@ function requiresSparkOnlyToken(modelId) {
1271
1271
  return isGptImage2ModelSelection(modelId) || isSeedanceModel(modelId) || isHappyHorseModel(modelId);
1272
1272
  }
1273
1273
 
1274
+ // Attach the user's explicit --billing-mode to a project config. Omitted by
1275
+ // default so the server keeps deciding coverage (Unlimited members get 'auto'
1276
+ // coverage server-side; token payers are unaffected).
1277
+ function withBillingMode(config) {
1278
+ if (!options.billingMode) return config;
1279
+ return { ...config, billingMode: options.billingMode };
1280
+ }
1281
+
1282
+ // Best-effort Sogni Unlimited entitlement lookup. Returns null (never throws)
1283
+ // when the wrapper predates getSubscriptionStatus() or the request fails, so
1284
+ // callers degrade to balance-only behavior.
1285
+ async function fetchSubscriptionSnapshot(client, log) {
1286
+ if (typeof client?.getSubscriptionStatus !== 'function') return null;
1287
+ try {
1288
+ return await client.getSubscriptionStatus();
1289
+ } catch (err) {
1290
+ if (!options.quiet && typeof log === 'function') {
1291
+ log(`Warning: could not fetch subscription status (${err?.message || 'error'})`);
1292
+ }
1293
+ return null;
1294
+ }
1295
+ }
1296
+
1297
+ const SUBSCRIPTION_TIER_LABELS = {
1298
+ unlimited: 'Sogni Unlimited',
1299
+ unlimited_pro: 'Sogni Unlimited Pro',
1300
+ };
1301
+
1302
+ function describeSubscription(subscription) {
1303
+ if (!subscription || subscription.active !== true) return 'none';
1304
+ const tierKey = String(subscription.tier || '').toLowerCase();
1305
+ const label = SUBSCRIPTION_TIER_LABELS[tierKey] || subscription.tier || 'subscription';
1306
+ return `${label} (${subscription.status || 'active'})`;
1307
+ }
1308
+
1274
1309
  // HappyHorse 1.1 ships three discrete vendor models (no mini/fast). The shared
1275
1310
  // intel client only resolves the fully-qualified ids; accept the bare
1276
1311
  // `happyhorse` / `happyhorse-1.1` selector here so `-m happyhorse` works the way
@@ -1757,6 +1792,7 @@ const options = {
1757
1792
  strictSize: false,
1758
1793
  quality: null, // Quality tier: fast|hq|pro — auto-selects model, steps, dimensions
1759
1794
  tokenType: null,
1795
+ billingMode: null, // auto|subscription|tokens — omitted by default so the server decides coverage
1760
1796
  steps: null,
1761
1797
  guidance: null,
1762
1798
  outputFormat: null,
@@ -1830,6 +1866,19 @@ const options = {
1830
1866
  concatFps: null, // --concat-fps <n>: override target fps for concat normalization
1831
1867
  extractFirstFrame: null, // --extract-first-frame <video> <image>
1832
1868
  extractFirstFrameOutput: null,
1869
+ sourceReelDir: null, // --source-reel <image-folder>: animate folder images into a stitched video
1870
+ sourceReelImageSeconds: 3,
1871
+ sourceReelTransitionSeconds: 3,
1872
+ sourceReelLoop: true,
1873
+ sourceReelWorkdir: null,
1874
+ sourceReelOutput: null,
1875
+ sourceReelImagePrompt: null,
1876
+ sourceReelTransitionPrompt: null,
1877
+ sourceReelTransitionPrompts: null,
1878
+ sourceReelPlanOnly: false,
1879
+ sourceReelConcurrency: 2,
1880
+ sourceReelModel: null,
1881
+ sourceReelTargetResolution: 768,
1833
1882
  // Audio remix (--remix-audio <in_video> <out_video>): loop/fade/mix without re-encoding video
1834
1883
  remixAudio: null,
1835
1884
  remixAudioOutput: null,
@@ -2039,6 +2088,11 @@ for (let i = 0; i < args.length; i++) {
2039
2088
  i++;
2040
2089
  options.tokenType = raw;
2041
2090
  cliSet.tokenType = true;
2091
+ } else if (arg === '--billing-mode') {
2092
+ const raw = requireFlagValue(args, i, arg);
2093
+ i++;
2094
+ options.billingMode = raw;
2095
+ cliSet.billingMode = true;
2042
2096
  } else if (arg === '--steps') {
2043
2097
  const raw = requireFlagValue(args, i, arg);
2044
2098
  i++;
@@ -2409,6 +2463,56 @@ for (let i = 0; i < args.length; i++) {
2409
2463
  i++;
2410
2464
  options.extractFirstFrame = videoArg;
2411
2465
  options.extractFirstFrameOutput = imageArg;
2466
+ } else if (arg === '--source-reel' || arg === '--image-reel') {
2467
+ const raw = expandHomePath(requireFlagValue(args, i, arg));
2468
+ i++;
2469
+ options.sourceReelDir = raw;
2470
+ } else if (arg === '--reel-image-seconds' || arg === '--reel-clip-seconds') {
2471
+ const raw = requireFlagValue(args, i, arg);
2472
+ i++;
2473
+ options.sourceReelImageSeconds = parsePositiveIntegerValue(raw, arg);
2474
+ } else if (arg === '--reel-transition-seconds') {
2475
+ const raw = requireFlagValue(args, i, arg);
2476
+ i++;
2477
+ options.sourceReelTransitionSeconds = parsePositiveIntegerValue(raw, arg);
2478
+ } else if (arg === '--reel-loop') {
2479
+ options.sourceReelLoop = true;
2480
+ } else if (arg === '--no-reel-loop') {
2481
+ options.sourceReelLoop = false;
2482
+ } else if (arg === '--reel-workdir') {
2483
+ const raw = expandHomePath(requireFlagValue(args, i, arg));
2484
+ i++;
2485
+ options.sourceReelWorkdir = raw;
2486
+ } else if (arg === '--reel-output') {
2487
+ const raw = expandHomePath(requireFlagValue(args, i, arg));
2488
+ i++;
2489
+ options.sourceReelOutput = raw;
2490
+ } else if (arg === '--reel-image-prompt') {
2491
+ const raw = requireFlagValue(args, i, arg);
2492
+ i++;
2493
+ options.sourceReelImagePrompt = raw;
2494
+ } else if (arg === '--reel-transition-prompt') {
2495
+ const raw = requireFlagValue(args, i, arg);
2496
+ i++;
2497
+ options.sourceReelTransitionPrompt = raw;
2498
+ } else if (arg === '--reel-transition-prompts') {
2499
+ const raw = requireFlagValue(args, i, arg);
2500
+ i++;
2501
+ options.sourceReelTransitionPrompts = raw;
2502
+ } else if (arg === '--reel-plan-only' || arg === '--reel-dry-run') {
2503
+ options.sourceReelPlanOnly = true;
2504
+ } else if (arg === '--reel-concurrency') {
2505
+ const raw = requireFlagValue(args, i, arg);
2506
+ i++;
2507
+ options.sourceReelConcurrency = parsePositiveIntegerValue(raw, arg, 1, 8);
2508
+ } else if (arg === '--reel-model') {
2509
+ const raw = requireFlagValue(args, i, arg);
2510
+ i++;
2511
+ options.sourceReelModel = raw;
2512
+ } else if (arg === '--reel-target-resolution') {
2513
+ const raw = requireFlagValue(args, i, arg);
2514
+ i++;
2515
+ options.sourceReelTargetResolution = parsePositiveIntegerValue(raw, arg, 480, 1536);
2412
2516
  } else if (arg === '--remix-audio') {
2413
2517
  const inArg = requireFlagValue(args, i, arg + ' (input video)');
2414
2518
  i++;
@@ -2865,6 +2969,21 @@ Seedance Reference Modes (mutually exclusive on seedance2 / seedance2-mini / see
2865
2969
  --looping, --loop Create seamless loop (i2v only): A→B→A
2866
2970
  --last-image Use last generated image as reference
2867
2971
 
2972
+ SourceReel (folder of images → loopable video):
2973
+ --source-reel <dir> Build a video reel from images in a folder (alias: --image-reel)
2974
+ --reel-plan-only Print the planned clips/transitions without rendering
2975
+ --reel-image-seconds <sec> Seconds per animated image clip (default: 3)
2976
+ --reel-transition-seconds <sec> Seconds per bridge transition (default: 3)
2977
+ --reel-loop / --no-reel-loop Include final last→first transition (default: loop)
2978
+ --reel-image-prompt <text> Motion prompt for each source image
2979
+ --reel-transition-prompt <text> Default transition style between images
2980
+ --reel-transition-prompts <json|@file> Per-transition prompt array/object
2981
+ --reel-workdir <dir> Use/create one working folder (default: <source>/sogni-source-reel-*)
2982
+ --reel-output <path> Final merged mp4 path (default: inside working folder)
2983
+ --reel-model <id> Video model for clips/transitions (default: WAN i2v lightx2v)
2984
+ --reel-concurrency <n> Parallel render jobs, 1-8 (default: 2)
2985
+ --reel-target-resolution <px> Inferred short side when -w/-h omitted (default: 768)
2986
+
2868
2987
  Hosted API Modes:
2869
2988
  --api-chat Use /v1/chat/completions with Sogni creative-agent tools
2870
2989
  --durable-chat Like --api-chat but routes through durable /v1/chat/runs + SSE
@@ -2906,8 +3025,10 @@ General:
2906
3025
  --steps <num> Override steps (model-dependent)
2907
3026
  --guidance <num> Override guidance (model-dependent)
2908
3027
  --token-type <type> Token type: spark|sogni|auto (default: spark, auto retries with alternate)
2909
- --balance, --balances Show SPARK/SOGNI balances and exit
2910
- --doctor Health check: Node, credentials, ffmpeg, auth, config, version
3028
+ --billing-mode <mode> Billing: auto|subscription|tokens (default: server decides; "subscription"
3029
+ requires Sogni Unlimited coverage, "tokens" opts out of it)
3030
+ --balance, --balances Show account, plan, and SPARK/SOGNI balances and exit
3031
+ --doctor Health check: Node, credentials, ffmpeg, auth, plan, config, version
2911
3032
  --snooze-update Snooze the pending update reminder (1 day → 2 days → 1 week)
2912
3033
  --whats-new [version] Show bundled CHANGELOG entries (everything after <version> if given)
2913
3034
  --version, -V Show sogni-agent version and exit
@@ -3023,6 +3144,8 @@ Examples:
3023
3144
  sogni-agent --video --ref cat.jpg --ref-audio speech.m4a -m wan_v2.2-14b-fp8_s2v_lightx2v "lip sync"
3024
3145
  sogni-agent --video --ref cover.jpg --ref-audio song.mp3 "music video"
3025
3146
  sogni-agent --video --ref-audio song.mp3 "abstract music visualizer"
3147
+ sogni-agent --source-reel ./images --reel-plan-only
3148
+ sogni-agent --source-reel ./images --reel-image-seconds 3 --reel-transition-seconds 3 --reel-image-prompt "friendly camera-ready motion"
3026
3149
  sogni-agent --music --duration 30 "uplifting cinematic synthwave theme for a product launch"
3027
3150
  sogni-agent --music --lyrics "Rise with the morning light" --bpm 128 --keyscale "C major" --output-format mp3 "bright indie pop chorus"
3028
3151
  sogni-agent --video --reference-audio-identity voice.webm 'NARRATOR: "This is my voice."'
@@ -3161,6 +3284,17 @@ if (options.tokenType) {
3161
3284
  options.tokenType = token;
3162
3285
  }
3163
3286
 
3287
+ if (options.billingMode) {
3288
+ const mode = String(options.billingMode).toLowerCase();
3289
+ if (mode !== 'auto' && mode !== 'subscription' && mode !== 'tokens') {
3290
+ fatalCliError('--billing-mode must be "auto", "subscription", or "tokens".', {
3291
+ code: 'INVALID_ARGUMENT',
3292
+ details: { flag: '--billing-mode', value: options.billingMode }
3293
+ });
3294
+ }
3295
+ options.billingMode = mode;
3296
+ }
3297
+
3164
3298
  if (options.apiTaskProfile) {
3165
3299
  const profile = String(options.apiTaskProfile).trim().toLowerCase();
3166
3300
  if (!VALID_API_TASK_PROFILES.has(profile)) {
@@ -3702,6 +3836,7 @@ const commandUsesGenerationSeed = !options.apiChat &&
3702
3836
  !options.extractLastFrame &&
3703
3837
  !options.extractFirstFrame &&
3704
3838
  !options.concatVideos &&
3839
+ !options.sourceReelDir &&
3705
3840
  !options.remixAudio &&
3706
3841
  !options.listMedia &&
3707
3842
  !options.memoryAction &&
@@ -3718,7 +3853,7 @@ if (apiWorkflowStartAction && apiWorkflowTemplate === 'storyboard_video' && !opt
3718
3853
  if (typeof options.prompt === 'string' && options.prompt.trim() === '') {
3719
3854
  options.prompt = '';
3720
3855
  }
3721
- if (!options.prompt && !options.apiChat && !apiWorkflowUtilityAction && !apiWorkflowStartAction && !apiModelUtilityAction && !apiReplayUtilityAction && !contractUtilityAction && !storyboardPlanUtilityAction && !options.estimateVideoCost && !options.multiAngle && !options.showBalance && !options.showVersion && !options.doctor && !options.extractLastFrame && !options.extractFirstFrame && !options.concatVideos && !options.remixAudio && !options.listMedia && !options.memoryAction && !options.personalityAction && !personaUtilityAction) {
3856
+ if (!options.prompt && !options.apiChat && !apiWorkflowUtilityAction && !apiWorkflowStartAction && !apiModelUtilityAction && !apiReplayUtilityAction && !contractUtilityAction && !storyboardPlanUtilityAction && !options.estimateVideoCost && !options.multiAngle && !options.showBalance && !options.showVersion && !options.doctor && !options.extractLastFrame && !options.extractFirstFrame && !options.concatVideos && !options.sourceReelDir && !options.remixAudio && !options.listMedia && !options.memoryAction && !options.personalityAction && !personaUtilityAction) {
3722
3857
  fatalCliError('No prompt provided. Use --help for usage.', { code: 'INVALID_ARGUMENT' });
3723
3858
  }
3724
3859
 
@@ -7489,6 +7624,484 @@ async function remixVideoAudio(inputVideo, outputVideo, opts = {}) {
7489
7624
  }
7490
7625
  }
7491
7626
 
7627
+ const SOURCE_REEL_IMAGE_EXTS = new Set(['.jpg', '.jpeg', '.png', '.webp']);
7628
+ const SOURCE_REEL_DEFAULT_MODEL = 'wan_v2.2-14b-fp8_i2v_lightx2v';
7629
+ const SOURCE_REEL_DEFAULT_IMAGE_PROMPT =
7630
+ 'A polished camera-ready photo moment: the subject or scene comes gently to life with restrained natural motion, soft breathing or environmental movement, subtle parallax, stable lighting, and a smooth steady camera. Preserve the source image identity, composition, style, and important details.';
7631
+ const SOURCE_REEL_DEFAULT_TRANSITION_PROMPT =
7632
+ 'Create a seamless, well-designed transition between the two shots with continuous camera motion, natural subject movement where appropriate, consistent lighting, and a clean landing into the next frame. Avoid a simple fade; make the bridge feel intentional and cinematic.';
7633
+
7634
+ function sourceReelTimestamp() {
7635
+ return new Date().toISOString().replace(/[-:]/g, '').replace(/\.\d+Z$/, 'Z');
7636
+ }
7637
+
7638
+ function sourceReelSlug(value, fallback = 'item') {
7639
+ const slug = String(value || '')
7640
+ .toLowerCase()
7641
+ .replace(/\.[^.]+$/, '')
7642
+ .replace(/[^a-z0-9]+/g, '-')
7643
+ .replace(/^-+|-+$/g, '')
7644
+ .slice(0, 64);
7645
+ return slug || fallback;
7646
+ }
7647
+
7648
+ function roundToMultiple(value, multiple) {
7649
+ return Math.max(multiple, Math.round(value / multiple) * multiple);
7650
+ }
7651
+
7652
+ function inferSourceReelDimensions(metadata, targetShortSide) {
7653
+ const rawWidth = Number(metadata?.width) || targetShortSide;
7654
+ const rawHeight = Number(metadata?.height) || targetShortSide;
7655
+ const aspect = rawWidth > 0 && rawHeight > 0 ? rawWidth / rawHeight : 1;
7656
+ let width;
7657
+ let height;
7658
+ if (aspect >= 1) {
7659
+ height = targetShortSide;
7660
+ width = targetShortSide * aspect;
7661
+ } else {
7662
+ width = targetShortSide;
7663
+ height = targetShortSide / aspect;
7664
+ }
7665
+
7666
+ const maxSide = Math.max(width, height);
7667
+ if (maxSide > 1536) {
7668
+ const scale = 1536 / maxSide;
7669
+ width *= scale;
7670
+ height *= scale;
7671
+ }
7672
+ const minSide = Math.min(width, height);
7673
+ if (minSide < 480) {
7674
+ const scale = 480 / minSide;
7675
+ width *= scale;
7676
+ height *= scale;
7677
+ }
7678
+
7679
+ return {
7680
+ width: roundToMultiple(width, 16),
7681
+ height: roundToMultiple(height, 16)
7682
+ };
7683
+ }
7684
+
7685
+ function uniqueSourceReelWorkdir(sourceDir) {
7686
+ const base = join(sourceDir, `sogni-source-reel-${sourceReelTimestamp()}`);
7687
+ if (!existsSync(base)) return base;
7688
+ for (let i = 2; i < 100; i++) {
7689
+ const candidate = `${base}-${i}`;
7690
+ if (!existsSync(candidate)) return candidate;
7691
+ }
7692
+ return mkdtempSync(`${base}-`);
7693
+ }
7694
+
7695
+ function loadSourceReelImages(sourceDir) {
7696
+ const dir = sanitizePath(sourceDir, '--source-reel');
7697
+ if (!existsSync(dir)) {
7698
+ const err = new Error(`SourceReel image folder not found: ${dir}`);
7699
+ err.code = 'FILE_NOT_FOUND';
7700
+ throw err;
7701
+ }
7702
+ const lstats = lstatSync(dir);
7703
+ if (!lstats.isDirectory() || lstats.isSymbolicLink()) {
7704
+ const err = new Error(`SourceReel path must be a real directory: ${dir}`);
7705
+ err.code = 'INVALID_PATH';
7706
+ throw err;
7707
+ }
7708
+
7709
+ const entries = readdirSync(dir);
7710
+ const images = [];
7711
+ for (const entry of entries) {
7712
+ const ext = extname(entry).toLowerCase();
7713
+ if (!SOURCE_REEL_IMAGE_EXTS.has(ext)) continue;
7714
+ const fullPath = join(dir, entry);
7715
+ const fileStats = lstatSync(fullPath);
7716
+ if (fileStats.isSymbolicLink() || !fileStats.isFile()) continue;
7717
+ images.push({
7718
+ path: fullPath,
7719
+ name: entry,
7720
+ base: basename(entry, ext),
7721
+ slug: sourceReelSlug(entry, `image-${images.length + 1}`)
7722
+ });
7723
+ }
7724
+ images.sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true, sensitivity: 'base' }));
7725
+ images.forEach((image, idx) => {
7726
+ image.index = idx + 1;
7727
+ image.id = String(idx + 1).padStart(2, '0');
7728
+ });
7729
+ return images;
7730
+ }
7731
+
7732
+ function loadSourceReelTransitionPromptOverrides(raw) {
7733
+ if (!raw) return null;
7734
+ const parsed = parseJsonArgument(raw, '--reel-transition-prompts', 'INVALID_REEL_PROMPTS');
7735
+ if (Array.isArray(parsed)) return parsed;
7736
+ if (parsed && typeof parsed === 'object') return parsed;
7737
+ fatalCliError('--reel-transition-prompts must be a JSON array or object, or @path to one.', {
7738
+ code: 'INVALID_REEL_PROMPTS'
7739
+ });
7740
+ }
7741
+
7742
+ function sourceReelTransitionOverride(overrides, index, from, to) {
7743
+ if (!overrides) return null;
7744
+ if (Array.isArray(overrides)) {
7745
+ return typeof overrides[index] === 'string' ? overrides[index] : null;
7746
+ }
7747
+ const keys = [
7748
+ `${from.id}-to-${to.id}`,
7749
+ `${from.index}-to-${to.index}`,
7750
+ `${from.slug}-to-${to.slug}`,
7751
+ `${from.base}-to-${to.base}`,
7752
+ ];
7753
+ for (const key of keys) {
7754
+ if (typeof overrides[key] === 'string') return overrides[key];
7755
+ }
7756
+ return typeof overrides.default === 'string' ? overrides.default : null;
7757
+ }
7758
+
7759
+ function buildSourceReelPlan() {
7760
+ const sourceDir = resolve(sanitizePath(options.sourceReelDir, '--source-reel'));
7761
+ const images = loadSourceReelImages(sourceDir);
7762
+ if (images.length === 0) {
7763
+ fatalCliError(`No source images found in ${sourceDir}. Supported: jpg, jpeg, png, webp.`, {
7764
+ code: 'NO_SOURCE_IMAGES',
7765
+ details: { sourceDir }
7766
+ });
7767
+ }
7768
+
7769
+ let dimensions = null;
7770
+ if (cliSet.width || cliSet.height) {
7771
+ if (!cliSet.width || !cliSet.height) {
7772
+ fatalCliError('SourceReel requires both -w and -h when overriding dimensions.', {
7773
+ code: 'INVALID_ARGUMENT'
7774
+ });
7775
+ }
7776
+ dimensions = {
7777
+ width: roundToMultiple(options.width, 16),
7778
+ height: roundToMultiple(options.height, 16)
7779
+ };
7780
+ }
7781
+
7782
+ const workdir = resolve(options.sourceReelWorkdir
7783
+ ? sanitizePath(options.sourceReelWorkdir, '--reel-workdir')
7784
+ : uniqueSourceReelWorkdir(sourceDir));
7785
+ const outputPath = resolve(options.sourceReelOutput
7786
+ ? sanitizePath(options.sourceReelOutput, '--reel-output')
7787
+ : join(workdir, options.sourceReelLoop ? 'source-reel-loop.mp4' : 'source-reel.mp4'));
7788
+
7789
+ const imagePrompt = options.sourceReelImagePrompt || options.prompt || SOURCE_REEL_DEFAULT_IMAGE_PROMPT;
7790
+ const transitionBasePrompt = options.sourceReelTransitionPrompt || SOURCE_REEL_DEFAULT_TRANSITION_PROMPT;
7791
+ const promptOverrides = loadSourceReelTransitionPromptOverrides(options.sourceReelTransitionPrompts);
7792
+ const model = options.sourceReelModel || (cliSet.model ? options.model : null) || SOURCE_REEL_DEFAULT_MODEL;
7793
+ const fps = cliSet.fps ? options.fps : 32;
7794
+ const concurrency = options.sourceReelConcurrency || 2;
7795
+
7796
+ const clips = images.map((image) => ({
7797
+ ...image,
7798
+ refPath: join(workdir, 'refs', `${image.id}-${image.slug}.jpg`),
7799
+ clipPath: join(workdir, 'clips', `${image.id}-${image.slug}.mp4`),
7800
+ logPath: join(workdir, 'logs', 'clips', `${image.id}-${image.slug}.log`),
7801
+ prompt: imagePrompt
7802
+ }));
7803
+
7804
+ const transitionCount = images.length > 1
7805
+ ? (options.sourceReelLoop ? images.length : images.length - 1)
7806
+ : 0;
7807
+ const transitions = [];
7808
+ for (let i = 0; i < transitionCount; i++) {
7809
+ const from = clips[i];
7810
+ const to = clips[(i + 1) % clips.length];
7811
+ const key = `${from.id}-to-${to.id}`;
7812
+ const override = sourceReelTransitionOverride(promptOverrides, i, from, to);
7813
+ const body = override || transitionBasePrompt;
7814
+ const prompt =
7815
+ `Start exactly on the first reference frame and end exactly on the second reference frame. ` +
7816
+ `${body}`;
7817
+ transitions.push({
7818
+ key,
7819
+ from: from.id,
7820
+ to: to.id,
7821
+ lastFramePath: join(workdir, 'frames', `${from.id}-${from.slug}-last.png`),
7822
+ firstFramePath: join(workdir, 'frames', `${to.id}-${to.slug}-first.png`),
7823
+ clipPath: join(workdir, 'transitions', `${key}.mp4`),
7824
+ logPath: join(workdir, 'logs', 'transitions', `${key}.log`),
7825
+ prompt
7826
+ });
7827
+ }
7828
+
7829
+ return {
7830
+ type: 'source-reel',
7831
+ sourceDir,
7832
+ workdir,
7833
+ outputPath,
7834
+ model,
7835
+ fps,
7836
+ dimensions,
7837
+ targetResolution: options.sourceReelTargetResolution,
7838
+ imageSeconds: options.sourceReelImageSeconds,
7839
+ transitionSeconds: options.sourceReelTransitionSeconds,
7840
+ loop: Boolean(options.sourceReelLoop),
7841
+ concurrency,
7842
+ imagePrompt,
7843
+ transitionBasePrompt,
7844
+ clips,
7845
+ transitions
7846
+ };
7847
+ }
7848
+
7849
+ function printSourceReelPlan(plan) {
7850
+ console.log('SourceReel plan');
7851
+ console.log(` Source folder: ${plan.sourceDir}`);
7852
+ console.log(` Working folder: ${plan.workdir}`);
7853
+ console.log(` Final output: ${plan.outputPath}`);
7854
+ console.log(` Images: ${plan.clips.length}`);
7855
+ console.log(` Clip seconds: ${plan.imageSeconds}`);
7856
+ console.log(` Transition seconds: ${plan.transitionSeconds}`);
7857
+ console.log(` Loop last→first: ${plan.loop ? 'yes' : 'no'}`);
7858
+ console.log(` Model: ${plan.model}`);
7859
+ console.log(` FPS: ${plan.fps}`);
7860
+ if (plan.dimensions) {
7861
+ console.log(` Size: ${plan.dimensions.width}x${plan.dimensions.height}`);
7862
+ } else {
7863
+ console.log(` Size: infer from first image, short side ${plan.targetResolution}px`);
7864
+ }
7865
+ console.log('');
7866
+ console.log('Clip prompt:');
7867
+ console.log(` ${plan.imagePrompt}`);
7868
+ console.log('');
7869
+ console.log('Default transition prompt:');
7870
+ console.log(` ${plan.transitionBasePrompt}`);
7871
+ console.log('');
7872
+ console.log('Images:');
7873
+ for (const clip of plan.clips) {
7874
+ console.log(` ${clip.id}. ${clip.name}`);
7875
+ }
7876
+ if (plan.transitions.length > 0) {
7877
+ console.log('');
7878
+ console.log('Transitions:');
7879
+ for (const transition of plan.transitions) {
7880
+ console.log(` ${transition.key}: ${transition.prompt}`);
7881
+ }
7882
+ }
7883
+ console.log('');
7884
+ console.log('Run the same command without --reel-plan-only to render.');
7885
+ }
7886
+
7887
+ async function prepareSourceReelReferenceImages(plan, log) {
7888
+ const refsDir = join(plan.workdir, 'refs');
7889
+ mkdirSync(refsDir, { recursive: true });
7890
+
7891
+ let dimensions = plan.dimensions;
7892
+ if (!dimensions) {
7893
+ const metadata = await sharp(plan.clips[0].path).rotate().metadata();
7894
+ dimensions = inferSourceReelDimensions(metadata, plan.targetResolution);
7895
+ plan.dimensions = dimensions;
7896
+ }
7897
+
7898
+ for (const clip of plan.clips) {
7899
+ if (isNonEmptyFile(clip.refPath)) {
7900
+ log(`SKIP ref ${clip.refPath}`);
7901
+ continue;
7902
+ }
7903
+ const background = await sharp(clip.path)
7904
+ .rotate()
7905
+ .resize(dimensions.width, dimensions.height, { fit: 'cover' })
7906
+ .blur(28)
7907
+ .modulate({ brightness: 0.72, saturation: 0.9 })
7908
+ .jpeg({ quality: 90 })
7909
+ .toBuffer();
7910
+ const foreground = await sharp(clip.path)
7911
+ .rotate()
7912
+ .resize(dimensions.width, dimensions.height, {
7913
+ fit: 'contain',
7914
+ background: { r: 0, g: 0, b: 0, alpha: 0 }
7915
+ })
7916
+ .png()
7917
+ .toBuffer();
7918
+ await sharp(background)
7919
+ .composite([{ input: foreground, gravity: 'center' }])
7920
+ .jpeg({ quality: 95 })
7921
+ .toFile(clip.refPath);
7922
+ log(`REF ${clip.name} -> ${clip.refPath}`);
7923
+ }
7924
+ }
7925
+
7926
+ async function runSourceReelPool(items, concurrency, worker) {
7927
+ let next = 0;
7928
+ const workers = Array.from({ length: Math.min(concurrency, items.length) }, async () => {
7929
+ while (next < items.length) {
7930
+ const index = next++;
7931
+ await worker(items[index], index);
7932
+ }
7933
+ });
7934
+ await Promise.all(workers);
7935
+ }
7936
+
7937
+ function sourceReelChildArgs(baseArgs, outputPath, prompt, plan, duration) {
7938
+ const args = [
7939
+ fileURLToPath(import.meta.url),
7940
+ '--no-update-check',
7941
+ '-q',
7942
+ '--json',
7943
+ '--video',
7944
+ '-m', plan.model,
7945
+ '--duration', String(duration),
7946
+ '--fps', String(plan.fps),
7947
+ '-w', String(plan.dimensions.width),
7948
+ '-h', String(plan.dimensions.height),
7949
+ '-o', outputPath,
7950
+ ...baseArgs
7951
+ ];
7952
+ if (options.tokenType) args.push('--token-type', options.tokenType);
7953
+ if (options.steps !== null && options.steps !== undefined) args.push('--steps', String(options.steps));
7954
+ if (options.guidance !== null && options.guidance !== undefined) args.push('--guidance', String(options.guidance));
7955
+ if (options.noFilter) args.push('--no-filter');
7956
+ if (options.strictSize) args.push('--strict-size');
7957
+ if (cliSet.timeout) args.push('-t', String(Math.ceil(options.timeout / 1000)));
7958
+ args.push(prompt);
7959
+ return args;
7960
+ }
7961
+
7962
+ function parseSourceReelChildJson(stdout) {
7963
+ const text = String(stdout || '').trim();
7964
+ if (!text) return null;
7965
+ try {
7966
+ return JSON.parse(text);
7967
+ } catch {
7968
+ const lastLine = text.split(/\r?\n/).map((line) => line.trim()).filter(Boolean).pop();
7969
+ if (!lastLine) return null;
7970
+ try { return JSON.parse(lastLine); } catch { return null; }
7971
+ }
7972
+ }
7973
+
7974
+ async function runSourceReelChild(label, args, logPath, outputPath) {
7975
+ const result = await runCommand(process.execPath, args, { captureOutput: true });
7976
+ const parsed = parseSourceReelChildJson(result.stdout);
7977
+ const logBody = [
7978
+ `label=${label}`,
7979
+ `command=${process.execPath} ${args.map((x) => JSON.stringify(x)).join(' ')}`,
7980
+ '',
7981
+ 'stdout:',
7982
+ result.stdout || '',
7983
+ '',
7984
+ 'stderr:',
7985
+ result.stderr || ''
7986
+ ].join('\n');
7987
+ writeOutputFileSafe(logPath, Buffer.from(logBody), 'SourceReel render log');
7988
+ if (result.error || result.status !== 0 || !parsed?.success || !isNonEmptyFile(outputPath)) {
7989
+ const err = new Error(`SourceReel render failed: ${label}`);
7990
+ err.code = parsed?.errorCode || parsed?.code || 'SOURCE_REEL_RENDER_FAILED';
7991
+ err.hint = parsed?.hint || `See log: ${logPath}`;
7992
+ err.details = { label, outputPath, logPath, status: result.status, child: parsed || null };
7993
+ throw err;
7994
+ }
7995
+ return parsed;
7996
+ }
7997
+
7998
+ async function runSourceReel(log) {
7999
+ const plan = buildSourceReelPlan();
8000
+ if (options.sourceReelPlanOnly) {
8001
+ if (options.json || JSON_ERROR_MODE) {
8002
+ console.log(JSON.stringify({ success: true, ...plan, timestamp: new Date().toISOString() }));
8003
+ } else {
8004
+ printSourceReelPlan(plan);
8005
+ }
8006
+ return;
8007
+ }
8008
+
8009
+ mkdirSync(plan.workdir, { recursive: true });
8010
+ mkdirSync(join(plan.workdir, 'clips'), { recursive: true });
8011
+ mkdirSync(join(plan.workdir, 'transitions'), { recursive: true });
8012
+ mkdirSync(join(plan.workdir, 'frames'), { recursive: true });
8013
+ mkdirSync(join(plan.workdir, 'logs', 'clips'), { recursive: true });
8014
+ mkdirSync(join(plan.workdir, 'logs', 'transitions'), { recursive: true });
8015
+
8016
+ await prepareSourceReelReferenceImages(plan, log);
8017
+ writeOutputFileSafe(join(plan.workdir, 'plan.json'), Buffer.from(JSON.stringify(plan, null, 2)), 'SourceReel plan');
8018
+
8019
+ log(`SourceReel rendering ${plan.clips.length} clips (${plan.imageSeconds}s each)...`);
8020
+ await runSourceReelPool(plan.clips, plan.concurrency, async (clip) => {
8021
+ if (isNonEmptyFile(clip.clipPath)) {
8022
+ log(`SKIP clip ${clip.clipPath}`);
8023
+ return;
8024
+ }
8025
+ log(`START clip ${clip.id} ${clip.name}`);
8026
+ const args = sourceReelChildArgs(['--ref', clip.refPath], clip.clipPath, clip.prompt, plan, plan.imageSeconds);
8027
+ await runSourceReelChild(`clip ${clip.id}`, args, clip.logPath, clip.clipPath);
8028
+ log(`DONE clip ${clip.id} -> ${clip.clipPath}`);
8029
+ });
8030
+
8031
+ for (const transition of plan.transitions) {
8032
+ const fromClip = plan.clips.find((clip) => clip.id === transition.from);
8033
+ const toClip = plan.clips.find((clip) => clip.id === transition.to);
8034
+ if (!isNonEmptyFile(transition.lastFramePath)) {
8035
+ log(`FRAME last ${fromClip.clipPath} -> ${transition.lastFramePath}`);
8036
+ await extractLastFrameFromVideo(fromClip.clipPath, transition.lastFramePath);
8037
+ }
8038
+ if (!isNonEmptyFile(transition.firstFramePath)) {
8039
+ log(`FRAME first ${toClip.clipPath} -> ${transition.firstFramePath}`);
8040
+ await extractFirstFrameFromVideo(toClip.clipPath, transition.firstFramePath);
8041
+ }
8042
+ }
8043
+
8044
+ if (plan.transitions.length > 0) {
8045
+ log(`SourceReel rendering ${plan.transitions.length} transitions (${plan.transitionSeconds}s each)...`);
8046
+ await runSourceReelPool(plan.transitions, plan.concurrency, async (transition) => {
8047
+ if (isNonEmptyFile(transition.clipPath)) {
8048
+ log(`SKIP transition ${transition.clipPath}`);
8049
+ return;
8050
+ }
8051
+ log(`START transition ${transition.key}`);
8052
+ const args = sourceReelChildArgs(
8053
+ ['--ref', transition.lastFramePath, '--ref-end', transition.firstFramePath],
8054
+ transition.clipPath,
8055
+ transition.prompt,
8056
+ plan,
8057
+ plan.transitionSeconds
8058
+ );
8059
+ await runSourceReelChild(`transition ${transition.key}`, args, transition.logPath, transition.clipPath);
8060
+ log(`DONE transition ${transition.key} -> ${transition.clipPath}`);
8061
+ });
8062
+ }
8063
+
8064
+ const concatParts = [];
8065
+ for (const clip of plan.clips) {
8066
+ concatParts.push(clip.clipPath);
8067
+ const transition = plan.transitions.find((item) => item.from === clip.id);
8068
+ if (transition) concatParts.push(transition.clipPath);
8069
+ }
8070
+
8071
+ if (concatParts.length === 1) {
8072
+ // Single-image reels have no bridge clips. Normalize through concat anyway
8073
+ // would require two inputs, so preserve the generated clip as the final.
8074
+ const buffer = readFileSync(concatParts[0]);
8075
+ writeOutputFileSafe(plan.outputPath, buffer, 'SourceReel final video');
8076
+ } else {
8077
+ log(`SourceReel stitching ${concatParts.length} clips -> ${plan.outputPath}`);
8078
+ await buildConcatVideoFromClips(plan.outputPath, concatParts, { targetFps: plan.fps });
8079
+ }
8080
+
8081
+ if (options.json || JSON_ERROR_MODE) {
8082
+ console.log(JSON.stringify({
8083
+ success: true,
8084
+ type: 'source-reel',
8085
+ sourceDir: plan.sourceDir,
8086
+ workdir: plan.workdir,
8087
+ outputPath: plan.outputPath,
8088
+ imageCount: plan.clips.length,
8089
+ transitionCount: plan.transitions.length,
8090
+ imageSeconds: plan.imageSeconds,
8091
+ transitionSeconds: plan.transitionSeconds,
8092
+ loop: plan.loop,
8093
+ model: plan.model,
8094
+ fps: plan.fps,
8095
+ width: plan.dimensions.width,
8096
+ height: plan.dimensions.height,
8097
+ timestamp: new Date().toISOString()
8098
+ }));
8099
+ } else {
8100
+ console.log(`SourceReel complete: ${plan.outputPath}`);
8101
+ console.log(`Working folder: ${plan.workdir}`);
8102
+ }
8103
+ }
8104
+
7492
8105
  async function runImageEditProjectWithEvents(client, editConfig, expectedCount, log, timeoutMs, label) {
7493
8106
  const results = [];
7494
8107
  let completed = 0;
@@ -7541,7 +8154,7 @@ async function runImageEditProjectWithEvents(client, editConfig, expectedCount,
7541
8154
  client.on(ClientEvent.JOB_FAILED, onFailed);
7542
8155
 
7543
8156
  try {
7544
- const projectResult = await client.createImageEditProject(editConfig);
8157
+ const projectResult = await client.createImageEditProject(withBillingMode(editConfig));
7545
8158
  projectId = projectResult?.project?.id || projectId;
7546
8159
 
7547
8160
  // Check for errors in the response (e.g., insufficient tokens)
@@ -7842,7 +8455,7 @@ async function runMultiAngleFlow(client, log) {
7842
8455
  if (options.autoResizeVideoAssets !== null) {
7843
8456
  clipConfig.autoResizeVideoAssets = options.autoResizeVideoAssets;
7844
8457
  }
7845
- const clipResult = await client.createVideoProject(clipConfig);
8458
+ const clipResult = await client.createVideoProject(withBillingMode(clipConfig));
7846
8459
 
7847
8460
  // Check for errors in the response (e.g., insufficient tokens)
7848
8461
  if (clipResult?.error || clipResult?.message) {
@@ -7929,6 +8542,15 @@ function buildVideoEstimateParams({ tokenType, steps }) {
7929
8542
 
7930
8543
  async function ensureSufficientVideoBalance(client, log) {
7931
8544
  if (!options.video || options.estimateVideoCost) return;
8545
+ // Sogni Unlimited bills covered video jobs to the subscription, so a low
8546
+ // token balance must not block them client-side. Vendor models
8547
+ // (Seedance/HappyHorse) always bill Premium Spark and keep the check, as
8548
+ // does an explicit --billing-mode tokens opt-out. The server stays
8549
+ // authoritative: an uncovered job still fails there with enriched guidance.
8550
+ if (options.billingMode !== 'tokens' && !requiresSparkOnlyToken(options.model)) {
8551
+ const subscription = await fetchSubscriptionSnapshot(client, log);
8552
+ if (subscription?.active === true) return;
8553
+ }
7932
8554
  const tokenType = options.tokenType || 'spark';
7933
8555
  const tokenLabel = tokenType.toUpperCase();
7934
8556
  let balance;
@@ -8062,9 +8684,19 @@ async function runDoctor() {
8062
8684
  });
8063
8685
  const authFlow = (async () => {
8064
8686
  await connectSogniClient(doctorClient);
8065
- return doctorClient.getBalance();
8687
+ const balance = await doctorClient.getBalance();
8688
+ // Identity + entitlement are best-effort: an old wrapper or a flaky
8689
+ // subscription endpoint must not fail the auth check itself.
8690
+ let accountInfo = null;
8691
+ if (typeof doctorClient.getAccountInfo === 'function') {
8692
+ try {
8693
+ accountInfo = await doctorClient.getAccountInfo();
8694
+ } catch { /* ignore */ }
8695
+ }
8696
+ const subscription = await fetchSubscriptionSnapshot(doctorClient, null);
8697
+ return { balance, accountInfo, subscription };
8066
8698
  })();
8067
- const balance = await Promise.race([
8699
+ const { balance, accountInfo, subscription } = await Promise.race([
8068
8700
  authFlow,
8069
8701
  new Promise((_, reject) => setTimeout(
8070
8702
  () => reject(Object.assign(new Error('timed out'), { code: 'DOCTOR_TIMEOUT' })),
@@ -8073,8 +8705,18 @@ async function runDoctor() {
8073
8705
  ]);
8074
8706
  const spark = Number.parseFloat(balance?.spark);
8075
8707
  const sogni = Number.parseFloat(balance?.sogni);
8708
+ const identity = accountInfo?.username ? `user ${accountInfo.username}, ` : '';
8076
8709
  add('auth', 'pass',
8077
- `API key accepted (SPARK ${Number.isFinite(spark) ? spark : '?'}, SOGNI ${Number.isFinite(sogni) ? sogni : '?'})`);
8710
+ `API key accepted (${identity}SPARK ${Number.isFinite(spark) ? spark : '?'}, SOGNI ${Number.isFinite(sogni) ? sogni : '?'})`);
8711
+ if (subscription) {
8712
+ if (subscription.active === true) {
8713
+ add('plan', 'pass', describeSubscription(subscription));
8714
+ } else if (Number.isFinite(spark) && spark <= 0 && Number.isFinite(sogni) && sogni <= 0) {
8715
+ add('plan', 'warn', 'no subscription and no token balance — renders will fail until you buy Spark Packs or subscribe');
8716
+ } else {
8717
+ add('plan', 'pass', 'none — renders bill Spark/SOGNI from this account\'s balance');
8718
+ }
8719
+ }
8078
8720
  } catch (err) {
8079
8721
  if (isInvalidApiKeyError(err)) {
8080
8722
  add('auth', 'fail', 'API key rejected — get a fresh key at https://dashboard.sogni.ai (account menu)');
@@ -8396,6 +9038,11 @@ async function main() {
8396
9038
  return;
8397
9039
  }
8398
9040
 
9041
+ if (options.sourceReelDir) {
9042
+ await runSourceReel(log);
9043
+ return;
9044
+ }
9045
+
8399
9046
  if (options.remixAudio) {
8400
9047
  const inputVideo = sanitizePath(options.remixAudio, '--remix-audio input');
8401
9048
  const outputVideo = sanitizePath(options.remixAudioOutput, '--remix-audio output');
@@ -8528,6 +9175,15 @@ async function main() {
8528
9175
  const balance = await client.getBalance();
8529
9176
  const spark = Number.parseFloat(balance?.spark);
8530
9177
  const sogni = Number.parseFloat(balance?.sogni);
9178
+ // Identity + plan make wrong-account and no-subscription states visible
9179
+ // (a low Spark balance is fine when Unlimited covers the renders).
9180
+ const subscription = await fetchSubscriptionSnapshot(client, log);
9181
+ let accountInfo = null;
9182
+ if (typeof client.getAccountInfo === 'function') {
9183
+ try {
9184
+ accountInfo = await client.getAccountInfo();
9185
+ } catch { /* identity display is best-effort */ }
9186
+ }
8531
9187
  if (options.json) {
8532
9188
  console.log(JSON.stringify({
8533
9189
  success: true,
@@ -8535,9 +9191,23 @@ async function main() {
8535
9191
  spark: Number.isFinite(spark) ? spark : null,
8536
9192
  sogni: Number.isFinite(sogni) ? sogni : null,
8537
9193
  tokenType: options.tokenType || 'spark',
9194
+ username: accountInfo?.username ?? null,
9195
+ subscription: subscription
9196
+ ? {
9197
+ active: subscription.active === true,
9198
+ status: subscription.status ?? null,
9199
+ tier: subscription.tier ?? null
9200
+ }
9201
+ : null,
8538
9202
  timestamp: new Date().toISOString()
8539
9203
  }));
8540
9204
  } else {
9205
+ if (accountInfo?.username) {
9206
+ console.log(`Account: ${accountInfo.username}`);
9207
+ }
9208
+ if (subscription) {
9209
+ console.log(`Plan: ${describeSubscription(subscription)}`);
9210
+ }
8541
9211
  console.log(`SPARK: ${formatTokenValue(spark)}`);
8542
9212
  console.log(`SOGNI: ${formatTokenValue(sogni)}`);
8543
9213
  }
@@ -9029,7 +9699,7 @@ async function main() {
9029
9699
  projectConfig.lastFrameStrength = options.lastFrameStrength;
9030
9700
  }
9031
9701
 
9032
- const videoResult = await client.createVideoProject(projectConfig);
9702
+ const videoResult = await client.createVideoProject(withBillingMode(projectConfig));
9033
9703
 
9034
9704
  // Check for errors in the response (e.g., insufficient tokens)
9035
9705
  if (videoResult?.error || videoResult?.message) {
@@ -9091,7 +9761,7 @@ async function main() {
9091
9761
  projectConfig.seed = options.seed;
9092
9762
  }
9093
9763
 
9094
- const audioResult = await client.createAudioProject(projectConfig);
9764
+ const audioResult = await client.createAudioProject(withBillingMode(projectConfig));
9095
9765
 
9096
9766
  if (audioResult?.error || audioResult?.message) {
9097
9767
  throw buildProjectResultError(audioResult);
@@ -9154,8 +9824,8 @@ async function main() {
9154
9824
  }
9155
9825
 
9156
9826
  const editResult = isGptImage2ModelSelection(options.model)
9157
- ? await client.createImageProject(editConfig)
9158
- : await client.createImageEditProject(editConfig);
9827
+ ? await client.createImageProject(withBillingMode(editConfig))
9828
+ : await client.createImageEditProject(withBillingMode(editConfig));
9159
9829
  if (editResult?.error || editResult?.message) {
9160
9830
  throw buildProjectResultError(editResult);
9161
9831
  }
@@ -9200,7 +9870,7 @@ async function main() {
9200
9870
  if (options.loras.length > 0) projectConfig.loras = options.loras;
9201
9871
  if (options.loraStrengths.length > 0) projectConfig.loraStrengths = options.loraStrengths;
9202
9872
 
9203
- const projectResult = await client.createImageProject(projectConfig);
9873
+ const projectResult = await client.createImageProject(withBillingMode(projectConfig));
9204
9874
 
9205
9875
  // Check for errors in the response (e.g., insufficient tokens)
9206
9876
  if (projectResult?.error || projectResult?.message) {
@@ -9269,7 +9939,7 @@ async function main() {
9269
9939
  projectConfig.seed = options.seed;
9270
9940
  }
9271
9941
 
9272
- const imageResult = await client.createImageProject(projectConfig);
9942
+ const imageResult = await client.createImageProject(withBillingMode(projectConfig));
9273
9943
  if (imageResult?.error || imageResult?.message) {
9274
9944
  throw buildProjectResultError(imageResult);
9275
9945
  }
@@ -9488,7 +10158,7 @@ async function main() {
9488
10158
  });
9489
10159
  });
9490
10160
 
9491
- const clip2Result = await client2.createVideoProject(projectConfig2);
10161
+ const clip2Result = await client2.createVideoProject(withBillingMode(projectConfig2));
9492
10162
 
9493
10163
  // Check for errors in the response (e.g., insufficient tokens)
9494
10164
  if (clip2Result?.error || clip2Result?.message) {
package/version.mjs CHANGED
@@ -1 +1 @@
1
- export const PACKAGE_VERSION = '3.11.0';
1
+ export const PACKAGE_VERSION = '3.12.0';