@decartai/sdk 0.0.60 → 0.0.62

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.
@@ -86,7 +86,7 @@ interface VideoEditInputs {
86
86
  reference_image?: FileInput;
87
87
  }
88
88
  /**
89
- * Model-specific input documentation for lucy-2-v2v.
89
+ * Model-specific input documentation for Lucy 2.1 video editing models.
90
90
  * Requires prompt (can be empty string). Optional reference_image can also be provided.
91
91
  */
92
92
  interface VideoEdit2Inputs {
@@ -143,7 +143,7 @@ interface PromptInput {
143
143
  * This allows different models to have field-specific documentation while maintaining type safety.
144
144
  * Specific models are checked first, then falls back to category-based selection.
145
145
  */
146
- type ModelSpecificInputs<T extends ModelDefinition> = T["name"] extends "lucy-pro-i2i" | "lucy-image-2" ? ImageEditingInputs : T["name"] extends "lucy-restyle-v2v" | "lucy-restyle-2" ? VideoRestyleInputs : T["name"] extends "lucy-2-v2v" | "lucy-2" | "lucy-2.1" | "lucy-2.1-vton" ? VideoEdit2Inputs : T["name"] extends "lucy-pro-v2v" | "lucy-clip" ? VideoEditInputs : T["name"] extends ImageModels ? ImageGenerationInputs : T["name"] extends VideoModels ? VideoModelInputs : PromptInput;
146
+ type ModelSpecificInputs<T extends ModelDefinition> = T["name"] extends "lucy-pro-i2i" | "lucy-image-2" ? ImageEditingInputs : T["name"] extends "lucy-restyle-v2v" | "lucy-restyle-2" ? VideoRestyleInputs : T["name"] extends "lucy-2.1" | "lucy-2.1-vton" ? VideoEdit2Inputs : T["name"] extends "lucy-pro-v2v" | "lucy-clip" ? VideoEditInputs : T["name"] extends ImageModels ? ImageGenerationInputs : T["name"] extends VideoModels ? VideoModelInputs : PromptInput;
147
147
  interface ProcessInputs {
148
148
  /**
149
149
  * Random seed for reproducible results.
@@ -16,6 +16,11 @@ declare const realTimeClientInitialStateSchema: z.ZodObject<{
16
16
  image: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<Blob, Blob>, z.ZodCustom<File, File>, z.ZodString]>>;
17
17
  }, z.core.$strip>;
18
18
  type OnRemoteStreamFn = (stream: MediaStream) => void;
19
+ type OnStatusFn = (status: string) => void;
20
+ type OnQueuePositionFn = (data: {
21
+ position: number;
22
+ queueSize: number;
23
+ }) => void;
19
24
  type RealTimeClientInitialState = z.infer<typeof realTimeClientInitialStateSchema>;
20
25
  declare const realTimeClientConnectOptionsSchema: z.ZodObject<{
21
26
  model: z.ZodObject<{
@@ -36,6 +41,8 @@ declare const realTimeClientConnectOptionsSchema: z.ZodObject<{
36
41
  image: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<Blob, Blob>, z.ZodCustom<File, File>, z.ZodString]>>;
37
42
  }, z.core.$strip>>;
38
43
  customizeOffer: z.ZodOptional<z.ZodCustom<z.core.$InferInnerFunctionTypeAsync<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>, z.core.$InferInnerFunctionTypeAsync<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>>;
44
+ onStatus: z.ZodOptional<z.ZodCustom<OnStatusFn, OnStatusFn>>;
45
+ onQueuePosition: z.ZodOptional<z.ZodCustom<OnQueuePositionFn, OnQueuePositionFn>>;
39
46
  }, z.core.$strip>;
40
47
  type RealTimeClientConnectOptions = Omit<z.infer<typeof realTimeClientConnectOptionsSchema>, "model"> & {
41
48
  model: ModelDefinition | CustomModelDefinition;
@@ -46,6 +53,11 @@ type Events = {
46
53
  generationTick: {
47
54
  seconds: number;
48
55
  };
56
+ status: string;
57
+ queuePosition: {
58
+ position: number;
59
+ queueSize: number;
60
+ };
49
61
  diagnostic: DiagnosticEvent;
50
62
  stats: WebRTCStats;
51
63
  };
@@ -57,7 +57,9 @@ const realTimeClientConnectOptionsSchema = z.object({
57
57
  model: modelDefinitionSchema,
58
58
  onRemoteStream: z.custom((val) => typeof val === "function", { message: "onRemoteStream must be a function" }),
59
59
  initialState: realTimeClientInitialStateSchema.optional(),
60
- customizeOffer: createAsyncFunctionSchema(z.function()).optional()
60
+ customizeOffer: createAsyncFunctionSchema(z.function()).optional(),
61
+ onStatus: z.custom((val) => typeof val === "function", { message: "onStatus must be a function" }).optional(),
62
+ onQueuePosition: z.custom((val) => typeof val === "function", { message: "onQueuePosition must be a function" }).optional()
61
63
  });
62
64
  const createRealTimeClient = (opts) => {
63
65
  const { baseUrl, apiKey, integration, logger } = opts;
@@ -65,7 +67,7 @@ const createRealTimeClient = (opts) => {
65
67
  const parsedOptions = realTimeClientConnectOptionsSchema.safeParse(options);
66
68
  if (!parsedOptions.success) throw parsedOptions.error;
67
69
  const isAvatarLive = options.model.name === "live_avatar" || options.model.name === "live-avatar";
68
- const { onRemoteStream, initialState } = parsedOptions.data;
70
+ const { onRemoteStream, initialState, onStatus, onQueuePosition } = parsedOptions.data;
69
71
  let audioStreamManager;
70
72
  let inputStream;
71
73
  if (isAvatarLive && !stream) {
@@ -155,6 +157,19 @@ const createRealTimeClient = (opts) => {
155
157
  emitOrBuffer("generationTick", { seconds: msg.seconds });
156
158
  };
157
159
  manager.getWebsocketMessageEmitter().on("generationTick", tickListener);
160
+ const wsEmitter = manager.getWebsocketMessageEmitter();
161
+ wsEmitter.on("status", (msg) => {
162
+ emitOrBuffer("status", msg.status);
163
+ onStatus?.(msg.status);
164
+ });
165
+ wsEmitter.on("queuePosition", (msg) => {
166
+ const data = {
167
+ position: msg.position,
168
+ queueSize: msg.queue_size
169
+ };
170
+ emitOrBuffer("queuePosition", data);
171
+ onQueuePosition?.(data);
172
+ });
158
173
  await manager.connect(inputStream);
159
174
  const methods = realtimeMethods(manager, imageToBase64);
160
175
  let statsCollector = null;
@@ -183,6 +183,14 @@ var WebRTCConnection = class {
183
183
  this.websocketMessagesEmitter.emit("sessionId", msg);
184
184
  return;
185
185
  }
186
+ if (msg.type === "status") {
187
+ this.websocketMessagesEmitter.emit("status", msg);
188
+ return;
189
+ }
190
+ if (msg.type === "queue_position") {
191
+ this.websocketMessagesEmitter.emit("queuePosition", msg);
192
+ return;
193
+ }
186
194
  if (!this.pc) return;
187
195
  switch (msg.type) {
188
196
  case "ready": {
@@ -1,10 +1,10 @@
1
1
  import { z } from "zod";
2
2
 
3
3
  //#region src/shared/model.d.ts
4
- declare const realtimeModels: z.ZodUnion<readonly [z.ZodLiteral<"lucy">, z.ZodLiteral<"lucy-2">, z.ZodLiteral<"lucy-2.1">, z.ZodLiteral<"lucy-2.1-vton">, z.ZodLiteral<"lucy-restyle">, z.ZodLiteral<"lucy-restyle-2">, z.ZodLiteral<"live-avatar">, z.ZodLiteral<"lucy-latest">, z.ZodLiteral<"lucy-vton-latest">, z.ZodLiteral<"lucy-restyle-latest">, z.ZodLiteral<"mirage">, z.ZodLiteral<"mirage_v2">, z.ZodLiteral<"lucy_v2v_720p_rt">, z.ZodLiteral<"lucy_2_rt">, z.ZodLiteral<"live_avatar">]>;
5
- declare const videoModels: z.ZodUnion<readonly [z.ZodLiteral<"lucy-clip">, z.ZodLiteral<"lucy-2">, z.ZodLiteral<"lucy-2.1">, z.ZodLiteral<"lucy-2.1-vton">, z.ZodLiteral<"lucy-restyle-2">, z.ZodLiteral<"lucy-motion">, z.ZodLiteral<"lucy-latest">, z.ZodLiteral<"lucy-vton-latest">, z.ZodLiteral<"lucy-restyle-latest">, z.ZodLiteral<"lucy-clip-latest">, z.ZodLiteral<"lucy-motion-latest">, z.ZodLiteral<"lucy-pro-v2v">, z.ZodLiteral<"lucy-restyle-v2v">, z.ZodLiteral<"lucy-2-v2v">]>;
4
+ declare const realtimeModels: z.ZodUnion<readonly [z.ZodLiteral<"lucy">, z.ZodLiteral<"lucy-2.1">, z.ZodLiteral<"lucy-2.1-vton">, z.ZodLiteral<"lucy-restyle">, z.ZodLiteral<"lucy-restyle-2">, z.ZodLiteral<"live-avatar">, z.ZodLiteral<"lucy-latest">, z.ZodLiteral<"lucy-vton-latest">, z.ZodLiteral<"lucy-restyle-latest">, z.ZodLiteral<"mirage">, z.ZodLiteral<"mirage_v2">, z.ZodLiteral<"lucy_v2v_720p_rt">, z.ZodLiteral<"live_avatar">]>;
5
+ declare const videoModels: z.ZodUnion<readonly [z.ZodLiteral<"lucy-clip">, z.ZodLiteral<"lucy-2.1">, z.ZodLiteral<"lucy-2.1-vton">, z.ZodLiteral<"lucy-restyle-2">, z.ZodLiteral<"lucy-motion">, z.ZodLiteral<"lucy-latest">, z.ZodLiteral<"lucy-vton-latest">, z.ZodLiteral<"lucy-restyle-latest">, z.ZodLiteral<"lucy-clip-latest">, z.ZodLiteral<"lucy-motion-latest">, z.ZodLiteral<"lucy-pro-v2v">, z.ZodLiteral<"lucy-restyle-v2v">]>;
6
6
  declare const imageModels: z.ZodUnion<readonly [z.ZodLiteral<"lucy-image-2">, z.ZodLiteral<"lucy-image-latest">, z.ZodLiteral<"lucy-pro-i2i">]>;
7
- declare const modelSchema: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"lucy">, z.ZodLiteral<"lucy-2">, z.ZodLiteral<"lucy-2.1">, z.ZodLiteral<"lucy-2.1-vton">, z.ZodLiteral<"lucy-restyle">, z.ZodLiteral<"lucy-restyle-2">, z.ZodLiteral<"live-avatar">, z.ZodLiteral<"lucy-latest">, z.ZodLiteral<"lucy-vton-latest">, z.ZodLiteral<"lucy-restyle-latest">, z.ZodLiteral<"mirage">, z.ZodLiteral<"mirage_v2">, z.ZodLiteral<"lucy_v2v_720p_rt">, z.ZodLiteral<"lucy_2_rt">, z.ZodLiteral<"live_avatar">]>, z.ZodUnion<readonly [z.ZodLiteral<"lucy-clip">, z.ZodLiteral<"lucy-2">, z.ZodLiteral<"lucy-2.1">, z.ZodLiteral<"lucy-2.1-vton">, z.ZodLiteral<"lucy-restyle-2">, z.ZodLiteral<"lucy-motion">, z.ZodLiteral<"lucy-latest">, z.ZodLiteral<"lucy-vton-latest">, z.ZodLiteral<"lucy-restyle-latest">, z.ZodLiteral<"lucy-clip-latest">, z.ZodLiteral<"lucy-motion-latest">, z.ZodLiteral<"lucy-pro-v2v">, z.ZodLiteral<"lucy-restyle-v2v">, z.ZodLiteral<"lucy-2-v2v">]>, z.ZodUnion<readonly [z.ZodLiteral<"lucy-image-2">, z.ZodLiteral<"lucy-image-latest">, z.ZodLiteral<"lucy-pro-i2i">]>]>;
7
+ declare const modelSchema: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"lucy">, z.ZodLiteral<"lucy-2.1">, z.ZodLiteral<"lucy-2.1-vton">, z.ZodLiteral<"lucy-restyle">, z.ZodLiteral<"lucy-restyle-2">, z.ZodLiteral<"live-avatar">, z.ZodLiteral<"lucy-latest">, z.ZodLiteral<"lucy-vton-latest">, z.ZodLiteral<"lucy-restyle-latest">, z.ZodLiteral<"mirage">, z.ZodLiteral<"mirage_v2">, z.ZodLiteral<"lucy_v2v_720p_rt">, z.ZodLiteral<"live_avatar">]>, z.ZodUnion<readonly [z.ZodLiteral<"lucy-clip">, z.ZodLiteral<"lucy-2.1">, z.ZodLiteral<"lucy-2.1-vton">, z.ZodLiteral<"lucy-restyle-2">, z.ZodLiteral<"lucy-motion">, z.ZodLiteral<"lucy-latest">, z.ZodLiteral<"lucy-vton-latest">, z.ZodLiteral<"lucy-restyle-latest">, z.ZodLiteral<"lucy-clip-latest">, z.ZodLiteral<"lucy-motion-latest">, z.ZodLiteral<"lucy-pro-v2v">, z.ZodLiteral<"lucy-restyle-v2v">]>, z.ZodUnion<readonly [z.ZodLiteral<"lucy-image-2">, z.ZodLiteral<"lucy-image-latest">, z.ZodLiteral<"lucy-pro-i2i">]>]>;
8
8
  type Model = z.infer<typeof modelSchema>;
9
9
  type RealTimeModels = z.infer<typeof realtimeModels>;
10
10
  type VideoModels = z.infer<typeof videoModels>;
@@ -64,22 +64,6 @@ declare const modelInputSchemas: {
64
64
  resolution: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"720p">>>;
65
65
  enhance_prompt: z.ZodOptional<z.ZodBoolean>;
66
66
  }, z.core.$strip>;
67
- readonly "lucy-2": z.ZodObject<{
68
- prompt: z.ZodString;
69
- reference_image: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<File, File>, z.ZodCustom<Blob, Blob>, z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>, z.ZodCustom<URL, URL>, z.ZodURL, z.ZodObject<{
70
- uri: z.ZodString;
71
- type: z.ZodString;
72
- name: z.ZodString;
73
- }, z.core.$strip>]>>;
74
- data: z.ZodUnion<readonly [z.ZodCustom<File, File>, z.ZodCustom<Blob, Blob>, z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>, z.ZodCustom<URL, URL>, z.ZodURL, z.ZodObject<{
75
- uri: z.ZodString;
76
- type: z.ZodString;
77
- name: z.ZodString;
78
- }, z.core.$strip>]>;
79
- seed: z.ZodOptional<z.ZodNumber>;
80
- resolution: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"720p">>>;
81
- enhance_prompt: z.ZodOptional<z.ZodBoolean>;
82
- }, z.core.$strip>;
83
67
  readonly "lucy-2.1": z.ZodObject<{
84
68
  prompt: z.ZodString;
85
69
  reference_image: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<File, File>, z.ZodCustom<Blob, Blob>, z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>, z.ZodCustom<URL, URL>, z.ZodURL, z.ZodObject<{
@@ -274,22 +258,6 @@ declare const modelInputSchemas: {
274
258
  resolution: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"720p">>>;
275
259
  enhance_prompt: z.ZodOptional<z.ZodBoolean>;
276
260
  }, z.core.$strip>;
277
- readonly "lucy-2-v2v": z.ZodObject<{
278
- prompt: z.ZodString;
279
- reference_image: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<File, File>, z.ZodCustom<Blob, Blob>, z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>, z.ZodCustom<URL, URL>, z.ZodURL, z.ZodObject<{
280
- uri: z.ZodString;
281
- type: z.ZodString;
282
- name: z.ZodString;
283
- }, z.core.$strip>]>>;
284
- data: z.ZodUnion<readonly [z.ZodCustom<File, File>, z.ZodCustom<Blob, Blob>, z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>, z.ZodCustom<URL, URL>, z.ZodURL, z.ZodObject<{
285
- uri: z.ZodString;
286
- type: z.ZodString;
287
- name: z.ZodString;
288
- }, z.core.$strip>]>;
289
- seed: z.ZodOptional<z.ZodNumber>;
290
- resolution: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"720p">>>;
291
- enhance_prompt: z.ZodOptional<z.ZodBoolean>;
292
- }, z.core.$strip>;
293
261
  };
294
262
  type ModelInputSchemas = typeof modelInputSchemas;
295
263
  type ModelDefinition<T extends Model = Model> = {
@@ -330,7 +298,6 @@ declare const models: {
330
298
  * Get a realtime streaming model identifier.
331
299
  *
332
300
  * Available options:
333
- * - `"lucy-2"` - Lucy 2 realtime video editing (720p)
334
301
  * - `"lucy-2.1"` - Lucy 2.1 realtime video editing
335
302
  * - `"lucy-2.1-vton"` - Lucy 2.1 virtual try-on
336
303
  * - `"lucy-restyle-2"` - Realtime video restyling
@@ -344,7 +311,6 @@ declare const models: {
344
311
  *
345
312
  * Available options:
346
313
  * - `"lucy-clip"` - Video-to-video editing
347
- * - `"lucy-2"` - Long-form video editing (720p)
348
314
  * - `"lucy-2.1"` - Long-form video editing (Lucy 2.1)
349
315
  * - `"lucy-2.1-vton"` - Virtual try-on video editing
350
316
  * - `"lucy-restyle-2"` - Video restyling
@@ -10,11 +10,9 @@ const MODEL_ALIASES = {
10
10
  mirage: "lucy-restyle",
11
11
  mirage_v2: "lucy-restyle-2",
12
12
  lucy_v2v_720p_rt: "lucy",
13
- lucy_2_rt: "lucy-2",
14
13
  live_avatar: "live-avatar",
15
14
  "lucy-pro-v2v": "lucy-clip",
16
15
  "lucy-restyle-v2v": "lucy-restyle-2",
17
- "lucy-2-v2v": "lucy-2",
18
16
  "lucy-pro-i2i": "lucy-image-2"
19
17
  };
20
18
  const _warnedAliases = /* @__PURE__ */ new Set();
@@ -27,7 +25,6 @@ function warnDeprecated(model) {
27
25
  }
28
26
  const realtimeModels = z.union([
29
27
  z.literal("lucy"),
30
- z.literal("lucy-2"),
31
28
  z.literal("lucy-2.1"),
32
29
  z.literal("lucy-2.1-vton"),
33
30
  z.literal("lucy-restyle"),
@@ -39,12 +36,10 @@ const realtimeModels = z.union([
39
36
  z.literal("mirage"),
40
37
  z.literal("mirage_v2"),
41
38
  z.literal("lucy_v2v_720p_rt"),
42
- z.literal("lucy_2_rt"),
43
39
  z.literal("live_avatar")
44
40
  ]);
45
41
  const videoModels = z.union([
46
42
  z.literal("lucy-clip"),
47
- z.literal("lucy-2"),
48
43
  z.literal("lucy-2.1"),
49
44
  z.literal("lucy-2.1-vton"),
50
45
  z.literal("lucy-restyle-2"),
@@ -55,8 +50,7 @@ const videoModels = z.union([
55
50
  z.literal("lucy-clip-latest"),
56
51
  z.literal("lucy-motion-latest"),
57
52
  z.literal("lucy-pro-v2v"),
58
- z.literal("lucy-restyle-v2v"),
59
- z.literal("lucy-2-v2v")
53
+ z.literal("lucy-restyle-v2v")
60
54
  ]);
61
55
  const imageModels = z.union([
62
56
  z.literal("lucy-image-2"),
@@ -140,7 +134,6 @@ const modelInputSchemas = {
140
134
  "lucy-clip": videoEditSchema,
141
135
  "lucy-image-2": imageEditSchema,
142
136
  "lucy-restyle-2": restyleSchema,
143
- "lucy-2": videoEdit2Schema,
144
137
  "lucy-2.1": videoEdit2Schema,
145
138
  "lucy-2.1-vton": videoEdit2Schema,
146
139
  "lucy-motion": z.object({
@@ -170,8 +163,7 @@ const modelInputSchemas = {
170
163
  "lucy-image-latest": imageEditSchema,
171
164
  "lucy-pro-v2v": videoEditSchema,
172
165
  "lucy-pro-i2i": imageEditSchema,
173
- "lucy-restyle-v2v": restyleSchema,
174
- "lucy-2-v2v": videoEdit2Schema
166
+ "lucy-restyle-v2v": restyleSchema
175
167
  };
176
168
  const modelDefinitionSchema = z.object({
177
169
  name: z.string(),
@@ -192,14 +184,6 @@ const _models = {
192
184
  height: 704,
193
185
  inputSchema: z.object({})
194
186
  },
195
- "lucy-2": {
196
- urlPath: "/v1/stream",
197
- name: "lucy-2",
198
- fps: 20,
199
- width: 1280,
200
- height: 720,
201
- inputSchema: z.object({})
202
- },
203
187
  "lucy-2.1": {
204
188
  urlPath: "/v1/stream",
205
189
  name: "lucy-2.1",
@@ -288,14 +272,6 @@ const _models = {
288
272
  height: 704,
289
273
  inputSchema: z.object({})
290
274
  },
291
- lucy_2_rt: {
292
- urlPath: "/v1/stream",
293
- name: "lucy_2_rt",
294
- fps: 20,
295
- width: 1280,
296
- height: 720,
297
- inputSchema: z.object({})
298
- },
299
275
  live_avatar: {
300
276
  urlPath: "/v1/stream",
301
277
  name: "live_avatar",
@@ -344,15 +320,6 @@ const _models = {
344
320
  height: 704,
345
321
  inputSchema: modelInputSchemas["lucy-clip"]
346
322
  },
347
- "lucy-2": {
348
- urlPath: "/v1/generate/lucy-2",
349
- queueUrlPath: "/v1/jobs/lucy-2",
350
- name: "lucy-2",
351
- fps: 20,
352
- width: 1280,
353
- height: 720,
354
- inputSchema: modelInputSchemas["lucy-2"]
355
- },
356
323
  "lucy-2.1": {
357
324
  urlPath: "/v1/generate/lucy-2.1",
358
325
  queueUrlPath: "/v1/jobs/lucy-2.1",
@@ -451,15 +418,6 @@ const _models = {
451
418
  width: 1280,
452
419
  height: 704,
453
420
  inputSchema: modelInputSchemas["lucy-restyle-v2v"]
454
- },
455
- "lucy-2-v2v": {
456
- urlPath: "/v1/generate/lucy-2-v2v",
457
- queueUrlPath: "/v1/jobs/lucy-2-v2v",
458
- name: "lucy-2-v2v",
459
- fps: 20,
460
- width: 1280,
461
- height: 720,
462
- inputSchema: modelInputSchemas["lucy-2-v2v"]
463
421
  }
464
422
  }
465
423
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decartai/sdk",
3
- "version": "0.0.60",
3
+ "version": "0.0.62",
4
4
  "description": "Decart's JavaScript SDK",
5
5
  "type": "module",
6
6
  "license": "MIT",