@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.
package/dist/index.d.cts CHANGED
@@ -106,6 +106,8 @@ interface VideoRequest {
106
106
  watermark?: boolean;
107
107
  /** Provider-side safety checker toggle (fal MiniMax). Provider default when unset. */
108
108
  safetyChecker?: boolean;
109
+ /** Seedance omni-reference subtask hint. `edit` forces duration -1 and adaptive ratio. */
110
+ taskType?: "reference" | "edit" | "extend";
109
111
  mode?: "standard" | "pro";
110
112
  }
111
113
  /**
@@ -157,9 +159,11 @@ interface MediaPart {
157
159
  cleanup?: () => Promise<void>;
158
160
  }
159
161
  type RequiredInput = "firstFrame" | "sourceVideo" | "references";
160
- type SupportedOption = "seed" | "quality" | "negativePrompt" | "cfgScale" | "generateAudio" | "promptExpansion" | "lastFrame" | "count" | "outputFormat" | "scaleFactor" | "safetySettings" | "temperature" | "upscale" | "watermark" | "safetyChecker" | "instrumental";
162
+ type SupportedOption = "seed" | "quality" | "negativePrompt" | "cfgScale" | "generateAudio" | "promptExpansion" | "lastFrame" | "count" | "outputFormat" | "scaleFactor" | "safetySettings" | "temperature" | "upscale" | "watermark" | "safetyChecker" | "taskType" | "instrumental";
161
163
  interface ReferenceLimits {
162
164
  images?: number;
165
+ /** Lower image cap when a reference video is also sent (Kling V3 Omni: 7 → 4). */
166
+ imagesWithVideo?: number;
163
167
  videos?: number;
164
168
  audios?: number;
165
169
  total?: number;
@@ -367,17 +371,36 @@ type ProviderKeys = Partial<Record<ProviderKeyName, string>> & {
367
371
  higgsfieldSecret?: string;
368
372
  /** Bedrock runtime credentials for Anthropic models when routing.anthropic = "bedrock". */
369
373
  aws?: {
370
- accessKeyId: string;
371
- secretAccessKey: string;
374
+ /** Bedrock region. Must serve the chosen inference profile (us-east-1 for "us"). */
372
375
  region: string;
376
+ accessKeyId?: string;
377
+ secretAccessKey?: string;
373
378
  sessionToken?: string;
379
+ /** Bedrock API key (AWS_BEARER_TOKEN_BEDROCK). Wins over SigV4. */
380
+ apiKey?: string;
381
+ /** For ECS task roles and other chains. The kit has no AWS SDK dependency; the app passes e.g. defaultProvider(). */
382
+ credentialProvider?: () => PromiseLike<{
383
+ accessKeyId: string;
384
+ secretAccessKey: string;
385
+ sessionToken?: string;
386
+ }>;
374
387
  };
375
388
  };
389
+ /** Key names a call can require, including the Bedrock credentials object. */
390
+ type RequiredKeyName = ProviderKeyName | "aws";
391
+ /** True when region is set AND (apiKey OR credentialProvider OR both static keys). */
392
+ declare function hasAwsCredentials(aws: ProviderKeys["aws"]): aws is NonNullable<ProviderKeys["aws"]>;
376
393
  interface Routing {
377
394
  /** Text models: direct provider or the Cloudflare AI Gateway. */
378
395
  text?: "direct" | "cloudflare";
379
- /** Anthropic chat via Bedrock (us. prefixed ids) or the Anthropic API. */
396
+ /**
397
+ * Anthropic chat via Bedrock or the Anthropic API. Default "direct". A row's
398
+ * `providerOptions.modelkit.transport` wins over this. When the chosen transport has
399
+ * no credentials and the other one has, the kit uses the other one and warns.
400
+ */
380
401
  anthropic?: "direct" | "bedrock";
402
+ /** Inference profile prefix for Bedrock ids. Default "us". */
403
+ bedrockProfile?: "us" | "global" | "eu" | "jp" | "au";
381
404
  /** fal from geo-blocked regions goes through the Cloudflare passthrough. */
382
405
  fal?: "direct" | "cloudflare-passthrough";
383
406
  cloudflare?: {
@@ -555,7 +578,7 @@ declare const ADAPTER_KEYS: Record<AdapterId, ProviderKeyName[]>;
555
578
  * enterprise tier; otherwise the pro keys are used. Mirrors trigger-workflows
556
579
  * enterprise-keys.ts, extended to Ark and Prodia.
557
580
  */
558
- declare function resolveKeys(config: ModelKitConfig, names: ProviderKeyName[], tier?: "pro" | "enterprise"): ProviderKeys;
581
+ declare function resolveKeys(config: ModelKitConfig, names: RequiredKeyName[], tier?: "pro" | "enterprise"): ProviderKeys;
559
582
  /** Build a ProviderKeys map from env with the given prefix ("" for pro, "ENTERPRISE_" for enterprise). */
560
583
  declare function keysFromEnv(env: NodeJS.ProcessEnv, prefix?: string): ProviderKeys;
561
584
 
@@ -584,11 +607,16 @@ declare function pollUntil<T>(check: () => Promise<T | undefined>, opts: {
584
607
  maxIntervalMs?: number;
585
608
  }): Promise<T>;
586
609
 
610
+ declare const ANTHROPIC_TRANSPORTS: readonly ["direct", "bedrock"];
611
+ type AnthropicTransport = (typeof ANTHROPIC_TRANSPORTS)[number];
612
+
587
613
  /** Everything an adapter needs for one call. Resolved by the core before dispatch. */
588
614
  interface AdapterContext {
589
615
  model: CatalogModel;
590
616
  keys: ProviderKeys;
591
617
  routing: Routing;
618
+ /** Resolved transport of an Anthropic text row (see anthropic-transport.ts); unset means direct. */
619
+ anthropicTransport?: AnthropicTransport;
592
620
  endpoints?: AdapterEndpoints;
593
621
  fetch: typeof fetch;
594
622
  logger: Pick<Console, "debug" | "info" | "warn" | "error">;
@@ -778,4 +806,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
778
806
  /** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
779
807
  declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
780
808
 
781
- export { ADAPTER_IDS, ADAPTER_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, 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 CatalogTextModel, DEFAULT_ADAPTERS, type DefaultObjectOutput, type Exposure, ExposureSchema, type GeneratedImage, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, 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 ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type ReferenceLimits, type RequiredInput, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, type TextMethods, type TextModelInstance, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type Warning, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, higgsfieldAdapter, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, withRetry, xaiVideoAdapter };
809
+ export { ADAPTER_IDS, ADAPTER_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, 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 CatalogTextModel, DEFAULT_ADAPTERS, type DefaultObjectOutput, type Exposure, ExposureSchema, type GeneratedImage, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, 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 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, type TextMethods, type TextModelInstance, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type Warning, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, withRetry, xaiVideoAdapter };
package/dist/index.d.ts CHANGED
@@ -106,6 +106,8 @@ interface VideoRequest {
106
106
  watermark?: boolean;
107
107
  /** Provider-side safety checker toggle (fal MiniMax). Provider default when unset. */
108
108
  safetyChecker?: boolean;
109
+ /** Seedance omni-reference subtask hint. `edit` forces duration -1 and adaptive ratio. */
110
+ taskType?: "reference" | "edit" | "extend";
109
111
  mode?: "standard" | "pro";
110
112
  }
111
113
  /**
@@ -157,9 +159,11 @@ interface MediaPart {
157
159
  cleanup?: () => Promise<void>;
158
160
  }
159
161
  type RequiredInput = "firstFrame" | "sourceVideo" | "references";
160
- type SupportedOption = "seed" | "quality" | "negativePrompt" | "cfgScale" | "generateAudio" | "promptExpansion" | "lastFrame" | "count" | "outputFormat" | "scaleFactor" | "safetySettings" | "temperature" | "upscale" | "watermark" | "safetyChecker" | "instrumental";
162
+ type SupportedOption = "seed" | "quality" | "negativePrompt" | "cfgScale" | "generateAudio" | "promptExpansion" | "lastFrame" | "count" | "outputFormat" | "scaleFactor" | "safetySettings" | "temperature" | "upscale" | "watermark" | "safetyChecker" | "taskType" | "instrumental";
161
163
  interface ReferenceLimits {
162
164
  images?: number;
165
+ /** Lower image cap when a reference video is also sent (Kling V3 Omni: 7 → 4). */
166
+ imagesWithVideo?: number;
163
167
  videos?: number;
164
168
  audios?: number;
165
169
  total?: number;
@@ -367,17 +371,36 @@ type ProviderKeys = Partial<Record<ProviderKeyName, string>> & {
367
371
  higgsfieldSecret?: string;
368
372
  /** Bedrock runtime credentials for Anthropic models when routing.anthropic = "bedrock". */
369
373
  aws?: {
370
- accessKeyId: string;
371
- secretAccessKey: string;
374
+ /** Bedrock region. Must serve the chosen inference profile (us-east-1 for "us"). */
372
375
  region: string;
376
+ accessKeyId?: string;
377
+ secretAccessKey?: string;
373
378
  sessionToken?: string;
379
+ /** Bedrock API key (AWS_BEARER_TOKEN_BEDROCK). Wins over SigV4. */
380
+ apiKey?: string;
381
+ /** For ECS task roles and other chains. The kit has no AWS SDK dependency; the app passes e.g. defaultProvider(). */
382
+ credentialProvider?: () => PromiseLike<{
383
+ accessKeyId: string;
384
+ secretAccessKey: string;
385
+ sessionToken?: string;
386
+ }>;
374
387
  };
375
388
  };
389
+ /** Key names a call can require, including the Bedrock credentials object. */
390
+ type RequiredKeyName = ProviderKeyName | "aws";
391
+ /** True when region is set AND (apiKey OR credentialProvider OR both static keys). */
392
+ declare function hasAwsCredentials(aws: ProviderKeys["aws"]): aws is NonNullable<ProviderKeys["aws"]>;
376
393
  interface Routing {
377
394
  /** Text models: direct provider or the Cloudflare AI Gateway. */
378
395
  text?: "direct" | "cloudflare";
379
- /** Anthropic chat via Bedrock (us. prefixed ids) or the Anthropic API. */
396
+ /**
397
+ * Anthropic chat via Bedrock or the Anthropic API. Default "direct". A row's
398
+ * `providerOptions.modelkit.transport` wins over this. When the chosen transport has
399
+ * no credentials and the other one has, the kit uses the other one and warns.
400
+ */
380
401
  anthropic?: "direct" | "bedrock";
402
+ /** Inference profile prefix for Bedrock ids. Default "us". */
403
+ bedrockProfile?: "us" | "global" | "eu" | "jp" | "au";
381
404
  /** fal from geo-blocked regions goes through the Cloudflare passthrough. */
382
405
  fal?: "direct" | "cloudflare-passthrough";
383
406
  cloudflare?: {
@@ -555,7 +578,7 @@ declare const ADAPTER_KEYS: Record<AdapterId, ProviderKeyName[]>;
555
578
  * enterprise tier; otherwise the pro keys are used. Mirrors trigger-workflows
556
579
  * enterprise-keys.ts, extended to Ark and Prodia.
557
580
  */
558
- declare function resolveKeys(config: ModelKitConfig, names: ProviderKeyName[], tier?: "pro" | "enterprise"): ProviderKeys;
581
+ declare function resolveKeys(config: ModelKitConfig, names: RequiredKeyName[], tier?: "pro" | "enterprise"): ProviderKeys;
559
582
  /** Build a ProviderKeys map from env with the given prefix ("" for pro, "ENTERPRISE_" for enterprise). */
560
583
  declare function keysFromEnv(env: NodeJS.ProcessEnv, prefix?: string): ProviderKeys;
561
584
 
@@ -584,11 +607,16 @@ declare function pollUntil<T>(check: () => Promise<T | undefined>, opts: {
584
607
  maxIntervalMs?: number;
585
608
  }): Promise<T>;
586
609
 
610
+ declare const ANTHROPIC_TRANSPORTS: readonly ["direct", "bedrock"];
611
+ type AnthropicTransport = (typeof ANTHROPIC_TRANSPORTS)[number];
612
+
587
613
  /** Everything an adapter needs for one call. Resolved by the core before dispatch. */
588
614
  interface AdapterContext {
589
615
  model: CatalogModel;
590
616
  keys: ProviderKeys;
591
617
  routing: Routing;
618
+ /** Resolved transport of an Anthropic text row (see anthropic-transport.ts); unset means direct. */
619
+ anthropicTransport?: AnthropicTransport;
592
620
  endpoints?: AdapterEndpoints;
593
621
  fetch: typeof fetch;
594
622
  logger: Pick<Console, "debug" | "info" | "warn" | "error">;
@@ -778,4 +806,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
778
806
  /** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
779
807
  declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
780
808
 
781
- export { ADAPTER_IDS, ADAPTER_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, 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 CatalogTextModel, DEFAULT_ADAPTERS, type DefaultObjectOutput, type Exposure, ExposureSchema, type GeneratedImage, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, 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 ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type ReferenceLimits, type RequiredInput, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, type TextMethods, type TextModelInstance, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type Warning, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, higgsfieldAdapter, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, withRetry, xaiVideoAdapter };
809
+ export { ADAPTER_IDS, ADAPTER_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, 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 CatalogTextModel, DEFAULT_ADAPTERS, type DefaultObjectOutput, type Exposure, ExposureSchema, type GeneratedImage, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, 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 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, type TextMethods, type TextModelInstance, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type Warning, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, withRetry, xaiVideoAdapter };