@shop-os/modelkit 0.1.10 → 0.2.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
@@ -1,8 +1,8 @@
1
1
  import { ImageModel, experimental_generateVideo, generateText as generateText$1, LanguageModel, FlexibleSchema, InferSchema, ToolSet, Output, streamText as streamText$1, JSONValue, generateObject as generateObject$1, streamObject as streamObject$1, LanguageModelUsage } from 'ai';
2
2
  export * from 'ai';
3
3
  export { Warning as AiWarning } from 'ai';
4
- import { LanguageModelV3, LanguageModelV2 } from '@ai-sdk/provider';
5
4
  import { z } from 'zod';
5
+ import { LanguageModelV3, LanguageModelV2 } from '@ai-sdk/provider';
6
6
 
7
7
  /**
8
8
  * Canonical vocabulary shared by every adapter. Adapters translate these
@@ -39,7 +39,7 @@ interface UpscaleOptions {
39
39
  faceEnhancementStrength?: number;
40
40
  }
41
41
  type ModelType = "text" | "image" | "video" | "audio" | "upscale" | "bg-remove";
42
- type Lifecycle = "active" | "hidden" | "deprecated" | "retired";
42
+ type Lifecycle = "active" | "deprecated" | "retired";
43
43
  type AdapterId = "ai-sdk-text" | "google-image" | "openai-image" | "google-genai" | "ark" | "fal" | "replicate" | "prodia" | "higgsfield" | "xai-video";
44
44
  /** Gemini image safety threshold, per category, sent only when the caller opts in. */
45
45
  type ImageSafetySetting = {
@@ -238,10 +238,6 @@ interface CatalogDisplay {
238
238
  }
239
239
  /** Capability flags a UI keys off. Absent means false / unknown. */
240
240
  interface CatalogCapabilities {
241
- /** Image rows: generates from a prompt alone. */
242
- imageGenerate?: boolean;
243
- /** Image rows: edits or conditions on reference images. */
244
- imageEdit?: boolean;
245
241
  /** Video rows: takes an existing video as the thing to edit or extend. */
246
242
  acceptsSourceVideo?: boolean;
247
243
  /** Video rows: first/last frames and reference images are mutually exclusive inputs. */
@@ -249,8 +245,6 @@ interface CatalogCapabilities {
249
245
  /** Text rows. `reasoning`: the model streams reasoning the UI should surface. */
250
246
  reasoning?: boolean;
251
247
  vision?: boolean;
252
- tools?: boolean;
253
- structuredOutput?: boolean;
254
248
  contextWindow?: number;
255
249
  }
256
250
  interface CatalogModel {
@@ -280,7 +274,6 @@ interface CatalogModel {
280
274
  */
281
275
  usage: {
282
276
  unit: UsageUnit;
283
- modality: UsageModality;
284
277
  slug?: string;
285
278
  providerLabel?: string;
286
279
  };
@@ -452,11 +445,52 @@ declare class Catalog {
452
445
  }): CatalogModel[];
453
446
  /** Merge rows by id. Used for catalogOverride. */
454
447
  withOverrides(rows: CatalogModel[]): Catalog;
448
+ /** Atomically swap every row. Builds the maps first so a bad batch throws before anything changes. */
449
+ replace(rows: CatalogModel[]): void;
455
450
  }
456
451
 
457
452
  /** Seeded from Cowork, Space Builder and trigger-workflows. See catalog/*.ts. */
458
453
  declare const MODELS: CatalogModel[];
459
454
 
455
+ declare const ADAPTER_IDS: readonly ["ai-sdk-text", "google-image", "openai-image", "google-genai", "ark", "fal", "replicate", "prodia", "higgsfield", "xai-video"];
456
+ declare const CatalogModelSchema: z.ZodType<CatalogModel>;
457
+ declare const CatalogSchema: z.ZodType<CatalogModel[]>;
458
+
459
+ declare const liveCatalog: Catalog;
460
+
461
+ interface CatalogCache {
462
+ get(): Promise<string | null>;
463
+ set(json: string): Promise<void>;
464
+ }
465
+ type CatalogAuth = {
466
+ bearer: string;
467
+ } | {
468
+ apiKey: string;
469
+ };
470
+ interface CatalogSource {
471
+ baseUrl: string;
472
+ auth: CatalogAuth;
473
+ ttlMs?: number;
474
+ /** Abort a fetch after this many ms. Default 10 s. */
475
+ timeoutMs?: number;
476
+ cache?: CatalogCache;
477
+ fetch?: typeof fetch;
478
+ logger?: Pick<Console, "debug" | "info" | "warn" | "error">;
479
+ }
480
+ type CatalogOrigin = "remote" | "last-good" | "snapshot";
481
+ interface PrimeCatalogResult {
482
+ origin: CatalogOrigin;
483
+ rowCount: number;
484
+ revision?: string;
485
+ error?: string;
486
+ }
487
+ /** Fetch, validate, swap into liveCatalog. Never throws. Second call returns the same promise. */
488
+ declare function primeCatalog(source: CatalogSource): Promise<PrimeCatalogResult>;
489
+ /** Test seam: stop the refresh timer and reset liveCatalog to MODELS and clear the memo. */
490
+ declare function resetLiveCatalog(): void;
491
+
492
+ declare function fileCatalogCache(path: string): CatalogCache;
493
+
460
494
  type OnUnsupported = "error" | "coerce";
461
495
  interface ResolveResult<T> {
462
496
  request: T;
@@ -698,4 +732,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
698
732
  /** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
699
733
  declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
700
734
 
701
- export { ADAPTER_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogCapabilities, type CatalogDisplay, type CatalogModel, type CatalogTextModel, DEFAULT_ADAPTERS, type DefaultObjectOutput, 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, 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 ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type ReferenceLimits, type RequiredInput, type ResolveResult, type Routing, type SupportedOption, 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, createDefaultModelKit, createModelKit, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, higgsfieldAdapter, isModelKitError, keysFromEnv, languageModel, mergeTextProviderOptions, nearestAspectRatio, openaiImageAdapter, passthroughTextModel, pollUntil, prepareMediaPart, prodiaAdapter, readErrorBody, replicateAdapter, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, streamObject, streamText, textUsageEvent, toGeneratedImage, withRetry, xaiVideoAdapter };
735
+ 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 CatalogModel, CatalogModelSchema, type CatalogOrigin, CatalogSchema, type CatalogSource, type CatalogTextModel, DEFAULT_ADAPTERS, type DefaultObjectOutput, 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, 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, type SupportedOption, 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, createDefaultModelKit, createModelKit, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, higgsfieldAdapter, isModelKitError, keysFromEnv, languageModel, liveCatalog, mergeTextProviderOptions, nearestAspectRatio, openaiImageAdapter, passthroughTextModel, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, streamObject, streamText, textUsageEvent, toGeneratedImage, withRetry, xaiVideoAdapter };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { ImageModel, experimental_generateVideo, generateText as generateText$1, LanguageModel, FlexibleSchema, InferSchema, ToolSet, Output, streamText as streamText$1, JSONValue, generateObject as generateObject$1, streamObject as streamObject$1, LanguageModelUsage } from 'ai';
2
2
  export * from 'ai';
3
3
  export { Warning as AiWarning } from 'ai';
4
- import { LanguageModelV3, LanguageModelV2 } from '@ai-sdk/provider';
5
4
  import { z } from 'zod';
5
+ import { LanguageModelV3, LanguageModelV2 } from '@ai-sdk/provider';
6
6
 
7
7
  /**
8
8
  * Canonical vocabulary shared by every adapter. Adapters translate these
@@ -39,7 +39,7 @@ interface UpscaleOptions {
39
39
  faceEnhancementStrength?: number;
40
40
  }
41
41
  type ModelType = "text" | "image" | "video" | "audio" | "upscale" | "bg-remove";
42
- type Lifecycle = "active" | "hidden" | "deprecated" | "retired";
42
+ type Lifecycle = "active" | "deprecated" | "retired";
43
43
  type AdapterId = "ai-sdk-text" | "google-image" | "openai-image" | "google-genai" | "ark" | "fal" | "replicate" | "prodia" | "higgsfield" | "xai-video";
44
44
  /** Gemini image safety threshold, per category, sent only when the caller opts in. */
45
45
  type ImageSafetySetting = {
@@ -238,10 +238,6 @@ interface CatalogDisplay {
238
238
  }
239
239
  /** Capability flags a UI keys off. Absent means false / unknown. */
240
240
  interface CatalogCapabilities {
241
- /** Image rows: generates from a prompt alone. */
242
- imageGenerate?: boolean;
243
- /** Image rows: edits or conditions on reference images. */
244
- imageEdit?: boolean;
245
241
  /** Video rows: takes an existing video as the thing to edit or extend. */
246
242
  acceptsSourceVideo?: boolean;
247
243
  /** Video rows: first/last frames and reference images are mutually exclusive inputs. */
@@ -249,8 +245,6 @@ interface CatalogCapabilities {
249
245
  /** Text rows. `reasoning`: the model streams reasoning the UI should surface. */
250
246
  reasoning?: boolean;
251
247
  vision?: boolean;
252
- tools?: boolean;
253
- structuredOutput?: boolean;
254
248
  contextWindow?: number;
255
249
  }
256
250
  interface CatalogModel {
@@ -280,7 +274,6 @@ interface CatalogModel {
280
274
  */
281
275
  usage: {
282
276
  unit: UsageUnit;
283
- modality: UsageModality;
284
277
  slug?: string;
285
278
  providerLabel?: string;
286
279
  };
@@ -452,11 +445,52 @@ declare class Catalog {
452
445
  }): CatalogModel[];
453
446
  /** Merge rows by id. Used for catalogOverride. */
454
447
  withOverrides(rows: CatalogModel[]): Catalog;
448
+ /** Atomically swap every row. Builds the maps first so a bad batch throws before anything changes. */
449
+ replace(rows: CatalogModel[]): void;
455
450
  }
456
451
 
457
452
  /** Seeded from Cowork, Space Builder and trigger-workflows. See catalog/*.ts. */
458
453
  declare const MODELS: CatalogModel[];
459
454
 
455
+ declare const ADAPTER_IDS: readonly ["ai-sdk-text", "google-image", "openai-image", "google-genai", "ark", "fal", "replicate", "prodia", "higgsfield", "xai-video"];
456
+ declare const CatalogModelSchema: z.ZodType<CatalogModel>;
457
+ declare const CatalogSchema: z.ZodType<CatalogModel[]>;
458
+
459
+ declare const liveCatalog: Catalog;
460
+
461
+ interface CatalogCache {
462
+ get(): Promise<string | null>;
463
+ set(json: string): Promise<void>;
464
+ }
465
+ type CatalogAuth = {
466
+ bearer: string;
467
+ } | {
468
+ apiKey: string;
469
+ };
470
+ interface CatalogSource {
471
+ baseUrl: string;
472
+ auth: CatalogAuth;
473
+ ttlMs?: number;
474
+ /** Abort a fetch after this many ms. Default 10 s. */
475
+ timeoutMs?: number;
476
+ cache?: CatalogCache;
477
+ fetch?: typeof fetch;
478
+ logger?: Pick<Console, "debug" | "info" | "warn" | "error">;
479
+ }
480
+ type CatalogOrigin = "remote" | "last-good" | "snapshot";
481
+ interface PrimeCatalogResult {
482
+ origin: CatalogOrigin;
483
+ rowCount: number;
484
+ revision?: string;
485
+ error?: string;
486
+ }
487
+ /** Fetch, validate, swap into liveCatalog. Never throws. Second call returns the same promise. */
488
+ declare function primeCatalog(source: CatalogSource): Promise<PrimeCatalogResult>;
489
+ /** Test seam: stop the refresh timer and reset liveCatalog to MODELS and clear the memo. */
490
+ declare function resetLiveCatalog(): void;
491
+
492
+ declare function fileCatalogCache(path: string): CatalogCache;
493
+
460
494
  type OnUnsupported = "error" | "coerce";
461
495
  interface ResolveResult<T> {
462
496
  request: T;
@@ -698,4 +732,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
698
732
  /** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
699
733
  declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
700
734
 
701
- export { ADAPTER_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogCapabilities, type CatalogDisplay, type CatalogModel, type CatalogTextModel, DEFAULT_ADAPTERS, type DefaultObjectOutput, 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, 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 ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type ReferenceLimits, type RequiredInput, type ResolveResult, type Routing, type SupportedOption, 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, createDefaultModelKit, createModelKit, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, higgsfieldAdapter, isModelKitError, keysFromEnv, languageModel, mergeTextProviderOptions, nearestAspectRatio, openaiImageAdapter, passthroughTextModel, pollUntil, prepareMediaPart, prodiaAdapter, readErrorBody, replicateAdapter, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, streamObject, streamText, textUsageEvent, toGeneratedImage, withRetry, xaiVideoAdapter };
735
+ 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 CatalogModel, CatalogModelSchema, type CatalogOrigin, CatalogSchema, type CatalogSource, type CatalogTextModel, DEFAULT_ADAPTERS, type DefaultObjectOutput, 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, 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, type SupportedOption, 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, createDefaultModelKit, createModelKit, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, higgsfieldAdapter, isModelKitError, keysFromEnv, languageModel, liveCatalog, mergeTextProviderOptions, nearestAspectRatio, openaiImageAdapter, passthroughTextModel, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, streamObject, streamText, textUsageEvent, toGeneratedImage, withRetry, xaiVideoAdapter };