@shop-os/modelkit 0.2.12 → 0.2.14
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 +19 -0
- package/README.md +43 -2
- package/dist/catalog.cjs +422 -148
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.d.cts +294 -1
- package/dist/catalog.d.ts +294 -1
- package/dist/catalog.js +422 -148
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +5835 -5126
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +371 -38
- package/dist/index.d.ts +371 -38
- package/dist/index.js +4195 -3495
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -432,6 +432,11 @@ interface CallContext {
|
|
|
432
432
|
/** "enterprise" picks keys.enterprise when every key for the provider is set, else falls back to pro. */
|
|
433
433
|
tier?: "pro" | "enterprise";
|
|
434
434
|
signal?: AbortSignal;
|
|
435
|
+
/** Media retries after the initial request. Set 0 when a durable host owns recovery.
|
|
436
|
+
* Unset preserves adapter defaults. Successful pending-job polls are not retries.
|
|
437
|
+
* Text methods use the AI SDK options.maxRetries instead.
|
|
438
|
+
*/
|
|
439
|
+
maxRetries?: number;
|
|
435
440
|
onUnsupported?: "error" | "coerce";
|
|
436
441
|
}
|
|
437
442
|
|
|
@@ -507,15 +512,375 @@ declare const SurfaceSchema: z.ZodEnum<{
|
|
|
507
512
|
}>;
|
|
508
513
|
declare const SURFACES: ("cowork" | "space_builder")[];
|
|
509
514
|
declare const ExposureSchema: z.ZodType<Surface[], unknown>;
|
|
515
|
+
declare const CatalogModelSchemaBase: z.ZodObject<{
|
|
516
|
+
id: z.ZodString;
|
|
517
|
+
aliases: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
518
|
+
label: z.ZodString;
|
|
519
|
+
type: z.ZodEnum<{
|
|
520
|
+
text: "text";
|
|
521
|
+
image: "image";
|
|
522
|
+
video: "video";
|
|
523
|
+
audio: "audio";
|
|
524
|
+
upscale: "upscale";
|
|
525
|
+
"bg-remove": "bg-remove";
|
|
526
|
+
}>;
|
|
527
|
+
adapter: z.ZodEnum<{
|
|
528
|
+
"ai-sdk-text": "ai-sdk-text";
|
|
529
|
+
"google-image": "google-image";
|
|
530
|
+
"openai-image": "openai-image";
|
|
531
|
+
"google-genai": "google-genai";
|
|
532
|
+
ark: "ark";
|
|
533
|
+
fal: "fal";
|
|
534
|
+
replicate: "replicate";
|
|
535
|
+
prodia: "prodia";
|
|
536
|
+
higgsfield: "higgsfield";
|
|
537
|
+
"xai-video": "xai-video";
|
|
538
|
+
}>;
|
|
539
|
+
providerModelId: z.ZodString;
|
|
540
|
+
lifecycle: z.ZodEnum<{
|
|
541
|
+
active: "active";
|
|
542
|
+
deprecated: "deprecated";
|
|
543
|
+
retired: "retired";
|
|
544
|
+
}>;
|
|
545
|
+
replacedBy: z.ZodOptional<z.ZodString>;
|
|
546
|
+
exposure: z.ZodType<Surface[], unknown, z.core.$ZodTypeInternals<Surface[], unknown>>;
|
|
547
|
+
constraints: z.ZodObject<{
|
|
548
|
+
aspectRatios: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
549
|
+
"1:1": "1:1";
|
|
550
|
+
"16:9": "16:9";
|
|
551
|
+
"9:16": "9:16";
|
|
552
|
+
"4:3": "4:3";
|
|
553
|
+
"3:4": "3:4";
|
|
554
|
+
"3:2": "3:2";
|
|
555
|
+
"2:3": "2:3";
|
|
556
|
+
"4:5": "4:5";
|
|
557
|
+
"5:4": "5:4";
|
|
558
|
+
"21:9": "21:9";
|
|
559
|
+
"9:21": "9:21";
|
|
560
|
+
"97:30": "97:30";
|
|
561
|
+
adaptive: "adaptive";
|
|
562
|
+
}>>>;
|
|
563
|
+
sizes: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
564
|
+
512: "512";
|
|
565
|
+
"1K": "1K";
|
|
566
|
+
"2K": "2K";
|
|
567
|
+
"4K": "4K";
|
|
568
|
+
}>>>;
|
|
569
|
+
resolutions: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
570
|
+
"360p": "360p";
|
|
571
|
+
"480p": "480p";
|
|
572
|
+
"720p": "720p";
|
|
573
|
+
"768p": "768p";
|
|
574
|
+
"1080p": "1080p";
|
|
575
|
+
"2k": "2k";
|
|
576
|
+
"4k": "4k";
|
|
577
|
+
}>>>;
|
|
578
|
+
durations: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
579
|
+
min: z.ZodNumber;
|
|
580
|
+
max: z.ZodNumber;
|
|
581
|
+
}, z.core.$loose>, z.ZodArray<z.ZodNumber>]>>;
|
|
582
|
+
durationPresets: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
583
|
+
qualityOptions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
584
|
+
exactSizes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
585
|
+
references: z.ZodOptional<z.ZodObject<{
|
|
586
|
+
images: z.ZodOptional<z.ZodNumber>;
|
|
587
|
+
imagesWithVideo: z.ZodOptional<z.ZodNumber>;
|
|
588
|
+
videos: z.ZodOptional<z.ZodNumber>;
|
|
589
|
+
audios: z.ZodOptional<z.ZodNumber>;
|
|
590
|
+
total: z.ZodOptional<z.ZodNumber>;
|
|
591
|
+
audioOnly: z.ZodOptional<z.ZodBoolean>;
|
|
592
|
+
}, z.core.$loose>>;
|
|
593
|
+
requires: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
594
|
+
references: "references";
|
|
595
|
+
firstFrame: "firstFrame";
|
|
596
|
+
sourceVideo: "sourceVideo";
|
|
597
|
+
}>>>;
|
|
598
|
+
supports: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
599
|
+
upscale: "upscale";
|
|
600
|
+
quality: "quality";
|
|
601
|
+
seed: "seed";
|
|
602
|
+
count: "count";
|
|
603
|
+
outputFormat: "outputFormat";
|
|
604
|
+
scaleFactor: "scaleFactor";
|
|
605
|
+
safetySettings: "safetySettings";
|
|
606
|
+
temperature: "temperature";
|
|
607
|
+
lastFrame: "lastFrame";
|
|
608
|
+
generateAudio: "generateAudio";
|
|
609
|
+
negativePrompt: "negativePrompt";
|
|
610
|
+
cfgScale: "cfgScale";
|
|
611
|
+
promptExpansion: "promptExpansion";
|
|
612
|
+
watermark: "watermark";
|
|
613
|
+
safetyChecker: "safetyChecker";
|
|
614
|
+
taskType: "taskType";
|
|
615
|
+
instrumental: "instrumental";
|
|
616
|
+
}>>>;
|
|
617
|
+
ratioIgnoredWith: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
618
|
+
firstFrame: "firstFrame";
|
|
619
|
+
sourceVideo: "sourceVideo";
|
|
620
|
+
}>>>;
|
|
621
|
+
}, z.core.$loose>;
|
|
622
|
+
defaults: z.ZodObject<{
|
|
623
|
+
references: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
624
|
+
url: z.ZodString;
|
|
625
|
+
label: z.ZodOptional<z.ZodString>;
|
|
626
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
627
|
+
bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
628
|
+
mime: z.ZodString;
|
|
629
|
+
label: z.ZodOptional<z.ZodString>;
|
|
630
|
+
}, z.core.$loose>]>>>;
|
|
631
|
+
aspectRatio: z.ZodOptional<z.ZodEnum<{
|
|
632
|
+
"1:1": "1:1";
|
|
633
|
+
"16:9": "16:9";
|
|
634
|
+
"9:16": "9:16";
|
|
635
|
+
"4:3": "4:3";
|
|
636
|
+
"3:4": "3:4";
|
|
637
|
+
"3:2": "3:2";
|
|
638
|
+
"2:3": "2:3";
|
|
639
|
+
"4:5": "4:5";
|
|
640
|
+
"5:4": "5:4";
|
|
641
|
+
"21:9": "21:9";
|
|
642
|
+
"9:21": "9:21";
|
|
643
|
+
"97:30": "97:30";
|
|
644
|
+
adaptive: "adaptive";
|
|
645
|
+
}>>;
|
|
646
|
+
size: z.ZodOptional<z.ZodEnum<{
|
|
647
|
+
512: "512";
|
|
648
|
+
"1K": "1K";
|
|
649
|
+
"2K": "2K";
|
|
650
|
+
"4K": "4K";
|
|
651
|
+
}>>;
|
|
652
|
+
exactSize: z.ZodOptional<z.ZodString>;
|
|
653
|
+
quality: z.ZodOptional<z.ZodEnum<{
|
|
654
|
+
auto: "auto";
|
|
655
|
+
low: "low";
|
|
656
|
+
medium: "medium";
|
|
657
|
+
high: "high";
|
|
658
|
+
xhigh: "xhigh";
|
|
659
|
+
max: "max";
|
|
660
|
+
}>>;
|
|
661
|
+
seed: z.ZodOptional<z.ZodNumber>;
|
|
662
|
+
count: z.ZodOptional<z.ZodNumber>;
|
|
663
|
+
outputFormat: z.ZodOptional<z.ZodEnum<{
|
|
664
|
+
png: "png";
|
|
665
|
+
jpeg: "jpeg";
|
|
666
|
+
webp: "webp";
|
|
667
|
+
}>>;
|
|
668
|
+
scaleFactor: z.ZodOptional<z.ZodNumber>;
|
|
669
|
+
safetySettings: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
670
|
+
category: z.ZodString;
|
|
671
|
+
threshold: z.ZodString;
|
|
672
|
+
}, z.core.$loose>>>;
|
|
673
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
674
|
+
upscale: z.ZodOptional<z.ZodObject<{
|
|
675
|
+
enhanceModel: z.ZodOptional<z.ZodString>;
|
|
676
|
+
subjectDetection: z.ZodOptional<z.ZodString>;
|
|
677
|
+
faceEnhancement: z.ZodOptional<z.ZodBoolean>;
|
|
678
|
+
faceEnhancementCreativity: z.ZodOptional<z.ZodNumber>;
|
|
679
|
+
faceEnhancementStrength: z.ZodOptional<z.ZodNumber>;
|
|
680
|
+
}, z.core.$loose>>;
|
|
681
|
+
firstFrame: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
682
|
+
url: z.ZodString;
|
|
683
|
+
label: z.ZodOptional<z.ZodString>;
|
|
684
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
685
|
+
bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
686
|
+
mime: z.ZodString;
|
|
687
|
+
label: z.ZodOptional<z.ZodString>;
|
|
688
|
+
}, z.core.$loose>]>>;
|
|
689
|
+
lastFrame: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
690
|
+
url: z.ZodString;
|
|
691
|
+
label: z.ZodOptional<z.ZodString>;
|
|
692
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
693
|
+
bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
694
|
+
mime: z.ZodString;
|
|
695
|
+
label: z.ZodOptional<z.ZodString>;
|
|
696
|
+
}, z.core.$loose>]>>;
|
|
697
|
+
sourceVideo: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
698
|
+
url: z.ZodString;
|
|
699
|
+
label: z.ZodOptional<z.ZodString>;
|
|
700
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
701
|
+
bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
702
|
+
mime: z.ZodString;
|
|
703
|
+
label: z.ZodOptional<z.ZodString>;
|
|
704
|
+
}, z.core.$loose>]>>;
|
|
705
|
+
referenceImages: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
706
|
+
url: z.ZodString;
|
|
707
|
+
label: z.ZodOptional<z.ZodString>;
|
|
708
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
709
|
+
bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
710
|
+
mime: z.ZodString;
|
|
711
|
+
label: z.ZodOptional<z.ZodString>;
|
|
712
|
+
}, z.core.$loose>]>>>;
|
|
713
|
+
referenceVideos: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
714
|
+
url: z.ZodString;
|
|
715
|
+
label: z.ZodOptional<z.ZodString>;
|
|
716
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
717
|
+
bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
718
|
+
mime: z.ZodString;
|
|
719
|
+
label: z.ZodOptional<z.ZodString>;
|
|
720
|
+
}, z.core.$loose>]>>>;
|
|
721
|
+
referenceAudios: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
722
|
+
url: z.ZodString;
|
|
723
|
+
label: z.ZodOptional<z.ZodString>;
|
|
724
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
725
|
+
bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
726
|
+
mime: z.ZodString;
|
|
727
|
+
label: z.ZodOptional<z.ZodString>;
|
|
728
|
+
}, z.core.$loose>]>>>;
|
|
729
|
+
resolution: z.ZodOptional<z.ZodEnum<{
|
|
730
|
+
"360p": "360p";
|
|
731
|
+
"480p": "480p";
|
|
732
|
+
"720p": "720p";
|
|
733
|
+
"768p": "768p";
|
|
734
|
+
"1080p": "1080p";
|
|
735
|
+
"2k": "2k";
|
|
736
|
+
"4k": "4k";
|
|
737
|
+
}>>;
|
|
738
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
739
|
+
generateAudio: z.ZodOptional<z.ZodBoolean>;
|
|
740
|
+
negativePrompt: z.ZodOptional<z.ZodString>;
|
|
741
|
+
cfgScale: z.ZodOptional<z.ZodNumber>;
|
|
742
|
+
promptExpansion: z.ZodOptional<z.ZodEnum<{
|
|
743
|
+
quality: "quality";
|
|
744
|
+
fast: "fast";
|
|
745
|
+
balanced: "balanced";
|
|
746
|
+
}>>;
|
|
747
|
+
watermark: z.ZodOptional<z.ZodBoolean>;
|
|
748
|
+
safetyChecker: z.ZodOptional<z.ZodBoolean>;
|
|
749
|
+
taskType: z.ZodOptional<z.ZodEnum<{
|
|
750
|
+
reference: "reference";
|
|
751
|
+
edit: "edit";
|
|
752
|
+
extend: "extend";
|
|
753
|
+
}>>;
|
|
754
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
755
|
+
standard: "standard";
|
|
756
|
+
pro: "pro";
|
|
757
|
+
}>>;
|
|
758
|
+
instrumental: z.ZodOptional<z.ZodBoolean>;
|
|
759
|
+
}, z.core.$loose>;
|
|
760
|
+
providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodType<ProviderOptionValue, unknown, z.core.$ZodTypeInternals<ProviderOptionValue, unknown>>>>>;
|
|
761
|
+
usage: z.ZodObject<{
|
|
762
|
+
unit: z.ZodEnum<{
|
|
763
|
+
tokens: "tokens";
|
|
764
|
+
images: "images";
|
|
765
|
+
seconds: "seconds";
|
|
766
|
+
reported_cost_usd: "reported_cost_usd";
|
|
767
|
+
compute_seconds: "compute_seconds";
|
|
768
|
+
}>;
|
|
769
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
770
|
+
providerLabel: z.ZodOptional<z.ZodString>;
|
|
771
|
+
}, z.core.$loose>;
|
|
772
|
+
pricingKind: z.ZodEnum<{
|
|
773
|
+
token: "token";
|
|
774
|
+
image_size: "image_size";
|
|
775
|
+
video_per_second: "video_per_second";
|
|
776
|
+
flat: "flat";
|
|
777
|
+
}>;
|
|
778
|
+
display: z.ZodOptional<z.ZodObject<{
|
|
779
|
+
provider: z.ZodString;
|
|
780
|
+
description: z.ZodString;
|
|
781
|
+
logo: z.ZodOptional<z.ZodString>;
|
|
782
|
+
costTier: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>]>>;
|
|
783
|
+
recommended: z.ZodOptional<z.ZodBoolean>;
|
|
784
|
+
sortOrder: z.ZodOptional<z.ZodNumber>;
|
|
785
|
+
chat: z.ZodOptional<z.ZodObject<{
|
|
786
|
+
providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodType<ProviderOptionValue, unknown, z.core.$ZodTypeInternals<ProviderOptionValue, unknown>>>>>;
|
|
787
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
788
|
+
}, z.core.$loose>>;
|
|
789
|
+
}, z.core.$loose>>;
|
|
790
|
+
capabilities: z.ZodOptional<z.ZodObject<{
|
|
791
|
+
acceptsSourceVideo: z.ZodOptional<z.ZodBoolean>;
|
|
792
|
+
framesExcludeReferences: z.ZodOptional<z.ZodBoolean>;
|
|
793
|
+
reasoning: z.ZodOptional<z.ZodBoolean>;
|
|
794
|
+
vision: z.ZodOptional<z.ZodBoolean>;
|
|
795
|
+
contextWindow: z.ZodOptional<z.ZodNumber>;
|
|
796
|
+
}, z.core.$loose>>;
|
|
797
|
+
}, z.core.$loose>;
|
|
510
798
|
declare const CatalogModelSchema: z.ZodType<CatalogModel>;
|
|
511
799
|
declare const CatalogSchema: z.ZodType<CatalogModel[]>;
|
|
512
800
|
|
|
801
|
+
declare const VIDEO_INPUT_SPEC_KEYS: readonly ["prompt", "durationSeconds", "aspectRatio", "resolution", "firstFrame", "lastFrame", "seed", "negativePrompt", "generateAudio", "cfgScale", "promptExpansion", "referenceImages"];
|
|
802
|
+
declare const AUDIO_INPUT_SPEC_KEYS: readonly ["prompt", "durationSeconds", "seed", "negativePrompt", "references", "sourceVideo", "instrumental"];
|
|
803
|
+
type InputSpecKey = (typeof VIDEO_INPUT_SPEC_KEYS)[number] | (typeof AUDIO_INPUT_SPEC_KEYS)[number];
|
|
804
|
+
declare const INPUT_SPEC_SUPPORTS_KEYS: readonly SupportedOption[];
|
|
805
|
+
declare const InputSpecSchema: z.ZodObject<{
|
|
806
|
+
fields: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
807
|
+
values: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>>;
|
|
808
|
+
static: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
809
|
+
}, z.core.$strict>;
|
|
810
|
+
type InputSpec = z.infer<typeof InputSpecSchema>;
|
|
811
|
+
interface InputSpecIssue {
|
|
812
|
+
path: PropertyKey[];
|
|
813
|
+
message: string;
|
|
814
|
+
}
|
|
815
|
+
interface ValidateRow {
|
|
816
|
+
type: string;
|
|
817
|
+
adapter: string;
|
|
818
|
+
constraints: {
|
|
819
|
+
supports?: readonly SupportedOption[] | undefined;
|
|
820
|
+
};
|
|
821
|
+
}
|
|
822
|
+
declare function isInputSpecKey(key: string): key is InputSpecKey;
|
|
823
|
+
declare function validateInputSpec(raw: ProviderOptionValue, row: ValidateRow): {
|
|
824
|
+
ok: true;
|
|
825
|
+
spec: InputSpec;
|
|
826
|
+
} | {
|
|
827
|
+
ok: false;
|
|
828
|
+
issues: InputSpecIssue[];
|
|
829
|
+
};
|
|
830
|
+
|
|
831
|
+
declare const ANTHROPIC_TRANSPORTS: readonly ["direct", "bedrock"];
|
|
832
|
+
type AnthropicTransport = (typeof ANTHROPIC_TRANSPORTS)[number];
|
|
833
|
+
|
|
834
|
+
/** Everything an adapter needs for one call. Resolved by the core before dispatch. */
|
|
835
|
+
interface AdapterContext {
|
|
836
|
+
model: CatalogModel;
|
|
837
|
+
keys: ProviderKeys;
|
|
838
|
+
routing: Routing;
|
|
839
|
+
/** Resolved transport of an Anthropic text row (see anthropic-transport.ts); unset means direct. */
|
|
840
|
+
anthropicTransport?: AnthropicTransport;
|
|
841
|
+
endpoints?: AdapterEndpoints;
|
|
842
|
+
fetch: typeof fetch;
|
|
843
|
+
logger: Pick<Console, "debug" | "info" | "warn" | "error">;
|
|
844
|
+
signal?: AbortSignal;
|
|
845
|
+
call: CallContext;
|
|
846
|
+
warnings: Warning[];
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* One adapter per provider API. The request the adapter receives has already
|
|
850
|
+
* passed resolveOptions: every option is inside the catalog constraints and the
|
|
851
|
+
* catalog defaults are filled in.
|
|
852
|
+
*/
|
|
853
|
+
interface Adapter {
|
|
854
|
+
id: string;
|
|
855
|
+
generateImage?(req: ImageRequest, ctx: AdapterContext): Promise<ImageResult>;
|
|
856
|
+
generateVideo?(req: VideoRequest, ctx: AdapterContext): Promise<VideoJob>;
|
|
857
|
+
generateAudio?(req: AudioRequest, ctx: AdapterContext): Promise<AudioResult>;
|
|
858
|
+
/**
|
|
859
|
+
* Turn a media reference into an AI SDK file part the provider's language
|
|
860
|
+
* model accepts. Google uploads large videos through the Files API.
|
|
861
|
+
*/
|
|
862
|
+
prepareMediaPart?(ref: MediaRef, mediaType: string, ctx: AdapterContext): Promise<MediaPart>;
|
|
863
|
+
/** Text: return an AI SDK LanguageModel for streamText / generateText. */
|
|
864
|
+
languageModel?(ctx: AdapterContext): LanguageModelV3;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
type DataOnlyRow = Pick<CatalogModel, "type" | "adapter" | "providerModelId" | "providerOptions" | "constraints">;
|
|
868
|
+
type DataOnlyVerdict = {
|
|
869
|
+
ok: true;
|
|
870
|
+
} | {
|
|
871
|
+
ok: false;
|
|
872
|
+
reason: string;
|
|
873
|
+
};
|
|
874
|
+
declare function adapterServesType(adapter: Adapter | undefined, type: DataOnlyRow["type"]): boolean;
|
|
875
|
+
declare function dataOnlyCapable(row: DataOnlyRow): DataOnlyVerdict;
|
|
876
|
+
|
|
513
877
|
type CatalogOrigin = "remote" | "last-good" | "snapshot";
|
|
514
878
|
interface PrimeCatalogResult {
|
|
515
879
|
origin: CatalogOrigin;
|
|
516
880
|
rowCount: number;
|
|
517
881
|
revision?: string;
|
|
518
882
|
error?: string;
|
|
883
|
+
droppedRows?: number;
|
|
519
884
|
}
|
|
520
885
|
interface LiveCatalogState {
|
|
521
886
|
catalog: Catalog;
|
|
@@ -553,6 +918,10 @@ interface CatalogEnvelope {
|
|
|
553
918
|
rows: CatalogModel[];
|
|
554
919
|
revision?: string;
|
|
555
920
|
}
|
|
921
|
+
interface QuarantineResult {
|
|
922
|
+
rows: CatalogModel[];
|
|
923
|
+
dropped: number;
|
|
924
|
+
}
|
|
556
925
|
/** Fetch, validate, swap into liveCatalog. Never throws. Second call returns the same promise. */
|
|
557
926
|
declare function primeCatalog(source: CatalogSource): Promise<PrimeCatalogResult>;
|
|
558
927
|
/** Test seam: stop the refresh timer, reset liveCatalog to MODELS and clear the memo. */
|
|
@@ -607,42 +976,6 @@ declare function pollUntil<T>(check: () => Promise<T | undefined>, opts: {
|
|
|
607
976
|
maxIntervalMs?: number;
|
|
608
977
|
}): Promise<T>;
|
|
609
978
|
|
|
610
|
-
declare const ANTHROPIC_TRANSPORTS: readonly ["direct", "bedrock"];
|
|
611
|
-
type AnthropicTransport = (typeof ANTHROPIC_TRANSPORTS)[number];
|
|
612
|
-
|
|
613
|
-
/** Everything an adapter needs for one call. Resolved by the core before dispatch. */
|
|
614
|
-
interface AdapterContext {
|
|
615
|
-
model: CatalogModel;
|
|
616
|
-
keys: ProviderKeys;
|
|
617
|
-
routing: Routing;
|
|
618
|
-
/** Resolved transport of an Anthropic text row (see anthropic-transport.ts); unset means direct. */
|
|
619
|
-
anthropicTransport?: AnthropicTransport;
|
|
620
|
-
endpoints?: AdapterEndpoints;
|
|
621
|
-
fetch: typeof fetch;
|
|
622
|
-
logger: Pick<Console, "debug" | "info" | "warn" | "error">;
|
|
623
|
-
signal?: AbortSignal;
|
|
624
|
-
call: CallContext;
|
|
625
|
-
warnings: Warning[];
|
|
626
|
-
}
|
|
627
|
-
/**
|
|
628
|
-
* One adapter per provider API. The request the adapter receives has already
|
|
629
|
-
* passed resolveOptions: every option is inside the catalog constraints and the
|
|
630
|
-
* catalog defaults are filled in.
|
|
631
|
-
*/
|
|
632
|
-
interface Adapter {
|
|
633
|
-
id: string;
|
|
634
|
-
generateImage?(req: ImageRequest, ctx: AdapterContext): Promise<ImageResult>;
|
|
635
|
-
generateVideo?(req: VideoRequest, ctx: AdapterContext): Promise<VideoJob>;
|
|
636
|
-
generateAudio?(req: AudioRequest, ctx: AdapterContext): Promise<AudioResult>;
|
|
637
|
-
/**
|
|
638
|
-
* Turn a media reference into an AI SDK file part the provider's language
|
|
639
|
-
* model accepts. Google uploads large videos through the Files API.
|
|
640
|
-
*/
|
|
641
|
-
prepareMediaPart?(ref: MediaRef, mediaType: string, ctx: AdapterContext): Promise<MediaPart>;
|
|
642
|
-
/** Text: return an AI SDK LanguageModel for streamText / generateText. */
|
|
643
|
-
languageModel?(ctx: AdapterContext): LanguageModelV3;
|
|
644
|
-
}
|
|
645
|
-
|
|
646
979
|
/**
|
|
647
980
|
* The AI SDK `LanguageModel` type. A string is a catalog id or alias; a provider
|
|
648
981
|
* instance (`openai("gpt-4o")`) runs through the SDK unchanged, with usage
|
|
@@ -773,7 +1106,7 @@ declare const replicateAdapter: Adapter;
|
|
|
773
1106
|
|
|
774
1107
|
declare const xaiVideoAdapter: Adapter;
|
|
775
1108
|
|
|
776
|
-
declare const DEFAULT_ADAPTERS:
|
|
1109
|
+
declare const DEFAULT_ADAPTERS: Record<AdapterId, Adapter>;
|
|
777
1110
|
|
|
778
1111
|
/**
|
|
779
1112
|
* All adapters registered. Keys default to process.env (pro = bare names,
|
|
@@ -810,4 +1143,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
|
|
|
810
1143
|
/** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
|
|
811
1144
|
declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
|
|
812
1145
|
|
|
813
|
-
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 CatalogEnvelope, type CatalogModel, CatalogModelSchema, type CatalogOrigin, CatalogSchema, type CatalogSource, type CatalogTextModel, DEFAULT_ADAPTERS, type DefaultObjectOutput, type Exposure, ExposureSchema, 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 RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, 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, compareCatalogOrder, createDefaultModelKit, createModelKit, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, 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, withRetry, xaiVideoAdapter };
|
|
1146
|
+
export { ADAPTER_IDS, ADAPTER_KEYS, AUDIO_INPUT_SPEC_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 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 ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, 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 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, withRetry, xaiVideoAdapter };
|