@shop-os/modelkit 0.1.11 → 0.2.2
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 +56 -3
- package/dist/catalog.cjs +438 -43
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.d.cts +50 -1
- package/dist/catalog.d.ts +50 -1
- package/dist/catalog.js +438 -43
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +618 -164
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +52 -2
- package/dist/index.d.ts +52 -2
- package/dist/index.js +610 -164
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/catalog.d.cts
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
|
|
@@ -417,11 +418,59 @@ declare class Catalog {
|
|
|
417
418
|
}): CatalogModel[];
|
|
418
419
|
/** Merge rows by id. Used for catalogOverride. */
|
|
419
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;
|
|
420
423
|
}
|
|
421
424
|
|
|
422
425
|
/** Seeded from Cowork, Space Builder and trigger-workflows. See catalog/*.ts. */
|
|
423
426
|
declare const MODELS: CatalogModel[];
|
|
424
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
|
+
type CatalogOrigin = "remote" | "last-good" | "snapshot";
|
|
433
|
+
interface LiveCatalogState {
|
|
434
|
+
catalog: Catalog;
|
|
435
|
+
memo: Promise<unknown> | undefined;
|
|
436
|
+
timer: ReturnType<typeof setInterval> | undefined;
|
|
437
|
+
revision: string | undefined;
|
|
438
|
+
origin: CatalogOrigin;
|
|
439
|
+
}
|
|
440
|
+
declare const liveState: LiveCatalogState;
|
|
441
|
+
declare const liveCatalog: Catalog;
|
|
442
|
+
|
|
443
|
+
interface CatalogCache {
|
|
444
|
+
get(): Promise<string | null>;
|
|
445
|
+
set(json: string): Promise<void>;
|
|
446
|
+
}
|
|
447
|
+
type CatalogAuth = {
|
|
448
|
+
bearer: string;
|
|
449
|
+
} | {
|
|
450
|
+
apiKey: string;
|
|
451
|
+
};
|
|
452
|
+
interface CatalogSource {
|
|
453
|
+
baseUrl: string;
|
|
454
|
+
auth: CatalogAuth;
|
|
455
|
+
ttlMs?: number;
|
|
456
|
+
/** Abort a fetch after this many ms. Default 10 s. */
|
|
457
|
+
timeoutMs?: number;
|
|
458
|
+
cache?: CatalogCache;
|
|
459
|
+
fetch?: typeof fetch;
|
|
460
|
+
logger?: Pick<Console, "debug" | "info" | "warn" | "error">;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
interface PrimeCatalogResult {
|
|
464
|
+
origin: CatalogOrigin;
|
|
465
|
+
rowCount: number;
|
|
466
|
+
revision?: string;
|
|
467
|
+
error?: string;
|
|
468
|
+
}
|
|
469
|
+
/** Fetch, validate, swap into liveCatalog. Never throws. Second call returns the same promise. */
|
|
470
|
+
declare function primeCatalog(source: CatalogSource): Promise<PrimeCatalogResult>;
|
|
471
|
+
/** Test seam: stop the refresh timer, reset liveCatalog to MODELS and clear the memo. */
|
|
472
|
+
declare function resetLiveCatalog(): void;
|
|
473
|
+
|
|
425
474
|
declare const IMAGE_MODELS: CatalogModel[];
|
|
426
475
|
|
|
427
476
|
declare const VIDEO_MODELS: CatalogModel[];
|
|
@@ -476,4 +525,4 @@ declare function isModelKitError(err: unknown): err is ModelKitError;
|
|
|
476
525
|
/** Resolve caller options against a catalog row, dispatching on `model.type`. */
|
|
477
526
|
declare function resolveOptions(model: CatalogModel, request: ImageRequest | VideoRequest | AudioRequest, onUnsupported?: OnUnsupported): ResolveResult<ImageRequest | VideoRequest | AudioRequest>;
|
|
478
527
|
|
|
479
|
-
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 };
|
|
528
|
+
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, 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, 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, liveState, 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
|
|
@@ -417,11 +418,59 @@ declare class Catalog {
|
|
|
417
418
|
}): CatalogModel[];
|
|
418
419
|
/** Merge rows by id. Used for catalogOverride. */
|
|
419
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;
|
|
420
423
|
}
|
|
421
424
|
|
|
422
425
|
/** Seeded from Cowork, Space Builder and trigger-workflows. See catalog/*.ts. */
|
|
423
426
|
declare const MODELS: CatalogModel[];
|
|
424
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
|
+
type CatalogOrigin = "remote" | "last-good" | "snapshot";
|
|
433
|
+
interface LiveCatalogState {
|
|
434
|
+
catalog: Catalog;
|
|
435
|
+
memo: Promise<unknown> | undefined;
|
|
436
|
+
timer: ReturnType<typeof setInterval> | undefined;
|
|
437
|
+
revision: string | undefined;
|
|
438
|
+
origin: CatalogOrigin;
|
|
439
|
+
}
|
|
440
|
+
declare const liveState: LiveCatalogState;
|
|
441
|
+
declare const liveCatalog: Catalog;
|
|
442
|
+
|
|
443
|
+
interface CatalogCache {
|
|
444
|
+
get(): Promise<string | null>;
|
|
445
|
+
set(json: string): Promise<void>;
|
|
446
|
+
}
|
|
447
|
+
type CatalogAuth = {
|
|
448
|
+
bearer: string;
|
|
449
|
+
} | {
|
|
450
|
+
apiKey: string;
|
|
451
|
+
};
|
|
452
|
+
interface CatalogSource {
|
|
453
|
+
baseUrl: string;
|
|
454
|
+
auth: CatalogAuth;
|
|
455
|
+
ttlMs?: number;
|
|
456
|
+
/** Abort a fetch after this many ms. Default 10 s. */
|
|
457
|
+
timeoutMs?: number;
|
|
458
|
+
cache?: CatalogCache;
|
|
459
|
+
fetch?: typeof fetch;
|
|
460
|
+
logger?: Pick<Console, "debug" | "info" | "warn" | "error">;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
interface PrimeCatalogResult {
|
|
464
|
+
origin: CatalogOrigin;
|
|
465
|
+
rowCount: number;
|
|
466
|
+
revision?: string;
|
|
467
|
+
error?: string;
|
|
468
|
+
}
|
|
469
|
+
/** Fetch, validate, swap into liveCatalog. Never throws. Second call returns the same promise. */
|
|
470
|
+
declare function primeCatalog(source: CatalogSource): Promise<PrimeCatalogResult>;
|
|
471
|
+
/** Test seam: stop the refresh timer, reset liveCatalog to MODELS and clear the memo. */
|
|
472
|
+
declare function resetLiveCatalog(): void;
|
|
473
|
+
|
|
425
474
|
declare const IMAGE_MODELS: CatalogModel[];
|
|
426
475
|
|
|
427
476
|
declare const VIDEO_MODELS: CatalogModel[];
|
|
@@ -476,4 +525,4 @@ declare function isModelKitError(err: unknown): err is ModelKitError;
|
|
|
476
525
|
/** Resolve caller options against a catalog row, dispatching on `model.type`. */
|
|
477
526
|
declare function resolveOptions(model: CatalogModel, request: ImageRequest | VideoRequest | AudioRequest, onUnsupported?: OnUnsupported): ResolveResult<ImageRequest | VideoRequest | AudioRequest>;
|
|
478
527
|
|
|
479
|
-
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 };
|
|
528
|
+
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, 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, 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, liveState, nearestAspectRatio, primeCatalog, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveOptions, resolveVideoOptions };
|