@shop-os/modelkit 0.2.26 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -42,7 +42,13 @@ interface UpscaleOptions {
42
42
  faceEnhancementCreativity?: number;
43
43
  faceEnhancementStrength?: number;
44
44
  }
45
- type ModelType = "text" | "image" | "video" | "audio" | "upscale" | "bg-remove";
45
+ type ModelType = "text" | "image" | "video" | "audio" | "upscale" | "bg-remove"
46
+ /** Video in, video out, no prompt: upscale, frame interpolation, SDR to HDR. */
47
+ | "video-tool";
48
+ /** What a `video-tool` row does to its source clip. */
49
+ type VideoToolKind = "upscale" | "interpolate" | "hdr";
50
+ /** Container/codec a video-tool row can write. */
51
+ type VideoToolOutputFormat = "h265" | "prores";
46
52
  type Lifecycle = "active" | "deprecated" | "retired";
47
53
  type Surface = "cowork" | "space_builder";
48
54
  /** @deprecated use Surface[] */
@@ -133,6 +139,61 @@ interface VideoCallOptions extends Omit<VideoRequest, "model"> {
133
139
  /** Reaches the provider only for AI SDK model instances; catalog rows carry their own. */
134
140
  providerOptions?: ProviderOptions;
135
141
  }
142
+ /** What the caller measured about a video-tool source; the kit never measures. */
143
+ interface VideoToolSource {
144
+ url: string;
145
+ width: number;
146
+ height: number;
147
+ durationSeconds: number;
148
+ fps?: number;
149
+ }
150
+ interface VideoToolRequest {
151
+ model: string;
152
+ source: VideoToolSource;
153
+ /** Upscale rows. */
154
+ upscaleFactor?: number;
155
+ /** Interpolate rows. */
156
+ targetFps?: number;
157
+ /** HDR rows; the row's first `outputFormats` entry when unset. */
158
+ outputFormat?: VideoToolOutputFormat;
159
+ }
160
+ /** The output a video-tool request will produce, from the request alone. */
161
+ interface VideoToolOutputSpec {
162
+ width: number;
163
+ height: number;
164
+ durationSeconds: number;
165
+ fps?: number;
166
+ resolution: VideoResolution;
167
+ format: "h264" | VideoToolOutputFormat;
168
+ }
169
+ interface VideoToolCallContext extends CallContext {
170
+ /** Where the provider posts the result when the job ends. */
171
+ webhookUrl?: string;
172
+ }
173
+ /**
174
+ * A submitted video-tool job. Plain JSON so a caller can store it and pass it back
175
+ * to `videoToolStatus` / `videoToolResult` / `cancelVideoTool` from another process.
176
+ */
177
+ interface VideoToolSubmission {
178
+ model: string;
179
+ provider: "fal";
180
+ requestId: string;
181
+ statusUrl: string;
182
+ responseUrl: string;
183
+ cancelUrl: string;
184
+ output: VideoToolOutputSpec;
185
+ }
186
+ type VideoToolStatus = "queued" | "running" | "completed";
187
+ interface VideoToolResult {
188
+ video: {
189
+ url: string;
190
+ mime?: string;
191
+ bytes?: number;
192
+ };
193
+ output: VideoToolOutputSpec;
194
+ usage: UsageEvent;
195
+ raw?: unknown;
196
+ }
136
197
  interface AudioRequest {
137
198
  model: string;
138
199
  prompt: string;
@@ -193,6 +254,33 @@ interface ReferenceLimits {
193
254
  audioOnly?: boolean;
194
255
  /** Per-video length caps (min/max each) and combined total for reference videos. */
195
256
  videoSeconds?: VideoSecondsLimits;
257
+ /** Per-clip length caps (min/max each) and combined total for reference audio, in seconds. */
258
+ audioSeconds?: {
259
+ min?: number;
260
+ max?: number;
261
+ total?: number;
262
+ };
263
+ /** File types the provider takes for reference audio, as lowercase extensions. */
264
+ audioFormats?: string[];
265
+ /** Largest reference audio file the provider takes, in bytes. */
266
+ audioMaxBytes?: number;
267
+ }
268
+ interface VideoToolConstraints {
269
+ kind: VideoToolKind;
270
+ /** Upscale: allowed factor range. */
271
+ upscaleFactor?: {
272
+ min: number;
273
+ max: number;
274
+ };
275
+ /** Upscale: the output's long edge may not pass this, in pixels. */
276
+ maxOutputLongEdge?: number;
277
+ /** Interpolate: allowed target frame rate range. */
278
+ fps?: {
279
+ min: number;
280
+ max: number;
281
+ };
282
+ /** HDR: the formats the row writes, first is the default. */
283
+ outputFormats?: VideoToolOutputFormat[];
196
284
  }
197
285
  /** Whether a video row's output has sound: always, switchable (`supports: generateAudio`), or silent. */
198
286
  type AudioOutput = "always" | "optional" | "never";
@@ -235,7 +323,12 @@ interface ModelConstraints {
235
323
  extension?: {
236
324
  segmentSeconds: number;
237
325
  maxTotalSeconds: number;
326
+ /** `joined` (absent): the provider returns the whole clip so far (Omni).
327
+ * `new`: it returns only the added footage and the caller joins it (Seedance). */
328
+ returns?: "new" | "joined";
238
329
  };
330
+ /** What a `video-tool` row accepts. Read it through `videoToolConstraints(row)`. */
331
+ tool?: VideoToolConstraints;
239
332
  /** Whether the output has sound. Read it through `outputAudio(row)`, which tolerates bad data. */
240
333
  audio?: AudioOutput;
241
334
  /** Prompt conventions. Read them through `promptConventions(row)`, which fills the default. */
@@ -296,6 +389,11 @@ interface CatalogDisplay {
296
389
  interface CatalogCapabilities {
297
390
  /** Video rows: takes an existing video as the thing to edit or extend. */
298
391
  acceptsSourceVideo?: boolean;
392
+ /**
393
+ * Video rows: offered for prompt-driven edits of a source clip (`taskType: "edit"`). Absent
394
+ * means the caller falls back to `acceptsSourceVideo`; `false` opts a row out.
395
+ */
396
+ videoEdit?: boolean;
299
397
  /** Video rows: first/last frames and reference images are mutually exclusive inputs. */
300
398
  framesExcludeReferences?: boolean;
301
399
  /** Video rows: a last frame is accepted only together with a first frame. */
@@ -414,6 +512,8 @@ interface UsageEvent {
414
512
  imageQuality?: ImageQuality;
415
513
  resolution?: VideoResolution;
416
514
  durationSeconds?: number;
515
+ /** Output frame rate (video-tool rows price by output frames). */
516
+ fps?: number;
417
517
  inputTokens?: number;
418
518
  outputTokens?: number;
419
519
  reportedCostUsd?: number;
@@ -580,6 +680,7 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
580
680
  audio: "audio";
581
681
  upscale: "upscale";
582
682
  "bg-remove": "bg-remove";
683
+ "video-tool": "video-tool";
583
684
  }>;
584
685
  adapter: z.ZodEnum<{
585
686
  "ai-sdk-text": "ai-sdk-text";
@@ -652,6 +753,13 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
652
753
  total: z.ZodOptional<z.ZodNumber>;
653
754
  editMin: z.ZodOptional<z.ZodNumber>;
654
755
  }, z.core.$loose>>;
756
+ audioSeconds: z.ZodOptional<z.ZodObject<{
757
+ min: z.ZodOptional<z.ZodNumber>;
758
+ max: z.ZodOptional<z.ZodNumber>;
759
+ total: z.ZodOptional<z.ZodNumber>;
760
+ }, z.core.$loose>>;
761
+ audioFormats: z.ZodOptional<z.ZodArray<z.ZodString>>;
762
+ audioMaxBytes: z.ZodOptional<z.ZodNumber>;
655
763
  }, z.core.$loose>>;
656
764
  requires: z.ZodOptional<z.ZodArray<z.ZodEnum<{
657
765
  references: "references";
@@ -691,6 +799,30 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
691
799
  extension: z.ZodOptional<z.ZodObject<{
692
800
  segmentSeconds: z.ZodNumber;
693
801
  maxTotalSeconds: z.ZodNumber;
802
+ returns: z.ZodOptional<z.ZodEnum<{
803
+ new: "new";
804
+ joined: "joined";
805
+ }>>;
806
+ }, z.core.$loose>>;
807
+ tool: z.ZodOptional<z.ZodObject<{
808
+ kind: z.ZodEnum<{
809
+ upscale: "upscale";
810
+ interpolate: "interpolate";
811
+ hdr: "hdr";
812
+ }>;
813
+ upscaleFactor: z.ZodOptional<z.ZodObject<{
814
+ min: z.ZodNumber;
815
+ max: z.ZodNumber;
816
+ }, z.core.$loose>>;
817
+ maxOutputLongEdge: z.ZodOptional<z.ZodNumber>;
818
+ fps: z.ZodOptional<z.ZodObject<{
819
+ min: z.ZodNumber;
820
+ max: z.ZodNumber;
821
+ }, z.core.$loose>>;
822
+ outputFormats: z.ZodOptional<z.ZodArray<z.ZodEnum<{
823
+ h265: "h265";
824
+ prores: "prores";
825
+ }>>>;
694
826
  }, z.core.$loose>>;
695
827
  audio: z.ZodOptional<z.ZodUnknown>;
696
828
  prompt: z.ZodOptional<z.ZodUnknown>;
@@ -879,6 +1011,7 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
879
1011
  }, z.core.$loose>>;
880
1012
  capabilities: z.ZodOptional<z.ZodObject<{
881
1013
  acceptsSourceVideo: z.ZodOptional<z.ZodBoolean>;
1014
+ videoEdit: z.ZodOptional<z.ZodBoolean>;
882
1015
  framesExcludeReferences: z.ZodOptional<z.ZodBoolean>;
883
1016
  lastFrameRequiresFirstFrame: z.ZodOptional<z.ZodBoolean>;
884
1017
  reasoning: z.ZodOptional<z.ZodBoolean>;
@@ -923,6 +1056,20 @@ declare function validateInputSpec(raw: ProviderOptionValue, row: ValidateRow):
923
1056
  declare const ANTHROPIC_TRANSPORTS: readonly ["direct", "bedrock"];
924
1057
  type AnthropicTransport = (typeof ANTHROPIC_TRANSPORTS)[number];
925
1058
 
1059
+ /** fal's webhook body (https://fal.ai/docs/model-apis/model-endpoints/webhooks). */
1060
+ declare const falWebhookBodySchema: z.ZodObject<{
1061
+ request_id: z.ZodString;
1062
+ gateway_request_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1063
+ status: z.ZodEnum<{
1064
+ OK: "OK";
1065
+ ERROR: "ERROR";
1066
+ }>;
1067
+ payload: z.ZodOptional<z.ZodNullable<z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>;
1068
+ error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1069
+ payload_error: z.ZodOptional<z.ZodNullable<z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>;
1070
+ }, z.core.$strip>;
1071
+ type FalWebhookBody = z.infer<typeof falWebhookBodySchema>;
1072
+
926
1073
  /** Everything an adapter needs for one call. Resolved by the core before dispatch. */
927
1074
  interface AdapterContext {
928
1075
  model: CatalogModel;
@@ -947,6 +1094,13 @@ interface Adapter {
947
1094
  generateImage?(req: ImageRequest, ctx: AdapterContext): Promise<ImageResult>;
948
1095
  generateVideo?(req: VideoRequest, ctx: AdapterContext): Promise<VideoJob>;
949
1096
  generateAudio?(req: AudioRequest, ctx: AdapterContext): Promise<AudioResult>;
1097
+ /** Video tools run as provider jobs the caller tracks; see ModelKit.submitVideoTool. */
1098
+ submitVideoTool?(req: VideoToolRequest, ctx: AdapterContext, opts: {
1099
+ webhookUrl?: string;
1100
+ }): Promise<VideoToolSubmission>;
1101
+ videoToolStatus?(sub: VideoToolSubmission, ctx: AdapterContext): Promise<VideoToolStatus>;
1102
+ videoToolResult?(sub: VideoToolSubmission, ctx: AdapterContext, webhook?: FalWebhookBody): Promise<VideoToolResult>;
1103
+ cancelVideoTool?(sub: VideoToolSubmission, ctx: AdapterContext): Promise<boolean>;
950
1104
  /**
951
1105
  * Turn a media reference into an AI SDK file part the provider's language
952
1106
  * model accepts. Google uploads large videos through the Files API.
@@ -1163,6 +1317,21 @@ interface ModelKit extends TextMethods {
1163
1317
  prepareMediaPart(modelId: string, ref: MediaRef, mediaType: string, call?: CallContext): Promise<MediaPart>;
1164
1318
  /** Which options a caller may show for this model. */
1165
1319
  describe(modelId: string): CatalogModel;
1320
+ /**
1321
+ * Start a video-tool job (`type: "video-tool"`) and return without waiting. Store the
1322
+ * submission; the provider posts to `call.webhookUrl` when the job ends.
1323
+ */
1324
+ submitVideoTool(req: VideoToolRequest, call?: VideoToolCallContext): Promise<VideoToolSubmission>;
1325
+ videoToolStatus(sub: VideoToolSubmission, call?: CallContext): Promise<VideoToolStatus>;
1326
+ /**
1327
+ * The finished output. Pass the verified webhook body when there is one; without it the
1328
+ * kit fetches the provider's stored result. Emits the usage event.
1329
+ */
1330
+ videoToolResult(sub: VideoToolSubmission, call?: CallContext & {
1331
+ webhook?: FalWebhookBody;
1332
+ }): Promise<VideoToolResult>;
1333
+ /** True when the provider accepted the cancel, false when the job had already ended. */
1334
+ cancelVideoTool(sub: VideoToolSubmission, call?: CallContext): Promise<boolean>;
1166
1335
  }
1167
1336
  interface LanguageModelHandle {
1168
1337
  model: LanguageModelV3;
@@ -1209,6 +1378,29 @@ declare const xaiVideoAdapter: Adapter;
1209
1378
 
1210
1379
  declare const DEFAULT_ADAPTERS: Record<AdapterId, Adapter>;
1211
1380
 
1381
+ /** A video-tool row's constraints, or undefined when the row has none or they are invalid. */
1382
+ declare function videoToolConstraints(row: CatalogModel): VideoToolConstraints | undefined;
1383
+ /** The pricing tier a frame lands in, by its short edge. */
1384
+ declare function resolutionTier(width: number, height: number): VideoResolution;
1385
+ type VideoToolPlan = {
1386
+ ok: true;
1387
+ output: VideoToolOutputSpec;
1388
+ } | {
1389
+ ok: false;
1390
+ error: string;
1391
+ };
1392
+ /**
1393
+ * What a video-tool request produces, checked against the row. Pure: callers use it to
1394
+ * validate and price before submitting, and the adapter uses it to build the usage event.
1395
+ */
1396
+ declare function planVideoTool(row: CatalogModel, req: Omit<VideoToolRequest, "model">): VideoToolPlan;
1397
+
1398
+ /**
1399
+ * Topaz Labs video tools on fal. `providerOptions.fal.model` names the Topaz model the
1400
+ * endpoint runs; the adapter sends it as `model`. Exposed on cowork only (Creative Studio).
1401
+ */
1402
+ declare const VIDEO_TOOL_MODELS: CatalogModel[];
1403
+
1212
1404
  /**
1213
1405
  * All adapters registered. Keys default to process.env (pro = bare names,
1214
1406
  * enterprise = ENTERPRISE_ prefix, sloosh = SLOOSH_ prefix) when `keys` is omitted.
@@ -1244,4 +1436,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
1244
1436
  /** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
1245
1437
  declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
1246
1438
 
1247
- export { ADAPTER_IDS, ADAPTER_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, 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 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 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, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type Warning, adapterServesType, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isInputSpecKey, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, missingTierKeys, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, withRetry, xaiVideoAdapter };
1439
+ export { ADAPTER_IDS, ADAPTER_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, 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 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, 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
@@ -42,7 +42,13 @@ interface UpscaleOptions {
42
42
  faceEnhancementCreativity?: number;
43
43
  faceEnhancementStrength?: number;
44
44
  }
45
- type ModelType = "text" | "image" | "video" | "audio" | "upscale" | "bg-remove";
45
+ type ModelType = "text" | "image" | "video" | "audio" | "upscale" | "bg-remove"
46
+ /** Video in, video out, no prompt: upscale, frame interpolation, SDR to HDR. */
47
+ | "video-tool";
48
+ /** What a `video-tool` row does to its source clip. */
49
+ type VideoToolKind = "upscale" | "interpolate" | "hdr";
50
+ /** Container/codec a video-tool row can write. */
51
+ type VideoToolOutputFormat = "h265" | "prores";
46
52
  type Lifecycle = "active" | "deprecated" | "retired";
47
53
  type Surface = "cowork" | "space_builder";
48
54
  /** @deprecated use Surface[] */
@@ -133,6 +139,61 @@ interface VideoCallOptions extends Omit<VideoRequest, "model"> {
133
139
  /** Reaches the provider only for AI SDK model instances; catalog rows carry their own. */
134
140
  providerOptions?: ProviderOptions;
135
141
  }
142
+ /** What the caller measured about a video-tool source; the kit never measures. */
143
+ interface VideoToolSource {
144
+ url: string;
145
+ width: number;
146
+ height: number;
147
+ durationSeconds: number;
148
+ fps?: number;
149
+ }
150
+ interface VideoToolRequest {
151
+ model: string;
152
+ source: VideoToolSource;
153
+ /** Upscale rows. */
154
+ upscaleFactor?: number;
155
+ /** Interpolate rows. */
156
+ targetFps?: number;
157
+ /** HDR rows; the row's first `outputFormats` entry when unset. */
158
+ outputFormat?: VideoToolOutputFormat;
159
+ }
160
+ /** The output a video-tool request will produce, from the request alone. */
161
+ interface VideoToolOutputSpec {
162
+ width: number;
163
+ height: number;
164
+ durationSeconds: number;
165
+ fps?: number;
166
+ resolution: VideoResolution;
167
+ format: "h264" | VideoToolOutputFormat;
168
+ }
169
+ interface VideoToolCallContext extends CallContext {
170
+ /** Where the provider posts the result when the job ends. */
171
+ webhookUrl?: string;
172
+ }
173
+ /**
174
+ * A submitted video-tool job. Plain JSON so a caller can store it and pass it back
175
+ * to `videoToolStatus` / `videoToolResult` / `cancelVideoTool` from another process.
176
+ */
177
+ interface VideoToolSubmission {
178
+ model: string;
179
+ provider: "fal";
180
+ requestId: string;
181
+ statusUrl: string;
182
+ responseUrl: string;
183
+ cancelUrl: string;
184
+ output: VideoToolOutputSpec;
185
+ }
186
+ type VideoToolStatus = "queued" | "running" | "completed";
187
+ interface VideoToolResult {
188
+ video: {
189
+ url: string;
190
+ mime?: string;
191
+ bytes?: number;
192
+ };
193
+ output: VideoToolOutputSpec;
194
+ usage: UsageEvent;
195
+ raw?: unknown;
196
+ }
136
197
  interface AudioRequest {
137
198
  model: string;
138
199
  prompt: string;
@@ -193,6 +254,33 @@ interface ReferenceLimits {
193
254
  audioOnly?: boolean;
194
255
  /** Per-video length caps (min/max each) and combined total for reference videos. */
195
256
  videoSeconds?: VideoSecondsLimits;
257
+ /** Per-clip length caps (min/max each) and combined total for reference audio, in seconds. */
258
+ audioSeconds?: {
259
+ min?: number;
260
+ max?: number;
261
+ total?: number;
262
+ };
263
+ /** File types the provider takes for reference audio, as lowercase extensions. */
264
+ audioFormats?: string[];
265
+ /** Largest reference audio file the provider takes, in bytes. */
266
+ audioMaxBytes?: number;
267
+ }
268
+ interface VideoToolConstraints {
269
+ kind: VideoToolKind;
270
+ /** Upscale: allowed factor range. */
271
+ upscaleFactor?: {
272
+ min: number;
273
+ max: number;
274
+ };
275
+ /** Upscale: the output's long edge may not pass this, in pixels. */
276
+ maxOutputLongEdge?: number;
277
+ /** Interpolate: allowed target frame rate range. */
278
+ fps?: {
279
+ min: number;
280
+ max: number;
281
+ };
282
+ /** HDR: the formats the row writes, first is the default. */
283
+ outputFormats?: VideoToolOutputFormat[];
196
284
  }
197
285
  /** Whether a video row's output has sound: always, switchable (`supports: generateAudio`), or silent. */
198
286
  type AudioOutput = "always" | "optional" | "never";
@@ -235,7 +323,12 @@ interface ModelConstraints {
235
323
  extension?: {
236
324
  segmentSeconds: number;
237
325
  maxTotalSeconds: number;
326
+ /** `joined` (absent): the provider returns the whole clip so far (Omni).
327
+ * `new`: it returns only the added footage and the caller joins it (Seedance). */
328
+ returns?: "new" | "joined";
238
329
  };
330
+ /** What a `video-tool` row accepts. Read it through `videoToolConstraints(row)`. */
331
+ tool?: VideoToolConstraints;
239
332
  /** Whether the output has sound. Read it through `outputAudio(row)`, which tolerates bad data. */
240
333
  audio?: AudioOutput;
241
334
  /** Prompt conventions. Read them through `promptConventions(row)`, which fills the default. */
@@ -296,6 +389,11 @@ interface CatalogDisplay {
296
389
  interface CatalogCapabilities {
297
390
  /** Video rows: takes an existing video as the thing to edit or extend. */
298
391
  acceptsSourceVideo?: boolean;
392
+ /**
393
+ * Video rows: offered for prompt-driven edits of a source clip (`taskType: "edit"`). Absent
394
+ * means the caller falls back to `acceptsSourceVideo`; `false` opts a row out.
395
+ */
396
+ videoEdit?: boolean;
299
397
  /** Video rows: first/last frames and reference images are mutually exclusive inputs. */
300
398
  framesExcludeReferences?: boolean;
301
399
  /** Video rows: a last frame is accepted only together with a first frame. */
@@ -414,6 +512,8 @@ interface UsageEvent {
414
512
  imageQuality?: ImageQuality;
415
513
  resolution?: VideoResolution;
416
514
  durationSeconds?: number;
515
+ /** Output frame rate (video-tool rows price by output frames). */
516
+ fps?: number;
417
517
  inputTokens?: number;
418
518
  outputTokens?: number;
419
519
  reportedCostUsd?: number;
@@ -580,6 +680,7 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
580
680
  audio: "audio";
581
681
  upscale: "upscale";
582
682
  "bg-remove": "bg-remove";
683
+ "video-tool": "video-tool";
583
684
  }>;
584
685
  adapter: z.ZodEnum<{
585
686
  "ai-sdk-text": "ai-sdk-text";
@@ -652,6 +753,13 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
652
753
  total: z.ZodOptional<z.ZodNumber>;
653
754
  editMin: z.ZodOptional<z.ZodNumber>;
654
755
  }, z.core.$loose>>;
756
+ audioSeconds: z.ZodOptional<z.ZodObject<{
757
+ min: z.ZodOptional<z.ZodNumber>;
758
+ max: z.ZodOptional<z.ZodNumber>;
759
+ total: z.ZodOptional<z.ZodNumber>;
760
+ }, z.core.$loose>>;
761
+ audioFormats: z.ZodOptional<z.ZodArray<z.ZodString>>;
762
+ audioMaxBytes: z.ZodOptional<z.ZodNumber>;
655
763
  }, z.core.$loose>>;
656
764
  requires: z.ZodOptional<z.ZodArray<z.ZodEnum<{
657
765
  references: "references";
@@ -691,6 +799,30 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
691
799
  extension: z.ZodOptional<z.ZodObject<{
692
800
  segmentSeconds: z.ZodNumber;
693
801
  maxTotalSeconds: z.ZodNumber;
802
+ returns: z.ZodOptional<z.ZodEnum<{
803
+ new: "new";
804
+ joined: "joined";
805
+ }>>;
806
+ }, z.core.$loose>>;
807
+ tool: z.ZodOptional<z.ZodObject<{
808
+ kind: z.ZodEnum<{
809
+ upscale: "upscale";
810
+ interpolate: "interpolate";
811
+ hdr: "hdr";
812
+ }>;
813
+ upscaleFactor: z.ZodOptional<z.ZodObject<{
814
+ min: z.ZodNumber;
815
+ max: z.ZodNumber;
816
+ }, z.core.$loose>>;
817
+ maxOutputLongEdge: z.ZodOptional<z.ZodNumber>;
818
+ fps: z.ZodOptional<z.ZodObject<{
819
+ min: z.ZodNumber;
820
+ max: z.ZodNumber;
821
+ }, z.core.$loose>>;
822
+ outputFormats: z.ZodOptional<z.ZodArray<z.ZodEnum<{
823
+ h265: "h265";
824
+ prores: "prores";
825
+ }>>>;
694
826
  }, z.core.$loose>>;
695
827
  audio: z.ZodOptional<z.ZodUnknown>;
696
828
  prompt: z.ZodOptional<z.ZodUnknown>;
@@ -879,6 +1011,7 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
879
1011
  }, z.core.$loose>>;
880
1012
  capabilities: z.ZodOptional<z.ZodObject<{
881
1013
  acceptsSourceVideo: z.ZodOptional<z.ZodBoolean>;
1014
+ videoEdit: z.ZodOptional<z.ZodBoolean>;
882
1015
  framesExcludeReferences: z.ZodOptional<z.ZodBoolean>;
883
1016
  lastFrameRequiresFirstFrame: z.ZodOptional<z.ZodBoolean>;
884
1017
  reasoning: z.ZodOptional<z.ZodBoolean>;
@@ -923,6 +1056,20 @@ declare function validateInputSpec(raw: ProviderOptionValue, row: ValidateRow):
923
1056
  declare const ANTHROPIC_TRANSPORTS: readonly ["direct", "bedrock"];
924
1057
  type AnthropicTransport = (typeof ANTHROPIC_TRANSPORTS)[number];
925
1058
 
1059
+ /** fal's webhook body (https://fal.ai/docs/model-apis/model-endpoints/webhooks). */
1060
+ declare const falWebhookBodySchema: z.ZodObject<{
1061
+ request_id: z.ZodString;
1062
+ gateway_request_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1063
+ status: z.ZodEnum<{
1064
+ OK: "OK";
1065
+ ERROR: "ERROR";
1066
+ }>;
1067
+ payload: z.ZodOptional<z.ZodNullable<z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>;
1068
+ error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1069
+ payload_error: z.ZodOptional<z.ZodNullable<z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>;
1070
+ }, z.core.$strip>;
1071
+ type FalWebhookBody = z.infer<typeof falWebhookBodySchema>;
1072
+
926
1073
  /** Everything an adapter needs for one call. Resolved by the core before dispatch. */
927
1074
  interface AdapterContext {
928
1075
  model: CatalogModel;
@@ -947,6 +1094,13 @@ interface Adapter {
947
1094
  generateImage?(req: ImageRequest, ctx: AdapterContext): Promise<ImageResult>;
948
1095
  generateVideo?(req: VideoRequest, ctx: AdapterContext): Promise<VideoJob>;
949
1096
  generateAudio?(req: AudioRequest, ctx: AdapterContext): Promise<AudioResult>;
1097
+ /** Video tools run as provider jobs the caller tracks; see ModelKit.submitVideoTool. */
1098
+ submitVideoTool?(req: VideoToolRequest, ctx: AdapterContext, opts: {
1099
+ webhookUrl?: string;
1100
+ }): Promise<VideoToolSubmission>;
1101
+ videoToolStatus?(sub: VideoToolSubmission, ctx: AdapterContext): Promise<VideoToolStatus>;
1102
+ videoToolResult?(sub: VideoToolSubmission, ctx: AdapterContext, webhook?: FalWebhookBody): Promise<VideoToolResult>;
1103
+ cancelVideoTool?(sub: VideoToolSubmission, ctx: AdapterContext): Promise<boolean>;
950
1104
  /**
951
1105
  * Turn a media reference into an AI SDK file part the provider's language
952
1106
  * model accepts. Google uploads large videos through the Files API.
@@ -1163,6 +1317,21 @@ interface ModelKit extends TextMethods {
1163
1317
  prepareMediaPart(modelId: string, ref: MediaRef, mediaType: string, call?: CallContext): Promise<MediaPart>;
1164
1318
  /** Which options a caller may show for this model. */
1165
1319
  describe(modelId: string): CatalogModel;
1320
+ /**
1321
+ * Start a video-tool job (`type: "video-tool"`) and return without waiting. Store the
1322
+ * submission; the provider posts to `call.webhookUrl` when the job ends.
1323
+ */
1324
+ submitVideoTool(req: VideoToolRequest, call?: VideoToolCallContext): Promise<VideoToolSubmission>;
1325
+ videoToolStatus(sub: VideoToolSubmission, call?: CallContext): Promise<VideoToolStatus>;
1326
+ /**
1327
+ * The finished output. Pass the verified webhook body when there is one; without it the
1328
+ * kit fetches the provider's stored result. Emits the usage event.
1329
+ */
1330
+ videoToolResult(sub: VideoToolSubmission, call?: CallContext & {
1331
+ webhook?: FalWebhookBody;
1332
+ }): Promise<VideoToolResult>;
1333
+ /** True when the provider accepted the cancel, false when the job had already ended. */
1334
+ cancelVideoTool(sub: VideoToolSubmission, call?: CallContext): Promise<boolean>;
1166
1335
  }
1167
1336
  interface LanguageModelHandle {
1168
1337
  model: LanguageModelV3;
@@ -1209,6 +1378,29 @@ declare const xaiVideoAdapter: Adapter;
1209
1378
 
1210
1379
  declare const DEFAULT_ADAPTERS: Record<AdapterId, Adapter>;
1211
1380
 
1381
+ /** A video-tool row's constraints, or undefined when the row has none or they are invalid. */
1382
+ declare function videoToolConstraints(row: CatalogModel): VideoToolConstraints | undefined;
1383
+ /** The pricing tier a frame lands in, by its short edge. */
1384
+ declare function resolutionTier(width: number, height: number): VideoResolution;
1385
+ type VideoToolPlan = {
1386
+ ok: true;
1387
+ output: VideoToolOutputSpec;
1388
+ } | {
1389
+ ok: false;
1390
+ error: string;
1391
+ };
1392
+ /**
1393
+ * What a video-tool request produces, checked against the row. Pure: callers use it to
1394
+ * validate and price before submitting, and the adapter uses it to build the usage event.
1395
+ */
1396
+ declare function planVideoTool(row: CatalogModel, req: Omit<VideoToolRequest, "model">): VideoToolPlan;
1397
+
1398
+ /**
1399
+ * Topaz Labs video tools on fal. `providerOptions.fal.model` names the Topaz model the
1400
+ * endpoint runs; the adapter sends it as `model`. Exposed on cowork only (Creative Studio).
1401
+ */
1402
+ declare const VIDEO_TOOL_MODELS: CatalogModel[];
1403
+
1212
1404
  /**
1213
1405
  * All adapters registered. Keys default to process.env (pro = bare names,
1214
1406
  * enterprise = ENTERPRISE_ prefix, sloosh = SLOOSH_ prefix) when `keys` is omitted.
@@ -1244,4 +1436,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
1244
1436
  /** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
1245
1437
  declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
1246
1438
 
1247
- export { ADAPTER_IDS, ADAPTER_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, 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 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 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, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type Warning, adapterServesType, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isInputSpecKey, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, missingTierKeys, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, withRetry, xaiVideoAdapter };
1439
+ export { ADAPTER_IDS, ADAPTER_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, 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 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, 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 };