aieo 0.1.27 → 0.1.29
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.cjs +1263 -306
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +1261 -304
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6,8 +6,8 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __export = (target, all) => {
|
|
9
|
-
for (var
|
|
10
|
-
__defProp(target,
|
|
9
|
+
for (var name17 in all)
|
|
10
|
+
__defProp(target, name17, { get: all[name17], enumerable: true });
|
|
11
11
|
};
|
|
12
12
|
var __copyProps = (to, from, except, desc) => {
|
|
13
13
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -173,7 +173,7 @@ var ConversationStorage = class {
|
|
|
173
173
|
}
|
|
174
174
|
};
|
|
175
175
|
|
|
176
|
-
// node_modules/@ai-sdk/provider/dist/index.mjs
|
|
176
|
+
// ../../node_modules/@ai-sdk/anthropic/node_modules/@ai-sdk/provider/dist/index.mjs
|
|
177
177
|
var marker = "vercel.ai.error";
|
|
178
178
|
var symbol = Symbol.for(marker);
|
|
179
179
|
var _a;
|
|
@@ -188,13 +188,13 @@ var AISDKError = class _AISDKError extends (_b = Error, _a = symbol, _b) {
|
|
|
188
188
|
* @param {unknown} [params.cause] - The underlying cause of the error.
|
|
189
189
|
*/
|
|
190
190
|
constructor({
|
|
191
|
-
name:
|
|
191
|
+
name: name142,
|
|
192
192
|
message,
|
|
193
193
|
cause
|
|
194
194
|
}) {
|
|
195
195
|
super(message);
|
|
196
196
|
this[_a] = true;
|
|
197
|
-
this.name =
|
|
197
|
+
this.name = name142;
|
|
198
198
|
this.cause = cause;
|
|
199
199
|
}
|
|
200
200
|
/**
|
|
@@ -205,8 +205,8 @@ var AISDKError = class _AISDKError extends (_b = Error, _a = symbol, _b) {
|
|
|
205
205
|
static isInstance(error) {
|
|
206
206
|
return _AISDKError.hasMarker(error, marker);
|
|
207
207
|
}
|
|
208
|
-
static hasMarker(error,
|
|
209
|
-
const markerSymbol = Symbol.for(
|
|
208
|
+
static hasMarker(error, marker152) {
|
|
209
|
+
const markerSymbol = Symbol.for(marker152);
|
|
210
210
|
return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
|
|
211
211
|
}
|
|
212
212
|
};
|
|
@@ -492,7 +492,326 @@ var UnsupportedFunctionalityError = class extends (_b14 = AISDKError, _a14 = sym
|
|
|
492
492
|
}
|
|
493
493
|
};
|
|
494
494
|
|
|
495
|
-
// node_modules/@ai-sdk/provider-utils/dist/index.mjs
|
|
495
|
+
// ../../node_modules/@ai-sdk/provider-utils/node_modules/@ai-sdk/provider/dist/index.mjs
|
|
496
|
+
var marker15 = "vercel.ai.error";
|
|
497
|
+
var symbol15 = Symbol.for(marker15);
|
|
498
|
+
var _a15;
|
|
499
|
+
var _b15;
|
|
500
|
+
var AISDKError2 = class _AISDKError2 extends (_b15 = Error, _a15 = symbol15, _b15) {
|
|
501
|
+
/**
|
|
502
|
+
* Creates an AI SDK Error.
|
|
503
|
+
*
|
|
504
|
+
* @param {Object} params - The parameters for creating the error.
|
|
505
|
+
* @param {string} params.name - The name of the error.
|
|
506
|
+
* @param {string} params.message - The error message.
|
|
507
|
+
* @param {unknown} [params.cause] - The underlying cause of the error.
|
|
508
|
+
*/
|
|
509
|
+
constructor({
|
|
510
|
+
name: name142,
|
|
511
|
+
message,
|
|
512
|
+
cause
|
|
513
|
+
}) {
|
|
514
|
+
super(message);
|
|
515
|
+
this[_a15] = true;
|
|
516
|
+
this.name = name142;
|
|
517
|
+
this.cause = cause;
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Checks if the given error is an AI SDK Error.
|
|
521
|
+
* @param {unknown} error - The error to check.
|
|
522
|
+
* @returns {boolean} True if the error is an AI SDK Error, false otherwise.
|
|
523
|
+
*/
|
|
524
|
+
static isInstance(error) {
|
|
525
|
+
return _AISDKError2.hasMarker(error, marker15);
|
|
526
|
+
}
|
|
527
|
+
static hasMarker(error, marker152) {
|
|
528
|
+
const markerSymbol = Symbol.for(marker152);
|
|
529
|
+
return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
|
|
530
|
+
}
|
|
531
|
+
};
|
|
532
|
+
var name14 = "AI_APICallError";
|
|
533
|
+
var marker22 = `vercel.ai.error.${name14}`;
|
|
534
|
+
var symbol22 = Symbol.for(marker22);
|
|
535
|
+
var _a22;
|
|
536
|
+
var _b22;
|
|
537
|
+
var APICallError2 = class extends (_b22 = AISDKError2, _a22 = symbol22, _b22) {
|
|
538
|
+
constructor({
|
|
539
|
+
message,
|
|
540
|
+
url,
|
|
541
|
+
requestBodyValues,
|
|
542
|
+
statusCode,
|
|
543
|
+
responseHeaders,
|
|
544
|
+
responseBody,
|
|
545
|
+
cause,
|
|
546
|
+
isRetryable = statusCode != null && (statusCode === 408 || // request timeout
|
|
547
|
+
statusCode === 409 || // conflict
|
|
548
|
+
statusCode === 429 || // too many requests
|
|
549
|
+
statusCode >= 500),
|
|
550
|
+
// server error
|
|
551
|
+
data
|
|
552
|
+
}) {
|
|
553
|
+
super({ name: name14, message, cause });
|
|
554
|
+
this[_a22] = true;
|
|
555
|
+
this.url = url;
|
|
556
|
+
this.requestBodyValues = requestBodyValues;
|
|
557
|
+
this.statusCode = statusCode;
|
|
558
|
+
this.responseHeaders = responseHeaders;
|
|
559
|
+
this.responseBody = responseBody;
|
|
560
|
+
this.isRetryable = isRetryable;
|
|
561
|
+
this.data = data;
|
|
562
|
+
}
|
|
563
|
+
static isInstance(error) {
|
|
564
|
+
return AISDKError2.hasMarker(error, marker22);
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
var name22 = "AI_EmptyResponseBodyError";
|
|
568
|
+
var marker32 = `vercel.ai.error.${name22}`;
|
|
569
|
+
var symbol32 = Symbol.for(marker32);
|
|
570
|
+
var _a32;
|
|
571
|
+
var _b32;
|
|
572
|
+
var EmptyResponseBodyError2 = class extends (_b32 = AISDKError2, _a32 = symbol32, _b32) {
|
|
573
|
+
// used in isInstance
|
|
574
|
+
constructor({ message = "Empty response body" } = {}) {
|
|
575
|
+
super({ name: name22, message });
|
|
576
|
+
this[_a32] = true;
|
|
577
|
+
}
|
|
578
|
+
static isInstance(error) {
|
|
579
|
+
return AISDKError2.hasMarker(error, marker32);
|
|
580
|
+
}
|
|
581
|
+
};
|
|
582
|
+
function getErrorMessage2(error) {
|
|
583
|
+
if (error == null) {
|
|
584
|
+
return "unknown error";
|
|
585
|
+
}
|
|
586
|
+
if (typeof error === "string") {
|
|
587
|
+
return error;
|
|
588
|
+
}
|
|
589
|
+
if (error instanceof Error) {
|
|
590
|
+
return error.message;
|
|
591
|
+
}
|
|
592
|
+
return JSON.stringify(error);
|
|
593
|
+
}
|
|
594
|
+
var name32 = "AI_InvalidArgumentError";
|
|
595
|
+
var marker42 = `vercel.ai.error.${name32}`;
|
|
596
|
+
var symbol42 = Symbol.for(marker42);
|
|
597
|
+
var _a42;
|
|
598
|
+
var _b42;
|
|
599
|
+
var InvalidArgumentError2 = class extends (_b42 = AISDKError2, _a42 = symbol42, _b42) {
|
|
600
|
+
constructor({
|
|
601
|
+
message,
|
|
602
|
+
cause,
|
|
603
|
+
argument
|
|
604
|
+
}) {
|
|
605
|
+
super({ name: name32, message, cause });
|
|
606
|
+
this[_a42] = true;
|
|
607
|
+
this.argument = argument;
|
|
608
|
+
}
|
|
609
|
+
static isInstance(error) {
|
|
610
|
+
return AISDKError2.hasMarker(error, marker42);
|
|
611
|
+
}
|
|
612
|
+
};
|
|
613
|
+
var name42 = "AI_InvalidPromptError";
|
|
614
|
+
var marker52 = `vercel.ai.error.${name42}`;
|
|
615
|
+
var symbol52 = Symbol.for(marker52);
|
|
616
|
+
var _a52;
|
|
617
|
+
var _b52;
|
|
618
|
+
var InvalidPromptError2 = class extends (_b52 = AISDKError2, _a52 = symbol52, _b52) {
|
|
619
|
+
constructor({
|
|
620
|
+
prompt,
|
|
621
|
+
message,
|
|
622
|
+
cause
|
|
623
|
+
}) {
|
|
624
|
+
super({ name: name42, message: `Invalid prompt: ${message}`, cause });
|
|
625
|
+
this[_a52] = true;
|
|
626
|
+
this.prompt = prompt;
|
|
627
|
+
}
|
|
628
|
+
static isInstance(error) {
|
|
629
|
+
return AISDKError2.hasMarker(error, marker52);
|
|
630
|
+
}
|
|
631
|
+
};
|
|
632
|
+
var name52 = "AI_InvalidResponseDataError";
|
|
633
|
+
var marker62 = `vercel.ai.error.${name52}`;
|
|
634
|
+
var symbol62 = Symbol.for(marker62);
|
|
635
|
+
var _a62;
|
|
636
|
+
var _b62;
|
|
637
|
+
var InvalidResponseDataError2 = class extends (_b62 = AISDKError2, _a62 = symbol62, _b62) {
|
|
638
|
+
constructor({
|
|
639
|
+
data,
|
|
640
|
+
message = `Invalid response data: ${JSON.stringify(data)}.`
|
|
641
|
+
}) {
|
|
642
|
+
super({ name: name52, message });
|
|
643
|
+
this[_a62] = true;
|
|
644
|
+
this.data = data;
|
|
645
|
+
}
|
|
646
|
+
static isInstance(error) {
|
|
647
|
+
return AISDKError2.hasMarker(error, marker62);
|
|
648
|
+
}
|
|
649
|
+
};
|
|
650
|
+
var name62 = "AI_JSONParseError";
|
|
651
|
+
var marker72 = `vercel.ai.error.${name62}`;
|
|
652
|
+
var symbol72 = Symbol.for(marker72);
|
|
653
|
+
var _a72;
|
|
654
|
+
var _b72;
|
|
655
|
+
var JSONParseError2 = class extends (_b72 = AISDKError2, _a72 = symbol72, _b72) {
|
|
656
|
+
constructor({ text, cause }) {
|
|
657
|
+
super({
|
|
658
|
+
name: name62,
|
|
659
|
+
message: `JSON parsing failed: Text: ${text}.
|
|
660
|
+
Error message: ${getErrorMessage2(cause)}`,
|
|
661
|
+
cause
|
|
662
|
+
});
|
|
663
|
+
this[_a72] = true;
|
|
664
|
+
this.text = text;
|
|
665
|
+
}
|
|
666
|
+
static isInstance(error) {
|
|
667
|
+
return AISDKError2.hasMarker(error, marker72);
|
|
668
|
+
}
|
|
669
|
+
};
|
|
670
|
+
var name72 = "AI_LoadAPIKeyError";
|
|
671
|
+
var marker82 = `vercel.ai.error.${name72}`;
|
|
672
|
+
var symbol82 = Symbol.for(marker82);
|
|
673
|
+
var _a82;
|
|
674
|
+
var _b82;
|
|
675
|
+
var LoadAPIKeyError2 = class extends (_b82 = AISDKError2, _a82 = symbol82, _b82) {
|
|
676
|
+
// used in isInstance
|
|
677
|
+
constructor({ message }) {
|
|
678
|
+
super({ name: name72, message });
|
|
679
|
+
this[_a82] = true;
|
|
680
|
+
}
|
|
681
|
+
static isInstance(error) {
|
|
682
|
+
return AISDKError2.hasMarker(error, marker82);
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
var name82 = "AI_LoadSettingError";
|
|
686
|
+
var marker92 = `vercel.ai.error.${name82}`;
|
|
687
|
+
var symbol92 = Symbol.for(marker92);
|
|
688
|
+
var _a92;
|
|
689
|
+
var _b92;
|
|
690
|
+
var LoadSettingError2 = class extends (_b92 = AISDKError2, _a92 = symbol92, _b92) {
|
|
691
|
+
// used in isInstance
|
|
692
|
+
constructor({ message }) {
|
|
693
|
+
super({ name: name82, message });
|
|
694
|
+
this[_a92] = true;
|
|
695
|
+
}
|
|
696
|
+
static isInstance(error) {
|
|
697
|
+
return AISDKError2.hasMarker(error, marker92);
|
|
698
|
+
}
|
|
699
|
+
};
|
|
700
|
+
var name92 = "AI_NoContentGeneratedError";
|
|
701
|
+
var marker102 = `vercel.ai.error.${name92}`;
|
|
702
|
+
var symbol102 = Symbol.for(marker102);
|
|
703
|
+
var _a102;
|
|
704
|
+
var _b102;
|
|
705
|
+
var NoContentGeneratedError2 = class extends (_b102 = AISDKError2, _a102 = symbol102, _b102) {
|
|
706
|
+
// used in isInstance
|
|
707
|
+
constructor({
|
|
708
|
+
message = "No content generated."
|
|
709
|
+
} = {}) {
|
|
710
|
+
super({ name: name92, message });
|
|
711
|
+
this[_a102] = true;
|
|
712
|
+
}
|
|
713
|
+
static isInstance(error) {
|
|
714
|
+
return AISDKError2.hasMarker(error, marker102);
|
|
715
|
+
}
|
|
716
|
+
};
|
|
717
|
+
var name102 = "AI_NoSuchModelError";
|
|
718
|
+
var marker112 = `vercel.ai.error.${name102}`;
|
|
719
|
+
var symbol112 = Symbol.for(marker112);
|
|
720
|
+
var _a112;
|
|
721
|
+
var _b112;
|
|
722
|
+
var NoSuchModelError2 = class extends (_b112 = AISDKError2, _a112 = symbol112, _b112) {
|
|
723
|
+
constructor({
|
|
724
|
+
errorName = name102,
|
|
725
|
+
modelId,
|
|
726
|
+
modelType,
|
|
727
|
+
message = `No such ${modelType}: ${modelId}`
|
|
728
|
+
}) {
|
|
729
|
+
super({ name: errorName, message });
|
|
730
|
+
this[_a112] = true;
|
|
731
|
+
this.modelId = modelId;
|
|
732
|
+
this.modelType = modelType;
|
|
733
|
+
}
|
|
734
|
+
static isInstance(error) {
|
|
735
|
+
return AISDKError2.hasMarker(error, marker112);
|
|
736
|
+
}
|
|
737
|
+
};
|
|
738
|
+
var name112 = "AI_TooManyEmbeddingValuesForCallError";
|
|
739
|
+
var marker122 = `vercel.ai.error.${name112}`;
|
|
740
|
+
var symbol122 = Symbol.for(marker122);
|
|
741
|
+
var _a122;
|
|
742
|
+
var _b122;
|
|
743
|
+
var TooManyEmbeddingValuesForCallError2 = class extends (_b122 = AISDKError2, _a122 = symbol122, _b122) {
|
|
744
|
+
constructor(options) {
|
|
745
|
+
super({
|
|
746
|
+
name: name112,
|
|
747
|
+
message: `Too many values for a single embedding call. The ${options.provider} model "${options.modelId}" can only embed up to ${options.maxEmbeddingsPerCall} values per call, but ${options.values.length} values were provided.`
|
|
748
|
+
});
|
|
749
|
+
this[_a122] = true;
|
|
750
|
+
this.provider = options.provider;
|
|
751
|
+
this.modelId = options.modelId;
|
|
752
|
+
this.maxEmbeddingsPerCall = options.maxEmbeddingsPerCall;
|
|
753
|
+
this.values = options.values;
|
|
754
|
+
}
|
|
755
|
+
static isInstance(error) {
|
|
756
|
+
return AISDKError2.hasMarker(error, marker122);
|
|
757
|
+
}
|
|
758
|
+
};
|
|
759
|
+
var name122 = "AI_TypeValidationError";
|
|
760
|
+
var marker132 = `vercel.ai.error.${name122}`;
|
|
761
|
+
var symbol132 = Symbol.for(marker132);
|
|
762
|
+
var _a132;
|
|
763
|
+
var _b132;
|
|
764
|
+
var TypeValidationError2 = class _TypeValidationError2 extends (_b132 = AISDKError2, _a132 = symbol132, _b132) {
|
|
765
|
+
constructor({ value, cause }) {
|
|
766
|
+
super({
|
|
767
|
+
name: name122,
|
|
768
|
+
message: `Type validation failed: Value: ${JSON.stringify(value)}.
|
|
769
|
+
Error message: ${getErrorMessage2(cause)}`,
|
|
770
|
+
cause
|
|
771
|
+
});
|
|
772
|
+
this[_a132] = true;
|
|
773
|
+
this.value = value;
|
|
774
|
+
}
|
|
775
|
+
static isInstance(error) {
|
|
776
|
+
return AISDKError2.hasMarker(error, marker132);
|
|
777
|
+
}
|
|
778
|
+
/**
|
|
779
|
+
* Wraps an error into a TypeValidationError.
|
|
780
|
+
* If the cause is already a TypeValidationError with the same value, it returns the cause.
|
|
781
|
+
* Otherwise, it creates a new TypeValidationError.
|
|
782
|
+
*
|
|
783
|
+
* @param {Object} params - The parameters for wrapping the error.
|
|
784
|
+
* @param {unknown} params.value - The value that failed validation.
|
|
785
|
+
* @param {unknown} params.cause - The original error or cause of the validation failure.
|
|
786
|
+
* @returns {TypeValidationError} A TypeValidationError instance.
|
|
787
|
+
*/
|
|
788
|
+
static wrap({
|
|
789
|
+
value,
|
|
790
|
+
cause
|
|
791
|
+
}) {
|
|
792
|
+
return _TypeValidationError2.isInstance(cause) && cause.value === value ? cause : new _TypeValidationError2({ value, cause });
|
|
793
|
+
}
|
|
794
|
+
};
|
|
795
|
+
var name132 = "AI_UnsupportedFunctionalityError";
|
|
796
|
+
var marker142 = `vercel.ai.error.${name132}`;
|
|
797
|
+
var symbol142 = Symbol.for(marker142);
|
|
798
|
+
var _a142;
|
|
799
|
+
var _b142;
|
|
800
|
+
var UnsupportedFunctionalityError2 = class extends (_b142 = AISDKError2, _a142 = symbol142, _b142) {
|
|
801
|
+
constructor({
|
|
802
|
+
functionality,
|
|
803
|
+
message = `'${functionality}' functionality not supported.`
|
|
804
|
+
}) {
|
|
805
|
+
super({ name: name132, message });
|
|
806
|
+
this[_a142] = true;
|
|
807
|
+
this.functionality = functionality;
|
|
808
|
+
}
|
|
809
|
+
static isInstance(error) {
|
|
810
|
+
return AISDKError2.hasMarker(error, marker142);
|
|
811
|
+
}
|
|
812
|
+
};
|
|
813
|
+
|
|
814
|
+
// ../../node_modules/@ai-sdk/provider-utils/dist/index.mjs
|
|
496
815
|
var z4 = __toESM(require("zod/v4"), 1);
|
|
497
816
|
var import_v3 = require("zod/v3");
|
|
498
817
|
var import_v32 = require("zod/v3");
|
|
@@ -625,7 +944,7 @@ var EventSourceParserStream = class extends TransformStream {
|
|
|
625
944
|
}
|
|
626
945
|
};
|
|
627
946
|
|
|
628
|
-
// node_modules/@ai-sdk/provider-utils/dist/index.mjs
|
|
947
|
+
// ../../node_modules/@ai-sdk/provider-utils/dist/index.mjs
|
|
629
948
|
function combineHeaders(...headers) {
|
|
630
949
|
return headers.reduce(
|
|
631
950
|
(combinedHeaders, currentHeaders) => ({
|
|
@@ -650,12 +969,12 @@ function createToolNameMapping({
|
|
|
650
969
|
}
|
|
651
970
|
return {
|
|
652
971
|
toProviderToolName: (customToolName) => {
|
|
653
|
-
var
|
|
654
|
-
return (
|
|
972
|
+
var _a18;
|
|
973
|
+
return (_a18 = customToolNameToProviderToolName[customToolName]) != null ? _a18 : customToolName;
|
|
655
974
|
},
|
|
656
975
|
toCustomToolName: (providerToolName) => {
|
|
657
|
-
var
|
|
658
|
-
return (
|
|
976
|
+
var _a18;
|
|
977
|
+
return (_a18 = providerToolNameToCustomToolName[providerToolName]) != null ? _a18 : providerToolName;
|
|
659
978
|
}
|
|
660
979
|
};
|
|
661
980
|
}
|
|
@@ -681,17 +1000,17 @@ var DelayedPromise = class {
|
|
|
681
1000
|
return this._promise;
|
|
682
1001
|
}
|
|
683
1002
|
resolve(value) {
|
|
684
|
-
var
|
|
1003
|
+
var _a18;
|
|
685
1004
|
this.status = { type: "resolved", value };
|
|
686
1005
|
if (this._promise) {
|
|
687
|
-
(
|
|
1006
|
+
(_a18 = this._resolve) == null ? void 0 : _a18.call(this, value);
|
|
688
1007
|
}
|
|
689
1008
|
}
|
|
690
1009
|
reject(error) {
|
|
691
|
-
var
|
|
1010
|
+
var _a18;
|
|
692
1011
|
this.status = { type: "rejected", error };
|
|
693
1012
|
if (this._promise) {
|
|
694
|
-
(
|
|
1013
|
+
(_a18 = this._reject) == null ? void 0 : _a18.call(this, error);
|
|
695
1014
|
}
|
|
696
1015
|
}
|
|
697
1016
|
isResolved() {
|
|
@@ -725,7 +1044,7 @@ var createIdGenerator = ({
|
|
|
725
1044
|
return generator;
|
|
726
1045
|
}
|
|
727
1046
|
if (alphabet.includes(separator)) {
|
|
728
|
-
throw new
|
|
1047
|
+
throw new InvalidArgumentError2({
|
|
729
1048
|
argument: "separator",
|
|
730
1049
|
message: `The separator "${separator}" must not be part of the alphabet "${alphabet}".`
|
|
731
1050
|
});
|
|
@@ -749,7 +1068,7 @@ function handleFetchError({
|
|
|
749
1068
|
if (error instanceof TypeError && FETCH_FAILED_ERROR_MESSAGES.includes(error.message.toLowerCase())) {
|
|
750
1069
|
const cause = error.cause;
|
|
751
1070
|
if (cause != null) {
|
|
752
|
-
return new
|
|
1071
|
+
return new APICallError2({
|
|
753
1072
|
message: `Cannot connect to API: ${cause.message}`,
|
|
754
1073
|
cause,
|
|
755
1074
|
url,
|
|
@@ -762,14 +1081,14 @@ function handleFetchError({
|
|
|
762
1081
|
return error;
|
|
763
1082
|
}
|
|
764
1083
|
function getRuntimeEnvironmentUserAgent(globalThisAny = globalThis) {
|
|
765
|
-
var
|
|
1084
|
+
var _a18, _b18, _c;
|
|
766
1085
|
if (globalThisAny.window) {
|
|
767
1086
|
return `runtime/browser`;
|
|
768
1087
|
}
|
|
769
|
-
if ((
|
|
1088
|
+
if ((_a18 = globalThisAny.navigator) == null ? void 0 : _a18.userAgent) {
|
|
770
1089
|
return `runtime/${globalThisAny.navigator.userAgent.toLowerCase()}`;
|
|
771
1090
|
}
|
|
772
|
-
if ((_c = (
|
|
1091
|
+
if ((_c = (_b18 = globalThisAny.process) == null ? void 0 : _b18.versions) == null ? void 0 : _c.node) {
|
|
773
1092
|
return `runtime/node.js/${globalThisAny.process.version.substring(0)}`;
|
|
774
1093
|
}
|
|
775
1094
|
if (globalThisAny.EdgeRuntime) {
|
|
@@ -821,23 +1140,23 @@ function loadApiKey({
|
|
|
821
1140
|
return apiKey;
|
|
822
1141
|
}
|
|
823
1142
|
if (apiKey != null) {
|
|
824
|
-
throw new
|
|
1143
|
+
throw new LoadAPIKeyError2({
|
|
825
1144
|
message: `${description} API key must be a string.`
|
|
826
1145
|
});
|
|
827
1146
|
}
|
|
828
1147
|
if (typeof process === "undefined") {
|
|
829
|
-
throw new
|
|
1148
|
+
throw new LoadAPIKeyError2({
|
|
830
1149
|
message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter. Environment variables is not supported in this environment.`
|
|
831
1150
|
});
|
|
832
1151
|
}
|
|
833
1152
|
apiKey = process.env[environmentVariableName];
|
|
834
1153
|
if (apiKey == null) {
|
|
835
|
-
throw new
|
|
1154
|
+
throw new LoadAPIKeyError2({
|
|
836
1155
|
message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter or the ${environmentVariableName} environment variable.`
|
|
837
1156
|
});
|
|
838
1157
|
}
|
|
839
1158
|
if (typeof apiKey !== "string") {
|
|
840
|
-
throw new
|
|
1159
|
+
throw new LoadAPIKeyError2({
|
|
841
1160
|
message: `${description} API key must be a string. The value of the ${environmentVariableName} environment variable is not a string.`
|
|
842
1161
|
});
|
|
843
1162
|
}
|
|
@@ -860,15 +1179,15 @@ function loadOptionalSetting({
|
|
|
860
1179
|
return settingValue;
|
|
861
1180
|
}
|
|
862
1181
|
function mediaTypeToExtension(mediaType) {
|
|
863
|
-
var
|
|
1182
|
+
var _a18;
|
|
864
1183
|
const [_type, subtype = ""] = mediaType.toLowerCase().split("/");
|
|
865
|
-
return (
|
|
1184
|
+
return (_a18 = {
|
|
866
1185
|
mpeg: "mp3",
|
|
867
1186
|
"x-wav": "wav",
|
|
868
1187
|
opus: "ogg",
|
|
869
1188
|
mp4: "m4a",
|
|
870
1189
|
"x-m4a": "m4a"
|
|
871
|
-
}[subtype]) != null ?
|
|
1190
|
+
}[subtype]) != null ? _a18 : subtype;
|
|
872
1191
|
}
|
|
873
1192
|
var suspectProtoRx = /"__proto__"\s*:/;
|
|
874
1193
|
var suspectConstructorRx = /"constructor"\s*:/;
|
|
@@ -973,11 +1292,11 @@ function parseAnyDef() {
|
|
|
973
1292
|
return {};
|
|
974
1293
|
}
|
|
975
1294
|
function parseArrayDef(def, refs) {
|
|
976
|
-
var
|
|
1295
|
+
var _a18, _b18, _c;
|
|
977
1296
|
const res = {
|
|
978
1297
|
type: "array"
|
|
979
1298
|
};
|
|
980
|
-
if (((
|
|
1299
|
+
if (((_a18 = def.type) == null ? void 0 : _a18._def) && ((_c = (_b18 = def.type) == null ? void 0 : _b18._def) == null ? void 0 : _c.typeName) !== import_v32.ZodFirstPartyTypeKind.ZodAny) {
|
|
981
1300
|
res.items = parseDef(def.type._def, {
|
|
982
1301
|
...refs,
|
|
983
1302
|
currentPath: [...refs.currentPath, "items"]
|
|
@@ -1343,8 +1662,8 @@ function escapeNonAlphaNumeric(source) {
|
|
|
1343
1662
|
return result;
|
|
1344
1663
|
}
|
|
1345
1664
|
function addFormat(schema, value, message, refs) {
|
|
1346
|
-
var
|
|
1347
|
-
if (schema.format || ((
|
|
1665
|
+
var _a18;
|
|
1666
|
+
if (schema.format || ((_a18 = schema.anyOf) == null ? void 0 : _a18.some((x) => x.format))) {
|
|
1348
1667
|
if (!schema.anyOf) {
|
|
1349
1668
|
schema.anyOf = [];
|
|
1350
1669
|
}
|
|
@@ -1363,8 +1682,8 @@ function addFormat(schema, value, message, refs) {
|
|
|
1363
1682
|
}
|
|
1364
1683
|
}
|
|
1365
1684
|
function addPattern(schema, regex, message, refs) {
|
|
1366
|
-
var
|
|
1367
|
-
if (schema.pattern || ((
|
|
1685
|
+
var _a18;
|
|
1686
|
+
if (schema.pattern || ((_a18 = schema.allOf) == null ? void 0 : _a18.some((x) => x.pattern))) {
|
|
1368
1687
|
if (!schema.allOf) {
|
|
1369
1688
|
schema.allOf = [];
|
|
1370
1689
|
}
|
|
@@ -1383,7 +1702,7 @@ function addPattern(schema, regex, message, refs) {
|
|
|
1383
1702
|
}
|
|
1384
1703
|
}
|
|
1385
1704
|
function stringifyRegExpWithFlags(regex, refs) {
|
|
1386
|
-
var
|
|
1705
|
+
var _a18;
|
|
1387
1706
|
if (!refs.applyRegexFlags || !regex.flags) {
|
|
1388
1707
|
return regex.source;
|
|
1389
1708
|
}
|
|
@@ -1413,7 +1732,7 @@ function stringifyRegExpWithFlags(regex, refs) {
|
|
|
1413
1732
|
pattern += source[i];
|
|
1414
1733
|
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
1415
1734
|
inCharRange = false;
|
|
1416
|
-
} else if (source[i + 1] === "-" && ((
|
|
1735
|
+
} else if (source[i + 1] === "-" && ((_a18 = source[i + 2]) == null ? void 0 : _a18.match(/[a-z]/))) {
|
|
1417
1736
|
pattern += source[i];
|
|
1418
1737
|
inCharRange = true;
|
|
1419
1738
|
} else {
|
|
@@ -1465,15 +1784,15 @@ function stringifyRegExpWithFlags(regex, refs) {
|
|
|
1465
1784
|
return pattern;
|
|
1466
1785
|
}
|
|
1467
1786
|
function parseRecordDef(def, refs) {
|
|
1468
|
-
var
|
|
1787
|
+
var _a18, _b18, _c, _d, _e, _f;
|
|
1469
1788
|
const schema = {
|
|
1470
1789
|
type: "object",
|
|
1471
|
-
additionalProperties: (
|
|
1790
|
+
additionalProperties: (_a18 = parseDef(def.valueType._def, {
|
|
1472
1791
|
...refs,
|
|
1473
1792
|
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
1474
|
-
})) != null ?
|
|
1793
|
+
})) != null ? _a18 : refs.allowedAdditionalProperties
|
|
1475
1794
|
};
|
|
1476
|
-
if (((
|
|
1795
|
+
if (((_b18 = def.keyType) == null ? void 0 : _b18._def.typeName) === import_v33.ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
|
|
1477
1796
|
const { type, ...keyType } = parseStringDef(def.keyType._def, refs);
|
|
1478
1797
|
return {
|
|
1479
1798
|
...schema,
|
|
@@ -1728,8 +2047,8 @@ function safeIsOptional(schema) {
|
|
|
1728
2047
|
}
|
|
1729
2048
|
}
|
|
1730
2049
|
var parseOptionalDef = (def, refs) => {
|
|
1731
|
-
var
|
|
1732
|
-
if (refs.currentPath.toString() === ((
|
|
2050
|
+
var _a18;
|
|
2051
|
+
if (refs.currentPath.toString() === ((_a18 = refs.propertyPath) == null ? void 0 : _a18.toString())) {
|
|
1733
2052
|
return parseDef(def.innerType._def, refs);
|
|
1734
2053
|
}
|
|
1735
2054
|
const innerSchema = parseDef(def.innerType._def, {
|
|
@@ -1906,10 +2225,10 @@ var getRelativePath = (pathA, pathB) => {
|
|
|
1906
2225
|
return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
|
|
1907
2226
|
};
|
|
1908
2227
|
function parseDef(def, refs, forceResolution = false) {
|
|
1909
|
-
var
|
|
2228
|
+
var _a18;
|
|
1910
2229
|
const seenItem = refs.seen.get(def);
|
|
1911
2230
|
if (refs.override) {
|
|
1912
|
-
const overrideResult = (
|
|
2231
|
+
const overrideResult = (_a18 = refs.override) == null ? void 0 : _a18.call(
|
|
1913
2232
|
refs,
|
|
1914
2233
|
def,
|
|
1915
2234
|
refs,
|
|
@@ -1975,11 +2294,11 @@ var getRefs = (options) => {
|
|
|
1975
2294
|
currentPath,
|
|
1976
2295
|
propertyPath: void 0,
|
|
1977
2296
|
seen: new Map(
|
|
1978
|
-
Object.entries(_options.definitions).map(([
|
|
2297
|
+
Object.entries(_options.definitions).map(([name17, def]) => [
|
|
1979
2298
|
def._def,
|
|
1980
2299
|
{
|
|
1981
2300
|
def: def._def,
|
|
1982
|
-
path: [..._options.basePath, _options.definitionPath,
|
|
2301
|
+
path: [..._options.basePath, _options.definitionPath, name17],
|
|
1983
2302
|
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
1984
2303
|
jsonSchema: void 0
|
|
1985
2304
|
}
|
|
@@ -1988,50 +2307,50 @@ var getRefs = (options) => {
|
|
|
1988
2307
|
};
|
|
1989
2308
|
};
|
|
1990
2309
|
var zod3ToJsonSchema = (schema, options) => {
|
|
1991
|
-
var
|
|
2310
|
+
var _a18;
|
|
1992
2311
|
const refs = getRefs(options);
|
|
1993
2312
|
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
|
|
1994
|
-
(acc, [
|
|
1995
|
-
var
|
|
2313
|
+
(acc, [name25, schema2]) => {
|
|
2314
|
+
var _a25;
|
|
1996
2315
|
return {
|
|
1997
2316
|
...acc,
|
|
1998
|
-
[
|
|
2317
|
+
[name25]: (_a25 = parseDef(
|
|
1999
2318
|
schema2._def,
|
|
2000
2319
|
{
|
|
2001
2320
|
...refs,
|
|
2002
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
2321
|
+
currentPath: [...refs.basePath, refs.definitionPath, name25]
|
|
2003
2322
|
},
|
|
2004
2323
|
true
|
|
2005
|
-
)) != null ?
|
|
2324
|
+
)) != null ? _a25 : parseAnyDef()
|
|
2006
2325
|
};
|
|
2007
2326
|
},
|
|
2008
2327
|
{}
|
|
2009
2328
|
) : void 0;
|
|
2010
|
-
const
|
|
2011
|
-
const main = (
|
|
2329
|
+
const name17 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
|
|
2330
|
+
const main = (_a18 = parseDef(
|
|
2012
2331
|
schema._def,
|
|
2013
|
-
|
|
2332
|
+
name17 === void 0 ? refs : {
|
|
2014
2333
|
...refs,
|
|
2015
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
2334
|
+
currentPath: [...refs.basePath, refs.definitionPath, name17]
|
|
2016
2335
|
},
|
|
2017
2336
|
false
|
|
2018
|
-
)) != null ?
|
|
2337
|
+
)) != null ? _a18 : parseAnyDef();
|
|
2019
2338
|
const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
|
|
2020
2339
|
if (title !== void 0) {
|
|
2021
2340
|
main.title = title;
|
|
2022
2341
|
}
|
|
2023
|
-
const combined =
|
|
2342
|
+
const combined = name17 === void 0 ? definitions ? {
|
|
2024
2343
|
...main,
|
|
2025
2344
|
[refs.definitionPath]: definitions
|
|
2026
2345
|
} : main : {
|
|
2027
2346
|
$ref: [
|
|
2028
2347
|
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
2029
2348
|
refs.definitionPath,
|
|
2030
|
-
|
|
2349
|
+
name17
|
|
2031
2350
|
].join("/"),
|
|
2032
2351
|
[refs.definitionPath]: {
|
|
2033
2352
|
...definitions,
|
|
2034
|
-
[
|
|
2353
|
+
[name17]: main
|
|
2035
2354
|
}
|
|
2036
2355
|
};
|
|
2037
2356
|
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
@@ -2111,7 +2430,7 @@ function standardSchemaWithJsonSchemaResolver(standardSchema2, jsonSchemaResolve
|
|
|
2111
2430
|
const result = await standardSchema2["~standard"].validate(value);
|
|
2112
2431
|
return "value" in result ? { success: true, value: result.value } : {
|
|
2113
2432
|
success: false,
|
|
2114
|
-
error: new
|
|
2433
|
+
error: new TypeValidationError2({
|
|
2115
2434
|
value,
|
|
2116
2435
|
cause: result.issues
|
|
2117
2436
|
})
|
|
@@ -2120,8 +2439,8 @@ function standardSchemaWithJsonSchemaResolver(standardSchema2, jsonSchemaResolve
|
|
|
2120
2439
|
});
|
|
2121
2440
|
}
|
|
2122
2441
|
function zod3Schema(zodSchema2, options) {
|
|
2123
|
-
var
|
|
2124
|
-
const useReferences = (
|
|
2442
|
+
var _a18;
|
|
2443
|
+
const useReferences = (_a18 = options == null ? void 0 : options.useReferences) != null ? _a18 : false;
|
|
2125
2444
|
return jsonSchema(
|
|
2126
2445
|
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
2127
2446
|
() => zod3ToJsonSchema(zodSchema2, {
|
|
@@ -2136,8 +2455,8 @@ function zod3Schema(zodSchema2, options) {
|
|
|
2136
2455
|
);
|
|
2137
2456
|
}
|
|
2138
2457
|
function zod4Schema(zodSchema2, options) {
|
|
2139
|
-
var
|
|
2140
|
-
const useReferences = (
|
|
2458
|
+
var _a18;
|
|
2459
|
+
const useReferences = (_a18 = options == null ? void 0 : options.useReferences) != null ? _a18 : false;
|
|
2141
2460
|
return jsonSchema(
|
|
2142
2461
|
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
2143
2462
|
() => z4.toJSONSchema(zodSchema2, {
|
|
@@ -2169,7 +2488,7 @@ async function validateTypes({
|
|
|
2169
2488
|
}) {
|
|
2170
2489
|
const result = await safeValidateTypes({ value, schema });
|
|
2171
2490
|
if (!result.success) {
|
|
2172
|
-
throw
|
|
2491
|
+
throw TypeValidationError2.wrap({ value, cause: result.error });
|
|
2173
2492
|
}
|
|
2174
2493
|
return result.value;
|
|
2175
2494
|
}
|
|
@@ -2188,13 +2507,13 @@ async function safeValidateTypes({
|
|
|
2188
2507
|
}
|
|
2189
2508
|
return {
|
|
2190
2509
|
success: false,
|
|
2191
|
-
error:
|
|
2510
|
+
error: TypeValidationError2.wrap({ value, cause: result.error }),
|
|
2192
2511
|
rawValue: value
|
|
2193
2512
|
};
|
|
2194
2513
|
} catch (error) {
|
|
2195
2514
|
return {
|
|
2196
2515
|
success: false,
|
|
2197
|
-
error:
|
|
2516
|
+
error: TypeValidationError2.wrap({ value, cause: error }),
|
|
2198
2517
|
rawValue: value
|
|
2199
2518
|
};
|
|
2200
2519
|
}
|
|
@@ -2210,10 +2529,10 @@ async function parseJSON({
|
|
|
2210
2529
|
}
|
|
2211
2530
|
return validateTypes({ value, schema });
|
|
2212
2531
|
} catch (error) {
|
|
2213
|
-
if (
|
|
2532
|
+
if (JSONParseError2.isInstance(error) || TypeValidationError2.isInstance(error)) {
|
|
2214
2533
|
throw error;
|
|
2215
2534
|
}
|
|
2216
|
-
throw new
|
|
2535
|
+
throw new JSONParseError2({ text, cause: error });
|
|
2217
2536
|
}
|
|
2218
2537
|
}
|
|
2219
2538
|
async function safeParseJSON({
|
|
@@ -2229,7 +2548,7 @@ async function safeParseJSON({
|
|
|
2229
2548
|
} catch (error) {
|
|
2230
2549
|
return {
|
|
2231
2550
|
success: false,
|
|
2232
|
-
error:
|
|
2551
|
+
error: JSONParseError2.isInstance(error) ? error : new JSONParseError2({ text, cause: error }),
|
|
2233
2552
|
rawValue: void 0
|
|
2234
2553
|
};
|
|
2235
2554
|
}
|
|
@@ -2270,7 +2589,7 @@ async function parseProviderOptions({
|
|
|
2270
2589
|
schema
|
|
2271
2590
|
});
|
|
2272
2591
|
if (!parsedProviderOptions.success) {
|
|
2273
|
-
throw new
|
|
2592
|
+
throw new InvalidArgumentError2({
|
|
2274
2593
|
argument: "providerOptions",
|
|
2275
2594
|
message: `invalid ${provider} provider options`,
|
|
2276
2595
|
cause: parsedProviderOptions.error
|
|
@@ -2352,10 +2671,10 @@ var postToApi = async ({
|
|
|
2352
2671
|
requestBodyValues: body.values
|
|
2353
2672
|
});
|
|
2354
2673
|
} catch (error) {
|
|
2355
|
-
if (isAbortError(error) ||
|
|
2674
|
+
if (isAbortError(error) || APICallError2.isInstance(error)) {
|
|
2356
2675
|
throw error;
|
|
2357
2676
|
}
|
|
2358
|
-
throw new
|
|
2677
|
+
throw new APICallError2({
|
|
2359
2678
|
message: "Failed to process error response",
|
|
2360
2679
|
cause: error,
|
|
2361
2680
|
statusCode: response.status,
|
|
@@ -2374,11 +2693,11 @@ var postToApi = async ({
|
|
|
2374
2693
|
});
|
|
2375
2694
|
} catch (error) {
|
|
2376
2695
|
if (error instanceof Error) {
|
|
2377
|
-
if (isAbortError(error) ||
|
|
2696
|
+
if (isAbortError(error) || APICallError2.isInstance(error)) {
|
|
2378
2697
|
throw error;
|
|
2379
2698
|
}
|
|
2380
2699
|
}
|
|
2381
|
-
throw new
|
|
2700
|
+
throw new APICallError2({
|
|
2382
2701
|
message: "Failed to process successful response",
|
|
2383
2702
|
cause: error,
|
|
2384
2703
|
statusCode: response.status,
|
|
@@ -2464,7 +2783,7 @@ var createJsonErrorResponseHandler = ({
|
|
|
2464
2783
|
if (responseBody.trim() === "") {
|
|
2465
2784
|
return {
|
|
2466
2785
|
responseHeaders,
|
|
2467
|
-
value: new
|
|
2786
|
+
value: new APICallError2({
|
|
2468
2787
|
message: response.statusText,
|
|
2469
2788
|
url,
|
|
2470
2789
|
requestBodyValues,
|
|
@@ -2482,7 +2801,7 @@ var createJsonErrorResponseHandler = ({
|
|
|
2482
2801
|
});
|
|
2483
2802
|
return {
|
|
2484
2803
|
responseHeaders,
|
|
2485
|
-
value: new
|
|
2804
|
+
value: new APICallError2({
|
|
2486
2805
|
message: errorToMessage(parsedError),
|
|
2487
2806
|
url,
|
|
2488
2807
|
requestBodyValues,
|
|
@@ -2496,7 +2815,7 @@ var createJsonErrorResponseHandler = ({
|
|
|
2496
2815
|
} catch (parseError) {
|
|
2497
2816
|
return {
|
|
2498
2817
|
responseHeaders,
|
|
2499
|
-
value: new
|
|
2818
|
+
value: new APICallError2({
|
|
2500
2819
|
message: response.statusText,
|
|
2501
2820
|
url,
|
|
2502
2821
|
requestBodyValues,
|
|
@@ -2511,7 +2830,7 @@ var createJsonErrorResponseHandler = ({
|
|
|
2511
2830
|
var createEventSourceResponseHandler = (chunkSchema2) => async ({ response }) => {
|
|
2512
2831
|
const responseHeaders = extractResponseHeaders(response);
|
|
2513
2832
|
if (response.body == null) {
|
|
2514
|
-
throw new
|
|
2833
|
+
throw new EmptyResponseBodyError2({});
|
|
2515
2834
|
}
|
|
2516
2835
|
return {
|
|
2517
2836
|
responseHeaders,
|
|
@@ -2529,7 +2848,7 @@ var createJsonResponseHandler = (responseSchema2) => async ({ response, url, req
|
|
|
2529
2848
|
});
|
|
2530
2849
|
const responseHeaders = extractResponseHeaders(response);
|
|
2531
2850
|
if (!parsedResult.success) {
|
|
2532
|
-
throw new
|
|
2851
|
+
throw new APICallError2({
|
|
2533
2852
|
message: "Invalid JSON response",
|
|
2534
2853
|
cause: parsedResult.error,
|
|
2535
2854
|
statusCode: response.status,
|
|
@@ -2548,7 +2867,7 @@ var createJsonResponseHandler = (responseSchema2) => async ({ response, url, req
|
|
|
2548
2867
|
var createBinaryResponseHandler = () => async ({ response, url, requestBodyValues }) => {
|
|
2549
2868
|
const responseHeaders = extractResponseHeaders(response);
|
|
2550
2869
|
if (!response.body) {
|
|
2551
|
-
throw new
|
|
2870
|
+
throw new APICallError2({
|
|
2552
2871
|
message: "Response body is empty",
|
|
2553
2872
|
url,
|
|
2554
2873
|
requestBodyValues,
|
|
@@ -2564,7 +2883,7 @@ var createBinaryResponseHandler = () => async ({ response, url, requestBodyValue
|
|
|
2564
2883
|
value: new Uint8Array(buffer)
|
|
2565
2884
|
};
|
|
2566
2885
|
} catch (error) {
|
|
2567
|
-
throw new
|
|
2886
|
+
throw new APICallError2({
|
|
2568
2887
|
message: "Failed to read response as array buffer",
|
|
2569
2888
|
url,
|
|
2570
2889
|
requestBodyValues,
|
|
@@ -2595,7 +2914,7 @@ function withoutTrailingSlash(url) {
|
|
|
2595
2914
|
return url == null ? void 0 : url.replace(/\/$/, "");
|
|
2596
2915
|
}
|
|
2597
2916
|
|
|
2598
|
-
// node_modules/@ai-sdk/anthropic/dist/index.mjs
|
|
2917
|
+
// ../../node_modules/@ai-sdk/anthropic/dist/index.mjs
|
|
2599
2918
|
var import_v42 = require("zod/v4");
|
|
2600
2919
|
var import_v43 = require("zod/v4");
|
|
2601
2920
|
var import_v44 = require("zod/v4");
|
|
@@ -3236,9 +3555,9 @@ var anthropicProviderOptions = import_v44.z.object({
|
|
|
3236
3555
|
});
|
|
3237
3556
|
var MAX_CACHE_BREAKPOINTS = 4;
|
|
3238
3557
|
function getCacheControl(providerMetadata) {
|
|
3239
|
-
var
|
|
3558
|
+
var _a18;
|
|
3240
3559
|
const anthropic2 = providerMetadata == null ? void 0 : providerMetadata.anthropic;
|
|
3241
|
-
const cacheControlValue = (
|
|
3560
|
+
const cacheControlValue = (_a18 = anthropic2 == null ? void 0 : anthropic2.cacheControl) != null ? _a18 : anthropic2 == null ? void 0 : anthropic2.cache_control;
|
|
3242
3561
|
return cacheControlValue;
|
|
3243
3562
|
}
|
|
3244
3563
|
var CacheControlValidator = class {
|
|
@@ -3770,20 +4089,20 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
3770
4089
|
warnings,
|
|
3771
4090
|
cacheControlValidator
|
|
3772
4091
|
}) {
|
|
3773
|
-
var
|
|
4092
|
+
var _a18, _b18, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
3774
4093
|
const betas = /* @__PURE__ */ new Set();
|
|
3775
4094
|
const blocks = groupIntoBlocks(prompt);
|
|
3776
4095
|
const validator = cacheControlValidator || new CacheControlValidator();
|
|
3777
4096
|
let system = void 0;
|
|
3778
4097
|
const messages = [];
|
|
3779
4098
|
async function shouldEnableCitations(providerMetadata) {
|
|
3780
|
-
var
|
|
4099
|
+
var _a25, _b25;
|
|
3781
4100
|
const anthropicOptions = await parseProviderOptions({
|
|
3782
4101
|
provider: "anthropic",
|
|
3783
4102
|
providerOptions: providerMetadata,
|
|
3784
4103
|
schema: anthropicFilePartProviderOptions
|
|
3785
4104
|
});
|
|
3786
|
-
return (
|
|
4105
|
+
return (_b25 = (_a25 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a25.enabled) != null ? _b25 : false;
|
|
3787
4106
|
}
|
|
3788
4107
|
async function getDocumentMetadata(providerMetadata) {
|
|
3789
4108
|
const anthropicOptions = await parseProviderOptions({
|
|
@@ -3826,10 +4145,10 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
3826
4145
|
for (let j = 0; j < content.length; j++) {
|
|
3827
4146
|
const part = content[j];
|
|
3828
4147
|
const isLastPart = j === content.length - 1;
|
|
3829
|
-
const cacheControl = (
|
|
4148
|
+
const cacheControl = (_a18 = validator.getCacheControl(part.providerOptions, {
|
|
3830
4149
|
type: "user message part",
|
|
3831
4150
|
canCache: true
|
|
3832
|
-
})) != null ?
|
|
4151
|
+
})) != null ? _a18 : isLastPart ? validator.getCacheControl(message.providerOptions, {
|
|
3833
4152
|
type: "user message",
|
|
3834
4153
|
canCache: true
|
|
3835
4154
|
}) : void 0;
|
|
@@ -3874,7 +4193,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
3874
4193
|
media_type: "application/pdf",
|
|
3875
4194
|
data: convertToBase64(part.data)
|
|
3876
4195
|
},
|
|
3877
|
-
title: (
|
|
4196
|
+
title: (_b18 = metadata.title) != null ? _b18 : part.filename,
|
|
3878
4197
|
...metadata.context && { context: metadata.context },
|
|
3879
4198
|
...enableCitations && {
|
|
3880
4199
|
citations: { enabled: true }
|
|
@@ -4384,7 +4703,7 @@ function mapAnthropicStopReason({
|
|
|
4384
4703
|
}
|
|
4385
4704
|
}
|
|
4386
4705
|
function createCitationSource(citation, citationDocuments, generateId3) {
|
|
4387
|
-
var
|
|
4706
|
+
var _a18;
|
|
4388
4707
|
if (citation.type !== "page_location" && citation.type !== "char_location") {
|
|
4389
4708
|
return;
|
|
4390
4709
|
}
|
|
@@ -4397,7 +4716,7 @@ function createCitationSource(citation, citationDocuments, generateId3) {
|
|
|
4397
4716
|
sourceType: "document",
|
|
4398
4717
|
id: generateId3(),
|
|
4399
4718
|
mediaType: documentInfo.mediaType,
|
|
4400
|
-
title: (
|
|
4719
|
+
title: (_a18 = citation.document_title) != null ? _a18 : documentInfo.title,
|
|
4401
4720
|
filename: documentInfo.filename,
|
|
4402
4721
|
providerMetadata: {
|
|
4403
4722
|
anthropic: citation.type === "page_location" ? {
|
|
@@ -4415,10 +4734,10 @@ function createCitationSource(citation, citationDocuments, generateId3) {
|
|
|
4415
4734
|
var AnthropicMessagesLanguageModel = class {
|
|
4416
4735
|
constructor(modelId, config) {
|
|
4417
4736
|
this.specificationVersion = "v3";
|
|
4418
|
-
var
|
|
4737
|
+
var _a18;
|
|
4419
4738
|
this.modelId = modelId;
|
|
4420
4739
|
this.config = config;
|
|
4421
|
-
this.generateId = (
|
|
4740
|
+
this.generateId = (_a18 = config.generateId) != null ? _a18 : generateId;
|
|
4422
4741
|
}
|
|
4423
4742
|
supportsUrl(url) {
|
|
4424
4743
|
return url.protocol === "https:";
|
|
@@ -4427,8 +4746,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4427
4746
|
return this.config.provider;
|
|
4428
4747
|
}
|
|
4429
4748
|
get supportedUrls() {
|
|
4430
|
-
var
|
|
4431
|
-
return (_c = (
|
|
4749
|
+
var _a18, _b18, _c;
|
|
4750
|
+
return (_c = (_b18 = (_a18 = this.config).supportedUrls) == null ? void 0 : _b18.call(_a18)) != null ? _c : {};
|
|
4432
4751
|
}
|
|
4433
4752
|
async getArgs({
|
|
4434
4753
|
userSuppliedBetas,
|
|
@@ -4447,7 +4766,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4447
4766
|
providerOptions,
|
|
4448
4767
|
stream
|
|
4449
4768
|
}) {
|
|
4450
|
-
var
|
|
4769
|
+
var _a18, _b18, _c, _d, _e, _f;
|
|
4451
4770
|
const warnings = [];
|
|
4452
4771
|
if (frequencyPenalty != null) {
|
|
4453
4772
|
warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
|
|
@@ -4492,7 +4811,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4492
4811
|
supportsStructuredOutput,
|
|
4493
4812
|
isKnownModel
|
|
4494
4813
|
} = getModelCapabilities(this.modelId);
|
|
4495
|
-
const structureOutputMode = (
|
|
4814
|
+
const structureOutputMode = (_a18 = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _a18 : "auto";
|
|
4496
4815
|
const useStructuredOutput = structureOutputMode === "outputFormat" || structureOutputMode === "auto" && supportsStructuredOutput;
|
|
4497
4816
|
const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !useStructuredOutput ? {
|
|
4498
4817
|
type: "function",
|
|
@@ -4503,7 +4822,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4503
4822
|
const cacheControlValidator = new CacheControlValidator();
|
|
4504
4823
|
const { prompt: messagesPrompt, betas } = await convertToAnthropicMessagesPrompt({
|
|
4505
4824
|
prompt,
|
|
4506
|
-
sendReasoning: (
|
|
4825
|
+
sendReasoning: (_b18 = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _b18 : true,
|
|
4507
4826
|
warnings,
|
|
4508
4827
|
cacheControlValidator
|
|
4509
4828
|
});
|
|
@@ -4671,10 +4990,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4671
4990
|
);
|
|
4672
4991
|
}
|
|
4673
4992
|
async getBetasFromHeaders(requestHeaders) {
|
|
4674
|
-
var
|
|
4993
|
+
var _a18, _b18;
|
|
4675
4994
|
const configHeaders = await resolve(this.config.headers);
|
|
4676
|
-
const configBetaHeader = (
|
|
4677
|
-
const requestBetaHeader = (
|
|
4995
|
+
const configBetaHeader = (_a18 = configHeaders["anthropic-beta"]) != null ? _a18 : "";
|
|
4996
|
+
const requestBetaHeader = (_b18 = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b18 : "";
|
|
4678
4997
|
return new Set(
|
|
4679
4998
|
[
|
|
4680
4999
|
...configBetaHeader.toLowerCase().split(","),
|
|
@@ -4683,38 +5002,38 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4683
5002
|
);
|
|
4684
5003
|
}
|
|
4685
5004
|
buildRequestUrl(isStreaming) {
|
|
4686
|
-
var
|
|
4687
|
-
return (_c = (
|
|
5005
|
+
var _a18, _b18, _c;
|
|
5006
|
+
return (_c = (_b18 = (_a18 = this.config).buildRequestUrl) == null ? void 0 : _b18.call(_a18, this.config.baseURL, isStreaming)) != null ? _c : `${this.config.baseURL}/messages`;
|
|
4688
5007
|
}
|
|
4689
5008
|
transformRequestBody(args) {
|
|
4690
|
-
var
|
|
4691
|
-
return (_c = (
|
|
5009
|
+
var _a18, _b18, _c;
|
|
5010
|
+
return (_c = (_b18 = (_a18 = this.config).transformRequestBody) == null ? void 0 : _b18.call(_a18, args)) != null ? _c : args;
|
|
4692
5011
|
}
|
|
4693
5012
|
extractCitationDocuments(prompt) {
|
|
4694
5013
|
const isCitationPart = (part) => {
|
|
4695
|
-
var
|
|
5014
|
+
var _a18, _b18;
|
|
4696
5015
|
if (part.type !== "file") {
|
|
4697
5016
|
return false;
|
|
4698
5017
|
}
|
|
4699
5018
|
if (part.mediaType !== "application/pdf" && part.mediaType !== "text/plain") {
|
|
4700
5019
|
return false;
|
|
4701
5020
|
}
|
|
4702
|
-
const anthropic2 = (
|
|
5021
|
+
const anthropic2 = (_a18 = part.providerOptions) == null ? void 0 : _a18.anthropic;
|
|
4703
5022
|
const citationsConfig = anthropic2 == null ? void 0 : anthropic2.citations;
|
|
4704
|
-
return (
|
|
5023
|
+
return (_b18 = citationsConfig == null ? void 0 : citationsConfig.enabled) != null ? _b18 : false;
|
|
4705
5024
|
};
|
|
4706
5025
|
return prompt.filter((message) => message.role === "user").flatMap((message) => message.content).filter(isCitationPart).map((part) => {
|
|
4707
|
-
var
|
|
5026
|
+
var _a18;
|
|
4708
5027
|
const filePart = part;
|
|
4709
5028
|
return {
|
|
4710
|
-
title: (
|
|
5029
|
+
title: (_a18 = filePart.filename) != null ? _a18 : "Untitled Document",
|
|
4711
5030
|
filename: filePart.filename,
|
|
4712
5031
|
mediaType: filePart.mediaType
|
|
4713
5032
|
};
|
|
4714
5033
|
});
|
|
4715
5034
|
}
|
|
4716
5035
|
async doGenerate(options) {
|
|
4717
|
-
var
|
|
5036
|
+
var _a18, _b18, _c, _d, _e, _f, _g, _h;
|
|
4718
5037
|
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs({
|
|
4719
5038
|
...options,
|
|
4720
5039
|
stream: false,
|
|
@@ -4894,11 +5213,11 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4894
5213
|
toolCallId: part.tool_use_id,
|
|
4895
5214
|
toolName: "web_search",
|
|
4896
5215
|
result: part.content.map((result) => {
|
|
4897
|
-
var
|
|
5216
|
+
var _a25;
|
|
4898
5217
|
return {
|
|
4899
5218
|
url: result.url,
|
|
4900
5219
|
title: result.title,
|
|
4901
|
-
pageAge: (
|
|
5220
|
+
pageAge: (_a25 = result.page_age) != null ? _a25 : null,
|
|
4902
5221
|
encryptedContent: result.encrypted_content,
|
|
4903
5222
|
type: result.type
|
|
4904
5223
|
};
|
|
@@ -4913,7 +5232,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4913
5232
|
title: result.title,
|
|
4914
5233
|
providerMetadata: {
|
|
4915
5234
|
anthropic: {
|
|
4916
|
-
pageAge: (
|
|
5235
|
+
pageAge: (_a18 = result.page_age) != null ? _a18 : null
|
|
4917
5236
|
}
|
|
4918
5237
|
}
|
|
4919
5238
|
});
|
|
@@ -4983,7 +5302,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4983
5302
|
inputTokens: response.usage.input_tokens,
|
|
4984
5303
|
outputTokens: response.usage.output_tokens,
|
|
4985
5304
|
totalTokens: response.usage.input_tokens + response.usage.output_tokens,
|
|
4986
|
-
cachedInputTokens: (
|
|
5305
|
+
cachedInputTokens: (_b18 = response.usage.cache_read_input_tokens) != null ? _b18 : void 0
|
|
4987
5306
|
},
|
|
4988
5307
|
request: { body: args },
|
|
4989
5308
|
response: {
|
|
@@ -5068,7 +5387,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5068
5387
|
}
|
|
5069
5388
|
},
|
|
5070
5389
|
transform(chunk, controller) {
|
|
5071
|
-
var
|
|
5390
|
+
var _a18, _b18, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
5072
5391
|
if (options.includeRawChunks) {
|
|
5073
5392
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
5074
5393
|
}
|
|
@@ -5238,11 +5557,11 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5238
5557
|
toolCallId: part.tool_use_id,
|
|
5239
5558
|
toolName: "web_search",
|
|
5240
5559
|
result: part.content.map((result) => {
|
|
5241
|
-
var
|
|
5560
|
+
var _a25;
|
|
5242
5561
|
return {
|
|
5243
5562
|
url: result.url,
|
|
5244
5563
|
title: result.title,
|
|
5245
|
-
pageAge: (
|
|
5564
|
+
pageAge: (_a25 = result.page_age) != null ? _a25 : null,
|
|
5246
5565
|
encryptedContent: result.encrypted_content,
|
|
5247
5566
|
type: result.type
|
|
5248
5567
|
};
|
|
@@ -5257,7 +5576,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5257
5576
|
title: result.title,
|
|
5258
5577
|
providerMetadata: {
|
|
5259
5578
|
anthropic: {
|
|
5260
|
-
pageAge: (
|
|
5579
|
+
pageAge: (_a18 = result.page_age) != null ? _a18 : null
|
|
5261
5580
|
}
|
|
5262
5581
|
}
|
|
5263
5582
|
});
|
|
@@ -5485,7 +5804,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5485
5804
|
}
|
|
5486
5805
|
case "message_start": {
|
|
5487
5806
|
usage.inputTokens = value.message.usage.input_tokens;
|
|
5488
|
-
usage.cachedInputTokens = (
|
|
5807
|
+
usage.cachedInputTokens = (_b18 = value.message.usage.cache_read_input_tokens) != null ? _b18 : void 0;
|
|
5489
5808
|
rawUsage = {
|
|
5490
5809
|
...value.message.usage
|
|
5491
5810
|
};
|
|
@@ -5939,14 +6258,14 @@ var anthropicTools = {
|
|
|
5939
6258
|
webSearch_20250305
|
|
5940
6259
|
};
|
|
5941
6260
|
function createAnthropic(options = {}) {
|
|
5942
|
-
var
|
|
5943
|
-
const baseURL = (
|
|
6261
|
+
var _a18, _b18;
|
|
6262
|
+
const baseURL = (_a18 = withoutTrailingSlash(
|
|
5944
6263
|
loadOptionalSetting({
|
|
5945
6264
|
settingValue: options.baseURL,
|
|
5946
6265
|
environmentVariableName: "ANTHROPIC_BASE_URL"
|
|
5947
6266
|
})
|
|
5948
|
-
)) != null ?
|
|
5949
|
-
const providerName = (
|
|
6267
|
+
)) != null ? _a18 : "https://api.anthropic.com/v1";
|
|
6268
|
+
const providerName = (_b18 = options.name) != null ? _b18 : "anthropic.messages";
|
|
5950
6269
|
const getHeaders = () => withUserAgentSuffix(
|
|
5951
6270
|
{
|
|
5952
6271
|
"anthropic-version": "2023-06-01",
|
|
@@ -5960,13 +6279,13 @@ function createAnthropic(options = {}) {
|
|
|
5960
6279
|
`ai-sdk/anthropic/${VERSION2}`
|
|
5961
6280
|
);
|
|
5962
6281
|
const createChatModel = (modelId) => {
|
|
5963
|
-
var
|
|
6282
|
+
var _a25;
|
|
5964
6283
|
return new AnthropicMessagesLanguageModel(modelId, {
|
|
5965
6284
|
provider: providerName,
|
|
5966
6285
|
baseURL,
|
|
5967
6286
|
headers: getHeaders,
|
|
5968
6287
|
fetch: options.fetch,
|
|
5969
|
-
generateId: (
|
|
6288
|
+
generateId: (_a25 = options.generateId) != null ? _a25 : generateId,
|
|
5970
6289
|
supportedUrls: () => ({
|
|
5971
6290
|
"image/*": [/^https?:\/\/.*$/]
|
|
5972
6291
|
})
|
|
@@ -5995,77 +6314,396 @@ function createAnthropic(options = {}) {
|
|
|
5995
6314
|
}
|
|
5996
6315
|
var anthropic = createAnthropic();
|
|
5997
6316
|
|
|
5998
|
-
// node_modules/@ai-sdk/google/dist/index.mjs
|
|
5999
|
-
var
|
|
6000
|
-
var
|
|
6001
|
-
var
|
|
6002
|
-
var
|
|
6003
|
-
var
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
(
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
|
|
6017
|
-
|
|
6018
|
-
|
|
6019
|
-
|
|
6020
|
-
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
}
|
|
6026
|
-
|
|
6027
|
-
()
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
})
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
this.
|
|
6062
|
-
this.
|
|
6063
|
-
this.
|
|
6064
|
-
this.
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
-
|
|
6317
|
+
// ../../node_modules/@ai-sdk/google/node_modules/@ai-sdk/provider/dist/index.mjs
|
|
6318
|
+
var marker16 = "vercel.ai.error";
|
|
6319
|
+
var symbol16 = Symbol.for(marker16);
|
|
6320
|
+
var _a16;
|
|
6321
|
+
var _b16;
|
|
6322
|
+
var AISDKError3 = class _AISDKError3 extends (_b16 = Error, _a16 = symbol16, _b16) {
|
|
6323
|
+
/**
|
|
6324
|
+
* Creates an AI SDK Error.
|
|
6325
|
+
*
|
|
6326
|
+
* @param {Object} params - The parameters for creating the error.
|
|
6327
|
+
* @param {string} params.name - The name of the error.
|
|
6328
|
+
* @param {string} params.message - The error message.
|
|
6329
|
+
* @param {unknown} [params.cause] - The underlying cause of the error.
|
|
6330
|
+
*/
|
|
6331
|
+
constructor({
|
|
6332
|
+
name: name142,
|
|
6333
|
+
message,
|
|
6334
|
+
cause
|
|
6335
|
+
}) {
|
|
6336
|
+
super(message);
|
|
6337
|
+
this[_a16] = true;
|
|
6338
|
+
this.name = name142;
|
|
6339
|
+
this.cause = cause;
|
|
6340
|
+
}
|
|
6341
|
+
/**
|
|
6342
|
+
* Checks if the given error is an AI SDK Error.
|
|
6343
|
+
* @param {unknown} error - The error to check.
|
|
6344
|
+
* @returns {boolean} True if the error is an AI SDK Error, false otherwise.
|
|
6345
|
+
*/
|
|
6346
|
+
static isInstance(error) {
|
|
6347
|
+
return _AISDKError3.hasMarker(error, marker16);
|
|
6348
|
+
}
|
|
6349
|
+
static hasMarker(error, marker152) {
|
|
6350
|
+
const markerSymbol = Symbol.for(marker152);
|
|
6351
|
+
return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
|
|
6352
|
+
}
|
|
6353
|
+
};
|
|
6354
|
+
var name15 = "AI_APICallError";
|
|
6355
|
+
var marker23 = `vercel.ai.error.${name15}`;
|
|
6356
|
+
var symbol23 = Symbol.for(marker23);
|
|
6357
|
+
var _a23;
|
|
6358
|
+
var _b23;
|
|
6359
|
+
var APICallError3 = class extends (_b23 = AISDKError3, _a23 = symbol23, _b23) {
|
|
6360
|
+
constructor({
|
|
6361
|
+
message,
|
|
6362
|
+
url,
|
|
6363
|
+
requestBodyValues,
|
|
6364
|
+
statusCode,
|
|
6365
|
+
responseHeaders,
|
|
6366
|
+
responseBody,
|
|
6367
|
+
cause,
|
|
6368
|
+
isRetryable = statusCode != null && (statusCode === 408 || // request timeout
|
|
6369
|
+
statusCode === 409 || // conflict
|
|
6370
|
+
statusCode === 429 || // too many requests
|
|
6371
|
+
statusCode >= 500),
|
|
6372
|
+
// server error
|
|
6373
|
+
data
|
|
6374
|
+
}) {
|
|
6375
|
+
super({ name: name15, message, cause });
|
|
6376
|
+
this[_a23] = true;
|
|
6377
|
+
this.url = url;
|
|
6378
|
+
this.requestBodyValues = requestBodyValues;
|
|
6379
|
+
this.statusCode = statusCode;
|
|
6380
|
+
this.responseHeaders = responseHeaders;
|
|
6381
|
+
this.responseBody = responseBody;
|
|
6382
|
+
this.isRetryable = isRetryable;
|
|
6383
|
+
this.data = data;
|
|
6384
|
+
}
|
|
6385
|
+
static isInstance(error) {
|
|
6386
|
+
return AISDKError3.hasMarker(error, marker23);
|
|
6387
|
+
}
|
|
6388
|
+
};
|
|
6389
|
+
var name23 = "AI_EmptyResponseBodyError";
|
|
6390
|
+
var marker33 = `vercel.ai.error.${name23}`;
|
|
6391
|
+
var symbol33 = Symbol.for(marker33);
|
|
6392
|
+
var _a33;
|
|
6393
|
+
var _b33;
|
|
6394
|
+
var EmptyResponseBodyError3 = class extends (_b33 = AISDKError3, _a33 = symbol33, _b33) {
|
|
6395
|
+
// used in isInstance
|
|
6396
|
+
constructor({ message = "Empty response body" } = {}) {
|
|
6397
|
+
super({ name: name23, message });
|
|
6398
|
+
this[_a33] = true;
|
|
6399
|
+
}
|
|
6400
|
+
static isInstance(error) {
|
|
6401
|
+
return AISDKError3.hasMarker(error, marker33);
|
|
6402
|
+
}
|
|
6403
|
+
};
|
|
6404
|
+
function getErrorMessage3(error) {
|
|
6405
|
+
if (error == null) {
|
|
6406
|
+
return "unknown error";
|
|
6407
|
+
}
|
|
6408
|
+
if (typeof error === "string") {
|
|
6409
|
+
return error;
|
|
6410
|
+
}
|
|
6411
|
+
if (error instanceof Error) {
|
|
6412
|
+
return error.message;
|
|
6413
|
+
}
|
|
6414
|
+
return JSON.stringify(error);
|
|
6415
|
+
}
|
|
6416
|
+
var name33 = "AI_InvalidArgumentError";
|
|
6417
|
+
var marker43 = `vercel.ai.error.${name33}`;
|
|
6418
|
+
var symbol43 = Symbol.for(marker43);
|
|
6419
|
+
var _a43;
|
|
6420
|
+
var _b43;
|
|
6421
|
+
var InvalidArgumentError3 = class extends (_b43 = AISDKError3, _a43 = symbol43, _b43) {
|
|
6422
|
+
constructor({
|
|
6423
|
+
message,
|
|
6424
|
+
cause,
|
|
6425
|
+
argument
|
|
6426
|
+
}) {
|
|
6427
|
+
super({ name: name33, message, cause });
|
|
6428
|
+
this[_a43] = true;
|
|
6429
|
+
this.argument = argument;
|
|
6430
|
+
}
|
|
6431
|
+
static isInstance(error) {
|
|
6432
|
+
return AISDKError3.hasMarker(error, marker43);
|
|
6433
|
+
}
|
|
6434
|
+
};
|
|
6435
|
+
var name43 = "AI_InvalidPromptError";
|
|
6436
|
+
var marker53 = `vercel.ai.error.${name43}`;
|
|
6437
|
+
var symbol53 = Symbol.for(marker53);
|
|
6438
|
+
var _a53;
|
|
6439
|
+
var _b53;
|
|
6440
|
+
var InvalidPromptError3 = class extends (_b53 = AISDKError3, _a53 = symbol53, _b53) {
|
|
6441
|
+
constructor({
|
|
6442
|
+
prompt,
|
|
6443
|
+
message,
|
|
6444
|
+
cause
|
|
6445
|
+
}) {
|
|
6446
|
+
super({ name: name43, message: `Invalid prompt: ${message}`, cause });
|
|
6447
|
+
this[_a53] = true;
|
|
6448
|
+
this.prompt = prompt;
|
|
6449
|
+
}
|
|
6450
|
+
static isInstance(error) {
|
|
6451
|
+
return AISDKError3.hasMarker(error, marker53);
|
|
6452
|
+
}
|
|
6453
|
+
};
|
|
6454
|
+
var name53 = "AI_InvalidResponseDataError";
|
|
6455
|
+
var marker63 = `vercel.ai.error.${name53}`;
|
|
6456
|
+
var symbol63 = Symbol.for(marker63);
|
|
6457
|
+
var _a63;
|
|
6458
|
+
var _b63;
|
|
6459
|
+
var InvalidResponseDataError3 = class extends (_b63 = AISDKError3, _a63 = symbol63, _b63) {
|
|
6460
|
+
constructor({
|
|
6461
|
+
data,
|
|
6462
|
+
message = `Invalid response data: ${JSON.stringify(data)}.`
|
|
6463
|
+
}) {
|
|
6464
|
+
super({ name: name53, message });
|
|
6465
|
+
this[_a63] = true;
|
|
6466
|
+
this.data = data;
|
|
6467
|
+
}
|
|
6468
|
+
static isInstance(error) {
|
|
6469
|
+
return AISDKError3.hasMarker(error, marker63);
|
|
6470
|
+
}
|
|
6471
|
+
};
|
|
6472
|
+
var name63 = "AI_JSONParseError";
|
|
6473
|
+
var marker73 = `vercel.ai.error.${name63}`;
|
|
6474
|
+
var symbol73 = Symbol.for(marker73);
|
|
6475
|
+
var _a73;
|
|
6476
|
+
var _b73;
|
|
6477
|
+
var JSONParseError3 = class extends (_b73 = AISDKError3, _a73 = symbol73, _b73) {
|
|
6478
|
+
constructor({ text, cause }) {
|
|
6479
|
+
super({
|
|
6480
|
+
name: name63,
|
|
6481
|
+
message: `JSON parsing failed: Text: ${text}.
|
|
6482
|
+
Error message: ${getErrorMessage3(cause)}`,
|
|
6483
|
+
cause
|
|
6484
|
+
});
|
|
6485
|
+
this[_a73] = true;
|
|
6486
|
+
this.text = text;
|
|
6487
|
+
}
|
|
6488
|
+
static isInstance(error) {
|
|
6489
|
+
return AISDKError3.hasMarker(error, marker73);
|
|
6490
|
+
}
|
|
6491
|
+
};
|
|
6492
|
+
var name73 = "AI_LoadAPIKeyError";
|
|
6493
|
+
var marker83 = `vercel.ai.error.${name73}`;
|
|
6494
|
+
var symbol83 = Symbol.for(marker83);
|
|
6495
|
+
var _a83;
|
|
6496
|
+
var _b83;
|
|
6497
|
+
var LoadAPIKeyError3 = class extends (_b83 = AISDKError3, _a83 = symbol83, _b83) {
|
|
6498
|
+
// used in isInstance
|
|
6499
|
+
constructor({ message }) {
|
|
6500
|
+
super({ name: name73, message });
|
|
6501
|
+
this[_a83] = true;
|
|
6502
|
+
}
|
|
6503
|
+
static isInstance(error) {
|
|
6504
|
+
return AISDKError3.hasMarker(error, marker83);
|
|
6505
|
+
}
|
|
6506
|
+
};
|
|
6507
|
+
var name83 = "AI_LoadSettingError";
|
|
6508
|
+
var marker93 = `vercel.ai.error.${name83}`;
|
|
6509
|
+
var symbol93 = Symbol.for(marker93);
|
|
6510
|
+
var _a93;
|
|
6511
|
+
var _b93;
|
|
6512
|
+
var LoadSettingError3 = class extends (_b93 = AISDKError3, _a93 = symbol93, _b93) {
|
|
6513
|
+
// used in isInstance
|
|
6514
|
+
constructor({ message }) {
|
|
6515
|
+
super({ name: name83, message });
|
|
6516
|
+
this[_a93] = true;
|
|
6517
|
+
}
|
|
6518
|
+
static isInstance(error) {
|
|
6519
|
+
return AISDKError3.hasMarker(error, marker93);
|
|
6520
|
+
}
|
|
6521
|
+
};
|
|
6522
|
+
var name93 = "AI_NoContentGeneratedError";
|
|
6523
|
+
var marker103 = `vercel.ai.error.${name93}`;
|
|
6524
|
+
var symbol103 = Symbol.for(marker103);
|
|
6525
|
+
var _a103;
|
|
6526
|
+
var _b103;
|
|
6527
|
+
var NoContentGeneratedError3 = class extends (_b103 = AISDKError3, _a103 = symbol103, _b103) {
|
|
6528
|
+
// used in isInstance
|
|
6529
|
+
constructor({
|
|
6530
|
+
message = "No content generated."
|
|
6531
|
+
} = {}) {
|
|
6532
|
+
super({ name: name93, message });
|
|
6533
|
+
this[_a103] = true;
|
|
6534
|
+
}
|
|
6535
|
+
static isInstance(error) {
|
|
6536
|
+
return AISDKError3.hasMarker(error, marker103);
|
|
6537
|
+
}
|
|
6538
|
+
};
|
|
6539
|
+
var name103 = "AI_NoSuchModelError";
|
|
6540
|
+
var marker113 = `vercel.ai.error.${name103}`;
|
|
6541
|
+
var symbol113 = Symbol.for(marker113);
|
|
6542
|
+
var _a113;
|
|
6543
|
+
var _b113;
|
|
6544
|
+
var NoSuchModelError3 = class extends (_b113 = AISDKError3, _a113 = symbol113, _b113) {
|
|
6545
|
+
constructor({
|
|
6546
|
+
errorName = name103,
|
|
6547
|
+
modelId,
|
|
6548
|
+
modelType,
|
|
6549
|
+
message = `No such ${modelType}: ${modelId}`
|
|
6550
|
+
}) {
|
|
6551
|
+
super({ name: errorName, message });
|
|
6552
|
+
this[_a113] = true;
|
|
6553
|
+
this.modelId = modelId;
|
|
6554
|
+
this.modelType = modelType;
|
|
6555
|
+
}
|
|
6556
|
+
static isInstance(error) {
|
|
6557
|
+
return AISDKError3.hasMarker(error, marker113);
|
|
6558
|
+
}
|
|
6559
|
+
};
|
|
6560
|
+
var name113 = "AI_TooManyEmbeddingValuesForCallError";
|
|
6561
|
+
var marker123 = `vercel.ai.error.${name113}`;
|
|
6562
|
+
var symbol123 = Symbol.for(marker123);
|
|
6563
|
+
var _a123;
|
|
6564
|
+
var _b123;
|
|
6565
|
+
var TooManyEmbeddingValuesForCallError3 = class extends (_b123 = AISDKError3, _a123 = symbol123, _b123) {
|
|
6566
|
+
constructor(options) {
|
|
6567
|
+
super({
|
|
6568
|
+
name: name113,
|
|
6569
|
+
message: `Too many values for a single embedding call. The ${options.provider} model "${options.modelId}" can only embed up to ${options.maxEmbeddingsPerCall} values per call, but ${options.values.length} values were provided.`
|
|
6570
|
+
});
|
|
6571
|
+
this[_a123] = true;
|
|
6572
|
+
this.provider = options.provider;
|
|
6573
|
+
this.modelId = options.modelId;
|
|
6574
|
+
this.maxEmbeddingsPerCall = options.maxEmbeddingsPerCall;
|
|
6575
|
+
this.values = options.values;
|
|
6576
|
+
}
|
|
6577
|
+
static isInstance(error) {
|
|
6578
|
+
return AISDKError3.hasMarker(error, marker123);
|
|
6579
|
+
}
|
|
6580
|
+
};
|
|
6581
|
+
var name123 = "AI_TypeValidationError";
|
|
6582
|
+
var marker133 = `vercel.ai.error.${name123}`;
|
|
6583
|
+
var symbol133 = Symbol.for(marker133);
|
|
6584
|
+
var _a133;
|
|
6585
|
+
var _b133;
|
|
6586
|
+
var TypeValidationError3 = class _TypeValidationError3 extends (_b133 = AISDKError3, _a133 = symbol133, _b133) {
|
|
6587
|
+
constructor({ value, cause }) {
|
|
6588
|
+
super({
|
|
6589
|
+
name: name123,
|
|
6590
|
+
message: `Type validation failed: Value: ${JSON.stringify(value)}.
|
|
6591
|
+
Error message: ${getErrorMessage3(cause)}`,
|
|
6592
|
+
cause
|
|
6593
|
+
});
|
|
6594
|
+
this[_a133] = true;
|
|
6595
|
+
this.value = value;
|
|
6596
|
+
}
|
|
6597
|
+
static isInstance(error) {
|
|
6598
|
+
return AISDKError3.hasMarker(error, marker133);
|
|
6599
|
+
}
|
|
6600
|
+
/**
|
|
6601
|
+
* Wraps an error into a TypeValidationError.
|
|
6602
|
+
* If the cause is already a TypeValidationError with the same value, it returns the cause.
|
|
6603
|
+
* Otherwise, it creates a new TypeValidationError.
|
|
6604
|
+
*
|
|
6605
|
+
* @param {Object} params - The parameters for wrapping the error.
|
|
6606
|
+
* @param {unknown} params.value - The value that failed validation.
|
|
6607
|
+
* @param {unknown} params.cause - The original error or cause of the validation failure.
|
|
6608
|
+
* @returns {TypeValidationError} A TypeValidationError instance.
|
|
6609
|
+
*/
|
|
6610
|
+
static wrap({
|
|
6611
|
+
value,
|
|
6612
|
+
cause
|
|
6613
|
+
}) {
|
|
6614
|
+
return _TypeValidationError3.isInstance(cause) && cause.value === value ? cause : new _TypeValidationError3({ value, cause });
|
|
6615
|
+
}
|
|
6616
|
+
};
|
|
6617
|
+
var name133 = "AI_UnsupportedFunctionalityError";
|
|
6618
|
+
var marker143 = `vercel.ai.error.${name133}`;
|
|
6619
|
+
var symbol143 = Symbol.for(marker143);
|
|
6620
|
+
var _a143;
|
|
6621
|
+
var _b143;
|
|
6622
|
+
var UnsupportedFunctionalityError3 = class extends (_b143 = AISDKError3, _a143 = symbol143, _b143) {
|
|
6623
|
+
constructor({
|
|
6624
|
+
functionality,
|
|
6625
|
+
message = `'${functionality}' functionality not supported.`
|
|
6626
|
+
}) {
|
|
6627
|
+
super({ name: name133, message });
|
|
6628
|
+
this[_a143] = true;
|
|
6629
|
+
this.functionality = functionality;
|
|
6630
|
+
}
|
|
6631
|
+
static isInstance(error) {
|
|
6632
|
+
return AISDKError3.hasMarker(error, marker143);
|
|
6633
|
+
}
|
|
6634
|
+
};
|
|
6635
|
+
|
|
6636
|
+
// ../../node_modules/@ai-sdk/google/dist/index.mjs
|
|
6637
|
+
var import_v418 = require("zod/v4");
|
|
6638
|
+
var import_v419 = require("zod/v4");
|
|
6639
|
+
var import_v420 = require("zod/v4");
|
|
6640
|
+
var import_v421 = require("zod/v4");
|
|
6641
|
+
var import_v422 = require("zod/v4");
|
|
6642
|
+
var import_v423 = require("zod/v4");
|
|
6643
|
+
var import_v424 = require("zod/v4");
|
|
6644
|
+
var import_v425 = require("zod/v4");
|
|
6645
|
+
var import_v426 = require("zod/v4");
|
|
6646
|
+
var import_v427 = require("zod/v4");
|
|
6647
|
+
var import_v428 = require("zod/v4");
|
|
6648
|
+
var VERSION3 = true ? "3.0.0-beta.62" : "0.0.0-test";
|
|
6649
|
+
var googleErrorDataSchema = lazySchema(
|
|
6650
|
+
() => zodSchema(
|
|
6651
|
+
import_v419.z.object({
|
|
6652
|
+
error: import_v419.z.object({
|
|
6653
|
+
code: import_v419.z.number().nullable(),
|
|
6654
|
+
message: import_v419.z.string(),
|
|
6655
|
+
status: import_v419.z.string()
|
|
6656
|
+
})
|
|
6657
|
+
})
|
|
6658
|
+
)
|
|
6659
|
+
);
|
|
6660
|
+
var googleFailedResponseHandler = createJsonErrorResponseHandler({
|
|
6661
|
+
errorSchema: googleErrorDataSchema,
|
|
6662
|
+
errorToMessage: (data) => data.error.message
|
|
6663
|
+
});
|
|
6664
|
+
var googleGenerativeAIEmbeddingProviderOptions = lazySchema(
|
|
6665
|
+
() => zodSchema(
|
|
6666
|
+
import_v420.z.object({
|
|
6667
|
+
/**
|
|
6668
|
+
* Optional. Optional reduced dimension for the output embedding.
|
|
6669
|
+
* If set, excessive values in the output embedding are truncated from the end.
|
|
6670
|
+
*/
|
|
6671
|
+
outputDimensionality: import_v420.z.number().optional(),
|
|
6672
|
+
/**
|
|
6673
|
+
* Optional. Specifies the task type for generating embeddings.
|
|
6674
|
+
* Supported task types:
|
|
6675
|
+
* - SEMANTIC_SIMILARITY: Optimized for text similarity.
|
|
6676
|
+
* - CLASSIFICATION: Optimized for text classification.
|
|
6677
|
+
* - CLUSTERING: Optimized for clustering texts based on similarity.
|
|
6678
|
+
* - RETRIEVAL_DOCUMENT: Optimized for document retrieval.
|
|
6679
|
+
* - RETRIEVAL_QUERY: Optimized for query-based retrieval.
|
|
6680
|
+
* - QUESTION_ANSWERING: Optimized for answering questions.
|
|
6681
|
+
* - FACT_VERIFICATION: Optimized for verifying factual information.
|
|
6682
|
+
* - CODE_RETRIEVAL_QUERY: Optimized for retrieving code blocks based on natural language queries.
|
|
6683
|
+
*/
|
|
6684
|
+
taskType: import_v420.z.enum([
|
|
6685
|
+
"SEMANTIC_SIMILARITY",
|
|
6686
|
+
"CLASSIFICATION",
|
|
6687
|
+
"CLUSTERING",
|
|
6688
|
+
"RETRIEVAL_DOCUMENT",
|
|
6689
|
+
"RETRIEVAL_QUERY",
|
|
6690
|
+
"QUESTION_ANSWERING",
|
|
6691
|
+
"FACT_VERIFICATION",
|
|
6692
|
+
"CODE_RETRIEVAL_QUERY"
|
|
6693
|
+
]).optional()
|
|
6694
|
+
})
|
|
6695
|
+
)
|
|
6696
|
+
);
|
|
6697
|
+
var GoogleGenerativeAIEmbeddingModel = class {
|
|
6698
|
+
constructor(modelId, config) {
|
|
6699
|
+
this.specificationVersion = "v3";
|
|
6700
|
+
this.maxEmbeddingsPerCall = 2048;
|
|
6701
|
+
this.supportsParallelCalls = true;
|
|
6702
|
+
this.modelId = modelId;
|
|
6703
|
+
this.config = config;
|
|
6704
|
+
}
|
|
6705
|
+
get provider() {
|
|
6706
|
+
return this.config.provider;
|
|
6069
6707
|
}
|
|
6070
6708
|
async doEmbed({
|
|
6071
6709
|
values,
|
|
@@ -6079,7 +6717,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
6079
6717
|
schema: googleGenerativeAIEmbeddingProviderOptions
|
|
6080
6718
|
});
|
|
6081
6719
|
if (values.length > this.maxEmbeddingsPerCall) {
|
|
6082
|
-
throw new
|
|
6720
|
+
throw new TooManyEmbeddingValuesForCallError3({
|
|
6083
6721
|
provider: this.provider,
|
|
6084
6722
|
modelId: this.modelId,
|
|
6085
6723
|
maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
|
|
@@ -6257,16 +6895,16 @@ function isEmptyObjectSchema(jsonSchema2) {
|
|
|
6257
6895
|
return jsonSchema2 != null && typeof jsonSchema2 === "object" && jsonSchema2.type === "object" && (jsonSchema2.properties == null || Object.keys(jsonSchema2.properties).length === 0) && !jsonSchema2.additionalProperties;
|
|
6258
6896
|
}
|
|
6259
6897
|
function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
6260
|
-
var
|
|
6898
|
+
var _a18, _b18;
|
|
6261
6899
|
const systemInstructionParts = [];
|
|
6262
6900
|
const contents = [];
|
|
6263
6901
|
let systemMessagesAllowed = true;
|
|
6264
|
-
const isGemmaModel = (
|
|
6902
|
+
const isGemmaModel = (_a18 = options == null ? void 0 : options.isGemmaModel) != null ? _a18 : false;
|
|
6265
6903
|
for (const { role, content } of prompt) {
|
|
6266
6904
|
switch (role) {
|
|
6267
6905
|
case "system": {
|
|
6268
6906
|
if (!systemMessagesAllowed) {
|
|
6269
|
-
throw new
|
|
6907
|
+
throw new UnsupportedFunctionalityError3({
|
|
6270
6908
|
functionality: "system messages are only supported at the beginning of the conversation"
|
|
6271
6909
|
});
|
|
6272
6910
|
}
|
|
@@ -6309,8 +6947,8 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
6309
6947
|
contents.push({
|
|
6310
6948
|
role: "model",
|
|
6311
6949
|
parts: content.map((part) => {
|
|
6312
|
-
var
|
|
6313
|
-
const thoughtSignature = ((
|
|
6950
|
+
var _a25, _b25, _c;
|
|
6951
|
+
const thoughtSignature = ((_b25 = (_a25 = part.providerOptions) == null ? void 0 : _a25.google) == null ? void 0 : _b25.thoughtSignature) != null ? String((_c = part.providerOptions.google) == null ? void 0 : _c.thoughtSignature) : void 0;
|
|
6314
6952
|
switch (part.type) {
|
|
6315
6953
|
case "text": {
|
|
6316
6954
|
return part.text.length === 0 ? void 0 : {
|
|
@@ -6327,7 +6965,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
6327
6965
|
}
|
|
6328
6966
|
case "file": {
|
|
6329
6967
|
if (part.data instanceof URL) {
|
|
6330
|
-
throw new
|
|
6968
|
+
throw new UnsupportedFunctionalityError3({
|
|
6331
6969
|
functionality: "File data URLs in assistant messages are not supported"
|
|
6332
6970
|
});
|
|
6333
6971
|
}
|
|
@@ -6396,7 +7034,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
6396
7034
|
name: part.toolName,
|
|
6397
7035
|
response: {
|
|
6398
7036
|
name: part.toolName,
|
|
6399
|
-
content: output.type === "execution-denied" ? (
|
|
7037
|
+
content: output.type === "execution-denied" ? (_b18 = output.reason) != null ? _b18 : "Tool execution denied." : output.value
|
|
6400
7038
|
}
|
|
6401
7039
|
}
|
|
6402
7040
|
});
|
|
@@ -6529,7 +7167,7 @@ function prepareTools2({
|
|
|
6529
7167
|
toolChoice,
|
|
6530
7168
|
modelId
|
|
6531
7169
|
}) {
|
|
6532
|
-
var
|
|
7170
|
+
var _a18;
|
|
6533
7171
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
6534
7172
|
const toolWarnings = [];
|
|
6535
7173
|
const isLatest = [
|
|
@@ -6645,7 +7283,7 @@ function prepareTools2({
|
|
|
6645
7283
|
case "function":
|
|
6646
7284
|
functionDeclarations.push({
|
|
6647
7285
|
name: tool2.name,
|
|
6648
|
-
description: (
|
|
7286
|
+
description: (_a18 = tool2.description) != null ? _a18 : "",
|
|
6649
7287
|
parameters: convertJSONSchemaToOpenAPISchema(tool2.inputSchema)
|
|
6650
7288
|
});
|
|
6651
7289
|
break;
|
|
@@ -6697,7 +7335,7 @@ function prepareTools2({
|
|
|
6697
7335
|
};
|
|
6698
7336
|
default: {
|
|
6699
7337
|
const _exhaustiveCheck = type;
|
|
6700
|
-
throw new
|
|
7338
|
+
throw new UnsupportedFunctionalityError3({
|
|
6701
7339
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
6702
7340
|
});
|
|
6703
7341
|
}
|
|
@@ -6731,17 +7369,17 @@ function mapGoogleGenerativeAIFinishReason({
|
|
|
6731
7369
|
var GoogleGenerativeAILanguageModel = class {
|
|
6732
7370
|
constructor(modelId, config) {
|
|
6733
7371
|
this.specificationVersion = "v3";
|
|
6734
|
-
var
|
|
7372
|
+
var _a18;
|
|
6735
7373
|
this.modelId = modelId;
|
|
6736
7374
|
this.config = config;
|
|
6737
|
-
this.generateId = (
|
|
7375
|
+
this.generateId = (_a18 = config.generateId) != null ? _a18 : generateId;
|
|
6738
7376
|
}
|
|
6739
7377
|
get provider() {
|
|
6740
7378
|
return this.config.provider;
|
|
6741
7379
|
}
|
|
6742
7380
|
get supportedUrls() {
|
|
6743
|
-
var
|
|
6744
|
-
return (_c = (
|
|
7381
|
+
var _a18, _b18, _c;
|
|
7382
|
+
return (_c = (_b18 = (_a18 = this.config).supportedUrls) == null ? void 0 : _b18.call(_a18)) != null ? _c : {};
|
|
6745
7383
|
}
|
|
6746
7384
|
async getArgs({
|
|
6747
7385
|
prompt,
|
|
@@ -6758,7 +7396,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
6758
7396
|
toolChoice,
|
|
6759
7397
|
providerOptions
|
|
6760
7398
|
}) {
|
|
6761
|
-
var
|
|
7399
|
+
var _a18;
|
|
6762
7400
|
const warnings = [];
|
|
6763
7401
|
const googleOptions = await parseProviderOptions({
|
|
6764
7402
|
provider: "google",
|
|
@@ -6804,7 +7442,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
6804
7442
|
responseSchema: (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && // Google GenAI does not support all OpenAPI Schema features,
|
|
6805
7443
|
// so this is needed as an escape hatch:
|
|
6806
7444
|
// TODO convert into provider option
|
|
6807
|
-
((
|
|
7445
|
+
((_a18 = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _a18 : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
|
|
6808
7446
|
...(googleOptions == null ? void 0 : googleOptions.audioTimestamp) && {
|
|
6809
7447
|
audioTimestamp: googleOptions.audioTimestamp
|
|
6810
7448
|
},
|
|
@@ -6830,7 +7468,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
6830
7468
|
};
|
|
6831
7469
|
}
|
|
6832
7470
|
async doGenerate(options) {
|
|
6833
|
-
var
|
|
7471
|
+
var _a18, _b18, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
6834
7472
|
const { args, warnings } = await this.getArgs(options);
|
|
6835
7473
|
const body = JSON.stringify(args);
|
|
6836
7474
|
const mergedHeaders = combineHeaders(
|
|
@@ -6854,7 +7492,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
6854
7492
|
});
|
|
6855
7493
|
const candidate = response.candidates[0];
|
|
6856
7494
|
const content = [];
|
|
6857
|
-
const parts = (
|
|
7495
|
+
const parts = (_b18 = (_a18 = candidate.content) == null ? void 0 : _a18.parts) != null ? _b18 : [];
|
|
6858
7496
|
const usageMetadata = response.usageMetadata;
|
|
6859
7497
|
let lastCodeExecutionToolCallId;
|
|
6860
7498
|
for (const part of parts) {
|
|
@@ -6980,7 +7618,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
6980
7618
|
controller.enqueue({ type: "stream-start", warnings });
|
|
6981
7619
|
},
|
|
6982
7620
|
transform(chunk, controller) {
|
|
6983
|
-
var
|
|
7621
|
+
var _a18, _b18, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
6984
7622
|
if (options.includeRawChunks) {
|
|
6985
7623
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
6986
7624
|
}
|
|
@@ -6991,8 +7629,8 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
6991
7629
|
const value = chunk.value;
|
|
6992
7630
|
const usageMetadata = value.usageMetadata;
|
|
6993
7631
|
if (usageMetadata != null) {
|
|
6994
|
-
usage.inputTokens = (
|
|
6995
|
-
usage.outputTokens = (
|
|
7632
|
+
usage.inputTokens = (_a18 = usageMetadata.promptTokenCount) != null ? _a18 : void 0;
|
|
7633
|
+
usage.outputTokens = (_b18 = usageMetadata.candidatesTokenCount) != null ? _b18 : void 0;
|
|
6996
7634
|
usage.totalTokens = (_c = usageMetadata.totalTokenCount) != null ? _c : void 0;
|
|
6997
7635
|
usage.reasoningTokens = (_d = usageMetadata.thoughtsTokenCount) != null ? _d : void 0;
|
|
6998
7636
|
usage.cachedInputTokens = (_e = usageMetadata.cachedContentTokenCount) != null ? _e : void 0;
|
|
@@ -7206,7 +7844,7 @@ function extractSources({
|
|
|
7206
7844
|
groundingMetadata,
|
|
7207
7845
|
generateId: generateId3
|
|
7208
7846
|
}) {
|
|
7209
|
-
var
|
|
7847
|
+
var _a18, _b18, _c, _d;
|
|
7210
7848
|
if (!(groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks)) {
|
|
7211
7849
|
return void 0;
|
|
7212
7850
|
}
|
|
@@ -7218,7 +7856,7 @@ function extractSources({
|
|
|
7218
7856
|
sourceType: "url",
|
|
7219
7857
|
id: generateId3(),
|
|
7220
7858
|
url: chunk.web.uri,
|
|
7221
|
-
title: (
|
|
7859
|
+
title: (_a18 = chunk.web.title) != null ? _a18 : void 0
|
|
7222
7860
|
});
|
|
7223
7861
|
} else if (chunk.retrievedContext != null) {
|
|
7224
7862
|
const uri = chunk.retrievedContext.uri;
|
|
@@ -7229,7 +7867,7 @@ function extractSources({
|
|
|
7229
7867
|
sourceType: "url",
|
|
7230
7868
|
id: generateId3(),
|
|
7231
7869
|
url: uri,
|
|
7232
|
-
title: (
|
|
7870
|
+
title: (_b18 = chunk.retrievedContext.title) != null ? _b18 : void 0
|
|
7233
7871
|
});
|
|
7234
7872
|
} else if (uri) {
|
|
7235
7873
|
const title = (_c = chunk.retrievedContext.title) != null ? _c : "Unknown Document";
|
|
@@ -7514,14 +8152,14 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
7514
8152
|
this.specificationVersion = "v3";
|
|
7515
8153
|
}
|
|
7516
8154
|
get maxImagesPerCall() {
|
|
7517
|
-
var
|
|
7518
|
-
return (
|
|
8155
|
+
var _a18;
|
|
8156
|
+
return (_a18 = this.settings.maxImagesPerCall) != null ? _a18 : 4;
|
|
7519
8157
|
}
|
|
7520
8158
|
get provider() {
|
|
7521
8159
|
return this.config.provider;
|
|
7522
8160
|
}
|
|
7523
8161
|
async doGenerate(options) {
|
|
7524
|
-
var
|
|
8162
|
+
var _a18, _b18, _c;
|
|
7525
8163
|
const {
|
|
7526
8164
|
prompt,
|
|
7527
8165
|
n = 1,
|
|
@@ -7552,7 +8190,7 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
7552
8190
|
providerOptions,
|
|
7553
8191
|
schema: googleImageProviderOptionsSchema
|
|
7554
8192
|
});
|
|
7555
|
-
const currentDate = (_c = (
|
|
8193
|
+
const currentDate = (_c = (_b18 = (_a18 = this.config._internal) == null ? void 0 : _a18.currentDate) == null ? void 0 : _b18.call(_a18)) != null ? _c : /* @__PURE__ */ new Date();
|
|
7556
8194
|
const parameters = {
|
|
7557
8195
|
sampleCount: n
|
|
7558
8196
|
};
|
|
@@ -7613,9 +8251,9 @@ var googleImageProviderOptionsSchema = lazySchema(
|
|
|
7613
8251
|
)
|
|
7614
8252
|
);
|
|
7615
8253
|
function createGoogleGenerativeAI(options = {}) {
|
|
7616
|
-
var
|
|
7617
|
-
const baseURL = (
|
|
7618
|
-
const providerName = (
|
|
8254
|
+
var _a18, _b18;
|
|
8255
|
+
const baseURL = (_a18 = withoutTrailingSlash(options.baseURL)) != null ? _a18 : "https://generativelanguage.googleapis.com/v1beta";
|
|
8256
|
+
const providerName = (_b18 = options.name) != null ? _b18 : "google.generative-ai";
|
|
7619
8257
|
const getHeaders = () => withUserAgentSuffix(
|
|
7620
8258
|
{
|
|
7621
8259
|
"x-goog-api-key": loadApiKey({
|
|
@@ -7628,12 +8266,12 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
7628
8266
|
`ai-sdk/google/${VERSION3}`
|
|
7629
8267
|
);
|
|
7630
8268
|
const createChatModel = (modelId) => {
|
|
7631
|
-
var
|
|
8269
|
+
var _a25;
|
|
7632
8270
|
return new GoogleGenerativeAILanguageModel(modelId, {
|
|
7633
8271
|
provider: providerName,
|
|
7634
8272
|
baseURL,
|
|
7635
8273
|
headers: getHeaders,
|
|
7636
|
-
generateId: (
|
|
8274
|
+
generateId: (_a25 = options.generateId) != null ? _a25 : generateId,
|
|
7637
8275
|
supportedUrls: () => ({
|
|
7638
8276
|
"*": [
|
|
7639
8277
|
// Google Generative Language "files" endpoint
|
|
@@ -7682,7 +8320,326 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
7682
8320
|
}
|
|
7683
8321
|
var google = createGoogleGenerativeAI();
|
|
7684
8322
|
|
|
7685
|
-
// node_modules/@ai-sdk/openai/dist/index.mjs
|
|
8323
|
+
// ../../node_modules/@ai-sdk/openai/node_modules/@ai-sdk/provider/dist/index.mjs
|
|
8324
|
+
var marker17 = "vercel.ai.error";
|
|
8325
|
+
var symbol17 = Symbol.for(marker17);
|
|
8326
|
+
var _a17;
|
|
8327
|
+
var _b17;
|
|
8328
|
+
var AISDKError4 = class _AISDKError4 extends (_b17 = Error, _a17 = symbol17, _b17) {
|
|
8329
|
+
/**
|
|
8330
|
+
* Creates an AI SDK Error.
|
|
8331
|
+
*
|
|
8332
|
+
* @param {Object} params - The parameters for creating the error.
|
|
8333
|
+
* @param {string} params.name - The name of the error.
|
|
8334
|
+
* @param {string} params.message - The error message.
|
|
8335
|
+
* @param {unknown} [params.cause] - The underlying cause of the error.
|
|
8336
|
+
*/
|
|
8337
|
+
constructor({
|
|
8338
|
+
name: name142,
|
|
8339
|
+
message,
|
|
8340
|
+
cause
|
|
8341
|
+
}) {
|
|
8342
|
+
super(message);
|
|
8343
|
+
this[_a17] = true;
|
|
8344
|
+
this.name = name142;
|
|
8345
|
+
this.cause = cause;
|
|
8346
|
+
}
|
|
8347
|
+
/**
|
|
8348
|
+
* Checks if the given error is an AI SDK Error.
|
|
8349
|
+
* @param {unknown} error - The error to check.
|
|
8350
|
+
* @returns {boolean} True if the error is an AI SDK Error, false otherwise.
|
|
8351
|
+
*/
|
|
8352
|
+
static isInstance(error) {
|
|
8353
|
+
return _AISDKError4.hasMarker(error, marker17);
|
|
8354
|
+
}
|
|
8355
|
+
static hasMarker(error, marker152) {
|
|
8356
|
+
const markerSymbol = Symbol.for(marker152);
|
|
8357
|
+
return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
|
|
8358
|
+
}
|
|
8359
|
+
};
|
|
8360
|
+
var name16 = "AI_APICallError";
|
|
8361
|
+
var marker24 = `vercel.ai.error.${name16}`;
|
|
8362
|
+
var symbol24 = Symbol.for(marker24);
|
|
8363
|
+
var _a24;
|
|
8364
|
+
var _b24;
|
|
8365
|
+
var APICallError4 = class extends (_b24 = AISDKError4, _a24 = symbol24, _b24) {
|
|
8366
|
+
constructor({
|
|
8367
|
+
message,
|
|
8368
|
+
url,
|
|
8369
|
+
requestBodyValues,
|
|
8370
|
+
statusCode,
|
|
8371
|
+
responseHeaders,
|
|
8372
|
+
responseBody,
|
|
8373
|
+
cause,
|
|
8374
|
+
isRetryable = statusCode != null && (statusCode === 408 || // request timeout
|
|
8375
|
+
statusCode === 409 || // conflict
|
|
8376
|
+
statusCode === 429 || // too many requests
|
|
8377
|
+
statusCode >= 500),
|
|
8378
|
+
// server error
|
|
8379
|
+
data
|
|
8380
|
+
}) {
|
|
8381
|
+
super({ name: name16, message, cause });
|
|
8382
|
+
this[_a24] = true;
|
|
8383
|
+
this.url = url;
|
|
8384
|
+
this.requestBodyValues = requestBodyValues;
|
|
8385
|
+
this.statusCode = statusCode;
|
|
8386
|
+
this.responseHeaders = responseHeaders;
|
|
8387
|
+
this.responseBody = responseBody;
|
|
8388
|
+
this.isRetryable = isRetryable;
|
|
8389
|
+
this.data = data;
|
|
8390
|
+
}
|
|
8391
|
+
static isInstance(error) {
|
|
8392
|
+
return AISDKError4.hasMarker(error, marker24);
|
|
8393
|
+
}
|
|
8394
|
+
};
|
|
8395
|
+
var name24 = "AI_EmptyResponseBodyError";
|
|
8396
|
+
var marker34 = `vercel.ai.error.${name24}`;
|
|
8397
|
+
var symbol34 = Symbol.for(marker34);
|
|
8398
|
+
var _a34;
|
|
8399
|
+
var _b34;
|
|
8400
|
+
var EmptyResponseBodyError4 = class extends (_b34 = AISDKError4, _a34 = symbol34, _b34) {
|
|
8401
|
+
// used in isInstance
|
|
8402
|
+
constructor({ message = "Empty response body" } = {}) {
|
|
8403
|
+
super({ name: name24, message });
|
|
8404
|
+
this[_a34] = true;
|
|
8405
|
+
}
|
|
8406
|
+
static isInstance(error) {
|
|
8407
|
+
return AISDKError4.hasMarker(error, marker34);
|
|
8408
|
+
}
|
|
8409
|
+
};
|
|
8410
|
+
function getErrorMessage4(error) {
|
|
8411
|
+
if (error == null) {
|
|
8412
|
+
return "unknown error";
|
|
8413
|
+
}
|
|
8414
|
+
if (typeof error === "string") {
|
|
8415
|
+
return error;
|
|
8416
|
+
}
|
|
8417
|
+
if (error instanceof Error) {
|
|
8418
|
+
return error.message;
|
|
8419
|
+
}
|
|
8420
|
+
return JSON.stringify(error);
|
|
8421
|
+
}
|
|
8422
|
+
var name34 = "AI_InvalidArgumentError";
|
|
8423
|
+
var marker44 = `vercel.ai.error.${name34}`;
|
|
8424
|
+
var symbol44 = Symbol.for(marker44);
|
|
8425
|
+
var _a44;
|
|
8426
|
+
var _b44;
|
|
8427
|
+
var InvalidArgumentError4 = class extends (_b44 = AISDKError4, _a44 = symbol44, _b44) {
|
|
8428
|
+
constructor({
|
|
8429
|
+
message,
|
|
8430
|
+
cause,
|
|
8431
|
+
argument
|
|
8432
|
+
}) {
|
|
8433
|
+
super({ name: name34, message, cause });
|
|
8434
|
+
this[_a44] = true;
|
|
8435
|
+
this.argument = argument;
|
|
8436
|
+
}
|
|
8437
|
+
static isInstance(error) {
|
|
8438
|
+
return AISDKError4.hasMarker(error, marker44);
|
|
8439
|
+
}
|
|
8440
|
+
};
|
|
8441
|
+
var name44 = "AI_InvalidPromptError";
|
|
8442
|
+
var marker54 = `vercel.ai.error.${name44}`;
|
|
8443
|
+
var symbol54 = Symbol.for(marker54);
|
|
8444
|
+
var _a54;
|
|
8445
|
+
var _b54;
|
|
8446
|
+
var InvalidPromptError4 = class extends (_b54 = AISDKError4, _a54 = symbol54, _b54) {
|
|
8447
|
+
constructor({
|
|
8448
|
+
prompt,
|
|
8449
|
+
message,
|
|
8450
|
+
cause
|
|
8451
|
+
}) {
|
|
8452
|
+
super({ name: name44, message: `Invalid prompt: ${message}`, cause });
|
|
8453
|
+
this[_a54] = true;
|
|
8454
|
+
this.prompt = prompt;
|
|
8455
|
+
}
|
|
8456
|
+
static isInstance(error) {
|
|
8457
|
+
return AISDKError4.hasMarker(error, marker54);
|
|
8458
|
+
}
|
|
8459
|
+
};
|
|
8460
|
+
var name54 = "AI_InvalidResponseDataError";
|
|
8461
|
+
var marker64 = `vercel.ai.error.${name54}`;
|
|
8462
|
+
var symbol64 = Symbol.for(marker64);
|
|
8463
|
+
var _a64;
|
|
8464
|
+
var _b64;
|
|
8465
|
+
var InvalidResponseDataError4 = class extends (_b64 = AISDKError4, _a64 = symbol64, _b64) {
|
|
8466
|
+
constructor({
|
|
8467
|
+
data,
|
|
8468
|
+
message = `Invalid response data: ${JSON.stringify(data)}.`
|
|
8469
|
+
}) {
|
|
8470
|
+
super({ name: name54, message });
|
|
8471
|
+
this[_a64] = true;
|
|
8472
|
+
this.data = data;
|
|
8473
|
+
}
|
|
8474
|
+
static isInstance(error) {
|
|
8475
|
+
return AISDKError4.hasMarker(error, marker64);
|
|
8476
|
+
}
|
|
8477
|
+
};
|
|
8478
|
+
var name64 = "AI_JSONParseError";
|
|
8479
|
+
var marker74 = `vercel.ai.error.${name64}`;
|
|
8480
|
+
var symbol74 = Symbol.for(marker74);
|
|
8481
|
+
var _a74;
|
|
8482
|
+
var _b74;
|
|
8483
|
+
var JSONParseError4 = class extends (_b74 = AISDKError4, _a74 = symbol74, _b74) {
|
|
8484
|
+
constructor({ text, cause }) {
|
|
8485
|
+
super({
|
|
8486
|
+
name: name64,
|
|
8487
|
+
message: `JSON parsing failed: Text: ${text}.
|
|
8488
|
+
Error message: ${getErrorMessage4(cause)}`,
|
|
8489
|
+
cause
|
|
8490
|
+
});
|
|
8491
|
+
this[_a74] = true;
|
|
8492
|
+
this.text = text;
|
|
8493
|
+
}
|
|
8494
|
+
static isInstance(error) {
|
|
8495
|
+
return AISDKError4.hasMarker(error, marker74);
|
|
8496
|
+
}
|
|
8497
|
+
};
|
|
8498
|
+
var name74 = "AI_LoadAPIKeyError";
|
|
8499
|
+
var marker84 = `vercel.ai.error.${name74}`;
|
|
8500
|
+
var symbol84 = Symbol.for(marker84);
|
|
8501
|
+
var _a84;
|
|
8502
|
+
var _b84;
|
|
8503
|
+
var LoadAPIKeyError4 = class extends (_b84 = AISDKError4, _a84 = symbol84, _b84) {
|
|
8504
|
+
// used in isInstance
|
|
8505
|
+
constructor({ message }) {
|
|
8506
|
+
super({ name: name74, message });
|
|
8507
|
+
this[_a84] = true;
|
|
8508
|
+
}
|
|
8509
|
+
static isInstance(error) {
|
|
8510
|
+
return AISDKError4.hasMarker(error, marker84);
|
|
8511
|
+
}
|
|
8512
|
+
};
|
|
8513
|
+
var name84 = "AI_LoadSettingError";
|
|
8514
|
+
var marker94 = `vercel.ai.error.${name84}`;
|
|
8515
|
+
var symbol94 = Symbol.for(marker94);
|
|
8516
|
+
var _a94;
|
|
8517
|
+
var _b94;
|
|
8518
|
+
var LoadSettingError4 = class extends (_b94 = AISDKError4, _a94 = symbol94, _b94) {
|
|
8519
|
+
// used in isInstance
|
|
8520
|
+
constructor({ message }) {
|
|
8521
|
+
super({ name: name84, message });
|
|
8522
|
+
this[_a94] = true;
|
|
8523
|
+
}
|
|
8524
|
+
static isInstance(error) {
|
|
8525
|
+
return AISDKError4.hasMarker(error, marker94);
|
|
8526
|
+
}
|
|
8527
|
+
};
|
|
8528
|
+
var name94 = "AI_NoContentGeneratedError";
|
|
8529
|
+
var marker104 = `vercel.ai.error.${name94}`;
|
|
8530
|
+
var symbol104 = Symbol.for(marker104);
|
|
8531
|
+
var _a104;
|
|
8532
|
+
var _b104;
|
|
8533
|
+
var NoContentGeneratedError4 = class extends (_b104 = AISDKError4, _a104 = symbol104, _b104) {
|
|
8534
|
+
// used in isInstance
|
|
8535
|
+
constructor({
|
|
8536
|
+
message = "No content generated."
|
|
8537
|
+
} = {}) {
|
|
8538
|
+
super({ name: name94, message });
|
|
8539
|
+
this[_a104] = true;
|
|
8540
|
+
}
|
|
8541
|
+
static isInstance(error) {
|
|
8542
|
+
return AISDKError4.hasMarker(error, marker104);
|
|
8543
|
+
}
|
|
8544
|
+
};
|
|
8545
|
+
var name104 = "AI_NoSuchModelError";
|
|
8546
|
+
var marker114 = `vercel.ai.error.${name104}`;
|
|
8547
|
+
var symbol114 = Symbol.for(marker114);
|
|
8548
|
+
var _a114;
|
|
8549
|
+
var _b114;
|
|
8550
|
+
var NoSuchModelError4 = class extends (_b114 = AISDKError4, _a114 = symbol114, _b114) {
|
|
8551
|
+
constructor({
|
|
8552
|
+
errorName = name104,
|
|
8553
|
+
modelId,
|
|
8554
|
+
modelType,
|
|
8555
|
+
message = `No such ${modelType}: ${modelId}`
|
|
8556
|
+
}) {
|
|
8557
|
+
super({ name: errorName, message });
|
|
8558
|
+
this[_a114] = true;
|
|
8559
|
+
this.modelId = modelId;
|
|
8560
|
+
this.modelType = modelType;
|
|
8561
|
+
}
|
|
8562
|
+
static isInstance(error) {
|
|
8563
|
+
return AISDKError4.hasMarker(error, marker114);
|
|
8564
|
+
}
|
|
8565
|
+
};
|
|
8566
|
+
var name114 = "AI_TooManyEmbeddingValuesForCallError";
|
|
8567
|
+
var marker124 = `vercel.ai.error.${name114}`;
|
|
8568
|
+
var symbol124 = Symbol.for(marker124);
|
|
8569
|
+
var _a124;
|
|
8570
|
+
var _b124;
|
|
8571
|
+
var TooManyEmbeddingValuesForCallError4 = class extends (_b124 = AISDKError4, _a124 = symbol124, _b124) {
|
|
8572
|
+
constructor(options) {
|
|
8573
|
+
super({
|
|
8574
|
+
name: name114,
|
|
8575
|
+
message: `Too many values for a single embedding call. The ${options.provider} model "${options.modelId}" can only embed up to ${options.maxEmbeddingsPerCall} values per call, but ${options.values.length} values were provided.`
|
|
8576
|
+
});
|
|
8577
|
+
this[_a124] = true;
|
|
8578
|
+
this.provider = options.provider;
|
|
8579
|
+
this.modelId = options.modelId;
|
|
8580
|
+
this.maxEmbeddingsPerCall = options.maxEmbeddingsPerCall;
|
|
8581
|
+
this.values = options.values;
|
|
8582
|
+
}
|
|
8583
|
+
static isInstance(error) {
|
|
8584
|
+
return AISDKError4.hasMarker(error, marker124);
|
|
8585
|
+
}
|
|
8586
|
+
};
|
|
8587
|
+
var name124 = "AI_TypeValidationError";
|
|
8588
|
+
var marker134 = `vercel.ai.error.${name124}`;
|
|
8589
|
+
var symbol134 = Symbol.for(marker134);
|
|
8590
|
+
var _a134;
|
|
8591
|
+
var _b134;
|
|
8592
|
+
var TypeValidationError4 = class _TypeValidationError4 extends (_b134 = AISDKError4, _a134 = symbol134, _b134) {
|
|
8593
|
+
constructor({ value, cause }) {
|
|
8594
|
+
super({
|
|
8595
|
+
name: name124,
|
|
8596
|
+
message: `Type validation failed: Value: ${JSON.stringify(value)}.
|
|
8597
|
+
Error message: ${getErrorMessage4(cause)}`,
|
|
8598
|
+
cause
|
|
8599
|
+
});
|
|
8600
|
+
this[_a134] = true;
|
|
8601
|
+
this.value = value;
|
|
8602
|
+
}
|
|
8603
|
+
static isInstance(error) {
|
|
8604
|
+
return AISDKError4.hasMarker(error, marker134);
|
|
8605
|
+
}
|
|
8606
|
+
/**
|
|
8607
|
+
* Wraps an error into a TypeValidationError.
|
|
8608
|
+
* If the cause is already a TypeValidationError with the same value, it returns the cause.
|
|
8609
|
+
* Otherwise, it creates a new TypeValidationError.
|
|
8610
|
+
*
|
|
8611
|
+
* @param {Object} params - The parameters for wrapping the error.
|
|
8612
|
+
* @param {unknown} params.value - The value that failed validation.
|
|
8613
|
+
* @param {unknown} params.cause - The original error or cause of the validation failure.
|
|
8614
|
+
* @returns {TypeValidationError} A TypeValidationError instance.
|
|
8615
|
+
*/
|
|
8616
|
+
static wrap({
|
|
8617
|
+
value,
|
|
8618
|
+
cause
|
|
8619
|
+
}) {
|
|
8620
|
+
return _TypeValidationError4.isInstance(cause) && cause.value === value ? cause : new _TypeValidationError4({ value, cause });
|
|
8621
|
+
}
|
|
8622
|
+
};
|
|
8623
|
+
var name134 = "AI_UnsupportedFunctionalityError";
|
|
8624
|
+
var marker144 = `vercel.ai.error.${name134}`;
|
|
8625
|
+
var symbol144 = Symbol.for(marker144);
|
|
8626
|
+
var _a144;
|
|
8627
|
+
var _b144;
|
|
8628
|
+
var UnsupportedFunctionalityError4 = class extends (_b144 = AISDKError4, _a144 = symbol144, _b144) {
|
|
8629
|
+
constructor({
|
|
8630
|
+
functionality,
|
|
8631
|
+
message = `'${functionality}' functionality not supported.`
|
|
8632
|
+
}) {
|
|
8633
|
+
super({ name: name134, message });
|
|
8634
|
+
this[_a144] = true;
|
|
8635
|
+
this.functionality = functionality;
|
|
8636
|
+
}
|
|
8637
|
+
static isInstance(error) {
|
|
8638
|
+
return AISDKError4.hasMarker(error, marker144);
|
|
8639
|
+
}
|
|
8640
|
+
};
|
|
8641
|
+
|
|
8642
|
+
// ../../node_modules/@ai-sdk/openai/dist/index.mjs
|
|
7686
8643
|
var import_v429 = require("zod/v4");
|
|
7687
8644
|
var import_v430 = require("zod/v4");
|
|
7688
8645
|
var import_v431 = require("zod/v4");
|
|
@@ -7731,7 +8688,7 @@ function convertToOpenAIChatMessages({
|
|
|
7731
8688
|
prompt,
|
|
7732
8689
|
systemMessageMode = "system"
|
|
7733
8690
|
}) {
|
|
7734
|
-
var
|
|
8691
|
+
var _a18;
|
|
7735
8692
|
const messages = [];
|
|
7736
8693
|
const warnings = [];
|
|
7737
8694
|
for (const { role, content } of prompt) {
|
|
@@ -7770,7 +8727,7 @@ function convertToOpenAIChatMessages({
|
|
|
7770
8727
|
messages.push({
|
|
7771
8728
|
role: "user",
|
|
7772
8729
|
content: content.map((part, index) => {
|
|
7773
|
-
var
|
|
8730
|
+
var _a25, _b18, _c;
|
|
7774
8731
|
switch (part.type) {
|
|
7775
8732
|
case "text": {
|
|
7776
8733
|
return { type: "text", text: part.text };
|
|
@@ -7783,12 +8740,12 @@ function convertToOpenAIChatMessages({
|
|
|
7783
8740
|
image_url: {
|
|
7784
8741
|
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${convertToBase64(part.data)}`,
|
|
7785
8742
|
// OpenAI specific extension: image detail
|
|
7786
|
-
detail: (
|
|
8743
|
+
detail: (_b18 = (_a25 = part.providerOptions) == null ? void 0 : _a25.openai) == null ? void 0 : _b18.imageDetail
|
|
7787
8744
|
}
|
|
7788
8745
|
};
|
|
7789
8746
|
} else if (part.mediaType.startsWith("audio/")) {
|
|
7790
8747
|
if (part.data instanceof URL) {
|
|
7791
|
-
throw new
|
|
8748
|
+
throw new UnsupportedFunctionalityError4({
|
|
7792
8749
|
functionality: "audio file parts with URLs"
|
|
7793
8750
|
});
|
|
7794
8751
|
}
|
|
@@ -7813,14 +8770,14 @@ function convertToOpenAIChatMessages({
|
|
|
7813
8770
|
};
|
|
7814
8771
|
}
|
|
7815
8772
|
default: {
|
|
7816
|
-
throw new
|
|
8773
|
+
throw new UnsupportedFunctionalityError4({
|
|
7817
8774
|
functionality: `audio content parts with media type ${part.mediaType}`
|
|
7818
8775
|
});
|
|
7819
8776
|
}
|
|
7820
8777
|
}
|
|
7821
8778
|
} else if (part.mediaType === "application/pdf") {
|
|
7822
8779
|
if (part.data instanceof URL) {
|
|
7823
|
-
throw new
|
|
8780
|
+
throw new UnsupportedFunctionalityError4({
|
|
7824
8781
|
functionality: "PDF file parts with URLs"
|
|
7825
8782
|
});
|
|
7826
8783
|
}
|
|
@@ -7832,7 +8789,7 @@ function convertToOpenAIChatMessages({
|
|
|
7832
8789
|
}
|
|
7833
8790
|
};
|
|
7834
8791
|
} else {
|
|
7835
|
-
throw new
|
|
8792
|
+
throw new UnsupportedFunctionalityError4({
|
|
7836
8793
|
functionality: `file part media type ${part.mediaType}`
|
|
7837
8794
|
});
|
|
7838
8795
|
}
|
|
@@ -7881,7 +8838,7 @@ function convertToOpenAIChatMessages({
|
|
|
7881
8838
|
contentValue = output.value;
|
|
7882
8839
|
break;
|
|
7883
8840
|
case "execution-denied":
|
|
7884
|
-
contentValue = (
|
|
8841
|
+
contentValue = (_a18 = output.reason) != null ? _a18 : "Tool execution denied.";
|
|
7885
8842
|
break;
|
|
7886
8843
|
case "content":
|
|
7887
8844
|
case "json":
|
|
@@ -8222,7 +9179,7 @@ function prepareChatTools({
|
|
|
8222
9179
|
};
|
|
8223
9180
|
default: {
|
|
8224
9181
|
const _exhaustiveCheck = type;
|
|
8225
|
-
throw new
|
|
9182
|
+
throw new UnsupportedFunctionalityError4({
|
|
8226
9183
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
8227
9184
|
});
|
|
8228
9185
|
}
|
|
@@ -8255,14 +9212,14 @@ var OpenAIChatLanguageModel = class {
|
|
|
8255
9212
|
toolChoice,
|
|
8256
9213
|
providerOptions
|
|
8257
9214
|
}) {
|
|
8258
|
-
var
|
|
9215
|
+
var _a18, _b18, _c, _d;
|
|
8259
9216
|
const warnings = [];
|
|
8260
|
-
const openaiOptions = (
|
|
9217
|
+
const openaiOptions = (_a18 = await parseProviderOptions({
|
|
8261
9218
|
provider: "openai",
|
|
8262
9219
|
providerOptions,
|
|
8263
9220
|
schema: openaiChatLanguageModelOptions
|
|
8264
|
-
})) != null ?
|
|
8265
|
-
const structuredOutputs = (
|
|
9221
|
+
})) != null ? _a18 : {};
|
|
9222
|
+
const structuredOutputs = (_b18 = openaiOptions.structuredOutputs) != null ? _b18 : true;
|
|
8266
9223
|
if (topK != null) {
|
|
8267
9224
|
warnings.push({ type: "unsupported", feature: "topK" });
|
|
8268
9225
|
}
|
|
@@ -8428,7 +9385,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
8428
9385
|
};
|
|
8429
9386
|
}
|
|
8430
9387
|
async doGenerate(options) {
|
|
8431
|
-
var
|
|
9388
|
+
var _a18, _b18, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
8432
9389
|
const { args: body, warnings } = await this.getArgs(options);
|
|
8433
9390
|
const {
|
|
8434
9391
|
responseHeaders,
|
|
@@ -8454,10 +9411,10 @@ var OpenAIChatLanguageModel = class {
|
|
|
8454
9411
|
if (text != null && text.length > 0) {
|
|
8455
9412
|
content.push({ type: "text", text });
|
|
8456
9413
|
}
|
|
8457
|
-
for (const toolCall of (
|
|
9414
|
+
for (const toolCall of (_a18 = choice.message.tool_calls) != null ? _a18 : []) {
|
|
8458
9415
|
content.push({
|
|
8459
9416
|
type: "tool-call",
|
|
8460
|
-
toolCallId: (
|
|
9417
|
+
toolCallId: (_b18 = toolCall.id) != null ? _b18 : generateId(),
|
|
8461
9418
|
toolName: toolCall.function.name,
|
|
8462
9419
|
input: toolCall.function.arguments
|
|
8463
9420
|
});
|
|
@@ -8543,7 +9500,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
8543
9500
|
controller.enqueue({ type: "stream-start", warnings });
|
|
8544
9501
|
},
|
|
8545
9502
|
transform(chunk, controller) {
|
|
8546
|
-
var
|
|
9503
|
+
var _a18, _b18, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
8547
9504
|
if (options.includeRawChunks) {
|
|
8548
9505
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
8549
9506
|
}
|
|
@@ -8569,8 +9526,8 @@ var OpenAIChatLanguageModel = class {
|
|
|
8569
9526
|
}
|
|
8570
9527
|
}
|
|
8571
9528
|
if (value.usage != null) {
|
|
8572
|
-
usage.inputTokens = (
|
|
8573
|
-
usage.outputTokens = (
|
|
9529
|
+
usage.inputTokens = (_a18 = value.usage.prompt_tokens) != null ? _a18 : void 0;
|
|
9530
|
+
usage.outputTokens = (_b18 = value.usage.completion_tokens) != null ? _b18 : void 0;
|
|
8574
9531
|
usage.totalTokens = (_c = value.usage.total_tokens) != null ? _c : void 0;
|
|
8575
9532
|
usage.reasoningTokens = (_e = (_d = value.usage.completion_tokens_details) == null ? void 0 : _d.reasoning_tokens) != null ? _e : void 0;
|
|
8576
9533
|
usage.cachedInputTokens = (_g = (_f = value.usage.prompt_tokens_details) == null ? void 0 : _f.cached_tokens) != null ? _g : void 0;
|
|
@@ -8608,19 +9565,19 @@ var OpenAIChatLanguageModel = class {
|
|
|
8608
9565
|
const index = toolCallDelta.index;
|
|
8609
9566
|
if (toolCalls[index] == null) {
|
|
8610
9567
|
if (toolCallDelta.type !== "function") {
|
|
8611
|
-
throw new
|
|
9568
|
+
throw new InvalidResponseDataError4({
|
|
8612
9569
|
data: toolCallDelta,
|
|
8613
9570
|
message: `Expected 'function' type.`
|
|
8614
9571
|
});
|
|
8615
9572
|
}
|
|
8616
9573
|
if (toolCallDelta.id == null) {
|
|
8617
|
-
throw new
|
|
9574
|
+
throw new InvalidResponseDataError4({
|
|
8618
9575
|
data: toolCallDelta,
|
|
8619
9576
|
message: `Expected 'id' to be a string.`
|
|
8620
9577
|
});
|
|
8621
9578
|
}
|
|
8622
9579
|
if (((_m = toolCallDelta.function) == null ? void 0 : _m.name) == null) {
|
|
8623
|
-
throw new
|
|
9580
|
+
throw new InvalidResponseDataError4({
|
|
8624
9581
|
data: toolCallDelta,
|
|
8625
9582
|
message: `Expected 'function.name' to be a string.`
|
|
8626
9583
|
});
|
|
@@ -8745,7 +9702,7 @@ function convertToOpenAICompletionPrompt({
|
|
|
8745
9702
|
for (const { role, content } of prompt) {
|
|
8746
9703
|
switch (role) {
|
|
8747
9704
|
case "system": {
|
|
8748
|
-
throw new
|
|
9705
|
+
throw new InvalidPromptError4({
|
|
8749
9706
|
message: "Unexpected system message in prompt: ${content}",
|
|
8750
9707
|
prompt
|
|
8751
9708
|
});
|
|
@@ -8771,7 +9728,7 @@ ${userMessage}
|
|
|
8771
9728
|
return part.text;
|
|
8772
9729
|
}
|
|
8773
9730
|
case "tool-call": {
|
|
8774
|
-
throw new
|
|
9731
|
+
throw new UnsupportedFunctionalityError4({
|
|
8775
9732
|
functionality: "tool-call messages"
|
|
8776
9733
|
});
|
|
8777
9734
|
}
|
|
@@ -8784,7 +9741,7 @@ ${assistantMessage}
|
|
|
8784
9741
|
break;
|
|
8785
9742
|
}
|
|
8786
9743
|
case "tool": {
|
|
8787
|
-
throw new
|
|
9744
|
+
throw new UnsupportedFunctionalityError4({
|
|
8788
9745
|
functionality: "tool messages"
|
|
8789
9746
|
});
|
|
8790
9747
|
}
|
|
@@ -9013,7 +9970,7 @@ var OpenAICompletionLanguageModel = class {
|
|
|
9013
9970
|
};
|
|
9014
9971
|
}
|
|
9015
9972
|
async doGenerate(options) {
|
|
9016
|
-
var
|
|
9973
|
+
var _a18, _b18, _c;
|
|
9017
9974
|
const { args, warnings } = await this.getArgs(options);
|
|
9018
9975
|
const {
|
|
9019
9976
|
responseHeaders,
|
|
@@ -9041,8 +9998,8 @@ var OpenAICompletionLanguageModel = class {
|
|
|
9041
9998
|
return {
|
|
9042
9999
|
content: [{ type: "text", text: choice.text }],
|
|
9043
10000
|
usage: {
|
|
9044
|
-
inputTokens: (
|
|
9045
|
-
outputTokens: (
|
|
10001
|
+
inputTokens: (_a18 = response.usage) == null ? void 0 : _a18.prompt_tokens,
|
|
10002
|
+
outputTokens: (_b18 = response.usage) == null ? void 0 : _b18.completion_tokens,
|
|
9046
10003
|
totalTokens: (_c = response.usage) == null ? void 0 : _c.total_tokens
|
|
9047
10004
|
},
|
|
9048
10005
|
finishReason: mapOpenAIFinishReason2(choice.finish_reason),
|
|
@@ -9195,20 +10152,20 @@ var OpenAIEmbeddingModel = class {
|
|
|
9195
10152
|
abortSignal,
|
|
9196
10153
|
providerOptions
|
|
9197
10154
|
}) {
|
|
9198
|
-
var
|
|
10155
|
+
var _a18;
|
|
9199
10156
|
if (values.length > this.maxEmbeddingsPerCall) {
|
|
9200
|
-
throw new
|
|
10157
|
+
throw new TooManyEmbeddingValuesForCallError4({
|
|
9201
10158
|
provider: this.provider,
|
|
9202
10159
|
modelId: this.modelId,
|
|
9203
10160
|
maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
|
|
9204
10161
|
values
|
|
9205
10162
|
});
|
|
9206
10163
|
}
|
|
9207
|
-
const openaiOptions = (
|
|
10164
|
+
const openaiOptions = (_a18 = await parseProviderOptions({
|
|
9208
10165
|
provider: "openai",
|
|
9209
10166
|
providerOptions,
|
|
9210
10167
|
schema: openaiEmbeddingProviderOptions
|
|
9211
|
-
})) != null ?
|
|
10168
|
+
})) != null ? _a18 : {};
|
|
9212
10169
|
const {
|
|
9213
10170
|
responseHeaders,
|
|
9214
10171
|
value: response,
|
|
@@ -9278,8 +10235,8 @@ var OpenAIImageModel = class {
|
|
|
9278
10235
|
this.specificationVersion = "v3";
|
|
9279
10236
|
}
|
|
9280
10237
|
get maxImagesPerCall() {
|
|
9281
|
-
var
|
|
9282
|
-
return (
|
|
10238
|
+
var _a18;
|
|
10239
|
+
return (_a18 = modelMaxImagesPerCall[this.modelId]) != null ? _a18 : 1;
|
|
9283
10240
|
}
|
|
9284
10241
|
get provider() {
|
|
9285
10242
|
return this.config.provider;
|
|
@@ -9294,7 +10251,7 @@ var OpenAIImageModel = class {
|
|
|
9294
10251
|
headers,
|
|
9295
10252
|
abortSignal
|
|
9296
10253
|
}) {
|
|
9297
|
-
var
|
|
10254
|
+
var _a18, _b18, _c, _d, _e, _f, _g;
|
|
9298
10255
|
const warnings = [];
|
|
9299
10256
|
if (aspectRatio != null) {
|
|
9300
10257
|
warnings.push({
|
|
@@ -9306,7 +10263,7 @@ var OpenAIImageModel = class {
|
|
|
9306
10263
|
if (seed != null) {
|
|
9307
10264
|
warnings.push({ type: "unsupported", feature: "seed" });
|
|
9308
10265
|
}
|
|
9309
|
-
const currentDate = (_c = (
|
|
10266
|
+
const currentDate = (_c = (_b18 = (_a18 = this.config._internal) == null ? void 0 : _a18.currentDate) == null ? void 0 : _b18.call(_a18)) != null ? _c : /* @__PURE__ */ new Date();
|
|
9310
10267
|
const { value: response, responseHeaders } = await postJsonToApi({
|
|
9311
10268
|
url: this.config.url({
|
|
9312
10269
|
path: "/images/generations",
|
|
@@ -9802,7 +10759,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
9802
10759
|
hasLocalShellTool = false,
|
|
9803
10760
|
hasApplyPatchTool = false
|
|
9804
10761
|
}) {
|
|
9805
|
-
var
|
|
10762
|
+
var _a18, _b18, _c, _d, _e;
|
|
9806
10763
|
const input = [];
|
|
9807
10764
|
const warnings = [];
|
|
9808
10765
|
for (const { role, content } of prompt) {
|
|
@@ -9837,7 +10794,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
9837
10794
|
input.push({
|
|
9838
10795
|
role: "user",
|
|
9839
10796
|
content: content.map((part, index) => {
|
|
9840
|
-
var
|
|
10797
|
+
var _a25, _b25, _c2;
|
|
9841
10798
|
switch (part.type) {
|
|
9842
10799
|
case "text": {
|
|
9843
10800
|
return { type: "input_text", text: part.text };
|
|
@@ -9850,7 +10807,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
9850
10807
|
...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
9851
10808
|
image_url: `data:${mediaType};base64,${convertToBase64(part.data)}`
|
|
9852
10809
|
},
|
|
9853
|
-
detail: (
|
|
10810
|
+
detail: (_b25 = (_a25 = part.providerOptions) == null ? void 0 : _a25.openai) == null ? void 0 : _b25.imageDetail
|
|
9854
10811
|
};
|
|
9855
10812
|
} else if (part.mediaType === "application/pdf") {
|
|
9856
10813
|
if (part.data instanceof URL) {
|
|
@@ -9867,7 +10824,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
9867
10824
|
}
|
|
9868
10825
|
};
|
|
9869
10826
|
} else {
|
|
9870
|
-
throw new
|
|
10827
|
+
throw new UnsupportedFunctionalityError4({
|
|
9871
10828
|
functionality: `file part media type ${part.mediaType}`
|
|
9872
10829
|
});
|
|
9873
10830
|
}
|
|
@@ -9882,7 +10839,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
9882
10839
|
for (const part of content) {
|
|
9883
10840
|
switch (part.type) {
|
|
9884
10841
|
case "text": {
|
|
9885
|
-
const id = (
|
|
10842
|
+
const id = (_b18 = (_a18 = part.providerOptions) == null ? void 0 : _a18.openai) == null ? void 0 : _b18.itemId;
|
|
9886
10843
|
if (store && id != null) {
|
|
9887
10844
|
input.push({ type: "item_reference", id });
|
|
9888
10845
|
break;
|
|
@@ -10051,7 +11008,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
10051
11008
|
break;
|
|
10052
11009
|
case "content":
|
|
10053
11010
|
contentValue = output.value.map((item) => {
|
|
10054
|
-
var
|
|
11011
|
+
var _a25;
|
|
10055
11012
|
switch (item.type) {
|
|
10056
11013
|
case "text": {
|
|
10057
11014
|
return { type: "input_text", text: item.text };
|
|
@@ -10065,7 +11022,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
10065
11022
|
case "file-data": {
|
|
10066
11023
|
return {
|
|
10067
11024
|
type: "input_file",
|
|
10068
|
-
filename: (
|
|
11025
|
+
filename: (_a25 = item.filename) != null ? _a25 : "data",
|
|
10069
11026
|
file_data: `data:${item.mediaType};base64,${item.data}`
|
|
10070
11027
|
};
|
|
10071
11028
|
}
|
|
@@ -11041,7 +11998,7 @@ async function prepareResponsesTools({
|
|
|
11041
11998
|
};
|
|
11042
11999
|
default: {
|
|
11043
12000
|
const _exhaustiveCheck = type;
|
|
11044
|
-
throw new
|
|
12001
|
+
throw new UnsupportedFunctionalityError4({
|
|
11045
12002
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
11046
12003
|
});
|
|
11047
12004
|
}
|
|
@@ -11075,7 +12032,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
11075
12032
|
toolChoice,
|
|
11076
12033
|
responseFormat
|
|
11077
12034
|
}) {
|
|
11078
|
-
var
|
|
12035
|
+
var _a18, _b18, _c, _d;
|
|
11079
12036
|
const warnings = [];
|
|
11080
12037
|
const modelConfig = getResponsesModelConfig(this.modelId);
|
|
11081
12038
|
if (topK != null) {
|
|
@@ -11123,12 +12080,12 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
11123
12080
|
toolNameMapping,
|
|
11124
12081
|
systemMessageMode: modelConfig.systemMessageMode,
|
|
11125
12082
|
fileIdPrefixes: this.config.fileIdPrefixes,
|
|
11126
|
-
store: (
|
|
12083
|
+
store: (_a18 = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _a18 : true,
|
|
11127
12084
|
hasLocalShellTool: hasOpenAITool("openai.local_shell"),
|
|
11128
12085
|
hasApplyPatchTool: hasOpenAITool("openai.apply_patch")
|
|
11129
12086
|
});
|
|
11130
12087
|
warnings.push(...inputWarnings);
|
|
11131
|
-
const strictJsonSchema = (
|
|
12088
|
+
const strictJsonSchema = (_b18 = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _b18 : false;
|
|
11132
12089
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
11133
12090
|
function addInclude(key) {
|
|
11134
12091
|
if (include == null) {
|
|
@@ -11278,7 +12235,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
11278
12235
|
};
|
|
11279
12236
|
}
|
|
11280
12237
|
async doGenerate(options) {
|
|
11281
|
-
var
|
|
12238
|
+
var _a18, _b18, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B;
|
|
11282
12239
|
const {
|
|
11283
12240
|
args: body,
|
|
11284
12241
|
warnings,
|
|
@@ -11306,7 +12263,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
11306
12263
|
fetch: this.config.fetch
|
|
11307
12264
|
});
|
|
11308
12265
|
if (response.error) {
|
|
11309
|
-
throw new
|
|
12266
|
+
throw new APICallError4({
|
|
11310
12267
|
message: response.error.message,
|
|
11311
12268
|
url,
|
|
11312
12269
|
requestBodyValues: body,
|
|
@@ -11332,7 +12289,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
11332
12289
|
providerMetadata: {
|
|
11333
12290
|
[providerKey]: {
|
|
11334
12291
|
itemId: part.id,
|
|
11335
|
-
reasoningEncryptedContent: (
|
|
12292
|
+
reasoningEncryptedContent: (_a18 = part.encrypted_content) != null ? _a18 : null
|
|
11336
12293
|
}
|
|
11337
12294
|
}
|
|
11338
12295
|
});
|
|
@@ -11375,7 +12332,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
11375
12332
|
}
|
|
11376
12333
|
case "message": {
|
|
11377
12334
|
for (const contentPart of part.content) {
|
|
11378
|
-
if (((_c = (
|
|
12335
|
+
if (((_c = (_b18 = options.providerOptions) == null ? void 0 : _b18.openai) == null ? void 0 : _c.logprobs) && contentPart.logprobs) {
|
|
11379
12336
|
logprobs.push(contentPart.logprobs);
|
|
11380
12337
|
}
|
|
11381
12338
|
const providerMetadata2 = {
|
|
@@ -11526,12 +12483,12 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
11526
12483
|
type: "listTools",
|
|
11527
12484
|
serverLabel: part.server_label,
|
|
11528
12485
|
tools: part.tools.map((t) => {
|
|
11529
|
-
var
|
|
12486
|
+
var _a25, _b25;
|
|
11530
12487
|
return {
|
|
11531
12488
|
name: t.name,
|
|
11532
|
-
description: (
|
|
12489
|
+
description: (_a25 = t.description) != null ? _a25 : void 0,
|
|
11533
12490
|
inputSchema: t.input_schema,
|
|
11534
|
-
annotations: (
|
|
12491
|
+
annotations: (_b25 = t.annotations) != null ? _b25 : void 0
|
|
11535
12492
|
};
|
|
11536
12493
|
}),
|
|
11537
12494
|
...part.error != null ? { error: part.error } : {}
|
|
@@ -11727,7 +12684,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
11727
12684
|
controller.enqueue({ type: "stream-start", warnings });
|
|
11728
12685
|
},
|
|
11729
12686
|
transform(chunk, controller) {
|
|
11730
|
-
var
|
|
12687
|
+
var _a18, _b18, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E;
|
|
11731
12688
|
if (options.includeRawChunks) {
|
|
11732
12689
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
11733
12690
|
}
|
|
@@ -11873,7 +12830,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
11873
12830
|
providerMetadata: {
|
|
11874
12831
|
[providerKey]: {
|
|
11875
12832
|
itemId: value.item.id,
|
|
11876
|
-
reasoningEncryptedContent: (
|
|
12833
|
+
reasoningEncryptedContent: (_a18 = value.item.encrypted_content) != null ? _a18 : null
|
|
11877
12834
|
}
|
|
11878
12835
|
}
|
|
11879
12836
|
});
|
|
@@ -11950,7 +12907,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
11950
12907
|
toolName: toolNameMapping.toCustomToolName("file_search"),
|
|
11951
12908
|
result: {
|
|
11952
12909
|
queries: value.item.queries,
|
|
11953
|
-
results: (_c = (
|
|
12910
|
+
results: (_c = (_b18 = value.item.results) == null ? void 0 : _b18.map((result) => ({
|
|
11954
12911
|
attributes: result.attributes,
|
|
11955
12912
|
fileId: result.file_id,
|
|
11956
12913
|
filename: result.filename,
|
|
@@ -12003,12 +12960,12 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
12003
12960
|
type: "listTools",
|
|
12004
12961
|
serverLabel: value.item.server_label,
|
|
12005
12962
|
tools: value.item.tools.map((t) => {
|
|
12006
|
-
var
|
|
12963
|
+
var _a25, _b25;
|
|
12007
12964
|
return {
|
|
12008
12965
|
name: t.name,
|
|
12009
|
-
description: (
|
|
12966
|
+
description: (_a25 = t.description) != null ? _a25 : void 0,
|
|
12010
12967
|
inputSchema: t.input_schema,
|
|
12011
|
-
annotations: (
|
|
12968
|
+
annotations: (_b25 = t.annotations) != null ? _b25 : void 0
|
|
12012
12969
|
};
|
|
12013
12970
|
}),
|
|
12014
12971
|
...value.item.error != null ? { error: value.item.error } : {}
|
|
@@ -12357,11 +13314,11 @@ function getResponsesModelConfig(modelId) {
|
|
|
12357
13314
|
};
|
|
12358
13315
|
}
|
|
12359
13316
|
function mapWebSearchOutput(action) {
|
|
12360
|
-
var
|
|
13317
|
+
var _a18;
|
|
12361
13318
|
switch (action.type) {
|
|
12362
13319
|
case "search":
|
|
12363
13320
|
return {
|
|
12364
|
-
action: { type: "search", query: (
|
|
13321
|
+
action: { type: "search", query: (_a18 = action.query) != null ? _a18 : void 0 },
|
|
12365
13322
|
// include sources when provided by the Responses API (behind include flag)
|
|
12366
13323
|
...action.sources != null && { sources: action.sources }
|
|
12367
13324
|
};
|
|
@@ -12446,8 +13403,8 @@ var OpenAISpeechModel = class {
|
|
|
12446
13403
|
};
|
|
12447
13404
|
}
|
|
12448
13405
|
async doGenerate(options) {
|
|
12449
|
-
var
|
|
12450
|
-
const currentDate = (_c = (
|
|
13406
|
+
var _a18, _b18, _c;
|
|
13407
|
+
const currentDate = (_c = (_b18 = (_a18 = this.config._internal) == null ? void 0 : _a18.currentDate) == null ? void 0 : _b18.call(_a18)) != null ? _c : /* @__PURE__ */ new Date();
|
|
12451
13408
|
const { requestBody, warnings } = await this.getArgs(options);
|
|
12452
13409
|
const {
|
|
12453
13410
|
value: audio,
|
|
@@ -12658,8 +13615,8 @@ var OpenAITranscriptionModel = class {
|
|
|
12658
13615
|
};
|
|
12659
13616
|
}
|
|
12660
13617
|
async doGenerate(options) {
|
|
12661
|
-
var
|
|
12662
|
-
const currentDate = (_c = (
|
|
13618
|
+
var _a18, _b18, _c, _d, _e, _f, _g, _h;
|
|
13619
|
+
const currentDate = (_c = (_b18 = (_a18 = this.config._internal) == null ? void 0 : _a18.currentDate) == null ? void 0 : _b18.call(_a18)) != null ? _c : /* @__PURE__ */ new Date();
|
|
12663
13620
|
const { formData, warnings } = await this.getArgs(options);
|
|
12664
13621
|
const {
|
|
12665
13622
|
value: response,
|
|
@@ -12705,14 +13662,14 @@ var OpenAITranscriptionModel = class {
|
|
|
12705
13662
|
};
|
|
12706
13663
|
var VERSION4 = true ? "3.0.0-beta.74" : "0.0.0-test";
|
|
12707
13664
|
function createOpenAI(options = {}) {
|
|
12708
|
-
var
|
|
12709
|
-
const baseURL = (
|
|
13665
|
+
var _a18, _b18;
|
|
13666
|
+
const baseURL = (_a18 = withoutTrailingSlash(
|
|
12710
13667
|
loadOptionalSetting({
|
|
12711
13668
|
settingValue: options.baseURL,
|
|
12712
13669
|
environmentVariableName: "OPENAI_BASE_URL"
|
|
12713
13670
|
})
|
|
12714
|
-
)) != null ?
|
|
12715
|
-
const providerName = (
|
|
13671
|
+
)) != null ? _a18 : "https://api.openai.com/v1";
|
|
13672
|
+
const providerName = (_b18 = options.name) != null ? _b18 : "openai";
|
|
12716
13673
|
const getHeaders = () => withUserAgentSuffix(
|
|
12717
13674
|
{
|
|
12718
13675
|
Authorization: `Bearer ${loadApiKey({
|