@sogni-ai/sogni-client 4.2.0-alpha.2 → 4.2.0-alpha.21

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.
Files changed (109) hide show
  1. package/CHANGELOG.md +148 -0
  2. package/CLAUDE.md +25 -3
  3. package/README.md +411 -136
  4. package/dist/Account/index.d.ts +4 -2
  5. package/dist/Account/index.js +27 -23
  6. package/dist/Account/index.js.map +1 -1
  7. package/dist/Account/types.d.ts +7 -0
  8. package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/index.d.ts +3 -1
  9. package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/index.js +26 -2
  10. package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/index.js.map +1 -1
  11. package/dist/ApiClient/WebSocketClient/eventSubscriptions.d.ts +33 -0
  12. package/dist/ApiClient/WebSocketClient/eventSubscriptions.js +39 -0
  13. package/dist/ApiClient/WebSocketClient/eventSubscriptions.js.map +1 -0
  14. package/dist/ApiClient/WebSocketClient/events.d.ts +24 -7
  15. package/dist/ApiClient/WebSocketClient/index.d.ts +5 -1
  16. package/dist/ApiClient/WebSocketClient/index.js +24 -1
  17. package/dist/ApiClient/WebSocketClient/index.js.map +1 -1
  18. package/dist/ApiClient/WebSocketClient/messages.d.ts +2 -0
  19. package/dist/ApiClient/WebSocketClient/types.d.ts +2 -0
  20. package/dist/ApiClient/index.d.ts +6 -1
  21. package/dist/ApiClient/index.js +7 -3
  22. package/dist/ApiClient/index.js.map +1 -1
  23. package/dist/Chat/ChatTools.d.ts +5 -49
  24. package/dist/Chat/ChatTools.js +311 -88
  25. package/dist/Chat/ChatTools.js.map +1 -1
  26. package/dist/Chat/index.d.ts +11 -2
  27. package/dist/Chat/index.js +78 -4
  28. package/dist/Chat/index.js.map +1 -1
  29. package/dist/Chat/modelRouting.d.ts +100 -0
  30. package/dist/Chat/modelRouting.js +441 -0
  31. package/dist/Chat/modelRouting.js.map +1 -0
  32. package/dist/Chat/sogniHostedTools.generated.json +529 -0
  33. package/dist/Chat/tools.d.ts +9 -55
  34. package/dist/Chat/tools.js +72 -228
  35. package/dist/Chat/tools.js.map +1 -1
  36. package/dist/Chat/types.d.ts +91 -2
  37. package/dist/CreativeWorkflows/index.d.ts +23 -0
  38. package/dist/CreativeWorkflows/index.js +274 -0
  39. package/dist/CreativeWorkflows/index.js.map +1 -0
  40. package/dist/CreativeWorkflows/types.d.ts +106 -0
  41. package/dist/CreativeWorkflows/types.js +3 -0
  42. package/dist/CreativeWorkflows/types.js.map +1 -0
  43. package/dist/Projects/Job.d.ts +6 -0
  44. package/dist/Projects/Job.js +60 -5
  45. package/dist/Projects/Job.js.map +1 -1
  46. package/dist/Projects/Project.js +15 -3
  47. package/dist/Projects/Project.js.map +1 -1
  48. package/dist/Projects/createJobRequestMessage.js +140 -6
  49. package/dist/Projects/createJobRequestMessage.js.map +1 -1
  50. package/dist/Projects/index.d.ts +10 -1
  51. package/dist/Projects/index.js +197 -58
  52. package/dist/Projects/index.js.map +1 -1
  53. package/dist/Projects/types/ModelOptions.d.ts +3 -3
  54. package/dist/Projects/types/ModelOptions.js +12 -5
  55. package/dist/Projects/types/ModelOptions.js.map +1 -1
  56. package/dist/Projects/types/ModelTiersRaw.d.ts +7 -7
  57. package/dist/Projects/types/RawProject.d.ts +2 -0
  58. package/dist/Projects/types/events.d.ts +5 -4
  59. package/dist/Projects/types/index.d.ts +77 -7
  60. package/dist/Projects/types/index.js.map +1 -1
  61. package/dist/Projects/utils/index.d.ts +8 -1
  62. package/dist/Projects/utils/index.js +22 -8
  63. package/dist/Projects/utils/index.js.map +1 -1
  64. package/dist/index.d.ts +28 -3
  65. package/dist/index.js +19 -1
  66. package/dist/index.js.map +1 -1
  67. package/dist/lib/RestClient.d.ts +4 -1
  68. package/dist/lib/RestClient.js +17 -9
  69. package/dist/lib/RestClient.js.map +1 -1
  70. package/dist/lib/mediaValidation.d.ts +16 -0
  71. package/dist/lib/mediaValidation.js +280 -0
  72. package/dist/lib/mediaValidation.js.map +1 -0
  73. package/dist/lib/validation.d.ts +6 -1
  74. package/dist/lib/validation.js +28 -2
  75. package/dist/lib/validation.js.map +1 -1
  76. package/llms-full.txt +372 -133
  77. package/llms.txt +197 -86
  78. package/package.json +13 -4
  79. package/src/Account/index.ts +22 -2
  80. package/src/Account/types.ts +7 -0
  81. package/src/ApiClient/WebSocketClient/BrowserWebSocketClient/index.ts +47 -3
  82. package/src/ApiClient/WebSocketClient/eventSubscriptions.ts +92 -0
  83. package/src/ApiClient/WebSocketClient/events.ts +25 -7
  84. package/src/ApiClient/WebSocketClient/index.ts +33 -1
  85. package/src/ApiClient/WebSocketClient/messages.ts +2 -0
  86. package/src/ApiClient/WebSocketClient/types.ts +2 -0
  87. package/src/ApiClient/index.ts +32 -2
  88. package/src/Chat/ChatTools.ts +395 -95
  89. package/src/Chat/index.ts +149 -5
  90. package/src/Chat/modelRouting.ts +602 -0
  91. package/src/Chat/sogniHostedTools.generated.json +529 -0
  92. package/src/Chat/tools.ts +98 -245
  93. package/src/Chat/types.ts +100 -2
  94. package/src/CreativeWorkflows/index.ts +290 -0
  95. package/src/CreativeWorkflows/types.ts +134 -0
  96. package/src/Projects/Job.ts +76 -5
  97. package/src/Projects/Project.ts +13 -3
  98. package/src/Projects/createJobRequestMessage.ts +152 -13
  99. package/src/Projects/index.ts +230 -52
  100. package/src/Projects/types/ModelOptions.ts +15 -8
  101. package/src/Projects/types/ModelTiersRaw.ts +7 -7
  102. package/src/Projects/types/RawProject.ts +2 -0
  103. package/src/Projects/types/events.ts +5 -4
  104. package/src/Projects/types/index.ts +86 -6
  105. package/src/Projects/utils/index.ts +24 -8
  106. package/src/index.ts +93 -0
  107. package/src/lib/RestClient.ts +15 -5
  108. package/src/lib/mediaValidation.ts +367 -0
  109. package/src/lib/validation.ts +38 -2
@@ -32,7 +32,9 @@ export interface SizePreset {
32
32
  aspect: string;
33
33
  }
34
34
 
35
- export type ImageOutputFormat = 'png' | 'jpg';
35
+ export type ImageOutputFormat = 'png' | 'jpg' | 'webp';
36
+ export type GptImageQuality = 'low' | 'medium' | 'high' | 'auto' | 'standard' | 'hd';
37
+ export type GptImageBackground = 'opaque' | 'auto';
36
38
  export type VideoOutputFormat = 'mp4';
37
39
  export type AudioOutputFormat = 'mp3' | 'flac' | 'wav';
38
40
 
@@ -85,6 +87,10 @@ export interface BaseProjectParams {
85
87
  * If not specified, the Sogni token will be used.
86
88
  */
87
89
  tokenType?: TokenType;
90
+ /**
91
+ * Optional client app/source label to attach to the project request for server-side attribution.
92
+ */
93
+ appSource?: string;
88
94
  /**
89
95
  * Array of LoRA IDs to apply.
90
96
  * Available LoRAs are model-specific. The worker will download the LoRA
@@ -123,6 +129,14 @@ export type InputMedia = File | Buffer | Blob | boolean;
123
129
  * - Frame count is calculated as: `duration * fps + 1`
124
130
  * - Frame count must follow the pattern: `1 + n*8` (i.e., 1, 9, 17, 25, 33, ...)
125
131
  * - Example: 5 seconds at 24fps = 121 frames (since 121 = 1 + 15*8)
132
+ *
133
+ * ### Seedance 2.0 Models (seedance-2-0*)
134
+ * - External API-backed video models for text-to-video, image-to-video,
135
+ * multimodal reference generation, image+audio-to-video, and video-to-video
136
+ * - Generate at fixed 24fps
137
+ * - Direct SDK project duration range is 4 to 15 seconds
138
+ * - Frame count is calculated as: `duration * 24 + 1`
139
+ * - Vendor reference limits are 9 images, 3 videos, 3 audios, and 12 asset files total
126
140
  */
127
141
  export interface VideoProjectParams extends BaseProjectParams {
128
142
  type: 'video';
@@ -133,11 +147,13 @@ export interface VideoProjectParams extends BaseProjectParams {
133
147
  */
134
148
  frames?: number;
135
149
  /**
136
- * Duration of the video in seconds. Supported range 1 to 10 (WAN) or 4 to 20 (LTX-2.3).
150
+ * Duration of the video in seconds. Supported range 1 to 10 (WAN), 4 to 20 (LTX-2.3),
151
+ * or 4 to 15 (Seedance direct SDK projects).
137
152
  *
138
153
  * The SDK automatically calculates the correct frame count based on the model:
139
154
  * - WAN 2.2: `duration * 16 + 1` (always 16fps generation)
140
155
  * - LTX-2.3: `duration * fps + 1`, snapped to frame step constraint
156
+ * - Seedance: `duration * 24 + 1`
141
157
  */
142
158
  duration?: number;
143
159
  /**
@@ -148,6 +164,8 @@ export interface VideoProjectParams extends BaseProjectParams {
148
164
  *
149
165
  * **LTX-2.3 Models:** Any value from 1-60 fps. This directly controls the generation
150
166
  * frame rate - there is no post-render interpolation.
167
+ *
168
+ * **Seedance Models:** Fixed 24fps external API generation.
151
169
  */
152
170
  fps?: number;
153
171
  /**
@@ -167,6 +185,12 @@ export interface VideoProjectParams extends BaseProjectParams {
167
185
  * Maps to: startImage (i2v), characterImage (animate), referenceImage (s2v, ia2v)
168
186
  */
169
187
  referenceImage?: InputMedia;
188
+ /**
189
+ * Seedance-only loose image context references. These must be publicly
190
+ * accessible HTTPS URLs that the vendor can fetch. Use referenceImage /
191
+ * referenceImageEnd when the image should lock the first or last frame.
192
+ */
193
+ referenceImageUrls?: string[];
170
194
  /**
171
195
  * Optional end image for i2v interpolation workflows.
172
196
  * When provided with referenceImage, the video will interpolate between the two images.
@@ -176,6 +200,17 @@ export interface VideoProjectParams extends BaseProjectParams {
176
200
  * Reference audio for audio-driven video workflows (s2v, ia2v, a2v).
177
201
  */
178
202
  referenceAudio?: InputMedia;
203
+ /**
204
+ * Seedance-only audio context references. These must be publicly accessible
205
+ * HTTPS URLs. Seedance does not support text+audio-only requests; include at
206
+ * least one image or video reference when using audio URL references.
207
+ */
208
+ referenceAudioUrls?: string[];
209
+ /**
210
+ * Enable native audio generation for external API-backed video models that support it.
211
+ * Seedance defaults to audio enabled server-side; set to false to request a silent video.
212
+ */
213
+ generateAudio?: boolean;
179
214
  /**
180
215
  * Reference audio for ID-LoRA speaker identity transfer (LTX-2.3 only).
181
216
  * Provide a ~5 second audio clip of the target speaker's voice.
@@ -208,6 +243,11 @@ export interface VideoProjectParams extends BaseProjectParams {
208
243
  * Maps to: drivingVideo (animate-move), sourceVideo (animate-replace), referenceVideo (v2v)
209
244
  */
210
245
  referenceVideo?: InputMedia;
246
+ /**
247
+ * Seedance-only video context references. These must be publicly accessible
248
+ * HTTPS URLs and map to Seedance reference_video assets.
249
+ */
250
+ referenceVideoUrls?: string[];
211
251
  /**
212
252
  * ControlNet parameters for LTX-2.3 v2v workflows.
213
253
  * Specifies which control signal to extract from the reference video.
@@ -301,6 +341,7 @@ export interface ImageProjectParams extends BaseProjectParams {
301
341
  startingImageStrength?: number;
302
342
  /**
303
343
  * Context images for multi-reference image generation.
344
+ * GPT Image 2 supports up to 16 context images.
304
345
  * Flux.2 Dev supports up to 6 context images.
305
346
  * Qwen Image Edit Plus supports up to 3 context images.
306
347
  * Flux Kontext supports up to 2 context images.
@@ -337,6 +378,15 @@ export interface ImageProjectParams extends BaseProjectParams {
337
378
  * Output format. Can be 'png' or 'jpg'. Defaults to 'png'.
338
379
  */
339
380
  outputFormat?: ImageOutputFormat;
381
+ /**
382
+ * GPT Image 2 quality preset. Only used by external OpenAI image models.
383
+ * Defaults to 'medium'.
384
+ */
385
+ gptImageQuality?: GptImageQuality;
386
+ /**
387
+ * GPT Image 2 background mode. Only used by external OpenAI image models.
388
+ */
389
+ gptImageBackground?: GptImageBackground;
340
390
  }
341
391
 
342
392
  export interface AudioProjectParams extends BaseProjectParams {
@@ -446,6 +496,16 @@ export type ImageUrlParams = {
446
496
  | 'contextImage4'
447
497
  | 'contextImage5'
448
498
  | 'contextImage6'
499
+ | 'contextImage7'
500
+ | 'contextImage8'
501
+ | 'contextImage9'
502
+ | 'contextImage10'
503
+ | 'contextImage11'
504
+ | 'contextImage12'
505
+ | 'contextImage13'
506
+ | 'contextImage14'
507
+ | 'contextImage15'
508
+ | 'contextImage16'
449
509
  | 'referenceImage'
450
510
  | 'referenceImageEnd';
451
511
  startContentType?: string;
@@ -520,10 +580,18 @@ export interface EstimateRequest {
520
580
  */
521
581
  sampler?: string;
522
582
  /**
523
- * Number of context images to use (for Flux Kontext).
524
- * Note that this parameter is ignored if `scheduler` is not provided
583
+ * Number of context images to use. Affects GPT Image 2 input-image pricing
584
+ * and context-aware worker timing estimates.
525
585
  */
526
586
  contextImages?: number;
587
+ /**
588
+ * GPT Image 2 quality preset, when estimating external OpenAI image jobs.
589
+ */
590
+ gptImageQuality?: GptImageQuality;
591
+ /**
592
+ * Output format, when estimating models with format-specific request metadata.
593
+ */
594
+ outputFormat?: ImageOutputFormat;
527
595
  }
528
596
 
529
597
  export interface VideoEstimateRequest {
@@ -538,8 +606,20 @@ export interface VideoEstimateRequest {
538
606
  */
539
607
  frames?: number;
540
608
  fps: number;
541
- steps: number;
609
+ steps?: number;
542
610
  numberOfMedia: number;
611
+ /**
612
+ * Price Seedance estimates using the video-input rate band.
613
+ */
614
+ hasVideoInput?: boolean;
615
+ /**
616
+ * Optional estimate-only signal: presence implies Seedance video-input pricing.
617
+ */
618
+ referenceVideo?: unknown;
619
+ /**
620
+ * Optional estimate-only signal: non-empty list implies Seedance video-input pricing.
621
+ */
622
+ referenceVideoUrls?: string[];
543
623
  }
544
624
 
545
625
  export interface AudioEstimateRequest {
@@ -567,7 +647,7 @@ export interface CostEstimation {
567
647
  export type EnhancementStrength = 'light' | 'medium' | 'heavy';
568
648
 
569
649
  /**
570
- * Video workflow types for WAN and LTX-2.3 models
650
+ * Video workflow types for WAN, LTX-2.3, and Seedance models
571
651
  */
572
652
  export type VideoWorkflowType =
573
653
  | 't2v'
@@ -17,7 +17,12 @@ export function getEnhacementStrength(strength: EnhancementStrength): number {
17
17
  * Video models produce MP4 output; image models produce PNG/JPG output.
18
18
  */
19
19
  export function isVideoModel(modelId: string): boolean {
20
- return modelId.startsWith('wan_') || modelId.startsWith('ltx2-') || modelId.startsWith('ltx23-');
20
+ return (
21
+ modelId.startsWith('wan_') ||
22
+ modelId.startsWith('ltx2-') ||
23
+ modelId.startsWith('ltx23-') ||
24
+ modelId.startsWith('seedance-2-0')
25
+ );
21
26
  }
22
27
 
23
28
  /**
@@ -67,6 +72,16 @@ export function isLtx2Model(modelId: string): boolean {
67
72
  return modelId.startsWith('ltx2-') || modelId.startsWith('ltx23-');
68
73
  }
69
74
 
75
+ /**
76
+ * Check if a model ID is a Seedance 2.0 video model.
77
+ *
78
+ * Seedance models are external API-backed video models. They generate at
79
+ * 24fps and support 4-15 second direct SDK project durations.
80
+ */
81
+ export function isSeedanceModel(modelId: string): boolean {
82
+ return modelId.startsWith('seedance-2-0');
83
+ }
84
+
70
85
  /**
71
86
  * LTX-2.3 frame step constraint.
72
87
  * Valid frame counts follow the pattern: 1 + n*8 (i.e., 1, 9, 17, 25, 33, ...)
@@ -76,7 +91,7 @@ export const LTX2_FRAME_STEP = 8;
76
91
  /**
77
92
  * Calculate the frame count for a given duration and fps based on the video model.
78
93
  *
79
- * ## Standard Behavior (LTX-2.3 and future models)
94
+ * ## Standard Behavior (LTX-2.3, Seedance, and future models)
80
95
  * - Generate at the actual specified FPS (no interpolation)
81
96
  * - Formula: duration * fps + 1
82
97
  * - LTX-2.3 specific: Frame count must follow the pattern: 1 + n*8
@@ -139,21 +154,22 @@ export function getVideoWorkflowType(modelId: string): VideoWorkflowType {
139
154
  // Check for supported video model prefixes
140
155
  const isWan = modelId.startsWith('wan_');
141
156
  const isLtx2 = modelId.startsWith('ltx2-') || modelId.startsWith('ltx23-');
157
+ const isSeedance = modelId.startsWith('seedance-2-0');
142
158
 
143
- if (!isWan && !isLtx2) return null;
159
+ if (!isWan && !isLtx2 && !isSeedance) return null;
144
160
 
145
- // WAN and LTX-2.3 models share similar workflow type suffixes
161
+ // WAN, LTX-2.3, and Seedance models share similar workflow type suffixes
146
162
  if (modelId.includes('_i2v')) return 'i2v';
147
163
  if (modelId.includes('_t2v')) return 't2v';
148
164
 
149
- // LTX-2.3 v2v ControlNet workflows (model IDs use underscore: ltx23-22b-fp8_v2v_distilled)
150
- if (isLtx2 && modelId.includes('_v2v')) return 'v2v';
165
+ // LTX-2.3 v2v ControlNet and Seedance v2v workflows
166
+ if ((isLtx2 || isSeedance) && modelId.includes('_v2v')) return 'v2v';
151
167
 
152
- // LTX-2.3 audio-to-video workflows
168
+ // LTX-2.3 and Seedance image+audio workflows
153
169
  // ia2v = image+audio to video (requires referenceImage + referenceAudio)
154
170
  // a2v = audio to video (requires referenceAudio only)
155
171
  // Note: Check _ia2v before _a2v since _ia2v contains _a2v as a substring
156
- if (isLtx2 && modelId.includes('_ia2v')) return 'ia2v';
172
+ if ((isLtx2 || isSeedance) && modelId.includes('_ia2v')) return 'ia2v';
157
173
  if (isLtx2 && modelId.includes('_a2v')) return 'a2v';
158
174
 
159
175
  // WAN-specific workflow types
package/src/index.ts CHANGED
@@ -4,6 +4,16 @@ import CurrentAccount from './Account/CurrentAccount';
4
4
  // ApiClient
5
5
  import ApiClient, { ApiError, ApiResponse } from './ApiClient';
6
6
  import { SupernetType } from './ApiClient/WebSocketClient/types';
7
+ import type {
8
+ SocketEventName,
9
+ SocketEventSubscriptionsUpdatedData
10
+ } from './ApiClient/WebSocketClient/events';
11
+ import type {
12
+ SocketEventSubscriptionInput,
13
+ SocketEventSubscriptionName,
14
+ SocketEventSubscriptions,
15
+ SocketEventSubscriptionUpdate
16
+ } from './ApiClient/WebSocketClient/eventSubscriptions';
7
17
  import { ApiConfig } from './ApiGroup';
8
18
  // Utils
9
19
  import { DefaultLogger, Logger, LogLevel } from './lib/DefaultLogger';
@@ -42,7 +52,13 @@ import {
42
52
  ChatCompletionChunk,
43
53
  ChatCompletionResult,
44
54
  ChatJobStateEvent,
55
+ ChatResponseFormat,
45
56
  ContentPart,
57
+ HostedChatCompletionParams,
58
+ HostedChatCompletionResult,
59
+ HostedChatCompletionChoice,
60
+ HostedChatCompletionMessage,
61
+ HostedCreativeWorkflowReference,
46
62
  TextContentPart,
47
63
  ImageUrlContentPart,
48
64
  TokenUsage as ChatTokenUsage,
@@ -57,12 +73,32 @@ import {
57
73
  ToolCallFunction,
58
74
  ToolChoice,
59
75
  ToolFunction,
76
+ SogniToolsMode,
60
77
  ToolExecutionProgress,
61
78
  ToolExecutionResult,
62
79
  ToolHistoryEntry,
63
80
  ToolExecutionOptions
64
81
  } from './Chat/types';
65
82
  import { SogniTools, buildSogniTools, isSogniToolCall, parseToolCallArguments } from './Chat/tools';
83
+ // Creative Workflows API
84
+ import CreativeWorkflowsApi, { parseCreativeWorkflowSseChunk } from './CreativeWorkflows';
85
+ import {
86
+ CreativeWorkflowArtifact,
87
+ CreativeWorkflowEvent,
88
+ CreativeWorkflowKind,
89
+ CreativeWorkflowRecord,
90
+ CreativeWorkflowSseEvent,
91
+ CreativeWorkflowStatus,
92
+ CreativeWorkflowHostedToolName,
93
+ ListCreativeWorkflowOptions,
94
+ StartCreativeWorkflowOptions,
95
+ StartCreativeWorkflowParams,
96
+ StartHostedToolSequenceWorkflowDependency,
97
+ StartHostedToolSequenceWorkflowInput,
98
+ StartHostedToolSequenceWorkflowStep,
99
+ StartImageToVideoWorkflowInput,
100
+ StreamCreativeWorkflowEventsOptions
101
+ } from './CreativeWorkflows/types';
66
102
  // Stats API
67
103
  import StatsApi from './Stats';
68
104
  // Base Types
@@ -86,9 +122,22 @@ export type {
86
122
  ChatCompletionResult,
87
123
  ChatJobStateEvent,
88
124
  ChatMessage,
125
+ ChatResponseFormat,
89
126
  ChatTokenUsage,
90
127
  ContentPart,
128
+ HostedChatCompletionChoice,
129
+ HostedChatCompletionMessage,
130
+ HostedChatCompletionParams,
131
+ HostedChatCompletionResult,
132
+ HostedCreativeWorkflowReference,
133
+ CreativeWorkflowArtifact,
134
+ CreativeWorkflowEvent,
135
+ CreativeWorkflowKind,
136
+ CreativeWorkflowRecord,
137
+ CreativeWorkflowSseEvent,
138
+ CreativeWorkflowStatus,
91
139
  ImageUrlContentPart,
140
+ ListCreativeWorkflowOptions,
92
141
  LLMCostEstimation,
93
142
  LLMJobCost,
94
143
  LLMModelInfo,
@@ -106,6 +155,14 @@ export type {
106
155
  LogLevel,
107
156
  ProjectParams,
108
157
  ProjectStatus,
158
+ CreativeWorkflowHostedToolName,
159
+ StartCreativeWorkflowOptions,
160
+ StartCreativeWorkflowParams,
161
+ StartHostedToolSequenceWorkflowDependency,
162
+ StartHostedToolSequenceWorkflowInput,
163
+ StartHostedToolSequenceWorkflowStep,
164
+ StartImageToVideoWorkflowInput,
165
+ StreamCreativeWorkflowEventsOptions,
109
166
  SupernetType,
110
167
  TokenType,
111
168
  ToolCall,
@@ -118,6 +175,13 @@ export type {
118
175
  ToolExecutionResult,
119
176
  ToolFunction,
120
177
  ToolHistoryEntry,
178
+ SogniToolsMode,
179
+ SocketEventName,
180
+ SocketEventSubscriptionInput,
181
+ SocketEventSubscriptionName,
182
+ SocketEventSubscriptions,
183
+ SocketEventSubscriptionsUpdatedData,
184
+ SocketEventSubscriptionUpdate,
121
185
  VideoControlNetName,
122
186
  VideoControlNetParams,
123
187
  VideoFormat,
@@ -131,12 +195,14 @@ export {
131
195
  ApiKeyAuthManager,
132
196
  ChatStream,
133
197
  ChatToolsApi,
198
+ CreativeWorkflowsApi,
134
199
  CurrentAccount,
135
200
  Job,
136
201
  Project,
137
202
  SogniTools,
138
203
  buildSogniTools,
139
204
  isSogniToolCall,
205
+ parseCreativeWorkflowSseChunk,
140
206
  parseToolCallArguments
141
207
  };
142
208
 
@@ -145,6 +211,19 @@ export interface SogniClientConfig {
145
211
  * The application ID string. Must be unique, multiple connections with the same ID will be rejected.
146
212
  */
147
213
  appId: string;
214
+ /**
215
+ * Optional client app/source label to attach to this connection for server-side attribution.
216
+ * The socket server uses this as the default source for project and chat requests from this client.
217
+ */
218
+ appSource?: string;
219
+ /**
220
+ * Initial WebSocket event subscriptions for this connection.
221
+ *
222
+ * Omit this option to receive the default socket event stream. To reduce socket traffic for
223
+ * proxy or headless clients that do not need live worker counts, set
224
+ * `{ modelAvailability: false }` to opt out of `swarmModels` and `swarmLLMModels` updates.
225
+ */
226
+ socketEventSubscriptions?: SocketEventSubscriptions;
148
227
  /**
149
228
  * Override the default REST API endpoint
150
229
  * @internal
@@ -214,6 +293,7 @@ export class SogniClient {
214
293
  projects: ProjectsApi;
215
294
  stats: StatsApi;
216
295
  chat: ChatApi;
296
+ creativeWorkflows: CreativeWorkflowsApi;
217
297
 
218
298
  apiClient: ApiClient;
219
299
 
@@ -222,6 +302,7 @@ export class SogniClient {
222
302
  this.projects = new ProjectsApi(config);
223
303
  this.stats = new StatsApi(config);
224
304
  this.chat = new ChatApi(config, this.projects);
305
+ this.creativeWorkflows = new CreativeWorkflowsApi(config);
225
306
 
226
307
  this.apiClient = config.client;
227
308
  }
@@ -277,6 +358,16 @@ export class SogniClient {
277
358
  this.apiClient.dispose();
278
359
  }
279
360
 
361
+ /**
362
+ * Update WebSocket event subscriptions for this live client.
363
+ *
364
+ * This is useful when a process needs the initial model availability snapshot for startup, but
365
+ * does not need ongoing worker count updates afterward.
366
+ */
367
+ async setSocketEventSubscriptions(update: SocketEventSubscriptionInput): Promise<void> {
368
+ await this.apiClient.setSocketEventSubscriptions(update);
369
+ }
370
+
280
371
  /**
281
372
  * Create client instance, with default configuration
282
373
  * @param config
@@ -293,6 +384,8 @@ export class SogniClient {
293
384
  baseUrl: restEndpoint,
294
385
  socketUrl: socketEndpoint,
295
386
  appId: config.appId,
387
+ appSource: config.appSource,
388
+ socketEventSubscriptions: config.socketEventSubscriptions,
296
389
  networkType: network,
297
390
  logger,
298
391
  authType,
@@ -4,6 +4,10 @@ import { JSONValue } from '../types/json';
4
4
  import { Logger } from './DefaultLogger';
5
5
  import { AuthManager } from './AuthManager';
6
6
 
7
+ interface RestRequestInit extends RequestInit {
8
+ timeoutMs?: number;
9
+ }
10
+
7
11
  class RestClient<E extends EventMap = never> extends TypedEventEmitter<E> {
8
12
  readonly baseUrl: string;
9
13
  protected _auth: AuthManager;
@@ -28,14 +32,15 @@ class RestClient<E extends EventMap = never> extends TypedEventEmitter<E> {
28
32
  return url.toString();
29
33
  }
30
34
 
31
- private async request<T = JSONValue>(url: string, options: RequestInit = {}): Promise<T> {
32
- const init = await this.auth.authenticateRequest(options);
35
+ private async request<T = JSONValue>(url: string, options: RestRequestInit = {}): Promise<T> {
36
+ const { timeoutMs = 30000, ...requestOptions } = options;
37
+ const init = await this.auth.authenticateRequest(requestOptions);
33
38
 
34
39
  // Add a timeout to detect hanging requests
35
40
  const controller = new AbortController();
36
41
  const timeoutId = setTimeout(() => {
37
42
  controller.abort();
38
- }, 30000);
43
+ }, timeoutMs);
39
44
 
40
45
  try {
41
46
  const response = await fetch(url, { ...init, signal: controller.signal });
@@ -69,13 +74,18 @@ class RestClient<E extends EventMap = never> extends TypedEventEmitter<E> {
69
74
  return this.request<T>(this.formatUrl(path, query));
70
75
  }
71
76
 
72
- post<T = JSONValue>(path: string, body: Record<string, unknown> = {}): Promise<T> {
77
+ post<T = JSONValue>(
78
+ path: string,
79
+ body: Record<string, unknown> = {},
80
+ options: Pick<RestRequestInit, 'timeoutMs'> = {}
81
+ ): Promise<T> {
73
82
  return this.request<T>(this.formatUrl(path), {
74
83
  method: 'POST',
75
84
  headers: {
76
85
  'Content-Type': 'application/json'
77
86
  },
78
- body: JSON.stringify(body)
87
+ body: JSON.stringify(body),
88
+ ...options
79
89
  });
80
90
  }
81
91
  }