@shop-os/modelkit 0.2.24 → 0.2.26
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 +14 -0
- package/README.md +6 -3
- package/dist/catalog.cjs +18 -2
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.d.cts +6 -3
- package/dist/catalog.d.ts +6 -3
- package/dist/catalog.js +18 -2
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +54 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -7
- package/dist/index.d.ts +14 -7
- package/dist/index.js +52 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -440,6 +440,8 @@ type ProviderKeys = Partial<Record<ProviderKeyName, string>> & {
|
|
|
440
440
|
}>;
|
|
441
441
|
};
|
|
442
442
|
};
|
|
443
|
+
/** Which key set a call uses. Enterprise falls back to pro; sloosh never falls back. */
|
|
444
|
+
type KeyTier = "pro" | "enterprise" | "sloosh";
|
|
443
445
|
/** Key names a call can require, including the Bedrock credentials object. */
|
|
444
446
|
type RequiredKeyName = ProviderKeyName | "aws";
|
|
445
447
|
/** True when region is set AND (apiKey OR credentialProvider OR both static keys). */
|
|
@@ -471,6 +473,7 @@ interface ModelKitConfig {
|
|
|
471
473
|
keys: {
|
|
472
474
|
pro: ProviderKeys;
|
|
473
475
|
enterprise?: ProviderKeys;
|
|
476
|
+
sloosh?: ProviderKeys;
|
|
474
477
|
};
|
|
475
478
|
routing?: Routing;
|
|
476
479
|
/** Provider base-url overrides; unset entries use each adapter's documented default. */
|
|
@@ -483,8 +486,8 @@ interface ModelKitConfig {
|
|
|
483
486
|
logger?: Pick<Console, "debug" | "info" | "warn" | "error">;
|
|
484
487
|
}
|
|
485
488
|
interface CallContext {
|
|
486
|
-
/** "enterprise" picks keys.enterprise when every key for the provider is set, else falls back to pro. */
|
|
487
|
-
tier?:
|
|
489
|
+
/** "enterprise" picks keys.enterprise when every key for the provider is set, else falls back to pro. "sloosh" uses keys.sloosh only and never falls back. */
|
|
490
|
+
tier?: KeyTier;
|
|
488
491
|
signal?: AbortSignal;
|
|
489
492
|
/** Media retries after the initial request. Set 0 when a durable host owns recovery.
|
|
490
493
|
* Unset preserves adapter defaults. Successful pending-job polls are not retries.
|
|
@@ -887,8 +890,9 @@ declare const CatalogModelSchema: z.ZodType<CatalogModel>;
|
|
|
887
890
|
declare const CatalogSchema: z.ZodType<CatalogModel[]>;
|
|
888
891
|
|
|
889
892
|
declare const VIDEO_INPUT_SPEC_KEYS: readonly ["prompt", "durationSeconds", "aspectRatio", "resolution", "firstFrame", "lastFrame", "seed", "negativePrompt", "generateAudio", "cfgScale", "promptExpansion", "referenceImages"];
|
|
893
|
+
declare const IMAGE_INPUT_SPEC_KEYS: readonly ["prompt", "references", "aspectRatio", "size", "outputFormat", "seed"];
|
|
890
894
|
declare const AUDIO_INPUT_SPEC_KEYS: readonly ["prompt", "durationSeconds", "seed", "negativePrompt", "references", "sourceVideo", "instrumental"];
|
|
891
|
-
type InputSpecKey = (typeof VIDEO_INPUT_SPEC_KEYS)[number] | (typeof AUDIO_INPUT_SPEC_KEYS)[number];
|
|
895
|
+
type InputSpecKey = (typeof VIDEO_INPUT_SPEC_KEYS)[number] | (typeof IMAGE_INPUT_SPEC_KEYS)[number] | (typeof AUDIO_INPUT_SPEC_KEYS)[number];
|
|
892
896
|
declare const INPUT_SPEC_SUPPORTS_KEYS: readonly SupportedOption[];
|
|
893
897
|
declare const InputSpecSchema: z.ZodObject<{
|
|
894
898
|
fields: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
@@ -1036,12 +1040,15 @@ declare function resolveAudioOptions(model: CatalogModel, request: AudioRequest,
|
|
|
1036
1040
|
|
|
1037
1041
|
/** Which key names an adapter needs. All of them must be set on a tier for that tier to win. */
|
|
1038
1042
|
declare const ADAPTER_KEYS: Record<AdapterId, ProviderKeyName[]>;
|
|
1043
|
+
/** The required names the given non-pro tier is missing. */
|
|
1044
|
+
declare function missingTierKeys(config: ModelKitConfig, tier: Exclude<KeyTier, "pro">, names: RequiredKeyName[]): RequiredKeyName[];
|
|
1039
1045
|
/**
|
|
1040
1046
|
* Enterprise wins only when every key the adapter needs is set on the
|
|
1041
1047
|
* enterprise tier; otherwise the pro keys are used. Mirrors trigger-workflows
|
|
1042
|
-
* enterprise-keys.ts, extended to Ark and Prodia.
|
|
1048
|
+
* enterprise-keys.ts, extended to Ark and Prodia. Sloosh never falls back:
|
|
1049
|
+
* a sloosh call with a missing key throws.
|
|
1043
1050
|
*/
|
|
1044
|
-
declare function resolveKeys(config: ModelKitConfig, names: RequiredKeyName[], tier?:
|
|
1051
|
+
declare function resolveKeys(config: ModelKitConfig, names: RequiredKeyName[], tier?: KeyTier): ProviderKeys;
|
|
1045
1052
|
/** Build a ProviderKeys map from env with the given prefix ("" for pro, "ENTERPRISE_" for enterprise). */
|
|
1046
1053
|
declare function keysFromEnv(env: NodeJS.ProcessEnv, prefix?: string): ProviderKeys;
|
|
1047
1054
|
|
|
@@ -1204,7 +1211,7 @@ declare const DEFAULT_ADAPTERS: Record<AdapterId, Adapter>;
|
|
|
1204
1211
|
|
|
1205
1212
|
/**
|
|
1206
1213
|
* All adapters registered. Keys default to process.env (pro = bare names,
|
|
1207
|
-
* enterprise = ENTERPRISE_ prefix) when `keys` is omitted.
|
|
1214
|
+
* enterprise = ENTERPRISE_ prefix, sloosh = SLOOSH_ prefix) when `keys` is omitted.
|
|
1208
1215
|
*/
|
|
1209
1216
|
declare function createDefaultModelKit(config?: Partial<ModelKitConfig>): ModelKit;
|
|
1210
1217
|
/**
|
|
@@ -1237,4 +1244,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
|
|
|
1237
1244
|
/** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
|
|
1238
1245
|
declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
|
|
1239
1246
|
|
|
1240
|
-
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, 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 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, 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 };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -440,6 +440,8 @@ type ProviderKeys = Partial<Record<ProviderKeyName, string>> & {
|
|
|
440
440
|
}>;
|
|
441
441
|
};
|
|
442
442
|
};
|
|
443
|
+
/** Which key set a call uses. Enterprise falls back to pro; sloosh never falls back. */
|
|
444
|
+
type KeyTier = "pro" | "enterprise" | "sloosh";
|
|
443
445
|
/** Key names a call can require, including the Bedrock credentials object. */
|
|
444
446
|
type RequiredKeyName = ProviderKeyName | "aws";
|
|
445
447
|
/** True when region is set AND (apiKey OR credentialProvider OR both static keys). */
|
|
@@ -471,6 +473,7 @@ interface ModelKitConfig {
|
|
|
471
473
|
keys: {
|
|
472
474
|
pro: ProviderKeys;
|
|
473
475
|
enterprise?: ProviderKeys;
|
|
476
|
+
sloosh?: ProviderKeys;
|
|
474
477
|
};
|
|
475
478
|
routing?: Routing;
|
|
476
479
|
/** Provider base-url overrides; unset entries use each adapter's documented default. */
|
|
@@ -483,8 +486,8 @@ interface ModelKitConfig {
|
|
|
483
486
|
logger?: Pick<Console, "debug" | "info" | "warn" | "error">;
|
|
484
487
|
}
|
|
485
488
|
interface CallContext {
|
|
486
|
-
/** "enterprise" picks keys.enterprise when every key for the provider is set, else falls back to pro. */
|
|
487
|
-
tier?:
|
|
489
|
+
/** "enterprise" picks keys.enterprise when every key for the provider is set, else falls back to pro. "sloosh" uses keys.sloosh only and never falls back. */
|
|
490
|
+
tier?: KeyTier;
|
|
488
491
|
signal?: AbortSignal;
|
|
489
492
|
/** Media retries after the initial request. Set 0 when a durable host owns recovery.
|
|
490
493
|
* Unset preserves adapter defaults. Successful pending-job polls are not retries.
|
|
@@ -887,8 +890,9 @@ declare const CatalogModelSchema: z.ZodType<CatalogModel>;
|
|
|
887
890
|
declare const CatalogSchema: z.ZodType<CatalogModel[]>;
|
|
888
891
|
|
|
889
892
|
declare const VIDEO_INPUT_SPEC_KEYS: readonly ["prompt", "durationSeconds", "aspectRatio", "resolution", "firstFrame", "lastFrame", "seed", "negativePrompt", "generateAudio", "cfgScale", "promptExpansion", "referenceImages"];
|
|
893
|
+
declare const IMAGE_INPUT_SPEC_KEYS: readonly ["prompt", "references", "aspectRatio", "size", "outputFormat", "seed"];
|
|
890
894
|
declare const AUDIO_INPUT_SPEC_KEYS: readonly ["prompt", "durationSeconds", "seed", "negativePrompt", "references", "sourceVideo", "instrumental"];
|
|
891
|
-
type InputSpecKey = (typeof VIDEO_INPUT_SPEC_KEYS)[number] | (typeof AUDIO_INPUT_SPEC_KEYS)[number];
|
|
895
|
+
type InputSpecKey = (typeof VIDEO_INPUT_SPEC_KEYS)[number] | (typeof IMAGE_INPUT_SPEC_KEYS)[number] | (typeof AUDIO_INPUT_SPEC_KEYS)[number];
|
|
892
896
|
declare const INPUT_SPEC_SUPPORTS_KEYS: readonly SupportedOption[];
|
|
893
897
|
declare const InputSpecSchema: z.ZodObject<{
|
|
894
898
|
fields: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
@@ -1036,12 +1040,15 @@ declare function resolveAudioOptions(model: CatalogModel, request: AudioRequest,
|
|
|
1036
1040
|
|
|
1037
1041
|
/** Which key names an adapter needs. All of them must be set on a tier for that tier to win. */
|
|
1038
1042
|
declare const ADAPTER_KEYS: Record<AdapterId, ProviderKeyName[]>;
|
|
1043
|
+
/** The required names the given non-pro tier is missing. */
|
|
1044
|
+
declare function missingTierKeys(config: ModelKitConfig, tier: Exclude<KeyTier, "pro">, names: RequiredKeyName[]): RequiredKeyName[];
|
|
1039
1045
|
/**
|
|
1040
1046
|
* Enterprise wins only when every key the adapter needs is set on the
|
|
1041
1047
|
* enterprise tier; otherwise the pro keys are used. Mirrors trigger-workflows
|
|
1042
|
-
* enterprise-keys.ts, extended to Ark and Prodia.
|
|
1048
|
+
* enterprise-keys.ts, extended to Ark and Prodia. Sloosh never falls back:
|
|
1049
|
+
* a sloosh call with a missing key throws.
|
|
1043
1050
|
*/
|
|
1044
|
-
declare function resolveKeys(config: ModelKitConfig, names: RequiredKeyName[], tier?:
|
|
1051
|
+
declare function resolveKeys(config: ModelKitConfig, names: RequiredKeyName[], tier?: KeyTier): ProviderKeys;
|
|
1045
1052
|
/** Build a ProviderKeys map from env with the given prefix ("" for pro, "ENTERPRISE_" for enterprise). */
|
|
1046
1053
|
declare function keysFromEnv(env: NodeJS.ProcessEnv, prefix?: string): ProviderKeys;
|
|
1047
1054
|
|
|
@@ -1204,7 +1211,7 @@ declare const DEFAULT_ADAPTERS: Record<AdapterId, Adapter>;
|
|
|
1204
1211
|
|
|
1205
1212
|
/**
|
|
1206
1213
|
* All adapters registered. Keys default to process.env (pro = bare names,
|
|
1207
|
-
* enterprise = ENTERPRISE_ prefix) when `keys` is omitted.
|
|
1214
|
+
* enterprise = ENTERPRISE_ prefix, sloosh = SLOOSH_ prefix) when `keys` is omitted.
|
|
1208
1215
|
*/
|
|
1209
1216
|
declare function createDefaultModelKit(config?: Partial<ModelKitConfig>): ModelKit;
|
|
1210
1217
|
/**
|
|
@@ -1237,4 +1244,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
|
|
|
1237
1244
|
/** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
|
|
1238
1245
|
declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
|
|
1239
1246
|
|
|
1240
|
-
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, 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 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, 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 };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -2093,6 +2093,14 @@ var VIDEO_INPUT_SPEC_KEYS = [
|
|
|
2093
2093
|
"promptExpansion",
|
|
2094
2094
|
"referenceImages"
|
|
2095
2095
|
];
|
|
2096
|
+
var IMAGE_INPUT_SPEC_KEYS = [
|
|
2097
|
+
"prompt",
|
|
2098
|
+
"references",
|
|
2099
|
+
"aspectRatio",
|
|
2100
|
+
"size",
|
|
2101
|
+
"outputFormat",
|
|
2102
|
+
"seed"
|
|
2103
|
+
];
|
|
2096
2104
|
var AUDIO_INPUT_SPEC_KEYS = [
|
|
2097
2105
|
"prompt",
|
|
2098
2106
|
"durationSeconds",
|
|
@@ -2109,14 +2117,22 @@ var INPUT_SPEC_SUPPORTS_KEYS = [
|
|
|
2109
2117
|
"generateAudio",
|
|
2110
2118
|
"cfgScale",
|
|
2111
2119
|
"promptExpansion",
|
|
2120
|
+
"outputFormat",
|
|
2112
2121
|
"instrumental"
|
|
2113
2122
|
];
|
|
2114
2123
|
var VIDEO_KEY_SET = new Set(VIDEO_INPUT_SPEC_KEYS);
|
|
2124
|
+
var IMAGE_KEY_SET = new Set(IMAGE_INPUT_SPEC_KEYS);
|
|
2115
2125
|
var AUDIO_KEY_SET = new Set(AUDIO_INPUT_SPEC_KEYS);
|
|
2116
2126
|
var ALL_KEY_SET = /* @__PURE__ */ new Set([
|
|
2117
2127
|
...VIDEO_INPUT_SPEC_KEYS,
|
|
2128
|
+
...IMAGE_INPUT_SPEC_KEYS,
|
|
2118
2129
|
...AUDIO_INPUT_SPEC_KEYS
|
|
2119
2130
|
]);
|
|
2131
|
+
var ALLOWED_KEYS_BY_TYPE = /* @__PURE__ */ new Map([
|
|
2132
|
+
["video", VIDEO_KEY_SET],
|
|
2133
|
+
["image", IMAGE_KEY_SET],
|
|
2134
|
+
["audio", AUDIO_KEY_SET]
|
|
2135
|
+
]);
|
|
2120
2136
|
var ProviderScalarSchema = z2.union([z2.string(), z2.number(), z2.boolean()]);
|
|
2121
2137
|
var FieldsSchema = z2.record(z2.string(), z2.string().min(1)).superRefine((fields, ctx) => {
|
|
2122
2138
|
const keys = Object.keys(fields);
|
|
@@ -2185,13 +2201,13 @@ function validateInputSpec(raw, row) {
|
|
|
2185
2201
|
};
|
|
2186
2202
|
}
|
|
2187
2203
|
const issues = [];
|
|
2188
|
-
|
|
2204
|
+
const allowed = ALLOWED_KEYS_BY_TYPE.get(row.type);
|
|
2205
|
+
if (allowed === void 0) {
|
|
2189
2206
|
issues.push({
|
|
2190
2207
|
path: [],
|
|
2191
2208
|
message: `inputSpec is not supported for "${row.type}" rows`
|
|
2192
2209
|
});
|
|
2193
2210
|
} else {
|
|
2194
|
-
const allowed = row.type === "video" ? VIDEO_KEY_SET : AUDIO_KEY_SET;
|
|
2195
2211
|
for (const key of Object.keys(spec.fields)) {
|
|
2196
2212
|
if (!allowed.has(key)) {
|
|
2197
2213
|
issues.push({
|
|
@@ -6735,6 +6751,12 @@ async function generateReplicateImage(req, ctx, deps) {
|
|
|
6735
6751
|
break;
|
|
6736
6752
|
}
|
|
6737
6753
|
default: {
|
|
6754
|
+
const specResult = replicateInputSpec(req, ctx);
|
|
6755
|
+
if (specResult.kind === "invalid") throw replicateInvalidSpec(ctx, specResult.issues);
|
|
6756
|
+
if (specResult.kind === "ok") {
|
|
6757
|
+
input = specResult.input;
|
|
6758
|
+
break;
|
|
6759
|
+
}
|
|
6738
6760
|
const first = (req.references ?? [])[0];
|
|
6739
6761
|
const imageInput = { prompt: req.prompt };
|
|
6740
6762
|
if (first) imageInput.image = refToUrl(first);
|
|
@@ -7987,10 +8009,22 @@ function hasAll(keys, names) {
|
|
|
7987
8009
|
function hasKey(keys, name) {
|
|
7988
8010
|
return hasAll(keys, [name]);
|
|
7989
8011
|
}
|
|
8012
|
+
function missingTierKeys(config, tier, names) {
|
|
8013
|
+
return names.filter((name) => !hasAll(config.keys[tier], [name]));
|
|
8014
|
+
}
|
|
7990
8015
|
function missingEnterpriseKeys(config, names) {
|
|
7991
|
-
return
|
|
8016
|
+
return missingTierKeys(config, "enterprise", names);
|
|
7992
8017
|
}
|
|
7993
8018
|
function resolveKeys(config, names, tier = "pro") {
|
|
8019
|
+
if (tier === "sloosh") {
|
|
8020
|
+
if (names.length === 0) return config.keys.sloosh ?? {};
|
|
8021
|
+
if (hasAll(config.keys.sloosh, names)) return config.keys.sloosh;
|
|
8022
|
+
throw new ModelKitError({
|
|
8023
|
+
code: "auth",
|
|
8024
|
+
message: `Missing Sloosh API key for ${names.join(", ")}`,
|
|
8025
|
+
retryable: false
|
|
8026
|
+
});
|
|
8027
|
+
}
|
|
7994
8028
|
if (tier === "enterprise" && hasAll(config.keys.enterprise, names))
|
|
7995
8029
|
return config.keys.enterprise;
|
|
7996
8030
|
if (names.length > 0 && !hasAll(config.keys.pro, names)) {
|
|
@@ -8186,6 +8220,7 @@ function resolveAnthropicTransport(model, config, tier, warn) {
|
|
|
8186
8220
|
const preferred = preferredAnthropicTransport(model, config.routing ?? {});
|
|
8187
8221
|
const usable = (transport) => {
|
|
8188
8222
|
const name = transport === "bedrock" ? "aws" : "anthropic";
|
|
8223
|
+
if (tier === "sloosh") return hasKey(config.keys.sloosh, name);
|
|
8189
8224
|
return hasKey(config.keys.pro, name) || tier === "enterprise" && hasKey(config.keys.enterprise, name);
|
|
8190
8225
|
};
|
|
8191
8226
|
if (usable(preferred)) return preferred;
|
|
@@ -8767,11 +8802,19 @@ function createModelKit(config, adapters) {
|
|
|
8767
8802
|
}
|
|
8768
8803
|
|
|
8769
8804
|
// src/default.ts
|
|
8805
|
+
function withSharedAws(keys) {
|
|
8806
|
+
const { pro, sloosh } = keys;
|
|
8807
|
+
if (!sloosh || sloosh.aws || !pro.aws) return keys;
|
|
8808
|
+
return { ...keys, sloosh: { ...sloosh, aws: pro.aws } };
|
|
8809
|
+
}
|
|
8770
8810
|
function createDefaultModelKit(config = {}) {
|
|
8771
|
-
const keys =
|
|
8772
|
-
|
|
8773
|
-
|
|
8774
|
-
|
|
8811
|
+
const keys = withSharedAws(
|
|
8812
|
+
config.keys ?? {
|
|
8813
|
+
pro: keysFromEnv(process.env),
|
|
8814
|
+
enterprise: keysFromEnv(process.env, "ENTERPRISE_"),
|
|
8815
|
+
sloosh: keysFromEnv(process.env, "SLOOSH_")
|
|
8816
|
+
}
|
|
8817
|
+
);
|
|
8775
8818
|
return createModelKit({ ...config, keys }, DEFAULT_ADAPTERS);
|
|
8776
8819
|
}
|
|
8777
8820
|
var generateText2 = (options, call) => createDefaultModelKit().generateText(options, call);
|
|
@@ -8794,6 +8837,7 @@ export {
|
|
|
8794
8837
|
CatalogSchema,
|
|
8795
8838
|
DEFAULT_ADAPTERS,
|
|
8796
8839
|
ExposureSchema,
|
|
8840
|
+
IMAGE_INPUT_SPEC_KEYS,
|
|
8797
8841
|
INPUT_SPEC_SUPPORTS_KEYS,
|
|
8798
8842
|
InputSpecSchema,
|
|
8799
8843
|
JsonObjectSchema,
|
|
@@ -8835,6 +8879,7 @@ export {
|
|
|
8835
8879
|
liveCatalog,
|
|
8836
8880
|
liveState,
|
|
8837
8881
|
mergeTextProviderOptions,
|
|
8882
|
+
missingTierKeys,
|
|
8838
8883
|
nearestAspectRatio,
|
|
8839
8884
|
normalizeExposure,
|
|
8840
8885
|
openaiImageAdapter,
|