@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/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
|
|
@@ -445,11 +445,61 @@ declare class Catalog {
|
|
|
445
445
|
}): CatalogModel[];
|
|
446
446
|
/** Merge rows by id. Used for catalogOverride. */
|
|
447
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;
|
|
448
450
|
}
|
|
449
451
|
|
|
450
452
|
/** Seeded from Cowork, Space Builder and trigger-workflows. See catalog/*.ts. */
|
|
451
453
|
declare const MODELS: CatalogModel[];
|
|
452
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
|
+
type CatalogOrigin = "remote" | "last-good" | "snapshot";
|
|
460
|
+
interface LiveCatalogState {
|
|
461
|
+
catalog: Catalog;
|
|
462
|
+
memo: Promise<unknown> | undefined;
|
|
463
|
+
timer: ReturnType<typeof setInterval> | undefined;
|
|
464
|
+
revision: string | undefined;
|
|
465
|
+
origin: CatalogOrigin;
|
|
466
|
+
}
|
|
467
|
+
declare const liveState: LiveCatalogState;
|
|
468
|
+
declare const liveCatalog: Catalog;
|
|
469
|
+
|
|
470
|
+
interface CatalogCache {
|
|
471
|
+
get(): Promise<string | null>;
|
|
472
|
+
set(json: string): Promise<void>;
|
|
473
|
+
}
|
|
474
|
+
type CatalogAuth = {
|
|
475
|
+
bearer: string;
|
|
476
|
+
} | {
|
|
477
|
+
apiKey: string;
|
|
478
|
+
};
|
|
479
|
+
interface CatalogSource {
|
|
480
|
+
baseUrl: string;
|
|
481
|
+
auth: CatalogAuth;
|
|
482
|
+
ttlMs?: number;
|
|
483
|
+
/** Abort a fetch after this many ms. Default 10 s. */
|
|
484
|
+
timeoutMs?: number;
|
|
485
|
+
cache?: CatalogCache;
|
|
486
|
+
fetch?: typeof fetch;
|
|
487
|
+
logger?: Pick<Console, "debug" | "info" | "warn" | "error">;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
interface PrimeCatalogResult {
|
|
491
|
+
origin: CatalogOrigin;
|
|
492
|
+
rowCount: number;
|
|
493
|
+
revision?: string;
|
|
494
|
+
error?: string;
|
|
495
|
+
}
|
|
496
|
+
/** Fetch, validate, swap into liveCatalog. Never throws. Second call returns the same promise. */
|
|
497
|
+
declare function primeCatalog(source: CatalogSource): Promise<PrimeCatalogResult>;
|
|
498
|
+
/** Test seam: stop the refresh timer, reset liveCatalog to MODELS and clear the memo. */
|
|
499
|
+
declare function resetLiveCatalog(): void;
|
|
500
|
+
|
|
501
|
+
declare function fileCatalogCache(path: string): CatalogCache;
|
|
502
|
+
|
|
453
503
|
type OnUnsupported = "error" | "coerce";
|
|
454
504
|
interface ResolveResult<T> {
|
|
455
505
|
request: T;
|
|
@@ -691,4 +741,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
|
|
|
691
741
|
/** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
|
|
692
742
|
declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
|
|
693
743
|
|
|
694
|
-
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 };
|
|
744
|
+
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, 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, 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, liveState, 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
|
|
@@ -445,11 +445,61 @@ declare class Catalog {
|
|
|
445
445
|
}): CatalogModel[];
|
|
446
446
|
/** Merge rows by id. Used for catalogOverride. */
|
|
447
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;
|
|
448
450
|
}
|
|
449
451
|
|
|
450
452
|
/** Seeded from Cowork, Space Builder and trigger-workflows. See catalog/*.ts. */
|
|
451
453
|
declare const MODELS: CatalogModel[];
|
|
452
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
|
+
type CatalogOrigin = "remote" | "last-good" | "snapshot";
|
|
460
|
+
interface LiveCatalogState {
|
|
461
|
+
catalog: Catalog;
|
|
462
|
+
memo: Promise<unknown> | undefined;
|
|
463
|
+
timer: ReturnType<typeof setInterval> | undefined;
|
|
464
|
+
revision: string | undefined;
|
|
465
|
+
origin: CatalogOrigin;
|
|
466
|
+
}
|
|
467
|
+
declare const liveState: LiveCatalogState;
|
|
468
|
+
declare const liveCatalog: Catalog;
|
|
469
|
+
|
|
470
|
+
interface CatalogCache {
|
|
471
|
+
get(): Promise<string | null>;
|
|
472
|
+
set(json: string): Promise<void>;
|
|
473
|
+
}
|
|
474
|
+
type CatalogAuth = {
|
|
475
|
+
bearer: string;
|
|
476
|
+
} | {
|
|
477
|
+
apiKey: string;
|
|
478
|
+
};
|
|
479
|
+
interface CatalogSource {
|
|
480
|
+
baseUrl: string;
|
|
481
|
+
auth: CatalogAuth;
|
|
482
|
+
ttlMs?: number;
|
|
483
|
+
/** Abort a fetch after this many ms. Default 10 s. */
|
|
484
|
+
timeoutMs?: number;
|
|
485
|
+
cache?: CatalogCache;
|
|
486
|
+
fetch?: typeof fetch;
|
|
487
|
+
logger?: Pick<Console, "debug" | "info" | "warn" | "error">;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
interface PrimeCatalogResult {
|
|
491
|
+
origin: CatalogOrigin;
|
|
492
|
+
rowCount: number;
|
|
493
|
+
revision?: string;
|
|
494
|
+
error?: string;
|
|
495
|
+
}
|
|
496
|
+
/** Fetch, validate, swap into liveCatalog. Never throws. Second call returns the same promise. */
|
|
497
|
+
declare function primeCatalog(source: CatalogSource): Promise<PrimeCatalogResult>;
|
|
498
|
+
/** Test seam: stop the refresh timer, reset liveCatalog to MODELS and clear the memo. */
|
|
499
|
+
declare function resetLiveCatalog(): void;
|
|
500
|
+
|
|
501
|
+
declare function fileCatalogCache(path: string): CatalogCache;
|
|
502
|
+
|
|
453
503
|
type OnUnsupported = "error" | "coerce";
|
|
454
504
|
interface ResolveResult<T> {
|
|
455
505
|
request: T;
|
|
@@ -691,4 +741,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
|
|
|
691
741
|
/** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
|
|
692
742
|
declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
|
|
693
743
|
|
|
694
|
-
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 };
|
|
744
|
+
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, 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, 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, liveState, mergeTextProviderOptions, nearestAspectRatio, openaiImageAdapter, passthroughTextModel, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, streamObject, streamText, textUsageEvent, toGeneratedImage, withRetry, xaiVideoAdapter };
|