@picsart/ai-sdk 6.13.1 → 6.13.3
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/index.d.ts +272 -240
- package/index.js +98 -5
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -343,6 +343,7 @@ type ModelInputById = {
|
|
|
343
343
|
prompt: string;
|
|
344
344
|
aspectRatio?: "1:1" | "16:9" | "9:16" | "3:4" | "4:3" | "2:3" | "21:9" | "auto";
|
|
345
345
|
count?: 1 | 2 | 4 | 6 | 8 | 10;
|
|
346
|
+
seed?: number;
|
|
346
347
|
imageUrls?: string[];
|
|
347
348
|
};
|
|
348
349
|
"gemini-2.5-flash-tts": {
|
|
@@ -368,6 +369,7 @@ type ModelInputById = {
|
|
|
368
369
|
aspectRatio?: "1:1" | "16:9" | "9:16" | "3:4" | "4:3" | "2:3" | "21:9" | "auto";
|
|
369
370
|
resolution?: "1K" | "2K" | "4K";
|
|
370
371
|
count?: 1 | 2 | 4 | 6 | 8 | 10;
|
|
372
|
+
seed?: number;
|
|
371
373
|
thinkingBudget?: number;
|
|
372
374
|
imageUrls?: string[];
|
|
373
375
|
};
|
|
@@ -376,6 +378,7 @@ type ModelInputById = {
|
|
|
376
378
|
aspectRatio?: "1:1" | "16:9" | "9:16" | "3:4" | "4:3" | "3:2" | "2:3" | "4:5" | "5:4" | "4:1" | "1:4" | "8:1" | "1:8" | "21:9" | "auto";
|
|
377
379
|
resolution?: "0.5K" | "1K" | "2K" | "4K";
|
|
378
380
|
count?: 1 | 2 | 4 | 6 | 8 | 10;
|
|
381
|
+
seed?: number;
|
|
379
382
|
thinkingLevel?: "minimal" | "high";
|
|
380
383
|
imageUrls?: string[];
|
|
381
384
|
};
|
|
@@ -383,6 +386,7 @@ type ModelInputById = {
|
|
|
383
386
|
prompt: string;
|
|
384
387
|
aspectRatio?: "1:1" | "16:9" | "9:16" | "3:4" | "4:3" | "3:2" | "2:3" | "4:5" | "5:4" | "4:1" | "1:4" | "8:1" | "1:8" | "21:9" | "auto";
|
|
385
388
|
count?: 1 | 2 | 4 | 6 | 8 | 10;
|
|
389
|
+
seed?: number;
|
|
386
390
|
thinkingLevel?: "minimal" | "high";
|
|
387
391
|
imageUrls?: string[];
|
|
388
392
|
};
|
|
@@ -1922,219 +1926,71 @@ type ModelInput<M extends TypedModelId> = ModelInputById[M];
|
|
|
1922
1926
|
type TextModelId = "claude-fable-5" | "claude-fable-5-1" | "claude-haiku-4-5" | "claude-opus-4-8" | "claude-opus-5" | "claude-sonnet-4-5" | "claude-sonnet-4-6" | "claude-sonnet-5" | "eleven-speech-to-text" | "gemini-2.5-flash" | "gemini-3-pro" | "gemini-3.5-flash-lite" | "gemini-3.6-flash" | "gemini-3.7-flash" | "gemini-3.8-flash" | "gpt-4.1-mini" | "gpt-4.1-nano" | "gpt-4o" | "gpt-4o-mini" | "gpt-5" | "gpt-5-mini" | "gpt-5.1" | "gpt-5.2" | "gpt-5.5" | "gpt-5.6-luna" | "gpt-5.6-sol" | "gpt-5.6-terra" | "gpt-6-astra";
|
|
1923
1927
|
type TextModelInputById = Pick<ModelInputById, TextModelId>;
|
|
1924
1928
|
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
generatedVoiceId?: string;
|
|
1936
|
-
/** URL of the generated video's last frame, when the model was asked for it
|
|
1937
|
-
* (`returnLastFrame`, seedance) — the seed for frame-chaining flows. */
|
|
1938
|
-
lastFrameUrl?: string;
|
|
1939
|
-
/** The draft a Seedance 2.5 Draft generation produced — pass it back
|
|
1940
|
-
* unchanged as `draftTask` to the matching `-draft-final` model to render
|
|
1941
|
-
* the final 1080p video (valid 7 days). Wire field names on purpose: the
|
|
1942
|
-
* worker signs it, so any change is rejected. */
|
|
1943
|
-
draftTask?: SeedanceDraftTask;
|
|
1944
|
-
}
|
|
1945
|
-
/** A Seedance 2.5 draft reference, as the worker issues it. */
|
|
1946
|
-
interface SeedanceDraftTask {
|
|
1947
|
-
id: string;
|
|
1948
|
-
video_input: boolean;
|
|
1949
|
-
signature: string;
|
|
1929
|
+
interface ParamSchema {
|
|
1930
|
+
type: 'string' | 'number' | 'boolean' | 'file';
|
|
1931
|
+
enum?: (string | number)[];
|
|
1932
|
+
default?: string | number | boolean;
|
|
1933
|
+
min?: number;
|
|
1934
|
+
max?: number;
|
|
1935
|
+
step?: number;
|
|
1936
|
+
required?: boolean;
|
|
1937
|
+
label?: string;
|
|
1938
|
+
accept?: string;
|
|
1950
1939
|
}
|
|
1940
|
+
type ModelParamSchema = Record<string, ParamSchema>;
|
|
1951
1941
|
|
|
1952
1942
|
/**
|
|
1953
|
-
*
|
|
1943
|
+
* Runtime catalogs — the standard format served by the platform
|
|
1944
|
+
* `<vendor>/v1/catalog/<voices|avatars|…>` tasks (voices, avatars, effect
|
|
1945
|
+
* templates), plus the in-memory hydration registry that lets runtime-fetched
|
|
1946
|
+
* catalogs back the descriptor system.
|
|
1954
1947
|
*
|
|
1955
|
-
*
|
|
1956
|
-
*
|
|
1948
|
+
* The wire types mirror the shared backend contract (`@picsart/pa-genai-common`);
|
|
1949
|
+
* the SDK owns its own copy so it carries no backend dependency.
|
|
1957
1950
|
*/
|
|
1958
1951
|
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
/** A folder reference in Picsart Drive. */
|
|
1962
|
-
interface DriveFolder {
|
|
1963
|
-
name: string;
|
|
1964
|
-
uid: string;
|
|
1965
|
-
}
|
|
1966
|
-
/** Drive save result, attached to GenerateResult when drive is enabled. */
|
|
1967
|
-
interface DriveSaveResult {
|
|
1968
|
-
uid: string;
|
|
1969
|
-
folder: DriveFolder;
|
|
1970
|
-
}
|
|
1971
|
-
/**
|
|
1972
|
-
* The generation input parameters, serialized into the `aiSDKPayload` attribute.
|
|
1973
|
-
* Captures every value from the generation context — the named fields below are
|
|
1974
|
-
* common ones for convenience; the index signature carries any other input param.
|
|
1975
|
-
*/
|
|
1976
|
-
interface SdkPayload {
|
|
1977
|
-
prompt: string;
|
|
1978
|
-
aspectRatio?: string;
|
|
1979
|
-
duration?: number;
|
|
1980
|
-
resolution?: string;
|
|
1981
|
-
generateAudio?: boolean;
|
|
1982
|
-
imageUrls?: string[];
|
|
1983
|
-
videoUrls?: string[];
|
|
1984
|
-
audioUrls?: string[];
|
|
1985
|
-
startFrame?: string;
|
|
1986
|
-
endFrame?: string;
|
|
1952
|
+
interface CatalogPreview {
|
|
1953
|
+
imageUrl?: string;
|
|
1987
1954
|
videoUrl?: string;
|
|
1988
1955
|
audioUrl?: string;
|
|
1989
|
-
[key: string]: unknown;
|
|
1990
|
-
}
|
|
1991
|
-
type DriveFile = {
|
|
1992
|
-
uid: string;
|
|
1993
|
-
} & Record<string, unknown>;
|
|
1994
|
-
interface DriveAttributes {
|
|
1995
|
-
model: string;
|
|
1996
|
-
/** JSON-encoded SdkPayload (all generation input params). */
|
|
1997
|
-
aiSDKPayload: string;
|
|
1998
|
-
appId?: string;
|
|
1999
|
-
appType?: AppType;
|
|
2000
|
-
}
|
|
2001
|
-
/** A saved Seedance 2.5 draft — pass `draftTask` unchanged as the final's
|
|
2002
|
-
* `draftTask` param until `draftExpiresAt`. */
|
|
2003
|
-
interface DriveDraftInfo {
|
|
2004
|
-
draftTask?: SeedanceDraftTask;
|
|
2005
|
-
/** ISO timestamp after which the vendor no longer renders a final from it. */
|
|
2006
|
-
draftExpiresAt?: string;
|
|
2007
|
-
}
|
|
2008
|
-
interface GenerationFile extends DriveDraftInfo {
|
|
2009
|
-
appId?: string;
|
|
2010
|
-
appType?: AppType;
|
|
2011
|
-
model?: string;
|
|
2012
|
-
aiSDKPayload?: SdkPayload;
|
|
2013
|
-
userReaction?: UserReaction;
|
|
2014
|
-
}
|
|
2015
|
-
interface DriveMediaItem {
|
|
2016
|
-
uid: string;
|
|
2017
|
-
url: string;
|
|
2018
|
-
name: string;
|
|
2019
|
-
type: MediaTypeFilter;
|
|
2020
|
-
previewUrl?: string;
|
|
2021
|
-
timestamp: number;
|
|
2022
|
-
}
|
|
2023
|
-
interface DriveFileDetails extends DriveMediaItem, DriveDraftInfo {
|
|
2024
|
-
createdAt?: string;
|
|
2025
|
-
model?: string;
|
|
2026
|
-
prompt?: string;
|
|
2027
|
-
service?: string;
|
|
2028
|
-
subType?: string;
|
|
2029
|
-
duration?: string;
|
|
2030
|
-
aspectRatio?: string;
|
|
2031
|
-
resolution?: string;
|
|
2032
|
-
quality?: string;
|
|
2033
|
-
userReaction?: UserReaction;
|
|
2034
|
-
referenceImageUrls?: string[];
|
|
2035
|
-
referenceVideoUrl?: string;
|
|
2036
|
-
referenceAudioUrl?: string;
|
|
2037
|
-
}
|
|
2038
|
-
interface ListOptions {
|
|
2039
|
-
folder?: DriveFolder;
|
|
2040
|
-
type?: MediaTypeFilter;
|
|
2041
|
-
}
|
|
2042
|
-
interface SaveParams {
|
|
2043
|
-
url: string;
|
|
2044
|
-
name: string;
|
|
2045
|
-
resourceType: 'PHOTO' | 'VIDEO' | 'AUDIO';
|
|
2046
|
-
attributes?: Record<string, string>;
|
|
2047
|
-
previewUrl?: string;
|
|
2048
1956
|
}
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
path?: string;
|
|
2053
|
-
/** Folder UID — overrides path when provided. */
|
|
2054
|
-
id?: string;
|
|
2055
|
-
}
|
|
2056
|
-
/** Drive save options injected into the workflow payload as `options.drive`. */
|
|
2057
|
-
interface PayloadDriveOptions {
|
|
2058
|
-
/** Filename for the saved asset. */
|
|
1957
|
+
interface CatalogItem {
|
|
1958
|
+
/** Vendor-native id, sent back verbatim on generate as the bound param's value. */
|
|
1959
|
+
id: string;
|
|
2059
1960
|
name: string;
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
1961
|
+
description?: string;
|
|
1962
|
+
/** Facets for filtering: gender, language, age, accent, tone, … */
|
|
1963
|
+
tags: string[];
|
|
1964
|
+
preview?: CatalogPreview;
|
|
1965
|
+
/** Vendor extras, e.g. `defaultVoiceId` on HeyGen avatars. */
|
|
1966
|
+
meta?: Record<string, unknown>;
|
|
2064
1967
|
}
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
ensureFolder(subfolder?: string): Promise<DriveFolder | null>;
|
|
2073
|
-
/** List the immediate subfolders of the root folder. */
|
|
2074
|
-
folders(): Promise<DriveFolder[]>;
|
|
2075
|
-
/** List all folders recursively. */
|
|
2076
|
-
allFolders(): Promise<DriveFolder[]>;
|
|
2077
|
-
/** Find a folder by name. */
|
|
2078
|
-
findFolder(name: string): Promise<DriveFolder | null>;
|
|
2079
|
-
/** List media items in a folder. */
|
|
2080
|
-
list(options?: ListOptions): Promise<DriveMediaItem[]>;
|
|
2081
|
-
/** List media items in a folder with full generation metadata. */
|
|
2082
|
-
listDetailed(options?: ListOptions): Promise<DriveFileDetails[]>;
|
|
2083
|
-
/** Read a single generation's stored attributes. */
|
|
2084
|
-
getGeneration(fileUid: string): Promise<GenerationFile | null>;
|
|
2085
|
-
/** Save an asset to Drive. */
|
|
2086
|
-
save(params: SaveParams, folder?: DriveFolder): Promise<DriveSaveResult | null>;
|
|
2087
|
-
/** Build the save params for a generation result. */
|
|
2088
|
-
buildSaveParams(url: string, modelId: string, modelName: string, mode: string, prompt?: string): SaveParams;
|
|
2089
|
-
/** Set a like/dislike reaction on a file. */
|
|
2090
|
-
addReaction(fileUid: string, reaction: UserReaction): Promise<boolean>;
|
|
2091
|
-
/** Clear the reaction on a file. */
|
|
2092
|
-
removeReaction(fileUid: string): Promise<boolean>;
|
|
1968
|
+
interface CatalogQuery {
|
|
1969
|
+
/** Worker-side filter (e.g. the seed-audio model variant on bytedance). */
|
|
1970
|
+
modelId?: string;
|
|
1971
|
+
/** Opaque cursor from a previous page. */
|
|
1972
|
+
cursor?: string;
|
|
1973
|
+
/** Page size. Every catalog task accepts up to 100. */
|
|
1974
|
+
limit?: number;
|
|
2093
1975
|
}
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
declare function parseGeneration(file: DriveFile | Record<string, unknown>): GenerationFile;
|
|
2103
|
-
|
|
2104
|
-
/** Result of `ai.apis.run()` — the API result plus optional credit usage. */
|
|
2105
|
-
type ApiResponse<R = unknown> = WorkflowResponse<R>;
|
|
2106
|
-
/**
|
|
2107
|
-
* Options for `ai.apis.run()` — execution mode, polling, abort signal, progress callbacks.
|
|
2108
|
-
* Intentionally omits the lib's `remoteSettingName` (a no-op without remote settings),
|
|
2109
|
-
* `onPartialResult`, and `notificationConfig` — these aren't part of the SDK surface.
|
|
2110
|
-
*/
|
|
2111
|
-
type ApiRunOptions = Omit<ExecutionOptions, 'remoteSettingName' | 'onPartialResult' | 'notificationConfig'>;
|
|
2112
|
-
/** Registry of known API names → their params/result types (from @picsart/workflows-types). */
|
|
2113
|
-
type ApiSchemas = WorkflowTypes;
|
|
2114
|
-
/**
|
|
2115
|
-
* The `ai.apis` surface — direct, low-level access to the Picsart model APIs.
|
|
2116
|
-
* Known API names (keys of {@link ApiSchemas}) get typed params + result;
|
|
2117
|
-
* unknown names take an open payload and return an unknown result.
|
|
2118
|
-
*
|
|
2119
|
-
* Failures arrive as {@link ApiError}, the same as the generation surface.
|
|
2120
|
-
*/
|
|
2121
|
-
interface ApisClient {
|
|
2122
|
-
/** Run an API by name (mirrors WorkflowsClient.run()). */
|
|
2123
|
-
run<W extends string = string>(api: W, payload: W extends keyof ApiSchemas ? ApiSchemas[W]['params'] : Record<string, unknown>, options?: ApiRunOptions): Promise<ApiResponse<W extends keyof ApiSchemas ? ApiSchemas[W]['result'] : unknown>>;
|
|
1976
|
+
interface CatalogResult {
|
|
1977
|
+
items: CatalogItem[];
|
|
1978
|
+
/** Crawl date or curation stamp identifying the snapshot. */
|
|
1979
|
+
version: string;
|
|
1980
|
+
/** How long the caller may cache this response. */
|
|
1981
|
+
ttlSeconds: number;
|
|
1982
|
+
/** `null` when the list is complete. */
|
|
1983
|
+
nextCursor: string | null;
|
|
2124
1984
|
}
|
|
2125
|
-
|
|
2126
|
-
interface
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
max?: number;
|
|
2132
|
-
step?: number;
|
|
2133
|
-
required?: boolean;
|
|
2134
|
-
label?: string;
|
|
2135
|
-
accept?: string;
|
|
1985
|
+
/** Binds a param's options to a platform catalog task. */
|
|
1986
|
+
interface CatalogSource {
|
|
1987
|
+
/** Catalog workflow name, e.g. `heygen/v1/catalog/voices`. */
|
|
1988
|
+
workflow: string;
|
|
1989
|
+
/** Worker-side filter passed on fetch. */
|
|
1990
|
+
modelId?: string;
|
|
2136
1991
|
}
|
|
2137
|
-
|
|
1992
|
+
declare function toVoiceOption(item: CatalogItem, provider: Provider): VoiceOption;
|
|
1993
|
+
declare function toAvatarOption(item: CatalogItem, provider: Provider): AvatarOption;
|
|
2138
1994
|
|
|
2139
1995
|
/**
|
|
2140
1996
|
* Param Descriptor types — the new, open-ended parameter definition system.
|
|
@@ -2653,6 +2509,12 @@ interface ModelDefinition {
|
|
|
2653
2509
|
/** I2V/edit payload builder when different from buildPayload. */
|
|
2654
2510
|
buildEditPayload?: PayloadBuilder;
|
|
2655
2511
|
outputSchema?: RuntimeSchema<unknown>;
|
|
2512
|
+
/**
|
|
2513
|
+
* File extension the model produces when it has no output-format param
|
|
2514
|
+
* (e.g. 'jpg'). Used to name a Drive save made before the job runs; without
|
|
2515
|
+
* it the mode default applies (png / mp4 / mp3).
|
|
2516
|
+
*/
|
|
2517
|
+
outputExtension?: string;
|
|
2656
2518
|
estimatedTime?: number | Record<string, number>;
|
|
2657
2519
|
editEstimatedTime?: number | Record<string, number>;
|
|
2658
2520
|
testTimeout?: number;
|
|
@@ -2669,57 +2531,227 @@ interface ModelDefinition {
|
|
|
2669
2531
|
}
|
|
2670
2532
|
|
|
2671
2533
|
/**
|
|
2672
|
-
*
|
|
2673
|
-
*
|
|
2674
|
-
|
|
2675
|
-
|
|
2534
|
+
* Per-item vendor metadata promoted from the response. Every key is
|
|
2535
|
+
* best-effort: present when the vendor reports it, absent otherwise.
|
|
2536
|
+
*/
|
|
2537
|
+
interface GenerateResultItemMetadata {
|
|
2538
|
+
/** Explore image id (recraft explore models) — pass back as `sourceImageId`
|
|
2539
|
+
* to iterate on this image. */
|
|
2540
|
+
exploreImageId?: string;
|
|
2541
|
+
/** Voice preview id (ElevenLabs voice design/remix) — pass to the vendor's
|
|
2542
|
+
* create-voice-from-preview step to persist the voice. */
|
|
2543
|
+
generatedVoiceId?: string;
|
|
2544
|
+
/** URL of the generated video's last frame, when the model was asked for it
|
|
2545
|
+
* (`returnLastFrame`, seedance) — the seed for frame-chaining flows. */
|
|
2546
|
+
lastFrameUrl?: string;
|
|
2547
|
+
/** The draft a Seedance 2.5 Draft generation produced — pass it back
|
|
2548
|
+
* unchanged as `draftTask` to the matching `-draft-final` model to render
|
|
2549
|
+
* the final 1080p video (valid 7 days). Wire field names on purpose: the
|
|
2550
|
+
* worker signs it, so any change is rejected. */
|
|
2551
|
+
draftTask?: SeedanceDraftTask;
|
|
2552
|
+
}
|
|
2553
|
+
/** A Seedance 2.5 draft reference, as the worker issues it. */
|
|
2554
|
+
interface SeedanceDraftTask {
|
|
2555
|
+
id: string;
|
|
2556
|
+
video_input: boolean;
|
|
2557
|
+
signature: string;
|
|
2558
|
+
}
|
|
2559
|
+
|
|
2560
|
+
/**
|
|
2561
|
+
* Drive client — manages folders and file saving in Picsart Drive.
|
|
2676
2562
|
*
|
|
2677
|
-
*
|
|
2678
|
-
*
|
|
2563
|
+
* Uses the same authenticated fetch as the generation client.
|
|
2564
|
+
* Root folder is auto-created on first use and cached.
|
|
2679
2565
|
*/
|
|
2680
2566
|
|
|
2681
|
-
|
|
2682
|
-
|
|
2567
|
+
type MediaTypeFilter = 'image' | 'video' | 'audio';
|
|
2568
|
+
type UserReaction = 'like' | 'dislike';
|
|
2569
|
+
/** A folder reference in Picsart Drive. */
|
|
2570
|
+
interface DriveFolder {
|
|
2571
|
+
name: string;
|
|
2572
|
+
uid: string;
|
|
2573
|
+
}
|
|
2574
|
+
/** Drive save result, attached to GenerateResult when drive is enabled. */
|
|
2575
|
+
interface DriveSaveResult {
|
|
2576
|
+
uid: string;
|
|
2577
|
+
folder: DriveFolder;
|
|
2578
|
+
}
|
|
2579
|
+
/**
|
|
2580
|
+
* The generation input parameters, serialized into the `aiSDKPayload` attribute.
|
|
2581
|
+
* Captures every value from the generation context — the named fields below are
|
|
2582
|
+
* common ones for convenience; the index signature carries any other input param.
|
|
2583
|
+
*/
|
|
2584
|
+
interface SdkPayload {
|
|
2585
|
+
prompt: string;
|
|
2586
|
+
aspectRatio?: string;
|
|
2587
|
+
duration?: number;
|
|
2588
|
+
resolution?: string;
|
|
2589
|
+
generateAudio?: boolean;
|
|
2590
|
+
imageUrls?: string[];
|
|
2591
|
+
videoUrls?: string[];
|
|
2592
|
+
audioUrls?: string[];
|
|
2593
|
+
startFrame?: string;
|
|
2594
|
+
endFrame?: string;
|
|
2683
2595
|
videoUrl?: string;
|
|
2684
2596
|
audioUrl?: string;
|
|
2597
|
+
[key: string]: unknown;
|
|
2685
2598
|
}
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2599
|
+
type DriveFile = {
|
|
2600
|
+
uid: string;
|
|
2601
|
+
} & Record<string, unknown>;
|
|
2602
|
+
interface DriveAttributes {
|
|
2603
|
+
model: string;
|
|
2604
|
+
/** JSON-encoded SdkPayload (all generation input params). */
|
|
2605
|
+
aiSDKPayload: string;
|
|
2606
|
+
appId?: string;
|
|
2607
|
+
appType?: AppType;
|
|
2608
|
+
}
|
|
2609
|
+
/** A saved Seedance 2.5 draft — pass `draftTask` unchanged as the final's
|
|
2610
|
+
* `draftTask` param until `draftExpiresAt`. */
|
|
2611
|
+
interface DriveDraftInfo {
|
|
2612
|
+
draftTask?: SeedanceDraftTask;
|
|
2613
|
+
/** ISO timestamp after which the vendor no longer renders a final from it. */
|
|
2614
|
+
draftExpiresAt?: string;
|
|
2615
|
+
}
|
|
2616
|
+
interface GenerationFile extends DriveDraftInfo {
|
|
2617
|
+
appId?: string;
|
|
2618
|
+
appType?: AppType;
|
|
2619
|
+
model?: string;
|
|
2620
|
+
aiSDKPayload?: SdkPayload;
|
|
2621
|
+
userReaction?: UserReaction;
|
|
2622
|
+
}
|
|
2623
|
+
interface DriveMediaItem {
|
|
2624
|
+
uid: string;
|
|
2625
|
+
url: string;
|
|
2689
2626
|
name: string;
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
preview?: CatalogPreview;
|
|
2694
|
-
/** Vendor extras, e.g. `defaultVoiceId` on HeyGen avatars. */
|
|
2695
|
-
meta?: Record<string, unknown>;
|
|
2627
|
+
type: MediaTypeFilter;
|
|
2628
|
+
previewUrl?: string;
|
|
2629
|
+
timestamp: number;
|
|
2696
2630
|
}
|
|
2697
|
-
interface
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2631
|
+
interface DriveFileDetails extends DriveMediaItem, DriveDraftInfo {
|
|
2632
|
+
createdAt?: string;
|
|
2633
|
+
model?: string;
|
|
2634
|
+
prompt?: string;
|
|
2635
|
+
service?: string;
|
|
2636
|
+
subType?: string;
|
|
2637
|
+
duration?: string;
|
|
2638
|
+
aspectRatio?: string;
|
|
2639
|
+
resolution?: string;
|
|
2640
|
+
quality?: string;
|
|
2641
|
+
userReaction?: UserReaction;
|
|
2642
|
+
referenceImageUrls?: string[];
|
|
2643
|
+
referenceVideoUrl?: string;
|
|
2644
|
+
referenceAudioUrl?: string;
|
|
2704
2645
|
}
|
|
2705
|
-
interface
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
version: string;
|
|
2709
|
-
/** How long the caller may cache this response. */
|
|
2710
|
-
ttlSeconds: number;
|
|
2711
|
-
/** `null` when the list is complete. */
|
|
2712
|
-
nextCursor: string | null;
|
|
2646
|
+
interface ListOptions {
|
|
2647
|
+
folder?: DriveFolder;
|
|
2648
|
+
type?: MediaTypeFilter;
|
|
2713
2649
|
}
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2650
|
+
interface SaveParams {
|
|
2651
|
+
url: string;
|
|
2652
|
+
name: string;
|
|
2653
|
+
resourceType: 'PHOTO' | 'VIDEO' | 'AUDIO';
|
|
2654
|
+
attributes?: Record<string, string>;
|
|
2655
|
+
previewUrl?: string;
|
|
2656
|
+
}
|
|
2657
|
+
/** Target folder for backend Drive save. */
|
|
2658
|
+
interface PayloadDriveFolderOptions {
|
|
2659
|
+
/** Folder path — backend resolves it (e.g. 'AI Playground' or 'AI Playground/My Board'). */
|
|
2660
|
+
path?: string;
|
|
2661
|
+
/** Folder UID — overrides path when provided. */
|
|
2662
|
+
id?: string;
|
|
2663
|
+
}
|
|
2664
|
+
/** Drive save options injected into the workflow payload as `options.drive`. */
|
|
2665
|
+
interface PayloadDriveOptions {
|
|
2666
|
+
/** Filename for the saved asset. */
|
|
2667
|
+
name: string;
|
|
2668
|
+
/** Generation attributes attached to the file (SDK-assembled, fixed shape). */
|
|
2669
|
+
attributes?: DriveAttributes;
|
|
2670
|
+
/** Target folder in Picsart Drive. */
|
|
2671
|
+
folder?: PayloadDriveFolderOptions;
|
|
2672
|
+
}
|
|
2673
|
+
/**
|
|
2674
|
+
* Drive operations surface — returned by {@link createDriveClient} and exposed
|
|
2675
|
+
* as `ai.drive` when Drive is configured. Manages folders, listing, saving, and
|
|
2676
|
+
* reactions in Picsart Drive.
|
|
2677
|
+
*/
|
|
2678
|
+
interface DriveClient {
|
|
2679
|
+
/** Ensure a folder exists (creating it if needed) and return it. */
|
|
2680
|
+
ensureFolder(subfolder?: string): Promise<DriveFolder | null>;
|
|
2681
|
+
/** List the immediate subfolders of the root folder. */
|
|
2682
|
+
folders(): Promise<DriveFolder[]>;
|
|
2683
|
+
/** List all folders recursively. */
|
|
2684
|
+
allFolders(): Promise<DriveFolder[]>;
|
|
2685
|
+
/** Find a folder by name. */
|
|
2686
|
+
findFolder(name: string): Promise<DriveFolder | null>;
|
|
2687
|
+
/** List media items in a folder. */
|
|
2688
|
+
list(options?: ListOptions): Promise<DriveMediaItem[]>;
|
|
2689
|
+
/** List media items in a folder with full generation metadata. */
|
|
2690
|
+
listDetailed(options?: ListOptions): Promise<DriveFileDetails[]>;
|
|
2691
|
+
/** Read a single generation's stored attributes. */
|
|
2692
|
+
getGeneration(fileUid: string): Promise<GenerationFile | null>;
|
|
2693
|
+
/** Save an asset to Drive. */
|
|
2694
|
+
save(params: SaveParams, folder?: DriveFolder): Promise<DriveSaveResult | null>;
|
|
2695
|
+
/** Build the save params for a generation result. */
|
|
2696
|
+
buildSaveParams(url: string, modelId: string, modelName: string, mode: string, prompt?: string): SaveParams;
|
|
2697
|
+
/** Set a like/dislike reaction on a file. */
|
|
2698
|
+
addReaction(fileUid: string, reaction: UserReaction): Promise<boolean>;
|
|
2699
|
+
/** Clear the reaction on a file. */
|
|
2700
|
+
removeReaction(fileUid: string): Promise<boolean>;
|
|
2701
|
+
}
|
|
2702
|
+
declare function inferResourceType(mode: string): 'PHOTO' | 'VIDEO' | 'AUDIO';
|
|
2703
|
+
/** What is known about the file being named. Every field is optional; the
|
|
2704
|
+
* most reliable one present wins (see `resolveExtension`). */
|
|
2705
|
+
interface FilenameHints {
|
|
2706
|
+
/** MIME type of the produced file (e.g. `image/jpeg`). */
|
|
2707
|
+
mimeType?: string;
|
|
2708
|
+
/** URL of the produced file; its path extension is used when present. */
|
|
2709
|
+
url?: string;
|
|
2710
|
+
/** Output format requested of (or declared by) the model, e.g. `jpeg`, `mov`, `ogg_opus`. */
|
|
2711
|
+
format?: string;
|
|
2712
|
+
}
|
|
2713
|
+
/**
|
|
2714
|
+
* Pick a file extension for a generation. Most to least reliable: the result's
|
|
2715
|
+
* MIME type, the result URL's path extension, the requested output format, then
|
|
2716
|
+
* the mode default (png / mp4 / mp3).
|
|
2717
|
+
*/
|
|
2718
|
+
declare function resolveExtension(mode: string, hints?: FilenameHints): string;
|
|
2719
|
+
/**
|
|
2720
|
+
* The output format a generation will produce, known before the job runs:
|
|
2721
|
+
* an explicit format param, else that param's catalog default, else the
|
|
2722
|
+
* model's declared `outputExtension`. Undefined when nothing is known.
|
|
2723
|
+
*/
|
|
2724
|
+
declare function expectedOutputFormat(model: Pick<ModelDefinition, 'paramConfig' | 'outputExtension'>, params: Record<string, unknown>): string | undefined;
|
|
2725
|
+
declare function buildFilename(prompt: string | undefined, mode: string, hints?: FilenameHints): string;
|
|
2726
|
+
declare function buildGenerationAttributes(input: {
|
|
2727
|
+
modelId: string;
|
|
2728
|
+
params: Record<string, unknown>;
|
|
2729
|
+
/** TODO(backend-autosave): temporary — remove once the backend stamps appId/appType. */
|
|
2730
|
+
app?: AppIdentity;
|
|
2731
|
+
}): DriveAttributes;
|
|
2732
|
+
declare function parseGeneration(file: DriveFile | Record<string, unknown>): GenerationFile;
|
|
2733
|
+
|
|
2734
|
+
/** Result of `ai.apis.run()` — the API result plus optional credit usage. */
|
|
2735
|
+
type ApiResponse<R = unknown> = WorkflowResponse<R>;
|
|
2736
|
+
/**
|
|
2737
|
+
* Options for `ai.apis.run()` — execution mode, polling, abort signal, progress callbacks.
|
|
2738
|
+
* Intentionally omits the lib's `remoteSettingName` (a no-op without remote settings),
|
|
2739
|
+
* `onPartialResult`, and `notificationConfig` — these aren't part of the SDK surface.
|
|
2740
|
+
*/
|
|
2741
|
+
type ApiRunOptions = Omit<ExecutionOptions, 'remoteSettingName' | 'onPartialResult' | 'notificationConfig'>;
|
|
2742
|
+
/** Registry of known API names → their params/result types (from @picsart/workflows-types). */
|
|
2743
|
+
type ApiSchemas = WorkflowTypes;
|
|
2744
|
+
/**
|
|
2745
|
+
* The `ai.apis` surface — direct, low-level access to the Picsart model APIs.
|
|
2746
|
+
* Known API names (keys of {@link ApiSchemas}) get typed params + result;
|
|
2747
|
+
* unknown names take an open payload and return an unknown result.
|
|
2748
|
+
*
|
|
2749
|
+
* Failures arrive as {@link ApiError}, the same as the generation surface.
|
|
2750
|
+
*/
|
|
2751
|
+
interface ApisClient {
|
|
2752
|
+
/** Run an API by name (mirrors WorkflowsClient.run()). */
|
|
2753
|
+
run<W extends string = string>(api: W, payload: W extends keyof ApiSchemas ? ApiSchemas[W]['params'] : Record<string, unknown>, options?: ApiRunOptions): Promise<ApiResponse<W extends keyof ApiSchemas ? ApiSchemas[W]['result'] : unknown>>;
|
|
2720
2754
|
}
|
|
2721
|
-
declare function toVoiceOption(item: CatalogItem, provider: Provider): VoiceOption;
|
|
2722
|
-
declare function toAvatarOption(item: CatalogItem, provider: Provider): AvatarOption;
|
|
2723
2755
|
|
|
2724
2756
|
/**
|
|
2725
2757
|
* ai.catalogs — runtime access to the platform catalog tasks
|
|
@@ -3489,4 +3521,4 @@ declare const getModel: (id: string) => ModelDefinition | undefined;
|
|
|
3489
3521
|
*/
|
|
3490
3522
|
declare const findModel: (ref: string) => ModelDefinition | undefined;
|
|
3491
3523
|
|
|
3492
|
-
export { ALL_MODELS, type AiClient, ApiError, type ApiErrorCode, type ApiErrorInit, type ApiResponse, type ApiRunOptions, type ApiSchemas, type ApisClient, type AppIdentity, type AppType, type AuthenticatedFetch, type AvatarOption, type BooleanDescriptor, type BooleanEntry, type CatalogDescriptor, type CatalogEntry, type CatalogItem, type CatalogPage, type CatalogPageOptions, type CatalogPreview, type CatalogQuery, type CatalogResult, type CatalogSource, type CatalogsClient, type CatalogsOptions, type ClientConfig, type CreditRange, type CreditRangeContext, type CreditTier, type CreditUsage, DEFAULT_VISIBLE_RELEASES, type DeepLinkResult, type DriveAttributes, type DriveClient, type DriveConfig, type DriveDraftInfo, type DriveFile, type DriveFileDetails, type DriveFolder, type DriveMediaItem, type DriveSaveResult, type EntryMeta, type EnumDescriptor, type EnumEntry, type EnumOption, type FileDescriptor, type FileEntry, type FlatParamEntry, type GenerateOptions, type GenerateResult, type GenerateResultItem, type GenerateResultItemMetadata, type GenerateTextResult, type GenerationContext, type GenerationEvent, GenerationEventType, type GenerationFile, type GenerationMode, type GenerationOptions, type GenerationProgress, type ListOptions, type MediaModelId, type MediaTypeFilter, Model, type ModelDefinition, type ModelDescriptor, type ModelFilter, type ModelInput, type ModelInputById, type ModelMeta, type ModelParams, type ModelParamsAccessor, Models, type ObjectDescriptor, type ObjectEntry, type ParamDescriptor, type ParamEntry, type ParamOption, type PayloadDriveFolderOptions, type PayloadDriveOptions, type PayloadInputsTransformationOptions, type PricingOptions, type ProviderInfo, type RangeDescriptor, type RangeEntry, type ReleaseTag, type SaveParams, type SdkPayload, type SdkTransport, type SeedanceDraftTask, type TextDescriptor, type TextEntry, type TextModelId, type TextModelInputById, type ToolUsage, type TransportPollOptions, type TransportResult, type TypedModelId, type UserReaction, type ValidationResult, type VoiceOption, type WorkflowJobHandle, type WorkflowSubmitRequest, buildFilename, buildGenerationAttributes, catalog, createClient, decodeDeepLinkPayload, encodeDeepLinkPayload, findModel, getModel, getModelsByMode, getVoiceById, inferResourceType, isVisibleForReleases, parseGeneration, releaseOf, toAvatarOption, toVoiceOption };
|
|
3524
|
+
export { ALL_MODELS, type AiClient, ApiError, type ApiErrorCode, type ApiErrorInit, type ApiResponse, type ApiRunOptions, type ApiSchemas, type ApisClient, type AppIdentity, type AppType, type AuthenticatedFetch, type AvatarOption, type BooleanDescriptor, type BooleanEntry, type CatalogDescriptor, type CatalogEntry, type CatalogItem, type CatalogPage, type CatalogPageOptions, type CatalogPreview, type CatalogQuery, type CatalogResult, type CatalogSource, type CatalogsClient, type CatalogsOptions, type ClientConfig, type CreditRange, type CreditRangeContext, type CreditTier, type CreditUsage, DEFAULT_VISIBLE_RELEASES, type DeepLinkResult, type DriveAttributes, type DriveClient, type DriveConfig, type DriveDraftInfo, type DriveFile, type DriveFileDetails, type DriveFolder, type DriveMediaItem, type DriveSaveResult, type EntryMeta, type EnumDescriptor, type EnumEntry, type EnumOption, type FileDescriptor, type FileEntry, type FlatParamEntry, type GenerateOptions, type GenerateResult, type GenerateResultItem, type GenerateResultItemMetadata, type GenerateTextResult, type GenerationContext, type GenerationEvent, GenerationEventType, type GenerationFile, type GenerationMode, type GenerationOptions, type GenerationProgress, type ListOptions, type MediaModelId, type MediaTypeFilter, Model, type ModelDefinition, type ModelDescriptor, type ModelFilter, type ModelInput, type ModelInputById, type ModelMeta, type ModelParams, type ModelParamsAccessor, Models, type ObjectDescriptor, type ObjectEntry, type ParamDescriptor, type ParamEntry, type ParamOption, type PayloadDriveFolderOptions, type PayloadDriveOptions, type PayloadInputsTransformationOptions, type PricingOptions, type ProviderInfo, type RangeDescriptor, type RangeEntry, type ReleaseTag, type SaveParams, type SdkPayload, type SdkTransport, type SeedanceDraftTask, type TextDescriptor, type TextEntry, type TextModelId, type TextModelInputById, type ToolUsage, type TransportPollOptions, type TransportResult, type TypedModelId, type UserReaction, type ValidationResult, type VoiceOption, type WorkflowJobHandle, type WorkflowSubmitRequest, buildFilename, buildGenerationAttributes, catalog, createClient, decodeDeepLinkPayload, encodeDeepLinkPayload, expectedOutputFormat, findModel, getModel, getModelsByMode, getVoiceById, inferResourceType, isVisibleForReleases, parseGeneration, releaseOf, resolveExtension, toAvatarOption, toVoiceOption };
|
package/index.js
CHANGED
|
@@ -1119,6 +1119,7 @@ function defineModels(provider, configs) {
|
|
|
1119
1119
|
if (c.editEstimatedTime !== void 0) model.editEstimatedTime = c.editEstimatedTime;
|
|
1120
1120
|
if (c.testTimeout !== void 0) model.testTimeout = c.testTimeout;
|
|
1121
1121
|
if (c.pollOptions !== void 0) model.pollOptions = c.pollOptions;
|
|
1122
|
+
if (c.outputExtension !== void 0) model.outputExtension = c.outputExtension;
|
|
1122
1123
|
if (c.badge !== void 0) model.badge = c.badge;
|
|
1123
1124
|
if (c.addedAt !== void 0) model.addedAt = c.addedAt;
|
|
1124
1125
|
if (c.deprecated !== void 0) model.deprecated = c.deprecated;
|
|
@@ -6377,6 +6378,7 @@ var buildGemini3ProImagePayload = (ctx) => ({
|
|
|
6377
6378
|
prompt: ctx.prompt,
|
|
6378
6379
|
model: "gemini-3-pro-image-preview",
|
|
6379
6380
|
count: ctx.count ?? 1,
|
|
6381
|
+
...ctx.seed != null ? { seed: ctx.seed } : {},
|
|
6380
6382
|
...ctx.imageUrls?.length ? { imageUrls: ctx.imageUrls } : {},
|
|
6381
6383
|
aspectRatio: ctx.aspectRatio ?? "1:1",
|
|
6382
6384
|
imageSize: ctx.resolution ?? "2K",
|
|
@@ -6386,6 +6388,7 @@ var buildGeminiFlashImagePayload = (ctx) => ({
|
|
|
6386
6388
|
prompt: ctx.prompt,
|
|
6387
6389
|
model: "gemini-2.5-flash-image",
|
|
6388
6390
|
count: ctx.count ?? 1,
|
|
6391
|
+
...ctx.seed != null ? { seed: ctx.seed } : {},
|
|
6389
6392
|
...ctx.imageUrls?.length ? { imageUrls: ctx.imageUrls } : {},
|
|
6390
6393
|
aspectRatio: ctx.aspectRatio ?? "16:9"
|
|
6391
6394
|
});
|
|
@@ -6393,6 +6396,7 @@ var buildGemini31FlashImagePayload = (ctx) => ({
|
|
|
6393
6396
|
prompt: ctx.prompt,
|
|
6394
6397
|
model: "gemini-3.1-flash-image-preview",
|
|
6395
6398
|
count: ctx.count ?? 1,
|
|
6399
|
+
...ctx.seed != null ? { seed: ctx.seed } : {},
|
|
6396
6400
|
...ctx.imageUrls?.length ? { imageUrls: ctx.imageUrls } : {},
|
|
6397
6401
|
aspectRatio: ctx.aspectRatio ?? "1:1",
|
|
6398
6402
|
imageSize: ctx.resolution ?? "1K",
|
|
@@ -6402,6 +6406,7 @@ var buildGemini31FlashLiteImagePayload = (ctx) => ({
|
|
|
6402
6406
|
prompt: ctx.prompt,
|
|
6403
6407
|
model: "gemini-3.1-flash-lite-image",
|
|
6404
6408
|
count: ctx.count ?? 1,
|
|
6409
|
+
...ctx.seed != null ? { seed: ctx.seed } : {},
|
|
6405
6410
|
...ctx.imageUrls?.length ? { imageUrls: ctx.imageUrls } : {},
|
|
6406
6411
|
aspectRatio: ctx.aspectRatio ?? "1:1",
|
|
6407
6412
|
imageSize: ctx.resolution ?? "1K",
|
|
@@ -6465,6 +6470,7 @@ var { MODELS: MODELS22 } = defineModels("google", [
|
|
|
6465
6470
|
...params.aspectRatio(["1:1", "16:9", "9:16", "3:4", "4:3", "3:2", "2:3", "4:5", "5:4", "4:1", "1:4", "8:1", "1:8", "21:9", "auto"], "1:1"),
|
|
6466
6471
|
...params.resolution(["0.5K", "1K", "2K", "4K"], "1K"),
|
|
6467
6472
|
...params.count(),
|
|
6473
|
+
...params.seed(),
|
|
6468
6474
|
...thinkingLevelParam,
|
|
6469
6475
|
...params.imageInput(14, "Source Images")
|
|
6470
6476
|
}
|
|
@@ -6487,6 +6493,7 @@ var { MODELS: MODELS22 } = defineModels("google", [
|
|
|
6487
6493
|
...params.prompt(),
|
|
6488
6494
|
...params.aspectRatio(["1:1", "16:9", "9:16", "3:4", "4:3", "3:2", "2:3", "4:5", "5:4", "4:1", "1:4", "8:1", "1:8", "21:9", "auto"], "1:1"),
|
|
6489
6495
|
...params.count(),
|
|
6496
|
+
...params.seed(),
|
|
6490
6497
|
...thinkingLevelParam,
|
|
6491
6498
|
...params.imageInput(14, "Source Images")
|
|
6492
6499
|
}
|
|
@@ -6510,6 +6517,7 @@ var { MODELS: MODELS22 } = defineModels("google", [
|
|
|
6510
6517
|
...params.aspectRatio([...GEMINI_AR_WIDE], "1:1"),
|
|
6511
6518
|
...params.resolution(["1K", "2K", "4K"], "2K"),
|
|
6512
6519
|
...params.count(),
|
|
6520
|
+
...params.seed(),
|
|
6513
6521
|
...thinkingBudgetParam,
|
|
6514
6522
|
...params.imageInput(14, "Source Images")
|
|
6515
6523
|
}
|
|
@@ -6532,6 +6540,7 @@ var { MODELS: MODELS22 } = defineModels("google", [
|
|
|
6532
6540
|
...params.prompt(),
|
|
6533
6541
|
...params.aspectRatio([...GEMINI_AR_WIDE], "16:9"),
|
|
6534
6542
|
...params.count(),
|
|
6543
|
+
...params.seed(),
|
|
6535
6544
|
...params.imageInput(14, "Source Images")
|
|
6536
6545
|
}
|
|
6537
6546
|
},
|
|
@@ -8851,6 +8860,8 @@ var { MODELS: MODELS30 } = defineModels("picsart", [
|
|
|
8851
8860
|
workflow: "pcp/v1/sana-sprint",
|
|
8852
8861
|
syncExecute: true,
|
|
8853
8862
|
buildPayload: buildPcpSanaSprintPayload,
|
|
8863
|
+
// The worker returns JPEG and exposes no format param.
|
|
8864
|
+
outputExtension: "jpg",
|
|
8854
8865
|
estimatedTime: 3,
|
|
8855
8866
|
mode: "image",
|
|
8856
8867
|
inputType: "t2i",
|
|
@@ -11732,9 +11743,90 @@ function inferResourceType(mode) {
|
|
|
11732
11743
|
if (mode === "audio") return "AUDIO";
|
|
11733
11744
|
return "PHOTO";
|
|
11734
11745
|
}
|
|
11735
|
-
|
|
11746
|
+
var MIME_EXTENSIONS = {
|
|
11747
|
+
"image/jpeg": "jpg",
|
|
11748
|
+
"image/jpg": "jpg",
|
|
11749
|
+
"image/pjpeg": "jpg",
|
|
11750
|
+
"image/png": "png",
|
|
11751
|
+
"image/webp": "webp",
|
|
11752
|
+
"image/gif": "gif",
|
|
11753
|
+
"image/avif": "avif",
|
|
11754
|
+
"image/heic": "heic",
|
|
11755
|
+
"image/heif": "heif",
|
|
11756
|
+
"image/bmp": "bmp",
|
|
11757
|
+
"image/tiff": "tiff",
|
|
11758
|
+
"image/svg+xml": "svg",
|
|
11759
|
+
"video/mp4": "mp4",
|
|
11760
|
+
"video/quicktime": "mov",
|
|
11761
|
+
"video/webm": "webm",
|
|
11762
|
+
"video/x-matroska": "mkv",
|
|
11763
|
+
"video/x-msvideo": "avi",
|
|
11764
|
+
"video/x-m4v": "m4v",
|
|
11765
|
+
"audio/mpeg": "mp3",
|
|
11766
|
+
"audio/mp3": "mp3",
|
|
11767
|
+
"audio/wav": "wav",
|
|
11768
|
+
"audio/x-wav": "wav",
|
|
11769
|
+
"audio/wave": "wav",
|
|
11770
|
+
"audio/vnd.wave": "wav",
|
|
11771
|
+
"audio/ogg": "ogg",
|
|
11772
|
+
"audio/opus": "ogg",
|
|
11773
|
+
"audio/aac": "aac",
|
|
11774
|
+
"audio/flac": "flac",
|
|
11775
|
+
"audio/x-flac": "flac",
|
|
11776
|
+
"audio/mp4": "m4a",
|
|
11777
|
+
"audio/x-m4a": "m4a",
|
|
11778
|
+
"audio/webm": "webm"
|
|
11779
|
+
};
|
|
11780
|
+
var EXTENSION_ALIASES = {
|
|
11781
|
+
jpeg: "jpg",
|
|
11782
|
+
jpe: "jpg",
|
|
11783
|
+
tif: "tiff",
|
|
11784
|
+
mpeg4: "mp4",
|
|
11785
|
+
quicktime: "mov"
|
|
11786
|
+
};
|
|
11787
|
+
function normalizeExtension(raw) {
|
|
11788
|
+
if (!raw) return void 0;
|
|
11789
|
+
const ext = raw.trim().toLowerCase().replace(/^\./, "").split("_")[0];
|
|
11790
|
+
if (!/^[a-z0-9]{2,5}$/.test(ext)) return void 0;
|
|
11791
|
+
return EXTENSION_ALIASES[ext] ?? ext;
|
|
11792
|
+
}
|
|
11793
|
+
function extensionFromMime(mimeType) {
|
|
11794
|
+
if (!mimeType) return void 0;
|
|
11795
|
+
const base2 = mimeType.split(";")[0].trim().toLowerCase();
|
|
11796
|
+
return MIME_EXTENSIONS[base2];
|
|
11797
|
+
}
|
|
11798
|
+
function extensionFromUrl(url) {
|
|
11799
|
+
if (!url) return void 0;
|
|
11800
|
+
let path;
|
|
11801
|
+
try {
|
|
11802
|
+
path = new URL(url).pathname;
|
|
11803
|
+
} catch {
|
|
11804
|
+
path = url.split(/[?#]/)[0];
|
|
11805
|
+
}
|
|
11806
|
+
const match = /\.([A-Za-z0-9]{2,5})$/.exec(path.split("/").pop() ?? "");
|
|
11807
|
+
return normalizeExtension(match?.[1]);
|
|
11808
|
+
}
|
|
11809
|
+
function defaultExtension(mode) {
|
|
11810
|
+
return mode === "video" ? "mp4" : mode === "audio" ? "mp3" : "png";
|
|
11811
|
+
}
|
|
11812
|
+
function resolveExtension(mode, hints = {}) {
|
|
11813
|
+
return extensionFromMime(hints.mimeType) ?? extensionFromUrl(hints.url) ?? normalizeExtension(hints.format) ?? defaultExtension(mode);
|
|
11814
|
+
}
|
|
11815
|
+
var FORMAT_PARAM_KEYS = ["outputFormat", "output_format", "format"];
|
|
11816
|
+
function expectedOutputFormat(model, params2) {
|
|
11817
|
+
for (const key of FORMAT_PARAM_KEYS) {
|
|
11818
|
+
const value = params2[key];
|
|
11819
|
+
if (typeof value === "string" && value) return value;
|
|
11820
|
+
}
|
|
11821
|
+
for (const key of FORMAT_PARAM_KEYS) {
|
|
11822
|
+
const fallback = model.paramConfig?.[key]?.descriptor?.default;
|
|
11823
|
+
if (typeof fallback === "string" && fallback) return fallback;
|
|
11824
|
+
}
|
|
11825
|
+
return model.outputExtension;
|
|
11826
|
+
}
|
|
11827
|
+
function buildFilename(prompt, mode, hints) {
|
|
11736
11828
|
const shortId = String(Date.now()).slice(-6);
|
|
11737
|
-
const ext = mode
|
|
11829
|
+
const ext = resolveExtension(mode, hints);
|
|
11738
11830
|
if (!prompt) return `ai-generation-${shortId}.${ext}`;
|
|
11739
11831
|
const slug = prompt.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 50);
|
|
11740
11832
|
return `${slug}-${shortId}.${ext}`;
|
|
@@ -12181,7 +12273,7 @@ function createDriveClient(f, apiUrl, rootFolderName) {
|
|
|
12181
12273
|
buildSaveParams(url, modelId, modelName, mode, prompt) {
|
|
12182
12274
|
return {
|
|
12183
12275
|
url,
|
|
12184
|
-
name: buildFilename(prompt, mode),
|
|
12276
|
+
name: buildFilename(prompt, mode, { url }),
|
|
12185
12277
|
resourceType: inferResourceType(mode),
|
|
12186
12278
|
attributes: {
|
|
12187
12279
|
tool: "ai-sdk",
|
|
@@ -12492,7 +12584,8 @@ function createClient(config) {
|
|
|
12492
12584
|
});
|
|
12493
12585
|
const folderPath = options?.folder?.name ?? driveConfig?.folder;
|
|
12494
12586
|
return {
|
|
12495
|
-
|
|
12587
|
+
// Named before the job runs, so the requested/declared format is the best hint.
|
|
12588
|
+
name: explicit?.name ?? buildFilename(params2.prompt, model.mode, { format: expectedOutputFormat(model, params2) }),
|
|
12496
12589
|
// SDK-assembled attributes are the baseline; explicit attributes win per-key.
|
|
12497
12590
|
attributes: { ...attributes, ...explicit?.attributes ?? {} },
|
|
12498
12591
|
folder: explicit?.folder ?? (folderPath ? { path: folderPath } : void 0)
|
|
@@ -13817,4 +13910,4 @@ function decodeDeepLinkPayload(encoded) {
|
|
|
13817
13910
|
return deserializePayload(encoded);
|
|
13818
13911
|
}
|
|
13819
13912
|
|
|
13820
|
-
export { ALL_MODELS, ApiError, ExecutionMode as ApiRunMode, DEFAULT_VISIBLE_RELEASES, GenerationEventType, Model, Models, buildFilename, buildGenerationAttributes, catalog, createClient, decodeDeepLinkPayload, encodeDeepLinkPayload, findModel, getModel, getModelsByMode, getVoiceById, inferResourceType, isVisibleForReleases, parseGeneration, releaseOf, toAvatarOption, toVoiceOption };
|
|
13913
|
+
export { ALL_MODELS, ApiError, ExecutionMode as ApiRunMode, DEFAULT_VISIBLE_RELEASES, GenerationEventType, Model, Models, buildFilename, buildGenerationAttributes, catalog, createClient, decodeDeepLinkPayload, encodeDeepLinkPayload, expectedOutputFormat, findModel, getModel, getModelsByMode, getVoiceById, inferResourceType, isVisibleForReleases, parseGeneration, releaseOf, resolveExtension, toAvatarOption, toVoiceOption };
|