@shop-os/modelkit 0.2.9 → 0.2.11

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.
@@ -103,6 +103,8 @@ interface VideoRequest {
103
103
  watermark?: boolean;
104
104
  /** Provider-side safety checker toggle (fal MiniMax). Provider default when unset. */
105
105
  safetyChecker?: boolean;
106
+ /** Seedance omni-reference subtask hint. `edit` forces duration -1 and adaptive ratio. */
107
+ taskType?: "reference" | "edit" | "extend";
106
108
  mode?: "standard" | "pro";
107
109
  }
108
110
  /**
@@ -154,9 +156,11 @@ interface MediaPart {
154
156
  cleanup?: () => Promise<void>;
155
157
  }
156
158
  type RequiredInput = "firstFrame" | "sourceVideo" | "references";
157
- type SupportedOption = "seed" | "quality" | "negativePrompt" | "cfgScale" | "generateAudio" | "promptExpansion" | "lastFrame" | "count" | "outputFormat" | "scaleFactor" | "safetySettings" | "temperature" | "upscale" | "watermark" | "safetyChecker" | "instrumental";
159
+ type SupportedOption = "seed" | "quality" | "negativePrompt" | "cfgScale" | "generateAudio" | "promptExpansion" | "lastFrame" | "count" | "outputFormat" | "scaleFactor" | "safetySettings" | "temperature" | "upscale" | "watermark" | "safetyChecker" | "taskType" | "instrumental";
158
160
  interface ReferenceLimits {
159
161
  images?: number;
162
+ /** Lower image cap when a reference video is also sent (Kling V3 Omni: 7 → 4). */
163
+ imagesWithVideo?: number;
160
164
  videos?: number;
161
165
  audios?: number;
162
166
  total?: number;
@@ -364,17 +368,36 @@ type ProviderKeys = Partial<Record<ProviderKeyName, string>> & {
364
368
  higgsfieldSecret?: string;
365
369
  /** Bedrock runtime credentials for Anthropic models when routing.anthropic = "bedrock". */
366
370
  aws?: {
367
- accessKeyId: string;
368
- secretAccessKey: string;
371
+ /** Bedrock region. Must serve the chosen inference profile (us-east-1 for "us"). */
369
372
  region: string;
373
+ accessKeyId?: string;
374
+ secretAccessKey?: string;
370
375
  sessionToken?: string;
376
+ /** Bedrock API key (AWS_BEARER_TOKEN_BEDROCK). Wins over SigV4. */
377
+ apiKey?: string;
378
+ /** For ECS task roles and other chains. The kit has no AWS SDK dependency; the app passes e.g. defaultProvider(). */
379
+ credentialProvider?: () => PromiseLike<{
380
+ accessKeyId: string;
381
+ secretAccessKey: string;
382
+ sessionToken?: string;
383
+ }>;
371
384
  };
372
385
  };
386
+ /** Key names a call can require, including the Bedrock credentials object. */
387
+ type RequiredKeyName = ProviderKeyName | "aws";
388
+ /** True when region is set AND (apiKey OR credentialProvider OR both static keys). */
389
+ declare function hasAwsCredentials(aws: ProviderKeys["aws"]): aws is NonNullable<ProviderKeys["aws"]>;
373
390
  interface Routing {
374
391
  /** Text models: direct provider or the Cloudflare AI Gateway. */
375
392
  text?: "direct" | "cloudflare";
376
- /** Anthropic chat via Bedrock (us. prefixed ids) or the Anthropic API. */
393
+ /**
394
+ * Anthropic chat via Bedrock or the Anthropic API. Default "direct". A row's
395
+ * `providerOptions.modelkit.transport` wins over this. When the chosen transport has
396
+ * no credentials and the other one has, the kit uses the other one and warns.
397
+ */
377
398
  anthropic?: "direct" | "bedrock";
399
+ /** Inference profile prefix for Bedrock ids. Default "us". */
400
+ bedrockProfile?: "us" | "global" | "eu" | "jp" | "au";
378
401
  /** fal from geo-blocked regions goes through the Cloudflare passthrough. */
379
402
  fal?: "direct" | "cloudflare-passthrough";
380
403
  cloudflare?: {
@@ -562,4 +585,4 @@ declare function isModelKitError(err: unknown): err is ModelKitError;
562
585
  /** Resolve caller options against a catalog row, dispatching on `model.type`. */
563
586
  declare function resolveOptions(model: CatalogModel, request: ImageRequest | VideoRequest | AudioRequest, onUnsupported?: OnUnsupported): ResolveResult<ImageRequest | VideoRequest | AudioRequest>;
564
587
 
565
- export { ADAPTER_IDS, type AdapterEndpoints, type AdapterId, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, type CatalogOrigin, CatalogSchema, type CatalogSource, type Exposure, ExposureSchema, type GeneratedImage, IMAGE_MODELS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, type JsonPrimitive, type JsonValue, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, OTHER_MODELS, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type ReferenceLimits, type RequiredInput, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, TEXT_MODELS, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type Warning, compareCatalogOrder, isListed, isListedOn, isModelKitError, liveCatalog, liveState, nearestAspectRatio, normalizeExposure, primeCatalog, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveOptions, resolveVideoOptions, sortCatalogRows };
588
+ export { ADAPTER_IDS, type AdapterEndpoints, type AdapterId, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, type CatalogOrigin, CatalogSchema, type CatalogSource, type Exposure, ExposureSchema, type GeneratedImage, IMAGE_MODELS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, type JsonPrimitive, type JsonValue, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, OTHER_MODELS, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type ReferenceLimits, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, TEXT_MODELS, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type Warning, compareCatalogOrder, hasAwsCredentials, isListed, isListedOn, isModelKitError, liveCatalog, liveState, nearestAspectRatio, normalizeExposure, primeCatalog, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveOptions, resolveVideoOptions, sortCatalogRows };
package/dist/catalog.d.ts CHANGED
@@ -103,6 +103,8 @@ interface VideoRequest {
103
103
  watermark?: boolean;
104
104
  /** Provider-side safety checker toggle (fal MiniMax). Provider default when unset. */
105
105
  safetyChecker?: boolean;
106
+ /** Seedance omni-reference subtask hint. `edit` forces duration -1 and adaptive ratio. */
107
+ taskType?: "reference" | "edit" | "extend";
106
108
  mode?: "standard" | "pro";
107
109
  }
108
110
  /**
@@ -154,9 +156,11 @@ interface MediaPart {
154
156
  cleanup?: () => Promise<void>;
155
157
  }
156
158
  type RequiredInput = "firstFrame" | "sourceVideo" | "references";
157
- type SupportedOption = "seed" | "quality" | "negativePrompt" | "cfgScale" | "generateAudio" | "promptExpansion" | "lastFrame" | "count" | "outputFormat" | "scaleFactor" | "safetySettings" | "temperature" | "upscale" | "watermark" | "safetyChecker" | "instrumental";
159
+ type SupportedOption = "seed" | "quality" | "negativePrompt" | "cfgScale" | "generateAudio" | "promptExpansion" | "lastFrame" | "count" | "outputFormat" | "scaleFactor" | "safetySettings" | "temperature" | "upscale" | "watermark" | "safetyChecker" | "taskType" | "instrumental";
158
160
  interface ReferenceLimits {
159
161
  images?: number;
162
+ /** Lower image cap when a reference video is also sent (Kling V3 Omni: 7 → 4). */
163
+ imagesWithVideo?: number;
160
164
  videos?: number;
161
165
  audios?: number;
162
166
  total?: number;
@@ -364,17 +368,36 @@ type ProviderKeys = Partial<Record<ProviderKeyName, string>> & {
364
368
  higgsfieldSecret?: string;
365
369
  /** Bedrock runtime credentials for Anthropic models when routing.anthropic = "bedrock". */
366
370
  aws?: {
367
- accessKeyId: string;
368
- secretAccessKey: string;
371
+ /** Bedrock region. Must serve the chosen inference profile (us-east-1 for "us"). */
369
372
  region: string;
373
+ accessKeyId?: string;
374
+ secretAccessKey?: string;
370
375
  sessionToken?: string;
376
+ /** Bedrock API key (AWS_BEARER_TOKEN_BEDROCK). Wins over SigV4. */
377
+ apiKey?: string;
378
+ /** For ECS task roles and other chains. The kit has no AWS SDK dependency; the app passes e.g. defaultProvider(). */
379
+ credentialProvider?: () => PromiseLike<{
380
+ accessKeyId: string;
381
+ secretAccessKey: string;
382
+ sessionToken?: string;
383
+ }>;
371
384
  };
372
385
  };
386
+ /** Key names a call can require, including the Bedrock credentials object. */
387
+ type RequiredKeyName = ProviderKeyName | "aws";
388
+ /** True when region is set AND (apiKey OR credentialProvider OR both static keys). */
389
+ declare function hasAwsCredentials(aws: ProviderKeys["aws"]): aws is NonNullable<ProviderKeys["aws"]>;
373
390
  interface Routing {
374
391
  /** Text models: direct provider or the Cloudflare AI Gateway. */
375
392
  text?: "direct" | "cloudflare";
376
- /** Anthropic chat via Bedrock (us. prefixed ids) or the Anthropic API. */
393
+ /**
394
+ * Anthropic chat via Bedrock or the Anthropic API. Default "direct". A row's
395
+ * `providerOptions.modelkit.transport` wins over this. When the chosen transport has
396
+ * no credentials and the other one has, the kit uses the other one and warns.
397
+ */
377
398
  anthropic?: "direct" | "bedrock";
399
+ /** Inference profile prefix for Bedrock ids. Default "us". */
400
+ bedrockProfile?: "us" | "global" | "eu" | "jp" | "au";
378
401
  /** fal from geo-blocked regions goes through the Cloudflare passthrough. */
379
402
  fal?: "direct" | "cloudflare-passthrough";
380
403
  cloudflare?: {
@@ -562,4 +585,4 @@ declare function isModelKitError(err: unknown): err is ModelKitError;
562
585
  /** Resolve caller options against a catalog row, dispatching on `model.type`. */
563
586
  declare function resolveOptions(model: CatalogModel, request: ImageRequest | VideoRequest | AudioRequest, onUnsupported?: OnUnsupported): ResolveResult<ImageRequest | VideoRequest | AudioRequest>;
564
587
 
565
- export { ADAPTER_IDS, type AdapterEndpoints, type AdapterId, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, type CatalogOrigin, CatalogSchema, type CatalogSource, type Exposure, ExposureSchema, type GeneratedImage, IMAGE_MODELS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, type JsonPrimitive, type JsonValue, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, OTHER_MODELS, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type ReferenceLimits, type RequiredInput, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, TEXT_MODELS, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type Warning, compareCatalogOrder, isListed, isListedOn, isModelKitError, liveCatalog, liveState, nearestAspectRatio, normalizeExposure, primeCatalog, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveOptions, resolveVideoOptions, sortCatalogRows };
588
+ export { ADAPTER_IDS, type AdapterEndpoints, type AdapterId, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, type CatalogOrigin, CatalogSchema, type CatalogSource, type Exposure, ExposureSchema, type GeneratedImage, IMAGE_MODELS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, type JsonPrimitive, type JsonValue, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, OTHER_MODELS, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type ReferenceLimits, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, TEXT_MODELS, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type Warning, compareCatalogOrder, hasAwsCredentials, isListed, isListedOn, isModelKitError, liveCatalog, liveState, nearestAspectRatio, normalizeExposure, primeCatalog, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveOptions, resolveVideoOptions, sortCatalogRows };
package/dist/catalog.js CHANGED
@@ -1467,6 +1467,7 @@ var VIDEO_MODELS = [
1467
1467
  },
1468
1468
  {
1469
1469
  // generateAudio defaults to false here (trigger-workflows); Space Builder defaults it to true.
1470
+ // omni_reference_task_type edit/extend: adaptive ratio, edit sends duration -1.
1470
1471
  id: "seedance-2.5",
1471
1472
  aliases: ["seedance-2-5", "dreamina-seedance-2-5-260628"],
1472
1473
  label: "Seedance 2.5",
@@ -1481,7 +1482,7 @@ var VIDEO_MODELS = [
1481
1482
  durations: { min: 4, max: 30 },
1482
1483
  references: { images: 30, videos: 10, audios: 10 },
1483
1484
  ratioIgnoredWith: ["firstFrame", "sourceVideo"],
1484
- supports: ["generateAudio", "seed", "lastFrame", "watermark"]
1485
+ supports: ["generateAudio", "seed", "lastFrame", "watermark", "taskType"]
1485
1486
  },
1486
1487
  defaults: {
1487
1488
  durationSeconds: 5,
@@ -1590,6 +1591,9 @@ var VIDEO_MODELS = [
1590
1591
  },
1591
1592
  {
1592
1593
  // mode standard/pro selects 720p/1080p; the endpoint takes no separate resolution.
1594
+ // Replicate: "Max 7 [images] without video, 4 with video"; 4K does not support
1595
+ // reference_video. No `videos` limit yet: the adapter sends no reference video,
1596
+ // so `imagesWithVideo` stays dormant until one is wired through.
1593
1597
  id: "kling-v3-omni-video",
1594
1598
  aliases: ["kwaivgi/kling-v3-omni-video", "kling-v3-omni"],
1595
1599
  label: "Kling V3 Omni",
@@ -1602,7 +1606,7 @@ var VIDEO_MODELS = [
1602
1606
  aspectRatios: [...KLING_RATIOS],
1603
1607
  resolutions: ["720p", "1080p"],
1604
1608
  durations: { min: 3, max: 15 },
1605
- references: { images: 7 },
1609
+ references: { images: 7, imagesWithVideo: 4 },
1606
1610
  supports: ["generateAudio", "lastFrame"]
1607
1611
  },
1608
1612
  defaults: { durationSeconds: 5, aspectRatio: "16:9", generateAudio: false, mode: "pro" },
@@ -1878,6 +1882,7 @@ var SupportedOptionSchema = z.enum([
1878
1882
  "upscale",
1879
1883
  "watermark",
1880
1884
  "safetyChecker",
1885
+ "taskType",
1881
1886
  "instrumental"
1882
1887
  ]);
1883
1888
  var UsageUnitSchema = z.enum([
@@ -1900,6 +1905,7 @@ var ProviderOptionValueSchema = z.lazy(
1900
1905
  var ProviderOptionsSchema = z.record(z.string(), z.record(z.string(), ProviderOptionValueSchema));
1901
1906
  var ReferenceLimitsSchema = z.looseObject({
1902
1907
  images: z.number().optional(),
1908
+ imagesWithVideo: z.number().optional(),
1903
1909
  videos: z.number().optional(),
1904
1910
  audios: z.number().optional(),
1905
1911
  total: z.number().optional(),
@@ -1961,6 +1967,7 @@ var DefaultsSchema = z.looseObject({
1961
1967
  promptExpansion: z.enum(["fast", "balanced", "quality"]).optional(),
1962
1968
  watermark: z.boolean().optional(),
1963
1969
  safetyChecker: z.boolean().optional(),
1970
+ taskType: z.enum(["reference", "edit", "extend"]).optional(),
1964
1971
  mode: z.enum(["standard", "pro"]).optional(),
1965
1972
  instrumental: z.boolean().optional()
1966
1973
  });
@@ -2027,7 +2034,18 @@ var CatalogModelSchemaBase = z.looseObject({
2027
2034
  });
2028
2035
  }
2029
2036
  });
2030
- var CatalogModelSchema = CatalogModelSchemaBase;
2037
+ var CatalogModelSchema = CatalogModelSchemaBase.superRefine(
2038
+ (row, ctx) => {
2039
+ const transport = row.providerOptions?.["modelkit"]?.["transport"];
2040
+ if (transport !== void 0 && transport !== "direct" && transport !== "bedrock") {
2041
+ ctx.addIssue({
2042
+ code: "custom",
2043
+ path: ["providerOptions", "modelkit", "transport"],
2044
+ message: 'transport must be "direct" or "bedrock"'
2045
+ });
2046
+ }
2047
+ }
2048
+ );
2031
2049
  var CatalogSchema = z.array(CatalogModelSchemaBase).superRefine((rows, ctx) => {
2032
2050
  const seenIds = /* @__PURE__ */ new Map();
2033
2051
  rows.forEach((row, index) => {
@@ -2497,6 +2515,9 @@ function resolveVideoOptions(model, request, onUnsupported = "error") {
2497
2515
  model,
2498
2516
  warnings
2499
2517
  );
2518
+ if (limits.imagesWithVideo !== void 0 && (limits.videos ?? 0) > 0 && videos.length > 0 && images.length > limits.imagesWithVideo) {
2519
+ images = trim("referenceImages", images, limits.imagesWithVideo, model, warnings);
2520
+ }
2500
2521
  if (limits.total !== void 0) {
2501
2522
  let over = images.length + videos.length + audios.length - limits.total;
2502
2523
  if (over > 0) {
@@ -2530,7 +2551,8 @@ function resolveVideoOptions(model, request, onUnsupported = "error") {
2530
2551
  "promptExpansion",
2531
2552
  "lastFrame",
2532
2553
  "watermark",
2533
- "safetyChecker"
2554
+ "safetyChecker",
2555
+ "taskType"
2534
2556
  ]);
2535
2557
  return { request: merged, warnings };
2536
2558
  }