@sogni-ai/sogni-creative-agent-skill 3.17.2 → 3.18.1
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/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/CHANGELOG.md +12 -12
- package/README.md +9 -2
- package/SKILL.md +7 -2
- package/desktop-extension/manifest.json +1 -1
- package/desktop-extension/server/tools.mjs +3 -1
- package/llm.txt +5 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +2 -1
- package/plugin-skills/sogni-creative-agent/SKILL.md +2 -1
- package/references/models.md +25 -2
- package/references/openclaw-config.md +4 -0
- package/references/video-editing.md +12 -3
- package/sogni-agent.mjs +52 -8
- package/sogni-app-id.mjs +138 -0
- package/sogni-hosted-client.mjs +2 -1
- package/version.mjs +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sogni-creative-agent",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.18.1",
|
|
4
4
|
"description": "Sogni Creative Agent: image, video, and music generation via Sogni AI's decentralized GPU network. Supports personas, persistent memories, style transfer, and multi-step creative workflows.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Sogni AI",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
# [3.18.1](https://github.com/Sogni-AI/sogni-creative-agent-skill/compare/v3.18.0...v3.18.1) (2026-07-28)
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
### Bug Fixes
|
|
5
5
|
|
|
6
|
-
* **
|
|
6
|
+
* **cli:** persist one recognizable `sogni-agent-<uuid>` application ID across SDK sessions to prevent repeated CLI runs from exhausting the per-address app-ID allowance ([#25](https://github.com/Sogni-AI/sogni-creative-agent-skill/issues/25))
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
# [3.18.0](https://github.com/Sogni-AI/sogni-creative-agent-skill/compare/v3.17.2...v3.18.0) (2026-07-27)
|
|
9
9
|
|
|
10
|
-
### Fixed
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
coverage is determined by `paymentModel: "subscription"` or explicit subscription-billing success.
|
|
14
|
-
* **video:** use an already-compatible local LTX/10Eros reference as the implicit i2v canvas, avoiding
|
|
15
|
-
misleading intermediate dimension adjustments and no-op resize messages.
|
|
11
|
+
### Features
|
|
16
12
|
|
|
17
|
-
|
|
13
|
+
* **video:** default first/last-frame pairs to LTX-2.3 morph ([#24](https://github.com/Sogni-AI/sogni-creative-agent-skill/issues/24)) ([430edf5](https://github.com/Sogni-AI/sogni-creative-agent-skill/commit/430edf58e1d1be1f757824e586a5ba7ef18764fe))
|
|
18
14
|
|
|
15
|
+
## [3.17.2](https://github.com/Sogni-AI/sogni-creative-agent-skill/compare/v3.17.1...v3.17.2) (2026-07-26)
|
|
19
16
|
|
|
20
17
|
### Bug Fixes
|
|
21
18
|
|
|
22
|
-
* **
|
|
23
|
-
|
|
19
|
+
* **billing:** clarify that `tokenType: "spark"` is a denomination rather than proof of a Spark debit;
|
|
20
|
+
Unlimited coverage is determined by `paymentModel: "subscription"` or explicit subscription-billing
|
|
21
|
+
success ([d836b49](https://github.com/Sogni-AI/sogni-creative-agent-skill/commit/d836b490bccda5c9e8166b2bb3d928708d2fbae4)).
|
|
22
|
+
* **video:** use an already-compatible local LTX/10Eros reference as the implicit i2v canvas, avoiding
|
|
23
|
+
misleading intermediate dimension adjustments and no-op resize messages
|
|
24
|
+
([d836b49](https://github.com/Sogni-AI/sogni-creative-agent-skill/commit/d836b490bccda5c9e8166b2bb3d928708d2fbae4)).
|
|
24
25
|
|
|
25
26
|
## [3.17.1](https://github.com/Sogni-AI/sogni-creative-agent-skill/compare/v3.17.0...v3.17.1) (2026-07-26)
|
|
26
27
|
|
|
27
|
-
|
|
28
28
|
### Bug Fixes
|
|
29
29
|
|
|
30
30
|
* **scripts:** refuse runtime sync on intelligence-client version mismatch ([247da8c](https://github.com/Sogni-AI/sogni-creative-agent-skill/commit/247da8c9cb7b6f0575a25543847ca00f44929c0a))
|
package/README.md
CHANGED
|
@@ -346,6 +346,8 @@ Defaults live under `~/.config/sogni/` for credentials, last-render metadata, pe
|
|
|
346
346
|
| Variable | Purpose |
|
|
347
347
|
|----------|---------|
|
|
348
348
|
| `SOGNI_CREDENTIALS_PATH` | Custom credentials file |
|
|
349
|
+
| `SOGNI_APP_ID` | Stable app ID override for ephemeral/container homes (generated default: `sogni-agent-<uuid>`) |
|
|
350
|
+
| `SOGNI_APP_ID_PATH` | Persistent app ID file (default: `~/.config/sogni/app-id`) |
|
|
349
351
|
| `SOGNI_LAST_RENDER_PATH` | Where last-render state is persisted |
|
|
350
352
|
| `SOGNI_MODEL_CATALOG_URL` | Model catalog API base URL (default: `https://api.sogni.ai/v1/model-catalog`) |
|
|
351
353
|
| `SOGNI_MODEL_CATALOG_CACHE_PATH` | Base path for the five-minute model catalog caches and ETags |
|
|
@@ -401,9 +403,14 @@ sogni-agent --video -m seedance2 --workflow t2v \
|
|
|
401
403
|
--ref-audio https://cdn.example.com/music.m4a \
|
|
402
404
|
"Use @Image1 for product identity, @Video1 for camera movement, and @Audio1 for music rhythm"
|
|
403
405
|
|
|
404
|
-
# Image-to-video (i2v)
|
|
406
|
+
# Image-to-video (i2v; defaults to wan_v2.2-14b-fp8_i2v_lightx2v)
|
|
405
407
|
sogni-agent --video --ref cat.jpg "gentle camera pan"
|
|
406
408
|
|
|
409
|
+
# Animate two images together (first frame → last frame; defaults to
|
|
410
|
+
# ltx23-22b-fp8_i2v_distilled with the auto-applied transition/morph LoRA)
|
|
411
|
+
sogni-agent --video --ref first.png --ref-end last.png \
|
|
412
|
+
"the opening frame flows smoothly into the final frame"
|
|
413
|
+
|
|
407
414
|
# Image+audio-to-video (auto-routes to LTX-2.3 ia2v)
|
|
408
415
|
sogni-agent --video --ref cover.jpg --ref-audio song.mp3 \
|
|
409
416
|
"music video with synchronized motion"
|
|
@@ -587,7 +594,7 @@ Music generation uses `--music` and outputs `mp3` by default. `--audio` remains
|
|
|
587
594
|
- Use `--target-resolution <px>` for bare resolution requests like "720p" — it targets the short side and preserves the inherited aspect ratio.
|
|
588
595
|
- Natural-language aspect requests like "portrait", "square", "16:9", or "9:16" are inferred when width/height aren't explicitly set. Combined requests like "720p 9:16" keep the requested short side while applying the requested shape.
|
|
589
596
|
- For i2v (and any workflow using `--ref` / `--ref-end`), the client wrapper resizes the reference image with strict aspect-fit (`fit: inside`) and uses the *resized* dimensions as the final video size. Because that resize uses rounding, a "valid" requested size can still produce an invalid final size (example: `1024×1536` requested, but ref becomes `1024×1535`). `sogni-agent` detects this for local refs and auto-adjusts to a nearby safe size.
|
|
590
|
-
- **LTX-2.3 two-keyframe morph:** when the LTX-2.3 i2v model `ltx23-22b-fp8_i2v_distilled` gets **both** a start frame (`--ref`) and an end frame (`--ref-end`), it auto-applies the ValiantCat transition/morph LoRA (lora id `transition`, trigger word `zhuanchang`, strength ~1.0) and morphs the first image into the last in a single render — no bridge clip or `--concat-videos` needed. The sogni-client SDK example feeds the two frames as its `image` / `end-image` arguments and additionally exposes manual `transition` / `transition-strength` SDK arguments.
|
|
597
|
+
- **LTX-2.3 two-keyframe morph (the default for `--ref` + `--ref-end` when no `-m` is given):** when the LTX-2.3 i2v model `ltx23-22b-fp8_i2v_distilled` gets **both** a start frame (`--ref`) and an end frame (`--ref-end`), it auto-applies the ValiantCat transition/morph LoRA (lora id `transition`, trigger word `zhuanchang`, strength ~1.0) and morphs the first image into the last in a single render — no bridge clip or `--concat-videos` needed. The sogni-client SDK example feeds the two frames as its `image` / `end-image` arguments and additionally exposes manual `transition` / `transition-strength` SDK arguments.
|
|
591
598
|
- **Private mature-theme creativity:** optional uncensored LTX-2.3 video models are available for adults who explicitly want them. They remain opt-in and are not part of ordinary model recommendations; the agent loads their specialized guidance only for a relevant request.
|
|
592
599
|
- Pass `--strict-size` to fail instead — the script will print a suggested size.
|
|
593
600
|
|
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 one-click image-folder loop reels, 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\", \"turn this image folder into a loop\", \"make music\", \"apply a style\", or \"generate me as a superhero\"."
|
|
4
4
|
metadata:
|
|
5
|
-
version: "3.
|
|
5
|
+
version: "3.18.1"
|
|
6
6
|
homepage: https://sogni.ai
|
|
7
7
|
openclaw:
|
|
8
8
|
emoji: "🎨"
|
|
@@ -94,6 +94,7 @@ sogni-agent -o /tmp/cat.png "a cat wearing a hat" # ✗ avoid — user can't
|
|
|
94
94
|
## Filesystem Paths and Overrides
|
|
95
95
|
|
|
96
96
|
- API key credentials file (read): `~/.config/sogni/credentials` (`SOGNI_CREDENTIALS_PATH`)
|
|
97
|
+
- Reusable installation app ID (read/write): `~/.config/sogni/app-id`; new IDs use `sogni-agent-<uuid>` (`SOGNI_APP_ID_PATH`; set a stable `SOGNI_APP_ID` value instead for ephemeral/container homes)
|
|
97
98
|
- Last render metadata (read/write): `~/.config/sogni/last-render.json` (`SOGNI_LAST_RENDER_PATH`)
|
|
98
99
|
- Model catalog: `https://api.sogni.ai/v1/model-catalog` (`SOGNI_MODEL_CATALOG_URL`)
|
|
99
100
|
- Model catalog cache (read/write, 5-minute TTL with ETag revalidation for model parameters and discovery): `~/.config/sogni/model-catalog-cache.json` (`SOGNI_MODEL_CATALOG_CACHE_PATH`)
|
|
@@ -144,8 +145,11 @@ sogni-agent -q -c /path/to/input.jpg -o ./edited.png "make it pop art style"
|
|
|
144
145
|
sogni-agent -q --photobooth --ref /path/to/face.jpg -o ./stylized.png "80s fashion portrait"
|
|
145
146
|
|
|
146
147
|
# Text-to-video / image-to-video (write the prompt per references/video-prompting.md)
|
|
148
|
+
# Single-image i2v defaults to wan_v2.2-14b-fp8_i2v_lightx2v; adding --ref-end
|
|
149
|
+
# defaults to ltx23-22b-fp8_i2v_distilled (transition/morph LoRA auto-applies).
|
|
147
150
|
sogni-agent -q --video -o ./video.mp4 "<cinematic prose paragraph>"
|
|
148
151
|
sogni-agent -q --video --ref /path/to/image.png -o ./video.mp4 "<cinematic prose paragraph>"
|
|
152
|
+
sogni-agent -q --video --ref ./first.png --ref-end ./last.png -o ./morph.mp4 "<LTX transition paragraph>"
|
|
149
153
|
|
|
150
154
|
# Sound-to-video (lip-sync), image+audio, audio-only (workflow auto-inferred)
|
|
151
155
|
sogni-agent --video --ref face.jpg --ref-audio speech.m4a -m wan_v2.2-14b-fp8_s2v_lightx2v "lip sync talking head"
|
|
@@ -239,7 +243,7 @@ For "4k" / "uhd" requests where the user accepts the Premium Spark vendor path o
|
|
|
239
243
|
|
|
240
244
|
### Video editing, stitching, 360 turnarounds
|
|
241
245
|
|
|
242
|
-
Trigger patterns — "animate/morph image A to image B" (`--ref A --ref-end B
|
|
246
|
+
Trigger patterns — "animate/morph image A to image B" or any first-frame/last-frame request (`--ref A --ref-end B` — defaults to `ltx23-22b-fp8_i2v_distilled`, a single render whose transition/morph LoRA auto-applies, no bridge clip; single-image i2v defaults to `wan_v2.2-14b-fp8_i2v_lightx2v`), "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.**
|
|
243
247
|
|
|
244
248
|
For a **one-click polished folder loop** where each source image animates and then morphs directly into the next original image, read [`references/loop-maker.md`](./references/loop-maker.md). Use its visually deduplicated, one-LTX-clip-per-pair workflow instead of the default SourceReel split animation-plus-bridge structure. Do not route true 360 novel-view synthesis to this direct pairwise workflow: a turning subject or occluder wipe is not a camera orbit. Trigger on requests such as "Sogni Loop Maker", "make this image folder a seamless loop", "one-click animated photo reel", the Claude Code command `/sogni-creative-agent:loop-maker`, or the Codex skill `$sogni-creative-agent:loop-maker`.
|
|
245
249
|
|
|
@@ -332,6 +336,7 @@ Eligible Sogni-hosted renders use Unlimited coverage when active; otherwise rend
|
|
|
332
336
|
|
|
333
337
|
- **Anything broken?** Run `sogni-agent doctor` first — it checks Node, credentials (and file permissions), config-dir writability, ffmpeg, live auth, and version freshness, with a fix in every failure detail.
|
|
334
338
|
- **Auth errors:** check `SOGNI_API_KEY` or `~/.config/sogni/credentials` (key from https://dashboard.sogni.ai, account menu).
|
|
339
|
+
- **Error 4061 / too many app IDs:** the CLI persists and reuses `~/.config/sogni/app-id`. Do not delete it between runs. For ephemeral/container homes, set the same `SOGNI_APP_ID` on every session or persist `SOGNI_APP_ID_PATH`. App IDs already registered today remain counted until 00:00 UTC, so an existing block may require waiting for that reset once after upgrading.
|
|
335
340
|
- **Video size errors:** sizes are model-specific (WAN ÷16 min 480 max 1536; LTX ÷64, long side ≤2048). The CLI auto-adjusts for local refs; `--strict-size` makes it fail with a suggested size instead. Details in [`references/models.md`](./references/models.md).
|
|
336
341
|
- **Timeouts:** try a faster model or raise `-t`.
|
|
337
342
|
- **No workers:** check https://sogni.ai for network status.
|
|
@@ -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.
|
|
5
|
+
"version": "3.18.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",
|
|
@@ -73,7 +73,9 @@ export const TOOLS = [
|
|
|
73
73
|
name: 'generate_video',
|
|
74
74
|
description:
|
|
75
75
|
'Generate a video from a text prompt, optionally driven by reference media. ' +
|
|
76
|
-
'ref = start frame image
|
|
76
|
+
'ref = start frame image (alone defaults to wan_v2.2-14b-fp8_i2v_lightx2v), ' +
|
|
77
|
+
'ref_end = end frame (with ref, defaults to ltx23-22b-fp8_i2v_distilled and its auto-applied transition/morph LoRA), ' +
|
|
78
|
+
'ref_audio = soundtrack/lip-sync audio, ref_video = motion reference. ' +
|
|
77
79
|
'Rendering takes minutes; prefer output_path (absolute .mp4). ' + CHAT_ATTACHMENT_NOTE,
|
|
78
80
|
inputSchema: {
|
|
79
81
|
type: 'object',
|
package/llm.txt
CHANGED
|
@@ -74,6 +74,11 @@ chmod 600 ~/.config/sogni/credentials
|
|
|
74
74
|
You can also export `SOGNI_API_KEY` instead of writing the file. Confirm with
|
|
75
75
|
`sogni-agent doctor`.
|
|
76
76
|
|
|
77
|
+
The CLI creates `~/.config/sogni/app-id` once and reuses that installation ID
|
|
78
|
+
for every SDK connection. Preserve that file between sessions. In ephemeral
|
|
79
|
+
containers, set one stable `SOGNI_APP_ID` value or mount a persistent
|
|
80
|
+
`SOGNI_APP_ID_PATH`; changing it on each run can trigger Sogni error 4061.
|
|
81
|
+
|
|
77
82
|
## Hosted API modes (require SOGNI_API_KEY)
|
|
78
83
|
|
|
79
84
|
- `sogni-agent --api-chat "prompt"` — `/v1/chat/completions` with hosted
|
package/openclaw.plugin.json
CHANGED
|
@@ -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.
|
|
5
|
+
"version": "3.18.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.
|
|
3
|
+
"version": "3.18.1",
|
|
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",
|
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
"openclaw.plugin.json",
|
|
80
80
|
"env.mjs",
|
|
81
81
|
"ssrf-guard.mjs",
|
|
82
|
+
"sogni-app-id.mjs",
|
|
82
83
|
"sogni-hosted-client.mjs",
|
|
83
84
|
"update-check.mjs",
|
|
84
85
|
"node-version-check.mjs",
|
|
@@ -22,7 +22,8 @@ Do not run the default `npx setup-sogni-agent-skill` from an installed plugin un
|
|
|
22
22
|
|
|
23
23
|
- Image: `sogni-agent "a cat on the moon, cinematic"`
|
|
24
24
|
- Image edit: `sogni-agent -c <path> "make it night, add fireflies"`
|
|
25
|
-
- Video (image-to-video): `sogni-agent --video --ref <path> "gentle camera pan"`
|
|
25
|
+
- Video (image-to-video): `sogni-agent --video --ref <path> "gentle camera pan"` (defaults to `wan_v2.2-14b-fp8_i2v_lightx2v`)
|
|
26
|
+
- Animate two images (first frame → last frame): `sogni-agent --video --ref <first> --ref-end <last> "smooth morph into the final frame"` (defaults to `ltx23-22b-fp8_i2v_distilled`; the transition/morph LoRA auto-applies)
|
|
26
27
|
- One-click image-folder loop: `/sogni-creative-agent:loop-maker ./images`
|
|
27
28
|
- One-click image-folder loop in Codex: `$sogni-creative-agent:loop-maker ./images`
|
|
28
29
|
- Music: `sogni-agent --music "ambient drone, 30 seconds"`
|
package/references/models.md
CHANGED
|
@@ -104,7 +104,7 @@ direct music generation. Music controls: `--lyrics`, `--language`, `--bpm`
|
|
|
104
104
|
| Model | Speed | Use Case |
|
|
105
105
|
|-------|-------|----------|
|
|
106
106
|
| `ltx23-22b-fp8_t2v_distilled` | Fast (~2-3min) | Default text-to-video with native dialogue/audio |
|
|
107
|
-
| `ltx23-22b-fp8_i2v_distilled` | Fast (~2-3min) | Image-to-video with native dialogue/audio |
|
|
107
|
+
| `ltx23-22b-fp8_i2v_distilled` | Fast (~2-3min) | Image-to-video with native dialogue/audio; **default for two-image first-frame → last-frame animation** (transition/morph LoRA auto-applies) |
|
|
108
108
|
| `ltx23-22b-fp8_ia2v_distilled` | Fast (~2-3min) | Image+audio-to-video |
|
|
109
109
|
| `ltx23-22b-fp8_a2v_distilled` | Fast (~2-3min) | Audio-to-video |
|
|
110
110
|
| `ltx23-22b-fp8_v2v_distilled` | Fast (~3min) | Video-to-video with ControlNet, plus canvas outpaint and masked inpaint |
|
|
@@ -117,13 +117,34 @@ direct music generation. Music controls: `--lyrics`, `--language`, `--bpm`
|
|
|
117
117
|
| `happyhorse-1.1-t2v` | Variable | HappyHorse 1.1 text-to-video, 3-15s, native audio, 720P/1080P |
|
|
118
118
|
| `happyhorse-1.1-i2v` | Variable | HappyHorse 1.1 image-to-video from one first-frame image (`--ref`) |
|
|
119
119
|
| `happyhorse-1.1-r2v` | Variable | HappyHorse 1.1 reference-to-video from 1-9 reference images (`-c`/`--context`) |
|
|
120
|
-
| `wan_v2.2-14b-fp8_i2v_lightx2v` | Fast |
|
|
120
|
+
| `wan_v2.2-14b-fp8_i2v_lightx2v` | Fast | **Default single-image image-to-video** (one `--ref`, no end frame) |
|
|
121
121
|
| `wan_v2.2-14b-fp8_i2v` | Slow | Higher quality video |
|
|
122
122
|
| `wan_v2.2-14b-fp8_t2v_lightx2v` | Fast | Text-to-video |
|
|
123
123
|
| `wan_v2.2-14b-fp8_s2v_lightx2v` | Fast | Face lip-sync with uploaded audio |
|
|
124
124
|
| `wan_v2.2-14b-fp8_animate-move_lightx2v` | Fast | Animate-move |
|
|
125
125
|
| `wan_v2.2-14b-fp8_animate-replace_lightx2v` | Fast | Animate-replace |
|
|
126
126
|
|
|
127
|
+
### Default image-to-video routing
|
|
128
|
+
|
|
129
|
+
- **Single-image i2v** (`--ref` only, no `-m`) defaults to
|
|
130
|
+
`wan_v2.2-14b-fp8_i2v_lightx2v`. Keep that default for plain "animate this
|
|
131
|
+
image" requests. The CLI auto-routes single-image i2v to
|
|
132
|
+
`ltx23-22b-fp8_i2v_distilled` only when the prompt calls for native audio
|
|
133
|
+
(quoted dialogue; words like audio, music, sound, speech, sings) or reads
|
|
134
|
+
as story direction (story, scene, script, narrative, commercial), or when
|
|
135
|
+
`-Q hq`/`-Q pro` is set — WAN clips render silent. If the prompt must
|
|
136
|
+
contain such words but the WAN path is still wanted, pin it explicitly
|
|
137
|
+
with `-m wan_v2.2-14b-fp8_i2v_lightx2v`.
|
|
138
|
+
- **Two-image first-frame → last-frame animation** (`--ref` + `--ref-end`,
|
|
139
|
+
no `-m`) defaults to `ltx23-22b-fp8_i2v_distilled`: the transition/morph
|
|
140
|
+
LoRA auto-attaches (trigger `zhuanchang`) and morphs the first image into
|
|
141
|
+
the end image in a single render. Use this default whenever the user asks
|
|
142
|
+
to animate two images together or supplies a first and last frame. Pass
|
|
143
|
+
`-m wan_v2.2-14b-fp8_i2v_lightx2v` only when the user explicitly wants the
|
|
144
|
+
WAN path (silent clip, no transition LoRA).
|
|
145
|
+
- A configured `videoModels.i2v` (OpenClaw plugin config) overrides both
|
|
146
|
+
defaults.
|
|
147
|
+
|
|
127
148
|
## HappyHorse 1.1 models
|
|
128
149
|
|
|
129
150
|
Alibaba HappyHorse 1.1 is a Premium-Spark vendor video family (three discrete
|
|
@@ -219,6 +240,8 @@ model recommendations.
|
|
|
219
240
|
| Direct music generation | `ace_step_1.5_xl_turbo` (or `--music-model turbo`) |
|
|
220
241
|
| Music with stronger lyric handling | `ace_step_1.5_xl_sft` (or `--music-model sft`) |
|
|
221
242
|
| Text-to-video with native dialogue/audio | `ltx23-22b-fp8_t2v_distilled` |
|
|
243
|
+
| Image-to-video from one start frame (default) | `wan_v2.2-14b-fp8_i2v_lightx2v` |
|
|
244
|
+
| Animate two images together (first frame → last frame) | `ltx23-22b-fp8_i2v_distilled` with `--ref A --ref-end B` (transition/morph LoRA auto-applies) |
|
|
222
245
|
| Image+audio-to-video | `ltx23-22b-fp8_ia2v_distilled` |
|
|
223
246
|
| Audio-to-video | `ltx23-22b-fp8_a2v_distilled` |
|
|
224
247
|
| Video-to-video with ControlNet | `ltx23-22b-fp8_v2v_distilled` |
|
|
@@ -70,6 +70,10 @@ CLI defaults are 512×512 images, count 1, spark tokens, prompt-hash seeds):
|
|
|
70
70
|
Notes:
|
|
71
71
|
|
|
72
72
|
- Seed strategies: `prompt-hash` (deterministic) or `random`.
|
|
73
|
+
- `videoModels.i2v` also governs two-image `--ref` + `--ref-end` renders:
|
|
74
|
+
when set, it overrides the built-in LTX-2.3 transition/morph default
|
|
75
|
+
(`ltx23-22b-fp8_i2v_distilled`) that otherwise applies to first/last-frame
|
|
76
|
+
pairs. Unset, single-image i2v defaults to `wan_v2.2-14b-fp8_i2v_lightx2v`.
|
|
73
77
|
- `defaultCount` is clamped to the CLI's safety cap (16 unless raised with
|
|
74
78
|
`SOGNI_MAX_COUNT`).
|
|
75
79
|
- `mediaInboundDir` defaults to `~/.openclaw/media/inbound`; when unset and
|
|
@@ -15,9 +15,17 @@ reproducible results and are the only sanctioned file operations.
|
|
|
15
15
|
When a user asks to **animate between two images**, use `--ref` (first frame) and `--ref-end` (last frame):
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
sogni-agent -q --video --ref ./imageA.png --ref-end ./imageB.png -o ./transition.mp4 "
|
|
18
|
+
sogni-agent -q --video --ref ./imageA.png --ref-end ./imageB.png -o ./transition.mp4 "<4-8 sentence LTX transition paragraph>"
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
+
**Default model:** with both `--ref` and `--ref-end` set and no `-m`, the CLI
|
|
22
|
+
defaults to `ltx23-22b-fp8_i2v_distilled` — the LTX-2.3 transition/morph path
|
|
23
|
+
described in the callout below — so write the prompt as an LTX paragraph per
|
|
24
|
+
[`video-prompting.md`](video-prompting.md). Pass
|
|
25
|
+
`-m wan_v2.2-14b-fp8_i2v_lightx2v` only when the user explicitly wants the
|
|
26
|
+
WAN path (silent clip, no transition LoRA). Plain single-image i2v (one
|
|
27
|
+
`--ref`, no end frame) defaults to `wan_v2.2-14b-fp8_i2v_lightx2v` instead.
|
|
28
|
+
|
|
21
29
|
**Always apply this pattern when:**
|
|
22
30
|
- User says "animate image A to image B" → use `--ref A --ref-end B`
|
|
23
31
|
- User says "animate this video to this image" → extract last frame, use as `--ref`, target image as `--ref-end`, then stitch
|
|
@@ -45,8 +53,9 @@ sogni-agent -q --video --ref ./imageA.png --ref-end ./imageB.png -o ./transition
|
|
|
45
53
|
```
|
|
46
54
|
2. **Generate a new video** using the last frame as `--ref` and the target image as `--ref-end`:
|
|
47
55
|
```bash
|
|
48
|
-
sogni-agent -q --video --ref ./lastframe.png --ref-end ./target.png -o ./continuation.mp4 "
|
|
56
|
+
sogni-agent -q --video --ref ./lastframe.png --ref-end ./target.png -o ./continuation.mp4 "<4-8 sentence LTX transition paragraph into the target image>"
|
|
49
57
|
```
|
|
58
|
+
(No `-m` needed — the two-frame default is `ltx23-22b-fp8_i2v_distilled` with the auto-applied transition/morph LoRA.)
|
|
50
59
|
3. **Concatenate the videos**:
|
|
51
60
|
```bash
|
|
52
61
|
sogni-agent --concat-videos ./full_sequence.mp4 ./existing.mp4 ./continuation.mp4
|
|
@@ -74,7 +83,7 @@ To **create a transition between two existing videos** (A → B), bridge them wi
|
|
|
74
83
|
```bash
|
|
75
84
|
sogni-agent -q --video -m wan_v2.2-14b-fp8_i2v_lightx2v \
|
|
76
85
|
--ref ./A_last.png --ref-end ./B_first.png --fps 24 \
|
|
77
|
-
-o ./transition.mp4 "descriptive morph between the two
|
|
86
|
+
-o ./transition.mp4 "descriptive morph between the two shots"
|
|
78
87
|
```
|
|
79
88
|
3. Concatenate A → transition → B:
|
|
80
89
|
```bash
|
package/sogni-agent.mjs
CHANGED
|
@@ -16,6 +16,7 @@ import { join, dirname, basename, extname, sep, resolve } from 'path';
|
|
|
16
16
|
import { homedir, tmpdir } from 'os';
|
|
17
17
|
import sharp from 'sharp';
|
|
18
18
|
import { getEnv, hasEnv } from './env.mjs';
|
|
19
|
+
import { getOrCreateSogniAppId } from './sogni-app-id.mjs';
|
|
19
20
|
import { PACKAGE_VERSION } from './version.mjs';
|
|
20
21
|
import { assertSafeUrl, fetchSafeUrl } from './ssrf-guard.mjs';
|
|
21
22
|
import {
|
|
@@ -120,6 +121,9 @@ const KNOWN_MODEL_CATALOG_TAGS = new Set([
|
|
|
120
121
|
// covered job that cannot bill. Codes are the source of truth in
|
|
121
122
|
// sogni-socket/constants/errorCodes.js (4078-4081).
|
|
122
123
|
const SUBSCRIPTION_BILLING_ERROR_CODES = new Set(['4078', '4079', '4080', '4081']);
|
|
124
|
+
const APP_ID_LIMIT_ERROR_CODE = '4061';
|
|
125
|
+
const APP_ID_LIMIT_HINT =
|
|
126
|
+
'This CLI now persists and reuses one installation app ID. Keep ~/.config/sogni/app-id between sessions; for ephemeral/container homes, set one stable SOGNI_APP_ID or persist SOGNI_APP_ID_PATH. App IDs already registered from this address remain counted until 00:00 UTC, so wait for the next UTC reset once if the address is already blocked.';
|
|
123
127
|
|
|
124
128
|
function subscriptionBillingFallback(code) {
|
|
125
129
|
if (code === undefined || code === null) return null;
|
|
@@ -191,6 +195,24 @@ function subscriptionBillingCodeFromError(error) {
|
|
|
191
195
|
?? record.payload?.error_code;
|
|
192
196
|
}
|
|
193
197
|
|
|
198
|
+
function isAppIdLimitError(error) {
|
|
199
|
+
if (!error) return false;
|
|
200
|
+
const code = error.code
|
|
201
|
+
?? error.errorCode
|
|
202
|
+
?? error.error_code
|
|
203
|
+
?? error.payload?.errorCode
|
|
204
|
+
?? error.payload?.error_code;
|
|
205
|
+
if (String(code) === APP_ID_LIMIT_ERROR_CODE) return true;
|
|
206
|
+
const message = `${error.message || ''} ${error.reason || ''} ${error.payload?.message || ''}`.toLowerCase();
|
|
207
|
+
return message.includes('too many app-ids') || message.includes('too many app ids');
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function enrichAppIdLimitError(error) {
|
|
211
|
+
if (!isAppIdLimitError(error)) return;
|
|
212
|
+
error.code = APP_ID_LIMIT_ERROR_CODE;
|
|
213
|
+
if (!error.hint) error.hint = APP_ID_LIMIT_HINT;
|
|
214
|
+
}
|
|
215
|
+
|
|
194
216
|
const require = createRequire(import.meta.url);
|
|
195
217
|
const rootClientModule = process.env.SOGNI_AGENT_TEST_STATE_PATH
|
|
196
218
|
? await import('@sogni-ai/sogni-intelligence-client')
|
|
@@ -855,6 +877,7 @@ function reportFatalError(error) {
|
|
|
855
877
|
if (getEnv('SOGNI_DEBUG') || getEnv('DEBUG')) {
|
|
856
878
|
console.error(error?.stack || String(error));
|
|
857
879
|
}
|
|
880
|
+
enrichAppIdLimitError(error);
|
|
858
881
|
if (isInvalidApiKeyError(error)) {
|
|
859
882
|
fatalCliError('Invalid Sogni API key.', {
|
|
860
883
|
code: 'INVALID_API_KEY',
|
|
@@ -878,6 +901,7 @@ async function connectSogniClient(client) {
|
|
|
878
901
|
try {
|
|
879
902
|
await client.connect();
|
|
880
903
|
} catch (error) {
|
|
904
|
+
enrichAppIdLimitError(error);
|
|
881
905
|
if (isInvalidApiKeyError(error) && !error.hint) {
|
|
882
906
|
error.hint = INVALID_API_KEY_HINT;
|
|
883
907
|
if (!error.code) error.code = 'INVALID_API_KEY';
|
|
@@ -3228,7 +3252,9 @@ Video Options:
|
|
|
3228
3252
|
--no-auto-resize-assets Disable auto-resize for video assets
|
|
3229
3253
|
--estimate-video-cost Estimate video cost and exit
|
|
3230
3254
|
--ref <path|url> Reference image for video (start/first frame on Seedance)
|
|
3231
|
-
--ref-end <path|url> End frame for interpolation/morphing
|
|
3255
|
+
--ref-end <path|url> End frame for interpolation/morphing; with --ref it
|
|
3256
|
+
defaults to the LTX-2.3 transition/morph model
|
|
3257
|
+
(last frame on Seedance)
|
|
3232
3258
|
--ref-audio <path|url> Audio reference. Repeatable on Seedance models (up to 3 total);
|
|
3233
3259
|
first entry is the primary, extras must be HTTPS URLs in CLI
|
|
3234
3260
|
direct-gen (use --api-chat for multi local-file uploads).
|
|
@@ -3398,7 +3424,7 @@ Image Models:
|
|
|
3398
3424
|
|
|
3399
3425
|
Recommended LTX 2.3 Video Models:
|
|
3400
3426
|
ltx23-22b-fp8_t2v_distilled Text-to-video with native dialogue/audio
|
|
3401
|
-
ltx23-22b-fp8_i2v_distilled Image-to-video with native dialogue/audio
|
|
3427
|
+
ltx23-22b-fp8_i2v_distilled Image-to-video with native dialogue/audio; default for --ref + --ref-end pairs
|
|
3402
3428
|
ltx23-22b-fp8_ia2v_distilled Image+audio-to-video
|
|
3403
3429
|
ltx23-22b-fp8_a2v_distilled Audio-to-video
|
|
3404
3430
|
ltx23-22b-fp8_v2v_distilled Video-to-video with ControlNet
|
|
@@ -3424,7 +3450,7 @@ HappyHorse 1.1 Video Model Selectors (3-15s, fixed 24fps, native audio, 720P/108
|
|
|
3424
3450
|
|
|
3425
3451
|
WAN 2.2 Video Models:
|
|
3426
3452
|
wan_v2.2-14b-fp8_t2v_lightx2v Text-to-video (fast)
|
|
3427
|
-
wan_v2.2-14b-fp8_i2v_lightx2v
|
|
3453
|
+
wan_v2.2-14b-fp8_i2v_lightx2v Default single-image image-to-video (fast)
|
|
3428
3454
|
wan_v2.2-14b-fp8_i2v Higher quality
|
|
3429
3455
|
wan_v2.2-14b-fp8_s2v_lightx2v Face lip-sync with uploaded audio (fast)
|
|
3430
3456
|
wan_v2.2-14b-fp8_s2v Sound-to-video (quality)
|
|
@@ -4030,7 +4056,21 @@ if (options.music) {
|
|
|
4030
4056
|
options.timeout = 600000;
|
|
4031
4057
|
}
|
|
4032
4058
|
} else if (options.video) {
|
|
4033
|
-
|
|
4059
|
+
if (!options.model) {
|
|
4060
|
+
let defaultVideoModel = selectDefaultVideoModel(options.videoWorkflow, options, openclawConfig);
|
|
4061
|
+
// Two-image first/last-frame animation defaults to the LTX-2.3 i2v morph
|
|
4062
|
+
// path (transition LoRA auto-applies); a configured videoModels.i2v or an
|
|
4063
|
+
// LTX pick from audio/quality routing still wins.
|
|
4064
|
+
if (
|
|
4065
|
+
options.videoWorkflow === 'i2v'
|
|
4066
|
+
&& options.refImage && options.refImageEnd
|
|
4067
|
+
&& !openclawConfig?.videoModels?.i2v
|
|
4068
|
+
&& !isLtx2Model(defaultVideoModel)
|
|
4069
|
+
) {
|
|
4070
|
+
defaultVideoModel = 'ltx23-22b-fp8_i2v_distilled';
|
|
4071
|
+
}
|
|
4072
|
+
options.model = defaultVideoModel || 'wan_v2.2-14b-fp8_i2v_lightx2v';
|
|
4073
|
+
}
|
|
4034
4074
|
options.model = resolveVideoModelAlias(options.model, options.videoWorkflow);
|
|
4035
4075
|
try {
|
|
4036
4076
|
await loadLiveModelDefaults(options.model);
|
|
@@ -4955,7 +4995,7 @@ async function dispatchWorkflowActionViaSdk(action, apiKey, params) {
|
|
|
4955
4995
|
restEndpoint: restBase,
|
|
4956
4996
|
socketEndpoint: process.env.SOGNI_SOCKET_ENDPOINT || undefined,
|
|
4957
4997
|
appSource: SOGNI_APP_SOURCE,
|
|
4958
|
-
appId:
|
|
4998
|
+
appId: getOrCreateSogniAppId(),
|
|
4959
4999
|
},
|
|
4960
5000
|
async (client) => {
|
|
4961
5001
|
if (action === 'list') {
|
|
@@ -5033,7 +5073,7 @@ async function dispatchChatHostedViaSdk(apiKey, body) {
|
|
|
5033
5073
|
restEndpoint: restBase,
|
|
5034
5074
|
socketEndpoint: process.env.SOGNI_SOCKET_ENDPOINT || undefined,
|
|
5035
5075
|
appSource: SOGNI_APP_SOURCE,
|
|
5036
|
-
appId:
|
|
5076
|
+
appId: getOrCreateSogniAppId(),
|
|
5037
5077
|
},
|
|
5038
5078
|
async (client) => helpers.sdkChatHostedCreate(client, body),
|
|
5039
5079
|
);
|
|
@@ -5076,7 +5116,7 @@ async function dispatchMediaReferenceUrlViaSdk({ ref, file, index, jobId, action
|
|
|
5076
5116
|
restEndpoint: restBase,
|
|
5077
5117
|
socketEndpoint: process.env.SOGNI_SOCKET_ENDPOINT || undefined,
|
|
5078
5118
|
appSource: SOGNI_APP_SOURCE,
|
|
5079
|
-
appId:
|
|
5119
|
+
appId: getOrCreateSogniAppId(),
|
|
5080
5120
|
},
|
|
5081
5121
|
async (client) => {
|
|
5082
5122
|
const type = apiMediaReferenceUploadType(ref, index);
|
|
@@ -5864,7 +5904,7 @@ async function runApiChatDurable(log, { apiKey, body }) {
|
|
|
5864
5904
|
restEndpoint: restBase,
|
|
5865
5905
|
socketEndpoint: process.env.SOGNI_SOCKET_ENDPOINT || undefined,
|
|
5866
5906
|
appSource: SOGNI_APP_SOURCE,
|
|
5867
|
-
appId:
|
|
5907
|
+
appId: getOrCreateSogniAppId(),
|
|
5868
5908
|
},
|
|
5869
5909
|
async (client) => {
|
|
5870
5910
|
const created = await helpers.sdkChatRunsCreate(client, runParams);
|
|
@@ -9397,6 +9437,7 @@ async function runDoctor() {
|
|
|
9397
9437
|
try {
|
|
9398
9438
|
doctorClient = new SogniClientWrapper({
|
|
9399
9439
|
appSource: SOGNI_APP_SOURCE,
|
|
9440
|
+
appId: getOrCreateSogniAppId(),
|
|
9400
9441
|
network: openclawConfig?.defaultNetwork || 'fast',
|
|
9401
9442
|
autoConnect: false,
|
|
9402
9443
|
apiKey: creds.SOGNI_API_KEY,
|
|
@@ -9938,6 +9979,7 @@ async function main() {
|
|
|
9938
9979
|
log('Connecting to Sogni...');
|
|
9939
9980
|
client = new SogniClientWrapper({
|
|
9940
9981
|
appSource: SOGNI_APP_SOURCE,
|
|
9982
|
+
appId: getOrCreateSogniAppId(),
|
|
9941
9983
|
network: openclawConfig?.defaultNetwork || 'fast',
|
|
9942
9984
|
autoConnect: false,
|
|
9943
9985
|
apiKey: creds.SOGNI_API_KEY,
|
|
@@ -10895,6 +10937,7 @@ async function main() {
|
|
|
10895
10937
|
const creds = loadCredentials();
|
|
10896
10938
|
const client2 = new SogniClientWrapper({
|
|
10897
10939
|
appSource: SOGNI_APP_SOURCE,
|
|
10940
|
+
appId: getOrCreateSogniAppId(),
|
|
10898
10941
|
network: openclawConfig?.defaultNetwork || 'fast',
|
|
10899
10942
|
autoConnect: false,
|
|
10900
10943
|
apiKey: creds.SOGNI_API_KEY,
|
|
@@ -11102,6 +11145,7 @@ async function main() {
|
|
|
11102
11145
|
if (!error.hint) error.hint = INVALID_API_KEY_HINT;
|
|
11103
11146
|
if (!error.code) error.code = 'INVALID_API_KEY';
|
|
11104
11147
|
}
|
|
11148
|
+
enrichAppIdLimitError(error);
|
|
11105
11149
|
|
|
11106
11150
|
exitCode = 1;
|
|
11107
11151
|
const shouldJson = options.json || IS_OPENCLAW_INVOCATION;
|
package/sogni-app-id.mjs
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Persistent Sogni application identity.
|
|
3
|
+
*
|
|
4
|
+
* Sogni limits how many distinct app IDs may connect from one address each
|
|
5
|
+
* UTC day. An app ID therefore represents an installation, not a process or
|
|
6
|
+
* request. Keep it outside credentials so rotating an API key does not rotate
|
|
7
|
+
* the installation identity.
|
|
8
|
+
*/
|
|
9
|
+
import { randomUUID } from 'node:crypto';
|
|
10
|
+
import {
|
|
11
|
+
closeSync,
|
|
12
|
+
mkdirSync,
|
|
13
|
+
openSync,
|
|
14
|
+
readFileSync,
|
|
15
|
+
unlinkSync,
|
|
16
|
+
writeFileSync,
|
|
17
|
+
} from 'node:fs';
|
|
18
|
+
import { homedir } from 'node:os';
|
|
19
|
+
import { dirname, join } from 'node:path';
|
|
20
|
+
import { getEnv } from './env.mjs';
|
|
21
|
+
|
|
22
|
+
const DEFAULT_APP_ID_PATH = join(homedir(), '.config', 'sogni', 'app-id');
|
|
23
|
+
const GENERATED_APP_ID_PREFIX = 'sogni-agent-';
|
|
24
|
+
const MAX_APP_ID_LENGTH = 256;
|
|
25
|
+
const APP_ID_CREATE_RETRIES = 20;
|
|
26
|
+
const APP_ID_CREATE_RETRY_MS = 5;
|
|
27
|
+
|
|
28
|
+
function expandHomePath(rawPath) {
|
|
29
|
+
if (rawPath === '~') return homedir();
|
|
30
|
+
if (rawPath?.startsWith('~/') || rawPath?.startsWith('~\\')) {
|
|
31
|
+
return join(homedir(), rawPath.slice(2));
|
|
32
|
+
}
|
|
33
|
+
return rawPath;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function validateAppId(value, source) {
|
|
37
|
+
const appId = typeof value === 'string' ? value.trim() : '';
|
|
38
|
+
if (!appId) {
|
|
39
|
+
const error = new Error(`${source} is empty.`);
|
|
40
|
+
error.code = 'INVALID_APP_ID';
|
|
41
|
+
error.hint = 'Set SOGNI_APP_ID to one stable non-empty identifier, or remove the empty app-id file so the CLI can recreate it.';
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
if (appId.length > MAX_APP_ID_LENGTH || /[\x00-\x1f\x7f]/.test(appId)) {
|
|
45
|
+
const error = new Error(`${source} must be at most ${MAX_APP_ID_LENGTH} characters and contain no control characters.`);
|
|
46
|
+
error.code = 'INVALID_APP_ID';
|
|
47
|
+
error.hint = 'Set SOGNI_APP_ID to one stable UUID-style identifier.';
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
return appId;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function waitForConcurrentWriter() {
|
|
54
|
+
// Another process can observe the file in the tiny interval between its
|
|
55
|
+
// exclusive creation and first write. Atomics.wait gives that writer a few
|
|
56
|
+
// milliseconds without introducing an async API into client construction.
|
|
57
|
+
const signal = new Int32Array(new SharedArrayBuffer(4));
|
|
58
|
+
Atomics.wait(signal, 0, 0, APP_ID_CREATE_RETRY_MS);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function readPersistedAppId(appIdPath) {
|
|
62
|
+
return validateAppId(readFileSync(appIdPath, 'utf8'), `Sogni app-id file ${appIdPath}`);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function appIdPersistenceError(error, appIdPath) {
|
|
66
|
+
if (error?.code === 'INVALID_APP_ID') return error;
|
|
67
|
+
const wrapped = new Error(`Could not persist the Sogni app ID at ${appIdPath}: ${error?.message || error}`);
|
|
68
|
+
wrapped.code = 'APP_ID_PERSISTENCE_FAILED';
|
|
69
|
+
wrapped.hint = 'Make that location writable, set SOGNI_APP_ID_PATH to a persistent writable file, or set one stable SOGNI_APP_ID value for every session.';
|
|
70
|
+
return wrapped;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Return the stable app ID for this installation, creating it exactly once.
|
|
75
|
+
*
|
|
76
|
+
* `SOGNI_APP_ID` is an explicit value override for ephemeral/container homes.
|
|
77
|
+
* `SOGNI_APP_ID_PATH` moves the persisted file to a durable mounted location.
|
|
78
|
+
*/
|
|
79
|
+
export function getOrCreateSogniAppId({
|
|
80
|
+
appId = getEnv('SOGNI_APP_ID', { trim: true }),
|
|
81
|
+
appIdPath = getEnv('SOGNI_APP_ID_PATH', { trim: true }) || DEFAULT_APP_ID_PATH,
|
|
82
|
+
generateUuid = randomUUID,
|
|
83
|
+
} = {}) {
|
|
84
|
+
if (appId) return validateAppId(appId, 'SOGNI_APP_ID');
|
|
85
|
+
|
|
86
|
+
const resolvedPath = expandHomePath(appIdPath);
|
|
87
|
+
try {
|
|
88
|
+
try {
|
|
89
|
+
return readPersistedAppId(resolvedPath);
|
|
90
|
+
} catch (error) {
|
|
91
|
+
if (error?.code !== 'ENOENT') throw error;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
mkdirSync(dirname(resolvedPath), { recursive: true, mode: 0o700 });
|
|
95
|
+
const candidate = validateAppId(
|
|
96
|
+
`${GENERATED_APP_ID_PREFIX}${generateUuid()}`,
|
|
97
|
+
'Generated Sogni app ID',
|
|
98
|
+
);
|
|
99
|
+
let descriptor;
|
|
100
|
+
let createdFile = false;
|
|
101
|
+
try {
|
|
102
|
+
descriptor = openSync(resolvedPath, 'wx', 0o600);
|
|
103
|
+
createdFile = true;
|
|
104
|
+
writeFileSync(descriptor, `${candidate}\n`, 'utf8');
|
|
105
|
+
return candidate;
|
|
106
|
+
} catch (error) {
|
|
107
|
+
if (error?.code !== 'EEXIST') throw error;
|
|
108
|
+
|
|
109
|
+
// A concurrent first launch won the exclusive create. Reuse its value
|
|
110
|
+
// once the short write window closes.
|
|
111
|
+
let lastError = error;
|
|
112
|
+
for (let attempt = 0; attempt < APP_ID_CREATE_RETRIES; attempt += 1) {
|
|
113
|
+
try {
|
|
114
|
+
return readPersistedAppId(resolvedPath);
|
|
115
|
+
} catch (readError) {
|
|
116
|
+
lastError = readError;
|
|
117
|
+
if (attempt + 1 < APP_ID_CREATE_RETRIES) waitForConcurrentWriter();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
throw lastError;
|
|
121
|
+
} finally {
|
|
122
|
+
if (descriptor !== undefined) closeSync(descriptor);
|
|
123
|
+
// Do not strand an empty/corrupt identity if this process created the
|
|
124
|
+
// file but could not finish writing it.
|
|
125
|
+
if (createdFile) {
|
|
126
|
+
try {
|
|
127
|
+
readPersistedAppId(resolvedPath);
|
|
128
|
+
} catch {
|
|
129
|
+
try { unlinkSync(resolvedPath); } catch { /* best effort */ }
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
} catch (error) {
|
|
134
|
+
throw appIdPersistenceError(error, resolvedPath);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export { DEFAULT_APP_ID_PATH };
|
package/sogni-hosted-client.mjs
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
*/
|
|
26
26
|
import { createRequire } from 'node:module';
|
|
27
27
|
import { assertSafeUrl } from './ssrf-guard.mjs';
|
|
28
|
+
import { getOrCreateSogniAppId } from './sogni-app-id.mjs';
|
|
28
29
|
|
|
29
30
|
const require = createRequire(import.meta.url);
|
|
30
31
|
const { SogniClient } = require('@sogni-ai/sogni-intelligence-client');
|
|
@@ -75,7 +76,7 @@ export async function assertSafeSogniEndpoints({ restEndpoint, socketEndpoint })
|
|
|
75
76
|
export async function withHostedClient({ apiKey, restEndpoint, socketEndpoint, appSource, appId }, work) {
|
|
76
77
|
await assertSafeSogniEndpoints({ restEndpoint, socketEndpoint });
|
|
77
78
|
const client = await SogniClient.createInstance({
|
|
78
|
-
appId: appId ??
|
|
79
|
+
appId: appId ?? getOrCreateSogniAppId(),
|
|
79
80
|
apiKey,
|
|
80
81
|
appSource: appSource ?? 'sogni-creative-agent-skill',
|
|
81
82
|
logLevel: 'error',
|
package/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const PACKAGE_VERSION = '3.
|
|
1
|
+
export const PACKAGE_VERSION = '3.18.1';
|