@sogni-ai/sogni-creative-agent-skill 3.11.0 → 3.12.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.12.0](https://github.com/Sogni-AI/sogni-creative-agent-skill/compare/v3.11.1...v3.12.0) (2026-07-05)
2
+
3
+
4
+ ### Features
5
+
6
+ * **unlimited:** surface plan entitlement and billing mode across the CLI ([373490f](https://github.com/Sogni-AI/sogni-creative-agent-skill/commit/373490fc30da1edea84d7928691ab419b44f5bcf))
7
+
8
+ ## [3.11.1](https://github.com/Sogni-AI/sogni-creative-agent-skill/compare/v3.11.0...v3.11.1) (2026-07-05)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **desktop:** fit inline image previews under the 1MB host result cap ([4666922](https://github.com/Sogni-AI/sogni-creative-agent-skill/commit/46669226a8c6fb9a70ff808ef58c387ae62a4778))
14
+
1
15
  # [3.11.0](https://github.com/Sogni-AI/sogni-creative-agent-skill/compare/v3.10.0...v3.11.0) (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.10.0"
5
+ version: "3.11.1"
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 |
@@ -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
 
@@ -14,11 +14,12 @@ A dependency-free MCP stdio server that wraps the globally installed
14
14
 
15
15
  Successful `generate_image`, `photobooth`, and frame-extraction calls attach
16
16
  the rendered image(s) to the tool result as MCP image content blocks, which
17
- Claude Desktop displays inline (up to 4 per call, full resolution; images
18
- that would exceed the ~3.5MB content ceiling are downscaled via `sharp`, or
19
- skipped with a note if that fails). The text block always keeps the hosted
20
- URL / saved path. Set `SOGNI_MCP_NO_INLINE_IMAGES=1` in the server env to
21
- disable.
17
+ Claude Desktop displays inline (up to 4 per call). Previews auto-fit the
18
+ host's 1MB tool-result limit: they share a ~700KB cumulative raw-byte budget,
19
+ and any image over the remaining budget is downscaled via a `sharp` ladder
20
+ (1024px/q80 → 768px/q70 → 512px/q60), or skipped with a note if none fits.
21
+ The text block always keeps the full-resolution URL / saved path. Set
22
+ `SOGNI_MCP_NO_INLINE_IMAGES=1` in the server env to disable.
22
23
 
23
24
  ## Build the .mcpb bundle
24
25
 
@@ -30,6 +31,9 @@ disable.
30
31
  pointing at this server inside the global npm package (preferred).
31
32
  2. The packed `.mcpb` is the manual drag-and-drop alternative
32
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`).
33
37
 
34
38
  The server needs the CLI installed globally (`npm i -g @sogni-ai/sogni-creative-agent-skill`);
35
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.10.0",
5
+ "version": "3.11.1",
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",
@@ -4,15 +4,31 @@
4
4
  // to call this and how to compose the result. Every expected failure (bad
5
5
  // JSON, missing file, failed fetch, oversized bytes) degrades silently —
6
6
  // callers must never end up worse off than the text-only result.
7
+ //
8
+ // Size budget: Claude Desktop rejects any tool result over 1MB total ("Tool
9
+ // result is too large. Maximum size is 1MB."). Inline previews therefore share
10
+ // a cumulative raw-byte budget (INLINE_BUDGET_RAW) that leaves headroom for
11
+ // base64 expansion (~4/3) plus the text block, keeping the whole result under
12
+ // the 1MB host cap. Each image attaches as-is if it fits the remaining budget;
13
+ // otherwise it is downscaled through a deterministic sharp ladder to the first
14
+ // rung that fits. The text block always carries the full-resolution URL/path —
15
+ // the inline block is only a preview.
7
16
  import { readFile } from 'node:fs/promises';
8
17
  import { extname } from 'node:path';
9
18
 
10
19
  const INLINE_TOOLS = new Set(['generate_image', 'photobooth']);
11
20
  const FRAME_ACTIONS = new Set(['extract_first_frame', 'extract_last_frame']);
12
21
  const MAX_INLINE_IMAGES = 4;
13
- const MAX_RAW_BYTES = 3.5 * 1024 * 1024; // ≈5MB once base64-encoded — the practical content ceiling
14
- const DOWNSCALE_MAX_DIM = 2048;
15
- const DOWNSCALE_JPEG_QUALITY = 85;
22
+ // Cumulative raw-byte budget across all inline images. ≈933KB once base64-
23
+ // encoded, which plus the text block stays safely under the 1MB host cap.
24
+ const INLINE_BUDGET_RAW = 700 * 1024;
25
+ // Deterministic downscale rungs, largest first; attach the first rung whose
26
+ // JPEG output fits the remaining budget.
27
+ const DOWNSCALE_LADDER = [
28
+ { dim: 1024, q: 80 },
29
+ { dim: 768, q: 70 },
30
+ { dim: 512, q: 60 },
31
+ ];
16
32
  const FETCH_TIMEOUT_MS = 20_000; // inline fetch must never meaningfully delay the text result
17
33
  const TOO_LARGE_NOTE = 'One image was too large to display inline; use the link above.';
18
34
 
@@ -79,18 +95,22 @@ async function obtainBytes(candidate, fetchImpl, fetchTimeoutMs) {
79
95
  return { data: Buffer.from(await res.arrayBuffer()), mime };
80
96
  }
81
97
 
82
- // Full-resolution by default; only an image that would blow the content
83
- // ceiling gets downscaled (sharp ships with the package), and if that is
84
- // impossible the image is skipped with a note rather than breaking the call.
85
- async function fitBytes(entry) {
86
- if (entry.data.length <= MAX_RAW_BYTES) return entry;
98
+ // Fit one image into the REMAINING cumulative budget. If the original bytes
99
+ // already fit, attach them unchanged. Otherwise downscale through the ladder
100
+ // (sharp ships with the package) and attach the first rung whose JPEG output
101
+ // fits. If no rung fits, or sharp is unavailable/throws, return null so the
102
+ // caller skips the image with a note rather than breaking the whole call.
103
+ async function fitToBudget(entry, remaining) {
104
+ if (entry.data.length <= remaining) return entry;
87
105
  try {
88
106
  const { default: sharp } = await import('sharp');
89
- const data = await sharp(entry.data)
90
- .resize({ width: DOWNSCALE_MAX_DIM, height: DOWNSCALE_MAX_DIM, fit: 'inside', withoutEnlargement: true })
91
- .jpeg({ quality: DOWNSCALE_JPEG_QUALITY })
92
- .toBuffer();
93
- if (data.length <= MAX_RAW_BYTES) return { data, mime: 'image/jpeg' };
107
+ for (const { dim, q } of DOWNSCALE_LADDER) {
108
+ const data = await sharp(entry.data)
109
+ .resize({ width: dim, height: dim, fit: 'inside', withoutEnlargement: true })
110
+ .jpeg({ quality: q })
111
+ .toBuffer();
112
+ if (data.length <= remaining) return { data, mime: 'image/jpeg' };
113
+ }
94
114
  return null;
95
115
  } catch {
96
116
  return null;
@@ -98,7 +118,8 @@ async function fitBytes(entry) {
98
118
  }
99
119
 
100
120
  export async function collectInlineImages({
101
- toolName, input, stdout, env = process.env, fetchImpl = fetch, fetchTimeoutMs = FETCH_TIMEOUT_MS,
121
+ toolName, input, stdout, env = process.env, fetchImpl = fetch,
122
+ fetchTimeoutMs = FETCH_TIMEOUT_MS, budgetRaw = INLINE_BUDGET_RAW,
102
123
  }) {
103
124
  const empty = { blocks: [], notes: [] };
104
125
  if (env.SOGNI_MCP_NO_INLINE_IMAGES === '1') return empty;
@@ -106,14 +127,17 @@ export async function collectInlineImages({
106
127
 
107
128
  const blocks = [];
108
129
  const notes = [];
130
+ let attachedRawTotal = 0;
109
131
  for (const candidate of sourceCandidates(toolName, input, stdout)) {
110
132
  if (blocks.length >= MAX_INLINE_IMAGES) break;
111
133
  try {
112
- const fitted = await fitBytes(await obtainBytes(candidate, fetchImpl, fetchTimeoutMs));
134
+ const remaining = budgetRaw - attachedRawTotal;
135
+ const fitted = await fitToBudget(await obtainBytes(candidate, fetchImpl, fetchTimeoutMs), remaining);
113
136
  if (!fitted) {
114
137
  if (!notes.includes(TOO_LARGE_NOTE)) notes.push(TOO_LARGE_NOTE);
115
138
  continue;
116
139
  }
140
+ attachedRawTotal += fitted.data.length;
117
141
  blocks.push({ type: 'image', data: fitted.data.toString('base64'), mimeType: fitted.mime });
118
142
  } catch {
119
143
  // Silent per-image degradation: the text block still carries the link.
@@ -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.10.0",
5
+ "version": "3.11.1",
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.0",
3
+ "version": "3.12.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"
@@ -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,
@@ -2039,6 +2075,11 @@ for (let i = 0; i < args.length; i++) {
2039
2075
  i++;
2040
2076
  options.tokenType = raw;
2041
2077
  cliSet.tokenType = true;
2078
+ } else if (arg === '--billing-mode') {
2079
+ const raw = requireFlagValue(args, i, arg);
2080
+ i++;
2081
+ options.billingMode = raw;
2082
+ cliSet.billingMode = true;
2042
2083
  } else if (arg === '--steps') {
2043
2084
  const raw = requireFlagValue(args, i, arg);
2044
2085
  i++;
@@ -2906,8 +2947,10 @@ General:
2906
2947
  --steps <num> Override steps (model-dependent)
2907
2948
  --guidance <num> Override guidance (model-dependent)
2908
2949
  --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
2950
+ --billing-mode <mode> Billing: auto|subscription|tokens (default: server decides; "subscription"
2951
+ requires Sogni Unlimited coverage, "tokens" opts out of it)
2952
+ --balance, --balances Show account, plan, and SPARK/SOGNI balances and exit
2953
+ --doctor Health check: Node, credentials, ffmpeg, auth, plan, config, version
2911
2954
  --snooze-update Snooze the pending update reminder (1 day → 2 days → 1 week)
2912
2955
  --whats-new [version] Show bundled CHANGELOG entries (everything after <version> if given)
2913
2956
  --version, -V Show sogni-agent version and exit
@@ -3161,6 +3204,17 @@ if (options.tokenType) {
3161
3204
  options.tokenType = token;
3162
3205
  }
3163
3206
 
3207
+ if (options.billingMode) {
3208
+ const mode = String(options.billingMode).toLowerCase();
3209
+ if (mode !== 'auto' && mode !== 'subscription' && mode !== 'tokens') {
3210
+ fatalCliError('--billing-mode must be "auto", "subscription", or "tokens".', {
3211
+ code: 'INVALID_ARGUMENT',
3212
+ details: { flag: '--billing-mode', value: options.billingMode }
3213
+ });
3214
+ }
3215
+ options.billingMode = mode;
3216
+ }
3217
+
3164
3218
  if (options.apiTaskProfile) {
3165
3219
  const profile = String(options.apiTaskProfile).trim().toLowerCase();
3166
3220
  if (!VALID_API_TASK_PROFILES.has(profile)) {
@@ -7541,7 +7595,7 @@ async function runImageEditProjectWithEvents(client, editConfig, expectedCount,
7541
7595
  client.on(ClientEvent.JOB_FAILED, onFailed);
7542
7596
 
7543
7597
  try {
7544
- const projectResult = await client.createImageEditProject(editConfig);
7598
+ const projectResult = await client.createImageEditProject(withBillingMode(editConfig));
7545
7599
  projectId = projectResult?.project?.id || projectId;
7546
7600
 
7547
7601
  // Check for errors in the response (e.g., insufficient tokens)
@@ -7842,7 +7896,7 @@ async function runMultiAngleFlow(client, log) {
7842
7896
  if (options.autoResizeVideoAssets !== null) {
7843
7897
  clipConfig.autoResizeVideoAssets = options.autoResizeVideoAssets;
7844
7898
  }
7845
- const clipResult = await client.createVideoProject(clipConfig);
7899
+ const clipResult = await client.createVideoProject(withBillingMode(clipConfig));
7846
7900
 
7847
7901
  // Check for errors in the response (e.g., insufficient tokens)
7848
7902
  if (clipResult?.error || clipResult?.message) {
@@ -7929,6 +7983,15 @@ function buildVideoEstimateParams({ tokenType, steps }) {
7929
7983
 
7930
7984
  async function ensureSufficientVideoBalance(client, log) {
7931
7985
  if (!options.video || options.estimateVideoCost) return;
7986
+ // Sogni Unlimited bills covered video jobs to the subscription, so a low
7987
+ // token balance must not block them client-side. Vendor models
7988
+ // (Seedance/HappyHorse) always bill Premium Spark and keep the check, as
7989
+ // does an explicit --billing-mode tokens opt-out. The server stays
7990
+ // authoritative: an uncovered job still fails there with enriched guidance.
7991
+ if (options.billingMode !== 'tokens' && !requiresSparkOnlyToken(options.model)) {
7992
+ const subscription = await fetchSubscriptionSnapshot(client, log);
7993
+ if (subscription?.active === true) return;
7994
+ }
7932
7995
  const tokenType = options.tokenType || 'spark';
7933
7996
  const tokenLabel = tokenType.toUpperCase();
7934
7997
  let balance;
@@ -8062,9 +8125,19 @@ async function runDoctor() {
8062
8125
  });
8063
8126
  const authFlow = (async () => {
8064
8127
  await connectSogniClient(doctorClient);
8065
- return doctorClient.getBalance();
8128
+ const balance = await doctorClient.getBalance();
8129
+ // Identity + entitlement are best-effort: an old wrapper or a flaky
8130
+ // subscription endpoint must not fail the auth check itself.
8131
+ let accountInfo = null;
8132
+ if (typeof doctorClient.getAccountInfo === 'function') {
8133
+ try {
8134
+ accountInfo = await doctorClient.getAccountInfo();
8135
+ } catch { /* ignore */ }
8136
+ }
8137
+ const subscription = await fetchSubscriptionSnapshot(doctorClient, null);
8138
+ return { balance, accountInfo, subscription };
8066
8139
  })();
8067
- const balance = await Promise.race([
8140
+ const { balance, accountInfo, subscription } = await Promise.race([
8068
8141
  authFlow,
8069
8142
  new Promise((_, reject) => setTimeout(
8070
8143
  () => reject(Object.assign(new Error('timed out'), { code: 'DOCTOR_TIMEOUT' })),
@@ -8073,8 +8146,18 @@ async function runDoctor() {
8073
8146
  ]);
8074
8147
  const spark = Number.parseFloat(balance?.spark);
8075
8148
  const sogni = Number.parseFloat(balance?.sogni);
8149
+ const identity = accountInfo?.username ? `user ${accountInfo.username}, ` : '';
8076
8150
  add('auth', 'pass',
8077
- `API key accepted (SPARK ${Number.isFinite(spark) ? spark : '?'}, SOGNI ${Number.isFinite(sogni) ? sogni : '?'})`);
8151
+ `API key accepted (${identity}SPARK ${Number.isFinite(spark) ? spark : '?'}, SOGNI ${Number.isFinite(sogni) ? sogni : '?'})`);
8152
+ if (subscription) {
8153
+ if (subscription.active === true) {
8154
+ add('plan', 'pass', describeSubscription(subscription));
8155
+ } else if (Number.isFinite(spark) && spark <= 0 && Number.isFinite(sogni) && sogni <= 0) {
8156
+ add('plan', 'warn', 'no subscription and no token balance — renders will fail until you buy Spark Packs or subscribe');
8157
+ } else {
8158
+ add('plan', 'pass', 'none — renders bill Spark/SOGNI from this account\'s balance');
8159
+ }
8160
+ }
8078
8161
  } catch (err) {
8079
8162
  if (isInvalidApiKeyError(err)) {
8080
8163
  add('auth', 'fail', 'API key rejected — get a fresh key at https://dashboard.sogni.ai (account menu)');
@@ -8528,6 +8611,15 @@ async function main() {
8528
8611
  const balance = await client.getBalance();
8529
8612
  const spark = Number.parseFloat(balance?.spark);
8530
8613
  const sogni = Number.parseFloat(balance?.sogni);
8614
+ // Identity + plan make wrong-account and no-subscription states visible
8615
+ // (a low Spark balance is fine when Unlimited covers the renders).
8616
+ const subscription = await fetchSubscriptionSnapshot(client, log);
8617
+ let accountInfo = null;
8618
+ if (typeof client.getAccountInfo === 'function') {
8619
+ try {
8620
+ accountInfo = await client.getAccountInfo();
8621
+ } catch { /* identity display is best-effort */ }
8622
+ }
8531
8623
  if (options.json) {
8532
8624
  console.log(JSON.stringify({
8533
8625
  success: true,
@@ -8535,9 +8627,23 @@ async function main() {
8535
8627
  spark: Number.isFinite(spark) ? spark : null,
8536
8628
  sogni: Number.isFinite(sogni) ? sogni : null,
8537
8629
  tokenType: options.tokenType || 'spark',
8630
+ username: accountInfo?.username ?? null,
8631
+ subscription: subscription
8632
+ ? {
8633
+ active: subscription.active === true,
8634
+ status: subscription.status ?? null,
8635
+ tier: subscription.tier ?? null
8636
+ }
8637
+ : null,
8538
8638
  timestamp: new Date().toISOString()
8539
8639
  }));
8540
8640
  } else {
8641
+ if (accountInfo?.username) {
8642
+ console.log(`Account: ${accountInfo.username}`);
8643
+ }
8644
+ if (subscription) {
8645
+ console.log(`Plan: ${describeSubscription(subscription)}`);
8646
+ }
8541
8647
  console.log(`SPARK: ${formatTokenValue(spark)}`);
8542
8648
  console.log(`SOGNI: ${formatTokenValue(sogni)}`);
8543
8649
  }
@@ -9029,7 +9135,7 @@ async function main() {
9029
9135
  projectConfig.lastFrameStrength = options.lastFrameStrength;
9030
9136
  }
9031
9137
 
9032
- const videoResult = await client.createVideoProject(projectConfig);
9138
+ const videoResult = await client.createVideoProject(withBillingMode(projectConfig));
9033
9139
 
9034
9140
  // Check for errors in the response (e.g., insufficient tokens)
9035
9141
  if (videoResult?.error || videoResult?.message) {
@@ -9091,7 +9197,7 @@ async function main() {
9091
9197
  projectConfig.seed = options.seed;
9092
9198
  }
9093
9199
 
9094
- const audioResult = await client.createAudioProject(projectConfig);
9200
+ const audioResult = await client.createAudioProject(withBillingMode(projectConfig));
9095
9201
 
9096
9202
  if (audioResult?.error || audioResult?.message) {
9097
9203
  throw buildProjectResultError(audioResult);
@@ -9154,8 +9260,8 @@ async function main() {
9154
9260
  }
9155
9261
 
9156
9262
  const editResult = isGptImage2ModelSelection(options.model)
9157
- ? await client.createImageProject(editConfig)
9158
- : await client.createImageEditProject(editConfig);
9263
+ ? await client.createImageProject(withBillingMode(editConfig))
9264
+ : await client.createImageEditProject(withBillingMode(editConfig));
9159
9265
  if (editResult?.error || editResult?.message) {
9160
9266
  throw buildProjectResultError(editResult);
9161
9267
  }
@@ -9200,7 +9306,7 @@ async function main() {
9200
9306
  if (options.loras.length > 0) projectConfig.loras = options.loras;
9201
9307
  if (options.loraStrengths.length > 0) projectConfig.loraStrengths = options.loraStrengths;
9202
9308
 
9203
- const projectResult = await client.createImageProject(projectConfig);
9309
+ const projectResult = await client.createImageProject(withBillingMode(projectConfig));
9204
9310
 
9205
9311
  // Check for errors in the response (e.g., insufficient tokens)
9206
9312
  if (projectResult?.error || projectResult?.message) {
@@ -9269,7 +9375,7 @@ async function main() {
9269
9375
  projectConfig.seed = options.seed;
9270
9376
  }
9271
9377
 
9272
- const imageResult = await client.createImageProject(projectConfig);
9378
+ const imageResult = await client.createImageProject(withBillingMode(projectConfig));
9273
9379
  if (imageResult?.error || imageResult?.message) {
9274
9380
  throw buildProjectResultError(imageResult);
9275
9381
  }
@@ -9488,7 +9594,7 @@ async function main() {
9488
9594
  });
9489
9595
  });
9490
9596
 
9491
- const clip2Result = await client2.createVideoProject(projectConfig2);
9597
+ const clip2Result = await client2.createVideoProject(withBillingMode(projectConfig2));
9492
9598
 
9493
9599
  // Check for errors in the response (e.g., insufficient tokens)
9494
9600
  if (clip2Result?.error || clip2Result?.message) {
package/version.mjs CHANGED
@@ -1 +1 @@
1
- export const PACKAGE_VERSION = '3.10.0';
1
+ export const PACKAGE_VERSION = '3.11.1';