@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.
@@ -1,4 +1,5 @@
1
1
  import { ImageModel, experimental_generateVideo } from 'ai';
2
+ import { z } from 'zod';
2
3
 
3
4
  /**
4
5
  * Canonical vocabulary shared by every adapter. Adapters translate these
@@ -35,7 +36,7 @@ interface UpscaleOptions {
35
36
  faceEnhancementStrength?: number;
36
37
  }
37
38
  type ModelType = "text" | "image" | "video" | "audio" | "upscale" | "bg-remove";
38
- type Lifecycle = "active" | "hidden" | "deprecated" | "retired";
39
+ type Lifecycle = "active" | "deprecated" | "retired";
39
40
  type AdapterId = "ai-sdk-text" | "google-image" | "openai-image" | "google-genai" | "ark" | "fal" | "replicate" | "prodia" | "higgsfield" | "xai-video";
40
41
  /** Gemini image safety threshold, per category, sent only when the caller opts in. */
41
42
  type ImageSafetySetting = {
@@ -234,10 +235,6 @@ interface CatalogDisplay {
234
235
  }
235
236
  /** Capability flags a UI keys off. Absent means false / unknown. */
236
237
  interface CatalogCapabilities {
237
- /** Image rows: generates from a prompt alone. */
238
- imageGenerate?: boolean;
239
- /** Image rows: edits or conditions on reference images. */
240
- imageEdit?: boolean;
241
238
  /** Video rows: takes an existing video as the thing to edit or extend. */
242
239
  acceptsSourceVideo?: boolean;
243
240
  /** Video rows: first/last frames and reference images are mutually exclusive inputs. */
@@ -245,8 +242,6 @@ interface CatalogCapabilities {
245
242
  /** Text rows. `reasoning`: the model streams reasoning the UI should surface. */
246
243
  reasoning?: boolean;
247
244
  vision?: boolean;
248
- tools?: boolean;
249
- structuredOutput?: boolean;
250
245
  contextWindow?: number;
251
246
  }
252
247
  interface CatalogModel {
@@ -276,7 +271,6 @@ interface CatalogModel {
276
271
  */
277
272
  usage: {
278
273
  unit: UsageUnit;
279
- modality: UsageModality;
280
274
  slug?: string;
281
275
  providerLabel?: string;
282
276
  };
@@ -424,11 +418,50 @@ declare class Catalog {
424
418
  }): CatalogModel[];
425
419
  /** Merge rows by id. Used for catalogOverride. */
426
420
  withOverrides(rows: CatalogModel[]): Catalog;
421
+ /** Atomically swap every row. Builds the maps first so a bad batch throws before anything changes. */
422
+ replace(rows: CatalogModel[]): void;
427
423
  }
428
424
 
429
425
  /** Seeded from Cowork, Space Builder and trigger-workflows. See catalog/*.ts. */
430
426
  declare const MODELS: CatalogModel[];
431
427
 
428
+ declare const ADAPTER_IDS: readonly ["ai-sdk-text", "google-image", "openai-image", "google-genai", "ark", "fal", "replicate", "prodia", "higgsfield", "xai-video"];
429
+ declare const CatalogModelSchema: z.ZodType<CatalogModel>;
430
+ declare const CatalogSchema: z.ZodType<CatalogModel[]>;
431
+
432
+ declare const liveCatalog: Catalog;
433
+
434
+ interface CatalogCache {
435
+ get(): Promise<string | null>;
436
+ set(json: string): Promise<void>;
437
+ }
438
+ type CatalogAuth = {
439
+ bearer: string;
440
+ } | {
441
+ apiKey: string;
442
+ };
443
+ interface CatalogSource {
444
+ baseUrl: string;
445
+ auth: CatalogAuth;
446
+ ttlMs?: number;
447
+ /** Abort a fetch after this many ms. Default 10 s. */
448
+ timeoutMs?: number;
449
+ cache?: CatalogCache;
450
+ fetch?: typeof fetch;
451
+ logger?: Pick<Console, "debug" | "info" | "warn" | "error">;
452
+ }
453
+ type CatalogOrigin = "remote" | "last-good" | "snapshot";
454
+ interface PrimeCatalogResult {
455
+ origin: CatalogOrigin;
456
+ rowCount: number;
457
+ revision?: string;
458
+ error?: string;
459
+ }
460
+ /** Fetch, validate, swap into liveCatalog. Never throws. Second call returns the same promise. */
461
+ declare function primeCatalog(source: CatalogSource): Promise<PrimeCatalogResult>;
462
+ /** Test seam: stop the refresh timer and reset liveCatalog to MODELS and clear the memo. */
463
+ declare function resetLiveCatalog(): void;
464
+
432
465
  declare const IMAGE_MODELS: CatalogModel[];
433
466
 
434
467
  declare const VIDEO_MODELS: CatalogModel[];
@@ -483,4 +516,4 @@ declare function isModelKitError(err: unknown): err is ModelKitError;
483
516
  /** Resolve caller options against a catalog row, dispatching on `model.type`. */
484
517
  declare function resolveOptions(model: CatalogModel, request: ImageRequest | VideoRequest | AudioRequest, onUnsupported?: OnUnsupported): ResolveResult<ImageRequest | VideoRequest | AudioRequest>;
485
518
 
486
- export { type AdapterEndpoints, type AdapterId, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogCapabilities, type CatalogDisplay, type CatalogModel, 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, 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 ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type ReferenceLimits, type RequiredInput, type ResolveResult, type Routing, type SupportedOption, 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, isModelKitError, nearestAspectRatio, resolveAudioOptions, resolveImageOptions, resolveOptions, resolveVideoOptions };
519
+ 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 CatalogModel, CatalogModelSchema, type CatalogOrigin, CatalogSchema, type CatalogSource, 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, 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, type SupportedOption, 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, isModelKitError, liveCatalog, nearestAspectRatio, primeCatalog, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveOptions, resolveVideoOptions };
package/dist/catalog.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ImageModel, experimental_generateVideo } from 'ai';
2
+ import { z } from 'zod';
2
3
 
3
4
  /**
4
5
  * Canonical vocabulary shared by every adapter. Adapters translate these
@@ -35,7 +36,7 @@ interface UpscaleOptions {
35
36
  faceEnhancementStrength?: number;
36
37
  }
37
38
  type ModelType = "text" | "image" | "video" | "audio" | "upscale" | "bg-remove";
38
- type Lifecycle = "active" | "hidden" | "deprecated" | "retired";
39
+ type Lifecycle = "active" | "deprecated" | "retired";
39
40
  type AdapterId = "ai-sdk-text" | "google-image" | "openai-image" | "google-genai" | "ark" | "fal" | "replicate" | "prodia" | "higgsfield" | "xai-video";
40
41
  /** Gemini image safety threshold, per category, sent only when the caller opts in. */
41
42
  type ImageSafetySetting = {
@@ -234,10 +235,6 @@ interface CatalogDisplay {
234
235
  }
235
236
  /** Capability flags a UI keys off. Absent means false / unknown. */
236
237
  interface CatalogCapabilities {
237
- /** Image rows: generates from a prompt alone. */
238
- imageGenerate?: boolean;
239
- /** Image rows: edits or conditions on reference images. */
240
- imageEdit?: boolean;
241
238
  /** Video rows: takes an existing video as the thing to edit or extend. */
242
239
  acceptsSourceVideo?: boolean;
243
240
  /** Video rows: first/last frames and reference images are mutually exclusive inputs. */
@@ -245,8 +242,6 @@ interface CatalogCapabilities {
245
242
  /** Text rows. `reasoning`: the model streams reasoning the UI should surface. */
246
243
  reasoning?: boolean;
247
244
  vision?: boolean;
248
- tools?: boolean;
249
- structuredOutput?: boolean;
250
245
  contextWindow?: number;
251
246
  }
252
247
  interface CatalogModel {
@@ -276,7 +271,6 @@ interface CatalogModel {
276
271
  */
277
272
  usage: {
278
273
  unit: UsageUnit;
279
- modality: UsageModality;
280
274
  slug?: string;
281
275
  providerLabel?: string;
282
276
  };
@@ -424,11 +418,50 @@ declare class Catalog {
424
418
  }): CatalogModel[];
425
419
  /** Merge rows by id. Used for catalogOverride. */
426
420
  withOverrides(rows: CatalogModel[]): Catalog;
421
+ /** Atomically swap every row. Builds the maps first so a bad batch throws before anything changes. */
422
+ replace(rows: CatalogModel[]): void;
427
423
  }
428
424
 
429
425
  /** Seeded from Cowork, Space Builder and trigger-workflows. See catalog/*.ts. */
430
426
  declare const MODELS: CatalogModel[];
431
427
 
428
+ declare const ADAPTER_IDS: readonly ["ai-sdk-text", "google-image", "openai-image", "google-genai", "ark", "fal", "replicate", "prodia", "higgsfield", "xai-video"];
429
+ declare const CatalogModelSchema: z.ZodType<CatalogModel>;
430
+ declare const CatalogSchema: z.ZodType<CatalogModel[]>;
431
+
432
+ declare const liveCatalog: Catalog;
433
+
434
+ interface CatalogCache {
435
+ get(): Promise<string | null>;
436
+ set(json: string): Promise<void>;
437
+ }
438
+ type CatalogAuth = {
439
+ bearer: string;
440
+ } | {
441
+ apiKey: string;
442
+ };
443
+ interface CatalogSource {
444
+ baseUrl: string;
445
+ auth: CatalogAuth;
446
+ ttlMs?: number;
447
+ /** Abort a fetch after this many ms. Default 10 s. */
448
+ timeoutMs?: number;
449
+ cache?: CatalogCache;
450
+ fetch?: typeof fetch;
451
+ logger?: Pick<Console, "debug" | "info" | "warn" | "error">;
452
+ }
453
+ type CatalogOrigin = "remote" | "last-good" | "snapshot";
454
+ interface PrimeCatalogResult {
455
+ origin: CatalogOrigin;
456
+ rowCount: number;
457
+ revision?: string;
458
+ error?: string;
459
+ }
460
+ /** Fetch, validate, swap into liveCatalog. Never throws. Second call returns the same promise. */
461
+ declare function primeCatalog(source: CatalogSource): Promise<PrimeCatalogResult>;
462
+ /** Test seam: stop the refresh timer and reset liveCatalog to MODELS and clear the memo. */
463
+ declare function resetLiveCatalog(): void;
464
+
432
465
  declare const IMAGE_MODELS: CatalogModel[];
433
466
 
434
467
  declare const VIDEO_MODELS: CatalogModel[];
@@ -483,4 +516,4 @@ declare function isModelKitError(err: unknown): err is ModelKitError;
483
516
  /** Resolve caller options against a catalog row, dispatching on `model.type`. */
484
517
  declare function resolveOptions(model: CatalogModel, request: ImageRequest | VideoRequest | AudioRequest, onUnsupported?: OnUnsupported): ResolveResult<ImageRequest | VideoRequest | AudioRequest>;
485
518
 
486
- export { type AdapterEndpoints, type AdapterId, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogCapabilities, type CatalogDisplay, type CatalogModel, 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, 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 ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type ReferenceLimits, type RequiredInput, type ResolveResult, type Routing, type SupportedOption, 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, isModelKitError, nearestAspectRatio, resolveAudioOptions, resolveImageOptions, resolveOptions, resolveVideoOptions };
519
+ 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 CatalogModel, CatalogModelSchema, type CatalogOrigin, CatalogSchema, type CatalogSource, 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, 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, type SupportedOption, 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, isModelKitError, liveCatalog, nearestAspectRatio, primeCatalog, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveOptions, resolveVideoOptions };