@sogni-ai/sogni-creative-agent-skill 3.6.1 → 3.6.3

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
@@ -5,6 +5,26 @@ All notable changes to this project are documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [3.6.3] - 2026-06-22
9
+
10
+ ### Added
11
+
12
+ - **Sogni Unlimited subscription guidance.** README, SKILL.md, and `llm.txt` now document the Unlimited plan,
13
+ and the CLI includes friendlier billing-error fallbacks for subscription-related failures.
14
+
15
+ ### Fixed
16
+
17
+ - **`sogni-agent self-update` now gives clearer recovery guidance after failed global package updates.** When the
18
+ package manager exits nonzero, the CLI reports the failing exit code and prints platform-specific permission
19
+ guidance (for example, `sudo sogni-agent self-update` on macOS/Linux or an Administrator terminal on Windows)
20
+ instead of leaving users with only raw npm output.
21
+ - **Codex and Hermes setup docs now mention the target app must be started once before targeted installer runs.**
22
+ `README.md` and `llm.txt` now match the setup installer preflight: `--only=codex` and `--only=hermes` exit
23
+ before installing anything if `~/.codex/` or `~/.hermes/` has not been created yet.
24
+ - **Claude plugin setup guidance no longer tells agents to create a duplicate personal Claude skill.** The
25
+ plugin-bundled skill now installs only the global CLI, tells agents not to run the default setup installer from
26
+ inside the plugin, and clarifies that setup cleanup does not uninstall the Claude Code plugin itself.
27
+
8
28
  ## [3.6.1] - 2026-06-15
9
29
 
10
30
  ### Changed
package/README.md CHANGED
@@ -64,6 +64,7 @@ With this skill, an agent can:
64
64
  - [Hosted API Modes](#hosted-api-modes)
65
65
  - [Dynamic Prompt Variations](#dynamic-prompt-variations)
66
66
  - [Token Auto-Fallback](#token-auto-fallback)
67
+ - [Sogni Unlimited Subscription](#sogni-unlimited-subscription)
67
68
  - [Error Reporting & Output](#error-reporting--output)
68
69
  - [For AI Agents](#for-ai-agents)
69
70
  - [Development](#development)
@@ -82,8 +83,9 @@ With this skill, an agent can:
82
83
 
83
84
  This auto-detects Claude Code, OpenAI Codex CLI, and Hermes Agent; installs the
84
85
  CLI globally; registers the skill into each detected runtime; prompts for your
85
- API key; and prints ChatGPT Custom-GPT setup instructions. (It does **not**
86
- configure OpenClaw — see the [OpenClaw plugin](#openclaw-plugin) section.)
86
+ API key; and tells you how to request ChatGPT Custom-GPT setup instructions.
87
+ (It does **not** configure OpenClaw — see the [OpenClaw plugin](#openclaw-plugin)
88
+ section.)
87
89
 
88
90
  Prefer to do it manually? Install the CLI directly:
89
91
 
@@ -151,10 +153,11 @@ The first command registers a `sogni` marketplace with one plugin entry (`sogni-
151
153
  The `npx` installer writes the skill to `~/.codex/skills/sogni-creative-agent-skill/`, which the Codex CLI discovers automatically:
152
154
 
153
155
  ```bash
154
- npm install -g @sogni-ai/sogni-creative-agent-skill@latest
155
156
  npx setup-sogni-agent-skill --only=codex
156
157
  ```
157
158
 
159
+ Start Codex once before running the installer so `~/.codex/` exists. If the selected local runtime is not detected, setup exits before installing anything.
160
+
158
161
  Restart Codex (or start a new session) and ask it to "generate an image of a sunset" — the skill shells out to the globally installed `sogni-agent`. To remove it later: `npx setup-sogni-agent-skill --uninstall --only=codex`.
159
162
 
160
163
  ### Hermes Agent
@@ -162,10 +165,11 @@ Restart Codex (or start a new session) and ask it to "generate an image of a sun
162
165
  [Hermes Agent](https://hermes-agent.nousresearch.com/) loads skills from `~/.hermes/skills/<category>/<name>/SKILL.md`. The `npx` installer places this skill at `~/.hermes/skills/media/sogni-creative-agent-skill/`:
163
166
 
164
167
  ```bash
165
- npm install -g @sogni-ai/sogni-creative-agent-skill@latest
166
168
  npx setup-sogni-agent-skill --only=hermes
167
169
  ```
168
170
 
171
+ Start Hermes once before running the installer so `~/.hermes/` exists. If the selected local runtime is not detected, setup exits before installing anything.
172
+
169
173
  Then `/reset` your Hermes session so it picks up the new skill. (You can also install manually: copy [`SKILL.md`](./SKILL.md) into `~/.hermes/skills/media/sogni-creative-agent-skill/SKILL.md`, or use `hermes skills install` if your build supports it.)
170
174
 
171
175
  ### OpenClaw plugin
@@ -216,7 +220,7 @@ When loaded through OpenClaw, this skill reads plugin defaults from OpenClaw con
216
220
 
217
221
  ### ChatGPT (Custom GPT)
218
222
 
219
- Running `npx setup-sogni-agent-skill` also prints step-by-step instructions for creating a ChatGPT Custom GPT whose Instructions embed this skill. Note that ChatGPT cannot run the local CLI; the Custom GPT path covers prompt-side behavior only.
223
+ Run `npx setup-sogni-agent-skill --only=chatgpt` to print step-by-step instructions for creating a ChatGPT Custom GPT whose Instructions embed this skill. Note that ChatGPT cannot run the local CLI; the Custom GPT path covers prompt-side behavior only.
220
224
 
221
225
  ### Manus / other SKILL.md frameworks
222
226
 
@@ -656,12 +660,77 @@ sogni-agent --token-type auto "a dragon eating tacos"
656
660
 
657
661
  Tries SPARK first, then falls back to SOGNI if the balance is too low. Vendor models such as Seedance and GPT Image 2 require Premium Spark eligibility and never use SOGNI fallback. If usable balance is still insufficient, buy Spark Packs at https://docs.sogni.ai/pricing/#spark-packs.
658
662
 
663
+ On a **Sogni Unlimited** subscription, Sogni-hosted generation is covered by the plan instead of spending tokens — see the next section.
664
+
665
+ ---
666
+
667
+ ## Sogni Unlimited Subscription
668
+
669
+ [Sogni Unlimited](https://docs.sogni.ai/pricing/unlimited-plan-details) is a flat-rate subscription that covers Sogni-hosted (Supernet) image, video, and music generation under a fair-use policy, instead of spending Spark or SOGNI per render. Manage subscriptions where they were purchased — the Stripe billing portal for web checkouts, or the App Store / Google Play account settings for mobile.
670
+
671
+ ### Plans
672
+
673
+ | Plan | Monthly | Annual |
674
+ | --- | --- | --- |
675
+ | **Unlimited** | $20 / mo | $199 / yr |
676
+ | **Unlimited Pro** | $50 / mo | $498 / yr |
677
+
678
+ App Store and Google Play prices may differ from web pricing due to platform fees. A 3-day free trial is available once per account (a payment method is required and the subscription converts to paid when the trial ends unless cancelled first).
679
+
680
+ ### What the subscription covers
681
+
682
+ - **Covered:** Sogni-hosted models on the Supernet — image, video, and music generation, including worker-hosted premium models. Covered renders bill to the subscription and do not spend Spark or SOGNI.
683
+ - **Not covered (Premium Spark only):** external-vendor models — **GPT Image 2** (`gpt-image-2`) and **Seedance 2.0 / Seedance 2.0 Fast** (`seedance-2-0`, `seedance-2-0-fast`). These always require Premium Spark eligibility even with an active subscription; they never bill to the subscription and never fall back to SOGNI.
684
+ - **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.
685
+
686
+ 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.
687
+
688
+ ### Free-trial usage limits
689
+
690
+ Trials include anti-abuse evaluation limits so the full plan experience is reserved for paid periods. As shipped (server-tunable): up to **30 jobs per UTC day**, a **100-render lifetime trial allowance**, images up to **~1.1 MP**, video up to **5 s / 720p**, and — for programmatic/API callers — a single allowed model (Z-Image Turbo). Full plan limits apply once the trial converts to paid. Cancelling during the trial ends Unlimited access immediately and prevents the first charge.
691
+
692
+ ### Fair-use throttling
693
+
694
+ Unlimited is fair-use, not unmetered. Limits are per UTC day and reset at UTC midnight; only successfully completed renders count toward the daily thresholds (failed / cancelled / retried renders do not).
695
+
696
+ - **Concurrent renders (base):** Unlimited — 4 images / 1 video in flight; Unlimited Pro — 16 images / 4 videos. Up to 512 jobs may be queued per account.
697
+ - **Daily slot decay** (active-concurrency ceiling drops as completed renders climb, per UTC day):
698
+ - Unlimited images: 4 → 2 → 1 → 0 at 1024 / 2048 / 3072 completed.
699
+ - Unlimited video: 1 → 0 at 32 completed.
700
+ - Unlimited Pro images: 16 → 8 → 4 → 1 at 2048 / 4096 / 6144 completed (never fully cut off).
701
+ - Unlimited Pro video: 4 → 2 → 1 → 0 at 32 / 64 / 128 completed.
702
+ - **Queue priority:** paid Spark and SOGNI jobs are dispatched ahead of subscription jobs; Unlimited Pro outranks Unlimited, which outranks free Spark. When a subscription exceeds its fast-lane fair-use allowance, further jobs run best-effort in the lowest-priority standard queue until capacity resets — they still complete, just later. Subscription jobs cannot target specific workers.
703
+
704
+ ### Billing states & cancellation
705
+
706
+ - **Active / trialing:** covered renders run normally.
707
+ - **Cancellation (paid):** Unlimited access continues until the end of the period already paid for; it simply does not renew.
708
+ - **Cancellation (during trial):** access ends immediately and no charge is made.
709
+ - **Grace / payment retry:** if a renewal payment fails, the provider retries it and **Unlimited access is paused** during the retry window — covered renders are declined with a renewal-retry error, and access resumes automatically once payment succeeds. You can keep rendering with Spark or SOGNI in the meantime.
710
+ - **Refunds:** mid-term refunds are not offered by default; App Store / Google Play purchases follow the store's refund process, and Stripe (web) refunds are handled by Sogni support.
711
+
712
+ ### Subscription billing errors
713
+
714
+ When a generation cannot bill to the subscription, the CLI surfaces a structured error (`--json` includes `errorCode`, `errorCategory`, and a `hint`):
715
+
716
+ | Code | Meaning | What to do |
717
+ | --- | --- | --- |
718
+ | `4078` | Unlimited billing is not available for this generation (a vendor model that the subscription never covers, or no verified entitlement). | Use Premium Spark for vendor models (GPT Image 2 / Seedance), or reconnect and retry for a transient entitlement read. |
719
+ | `4079` | Maximum queued jobs reached for the plan. | Wait for queued jobs to finish, then submit more. |
720
+ | `4080` | Renewal payment is being retried; Unlimited access is paused. | Pay for this render with Spark or SOGNI (`--token-type spark` / `sogni`) for now. **Do not auto-retry the covered job** — access resumes on its own once renewal succeeds. |
721
+ | `4081` | The feature requires a higher subscription plan. | Upgrade to Unlimited Pro. |
722
+
723
+ ### Worker revenue share
724
+
725
+ Sogni workers that power subscription-covered jobs earn from a separate monthly pool — 51% of net subscription revenue — settled per UTC month and claimable in USDC on Base. Subscription jobs are excluded from the regular Spark/SOGNI token-economy leaderboard (they do not spend tokens) and accrue to this pool instead.
726
+
659
727
  ---
660
728
 
661
729
  ## Error Reporting & Output
662
730
 
663
731
  - **Exit codes:** failures use a non-zero exit code with human-readable stderr.
664
732
  - **Structured output:** add `--json` when an agent needs machine-parseable success/error data, or `--last` to inspect the last render. JSON failures include canonical `errorType`, `errorCategory`, and `retryable` fields where the shared runtime can classify the error.
733
+ - **Subscription billing errors:** subscription-billing failures carry `errorCode` `4078` / `4079` / `4080` / `4081`, `errorCategory: "subscription_billing"`, and an actionable `hint`. See [Subscription billing errors](#subscription-billing-errors) for what each means; in particular, do not auto-retry a `4080` (grace / renewal-retry) covered job — pay with Spark or SOGNI instead.
665
734
  - **stdout stays parseable in `--json` mode:** progress lines, SSE workflow frames, and warnings go to stderr; stdout carries exactly one JSON object. `--last --json` wraps the record in a `{ "success": true, ... }` envelope and exits 1 with `errorCode: "NO_LAST_RENDER"` when nothing has been rendered yet.
666
735
  - **Output files:** use `-o <path>` to save locally; otherwise the CLI prints a result URL.
667
736
  - **Quiet mode:** `-q` / `--quiet` suppresses progress output without changing exit semantics.
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/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.6.1"
5
+ version: "3.6.3"
6
6
  homepage: https://sogni.ai
7
7
  openclaw:
8
8
  emoji: "🎨"
@@ -238,6 +238,21 @@ Use `--token-type auto` to retry native Sogni models with SOGNI tokens when SPAR
238
238
 
239
239
  Do not collect payment details, quote a custom price, or simulate a purchase in the terminal.
240
240
 
241
+ ### Sogni Unlimited Subscription & Billing Errors
242
+
243
+ On a **Sogni Unlimited** subscription, Sogni-hosted (Supernet) image, video, and music generation is covered by the plan under a fair-use policy instead of spending Spark or SOGNI. Plans: Unlimited ($20/mo, $199/yr) and Unlimited Pro ($50/mo, $498/yr), with a one-per-account 3-day free trial. External-vendor models — **GPT Image 2** and **Seedance 2.0 / Fast** — are never covered and always require Premium Spark, even on an active subscription. Selecting SOGNI opts a job out of coverage. The server decides coverage from the verified entitlement and resolved model; never tell the user a vendor model is "free on Unlimited."
244
+
245
+ Unlimited is fair-use, not unmetered: per-UTC-day concurrency ceilings step down as completed renders climb (and reset at UTC midnight), and once a plan's fast-lane allowance is exceeded, further jobs run best-effort in a lower-priority standard queue until capacity resets. Describe this as **fair use** / a **standard (throttled) queue** — never as "relaxed."
246
+
247
+ When a generation cannot bill to the subscription, the CLI returns a structured error (`errorCategory: "subscription_billing"`). Respond by the `errorCode`, and **do not** collect payment details or simulate a purchase:
248
+
249
+ - **`4078` — Unlimited billing unavailable for this generation.** Either a vendor model the subscription never covers (use Premium Spark for GPT Image 2 / Seedance), or no verified entitlement right now (reconnect and retry). Offer the Premium Spark / `--token-type` path; do not claim the subscription will cover a vendor model.
250
+ - **`4079` — Maximum queued jobs reached.** Ask the user to wait for queued jobs to finish before submitting more; this resolves on its own.
251
+ - **`4080` — Renewal payment is being retried; access is paused.** Tell the user Unlimited resumes automatically once the renewal succeeds and that they can render now with Spark or SOGNI (`--token-type spark` / `sogni`). **Never auto-retry the covered job in a loop** — it will keep failing until billing recovers.
252
+ - **`4081` — Higher plan required.** Suggest upgrading to Unlimited Pro.
253
+
254
+ Cancelling a paid subscription keeps access until the end of the paid period; cancelling during the trial ends access immediately. Manage billing where it was purchased (Stripe portal for web, App Store / Google Play settings for mobile) — the CLI does not change plans.
255
+
241
256
  ### Suggest next steps after a render
242
257
 
243
258
  After an image: offer to animate it (`--video --ref <result>`), restyle it (`-c <result> "Apply style: ..."`), change the angle (`--multi-angle -c <result>`), generate variations (`-n 3 "{a|b|c}"`), or refine at `-Q pro`. After a video: offer different motion, dialogue (LTX), longer `--duration`, stitching (`--concat-videos`), or a soundtrack (`--concat-audio` / `--remix-audio`).
package/llm.txt CHANGED
@@ -8,10 +8,13 @@ Manus AI, and other SKILL.md-aware agent runtimes.
8
8
 
9
9
  ```bash
10
10
  # One-command install: detects Claude Code, Codex CLI, and Hermes; installs the
11
- # CLI globally; prompts for the API key; prints ChatGPT Custom-GPT instructions.
11
+ # CLI globally; prompts for the API key; points to ChatGPT Custom-GPT setup.
12
12
  # (Does NOT configure OpenClaw — see below.)
13
13
  npx setup-sogni-agent-skill
14
14
 
15
+ # Print ChatGPT Custom-GPT instructions explicitly.
16
+ npx setup-sogni-agent-skill --only=chatgpt
17
+
15
18
  # Agent-safe manual CLI install or upgrade
16
19
  npm install -g @sogni-ai/sogni-creative-agent-skill@latest
17
20
  sogni-agent --version
@@ -23,11 +26,11 @@ sogni-agent --version
23
26
  # Pick ONE Claude Code registration: the plugin OR the ~/.claude/skills install
24
27
  # from the npx installer — not both.
25
28
 
26
- # OpenAI Codex CLI (writes ~/.codex/skills/sogni-creative-agent-skill/)
29
+ # OpenAI Codex CLI (start Codex once first so ~/.codex/ exists)
27
30
  npx setup-sogni-agent-skill --only=codex
28
31
 
29
- # Hermes Agent (writes ~/.hermes/skills/media/sogni-creative-agent-skill/),
30
- # then /reset the Hermes session
32
+ # Hermes Agent (start Hermes once first so ~/.hermes/ exists), then /reset the
33
+ # Hermes session
31
34
  npx setup-sogni-agent-skill --only=hermes
32
35
 
33
36
  # OpenClaw plugin (the npm package is scoped — use the npm: source prefix)
@@ -90,6 +93,26 @@ You can also export `SOGNI_API_KEY` instead of writing the file. Confirm with
90
93
  - Cost policy: `--workflow-max-cost`, `--confirm-cost`, `--no-confirm-cost`.
91
94
  - JSON errors include canonical `errorType`, `errorCategory`, and `retryable`.
92
95
 
96
+ ## Sogni Unlimited subscription
97
+
98
+ Sogni Unlimited is a flat-rate subscription that covers Sogni-hosted (Supernet)
99
+ image, video, and music generation under a fair-use policy instead of spending
100
+ Spark or SOGNI per render. Plans: Unlimited ($20/mo, $199/yr) and Unlimited Pro
101
+ ($50/mo, $498/yr), with a one-per-account 3-day free trial (trial usage is
102
+ capped). External-vendor models — GPT Image 2 (`gpt-image-2`) and Seedance 2.0 /
103
+ Fast (`seedance-2-0`, `seedance-2-0-fast`) — are never covered and always need
104
+ Premium Spark; selecting SOGNI opts a job out of coverage. The server decides
105
+ coverage from the verified entitlement + resolved model; the CLI never asserts
106
+ coverage. Fair-use throttling lowers per-UTC-day concurrency as completed renders
107
+ climb (resets UTC midnight) and demotes over-allowance jobs to a lower-priority
108
+ standard queue — describe this as fair use / standard queue, never "relaxed".
109
+ Subscription-billing failures use `errorCategory: "subscription_billing"` with
110
+ `errorCode` 4078 (vendor/no-entitlement -> use Premium Spark or reconnect), 4079
111
+ (queue cap -> wait), 4080 (renewal retry, access paused -> pay with Spark/SOGNI,
112
+ do NOT auto-retry the covered job), or 4081 (higher plan -> upgrade to Pro). Paid
113
+ cancellation keeps access until period end; cancelling during the trial ends
114
+ access immediately.
115
+
93
116
  ## Repo
94
117
 
95
118
  Sogni-AI/sogni-creative-agent-skill
@@ -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.6.1",
5
+ "version": "3.6.3",
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.6.1",
3
+ "version": "3.6.3",
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",
package/sogni-agent.mjs CHANGED
@@ -90,6 +90,86 @@ import {
90
90
  const SPARK_PACKS_PURCHASE_URL = 'https://docs.sogni.ai/pricing/#spark-packs';
91
91
  const SPARK_PACKS_PURCHASE_HINT = `Buy Spark Packs to continue: ${SPARK_PACKS_PURCHASE_URL}`;
92
92
 
93
+ const UNLIMITED_PLAN_URL = 'https://docs.sogni.ai/pricing/unlimited-plan-details';
94
+
95
+ // Skill-local fallback guidance for Sogni Unlimited subscription billing errors,
96
+ // keyed on the canonical socket error code (a structured fact, not an English
97
+ // message). Mirrors the `insufficient_credits` enrichment below: it adds an
98
+ // actionable hint/category so an agent responds correctly instead of looping a
99
+ // covered job that cannot bill. Codes are the source of truth in
100
+ // sogni-socket/constants/errorCodes.js (4078-4081).
101
+ const SUBSCRIPTION_BILLING_ERROR_CODES = new Set(['4078', '4079', '4080', '4081']);
102
+
103
+ function subscriptionBillingFallback(code) {
104
+ if (code === undefined || code === null) return null;
105
+ const key = String(code);
106
+ if (!SUBSCRIPTION_BILLING_ERROR_CODES.has(key)) return null;
107
+ switch (key) {
108
+ case '4078':
109
+ // Vendor model the subscription never covers, or no verified entitlement.
110
+ return {
111
+ retryable: false,
112
+ hint: 'This generation is not covered by Sogni Unlimited. Vendor models (GPT Image 2, Seedance) always require Premium Spark; otherwise reconnect and try again. ' + SPARK_PACKS_PURCHASE_HINT,
113
+ purchaseLabel: 'Get Premium Spark',
114
+ purchaseUrl: SPARK_PACKS_PURCHASE_URL,
115
+ };
116
+ case '4079':
117
+ // Per-plan queued-job ceiling reached.
118
+ return {
119
+ retryable: true,
120
+ hint: 'Unlimited plan: maximum queued jobs reached. Wait for queued jobs to finish before submitting more.',
121
+ };
122
+ case '4080':
123
+ // Renewal payment retry — Unlimited access paused. Do NOT auto-retry the
124
+ // covered job; it will keep failing until billing recovers.
125
+ return {
126
+ retryable: false,
127
+ hint: 'Unlimited renewal payment is being retried and access is paused. Render now with Spark or SOGNI (--token-type spark|sogni); Unlimited resumes automatically once the renewal succeeds. Do not auto-retry the covered job.',
128
+ };
129
+ case '4081':
130
+ // Feature requires a higher subscription tier.
131
+ return {
132
+ retryable: false,
133
+ hint: `This feature requires a higher subscription plan. Upgrade to Unlimited Pro: ${UNLIMITED_PLAN_URL}`,
134
+ purchaseLabel: 'Upgrade to Unlimited Pro',
135
+ purchaseUrl: UNLIMITED_PLAN_URL,
136
+ };
137
+ default:
138
+ return null;
139
+ }
140
+ }
141
+
142
+ // Apply subscription-billing fallback enrichment to an error payload. Returns
143
+ // true when the code matched (so callers skip the generic insufficient_credits
144
+ // branch — subscription denials get subscription-specific guidance, never a bare
145
+ // "Buy Spark Packs"). Extracts the code from the canonical shapes the SDK and
146
+ // socket surface it in.
147
+ function applySubscriptionBillingEnrichment(payload, code) {
148
+ const fallback = subscriptionBillingFallback(code);
149
+ if (!fallback) return false;
150
+ payload.errorCode = String(code);
151
+ payload.errorCategory = 'subscription_billing';
152
+ payload.retryable = fallback.retryable;
153
+ if (!payload.hint) payload.hint = fallback.hint;
154
+ if (fallback.purchaseUrl) {
155
+ payload.purchaseAction = true;
156
+ payload.purchaseLabel = fallback.purchaseLabel;
157
+ payload.purchaseUrl = fallback.purchaseUrl;
158
+ payload.purchaseReason = fallback.hint;
159
+ }
160
+ return true;
161
+ }
162
+
163
+ function subscriptionBillingCodeFromError(error) {
164
+ if (!error || typeof error !== 'object') return undefined;
165
+ const record = error;
166
+ return record.code
167
+ ?? record.errorCode
168
+ ?? record.error_code
169
+ ?? record.payload?.errorCode
170
+ ?? record.payload?.error_code;
171
+ }
172
+
93
173
  const require = createRequire(import.meta.url);
94
174
  const rootClientModule = process.env.SOGNI_AGENT_TEST_STATE_PATH
95
175
  ? await import('@sogni-ai/sogni-intelligence-client')
@@ -315,7 +395,10 @@ function buildCliErrorPayload({ message, code, details, hint, prompt }) {
315
395
  if (code) payload.errorCode = code;
316
396
  if (details) payload.errorDetails = details;
317
397
  if (hint) payload.hint = hint;
318
- if (classified.category === 'insufficient_credits') {
398
+ if (applySubscriptionBillingEnrichment(payload, code)) {
399
+ // Subscription-billing code (4078-4081) — handled with subscription-specific
400
+ // guidance; skip the generic "Buy Spark Packs" credits branch.
401
+ } else if (classified.category === 'insufficient_credits') {
319
402
  payload.purchaseAction = true;
320
403
  payload.purchaseLabel = 'Buy Spark Packs';
321
404
  payload.purchaseUrl = SPARK_PACKS_PURCHASE_URL;
@@ -394,7 +477,11 @@ function addCanonicalErrorFields(payload, error) {
394
477
  if (classified.technicalError && classified.technicalError !== classified.message) {
395
478
  payload.technicalError = classified.technicalError;
396
479
  }
397
- if (classified.category === 'insufficient_credits') {
480
+ const subscriptionCode = subscriptionBillingCodeFromError(error);
481
+ if (applySubscriptionBillingEnrichment(payload, subscriptionCode)) {
482
+ // Subscription-billing code (4078-4081) — handled with subscription-specific
483
+ // guidance; skip the generic "Buy Spark Packs" credits branch.
484
+ } else if (classified.category === 'insufficient_credits') {
398
485
  payload.purchaseAction = true;
399
486
  payload.purchaseLabel = 'Buy Spark Packs';
400
487
  payload.purchaseUrl = SPARK_PACKS_PURCHASE_URL;
package/update-check.mjs CHANGED
@@ -24,7 +24,7 @@
24
24
  import { spawn, spawnSync } from 'child_process';
25
25
  import { existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync } from 'fs';
26
26
  import { dirname, join } from 'path';
27
- import { homedir } from 'os';
27
+ import { homedir, platform as osPlatform } from 'os';
28
28
  import https from 'https';
29
29
 
30
30
  export const PACKAGE_NAME = '@sogni-ai/sogni-creative-agent-skill';
@@ -73,6 +73,20 @@ export function detectPackageManager(env = process.env) {
73
73
  return { manager: 'npm', installCmd: `npm install -g ${PACKAGE_NAME}` };
74
74
  }
75
75
 
76
+ function isPermissionErrorText(text) {
77
+ return /EACCES|EPERM|permission denied|operation not permitted/i.test(String(text || ''));
78
+ }
79
+
80
+ export function formatSelfUpdatePermissionHint({ manager = 'npm', platform = osPlatform() } = {}) {
81
+ const rerun = platform === 'win32'
82
+ ? 'open a terminal as Administrator and run `sogni-agent self-update` again'
83
+ : 'run `sudo sogni-agent self-update`';
84
+ if (manager === 'npm') {
85
+ return `Hint: if npm reported a permissions error, ${rerun}, or install Node with a version manager (nvm/fnm/volta).`;
86
+ }
87
+ return `Hint: if ${manager} reported a permissions error, ${rerun}, or fix your global ${manager} install permissions.`;
88
+ }
89
+
76
90
  // Hard opt-outs only. Notices are deliberately NOT skipped for non-TTY
77
91
  // stderr, --json, or OpenClaw plugin invocations anymore: those are exactly
78
92
  // the agent contexts that should relay "an update is available" to the user
@@ -432,22 +446,29 @@ export function runSelfUpdate({
432
446
  statePath = DEFAULT_STATE_PATH,
433
447
  spawnSyncFn = spawnSync,
434
448
  stdio = 'inherit',
449
+ platform = osPlatform(),
450
+ log = console.error,
435
451
  } = {}) {
436
452
  const { manager, installCmd } = detectPackageManager(env);
437
453
  const [command, ...args] = installCmd.split(' ');
438
- console.error(`Running: ${installCmd}`);
454
+ log(`Running: ${installCmd}`);
439
455
  const result = spawnSyncFn(command, args, { stdio, env });
440
456
  if (result.error) {
441
- console.error(`self-update failed: ${result.error.message}`);
457
+ log(`self-update failed: ${result.error.message}`);
442
458
  if (manager === 'npm' && /EACCES|EPERM/i.test(result.error.message)) {
443
- console.error('Hint: re-run with sudo, or install with a Node version manager (nvm/fnm/volta).');
459
+ log(formatSelfUpdatePermissionHint({ manager, platform }));
444
460
  }
445
461
  return 1;
446
462
  }
447
463
  if (typeof result.status === 'number' && result.status !== 0) {
464
+ log(`self-update failed: ${installCmd} exited with code ${result.status}.`);
465
+ const stderr = result.stderr ? result.stderr.toString('utf8') : '';
466
+ if (manager === 'npm' || isPermissionErrorText(stderr)) {
467
+ log(formatSelfUpdatePermissionHint({ manager, platform }));
468
+ }
448
469
  return result.status;
449
470
  }
450
471
  clearState(statePath);
451
- console.error('Updated. Run `sogni-agent --whats-new` to see what changed.');
472
+ log('Updated. Run `sogni-agent --whats-new` to see what changed.');
452
473
  return 0;
453
474
  }
package/version.mjs CHANGED
@@ -1 +1 @@
1
- export const PACKAGE_VERSION = '3.6.1';
1
+ export const PACKAGE_VERSION = '3.6.3';