@shop-os/modelkit 0.4.5 → 0.4.7
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 +16 -0
- package/README.md +5 -1
- package/dist/catalog.cjs +1 -0
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.d.cts +10 -1
- package/dist/catalog.d.ts +10 -1
- package/dist/catalog.js +1 -0
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +210 -121
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -1
- package/dist/index.d.ts +18 -1
- package/dist/index.js +209 -121
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -686,6 +686,15 @@ declare const SurfaceSchema: z.ZodEnum<{
|
|
|
686
686
|
}>;
|
|
687
687
|
declare const SURFACES: ("cowork" | "space_builder")[];
|
|
688
688
|
declare const ExposureSchema: z.ZodType<Surface[], unknown>;
|
|
689
|
+
declare const VideoResolutionSchema: z.ZodEnum<{
|
|
690
|
+
"360p": "360p";
|
|
691
|
+
"480p": "480p";
|
|
692
|
+
"720p": "720p";
|
|
693
|
+
"768p": "768p";
|
|
694
|
+
"1080p": "1080p";
|
|
695
|
+
"2k": "2k";
|
|
696
|
+
"4k": "4k";
|
|
697
|
+
}>;
|
|
689
698
|
declare const CatalogModelSchemaBase: z.ZodObject<{
|
|
690
699
|
id: z.ZodString;
|
|
691
700
|
aliases: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
@@ -1144,6 +1153,8 @@ interface Adapter {
|
|
|
1144
1153
|
id: string;
|
|
1145
1154
|
generateImage?(req: ImageRequest, ctx: AdapterContext): Promise<ImageResult>;
|
|
1146
1155
|
generateVideo?(req: VideoRequest, ctx: AdapterContext): Promise<VideoJob>;
|
|
1156
|
+
/** Reconnect to a job `generateVideo` submitted earlier; never submits. */
|
|
1157
|
+
resumeVideo?(req: VideoRequest, jobId: string, ctx: AdapterContext): VideoJob;
|
|
1147
1158
|
generateAudio?(req: AudioRequest, ctx: AdapterContext): Promise<AudioResult>;
|
|
1148
1159
|
/** Video tools run as provider jobs the caller tracks; see ModelKit.submitVideoTool. */
|
|
1149
1160
|
submitVideoTool?(req: VideoToolRequest, ctx: AdapterContext, opts: {
|
|
@@ -1350,6 +1361,12 @@ interface ModelKit extends TextMethods {
|
|
|
1350
1361
|
* `model` is a catalog id or an AI SDK video model instance.
|
|
1351
1362
|
*/
|
|
1352
1363
|
generateVideo(req: VideoCallOptions, call?: CallContext): Promise<VideoCallJob>;
|
|
1364
|
+
/**
|
|
1365
|
+
* Reconnect to a video job submitted earlier with `generateVideo` (same request), by its
|
|
1366
|
+
* `jobId`. Never submits a new job. Await `job.result()` as usual; usage is emitted once.
|
|
1367
|
+
* A resumed job reports only the resumed wait in `latencyMs`.
|
|
1368
|
+
*/
|
|
1369
|
+
resumeVideo(req: VideoCallOptions, jobId: string, call?: CallContext): Promise<VideoCallJob>;
|
|
1353
1370
|
/** AI SDK LanguageModel for chat models. Pair with the catalog's providerOptions. */
|
|
1354
1371
|
languageModel(modelId: string, call?: CallContext): LanguageModelHandle;
|
|
1355
1372
|
/** Usage-event `provider` for a catalog model, without building it: "bedrock" on Bedrock, else the vendor. */
|
|
@@ -1491,4 +1508,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
|
|
|
1491
1508
|
/** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
|
|
1492
1509
|
declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
|
|
1493
1510
|
|
|
1494
|
-
export { ADAPTER_IDS, ADAPTER_KEYS, ARRAY_INPUT_SPEC_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type ArrayInputSpecKey, type AspectRatio, type AudioOutput, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, CatalogModelSchemaBase, type CatalogOrigin, CatalogSchema, type CatalogSource, type CatalogTextModel, DEFAULT_ADAPTERS, type DataOnlyRow, type DataOnlyVerdict, type DefaultObjectOutput, type Exposure, ExposureSchema, type FalWebhookBody, type GeneratedImage, IMAGE_INPUT_SPEC_KEYS, INPUT_SPEC_SUPPORTS_KEYS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type InputSpec, type InputSpecDimensions, type InputSpecIssue, type InputSpecKey, InputSpecSchema, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type KeyTier, type LanguageModelHandle, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKit, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, type ModelkitGenerateObjectOptions, type ModelkitGenerateTextOptions, type ModelkitStreamObjectOptions, type ModelkitStreamTextOptions, type ObjectOutput, type ObjectResult, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type PromptConventions, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type ReferenceSyntax, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, type TextMethods, type TextModelInstance, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_INPUT_SPEC_KEYS, VIDEO_TOOL_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type VideoToolCallContext, type VideoToolConstraints, type VideoToolKind, type VideoToolOutputFormat, type VideoToolOutputSpec, type VideoToolPlan, type VideoToolRequest, type VideoToolResult, type VideoToolSource, type VideoToolStatus, type VideoToolSubmission, type Warning, adapterServesType, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, falWebhookBodySchema, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isArrayInputSpecKey, isInputSpecKey, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, missingTierKeys, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, planVideoTool, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolutionTier, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, videoToolConstraints, withRetry, xaiVideoAdapter };
|
|
1511
|
+
export { ADAPTER_IDS, ADAPTER_KEYS, ARRAY_INPUT_SPEC_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type ArrayInputSpecKey, type AspectRatio, type AudioOutput, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, CatalogModelSchemaBase, type CatalogOrigin, CatalogSchema, type CatalogSource, type CatalogTextModel, DEFAULT_ADAPTERS, type DataOnlyRow, type DataOnlyVerdict, type DefaultObjectOutput, type Exposure, ExposureSchema, type FalWebhookBody, type GeneratedImage, IMAGE_INPUT_SPEC_KEYS, INPUT_SPEC_SUPPORTS_KEYS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type InputSpec, type InputSpecDimensions, type InputSpecIssue, type InputSpecKey, InputSpecSchema, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type KeyTier, type LanguageModelHandle, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKit, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, type ModelkitGenerateObjectOptions, type ModelkitGenerateTextOptions, type ModelkitStreamObjectOptions, type ModelkitStreamTextOptions, type ObjectOutput, type ObjectResult, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type PromptConventions, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type ReferenceSyntax, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, type TextMethods, type TextModelInstance, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_INPUT_SPEC_KEYS, VIDEO_TOOL_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, VideoResolutionSchema, type VideoResult, type VideoSecondsLimits, type VideoToolCallContext, type VideoToolConstraints, type VideoToolKind, type VideoToolOutputFormat, type VideoToolOutputSpec, type VideoToolPlan, type VideoToolRequest, type VideoToolResult, type VideoToolSource, type VideoToolStatus, type VideoToolSubmission, type Warning, adapterServesType, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, falWebhookBodySchema, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isArrayInputSpecKey, isInputSpecKey, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, missingTierKeys, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, planVideoTool, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolutionTier, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, videoToolConstraints, withRetry, xaiVideoAdapter };
|
package/dist/index.d.ts
CHANGED
|
@@ -686,6 +686,15 @@ declare const SurfaceSchema: z.ZodEnum<{
|
|
|
686
686
|
}>;
|
|
687
687
|
declare const SURFACES: ("cowork" | "space_builder")[];
|
|
688
688
|
declare const ExposureSchema: z.ZodType<Surface[], unknown>;
|
|
689
|
+
declare const VideoResolutionSchema: z.ZodEnum<{
|
|
690
|
+
"360p": "360p";
|
|
691
|
+
"480p": "480p";
|
|
692
|
+
"720p": "720p";
|
|
693
|
+
"768p": "768p";
|
|
694
|
+
"1080p": "1080p";
|
|
695
|
+
"2k": "2k";
|
|
696
|
+
"4k": "4k";
|
|
697
|
+
}>;
|
|
689
698
|
declare const CatalogModelSchemaBase: z.ZodObject<{
|
|
690
699
|
id: z.ZodString;
|
|
691
700
|
aliases: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
@@ -1144,6 +1153,8 @@ interface Adapter {
|
|
|
1144
1153
|
id: string;
|
|
1145
1154
|
generateImage?(req: ImageRequest, ctx: AdapterContext): Promise<ImageResult>;
|
|
1146
1155
|
generateVideo?(req: VideoRequest, ctx: AdapterContext): Promise<VideoJob>;
|
|
1156
|
+
/** Reconnect to a job `generateVideo` submitted earlier; never submits. */
|
|
1157
|
+
resumeVideo?(req: VideoRequest, jobId: string, ctx: AdapterContext): VideoJob;
|
|
1147
1158
|
generateAudio?(req: AudioRequest, ctx: AdapterContext): Promise<AudioResult>;
|
|
1148
1159
|
/** Video tools run as provider jobs the caller tracks; see ModelKit.submitVideoTool. */
|
|
1149
1160
|
submitVideoTool?(req: VideoToolRequest, ctx: AdapterContext, opts: {
|
|
@@ -1350,6 +1361,12 @@ interface ModelKit extends TextMethods {
|
|
|
1350
1361
|
* `model` is a catalog id or an AI SDK video model instance.
|
|
1351
1362
|
*/
|
|
1352
1363
|
generateVideo(req: VideoCallOptions, call?: CallContext): Promise<VideoCallJob>;
|
|
1364
|
+
/**
|
|
1365
|
+
* Reconnect to a video job submitted earlier with `generateVideo` (same request), by its
|
|
1366
|
+
* `jobId`. Never submits a new job. Await `job.result()` as usual; usage is emitted once.
|
|
1367
|
+
* A resumed job reports only the resumed wait in `latencyMs`.
|
|
1368
|
+
*/
|
|
1369
|
+
resumeVideo(req: VideoCallOptions, jobId: string, call?: CallContext): Promise<VideoCallJob>;
|
|
1353
1370
|
/** AI SDK LanguageModel for chat models. Pair with the catalog's providerOptions. */
|
|
1354
1371
|
languageModel(modelId: string, call?: CallContext): LanguageModelHandle;
|
|
1355
1372
|
/** Usage-event `provider` for a catalog model, without building it: "bedrock" on Bedrock, else the vendor. */
|
|
@@ -1491,4 +1508,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
|
|
|
1491
1508
|
/** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
|
|
1492
1509
|
declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
|
|
1493
1510
|
|
|
1494
|
-
export { ADAPTER_IDS, ADAPTER_KEYS, ARRAY_INPUT_SPEC_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type ArrayInputSpecKey, type AspectRatio, type AudioOutput, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, CatalogModelSchemaBase, type CatalogOrigin, CatalogSchema, type CatalogSource, type CatalogTextModel, DEFAULT_ADAPTERS, type DataOnlyRow, type DataOnlyVerdict, type DefaultObjectOutput, type Exposure, ExposureSchema, type FalWebhookBody, type GeneratedImage, IMAGE_INPUT_SPEC_KEYS, INPUT_SPEC_SUPPORTS_KEYS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type InputSpec, type InputSpecDimensions, type InputSpecIssue, type InputSpecKey, InputSpecSchema, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type KeyTier, type LanguageModelHandle, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKit, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, type ModelkitGenerateObjectOptions, type ModelkitGenerateTextOptions, type ModelkitStreamObjectOptions, type ModelkitStreamTextOptions, type ObjectOutput, type ObjectResult, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type PromptConventions, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type ReferenceSyntax, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, type TextMethods, type TextModelInstance, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_INPUT_SPEC_KEYS, VIDEO_TOOL_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type VideoToolCallContext, type VideoToolConstraints, type VideoToolKind, type VideoToolOutputFormat, type VideoToolOutputSpec, type VideoToolPlan, type VideoToolRequest, type VideoToolResult, type VideoToolSource, type VideoToolStatus, type VideoToolSubmission, type Warning, adapterServesType, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, falWebhookBodySchema, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isArrayInputSpecKey, isInputSpecKey, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, missingTierKeys, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, planVideoTool, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolutionTier, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, videoToolConstraints, withRetry, xaiVideoAdapter };
|
|
1511
|
+
export { ADAPTER_IDS, ADAPTER_KEYS, ARRAY_INPUT_SPEC_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type ArrayInputSpecKey, type AspectRatio, type AudioOutput, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, CatalogModelSchemaBase, type CatalogOrigin, CatalogSchema, type CatalogSource, type CatalogTextModel, DEFAULT_ADAPTERS, type DataOnlyRow, type DataOnlyVerdict, type DefaultObjectOutput, type Exposure, ExposureSchema, type FalWebhookBody, type GeneratedImage, IMAGE_INPUT_SPEC_KEYS, INPUT_SPEC_SUPPORTS_KEYS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type InputSpec, type InputSpecDimensions, type InputSpecIssue, type InputSpecKey, InputSpecSchema, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type KeyTier, type LanguageModelHandle, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKit, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, type ModelkitGenerateObjectOptions, type ModelkitGenerateTextOptions, type ModelkitStreamObjectOptions, type ModelkitStreamTextOptions, type ObjectOutput, type ObjectResult, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type PromptConventions, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type ReferenceSyntax, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, type TextMethods, type TextModelInstance, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_INPUT_SPEC_KEYS, VIDEO_TOOL_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, VideoResolutionSchema, type VideoResult, type VideoSecondsLimits, type VideoToolCallContext, type VideoToolConstraints, type VideoToolKind, type VideoToolOutputFormat, type VideoToolOutputSpec, type VideoToolPlan, type VideoToolRequest, type VideoToolResult, type VideoToolSource, type VideoToolStatus, type VideoToolSubmission, type Warning, adapterServesType, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, falWebhookBodySchema, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isArrayInputSpecKey, isInputSpecKey, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, missingTierKeys, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, planVideoTool, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolutionTier, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, videoToolConstraints, withRetry, xaiVideoAdapter };
|
package/dist/index.js
CHANGED
|
@@ -3651,6 +3651,11 @@ var arkAdapter = {
|
|
|
3651
3651
|
async generateVideo(req, ctx) {
|
|
3652
3652
|
throwIfAborted(ctx.signal);
|
|
3653
3653
|
return generateSeedanceVideo(req, ctx);
|
|
3654
|
+
},
|
|
3655
|
+
resumeVideo(req, jobId, ctx) {
|
|
3656
|
+
throwIfAborted(ctx.signal);
|
|
3657
|
+
const key = arkKey(ctx);
|
|
3658
|
+
return seedanceJob(ctx, key, jobId, seedanceUsage(ctx, req, seedanceInitialDuration(req)));
|
|
3654
3659
|
}
|
|
3655
3660
|
};
|
|
3656
3661
|
function arkKey(ctx) {
|
|
@@ -3808,17 +3813,22 @@ var SeedanceResponseSchema = z7.object({
|
|
|
3808
3813
|
error: z7.union([z7.string(), z7.object({ message: z7.string().optional() })]).optional()
|
|
3809
3814
|
});
|
|
3810
3815
|
var SeedanceErrorMessageSchema = z7.object({ message: z7.string().optional() });
|
|
3816
|
+
function seedanceResolution(req) {
|
|
3817
|
+
return req.resolution ?? "720p";
|
|
3818
|
+
}
|
|
3811
3819
|
function seedanceUsage(ctx, req, duration) {
|
|
3812
|
-
|
|
3820
|
+
return {
|
|
3813
3821
|
model: ctx.model.id,
|
|
3814
3822
|
provider: "ark",
|
|
3815
3823
|
modality: "VIDEO",
|
|
3816
3824
|
unit: "seconds",
|
|
3817
3825
|
quantity: duration,
|
|
3818
|
-
durationSeconds: duration
|
|
3826
|
+
durationSeconds: duration,
|
|
3827
|
+
resolution: seedanceResolution(req)
|
|
3819
3828
|
};
|
|
3820
|
-
|
|
3821
|
-
|
|
3829
|
+
}
|
|
3830
|
+
function seedanceInitialDuration(req) {
|
|
3831
|
+
return req.durationSeconds ?? 5;
|
|
3822
3832
|
}
|
|
3823
3833
|
function seedanceErrorMessage(error, status) {
|
|
3824
3834
|
const asString = z7.string().safeParse(error);
|
|
@@ -3827,6 +3837,82 @@ function seedanceErrorMessage(error, status) {
|
|
|
3827
3837
|
if (asObject.success && asObject.data.message !== void 0) return asObject.data.message;
|
|
3828
3838
|
return `Seedance task ${status}`;
|
|
3829
3839
|
}
|
|
3840
|
+
function seedanceJob(ctx, key, jobId, usage2) {
|
|
3841
|
+
const modelId = ctx.model.id;
|
|
3842
|
+
const fetchStatus = async () => {
|
|
3843
|
+
const res = await arkFetch(ctx, `${arkBaseUrl(ctx)}${SUBMIT_PATH}/${jobId}`, {
|
|
3844
|
+
headers: { Authorization: `Bearer ${key}` }
|
|
3845
|
+
});
|
|
3846
|
+
if (!res.ok) {
|
|
3847
|
+
if (ctx.call.maxRetries !== 0 && (res.status === 429 || res.status >= 500))
|
|
3848
|
+
return void 0;
|
|
3849
|
+
const text2 = await res.text().catch(() => "");
|
|
3850
|
+
throwArkError(res.status, text2, modelId);
|
|
3851
|
+
}
|
|
3852
|
+
const parsed = SeedanceResponseSchema.safeParse(await res.json());
|
|
3853
|
+
if (!parsed.success) return {};
|
|
3854
|
+
return parsed.data;
|
|
3855
|
+
};
|
|
3856
|
+
return {
|
|
3857
|
+
jobId,
|
|
3858
|
+
async poll() {
|
|
3859
|
+
const polled = await fetchStatus();
|
|
3860
|
+
if (!polled) return { status: "running" };
|
|
3861
|
+
const status = (polled.status ?? "queued").toLowerCase();
|
|
3862
|
+
if (status === "succeeded") return { status: "succeeded", raw: polled };
|
|
3863
|
+
if (status === "failed" || status === "expired" || status === "cancelled") {
|
|
3864
|
+
return { status: "failed", raw: polled };
|
|
3865
|
+
}
|
|
3866
|
+
if (status === "queued" || status === "pending")
|
|
3867
|
+
return { status: "pending", raw: polled };
|
|
3868
|
+
return { status: "running", raw: polled };
|
|
3869
|
+
},
|
|
3870
|
+
async result(opts) {
|
|
3871
|
+
const optSignal = opts?.signal ?? ctx.signal;
|
|
3872
|
+
const pollOpts = {
|
|
3873
|
+
intervalMs: opts?.pollIntervalMs ?? SEEDANCE_POLL_INTERVAL_MS,
|
|
3874
|
+
timeoutMs: opts?.timeoutMs ?? RESULT_TIMEOUT_MS
|
|
3875
|
+
};
|
|
3876
|
+
if (optSignal !== void 0) pollOpts.signal = optSignal;
|
|
3877
|
+
return pollUntil(async () => {
|
|
3878
|
+
const polled = await fetchStatus();
|
|
3879
|
+
if (!polled) return void 0;
|
|
3880
|
+
const status = (polled.status ?? "queued").toLowerCase();
|
|
3881
|
+
if (status === "succeeded") {
|
|
3882
|
+
const url = polled.content?.video_url;
|
|
3883
|
+
if (!url)
|
|
3884
|
+
throwArkError(
|
|
3885
|
+
void 0,
|
|
3886
|
+
"Seedance task succeeded but returned no video_url",
|
|
3887
|
+
modelId
|
|
3888
|
+
);
|
|
3889
|
+
if (polled.duration !== void 0 && polled.duration > 0) {
|
|
3890
|
+
usage2.quantity = polled.duration;
|
|
3891
|
+
usage2.durationSeconds = polled.duration;
|
|
3892
|
+
}
|
|
3893
|
+
const rendered = VideoResolutionSchema.safeParse(
|
|
3894
|
+
polled.resolution?.toLowerCase()
|
|
3895
|
+
);
|
|
3896
|
+
if (rendered.success) usage2.resolution = rendered.data;
|
|
3897
|
+
const tokens = polled.usage;
|
|
3898
|
+
if (tokens?.total_tokens !== void 0 && tokens.completion_tokens !== void 0) {
|
|
3899
|
+
usage2.inputTokens = tokens.total_tokens - tokens.completion_tokens;
|
|
3900
|
+
usage2.outputTokens = tokens.completion_tokens;
|
|
3901
|
+
}
|
|
3902
|
+
return {
|
|
3903
|
+
video: { url, expiresAt: new Date(Date.now() + VIDEO_URL_TTL_MS) },
|
|
3904
|
+
usage: usage2,
|
|
3905
|
+
raw: polled
|
|
3906
|
+
};
|
|
3907
|
+
}
|
|
3908
|
+
if (status === "failed" || status === "expired" || status === "cancelled") {
|
|
3909
|
+
throwArkError(void 0, seedanceErrorMessage(polled.error, status), modelId);
|
|
3910
|
+
}
|
|
3911
|
+
return void 0;
|
|
3912
|
+
}, pollOpts);
|
|
3913
|
+
}
|
|
3914
|
+
};
|
|
3915
|
+
}
|
|
3830
3916
|
async function generateSeedanceVideo(req, ctx) {
|
|
3831
3917
|
const modelId = ctx.model.id;
|
|
3832
3918
|
const taskType = req.taskType;
|
|
@@ -3841,10 +3927,10 @@ async function generateSeedanceVideo(req, ctx) {
|
|
|
3841
3927
|
});
|
|
3842
3928
|
}
|
|
3843
3929
|
const key = arkKey(ctx);
|
|
3844
|
-
const requestedDuration = req
|
|
3930
|
+
const requestedDuration = seedanceInitialDuration(req);
|
|
3845
3931
|
let duration = requestedDuration;
|
|
3846
3932
|
if (taskType === "edit") duration = -1;
|
|
3847
|
-
const resolution = req
|
|
3933
|
+
const resolution = seedanceResolution(req);
|
|
3848
3934
|
const content = [{ type: "text", text: req.prompt }];
|
|
3849
3935
|
if (req.firstFrame) {
|
|
3850
3936
|
content.push({
|
|
@@ -3922,75 +4008,7 @@ async function generateSeedanceVideo(req, ctx) {
|
|
|
3922
4008
|
if (!submit.id) throwArkError(void 0, "Seedance task create returned no id", modelId);
|
|
3923
4009
|
const jobId = submit.id;
|
|
3924
4010
|
const usage2 = seedanceUsage(ctx, req, taskType === "edit" ? requestedDuration : duration);
|
|
3925
|
-
|
|
3926
|
-
const res = await arkFetch(ctx, `${arkBaseUrl(ctx)}${SUBMIT_PATH}/${jobId}`, {
|
|
3927
|
-
headers: { Authorization: `Bearer ${key}` }
|
|
3928
|
-
});
|
|
3929
|
-
if (!res.ok) {
|
|
3930
|
-
if (ctx.call.maxRetries !== 0 && (res.status === 429 || res.status >= 500))
|
|
3931
|
-
return void 0;
|
|
3932
|
-
const text2 = await res.text().catch(() => "");
|
|
3933
|
-
throwArkError(res.status, text2, modelId);
|
|
3934
|
-
}
|
|
3935
|
-
const parsed = SeedanceResponseSchema.safeParse(await res.json());
|
|
3936
|
-
if (!parsed.success) return {};
|
|
3937
|
-
return parsed.data;
|
|
3938
|
-
};
|
|
3939
|
-
return {
|
|
3940
|
-
jobId,
|
|
3941
|
-
async poll() {
|
|
3942
|
-
const polled = await fetchStatus();
|
|
3943
|
-
if (!polled) return { status: "running" };
|
|
3944
|
-
const status = (polled.status ?? "queued").toLowerCase();
|
|
3945
|
-
if (status === "succeeded") return { status: "succeeded", raw: polled };
|
|
3946
|
-
if (status === "failed" || status === "expired" || status === "cancelled") {
|
|
3947
|
-
return { status: "failed", raw: polled };
|
|
3948
|
-
}
|
|
3949
|
-
if (status === "queued" || status === "pending")
|
|
3950
|
-
return { status: "pending", raw: polled };
|
|
3951
|
-
return { status: "running", raw: polled };
|
|
3952
|
-
},
|
|
3953
|
-
async result(opts) {
|
|
3954
|
-
const optSignal = opts?.signal ?? ctx.signal;
|
|
3955
|
-
const pollOpts = {
|
|
3956
|
-
intervalMs: opts?.pollIntervalMs ?? SEEDANCE_POLL_INTERVAL_MS,
|
|
3957
|
-
timeoutMs: opts?.timeoutMs ?? RESULT_TIMEOUT_MS
|
|
3958
|
-
};
|
|
3959
|
-
if (optSignal !== void 0) pollOpts.signal = optSignal;
|
|
3960
|
-
return pollUntil(async () => {
|
|
3961
|
-
const polled = await fetchStatus();
|
|
3962
|
-
if (!polled) return void 0;
|
|
3963
|
-
const status = (polled.status ?? "queued").toLowerCase();
|
|
3964
|
-
if (status === "succeeded") {
|
|
3965
|
-
const url = polled.content?.video_url;
|
|
3966
|
-
if (!url)
|
|
3967
|
-
throwArkError(
|
|
3968
|
-
void 0,
|
|
3969
|
-
"Seedance task succeeded but returned no video_url",
|
|
3970
|
-
modelId
|
|
3971
|
-
);
|
|
3972
|
-
if (polled.duration !== void 0 && polled.duration > 0) {
|
|
3973
|
-
usage2.quantity = polled.duration;
|
|
3974
|
-
usage2.durationSeconds = polled.duration;
|
|
3975
|
-
}
|
|
3976
|
-
const tokens = polled.usage;
|
|
3977
|
-
if (tokens?.total_tokens !== void 0 && tokens.completion_tokens !== void 0) {
|
|
3978
|
-
usage2.inputTokens = tokens.total_tokens - tokens.completion_tokens;
|
|
3979
|
-
usage2.outputTokens = tokens.completion_tokens;
|
|
3980
|
-
}
|
|
3981
|
-
return {
|
|
3982
|
-
video: { url, expiresAt: new Date(Date.now() + VIDEO_URL_TTL_MS) },
|
|
3983
|
-
usage: usage2,
|
|
3984
|
-
raw: polled
|
|
3985
|
-
};
|
|
3986
|
-
}
|
|
3987
|
-
if (status === "failed" || status === "expired" || status === "cancelled") {
|
|
3988
|
-
throwArkError(void 0, seedanceErrorMessage(polled.error, status), modelId);
|
|
3989
|
-
}
|
|
3990
|
-
return void 0;
|
|
3991
|
-
}, pollOpts);
|
|
3992
|
-
}
|
|
3993
|
-
};
|
|
4011
|
+
return seedanceJob(ctx, key, jobId, usage2);
|
|
3994
4012
|
}
|
|
3995
4013
|
|
|
3996
4014
|
// src/adapters/fal.ts
|
|
@@ -4780,9 +4798,15 @@ function videoUsage(ctx, req, duration) {
|
|
|
4780
4798
|
quantity: duration,
|
|
4781
4799
|
durationSeconds: duration
|
|
4782
4800
|
};
|
|
4783
|
-
|
|
4801
|
+
const resolution = falVideoResolution(ctx.model.providerModelId, req);
|
|
4802
|
+
if (resolution !== void 0) event.resolution = resolution;
|
|
4784
4803
|
return event;
|
|
4785
4804
|
}
|
|
4805
|
+
function falVideoResolution(providerModelId, req) {
|
|
4806
|
+
if (isWan(providerModelId)) return wanResolution(req);
|
|
4807
|
+
if (isMinimax(providerModelId)) return minimaxResolution(req, minimaxFamily(providerModelId));
|
|
4808
|
+
return req.resolution;
|
|
4809
|
+
}
|
|
4786
4810
|
async function decodeImage(ctx, url, contentType) {
|
|
4787
4811
|
if (url.startsWith("data:")) {
|
|
4788
4812
|
const comma = url.indexOf(",");
|
|
@@ -4914,12 +4938,14 @@ function isFalVideoKnown(providerModelId) {
|
|
|
4914
4938
|
function minimaxFamily(providerModelId) {
|
|
4915
4939
|
return H3_MAX_MODEL_IDS.has(providerModelId.toLowerCase()) ? "h3-max" : "h3";
|
|
4916
4940
|
}
|
|
4941
|
+
function minimaxResolution(req, family) {
|
|
4942
|
+
return req.resolution ?? (family === "h3-max" ? "768p" : "2k");
|
|
4943
|
+
}
|
|
4917
4944
|
function minimaxBase(req, family) {
|
|
4918
|
-
const resolution = (family === "h3-max" ? req.resolution ?? "768p" : req.resolution ?? "2k").toUpperCase();
|
|
4919
4945
|
const input = {
|
|
4920
4946
|
prompt: req.prompt.trim(),
|
|
4921
4947
|
duration: req.durationSeconds ?? 5,
|
|
4922
|
-
resolution,
|
|
4948
|
+
resolution: minimaxResolution(req, family).toUpperCase(),
|
|
4923
4949
|
prompt_expansion_mode: req.promptExpansion ?? "balanced"
|
|
4924
4950
|
};
|
|
4925
4951
|
if (req.safetyChecker !== void 0) input.enable_safety_checker = req.safetyChecker;
|
|
@@ -4930,11 +4956,14 @@ var WAN_MODEL_IDS = /* @__PURE__ */ new Set(["alibaba/wan-3.0"]);
|
|
|
4930
4956
|
function isWan(providerModelId) {
|
|
4931
4957
|
return WAN_MODEL_IDS.has(providerModelId.toLowerCase());
|
|
4932
4958
|
}
|
|
4959
|
+
function wanResolution(req) {
|
|
4960
|
+
return req.resolution ?? "1080p";
|
|
4961
|
+
}
|
|
4933
4962
|
function wanVideo(req, family) {
|
|
4934
4963
|
const input = {
|
|
4935
4964
|
prompt: req.prompt.trim(),
|
|
4936
4965
|
duration: req.durationSeconds ?? 5,
|
|
4937
|
-
resolution: req
|
|
4966
|
+
resolution: wanResolution(req),
|
|
4938
4967
|
aspect_ratio: req.aspectRatio ?? "adaptive",
|
|
4939
4968
|
audio: req.generateAudio ?? true
|
|
4940
4969
|
};
|
|
@@ -5535,7 +5564,7 @@ async function downloadVideo(ctx, url, apiKey, signal) {
|
|
|
5535
5564
|
mime: res.headers.get("content-type")?.split(";")[0]?.trim() || "video/mp4"
|
|
5536
5565
|
};
|
|
5537
5566
|
}
|
|
5538
|
-
function videoUsage2(ctx,
|
|
5567
|
+
function videoUsage2(ctx, duration, resolution) {
|
|
5539
5568
|
const event = {
|
|
5540
5569
|
model: ctx.model.id,
|
|
5541
5570
|
provider: "google-genai",
|
|
@@ -5544,7 +5573,7 @@ function videoUsage2(ctx, req, duration) {
|
|
|
5544
5573
|
quantity: duration,
|
|
5545
5574
|
durationSeconds: duration
|
|
5546
5575
|
};
|
|
5547
|
-
if (
|
|
5576
|
+
if (resolution !== void 0) event.resolution = resolution;
|
|
5548
5577
|
return event;
|
|
5549
5578
|
}
|
|
5550
5579
|
async function generateVeoVideo(req, ctx, createGenAIClient) {
|
|
@@ -5638,7 +5667,7 @@ async function generateVeoVideo(req, ctx, createGenAIClient) {
|
|
|
5638
5667
|
}
|
|
5639
5668
|
};
|
|
5640
5669
|
const jobId = operation.name ?? crypto.randomUUID();
|
|
5641
|
-
const usage2 = videoUsage2(ctx,
|
|
5670
|
+
const usage2 = videoUsage2(ctx, duration, req.resolution ?? "720p");
|
|
5642
5671
|
return {
|
|
5643
5672
|
jobId,
|
|
5644
5673
|
async poll() {
|
|
@@ -5762,10 +5791,8 @@ async function generateOmniVideo(req, ctx, createGenAIClient) {
|
|
|
5762
5791
|
if (req.sourceVideo === void 0 && !extend && req.aspectRatio !== void 0 && req.aspectRatio !== "adaptive") {
|
|
5763
5792
|
responseFormat.aspect_ratio = toOmniAspect(req.aspectRatio);
|
|
5764
5793
|
}
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
if (omniResolution !== void 0) responseFormat.resolution = omniResolution;
|
|
5768
|
-
}
|
|
5794
|
+
const omniResolution = isOmniV1 ? void 0 : toOmniResolution(req.resolution);
|
|
5795
|
+
if (omniResolution !== void 0) responseFormat.resolution = omniResolution;
|
|
5769
5796
|
if (req.durationSeconds !== void 0) responseFormat.duration = `${req.durationSeconds}s`;
|
|
5770
5797
|
const client2 = createGenAIClient({
|
|
5771
5798
|
apiKey,
|
|
@@ -5883,7 +5910,7 @@ async function generateOmniVideo(req, ctx, createGenAIClient) {
|
|
|
5883
5910
|
if (!(extend && !chained)) await cleanupUploads();
|
|
5884
5911
|
}
|
|
5885
5912
|
const jobId = interaction.id ?? crypto.randomUUID();
|
|
5886
|
-
const usage2 = videoUsage2(ctx,
|
|
5913
|
+
const usage2 = videoUsage2(ctx, duration, omniResolution ?? "720p");
|
|
5887
5914
|
const getInteraction = async () => {
|
|
5888
5915
|
try {
|
|
5889
5916
|
const getParams = { stream: false };
|
|
@@ -7465,7 +7492,8 @@ function videoUsage4(ctx, req) {
|
|
|
7465
7492
|
unit: "compute_seconds",
|
|
7466
7493
|
quantity: 0
|
|
7467
7494
|
};
|
|
7468
|
-
|
|
7495
|
+
const resolution = replicateVideoResolution(ctx.model.providerModelId, req);
|
|
7496
|
+
if (resolution !== void 0) event.resolution = resolution;
|
|
7469
7497
|
if (req.durationSeconds !== void 0) event.durationSeconds = req.durationSeconds;
|
|
7470
7498
|
return event;
|
|
7471
7499
|
}
|
|
@@ -7702,7 +7730,7 @@ function klingInput(req) {
|
|
|
7702
7730
|
const input = {
|
|
7703
7731
|
prompt: req.prompt,
|
|
7704
7732
|
duration: req.durationSeconds ?? 10,
|
|
7705
|
-
mode: req.mode
|
|
7733
|
+
mode: klingTier(req).mode,
|
|
7706
7734
|
generate_audio: req.generateAudio ?? false
|
|
7707
7735
|
};
|
|
7708
7736
|
const startImage = images[0];
|
|
@@ -7716,17 +7744,25 @@ function klingInput(req) {
|
|
|
7716
7744
|
if (req.negativePrompt !== void 0) input.negative_prompt = req.negativePrompt;
|
|
7717
7745
|
return input;
|
|
7718
7746
|
}
|
|
7719
|
-
function
|
|
7720
|
-
|
|
7721
|
-
if (
|
|
7722
|
-
if (
|
|
7723
|
-
return req.
|
|
7747
|
+
function replicateVideoResolution(providerModelId, req) {
|
|
7748
|
+
const kind = videoKind(providerModelId);
|
|
7749
|
+
if (kind === "kling" || kind === "kling-omni") return klingTier(req).resolution;
|
|
7750
|
+
if (kind === "hailuo") return hailuoResolution(req);
|
|
7751
|
+
return req.resolution;
|
|
7752
|
+
}
|
|
7753
|
+
var KLING_TIERS = [
|
|
7754
|
+
{ mode: "standard", resolution: "720p" },
|
|
7755
|
+
{ mode: "pro", resolution: "1080p" },
|
|
7756
|
+
{ mode: "4k", resolution: "4k" }
|
|
7757
|
+
];
|
|
7758
|
+
function klingTier(req) {
|
|
7759
|
+
return KLING_TIERS.find((tier) => tier.resolution === req.resolution) ?? KLING_TIERS.find((tier) => tier.mode === req.mode) ?? KLING_TIERS[0];
|
|
7724
7760
|
}
|
|
7725
7761
|
function klingOmniInput(req) {
|
|
7726
7762
|
const input = {
|
|
7727
7763
|
prompt: req.prompt,
|
|
7728
7764
|
duration: req.durationSeconds ?? 10,
|
|
7729
|
-
mode:
|
|
7765
|
+
mode: klingTier(req).mode,
|
|
7730
7766
|
generate_audio: req.generateAudio ?? false
|
|
7731
7767
|
};
|
|
7732
7768
|
const start = req.firstFrame ?? req.lastFrame;
|
|
@@ -7740,11 +7776,14 @@ function klingOmniInput(req) {
|
|
|
7740
7776
|
if (refs.length > 0) input.reference_images = refs;
|
|
7741
7777
|
return input;
|
|
7742
7778
|
}
|
|
7779
|
+
function hailuoResolution(req) {
|
|
7780
|
+
return req.resolution ?? "768p";
|
|
7781
|
+
}
|
|
7743
7782
|
function hailuoInput(req) {
|
|
7744
7783
|
const input = {
|
|
7745
7784
|
prompt: req.prompt,
|
|
7746
7785
|
duration: req.durationSeconds ?? 6,
|
|
7747
|
-
resolution: req
|
|
7786
|
+
resolution: hailuoResolution(req),
|
|
7748
7787
|
prompt_optimizer: true
|
|
7749
7788
|
};
|
|
7750
7789
|
if (req.firstFrame) input.first_frame_image = refToUrl(req.firstFrame);
|
|
@@ -9579,6 +9618,33 @@ function createModelKit(config, adapters) {
|
|
|
9579
9618
|
result: () => done
|
|
9580
9619
|
};
|
|
9581
9620
|
}
|
|
9621
|
+
function wrapVideoJob(model, job, warnings, startedAt) {
|
|
9622
|
+
const result = job.result.bind(job);
|
|
9623
|
+
let settled;
|
|
9624
|
+
return {
|
|
9625
|
+
...job,
|
|
9626
|
+
warnings,
|
|
9627
|
+
result(opts) {
|
|
9628
|
+
if (settled) return settled;
|
|
9629
|
+
const pending = result(opts).then(
|
|
9630
|
+
async (out) => {
|
|
9631
|
+
const usage2 = timed(
|
|
9632
|
+
{ ...out.usage, model: model.id, unit: model.usage.unit },
|
|
9633
|
+
startedAt
|
|
9634
|
+
);
|
|
9635
|
+
await emit(usage2);
|
|
9636
|
+
return { ...out, usage: usage2 };
|
|
9637
|
+
},
|
|
9638
|
+
(cause) => {
|
|
9639
|
+
settled = void 0;
|
|
9640
|
+
throw cause;
|
|
9641
|
+
}
|
|
9642
|
+
);
|
|
9643
|
+
settled = pending;
|
|
9644
|
+
return pending;
|
|
9645
|
+
}
|
|
9646
|
+
};
|
|
9647
|
+
}
|
|
9582
9648
|
return {
|
|
9583
9649
|
catalog,
|
|
9584
9650
|
describe: (id) => catalog.require(id),
|
|
@@ -9663,31 +9729,52 @@ function createModelKit(config, adapters) {
|
|
|
9663
9729
|
});
|
|
9664
9730
|
const startedAt = Date.now();
|
|
9665
9731
|
const job = await adapter.generateVideo(request, ctx);
|
|
9666
|
-
|
|
9667
|
-
|
|
9668
|
-
|
|
9669
|
-
|
|
9670
|
-
|
|
9671
|
-
|
|
9672
|
-
|
|
9673
|
-
|
|
9674
|
-
|
|
9675
|
-
|
|
9676
|
-
|
|
9677
|
-
|
|
9678
|
-
|
|
9679
|
-
|
|
9680
|
-
|
|
9681
|
-
|
|
9682
|
-
|
|
9683
|
-
|
|
9684
|
-
|
|
9685
|
-
|
|
9686
|
-
|
|
9687
|
-
|
|
9688
|
-
|
|
9689
|
-
}
|
|
9690
|
-
}
|
|
9732
|
+
return wrapVideoJob(model, job, warnings, startedAt);
|
|
9733
|
+
},
|
|
9734
|
+
async resumeVideo(req, jobId, call = {}) {
|
|
9735
|
+
mediaRetryOptions(call);
|
|
9736
|
+
if (!jobId) {
|
|
9737
|
+
throw new ModelKitError({
|
|
9738
|
+
code: "missing_input",
|
|
9739
|
+
message: "resumeVideo needs a jobId",
|
|
9740
|
+
retryable: false
|
|
9741
|
+
});
|
|
9742
|
+
}
|
|
9743
|
+
if (!isCatalogId(req.model)) {
|
|
9744
|
+
throw new ModelKitError({
|
|
9745
|
+
code: "unsupported_option",
|
|
9746
|
+
message: "resumeVideo needs a catalog model id"
|
|
9747
|
+
});
|
|
9748
|
+
}
|
|
9749
|
+
const model = catalog.require(req.model);
|
|
9750
|
+
if (model.type !== "video")
|
|
9751
|
+
throw new ModelKitError({
|
|
9752
|
+
code: "unsupported_option",
|
|
9753
|
+
message: `${model.id} is not a video model`,
|
|
9754
|
+
model: model.id
|
|
9755
|
+
});
|
|
9756
|
+
const { request: input, warnings: inputWarnings } = videoRequestOf({
|
|
9757
|
+
...req,
|
|
9758
|
+
model: req.model
|
|
9759
|
+
});
|
|
9760
|
+
const { request, warnings } = resolveVideoOptions(
|
|
9761
|
+
model,
|
|
9762
|
+
input,
|
|
9763
|
+
call.onUnsupported ?? "error"
|
|
9764
|
+
);
|
|
9765
|
+
warnings.push(...inputWarnings);
|
|
9766
|
+
logCoercions(logger, model.id, warnings);
|
|
9767
|
+
const signal = combineSignals(req.abortSignal, call.signal);
|
|
9768
|
+
const { adapter, ctx } = context(model, signal ? { ...call, signal } : call, warnings);
|
|
9769
|
+
if (!adapter.resumeVideo)
|
|
9770
|
+
throw new ModelKitError({
|
|
9771
|
+
code: "unsupported_option",
|
|
9772
|
+
message: `${adapter.id} cannot resume a video job`,
|
|
9773
|
+
model: model.id
|
|
9774
|
+
});
|
|
9775
|
+
const startedAt = Date.now();
|
|
9776
|
+
const job = adapter.resumeVideo(request, jobId, ctx);
|
|
9777
|
+
return wrapVideoJob(model, { ...job, jobId }, warnings, startedAt);
|
|
9691
9778
|
},
|
|
9692
9779
|
async generateAudio(req, call = {}) {
|
|
9693
9780
|
mediaRetryOptions(call);
|
|
@@ -9931,6 +10018,7 @@ export {
|
|
|
9931
10018
|
SurfaceSchema,
|
|
9932
10019
|
VIDEO_INPUT_SPEC_KEYS,
|
|
9933
10020
|
VIDEO_TOOL_MODELS,
|
|
10021
|
+
VideoResolutionSchema,
|
|
9934
10022
|
adapterServesType,
|
|
9935
10023
|
aiSdkTextAdapter,
|
|
9936
10024
|
arkAdapter,
|