@sogni-ai/sogni-creative-agent-skill 3.18.0 โ 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 +7 -0
- package/README.md +2 -0
- package/SKILL.md +3 -1
- package/desktop-extension/manifest.json +1 -1
- package/llm.txt +5 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +2 -1
- package/sogni-agent.mjs +32 -4
- 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.18.
|
|
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,3 +1,10 @@
|
|
|
1
|
+
# [3.18.1](https://github.com/Sogni-AI/sogni-creative-agent-skill/compare/v3.18.0...v3.18.1) (2026-07-28)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
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
|
+
|
|
1
8
|
# [3.18.0](https://github.com/Sogni-AI/sogni-creative-agent-skill/compare/v3.17.2...v3.18.0) (2026-07-27)
|
|
2
9
|
|
|
3
10
|
|
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 |
|
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.18.
|
|
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`)
|
|
@@ -335,6 +336,7 @@ Eligible Sogni-hosted renders use Unlimited coverage when active; otherwise rend
|
|
|
335
336
|
|
|
336
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.
|
|
337
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.
|
|
338
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).
|
|
339
341
|
- **Timeouts:** try a faster model or raise `-t`.
|
|
340
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.18.
|
|
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",
|
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.18.
|
|
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.18.
|
|
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",
|
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';
|
|
@@ -4971,7 +4995,7 @@ async function dispatchWorkflowActionViaSdk(action, apiKey, params) {
|
|
|
4971
4995
|
restEndpoint: restBase,
|
|
4972
4996
|
socketEndpoint: process.env.SOGNI_SOCKET_ENDPOINT || undefined,
|
|
4973
4997
|
appSource: SOGNI_APP_SOURCE,
|
|
4974
|
-
appId:
|
|
4998
|
+
appId: getOrCreateSogniAppId(),
|
|
4975
4999
|
},
|
|
4976
5000
|
async (client) => {
|
|
4977
5001
|
if (action === 'list') {
|
|
@@ -5049,7 +5073,7 @@ async function dispatchChatHostedViaSdk(apiKey, body) {
|
|
|
5049
5073
|
restEndpoint: restBase,
|
|
5050
5074
|
socketEndpoint: process.env.SOGNI_SOCKET_ENDPOINT || undefined,
|
|
5051
5075
|
appSource: SOGNI_APP_SOURCE,
|
|
5052
|
-
appId:
|
|
5076
|
+
appId: getOrCreateSogniAppId(),
|
|
5053
5077
|
},
|
|
5054
5078
|
async (client) => helpers.sdkChatHostedCreate(client, body),
|
|
5055
5079
|
);
|
|
@@ -5092,7 +5116,7 @@ async function dispatchMediaReferenceUrlViaSdk({ ref, file, index, jobId, action
|
|
|
5092
5116
|
restEndpoint: restBase,
|
|
5093
5117
|
socketEndpoint: process.env.SOGNI_SOCKET_ENDPOINT || undefined,
|
|
5094
5118
|
appSource: SOGNI_APP_SOURCE,
|
|
5095
|
-
appId:
|
|
5119
|
+
appId: getOrCreateSogniAppId(),
|
|
5096
5120
|
},
|
|
5097
5121
|
async (client) => {
|
|
5098
5122
|
const type = apiMediaReferenceUploadType(ref, index);
|
|
@@ -5880,7 +5904,7 @@ async function runApiChatDurable(log, { apiKey, body }) {
|
|
|
5880
5904
|
restEndpoint: restBase,
|
|
5881
5905
|
socketEndpoint: process.env.SOGNI_SOCKET_ENDPOINT || undefined,
|
|
5882
5906
|
appSource: SOGNI_APP_SOURCE,
|
|
5883
|
-
appId:
|
|
5907
|
+
appId: getOrCreateSogniAppId(),
|
|
5884
5908
|
},
|
|
5885
5909
|
async (client) => {
|
|
5886
5910
|
const created = await helpers.sdkChatRunsCreate(client, runParams);
|
|
@@ -9413,6 +9437,7 @@ async function runDoctor() {
|
|
|
9413
9437
|
try {
|
|
9414
9438
|
doctorClient = new SogniClientWrapper({
|
|
9415
9439
|
appSource: SOGNI_APP_SOURCE,
|
|
9440
|
+
appId: getOrCreateSogniAppId(),
|
|
9416
9441
|
network: openclawConfig?.defaultNetwork || 'fast',
|
|
9417
9442
|
autoConnect: false,
|
|
9418
9443
|
apiKey: creds.SOGNI_API_KEY,
|
|
@@ -9954,6 +9979,7 @@ async function main() {
|
|
|
9954
9979
|
log('Connecting to Sogni...');
|
|
9955
9980
|
client = new SogniClientWrapper({
|
|
9956
9981
|
appSource: SOGNI_APP_SOURCE,
|
|
9982
|
+
appId: getOrCreateSogniAppId(),
|
|
9957
9983
|
network: openclawConfig?.defaultNetwork || 'fast',
|
|
9958
9984
|
autoConnect: false,
|
|
9959
9985
|
apiKey: creds.SOGNI_API_KEY,
|
|
@@ -10911,6 +10937,7 @@ async function main() {
|
|
|
10911
10937
|
const creds = loadCredentials();
|
|
10912
10938
|
const client2 = new SogniClientWrapper({
|
|
10913
10939
|
appSource: SOGNI_APP_SOURCE,
|
|
10940
|
+
appId: getOrCreateSogniAppId(),
|
|
10914
10941
|
network: openclawConfig?.defaultNetwork || 'fast',
|
|
10915
10942
|
autoConnect: false,
|
|
10916
10943
|
apiKey: creds.SOGNI_API_KEY,
|
|
@@ -11118,6 +11145,7 @@ async function main() {
|
|
|
11118
11145
|
if (!error.hint) error.hint = INVALID_API_KEY_HINT;
|
|
11119
11146
|
if (!error.code) error.code = 'INVALID_API_KEY';
|
|
11120
11147
|
}
|
|
11148
|
+
enrichAppIdLimitError(error);
|
|
11121
11149
|
|
|
11122
11150
|
exitCode = 1;
|
|
11123
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.18.
|
|
1
|
+
export const PACKAGE_VERSION = '3.18.1';
|