@sogni-ai/sogni-client 5.29.1 → 5.29.2
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 +7 -0
- package/README.md +24 -5
- package/dist/index.d.ts +12 -6
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist-esm/index.js +6 -1
- package/dist-esm/index.js.map +1 -1
- package/dist-esm/version.js +1 -1
- package/llms-full.txt +19 -5
- package/llms.txt +18 -4
- package/package.json +2 -1
- package/src/index.ts +20 -7
- package/src/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [5.29.2](https://github.com/Sogni-AI/sogni-client/compare/v5.29.1...v5.29.2) (2026-09-05)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **client:** support REST-only startup without app ID ([90dc94d](https://github.com/Sogni-AI/sogni-client/commit/90dc94d8ca2fa5ca7a3e05aa58efc2543979794d))
|
|
7
|
+
|
|
1
8
|
## [5.29.1](https://github.com/Sogni-AI/sogni-client/compare/v5.29.0...v5.29.1) (2026-09-05)
|
|
2
9
|
|
|
3
10
|
|
package/README.md
CHANGED
|
@@ -80,7 +80,8 @@ uploaded to Sogni servers where it will be stored for 24 hours. After this perio
|
|
|
80
80
|
|
|
81
81
|
## Client initialization
|
|
82
82
|
|
|
83
|
-
To initialize a client,
|
|
83
|
+
To initialize a WebSocket client, provide a stable `appId` and account credentials. Generate the ID
|
|
84
|
+
once per application installation and persist it across process restarts or page reloads.
|
|
84
85
|
|
|
85
86
|
### Option 1: API Key Authentication (Recommended)
|
|
86
87
|
|
|
@@ -92,7 +93,8 @@ API key authentication is the simplest way to connect. The client auto-authentic
|
|
|
92
93
|
import { SogniClient } from '@sogni-ai/sogni-client';
|
|
93
94
|
|
|
94
95
|
const sogni = await SogniClient.createInstance({
|
|
95
|
-
appId: '
|
|
96
|
+
appId: 'my-app-installation', // Stable across restarts; do not generate a new value per run
|
|
97
|
+
appSource: 'my-app',
|
|
96
98
|
network: 'fast', // Network to use, 'fast' or 'relaxed'
|
|
97
99
|
apiKey: 'your-api-key' // API key for authentication
|
|
98
100
|
});
|
|
@@ -109,7 +111,8 @@ const models = await sogni.projects.waitForModels();
|
|
|
109
111
|
import { SogniClient } from '@sogni-ai/sogni-client';
|
|
110
112
|
|
|
111
113
|
const sogni = await SogniClient.createInstance({
|
|
112
|
-
appId: '
|
|
114
|
+
appId: 'my-app-installation',
|
|
115
|
+
appSource: 'my-app',
|
|
113
116
|
network: 'fast'
|
|
114
117
|
});
|
|
115
118
|
|
|
@@ -120,9 +123,26 @@ const models = await sogni.projects.waitForModels();
|
|
|
120
123
|
**Important Note:**
|
|
121
124
|
|
|
122
125
|
- These samples assume you are using ES modules, which allow `await` on the top level, if you are CommonJS you will need to wrap `await` calls in an async function.
|
|
123
|
-
- `appId`
|
|
126
|
+
- `appId` identifies one application installation. Reuse the same value across restarts and reloads.
|
|
127
|
+
- If you generate an `appId`, generate it once and save it (for example in browser
|
|
128
|
+
`localStorage`). Do not call `randomUUID()` every time the application starts.
|
|
124
129
|
- Only one connection per `appId` is allowed. If you try to connect with the same `appId` multiple times, the previous connection will be closed.
|
|
125
130
|
|
|
131
|
+
### REST-only clients
|
|
132
|
+
|
|
133
|
+
Set `disableSocket: true` when a process uses only REST APIs. This mode opens no artist WebSocket
|
|
134
|
+
and does not require an `appId`:
|
|
135
|
+
|
|
136
|
+
```javascript
|
|
137
|
+
const sogni = await SogniClient.createInstance({
|
|
138
|
+
apiKey: 'your-api-key',
|
|
139
|
+
disableSocket: true
|
|
140
|
+
});
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Socket-backed project generation and chat completions are unavailable in REST-only mode. Hosted
|
|
144
|
+
chat, durable workflows, replay records, announcements, and account REST APIs remain available.
|
|
145
|
+
|
|
126
146
|
### Connection metadata and event subscriptions
|
|
127
147
|
|
|
128
148
|
Use `appSource` to identify the product or integration behind a client connection. The SDK forwards it during authentication and on socket-backed project/chat requests so server-side reporting can attribute usage consistently.
|
|
@@ -1210,7 +1230,6 @@ Long-running multi-step creative workflows can be persisted on the server and ob
|
|
|
1210
1230
|
|
|
1211
1231
|
```javascript
|
|
1212
1232
|
const sogni = await SogniClient.createInstance({
|
|
1213
|
-
appId: 'creative-workflow-demo',
|
|
1214
1233
|
apiKey: process.env.SOGNI_API_KEY,
|
|
1215
1234
|
disableSocket: true
|
|
1216
1235
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -45,7 +45,9 @@ export type { CompletedRecoveredProject, ProjectRecoverySnapshot, ProjectResolut
|
|
|
45
45
|
export { ApiError, ApiKeyAuthManager, ChatJobError, ChatStream, ChatToolsApi, CreativeWorkflowsApi, CreativeWorkflowTemplatesApi, ReplayApi, CurrentAccount, Job, Project, PROJECT_LOST_ORIGINAL_CODE, SogniTools, SUBSCRIPTION_ERROR_CODES, isProjectLostError, isSubscriptionLimitError, isSogniToolCall, parseCreativeWorkflowSseChunk, parseToolCallArguments, projectParamsFromRecoveredProject };
|
|
46
46
|
export interface SogniClientConfig {
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
48
|
+
* Stable ID for this application installation. Reuse it across process restarts and page reloads.
|
|
49
|
+
* It only needs to be unique among simultaneous connections for the same account; a second live
|
|
50
|
+
* connection with the same ID replaces the first one.
|
|
49
51
|
*/
|
|
50
52
|
appId: string;
|
|
51
53
|
/**
|
|
@@ -81,10 +83,9 @@ export interface SogniClientConfig {
|
|
|
81
83
|
*/
|
|
82
84
|
socketEndpoint?: string;
|
|
83
85
|
/**
|
|
84
|
-
* Disable WebSocket connection
|
|
85
|
-
*
|
|
86
|
-
* @
|
|
87
|
-
* @internal
|
|
86
|
+
* Disable the WebSocket connection for REST-only clients. Socket-backed project generation and
|
|
87
|
+
* chat completions are unavailable in this mode. An `appId` is optional when this is `true`.
|
|
88
|
+
* @default false
|
|
88
89
|
*/
|
|
89
90
|
disableSocket?: boolean;
|
|
90
91
|
/**
|
|
@@ -133,6 +134,11 @@ export interface SogniClientConfig {
|
|
|
133
134
|
*/
|
|
134
135
|
multiInstance?: boolean;
|
|
135
136
|
}
|
|
137
|
+
/** Configuration for a client that uses only REST APIs and never opens an artist WebSocket. */
|
|
138
|
+
export type RestOnlySogniClientConfig = Omit<SogniClientConfig, 'appId' | 'disableSocket'> & {
|
|
139
|
+
disableSocket: true;
|
|
140
|
+
appId?: string;
|
|
141
|
+
};
|
|
136
142
|
export declare class SogniClient {
|
|
137
143
|
account: AccountApi;
|
|
138
144
|
projects: ProjectsApi;
|
|
@@ -200,5 +206,5 @@ export declare class SogniClient {
|
|
|
200
206
|
* Create client instance, with default configuration
|
|
201
207
|
* @param config
|
|
202
208
|
*/
|
|
203
|
-
static createInstance(config: SogniClientConfig): Promise<SogniClient>;
|
|
209
|
+
static createInstance(config: SogniClientConfig | RestOnlySogniClientConfig): Promise<SogniClient>;
|
|
204
210
|
}
|
package/dist/index.js
CHANGED
|
@@ -177,16 +177,21 @@ class SogniClient {
|
|
|
177
177
|
*/
|
|
178
178
|
static createInstance(config) {
|
|
179
179
|
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
+
var _a;
|
|
180
181
|
const restEndpoint = config.restEndpoint || 'https://api.sogni.ai';
|
|
181
182
|
const socketEndpoint = config.socketEndpoint || 'wss://socket.sogni.ai';
|
|
182
183
|
const network = config.network || 'fast';
|
|
183
184
|
const logger = config.logger || new DefaultLogger_js_1.DefaultLogger(config.logLevel || 'warn');
|
|
184
185
|
const isTestnet = config.testnet !== undefined ? config.testnet : false;
|
|
185
186
|
const authType = config.apiKey ? 'apiKey' : config.authType || 'token';
|
|
187
|
+
const appId = (_a = config.appId) === null || _a === void 0 ? void 0 : _a.trim();
|
|
188
|
+
if (!appId && !config.disableSocket) {
|
|
189
|
+
throw new Error('appId is required when WebSocket connections are enabled');
|
|
190
|
+
}
|
|
186
191
|
const client = new index_js_2.default({
|
|
187
192
|
baseUrl: restEndpoint,
|
|
188
193
|
socketUrl: socketEndpoint,
|
|
189
|
-
appId:
|
|
194
|
+
appId: appId || 'rest-only',
|
|
190
195
|
appSource: config.appSource,
|
|
191
196
|
attribution: config.attribution,
|
|
192
197
|
socketEventSubscriptions: config.socketEventSubscriptions,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAc;AACd,kEAA4C;AAC5C,oFAAyD;AAmZvD,yBAnZK,2BAAc,CAmZL;AAlZhB,YAAY;AACZ,iEAAwE;AAyYtE,yFAzYkB,mBAAQ,OAyYlB;AAxXV,QAAQ;AACR,6DAAyE;AACzE,4EAAiD;AACjD,eAAe;AACf,mEAA8C;AAC9C,+DAAmD;AA4XjD,cA5XK,gBAAG,CA4XL;AA3XL,uEAA+D;AA4X7D,kBA5XK,oBAAO,CA4XL;AAnVT,wDAIgC;AAgV9B,2GAnVA,wCAA0B,OAmVA;AAG1B,mGArVA,gCAAkB,OAqVA;AAKlB,kHAzVA,+CAAiC,OAyVA;AA7TnC,WAAW;AACX,+DAAsC;AACtC,6EAA0E;AA0SxE,uBA1SK,yBAAY,CA0SL;AAzSd,yEAA8C;AA0S5C,qBA1SK,uBAAU,CA0SL;AAzSZ,uEAA+C;AA0S7C,uBA1SK,sBAAY,CA0SL;AAhQd,8CAAsF;AAwQpF,2FAxQO,qBAAU,OAwQP;AAIV,gGA5QmB,0BAAe,OA4QnB;AAEf,uGA9QoC,iCAAsB,OA8QpC;AA7QxB,yBAAyB;AACzB,yEAAmG;AA+PjG,+BA/PK,kBAAoB,CA+PL;AAYpB,8GA3Q6B,wCAA6B,OA2Q7B;AA1Q/B,sFAAkF;AA+PhF,uCA/PK,kBAA4B,CA+PL;AA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ACtC,CAAC,CAAC;YACH,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;YAExD,6CAA6C;YAC7C,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;gBAClB,MAAM,IAAI,GAAG,MAAM,CAAC,IAAyB,CAAC;gBAC9C,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACzC,CAAC;YAED,OAAO,WAAW,CAAC;QACrB,CAAC;KAAA;CACF;AA9JD,kCA8JC"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const LIB_VERSION = "5.29.
|
|
1
|
+
export declare const LIB_VERSION = "5.29.2";
|
package/dist/version.js
CHANGED
|
@@ -3,5 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.LIB_VERSION = void 0;
|
|
4
4
|
// AUTO-GENERATED by scripts/generate-version.mjs — do not edit.
|
|
5
5
|
// Source of truth: package.json version.
|
|
6
|
-
exports.LIB_VERSION = '5.29.
|
|
6
|
+
exports.LIB_VERSION = '5.29.2';
|
|
7
7
|
//# sourceMappingURL=version.js.map
|
package/dist-esm/index.js
CHANGED
|
@@ -119,16 +119,21 @@ export class SogniClient {
|
|
|
119
119
|
*/
|
|
120
120
|
static createInstance(config) {
|
|
121
121
|
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
var _a;
|
|
122
123
|
const restEndpoint = config.restEndpoint || 'https://api.sogni.ai';
|
|
123
124
|
const socketEndpoint = config.socketEndpoint || 'wss://socket.sogni.ai';
|
|
124
125
|
const network = config.network || 'fast';
|
|
125
126
|
const logger = config.logger || new DefaultLogger(config.logLevel || 'warn');
|
|
126
127
|
const isTestnet = config.testnet !== undefined ? config.testnet : false;
|
|
127
128
|
const authType = config.apiKey ? 'apiKey' : config.authType || 'token';
|
|
129
|
+
const appId = (_a = config.appId) === null || _a === void 0 ? void 0 : _a.trim();
|
|
130
|
+
if (!appId && !config.disableSocket) {
|
|
131
|
+
throw new Error('appId is required when WebSocket connections are enabled');
|
|
132
|
+
}
|
|
128
133
|
const client = new ApiClient({
|
|
129
134
|
baseUrl: restEndpoint,
|
|
130
135
|
socketUrl: socketEndpoint,
|
|
131
|
-
appId:
|
|
136
|
+
appId: appId || 'rest-only',
|
|
132
137
|
appSource: config.appSource,
|
|
133
138
|
attribution: config.attribution,
|
|
134
139
|
socketEventSubscriptions: config.socketEventSubscriptions,
|
package/dist-esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,cAAc;AACd,OAAO,UAAU,MAAM,oBAAoB,CAAC;AAC5C,OAAO,cAAc,MAAM,6BAA6B,CAAC;AACzD,YAAY;AACZ,OAAO,SAAS,EAAE,EAAE,QAAQ,EAAe,MAAM,sBAAsB,CAAC;AAiBxE,QAAQ;AACR,OAAO,EAAE,aAAa,EAAoB,MAAM,wBAAwB,CAAC;AACzE,OAAO,YAAY,MAAM,uBAAuB,CAAC;AACjD,eAAe;AACf,OAAO,WAAW,MAAM,qBAAqB,CAAC;AAC9C,OAAO,GAAkB,MAAM,mBAAmB,CAAC;AACnD,OAAO,OAA0B,MAAM,uBAAuB,CAAC;AAyC/D,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,EAClB,iCAAiC,EAClC,MAAM,wBAAwB,CAAC;AA2BhC,WAAW;AACX,OAAO,OAAO,MAAM,iBAAiB,CAAC;AACtC,OAAO,YAAoC,MAAM,wBAAwB,CAAC;AAC1E,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAC9C,OAAO,YAAY,MAAM,qBAAqB,CAAC;AA0C/C,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACtF,yBAAyB;AACzB,OAAO,oBAAoB,EAAE,EAAE,6BAA6B,E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key auth (recommended) — no login() needed
|
|
79
79
|
const sogni = await SogniClient.createInstance({
|
|
80
|
-
appId: 'my-
|
|
80
|
+
appId: 'my-app-installation',
|
|
81
|
+
appSource: 'my-app',
|
|
81
82
|
apiKey: 'your-api-key'
|
|
82
83
|
});
|
|
83
84
|
|
|
84
85
|
// Option 2: Username/password auth
|
|
85
|
-
// const sogni = await SogniClient.createInstance({
|
|
86
|
+
// const sogni = await SogniClient.createInstance({
|
|
87
|
+
// appId: 'my-app-installation',
|
|
88
|
+
// appSource: 'my-app'
|
|
89
|
+
// });
|
|
86
90
|
// await sogni.account.login('username', 'password');
|
|
87
91
|
|
|
88
92
|
await sogni.projects.waitForModels();
|
|
@@ -126,7 +130,8 @@ CREATING THE CLIENT:
|
|
|
126
130
|
import { SogniClient } from '@sogni-ai/sogni-client';
|
|
127
131
|
|
|
128
132
|
const sogni = await SogniClient.createInstance({
|
|
129
|
-
appId: '
|
|
133
|
+
appId: 'my-app-installation', // Generate once and persist; never regenerate on each start
|
|
134
|
+
appSource: 'my-app',
|
|
130
135
|
network: 'fast' // 'fast' or 'relaxed'
|
|
131
136
|
});
|
|
132
137
|
```
|
|
@@ -138,7 +143,8 @@ dropdown in the top-right corner to provision your key.
|
|
|
138
143
|
```javascript
|
|
139
144
|
// API key auth — auto-authenticates via WebSocket, no login() needed
|
|
140
145
|
const sogni = await SogniClient.createInstance({
|
|
141
|
-
appId: '
|
|
146
|
+
appId: 'my-app-installation',
|
|
147
|
+
appSource: 'my-app',
|
|
142
148
|
network: 'fast',
|
|
143
149
|
apiKey: 'your-api-key'
|
|
144
150
|
});
|
|
@@ -150,12 +156,20 @@ AUTHENTICATION - USERNAME/PASSWORD:
|
|
|
150
156
|
```javascript
|
|
151
157
|
// Username/password login
|
|
152
158
|
const sogni = await SogniClient.createInstance({
|
|
153
|
-
appId: '
|
|
159
|
+
appId: 'my-app-installation',
|
|
160
|
+
appSource: 'my-app',
|
|
154
161
|
network: 'fast'
|
|
155
162
|
});
|
|
156
163
|
await sogni.account.login('username', 'password');
|
|
157
164
|
```
|
|
158
165
|
|
|
166
|
+
APP ID LIFECYCLE:
|
|
167
|
+
|
|
168
|
+
Generate an `appId` once per application installation and persist it across process restarts or page
|
|
169
|
+
reloads. Calling `randomUUID()` every time the process starts creates a new application identity on
|
|
170
|
+
every run. For REST-only usage, pass `disableSocket: true`; `appId` is optional and the client opens
|
|
171
|
+
no artist WebSocket.
|
|
172
|
+
|
|
159
173
|
API KEY VS USERNAME/PASSWORD:
|
|
160
174
|
|
|
161
175
|
- API key: Pass `apiKey` to `createInstance()`. Auto-authenticates via WebSocket
|
package/llms.txt
CHANGED
|
@@ -21,10 +21,17 @@ The SDK publishes CommonJS (`dist/index.js`), ESM (`dist-esm/index.js`), and Typ
|
|
|
21
21
|
import { SogniClient } from '@sogni-ai/sogni-client';
|
|
22
22
|
|
|
23
23
|
// Option 1: API key auth (recommended) — no login() needed
|
|
24
|
-
const sogni = await SogniClient.createInstance({
|
|
24
|
+
const sogni = await SogniClient.createInstance({
|
|
25
|
+
appId: 'my-app-installation',
|
|
26
|
+
appSource: 'my-app',
|
|
27
|
+
apiKey: 'your-api-key'
|
|
28
|
+
});
|
|
25
29
|
|
|
26
30
|
// Option 2: Username/password auth
|
|
27
|
-
// const sogni = await SogniClient.createInstance({
|
|
31
|
+
// const sogni = await SogniClient.createInstance({
|
|
32
|
+
// appId: 'my-app-installation',
|
|
33
|
+
// appSource: 'my-app'
|
|
34
|
+
// });
|
|
28
35
|
// await sogni.account.login('username', 'password');
|
|
29
36
|
|
|
30
37
|
await sogni.projects.waitForModels();
|
|
@@ -89,7 +96,8 @@ Each email-verified account is allowed 400 free Spark render credits per month.
|
|
|
89
96
|
|
|
90
97
|
```javascript
|
|
91
98
|
const sogni = await SogniClient.createInstance({
|
|
92
|
-
appId: '
|
|
99
|
+
appId: 'my-app-installation', // Generate once and persist; never regenerate on each start
|
|
100
|
+
appSource: 'my-app',
|
|
93
101
|
network: 'fast', // 'fast' (GPU) or 'relaxed' (Mac)
|
|
94
102
|
apiKey: 'your-api-key' // Auto-authenticates, no login() needed
|
|
95
103
|
});
|
|
@@ -99,7 +107,8 @@ const sogni = await SogniClient.createInstance({
|
|
|
99
107
|
|
|
100
108
|
```javascript
|
|
101
109
|
const sogni = await SogniClient.createInstance({
|
|
102
|
-
appId: '
|
|
110
|
+
appId: 'my-app-installation',
|
|
111
|
+
appSource: 'my-app',
|
|
103
112
|
network: 'fast'
|
|
104
113
|
});
|
|
105
114
|
await sogni.account.login(username, password);
|
|
@@ -109,6 +118,11 @@ await sogni.account.login(username, password);
|
|
|
109
118
|
|
|
110
119
|
- **API key**: Pass `apiKey` to `createInstance()`. Auto-authenticates via WebSocket. No `login()` call needed. Most REST API calls (balance, profile, etc.) available. Sensitive operations (withdrawals, staking, 2FA) not available.
|
|
111
120
|
- **Username/password**: Call `sogni.account.login()` after creating instance. Full REST API access.
|
|
121
|
+
- **REST-only**: Pass `disableSocket: true`; `appId` is then optional and no artist WebSocket is opened. Use this for hosted chat, durable workflows, replay, announcements, and account REST APIs.
|
|
122
|
+
|
|
123
|
+
Generate an `appId` once per application installation and persist it across restarts or page
|
|
124
|
+
reloads. Calling `randomUUID()` each time the process starts creates a different application
|
|
125
|
+
identity on every run.
|
|
112
126
|
|
|
113
127
|
### Subscription Entitlements
|
|
114
128
|
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "5.29.
|
|
6
|
+
"version": "5.29.2",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=22"
|
|
9
9
|
},
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"build": "npm run clean && npm run codegen && tsc --project tsconfig.json && tsc --project tsconfig.esm.json && node scripts/write-dist-esm-package-json.mjs",
|
|
63
63
|
"test:chat-routing": "npm run build && node scripts/check-chat-model-routing.cjs",
|
|
64
64
|
"test:attribution": "npm run build && node scripts/check-attribution-transport.cjs",
|
|
65
|
+
"test:rest-only": "npm run build && node scripts/check-rest-only-config.cjs",
|
|
65
66
|
"test:subscription-api": "npm run build && node scripts/check-subscription-api.cjs",
|
|
66
67
|
"test:model-options": "npm run build && node scripts/check-video-model-options.cjs",
|
|
67
68
|
"test:video-estimates": "npm run build && node scripts/check-video-estimates.cjs",
|
package/src/index.ts
CHANGED
|
@@ -419,7 +419,9 @@ export {
|
|
|
419
419
|
|
|
420
420
|
export interface SogniClientConfig {
|
|
421
421
|
/**
|
|
422
|
-
*
|
|
422
|
+
* Stable ID for this application installation. Reuse it across process restarts and page reloads.
|
|
423
|
+
* It only needs to be unique among simultaneous connections for the same account; a second live
|
|
424
|
+
* connection with the same ID replaces the first one.
|
|
423
425
|
*/
|
|
424
426
|
appId: string;
|
|
425
427
|
/**
|
|
@@ -455,10 +457,9 @@ export interface SogniClientConfig {
|
|
|
455
457
|
*/
|
|
456
458
|
socketEndpoint?: string;
|
|
457
459
|
/**
|
|
458
|
-
* Disable WebSocket connection
|
|
459
|
-
*
|
|
460
|
-
* @
|
|
461
|
-
* @internal
|
|
460
|
+
* Disable the WebSocket connection for REST-only clients. Socket-backed project generation and
|
|
461
|
+
* chat completions are unavailable in this mode. An `appId` is optional when this is `true`.
|
|
462
|
+
* @default false
|
|
462
463
|
*/
|
|
463
464
|
disableSocket?: boolean;
|
|
464
465
|
/**
|
|
@@ -508,6 +509,12 @@ export interface SogniClientConfig {
|
|
|
508
509
|
multiInstance?: boolean;
|
|
509
510
|
}
|
|
510
511
|
|
|
512
|
+
/** Configuration for a client that uses only REST APIs and never opens an artist WebSocket. */
|
|
513
|
+
export type RestOnlySogniClientConfig = Omit<SogniClientConfig, 'appId' | 'disableSocket'> & {
|
|
514
|
+
disableSocket: true;
|
|
515
|
+
appId?: string;
|
|
516
|
+
};
|
|
517
|
+
|
|
511
518
|
export class SogniClient {
|
|
512
519
|
account: AccountApi;
|
|
513
520
|
projects: ProjectsApi;
|
|
@@ -624,18 +631,24 @@ export class SogniClient {
|
|
|
624
631
|
* Create client instance, with default configuration
|
|
625
632
|
* @param config
|
|
626
633
|
*/
|
|
627
|
-
static async createInstance(
|
|
634
|
+
static async createInstance(
|
|
635
|
+
config: SogniClientConfig | RestOnlySogniClientConfig
|
|
636
|
+
): Promise<SogniClient> {
|
|
628
637
|
const restEndpoint = config.restEndpoint || 'https://api.sogni.ai';
|
|
629
638
|
const socketEndpoint = config.socketEndpoint || 'wss://socket.sogni.ai';
|
|
630
639
|
const network = config.network || 'fast';
|
|
631
640
|
const logger = config.logger || new DefaultLogger(config.logLevel || 'warn');
|
|
632
641
|
const isTestnet = config.testnet !== undefined ? config.testnet : false;
|
|
633
642
|
const authType = config.apiKey ? 'apiKey' : config.authType || 'token';
|
|
643
|
+
const appId = config.appId?.trim();
|
|
644
|
+
if (!appId && !config.disableSocket) {
|
|
645
|
+
throw new Error('appId is required when WebSocket connections are enabled');
|
|
646
|
+
}
|
|
634
647
|
|
|
635
648
|
const client = new ApiClient({
|
|
636
649
|
baseUrl: restEndpoint,
|
|
637
650
|
socketUrl: socketEndpoint,
|
|
638
|
-
appId:
|
|
651
|
+
appId: appId || 'rest-only',
|
|
639
652
|
appSource: config.appSource,
|
|
640
653
|
attribution: config.attribution,
|
|
641
654
|
socketEventSubscriptions: config.socketEventSubscriptions,
|
package/src/version.ts
CHANGED