@sogni-ai/sogni-client 4.0.0-alpha.9 → 4.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/CHANGELOG.md +268 -0
- package/README.md +262 -27
- package/dist/Account/index.d.ts +18 -16
- package/dist/Account/index.js +31 -20
- package/dist/Account/index.js.map +1 -1
- package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/ChannelCoordinator.d.ts +66 -0
- package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/ChannelCoordinator.js +332 -0
- package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/ChannelCoordinator.js.map +1 -0
- package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/index.d.ts +28 -0
- package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/index.js +203 -0
- package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/index.js.map +1 -0
- package/dist/ApiClient/WebSocketClient/events.d.ts +12 -0
- package/dist/ApiClient/WebSocketClient/index.d.ts +2 -2
- package/dist/ApiClient/WebSocketClient/index.js +13 -3
- package/dist/ApiClient/WebSocketClient/index.js.map +1 -1
- package/dist/ApiClient/WebSocketClient/types.d.ts +13 -0
- package/dist/ApiClient/index.d.ts +4 -4
- package/dist/ApiClient/index.js +23 -4
- package/dist/ApiClient/index.js.map +1 -1
- package/dist/Projects/Job.d.ts +44 -4
- package/dist/Projects/Job.js +83 -16
- package/dist/Projects/Job.js.map +1 -1
- package/dist/Projects/Project.d.ts +18 -0
- package/dist/Projects/Project.js +38 -10
- package/dist/Projects/Project.js.map +1 -1
- package/dist/Projects/createJobRequestMessage.js +170 -13
- package/dist/Projects/createJobRequestMessage.js.map +1 -1
- package/dist/Projects/index.d.ts +112 -11
- package/dist/Projects/index.js +473 -45
- package/dist/Projects/index.js.map +1 -1
- package/dist/Projects/types/ComfySamplerParams.d.ts +28 -0
- package/dist/Projects/types/ComfySamplerParams.js +36 -0
- package/dist/Projects/types/ComfySamplerParams.js.map +1 -0
- package/dist/Projects/types/ComfySchedulerParams.d.ts +17 -0
- package/dist/Projects/types/ComfySchedulerParams.js +23 -0
- package/dist/Projects/types/ComfySchedulerParams.js.map +1 -0
- package/dist/Projects/types/EstimationResponse.d.ts +2 -0
- package/dist/Projects/types/ForgeSamplerParams.d.ts +27 -0
- package/dist/Projects/types/ForgeSamplerParams.js +39 -0
- package/dist/Projects/types/ForgeSamplerParams.js.map +1 -0
- package/dist/Projects/types/ForgeSchedulerParams.d.ts +17 -0
- package/dist/Projects/types/ForgeSchedulerParams.js +28 -0
- package/dist/Projects/types/ForgeSchedulerParams.js.map +1 -0
- package/dist/Projects/types/events.d.ts +5 -1
- package/dist/Projects/types/index.d.ts +205 -38
- package/dist/Projects/types/index.js +17 -0
- package/dist/Projects/types/index.js.map +1 -1
- package/dist/Projects/utils.d.ts +19 -1
- package/dist/Projects/utils.js +68 -0
- package/dist/Projects/utils.js.map +1 -1
- package/dist/index.d.ts +12 -4
- package/dist/index.js +14 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/AuthManager/TokenAuthManager.js +0 -2
- package/dist/lib/AuthManager/TokenAuthManager.js.map +1 -1
- package/dist/lib/DataEntity.js +4 -2
- package/dist/lib/DataEntity.js.map +1 -1
- package/dist/lib/RestClient.js +15 -2
- package/dist/lib/RestClient.js.map +1 -1
- package/dist/lib/validation.d.ts +26 -2
- package/dist/lib/validation.js +95 -10
- package/dist/lib/validation.js.map +1 -1
- package/package.json +4 -4
- package/src/Account/index.ts +30 -19
- package/src/ApiClient/WebSocketClient/BrowserWebSocketClient/ChannelCoordinator.ts +426 -0
- package/src/ApiClient/WebSocketClient/BrowserWebSocketClient/index.ts +237 -0
- package/src/ApiClient/WebSocketClient/events.ts +14 -0
- package/src/ApiClient/WebSocketClient/index.ts +15 -5
- package/src/ApiClient/WebSocketClient/types.ts +16 -0
- package/src/ApiClient/index.ts +30 -8
- package/src/Projects/Job.ts +97 -16
- package/src/Projects/Project.ts +46 -13
- package/src/Projects/createJobRequestMessage.ts +222 -35
- package/src/Projects/index.ts +504 -49
- package/src/Projects/types/ComfySamplerParams.ts +34 -0
- package/src/Projects/types/ComfySchedulerParams.ts +21 -0
- package/src/Projects/types/EstimationResponse.ts +2 -0
- package/src/Projects/types/ForgeSamplerParams.ts +37 -0
- package/src/Projects/types/ForgeSchedulerParams.ts +26 -0
- package/src/Projects/types/events.ts +6 -0
- package/src/Projects/types/index.ts +243 -39
- package/src/Projects/utils.ts +66 -1
- package/src/index.ts +60 -8
- package/src/lib/AuthManager/TokenAuthManager.ts +0 -2
- package/src/lib/DataEntity.ts +4 -2
- package/src/lib/RestClient.ts +16 -2
- package/src/lib/validation.ts +111 -14
- package/dist/Projects/types/SamplerParams.d.ts +0 -12
- package/dist/Projects/types/SamplerParams.js +0 -21
- package/dist/Projects/types/SamplerParams.js.map +0 -1
- package/dist/Projects/types/SchedulerParams.d.ts +0 -13
- package/dist/Projects/types/SchedulerParams.js +0 -19
- package/dist/Projects/types/SchedulerParams.js.map +0 -1
- package/src/Projects/types/SamplerParams.ts +0 -19
- package/src/Projects/types/SchedulerParams.ts +0 -17
|
@@ -1,17 +1,27 @@
|
|
|
1
1
|
import { SupernetType } from '../../ApiClient/WebSocketClient/types';
|
|
2
2
|
import { ControlNetParams } from './ControlNetParams';
|
|
3
3
|
import { TokenType } from '../../types/token';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { ForgeSampler, SupportedForgeSamplers } from './ForgeSamplerParams';
|
|
5
|
+
import { ForgeScheduler, SupportedForgeSchedulers } from './ForgeSchedulerParams';
|
|
6
|
+
import { ComfySampler, SupportedComfySamplers } from './ComfySamplerParams';
|
|
7
|
+
import { ComfyScheduler, SupportedComfySchedulers } from './ComfySchedulerParams';
|
|
6
8
|
export interface SupportedModel {
|
|
7
9
|
id: string;
|
|
8
10
|
name: string;
|
|
9
11
|
SID: number;
|
|
12
|
+
/**
|
|
13
|
+
* Media type produced by this model: 'image' or 'video'
|
|
14
|
+
*/
|
|
15
|
+
media: 'image' | 'video';
|
|
10
16
|
}
|
|
11
17
|
export interface AvailableModel {
|
|
12
18
|
id: string;
|
|
13
19
|
name: string;
|
|
14
20
|
workerCount: number;
|
|
21
|
+
/**
|
|
22
|
+
* Media type produced by this model: 'image' or 'video'
|
|
23
|
+
*/
|
|
24
|
+
media: 'image' | 'video';
|
|
15
25
|
}
|
|
16
26
|
export interface SizePreset {
|
|
17
27
|
label: string;
|
|
@@ -21,14 +31,21 @@ export interface SizePreset {
|
|
|
21
31
|
ratio: string;
|
|
22
32
|
aspect: string;
|
|
23
33
|
}
|
|
24
|
-
export type
|
|
25
|
-
export type
|
|
26
|
-
export type
|
|
27
|
-
export
|
|
34
|
+
export type Sampler = ForgeSampler | ComfySampler;
|
|
35
|
+
export type Scheduler = ForgeScheduler | ComfyScheduler;
|
|
36
|
+
export type { ForgeSampler, ForgeScheduler, ComfySampler, ComfyScheduler };
|
|
37
|
+
export { SupportedForgeSamplers, SupportedForgeSchedulers, SupportedComfySamplers, SupportedComfySchedulers };
|
|
38
|
+
export type ImageOutputFormat = 'png' | 'jpg';
|
|
39
|
+
export type VideoOutputFormat = 'mp4';
|
|
40
|
+
export interface BaseProjectParams {
|
|
28
41
|
/**
|
|
29
42
|
* ID of the model to use, available models are available in the `availableModels` property of the `ProjectsApi` instance.
|
|
30
43
|
*/
|
|
31
44
|
modelId: string;
|
|
45
|
+
/**
|
|
46
|
+
* Number of media files to generate. Depending on project type, this can be number of images or number of videos.
|
|
47
|
+
*/
|
|
48
|
+
numberOfMedia: number;
|
|
32
49
|
/**
|
|
33
50
|
* Prompt for what to be created
|
|
34
51
|
*/
|
|
@@ -42,15 +59,17 @@ export interface ProjectParams {
|
|
|
42
59
|
*/
|
|
43
60
|
stylePrompt: string;
|
|
44
61
|
/**
|
|
45
|
-
* Number of steps. For most Stable Diffusion models, optimal value is 20
|
|
62
|
+
* Number of steps. For most Stable Diffusion models, optimal value is 20.
|
|
46
63
|
*/
|
|
47
|
-
steps
|
|
64
|
+
steps?: number;
|
|
48
65
|
/**
|
|
49
|
-
* Guidance scale. For most Stable Diffusion models, optimal value is 7.5
|
|
66
|
+
* Guidance scale. For most Stable Diffusion models, optimal value is 7.5.
|
|
67
|
+
* For video models: Regular models range 0.7-8.0, LoRA version (lightx2v) range 0.7-1.6, step 0.01.
|
|
68
|
+
* This maps to `guidanceScale` in the keyFrame for both image and video models.
|
|
50
69
|
*/
|
|
51
|
-
guidance
|
|
70
|
+
guidance?: number;
|
|
52
71
|
/**
|
|
53
|
-
* Override current network type. Default value can be read from `
|
|
72
|
+
* Override current network type. Default value can be read from `sogni.account.currentAccount.network`
|
|
54
73
|
*/
|
|
55
74
|
network?: SupernetType;
|
|
56
75
|
/**
|
|
@@ -63,46 +82,144 @@ export interface ProjectParams {
|
|
|
63
82
|
*/
|
|
64
83
|
seed?: number;
|
|
65
84
|
/**
|
|
66
|
-
*
|
|
85
|
+
* Select which tokens to use for the project.
|
|
86
|
+
* If not specified, the Sogni token will be used.
|
|
67
87
|
*/
|
|
68
|
-
|
|
88
|
+
tokenType?: TokenType;
|
|
89
|
+
}
|
|
90
|
+
export type InputMedia = File | Buffer | Blob | boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Video-specific parameters for video workflows (t2v, i2v, s2v, animate).
|
|
93
|
+
* Only applicable when using video models like wan_v2.2-14b-fp8_t2v.
|
|
94
|
+
* Includes frame count, fps, shift, and reference assets (image, audio, video).
|
|
95
|
+
*/
|
|
96
|
+
export interface VideoProjectParams extends BaseProjectParams {
|
|
97
|
+
type: 'video';
|
|
69
98
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* `File` - file object from input[type=file]
|
|
73
|
-
* `Buffer` - Node.js buffer object with image data
|
|
74
|
-
* `Blob` - blob object with image data
|
|
75
|
-
* `true` - indicates that the image is already uploaded to the server
|
|
99
|
+
* Number of frames to generate
|
|
100
|
+
* @deprecated Use duration instead
|
|
76
101
|
*/
|
|
77
|
-
|
|
102
|
+
frames?: number;
|
|
78
103
|
/**
|
|
79
|
-
*
|
|
104
|
+
* Duration of the video in seconds. Supported range 1 to 10
|
|
80
105
|
*/
|
|
81
|
-
|
|
106
|
+
duration?: number;
|
|
107
|
+
/**
|
|
108
|
+
* Frames per second for output video
|
|
109
|
+
*/
|
|
110
|
+
fps?: number;
|
|
111
|
+
/**
|
|
112
|
+
* Shift parameter for video diffusion models.
|
|
113
|
+
* Controls motion intensity. Range: 1.0-8.0, step 0.1.
|
|
114
|
+
* Default: 8.0 for regular models, 5.0 for speed lora (lightx2v) except s2v and animate which use 8.0
|
|
115
|
+
*/
|
|
116
|
+
shift?: number;
|
|
117
|
+
/**
|
|
118
|
+
* TeaCache optimization threshold for T2V and I2V models.
|
|
119
|
+
* Range: 0.0-1.0. 0.0 = disabled.
|
|
120
|
+
* Recommended: 0.15 for T2V (~1.5x speedup), 0.2 for I2V (conservative quality-focused)
|
|
121
|
+
*/
|
|
122
|
+
teacacheThreshold?: number;
|
|
123
|
+
/**
|
|
124
|
+
* Reference image for WAN video workflows.
|
|
125
|
+
* Maps to: startImage (i2v), characterImage (animate), referenceImage (s2v)
|
|
126
|
+
*/
|
|
127
|
+
referenceImage?: InputMedia;
|
|
128
|
+
/**
|
|
129
|
+
* Optional end image for i2v interpolation workflows.
|
|
130
|
+
* When provided with referenceImage, the video will interpolate between the two images.
|
|
131
|
+
*/
|
|
132
|
+
referenceImageEnd?: InputMedia;
|
|
133
|
+
/**
|
|
134
|
+
* Reference audio for s2v (sound-to-video) workflows.
|
|
135
|
+
*/
|
|
136
|
+
referenceAudio?: InputMedia;
|
|
137
|
+
/**
|
|
138
|
+
* Audio start position in seconds for s2v workflows.
|
|
139
|
+
* Specifies where to begin reading from the audio file.
|
|
140
|
+
* Default: 0
|
|
141
|
+
*/
|
|
142
|
+
audioStart?: number;
|
|
143
|
+
/**
|
|
144
|
+
* Audio duration in seconds for s2v workflows.
|
|
145
|
+
* Specifies how many seconds of audio to use.
|
|
146
|
+
* If not provided, defaults to 30 seconds on the server.
|
|
147
|
+
*/
|
|
148
|
+
audioDuration?: number;
|
|
149
|
+
/**
|
|
150
|
+
* Reference video for animate workflows.
|
|
151
|
+
* Maps to: drivingVideo (animate-move), sourceVideo (animate-replace)
|
|
152
|
+
*/
|
|
153
|
+
referenceVideo?: InputMedia;
|
|
82
154
|
/**
|
|
83
|
-
*
|
|
155
|
+
* Video start position in seconds for animate workflows (animate-move, animate-replace).
|
|
156
|
+
* Specifies where to begin reading from the reference video file.
|
|
157
|
+
* Default: 0
|
|
158
|
+
*/
|
|
159
|
+
videoStart?: number;
|
|
160
|
+
/**
|
|
161
|
+
* Output video width. Only used if `sizePreset` is "custom"
|
|
162
|
+
*/
|
|
163
|
+
width?: number;
|
|
164
|
+
/**
|
|
165
|
+
* Output video height. Only used if `sizePreset` is "custom"
|
|
166
|
+
*/
|
|
167
|
+
height?: number;
|
|
168
|
+
/**
|
|
169
|
+
* ComfyUI sampler for video generation.
|
|
170
|
+
* Uses ComfyUI's native lowercase format: euler, euler_ancestral, dpmpp_2m, etc.
|
|
171
|
+
* Default: euler (or uni_pc for s2v models)
|
|
172
|
+
*/
|
|
173
|
+
sampler?: ComfySampler;
|
|
174
|
+
/**
|
|
175
|
+
* ComfyUI scheduler for video generation.
|
|
176
|
+
* Uses ComfyUI's native lowercase format: simple, normal, karras, sgm_uniform, etc.
|
|
177
|
+
* Default: simple
|
|
178
|
+
*/
|
|
179
|
+
scheduler?: ComfyScheduler;
|
|
180
|
+
/**
|
|
181
|
+
* Output video format. For now only 'mp4' is supported, defaults to 'mp4'.
|
|
182
|
+
*/
|
|
183
|
+
outputFormat?: VideoOutputFormat;
|
|
184
|
+
}
|
|
185
|
+
export interface ImageProjectParams extends BaseProjectParams {
|
|
186
|
+
type: 'image';
|
|
187
|
+
/**
|
|
188
|
+
* Number of previews to generate. Note that previews affect project cost
|
|
189
|
+
*/
|
|
190
|
+
numberOfPreviews?: number;
|
|
191
|
+
/**
|
|
192
|
+
* Starting image for img2img workflows.
|
|
84
193
|
* Supported types:
|
|
85
194
|
* `File` - file object from input[type=file]
|
|
86
195
|
* `Buffer` - Node.js buffer object with image data
|
|
87
196
|
* `Blob` - blob object with image data
|
|
88
197
|
* `true` - indicates that the image is already uploaded to the server
|
|
89
198
|
*/
|
|
90
|
-
|
|
199
|
+
startingImage?: InputMedia;
|
|
200
|
+
/**
|
|
201
|
+
* How strong effect of starting image should be. From 0 to 1, default 0.5
|
|
202
|
+
*/
|
|
203
|
+
startingImageStrength?: number;
|
|
91
204
|
/**
|
|
92
|
-
*
|
|
205
|
+
* Context images for multi-reference image generation.
|
|
206
|
+
* Flux.2 Dev and Qwen Image Edit Plus support up to 3 context images.
|
|
207
|
+
* Flux Kontext supports up to 2 context images.
|
|
93
208
|
*/
|
|
94
|
-
|
|
209
|
+
contextImages?: InputMedia[];
|
|
95
210
|
/**
|
|
96
|
-
*
|
|
211
|
+
* Legacy sampler for non-ComfyUI models (Automatic1111 workers).
|
|
212
|
+
* Not supported for ComfyUI models - use comfySampler instead.
|
|
97
213
|
*/
|
|
98
214
|
sampler?: Sampler;
|
|
99
215
|
/**
|
|
100
|
-
*
|
|
216
|
+
* Legacy scheduler for non-ComfyUI models (Automatic1111 workers).
|
|
217
|
+
* Not supported for ComfyUI models - use comfyScheduler instead.
|
|
101
218
|
*/
|
|
102
219
|
scheduler?: Scheduler;
|
|
103
220
|
/**
|
|
104
221
|
* Size preset ID to use. You can query available size presets
|
|
105
|
-
* from `
|
|
222
|
+
* from `sogni.projects.sizePresets(network, modelId)`
|
|
106
223
|
*/
|
|
107
224
|
sizePreset?: 'custom' | string;
|
|
108
225
|
/**
|
|
@@ -118,22 +235,38 @@ export interface ProjectParams {
|
|
|
118
235
|
*/
|
|
119
236
|
controlNet?: ControlNetParams;
|
|
120
237
|
/**
|
|
121
|
-
*
|
|
122
|
-
* If not specified, the Sogni token will be used.
|
|
123
|
-
*/
|
|
124
|
-
tokenType?: TokenType;
|
|
125
|
-
/**
|
|
126
|
-
* Output image format. Can be 'png' or 'jpg'.
|
|
127
|
-
* If not specified, 'png' will be used.
|
|
238
|
+
* Output format. Can be 'png' or 'jpg'. Defaults to 'png'.
|
|
128
239
|
*/
|
|
129
|
-
outputFormat?:
|
|
240
|
+
outputFormat?: ImageOutputFormat;
|
|
130
241
|
}
|
|
242
|
+
export type ProjectParams = ImageProjectParams | VideoProjectParams;
|
|
243
|
+
export declare function isVideoParams(params: ProjectParams): params is VideoProjectParams;
|
|
244
|
+
export declare function isImageParams(params: ProjectParams): params is ImageProjectParams;
|
|
245
|
+
/**
|
|
246
|
+
* Supported audio formats
|
|
247
|
+
*/
|
|
248
|
+
export type AudioFormat = 'm4a' | 'mp3' | 'wav';
|
|
249
|
+
/**
|
|
250
|
+
* Supported video formats
|
|
251
|
+
*/
|
|
252
|
+
export type VideoFormat = 'mp4' | 'mov';
|
|
253
|
+
/**
|
|
254
|
+
* Parameters for image asset URL requests (upload/download)
|
|
255
|
+
*/
|
|
131
256
|
export type ImageUrlParams = {
|
|
132
257
|
imageId: string;
|
|
133
258
|
jobId: string;
|
|
134
|
-
type: 'preview' | 'complete' | 'startingImage' | 'cnImage' | 'contextImage1' | 'contextImage2';
|
|
259
|
+
type: 'preview' | 'complete' | 'startingImage' | 'cnImage' | 'contextImage1' | 'contextImage2' | 'contextImage3' | 'referenceImage' | 'referenceImageEnd';
|
|
135
260
|
startContentType?: string;
|
|
136
261
|
};
|
|
262
|
+
/**
|
|
263
|
+
* Parameters for media asset URL requests (video/audio upload/download)
|
|
264
|
+
*/
|
|
265
|
+
export type MediaUrlParams = {
|
|
266
|
+
id?: string;
|
|
267
|
+
jobId: string;
|
|
268
|
+
type: 'complete' | 'preview' | 'referenceAudio' | 'referenceVideo';
|
|
269
|
+
};
|
|
137
270
|
export interface EstimateRequest {
|
|
138
271
|
/**
|
|
139
272
|
* Network to use. Can be 'fast' or 'relaxed'
|
|
@@ -195,4 +328,38 @@ export interface EstimateRequest {
|
|
|
195
328
|
*/
|
|
196
329
|
contextImages?: number;
|
|
197
330
|
}
|
|
331
|
+
export interface VideoEstimateRequest {
|
|
332
|
+
tokenType: TokenType;
|
|
333
|
+
model: string;
|
|
334
|
+
width: number;
|
|
335
|
+
height: number;
|
|
336
|
+
duration: number;
|
|
337
|
+
/**
|
|
338
|
+
* Number of frames to generate.
|
|
339
|
+
* @deprecated Use duration instead
|
|
340
|
+
*/
|
|
341
|
+
frames?: number;
|
|
342
|
+
fps: number;
|
|
343
|
+
steps: number;
|
|
344
|
+
numberOfMedia: number;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Represents estimation of project cost in different currency formats
|
|
348
|
+
*/
|
|
349
|
+
export interface CostEstimation {
|
|
350
|
+
/** Cost in selected token type */
|
|
351
|
+
token: string;
|
|
352
|
+
/** Cost in USD */
|
|
353
|
+
usd: string;
|
|
354
|
+
/** Cost in Spark Points */
|
|
355
|
+
spark: string;
|
|
356
|
+
/** Cost in Sogni tokens */
|
|
357
|
+
sogni: string;
|
|
358
|
+
}
|
|
198
359
|
export type EnhancementStrength = 'light' | 'medium' | 'heavy';
|
|
360
|
+
/**
|
|
361
|
+
* Video workflow types for WAN models
|
|
362
|
+
*/
|
|
363
|
+
export type VideoWorkflowType = 't2v' | 'i2v' | 's2v' | 'animate-move' | 'animate-replace' | null;
|
|
364
|
+
export type AssetRequirement = 'required' | 'optional' | 'forbidden';
|
|
365
|
+
export type VideoAssetKey = 'referenceImage' | 'referenceImageEnd' | 'referenceAudio' | 'referenceVideo';
|
|
@@ -1,3 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SupportedComfySchedulers = exports.SupportedComfySamplers = exports.SupportedForgeSchedulers = exports.SupportedForgeSamplers = void 0;
|
|
4
|
+
exports.isVideoParams = isVideoParams;
|
|
5
|
+
exports.isImageParams = isImageParams;
|
|
6
|
+
const ForgeSamplerParams_1 = require("./ForgeSamplerParams");
|
|
7
|
+
Object.defineProperty(exports, "SupportedForgeSamplers", { enumerable: true, get: function () { return ForgeSamplerParams_1.SupportedForgeSamplers; } });
|
|
8
|
+
const ForgeSchedulerParams_1 = require("./ForgeSchedulerParams");
|
|
9
|
+
Object.defineProperty(exports, "SupportedForgeSchedulers", { enumerable: true, get: function () { return ForgeSchedulerParams_1.SupportedForgeSchedulers; } });
|
|
10
|
+
const ComfySamplerParams_1 = require("./ComfySamplerParams");
|
|
11
|
+
Object.defineProperty(exports, "SupportedComfySamplers", { enumerable: true, get: function () { return ComfySamplerParams_1.SupportedComfySamplers; } });
|
|
12
|
+
const ComfySchedulerParams_1 = require("./ComfySchedulerParams");
|
|
13
|
+
Object.defineProperty(exports, "SupportedComfySchedulers", { enumerable: true, get: function () { return ComfySchedulerParams_1.SupportedComfySchedulers; } });
|
|
14
|
+
function isVideoParams(params) {
|
|
15
|
+
return params.type === 'video';
|
|
16
|
+
}
|
|
17
|
+
function isImageParams(params) {
|
|
18
|
+
return params.type === 'image';
|
|
19
|
+
}
|
|
3
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Projects/types/index.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Projects/types/index.ts"],"names":[],"mappings":";;;AAqQA,sCAEC;AAED,sCAEC;AAxQD,6DAA4E;AAyC1E,uGAzCqB,2CAAsB,OAyCrB;AAxCxB,iEAAkF;AAyChF,yGAzCuB,+CAAwB,OAyCvB;AAxC1B,6DAA4E;AAyC1E,uGAzCqB,2CAAsB,OAyCrB;AAxCxB,iEAAkF;AAyChF,yGAzCuB,+CAAwB,OAyCvB;AAsN1B,SAAgB,aAAa,CAAC,MAAqB;IACjD,OAAO,MAAM,CAAC,IAAI,KAAK,OAAO,CAAC;AACjC,CAAC;AAED,SAAgB,aAAa,CAAC,MAAqB;IACjD,OAAO,MAAM,CAAC,IAAI,KAAK,OAAO,CAAC;AACjC,CAAC"}
|
package/dist/Projects/utils.d.ts
CHANGED
|
@@ -1,2 +1,20 @@
|
|
|
1
|
-
import { EnhancementStrength } from './types';
|
|
1
|
+
import { AssetRequirement, EnhancementStrength, VideoAssetKey, VideoWorkflowType } from './types';
|
|
2
2
|
export declare function getEnhacementStrength(strength: EnhancementStrength): number;
|
|
3
|
+
/**
|
|
4
|
+
* Check if a model ID is for a video workflow.
|
|
5
|
+
* This is consistent with the `media` property returned by the models list API.
|
|
6
|
+
* Video models produce MP4 output; image models produce PNG/JPG output.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isVideoModel(modelId: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Get the video workflow type from a model ID.
|
|
11
|
+
* Returns null for non-video models.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getVideoWorkflowType(modelId: string): VideoWorkflowType;
|
|
14
|
+
/**
|
|
15
|
+
* Asset requirements for each video workflow type.
|
|
16
|
+
* - required: Must be provided
|
|
17
|
+
* - optional: Can be provided
|
|
18
|
+
* - forbidden: Must NOT be provided
|
|
19
|
+
*/
|
|
20
|
+
export declare const VIDEO_WORKFLOW_ASSETS: Record<NonNullable<VideoWorkflowType>, Record<VideoAssetKey, AssetRequirement>>;
|
package/dist/Projects/utils.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VIDEO_WORKFLOW_ASSETS = void 0;
|
|
3
4
|
exports.getEnhacementStrength = getEnhacementStrength;
|
|
5
|
+
exports.isVideoModel = isVideoModel;
|
|
6
|
+
exports.getVideoWorkflowType = getVideoWorkflowType;
|
|
4
7
|
function getEnhacementStrength(strength) {
|
|
5
8
|
switch (strength) {
|
|
6
9
|
case 'light':
|
|
@@ -11,4 +14,69 @@ function getEnhacementStrength(strength) {
|
|
|
11
14
|
return 0.35;
|
|
12
15
|
}
|
|
13
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Check if a model ID is for a video workflow.
|
|
19
|
+
* This is consistent with the `media` property returned by the models list API.
|
|
20
|
+
* Video models produce MP4 output; image models produce PNG/JPG output.
|
|
21
|
+
*/
|
|
22
|
+
function isVideoModel(modelId) {
|
|
23
|
+
return modelId.startsWith('wan_');
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get the video workflow type from a model ID.
|
|
27
|
+
* Returns null for non-video models.
|
|
28
|
+
*/
|
|
29
|
+
function getVideoWorkflowType(modelId) {
|
|
30
|
+
if (!modelId || !modelId.startsWith('wan_'))
|
|
31
|
+
return null;
|
|
32
|
+
if (modelId.includes('_i2v'))
|
|
33
|
+
return 'i2v';
|
|
34
|
+
if (modelId.includes('_s2v'))
|
|
35
|
+
return 's2v';
|
|
36
|
+
if (modelId.includes('_animate-move'))
|
|
37
|
+
return 'animate-move';
|
|
38
|
+
if (modelId.includes('_animate-replace'))
|
|
39
|
+
return 'animate-replace';
|
|
40
|
+
if (modelId.includes('_t2v'))
|
|
41
|
+
return 't2v';
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Asset requirements for each video workflow type.
|
|
46
|
+
* - required: Must be provided
|
|
47
|
+
* - optional: Can be provided
|
|
48
|
+
* - forbidden: Must NOT be provided
|
|
49
|
+
*/
|
|
50
|
+
exports.VIDEO_WORKFLOW_ASSETS = {
|
|
51
|
+
t2v: {
|
|
52
|
+
referenceImage: 'forbidden',
|
|
53
|
+
referenceImageEnd: 'forbidden',
|
|
54
|
+
referenceAudio: 'forbidden',
|
|
55
|
+
referenceVideo: 'forbidden'
|
|
56
|
+
},
|
|
57
|
+
i2v: {
|
|
58
|
+
referenceImage: 'optional',
|
|
59
|
+
referenceImageEnd: 'optional',
|
|
60
|
+
referenceAudio: 'forbidden',
|
|
61
|
+
referenceVideo: 'forbidden'
|
|
62
|
+
},
|
|
63
|
+
s2v: {
|
|
64
|
+
referenceImage: 'required',
|
|
65
|
+
referenceAudio: 'required',
|
|
66
|
+
referenceImageEnd: 'forbidden',
|
|
67
|
+
referenceVideo: 'forbidden'
|
|
68
|
+
},
|
|
69
|
+
'animate-move': {
|
|
70
|
+
referenceImage: 'required',
|
|
71
|
+
referenceVideo: 'required',
|
|
72
|
+
referenceImageEnd: 'forbidden',
|
|
73
|
+
referenceAudio: 'forbidden'
|
|
74
|
+
},
|
|
75
|
+
'animate-replace': {
|
|
76
|
+
referenceImage: 'required',
|
|
77
|
+
referenceVideo: 'required',
|
|
78
|
+
referenceImageEnd: 'forbidden',
|
|
79
|
+
referenceAudio: 'forbidden'
|
|
80
|
+
}
|
|
81
|
+
};
|
|
14
82
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/Projects/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/Projects/utils.ts"],"names":[],"mappings":";;;AAEA,sDASC;AAOD,oCAEC;AAMD,oDAQC;AAhCD,SAAgB,qBAAqB,CAAC,QAA6B;IACjE,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,OAAO;YACV,OAAO,IAAI,CAAC;QACd,KAAK,OAAO;YACV,OAAO,IAAI,CAAC;QACd;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAgB,YAAY,CAAC,OAAe;IAC1C,OAAO,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC;AAED;;;GAGG;AACH,SAAgB,oBAAoB,CAAC,OAAe;IAClD,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IACzD,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3C,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3C,IAAI,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC;QAAE,OAAO,cAAc,CAAC;IAC7D,IAAI,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC;QAAE,OAAO,iBAAiB,CAAC;IACnE,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3C,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACU,QAAA,qBAAqB,GAG9B;IACF,GAAG,EAAE;QACH,cAAc,EAAE,WAAW;QAC3B,iBAAiB,EAAE,WAAW;QAC9B,cAAc,EAAE,WAAW;QAC3B,cAAc,EAAE,WAAW;KAC5B;IACD,GAAG,EAAE;QACH,cAAc,EAAE,UAAU;QAC1B,iBAAiB,EAAE,UAAU;QAC7B,cAAc,EAAE,WAAW;QAC3B,cAAc,EAAE,WAAW;KAC5B;IACD,GAAG,EAAE;QACH,cAAc,EAAE,UAAU;QAC1B,cAAc,EAAE,UAAU;QAC1B,iBAAiB,EAAE,WAAW;QAC9B,cAAc,EAAE,WAAW;KAC5B;IACD,cAAc,EAAE;QACd,cAAc,EAAE,UAAU;QAC1B,cAAc,EAAE,UAAU;QAC1B,iBAAiB,EAAE,WAAW;QAC9B,cAAc,EAAE,WAAW;KAC5B;IACD,iBAAiB,EAAE;QACjB,cAAc,EAAE,UAAU;QAC1B,cAAc,EAAE,UAAU;QAC1B,iBAAiB,EAAE,WAAW;QAC9B,cAAc,EAAE,WAAW;KAC5B;CACF,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,13 +6,13 @@ import { Logger, LogLevel } from './lib/DefaultLogger';
|
|
|
6
6
|
import ProjectsApi from './Projects';
|
|
7
7
|
import Job, { JobStatus } from './Projects/Job';
|
|
8
8
|
import Project, { ProjectStatus } from './Projects/Project';
|
|
9
|
-
import { AvailableModel,
|
|
9
|
+
import { AvailableModel, ImageProjectParams, ImageOutputFormat, ProjectParams, Sampler, ForgeSampler, ComfySampler, Scheduler, ForgeScheduler, ComfyScheduler, SupportedForgeSamplers, SupportedForgeSchedulers, SupportedComfySamplers, SupportedComfySchedulers, VideoProjectParams, AudioFormat, VideoFormat, VideoOutputFormat, VideoWorkflowType } from './Projects/types';
|
|
10
10
|
import StatsApi from './Stats';
|
|
11
11
|
import ErrorData from './types/ErrorData';
|
|
12
12
|
import { TokenType } from './types/token';
|
|
13
13
|
import { TokenAuthData } from './lib/AuthManager';
|
|
14
|
-
export type { AvailableModel, ErrorData, JobStatus, Logger, LogLevel,
|
|
15
|
-
export { ApiError, CurrentAccount, Job, Project };
|
|
14
|
+
export type { AudioFormat, AvailableModel, ErrorData, ImageProjectParams, ImageOutputFormat, JobStatus, Logger, LogLevel, ProjectParams, ProjectStatus, Sampler, ForgeSampler, ComfySampler, SupernetType, Scheduler, ForgeScheduler, ComfyScheduler, TokenType, VideoFormat, VideoOutputFormat, VideoProjectParams, VideoWorkflowType };
|
|
15
|
+
export { ApiError, CurrentAccount, Job, Project, SupportedComfySchedulers, SupportedComfySamplers, SupportedForgeSchedulers, SupportedForgeSamplers };
|
|
16
16
|
export interface SogniClientConfig {
|
|
17
17
|
/**
|
|
18
18
|
* The application ID string. Must be unique, multiple connections with the same ID will be rejected.
|
|
@@ -30,7 +30,7 @@ export interface SogniClientConfig {
|
|
|
30
30
|
socketEndpoint?: string;
|
|
31
31
|
/**
|
|
32
32
|
* Disable WebSocket connection. Useful for testing or when WebSocket is not needed.
|
|
33
|
-
* Note that many may not work without WebSocket connection.
|
|
33
|
+
* Note that many APIs may not work without WebSocket connection.
|
|
34
34
|
* @experimental
|
|
35
35
|
* @internal
|
|
36
36
|
*/
|
|
@@ -62,6 +62,14 @@ export interface SogniClientConfig {
|
|
|
62
62
|
* @experimental
|
|
63
63
|
*/
|
|
64
64
|
authType?: 'token' | 'cookies';
|
|
65
|
+
/**
|
|
66
|
+
* Browser only. If true, the client will use a single WebSocket connection shared across multiple
|
|
67
|
+
* tabs. This is useful for browser apps that need to process multiple projects at the same time.
|
|
68
|
+
* Only works in browser environment and with cookie authentication.
|
|
69
|
+
* @default false
|
|
70
|
+
* @experimental
|
|
71
|
+
*/
|
|
72
|
+
multiInstance?: boolean;
|
|
65
73
|
}
|
|
66
74
|
export declare class SogniClient {
|
|
67
75
|
account: AccountApi;
|
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.SogniClient = exports.Project = exports.Job = exports.CurrentAccount = exports.ApiError = void 0;
|
|
38
|
+
exports.SogniClient = exports.SupportedForgeSamplers = exports.SupportedForgeSchedulers = exports.SupportedComfySamplers = exports.SupportedComfySchedulers = exports.Project = exports.Job = exports.CurrentAccount = exports.ApiError = void 0;
|
|
39
39
|
// Account API
|
|
40
40
|
const Account_1 = __importDefault(require("./Account"));
|
|
41
41
|
const CurrentAccount_1 = __importDefault(require("./Account/CurrentAccount"));
|
|
@@ -52,6 +52,11 @@ const Job_1 = __importDefault(require("./Projects/Job"));
|
|
|
52
52
|
exports.Job = Job_1.default;
|
|
53
53
|
const Project_1 = __importDefault(require("./Projects/Project"));
|
|
54
54
|
exports.Project = Project_1.default;
|
|
55
|
+
const types_1 = require("./Projects/types");
|
|
56
|
+
Object.defineProperty(exports, "SupportedForgeSamplers", { enumerable: true, get: function () { return types_1.SupportedForgeSamplers; } });
|
|
57
|
+
Object.defineProperty(exports, "SupportedForgeSchedulers", { enumerable: true, get: function () { return types_1.SupportedForgeSchedulers; } });
|
|
58
|
+
Object.defineProperty(exports, "SupportedComfySamplers", { enumerable: true, get: function () { return types_1.SupportedComfySamplers; } });
|
|
59
|
+
Object.defineProperty(exports, "SupportedComfySchedulers", { enumerable: true, get: function () { return types_1.SupportedComfySchedulers; } });
|
|
55
60
|
// Stats API
|
|
56
61
|
const Stats_1 = __importDefault(require("./Stats"));
|
|
57
62
|
const AuthManager_1 = require("./lib/AuthManager");
|
|
@@ -92,9 +97,13 @@ class SogniClient {
|
|
|
92
97
|
throw Error('This method should only be called when using cookie auth');
|
|
93
98
|
}
|
|
94
99
|
try {
|
|
95
|
-
yield this.apiClient.rest.get('/v1/account/me');
|
|
100
|
+
const res = yield this.apiClient.rest.get('/v1/account/me');
|
|
96
101
|
yield auth.authenticate();
|
|
97
|
-
|
|
102
|
+
this.currentAccount._update({
|
|
103
|
+
username: res.data.username,
|
|
104
|
+
email: res.data.currentEmail,
|
|
105
|
+
walletAddress: res.data.walletAddress
|
|
106
|
+
});
|
|
98
107
|
return true;
|
|
99
108
|
}
|
|
100
109
|
catch (e) {
|
|
@@ -121,7 +130,8 @@ class SogniClient {
|
|
|
121
130
|
networkType: network,
|
|
122
131
|
logger,
|
|
123
132
|
authType: config.authType || 'token',
|
|
124
|
-
disableSocket: config.disableSocket
|
|
133
|
+
disableSocket: config.disableSocket,
|
|
134
|
+
multiInstance: config.multiInstance
|
|
125
135
|
});
|
|
126
136
|
const eip712 = new EIP712Helper_1.default({
|
|
127
137
|
name: isTestnet ? 'Sogni-testnet' : 'Sogni AI',
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAc;AACd,wDAAmC;AACnC,8EAAsD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAc;AACd,wDAAmC;AACnC,8EAAsD;AAoEpD,yBApEK,wBAAc,CAoEL;AAnEhB,YAAY;AACZ,yDAA+D;AAiE7D,yFAjEkB,oBAA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AAC,KAAK;gBACnB,WAAW,EAAE,OAAO;gBACpB,MAAM;gBACN,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,OAAO;gBACpC,aAAa,EAAE,MAAM,CAAC,aAAa;gBACnC,aAAa,EAAE,MAAM,CAAC,aAAa;aACpC,CAAC,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,sBAAY,CAAC;gBAC9B,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,UAAU;gBAC9C,OAAO,EAAE,GAAG;gBACZ,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;aACtC,CAAC,CAAC;YACH,OAAO,IAAI,WAAW,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QAC7C,CAAC;KAAA;CACF;AAtFD,kCAsFC"}
|
|
@@ -42,7 +42,6 @@ class TokenAuthManager extends AuthManagerBase_1.default {
|
|
|
42
42
|
const { expiresAt } = (0, utils_1.decodeToken)(token);
|
|
43
43
|
if (expiresAt > new Date()) {
|
|
44
44
|
this._updateTokens({ token, refreshToken });
|
|
45
|
-
this.emit('updated', true);
|
|
46
45
|
return;
|
|
47
46
|
}
|
|
48
47
|
}
|
|
@@ -51,7 +50,6 @@ class TokenAuthManager extends AuthManagerBase_1.default {
|
|
|
51
50
|
const { expiresAt: refreshExpiresAt } = (0, utils_1.decodeRefreshToken)(refreshToken);
|
|
52
51
|
this._refreshTokenExpiresAt = refreshExpiresAt;
|
|
53
52
|
yield this._renewTokenSafe();
|
|
54
|
-
this.emit('updated', true);
|
|
55
53
|
});
|
|
56
54
|
}
|
|
57
55
|
clear() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TokenAuthManager.js","sourceRoot":"","sources":["../../../src/lib/AuthManager/TokenAuthManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,oCAA2D;AAC3D,+CAA6D;AAE7D,2DAAmC;AACnC,0D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AAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,IAAI,CAAC,KAAK,EAAE,CAAC;gBACb,MAAM,IAAI,oBAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,YAAgC,CAAC,CAAC;YACxE,CAAC;YACD,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,YAAY,CAAC,IAAI,CAAC;YAClD,IAAI,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;YAC5C,OAAO,IAAI,CAAC,MAAO,CAAC;QACtB,CAAC;KAAA;CACF;AAED,kBAAe,gBAAgB,CAAC"}
|
package/dist/lib/DataEntity.js
CHANGED
|
@@ -18,9 +18,11 @@ class DataEntity extends TypedEventEmitter_1.default {
|
|
|
18
18
|
_update(delta) {
|
|
19
19
|
//@ts-ignore
|
|
20
20
|
const changedKeys = Object.keys(delta).filter((key) => this.data[key] !== delta[key]);
|
|
21
|
-
this.data = Object.assign(Object.assign({}, this.data), delta);
|
|
22
21
|
this.lastUpdated = new Date();
|
|
23
|
-
|
|
22
|
+
if (changedKeys.length > 0) {
|
|
23
|
+
this.data = Object.assign(Object.assign({}, this.data), delta);
|
|
24
|
+
this.emit('updated', changedKeys);
|
|
25
|
+
}
|
|
24
26
|
}
|
|
25
27
|
/**
|
|
26
28
|
* Get a copy of the entity's data
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataEntity.js","sourceRoot":"","sources":["../../src/lib/DataEntity.ts"],"names":[],"mappings":";;;;;AAAA,mCAAmC;AACnC,4EAAoD;AASpD,MAAe,UAAqD,SAAQ,2BAAoB;IAK9F,YAAY,IAAO;QACjB,KAAK,EAAE,CAAC;QAHA,gBAAW,GAAS,IAAI,IAAI,EAAE,CAAC;QAIvC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED;;;OAGG;IACH,OAAO,CAAC,KAAiB;QACvB,YAAY;QACZ,MAAM,WAAW,GAAG,M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