@decartai/sdk 0.0.64 → 0.0.66
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/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/process/types.d.ts +1 -1
- package/dist/shared/model.d.ts +105 -4
- package/dist/shared/model.js +143 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LogLevel, Logger, createConsoleLogger, noopLogger } from "./utils/logger.js";
|
|
2
|
-
import { CustomModelDefinition, ImageModelDefinition, ImageModels, Model, ModelDefinition, RealTimeModels, VideoModelDefinition, VideoModels, isImageModel, isRealtimeModel, isVideoModel, models } from "./shared/model.js";
|
|
2
|
+
import { CanonicalModel, CustomModelDefinition, ImageModelDefinition, ImageModels, ListedModelDefinition, Model, ModelDefinition, ModelKind, RealTimeModels, VideoModelDefinition, VideoModels, isCanonicalModel, isImageModel, isModel, isRealtimeModel, isVideoModel, listModels, modelAliases, models, resolveCanonicalModelAlias, resolveModelAlias } from "./shared/model.js";
|
|
3
3
|
import { FileInput, ProcessOptions, ReactNativeFile } from "./process/types.js";
|
|
4
4
|
import { ProcessClient } from "./process/client.js";
|
|
5
5
|
import { JobStatus, JobStatusResponse, JobSubmitResponse, QueueJobResult, QueueSubmitAndPollOptions, QueueSubmitOptions } from "./queue/types.js";
|
|
@@ -134,4 +134,4 @@ declare const createDecartClient: (options?: DecartClientOptions) => {
|
|
|
134
134
|
tokens: TokensClient;
|
|
135
135
|
};
|
|
136
136
|
//#endregion
|
|
137
|
-
export { type ConnectionPhase, type ConnectionState, type CreateTokenOptions, type CreateTokenResponse, type CustomModelDefinition, DecartClientOptions, type DecartSDKError, type DiagnosticEvent, type DiagnosticEventName, type DiagnosticEvents, ERROR_CODES, type FileInput, type IceCandidateEvent, type IceStateEvent, type ImageModelDefinition, type ImageModels, type JobStatus, type JobStatusResponse, type JobSubmitResponse, type LogLevel, type Logger, type Model, type ModelDefinition, type ModelState, type PeerConnectionStateEvent, type PhaseTimingEvent, type ProcessClient, type ProcessOptions, type QueueClient, type QueueJobResult, type QueueSubmitAndPollOptions, type QueueSubmitOptions, type ReactNativeFile, type RealTimeClient, type RealTimeClientConnectOptions, type RealTimeClientInitialState, type Events as RealTimeEvents, type RealTimeModels, type RealTimeSubscribeClient, type ReconnectEvent, type SelectedCandidatePairEvent, type SetInput, type SignalingStateEvent, type SubscribeEvents, type SubscribeOptions, type TokensClient, type VideoModelDefinition, type VideoModels, type VideoStallEvent, type WebRTCStats, createConsoleLogger, createDecartClient, isImageModel, isRealtimeModel, isVideoModel, models, noopLogger };
|
|
137
|
+
export { type CanonicalModel, type ConnectionPhase, type ConnectionState, type CreateTokenOptions, type CreateTokenResponse, type CustomModelDefinition, DecartClientOptions, type DecartSDKError, type DiagnosticEvent, type DiagnosticEventName, type DiagnosticEvents, ERROR_CODES, type FileInput, type IceCandidateEvent, type IceStateEvent, type ImageModelDefinition, type ImageModels, type JobStatus, type JobStatusResponse, type JobSubmitResponse, type ListedModelDefinition, type LogLevel, type Logger, type Model, type ModelDefinition, type ModelKind, type ModelState, type PeerConnectionStateEvent, type PhaseTimingEvent, type ProcessClient, type ProcessOptions, type QueueClient, type QueueJobResult, type QueueSubmitAndPollOptions, type QueueSubmitOptions, type ReactNativeFile, type RealTimeClient, type RealTimeClientConnectOptions, type RealTimeClientInitialState, type Events as RealTimeEvents, type RealTimeModels, type RealTimeSubscribeClient, type ReconnectEvent, type SelectedCandidatePairEvent, type SetInput, type SignalingStateEvent, type SubscribeEvents, type SubscribeOptions, type TokensClient, type VideoModelDefinition, type VideoModels, type VideoStallEvent, type WebRTCStats, createConsoleLogger, createDecartClient, isCanonicalModel, isImageModel, isModel, isRealtimeModel, isVideoModel, listModels, modelAliases, models, noopLogger, resolveCanonicalModelAlias, resolveModelAlias };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ERROR_CODES, createInvalidApiKeyError, createInvalidBaseUrlError } from "./utils/errors.js";
|
|
2
2
|
import { createProcessClient } from "./process/client.js";
|
|
3
3
|
import { createQueueClient } from "./queue/client.js";
|
|
4
|
-
import { isImageModel, isRealtimeModel, isVideoModel, models } from "./shared/model.js";
|
|
4
|
+
import { isCanonicalModel, isImageModel, isModel, isRealtimeModel, isVideoModel, listModels, modelAliases, models, resolveCanonicalModelAlias, resolveModelAlias } from "./shared/model.js";
|
|
5
5
|
import { createRealTimeClient } from "./realtime/client.js";
|
|
6
6
|
import { createTokensClient } from "./tokens/client.js";
|
|
7
7
|
import { readEnv } from "./utils/env.js";
|
|
@@ -88,4 +88,4 @@ const createDecartClient = (options = {}) => {
|
|
|
88
88
|
};
|
|
89
89
|
|
|
90
90
|
//#endregion
|
|
91
|
-
export { ERROR_CODES, createConsoleLogger, createDecartClient, isImageModel, isRealtimeModel, isVideoModel, models, noopLogger };
|
|
91
|
+
export { ERROR_CODES, createConsoleLogger, createDecartClient, isCanonicalModel, isImageModel, isModel, isRealtimeModel, isVideoModel, listModels, modelAliases, models, noopLogger, resolveCanonicalModelAlias, resolveModelAlias };
|
package/dist/process/types.d.ts
CHANGED
|
@@ -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.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" | "lucy-vton-2" | "lucy-vton" | "lucy-2.1-vton-2" | "lucy-vton-latest" ? 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.
|
package/dist/shared/model.d.ts
CHANGED
|
@@ -1,10 +1,34 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
3
|
//#region src/shared/model.d.ts
|
|
4
|
-
|
|
5
|
-
declare const
|
|
4
|
+
|
|
5
|
+
declare const canonicalModelSchema: z.ZodEnum<{
|
|
6
|
+
"lucy-2.1": "lucy-2.1";
|
|
7
|
+
"lucy-2.1-vton": "lucy-2.1-vton";
|
|
8
|
+
"lucy-vton-2": "lucy-vton-2";
|
|
9
|
+
"lucy-restyle-2": "lucy-restyle-2";
|
|
10
|
+
"lucy-clip": "lucy-clip";
|
|
11
|
+
"lucy-image-2": "lucy-image-2";
|
|
12
|
+
}>;
|
|
13
|
+
type CanonicalModel = z.infer<typeof canonicalModelSchema>;
|
|
14
|
+
/**
|
|
15
|
+
* Map of deprecated model names to their canonical replacements.
|
|
16
|
+
* Old names still work but will log a deprecation warning.
|
|
17
|
+
*/
|
|
18
|
+
declare const modelAliases: {
|
|
19
|
+
readonly mirage_v2: "lucy-restyle-2";
|
|
20
|
+
readonly "lucy-vton": "lucy-2.1-vton";
|
|
21
|
+
readonly "lucy-2.1-vton-2": "lucy-vton-2";
|
|
22
|
+
readonly "lucy-pro-v2v": "lucy-clip";
|
|
23
|
+
readonly "lucy-restyle-v2v": "lucy-restyle-2";
|
|
24
|
+
readonly "lucy-pro-i2i": "lucy-image-2";
|
|
25
|
+
};
|
|
26
|
+
/** @internal Test-only helper to reset deprecation warning tracking */
|
|
27
|
+
|
|
28
|
+
declare const realtimeModels: z.ZodUnion<readonly [z.ZodLiteral<"lucy-2.1">, z.ZodLiteral<"lucy-2.1-vton">, z.ZodLiteral<"lucy-vton-2">, z.ZodLiteral<"lucy-restyle-2">, z.ZodLiteral<"lucy-latest">, z.ZodLiteral<"lucy-vton-latest">, z.ZodLiteral<"lucy-restyle-latest">, z.ZodLiteral<"mirage_v2">, z.ZodLiteral<"lucy-vton">, z.ZodLiteral<"lucy-2.1-vton-2">]>;
|
|
29
|
+
declare const videoModels: z.ZodUnion<readonly [z.ZodLiteral<"lucy-clip">, z.ZodLiteral<"lucy-2.1">, z.ZodLiteral<"lucy-2.1-vton">, z.ZodLiteral<"lucy-vton-2">, z.ZodLiteral<"lucy-restyle-2">, z.ZodLiteral<"lucy-latest">, z.ZodLiteral<"lucy-vton-latest">, z.ZodLiteral<"lucy-restyle-latest">, z.ZodLiteral<"lucy-clip-latest">, z.ZodLiteral<"lucy-vton">, z.ZodLiteral<"lucy-2.1-vton-2">, z.ZodLiteral<"lucy-pro-v2v">, z.ZodLiteral<"lucy-restyle-v2v">]>;
|
|
6
30
|
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-2.1">, z.ZodLiteral<"lucy-2.1-vton">, z.ZodLiteral<"lucy-restyle-2">, z.ZodLiteral<"lucy-latest">, z.ZodLiteral<"lucy-vton-latest">, z.ZodLiteral<"lucy-restyle-latest">, z.ZodLiteral<"mirage_v2">]>, 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-latest">, z.ZodLiteral<"lucy-vton-latest">, z.ZodLiteral<"lucy-restyle-latest">, z.ZodLiteral<"lucy-clip-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">]>]>;
|
|
31
|
+
declare const modelSchema: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"lucy-2.1">, z.ZodLiteral<"lucy-2.1-vton">, z.ZodLiteral<"lucy-vton-2">, z.ZodLiteral<"lucy-restyle-2">, z.ZodLiteral<"lucy-latest">, z.ZodLiteral<"lucy-vton-latest">, z.ZodLiteral<"lucy-restyle-latest">, z.ZodLiteral<"mirage_v2">, z.ZodLiteral<"lucy-vton">, z.ZodLiteral<"lucy-2.1-vton-2">]>, z.ZodUnion<readonly [z.ZodLiteral<"lucy-clip">, z.ZodLiteral<"lucy-2.1">, z.ZodLiteral<"lucy-2.1-vton">, z.ZodLiteral<"lucy-vton-2">, z.ZodLiteral<"lucy-restyle-2">, z.ZodLiteral<"lucy-latest">, z.ZodLiteral<"lucy-vton-latest">, z.ZodLiteral<"lucy-restyle-latest">, z.ZodLiteral<"lucy-clip-latest">, z.ZodLiteral<"lucy-vton">, z.ZodLiteral<"lucy-2.1-vton-2">, 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
32
|
type Model = z.infer<typeof modelSchema>;
|
|
9
33
|
type RealTimeModels = z.infer<typeof realtimeModels>;
|
|
10
34
|
type VideoModels = z.infer<typeof videoModels>;
|
|
@@ -12,6 +36,20 @@ type ImageModels = z.infer<typeof imageModels>;
|
|
|
12
36
|
declare function isRealtimeModel(model: string): model is RealTimeModels;
|
|
13
37
|
declare function isVideoModel(model: string): model is VideoModels;
|
|
14
38
|
declare function isImageModel(model: string): model is ImageModels;
|
|
39
|
+
declare function isModel(model: string): model is Model;
|
|
40
|
+
declare function isCanonicalModel(model: string): model is CanonicalModel;
|
|
41
|
+
/**
|
|
42
|
+
* Resolve deprecated aliases to canonical model names and pass accepted model names through unchanged.
|
|
43
|
+
* Latest aliases pass through unchanged because they are server-side moving targets. This is a pure normalization helper
|
|
44
|
+
* and does not emit deprecation warnings.
|
|
45
|
+
*/
|
|
46
|
+
declare function resolveModelAlias(model: string): Model | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Resolve deprecated aliases and canonical inputs to stable canonical model names.
|
|
49
|
+
* Latest aliases are server-side moving targets, so they intentionally return undefined. This is a pure normalization
|
|
50
|
+
* helper and does not emit deprecation warnings.
|
|
51
|
+
*/
|
|
52
|
+
declare function resolveCanonicalModelAlias(model: string): CanonicalModel | undefined;
|
|
15
53
|
declare const modelInputSchemas: {
|
|
16
54
|
readonly "lucy-clip": z.ZodObject<{
|
|
17
55
|
prompt: z.ZodString;
|
|
@@ -96,6 +134,22 @@ declare const modelInputSchemas: {
|
|
|
96
134
|
resolution: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"720p">>>;
|
|
97
135
|
enhance_prompt: z.ZodOptional<z.ZodBoolean>;
|
|
98
136
|
}, z.core.$strip>;
|
|
137
|
+
readonly "lucy-vton-2": z.ZodObject<{
|
|
138
|
+
prompt: z.ZodString;
|
|
139
|
+
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<{
|
|
140
|
+
uri: z.ZodString;
|
|
141
|
+
type: z.ZodString;
|
|
142
|
+
name: z.ZodString;
|
|
143
|
+
}, z.core.$strip>]>>;
|
|
144
|
+
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<{
|
|
145
|
+
uri: z.ZodString;
|
|
146
|
+
type: z.ZodString;
|
|
147
|
+
name: z.ZodString;
|
|
148
|
+
}, z.core.$strip>]>;
|
|
149
|
+
seed: z.ZodOptional<z.ZodNumber>;
|
|
150
|
+
resolution: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"720p">>>;
|
|
151
|
+
enhance_prompt: z.ZodOptional<z.ZodBoolean>;
|
|
152
|
+
}, z.core.$strip>;
|
|
99
153
|
readonly "lucy-latest": z.ZodObject<{
|
|
100
154
|
prompt: z.ZodString;
|
|
101
155
|
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<{
|
|
@@ -179,6 +233,38 @@ declare const modelInputSchemas: {
|
|
|
179
233
|
}>>>;
|
|
180
234
|
enhance_prompt: z.ZodOptional<z.ZodBoolean>;
|
|
181
235
|
}, z.core.$strip>;
|
|
236
|
+
readonly "lucy-vton": z.ZodObject<{
|
|
237
|
+
prompt: z.ZodString;
|
|
238
|
+
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<{
|
|
239
|
+
uri: z.ZodString;
|
|
240
|
+
type: z.ZodString;
|
|
241
|
+
name: z.ZodString;
|
|
242
|
+
}, z.core.$strip>]>>;
|
|
243
|
+
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<{
|
|
244
|
+
uri: z.ZodString;
|
|
245
|
+
type: z.ZodString;
|
|
246
|
+
name: z.ZodString;
|
|
247
|
+
}, z.core.$strip>]>;
|
|
248
|
+
seed: z.ZodOptional<z.ZodNumber>;
|
|
249
|
+
resolution: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"720p">>>;
|
|
250
|
+
enhance_prompt: z.ZodOptional<z.ZodBoolean>;
|
|
251
|
+
}, z.core.$strip>;
|
|
252
|
+
readonly "lucy-2.1-vton-2": z.ZodObject<{
|
|
253
|
+
prompt: z.ZodString;
|
|
254
|
+
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<{
|
|
255
|
+
uri: z.ZodString;
|
|
256
|
+
type: z.ZodString;
|
|
257
|
+
name: z.ZodString;
|
|
258
|
+
}, z.core.$strip>]>>;
|
|
259
|
+
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<{
|
|
260
|
+
uri: z.ZodString;
|
|
261
|
+
type: z.ZodString;
|
|
262
|
+
name: z.ZodString;
|
|
263
|
+
}, z.core.$strip>]>;
|
|
264
|
+
seed: z.ZodOptional<z.ZodNumber>;
|
|
265
|
+
resolution: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"720p">>>;
|
|
266
|
+
enhance_prompt: z.ZodOptional<z.ZodBoolean>;
|
|
267
|
+
}, z.core.$strip>;
|
|
182
268
|
readonly "lucy-pro-v2v": z.ZodObject<{
|
|
183
269
|
prompt: z.ZodString;
|
|
184
270
|
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<{
|
|
@@ -265,6 +351,19 @@ type ImageModelDefinition = ModelDefinition<ImageModels> & {
|
|
|
265
351
|
type VideoModelDefinition = ModelDefinition<VideoModels> & {
|
|
266
352
|
queueUrlPath: string;
|
|
267
353
|
};
|
|
354
|
+
type ModelKind = "realtime" | "video" | "image";
|
|
355
|
+
type ListedModelDefinition = ModelDefinition & {
|
|
356
|
+
kind: ModelKind;
|
|
357
|
+
};
|
|
358
|
+
/**
|
|
359
|
+
* List SDK model definitions by kind.
|
|
360
|
+
* When canonicalOnly is true, deprecated and latest aliases are excluded per kind. Models available in multiple kinds
|
|
361
|
+
* are returned once per kind with the same name and different kind values.
|
|
362
|
+
*/
|
|
363
|
+
declare function listModels(options?: {
|
|
364
|
+
kind?: ModelKind;
|
|
365
|
+
canonicalOnly?: boolean;
|
|
366
|
+
}): ListedModelDefinition[];
|
|
268
367
|
declare const models: {
|
|
269
368
|
/**
|
|
270
369
|
* Get a realtime streaming model identifier.
|
|
@@ -272,6 +371,7 @@ declare const models: {
|
|
|
272
371
|
* Available options:
|
|
273
372
|
* - `"lucy-2.1"` - Lucy 2.1 realtime video editing
|
|
274
373
|
* - `"lucy-2.1-vton"` - Lucy 2.1 virtual try-on
|
|
374
|
+
* - `"lucy-vton-2"` - Lucy virtual try-on 2
|
|
275
375
|
* - `"lucy-restyle-2"` - Realtime video restyling
|
|
276
376
|
*/
|
|
277
377
|
realtime: <T extends RealTimeModels>(model: T) => ModelDefinition<T>;
|
|
@@ -282,6 +382,7 @@ declare const models: {
|
|
|
282
382
|
* - `"lucy-clip"` - Video-to-video editing
|
|
283
383
|
* - `"lucy-2.1"` - Long-form video editing (Lucy 2.1)
|
|
284
384
|
* - `"lucy-2.1-vton"` - Virtual try-on video editing
|
|
385
|
+
* - `"lucy-vton-2"` - Virtual try-on 2 video editing
|
|
285
386
|
* - `"lucy-restyle-2"` - Video restyling
|
|
286
387
|
*/
|
|
287
388
|
video: <T extends VideoModels>(model: T) => ModelDefinition<T> & {
|
|
@@ -298,4 +399,4 @@ declare const models: {
|
|
|
298
399
|
};
|
|
299
400
|
};
|
|
300
401
|
//#endregion
|
|
301
|
-
export { CustomModelDefinition, ImageModelDefinition, ImageModels, Model, ModelDefinition, ModelInputSchemas, RealTimeModels, VideoModelDefinition, VideoModels, isImageModel, isRealtimeModel, isVideoModel, models };
|
|
402
|
+
export { CanonicalModel, CustomModelDefinition, ImageModelDefinition, ImageModels, ListedModelDefinition, Model, ModelDefinition, ModelInputSchemas, ModelKind, RealTimeModels, VideoModelDefinition, VideoModels, isCanonicalModel, isImageModel, isModel, isRealtimeModel, isVideoModel, listModels, modelAliases, models, resolveCanonicalModelAlias, resolveModelAlias };
|
package/dist/shared/model.js
CHANGED
|
@@ -2,19 +2,47 @@ import { createModelNotFoundError } from "../utils/errors.js";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
4
|
//#region src/shared/model.ts
|
|
5
|
+
const CANONICAL_MODEL_NAMES = [
|
|
6
|
+
"lucy-2.1",
|
|
7
|
+
"lucy-2.1-vton",
|
|
8
|
+
"lucy-vton-2",
|
|
9
|
+
"lucy-restyle-2",
|
|
10
|
+
"lucy-clip",
|
|
11
|
+
"lucy-image-2"
|
|
12
|
+
];
|
|
13
|
+
const CANONICAL_REALTIME_MODEL_NAMES = [
|
|
14
|
+
"lucy-2.1",
|
|
15
|
+
"lucy-2.1-vton",
|
|
16
|
+
"lucy-vton-2",
|
|
17
|
+
"lucy-restyle-2"
|
|
18
|
+
];
|
|
19
|
+
const CANONICAL_VIDEO_MODEL_NAMES = [
|
|
20
|
+
"lucy-clip",
|
|
21
|
+
"lucy-2.1",
|
|
22
|
+
"lucy-2.1-vton",
|
|
23
|
+
"lucy-vton-2",
|
|
24
|
+
"lucy-restyle-2"
|
|
25
|
+
];
|
|
26
|
+
const CANONICAL_IMAGE_MODEL_NAMES = ["lucy-image-2"];
|
|
27
|
+
const canonicalRealtimeModels = z.enum(CANONICAL_REALTIME_MODEL_NAMES);
|
|
28
|
+
const canonicalVideoModels = z.enum(CANONICAL_VIDEO_MODEL_NAMES);
|
|
29
|
+
const canonicalImageModels = z.enum(CANONICAL_IMAGE_MODEL_NAMES);
|
|
30
|
+
const canonicalModelSchema = z.enum(CANONICAL_MODEL_NAMES);
|
|
5
31
|
/**
|
|
6
32
|
* Map of deprecated model names to their canonical replacements.
|
|
7
33
|
* Old names still work but will log a deprecation warning.
|
|
8
34
|
*/
|
|
9
|
-
const
|
|
35
|
+
const modelAliases = {
|
|
10
36
|
mirage_v2: "lucy-restyle-2",
|
|
37
|
+
"lucy-vton": "lucy-2.1-vton",
|
|
38
|
+
"lucy-2.1-vton-2": "lucy-vton-2",
|
|
11
39
|
"lucy-pro-v2v": "lucy-clip",
|
|
12
40
|
"lucy-restyle-v2v": "lucy-restyle-2",
|
|
13
41
|
"lucy-pro-i2i": "lucy-image-2"
|
|
14
42
|
};
|
|
15
43
|
const _warnedAliases = /* @__PURE__ */ new Set();
|
|
16
44
|
function warnDeprecated(model) {
|
|
17
|
-
const canonical =
|
|
45
|
+
const canonical = modelAliases[model];
|
|
18
46
|
if (canonical && !_warnedAliases.has(model)) {
|
|
19
47
|
_warnedAliases.add(model);
|
|
20
48
|
console.warn(`[Decart SDK] Model "${model}" is deprecated. Use "${canonical}" instead. See https://docs.platform.decart.ai/models for details.`);
|
|
@@ -23,21 +51,27 @@ function warnDeprecated(model) {
|
|
|
23
51
|
const realtimeModels = z.union([
|
|
24
52
|
z.literal("lucy-2.1"),
|
|
25
53
|
z.literal("lucy-2.1-vton"),
|
|
54
|
+
z.literal("lucy-vton-2"),
|
|
26
55
|
z.literal("lucy-restyle-2"),
|
|
27
56
|
z.literal("lucy-latest"),
|
|
28
57
|
z.literal("lucy-vton-latest"),
|
|
29
58
|
z.literal("lucy-restyle-latest"),
|
|
30
|
-
z.literal("mirage_v2")
|
|
59
|
+
z.literal("mirage_v2"),
|
|
60
|
+
z.literal("lucy-vton"),
|
|
61
|
+
z.literal("lucy-2.1-vton-2")
|
|
31
62
|
]);
|
|
32
63
|
const videoModels = z.union([
|
|
33
64
|
z.literal("lucy-clip"),
|
|
34
65
|
z.literal("lucy-2.1"),
|
|
35
66
|
z.literal("lucy-2.1-vton"),
|
|
67
|
+
z.literal("lucy-vton-2"),
|
|
36
68
|
z.literal("lucy-restyle-2"),
|
|
37
69
|
z.literal("lucy-latest"),
|
|
38
70
|
z.literal("lucy-vton-latest"),
|
|
39
71
|
z.literal("lucy-restyle-latest"),
|
|
40
72
|
z.literal("lucy-clip-latest"),
|
|
73
|
+
z.literal("lucy-vton"),
|
|
74
|
+
z.literal("lucy-2.1-vton-2"),
|
|
41
75
|
z.literal("lucy-pro-v2v"),
|
|
42
76
|
z.literal("lucy-restyle-v2v")
|
|
43
77
|
]);
|
|
@@ -60,6 +94,34 @@ function isVideoModel(model) {
|
|
|
60
94
|
function isImageModel(model) {
|
|
61
95
|
return imageModels.safeParse(model).success;
|
|
62
96
|
}
|
|
97
|
+
function isModel(model) {
|
|
98
|
+
return modelSchema.safeParse(model).success;
|
|
99
|
+
}
|
|
100
|
+
function isCanonicalModel(model) {
|
|
101
|
+
return canonicalModelSchema.safeParse(model).success;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Resolve deprecated aliases to canonical model names and pass accepted model names through unchanged.
|
|
105
|
+
* Latest aliases pass through unchanged because they are server-side moving targets. This is a pure normalization helper
|
|
106
|
+
* and does not emit deprecation warnings.
|
|
107
|
+
*/
|
|
108
|
+
function resolveModelAlias(model) {
|
|
109
|
+
const canonical = modelAliases[model];
|
|
110
|
+
if (canonical) return canonical;
|
|
111
|
+
const parsedModel = modelSchema.safeParse(model);
|
|
112
|
+
return parsedModel.success ? parsedModel.data : void 0;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Resolve deprecated aliases and canonical inputs to stable canonical model names.
|
|
116
|
+
* Latest aliases are server-side moving targets, so they intentionally return undefined. This is a pure normalization
|
|
117
|
+
* helper and does not emit deprecation warnings.
|
|
118
|
+
*/
|
|
119
|
+
function resolveCanonicalModelAlias(model) {
|
|
120
|
+
const canonical = modelAliases[model];
|
|
121
|
+
if (canonical) return canonical;
|
|
122
|
+
const parsedModel = canonicalModelSchema.safeParse(model);
|
|
123
|
+
return parsedModel.success ? parsedModel.data : void 0;
|
|
124
|
+
}
|
|
63
125
|
const fileInputSchema = z.union([
|
|
64
126
|
z.instanceof(File),
|
|
65
127
|
z.instanceof(Blob),
|
|
@@ -121,11 +183,14 @@ const modelInputSchemas = {
|
|
|
121
183
|
"lucy-restyle-2": restyleSchema,
|
|
122
184
|
"lucy-2.1": videoEdit2Schema,
|
|
123
185
|
"lucy-2.1-vton": videoEdit2Schema,
|
|
186
|
+
"lucy-vton-2": videoEdit2Schema,
|
|
124
187
|
"lucy-latest": videoEdit2Schema,
|
|
125
188
|
"lucy-vton-latest": videoEdit2Schema,
|
|
126
189
|
"lucy-restyle-latest": restyleSchema,
|
|
127
190
|
"lucy-clip-latest": videoEditSchema,
|
|
128
191
|
"lucy-image-latest": imageEditSchema,
|
|
192
|
+
"lucy-vton": videoEdit2Schema,
|
|
193
|
+
"lucy-2.1-vton-2": videoEdit2Schema,
|
|
129
194
|
"lucy-pro-v2v": videoEditSchema,
|
|
130
195
|
"lucy-pro-i2i": imageEditSchema,
|
|
131
196
|
"lucy-restyle-v2v": restyleSchema
|
|
@@ -157,6 +222,14 @@ const _models = {
|
|
|
157
222
|
height: 624,
|
|
158
223
|
inputSchema: z.object({})
|
|
159
224
|
},
|
|
225
|
+
"lucy-vton-2": {
|
|
226
|
+
urlPath: "/v1/stream",
|
|
227
|
+
name: "lucy-vton-2",
|
|
228
|
+
fps: 20,
|
|
229
|
+
width: 1088,
|
|
230
|
+
height: 624,
|
|
231
|
+
inputSchema: z.object({})
|
|
232
|
+
},
|
|
160
233
|
"lucy-restyle-2": {
|
|
161
234
|
urlPath: "/v1/stream",
|
|
162
235
|
name: "lucy-restyle-2",
|
|
@@ -196,6 +269,22 @@ const _models = {
|
|
|
196
269
|
width: 1280,
|
|
197
270
|
height: 704,
|
|
198
271
|
inputSchema: z.object({})
|
|
272
|
+
},
|
|
273
|
+
"lucy-vton": {
|
|
274
|
+
urlPath: "/v1/stream",
|
|
275
|
+
name: "lucy-vton",
|
|
276
|
+
fps: 20,
|
|
277
|
+
width: 1088,
|
|
278
|
+
height: 624,
|
|
279
|
+
inputSchema: z.object({})
|
|
280
|
+
},
|
|
281
|
+
"lucy-2.1-vton-2": {
|
|
282
|
+
urlPath: "/v1/stream",
|
|
283
|
+
name: "lucy-2.1-vton-2",
|
|
284
|
+
fps: 20,
|
|
285
|
+
width: 1088,
|
|
286
|
+
height: 624,
|
|
287
|
+
inputSchema: z.object({})
|
|
199
288
|
}
|
|
200
289
|
},
|
|
201
290
|
image: {
|
|
@@ -255,6 +344,15 @@ const _models = {
|
|
|
255
344
|
height: 624,
|
|
256
345
|
inputSchema: modelInputSchemas["lucy-2.1-vton"]
|
|
257
346
|
},
|
|
347
|
+
"lucy-vton-2": {
|
|
348
|
+
urlPath: "/v1/generate/lucy-vton-2",
|
|
349
|
+
queueUrlPath: "/v1/jobs/lucy-vton-2",
|
|
350
|
+
name: "lucy-vton-2",
|
|
351
|
+
fps: 20,
|
|
352
|
+
width: 1088,
|
|
353
|
+
height: 624,
|
|
354
|
+
inputSchema: modelInputSchemas["lucy-vton-2"]
|
|
355
|
+
},
|
|
258
356
|
"lucy-restyle-2": {
|
|
259
357
|
urlPath: "/v1/generate/lucy-restyle-2",
|
|
260
358
|
queueUrlPath: "/v1/jobs/lucy-restyle-2",
|
|
@@ -300,6 +398,24 @@ const _models = {
|
|
|
300
398
|
height: 704,
|
|
301
399
|
inputSchema: modelInputSchemas["lucy-clip-latest"]
|
|
302
400
|
},
|
|
401
|
+
"lucy-vton": {
|
|
402
|
+
urlPath: "/v1/generate/lucy-vton",
|
|
403
|
+
queueUrlPath: "/v1/jobs/lucy-vton",
|
|
404
|
+
name: "lucy-vton",
|
|
405
|
+
fps: 20,
|
|
406
|
+
width: 1088,
|
|
407
|
+
height: 624,
|
|
408
|
+
inputSchema: modelInputSchemas["lucy-vton"]
|
|
409
|
+
},
|
|
410
|
+
"lucy-2.1-vton-2": {
|
|
411
|
+
urlPath: "/v1/generate/lucy-2.1-vton-2",
|
|
412
|
+
queueUrlPath: "/v1/jobs/lucy-2.1-vton-2",
|
|
413
|
+
name: "lucy-2.1-vton-2",
|
|
414
|
+
fps: 20,
|
|
415
|
+
width: 1088,
|
|
416
|
+
height: 624,
|
|
417
|
+
inputSchema: modelInputSchemas["lucy-2.1-vton-2"]
|
|
418
|
+
},
|
|
303
419
|
"lucy-pro-v2v": {
|
|
304
420
|
urlPath: "/v1/generate/lucy-pro-v2v",
|
|
305
421
|
queueUrlPath: "/v1/jobs/lucy-pro-v2v",
|
|
@@ -320,6 +436,29 @@ const _models = {
|
|
|
320
436
|
}
|
|
321
437
|
}
|
|
322
438
|
};
|
|
439
|
+
const modelKinds = [
|
|
440
|
+
"realtime",
|
|
441
|
+
"video",
|
|
442
|
+
"image"
|
|
443
|
+
];
|
|
444
|
+
const canonicalSchemasByKind = {
|
|
445
|
+
realtime: canonicalRealtimeModels,
|
|
446
|
+
video: canonicalVideoModels,
|
|
447
|
+
image: canonicalImageModels
|
|
448
|
+
};
|
|
449
|
+
/**
|
|
450
|
+
* List SDK model definitions by kind.
|
|
451
|
+
* When canonicalOnly is true, deprecated and latest aliases are excluded per kind. Models available in multiple kinds
|
|
452
|
+
* are returned once per kind with the same name and different kind values.
|
|
453
|
+
*/
|
|
454
|
+
function listModels(options = {}) {
|
|
455
|
+
return (options.kind ? [options.kind] : modelKinds).flatMap((kind) => {
|
|
456
|
+
return Object.values(_models[kind]).filter((modelDefinition) => !options.canonicalOnly || canonicalSchemasByKind[kind].safeParse(modelDefinition.name).success).map((modelDefinition) => ({
|
|
457
|
+
...modelDefinition,
|
|
458
|
+
kind
|
|
459
|
+
}));
|
|
460
|
+
});
|
|
461
|
+
}
|
|
323
462
|
const models = {
|
|
324
463
|
realtime: (model) => {
|
|
325
464
|
warnDeprecated(model);
|
|
@@ -342,4 +481,4 @@ const models = {
|
|
|
342
481
|
};
|
|
343
482
|
|
|
344
483
|
//#endregion
|
|
345
|
-
export { isImageModel, isRealtimeModel, isVideoModel, modelDefinitionSchema, models };
|
|
484
|
+
export { isCanonicalModel, isImageModel, isModel, isRealtimeModel, isVideoModel, listModels, modelAliases, modelDefinitionSchema, models, resolveCanonicalModelAlias, resolveModelAlias };
|