@sogni-ai/sogni-client-wrapper 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
package/README.md ADDED
@@ -0,0 +1,229 @@
1
+ # Sogni Client Wrapper
2
+
3
+ [![NPM version](https://img.shields.io/npm/v/sogni-client-wrapper.svg)](https://www.npmjs.com/package/sogni-client-wrapper) [![License](https://img.shields.io/npm/l/sogni-client-wrapper.svg)](https://www.npmjs.com/package/sogni-client-wrapper)
4
+
5
+ An enhanced Node.js wrapper for the [`@sogni-ai/sogni-client`](https://sdk-docs.sogni.ai/) library, designed for robustness, ease of use, and seamless integration with platforms like [n8n](https://n8n.io/).
6
+
7
+ This library simplifies interaction with the Sogni AI Supernet by providing a promise-based API, automatic connection management, enhanced error handling, and a more developer-friendly interface.
8
+
9
+ ## Features
10
+
11
+ - **Promise-Based API**: Modern `async/await` support for all core operations.
12
+ - **Connection Management**: Automatic connection and reconnection handling.
13
+ - **Simplified Configuration**: Sensible defaults and clear configuration options.
14
+ - **Enhanced Error Handling**: Custom error classes for better error diagnosis.
15
+ - **Type-Safe**: Written entirely in TypeScript with full type definitions.
16
+ - **n8n-Ready**: Built with n8n integration in mind, managing connection lifecycles effectively.
17
+ - **Utility Helpers**: Includes helpers for validation, retries, and formatting.
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ npm install sogni-client-wrapper
23
+ ```
24
+
25
+ Or with Yarn:
26
+
27
+ ```bash
28
+ yarn add sogni-client-wrapper
29
+ ```
30
+
31
+ ## Quick Start
32
+
33
+ Here is a simple example of how to generate an image using the wrapper:
34
+
35
+ ```typescript
36
+ import { SogniClientWrapper } from 'sogni-client-wrapper';
37
+
38
+ async function main() {
39
+ // 1. Create and connect the client
40
+ const client = new SogniClientWrapper({
41
+ username: 'YOUR_SOGNI_USERNAME',
42
+ password: 'YOUR_SOGNI_PASSWORD',
43
+ });
44
+
45
+ try {
46
+ // The client connects automatically on the first operation
47
+ console.log('Client connected!');
48
+
49
+ // 2. Find the most popular model
50
+ const model = await client.getMostPopularModel();
51
+ console.log(`Using model: ${model.id} (${model.workerCount} workers)`);
52
+
53
+ // 3. Generate an image
54
+ console.log('Generating image...');
55
+ const result = await client.createProject({
56
+ modelId: model.id,
57
+ positivePrompt: 'A photorealistic portrait of a majestic lion in the savanna at sunset',
58
+ negativePrompt: 'blurry, cartoon, low quality',
59
+ stylePrompt: 'cinematic',
60
+ steps: 30,
61
+ guidance: 8,
62
+ });
63
+
64
+ if (result.completed && result.imageUrls) {
65
+ console.log('Image generation successful!');
66
+ console.log('Image URLs:', result.imageUrls);
67
+ } else {
68
+ console.error('Image generation did not complete.');
69
+ }
70
+
71
+ } catch (error) {
72
+ console.error('An error occurred:', error);
73
+ } finally {
74
+ // 4. Disconnect the client
75
+ await client.disconnect();
76
+ console.log('Client disconnected.');
77
+ }
78
+ }
79
+
80
+ main();
81
+ ```
82
+
83
+ ## API Reference
84
+
85
+ ### `new SogniClientWrapper(config)`
86
+
87
+ Creates a new client instance.
88
+
89
+ **Configuration (`SogniClientConfig`)**
90
+
91
+ | Parameter | Type | Default | Description |
92
+ |---|---|---|---|
93
+ | `username` | `string` | **Required** | Your Sogni account username. |
94
+ | `password` | `string` | **Required** | Your Sogni account password. |
95
+ | `appId` | `string` | Auto-generated UUID | Unique ID for your application. |
96
+ | `network` | `'fast' \| 'relaxed'` | `'fast'` | The Sogni network to use. |
97
+ | `autoConnect` | `boolean` | `true` | Connect automatically on the first operation. |
98
+ | `reconnect` | `boolean` | `true` | Attempt to reconnect if the connection is lost. |
99
+ | `reconnectInterval` | `number` | `5000` | Time in ms between reconnect attempts. |
100
+ | `timeout` | `number` | `300000` | Default timeout in ms for operations. |
101
+ | `debug` | `boolean` | `false` | Enable detailed console logging. |
102
+
103
+ ### Core Methods
104
+
105
+ - `connect(): Promise<void>`: Manually initiates the connection to Sogni.
106
+ - `disconnect(): Promise<void>`: Disconnects the client.
107
+ - `isConnected(): boolean`: Checks if the client is currently connected.
108
+ - `getConnectionState(): ConnectionState`: Returns the current connection status.
109
+
110
+ ### Main Operations
111
+
112
+ - `createProject(config: ProjectConfig): Promise<ProjectResult>`: Creates a new image generation project.
113
+ - `waitForCompletion` (default: `true`): If true, the promise resolves only when the image(s) are ready.
114
+ - `getAvailableModels(options?: GetModelsOptions): Promise<ModelInfo[]>`: Retrieves a list of available models.
115
+ - `getModel(modelId: string): Promise<ModelInfo>`: Retrieves details for a specific model.
116
+ - `getMostPopularModel(): Promise<ModelInfo>`: A helper to get the model with the most active workers.
117
+ - `getBalance(): Promise<BalanceInfo>`: Fetches your current SOGNI and Spark token balance.
118
+ - `getSizePresets(network: 'fast' \| 'relaxed', modelId: string): Promise<SizePreset[]>`: Gets available output size presets for a model.
119
+
120
+ ### Event Handling
121
+
122
+ The wrapper is an `EventEmitter` and provides type-safe events.
123
+
124
+ ```typescript
125
+ import { ClientEvent } from 'sogni-client-wrapper';
126
+
127
+ client.on(ClientEvent.CONNECTED, () => {
128
+ console.log('Client is connected!');
129
+ });
130
+
131
+ client.on(ClientEvent.PROJECT_PROGRESS, (progress) => {
132
+ console.log(`Project ${progress.projectId} is ${progress.percentage}% complete.`);
133
+ });
134
+
135
+ client.on(ClientEvent.ERROR, (error) => {
136
+ console.error('A client error occurred:', error.message);
137
+ });
138
+ ```
139
+
140
+ | Event | Payload | Description |
141
+ |---|---|---|
142
+ | `connected` | `void` | Fired when the client successfully connects. |
143
+ | `disconnected` | `void` | Fired when the client disconnects. |
144
+ | `reconnecting` | `number` | Fired when a reconnection attempt starts. Payload is the attempt number. |
145
+ | `error` | `ErrorData` | Fired when a client or connection error occurs. |
146
+ | `projectProgress` | `ProjectProgress` | Fired with real-time progress updates for a project. |
147
+ | `projectCompleted` | `ProjectResult` | Fired when a project successfully completes. |
148
+ | `projectFailed` | `ErrorData` | Fired when a project fails. |
149
+
150
+ ## Error Handling
151
+
152
+ The library throws custom errors that extend `SogniError`. This allows you to catch specific types of errors.
153
+
154
+ - `SogniConnectionError`: Issues with connecting to the WebSocket server.
155
+ - `SogniAuthenticationError`: Invalid username or password.
156
+ - `SogniProjectError`: The image generation project failed.
157
+ - `SogniTimeoutError`: An operation took longer than the configured timeout.
158
+ - `SogniValidationError`: Invalid configuration or parameters.
159
+ - `SogniBalanceError`: Insufficient token balance.
160
+
161
+ ```typescript
162
+ import { SogniAuthenticationError, SogniProjectError } from 'sogni-client-wrapper';
163
+
164
+ try {
165
+ // ... your code
166
+ } catch (error) {
167
+ if (error instanceof SogniAuthenticationError) {
168
+ console.error('Please check your credentials.');
169
+ } else if (error instanceof SogniProjectError) {
170
+ console.error('The image generation failed. Please try a different prompt or model.');
171
+ } else {
172
+ console.error('An unknown error occurred:', error);
173
+ }
174
+ }
175
+ ```
176
+
177
+ ## Testing
178
+
179
+ The library includes both basic unit tests and end-to-end tests.
180
+
181
+ ### Running Tests
182
+
183
+ ```bash
184
+ # Run basic unit tests (no credentials required)
185
+ npm test
186
+
187
+ # Run end-to-end tests (requires Sogni API credentials)
188
+ npm run test:e2e
189
+
190
+ # Run all tests
191
+ npm run test:all
192
+ ```
193
+
194
+ ### Setting Up End-to-End Tests
195
+
196
+ To run the end-to-end tests, you need to provide your Sogni API credentials via environment variables:
197
+
198
+ 1. Copy the example environment file:
199
+ ```bash
200
+ cp .env.example .env
201
+ ```
202
+
203
+ 2. Edit `.env` and add your Sogni credentials:
204
+ ```env
205
+ SOGNI_USERNAME=your_sogni_username
206
+ SOGNI_PASSWORD=your_sogni_password
207
+ ```
208
+
209
+ 3. Run the e2e tests:
210
+ ```bash
211
+ npm run test:e2e
212
+ ```
213
+
214
+ **Note:** The e2e tests will make real API calls and may consume tokens from your Sogni account. They include image generation tests that will use your Spark tokens.
215
+
216
+ ## TypeScript
217
+
218
+ This library is written in TypeScript and exports all necessary types for a fully-typed experience.
219
+
220
+ - `SogniClientConfig`: Configuration for the client constructor.
221
+ - `ProjectConfig`: Parameters for creating a project.
222
+ - `ProjectResult`: The return type for a completed project.
223
+ - `ModelInfo`: Detailed information about an available model.
224
+ - `BalanceInfo`: Your token balance.
225
+ - `ErrorData`: The structure of error objects.
226
+
227
+ ## License
228
+
229
+ [MIT](LICENSE)
@@ -0,0 +1,36 @@
1
+ import { EventEmitter } from 'events';
2
+ import type { SogniClientConfig, ProjectConfig, ProjectResult, ConnectionState, ModelInfo, BalanceInfo, SizePreset, GetModelsOptions, ClientEventCallbacks } from '../types';
3
+ import { ClientEvent } from '../types';
4
+ export declare class SogniClientWrapper extends EventEmitter {
5
+ private client;
6
+ private config;
7
+ private connectionState;
8
+ private reconnectTimer;
9
+ private isReconnecting;
10
+ constructor(config: SogniClientConfig);
11
+ connect(): Promise<void>;
12
+ disconnect(): Promise<void>;
13
+ isConnected(): boolean;
14
+ getConnectionState(): ConnectionState;
15
+ getAvailableModels(options?: GetModelsOptions): Promise<ModelInfo[]>;
16
+ getModel(modelId: string): Promise<ModelInfo>;
17
+ getMostPopularModel(): Promise<ModelInfo>;
18
+ getBalance(): Promise<BalanceInfo>;
19
+ getSizePresets(network: 'fast' | 'relaxed', modelId: string): Promise<SizePreset[]>;
20
+ createProject(config: ProjectConfig): Promise<ProjectResult>;
21
+ createProjectWithRetry(config: ProjectConfig, options?: {
22
+ maxAttempts?: number;
23
+ retryDelay?: number;
24
+ }): Promise<ProjectResult>;
25
+ private ensureConnected;
26
+ private setupEventListeners;
27
+ private scheduleReconnect;
28
+ private updateConnectionState;
29
+ private createTimeoutPromise;
30
+ private getRecommendedSettings;
31
+ private sanitizeConfig;
32
+ private log;
33
+ on<E extends ClientEvent>(event: E, listener: ClientEventCallbacks[E]): this;
34
+ emit<E extends ClientEvent>(event: E, ...args: Parameters<ClientEventCallbacks[E]>): boolean;
35
+ }
36
+ //# sourceMappingURL=SogniClientWrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SogniClientWrapper.d.ts","sourceRoot":"","sources":["../../src/client/SogniClientWrapper.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,KAAK,EACV,iBAAiB,EACjB,aAAa,EACb,aAAa,EAGb,eAAe,EACf,SAAS,EACT,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAqBvC,qBAAa,kBAAmB,SAAQ,YAAY;IAClD,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,MAAM,CAA8B;IAC5C,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,cAAc,CAA+B;IACrD,OAAO,CAAC,cAAc,CAAkB;gBAE5B,MAAM,EAAE,iBAAiB;IAuC/B,OAAO,IAAI,OAAO,CAAC,IAAI,CA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niClientWrapper = void 0;
4
+ const events_1 = require("events");
5
+ const sogni_client_1 = require("@sogni-ai/sogni-client");
6
+ const types_1 = require("../types");
7
+ const errors_1 = require("../utils/errors");
8
+ const helpers_1 = require("../utils/helpers");
9
+ class SogniClientWrapper extends events_1.EventEmitter {
10
+ constructor(config) {
11
+ super();
12
+ this.client = null;
13
+ this.reconnectTimer = null;
14
+ this.isReconnecting = false;
15
+ (0, helpers_1.validateClientConfig)(config);
16
+ this.config = {
17
+ username: config.username,
18
+ password: config.password,
19
+ appId: config.appId || (0, helpers_1.generateAppId)(),
20
+ network: config.network || 'fast',
21
+ autoConnect: config.autoConnect !== false,
22
+ reconnect: config.reconnect !== false,
23
+ reconnectInterval: config.reconnectInterval || 5000,
24
+ timeout: config.timeout || 300000,
25
+ debug: config.debug || false,
26
+ };
27
+ this.connectionState = {
28
+ status: 'disconnected',
29
+ isConnected: false,
30
+ isConnecting: false,
31
+ reconnectAttempts: 0,
32
+ };
33
+ if (this.config.autoConnect) {
34
+ this.connect().catch((error) => {
35
+ this.log('Auto-connect failed:', error);
36
+ this.emit(types_1.ClientEvent.ERROR, errors_1.SogniError.fromError(error, 'AUTO_CONNECT_FAILED').toErrorData());
37
+ });
38
+ }
39
+ }
40
+ async connect() {
41
+ if (this.connectionState.isConnected) {
42
+ this.log('Already connected');
43
+ return;
44
+ }
45
+ if (this.connectionState.isConnecting) {
46
+ this.log('Connection already in progress');
47
+ await (0, helpers_1.waitFor)(() => this.connectionState.isConnected, {
48
+ timeout: 30000,
49
+ timeoutMessage: 'Connection timeout',
50
+ });
51
+ return;
52
+ }
53
+ this.updateConnectionState({ status: 'connecting', isConnecting: true });
54
+ try {
55
+ this.log('Creating Sogni client...');
56
+ this.client = await sogni_client_1.SogniClient.createInstance({
57
+ appId: this.config.appId,
58
+ network: this.config.network,
59
+ });
60
+ this.log('Logging in...');
61
+ await this.client.account.login(this.config.username, this.config.password);
62
+ this.log('Waiting for models...');
63
+ await this.client.projects.waitForModels();
64
+ this.log('Connected successfully');
65
+ this.updateConnectionState({
66
+ status: 'connected',
67
+ isConnected: true,
68
+ isConnecting: false,
69
+ reconnectAttempts: 0,
70
+ connectedAt: new Date(),
71
+ });
72
+ this.emit(types_1.ClientEvent.CONNECTED);
73
+ this.setupEventListeners();
74
+ }
75
+ catch (error) {
76
+ this.log('Connection failed:', error);
77
+ const sogniError = error instanceof Error && error.message.includes('auth')
78
+ ? new errors_1.SogniAuthenticationError('Authentication failed', undefined, error)
79
+ : new errors_1.SogniConnectionError('Failed to connect to Sogni Supernet', undefined, error);
80
+ this.updateConnectionState({
81
+ status: 'failed',
82
+ isConnected: false,
83
+ isConnecting: false,
84
+ lastError: sogniError.toErrorData(),
85
+ });
86
+ this.emit(types_1.ClientEvent.ERROR, sogniError.toErrorData());
87
+ if (this.config.reconnect && !this.isReconnecting) {
88
+ this.scheduleReconnect();
89
+ }
90
+ throw sogniError;
91
+ }
92
+ }
93
+ async disconnect() {
94
+ if (this.reconnectTimer) {
95
+ clearTimeout(this.reconnectTimer);
96
+ this.reconnectTimer = null;
97
+ }
98
+ this.isReconnecting = false;
99
+ if (this.client) {
100
+ this.client = null;
101
+ }
102
+ this.updateConnectionState({
103
+ status: 'disconnected',
104
+ isConnected: false,
105
+ isConnecting: false,
106
+ });
107
+ this.emit(types_1.ClientEvent.DISCONNECTED);
108
+ this.log('Disconnected');
109
+ }
110
+ isConnected() {
111
+ return this.connectionState.isConnected && this.client !== null;
112
+ }
113
+ getConnectionState() {
114
+ return { ...this.connectionState };
115
+ }
116
+ async getAvailableModels(options = {}) {
117
+ await this.ensureConnected();
118
+ let models = this.client.projects.availableModels;
119
+ if (options.network) {
120
+ }
121
+ if (options.minWorkers !== undefined) {
122
+ models = models.filter((m) => m.workerCount >= options.minWorkers);
123
+ }
124
+ if (options.sortByWorkers) {
125
+ models = [...models].sort((a, b) => b.workerCount - a.workerCount);
126
+ }
127
+ return models.map((model) => ({
128
+ ...model,
129
+ isAvailable: model.workerCount > 0,
130
+ recommendedSettings: this.getRecommendedSettings(model.id),
131
+ }));
132
+ }
133
+ async getModel(modelId) {
134
+ const models = await this.getAvailableModels();
135
+ const model = models.find((m) => m.id === modelId);
136
+ if (!model) {
137
+ throw new errors_1.SogniModelNotFoundError(modelId);
138
+ }
139
+ return model;
140
+ }
141
+ async getMostPopularModel() {
142
+ const models = await this.getAvailableModels({ sortByWorkers: true });
143
+ if (models.length === 0) {
144
+ throw new errors_1.SogniError('No models available', 'NO_MODELS_AVAILABLE');
145
+ }
146
+ return models[0];
147
+ }
148
+ async getBalance() {
149
+ await this.ensureConnected();
150
+ await (0, helpers_1.sleep)(1000);
151
+ const balances = this.client.account.balances;
152
+ return {
153
+ sogni: balances?.sogni || 0,
154
+ spark: balances?.spark || 0,
155
+ lastUpdated: new Date(),
156
+ };
157
+ }
158
+ async getSizePresets(network, modelId) {
159
+ await this.ensureConnected();
160
+ try {
161
+ const presets = await this.client.projects.getSizePresets(network, modelId);
162
+ return presets;
163
+ }
164
+ catch (error) {
165
+ throw errors_1.SogniError.fromError(error, 'GET_SIZE_PRESETS_FAILED');
166
+ }
167
+ }
168
+ async createProject(config) {
169
+ await this.ensureConnected();
170
+ (0, helpers_1.validateProjectConfig)(config);
171
+ const { waitForCompletion = true, timeout = this.config.timeout, onProgress, onJobCompleted, onJobFailed, ...projectParams } = config;
172
+ try {
173
+ this.log('Creating project with config:', this.sanitizeConfig(config));
174
+ const sdkParams = {
175
+ ...projectParams,
176
+ negativePrompt: projectParams.negativePrompt || '',
177
+ stylePrompt: projectParams.stylePrompt || '',
178
+ };
179
+ const project = await this.client.projects.create(sdkParams);
180
+ this.emit(types_1.ClientEvent.PROJECT_CREATED, project);
181
+ if (onProgress) {
182
+ project.on('progress', (progress) => {
183
+ const progressData = {
184
+ projectId: project.id,
185
+ percentage: progress,
186
+ completedJobs: 0,
187
+ totalJobs: projectParams.numberOfImages || 1,
188
+ };
189
+ onProgress(progressData);
190
+ this.emit(types_1.ClientEvent.PROJECT_PROGRESS, progressData);
191
+ });
192
+ }
193
+ if (onJobCompleted) {
194
+ project.on('jobCompleted', (job) => {
195
+ onJobCompleted(job);
196
+ });
197
+ }
198
+ if (onJobFailed) {
199
+ project.on('jobFailed', (job) => {
200
+ onJobFailed(job);
201
+ });
202
+ }
203
+ if (!waitForCompletion) {
204
+ return {
205
+ project,
206
+ completed: false,
207
+ };
208
+ }
209
+ this.log('Waiting for project completion...');
210
+ const imageUrls = await Promise.race([
211
+ project.waitForCompletion(),
212
+ this.createTimeoutPromise(timeout),
213
+ ]);
214
+ this.log('Project completed successfully');
215
+ const result = {
216
+ project,
217
+ imageUrls,
218
+ completed: true,
219
+ };
220
+ this.emit(types_1.ClientEvent.PROJECT_COMPLETED, result);
221
+ return result;
222
+ }
223
+ catch (error) {
224
+ this.log('Project failed:', error);
225
+ const projectError = error instanceof errors_1.SogniTimeoutError
226
+ ? error
227
+ : new errors_1.SogniProjectError('Project creation failed', undefined, error);
228
+ this.emit(types_1.ClientEvent.PROJECT_FAILED, projectError.toErrorData());
229
+ throw projectError;
230
+ }
231
+ }
232
+ async createProjectWithRetry(config, options = {}) {
233
+ const { maxAttempts = 3, retryDelay = 2000 } = options;
234
+ return (0, helpers_1.retry)(() => this.createProject(config), {
235
+ maxAttempts,
236
+ initialDelay: retryDelay,
237
+ onRetry: (attempt, error) => {
238
+ this.log(`Retry attempt ${attempt} after error:`, error.message);
239
+ },
240
+ });
241
+ }
242
+ async ensureConnected() {
243
+ if (!this.isConnected()) {
244
+ await this.connect();
245
+ }
246
+ }
247
+ setupEventListeners() {
248
+ if (!this.client)
249
+ return;
250
+ }
251
+ scheduleReconnect() {
252
+ if (this.reconnectTimer) {
253
+ return;
254
+ }
255
+ this.isReconnecting = true;
256
+ this.updateConnectionState({
257
+ status: 'reconnecting',
258
+ reconnectAttempts: this.connectionState.reconnectAttempts + 1,
259
+ });
260
+ this.emit(types_1.ClientEvent.RECONNECTING, this.connectionState.reconnectAttempts);
261
+ this.reconnectTimer = setTimeout(async () => {
262
+ this.reconnectTimer = null;
263
+ try {
264
+ await this.connect();
265
+ this.isReconnecting = false;
266
+ this.emit(types_1.ClientEvent.RECONNECTED);
267
+ }
268
+ catch (error) {
269
+ this.log('Reconnection failed:', error);
270
+ if (this.config.reconnect) {
271
+ this.scheduleReconnect();
272
+ }
273
+ else {
274
+ this.isReconnecting = false;
275
+ }
276
+ }
277
+ }, this.config.reconnectInterval);
278
+ }
279
+ updateConnectionState(updates) {
280
+ this.connectionState = {
281
+ ...this.connectionState,
282
+ ...updates,
283
+ };
284
+ }
285
+ createTimeoutPromise(timeoutMs) {
286
+ return new Promise((_, reject) => {
287
+ setTimeout(() => {
288
+ reject(new errors_1.SogniTimeoutError(`Operation timed out after ${timeoutMs}ms`, timeoutMs));
289
+ }, timeoutMs);
290
+ });
291
+ }
292
+ getRecommendedSettings(modelId) {
293
+ if (modelId.includes('flux')) {
294
+ return { steps: 4, guidance: 3.5 };
295
+ }
296
+ if (modelId.includes('lightning') || modelId.includes('turbo') || modelId.includes('lcm')) {
297
+ return { steps: 4, guidance: 1.0 };
298
+ }
299
+ return { steps: 20, guidance: 7.5 };
300
+ }
301
+ sanitizeConfig(config) {
302
+ const sanitized = { ...config };
303
+ if (sanitized.password)
304
+ sanitized.password = '***';
305
+ return sanitized;
306
+ }
307
+ log(...args) {
308
+ if (this.config.debug) {
309
+ console.log('[SogniClientWrapper]', ...args);
310
+ }
311
+ }
312
+ on(event, listener) {
313
+ return super.on(event, listener);
314
+ }
315
+ emit(event, ...args) {
316
+ return super.emit(event, ...args);
317
+ }
318
+ }
319
+ exports.SogniClientWrapper = SogniClientWrapper;
320
+ //# sourceMappingURL=SogniClientWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SogniClientWrapper.js","sourceRoot":"","sources":["../../src/client/SogniClientWrapper.ts"],"names":[],"mappings":";;;AAKA,mCAAsC;AACtC,yDAAmF;AAcnF,oCAAuC;AACvC,4CAOyB;AACzB,8CAO0B;AAK1B,MAAa,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,CAAC,MAAM,CAAC,EAAE,CAAC;YAC7B,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;QACrC,CAAC;QACD,IAAI,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1F,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;QACrC,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;IACtC,CAAC;IAKO,cAAc,CAAC,MAAW;QAChC,MAAM,SAAS,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC;QAChC,IAAI,SAAS,CAAC,QAAQ;YAAE,SAAS,CAAC,QAAQ,GAAG,KAAK,CAAC;QACnD,OAAO,SAAS,CAAC;IACnB,CAAC;IAKO,GAAG,CAAC,GAAG,IAAW;QACxB,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YACtB,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,GAAG,IAAI,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IAKD,EAAE,CAAwB,KAAQ,EAAE,QAAiC;QACnE,OAAO,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;IAKD,IAAI,CAAwB,KAAQ,EAAE,GAAG,IAAyC;QAChF,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;IACpC,CAAC;CACF;AAnfD,gDAmfC"}
@@ -0,0 +1,7 @@
1
+ export { SogniClientWrapper } from './client/SogniClientWrapper';
2
+ export type { SogniClientConfig, ProjectConfig, ProjectResult, ProjectProgress, ConnectionStatus, ConnectionState, ModelInfo, BalanceInfo, SizePreset, GetModelsOptions, CreateProjectOptions, ErrorData, Project, Job, AvailableModel, SupernetType, TokenType, OutputFormat, Scheduler, TimeStepSpacing, ControlNetParams, ControlNetName, ControlNetMode, } from './types';
3
+ export { ClientEvent } from './types';
4
+ export { SogniError, SogniConnectionError, SogniAuthenticationError, SogniProjectError, SogniTimeoutError, SogniBalanceError, SogniValidationError, SogniConfigurationError, SogniModelNotFoundError, SogniNetworkError, } from './utils/errors';
5
+ export { generateAppId, validateClientConfig, validateProjectConfig, sleep, retry, formatBytes, formatDuration, } from './utils/helpers';
6
+ export { SogniClientWrapper as default } from './client/SogniClientWrapper';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAGjE,YAAY,EACV,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,SAAS,EACT,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,oBAAoB,EACpB,SAAS,EAET,OAAO,EACP,GAAG,EACH,cAAc,EACd,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,SAAS,EACT,eAAe,EAEf,gBAAgB,EAChB,cAAc,EACd,cAAc,GACf,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtC,OAAO,EACL,UAAU,EACV,oBAAoB,EACpB,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,KAAK,EACL,KAAK,EACL,WAAW,EACX,cAAc,GACf,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,kBAAkB,IAAI,OAAO,EAAE,MAAM,6BAA6B,CAAC"}